InstancedBufferGeometry.copy three.js 中的错误

InstancedBufferGeometry.copy error in three.js

我是运行一个three.js示例代码,它的three.js版本是0.124.

createObj() {
    const geometry = new THREE.InstancedBufferGeometry();
    const baseGeometry = new THREE.BoxGeometry(2, 2, 20, 2, 2, 6);
    
    // Copy attributes of the base Geometry to the instancing Geometry
    geometry.copy(baseGeometry);
}

当'geometry.copy(baseGeometry);'中的代码为运行时,弹出错误,如图

TypeError: Cannot read properties of undefined (reading 'clone')
    at InstancedBufferGeometry.copy (three.module.js?cf64:10935)
    at InstancedBufferGeometry.copy (three.module.js?cf64:40628)
    at createObj (Clouds.js?d048:24)

InstancedBufferGeometry.copy() 只接受另一个 InstancedBufferGeometry 对象作为参数。您正在尝试传递遗留 Geometry 对象(THREE.Geometry was part of the core up until r125,并且您正在使用 r124),因此在执行该方法时发现它缺少所有实例化属性时它会中断。

See here in the docs for using the copy() method