|
@@ -53046,6 +53046,486 @@ var BABYLON;
|
|
//# sourceMappingURL=babylon.arcRotateCamera.js.map
|
|
//# sourceMappingURL=babylon.arcRotateCamera.js.map
|
|
|
|
|
|
|
|
|
|
|
|
+var BABYLON;
|
|
|
|
+(function (BABYLON) {
|
|
|
|
+ /**
|
|
|
|
+ * Manage the keyboard inputs to control the movement of an arc rotate camera.
|
|
|
|
+ * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
|
|
|
|
+ */
|
|
|
|
+ var FollowCameraKeyboardMoveInput = /** @class */ (function () {
|
|
|
|
+ function FollowCameraKeyboardMoveInput() {
|
|
|
|
+ /**
|
|
|
|
+ * Defines the list of key codes associated with the up action (increase heightOffset)
|
|
|
|
+ */
|
|
|
|
+ this.keysUp = [38];
|
|
|
|
+ /**
|
|
|
|
+ * Defines the list of key codes associated with the down action (decrease heightOffset)
|
|
|
|
+ */
|
|
|
|
+ this.keysDown = [40];
|
|
|
|
+ /**
|
|
|
|
+ * Defines the list of key codes associated with the left action (increase rotation)
|
|
|
|
+ */
|
|
|
|
+ this.keysLeft = [37];
|
|
|
|
+ /**
|
|
|
|
+ * Defines the list of key codes associated with the right action (decrease rotation)
|
|
|
|
+ */
|
|
|
|
+ this.keysRight = [39];
|
|
|
|
+ /**
|
|
|
|
+ * Defines the rate of change of heightOffset.
|
|
|
|
+ */
|
|
|
|
+ this.heightSensibility = 1;
|
|
|
|
+ /**
|
|
|
|
+ * Defines the rate of change of rotationOffset.
|
|
|
|
+ */
|
|
|
|
+ this.rotationSensibility = 1;
|
|
|
|
+ /**
|
|
|
|
+ * Defines the rate of change of radius.
|
|
|
|
+ */
|
|
|
|
+ this.radiusSensibility = 1;
|
|
|
|
+ /**
|
|
|
|
+ * Defines the minimum heightOffset value.
|
|
|
|
+ */
|
|
|
|
+ this.minHeightOffset = 0;
|
|
|
|
+ /**
|
|
|
|
+ * Defines the minimum radius value.
|
|
|
|
+ */
|
|
|
|
+ this.minRadius = 0;
|
|
|
|
+ this._keys = new Array();
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * Attach the input controls to a specific dom element to get the input from.
|
|
|
|
+ * @param element Defines the element the controls should be listened from
|
|
|
|
+ * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
|
|
|
|
+ */
|
|
|
|
+ FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
|
|
|
|
+ var _this = this;
|
|
|
|
+ if (this._onCanvasBlurObserver) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._scene = this.camera.getScene();
|
|
|
|
+ this._engine = this._scene.getEngine();
|
|
|
|
+ this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
|
|
|
|
+ _this._keys = [];
|
|
|
|
+ });
|
|
|
|
+ this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
|
|
|
|
+ var evt = info.event;
|
|
|
|
+ if (!evt.metaKey) {
|
|
|
|
+ if (info.type === BABYLON.KeyboardEventTypes.KEYDOWN) {
|
|
|
|
+ // this._ctrlPressed = evt.ctrlKey;
|
|
|
|
+ _this._altPressed = evt.altKey;
|
|
|
|
+ if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysDown.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysRight.indexOf(evt.keyCode) !== -1) {
|
|
|
|
+ var index = _this._keys.indexOf(evt.keyCode);
|
|
|
|
+ if (index === -1) {
|
|
|
|
+ _this._keys.push(evt.keyCode);
|
|
|
|
+ }
|
|
|
|
+ if (evt.preventDefault) {
|
|
|
|
+ if (!noPreventDefault) {
|
|
|
|
+ evt.preventDefault();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysDown.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
|
|
|
|
+ _this.keysRight.indexOf(evt.keyCode) !== -1) {
|
|
|
|
+ var index = _this._keys.indexOf(evt.keyCode);
|
|
|
|
+ if (index >= 0) {
|
|
|
|
+ _this._keys.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ if (evt.preventDefault) {
|
|
|
|
+ if (!noPreventDefault) {
|
|
|
|
+ evt.preventDefault();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Detach the current controls from the specified dom element.
|
|
|
|
+ * @param element Defines the element to stop listening the inputs from
|
|
|
|
+ */
|
|
|
|
+ FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
|
|
|
|
+ if (this._scene) {
|
|
|
|
+ if (this._onKeyboardObserver) {
|
|
|
|
+ this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
|
|
|
|
+ }
|
|
|
|
+ if (this._onCanvasBlurObserver) {
|
|
|
|
+ this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
|
|
|
|
+ }
|
|
|
|
+ this._onKeyboardObserver = null;
|
|
|
|
+ this._onCanvasBlurObserver = null;
|
|
|
|
+ }
|
|
|
|
+ this._keys = [];
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Update the current camera state depending on the inputs that have been used this frame.
|
|
|
|
+ * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
|
|
|
|
+ */
|
|
|
|
+ FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
|
|
|
|
+ if (this._onKeyboardObserver) {
|
|
|
|
+ for (var index = 0; index < this._keys.length; index++) {
|
|
|
|
+ var keyCode = this._keys[index];
|
|
|
|
+ if (this.keysLeft.indexOf(keyCode) !== -1) {
|
|
|
|
+ this.camera.rotationOffset += this.rotationSensibility;
|
|
|
|
+ this.camera.rotationOffset %= 180;
|
|
|
|
+ }
|
|
|
|
+ else if (this.keysUp.indexOf(keyCode) !== -1) {
|
|
|
|
+ if (this._altPressed) {
|
|
|
|
+ this.camera.radius += this.radiusSensibility;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ this.camera.heightOffset += this.heightSensibility;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (this.keysRight.indexOf(keyCode) !== -1) {
|
|
|
|
+ this.camera.rotationOffset -= this.rotationSensibility;
|
|
|
|
+ this.camera.rotationOffset %= 180;
|
|
|
|
+ }
|
|
|
|
+ else if (this.keysDown.indexOf(keyCode) !== -1) {
|
|
|
|
+ if (this._altPressed) {
|
|
|
|
+ this.camera.radius -= this.radiusSensibility;
|
|
|
|
+ this.camera.radius =
|
|
|
|
+ Math.max(this.minRadius, this.camera.radius);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ this.camera.heightOffset -= this.heightSensibility;
|
|
|
|
+ this.camera.heightOffset =
|
|
|
|
+ Math.max(this.minHeightOffset, this.camera.heightOffset);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Gets the class name of the current intput.
|
|
|
|
+ * @returns the class name
|
|
|
|
+ */
|
|
|
|
+ FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
|
|
|
|
+ return "FollowCameraKeyboardMoveInput";
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Get the friendly name associated with the input class.
|
|
|
|
+ * @returns the input friendly name
|
|
|
|
+ */
|
|
|
|
+ FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
|
|
|
|
+ return "keyboard";
|
|
|
|
+ };
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "keysUp", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "keysDown", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "keysRight", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "minHeightOffset", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCameraKeyboardMoveInput.prototype, "minRadius", void 0);
|
|
|
|
+ return FollowCameraKeyboardMoveInput;
|
|
|
|
+ }());
|
|
|
|
+ BABYLON.FollowCameraKeyboardMoveInput = FollowCameraKeyboardMoveInput;
|
|
|
|
+ BABYLON.CameraInputTypes["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
|
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
|
+
|
|
|
|
+//# sourceMappingURL=babylon.followCameraKeyboardMoveInput.js.map
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+var BABYLON;
|
|
|
|
+(function (BABYLON) {
|
|
|
|
+ /**
|
|
|
|
+ * Default Inputs manager for the FollowCamera.
|
|
|
|
+ * It groups all the default supported inputs for ease of use.
|
|
|
|
+ * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
|
|
|
|
+ */
|
|
|
|
+ var FollowCameraInputsManager = /** @class */ (function (_super) {
|
|
|
|
+ __extends(FollowCameraInputsManager, _super);
|
|
|
|
+ /**
|
|
|
|
+ * Instantiates a new FollowCameraInputsManager.
|
|
|
|
+ * @param camera Defines the camera the inputs belong to
|
|
|
|
+ */
|
|
|
|
+ function FollowCameraInputsManager(camera) {
|
|
|
|
+ return _super.call(this, camera) || this;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * Add keyboard input support to the input manager.
|
|
|
|
+ * @returns the current input manager
|
|
|
|
+ */
|
|
|
|
+ FollowCameraInputsManager.prototype.addKeyboard = function () {
|
|
|
|
+ this.add(new BABYLON.FollowCameraKeyboardMoveInput());
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Add mouse wheel input support to the input manager.
|
|
|
|
+ * @returns the current input manager
|
|
|
|
+ */
|
|
|
|
+ FollowCameraInputsManager.prototype.addMouseWheel = function () {
|
|
|
|
+ console.warn("MouseWheel support not yet implemented for FollowCamera.");
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Add pointers input support to the input manager.
|
|
|
|
+ * @returns the current input manager
|
|
|
|
+ */
|
|
|
|
+ FollowCameraInputsManager.prototype.addPointers = function () {
|
|
|
|
+ console.warn("Pointer support not yet implemented for FollowCamera.");
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Add orientation input support to the input manager.
|
|
|
|
+ * @returns the current input manager
|
|
|
|
+ */
|
|
|
|
+ FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
|
|
|
|
+ console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
|
|
+ return FollowCameraInputsManager;
|
|
|
|
+ }(BABYLON.CameraInputsManager));
|
|
|
|
+ BABYLON.FollowCameraInputsManager = FollowCameraInputsManager;
|
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
|
+
|
|
|
|
+//# sourceMappingURL=babylon.followCameraInputsManager.js.map
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+var BABYLON;
|
|
|
|
+(function (BABYLON) {
|
|
|
|
+ BABYLON.Node.AddNodeConstructor("FollowCamera", function (name, scene) {
|
|
|
|
+ return function () { return new FollowCamera(name, BABYLON.Vector3.Zero(), scene); };
|
|
|
|
+ });
|
|
|
|
+ BABYLON.Node.AddNodeConstructor("ArcFollowCamera", function (name, scene) {
|
|
|
|
+ return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
|
|
|
|
+ });
|
|
|
|
+ /**
|
|
|
|
+ * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
|
|
|
|
+ * an arc rotate version arcFollowCamera are available.
|
|
|
|
+ * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
+ */
|
|
|
|
+ var FollowCamera = /** @class */ (function (_super) {
|
|
|
|
+ __extends(FollowCamera, _super);
|
|
|
|
+ /**
|
|
|
|
+ * Instantiates the follow camera.
|
|
|
|
+ * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
+ * @param name Define the name of the camera in the scene
|
|
|
|
+ * @param position Define the position of the camera
|
|
|
|
+ * @param scene Define the scene the camera belong to
|
|
|
|
+ * @param lockedTarget Define the target of the camera
|
|
|
|
+ */
|
|
|
|
+ function FollowCamera(name, position, scene, lockedTarget) {
|
|
|
|
+ if (lockedTarget === void 0) { lockedTarget = null; }
|
|
|
|
+ var _this = _super.call(this, name, position, scene) || this;
|
|
|
|
+ /**
|
|
|
|
+ * Distance the follow camera should follow an object at
|
|
|
|
+ */
|
|
|
|
+ _this.radius = 12;
|
|
|
|
+ /**
|
|
|
|
+ * Define a rotation offset between the camera and the object it follows
|
|
|
|
+ */
|
|
|
|
+ _this.rotationOffset = 0;
|
|
|
|
+ /**
|
|
|
|
+ * Define a height offset between the camera and the object it follows.
|
|
|
|
+ * It can help following an object from the top (like a car chaing a plane)
|
|
|
|
+ */
|
|
|
|
+ _this.heightOffset = 4;
|
|
|
|
+ /**
|
|
|
|
+ * Define how fast the camera can accelerate to follow it s target.
|
|
|
|
+ */
|
|
|
|
+ _this.cameraAcceleration = 0.05;
|
|
|
|
+ /**
|
|
|
|
+ * Define the speed limit of the camera following an object.
|
|
|
|
+ */
|
|
|
|
+ _this.maxCameraSpeed = 20;
|
|
|
|
+ _this.lockedTarget = lockedTarget;
|
|
|
|
+ _this.inputs = new BABYLON.FollowCameraInputsManager(_this);
|
|
|
|
+ _this.inputs.addKeyboard();
|
|
|
|
+ return _this;
|
|
|
|
+ // Uncomment the following line when the relevant handlers have been implemented.
|
|
|
|
+ // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
|
|
|
|
+ }
|
|
|
|
+ FollowCamera.prototype._follow = function (cameraTarget) {
|
|
|
|
+ if (!cameraTarget) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var yRotation;
|
|
|
|
+ if (cameraTarget.rotationQuaternion) {
|
|
|
|
+ var rotMatrix = new BABYLON.Matrix();
|
|
|
|
+ cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
|
|
|
|
+ yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ yRotation = cameraTarget.rotation.y;
|
|
|
|
+ }
|
|
|
|
+ var radians = BABYLON.Tools.ToRadians(this.rotationOffset) + yRotation;
|
|
|
|
+ var targetPosition = cameraTarget.getAbsolutePosition();
|
|
|
|
+ var targetX = targetPosition.x + Math.sin(radians) * this.radius;
|
|
|
|
+ var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
|
|
|
|
+ var dx = targetX - this.position.x;
|
|
|
|
+ var dy = (targetPosition.y + this.heightOffset) - this.position.y;
|
|
|
|
+ var dz = (targetZ) - this.position.z;
|
|
|
|
+ var vx = dx * this.cameraAcceleration * 2; //this is set to .05
|
|
|
|
+ var vy = dy * this.cameraAcceleration;
|
|
|
|
+ var vz = dz * this.cameraAcceleration * 2;
|
|
|
|
+ if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
|
|
|
|
+ vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
+ }
|
|
|
|
+ if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
|
|
|
|
+ vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
+ }
|
|
|
|
+ if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
|
|
|
|
+ vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
+ }
|
|
|
|
+ this.position = new BABYLON.Vector3(this.position.x + vx, this.position.y + vy, this.position.z + vz);
|
|
|
|
+ this.setTarget(targetPosition);
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Attached controls to the current camera.
|
|
|
|
+ * @param element Defines the element the controls should be listened from
|
|
|
|
+ * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
|
|
|
|
+ */
|
|
|
|
+ FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
|
|
|
|
+ this.inputs.attachElement(element, noPreventDefault);
|
|
|
|
+ this._reset = function () {
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Detach the current controls from the camera.
|
|
|
|
+ * The camera will stop reacting to inputs.
|
|
|
|
+ * @param element Defines the element to stop listening the inputs from
|
|
|
|
+ */
|
|
|
|
+ FollowCamera.prototype.detachControl = function (element) {
|
|
|
|
+ this.inputs.detachElement(element);
|
|
|
|
+ if (this._reset) {
|
|
|
|
+ this._reset();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /** @hidden */
|
|
|
|
+ FollowCamera.prototype._checkInputs = function () {
|
|
|
|
+ this.inputs.checkInputs();
|
|
|
|
+ _super.prototype._checkInputs.call(this);
|
|
|
|
+ if (this.lockedTarget) {
|
|
|
|
+ this._follow(this.lockedTarget);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Gets the camera class name.
|
|
|
|
+ * @returns the class name
|
|
|
|
+ */
|
|
|
|
+ FollowCamera.prototype.getClassName = function () {
|
|
|
|
+ return "FollowCamera";
|
|
|
|
+ };
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCamera.prototype, "radius", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCamera.prototype, "rotationOffset", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCamera.prototype, "heightOffset", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCamera.prototype, "cameraAcceleration", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serialize()
|
|
|
|
+ ], FollowCamera.prototype, "maxCameraSpeed", void 0);
|
|
|
|
+ __decorate([
|
|
|
|
+ BABYLON.serializeAsMeshReference("lockedTargetId")
|
|
|
|
+ ], FollowCamera.prototype, "lockedTarget", void 0);
|
|
|
|
+ return FollowCamera;
|
|
|
|
+ }(BABYLON.TargetCamera));
|
|
|
|
+ BABYLON.FollowCamera = FollowCamera;
|
|
|
|
+ /**
|
|
|
|
+ * Arc Rotate version of the follow camera.
|
|
|
|
+ * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
|
|
|
|
+ * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
+ */
|
|
|
|
+ var ArcFollowCamera = /** @class */ (function (_super) {
|
|
|
|
+ __extends(ArcFollowCamera, _super);
|
|
|
|
+ /**
|
|
|
|
+ * Instantiates a new ArcFollowCamera
|
|
|
|
+ * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
+ * @param name Define the name of the camera
|
|
|
|
+ * @param alpha Define the rotation angle of the camera around the logitudinal axis
|
|
|
|
+ * @param beta Define the rotation angle of the camera around the elevation axis
|
|
|
|
+ * @param radius Define the radius of the camera from its target point
|
|
|
|
+ * @param target Define the target of the camera
|
|
|
|
+ * @param scene Define the scene the camera belongs to
|
|
|
|
+ */
|
|
|
|
+ function ArcFollowCamera(name,
|
|
|
|
+ /** The longitudinal angle of the camera */
|
|
|
|
+ alpha,
|
|
|
|
+ /** The latitudinal angle of the camera */
|
|
|
|
+ beta,
|
|
|
|
+ /** The radius of the camera from its target */
|
|
|
|
+ radius,
|
|
|
|
+ /** Define the camera target (the messh it should follow) */
|
|
|
|
+ target, scene) {
|
|
|
|
+ var _this = _super.call(this, name, BABYLON.Vector3.Zero(), scene) || this;
|
|
|
|
+ _this.alpha = alpha;
|
|
|
|
+ _this.beta = beta;
|
|
|
|
+ _this.radius = radius;
|
|
|
|
+ _this.target = target;
|
|
|
|
+ _this._cartesianCoordinates = BABYLON.Vector3.Zero();
|
|
|
|
+ _this._follow();
|
|
|
|
+ return _this;
|
|
|
|
+ }
|
|
|
|
+ ArcFollowCamera.prototype._follow = function () {
|
|
|
|
+ if (!this.target) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
|
|
|
|
+ this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
|
|
|
|
+ this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
|
|
|
|
+ var targetPosition = this.target.getAbsolutePosition();
|
|
|
|
+ this.position = targetPosition.add(this._cartesianCoordinates);
|
|
|
|
+ this.setTarget(targetPosition);
|
|
|
|
+ };
|
|
|
|
+ /** @hidden */
|
|
|
|
+ ArcFollowCamera.prototype._checkInputs = function () {
|
|
|
|
+ _super.prototype._checkInputs.call(this);
|
|
|
|
+ this._follow();
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Returns the class name of the object.
|
|
|
|
+ * It is mostly used internally for serialization purposes.
|
|
|
|
+ */
|
|
|
|
+ ArcFollowCamera.prototype.getClassName = function () {
|
|
|
|
+ return "ArcFollowCamera";
|
|
|
|
+ };
|
|
|
|
+ return ArcFollowCamera;
|
|
|
|
+ }(BABYLON.TargetCamera));
|
|
|
|
+ BABYLON.ArcFollowCamera = ArcFollowCamera;
|
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
|
+
|
|
|
|
+//# sourceMappingURL=babylon.followCamera.js.map
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -85354,197 +85834,6 @@ var BABYLON;
|
|
//# sourceMappingURL=babylon.gamepadSceneComponent.js.map
|
|
//# sourceMappingURL=babylon.gamepadSceneComponent.js.map
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-var BABYLON;
|
|
|
|
-(function (BABYLON) {
|
|
|
|
- BABYLON.Node.AddNodeConstructor("FollowCamera", function (name, scene) {
|
|
|
|
- return function () { return new FollowCamera(name, BABYLON.Vector3.Zero(), scene); };
|
|
|
|
- });
|
|
|
|
- BABYLON.Node.AddNodeConstructor("ArcFollowCamera", function (name, scene) {
|
|
|
|
- return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
|
|
|
|
- });
|
|
|
|
- /**
|
|
|
|
- * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
|
|
|
|
- * an arc rotate version arcFollowCamera are available.
|
|
|
|
- * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
- */
|
|
|
|
- var FollowCamera = /** @class */ (function (_super) {
|
|
|
|
- __extends(FollowCamera, _super);
|
|
|
|
- /**
|
|
|
|
- * Instantiates the follow camera.
|
|
|
|
- * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
- * @param name Define the name of the camera in the scene
|
|
|
|
- * @param position Define the position of the camera
|
|
|
|
- * @param scene Define the scene the camera belong to
|
|
|
|
- * @param lockedTarget Define the target of the camera
|
|
|
|
- */
|
|
|
|
- function FollowCamera(name, position, scene, lockedTarget) {
|
|
|
|
- if (lockedTarget === void 0) { lockedTarget = null; }
|
|
|
|
- var _this = _super.call(this, name, position, scene) || this;
|
|
|
|
- /**
|
|
|
|
- * Distance the follow camera should follow an object at
|
|
|
|
- */
|
|
|
|
- _this.radius = 12;
|
|
|
|
- /**
|
|
|
|
- * Define a rotation offset between the camera and the object it follows
|
|
|
|
- */
|
|
|
|
- _this.rotationOffset = 0;
|
|
|
|
- /**
|
|
|
|
- * Define a height offset between the camera and the object it follows.
|
|
|
|
- * It can help following an object from the top (like a car chaing a plane)
|
|
|
|
- */
|
|
|
|
- _this.heightOffset = 4;
|
|
|
|
- /**
|
|
|
|
- * Define how fast the camera can accelerate to follow it s target.
|
|
|
|
- */
|
|
|
|
- _this.cameraAcceleration = 0.05;
|
|
|
|
- /**
|
|
|
|
- * Define the speed limit of the camera following an object.
|
|
|
|
- */
|
|
|
|
- _this.maxCameraSpeed = 20;
|
|
|
|
- _this.lockedTarget = lockedTarget;
|
|
|
|
- return _this;
|
|
|
|
- }
|
|
|
|
- FollowCamera.prototype._follow = function (cameraTarget) {
|
|
|
|
- if (!cameraTarget) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- var yRotation;
|
|
|
|
- if (cameraTarget.rotationQuaternion) {
|
|
|
|
- var rotMatrix = new BABYLON.Matrix();
|
|
|
|
- cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
|
|
|
|
- yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- yRotation = cameraTarget.rotation.y;
|
|
|
|
- }
|
|
|
|
- var radians = BABYLON.Tools.ToRadians(this.rotationOffset) + yRotation;
|
|
|
|
- var targetPosition = cameraTarget.getAbsolutePosition();
|
|
|
|
- var targetX = targetPosition.x + Math.sin(radians) * this.radius;
|
|
|
|
- var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
|
|
|
|
- var dx = targetX - this.position.x;
|
|
|
|
- var dy = (targetPosition.y + this.heightOffset) - this.position.y;
|
|
|
|
- var dz = (targetZ) - this.position.z;
|
|
|
|
- var vx = dx * this.cameraAcceleration * 2; //this is set to .05
|
|
|
|
- var vy = dy * this.cameraAcceleration;
|
|
|
|
- var vz = dz * this.cameraAcceleration * 2;
|
|
|
|
- if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
|
|
|
|
- vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
- }
|
|
|
|
- if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
|
|
|
|
- vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
- }
|
|
|
|
- if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
|
|
|
|
- vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
|
|
|
|
- }
|
|
|
|
- this.position = new BABYLON.Vector3(this.position.x + vx, this.position.y + vy, this.position.z + vz);
|
|
|
|
- this.setTarget(targetPosition);
|
|
|
|
- };
|
|
|
|
- /** @hidden */
|
|
|
|
- FollowCamera.prototype._checkInputs = function () {
|
|
|
|
- _super.prototype._checkInputs.call(this);
|
|
|
|
- if (this.lockedTarget) {
|
|
|
|
- this._follow(this.lockedTarget);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- /**
|
|
|
|
- * Gets the camera class name.
|
|
|
|
- * @returns the class name
|
|
|
|
- */
|
|
|
|
- FollowCamera.prototype.getClassName = function () {
|
|
|
|
- return "FollowCamera";
|
|
|
|
- };
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serialize()
|
|
|
|
- ], FollowCamera.prototype, "radius", void 0);
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serialize()
|
|
|
|
- ], FollowCamera.prototype, "rotationOffset", void 0);
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serialize()
|
|
|
|
- ], FollowCamera.prototype, "heightOffset", void 0);
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serialize()
|
|
|
|
- ], FollowCamera.prototype, "cameraAcceleration", void 0);
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serialize()
|
|
|
|
- ], FollowCamera.prototype, "maxCameraSpeed", void 0);
|
|
|
|
- __decorate([
|
|
|
|
- BABYLON.serializeAsMeshReference("lockedTargetId")
|
|
|
|
- ], FollowCamera.prototype, "lockedTarget", void 0);
|
|
|
|
- return FollowCamera;
|
|
|
|
- }(BABYLON.TargetCamera));
|
|
|
|
- BABYLON.FollowCamera = FollowCamera;
|
|
|
|
- /**
|
|
|
|
- * Arc Rotate version of the follow camera.
|
|
|
|
- * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
|
|
|
|
- * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
- */
|
|
|
|
- var ArcFollowCamera = /** @class */ (function (_super) {
|
|
|
|
- __extends(ArcFollowCamera, _super);
|
|
|
|
- /**
|
|
|
|
- * Instantiates a new ArcFollowCamera
|
|
|
|
- * @see http://doc.babylonjs.com/features/cameras#follow-camera
|
|
|
|
- * @param name Define the name of the camera
|
|
|
|
- * @param alpha Define the rotation angle of the camera around the logitudinal axis
|
|
|
|
- * @param beta Define the rotation angle of the camera around the elevation axis
|
|
|
|
- * @param radius Define the radius of the camera from its target point
|
|
|
|
- * @param target Define the target of the camera
|
|
|
|
- * @param scene Define the scene the camera belongs to
|
|
|
|
- */
|
|
|
|
- function ArcFollowCamera(name,
|
|
|
|
- /** The longitudinal angle of the camera */
|
|
|
|
- alpha,
|
|
|
|
- /** The latitudinal angle of the camera */
|
|
|
|
- beta,
|
|
|
|
- /** The radius of the camera from its target */
|
|
|
|
- radius,
|
|
|
|
- /** Define the camera target (the messh it should follow) */
|
|
|
|
- target, scene) {
|
|
|
|
- var _this = _super.call(this, name, BABYLON.Vector3.Zero(), scene) || this;
|
|
|
|
- _this.alpha = alpha;
|
|
|
|
- _this.beta = beta;
|
|
|
|
- _this.radius = radius;
|
|
|
|
- _this.target = target;
|
|
|
|
- _this._cartesianCoordinates = BABYLON.Vector3.Zero();
|
|
|
|
- _this._follow();
|
|
|
|
- return _this;
|
|
|
|
- }
|
|
|
|
- ArcFollowCamera.prototype._follow = function () {
|
|
|
|
- if (!this.target) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
|
|
|
|
- this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
|
|
|
|
- this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
|
|
|
|
- var targetPosition = this.target.getAbsolutePosition();
|
|
|
|
- this.position = targetPosition.add(this._cartesianCoordinates);
|
|
|
|
- this.setTarget(targetPosition);
|
|
|
|
- };
|
|
|
|
- /** @hidden */
|
|
|
|
- ArcFollowCamera.prototype._checkInputs = function () {
|
|
|
|
- _super.prototype._checkInputs.call(this);
|
|
|
|
- this._follow();
|
|
|
|
- };
|
|
|
|
- /**
|
|
|
|
- * Returns the class name of the object.
|
|
|
|
- * It is mostly used internally for serialization purposes.
|
|
|
|
- */
|
|
|
|
- ArcFollowCamera.prototype.getClassName = function () {
|
|
|
|
- return "ArcFollowCamera";
|
|
|
|
- };
|
|
|
|
- return ArcFollowCamera;
|
|
|
|
- }(BABYLON.TargetCamera));
|
|
|
|
- BABYLON.ArcFollowCamera = ArcFollowCamera;
|
|
|
|
-})(BABYLON || (BABYLON = {}));
|
|
|
|
-
|
|
|
|
-//# sourceMappingURL=babylon.followCamera.js.map
|
|
|
|
-
|
|
|
|
-
|
|
|
|
var BABYLON;
|
|
var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
/**
|
|
/**
|