# Instanced cube not showing when viewed from certain perspectives unless position is 0, 0, 0

**URL:** <https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235>\
**Category:** Questions\
**Tags:** normal-material, instanced-mesh\
**Created:** [May 15, 2020, 2:59am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235 "2020-05-15T02:59:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dullbananas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dullbananas/32/10850_2.png) [@dullbananas](https://discourse.threejs.org/u/dullbananas)\
**Post date:** [May 15, 2020, 2:59am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/1 "2020-05-15T02:59:59Z")

</div>

I had this cube working fine, but when I set its position to something other than (0, 0, 0), it became invisible when looked at depending on where I am viewing it from. None of the objects are transparent.

 ![ezgif.com-optimize 3](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/a/a2f65f3a743eb88e2f4ca085c5d66cefb17ec3af.gif)

This is some of the source code:

```auto
scene.autoUpdate = true;

let camera = new THREE.PerspectiveCamera(
	75, // field of view
	window.innerWidth / window.innerHeight, // aspect ratio
	0.1, // near clipping plane
	32, // far clipping plane
);

let renderer = new THREE.WebGLRenderer({
	canvas: document.getElementById('world-canvas') as HTMLCanvasElement,
	precision: 'mediump',
	stencil: false,
});

let voxelGeometry = new THREE.BoxBufferGeometry(1, 1, 1);

let material = new THREE.MeshNormalMaterial();

function newVoxelMesh(count: number): THREE.InstancedMesh {
	let mesh = new THREE.InstancedMesh(voxelGeometry, material, count);
	scene.add(mesh);
	return mesh;
}

// Used to hold the matrix that will be applied to objects
let transform = new THREE.Object3D();

function addVoxel(index: number, mesh: THREE.InstancedMesh, x: number, y: number, z: number) {
	transform.position.set(x, y, z);
	transform.updateMatrix();
	mesh.setMatrixAt(index, transform.matrix);
}

let tmpMesh = newVoxelMesh(1);
addVoxel(0, tmpMesh, 0, 0, 4);

camera.position.set(0, 0, 8);
camera.lookAt(0, 0, 4);

function renderFrame() {
	camera.updateProjectionMatrix();
	renderer.render(scene, camera);
}

```

I tried doing many things to fix this, like using Camera.updateProjectionMatrix(), turning on auto matrix update, and even switching to orthographic camera. I found a possible solution which is to disable Object3D.frustumCulled, but this will cause performance issues when I add more voxel geometry in the future.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 15, 2020, 8:07am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/2 "2020-05-15T08:07:51Z")

</div>

Can you try to increase your camera with a higher far plane value? Besides, can you try to remove the `precision` parameter from `WebGLRenderer` ctor? Do you see any effects?

---

<div class="post-metadata">

**Author:** ![dullbananas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dullbananas/32/10850_2.png) [@dullbananas](https://discourse.threejs.org/u/dullbananas)\
**Post date:** [May 16, 2020, 2:25am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/3 "2020-05-16T02:25:49Z")

</div>

I tried both and it still does not work correctly.

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [May 16, 2020, 2:33am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/4 "2020-05-16T02:33:10Z")

</div>

Related to [https://github.com/mrdoob/three.js/issues/18334](https://github.com/mrdoob/three.js/issues/18334)? Culling does not know about all of the instances. You may need to disable it or set a manual bounding box for now.

---

<div class="post-metadata">

**Author:** ![dullbananas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dullbananas/32/10850_2.png) [@dullbananas](https://discourse.threejs.org/u/dullbananas)\
**Post date:** [May 16, 2020, 2:38am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/5 "2020-05-16T02:38:52Z")

</div>

I tried changing the background color of the scene to see if the cube is just turning black, and it’s not. I also tried switching to MeshDepthMaterial and it still does not work.

---

<div class="post-metadata">

**Author:** ![dullbananas](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dullbananas/32/10850_2.png) [@dullbananas](https://discourse.threejs.org/u/dullbananas)\
**Post date:** [May 16, 2020, 2:49am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/6 "2020-05-16T02:49:11Z")

</div>

I disabled frustumCulled for now

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 16, 2020, 9:31am UTC](https://discourse.threejs.org/t/instanced-cube-not-showing-when-viewed-from-certain-perspectives-unless-position-is-0-0-0/15235/7 "2020-05-16T09:31:11Z")

</div>

View frustum culling is deactivated by default for `InstancedMesh`:

> <https://github.com/mrdoob/three.js/blob/c9e5983629a8fa5dcd8991162635e87644832746/src/objects/InstancedMesh.js#L23>

So I don’t think you have to disable it in your application.
