How to clone collada model in threejs?

耗尽温柔 提交于 2019-12-19 10:22:20

问题


I've loaded a .dae model, which I would like to use more times in my scene. This code works with meshes, but the collada.scene object isn't a mesh:

var mesh2 = new THREE.Mesh( loadedMesh.geometry, loadedMesh.material );

How is it possible, to share the same collada model between some objects?


回答1:


The dae scene is not a mesh, but there's certainly a mesh in it. You should console.log the collada object, or put a breakpoint in the load function, and inspect where is the mesh you want.

Given a mesh located in collada.scene.children[0]

In the load function, store the mesh somewhere, say window.referenceModel

window.referenceModel = collada.scene.children[0];

Later, when you want to clone this model

var refObject = window.referenceModel;
var clone = new THREE.Mesh( refObject.geometry, refObject.material );
// here you can apply transformations, for this clone only
scene.add( clone );


来源:https://stackoverflow.com/questions/18942539/how-to-clone-collada-model-in-threejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!