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


TypeScript vec3.copy方法代码示例

本文整理汇总了TypeScript中gl-matrix.vec3.copy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript vec3.copy方法的具体用法?TypeScript vec3.copy怎么用?TypeScript vec3.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gl-matrix.vec3的用法示例。


在下文中一共展示了vec3.copy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
开发者ID:rmx,项目名称:encounter,代码行数:30,代码来源:MovePath.ts

示例2: 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

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

示例4: distanceSqToPoint

  public distanceSqToPoint(point: Vector3) {
    vec3.subtract(v1, point.v, this.origin.v);
    const directionDistance = vec3.dot(v1, this.direction.v);

    // point behind the ray
    if (directionDistance < 0) {
      return vec3.squaredDistance(this.origin.v, point.v);
    }

    vec3.copy(v1, this.direction.v);
    vec3.scale(v1, v1, directionDistance);
    vec3.add(v1, v1, this.origin.v);

    return vec3.squaredDistance(v1, point.v);
  }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:15,代码来源:Ray.ts

示例5: 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

示例6:

outVec2 = vec2.random(outVec2, 5.0);
outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A);
outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA);
outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A);
outVec2 = vec2.transformMat4(outVec2, vec2A, mat4A);
vecArray = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize);
outStr = vec2.str(vec2A);
outBool = vec2.exactEquals(vec2A, vec2B);
outBool = vec2.equals(vec2A, vec2B);
outVec2 = vec2.add(outVec2, [0, 1], [2, 3]); // test one method with number array input

// vec3
outVec3 = vec3.create();
outVec3 = vec3.clone(vec3A);
outVec3 = vec3.fromValues(1, 2, 3);
outVec3 = vec3.copy(outVec3, vec3A);
outVec3 = vec3.set(outVec3, 1, 2, 3);
outVec3 = vec3.add(outVec3, vec3A, vec3B);
outVec3 = vec3.subtract(outVec3, vec3A, vec3B);
outVec3 = vec3.sub(outVec3, vec3A, vec3B);
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);
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:31,代码来源:gl-matrix-tests.ts

示例7: fromJSON

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

示例8: copy

 public copy(rgb: number[]) {
   vec3.copy(this.v, vec3.fromValues(rgb[0], rgb[1], rgb[2]));
   return this;
 }
开发者ID:davidpaulrosser,项目名称:leonardo,代码行数:4,代码来源:Color.ts


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