Three. js source code annotation (fifty-eight) Material/RawShaderMaterial. js
/*** @ Author mrdoob/http://mrdoob.com/* // RawShaderMaterial method creates a material type for the custom shader according to the parameter parameters, such a material object allows users to expand the material type, with unlimited possibilities. this class works in the same way as ShaderMaterial //. Except for custom uniforms and attribute attributes, they are not automatically appended to the GLSL shader code. /// the format of the parameters parameter is shown above. the ShaderMaterial object function is implemented by defining the constructed function prototype object. most attribute Methods inherit from the base class ShaderMaterial of the material. ///// Example: // var material = new THREE. rawShaderMaterial ({// uniforms: {// time: {type: f, value: new THREE. vector2 ()} //}, // vertexShader: document. getElementById ('vertexshader '). textContent, // fragmentShader: document. getElementById ('fragmentshader '). textContent ///});///*////RawShaderMaterial///Material attribute parameters in JSON format of string type ///
Returns RawShaderMaterial to create a material type for the custom shader.
THREE. rawShaderMaterial = function (parameters) {THREE. shaderMaterial. call (this, parameters); // call the call method of the ShaderMaterial object, and hand over the method originally belonging to the ShaderMaterial to the current object for use .}; /*************************************** * ************************ the method attribute definition of RawShaderMaterial object is as follows, inherited from ShaderMaterial ************************************* * ***********************/THREE. rawShaderMaterial. prototype = Object. create (THREE. shaderMaterial. prototype);/* clone method // clone method: clone RawShaderMaterial object ,*////Clone///RawShaderMaterial object; optional .///
Returns the cloned RawShaderMaterial object.
THREE. rawShaderMaterial. prototype. clone = function () {// copy the attributes of the material one by one var material = new THREE. rawShaderMaterial (); THREE. shaderMaterial. prototype. clone. call (this, material); return material; // returns the cloned RawShaderMaterial object}; previous http://www.bkjia.com/kf/201412/365624.html