Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is clipping done automatically in Three.js?

So, I was reading about clipping in this Wikipedia article. It seems pretty essential to any and all games, so, do I have to do it, or is it done automatically by Three.js, or even WebGL? Thanks!

like image 575
corazza Avatar asked Jan 27 '26 07:01

corazza


1 Answers

You can pass values for the near and far clipping planes to your camera object:

var camera = new THREE.PerspectiveCamera( fov, aspect, near, far );

near and far can contain values for example near = 0.1 and far = 10000 so an object which lies between these values will be rendered.

EDIT:

near and far, represent the clipping planes for your world. In a scene with thousands of objects and textures being drawn at once, it would be taxing on the CPU and GPU to try and show everything. Even worse, it would be wasteful to draw the things you cant even see. The near clipping plane is usually relatively close to the user, whereas the far clipping plane is somewhere off in the distance. As objects cross the far plane, they spontaneously appear or disappear. Some games use fog to make the appearance and disappearance of objects more realistic.

like image 178
Neil Avatar answered Jan 28 '26 22:01

Neil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!