SpotLight.html 4.9 KB
Newer Older
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
4
		<meta charset="utf-8" />
5 6 7 8 9
		<script src="../../list.js"></script>
		<script src="../../page.js"></script>
		<link type="text/css" rel="stylesheet" href="../../page.css" />
	</head>
	<body>
C
cjshannon 已提交
10
		[page:Object3D] &rarr; [page:Light] &rarr;
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

		<h1>[name]</h1>

		<div class="desc">A point light that can cast shadow in one direction.</div>
		
		<div class="desc">Affects objects using [page:MeshLambertMaterial] or [page:MeshPhongMaterial].</div>


		<h2>Example</h2>

		<code>// white spotlight shining from the side, casting shadow

var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 100, 1000, 100 );

spotLight.castShadow = true;

spotLight.shadowMapWidth = 1024;
spotLight.shadowMapHeight = 1024;

spotLight.shadowCameraNear = 500;
spotLight.shadowCameraFar = 4000;
spotLight.shadowCameraFov = 30;

scene.add( spotLight );</code>


		<h2>Constructor</h2>

C
cjshannon 已提交
40

41
		<h3>[name]([page:Integer hex], [page:Float intensity], [page:todo distance], [page:todo angle], [page:todo exponent])</h3>
C
cjshannon 已提交
42
		<div>
43 44
		[page:Integer hex] — Numeric value of the RGB component of the color. <br />
		[page:Float intensity] — Numeric value of the light's strength/intensity. <br />
45 46
		distance -- Maximum distance from origin where light will shine whose intensity is attenuated linearly based on distance from origin. <br />
		angle -- Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2.  <br />
C
cjshannon 已提交
47 48 49 50 51 52
		exponent -- todo
		</div>
		<div>
		todo
		</div>
		
53 54 55

		<h2>Properties</h2>

56
		<h3>[property:Object3D target]</h3>
57 58 59 60 61
		<div>
			Spotlight focus points at target.position.<br />
			Default position — *(0,0,0)*.
		</div>
	
62
		<h3>[property:Float intensity]</h3>
63 64 65 66 67
		<div>
			Light's intensity.<br />
			Default — *1.0*.
		</div>
	
68
		<h3>[property:Float distance]</h3>
69 70 71 72 73
		<div>
			If non-zero, light will attenuate linearly from maximum intensity at light *position* down to zero at *distance*.<br />
			Default — *0.0*.
		</div>
	
74
		<h3>[property:Float angle]</h3>
75
		<div>
76 77
			Maximum extent of the spotlight, in radians, from its direction. Should be no more than *Math.PI/2*.<br />
			Default — *Math.PI/3*.
78 79
		</div>
	
80
		<h3>[property:Float exponent]</h3>
81 82 83 84 85
		<div>
			Rapidity of the falloff of light from its target direction.<br />
			Default — *10.0*.
		</div>
	
86
		<h3>[property:Boolean castShadow]</h3>
87 88 89 90 91
		<div>
			If set to *true* light will cast dynamic shadows. *Warning*: This is expensive and requires tweaking to get shadows looking right.<br />
			Default — *false*.
		</div>
		
92
		<h3>[property:Boolean onlyShadow]</h3>
93 94 95 96 97
		<div>
			If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).<br />
			Default — *false*.
		</div>
		
98
		<h3>[property:Float shadowCameraNear]</h3>
99 100 101 102 103
		<div>
			Perspective shadow camera frustum <em>near</em> parameter.<br />
			Default — *50*.
		</div>

104
		<h3>[property:Float shadowCameraFar]</h3>
105 106 107 108 109
		<div>
			Perspective shadow camera frustum <em>far</em> parameter.<br />
			Default — *5000*.
		</div>

110
		<h3>[property:Float shadowCameraFov]</h3>
111 112 113 114 115
		<div>
			Perspective shadow camera frustum <em>field of view</em> parameter.<br />
			Default — *50*.
		</div>
		
116
		<h3>[property:Boolean shadowCameraVisible]</h3>
117 118 119 120 121
		<div>
			Show debug shadow camera frustum.<br />
			Default — *false*.
		</div>
		
122
		<h3>[property:Float shadowBias]</h3>
123
		<div>
124
			Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.<br />
125 126 127
			Default — *0*.
		</div>

128
		<h3>[property:Float shadowDarkness]</h3>
129 130 131 132 133
		<div>
			Darkness of shadow casted by this light (from *0* to *1*).<br />
			Default — *0.5*.
		</div>

134
		<h3>[property:Integer shadowMapWidth]</h3>
135 136 137 138 139
		<div>
			Shadow map texture width in pixels.<br />
			Default — *512*.
		</div>

140
		<h3>[property:Integer shadowMapHeight]</h3>
141 142 143 144 145
		<div>
			Shadow map texture height in pixels.<br />
			Default — *512*.
		</div>
		
146
		<h3>[property:Vector2 shadowMapSize]</h3>
C
cjshannon 已提交
147
		<div>
148
			The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering.
C
cjshannon 已提交
149 150
		</div> 

151
		<h3>[property:PerspectiveCamera shadowCamera]</h3>
C
cjshannon 已提交
152
		<div>
153
			The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings.
C
cjshannon 已提交
154 155
		</div> 

156
		<h3>[property:Matrix4 shadowMatrix]</h3>
C
cjshannon 已提交
157
		<div>
158
			Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering.
C
cjshannon 已提交
159 160
		</div> 

161
		<h3>[property:WebGLRenderTarget shadowMap]</h3>
C
cjshannon 已提交
162
		<div>
163
		    The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
C
cjshannon 已提交
164 165
		</div> 

166 167
		<h2>Methods</h2>		
		
168 169 170 171 172
		<h2>Source</h2>

		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
	</body>
</html>