Three.js Source Note (72) Extras/geometries/planegeometry.js

Source: Internet
Author: User

Commercial Territory (http://blog.csdn.net/omni360/)

This article follows "Attribution-non-commercial use-consistent" authoring public agreement

Reprint Please keep this sentence: Business Domain-this blog focuses on Agile development and mobile and IoT device research: Data visualization, Golang, HTML5, WEBGL, three. JS, Otherwise, from this blog article refused to reprint or reprint, thank you for your cooperation.


I was just beginning to learn, a lot of things are definitely wrong and please forgive me.

The following code is a comment for the extras/geometries/planegeometry.js file in the three.js source file.

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

/** * @author mrdoob/http://mrdoob.com/* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/ Papervision3d/objects/primitives/plane.as *//*///planegeometry is used to create a planar object within a three-dimensional space.//////usage: var geometry = new three. Planegeometry (5,5,20,32);///var material = new three. Meshbasicmaterial ({color:0x00ff00});///var plane = new three. Mesh (geometry,material);///Scene.add (plane); *////<summary>planegeometry</summary>///<param name = Height of "width" type= "float" > Plane </param>///<param name = "height" type= "float" > Flat width </param>///< param name = "widthsegments" type= "int" > The number of segments in the wide direction of the object </param>///<param name = "Heightsegments" type= "int" > The high-direction subdivision segment number of the object </param>three. Planegeometry = function (width, height, widthsegments, heightsegments) {three. Geometry.call (this); this.parameters = {width:width,//The height of the plane height:height,//the width of the plane widthsegments:widthsegments,// The number of segment segments in the wide direction of the object heightsegments:heightsegments//the high-direction subdivision segment number of the object};//height, half the width, set the Planar objectThe drop point, which is the center point. Var ix, Iz;var width_half = Width/2;var Height_half = Height/2;var GridX = widthsegments | | 1;var Gridz = heightsegments | | 1;var gridX1 = GridX + 1;var gridZ1 = Gridz + 1;var segment_width = Width/gridx;var Segment_height = Height/gridz;var normal = new three. Vector3 (0, 0, 1);//Set the normal direction.//The following two algorithms calculate all vertices first, triangle face, UV index order, for (iz = 0; iz < gridZ1; iz + +) {var y = iz * segment_he Ight-height_half;for (ix = 0; ix < gridX1; IX + +) {var x = IX * Segment_width-width_half;this.vertices.push (NEW Three. Vector3 (x,-y, 0));}}  for (iz = 0; iz < Gridz, iz + +) {for (ix = 0; ix < GridX; IX + +) {var a = IX + gridX1 * Iz;var B = ix + gridX1 * (iz + 1); var C = (ix + 1) + gridX1 * (iz + 1); var d = (ix + 1) + gridX1 * Iz;var UVA = new three. Vector2 (Ix/gridx, 1-iz/gridz); var UVB = new three. Vector2 (IX/GRIDX, 1-(iz + 1)/Gridz), var UVC = new three. Vector2 ((ix + 1)/GridX, 1-(iz + 1)/Gridz), var uvd = new three. Vector2 ((ix + 1)/GridX, 1-iz/gridz); var face = new three. Face3 (A, B, d); Face.normal.copy (normal), Face.vertexNormals.push (Normal.clone (), Normal.clone (), Normal.clone ()); This.faces.push (face), this.facevertexuvs[0].push ([UVA, UVB, UVD]) and face = new three. Face3 (b, C, D); Face.normal.copy (normal), Face.vertexNormals.push (Normal.clone (), Normal.clone (), Normal.clone ()); This.faces.push (face), this.facevertexuvs[0].push ([Uvb.clone (), UVC, Uvd.clone ()]);}}};/ The following is a method property definition for the Planegeometry object, inherited from the Geometry object. ***************** /three. Planegeometry.prototype = Object.create (three. Geometry.prototype);



Commercial Territory (http://blog.csdn.net/omni360/)

This article follows "Attribution-non-commercial use-consistent" authoring public agreement

Reprint Please keep this sentence: Business Domain-this blog focuses on Agile development and mobile and IoT device research: Data visualization, Golang, HTML5, WEBGL, three. JS, Otherwise, from this blog article refused to reprint or reprint, thank you for your cooperation.


The following code is a comment for the extras/geometries/planegeometry.js file in the three.js source file.

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

Three.js Source Note (72) Extras/geometries/planegeometry.js

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.