简体   繁体   中英

Changing the camera's near plane

I have a view with (buffer) geometry objects and a few different layers of markups, each stored in their own scene. This allows me to easily switch them off or draw them on top of objects regardless of depth.

What I'm trying to accomplish is easy cross sections using the camera's near and far fields. I place the (orthographic) camera at the location I'd like to make my 'cut' and that works well. The issue is that I can't 'cut' off my markup layers when I 'cut' through the objects. I would like the markups to still be fully visible.

What I've attempted is changing the camera's near field inside the render loop:

function animate() {
    requestAnimationFrame( animate );
    renderer.clear();

    //  Switch the near field for this scene
    var oldNear = camera.near;
    camera.near = -1000;
    renderer.render( sceneFTA, camera );
    camera.near = oldNear;
    //

    renderer.render( scene, camera );
    //the following scenes are always drawn on top
    renderer.clearDepth(); 
    renderer.render(sceneMarkup, camera);
    renderer.render(scenePts, camera);
}

I'm not sure what's going wrong. I can change the camera.near property before the render loop and see the changes take effect, but quickly switching inside the loop doesn't seem to do anything. The result of this is identical to leaving the near field unchanged.

Any ideas how I can make the near-field change work?

If you change the camera parameters specified in the camera constructor, you need to call

camera.updateProjectionMatrix();

three.js r.71

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM