當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vec2.copy方法代碼示例

本文整理匯總了TypeScript中gl-matrix.vec2.copy方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript vec2.copy方法的具體用法?TypeScript vec2.copy怎麽用?TypeScript vec2.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gl-matrix.vec2的用法示例。


在下文中一共展示了vec2.copy方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: fromArray

 public fromArray(values: number[]) {
   return vec2.copy(this.v, values);
 }
開發者ID:davidpaulrosser,項目名稱:leonardo,代碼行數:3,代碼來源:Vector2.ts

示例3: copy

 public copy(vector2: Vector2) {
   vec2.copy(this.v, vector2.v);
   return this;
 }
開發者ID:davidpaulrosser,項目名稱:leonardo,代碼行數:4,代碼來源:Vector2.ts

示例4:

let outMat2 = mat2.create();
let outMat2d = mat2d.create();
let outMat3 = mat3.create();
let outMat4 = mat4.create();
let outQuat = quat.create();

let outMat2Null: mat2 | null;
let outMat2dNull: mat2d | null;
let outMat3Null: mat3 | null;
let outMat4Null: mat4 | null;

// vec2
outVec2 = vec2.create();
outVec2 = vec2.clone(vec2A);
outVec2 = vec2.fromValues(1, 2);
outVec2 = vec2.copy(outVec2, vec2A);
outVec2 = vec2.set(outVec2, 1, 2);
outVec2 = vec2.add(outVec2, vec2A, vec2B);
outVec2 = vec2.subtract(outVec2, vec2A, vec2B);
outVec2 = vec2.sub(outVec2, vec2A, vec2B);
outVec2 = vec2.multiply(outVec2, vec2A, vec2B);
outVec2 = vec2.mul(outVec2, vec2A, vec2B);
outVec2 = vec2.divide(outVec2, vec2A, vec2B);
outVec2 = vec2.div(outVec2, vec2A, vec2B);
outVec2 = vec2.ceil(outVec2, vec2A);
outVec2 = vec2.floor(outVec2, vec2A);
outVec2 = vec2.min(outVec2, vec2A, vec2B);
outVec2 = vec2.max(outVec2, vec2A, vec2B);
outVec2 = vec2.round(outVec2, vec2A);
outVec2 = vec2.scale(outVec2, vec2A, 2);
outVec2 = vec2.scaleAndAdd(outVec2, vec2A, vec2B, 0.5);
開發者ID:DenisCarriere,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:gl-matrix-tests.ts


注:本文中的gl-matrix.vec2.copy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。