Sign in to follow this  
Tableuraz

Making a mesh match Camera view

Recommended Posts

Hi there !

 

I have a small question, I am looking for the best way to make a mesh match the camera clipping plane.

The only issue I am getting is that the camera is always zooming/unzooming because the mesh never perfectly fits the clipping plane... I made a simple Playground scene to show the issue :

http://www.babylonjs-playground.com/#AZZNI

 

You can increase the zoomingSteps value if you can't see the issue.

 

Thanks in advance for your help, I will keep you informed if I find a solution.  ^_^

Share this post


Link to post
Share on other sites

Issue fixed, in case anyone has the same issue, here is the corrected playground, you can change the "ground" size before running it again to see it work :

http://www.babylonjs-playground.com/#AZZNI#1

 

And you can modify the code to this if you don't want to have a function running in the background for no reason :

if (!ground.isCompletelyInFrustum(scene.activeCamera)) {	scene.beforeRender = function() {		if (!ground.isCompletelyInFrustum(scene.activeCamera)){			scene.activeCamera.fov += zoomingSteps;			scene.activeCamera.setTarget(ground.position);		}		else			scene.beforeRender = null;	}}else if (ground.isCompletelyInFrustum(scene.activeCamera)) {	scene.beforeRender = function() {		if (ground.isCompletelyInFrustum(scene.activeCamera)){			scene.activeCamera.fov -= zoomingSteps;			scene.activeCamera.setTarget(ground.position);		}		else			scene.beforeRender = null;	}}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.