73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
|
/**
|
||
|
* Entities with LookAt component looks to targetPosition (default up is 0,1,0)
|
||
|
* @param graphics GameLib.D3.Graphics
|
||
|
* @param parentObject
|
||
|
* @param apiLookAt GameLib.D3.API.LookAt
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.LookAt = function RuntimeLookAt(
|
||
|
graphics,
|
||
|
parentObject,
|
||
|
apiLookAt
|
||
|
) {
|
||
|
this.graphics = graphics;
|
||
|
this.graphics.isNotThreeThrow();
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(parentObject)) {
|
||
|
parentObject = null;
|
||
|
}
|
||
|
this.parentObject = parentObject;
|
||
|
|
||
|
GameLib.D3.API.LookAt.call(
|
||
|
this,
|
||
|
apiLookAt.id,
|
||
|
apiLookAt.name,
|
||
|
apiLookAt.currentPosition,
|
||
|
apiLookAt.targetPosition,
|
||
|
apiLookAt.targetPositionOffset,
|
||
|
apiLookAt.rotationSpeed,
|
||
|
apiLookAt.lookAtMatrix,
|
||
|
apiLookAt.up,
|
||
|
apiLookAt.currentRotation
|
||
|
);
|
||
|
|
||
|
this.currentPosition = new GameLib.Vector3(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.currentPosition
|
||
|
);
|
||
|
|
||
|
this.targetPosition = new GameLib.Vector3(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.targetPosition
|
||
|
);
|
||
|
|
||
|
this.targetOffset = new GameLib.Vector3(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.targetOffset
|
||
|
);
|
||
|
|
||
|
this.lookAtMatrix = new GameLib.Matrix4(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.lookAtMatrix
|
||
|
);
|
||
|
|
||
|
this.up = new GameLib.Vector3(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.up
|
||
|
);
|
||
|
|
||
|
this.currentRotation = new GameLib.Quaternion(
|
||
|
this.graphics,
|
||
|
this,
|
||
|
this.currentRotation
|
||
|
);
|
||
|
};
|
||
|
|
||
|
GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype);
|
||
|
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt;
|