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

相关推荐
3DVisionary14 小时前
消费电子曲面如何逆向?蓝光3D扫描实现精密件快速迭代
3d·制造·智能制造·逆向工程·蓝光三维扫描·形位公差分析·消费电子制造
AI前沿资讯14 小时前
哪个AI 3D创作工具更适合视频创作?——2026年V2Fun实战指南
人工智能·3d·音视频
君为先-bey14 小时前
DiffusionGS: 将3D高斯溅射嵌入扩散模型的单阶段图像到三维生成
深度学习·计算机视觉·3d·扩散模型·三维点云
葛兰岱尔1 天前
3D模数师V1.2 震撼发布:支持3D/BIM/GIS全栈融合的桌面端查看应用工具,开启工程数字孪生新纪元!
3d
相忘于江湖4265431 天前
vs code 代码保存自动格式化
前端·vue
LuminWave1 天前
多维场景落地,3D激光雷达成机器人产业核心感知基石
人工智能·3d·机器人
I'mSQL1 天前
下载威图机柜3D模型
3d·自动化
LONGZETECH2 天前
Unity 3D+C/S架构无人机数字孪生实训室:破解实训“三高”难题的底层技术实现
c语言·开发语言·3d·unity·架构·无人机
艺杯羹2 天前
Vibe Coding实战:从零构建网页3D交互角色
3d·ai·交互·ai编程·ai agent·vibe coding
菩提树下的凡夫2 天前
基于Halcon深度图的曲面圆柱凹坑缺陷处理方法
人工智能·计算机视觉·3d