PDA

View Full Version : vector multiply in webgl



giuseppe500
08-08-2011, 09:40 AM
hello.
How i can multiply two vector3 or two vector4 in webgl?
I tryed vector1 * vector2 but is don't correct.
thanks.

giuseppe500
08-08-2011, 09:57 AM
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);
alert(zoom);
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);

this.updateViewMatrix();
}