问题描述
我在截锥体剔除方面遇到了问题.我们知道在 Three.js 中视锥剔除是默认的,如果需要我们可以设置
I am facing a issue in frustum culling.We know in Three.js frustum culling is default, if needed we can set
mesh.frustumCulled =false;
我的问题是如何在实例几何中实现截锥体剔除,如果我启用
my issue is how to implement frustum culling in instance geometry,If i enable
mesh.frustumCulled = true
所有实例数据都是从场景中剔除的,而原始实例是从视锥体中剔除的,因为我的原始几何体在一个位置,所以实例将被矩阵(位置、旋转、缩放)放置.我使用了 InstanceBufferGeometry 和 InterleavedBufferAttribute,如three.js 示例中所述webgl_interactive_instances_gpu
all the instance data culled from scene while the original instance culled from frustum,because my original geometry is in one position, instance will be place by the matrix(position,rotation,scale).I used InstanceBufferGeometry and InterleavedBufferAttribute as described in three.js examplewebgl_interactive_instances_gpu
提前致谢..
推荐答案
Instancing 发生在 gpu 上;cpu 上的视锥体剔除.
Instancing occurs on the gpu; frustum culling on the cpu.
如果您正在使用实例化,您可以禁用网格的视锥剔除
If you are using instancing, you can either disable frustum culling for your mesh
mesh.frustumCulled = false;
或者您可以手动指定边界球
or you can manually specify the bounding sphere
mesh.geometry.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
如果需要更新绑定球体,
If you need to update the bound sphere,
mesh.geometry.boundingSphere.center.set( x, y, z );
mesh.geometry.boundingSphere.radius = radius;
three.js r.93
three.js r.93
这篇关于实例几何体 Frustum 剔除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!