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

What is the Three.Face3 in viewer.impl.hitTestViewport returned object?

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

这是一个例子:

代表什么?

我不能马上回答这个问题。但是我可以肯定地说的是如何在观察器中实现光线追踪,即如何定义要发射的光线以及如何在Forge模型中确定与它相交的three.js个对象。 GitHub:

上的 ForgeFader 项目演示了这一点

https://github.com/jeremytammik/forgefader

只需查看 three.js viewer implementation 中的源代码,第 #8228 行。

// 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 文档:

Triangular face used in Geometry. These are created automatically for all standard geometry types, however if you are building a custom geometry you will have to create them manually.