|
@@ -1,4 +1,8 @@
|
|
module BABYLON {
|
|
module BABYLON {
|
|
|
|
+ /**
|
|
|
|
+ * Class used to make a bone look toward a point in space
|
|
|
|
+ * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
|
|
|
|
+ */
|
|
export class BoneLookController {
|
|
export class BoneLookController {
|
|
|
|
|
|
private static _tmpVecs: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero()];
|
|
private static _tmpVecs: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero()];
|
|
@@ -6,47 +10,47 @@ module BABYLON {
|
|
private static _tmpMats: Matrix[] = [Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity()];
|
|
private static _tmpMats: Matrix[] = [Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity()];
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The target Vector3 that the bone will look at.
|
|
|
|
|
|
+ * The target Vector3 that the bone will look at
|
|
*/
|
|
*/
|
|
public target: Vector3;
|
|
public target: Vector3;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The mesh that the bone is attached to.
|
|
|
|
|
|
+ * The mesh that the bone is attached to
|
|
*/
|
|
*/
|
|
public mesh: AbstractMesh;
|
|
public mesh: AbstractMesh;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The bone that will be looking to the target.
|
|
|
|
|
|
+ * The bone that will be looking to the target
|
|
*/
|
|
*/
|
|
public bone: Bone;
|
|
public bone: Bone;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The up axis of the coordinate system that is used when the bone is rotated.
|
|
|
|
|
|
+ * The up axis of the coordinate system that is used when the bone is rotated
|
|
*/
|
|
*/
|
|
public upAxis: Vector3 = Vector3.Up();
|
|
public upAxis: Vector3 = Vector3.Up();
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
|
|
|
|
|
|
+ * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
|
|
*/
|
|
*/
|
|
public upAxisSpace: Space = Space.LOCAL;
|
|
public upAxisSpace: Space = Space.LOCAL;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Used to make an adjustment to the yaw of the bone.
|
|
|
|
|
|
+ * Used to make an adjustment to the yaw of the bone
|
|
*/
|
|
*/
|
|
public adjustYaw = 0;
|
|
public adjustYaw = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Used to make an adjustment to the pitch of the bone.
|
|
|
|
|
|
+ * Used to make an adjustment to the pitch of the bone
|
|
*/
|
|
*/
|
|
public adjustPitch = 0;
|
|
public adjustPitch = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Used to make an adjustment to the roll of the bone.
|
|
|
|
|
|
+ * Used to make an adjustment to the roll of the bone
|
|
*/
|
|
*/
|
|
public adjustRoll = 0;
|
|
public adjustRoll = 0;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp).
|
|
|
|
|
|
+ * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
|
|
*/
|
|
*/
|
|
public slerpAmount = 1;
|
|
public slerpAmount = 1;
|
|
|
|
|
|
@@ -71,7 +75,7 @@ module BABYLON {
|
|
private _fowardAxis: Vector3 = Vector3.Forward();
|
|
private _fowardAxis: Vector3 = Vector3.Forward();
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get/set the minimum yaw angle that the bone can look to.
|
|
|
|
|
|
+ * Gets or sets the minimum yaw angle that the bone can look to
|
|
*/
|
|
*/
|
|
get minYaw(): number {
|
|
get minYaw(): number {
|
|
return this._minYaw;
|
|
return this._minYaw;
|
|
@@ -88,7 +92,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get/set the maximum yaw angle that the bone can look to.
|
|
|
|
|
|
+ * Gets or sets the maximum yaw angle that the bone can look to
|
|
*/
|
|
*/
|
|
get maxYaw(): number {
|
|
get maxYaw(): number {
|
|
return this._maxYaw;
|
|
return this._maxYaw;
|
|
@@ -105,7 +109,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get/set the minimum pitch angle that the bone can look to.
|
|
|
|
|
|
+ * Gets or sets the minimum pitch angle that the bone can look to
|
|
*/
|
|
*/
|
|
get minPitch(): number {
|
|
get minPitch(): number {
|
|
return this._minPitch;
|
|
return this._minPitch;
|
|
@@ -117,7 +121,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get/set the maximum pitch angle that the bone can look to.
|
|
|
|
|
|
+ * Gets or sets the maximum pitch angle that the bone can look to
|
|
*/
|
|
*/
|
|
get maxPitch(): number {
|
|
get maxPitch(): number {
|
|
return this._maxPitch;
|
|
return this._maxPitch;
|
|
@@ -134,18 +138,18 @@ module BABYLON {
|
|
* @param bone the bone that will be looking to the target
|
|
* @param bone the bone that will be looking to the target
|
|
* @param target the target Vector3 to look at
|
|
* @param target the target Vector3 to look at
|
|
* @param settings optional settings:
|
|
* @param settings optional settings:
|
|
- * - maxYaw: the maximum angle the bone will yaw to
|
|
|
|
- * - minYaw: the minimum angle the bone will yaw to
|
|
|
|
- * - maxPitch: the maximum angle the bone will pitch to
|
|
|
|
- * - minPitch: the minimum angle the bone will yaw to
|
|
|
|
- * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
|
|
|
|
- * - upAxis: the up axis of the coordinate system
|
|
|
|
- * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
|
|
|
|
- * - yawAxis: set yawAxis if the bone does not yaw on the y axis
|
|
|
|
- * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
|
|
|
|
- * - adjustYaw: used to make an adjustment to the yaw of the bone
|
|
|
|
- * - adjustPitch: used to make an adjustment to the pitch of the bone
|
|
|
|
- * - adjustRoll: used to make an adjustment to the roll of the bone
|
|
|
|
|
|
+ * * maxYaw: the maximum angle the bone will yaw to
|
|
|
|
+ * * minYaw: the minimum angle the bone will yaw to
|
|
|
|
+ * * maxPitch: the maximum angle the bone will pitch to
|
|
|
|
+ * * minPitch: the minimum angle the bone will yaw to
|
|
|
|
+ * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
|
|
|
|
+ * * upAxis: the up axis of the coordinate system
|
|
|
|
+ * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
|
|
|
|
+ * * yawAxis: set yawAxis if the bone does not yaw on the y axis
|
|
|
|
+ * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
|
|
|
|
+ * * adjustYaw: used to make an adjustment to the yaw of the bone
|
|
|
|
+ * * adjustPitch: used to make an adjustment to the pitch of the bone
|
|
|
|
+ * * adjustRoll: used to make an adjustment to the roll of the bone
|
|
**/
|
|
**/
|
|
constructor(mesh: AbstractMesh,
|
|
constructor(mesh: AbstractMesh,
|
|
bone: Bone,
|
|
bone: Bone,
|
|
@@ -253,7 +257,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
|
|
|
|
|
|
+ * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
|
|
*/
|
|
*/
|
|
public update(): void {
|
|
public update(): void {
|
|
|
|
|