I am kind confused how to use the default keyboard keys to move UniversalCamera,
my question based on this PG
in this PG, by presssing key ArrowRight, ArrowLeft, ArrowUp, ArrowDown moves camera.
no special code need to have this functionality..
But cannot have the same functionality in my App using UniversalCamera or FreeCamera.
my code is this
import { UniversalCamera, ArcRotateCamera, HemisphericLight, PointLight, GlowLayer, Color3, Vector3, TransformNode} from '@babylonjs/core';
//universalcamera
this.camera = new UniversalCamera('universal-camera', new Vector3(0, 0, (1500 * 3)), scene);
this.camera.maxZ = 20000000;
this.camera.minZ = 0.5;
this.camera.fov = 0.5;
this.camera.inertia = 0.9;
this.camera.angularSensibility = 1500;
this.camera.speed = 0.2;
this.camera.inputs.addMouseWheel();
this.camera.attachControl(canvas, true);
with this code cannot move camera with arrowkeys!!
log for UniversalCamera (firefox)
Object { attachedToElement: true, attached: {β¦}, camera: {β¦}, checkInputs: _addCheckInputs(), _mouseInput: {β¦}, _mouseWheelInput: {β¦}, noPreventDefault: true }
β
_mouseInput: Object { touchEnabled: false, angularSensibility: 1500, _allowCameraRotation: true, β¦ }
β
_mouseWheelInput: Object { wheelPrecisionX: 0.6, wheelPrecisionY: 0.6, wheelPrecisionZ: 0.6, β¦ }
β
attached: Object { keyboard: {β¦}, mouse: {β¦}, touch: {β¦}, β¦ }
ββ
gamepad: Object { gamepadAngularSensibility: 200, gamepadMoveSensibility: 40, deadzoneDelta: 0.1, β¦ }
ββ
keyboard: Object { keysUp: (1) [β¦], keysUpward: (1) [β¦], rotationSpeed: 0.5, β¦ }
βββ
_engine: Object { _colorWrite: true, _colorWriteChanged: false, _badOS: false, β¦ }
βββ
_keys: Array []
βββ
_onCanvasBlurObserver: Object { mask: -1, _willBeUnregistered: false, unregisterOnNextCall: false, β¦ }
βββ
_onKeyboardObserver: Object { mask: -1, _willBeUnregistered: false, unregisterOnNextCall: false, β¦ }
βββ
_scene: Object { _isScene: true, _blockEntityCollection: false, autoClear: true, β¦ }
βββ
camera: Object { _isDirty: false, _nodeDataStorage: {β¦}, state: "", β¦ }
βββ
keysDown: Array [ 40 ]
βββ
keysDownward: Array [ 34 ]
βββ
keysLeft: Array [ 37 ]
βββ
keysRight: Array [ 39 ]
βββ
keysRotateDown: Array []
βββ
keysRotateLeft: Array []
βββ
keysRotateRight: Array []
βββ
keysRotateUp: Array []
βββ
keysUp: Array [ 38 ]
βββ
keysUpward: Array [ 33 ]
βββ
rotationSpeed: 0.5
βββ
<prototype>: Object { β¦ }
ββ
mouse: Object { touchEnabled: false, angularSensibility: 1500, _allowCameraRotation: true, β¦ }
ββ
mousewheel: Object { wheelPrecisionX: 0.6, wheelPrecisionY: 0.6, wheelPrecisionZ: 0.6, β¦ }
ββ
touch: Object { allowMouse: false, touchAngularSensibility: 200000, touchMoveSensibility: 250, β¦ }
ββ
<prototype>: Object { β¦ }
β
attachedToElement: true
β
camera: Object { _isDirty: false, _nodeDataStorage: {β¦}, state: "", β¦ }
β
checkInputs: function _addCheckInputs()
β
noPreventDefault: true
β
<prototype>: Object { addDeviceOrientation: addDeviceOrientation(smoothFactor), addVirtualJoystick: addVirtualJoystick(), addGamepad: addGamepad(), β¦ }
when i use ArcRotateCamera and press key ArrowRight, ArrowLeft, ArrowUp, ArrowDown moves camera.
log for ArcRotateCamera (firefox)
Object { attachedToElement: true, attached: {β¦}, camera: {β¦}, checkInputs: _addCheckInputs(), noPreventDefault: true }
β
attached: Object { keyboard: {β¦}, mousewheel: {β¦}, pointers: {β¦} }
ββ
keyboard: Object { panningSensibility: 50, zoomingSensibility: 25, useAltToZoom: true, β¦ }
ββ
mousewheel: Object { wheelPrecision: 0.1, zoomToMouseLocation: false, wheelDeltaPercentage: 0.002, β¦ }
ββ
pointers: Object { _currentMousePointerIdDown: -1, angularSensibilityX: 3000, angularSensibilityY: 3000, β¦ }
ββ
<prototype>: Object { β¦ }
β
attachedToElement: true
β
camera: Object { _isDirty: false, _nodeDataStorage: {β¦}, state: "", β¦ }
β
checkInputs: function _addCheckInputs()
β
noPreventDefault: true
β
<prototype>: Object { addVRDeviceOrientation: addVRDeviceOrientation(), addGamepad: addGamepad(), β¦ }
what i am missing here?
why cannot use the default arrowkeys??