viewer.impl.hitTestViewport返回的对象中的Three.Face3是什么?

时间:2017-04-26 12:11:16

标签: autodesk autodesk-forge autodesk-viewer

viewer.impl.hitTestViewport()返回的对象中的Three.face是什么?

以下是一个例子:

enter image description here

它代表什么?

2 个答案:

答案 0 :(得分:0)

我不能回答那个副手。然而,我可以肯定地说,如何在观察器中实现光线跟踪,即如何定义要拍摄的光线以及如何确定Forge模型中与之相交的三个物体。 GitHub上的ForgeFader项目证明了这一点:

https://github.com/jeremytammik/forgefader

答案 1 :(得分:0)

只需查看第{8228行three.js viewer implementation中的源代码即可。

// File:src/core/Face3.js

  /**
   * @author mrdoob / http://mrdoob.com/
   * @author alteredq / http://alteredqualia.com/
   */

  THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {

    this.a = a;
    this.b = b;
    this.c = c;

    this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
    this.vertexNormals = normal instanceof Array ? normal : [];

    this.color = color instanceof THREE.Color ? color : new THREE.Color();
    this.vertexColors = color instanceof Array ? color : [];

    this.vertexTangents = [];

    this.materialIndex = materialIndex !== undefined ? materialIndex : 0;

  };

  THREE.Face3.prototype = {

    constructor: THREE.Face3,

    clone: function () {

      var face = new THREE.Face3( this.a, this.b, this.c );

      face.normal.copy( this.normal );
      face.color.copy( this.color );

      face.materialIndex = this.materialIndex;

      for ( var i = 0, il = this.vertexNormals.length; i < il; i ++ ) {

        face.vertexNormals[ i ] = this.vertexNormals[ i ].clone();

      }

      for ( var i = 0, il = this.vertexColors.length; i < il; i ++ ) {

        face.vertexColors[ i ] = this.vertexColors[ i ].clone();

      }

      for ( var i = 0, il = this.vertexTangents.length; i < il; i ++ ) {

        face.vertexTangents[ i ] = this.vertexTangents[ i ].clone();

      }

      return face;

    }

  };

另请查看three.js Face3文档:

  

几何中使用的三角形面。这些是为所有标准几何类型自动创建的,但是如果要构建自定义几何体,则必须手动创建它们。