camera's near field update

Is there any way to change camera's near and far parameters without re-creation of camera

Because camera stops showing objects when I try to change them

in some cases, it just shows black screen (even there is skybox)

Before: enter image description here

After near parameter change: enter image description here

All the button does:

function changeNear() {
  camera.near = 0;
  console.log(camera.near)
  camera.updateProjectionMatrix()

}

codepen: https://codepen.io/random-jordan/pen/gOeYjpa?editors=1111

Upvotes: 0

Views: 36

Answers (1)

madzong
madzong

Reputation: 396

You don't need to recreate the camera.

You are not seeing the objects because near: 10 is too far away so the objects don't get rendered.

Try setting near to 0.1 by default and setting it to 2.5 in changeNear(). You will see that near gets changed just enough so that the objects get cut a bit.

Upvotes: 2

Related Questions