这篇文章主要以3D模型为主,通过blender绘制的模型,用Threejs加载到场景中,通过移动一些模型,做出动画效果,也是数字孪生中做常见的一种方式,但是缺点是需要建模人员辅助来制作,首先还是需要新建一个threejs的场景,包括场景,相机,渲染器等。
另外这里因为是要创建工厂,所以需要绘制出地板,地板在之前的章节中都有做过,这里就直接添加上去了,然后将基础设施的场景通过Threejs加载出来,
代码如下:
initFactory(){
const loader = new GLTFLoader()
loader.load("/static/models/product/make.glb", (gltf) => {
gltf.scene.scale.set(10,10,10)
gltf.scene.position.set(0,0,18)
gltf.scene.rotation.x = Math.PI/2
gltf.scene.rotation.y = Math.PI/2
this.scene.add(gltf.scene) // 加入场景
})
},
如图:
然后需要在场景中添加车和产品物料,
initAgv(){
const loader = new GLTFLoader()
loader