CarlosDvlp Posted April 3, 2016 Share Posted April 3, 2016 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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 3, 2016 Share Posted April 3, 2016 If you use a rotating camera, for example the angle beta up and down, you can do like this. for alpha you can do the same. if (camera.beta < 0.1) camera.beta = 0.1; else if (camera.beta > (Math.PI / 2) * 0.92) camera.beta = (Math.PI / 2) * 0.92; Pryme8 1 Quote Link to comment Share on other sites More sharing options...
CarlosDvlp Posted April 4, 2016 Author Share Posted April 4, 2016 Can I do the same with free camera? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted April 4, 2016 Share Posted April 4, 2016 Yes. You can do it with the camera free using rotation on the Y axis : if(camera.rotation.y > 45) camera.rotation.y = 45; else if(camera.rotation.y < -45) camera.rotation.y = -45; 45 = 45° Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.