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博客

相关推荐
三维频道7 小时前
压铸件尺寸检测与模具监测方案 / 3D Scanning for Die-casting QC & Mold Monitoring
人工智能·计算机视觉·3d·尺寸检测·xtom·压铸件·模具优化
aini_lovee7 小时前
LIS3DH低功耗加速度传感器驱动程序
3d
三维频道7 小时前
注塑件变形怎么调优?全尺寸3D检测如何助力精密注塑“减废增效”
3d·制造·智能制造·3d扫描仪·新拓三维·注塑模具质检·三维尺寸偏差分析
AI前沿资讯7 小时前
2026年3D动画制作工具推荐:从传统工作流到AI一站式创作
人工智能·3d
bryant_meng1 天前
【3D】Stereo Matching learning notes
计算机视觉·3d·双目匹配
三维频道1 天前
工业级三维扫描实测:汽车灯具复杂结构件的全尺寸 3D 测量方案分析
java·人工智能·python·数码相机·3d·汽车·汽车轻量化制造
MapVillage1 天前
3D Gaussian Splats 高斯泼溅技术
3d
杀生丸学AI1 天前
【三维重建】Neural Gabor Splatting:基于神经Gabor的增强型3DGS(高频表面重建)
3d·aigc·扩散模型·视觉大模型·点云分割·高斯泼溅·空间智能
a1117761 天前
Web3D 在线3D模型骨骼动画编辑器(开源 Reze Studio)
前端·3d·开源·html
Hody911 天前
【XR技术介绍】AI快速扫描3D场景技术全景解析:水平、路径与技术选型
人工智能·3d·xr