Three.js Source Note (66) objects/sprite.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 objects/sprite.js file in the three.js source file.

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

/** * @author Mikael emtinger/http://gomo.se/* @author alteredq/http://alteredqualia.com/*//*///sprite object, point sprite object, corresponding particle pair Like, the specific implementation is to create a plane that is always facing the camera through buffergeometry.//usage: var map = three. Imageutils.loadtexture ("Sprite.png");//Load Image Object///var material = new three. Spritematerial ({map:map,color:0xffffff,fog:true});//Create material object, there is a material object specifically for the Sprite object spritematerial.///var sprite = New three. Sprite (material);//Create Sprite object.//Scene.add (line); Add sprites to the scene. *////<summary>sprite</summary>///<param name = "Material" type= "three. Spritematerial "> Optional parameter, spritematerial object (material object dedicated to point Sprite object) </param>///<returns type=" Sprite "> Return Sprite Object </returns>three. Sprite = (function () {var vertices = new Float32array ([-0.5,-0.5, 0, 0.5,-0.5, 0, 0.5, 0.5, 0]); var geometry = New three. Buffergeometry ();//Use Buffergeometry object Geometry.addattribute (' position ', new three. Bufferattribute (vertices, 3));//Add the Position property to the Geometry object. Here you can see the source comment for the Buffergeometry object. Return function (material) { Three. ObjEct3d.call (this);//Call method of the Object3d object is called, the method that originally belongs to Object3d is handed to the current object sprite for use. This.geometry = Geometry;this.material = ( Material!== undefined)? Material:new three. Spritematerial ();};} ) ();/***************************************************** The following is a method property definition for a Sprite object, inherited from object3d********************** /three. Sprite.prototype = Object.create (three. Object3d.prototype); The/*///raycast method is used to obtain the intersection of the current object and the ray (parameter raycaster). Raycaster.intersectobject calls this method. Mainly used for collision detection,///When selecting objects in the scene, it is often used to determine whether the current mouse is coincident with the object to select the object.///Note:raycast method The parameter intersects parameter is used to store the collection of intersections, in the following format:// Intersects.push ({//////distance:distance,///point:this.position,///face:null,///object:this//////});///*//// <summary>raycast</summary>///<param name = "Raycaster" type= "three. Raycaster "> Ray object </param>///<param name =" intersects "type=" Objectarray "> Intersection of Attribute Collection </param>/// <returns type= the attribute collection </returns>three for the "Objectarray" > Intersection. Sprite.prototype.raycast = (function () {var matrixposition = nEW three. Vector3 (); return function (Raycaster, intersects) {matrixposition.setfrommatrixposition (this.matrixworld); var Distance = Raycaster.ray.distanceToPoint (matrixposition); if (Distance > this.scale.x) {return;} Intersects.push ({distance:distance,point:this.position,face:null,object:this});};} ()); The/*updatematrix method///updatematrix method updates the translation, rotation, and scaling properties of the current sprite in the scene. *////<summary>updatematrix</summary>/// <returns type= "Skeleton" > returns the new Sprite object. </returns>three. Sprite.prototype.updateMatrix = function () {this.matrix.compose (this.position, this.quaternion, This.scale);// The Compose method applies the translation, rotation, and scaling settings of the transformation matrix This.matrixworldneedsupdate = True;//sprite Object Matrixworldneedsupdate property, set to true.};/ *clone method///clone method clones a Sprite object. *////<summary>clone</summary>///<param name = "Object" Type= " Sprite > Receive cloned Sprite object </param>///<returns type= "Sprite" > returns the cloned Sprite object. </returns>three. Sprite.prototype.clone = function (object) {if (object = = = undefined) Object = new Three. Sprite (this.material); Three. Object3D.prototype.clone.call (This, object), return object;//returns the cloned Sprite object};//backwards compatibility backwards compatible, The particle was renamed as a sprite. Three. particle = three. Sprite;



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 objects/sprite.js file in the three.js source file.

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

Three.js Source Note (66) objects/sprite.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.