1 /**
  2  * @author alteredq / http://alteredqualia.com/
  3  */
  4 
  5 /**@constructor*/
  6 THREE.DepthPassPlugin = function ( ) {
  7 
  8 	this.enabled = false;
  9 	this.renderTarget = null;
 10 
 11 	var _gl,
 12 	_renderer,
 13 	_depthMaterial, _depthMaterialMorph, _depthMaterialSkin, _depthMaterialMorphSkin,
 14 
 15 	_frustum = new THREE.Frustum(),
 16 	_projScreenMatrix = new THREE.Matrix4();
 17 
 18 	this.init = function ( renderer ) {
 19 
 20 		_gl = renderer.context;
 21 		_renderer = renderer;
 22 
 23 		var depthShader = THREE.ShaderLib[ "depthRGBA" ];
 24 		var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );
 25 
 26 		_depthMaterial = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms } );
 27 		_depthMaterialMorph = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms, morphTargets: true } );
 28 		_depthMaterialSkin = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms, skinning: true } );
 29 		_depthMaterialMorphSkin = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms, morphTargets: true, skinning: true } );
 30 
 31 		_depthMaterial._shadowPass = true;
 32 		_depthMaterialMorph._shadowPass = true;
 33 		_depthMaterialSkin._shadowPass = true;
 34 		_depthMaterialMorphSkin._shadowPass = true;
 35 
 36 	};
 37 
 38 	this.render = function ( scene, camera ) {
 39 
 40 		if ( ! this.enabled ) return;
 41 
 42 		this.update( scene, camera );
 43 
 44 	};
 45 
 46 	this.update = function ( scene, camera ) {
 47 
 48 		var i, il, j, jl, n,
 49 
 50 		program, buffer, material,
 51 		webglObject, object, light,
 52 		renderList,
 53 
 54 		fog = null;
 55 
 56 		// set GL state for depth map
 57 
 58 		_gl.clearColor( 1, 1, 1, 1 );
 59 		_gl.disable( _gl.BLEND );
 60 
 61 		_renderer.setDepthTest( true );
 62 
 63 		// update scene
 64 
 65 		if ( _renderer.autoUpdateScene ) scene.updateMatrixWorld();
 66 
 67 		// update camera matrices and frustum
 68 
 69 		if ( ! camera._viewMatrixArray ) camera._viewMatrixArray = new Float32Array( 16 );
 70 		if ( ! camera._projectionMatrixArray ) camera._projectionMatrixArray = new Float32Array( 16 );
 71 
 72 		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 73 
 74 		camera.matrixWorldInverse.flattenToArray( camera._viewMatrixArray );
 75 		camera.projectionMatrix.flattenToArray( camera._projectionMatrixArray );
 76 
 77 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
 78 		_frustum.setFromMatrix( _projScreenMatrix );
 79 
 80 		// render depth map
 81 
 82 		_renderer.setRenderTarget( this.renderTarget );
 83 		_renderer.clear();
 84 
 85 		// set object matrices & frustum culling
 86 
 87 		renderList = scene.__webglObjects;
 88 
 89 		for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
 90 
 91 			webglObject = renderList[ j ];
 92 			object = webglObject.object;
 93 
 94 			webglObject.render = false;
 95 
 96 			if ( object.visible ) {
 97 
 98 				if ( ! ( object instanceof THREE.Mesh || object instanceof THREE.ParticleSystem ) || ! ( object.frustumCulled ) || _frustum.contains( object ) ) {
 99 
100 					object._modelViewMatrix.multiply( camera.matrixWorldInverse, object.matrixWorld );
101 
102 					webglObject.render = true;
103 
104 				}
105 
106 			}
107 
108 		}
109 
110 		// render regular objects
111 
112 		var objectMaterial, useMorphing, useSkinning;
113 
114 		for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
115 
116 			webglObject = renderList[ j ];
117 
118 			if ( webglObject.render ) {
119 
120 				object = webglObject.object;
121 				buffer = webglObject.buffer;
122 
123 				// todo: create proper depth material for particles
124 
125 				if ( object instanceof THREE.ParticleSystem && !object.customDepthMaterial ) continue;
126 
127 				objectMaterial = getObjectMaterial( object );
128 
129 				if ( objectMaterial ) _renderer.setMaterialFaces( object.material );
130 
131 				useMorphing = object.geometry.morphTargets.length > 0 && objectMaterial.morphTargets;
132 				useSkinning = object instanceof THREE.SkinnedMesh && objectMaterial.skinning;
133 
134 				if ( object.customDepthMaterial ) {
135 
136 					material = object.customDepthMaterial;
137 
138 				} else if ( useSkinning ) {
139 
140 					material = useMorphing ? _depthMaterialMorphSkin : _depthMaterialSkin;
141 
142 				} else if ( useMorphing ) {
143 
144 					material = _depthMaterialMorph;
145 
146 				} else {
147 
148 					material = _depthMaterial;
149 
150 				}
151 
152 				if ( buffer instanceof THREE.BufferGeometry ) {
153 
154 					_renderer.renderBufferDirect( camera, scene.__lights, fog, material, buffer, object );
155 
156 				} else {
157 
158 					_renderer.renderBuffer( camera, scene.__lights, fog, material, buffer, object );
159 
160 				}
161 
162 			}
163 
164 		}
165 
166 		// set matrices and render immediate objects
167 
168 		renderList = scene.__webglObjectsImmediate;
169 
170 		for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
171 
172 			webglObject = renderList[ j ];
173 			object = webglObject.object;
174 
175 			if ( object.visible ) {
176 
177 				object._modelViewMatrix.multiply( camera.matrixWorldInverse, object.matrixWorld );
178 
179 				_renderer.renderImmediateObject( camera, scene.__lights, fog, _depthMaterial, object );
180 
181 			}
182 
183 		}
184 
185 		// restore GL state
186 
187 		var clearColor = _renderer.getClearColor(),
188 		clearAlpha = _renderer.getClearAlpha();
189 
190 		_gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha );
191 		_gl.enable( _gl.BLEND );
192 
193 	};
194 
195 	// For the moment just ignore objects that have multiple materials with different animation methods
196 	// Only the first material will be taken into account for deciding which depth material to use
197 
198 	function getObjectMaterial( object ) {
199 
200 		return object.material instanceof THREE.MeshFaceMaterial
201 			? object.material.materials[ 0 ]
202 			: object.material;
203 
204 	};
205 
206 };
207 
208 

nike free rn new balance hombre baratas cinturones gucci ugg rebajas cinturon gucci ray ban baratas nike cortez peuterey mujer christian louboutin madrid mbt zapatos gafas ray ban baratas mbt ofertas air max blancas mbt barcelona nike air max 90 woolrich barcelona nike mujer botas ugg gafas de sol carrera aratas air max 2016 baratas oakley baratas nike air max 2016

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea