Jump to content

Cameras and angle limits


CarlosDvlp
 Share

Recommended Posts

Hey guys! thanks for all the answers in the other topic, those helped me a lot ;).  I have a doubt, how can I set a min angle and max angle for my camera rotation?

because I don't want my camera to rotate 360° :( . What I tried is to  let a little box to follow the camera and it has a collision with some walls in order to stop showing the part I don't want to. it worked but the effects are really ugly.

That's is solution, as I mentioned It's has some ugly effects and is not always exact.

var prevTarget= jQuery.extend(true, {}, camera.getTarget());

//OP1			 
scene.registerBeforeRender(function () {		            

    for(var i in objs)//the walls I mentioned
	      if (objs[i].intersectsMesh(sphere, true) && scene.isReady()) 
			            	camera.setTarget(prevTarget);               
	      

 prevTarget= jQuery.extend(true, {}, camera.getTarget());
            
});

//or
//OP2 (more precise)
setInterval(function(){

	  for(var i in objs) //the walls I mentioned
			 if (objs[i].intersectsMesh(sphere, true) && scene.isReady()) 
			                camera.setTarget(prevTarget);			            	
			            

	prevTarget= jQuery.extend(true, {}, camera.rotation);
 },0.1);

I hope a better way to do it, thanks guys for supporting us ;)

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...