本文整理匯總了TypeScript中gl-matrix.vec3類的典型用法代碼示例。如果您正苦於以下問題:TypeScript vec3類的具體用法?TypeScript vec3怎麽用?TypeScript vec3使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了vec3類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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);
}
示例2: constructor
protected constructor(
data: PointableData
) {
this.direction = vec3.fromValues(...data.direction);
this.handId = data.handId;
this.id = data.id;
this.length = data.length;
this.stabilizedTipPosition = vec3.fromValues(...data.stabilizedTipPosition);
this.timeVisible = data.timeVisible;
this.tipPosition = vec3.fromValues(...data.tipPosition);
this.tipVelocity = vec3.fromValues(...data.tipVelocity);
this.touchDistance = data.touchDistance;
this.touchZone = data.touchZone || 'none';
this.width = data.width;
}
示例3: denormalizePoint
denormalizePoint(normalizedPosition: [ number, number, number ]): vec3 {
return vec3.fromValues(
(normalizedPosition[0] - 0.5) * this.size[0] + this.center[0],
(normalizedPosition[1] - 0.5) * this.size[1] + this.center[1],
(normalizedPosition[2] - 0.5) * this.size[2] + this.center[2]
);
}
示例4: createBoneDirection
static createBoneDirection(basis: mat3): vec3 {
return vec3.fromValues(
basis[6] * -1,
basis[7] * -1,
basis[8] * -1
);
}
示例5: angleAxis
/**
* Calculate the rotation quaternion represented as pair of angle and axis.
*/
public static angleAxis(angle: number, axis: Vector3): Quaternion {
const axisVec = vec3.create();
axisVec[0] = axis.X;
axisVec[1] = axis.Y;
axisVec[2] = axis.Z;
const newQuat = quat.create();
return new Quaternion(quat.setAxisAngle(newQuat, axisVec, +angle));
}
示例6: 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);
}
}
}
示例7: hexStringToRgb
public hexStringToRgb(hex: string) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result
? vec3.fromValues(
parseInt(result[1], 16),
parseInt(result[2], 16),
parseInt(result[3], 16)
)
: null;
}
示例8: 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);
}
示例9: convert
public convert(hex: string | number) {
let rgb;
if (typeof hex === 'number') {
rgb = this.hexIntToRgb(hex);
}
if (typeof hex === 'string') {
rgb = this.hexStringToRgb(hex);
}
vec3.copy(this.v, this.normalize(rgb));
return this;
}
示例10: constructor
private constructor(
data: HandData
) {
this.armBasis = data.armBasis.map(basis => vec3.fromValues(...basis)) as Triple<vec3>;
this.armWidth = data.armWidth;
this.confidence = data.confidence;
this.direction = vec3.fromValues(...data.direction);
this.elbow = vec3.fromValues(...data.elbow);
this.grabStrength = data.grabStrength;
this.id = data.id;
this.palmNormal = vec3.fromValues(...data.palmNormal);
this.palmPosition = vec3.fromValues(...data.palmPosition);
this.palmVelocity = vec3.fromValues(...data.palmVelocity);
this.palmWidth = data.palmWidth;
this.pinchStrength = data.pinchStrength;
this.r = mat3.fromValues(
data.r[0][0], data.r[0][1], data.r[0][2],
data.r[1][0], data.r[1][1], data.r[1][2],
data.r[2][0], data.r[2][1], data.r[2][2]
);
this.s = data.s;
this.sphereCenter = vec3.fromValues(...data.sphereCenter);
this.sphereRadius = data.sphereRadius;
this.stabilizedPalmPosition = vec3.fromValues(...data.stabilizedPalmPosition);
this.t = vec3.fromValues(...data.t);
this.timeVisible = data.timeVisible;
this.type = data.type;
this.wrist = vec3.fromValues(...data.wrist);
this.pointables = [];
this.fingers = {};
this.arm = new Bone(
BoneType.arm,
this.armBasis,
this.elbow,
this.wrist,
this.armWidth
);
this.pitch = Math.atan2(this.direction[1], -this.direction[2]);
this.yaw = Math.atan2(this.direction[0], -this.direction[2]);
this.roll = Math.atan2(this.palmNormal[0], -this.palmNormal[1]);
}