Priya Pramesi
Priya Pramesi

Reputation: 21

A-Frame Frustum Culling

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>

Upvotes: 2

Views: 1255

Answers (3)

JoanaB
JoanaB

Reputation: 11

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

Upvotes: 1

Ben Clarke
Ben Clarke

Reputation: 31

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.

Upvotes: 3

digitalBath
digitalBath

Reputation: 56

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.

Upvotes: 0

Related Questions