three.js code comments

Please keep this sentence for reprinting: Business Domain Boundless - This blog focuses on agile development and research on mobile and IoT devices: data visualization, GOLANG, html5 , WEBGL, THREE.JS, otherwise, articles from this blog will not be reprinted or reprinted. Thank you for your cooperation.

I'm just starting to learn, so I'm sure I'm wrong in many places, please forgive me.

The following code is a comment to the Light/DirectionalLight.js file in the THREE.JS source file.

/**
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
*/
/*
///DirectionalLight method is created according to the color attribute color and intensity attribute of the set light Parallel light source.
///The functional function of the DirectionalLight object is implemented by the function prototype object defined and constructed.
/// NOTE: SpotLight type lights implement shadows, but you need to use MeshLambertMaterial or MeshPhongMaterial in the scene
/// The following comments are directly Excerpted from: http://www.cnblogs.com/yiyezhai/archive/2012/12/24/2829991.html
/// Example:
/// var light = new THREE.SpotLight(0xff0000,1,100,Math.PI/ 2,5); //Create a light object
/// light.position.set(50,50,30); //Set position
/// light.castShadow = true; //Enable shadows
/// light.shadowMapWidth = 1024; //The shadow map width is set to 1024 pixels
/// light.shadowMapHeight = 1024; //The shadow map height is set to 1024 pixels
/
_
_ /Shadow frustum area fov property
/// scene.add(lignt); //Add scene
*/
///DirectionalLight
///Light color property
///Light intensity, default is 1
/// Returns DirectionalLight, parallel light source.
THREE.DirectionalLight = function ( color, intensity ) {
THREE.Light.call( this, color ); //Call the call method of the Light object, and pass the method originally belonging to Light to the current object DirectionalLight Use.
this.position.set( 0, 1, 0 ); //The position property of the light is initialized to, 0,1,0
this.target = new THREE.Object3D(); //Create a target point object, the target point The object is an Object3D object.
this.intensity = ( intensity !== undefined ) ? intensity : 1; //The color property of the light, if not specified, is initialized to 1. (The density of light, the default is 1. Because the three of RGB Each value is between 0 and 255, which cannot reflect the change of the intensity of the light. The stronger the light, the brighter the surface of the object.)
this.castShadow = false; //Boolean value, the default is false, if set to true, for all surfaces, it will calculate whether it is occluded in the lighting direction on a pixel-by-pixel basis, which consumes a lot of calculations.
this.onlyShadow = false; //Boolean, controls whether to only generate shadows without "illuminating" the object, the default is false. There may be some special applications for this model.
//
this.shadowCameraNear = 50; //shadowCameraNear property, the near end of the orthogonal projection cube, defines a range (orthogonal projection cube), does not calculate the shadow of objects outside the range, the default near is 50
this.shadowCameraFar = 5000 ; //shadowCameraFar property, the far end of the orthogonal projection cube, defines a range (orthogonal projection cube), does not calculate the shadow of objects outside the range, far defaults to 5000
this.shadowCameraLeft = - 500; //shadowCameraLeft property, The left end of the orthogonal projection cube, defines a range (orthogonal projection cube), does not calculate the shadow of objects outside the range, the default left is 500
this.shadowCameraRight = 500; //shadowCameraRight property, the right end of the orthogonal projection cube, defines a Range (orthogonal projection cube), do not calculate the shadow of objects outside the range, right defaults to 500
this.shadowCameraTop = 500; //shadowCameraTop property, the upper end of the orthographic projection cube, defines a range (orthogonal projection cube), Do not calculate the shadow of objects outside the range, top defaults to 500
this.shadowCameraBottom = - 500; //shadowCameraBottom property, the lower end of the orthogonal projection cube, defines a range (orthogonal projection cube), does not calculate the shadow of objects outside the range, Bottom defaults to 500
this.shadowCameraVisible = false; / /shadowCameraVisible is set to true, the frame of the light will be displayed in the scene, which is convenient for debugging
this.shadowBias = 0; //The offset of the shadow map,
this.shadowDarkness = 0.5; //The influence of shadows on the brightness of objects, the default is 0.5
this .shadowMapWidth = 512; // Shadow map width, unit pixel, default 512
this.shadowMapHeight = 512; // Shadow map height, unit pixel, default 512
/* For parallel light, WebGL can use cascaded shadow maps (or become parallel Split Shadow Map) has good shadow quality, especially when viewed from a distance.
Cascaded shadows are progressively larger by dividing the visible area and use the same size in each shadow map. The result is that objects close to the viewer will get more shadow map pixels than objects further away.
Shadow distance is very important for the quality and performance of directional light shadows. Like the number of shadow cascades, the shadow distance can be set in the quality settings, and it is easy to lower the shadow range to reduce hardware performance costs.
At the end of the shadow distance, the shadow will fade out and objects further away will have no shadow. Most of the time the shadows farther in the scene are not noticeable! */
this.shadowCascade = false; // shadow cascade
this.shadowCascadeOffset = new THREE.Vector3( 0, 0, - 1000 ); //Shadow cascade offset distance
this.shadowCascadeCount = 2; //When using 2 shadow cascades, the entire shadow distance is divided by default Two blocks, the smaller block near the viewer and the larger block far away
this.shadowCascadeBias = [ 0, 0, 0 ]; // shadow cascade offset array
this.shadowCascadeWidth = [ 512, 512, 512 ]; // shadow cascade width array
this.shadowCascadeHeight = [ 512, 512, 512 ]; // shadow cascade height array
this.shadowCascadeNearZ = [ - 1.000, 0.990, 0.998 ]; // shadow cascade near
this.shadowCascadeFarZ = [ 0.990, 0.998, 1.000 ]; //Shadow cascade far away
this.shadowCascadeArray = []; //Shadow cascade array
//TODO: I don't understand the following at all, I will add detailed comments
later this.shadowMap = null ; //Specify the shadow map, WebGLRenderTarget object, it seems very complicated here, I don't understand it at all, I will add detailed comments later.
this.shadowMapSize = null; //The size of the shadow map, note that this should be consistent with the texture in OpenGL Requirement (2 n power + 2n) 
this.shadowCamera = null; //shadow map camera, THREE.PerspectiveCamera object,
this.shadowMatrix = null; //shadow map matrix
};
/************************************ ****************************************************
****The following is the function definition provided by the DirectionalLight object, part of which is inherited from the Light method through the prototype
**************************** **************************************************** ********/
THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype ); //DirectionalLight object inherits all property methods from the prototype of THREE.Light
/*clone method
///clone method clone DirectionalLight object
*/
///clone
///Return the cloned DirectionalLight object 
THREE.DirectionalLight.prototype.clone = function () {
var light = new THREE.DirectionalLight();
THREE.Light.prototype.clone.call( this, light ); //Call the THREE.Light.clone method to clone the parallel light object
//Copy the properties of the current light object
light.target = this.target.clone();
light.intensity = this.intensity;
light.castShadow = this.castShadow;
light.onlyShadow = this.onlyShadow;
//
light.shadowCameraNear = this.shadowCameraNear;
light.shadowCameraFar = this.shadowCameraFar;
light.shadowCameraLeft = this.shadowCameraLeft;
light.shadowCameraRight = this.shadowCameraRight;
light.shadowCameraTop = this.shadowCameraTop;
light.shadowCameraBottom = this.shadowCameraBottom;
light.shadowCameraVisible = this.shadowCameraVisible;
light.shadowBias = this.shadowBias;
light.shadowDarkness = this.shadowDarkness;
light.shadowMapWidth = this.shadowMapWidth;
light.shadowMapHeight = this.shadowMapHeight;
//
light.shadowCascade = this.shadowCascade;
light.shadowCascadeOffset.copy( this.shadowCascadeOffset );
light.shadowCascadeCount = this.shadowCascadeCount;
light.shadowCascadeBias = this.shadowCascadeBias.slice( 0 );
light.shadowCascadeWidth = this.shadowCascadeWidth.slice( 0 );
light.shadowCascadeHeight = this.shadowCascadeHeight.slice( 0 );
light.shadowCascadeNearZ = this.shadowCascadeNearZ.slice( 0 );
light.shadowCascadeFarZ = this.shadowCascadeFarZ.slice( 0 );
return light; //返回克隆的平行光的对象
};

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326625572&siteId=291194637