Three. js source code annotation () objects/Sprite. js, three. jssprite. js
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.
I also just started learning. Sorry for the errors in many places.
The following code is a comment on the objects/Sprite. JS file in the THREE. js source code file.
More updates in: https://github.com/omni360/three.js.sourcecode
/*** @ Author mikael emtinger/http://gomo.se/* @ author alteredq/http://alteredqualia.com/* // Sprite object, vertex genie object, corresponding particle object, 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 the image object // var material = new THREE. spriteMaterial ({map: map, color: 0 xffffff, fog: true}); // create a material object. Here there is a material object SpriteMaterial that applies to Sprite objects. /// var sprite = new THREE. sprite (material); // Create a genie object. /// scene. add (line); // add the genie to the scene. * //// <summary> Sprite </summary> /// <param name = "material" type = "THREE. spriteMaterial "> (optional) SpriteMaterial object) </param> /// <returns type = "Sprite"> the Sprite object </returns> THREE is returned. 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 the buffergeometry object geometry. AddAttribute ('position', new THREE. bufferAttribute (vertices, 3); // Add the position attribute to the geometry object. here you can see the source code comment of the BufferGeometry object. return function (material) {THREE. object3D. call (this); // call the call method of the Object3D object and hand over the method originally belonging to Object3D to the current object Sprite for use. this. geometry = geometry; this. material = (material! = Undefined )? Material: new THREE. spriteMaterial ();};})(); /*************************************** * ************ the method attribute definition of the Sprite object is as follows, 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 (raycaster parameter. raycaster. intersectObject calls this method. It is mainly used for collision detection. // It is often used when you select an object in a scenario. It is used to determine whether the current mouse matches the object and select an object. /// NOTE: The intersects parameter in the raycast method is used to store the set of intersections. The format is as follows: // 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 "> set of intersection attributes </param> /// <returns type = "ObjectArray"> set of intersection attributes </returns> THREE. 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 });};}()); /* updateMatrix method // updateMatrix method updates the pan, rotate, and zoom attributes of the current genie in the scenario. * //// <summary> updateMatrix </summary> // <returns type = "Skeleton"> returns a 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; // set the attribute of the Sprite object matrixWorldNeedsUpdate to true .}; /* clone method // clone method to clone a Sprite object. * //// <summary> clone </summary> /// <param name = "object" type = "Sprite"> receives the cloned Sprite object </param> // /<returns type = "Sprite"> the cloned Sprite object is returned. </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; // return the cloned Sprite object}; // Backwards compatibility is backward compatible, and the particle is renamed as a Sprite. THREE. particle = THREE. sprite;
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 objects/Sprite. JS file in the THREE. js source code file.
More updates in: https://github.com/omni360/three.js.sourcecode