freshfork / p5.EasyCam

A p5.js library for easy 3D camera control.
https://freshfork.github.io/p5.EasyCam
MIT License
137 stars 33 forks source link

Limit Yaw, Pitch or Roll Rotation to a set angle #9

Open carlosnavarro-cn opened 4 years ago

carlosnavarro-cn commented 4 years ago

Hello James, I tried successfully your indications to limit the yaw, pitch and roll rotations. I would love to limit the angle for each of this. Right now they have a rotation similar to 360 (or they can rotate infinite times). Is there a way to limit the pitch rotation to 180 degrees, as it happens on any of the models in this website here: https://app.shapediver.com/m/array-table-dimension

Thanks in advance, CN

jwdunn1 commented 4 years ago

This type of angle limitation does not presently exist in EasyCam (or its predecessor) and would be considered a feature request. I'll leave this issue open if someone wishes to contribute this enhancement. For an existing p5.js camera solution, similar to what you shared, see SimpleCam. Check out the examples on that repository page.

carlosnavarro-cn commented 4 years ago

This type of angle limitation does not presently exist in EasyCam (or its predecessor) and would be considered a feature request. I'll leave this issue open if someone wishes to contribute this enhancement. For an existing p5.js camera solution, similar to what you shared, see SimpleCam. Check out the examples on that repository page.

James, thanks for your feedback. I just looked into the SimpleCam repository and think it works more similarly to what i was intending. With regards to this subject on EasyCam, I was also trying to set the 3 (yaw, pitch and roll) constrain rotation parameters all to false for when I wanted to stop all rotations completely, but I see that 3 falses end up resulting as if they were all set to true. Is they a way to stop all rotations, and also stop the zomming completely to have as if it were a still camera? I looked into set rotation, and the mouse and wheel controls but didn't get to anything. Thank you.

jwdunn1 commented 4 years ago

An EasyCam instance can be deactivated by removing the event listeners. A simple example using keys as toggles:

function keyPressed(){
  if(key=='r') cam.removeMouseListeners();
  if(key=='a') cam.attachMouseListeners();
}
carlosnavarro-cn commented 4 years ago

An EasyCam instance can be deactivated by removing the event listeners. A simple example using keys as toggles:

function keyPressed(){
  if(key=='r') cam.removeMouseListeners();
  if(key=='a') cam.attachMouseListeners();
}

This works great. Thank you!