How to clone collada model in threejs?

前端 未结 1 1739
囚心锁ツ
囚心锁ツ 2021-01-15 02:17

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 mes

相关标签:
1条回答
  • 2021-01-15 03:11

    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 );
    
    0 讨论(0)
提交回复
热议问题