本文整理汇总了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]);
}