本文整理匯總了TypeScript中gl-matrix.vec3.scale方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript vec3.scale方法的具體用法?TypeScript vec3.scale怎麽用?TypeScript vec3.scale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gl-matrix.vec3
的用法示例。
在下文中一共展示了vec3.scale方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: moveAlong
moveAlong(elapsedTime: number, speed: number): Vec3 {
// If there is no further waypoint, we've arrived at the end and we
// always return the current position.
if (this.done) {
return vec3.clone(this.currentPosition);
}
// The vector from the current position to the next waypoint.
var vector = vec3.subtract(vec3.create(), this.waypoints[0], this.currentPosition)
, vectorLength = vec3.length(vector)
, distanceMoved = speed * elapsedTime;
if (vectorLength < distanceMoved) {
// The remaining distance in the current segment is less than what
// we moved, jump to the next waypoint and move along the next path
// segment from there.
vec3.copy(this.currentPosition, this.waypoints.shift());
this.currentHeading = normalizeHeading(Math.atan2(vector[1], vector[0]));
return this.moveAlong(elapsedTime - vectorLength / speed, speed);
}
// We have not yet reached the next waypoint. Move along the vector
// towards it and update the heading.
vec3.add(this.currentPosition, this.currentPosition, vec3.scale(vec3.create(), vec3.normalize(vec3.create(), vector), distanceMoved));
this.currentHeading = normalizeHeading(Math.atan2(vector[1], vector[0]));
return vec3.clone(this.currentPosition);
}
示例2: at
public at(scale: number) {
const result = vec3.fromValues(
this.direction.v[0],
this.direction.v[1],
this.direction.v[2]
);
vec3.scale(result, result, scale);
vec3.add(result, result, this.origin.v);
}
示例3: distanceSqToPoint
public distanceSqToPoint(point: Vector3) {
vec3.subtract(v1, point.v, this.origin.v);
const directionDistance = vec3.dot(v1, this.direction.v);
// point behind the ray
if (directionDistance < 0) {
return vec3.squaredDistance(this.origin.v, point.v);
}
vec3.copy(v1, this.direction.v);
vec3.scale(v1, v1, directionDistance);
vec3.add(v1, v1, this.origin.v);
return vec3.squaredDistance(v1, point.v);
}
示例4:
outVec3 = vec3.fromValues(1, 2, 3);
outVec3 = vec3.copy(outVec3, vec3A);
outVec3 = vec3.set(outVec3, 1, 2, 3);
outVec3 = vec3.add(outVec3, vec3A, vec3B);
outVec3 = vec3.subtract(outVec3, vec3A, vec3B);
outVec3 = vec3.sub(outVec3, vec3A, vec3B);
outVec3 = vec3.multiply(outVec3, vec3A, vec3B);
outVec3 = vec3.mul(outVec3, vec3A, vec3B);
outVec3 = vec3.divide(outVec3, vec3A, vec3B);
outVec3 = vec3.div(outVec3, vec3A, vec3B);
outVec3 = vec3.ceil(outVec3, vec3A);
outVec3 = vec3.floor(outVec3, vec3A);
outVec3 = vec3.min(outVec3, vec3A, vec3B);
outVec3 = vec3.max(outVec3, vec3A, vec3B);
outVec3 = vec3.round(outVec3, vec3A);
outVec3 = vec3.scale(outVec3, vec3A, 2);
outVec3 = vec3.scaleAndAdd(outVec3, vec3A, vec3B, 0.5);
outVal = vec3.distance(vec3A, vec3B);
outVal = vec3.dist(vec3A, vec3B);
outVal = vec3.squaredDistance(vec3A, vec3B);
outVal = vec3.sqrDist(vec3A, vec3B);
outVal = vec3.length(vec3A);
outVal = vec3.len(vec3A);
outVal = vec3.squaredLength(vec3A);
outVal = vec3.sqrLen(vec3A);
outVec3 = vec3.negate(outVec3, vec3A);
outVec3 = vec3.inverse(outVec3, vec3A);
outVec3 = vec3.normalize(outVec3, vec3A);
outVal = vec3.dot(vec3A, vec3B);
outVec3 = vec3.cross(outVec3, vec3A, vec3B);
outVec3 = vec3.lerp(outVec3, vec3A, vec3B, 0.5);