Scene Rendering for a particular object

Hii,
In my project there are many shapes objects (like line,rectangle etc) added in scene and we can rotate each object separately but as the objects increase the rendering becomes slow.Is there anything that we can focus our render to that particular object and neglect other objects so that it should not have to render each and every objects which leads to lags the performance.

Thanks & Regards
Raman

Hi Raman,

It’s very hard to to give advice on performance without seeing your code. Can you share a minimal working example using codepen?

You can try testing to see if the object is onscreen and only updating in that case:

camera.updateMatrix(); // make sure camera's local matrix is updated
camera.updateMatrixWorld(); // make sure camera's world matrix is updated
camera.matrixWorldInverse.getInverse( camera.matrixWorld );

plane.updateMatrix(); // make sure plane's local matrix is updated
plane.updateMatrixWorld(); // make sure plane's world matrix is updated

var frustum = new THREE.Frustum();
frustum.setFromMatrix( new THREE.Matrix4().multiply( camera.projectionMatrix, camera.matrixWorldInverse ) );

// if( !frustum.intersectsObject ( object ) ) { // more accurate, possibly slower
if( !frustum.containsPoint ( object.position ) ) {

    // update the object 

}

Other things to try: Make sure you are using BufferGeometries, use instancing.

1 Like