@babylonjs/core 5.0.0-beta.8 → 5.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +20 -5
- package/DeviceInput/InputDevices/deviceSourceManager.js +68 -7
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +15 -10
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js +25 -31
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +7 -6
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +62 -33
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +7 -0
- package/Engines/Extensions/engine.views.js +12 -0
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/nativeEngine.js +2 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +0 -1
- package/Inputs/scene.inputManager.js +5 -5
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Loading/sceneLoader.js +4 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +1 -1
- package/Meshes/mesh.vertexData.js +2 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/error.d.ts +51 -0
- package/Misc/error.js +66 -0
- package/Misc/error.js.map +1 -0
- package/Misc/fileTools.d.ts +4 -4
- package/Misc/fileTools.js +7 -7
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Particles/particleSystem.js +7 -1
- package/Particles/particleSystem.js.map +1 -1
- package/package.json +4 -4
- package/Misc/baseError.d.ts +0 -7
- package/Misc/baseError.js +0 -18
- package/Misc/baseError.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzD,IAAM,YAAY,GAAG,GAAG,CAAC;AACzB,IAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhE,cAAc;AACd;IA8DI,8BAAY,MAAc;QApC1B,kBAAkB;QACV,YAAO,GAAmD,EAAE,CAAC;QAE7D,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAY,KAAK,CAAC;QAGvB,iBAAY,GAAY,KAAK,CAAC,QAAQ,EAAE,CAAC;QAIlD,uBAAkB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACvC,qBAAgB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACrC,uBAAkB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QAEvC,sBAAiB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACtC,sBAAiB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACtC,oBAAe,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACpC,uBAAkB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QACvC,sBAAiB,GAAG,UAAC,GAAQ,IAAO,CAAC,CAAC;QAGtC,aAAQ,GAAG,CAAC,CAAC,CAAC;QACL,oBAAe,GAAG,aAAa,CAAC,oBAAoB,EAAE,IAAI,SA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G;IACK,4CAAa,GAArB;QACI,cAAc;QACd,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7E,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAE5E,kBAAkB;QAClB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChF,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE5E,iBAAiB;QACjB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5F,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAE3F,IAAI,IAAI,CAAC,0BAA0B,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;SAC7E;IACL,CAAC;IACL,2BAAC;AAAD,CAAC,AAzvBD,IAyvBC","sourcesContent":["import { Engine } from \"../../Engines/engine\";\r\nimport { IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { DomManagement } from \"../../Misc/domManagement\";\r\nimport { Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\nconst MAX_KEYCODES = 255;\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @hidden */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n /** onDeviceConnected property */\r\n public set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void) {\r\n this._onDeviceConnected = callback;\r\n\r\n // Iterate through each active device and rerun new callback\r\n for (let deviceType = 0; deviceType < this._inputs.length; deviceType++) {\r\n const inputs = this._inputs[deviceType];\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n public get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void {\r\n return this._onDeviceConnected;\r\n }\r\n\r\n public onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n public onInputChanged: (deviceEvent: IDeviceEvent) => void;\r\n\r\n // Private Members\r\n private _inputs: Array<{ [deviceSlot: number]: Array<number> }> = [];\r\n private _gamepads: Array<DeviceType>;\r\n private _keyboardActive: boolean = false;\r\n private _pointerActive: boolean = false;\r\n private _elementToAttachTo: HTMLElement;\r\n private readonly _engine: Engine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n private _keyboardDownEvent = (evt: any) => { };\r\n private _keyboardUpEvent = (evt: any) => { };\r\n private _keyboardBlurEvent = (evt: any) => { };\r\n\r\n private _pointerMoveEvent = (evt: any) => { };\r\n private _pointerDownEvent = (evt: any) => { };\r\n private _pointerUpEvent = (evt: any) => { };\r\n private _pointerWheelEvent = (evt: any) => { };\r\n private _pointerBlurEvent = (evt: any) => { };\r\n private _wheelEventName: string;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = DomManagement.IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -1;\r\n\r\n // Array to store active Pointer ID values; prevents issues with negative pointerIds\r\n private _activeTouchIds: Array<number>;\r\n private _maxTouchPoints: number = 0;\r\n\r\n private _pointerInputClearObserver: Nullable<Observer<Engine>> = null;\r\n\r\n private _gamepadConnectedEvent = (evt: any) => { };\r\n private _gamepadDisconnectedEvent = (evt: any) => { };\r\n\r\n private _eventPrefix: string;\r\n\r\n constructor(engine: Engine) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this.onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n this._configureEvents();\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (!device) {\r\n throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense && navigator.getGamepads) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\r\n }\r\n\r\n return currentValue;\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n return (this._inputs[deviceType] !== undefined);\r\n }\r\n\r\n /**\r\n * Dispose of all the eventlisteners\r\n */\r\n public dispose(): void {\r\n // Observables\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\r\n\r\n // Gamepad Events\r\n window.removeEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.removeEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n }\r\n\r\n /**\r\n * Configures events to work with an engine's active element\r\n */\r\n private _configureEvents(): void {\r\n const inputElement = this._engine.getInputElement();\r\n if (inputElement && this._elementToAttachTo !== inputElement) {\r\n // If the engine's input element has changed, unregister events from previous element\r\n if (this._elementToAttachTo) {\r\n this._removeEvents();\r\n }\r\n\r\n this._elementToAttachTo = inputElement;\r\n // Set tab index for the inputElement to the engine's canvasTabIndex, if and only if the element's tab index is -1\r\n this._elementToAttachTo.tabIndex = (this._elementToAttachTo.tabIndex !== -1) ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex;\r\n this._handleKeyActions();\r\n this._handlePointerActions();\r\n this._handleGamepadActions();\r\n\r\n // Check for devices that are already connected but aren't registered. Currently, only checks for gamepads and mouse\r\n this._checkForConnectedDevices();\r\n }\r\n }\r\n\r\n /**\r\n * Checks for existing connections to devices and register them, if necessary\r\n * Currently handles gamepads and mouse\r\n */\r\n private _checkForConnectedDevices(): void {\r\n if (navigator.getGamepads) {\r\n const gamepads = navigator.getGamepads();\r\n\r\n for (const gamepad of gamepads) {\r\n if (gamepad) {\r\n this._addGamePad(gamepad);\r\n }\r\n }\r\n }\r\n\r\n // If the device in use has mouse capabilities, pre-register mouse\r\n if (matchMedia('(pointer:fine)').matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overriden when the first mouse event happens.\r\n // There isn't any good way to get the current position outside of a pointer event so that's why this was done.\r\n this._addPointerDevice(DeviceType.Mouse, 0, 0, 0);\r\n }\r\n }\r\n\r\n // Private functions\r\n /**\r\n * Add a gamepad to the DeviceInputSystem\r\n * @param gamepad A single DOM Gamepad object\r\n */\r\n private _addGamePad(gamepad: any): void {\r\n const deviceType = this._getGamepadDeviceType(gamepad.id);\r\n const deviceSlot = gamepad.index;\r\n\r\n this._gamepads = this._gamepads || new Array<DeviceType>(gamepad.index + 1);\r\n this._registerDevice(deviceType, deviceSlot, gamepad.buttons.length + gamepad.axes.length);\r\n\r\n this._gamepads[deviceSlot] = deviceType;\r\n }\r\n\r\n /**\r\n * Add pointer device to DeviceInputSystem\r\n * @param deviceType Type of Pointer to add\r\n * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)\r\n * @param currentX Current X at point of adding\r\n * @param currentY Current Y at point of adding\r\n */\r\n private _addPointerDevice(deviceType: DeviceType, deviceSlot: number, currentX: number, currentY: number): void {\r\n if (!this._pointerActive) {\r\n this._pointerActive = true;\r\n }\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n const pointer = this._inputs[deviceType][deviceSlot]; /* initialize our pointer position immediately after registration */\r\n pointer[0] = currentX;\r\n pointer[1] = currentY;\r\n }\r\n\r\n /**\r\n * Add device and inputs to device array\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param numberOfInputs Number of input entries to create for given device\r\n */\r\n private _registerDevice(deviceType: DeviceType, deviceSlot: number, numberOfInputs: number): void {\r\n if (deviceSlot === undefined) {\r\n throw `Unable to register device ${DeviceType[deviceType]} to undefined slot.`;\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n const device = new Array<number>(numberOfInputs);\r\n\r\n for (let i = 0; i < numberOfInputs; i++) {\r\n device[i] = 0; /* set device input as unpressed */\r\n }\r\n\r\n this._inputs[deviceType][deviceSlot] = device;\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Given a specific device name, remove that device from the device map\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _unregisterDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n delete this._inputs[deviceType][deviceSlot];\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Handle all actions that come from keyboard interaction\r\n */\r\n private _handleKeyActions(): void {\r\n this._keyboardDownEvent = ((evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 1;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 0;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardUpEvent = ((evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 1;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardBlurEvent = ((evt) => {\r\n if (this._keyboardActive) {\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n\r\n for (let i = 0; i < kbKey.length; i++) {\r\n if (kbKey[i] !== 0) {\r\n kbKey[i] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i;\r\n deviceEvent.currentState = 0;\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.addEventListener(\"keyup\", this._keyboardUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._keyboardBlurEvent);\r\n }\r\n\r\n /**\r\n * Handle all actions that come from pointer interaction\r\n */\r\n private _handlePointerActions(): void {\r\n this._maxTouchPoints = (DomManagement.IsNavigatorAvailable() && navigator.maxTouchPoints) || 0;\r\n if (!this._activeTouchIds) {\r\n this._activeTouchIds = new Array<number>(this._maxTouchPoints);\r\n }\r\n\r\n for (let i = 0; i < this._maxTouchPoints; i++) {\r\n this._activeTouchIds[i] = -1;\r\n }\r\n\r\n this._pointerMoveEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[PointerInput.DeltaHorizontal] = evt.movementX;\r\n pointer[PointerInput.DeltaVertical] = evt.movementY;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n\r\n // Lets Propagate the event for move with same position.\r\n if (!this._usingSafari && evt.button !== -1) {\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = pointer[evt.button + 2];\r\n pointer[evt.button + 2] = (pointer[evt.button + 2] ? 0 : 1); // Reverse state of button if evt.button has value\r\n deviceEvent.currentState = pointer[evt.button + 2];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._pointerDownEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : evt.pointerId;\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n }\r\n else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n else if (deviceType === DeviceType.Touch) {\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n const previousButton = pointer[evt.button + 2];\r\n\r\n if (deviceType === DeviceType.Mouse) { // Mouse; Among supported browsers, value is either 1 or 0 for mouse\r\n if (this._mouseId === -1) {\r\n if (evt.pointerId === undefined) { // If there is no pointerId (eg. manually dispatched MouseEvent)\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n }\r\n else {\r\n this._mouseId = evt.pointerId;\r\n }\r\n }\r\n\r\n if (!document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n else { // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 1;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._pointerUpEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n if (deviceSlot === -1) {\r\n return;\r\n }\r\n else {\r\n this._activeTouchIds[deviceSlot] = -1;\r\n }\r\n }\r\n\r\n const pointer = this._inputs[deviceType]?.[deviceSlot];\r\n if (pointer && pointer[evt.button + 2] !== 0) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n const previousButton = pointer[evt.button + 2];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n\r\n if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n });\r\n\r\n // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName = \"onwheel\" in document.createElement(\"div\") ? \"wheel\" : // Modern browsers support \"wheel\"\r\n (<any>document).onmousewheel !== undefined ? \"mousewheel\" : // Webkit and IE support at least \"mousewheel\"\r\n \"DOMMouseScroll\"; // let's assume that remaining browsers are older Firefox\r\n\r\n // Code originally in scene.inputManager.ts\r\n // Chrome reports warning in console if wheel listener doesn't set an explicit passive option.\r\n // IE11 only supports captureEvent:boolean, not options:object, and it defaults to false.\r\n // Feature detection technique copied from: https://github.com/github/eventlistener-polyfill (MIT license)\r\n let passiveSupported = false;\r\n const noop = function () { };\r\n\r\n try {\r\n const options: object = {\r\n passive: {\r\n get: function () {\r\n passiveSupported = true;\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n }\r\n catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = ((evt) => {\r\n // Handle mouse buttons\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let i = 0; i <= PointerInput.BrowserForward; i++) {\r\n if (pointer[i + 2] === 1) {\r\n pointer[i + 2] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, i + 2, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Mouse;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i + 2;\r\n deviceEvent.currentState = pointer[i + 2];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n }\r\n\r\n // Handle Active Touches\r\n if (this.isDeviceAvailable(DeviceType.Touch)) {\r\n const pointer = this._inputs[DeviceType.Touch];\r\n\r\n for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {\r\n const pointerId = this._activeTouchIds[deviceSlot];\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(pointerId);\r\n }\r\n\r\n if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {\r\n pointer[deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Touch;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.LeftClick;\r\n deviceEvent.currentState = pointer[deviceSlot][PointerInput.LeftClick];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this.onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._pointerWheelEvent = ((evt) => {\r\n const deviceType = DeviceType.Mouse;\r\n const deviceSlot = 0;\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = [];\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._pointerActive = true;\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n // Store previous values for event\r\n let previousWheelScrollX = pointer[PointerInput.MouseWheelX];\r\n let previousWheelScrollY = pointer[PointerInput.MouseWheelY];\r\n let previousWheelScrollZ = pointer[PointerInput.MouseWheelZ];\r\n\r\n pointer[PointerInput.MouseWheelX] = evt.deltaX || 0;\r\n pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0;\r\n pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n deviceEvent.previousState = previousWheelScrollX;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelX];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n deviceEvent.previousState = previousWheelScrollY;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelY];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n deviceEvent.previousState = previousWheelScrollZ;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelZ];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._pointerBlurEvent);\r\n this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false);\r\n\r\n // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame\r\n this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n pointer[PointerInput.MouseWheelX] = 0;\r\n pointer[PointerInput.MouseWheelY] = 0;\r\n pointer[PointerInput.MouseWheelZ] = 0;\r\n pointer[PointerInput.DeltaHorizontal] = 0;\r\n pointer[PointerInput.DeltaVertical] = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Handle all actions that come from gamepad interaction\r\n */\r\n private _handleGamepadActions(): void {\r\n this._gamepadConnectedEvent = ((evt: any) => {\r\n this._addGamePad(evt.gamepad);\r\n });\r\n\r\n this._gamepadDisconnectedEvent = ((evt: any) => {\r\n if (this._gamepads) {\r\n const deviceType = this._getGamepadDeviceType(evt.gamepad.id);\r\n const deviceSlot = evt.gamepad.index;\r\n\r\n this._unregisterDevice(deviceType, deviceSlot);\r\n delete this._gamepads[deviceSlot];\r\n }\r\n });\r\n\r\n window.addEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.addEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n /**\r\n * Update all non-event based devices with each frame\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n */\r\n private _updateDevice(deviceType: DeviceType, deviceSlot: number, inputIndex: number): void {\r\n // Gamepads\r\n const gp = navigator.getGamepads()[deviceSlot];\r\n\r\n if (gp && deviceType === this._gamepads[deviceSlot]) {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (inputIndex >= gp.buttons.length) {\r\n device[inputIndex] = gp.axes[inputIndex - gp.buttons.length].valueOf();\r\n }\r\n else {\r\n device[inputIndex] = gp.buttons[inputIndex].value;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets DeviceType from the device name\r\n * @param deviceName Name of Device from DeviceInputSystem\r\n * @returns DeviceType enum value\r\n */\r\n private _getGamepadDeviceType(deviceName: string): DeviceType {\r\n if (deviceName.indexOf(\"054c\") !== -1) { // DualShock 4 Gamepad\r\n return (deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock);\r\n }\r\n else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) { // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n }\r\n else if (deviceName.indexOf(\"057e\") !== -1) { // Switch Gamepad\r\n return DeviceType.Switch;\r\n }\r\n\r\n return DeviceType.Generic;\r\n }\r\n\r\n /**\r\n * Get DeviceType from a given pointer/mouse/touch event.\r\n * @param evt PointerEvent to evaluate\r\n * @returns DeviceType interpreted from event\r\n */\r\n private _getPointerType(evt: any): DeviceType {\r\n let deviceType = DeviceType.Mouse;\r\n\r\n if (evt.pointerType === \"touch\" || evt.pointerType === \"pen\" || evt.touches) {\r\n deviceType = DeviceType.Touch;\r\n }\r\n\r\n return deviceType;\r\n }\r\n\r\n /**\r\n * Remove events from active input element\r\n */\r\n private _removeEvents(): void {\r\n // Blur Events\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._keyboardBlurEvent);\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._pointerBlurEvent);\r\n\r\n // Keyboard Events\r\n this._elementToAttachTo.removeEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.removeEventListener(\"keyup\", this._keyboardUpEvent);\r\n\r\n // Pointer Events\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent);\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/webDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,E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AAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,eAAe;YAC3I,OAAO,UAAU,CAAC,IAAI,CAAC;SAC1B;aACI,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,iBAAiB;YAC3D,OAAO,UAAU,CAAC,MAAM,CAAC;SAC5B;QAED,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACK,8CAAe,GAAvB,UAAwB,GAAQ;QAC5B,IAAI,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;QAElC,IAAI,GAAG,CAAC,WAAW,KAAK,OAAO,IAAI,GAAG,CAAC,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE;YACzE,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;SACjC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IACL,2BAAC;AAAD,CAAC,AAvxBD,IAuxBC","sourcesContent":["import { Engine } from \"../../Engines/engine\";\r\nimport { IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { DomManagement } from \"../../Misc/domManagement\";\r\nimport { Observer } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\nconst MAX_KEYCODES = 255;\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @hidden */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n /** onDeviceConnected property */\r\n public set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void) {\r\n this._onDeviceConnected = callback;\r\n\r\n // Iterate through each active device and rerun new callback\r\n for (let deviceType = 0; deviceType < this._inputs.length; deviceType++) {\r\n const inputs = this._inputs[deviceType];\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n public get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void {\r\n return this._onDeviceConnected;\r\n }\r\n\r\n public onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n public onInputChanged: (deviceEvent: IDeviceEvent) => void;\r\n\r\n // Private Members\r\n private _inputs: Array<{ [deviceSlot: number]: Array<number> }> = [];\r\n private _gamepads: Array<DeviceType>;\r\n private _keyboardActive: boolean = false;\r\n private _pointerActive: boolean = false;\r\n private _elementToAttachTo: HTMLElement;\r\n private readonly _engine: Engine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n private _keyboardDownEvent = (evt: any) => { };\r\n private _keyboardUpEvent = (evt: any) => { };\r\n private _keyboardBlurEvent = (evt: any) => { };\r\n\r\n private _pointerMoveEvent = (evt: any) => { };\r\n private _pointerDownEvent = (evt: any) => { };\r\n private _pointerUpEvent = (evt: any) => { };\r\n private _pointerWheelEvent = (evt: any) => { };\r\n private _pointerBlurEvent = (evt: any) => { };\r\n private _wheelEventName: string;\r\n private _eventsAttached: boolean = false;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = DomManagement.IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -1;\r\n\r\n // Array to store active Pointer ID values; prevents issues with negative pointerIds\r\n private _activeTouchIds: Array<number>;\r\n private _maxTouchPoints: number = 0;\r\n\r\n private _pointerInputClearObserver: Nullable<Observer<Engine>> = null;\r\n\r\n private _gamepadConnectedEvent = (evt: any) => { };\r\n private _gamepadDisconnectedEvent = (evt: any) => { };\r\n\r\n private _eventPrefix: string;\r\n\r\n constructor(engine: Engine) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this.onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n this.onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n this._enableEvents();\r\n\r\n // Set callback to enable event handler switching when inputElement changes\r\n if (!this._engine._onEngineViewChanged) {\r\n this._engine._onEngineViewChanged = () => {\r\n this._enableEvents();\r\n };\r\n }\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (!device) {\r\n throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense && navigator.getGamepads) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\r\n }\r\n\r\n return currentValue;\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n return (this._inputs[deviceType] !== undefined);\r\n }\r\n\r\n /**\r\n * Dispose of all the eventlisteners\r\n */\r\n public dispose(): void {\r\n // Callbacks\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n delete this._engine._onEngineViewChanged;\r\n\r\n if (this._elementToAttachTo) {\r\n this._disableEvents();\r\n }\r\n }\r\n\r\n /**\r\n * Enable listening for user input events\r\n */\r\n private _enableEvents(): void {\r\n const inputElement = this?._engine.getInputElement();\r\n if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {\r\n // Remove events before adding to avoid double events or simultaneous events on multiple canvases\r\n this._disableEvents();\r\n\r\n // If the inputs array has already been created, zero it out to before setting up events\r\n if (this._inputs) {\r\n for (const inputs of this._inputs) {\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n const device = inputs[deviceSlot];\r\n if (device) {\r\n for (let inputIndex = 0; inputIndex < device.length; inputIndex++) {\r\n device[inputIndex] = 0;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._elementToAttachTo = inputElement;\r\n // Set tab index for the inputElement to the engine's canvasTabIndex, if and only if the element's tab index is -1\r\n this._elementToAttachTo.tabIndex = (this._elementToAttachTo.tabIndex !== -1) ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex;\r\n this._handleKeyActions();\r\n this._handlePointerActions();\r\n this._handleGamepadActions();\r\n this._eventsAttached = true;\r\n\r\n // Check for devices that are already connected but aren't registered. Currently, only checks for gamepads and mouse\r\n this._checkForConnectedDevices();\r\n }\r\n }\r\n\r\n /**\r\n * Disable listening for user input events\r\n */\r\n private _disableEvents(): void {\r\n if (this._elementToAttachTo) {\r\n // Blur Events\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._keyboardBlurEvent);\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._pointerBlurEvent);\r\n\r\n // Keyboard Events\r\n this._elementToAttachTo.removeEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.removeEventListener(\"keyup\", this._keyboardUpEvent);\r\n\r\n // Pointer Events\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent);\r\n\r\n // Gamepad Events\r\n window.removeEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.removeEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n\r\n this._eventsAttached = false;\r\n }\r\n\r\n /**\r\n * Checks for existing connections to devices and register them, if necessary\r\n * Currently handles gamepads and mouse\r\n */\r\n private _checkForConnectedDevices(): void {\r\n if (navigator.getGamepads) {\r\n const gamepads = navigator.getGamepads();\r\n\r\n for (const gamepad of gamepads) {\r\n if (gamepad) {\r\n this._addGamePad(gamepad);\r\n }\r\n }\r\n }\r\n\r\n // If the device in use has mouse capabilities, pre-register mouse\r\n if (matchMedia('(pointer:fine)').matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overriden when the first mouse event happens.\r\n // There isn't any good way to get the current position outside of a pointer event so that's why this was done.\r\n this._addPointerDevice(DeviceType.Mouse, 0, 0, 0);\r\n }\r\n }\r\n\r\n // Private functions\r\n /**\r\n * Add a gamepad to the DeviceInputSystem\r\n * @param gamepad A single DOM Gamepad object\r\n */\r\n private _addGamePad(gamepad: any): void {\r\n const deviceType = this._getGamepadDeviceType(gamepad.id);\r\n const deviceSlot = gamepad.index;\r\n\r\n this._gamepads = this._gamepads || new Array<DeviceType>(gamepad.index + 1);\r\n this._registerDevice(deviceType, deviceSlot, gamepad.buttons.length + gamepad.axes.length);\r\n\r\n this._gamepads[deviceSlot] = deviceType;\r\n }\r\n\r\n /**\r\n * Add pointer device to DeviceInputSystem\r\n * @param deviceType Type of Pointer to add\r\n * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)\r\n * @param currentX Current X at point of adding\r\n * @param currentY Current Y at point of adding\r\n */\r\n private _addPointerDevice(deviceType: DeviceType, deviceSlot: number, currentX: number, currentY: number): void {\r\n if (!this._pointerActive) {\r\n this._pointerActive = true;\r\n }\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n const pointer = this._inputs[deviceType][deviceSlot]; /* initialize our pointer position immediately after registration */\r\n pointer[0] = currentX;\r\n pointer[1] = currentY;\r\n }\r\n\r\n /**\r\n * Add device and inputs to device array\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param numberOfInputs Number of input entries to create for given device\r\n */\r\n private _registerDevice(deviceType: DeviceType, deviceSlot: number, numberOfInputs: number): void {\r\n if (deviceSlot === undefined) {\r\n throw `Unable to register device ${DeviceType[deviceType]} to undefined slot.`;\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n const device = new Array<number>(numberOfInputs);\r\n\r\n for (let i = 0; i < numberOfInputs; i++) {\r\n device[i] = 0; /* set device input as unpressed */\r\n }\r\n\r\n this._inputs[deviceType][deviceSlot] = device;\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Given a specific device name, remove that device from the device map\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _unregisterDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n delete this._inputs[deviceType][deviceSlot];\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Handle all actions that come from keyboard interaction\r\n */\r\n private _handleKeyActions(): void {\r\n this._keyboardDownEvent = ((evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 1;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 0;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardUpEvent = ((evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n deviceEvent.previousState = 1;\r\n deviceEvent.currentState = kbKey[evt.keyCode];\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n });\r\n\r\n this._keyboardBlurEvent = ((evt) => {\r\n if (this._keyboardActive) {\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n\r\n for (let i = 0; i < kbKey.length; i++) {\r\n if (kbKey[i] !== 0) {\r\n kbKey[i] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Keyboard;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i;\r\n deviceEvent.currentState = 0;\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.addEventListener(\"keyup\", this._keyboardUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._keyboardBlurEvent);\r\n }\r\n\r\n /**\r\n * Handle all actions that come from pointer interaction\r\n */\r\n private _handlePointerActions(): void {\r\n // If maxTouchPoints is defined, use that value. Otherwise, allow for a minimum for supported gestures like pinch\r\n this._maxTouchPoints = (DomManagement.IsNavigatorAvailable() && navigator.maxTouchPoints) || 2;\r\n if (!this._activeTouchIds) {\r\n this._activeTouchIds = new Array<number>(this._maxTouchPoints);\r\n }\r\n\r\n for (let i = 0; i < this._maxTouchPoints; i++) {\r\n this._activeTouchIds[i] = -1;\r\n }\r\n\r\n this._pointerMoveEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[PointerInput.DeltaHorizontal] = evt.movementX;\r\n pointer[PointerInput.DeltaVertical] = evt.movementY;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n\r\n // Lets Propagate the event for move with same position.\r\n if (!this._usingSafari && evt.button !== -1) {\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = pointer[evt.button + 2];\r\n pointer[evt.button + 2] = (pointer[evt.button + 2] ? 0 : 1); // Reverse state of button if evt.button has value\r\n deviceEvent.currentState = pointer[evt.button + 2];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._pointerDownEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : evt.pointerId;\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n }\r\n else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n else if (deviceType === DeviceType.Touch) {\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n const previousButton = pointer[evt.button + 2];\r\n\r\n if (deviceType === DeviceType.Mouse) { // Mouse; Among supported browsers, value is either 1 or 0 for mouse\r\n if (this._mouseId === -1) {\r\n if (evt.pointerId === undefined) { // If there is no pointerId (eg. manually dispatched MouseEvent)\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n }\r\n else {\r\n this._mouseId = evt.pointerId;\r\n }\r\n }\r\n\r\n if (!document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n else { // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n }\r\n catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 1;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._pointerUpEvent = ((evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = (deviceType === DeviceType.Mouse) ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n if (deviceSlot === -1) {\r\n return;\r\n }\r\n else {\r\n this._activeTouchIds[deviceSlot] = -1;\r\n }\r\n }\r\n\r\n const pointer = this._inputs[deviceType]?.[deviceSlot];\r\n if (pointer && pointer[evt.button + 2] !== 0) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n const previousButton = pointer[evt.button + 2];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this.onInputChanged(deviceEvent);\r\n }\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n deviceEvent.previousState = previousButton;\r\n deviceEvent.currentState = pointer[deviceEvent.inputIndex];\r\n\r\n if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this.onInputChanged(deviceEvent);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n });\r\n\r\n // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName = \"onwheel\" in document.createElement(\"div\") ? \"wheel\" : // Modern browsers support \"wheel\"\r\n (<any>document).onmousewheel !== undefined ? \"mousewheel\" : // Webkit and IE support at least \"mousewheel\"\r\n \"DOMMouseScroll\"; // let's assume that remaining browsers are older Firefox\r\n\r\n // Code originally in scene.inputManager.ts\r\n // Chrome reports warning in console if wheel listener doesn't set an explicit passive option.\r\n // IE11 only supports captureEvent:boolean, not options:object, and it defaults to false.\r\n // Feature detection technique copied from: https://github.com/github/eventlistener-polyfill (MIT license)\r\n let passiveSupported = false;\r\n const noop = function () { };\r\n\r\n try {\r\n const options: object = {\r\n passive: {\r\n get: function () {\r\n passiveSupported = true;\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n }\r\n catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = ((evt) => {\r\n // Handle mouse buttons\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let i = 0; i <= PointerInput.BrowserForward; i++) {\r\n if (pointer[i + 2] === 1) {\r\n pointer[i + 2] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, i + 2, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Mouse;\r\n deviceEvent.deviceSlot = 0;\r\n deviceEvent.inputIndex = i + 2;\r\n deviceEvent.currentState = pointer[i + 2];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n }\r\n\r\n // Handle Active Touches\r\n if (this.isDeviceAvailable(DeviceType.Touch)) {\r\n const pointer = this._inputs[DeviceType.Touch];\r\n\r\n for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {\r\n const pointerId = this._activeTouchIds[deviceSlot];\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(pointerId);\r\n }\r\n\r\n if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {\r\n pointer[deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const evt: IEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 1, this, this._elementToAttachTo);\r\n const deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = DeviceType.Touch;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = PointerInput.LeftClick;\r\n deviceEvent.currentState = pointer[deviceSlot][PointerInput.LeftClick];\r\n deviceEvent.previousState = 1;\r\n this.onInputChanged(deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this.onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._pointerWheelEvent = ((evt) => {\r\n const deviceType = DeviceType.Mouse;\r\n const deviceSlot = 0;\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = [];\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._pointerActive = true;\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n // Store previous values for event\r\n let previousWheelScrollX = pointer[PointerInput.MouseWheelX];\r\n let previousWheelScrollY = pointer[PointerInput.MouseWheelY];\r\n let previousWheelScrollZ = pointer[PointerInput.MouseWheelZ];\r\n\r\n pointer[PointerInput.MouseWheelX] = evt.deltaX || 0;\r\n pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0;\r\n pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n deviceEvent.previousState = previousWheelScrollX;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelX];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n deviceEvent.previousState = previousWheelScrollY;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelY];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n deviceEvent.previousState = previousWheelScrollZ;\r\n deviceEvent.currentState = pointer[PointerInput.MouseWheelZ];\r\n this.onInputChanged(deviceEvent);\r\n }\r\n }\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._pointerBlurEvent);\r\n this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false);\r\n\r\n // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame\r\n this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n pointer[PointerInput.MouseWheelX] = 0;\r\n pointer[PointerInput.MouseWheelY] = 0;\r\n pointer[PointerInput.MouseWheelZ] = 0;\r\n pointer[PointerInput.DeltaHorizontal] = 0;\r\n pointer[PointerInput.DeltaVertical] = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Handle all actions that come from gamepad interaction\r\n */\r\n private _handleGamepadActions(): void {\r\n this._gamepadConnectedEvent = ((evt: any) => {\r\n this._addGamePad(evt.gamepad);\r\n });\r\n\r\n this._gamepadDisconnectedEvent = ((evt: any) => {\r\n if (this._gamepads) {\r\n const deviceType = this._getGamepadDeviceType(evt.gamepad.id);\r\n const deviceSlot = evt.gamepad.index;\r\n\r\n this._unregisterDevice(deviceType, deviceSlot);\r\n delete this._gamepads[deviceSlot];\r\n }\r\n });\r\n\r\n window.addEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.addEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n /**\r\n * Update all non-event based devices with each frame\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n */\r\n private _updateDevice(deviceType: DeviceType, deviceSlot: number, inputIndex: number): void {\r\n // Gamepads\r\n const gp = navigator.getGamepads()[deviceSlot];\r\n\r\n if (gp && deviceType === this._gamepads[deviceSlot]) {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (inputIndex >= gp.buttons.length) {\r\n device[inputIndex] = gp.axes[inputIndex - gp.buttons.length].valueOf();\r\n }\r\n else {\r\n device[inputIndex] = gp.buttons[inputIndex].value;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets DeviceType from the device name\r\n * @param deviceName Name of Device from DeviceInputSystem\r\n * @returns DeviceType enum value\r\n */\r\n private _getGamepadDeviceType(deviceName: string): DeviceType {\r\n if (deviceName.indexOf(\"054c\") !== -1) { // DualShock 4 Gamepad\r\n return (deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock);\r\n }\r\n else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) { // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n }\r\n else if (deviceName.indexOf(\"057e\") !== -1) { // Switch Gamepad\r\n return DeviceType.Switch;\r\n }\r\n\r\n return DeviceType.Generic;\r\n }\r\n\r\n /**\r\n * Get DeviceType from a given pointer/mouse/touch event.\r\n * @param evt PointerEvent to evaluate\r\n * @returns DeviceType interpreted from event\r\n */\r\n private _getPointerType(evt: any): DeviceType {\r\n let deviceType = DeviceType.Mouse;\r\n\r\n if (evt.pointerType === \"touch\" || evt.pointerType === \"pen\" || evt.touches) {\r\n deviceType = DeviceType.Touch;\r\n }\r\n\r\n return deviceType;\r\n }\r\n}\r\n"]}
|
|
@@ -18,10 +18,17 @@ export declare class EngineView {
|
|
|
18
18
|
}
|
|
19
19
|
declare module "../../Engines/engine" {
|
|
20
20
|
interface Engine {
|
|
21
|
+
/** @hidden */
|
|
22
|
+
_inputElement: Nullable<HTMLElement>;
|
|
21
23
|
/**
|
|
22
24
|
* Gets or sets the HTML element to use for attaching events
|
|
23
25
|
*/
|
|
24
26
|
inputElement: Nullable<HTMLElement>;
|
|
27
|
+
/**
|
|
28
|
+
* Observable to handle when a change to inputElement occurs
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
_onEngineViewChanged?: () => void;
|
|
25
32
|
/**
|
|
26
33
|
* Gets the current engine view
|
|
27
34
|
* @see https://doc.babylonjs.com/how_to/multi_canvases
|
|
@@ -9,6 +9,18 @@ var EngineView = /** @class */ (function () {
|
|
|
9
9
|
return EngineView;
|
|
10
10
|
}());
|
|
11
11
|
export { EngineView };
|
|
12
|
+
Object.defineProperty(Engine.prototype, "inputElement", {
|
|
13
|
+
get: function () {
|
|
14
|
+
return this._inputElement;
|
|
15
|
+
},
|
|
16
|
+
set: function (value) {
|
|
17
|
+
var _a;
|
|
18
|
+
if (this._inputElement !== value) {
|
|
19
|
+
this._inputElement = value;
|
|
20
|
+
(_a = this._onEngineViewChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
});
|
|
12
24
|
Engine.prototype.getInputElement = function () {
|
|
13
25
|
return this.inputElement || this.getRenderingCanvas();
|
|
14
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.views.js","sourceRoot":"","sources":["../../../../sourceES6/core/Engines/Extensions/engine.views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKnC;;;GAGG;AACH;IAAA;IAWA,CAAC;IAAD,iBAAC;AAAD,CAAC,AAXD,IAWC;;AAqCD,MAAM,CAAC,SAAS,CAAC,eAAe,GAAG;IAC/B,OAAO,IAAI,C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;QACV,IAAI,aAAa,IAAI,KAAK,EAAE;YACxB,KAAK,CAAC,YAAY,GAAG,aAAa,CAAC;SACtC;KACJ;IAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAEvB,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Engine } from \"../engine\";\r\nimport { Camera } from '../../Cameras/camera';\r\nimport { Nullable } from '../../types';\r\nimport { Scene } from '../../scene';\r\n\r\n/**\r\n * Class used to define an additional view for the engine\r\n * @see https://doc.babylonjs.com/divingDeeper/scene/multiCanvas\r\n */\r\nexport class EngineView {\r\n /** Defines the canvas where to render the view */\r\n target: HTMLCanvasElement;\r\n /** Defines an optional camera used to render the view (will use active camera else) */\r\n camera?: Camera;\r\n /** Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1 */\r\n clearBeforeCopy?: boolean;\r\n /** Indicates if the view is enabled (true by default) */\r\n enabled: boolean;\r\n /** Defines a custom function to handle canvas size changes. (the canvas to render into is provided to the callback) */\r\n customResize?: (canvas: HTMLCanvasElement) => void;\r\n}\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n export interface Engine {\r\n\r\n /**\r\n * Gets or sets the HTML element to use for attaching events\r\n */\r\n inputElement: Nullable<HTMLElement>;\r\n\r\n /**\r\n * Gets the current engine view\r\n * @see https://doc.babylonjs.com/how_to/multi_canvases\r\n */\r\n activeView: Nullable<EngineView>;\r\n\r\n /** Gets or sets the list of views */\r\n views: EngineView[];\r\n\r\n /**\r\n * Register a new child canvas\r\n * @param canvas defines the canvas to register\r\n * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)\r\n * @param clearBeforeCopy Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1\r\n * @returns the associated view\r\n */\r\n registerView(canvas: HTMLCanvasElement, camera?: Camera, clearBeforeCopy?: boolean): EngineView;\r\n\r\n /**\r\n * Remove a registered child canvas\r\n * @param canvas defines the canvas to remove\r\n * @returns the current engine\r\n */\r\n unRegisterView(canvas: HTMLCanvasElement): Engine;\r\n }\r\n}\r\n\r\nEngine.prototype.getInputElement = function (): Nullable<HTMLElement> {\r\n return this.inputElement || this.getRenderingCanvas();\r\n};\r\n\r\nEngine.prototype.registerView = function (canvas: HTMLCanvasElement, camera?: Camera, clearBeforeCopy?: boolean): EngineView {\r\n if (!this.views) {\r\n this.views = [];\r\n }\r\n\r\n for (var view of this.views) {\r\n if (view.target === canvas) {\r\n return view;\r\n }\r\n }\r\n\r\n let masterCanvas = this.getRenderingCanvas();\r\n if (masterCanvas) {\r\n canvas.width = masterCanvas.width;\r\n canvas.height = masterCanvas.height;\r\n }\r\n\r\n let newView = { target: canvas, camera, clearBeforeCopy, enabled: true };\r\n this.views.push(newView);\r\n\r\n if (camera) {\r\n camera.onDisposeObservable.add(() => {\r\n this.unRegisterView(canvas);\r\n });\r\n }\r\n\r\n return newView;\r\n};\r\n\r\nEngine.prototype.unRegisterView = function (canvas: HTMLCanvasElement): Engine {\r\n if (!this.views) {\r\n return this;\r\n }\r\n\r\n for (var view of this.views) {\r\n if (view.target === canvas) {\r\n let index = this.views.indexOf(view);\r\n\r\n if (index !== -1) {\r\n this.views.splice(index, 1);\r\n }\r\n break;\r\n }\r\n }\r\n\r\n return this;\r\n};\r\n\r\nEngine.prototype._renderViews = function () {\r\n if (!this.views) {\r\n return false;\r\n }\r\n\r\n let parent = this.getRenderingCanvas();\r\n\r\n if (!parent) {\r\n return false;\r\n }\r\n\r\n for (var view of this.views) {\r\n if (!view.enabled) {\r\n continue;\r\n }\r\n let canvas = view.target;\r\n let context = canvas.getContext(\"2d\");\r\n if (!context) {\r\n continue;\r\n }\r\n let camera = view.camera;\r\n let previewCamera: Nullable<Camera> = null;\r\n let scene: Nullable<Scene> = null;\r\n if (camera) {\r\n scene = camera.getScene();\r\n\r\n if (scene.activeCameras && scene.activeCameras.length) {\r\n continue;\r\n }\r\n\r\n this.activeView = view;\r\n\r\n previewCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n if (view.customResize) {\r\n view.customResize(canvas);\r\n }\r\n else {\r\n // Set sizes\r\n const width = Math.floor(canvas.clientWidth / this._hardwareScalingLevel);\r\n const height = Math.floor(canvas.clientHeight / this._hardwareScalingLevel);\r\n\r\n const dimsChanged =\r\n width !== canvas.width || parent.width !== canvas.width ||\r\n height !== canvas.height || parent.height !== canvas.height;\r\n if (canvas.clientWidth && canvas.clientHeight && dimsChanged) {\r\n canvas.width = width;\r\n canvas.height = height;\r\n this.setSize(width, height);\r\n }\r\n }\r\n\r\n if (!parent.width || !parent.height) {\r\n return false;\r\n }\r\n\r\n // Render the frame\r\n this._renderFrame();\r\n\r\n this.flushFramebuffer();\r\n\r\n // Copy to target\r\n if (view.clearBeforeCopy) {\r\n context.clearRect(0, 0, parent.width, parent.height);\r\n }\r\n context.drawImage(parent, 0, 0);\r\n\r\n // Restore\r\n if (previewCamera && scene) {\r\n scene.activeCamera = previewCamera;\r\n }\r\n }\r\n\r\n this.activeView = null;\r\n\r\n return true;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.views.js","sourceRoot":"","sources":["../../../../sourceES6/core/Engines/Extensions/engine.views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKnC;;;GAGG;AACH;IAAA;IAWA,CAAC;IAAD,iBAAC;AAAD,CAAC,AAXD,IAWC;;AA6CD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,EAAE;IACpD,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IACD,GAAG,EAAE,UAAwB,KAAkB;;QAC3C,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,EAAE;YAC9B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,MAAA,IAAI,CAAC,oBAAoB,+CAAzB,IAAI,CAAyB,CAAC;SACjC;IACL,CAAC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ACD,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAEhC,UAAU;QACV,IAAI,aAAa,IAAI,KAAK,EAAE;YACxB,KAAK,CAAC,YAAY,GAAG,aAAa,CAAC;SACtC;KACJ;IAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAEvB,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Engine } from \"../engine\";\r\nimport { Camera } from '../../Cameras/camera';\r\nimport { Nullable } from '../../types';\r\nimport { Scene } from '../../scene';\r\n\r\n/**\r\n * Class used to define an additional view for the engine\r\n * @see https://doc.babylonjs.com/divingDeeper/scene/multiCanvas\r\n */\r\nexport class EngineView {\r\n /** Defines the canvas where to render the view */\r\n target: HTMLCanvasElement;\r\n /** Defines an optional camera used to render the view (will use active camera else) */\r\n camera?: Camera;\r\n /** Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1 */\r\n clearBeforeCopy?: boolean;\r\n /** Indicates if the view is enabled (true by default) */\r\n enabled: boolean;\r\n /** Defines a custom function to handle canvas size changes. (the canvas to render into is provided to the callback) */\r\n customResize?: (canvas: HTMLCanvasElement) => void;\r\n}\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n export interface Engine {\r\n /** @hidden */\r\n _inputElement: Nullable<HTMLElement>;\r\n\r\n /**\r\n * Gets or sets the HTML element to use for attaching events\r\n */\r\n inputElement: Nullable<HTMLElement>;\r\n\r\n /**\r\n * Observable to handle when a change to inputElement occurs\r\n * @hidden\r\n */\r\n _onEngineViewChanged?: () => void;\r\n\r\n /**\r\n * Gets the current engine view\r\n * @see https://doc.babylonjs.com/how_to/multi_canvases\r\n */\r\n activeView: Nullable<EngineView>;\r\n\r\n /** Gets or sets the list of views */\r\n views: EngineView[];\r\n\r\n /**\r\n * Register a new child canvas\r\n * @param canvas defines the canvas to register\r\n * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)\r\n * @param clearBeforeCopy Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1\r\n * @returns the associated view\r\n */\r\n registerView(canvas: HTMLCanvasElement, camera?: Camera, clearBeforeCopy?: boolean): EngineView;\r\n\r\n /**\r\n * Remove a registered child canvas\r\n * @param canvas defines the canvas to remove\r\n * @returns the current engine\r\n */\r\n unRegisterView(canvas: HTMLCanvasElement): Engine;\r\n }\r\n}\r\n\r\nObject.defineProperty(Engine.prototype, \"inputElement\", {\r\n get: function (this: Engine) {\r\n return this._inputElement;\r\n },\r\n set: function (this: Engine, value: HTMLElement) {\r\n if (this._inputElement !== value) {\r\n this._inputElement = value;\r\n this._onEngineViewChanged?.();\r\n }\r\n },\r\n});\r\n\r\nEngine.prototype.getInputElement = function (): Nullable<HTMLElement> {\r\n return this.inputElement || this.getRenderingCanvas();\r\n};\r\n\r\nEngine.prototype.registerView = function (canvas: HTMLCanvasElement, camera?: Camera, clearBeforeCopy?: boolean): EngineView {\r\n if (!this.views) {\r\n this.views = [];\r\n }\r\n\r\n for (var view of this.views) {\r\n if (view.target === canvas) {\r\n return view;\r\n }\r\n }\r\n\r\n let masterCanvas = this.getRenderingCanvas();\r\n if (masterCanvas) {\r\n canvas.width = masterCanvas.width;\r\n canvas.height = masterCanvas.height;\r\n }\r\n\r\n let newView = { target: canvas, camera, clearBeforeCopy, enabled: true };\r\n this.views.push(newView);\r\n\r\n if (camera) {\r\n camera.onDisposeObservable.add(() => {\r\n this.unRegisterView(canvas);\r\n });\r\n }\r\n\r\n return newView;\r\n};\r\n\r\nEngine.prototype.unRegisterView = function (canvas: HTMLCanvasElement): Engine {\r\n if (!this.views) {\r\n return this;\r\n }\r\n\r\n for (var view of this.views) {\r\n if (view.target === canvas) {\r\n let index = this.views.indexOf(view);\r\n\r\n if (index !== -1) {\r\n this.views.splice(index, 1);\r\n }\r\n break;\r\n }\r\n }\r\n\r\n return this;\r\n};\r\n\r\nEngine.prototype._renderViews = function () {\r\n if (!this.views) {\r\n return false;\r\n }\r\n\r\n let parent = this.getRenderingCanvas();\r\n\r\n if (!parent) {\r\n return false;\r\n }\r\n\r\n for (var view of this.views) {\r\n if (!view.enabled) {\r\n continue;\r\n }\r\n let canvas = view.target;\r\n let context = canvas.getContext(\"2d\");\r\n if (!context) {\r\n continue;\r\n }\r\n let camera = view.camera;\r\n let previewCamera: Nullable<Camera> = null;\r\n let scene: Nullable<Scene> = null;\r\n if (camera) {\r\n scene = camera.getScene();\r\n\r\n if (scene.activeCameras && scene.activeCameras.length) {\r\n continue;\r\n }\r\n\r\n this.activeView = view;\r\n\r\n previewCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n if (view.customResize) {\r\n view.customResize(canvas);\r\n }\r\n else {\r\n // Set sizes\r\n const width = Math.floor(canvas.clientWidth / this._hardwareScalingLevel);\r\n const height = Math.floor(canvas.clientHeight / this._hardwareScalingLevel);\r\n\r\n const dimsChanged =\r\n width !== canvas.width || parent.width !== canvas.width ||\r\n height !== canvas.height || parent.height !== canvas.height;\r\n if (canvas.clientWidth && canvas.clientHeight && dimsChanged) {\r\n canvas.width = width;\r\n canvas.height = height;\r\n this.setSize(width, height);\r\n }\r\n }\r\n\r\n if (!parent.width || !parent.height) {\r\n return false;\r\n }\r\n\r\n // Render the frame\r\n this._renderFrame();\r\n\r\n this.flushFramebuffer();\r\n\r\n // Copy to target\r\n if (view.clearBeforeCopy) {\r\n context.clearRect(0, 0, parent.width, parent.height);\r\n }\r\n context.drawImage(parent, 0, 0);\r\n\r\n // Restore\r\n if (previewCamera && scene) {\r\n scene.activeCamera = previewCamera;\r\n }\r\n }\r\n\r\n this.activeView = null;\r\n\r\n return true;\r\n};\r\n"]}
|
package/Engines/nativeEngine.js
CHANGED
|
@@ -14,6 +14,7 @@ import { ShaderCodeInliner } from "./Processors/shaderCodeInliner.js";
|
|
|
14
14
|
import { WebGL2ShaderProcessor } from '../Engines/WebGL/webGL2ShaderProcessors.js';
|
|
15
15
|
import { RenderTargetWrapper } from "./renderTargetWrapper.js";
|
|
16
16
|
import { NativeDataStream } from "./Native/nativeDataStream.js";
|
|
17
|
+
import { RuntimeError, ErrorCodes } from "../Misc/error.js";
|
|
17
18
|
var onNativeObjectInitialized = new Observable();
|
|
18
19
|
if (typeof self !== 'undefined' && !self.hasOwnProperty("_native")) {
|
|
19
20
|
var __native_1;
|
|
@@ -2500,7 +2501,7 @@ var NativeEngine = /** @class */ (function (_super) {
|
|
|
2500
2501
|
return _native.Engine.TEXTURE_FORMAT_RGBA32F;
|
|
2501
2502
|
}
|
|
2502
2503
|
else {
|
|
2503
|
-
throw new
|
|
2504
|
+
throw new RuntimeError("Unsupported texture format or type: format ".concat(format, ", type ").concat(type, "."), ErrorCodes.UnsupportedTextureError);
|
|
2504
2505
|
}
|
|
2505
2506
|
};
|
|
2506
2507
|
NativeEngine.prototype._getNativeAlphaMode = function (mode) {
|