Vue 3d loaderVue 3d loader
指南
  • English
  • 简体中文
GitHub
指南
  • English
  • 简体中文
GitHub
  • 指南

    • 介绍
    • 快速上手
    • 事件
    • API
    • 捐助
  • 样例

    • 加载一个模型
    • 加载多个模型并单独设置模型位置
    • 加载JSON模型
    • 加载Draco压缩模型
    • 设置场景高宽
    • 材质及纹理
    • 背景颜色及透明度
    • 交互控制
    • 旋转模型
    • 事件
    • 灯光
    • 相机位置及旋转
    • 并行加载多模型
    • 标注
    • 播放/停止动画
    • 开启阻尼
    • 加载进度
    • 控制相机垂直/水平旋转
    • 开启坐标轴及网格
    • 设置摄像头向内外的距离
    • 点光源跟随相机移动
    • 克隆相同模型

材质及纹理

OBJ+MTL

FBX+JPG

<template>
  <div>
    <div v-for="item in loaderList" :key="item.title">
      <h1>{{ item.title }}</h1>
      <vue3dLoader
        :height="item.height"
        :showFps="item.showFps"
        :filePath="item.filePath"
        :mtlPath="item.mtlPath"
        :textureImage="item.textureImage"
        :backgroundColor="item.backgroundColor"
        :outputEncoding="item.outputEncoding"
        :cameraPosition="item.cameraPosition"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { vue3dLoader } from "vue-3d-loader";
import { ref } from "vue";
const object = ref(null);
const loaderList = ref();
loaderList.value = [
  {
    title: "OBJ+MTL",
    filePath: "/models/obj/male02.obj",
    mtlPath: "/models/obj/male02.mtl",
    showFps: false,
    height: 400,
    backgroundColor: "#f2f2f2",
    outputEncoding: "sRGB",
    cameraPosition: { x: -100, y: 100, z: 200 },
  },
  {
    title: "FBX+JPG",
    filePath: "/models/fbx/stanford-bunny.fbx",
    textureImage: "/models/fbx/brick.png",
    height: 400,
  },
];
function onMouseMove(event: MouseEvent, intersected: any) {
  // console.log('event', event);
  if (object.value) {
    (object.value as any).material.color.setStyle("#fff");
  }

  if (intersected) {
    object.value = intersected.object;
    (object.value as any).material.color.setStyle("#13ce66");
  }
}
</script>
<style>
h1 {
  font-size: 20px;
}
</style>
在 GitHub 上编辑此页
上次更新: 2022/10/30 21:09
Contributors: Tony Tao
Prev
设置场景高宽
Next
背景颜色及透明度