Skip to content

Commit c166e46

Browse files
committed
opt-in light.target (docs)
1 parent afc44eb commit c166e46

File tree

4 files changed

+55
-49
lines changed

4 files changed

+55
-49
lines changed

docs/api/lights/DirectionalLight.html

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ <h2>Example</h2>
6060

6161
<h2>Constructor</h2>
6262

63-
<h3>[name]( [param:Integer color], [param:Float intensity] )</h3>
63+
<h3>[name]( [param:Integer color], [param:Float intensity], [param:OrthographicCamera camera] )</h3>
6464
<p>
6565
[page:Integer color] - (optional) hexadecimal color of the light. Default is 0xffffff (white).<br />
66-
[page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br /><br />
66+
[page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br />
67+
[page:OrthographicCamera camera] - (optional) the light's view of the world.<br /><br />
6768

6869
Creates a new [name].
6970
</p>
@@ -99,30 +100,26 @@ <h3>[property:DirectionalLightShadow shadow]</h3>
99100

100101
<h3>[property:Object3D target]</h3>
101102
<p>
102-
The DirectionalLight points from its [page:.position position] to target.position. The default
103-
position of the target is *(0, 0, 0)*.<br />
104-
105-
*Note*: For the target's position to be changed to anything other than the default,
106-
it must be added to the [page:Scene scene] using
107-
</p>
108-
<code>
109-
scene.add( light.target );
110-
</code>
111-
<p>
112-
This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
113-
updated each frame.<br /><br />
114-
115-
It is also possible to set the target to be another object in the scene (anything with a
116-
[page:Object3D.position position] property), like so:
117-
</p>
118-
<code>
119-
var targetObject = new THREE.Object3D();
120-
scene.add(targetObject);
121-
122-
light.target = targetObject;
123-
</code>
124-
<p>
125-
The directionalLight will now track the target object.
103+
The DirectionalLight points from its [page:.position position] to target.position.
104+
If target is undefined, it points to to the origin *(0, 0, 0)* of its parent frame.<br />
105+
106+
The position pointed to by the DirectionalLight may be changed using lookAt
107+
<code>
108+
light.lookAt( x, y, z ); // or
109+
light.lookAt( lookAtPosition );
110+
</code>
111+
*Note*: the LookAt position must be expressed in the parent frame of the light, which is typically
112+
the world frame if the light has been added to the scene with no rotation/translation.
113+
114+
Alternatively, it may be set to track a target object.
115+
<code>
116+
var targetObject = new THREE.Object3D();
117+
scene.add(targetObject);
118+
119+
light.target = targetObject;
120+
</code>
121+
*Note*: The target object mush be added to the [page:Scene scene] to get its
122+
[page:Object3D.matrixWorld matrixWorld] automatically updated each frame.
126123
</p>
127124

128125

docs/api/lights/SpotLight.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h2>Code Example</h2>
6767
<h2>Constructor</h2>
6868

6969

70-
<h3>[name]( [param:Integer color], [param:Float intensity], [param:Float distance], [param:Radians angle], [param:Float penumbra], [param:Float decay] )</h3>
70+
<h3>[name]( [param:Integer color], [param:Float intensity], [param:Float distance], [param:Radians angle], [param:Float penumbra], [param:Float decay], [param:PerspectiveCamera camera] )</h3>
7171
<p>
7272
[page:Integer color] - (optional) hexadecimal color of the light. Default is 0xffffff (white).<br />
7373
[page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br /><br />
@@ -78,6 +78,7 @@ <h3>[name]( [param:Integer color], [param:Float intensity], [param:Float distanc
7878
[page:Float penumbra] - Percent of the spotlight cone that is attenuated due to penumbra.
7979
Takes values between zero and 1. Default is zero.<br />
8080
[page:Float decay] - The amount the light dims along the distance of the light.<br /><br />
81+
[page:PerspectiveCamera camera] - (optional) the light's view of the world.<br /><br />
8182

8283
Creates a new [name].
8384
</p>
@@ -152,30 +153,28 @@ <h3>[property:SpotLightShadow shadow]</h3>
152153

153154
<h3>[property:Object3D target]</h3>
154155
<p>
155-
The Spotlight points from its [page:.position position] to target.position. The default
156-
position of the target is *(0, 0, 0)*.<br />
156+
The Spotlight points from its [page:.position position] to target.position.
157+
If target is undefined, it points to to the origin *(0, 0, 0)* of its parent frame.<br />
157158

158-
*Note*: For the target's position to be changed to anything other than the default,
159-
it must be added to the [page:Scene scene] using
159+
The position pointed to by the Spotlight may be changed using lookAt
160160
<code>
161-
scene.add( light.target );
161+
light.lookAt( x, y, z ); // or
162+
light.lookAt( vector3 );
162163
</code>
164+
*Note*: the LookAt position must be expressed in the parent frame of the light, which is typically
165+
the world frame if the light has been added to the scene with no rotation/translation.
163166

164-
This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
165-
updated each frame.<br /><br />
166-
167-
It is also possible to set the target to be another object in the scene (anything with a
168-
[page:Object3D.position position] property), like so:
167+
Alternatively, it may be set to track a target object.
169168
<code>
170169
var targetObject = new THREE.Object3D();
171170
scene.add(targetObject);
172171

173172
light.target = targetObject;
174173
</code>
175-
The spotlight will now track the target object.
174+
*Note*: The target object mush be added to the [page:Scene scene] to get its
175+
[page:Object3D.matrixWorld matrixWorld] automatically updated each frame.
176176
</p>
177177

178-
179178
<h2>Methods</h2>
180179

181180
See the base [page:Light Light] class for common methods.

docs/api/lights/shadows/DirectionalLightShadow.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ <h2>Example</h2>
6161
</code>
6262
</p>
6363

64+
<h3>[name]( [param:OrthographicCamera camera] )</h3>
65+
<p>
66+
[page:OrthographicCamera camera] - (optional) the light's view of the world.<br /><br />
67+
68+
Create a new [name]. If not provided, the constructor creates an [page:OrthographicCamera]
69+
to manage the shadow's view of the world. This is not intended to be called directly - it is called
70+
internally by [page:DirectionalLight].
71+
</p>
72+
73+
6474
<h2>Constructor</h2>
6575
<h3>[name]( )</h3>
6676
<p>
@@ -73,7 +83,7 @@ <h2>Properties</h2>
7383
See the base [page:LightShadow LightShadow] class for common properties.
7484
</p>
7585

76-
<h3>[property:Camera camera]</h3>
86+
<h3>[property:OrthographicCamera camera]</h3>
7787
<p>
7888
The light's view of the world. This is used to generate a depth map of the scene; objects behind
7989
other objects from the light's perspective will be in shadow.<br /><br />

docs/api/lights/shadows/SpotLightShadow.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,20 @@ <h2>Example</h2>
5959

6060
<h2>Constructor</h2>
6161

62-
The constructor creates a [param:PerspectiveCamera PerspectiveCamera] to manage the shadow's view of the world.
62+
<h3>[name]( [param:PerspectiveCamera camera] )</h3>
63+
<p>
64+
[page:PerspectiveCamera camera] - (optional) the light's view of the world.<br /><br />
65+
66+
Create a new [name]. If not provided, the constructor creates a [page:PerspectiveCamera]
67+
to manage the shadow's view of the world.
68+
</p>
69+
6370

6471
<h2>Properties</h2>
6572
See the base [page:LightShadow LightShadow] class for common properties.
6673

6774

68-
<h3>[property:Camera camera]</h3>
75+
<h3>[property:PerspectiveCamera camera]</h3>
6976
<p>
7077
The light's view of the world. This is used to generate a depth map of the scene; objects behind
7178
other objects from the light's perspective will be in shadow.<br /><br />
@@ -79,13 +86,6 @@ <h3>[property:Camera camera]</h3>
7986

8087
</p>
8188

82-
<h3>[property:Boolean isSpotLightShadow]</h3>
83-
<p>
84-
Used to check whether this or derived classes are spot light shadows. Default is *true*.<br /><br />
85-
86-
You should not change this, as it used internally for optimisation.
87-
</p>
88-
8989
<h2>Methods</h2>
9090
See the base [page:LightShadow LightShadow] class for common methods.
9191

0 commit comments

Comments
 (0)