当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vec3.transformMat4方法代码示例

本文整理汇总了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;
  }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:42,代码来源:Raycaster.ts

示例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);
    }
  }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:36,代码来源:Raycaster.ts

示例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);
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:31,代码来源:gl-matrix-tests.ts

示例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;
 }
开发者ID:kyasbal-1994,项目名称:jThree,代码行数:6,代码来源:PointList.ts

示例5: transform

 transform(mat: Mat4): void {
     vec3.transformMat4(this.min, this.min, mat);
     vec3.transformMat4(this.max, this.max, mat);
 }
开发者ID:rmx,项目名称:encounter,代码行数:4,代码来源:BoundingBox.ts

示例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]);
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:5,代码来源:Sphere.ts


注:本文中的gl-matrix.vec3.transformMat4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。