在我的程序中,有一个由线条构成的网格,我克隆,更改顶点,添加到数组,然后添加到场景中作为不断增长的conga线形状。问题是克隆的形状似乎遵循与原始形状相同的平截头体,所以如果我看到康加线的开头,我可以看到它,但如果我看到结束(并且开始是不在视野中) )整个事情都消失了。
我找不到影响截头体的“needsUpdate”参数,而不是frustrumCulled,但我不想禁用截头剔除,因为我不想在不看它时渲染形状!
我错过了什么吗?
以下是“动画”康加系列的代码部分。现在它只是永久地添加了行,但这只是暂时的,直到我开始工作。
this.blurb = function( scene ) { // function is called every frew frames to add a new shape
if ( blurbShapes && blurbShapes.length ) { // checks if the array is already populated by shapes
// makes a clone of the last geometry in the array and its mesh
blurbCopy = blurbShapes[ blurbShapes.length - 1 ].geometry.clone();
blurbMaterialCopy = blurbShapes[ blurbShapes.length - 1 ].material.clone();
// randomly jitters the vertices of the geometry a bit for variety
for ( var i = 0; i < blurbCopy.vertices.length; i++ ) {
blurbCopy.vertices[i].x += Math.random() - 0.5;
blurbCopy.vertices[i].y += Math.random() - 0.5;
blurbCopy.vertices[i].z += Math.random() - 2;
}
// closes the loop by making the first vertex look at the last one
blurbCopy.vertices[0] = blurbCopy.vertices[ blurbCopy.vertices.length - 1 ];
blurbMaterialCopy.color.offsetHSL ( 0.01, 0, 0 );
// update vertex information -- but this doesn't seem to update where the camera thinks the geometry is!
blurbCopy.verticesNeedUpdate = true;
// add the shape to the array
blurbShapes.push( new THREE.Line( blurbCopy, blurbMaterialCopy ) );
scene.add( blurbShapes[ blurbShapes.length - 1 ] );
} else { // first time
color = new THREE.Color();
color.setHSL( Math.random(), 0.7, 0.8 );
material = new THREE.LineBasicMaterial( { color: color } ),
geometry = new THREE.CircleGeometry( 32, 32 );
// Remove center vertex and make it equal to the last vertex
geometry.vertices[0] = geometry.vertices[ geometry.vertices.length - 1 ];
geometry.verticesNeedUpdate = true;
blurbShapes.push( new THREE.Line( geometry, material ) );
scene.add( blurbShapes[0] );
}
}
编辑:添加阅读评论。
这是上下文的图片。在第一个康加的线条线是完全可见的; “第一”线位于图像的最右边,一半显示。在第二个图像中,我看起来略微偏离了“第一”线,因此它不在视野范围内,整个阵列都消失了。