Object3D.html 9.0 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>

Y
Yuri Feldman 已提交
13
		<div class="desc">Base class for scene graph objects.</div>
14 15 16 17


		<h2>Constructor</h2>

C
cjshannon 已提交
18

19
		<h3>[name]()</h3>
C
cjshannon 已提交
20
		<div>
G
Greg Tatum 已提交
21
		The constructor takes no arguments.
C
cjshannon 已提交
22
		</div>
23 24 25 26


		<h2>Properties</h2>

27
		<h3>[property:Integer id]</h3>
28
		<div>
29
		readonly – Unique number for this object instance.
G
gero3 已提交
30
		</div>
31

32
		<h3>[property:String uuid]</h3>
G
gero3 已提交
33
		<div>
34
		[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance.
G
gero3 已提交
35
		This gets automatically assigned, so this shouldn't be edited.
36 37
		</div>

38
		<h3>[property:String name]</h3>
39
		<div>
S
sole 已提交
40
		Optional name of the object (doesn't need to be unique).
41
		</div>
M
Mr.doob 已提交
42

43
		<h3>[property:Object3D parent]</h3>
44
		<div>
S
sole 已提交
45
		Object's parent in the scene graph.
46
		</div>
M
Mr.doob 已提交
47

48
		<h3>[property:Object3D children]</h3>
49 50 51 52
		<div>
		Array with object's children.
		</div>

53
		<h3>[property:Vector3 position]</h3>
54 55 56 57
		<div>
		Object's local position.
		</div>

58
		<h3>[property:Euler rotation]</h3>
59
		<div>
G
Greg Tatum 已提交
60
		Object's local rotation (<a href="https://en.wikipedia.org/wiki/Euler_angles" target="_blank">Euler angles</a>), in radians.
61 62
		</div>

63
		<h3>[property:Vector3 scale]</h3>
64 65 66 67
		<div>
		Object's local scale.
		</div>

68
		<h3>[property:Vector3 up]</h3>
69
		<div>
P
paulmasson 已提交
70
		Up direction. Default is THREE.Vector3( 0, 1, 0 ).
71 72
		</div>

73
		<h3>[property:Matrix4 matrix]</h3>
74 75 76 77
		<div>
		Local transform.
		</div>

78
		<h3>[property:Quaternion quaternion]</h3>
79
		<div>
80
		Object's local rotation as [page:Quaternion Quaternion].
81 82
		</div>

83
		<h3>[property:Boolean visible]</h3>
84 85 86
		<div>
		Object gets rendered if *true*.
		</div>
87 88 89
		<div>
		default – true
		</div>
90

91
		<h3>[property:Boolean castShadow]</h3>
92 93 94
		<div>
		Gets rendered into shadow map.
		</div>
95 96 97
		<div>
		default – false
		</div>
98

99
		<h3>[property:Boolean receiveShadow]</h3>
100 101 102
		<div>
		Material gets baked in shadow receiving.
		</div>
103 104 105
		<div>
		default – false
		</div>
106

107
		<h3>[property:Boolean frustumCulled]</h3>
108 109 110
		<div>
		When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible.
		</div>
111 112 113
		<div>
		default – true
		</div>
114

115
		<h3>[property:Boolean matrixAutoUpdate]</h3>
116 117 118
		<div>
		When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property.
		</div>
119 120 121
		<div>
		default – true
		</div>
122

123
		<h3>[property:Boolean matrixWorldNeedsUpdate]</h3>
124 125 126
		<div>
		When this is set, it calculates the matrixWorld in that frame and resets this property to false.
		</div>
127 128 129
		<div>
		default – false
		</div>
130

131
		<h3>[property:object userData]</h3>
C
cjshannon 已提交
132
		<div>
G
Greg Tatum 已提交
133
		An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned.
134
		</div>
C
cjshannon 已提交
135

136
		<h3>[property:Matrix4 matrixWorld]</h3>
C
cjshannon 已提交
137
		<div>
G
Greg Tatum 已提交
138
		The global transform of the object. If the Object3d has no parent, then it's identical to the local transform.
139 140
		</div>

C
cjshannon 已提交
141

142
		<h2>Methods</h2>
143

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

146
		<h3>[method:null applyMatrix]( [page:Matrix4 matrix])</h3>
147 148 149 150 151 152
		<div>
		matrix - matrix
		</div>
		<div>
		This updates the position, rotation and scale with the matrix.
		</div>
153

154
		<h3>[method:null translateX]( [page:Float distance] )</h3>
155
		<div>
156 157 158
		distance - Distance.<br />
		</div>
		<div>
159 160 161
		Translates object along x axis by distance.
		</div>

162
		<h3>[method:null translateY]( [page:Float distance] )</h3>
163
		<div>
164 165 166
		distance - Distance.<br />
		</div>
		<div>
167 168 169
		Translates object along y axis by distance.
		</div>

170
		<h3>[method:null translateZ]( [page:Float distance] )</h3>
171
		<div>
172 173 174
		distance - Distance.<br />
		</div>
		<div>
175 176
		Translates object along z axis by distance.
		</div>
177

178
		<h3>[method:Vector3 localToWorld]( [page:Vector3 vector] )</h3>
179 180 181 182 183 184 185
		<div>
		vector - A local vector.<br />
		</div>
		<div>
		Updates the vector from local space to world space.
		</div>

186
		<h3>[method:Vector3 worldToLocal]( [page:Vector3 vector] )</h3>
187 188 189 190 191 192
		<div>
		vector - A world vector.<br />
		</div>
		<div>
		Updates the vector from world space to local space.
		</div>
193

194
		<h3>[method:null lookAt]( [page:Vector3 vector] )</h3>
195
		<div>
196 197 198
		vector - A world vector to look at.<br />
		</div>
		<div>
199 200 201
		Rotates object to face point in space.
		</div>

202
		<h3>[method:null add]( [page:Object3D object], ... )</h3>
203
		<div>
204 205 206
		object - An object.<br />
		</div>
		<div>
207
		Adds *object* as child of this object. An arbitrary number of objects may be added.
208 209
		</div>

210
		<h3>[method:null remove]( [page:Object3D object], ... )</h3>
211
		<div>
212 213 214
		object - An object.<br />
		</div>
		<div>
215
		Removes *object* as child of this object. An arbitrary number of objects may be removed.
216 217
		</div>

218
		<h3>[method:null traverse]( [page:Function callback] )</h3>
219
		<div>
220
		callback - A function with as first argument an object3D object.<br />
221 222
		</div>
		<div>
223
		Executes the callback on this object and all descendants.
224
		</div>
225

226 227 228 229 230 231 232 233
		<h3>[method:null traverseVisible]( [page:Function callback] )</h3>
		<div>
		callback - A function with as first argument an object3D object.<br />
		</div>
		<div>
		Like traverse, but the callback will only be executed for visible objects.
		Descendants of invisible objects are not traversed.
		</div>
234

235 236 237 238 239
		<h3>[method:null traverseAncestors]( [page:Function callback] )</h3>
		<div>
		callback - A function with as first argument an object3D object.<br />
		</div>
		<div>
240
		Executes the callback on all ancestors.
241
		</div>
242

243
		<h3>[method:null updateMatrix]()</h3>
244 245 246 247
		<div>
		Updates local transform.
		</div>

248
		<h3>[method:null updateMatrixWorld]( [page:Boolean force] )</h3>
249 250 251 252
		<div>
		Updates global transform of the object and its children.
		</div>

253
		<h3>[method:Object3D clone]()</h3>
254 255 256 257
		<div>
		Creates a new clone of this object and all descendants.
		</div>

258

M
Mr.doob 已提交
259
		<h3>[method:Object3D getObjectByName]([page:String name])</h3>
C
cjshannon 已提交
260
		<div>
G
Greg Tatum 已提交
261
		name -- String to match to the children's Object3d.name property. <br />
C
cjshannon 已提交
262 263
		</div>
		<div>
M
Mr.doob 已提交
264
		Searches through the object's children and returns the first with a matching name.
C
cjshannon 已提交
265 266
		</div>

M
Mr.doob 已提交
267
		<h3>[method:Object3D getObjectById]([page:Integer id])</h3>
C
cjshannon 已提交
268
		<div>
G
Greg Tatum 已提交
269
		id -- Unique number of the object instance<br />
C
cjshannon 已提交
270 271
		</div>
		<div>
M
Mr.doob 已提交
272
		Searches through the object's children and returns the first with a matching id.
C
cjshannon 已提交
273
		</div>
274

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
		<h3>[method:Vector3 getWorldPosition]([page:Vector3 optionalTarget])</h3>
		<div>
		optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)<br />
		</div>
		<div>
		Returns a vector representing the position of the object in world space.
		</div>

		<h3>[method:Quaternion getWorldQuaternion]([page:Quaternion optionalTarget])</h3>
		<div>
		optionalTarget — Optional target to set the result. Otherwise, a new `Quaternion` is instantiated. (optional)<br />
		</div>
		<div>
		Returns a quaternion representing the rotation of the object in world space.
		</div>

		<h3>[method:Euler getWorldRotation]([page:Euler optionalTarget])</h3>
		<div>
		optionalTarget — Optional target to set the result. Otherwise, a new `Euler` is instantiated. (optional)<br />
		</div>
		<div>
		Returns the euler angles representing the rotation of the object in world space.
		</div>

		<h3>[method:Vector3 getWorldScale]([page:Vector3 optionalTarget])</h3>
		<div>
		optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)<br />
		</div>
		<div>
		Returns a vector of the scaling factors applied to the object for each axis in world space.
		</div>

		<h3>[method:Vector3 getWorldDirection]([page:Vector3 optionalTarget])</h3>
		<div>
		optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)<br />
		</div>
		<div>
		Returns a vector representing the direction of object's positive z-axis in world space.
		</div>

315
		<h3>[method:Object3D translateOnAxis]([page:Vector3 axis], [page:Float distance])</h3>
C
cjshannon 已提交
316
		<div>
G
Greg Tatum 已提交
317 318
		axis -- A normalized vector in object space.<br />
		distance -- The distance to translate.
C
cjshannon 已提交
319 320
		</div>
		<div>
G
Greg Tatum 已提交
321
		Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
C
cjshannon 已提交
322
		</div>
323

324
		<h3>[method:Object3D rotateOnAxis]([page:Vector3 axis], [page:Float angle])</h3>
C
cjshannon 已提交
325
		<div>
G
Greg Tatum 已提交
326 327
		axis -- A normalized vector in object space. <br />
		angle -- The angle in radians.
C
cjshannon 已提交
328 329
		</div>
		<div>
G
Greg Tatum 已提交
330
		Rotate an object along an axis in object space. The axis is assumed to be normalized.
C
cjshannon 已提交
331 332
		</div>

333 334
		<h3>[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])</h3>
		<div>
M
Mr.doob 已提交
335
		Abstract 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 participate in raycasting.
336 337
		</div>

338 339 340 341 342
		<h2>Source</h2>

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