Преглед изворни кода

ShadowMaterial: Added parameters

Mugen87 пре 8 година
родитељ
комит
201e1db070

+ 7 - 3
docs/api/materials/ShadowMaterial.html

@@ -13,11 +13,11 @@
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
 		<div class="desc">
 		<div class="desc">
-		This material can recieve shadows, but otherwise is completely transparent.
+		This material can receive shadows, but otherwise is completely transparent.
 		</div>
 		</div>
 
 
 		<h3>Example</h3>
 		<h3>Example</h3>
-		[example:webgl_geometry_spline_editor gemoetry / spline / editor]
+		[example:webgl_geometry_spline_editor geometry / spline / editor]
 
 
 		<code>
 		<code>
 var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 );
 var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 );
@@ -34,7 +34,11 @@ scene.add( plane );
 
 
 		<h2>Constructor</h2>
 		<h2>Constructor</h2>
 
 
-		<h3>[name]( )</h3>
+		<h3>[name]( [page:Object parameters] )</h3>
+		<div>
+			[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance.
+			Any property of the material (including any property inherited from [page:Material] and [page:ShaderMaterial]) can be passed in here.<br /><br />
+		</div>
 
 
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>

+ 1 - 4
examples/webgl_geometry_spline_editor.html

@@ -98,12 +98,9 @@
 				scene.add( light );
 				scene.add( light );
 				spotlight = light;
 				spotlight = light;
 
 
-				// scene.add( new THREE.CameraHelper( light.shadow.camera ) );
-
 				var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 );
 				var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 );
 				planeGeometry.rotateX( - Math.PI / 2 );
 				planeGeometry.rotateX( - Math.PI / 2 );
-				var planeMaterial = new THREE.ShadowMaterial();
-				planeMaterial.opacity = 0.2;
+				var planeMaterial = new THREE.ShadowMaterial( { opacity: 0.2 } );
 
 
 				var plane = new THREE.Mesh( planeGeometry, planeMaterial );
 				var plane = new THREE.Mesh( planeGeometry, planeMaterial );
 				plane.position.y = -200;
 				plane.position.y = -200;

+ 10 - 4
src/materials/ShadowMaterial.js

@@ -5,9 +5,13 @@ import { UniformsUtils } from '../renderers/shaders/UniformsUtils';
 
 
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
+ *
+ * parameters = {
+ *  opacity: <float>
+ * }
  */
  */
 
 
-function ShadowMaterial() {
+function ShadowMaterial( parameters ) {
 
 
 	ShaderMaterial.call( this, {
 	ShaderMaterial.call( this, {
 		uniforms: UniformsUtils.merge( [
 		uniforms: UniformsUtils.merge( [
@@ -20,9 +24,6 @@ function ShadowMaterial() {
 		fragmentShader: ShaderChunk[ 'shadow_frag' ]
 		fragmentShader: ShaderChunk[ 'shadow_frag' ]
 	} );
 	} );
 
 
-	this.lights = true;
-	this.transparent = true;
-
 	Object.defineProperties( this, {
 	Object.defineProperties( this, {
 		opacity: {
 		opacity: {
 			enumerable: true,
 			enumerable: true,
@@ -35,6 +36,11 @@ function ShadowMaterial() {
 		}
 		}
 	} );
 	} );
 
 
+	this.setValues( parameters );
+
+	this.lights = true;
+	this.transparent = true;
+
 }
 }
 
 
 ShadowMaterial.prototype = Object.create( ShaderMaterial.prototype );
 ShadowMaterial.prototype = Object.create( ShaderMaterial.prototype );