我一直在练习在three.js回购中克隆一个three.js代码。
在这个例子中,有些事情我不明白。
为什么THREE.InstancedBufferGeometry应该被THREE.BufferGeomtry.prototype复制?
loader.load( './models/gltf/Flower/Flower.glb', function ( gltf ) {
const _stemMesh = gltf.scene.getObjectByName( 'Stem' );
const _blossomMesh = gltf.scene.getObjectByName( 'Blossom' );
stemGeometry = new THREE.InstancedBufferGeometry();
blossomGeometry = new THREE.InstancedBufferGeometry();
THREE.BufferGeometry.prototype.copy.call( stemGeometry, _stemMesh.geometry );
THREE.BufferGeometry.prototype.copy.call( blossomGeometry, _blossomMesh.geometry );也许是关于javascript的,但我还是不明白。
为什么我不能直接使用InstancedBufferGeometry.copy()?
谢谢,
发布于 2021-02-03 10:36:00
为什么THREE.InstancedBufferGeometry应该被THREE.BufferGeomtry.prototype复制?
InstancedBufferGeometry是带有覆盖copy()方法的BufferGeometry的子类。如果要直接使用InstancedBufferGeometry.copy(),则该方法将尝试从BufferGeometry复制名为instanceCount的InstancedBufferGeometry特定属性。因此,派生类的属性将成为undefined。
https://stackoverflow.com/questions/66023258
复制相似问题