Sign in to follow this  

vector multiply webgl

Recommended Posts

How i can multiply two vector3 or two vector4 in webgl?
I tryed vector1 * vector2 but is don't correct.

Share this post

Link to post
Share on other sites
because i have this code for zoom on orbital camera ,but when this.m_orbitOffsetDistance become negative , i can't zoom

zoom: function (zoom, minZoom, maxZoom) {
if (this.m_behavior == CAMERA_BEHAVIOR_ORBIT) {
// Moves the camera closer to or further away from the orbit
// target. The zoom amounts are in world units.

this.m_orbitMaxZoom = maxZoom;
this.m_orbitMinZoom = minZoom;

var vOffset = vec3.create();
vec3.subtract(this.m_eye, this.m_target, vOffset);

this.m_orbitOffsetDistance = vec3.length(vOffset);
vec3.normalize(vOffset, vOffset);
this.m_orbitOffsetDistance += zoom;
// this.m_orbitOffsetDistance = Math.min(Math.max(this.m_orbitOffsetDistance, minZoom), maxZoom);

vec3.scale(this.m_orbitOffsetDistance, vOffset, vOffset);

vec3.add(vOffset, this.m_target, this.m_eye);


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this