Three. js source code annotation () Material/SpriteMaterial. js
/*** @ Author alteredq/http://alteredqualia.com/*** parameters = {* color:
, * Opacity:
, * Map: new THREE. Texture (), ** blending: THREE. NormalBlending, * depthTest:
, * DepthWrite:
, ** UvOffset: new THREE. Vector2 (), * uvScale: new THREE. Vector2 (), ** fog:
*} * // The SpriteMaterial method creates the Sprite material type based on the parameters parameter. The format of the parameters parameter is shown above. the SpriteMaterial object function is implemented by defining the constructed function prototype object. most attribute Methods inherit from the Material's base class Material. *////
SpriteMaterial///
Material attribute parameters in JSON format of string type ///
Return SpriteMaterial and click the sprite material.
THREE. spriteMaterial = function (parameters) {THREE. material. call (this); // call the call method of the Material object, and hand over the method originally belonging to the Material to the current object SpriteMaterial to use // defaults default this. color = new THREE. color (0 xffffff); // Color, default Initialization is 0 xffffff, white this. map = null; // normal texture. The default value is nullthis. rotation = 0; // The rotation Angle of the texture of the particle system. think about it. this. fog = false; // fog effect. The default value is true. // TODO: Why does SpriteMaterial have the fog effect attribute, and the default Initialization is true ????????? // Set parameters to set the parameter this. setValues (parameters); // call the setValues method of the Material class and assign the parameter parameters to the attributes of the current SpriteMaterial Material .}; /*************************************** * ************************ the method attribute definition of the SpriteMaterial object is as follows, inherited from Material ************************************* * ***********************/THREE. spriteMaterial. prototype = Object. create (THREE. material. prototype);/* clone method // clone method to clone the SpriteMaterial object ,*////
Clone///
SpriteMaterial object; optional .///
Returns the cloned SpriteMaterial object.
THREE. spriteMaterial. prototype. clone = function () {// copy the attributes of the material one by one. var material = new THREE. spriteMaterial (); THREE. material. prototype. clone. call (this, material); material. color. copy (this. color); material. map = this. map; material. rotation = this. rotation; material. fog = this. fog; return material; // returns the cloned SpriteMaterial object };
Http://www.bkjia.com/kf/201412/365617.html previous