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 refuse to 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
/// Return 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 the 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属性,正交投影立方体下端,定义一个范围(正交投影立方体),不计算在范围之外的物体的阴影,Bottom默认是500
this.shadowCameraVisible = false; //shadowCameraVisible设置为true,会在场景中显示灯光的框架,方便调试
this.shadowBias = 0; //阴影贴图的偏移,
this.shadowDarkness = 0.5; //阴影对物体亮度的影响,默认是0.5
this.shadowMapWidth = 512; //阴影贴图宽度,单位像素,默认512
this.shadowMapHeight = 512; //阴影贴图高度,单位像素,默认512
/*对于平行光,WebGL可以使用级联阴影贴图(或成为平行分割阴影贴图)有很好的阴影质量,特别是远距离观看。
级联阴影通过分割可视区域逐步部分变大,并使用相同的大小,在每个阴影贴图。结果是物体接近观看者将比更远的物体获得更多的阴影贴图像素。
对于平行光阴影的质量和性能,阴影的距离是非常重要的。就像阴影级联数,阴影距离可以在质量设置中设置,很容易降低阴影范围,以减少硬件性能消耗。
在阴影距离结束处,阴影将淡出,更远的物体将没有阴影。大多数情况下在场景中更远地方的阴影不会引人注目!*/
this.shadowCascade = false; //阴影级联
this.shadowCascadeOffset = new THREE.Vector3( 0, 0, - 1000 ); //阴影级联偏移距离
this.shadowCascadeCount = 2; //当使用2个阴影级联时,整个阴影距离内,默认被分为两块,靠近观察者较小的块和远处较大的块
this.shadowCascadeBias = [ 0, 0, 0 ]; //阴影级联偏移数组
this.shadowCascadeWidth = [ 512, 512, 512 ]; //阴影级联宽度数组
this.shadowCascadeHeight = [ 512, 512, 512 ]; //阴影级联高度数组
this.shadowCascadeNearZ = [ - 1.000, 0.990, 0.998 ]; //阴影级联近处
this.shadowCascadeFarZ = [ 0.990, 0.998, 1.000 ]; //阴影级联远处
this.shadowCascadeArray = []; //阴影级联数组
//TODO: 下面这些完全没弄明白,以后补上详细的注释
this.shadowMap = null; //指定阴影贴图,WebGLRenderTarget对象,这里好像很复杂,完全没弄明白,以后补上详细的注释.
this.shadowMapSize = null; //阴影图的大小,注意,这里应符合OpenGL中对纹理的要求(2的n次方+2n) 
this.shadowCamera = null; //阴影贴图相机,THREE.PerspectiveCamera对象,
this.shadowMatrix = null; //阴影贴图矩阵
};
/**************************************************************************************
****下面是DirectionalLight对象提供的功能函数定义,一部分通过prototype继承自Light方法
***************************************************************************************/
THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype ); //DirectionalLight对象从THREE.Light的原型继承所有属性方法
/*clone方法
///clone方法克隆DirectionalLight对象
*/
///clone
///返回克隆的DirectionalLight对象 
THREE.DirectionalLight.prototype.clone = function () {
var light = new THREE.DirectionalLight();
THREE.Light.prototype.clone.call( this, light ); //调用THREE.Light.clone方法,克隆平行光对象
//复制当前灯光对象的属性
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=326625659&siteId=291194637