浏览代码

full api documentation for h2d and h3d Object

Nicolas Cannasse 7 年之前
父节点
当前提交
18524f70be
共有 2 个文件被更改,包括 305 次插入42 次删除
  1. 109 14
      h2d/Object.hx
  2. 196 28
      h3d/scene/Object.hx

+ 109 - 14
h2d/Object.hx

@@ -10,23 +10,58 @@ class Object {
 	var parentContainer : Object;
 	var parentContainer : Object;
 
 
 	/**
 	/**
-		The parent `Sprite` in the scene tree.
+		The parent object in the scene tree.
 	**/
 	**/
 	public var parent(default, null) : Object;
 	public var parent(default, null) : Object;
+
 	/**
 	/**
-		How many immediate children this sprite has.
+		How many immediate children this object has.
 	**/
 	**/
 	public var numChildren(get, never) : Int;
 	public var numChildren(get, never) : Int;
 
 
+	/**
+		The name of the object, can be used to retrieve an object within a tree by using `getObjectByName` (default null)
+	**/
+	public var name : String;
+
+	/**
+		The x position (in pixels) of the object relative to its parent.
+	**/
 	public var x(default,set) : Float;
 	public var x(default,set) : Float;
+
+	/**
+		The y position (in pixels) of the object relative to its parent.
+	**/
 	public var y(default, set) : Float;
 	public var y(default, set) : Float;
+
+	/**
+		The amount of horizontal scaling of this object (default 1.0)
+	**/
 	public var scaleX(default,set) : Float;
 	public var scaleX(default,set) : Float;
+
+	/**
+		The amount of vertical scaling of this object (default 1.0)
+	**/
 	public var scaleY(default,set) : Float;
 	public var scaleY(default,set) : Float;
+
+	/**
+		The rotation angle of this object, in radians.
+	**/
 	public var rotation(default, set) : Float;
 	public var rotation(default, set) : Float;
+
+	/**
+		Is the object and its children are displayed on screen (default true).
+	**/
 	public var visible(default, set) : Bool;
 	public var visible(default, set) : Bool;
-	public var name : String;
+
+	/**
+		The amount of transparency of the Object (default 1.0)
+	**/
 	public var alpha : Float = 1.;
 	public var alpha : Float = 1.;
 
 
+	/**
+		The post process filter for this object.
+	**/
 	public var filter(default,set) : h2d.filter.Filter;
 	public var filter(default,set) : h2d.filter.Filter;
 
 
 	var matA : Float;
 	var matA : Float;
@@ -40,6 +75,9 @@ class Object {
 	var allocated : Bool;
 	var allocated : Bool;
 	var lastFrame : Int;
 	var lastFrame : Int;
 
 
+	/**
+		Create a new empty object, and adds it to the parent object if not null.
+	**/
 	public function new( ?parent : Object ) {
 	public function new( ?parent : Object ) {
 		matA = 1; matB = 0; matC = 0; matD = 1; absX = 0; absY = 0;
 		matA = 1; matB = 0; matC = 0; matD = 1; absX = 0; absY = 0;
 		x = 0; y = 0; scaleX = 1; scaleY = 1; rotation = 0;
 		x = 0; y = 0; scaleX = 1; scaleY = 1; rotation = 0;
@@ -51,9 +89,9 @@ class Object {
 	}
 	}
 
 
 	/**
 	/**
-		Returns the bounds of the sprite for its whole content, recursively.
+		Return the bounds of the object for its whole content, recursively.
 		If relativeTo is null, it will return the bounds in the absolute coordinates.
 		If relativeTo is null, it will return the bounds in the absolute coordinates.
-		If not, it will return the bounds relative to the specified sprite coordinates.
+		If not, it will return the bounds relative to the specified object coordinates.
 		You can pass an already allocated bounds or getBounds will allocate one for you and return it.
 		You can pass an already allocated bounds or getBounds will allocate one for you and return it.
 	**/
 	**/
 	public function getBounds( ?relativeTo : Object, ?out : h2d.col.Bounds ) : h2d.col.Bounds {
 	public function getBounds( ?relativeTo : Object, ?out : h2d.col.Bounds ) : h2d.col.Bounds {
@@ -72,8 +110,8 @@ class Object {
 	}
 	}
 
 
 	/**
 	/**
-		This is similar to getBounds(parent), but instead of the full content, it will return
-		the size based on the alignement of the Sprite. For instance for a text, getBounds will return
+		Similar to getBounds(parent), but instead of the full content, it will return
+		the size based on the alignement of the object. For instance for a text, getBounds will return
 		the full glyphs size whereas getSize() will ignore the pixels under the baseline.
 		the full glyphs size whereas getSize() will ignore the pixels under the baseline.
 	**/
 	**/
 	public function getSize( ?out : h2d.col.Bounds ) : h2d.col.Bounds {
 	public function getSize( ?out : h2d.col.Bounds ) : h2d.col.Bounds {
@@ -89,6 +127,9 @@ class Object {
 		return out;
 		return out;
 	}
 	}
 
 
+	/**
+		Find a single object in the tree by calling `f` on each and returning the first not-null value returned, or null if not found.
+	**/
 	public function find<T>( f : Object -> Null<T> ) : Null<T> {
 	public function find<T>( f : Object -> Null<T> ) : Null<T> {
 		var v = f(this);
 		var v = f(this);
 		if( v != null )
 		if( v != null )
@@ -100,6 +141,9 @@ class Object {
 		return null;
 		return null;
 	}
 	}
 
 
+	/**
+		Find several objects in the tree by calling `f` on each and returning all the not-null values returned.
+	**/
 	public function findAll<T>( f : Object -> Null<T>, ?arr : Array<T> ) : Array<T> {
 	public function findAll<T>( f : Object -> Null<T>, ?arr : Array<T> ) : Array<T> {
 		if( arr == null ) arr = [];
 		if( arr == null ) arr = [];
 		var v = f(this);
 		var v = f(this);
@@ -202,13 +246,19 @@ class Object {
 		out.addPos(x * rA + y * rC, x * rB + y * rD);
 		out.addPos(x * rA + y * rC, x * rB + y * rD);
 	}
 	}
 
 
-	public function getSpritesCount() : Int {
+	/**
+		Return the total number of children, recursively.
+	**/
+	public function getObjectsCount() : Int {
 		var k = 0;
 		var k = 0;
 		for( c in children )
 		for( c in children )
-			k += c.getSpritesCount() + 1;
+			k += c.getObjectsCount() + 1;
 		return k;
 		return k;
 	}
 	}
 
 
+	/**
+		Convert a local position (or [0,0] if pt is null) relative to the object origin into an absolute screen position, applying all the inherited transforms.
+	**/
 	public function localToGlobal( ?pt : h2d.col.Point ) : h2d.col.Point {
 	public function localToGlobal( ?pt : h2d.col.Point ) : h2d.col.Point {
 		syncPos();
 		syncPos();
 		if( pt == null ) pt = new h2d.col.Point();
 		if( pt == null ) pt = new h2d.col.Point();
@@ -219,6 +269,9 @@ class Object {
 		return pt;
 		return pt;
 	}
 	}
 
 
+	/**
+		Convert an absolute screen position into a local position relative to the object origin, applying all the inherited transforms.
+	**/
 	public function globalToLocal( pt : h2d.col.Point ) : h2d.col.Point {
 	public function globalToLocal( pt : h2d.col.Point ) : h2d.col.Point {
 		syncPos();
 		syncPos();
 		pt.x -= absX;
 		pt.x -= absX;
@@ -245,10 +298,16 @@ class Object {
 		return b;
 		return b;
 	}
 	}
 
 
+	/**
+		Add a child object at the end of the children list.
+	**/
 	public function addChild( s : Object ) : Void {
 	public function addChild( s : Object ) : Void {
 		addChildAt(s, children.length);
 		addChildAt(s, children.length);
 	}
 	}
 
 
+	/**
+		Insert a child object at the specified position of the children list.
+	**/
 	public function addChildAt( s : Object, pos : Int ) : Void {
 	public function addChildAt( s : Object, pos : Int ) : Void {
 		if( pos < 0 ) pos = 0;
 		if( pos < 0 ) pos = 0;
 		if( pos > children.length ) pos = children.length;
 		if( pos > children.length ) pos = children.length;
@@ -317,6 +376,9 @@ class Object {
 		m.y = absY;
 		m.y = absY;
 	}
 	}
 
 
+	/**
+		Remove the given object from our immediate children list if it's part of it.
+	**/
 	public function removeChild( s : Object ) {
 	public function removeChild( s : Object ) {
 		if( children.remove(s) ) {
 		if( children.remove(s) ) {
 			if( s.allocated ) s.onRemove();
 			if( s.allocated ) s.onRemove();
@@ -333,6 +395,9 @@ class Object {
 			s.setParentContainer(c);
 			s.setParentContainer(c);
 	}
 	}
 
 
+	/**
+		Remove all children from our immediate children list
+	**/
 	public function removeChildren() {
 	public function removeChildren() {
 		while( numChildren>0 )
 		while( numChildren>0 )
 			removeChild( getChildAt(0) );
 			removeChild( getChildAt(0) );
@@ -346,6 +411,9 @@ class Object {
 		if( this != null && parent != null ) parent.removeChild(this);
 		if( this != null && parent != null ) parent.removeChild(this);
 	}
 	}
 
 
+	/**
+		Draw the object and all its children into the given Texture
+	**/
 	public function drawTo( t : h3d.mat.Texture ) {
 	public function drawTo( t : h3d.mat.Texture ) {
 		var s = getScene();
 		var s = getScene();
 		var needDispose = s == null;
 		var needDispose = s == null;
@@ -509,7 +577,7 @@ class Object {
 	}
 	}
 
 
 	/**
 	/**
-		Will clip a local bounds with our global viewport
+		Clip a local bounds with our global viewport
 	**/
 	**/
 	function clipBounds( ctx : RenderContext, bounds : h2d.col.Bounds ) {
 	function clipBounds( ctx : RenderContext, bounds : h2d.col.Bounds ) {
 		var view = ctx.tmpBounds;
 		var view = ctx.tmpBounds;
@@ -711,46 +779,70 @@ class Object {
 		return rotation = v;
 		return rotation = v;
 	}
 	}
 
 
+	/**
+		Move the object by the specied amount along its current direction (rotation angle).
+	**/
 	public function move( dx : Float, dy : Float ) {
 	public function move( dx : Float, dy : Float ) {
 		x += dx * Math.cos(rotation);
 		x += dx * Math.cos(rotation);
 		y += dy * Math.sin(rotation);
 		y += dy * Math.sin(rotation);
 	}
 	}
 
 
+	/**
+		Set the position of the object relative to its parent.
+	**/
 	public inline function setPosition( x : Float, y : Float ) {
 	public inline function setPosition( x : Float, y : Float ) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 	}
 	}
 
 
+	/**
+		Rotate the object by the given angle (in radians)
+	**/
 	public inline function rotate( v : Float ) {
 	public inline function rotate( v : Float ) {
 		rotation += v;
 		rotation += v;
 	}
 	}
 
 
+	/**
+		Scale uniformly the object by the given factor.
+	**/
 	public inline function scale( v : Float ) {
 	public inline function scale( v : Float ) {
 		scaleX *= v;
 		scaleX *= v;
 		scaleY *= v;
 		scaleY *= v;
 	}
 	}
 
 
+	/**
+		Set the uniform scale for the object.
+	**/
 	public inline function setScale( v : Float ) {
 	public inline function setScale( v : Float ) {
 		scaleX = v;
 		scaleX = v;
 		scaleY = v;
 		scaleY = v;
 	}
 	}
 
 
+	/**
+		Return the `n`th element among our immediate children list, or null if there is no.
+	**/
 	public inline function getChildAt( n ) {
 	public inline function getChildAt( n ) {
 		return children[n];
 		return children[n];
 	}
 	}
 
 
-	public function getChildIndex( s ) {
+	/**
+		Return the index of the object `o` within our immediate children list, or `-1` if it is not part of our children list.
+	**/
+	public function getChildIndex( o ) {
 		for( i in 0...children.length )
 		for( i in 0...children.length )
-			if( children[i] == s )
+			if( children[i] == o )
 				return i;
 				return i;
 		return -1;
 		return -1;
 	}
 	}
 
 
-	public function getSpriteByName( name : String ) {
+	/**
+		Search for an object recursively by name, return null if not found.
+	**/
+	public function getObjectByName( name : String ) {
 		if( this.name == name )
 		if( this.name == name )
 			return this;
 			return this;
 		for( c in children ) {
 		for( c in children ) {
-			var o = c.getSpriteByName(name);
+			var o = c.getObjectByName(name);
 			if( o != null ) return o;
 			if( o != null ) return o;
 		}
 		}
 		return null;
 		return null;
@@ -760,6 +852,9 @@ class Object {
 		return children.length;
 		return children.length;
 	}
 	}
 
 
+	/**
+		Return an iterator over this object immediate children
+	**/
 	public inline function iterator() {
 	public inline function iterator() {
 		return new hxd.impl.ArrayIterator(children);
 		return new hxd.impl.ArrayIterator(children);
 	}
 	}

+ 196 - 28
h3d/scene/Object.hx

@@ -30,23 +30,68 @@ class Object implements hxd.impl.Serializable {
 
 
 	@:s var flags : ObjectFlags;
 	@:s var flags : ObjectFlags;
 	var children : Array<Object>;
 	var children : Array<Object>;
+
+	/**
+		The parent object in the scene tree.
+	**/
 	public var parent(default, null) : Object;
 	public var parent(default, null) : Object;
+
+	/**
+		How many immediate children this object has.
+	**/
 	public var numChildren(get, never) : Int;
 	public var numChildren(get, never) : Int;
 
 
+	/**
+		The name of the object, can be used to retrieve an object within a tree by using `getObjectByName` (default null)
+	**/
 	@:s public var name : Null<String>;
 	@:s public var name : Null<String>;
+
+	/**
+		The x position of the object relative to its parent.
+	**/
 	@:s public var x(default,set) : Float;
 	@:s public var x(default,set) : Float;
+
+	/**
+		The y position of the object relative to its parent.
+	**/
 	@:s public var y(default, set) : Float;
 	@:s public var y(default, set) : Float;
+
+	/**
+		The z position of the object relative to its parent.
+	**/
 	@:s public var z(default, set) : Float;
 	@:s public var z(default, set) : Float;
+
+	/**
+		The amount of scaling along the X axis of this object (default 1.0)
+	**/
 	@:s public var scaleX(default,set) : Float;
 	@:s public var scaleX(default,set) : Float;
+
+	/**
+		The amount of scaling along the Y axis of this object (default 1.0)
+	**/
 	@:s public var scaleY(default, set) : Float;
 	@:s public var scaleY(default, set) : Float;
+
+	/**
+		The amount of scaling along the Z axis of this object (default 1.0)
+	**/
 	@:s public var scaleZ(default,set) : Float;
 	@:s public var scaleZ(default,set) : Float;
+
+
+	/**
+		Is the object and its children are displayed on screen (default true).
+	**/
 	public var visible(get, set) : Bool;
 	public var visible(get, set) : Bool;
+
 	var allocated(get,set) : Bool;
 	var allocated(get,set) : Bool;
 
 
 	/**
 	/**
 		Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
 		Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
 	**/
 	**/
 	@:s public var follow(default, set) : Object;
 	@:s public var follow(default, set) : Object;
+
+	/**
+		When follow is set, only follow the position and ignore both scale and rotation.
+	**/
 	public var followPositionOnly(get, set) : Bool;
 	public var followPositionOnly(get, set) : Bool;
 
 
 	/**
 	/**
@@ -56,12 +101,6 @@ class Object implements hxd.impl.Serializable {
 	public var defaultTransform(default, set) : h3d.Matrix;
 	public var defaultTransform(default, set) : h3d.Matrix;
 	@:s public var currentAnimation(default, null) : h3d.anim.Animation;
 	@:s public var currentAnimation(default, null) : h3d.anim.Animation;
 
 
-	/**
-		When selecting the lights to apply to this object, we will use the camera target as reference
-		instead of the object absolute position. This is useful for very large objects so they can get good lighting.
-	**/
-	public var lightCameraCenter(get, set) : Bool;
-
 	/**
 	/**
 		Inform that the object is not to be displayed and his animation doesn't have to be sync. Unlike visible, this doesn't apply to children unless inheritCulled is set to true.
 		Inform that the object is not to be displayed and his animation doesn't have to be sync. Unlike visible, this doesn't apply to children unless inheritCulled is set to true.
 	**/
 	**/
@@ -83,7 +122,7 @@ class Object implements hxd.impl.Serializable {
 	public var ignoreBounds(get, set) : Bool;
 	public var ignoreBounds(get, set) : Bool;
 
 
 	/**
 	/**
-		When enabled, the object is ignore when using getCollider()
+		When enabled, the object is ignored when using getCollider()
 	**/
 	**/
 	public var ignoreCollide(get, set) : Bool;
 	public var ignoreCollide(get, set) : Bool;
 
 
@@ -97,12 +136,21 @@ class Object implements hxd.impl.Serializable {
 	**/
 	**/
 	public var ignoreParentTransform(get, set) : Bool;
 	public var ignoreParentTransform(get, set) : Bool;
 
 
+	/**
+		When selecting the lights to apply to this object, we will use the camera target as reference
+		instead of the object absolute position. This is useful for very large objects so they can get good lighting.
+	**/
+	public var lightCameraCenter(get, set) : Bool;
+
 	var absPos : h3d.Matrix;
 	var absPos : h3d.Matrix;
 	var invPos : h3d.Matrix;
 	var invPos : h3d.Matrix;
 	var qRot : h3d.Quat;
 	var qRot : h3d.Quat;
 	var posChanged(get,set) : Bool;
 	var posChanged(get,set) : Bool;
 	var lastFrame : Int;
 	var lastFrame : Int;
 
 
+	/**
+		Create a new empty object, and adds it to the parent object if not null.
+	**/
 	public function new( ?parent : Object ) {
 	public function new( ?parent : Object ) {
 		flags = new ObjectFlags();
 		flags = new ObjectFlags();
 		absPos = new h3d.Matrix();
 		absPos = new h3d.Matrix();
@@ -141,17 +189,23 @@ class Object implements hxd.impl.Serializable {
 	inline function set_allowSerialize(b) return !flags.set(FNoSerialize, !b);
 	inline function set_allowSerialize(b) return !flags.set(FNoSerialize, !b);
 	inline function set_ignoreParentTransform(b) return flags.set(FIgnoreParentTransform, b);
 	inline function set_ignoreParentTransform(b) return flags.set(FIgnoreParentTransform, b);
 
 
+	/**
+		Create an animation instance bound to the object, set it as currentAnimation and play it.
+	**/
 	public function playAnimation( a : h3d.anim.Animation ) {
 	public function playAnimation( a : h3d.anim.Animation ) {
 		return currentAnimation = a.createInstance(this);
 		return currentAnimation = a.createInstance(this);
 	}
 	}
 
 
 	/**
 	/**
-		Changes the current animation. This animation should be an instance that was created by playAnimation!
+		Change the current animation. This animation should be an instance that was previously created by playAnimation.
 	**/
 	**/
 	public function switchToAnimation( a : h3d.anim.Animation ) {
 	public function switchToAnimation( a : h3d.anim.Animation ) {
 		return currentAnimation = a;
 		return currentAnimation = a;
 	}
 	}
 
 
+	/**
+		Stop the current animation. If recursive is set to true, all children will also stop their animation
+	**/
 	public function stopAnimation( ?recursive = false ) {
 	public function stopAnimation( ?recursive = false ) {
 		currentAnimation = null;
 		currentAnimation = null;
 		if(recursive) {
 		if(recursive) {
@@ -184,6 +238,9 @@ class Object implements hxd.impl.Serializable {
 				c.applyAnimationTransform();
 				c.applyAnimationTransform();
 	}
 	}
 
 
+	/**
+		Return the total number of children, recursively.
+	**/
 	public function getObjectsCount() {
 	public function getObjectsCount() {
 		var k = 0;
 		var k = 0;
 		for( c in children )
 		for( c in children )
@@ -191,6 +248,9 @@ class Object implements hxd.impl.Serializable {
 		return k;
 		return k;
 	}
 	}
 
 
+	/**
+		Search for a material recursively by name, return it or null if not found.
+	**/
 	public function getMaterialByName( name : String ) : h3d.mat.Material {
 	public function getMaterialByName( name : String ) : h3d.mat.Material {
 		for( o in children ) {
 		for( o in children ) {
 			var m = o.getMaterialByName(name);
 			var m = o.getMaterialByName(name);
@@ -199,6 +259,9 @@ class Object implements hxd.impl.Serializable {
 		return null;
 		return null;
 	}
 	}
 
 
+	/**
+		Find a single object in the tree by calling `f` on each and returning the first not-null value returned, or null if not found.
+	**/
 	public function find<T>( f : Object -> Null<T> ) : Null<T> {
 	public function find<T>( f : Object -> Null<T> ) : Null<T> {
 		var v = f(this);
 		var v = f(this);
 		if( v != null )
 		if( v != null )
@@ -210,6 +273,9 @@ class Object implements hxd.impl.Serializable {
 		return null;
 		return null;
 	}
 	}
 
 
+	/**
+		Find several objects in the tree by calling `f` on each and returning all the not-null values returned.
+	**/
 	public function findAll<T>( f : Object -> Null<T>, ?arr : Array<T> ) : Array<T> {
 	public function findAll<T>( f : Object -> Null<T>, ?arr : Array<T> ) : Array<T> {
 		if( arr == null ) arr = [];
 		if( arr == null ) arr = [];
 		var v = f(this);
 		var v = f(this);
@@ -220,6 +286,9 @@ class Object implements hxd.impl.Serializable {
 		return arr;
 		return arr;
 	}
 	}
 
 
+	/**
+		Return all materials in the tree.
+	**/
 	public function getMaterials( ?a : Array<h3d.mat.Material> ) {
 	public function getMaterials( ?a : Array<h3d.mat.Material> ) {
 		if( a == null ) a = [];
 		if( a == null ) a = [];
 		for( o in children )
 		for( o in children )
@@ -228,7 +297,7 @@ class Object implements hxd.impl.Serializable {
 	}
 	}
 
 
 	/**
 	/**
-		Transform a point from the local object coordinates to the global ones. The point is modified and returned.
+		Convert a local position (or [0,0] if pt is null) relative to the object origin into an absolute global position, applying all the inherited transforms.
 	**/
 	**/
 	public function localToGlobal( ?pt : h3d.Vector ) {
 	public function localToGlobal( ?pt : h3d.Vector ) {
 		syncPos();
 		syncPos();
@@ -238,7 +307,7 @@ class Object implements hxd.impl.Serializable {
 	}
 	}
 
 
 	/**
 	/**
-		Transform a point from the global coordinates to the object local ones. The point is modified and returned.
+		Convert an absolute global position into a local position relative to the object origin, applying all the inherited transforms.
 	**/
 	**/
 	public function globalToLocal( pt : h3d.Vector ) {
 	public function globalToLocal( pt : h3d.Vector ) {
 		pt.transform3x4(getInvPos());
 		pt.transform3x4(getInvPos());
@@ -260,13 +329,17 @@ class Object implements hxd.impl.Serializable {
 	}
 	}
 
 
 	/**
 	/**
-		Return the bounds of this object, in absolute position.
+		Return the bounds of this object and all its children, in absolute global coordinates.
 	**/
 	**/
-	public function getBounds( ?b : h3d.col.Bounds, rec = false ) {
-		if( !rec )
-			syncPos();
+	@:final public function getBounds( ?b : h3d.col.Bounds ) {
 		if( b == null )
 		if( b == null )
 			b = new h3d.col.Bounds();
 			b = new h3d.col.Bounds();
+		if( parent != null )
+			parent.syncPos();
+		return getBoundsRec(b);
+	}
+
+	function getBoundsRec( b : h3d.col.Bounds ) {
 		if( posChanged ) {
 		if( posChanged ) {
 			for( c in children )
 			for( c in children )
 				c.posChanged = true;
 				c.posChanged = true;
@@ -274,10 +347,13 @@ class Object implements hxd.impl.Serializable {
 			calcAbsPos();
 			calcAbsPos();
 		}
 		}
 		for( c in children )
 		for( c in children )
-			c.getBounds(b, true);
+			c.getBoundsRec(b);
 		return b;
 		return b;
 	}
 	}
 
 
+	/**
+		Return all meshes part of this tree
+	**/
 	public function getMeshes( ?out : Array<Mesh> ) {
 	public function getMeshes( ?out : Array<Mesh> ) {
 		if( out == null ) out = [];
 		if( out == null ) out = [];
 		var m = Std.instance(this, Mesh);
 		var m = Std.instance(this, Mesh);
@@ -287,10 +363,16 @@ class Object implements hxd.impl.Serializable {
 		return out;
 		return out;
 	}
 	}
 
 
+	/**
+		Search for an mesh recursively by name, return null if not found.
+	**/
 	public function getMeshByName( name : String) {
 	public function getMeshByName( name : String) {
 		return Std.instance(getObjectByName(name), Mesh);
 		return Std.instance(getObjectByName(name), Mesh);
 	}
 	}
 
 
+	/**
+		Search for an object recursively by name, return null if not found.
+	**/
 	public function getObjectByName( name : String ) {
 	public function getObjectByName( name : String ) {
 		if( this.name == name )
 		if( this.name == name )
 			return this;
 			return this;
@@ -301,6 +383,9 @@ class Object implements hxd.impl.Serializable {
 		return null;
 		return null;
 	}
 	}
 
 
+	/**
+		Make a copy of the object and all its children.
+	**/
 	public function clone( ?o : Object ) : Object {
 	public function clone( ?o : Object ) : Object {
 		if( o == null ) o = new Object();
 		if( o == null ) o = new Object();
 		#if debug
 		#if debug
@@ -327,10 +412,16 @@ class Object implements hxd.impl.Serializable {
 		return o;
 		return o;
 	}
 	}
 
 
+	/**
+		Add a child object at the end of the children list.
+	**/
 	public function addChild( o : Object ) {
 	public function addChild( o : Object ) {
 		addChildAt(o, children.length);
 		addChildAt(o, children.length);
 	}
 	}
 
 
+	/**
+		Insert a child object at the specified position of the children list.
+	**/
 	public function addChildAt( o : Object, pos : Int ) {
 	public function addChildAt( o : Object, pos : Int ) {
 		if( pos < 0 ) pos = 0;
 		if( pos < 0 ) pos = 0;
 		if( pos > children.length ) pos = children.length;
 		if( pos > children.length ) pos = children.length;
@@ -360,6 +451,9 @@ class Object implements hxd.impl.Serializable {
 		}
 		}
 	}
 	}
 
 
+	/**
+		Iterate on all mesh that are currently visible and not culled in the tree. Call `callb` for each mesh found.
+	**/
 	public function iterVisibleMeshes( callb : Mesh -> Void ) {
 	public function iterVisibleMeshes( callb : Mesh -> Void ) {
 		if( !visible || (culled && inheritCulled) )
 		if( !visible || (culled && inheritCulled) )
 			return;
 			return;
@@ -390,6 +484,9 @@ class Object implements hxd.impl.Serializable {
 			c.onRemove();
 			c.onRemove();
 	}
 	}
 
 
+	/**
+		Remove the given object from our immediate children list if it's part of it.
+	**/
 	public function removeChild( o : Object ) {
 	public function removeChild( o : Object ) {
 		if( children.remove(o) ) {
 		if( children.remove(o) ) {
 			if( o.allocated ) o.onRemove();
 			if( o.allocated ) o.onRemove();
@@ -398,7 +495,26 @@ class Object implements hxd.impl.Serializable {
 		}
 		}
 	}
 	}
 
 
-	function getScene() {
+	/**
+		Remove all children from our immediate children list
+	**/
+	public function removeChildren() {
+		while( numChildren>0 )
+			removeChild( getChildAt(0) );
+	}
+
+	/**
+		Same as parent.removeChild(this), but does nothing if parent is null.
+		In order to capture add/removal from scene, you can override onAdd/onRemove/onParentChanged
+	**/
+	public inline function remove() {
+		if( this != null && parent != null ) parent.removeChild(this);
+	}
+
+	/**
+		Return the Scene this object is part of, or null if not added to a Scene.
+	**/
+	public function getScene() {
 		var p = this;
 		var p = this;
 		while( p.parent != null ) p = p.parent;
 		while( p.parent != null ) p = p.parent;
 		return Std.instance(p, Scene);
 		return Std.instance(p, Scene);
@@ -412,10 +528,16 @@ class Object implements hxd.impl.Serializable {
 		return absPos;
 		return absPos;
 	}
 	}
 
 
+	/**
+		Tell if the object is a Mesh.
+	**/
 	public inline function isMesh() {
 	public inline function isMesh() {
 		return Std.instance(this, Mesh) != null;
 		return Std.instance(this, Mesh) != null;
 	}
 	}
 
 
+	/**
+		If the object is a Mesh, return the corresponding Mesh. If not, throw an exception.
+	**/
 	public function toMesh() : Mesh {
 	public function toMesh() : Mesh {
 		var m = Std.instance(this, Mesh);
 		var m = Std.instance(this, Mesh);
 		if( m != null )
 		if( m != null )
@@ -424,7 +546,7 @@ class Object implements hxd.impl.Serializable {
 	}
 	}
 
 
 	/**
 	/**
-		Build and returns the global absolute recursive collider for the object.
+		Build and return the global absolute recursive collider for the object.
 		Returns null if no collider was found or if ignoreCollide was set to true.
 		Returns null if no collider was found or if ignoreCollide was set to true.
 	**/
 	**/
 	@:final public function getCollider() : h3d.col.Collider {
 	@:final public function getCollider() : h3d.col.Collider {
@@ -469,14 +591,6 @@ class Object implements hxd.impl.Serializable {
 		return null;
 		return null;
 	}
 	}
 
 
-	/**
-		Same as parent.removeChild(this), but does nothing if parent is null.
-		In order to capture add/removal from scene, you can override onAdd/onRemove/onParentChanged
-	**/
-	public inline function remove() {
-		if( this != null && parent != null ) parent.removeChild(this);
-	}
-
 	function draw( ctx : RenderContext ) {
 	function draw( ctx : RenderContext ) {
 	}
 	}
 
 
@@ -633,6 +747,9 @@ class Object implements hxd.impl.Serializable {
 		return v;
 		return v;
 	}
 	}
 
 
+	/**
+		Set the position of the object relative to its parent.
+	**/
 	public inline function setPosition( x : Float, y : Float, z : Float ) {
 	public inline function setPosition( x : Float, y : Float, z : Float ) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
@@ -640,6 +757,9 @@ class Object implements hxd.impl.Serializable {
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Set the position, scale and rotation of the object relative to its parent based on the specified transform matrix.
+	**/
 	public function setTransform( mat : h3d.Matrix ) {
 	public function setTransform( mat : h3d.Matrix ) {
 		var s = mat.getScale();
 		var s = mat.getScale();
 		this.x = mat.tx;
 		this.x = mat.tx;
@@ -653,9 +773,9 @@ class Object implements hxd.impl.Serializable {
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
-	/*
-		Rotate around the current rotation axis.
-	*/
+	/**
+		Rotate around the current rotation axis by the specified angles (in radian).
+	**/
 	public function rotate( rx : Float, ry : Float, rz : Float ) {
 	public function rotate( rx : Float, ry : Float, rz : Float ) {
 		var qTmp = new h3d.Quat();
 		var qTmp = new h3d.Quat();
 		qTmp.initRotation(rx, ry, rz);
 		qTmp.initRotation(rx, ry, rz);
@@ -663,34 +783,57 @@ class Object implements hxd.impl.Serializable {
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Set the rotation using the specified angles (in radian).
+	**/
 	public function setRotation( rx : Float, ry : Float, rz : Float ) {
 	public function setRotation( rx : Float, ry : Float, rz : Float ) {
 		qRot.initRotation(rx, ry, rz);
 		qRot.initRotation(rx, ry, rz);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Set the rotation using the specified axis and angle of rotation around it (in radian).
+	**/
 	public function setRotationAxis( ax : Float, ay : Float, az : Float, angle : Float ) {
 	public function setRotationAxis( ax : Float, ay : Float, az : Float, angle : Float ) {
 		qRot.initRotateAxis(ax, ay, az, angle);
 		qRot.initRotateAxis(ax, ay, az, angle);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Set the rotation using the specified look at direction
+	**/
 	public function setDirection( v : h3d.Vector ) {
 	public function setDirection( v : h3d.Vector ) {
 		qRot.initDirection(v);
 		qRot.initDirection(v);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Return the direction in which the object rotation is currently oriented to
+	**/
 	public function getDirection() {
 	public function getDirection() {
 		return qRot.getDirection();
 		return qRot.getDirection();
 	}
 	}
 
 
+	/**
+		Return the quaternion representing the current object rotation.
+		Dot not modify as it's not a copy.
+	**/
 	public function getRotationQuat() {
 	public function getRotationQuat() {
 		return qRot;
 		return qRot;
 	}
 	}
 
 
+	/**
+		Set the quaternion representing the current object rotation.
+		Dot not modify the value afterwards as no copy is made.
+	**/
 	public function setRotationQuat(q) {
 	public function setRotationQuat(q) {
 		qRot = q;
 		qRot = q;
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Scale uniformly the object by the given factor.
+	**/
 	public inline function scale( v : Float ) {
 	public inline function scale( v : Float ) {
 		scaleX *= v;
 		scaleX *= v;
 		scaleY *= v;
 		scaleY *= v;
@@ -698,6 +841,9 @@ class Object implements hxd.impl.Serializable {
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Set the uniform scale for the object.
+	**/
 	public inline function setScale( v : Float ) {
 	public inline function setScale( v : Float ) {
 		scaleX = v;
 		scaleX = v;
 		scaleY = v;
 		scaleY = v;
@@ -705,22 +851,44 @@ class Object implements hxd.impl.Serializable {
 		posChanged = true;
 		posChanged = true;
 	}
 	}
 
 
+	/**
+		Return both class name and object name if any.
+	**/
 	public function toString() {
 	public function toString() {
 		return Type.getClassName(Type.getClass(this)).split(".").pop() + (name == null ? "" : "(" + name + ")");
 		return Type.getClassName(Type.getClass(this)).split(".").pop() + (name == null ? "" : "(" + name + ")");
 	}
 	}
 
 
+	/**
+		Return the `n`th element among our immediate children list, or null if there is no.
+	**/
 	public inline function getChildAt( n ) {
 	public inline function getChildAt( n ) {
 		return children[n];
 		return children[n];
 	}
 	}
 
 
+	/**
+		Return the index of the object `o` within our immediate children list, or `-1` if it is not part of our children list.
+	**/
+	public function getChildIndex( o ) {
+		for( i in 0...children.length )
+			if( children[i] == o )
+				return i;
+		return -1;
+	}
+
 	inline function get_numChildren() {
 	inline function get_numChildren() {
 		return children.length;
 		return children.length;
 	}
 	}
 
 
+	/**
+		Return an iterator over this object immediate children
+	**/
 	public inline function iterator() : hxd.impl.ArrayIterator<Object> {
 	public inline function iterator() : hxd.impl.ArrayIterator<Object> {
 		return new hxd.impl.ArrayIterator(children);
 		return new hxd.impl.ArrayIterator(children);
 	}
 	}
 
 
+	/**
+		Free the GPU memory for this object and its children
+	**/
 	public function dispose() {
 	public function dispose() {
 		for( c in children )
 		for( c in children )
 			c.dispose();
 			c.dispose();