Three. js source code annotation (fifty-five) Material/SpriteCanvasMaterial. js
/*** @ Author mrdoob/http://mrdoob.com/*** parameters = {* color:
, * Program:
, * Opacity:
, * Blending: THREE. normalBlending *} * // The SpriteCanvasMaterial method creates the Sprite (DOT Sprite) material type for the canvas Renderer Based on the parameter parameters. The format of the parameters parameter is shown above. the SpriteCanvasMaterial object function is implemented by defining the constructed function prototype object. most attribute Methods inherit from the Material's base class Material. /// TODO: Apart from several different attributes, SpriteCanvasMaterial and SpriteMaterial have different application scenarios? *////
SpriteCanvasMaterial///
Material attribute parameters in JSON format of string type ///
Return SpriteCanvasMaterial and click the sprite material.
THREE. spriteCanvasMaterial = 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 SpriteCanvasMaterial to use this. color = new THREE. color (0 xffffff); // Color, default Initialization is 0 xffffff, white this. program = function (context, color) {}; // custom program, // TODO: this. what does the program attribute mean here ??? This. setValues (parameters); // call the setValues method of the Material class and assign the parameter parameters to the attributes of the current SpriteCanvasMaterial Material .}; /*************************************** * ************************ the method attribute definition of the SpriteCanvasMaterial object is as follows, inherited from Material ************************************* * ***********************/THREE. spriteCanvasMaterial. prototype = Object. create (THREE. material. prototype);/* clone method // clone method to clone the SpriteCanvasMaterial object ,*////
Clone///
SpriteCanvasMaterial object; optional .///
Returns the cloned SpriteCanvasMaterial object.
THREE. spriteCanvasMaterial. prototype. clone = function () {// copy the attributes of the material one by one. var material = new THREE. spriteCanvasMaterial (); THREE. material. prototype. clone. call (this, material); material. color. copy (this. color); material. program = this. program; return material; // return the cloned SpriteMaterial object}; // backwards compatibility is backward compatible with the method. spriteCanvasMaterial method replacement. */THREE. particle canvasmaterial = THREE. spriteCanvasMaterial;
Http://www.bkjia.com/kf/201412/365616.html previous