Three. js source code annotation (23) Core/Face3.js

Source: Internet
Author: User

Three. js source code annotation (23) Core/Face3.js

 

Reprinted please keep this sentence: Wuji-this blog focuses on Agile development and mobile and IOT device research: data visualization, GOLANG, Html5, WEBGL, THREE. JS. Otherwise, the post from this blog will not be reprinted or reprinted. Thank you for your cooperation.


I also just started learning. Sorry for the errors in many places.

The following code is a comment on the Core/Face3.js file in the THREE. JS source code file.

More updates in: https://github.com/omni360/three.js.sourcecode


/*** @ Author mrdoob/http://mrdoob.com/* @ author alteredq/http://alteredqualia.com/* // Face3 object constructor. this interface is used to create a triangle object in a 3D space using parameters a, B, c, normal, color, and materialIndex. function functions of Face3 objects are implemented using a function prototype object constructed. //// usage: var a = 0, B = 1, c = 2; var normal = new THREE. vector3 (0, 1, 0); var color = new THREE. color (0xffaa00); var face = new THREE. face3 (a, B, c, normal, color, 0); // create a color 0xffaa00 composed of three points: a, B, and c. The normal point is normal, A triangle object with a material index of 0. //// usage: var a = 0, B = 1, c = 2; var normal1 = new THREE. vector3 (0, 1, 0), normal2 = new THREE. vector3 (0, 1, 0), normal3 = new THREE. vector3 (0, 1, 0); normal = new Array (normal1, normal2, normal3); var color1 = new THREE. color (0xffaa00), color2 = new THREE. color (0x00aaff), color3 = new THREE. color (0x00ffaa); var color = new Array (color1, color2, color3); var face = new THREE. face3 (a, B, c, normal, color, 0); // create a three-point combination of a, B, and c in the color 0xffaa00, 0x00aaff, 0x00ffaa, normal points to normal, and the material index is 0. *////Face3///Index of triangle corner ///Index of triangle Angle Point B ///Index of triangle Angle Point c ///Triangle normal vector, or vertex Normal Vector Array ///Triangle color value or vertex color value array ///Material Index THREE. face3 = function (a, B, c, normal, color, materialIndex) {this. a = a; // The index of triangle Vertex a this. B = B; // The index of triangle vertex B this. c = c; // The index of triangle vertex c this. normal = normal instanceof THREE. vector3? Normal: new THREE. Vector3 (); // normal vector of the triangle surface this. vertexNormals = normal instanceof Array? Normal: []; // the array of triangle vertex normal vectors. this. color = color instanceof THREE. Color? Color: new THREE. Color (); // the color of the triangle. this. vertexColors = color instanceof Array? Color: []; // array of vertex color values on the triangle surface this. vertexTangents = []; // this. materialIndex = materialIndex! = Undefined? MaterialIndex: 0; // triangle Material Index }; /*************************************** * ***** The following are functions provided by Face3 objects. **************************************** /THREE. face3.prototype = {constructor: THREE. face3, // constructor, returns a reference to the Face3 function that created this object/* clone method // clone method to clone a triangle object. *////Clone///
 
  
Returns a triangular area object.
 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; // returns the cloned Triangle Surface object .}};


Wuji (http://blog.csdn.net/omni360)

This article follows the "signature-non-commercial use-consistency" creation public agreement

Reprinted please keep this sentence: Wuji-this blog focuses on Agile development and mobile and IOT device research: data visualization, GOLANG, Html5, WEBGL, THREE. JS. Otherwise, the post from this blog will not be reprinted or reprinted. Thank you for your cooperation.


The following code is a comment on the Core/Face3.js file in the THREE. JS source code file.

More updates in: https://github.com/omni360/three.js.sourcecode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.