three.js - Keeping camera above ground (using OrbitControls.js) -



three.js - Keeping camera above ground (using OrbitControls.js) -

so have simple situation ground plane y=0 , want maintain photographic camera above ground @ time. want controls sense intuitive (and touch-compatible) , figured out orbitcontrols.js seems best suited this, because there can limit polar angle setting maxpolarangle less or equal math.pi/2 (quarter turn).

still, doing user can pan below ground unless panning disabled altogether (which don't want to). manually limiting y never goes negative felt weird figured ignoring changed on y axis e.g. changing line 165 (panup function) following

panoffset.set( te[ 4 ], 0, te[ 6 ] ); panoffset.normalize();

led quick , dirty solution did wanted.

but user can alter photographic camera height zooming.

can think of improve solution? maybe thread can serve nutrient thought official solution, sure wouldn't 1 benefiting such solution.

/edit: wasn't normalizing offset vector @ first led issue, changed now.

i had problems getting orbitscontrols.js work desired. soulution worked best me create own camaracontrols did function per requirements. suspect not reply looking involves bit of work. add together own update function clamps values.

three.orbitcontrols.clampedupdate = function () { three.orbitcontrols.update.call(this); if (this.object.position.y < 0) { this.object.position.y = 0; } }

three.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -