Browse Source

Camera import

sebavan 6 years ago
parent
commit
1a45139e17

+ 9 - 2
src/Cameras/Inputs/followCameraKeyboardMoveInput.ts

@@ -1,4 +1,12 @@
-module BABYLON {
+import { ICameraInput, CameraInputTypes } from "../../Cameras/cameraInputsManager";
+import { FollowCamera } from "../../Cameras/followCamera";
+import { serialize } from "../../Misc/decorators";
+import { Nullable } from "../../types";
+import { Observer } from "../../Misc/observable";
+import { Engine } from "../../Engines/engine";
+import { KeyboardInfo, KeyboardEventTypes } from "../../Events/keyboardEvents";
+import { Scene } from "../../scene";
+
     /**
      * Manage the keyboard inputs to control the movement of an arc rotate camera.
      * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
@@ -206,4 +214,3 @@ module BABYLON {
     }
 
     (<any>CameraInputTypes)["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
-}

+ 36 - 35
src/Cameras/followCamera.ts

@@ -6,6 +6,7 @@ import { Scene } from "../scene";
 import { Matrix, Vector3 } from "../Maths/math";
 import { Node } from "../node";
 import { AbstractMesh } from "../Meshes/abstractMesh";
+import { FollowCameraInputsManager } from './followCameraInputsManager';
     Node.AddNodeConstructor("FollowCamera", (name, scene) => {
         return () => new FollowCamera(name, Vector3.Zero(), scene);
     });
@@ -57,11 +58,11 @@ import { AbstractMesh } from "../Meshes/abstractMesh";
         @serializeAsMeshReference("lockedTargetId")
         public lockedTarget: Nullable<AbstractMesh>;
 
-        /**
-         * Defines the input associated with the camera.
-         */
-        public inputs: FollowCameraInputsManager;
-
+        /**
+         * Defines the input associated with the camera.
+         */
+        public inputs: FollowCameraInputsManager;
+
         /**
          * Instantiates the follow camera.
          * @see http://doc.babylonjs.com/features/cameras#follow-camera
@@ -74,10 +75,10 @@ import { AbstractMesh } from "../Meshes/abstractMesh";
             super(name, position, scene);
 
             this.lockedTarget = lockedTarget;
-            this.inputs = new FollowCameraInputsManager(this);
-            this.inputs.addKeyboard();
-            // Uncomment the following line when the relevant handlers have been implemented.
-            // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
+            this.inputs = new FollowCameraInputsManager(this);
+            this.inputs.addKeyboard();
+            // Uncomment the following line when the relevant handlers have been implemented.
+            // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
         }
 
         private _follow(cameraTarget: AbstractMesh) {
@@ -121,34 +122,34 @@ import { AbstractMesh } from "../Meshes/abstractMesh";
             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)
-         */
-        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
-          this.inputs.attachElement(element, noPreventDefault);
-
-          this._reset = () => {
-          };
-        }
-
-        /**
-         * 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
-         */
-        public detachControl(element: HTMLElement): void {
-          this.inputs.detachElement(element);
-
-          if (this._reset) {
-            this._reset();
-          }
-        }
-
+        /**
+         * 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)
+         */
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void {
+          this.inputs.attachElement(element, noPreventDefault);
+
+          this._reset = () => {
+          };
+        }
+
+        /**
+         * 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
+         */
+        public detachControl(element: HTMLElement): void {
+          this.inputs.detachElement(element);
+
+          if (this._reset) {
+            this._reset();
+          }
+        }
+
         /** @hidden */
         public _checkInputs(): void {
-            this.inputs.checkInputs();
+            this.inputs.checkInputs();
             super._checkInputs();
             if (this.lockedTarget) {
                 this._follow(this.lockedTarget);

+ 4 - 2
src/Cameras/followCameraInputsManager.ts

@@ -1,4 +1,7 @@
-module BABYLON {
+import { CameraInputsManager } from "./cameraInputsManager";
+import { FollowCamera } from "./followCamera";
+import { FollowCameraKeyboardMoveInput } from './Inputs/followCameraKeyboardMoveInput';
+
     /**
      * Default Inputs manager for the FollowCamera.
      * It groups all the default supported inputs for ease of use.
@@ -49,4 +52,3 @@ module BABYLON {
             return this;
         }
     }
-}