1. 程式人生 > >three.js 原始碼註釋(五十一)Material /MeshDepthMaterial.js

three.js 原始碼註釋(五十一)Material /MeshDepthMaterial.js


俺也是剛開始學,好多地兒肯定不對還請見諒.

以下程式碼是THREE.JS 原始碼檔案中materials/MeshDepthMaterial.js檔案的註釋.


/**
 * @author mrdoob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 *
 * parameters = {
 *  opacity: <float>,
 *
 *  blending: THREE.NormalBlending,
 *  depthTest: <bool>,
 *  depthWrite: <bool>,
 *
 *  wireframe: <boolean>,
 *  wireframeLinewidth: <float>
 * }
 */

/*
///MeshDepthMaterial方法根據引數parameters建立基於相機遠近裁切面自動變換亮度(明暗度)的mesh(網格)的材質型別,離相機越近,材質越亮(白),離相機越遠,材質越暗(黑).
///parameters引數的格式看上面.MeshDepthMaterial物件的功能函式採用,定義構造的函式原型物件來實現.大部分屬性方法繼承自材質的基類Material.
*/
///<summary>MeshDepthMaterial</summary>
///<param name ="parameters" type="String">string型別的JSON格式材質屬性引數</param>
///<returns type="Materialistically">返回MeshDepthMaterial,網格深度材質.</returns>
THREE.MeshDepthMaterial = function ( parameters ) {

	THREE.Material.call( this );	//呼叫Material物件的call方法,將原本屬於Material的方法交給當前物件MeshDepthMaterial來使用.

	this.morphTargets = false;		//定義材質是否設定目標變形動畫,預設為false
	this.wireframe = false;;			//以線框方式渲染幾何體.預設為false
	this.wireframeLinewidth = 1;		//線框的寬度,預設初始化為1.

	this.setValues( parameters );		//呼叫Material類的setValues方法,將引數parameters賦值給當前MeshDepthMaterial材質的屬性.

};

/*************************************************************
****下面是MeshDepthMaterial物件的方法屬性定義,繼承自Material
*************************************************************/
THREE.MeshDepthMaterial.prototype = Object.create( THREE.Material.prototype );

/*clone方法
///clone方法克隆MeshDepthMaterial物件,
*/
///<summary>clone</summary>
///<param name ="material" type="MeshDepthMaterial">MeshDepthMaterial物件,可有可無.</param>
///<returns type="MeshDepthMaterial">返回克隆的MeshDepthMaterial物件</returns>	
THREE.MeshDepthMaterial.prototype.clone = function () {
	//以下是將材質的屬性一一進行復制
	var material = new THREE.MeshDepthMaterial();

	THREE.Material.prototype.clone.call( this, material );

	material.wireframe = this.wireframe;
	material.wireframeLinewidth = this.wireframeLinewidth;

	return material;	//返回克隆的MeshDepthMaterial物件

};



以下程式碼是THREE.JS 原始碼檔案中materials/MeshDepthMaterial.js檔案的註釋.