首页 > 解决方案 > Threejs中未显示的点

问题描述

我正在尝试在 threejs 中使用 Points 对象。我正在尝试显示一个点,但它没有显示出来。浏览器没有给出任何错误。让我知道需要做什么。谢谢

let pointGeometry:any = new BufferGeometry();
let positionAttribute = new BufferAttribute( new Float32Array([10,5,10]), 10 );
pointGeometry.setAttribute( 'position', positionAttribute );
pointGeometry.attributes.position.needsUpdate = true;
pointGeometry.setDrawRange(0,10);
let pointMaterial = new PointsMaterial( { color: 0x03F9E7, size: 10 } );
this.point = new Points( pointGeometry, pointMaterial );
this.point.name = 'point';
this.point.scale.copy( new Vector3(10,10,10) );
this.scene.add( this.point );

标签: three.jspointsparticle-system

解决方案


的应该itemSize是。BufferAttribute3

let positionAttribute = new BufferAttribute( new Float32Array([10,5,10]), 3 );
pointGeometry.setAttribute( 'position', positionAttribute );

itemSize-- 应该与特定顶点关联的数组值的数量。例如,如果此属性存储一个 3 分量向量(例如位置、法线或颜色),则 itemSize 应为 3。

[文档] BufferAttribute

另一个原因可能是相机看错了位置。如果你设置一个比例,10点的最终位置会在[100,50,100]


推荐阅读