vue-3d-loader

vue-3d-loader - npm

GitHub - king2088/vue-3d-loader: VueJS and threeJS 3d viewer

是对 vue-3d-model 的改进,降低Threejs使用难度

复制代码
# 默认安装 "vue-3d-loader": "^1.3.4", 只支持vue2
npm i vue-3d-loader
# vue3 需要安装2版本,vite只建立在vue3之上的,因此vite也是需要安装2版本
npm i vue-3d-loader@2.2.1 --save 

<template>
  <div class="player-container">
    <!--1和2版本都是 @load-->
    <vue3dLoader style="height: 100vh;" :showFps="false" :scale="scale" :rotation="rotation" :lights="lights" filePath="https://basin.csceccloud.net:9000/tomcat/fbx/yushuihy.FBX"
      :backgroundAlpha="0" @load="onLoad"></vue3dLoader>
    <!-- <vue3dLoader style="height: 100vh;" :showFps="false" :scale="scale" :rotation="rotation" :lights="lights" filePath="https://basin.csceccloud.net:9000/tomcat/fbx/panjiduanmian.glb"
      :backgroundAlpha="0" @load="onLoad"></vue3dLoader> -->
  </div>
</template>

<script>
import { vue3dLoader } from "vue-3d-loader";

export default {
  components: {
    vue3dLoader
  },
  data() {
    return {
      scale: { x: 1.5, y: 1.5, z: 1.3 },
      rotation: {
        x: 0,
        y: 0,
        z: 0,
      },
      //3d模型灯光
      lights: [
        {
          type: 'HemisphereLight',
          position: { x: 2, y: 2, z: 2 },
          skyColor: 0xffffff,
          intensity: 2,
        },
        {
          type: 'DirectionalLight',
          position: { x: 2, y: 2, z: 2 },
          color: 0xffffff,
          intensity: 2,
        }
      ],
    }
  },
  methods: {
    onLoad() {
      console.log('模型加载完成')
      this.rotate();
    },
    rotate() {
      requestAnimationFrame(this.rotate);//实现自动旋转效果
      this.rotation.y += 0.001;
    },
  }
}
</script>

<style>
html,
body {
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.player-container {
  width: 100vw;
  height: 100vh;
  background-color: black;
}
</style>

模型放在服务器的tomcat中,跨域配置参见这篇文章:

vue-3d-model-CSDN博客

相关推荐
kyle~2 小时前
Open3D---FPFH 3D点云的快速点特征直方图描述符
3d·机器人·点云处理
Zldaisy3d3 小时前
哈佛大学发布“七十二变”软体机器手,提出旋转多材料3D打印新方法
3d
动恰客流管家1 天前
动恰3DV3丨客流统计系统:自然山水景区客流统计破局,景区数字化标配
数据结构·microsoft·3d
CG_MAGIC1 天前
Blender场景教程:秘密实验室
3d·blender·建模教程·渲云渲染·3d软件
.生产的驴1 天前
Vue3 超大字体font-slice按需分片加载,极速提升首屏速度, 中文分片加载方案,性能优化
前端·vue.js·windows·青少年编程·性能优化·vue·rescript
UltraLAB-F1 天前
医学图像处理算力瓶颈深度解析:从3D CT到高分辨率MRI,UltraLAB硬件方案如何破局?
图像处理·人工智能·3d
宁波阿成2 天前
族谱管理系统架构分析与亮点总结
java·系统架构·vue·ruoyi-vue·族谱
不想上班只想要钱2 天前
模板里 item.xxx 报错 ,报 item的类型为未知
前端·vue
一只小阿乐2 天前
js流式模式输出 函数模式使用
开发语言·javascript·ai·vue·agent·流式数据·node 服务