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

相关推荐
2601_9564141412 小时前
AI3D模型生成工具怎么比较?2026主流平台对比与实测维度解析
人工智能·3d
蓝速科技17 小时前
蓝速科技视觉 3D 全息仓 AI 数字人一体机深度评测
人工智能·科技·3d
chaoyuanl1 天前
现有游乐设施 XR 数字化升级改造方案
大数据·科技·3d·xr·娱乐
3D小将1 天前
3D格式转换之3MF模型转GLB通用技术
3d·solidworks模型·ug模型·rhino模型·catia模型
山海云端有限公司1 天前
随机诗词API实战:Vue项目接入完整示例与5个常见坑
vue·实战·前端开发·跨域·api调用·随机诗词api
韭菜钟1 天前
利用OpenCV进行3d相机手眼标定(眼在手上/眼在手外)
opencv·3d
数智工坊1 天前
视图集合化+轻量Transformer:VSFormer开启多视图3D形状理解新范式
深度学习·3d·transformer
暗冰ཏོ2 天前
Spring Boot + Vue3 订单支付模块技术实现:支付单、回调验签、幂等处理与余额扣减
前端·spring boot·后端·vue·微信支付·支付宝支付
digitalpath2 天前
AutoCAD Plant3D免费版下载安装教程(附安装包)AutoCAD Plant3D 2026 保姆级安装教程
其他·3d
具身新纪元2 天前
ICML 2026|工业3D质检迎来新SOTA:零样本缺陷检测开始拼“多模态硬融合”
3d