如何解决如何在Threejs中使用InstancedBufferGeometry
当我使用InstancedBufferGeometry不显示时。 (当下面的代码删除注释时,将显示多边形。) 但是,当显示多边形时,我使用BufferGeometry。
为什么下面的代码不起作用。
请教我。
const createGeometry = () => {
// const geometry = new THREE.BufferGeometry();
const geometry = new THREE.InstancedBufferGeometry();
const positions = new THREE.BufferAttribute(new Float32Array(4 * 3),3);
const uvs = new THREE.BufferAttribute(new Float32Array(4 * 2),2);
positions.setXYZ(0,-0.5,0.5,1.0);
positions.setXYZ(1,1.0);
positions.setXYZ(2,1.0);
positions.setXYZ(3,1.0);
uvs.setXYZ(0,0.0,0.0);
uvs.setXYZ(1,1.0,0.0);
uvs.setXYZ(2,1.0);
uvs.setXYZ(3,1.0);
geometry.setAttribute("position",positions);
geometry.setAttribute("uv",uvs);
geometry.setIndex(
new THREE.BufferAttribute(new Uint16Array([0,2,1,3,1]),1)
);
return geometry;
};
使用BufferGeometry时。
解决方法
不支持使用没有至少一个InstancedBufferAttribute
的{{1}}。
这种用法甚至没有意义,因为您希望拥有一个或多个定义每个实例的变体的属性。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。