A-Frame Frustum Culling

Viewed 533

How do I turn off frustum culling on a gltf model in A-Frame? I know in Three.js you can just traverse the object and add node.frustumCulled = false. I've tried

AFRAME.registerComponent('disable-culling', {
  init: function(){
    var object3D = this.el.sceneEl.object3D;
    object3D.traverse((node) => {
      node.frustumCulled = false
    })
  }
})

but that doesn't work. Does anyone have any idea? The entity is

<a-entity
  id="ball"
  scale="0.3 0.3 0.3"
  position="0 0 -7"
  gltf-model="#ballModel"
  disable-culling
  animation-mixer="clip: *; loop: once; clampWhenFinished: true;"
  shadow>
</a-entity>
3 Answers

I had a similar problem which was solved with frustum culling -

el.addEventListener('model-loaded', () => {
  const model = el.getObject3D('mesh');
  model.traverse((node) => {
    if (node.isMesh) {
      node.frustumCulled = false;
    }
  });
});

I wonder if your solution didn't work simply because the model hadn't finished loading.

Go back with your 3D model to Blender, select your model on object mode and then press "ctrl A" - apply all transformations.

I just had this problem where animated models were getting culled before fully exiting the scene. In my case, the cause seemed to be that the object scale was too small. Once I scaled up the object up in Blender and re-exported the gltf file, the models were culled correctly.

Related