Skip to content

Commit cb5d4de

Browse files
authored
JSDoc: Document events. (#30547)
1 parent b9068ab commit cb5d4de

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

src/core/Object3D.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,42 @@ const _xAxis = /*@__PURE__*/ new Vector3( 1, 0, 0 );
2222
const _yAxis = /*@__PURE__*/ new Vector3( 0, 1, 0 );
2323
const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 );
2424

25+
/**
26+
* Fires when the object has been added to its parent object.
27+
*
28+
* @event Object3D#added
29+
* @type {Object}
30+
*/
2531
const _addedEvent = { type: 'added' };
32+
33+
/**
34+
* Fires when the object has been removed from its parent object.
35+
*
36+
* @event Object3D#removed
37+
* @type {Object}
38+
*/
2639
const _removedEvent = { type: 'removed' };
2740

41+
/**
42+
* Fires when a new child object has been added.
43+
*
44+
* @event Object3D#childadded
45+
* @type {Object}
46+
*/
2847
const _childaddedEvent = { type: 'childadded', child: null };
48+
49+
/**
50+
* Fires when a new child object has been added.
51+
*
52+
* @event Object3D#childremoved
53+
* @type {Object}
54+
*/
2955
const _childremovedEvent = { type: 'childremoved', child: null };
3056

3157
/**
3258
* This is the base class for most objects in three.js and provides a set of
3359
* properties and methods for manipulating objects in 3D space.
3460
*
35-
* Note that this can be used for grouping objects via the `add()` method which
36-
* adds the object as a child, however it is better to use {@link Group} for this.
37-
*
3861
* @augments EventDispatcher
3962
*/
4063
class Object3D extends EventDispatcher {
@@ -666,6 +689,8 @@ class Object3D extends EventDispatcher {
666689
* objects may be added. Any current parent on an object passed in here will be
667690
* removed, since an object can have at most one parent.
668691
*
692+
* @fires Object3D#added
693+
* @fires Object3D#childadded
669694
* @param {Object3D} object - The 3D object to add.
670695
* @return {Object3D} A reference to this instance.
671696
*/
@@ -716,6 +741,8 @@ class Object3D extends EventDispatcher {
716741
* Removes the given 3D object as child from this 3D object.
717742
* An arbitrary number of objects may be removed.
718743
*
744+
* @fires Object3D#removed
745+
* @fires Object3D#childremoved
719746
* @param {Object3D} object - The 3D object to remove.
720747
* @return {Object3D} A reference to this instance.
721748
*/
@@ -755,6 +782,8 @@ class Object3D extends EventDispatcher {
755782
/**
756783
* Removes this 3D object from its current parent.
757784
*
785+
* @fires Object3D#removed
786+
* @fires Object3D#childremoved
758787
* @return {Object3D} A reference to this instance.
759788
*/
760789
removeFromParent() {
@@ -774,6 +803,8 @@ class Object3D extends EventDispatcher {
774803
/**
775804
* Removes all child objects.
776805
*
806+
* @fires Object3D#removed
807+
* @fires Object3D#childremoved
777808
* @return {Object3D} A reference to this instance.
778809
*/
779810
clear() {
@@ -786,6 +817,8 @@ class Object3D extends EventDispatcher {
786817
* Adds the given 3D object as a child of this 3D object, while maintaining the object's world
787818
* transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).
788819
*
820+
* @fires Object3D#added
821+
* @fires Object3D#childadded
789822
* @param {Object3D} object - The 3D object to attach.
790823
* @return {Object3D} A reference to this instance.
791824
*/

0 commit comments

Comments
 (0)