Object3D.html 14.6 KB
Newer Older
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
M
Mr.doob 已提交
4
		<meta charset="utf-8" />
M
Mr.doob 已提交
5 6 7 8
		<base href="../../" />
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
9 10 11 12
	</head>
	<body>
		<h1>[name]</h1>

L
looeee 已提交
13
		<div class="desc">
L
Lewy Blue 已提交
14
			This is the base class for most objects in three.js and provides a set of properties and methods
L
looeee 已提交
15 16 17 18 19
			for manipulating objects in 3D space.<br /><br />

			Note that this can be used for grouping objects via the [page:.add]( object ) method
			which adds the object as a child, however it is better to use [page:Group] for this.
		</div>
20 21 22 23


		<h2>Constructor</h2>

C
cjshannon 已提交
24

25
		<h3>[name]()</h3>
C
cjshannon 已提交
26
		<div>
G
Greg Tatum 已提交
27
		The constructor takes no arguments.
C
cjshannon 已提交
28
		</div>
29 30 31 32


		<h2>Properties</h2>

L
looeee 已提交
33 34
		<h3>[property:Boolean castShadow]</h3>
		<div>Whether the object gets rendered into shadow map. Default is *false*.</div>
35

L
looeee 已提交
36 37
		<h3>[property:Object3D children]</h3>
		<div>Array with object's children. See [page:Group] for info on manually grouping objects.</div>
38

L
looeee 已提交
39
		<h3>[property:Boolean frustumCulled]</h3>
40
		<div>
L
looeee 已提交
41 42
		When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object.
		Otherwise the object gets renderered every frame even if it isn't visible. Default is *true*.
43
		</div>
M
Mr.doob 已提交
44

L
looeee 已提交
45 46
		<h3>[property:Integer id]</h3>
		<div>readonly – Unique number for this object instance.</div>
M
Mr.doob 已提交
47

L
looeee 已提交
48
		<h3>[property:Boolean isObject]</h3>
49
		<div>
L
looeee 已提交
50
			Used to check whether this or derived classes are Object3Ds. Default is *true*.<br /><br />
51

J
Jing Ma 已提交
52
			You should not change this, as it is used internally for optimisation.
53 54
		</div>

L
looeee 已提交
55
		<h3>[property:Layers layers]</h3>
56
		<div>
L
looeee 已提交
57 58
		The layer membership of the object. The object is only visible if it has at least one
		layer in common with the [page:Camera] in use.
59 60
		</div>

L
looeee 已提交
61 62
		<h3>[property:Matrix4 matrix]</h3>
		<div>The local transform matrix.</div>
63

L
looeee 已提交
64
		<h3>[property:Boolean matrixAutoUpdate]</h3>
65
		<div>
L
looeee 已提交
66
		When this is set, it calculates the matrix of position, (rotation or quaternion) and
67
		scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DefaultMatrixAutoUpdate] (true).
68 69
		</div>

L
looeee 已提交
70
		<h3>[property:Matrix4 matrixWorld]</h3>
71
		<div>
J
Jing Ma 已提交
72
		The global transform of the object. If the Object3D has no parent, then it's identical to
L
looeee 已提交
73
		the local transform [page:.matrix].
74 75
		</div>

L
looeee 已提交
76
		<h3>[property:Boolean matrixWorldNeedsUpdate]</h3>
77
		<div>
L
looeee 已提交
78 79
		When this is set, it calculates the matrixWorld in that frame and resets this property
		 to false. Default is *false*.
80 81
		</div>

L
looeee 已提交
82 83
		<h3>[property:Matrix4 modelViewMatrix]</h3>
		<div>This is passed to the shader and used to calculate the position of the object.</div>
84

L
looeee 已提交
85 86 87 88 89 90 91
		<h3>[property:String name]</h3>
		<div>Optional name of the object (doesn't need to be unique). Default is an empty string.</div>

		<h3>[property:Matrix3 normalMatrix]</h3>
		<div>This is passed to the shader and used to calculate lighting for the object.</div>

		<h3>[property:function onAfterRender]</h3>
92
		<div>
L
looeee 已提交
93 94 95
		An optional callback that is executed immediately after the Object3D is rendered.
		This function is called with the following parameters: renderer, scene, camera, geometry,
		material, group.
96
		</div>
L
looeee 已提交
97 98

		<h3>[property:function onBeforeRender]</h3>
99
		<div>
L
looeee 已提交
100 101 102
		An optional callback that is executed immediately before the Object3D is rendered.
		This function is called with the following parameters: renderer, scene, camera, geometry,
		material, group.
103
		</div>
104

L
looeee 已提交
105 106 107 108 109 110 111 112 113
		<h3>[property:Object3D parent]</h3>
		<div>Object's parent in the [link:https://en.wikipedia.org/wiki/Scene_graph scene graph].</div>

		<h3>[property:Vector3 position]</h3>
		<div>The object's local position.</div>

		<h3>[property:Quaternion quaternion]</h3>
		<div>Object's local rotation as a [page:Quaternion Quaternion].</div>

114
		<h3>[property:Boolean receiveShadow]</h3>
L
looeee 已提交
115
		<div>Whether the material receives shadows. Default is *false*.</div>
116

L
looeee 已提交
117
		<h3>[property:Number renderOrder]</h3>
118
		<div>
L
looeee 已提交
119 120 121
		This value allows the default rendering order of [link:https://en.wikipedia.org/wiki/Scene_graph scene graph]
		objects to be overridden although opaque and transparent objects remain sorted independently.
		Sorting is from lowest to highest renderOrder. Default value is *0*.
122
		</div>
123

L
looeee 已提交
124
		<h3>[property:Euler rotation]</h3>
125
		<div>
L
looeee 已提交
126
		Object's local rotation (see [link:https://en.wikipedia.org/wiki/Euler_angles Euler angles]), in radians.
127
		</div>
128

L
looeee 已提交
129
		<h3>[property:Vector3 scale]</h3>
130
		<div>
L
looeee 已提交
131
		The object's local [property:Vector3 scale]. Default is [page:Vector3]( 1, 1, 1 ).
132
		</div>
133

L
looeee 已提交
134
		<h3>[property:Vector3 up]</h3>
135
		<div>
L
Lewy Blue 已提交
136 137
		This is used by the [page:.lookAt lookAt] method, for example, to determine the orientation of the result.<br />
		Default is [page:Object3D.DefaultUp] - that is, ( 0, 1, 0 ).
138
		</div>
L
looeee 已提交
139

140
		<h3>[property:object userData]</h3>
C
cjshannon 已提交
141
		<div>
J
Jing Ma 已提交
142
		An object that can be used to store custom data about the Object3D. It should not hold
L
looeee 已提交
143
		references to functions as these will not be cloned.
144
		</div>
C
cjshannon 已提交
145

L
looeee 已提交
146
		<h3>[property:String uuid]</h3>
C
cjshannon 已提交
147
		<div>
L
looeee 已提交
148 149
		[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance.
		This gets automatically assigned, so this shouldn't be edited.
150 151
		</div>

L
looeee 已提交
152 153 154 155 156
		<h3>[property:Boolean visible]</h3>
		<div>Object gets rendered if *true*. Default is *true*.</div>



157

158 159 160 161 162 163 164 165 166 167 168 169 170
		<h2>Static Properties</h2>
		<div>
			Static properties and methods are defined per class rather than per instance of that class.
			This means that changing [page:Object3D.DefaultUp] or [page:Object3D.DefaultMatrixAutoUpdate]
			will change the values of [page:.up up] and [page:.matrixAutoUpdate matrixAutoUpdate] for
			<em>every</em>	instance of Object3D (or derived classes)	created after the change has
			been made (already created Object3Ds will not be affected).
		</div>

		<h3>[property:Vector3 DefaultUp]</h3>
		<div>
			The default [page:.up up] direction for objects, also used as the default position for [page:DirectionalLight],
			[page:HemisphereLight] and [page:Spotlight] (which creates lights shining from the top down).<br />
J
Jing Ma 已提交
171
			Set to ( 0, 1, 0 ) by default.
172 173 174 175
		</div>

		<h3>[property:Vector3 DefaultMatrixAutoUpdate]</h3>
		<div>
J
Jing Ma 已提交
176
			The default setting for [page:.matrixAutoUpdate matrixAutoUpdate] for newly created Object3Ds.<br />
C
cjshannon 已提交
177

178
		</div>
A
aardgoose 已提交
179

180

181
		<h2>Methods</h2>
182

G
Greg Tatum 已提交
183
		<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
184

L
looeee 已提交
185
		<h3>[method:null add]( [page:Object3D object], ... )</h3>
186
		<div>
L
looeee 已提交
187
		Adds *object* as child of this object. An arbitrary number of objects may be added.<br /><br />
188

L
looeee 已提交
189
		See [page:Group] for info on manually grouping objects.
190 191
		</div>

L
looeee 已提交
192 193 194 195
		<h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
		<div>This updates the position, rotation and scale with the matrix.</div>

		<h3>[method:Object3D clone]( [page:Boolean recursive] )</h3>
196
		<div>
L
looeee 已提交
197 198
		recursive -- if true, descendants of the object are also cloned. Default is true.<br /><br />

J
Jing Ma 已提交
199
		Returns a clone of this object and optionally all descendants.
200
		</div>
L
looeee 已提交
201 202

		<h3>[method:Object3D copy]( [page:Object3D object], [page:Boolean recursive] )</h3>
203
		<div>
L
looeee 已提交
204 205 206
		recursive -- if true, descendants of the object are also copied. Default is true.<br /><br />

		Copy the given object into this object.
207 208
		</div>

L
looeee 已提交
209
		<h3>[method:Object3D getObjectById]( [page:Integer id] )</h3>
210
		<div>
L
looeee 已提交
211 212 213 214
		id -- Unique number of the object instance<br /><br />

		Searches through the object's children and returns the first with a matching id.<br />
		Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
215
		</div>
L
looeee 已提交
216 217

		<h3>[method:Object3D getObjectByName]( [page:String name] )</h3>
218
		<div>
J
Jing Ma 已提交
219
		name -- String to match to the children's Object3D.name property. <br /><br />
L
looeee 已提交
220 221 222 223

		Searches through the object's children and returns the first with a matching name.<br />
		Note that for most objects the [property:name] is an empty string by default. You will
		have to set it manually to make use of this method.
224
		</div>
225

L
looeee 已提交
226
		<h3>[method:Object3D getObjectByProperty]( [page:String name], [page:Float value] )</h3>
227
		<div>
L
looeee 已提交
228 229 230
		name -- the property name to search for. <br />
		value -- value of the given property. <br /><br />

J
Jing Ma 已提交
231
		Searches through the object's children and returns the first with a property that matches the value given.
232
		</div>
L
looeee 已提交
233 234

		<h3>[method:Vector3 getWorldPosition]( [page:Vector3 optionalTarget] )</h3>
235
		<div>
L
looeee 已提交
236 237 238
		optionalTarget — (optional) target to set the result. Otherwise, a new [page:Vector3] is instantiated. <br /><br />

		Returns a vector representing the position of the object in world space.
239 240
		</div>

L
looeee 已提交
241
		<h3>[method:Quaternion getWorldQuaternion]( [page:Quaternion optionalTarget] )</h3>
242
		<div>
L
Lewy Blue 已提交
243 244
		optionalTarget — (optional) if specified, the result will be copied into this Quaternion,
		otherwise a new Quaternion will be created. <br /><br />
L
looeee 已提交
245 246

		Returns a quaternion representing the rotation of the object in world space.
247
		</div>
L
looeee 已提交
248 249

		<h3>[method:Euler getWorldRotation]( [page:Euler optionalTarget] )</h3>
250
		<div>
L
Lewy Blue 已提交
251 252
		optionalTarget — (optional) if specified, the result will be copied into this Euler,
		otherwise a new Euler will be created. <br /><br />
L
looeee 已提交
253 254

		Returns the euler angles representing the rotation of the object in world space.
255 256
		</div>

L
looeee 已提交
257
		<h3>[method:Vector3 getWorldScale]( [page:Vector3 optionalTarget] )</h3>
258
		<div>
L
Lewy Blue 已提交
259 260
		[page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
		otherwise a new Vector3 will be created. <br /><br />
L
looeee 已提交
261 262

		Returns a vector of the scaling factors applied to the object for each axis in world space.
263
		</div>
L
looeee 已提交
264 265

		<h3>[method:Vector3 getWorldDirection]( [page:Vector3 optionalTarget] )</h3>
266
		<div>
L
Lewy Blue 已提交
267 268
		[page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
		otherwise a new Vector3 will be created. <br /><br />
L
looeee 已提交
269 270

		Returns a vector representing the direction of object's positive z-axis in world space.
271 272
		</div>

L
looeee 已提交
273

274
		<h3>[method:Vector3 localToWorld]( [page:Vector3 vector] )</h3>
275
		<div>
T
Tentone 已提交
276
		vector - A vector representing a position in local (object) space.<br /><br />
277

L
looeee 已提交
278
		Converts the vector from local space to world space.
279
		</div>
280

281
		<h3>[method:null lookAt]( [page:Vector3 vector] )</h3>
282
		<div>
L
looeee 已提交
283
		vector - A vector representing a position in world space.<br /><br />
284

L
looeee 已提交
285
		Rotates the object to face a point in world space.
286
		</div>
L
looeee 已提交
287 288

		<h3>[method:Array raycast]( [page:Raycaster raycaster], [page:Array intersects] )</h3>
289
		<div>
L
looeee 已提交
290 291 292
		Abstract (empty) method to get intersections between a casted ray and this object.
		Subclasses such as [page:Mesh], [page:Line], and [page:Points] implement this method in order
		to use raycasting.
293 294
		</div>

295
		<h3>[method:null remove]( [page:Object3D object], ... )</h3>
296
		<div>
297
		Removes *object* as child of this object. An arbitrary number of objects may be removed.
298 299
		</div>

L
looeee 已提交
300
		<h3>[method:Object3D rotateOnAxis]( [page:Vector3 axis], [page:Float angle] )</h3>
301
		<div>
L
looeee 已提交
302 303
		axis -- A normalized vector in object space. <br />
		angle -- The angle in radians.<br /><br />
304

L
looeee 已提交
305
		Rotate an object along an axis in object space. The axis is assumed to be normalized.
306
		</div>
307

L
looeee 已提交
308
		<h3>[method:null rotateX]( [page:Float rad] )</h3>
309
		<div>
L
looeee 已提交
310
		rad - the angle to rotate in radians.<br /><br />
311

L
looeee 已提交
312
		Rotates the object around x axis in local space.
313 314
		</div>

L
looeee 已提交
315
		<h3>[method:null rotateY]( [page:Float rad] )</h3>
316
		<div>
L
looeee 已提交
317
		rad - the angle to rotate in radians.<br /><br />
318

L
looeee 已提交
319
		Rotates the object around y axis in local space.
320 321
		</div>

L
looeee 已提交
322
		<h3>[method:null rotateZ]( [page:Float rad] )</h3>
C
cjshannon 已提交
323
		<div>
L
looeee 已提交
324
		rad - the angle to rotate in radians.<br /><br />
C
cjshannon 已提交
325

L
looeee 已提交
326
		Rotates the object around z axis in local space.
C
cjshannon 已提交
327
		</div>
328

L
looeee 已提交
329
		<h3>[method:null setRotationFromAxisAngle]( [page:Vector3 axis], [page:Float angle] )</h3>
330
		<div>
L
looeee 已提交
331 332
			axis -- A normalized vector in object space. <br />
			angle -- angle in radians<br /><br />
333

L
looeee 已提交
334 335
			Calls [page:Quaternion.setFromAxisAngle setFromAxisAngle]( [page:Float axis], [page:Float angle] )
			on the [page:.quaternion].
336 337
		</div>

L
looeee 已提交
338
		<h3>[method:null setRotationFromEuler]( [page:Euler euler] )</h3>
339
		<div>
L
looeee 已提交
340
			euler -- Euler angle specifying rotation amount.<br />
341

L
looeee 已提交
342 343
			Calls [page:Quaternion.setRotationFromEuler setRotationFromEuler]( [page:Euler euler])
			on the [page:.quaternion].
344
		</div>
L
looeee 已提交
345 346

		<h3>[method:null setRotationFromMatrix]( [page:Matrix4 m] )</h3>
347
		<div>
L
looeee 已提交
348 349 350 351 352 353
			m -- rotate the quaternion by the rotation component of the matrix.<br />

			Calls [page:Quaternion.setFromRotationMatrix setFromRotationMatrix]( [page:Matrix4 m])
			on the [page:.quaternion].<br /><br />

			Note that this assumes that the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
354 355
		</div>

L
looeee 已提交
356
		<h3>[method:null setRotationFromQuaternion]( [page:Quaternion q] )</h3>
357
		<div>
L
looeee 已提交
358 359 360
			q -- normalized Quaternion.<br /><br />

			Copy the given quaternion into [page:.quaternion].
361
		</div>
L
looeee 已提交
362 363

		<h3>[method:null toJSON]( [page:Quaternion q] )</h3>
364
		<div>
L
looeee 已提交
365
			Convert the object to JSON format.
366 367
		</div>

368
		<h3>[method:Object3D translateOnAxis]( [page:Vector3 axis], [page:Float distance] )</h3>
C
cjshannon 已提交
369
		<div>
G
Greg Tatum 已提交
370
		axis -- A normalized vector in object space.<br />
L
looeee 已提交
371 372 373
		distance -- The distance to translate.<br /><br />

		Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
C
cjshannon 已提交
374
		</div>
L
looeee 已提交
375 376 377 378 379 380 381 382 383 384 385

		<h3>[method:null translateX]( [page:Float distance] )</h3>
		<div>Translates object along x axis by *distance* units.</div>

		<h3>[method:null translateY]( [page:Float distance] )</h3>
		<div>Translates object along y axis by *distance* units.</div>

		<h3>[method:null translateZ]( [page:Float distance] )</h3>
		<div>Translates object along z axis by *distance* units.</div>

		<h3>[method:null traverse]( [page:Function callback] )</h3>
C
cjshannon 已提交
386
		<div>
L
looeee 已提交
387 388 389
		callback - A function with as first argument an object3D object.<br /><br />

		Executes the callback on this object and all descendants.
C
cjshannon 已提交
390
		</div>
391

L
looeee 已提交
392
		<h3>[method:null traverseVisible]( [page:Function callback] )</h3>
C
cjshannon 已提交
393
		<div>
L
looeee 已提交
394 395 396 397
		callback - A function with as first argument an object3D object.<br /><br />

		Like traverse, but the callback will only be executed for visible objects.
		Descendants of invisible objects are not traversed.
C
cjshannon 已提交
398
		</div>
L
looeee 已提交
399 400

		<h3>[method:null traverseAncestors]( [page:Function callback] )</h3>
C
cjshannon 已提交
401
		<div>
L
looeee 已提交
402 403 404
		callback - A function with as first argument an object3D object.<br /><br />

		Executes the callback on all ancestors.
C
cjshannon 已提交
405 406
		</div>

L
looeee 已提交
407 408 409 410 411 412 413 414
		<h3>[method:null updateMatrix]()</h3>
		<div>Update the local transform.</div>

		<h3>[method:null updateMatrixWorld]( [page:Boolean force] )</h3>
		<div>Update the global transform of the object and its children.</div>


		<h3>[method:Vector3 worldToLocal]( [page:Vector3 vector] )</h3>
415
		<div>
L
looeee 已提交
416 417 418
		vector - A world vector.<br /><br />

		Updates the vector from world space to local space.
419 420
		</div>

421 422 423 424 425
		<h2>Source</h2>

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