本文整理匯總了TypeScript中gl-matrix.vec3.transformMat4方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript vec3.transformMat4方法的具體用法?TypeScript vec3.transformMat4怎麽用?TypeScript vec3.transformMat4使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gl-matrix.vec3
的用法示例。
在下文中一共展示了vec3.transformMat4方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: intersectObject
public intersectObject(object: Mesh) {
if (!object.visible) return;
let intersect;
let uv;
let face;
// Check sphere
if (object.boundingSphere === undefined) object.computeBoundingSphere();
sphere.copy(object.boundingSphere);
// Apply object modelMatrix, incase object has been transformed
sphere.applyMatrix(object.modelMatrix);
// Exit if the ray doesn't intersect the sphere
if (!this.ray.intersectsSphere(sphere)) {
return;
}
for (const f of object.geometry.faces) {
vec3.copy(fvA.v, f.vertices[0].v);
vec3.copy(fvB.v, f.vertices[1].v);
vec3.copy(fvC.v, f.vertices[2].v);
// Multiply vertices by object matrix
vec3.transformMat4(fvA.v, fvA.v, object.modelMatrix);
vec3.transformMat4(fvB.v, fvB.v, object.modelMatrix);
vec3.transformMat4(fvC.v, fvC.v, object.modelMatrix);
intersect = this.ray.intersectTriangle(fvA, fvB, fvC);
if (intersect) {
// Get uv intersection
vec2.copy(uvA.v, object.geometry.uvs[f.uvs[0]].v);
vec2.copy(uvB.v, object.geometry.uvs[f.uvs[1]].v);
vec2.copy(uvC.v, object.geometry.uvs[f.uvs[2]].v);
face = f;
uv = this.uvIntersection(intersect, fvA, fvB, fvC);
break;
}
}
return intersect ? { point: intersect, uv, face } : null;
}
示例2: setFromCamera
public setFromCamera(
coords: Vector2,
scene: Scene,
camera: PerspectiveCamera,
object: Mesh
) {
if (camera && camera.isPespectiveCamera) {
this.ray.origin.copy(camera.position);
vec3.copy(cameraDirection, [coords.x, coords.y, 0.5]);
mat4.multiply(
inversedProjectionViewMatrix,
camera.projectionMatrix,
camera.worldInverseMatrix
);
mat4.invert(inversedProjectionViewMatrix, inversedProjectionViewMatrix);
vec3.transformMat4(
cameraDirection,
cameraDirection,
inversedProjectionViewMatrix
);
vec3.sub(cameraDirection, cameraDirection, camera.position.v);
vec3.normalize(cameraDirection, cameraDirection);
directionVector.set(
cameraDirection[0],
cameraDirection[1],
cameraDirection[2]
);
this.ray.direction.copy(directionVector);
}
}
示例3:
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);
outVec3 = vec3.transformQuat(outVec3, vec3A, quatA);
outVec3 = vec3.rotateX(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateY(outVec3, vec3A, vec3B, Math.PI);
outVec3 = vec3.rotateZ(outVec3, vec3A, vec3B, Math.PI);
vecArray = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize);
outVal = vec3.angle(vec3A, vec3B);
outStr = vec3.str(vec3A);
outBool = vec3.exactEquals(vec3A, vec3B);
outBool = vec3.equals(vec3A, vec3B);
outVec3 = vec3.add(outVec3, [0, 1, 2], [3, 4, 5]); // test one method with number array input
// vec4
outVec4 = vec4.create();
outVec4 = vec4.clone(vec4A);
outVec4 = vec4.fromValues(1, 2, 3, 4);
示例4: transform
public transform(transformMatrix: Matrix): void {
for (let i = 0; i < this.points.length; i++) {
vec3.transformMat4(this.points[i].rawElements, this.points[i].rawElements, transformMatrix.rawElements);
}
return;
}
示例5: transform
transform(mat: Mat4): void {
vec3.transformMat4(this.min, this.min, mat);
vec3.transformMat4(this.max, this.max, mat);
}
示例6: applyMatrix
public applyMatrix(matrix: mat4) {
vec3.transformMat4(this.center.v, this.center.v, matrix);
const scaling = mat4.getScaling(vec3.create(), matrix);
this.radius *= Math.max(scaling[0], scaling[1], scaling[2]);
}