本文整理汇总了TypeScript中gl-matrix.vec3.length方法的典型用法代码示例。如果您正苦于以下问题:TypeScript vec3.length方法的具体用法?TypeScript vec3.length怎么用?TypeScript vec3.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl-matrix.vec3
的用法示例。
在下文中一共展示了vec3.length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: needRecomputeMovePath
private needRecomputeMovePath(): boolean {
var terrain = lookupEntity<Terrain>(this.state, this.target.terrainId)
, tpos = getWorldCoordinates(terrain, this.target.terrainPosition)
, fpos = finalPosition(this.owner)
, distance = Math.abs(vec3.length(vec3.subtract(vec3.create(), tpos, fpos)))
, diff = distance - (this.distance + this.target.boundingRadius);
return 0.1 < diff;
function finalPosition(entity: WorldObject): Vec3 {
if (entity.movePath) {
return entity.movePath.finalPosition;
} else {
return getWorldCoordinates(terrain, entity.terrainPosition);
}
}
}
示例3: constructor
constructor(
readonly type: BoneType,
readonly basis: Triple<vec3>,
readonly prevJoint: vec3,
readonly nextJoint: vec3,
readonly width: number
) {
const difference = vec3.subtract(vec3.create(), this.nextJoint, this.prevJoint);
this.length = vec3.length(difference);
this.basisMatrix = mat3.fromValues(
this.basis[0][0], this.basis[0][1], this.basis[0][2],
this.basis[1][0], this.basis[1][1], this.basis[1][2],
this.basis[2][0], this.basis[2][1], this.basis[2][2]
);
this.left = mat3.determinant(this.basisMatrix) < 0;
this.center = vec3.lerp(vec3.create(), this.prevJoint, this.nextJoint, 0.5);
this.direction = Bone.createBoneDirection(this.basisMatrix);
this.matrix = Bone.createBoneMatrix(this.basisMatrix, this.center, this.left);
}
示例4:
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);
outVec3 = vec3.hermite(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.bezier(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5);
outVec3 = vec3.random(outVec3);
outVec3 = vec3.random(outVec3, 5.0);
outVec3 = vec3.transformMat3(outVec3, vec3A, mat3A);
outVec3 = vec3.transformMat4(outVec3, vec3A, mat4A);
示例5: diameter
diameter(): number {
return vec3.length(this.diagonal());
}