InstancedMesh mesh visibility from different angles | mesh order?

Hi everyone,


I am using instancedMesh and for loop in order to display array of boxes with random height/width. The problem is if i rotate with orbit control around i see very weird artifact, alsmot like boxes are not ordered correctly, how do i fix it ? Attaching screenshot

It looks like you might be setting .transparent = true on your materials. Avoid that unless you really need it. Transparency is always order-dependent, and order gets particularly difficult with instanced meshes because the renderer can no longer sort them for you at runtime, as it would normally do.

If it’s not that, you may need to share enough detail that someone can reproduce the problem.

Thanks for the reply ! I am not using transparency, here is very simplyfied code. I have a feeling it has to do with order, but by some reason i did not see this issue in any other examples

this.instanceCount = 4
this.boxMaterialBasic = new THREE.MeshNormalMaterial({})
this.geo = new THREE.BoxGeometry( 1, 1, 1 )
this.mesh = new THREE.InstancedMesh(this.geo, this.boxMaterialBasic,this.instanceCount)
this.transform = new THREE.Object3D();
this.ii = 0
for (let i = 0; i < this.instanceCount; i++) {



Check your camera settings, could be you either have far plane less than near for perspective or flipped left/right/top/bottom values for ortho camera.

Thanks, it worked,
My near value was too low = new THREE.PerspectiveCamera(