问题描述
我已经加载了 .dae
模型,我想在我的场景中使用更多次。此代码适用于网格,但 collada.scene
对象不是网格:
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 );
如何在一些对象之间共享相同的collada模型?
How is it possible, to share the same collada model between some objects?
推荐答案
dae场景不是网格,但肯定有网格。
您应该在console.log中使用collada对象,或在 load
函数中放置断点,并检查所需的网格在哪里。
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.
给定位于的网格collada.scene.children [0]
在 load
函数中,将网格存储在某处,比如 window.referenceModel
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 );
这篇关于如何在threejs中克隆collada模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!