@babylonjs/core 5.0.0-beta.9 → 5.0.0-rc.2

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.
Files changed (187) hide show
  1. package/Actions/actionEvent.d.ts +3 -4
  2. package/Actions/actionEvent.js.map +1 -1
  3. package/Animations/animation.d.ts +4 -4
  4. package/Animations/animation.js +4 -4
  5. package/Animations/animation.js.map +1 -1
  6. package/Audio/sound.d.ts +12 -6
  7. package/Audio/sound.js +48 -24
  8. package/Audio/sound.js.map +1 -1
  9. package/BakedVertexAnimation/vertexAnimationBaker.js +0 -1
  10. package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
  11. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  12. package/Behaviors/Meshes/pointerDragBehavior.js +5 -0
  13. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  14. package/Bones/skeleton.js +20 -13
  15. package/Bones/skeleton.js.map +1 -1
  16. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +1 -0
  17. package/Cameras/Inputs/BaseCameraPointersInput.js +4 -3
  18. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  19. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +10 -9
  20. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  21. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  22. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  23. package/Cameras/arcRotateCamera.d.ts +4 -2
  24. package/Cameras/arcRotateCamera.js +11 -6
  25. package/Cameras/arcRotateCamera.js.map +1 -1
  26. package/Cameras/targetCamera.d.ts +1 -0
  27. package/Cameras/targetCamera.js +1 -0
  28. package/Cameras/targetCamera.js.map +1 -1
  29. package/Culling/ray.js +4 -2
  30. package/Culling/ray.js.map +1 -1
  31. package/DeviceInput/Helpers/eventFactory.d.ts +6 -6
  32. package/DeviceInput/Helpers/eventFactory.js +34 -16
  33. package/DeviceInput/Helpers/eventFactory.js.map +1 -1
  34. package/DeviceInput/InputDevices/deviceEnums.d.ts +26 -3
  35. package/DeviceInput/InputDevices/deviceEnums.js +31 -7
  36. package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
  37. package/DeviceInput/InputDevices/deviceSource.d.ts +11 -3
  38. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  39. package/DeviceInput/InputDevices/deviceSourceManager.d.ts +12 -9
  40. package/DeviceInput/InputDevices/deviceSourceManager.js +75 -12
  41. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  42. package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
  43. package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
  44. package/DeviceInput/InputDevices/inputInterfaces.d.ts +3 -28
  45. package/DeviceInput/InputDevices/inputInterfaces.js.map +1 -1
  46. package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +4 -24
  47. package/DeviceInput/InputDevices/internalDeviceSourceManager.js +27 -91
  48. package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
  49. package/DeviceInput/InputDevices/nativeDeviceInputSystem.d.ts +3 -2
  50. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +7 -13
  51. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
  52. package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +4 -2
  53. package/DeviceInput/InputDevices/webDeviceInputSystem.js +54 -77
  54. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
  55. package/Engines/Extensions/engine.query.d.ts +7 -0
  56. package/Engines/Extensions/engine.query.js +12 -0
  57. package/Engines/Extensions/engine.query.js.map +1 -1
  58. package/Engines/Extensions/engine.renderTarget.d.ts +5 -0
  59. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  60. package/Engines/ICanvas.d.ts +4 -0
  61. package/Engines/ICanvas.js.map +1 -1
  62. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  63. package/Engines/Native/nativeInterfaces.js.map +1 -1
  64. package/Engines/engine.d.ts +14 -2
  65. package/Engines/engine.js +25 -0
  66. package/Engines/engine.js.map +1 -1
  67. package/Engines/index.d.ts +1 -0
  68. package/Engines/index.js +1 -0
  69. package/Engines/index.js.map +1 -1
  70. package/Engines/nativeEngine.d.ts +8 -0
  71. package/Engines/nativeEngine.js +38 -10
  72. package/Engines/nativeEngine.js.map +1 -1
  73. package/Engines/thinEngine.js +2 -2
  74. package/Engines/thinEngine.js.map +1 -1
  75. package/Engines/webgpuEngine.js +2 -2
  76. package/Engines/webgpuEngine.js.map +1 -1
  77. package/Events/deviceInputEvents.d.ts +17 -18
  78. package/Events/deviceInputEvents.js.map +1 -1
  79. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  80. package/Helpers/environmentHelper.js +2 -2
  81. package/Helpers/environmentHelper.js.map +1 -1
  82. package/Helpers/videoDome.d.ts +8 -0
  83. package/Helpers/videoDome.js +18 -4
  84. package/Helpers/videoDome.js.map +1 -1
  85. package/Inputs/scene.inputManager.js +50 -24
  86. package/Inputs/scene.inputManager.js.map +1 -1
  87. package/Layers/effectLayer.d.ts +1 -0
  88. package/Layers/effectLayer.js +24 -0
  89. package/Layers/effectLayer.js.map +1 -1
  90. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -2
  91. package/Materials/Node/Blocks/Dual/textureBlock.js +50 -8
  92. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  93. package/Materials/Node/Blocks/elbowBlock.d.ts +6 -0
  94. package/Materials/Node/Blocks/elbowBlock.js +25 -0
  95. package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
  96. package/Materials/Node/Blocks/simplexPerlin3DBlock.js +1 -0
  97. package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
  98. package/Materials/Node/nodeMaterialBlock.d.ts +1 -1
  99. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  100. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  101. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  102. package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
  103. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  104. package/Materials/Textures/dynamicTexture.d.ts +1 -1
  105. package/Materials/Textures/dynamicTexture.js.map +1 -1
  106. package/Materials/materialPluginBase.d.ts +5 -0
  107. package/Materials/materialPluginBase.js +5 -0
  108. package/Materials/materialPluginBase.js.map +1 -1
  109. package/Materials/materialPluginEvent.d.ts +1 -0
  110. package/Materials/materialPluginEvent.js.map +1 -1
  111. package/Materials/materialPluginManager.d.ts +1 -0
  112. package/Materials/materialPluginManager.js +20 -15
  113. package/Materials/materialPluginManager.js.map +1 -1
  114. package/Materials/standardMaterial.js +1 -0
  115. package/Materials/standardMaterial.js.map +1 -1
  116. package/Maths/math.vector.d.ts +5 -0
  117. package/Maths/math.vector.js +20 -9
  118. package/Maths/math.vector.js.map +1 -1
  119. package/Meshes/Builders/polygonBuilder.js +2 -1
  120. package/Meshes/Builders/polygonBuilder.js.map +1 -1
  121. package/Meshes/Compression/dracoCompression.js +3 -7
  122. package/Meshes/Compression/dracoCompression.js.map +1 -1
  123. package/Meshes/abstractMesh.d.ts +1 -1
  124. package/Meshes/abstractMesh.js +0 -1
  125. package/Meshes/abstractMesh.js.map +1 -1
  126. package/Meshes/geometry.js +5 -0
  127. package/Meshes/geometry.js.map +1 -1
  128. package/Meshes/instancedMesh.js +7 -4
  129. package/Meshes/instancedMesh.js.map +1 -1
  130. package/Meshes/mesh.js +21 -22
  131. package/Meshes/mesh.js.map +1 -1
  132. package/Meshes/mesh.vertexData.d.ts +3 -2
  133. package/Meshes/mesh.vertexData.js +114 -85
  134. package/Meshes/mesh.vertexData.js.map +1 -1
  135. package/Meshes/transformNode.d.ts +3 -3
  136. package/Meshes/transformNode.js +9 -6
  137. package/Meshes/transformNode.js.map +1 -1
  138. package/Misc/fileTools.js +23 -9
  139. package/Misc/fileTools.js.map +1 -1
  140. package/Misc/khronosTextureContainer2.d.ts +10 -15
  141. package/Misc/khronosTextureContainer2.js +31 -60
  142. package/Misc/khronosTextureContainer2.js.map +1 -1
  143. package/Misc/videoRecorder.d.ts +1 -1
  144. package/Misc/videoRecorder.js +1 -1
  145. package/Misc/videoRecorder.js.map +1 -1
  146. package/Misc/workerPool.d.ts +37 -3
  147. package/Misc/workerPool.js +91 -15
  148. package/Misc/workerPool.js.map +1 -1
  149. package/Morph/morphTarget.d.ts +2 -1
  150. package/Morph/morphTarget.js +5 -1
  151. package/Morph/morphTarget.js.map +1 -1
  152. package/Morph/morphTargetManager.js +1 -1
  153. package/Morph/morphTargetManager.js.map +1 -1
  154. package/Particles/particleSystem.d.ts +13 -1
  155. package/Particles/particleSystem.js +20 -0
  156. package/Particles/particleSystem.js.map +1 -1
  157. package/Particles/pointsCloudSystem.d.ts +1 -1
  158. package/Particles/pointsCloudSystem.js +1 -1
  159. package/Particles/pointsCloudSystem.js.map +1 -1
  160. package/Rendering/prePassRenderer.js +12 -2
  161. package/Rendering/prePassRenderer.js.map +1 -1
  162. package/Rendering/subSurfaceConfiguration.js +1 -1
  163. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  164. package/Rendering/utilityLayerRenderer.js +2 -0
  165. package/Rendering/utilityLayerRenderer.js.map +1 -1
  166. package/Shaders/ShadersInclude/pointCloudVertex.js +1 -1
  167. package/Shaders/ShadersInclude/pointCloudVertex.js.map +1 -1
  168. package/Shaders/background.vertex.js +1 -1
  169. package/Shaders/background.vertex.js.map +1 -1
  170. package/Shaders/pbr.vertex.js +1 -1
  171. package/Shaders/pbr.vertex.js.map +1 -1
  172. package/XR/features/WebXRImageTracking.d.ts +2 -1
  173. package/XR/features/WebXRImageTracking.js +43 -64
  174. package/XR/features/WebXRImageTracking.js.map +1 -1
  175. package/XR/features/WebXRNearInteraction.js +4 -2
  176. package/XR/features/WebXRNearInteraction.js.map +1 -1
  177. package/XR/native/nativeXRFrame.d.ts +1 -0
  178. package/XR/native/nativeXRFrame.js +1 -0
  179. package/XR/native/nativeXRFrame.js.map +1 -1
  180. package/XR/webXRSessionManager.js +1 -0
  181. package/XR/webXRSessionManager.js.map +1 -1
  182. package/package.json +1 -1
  183. package/scene.d.ts +1 -10
  184. package/scene.js +36 -39
  185. package/scene.js.map +1 -1
  186. package/types.d.ts +1 -1
  187. package/types.js.map +1 -1
@@ -1,32 +1,7 @@
1
- import { IEvent } from "../../Events/deviceInputEvents";
1
+ import { IUIEvent } from "../../Events/deviceInputEvents";
2
2
  import { IDisposable } from "../../scene";
3
3
  import { Nullable } from "../../types";
4
4
  import { DeviceType } from "./deviceEnums";
5
- /**
6
- * Interface for Observables in DeviceInputSystem
7
- */
8
- export interface IDeviceEvent extends IEvent {
9
- /**
10
- * Device type
11
- */
12
- deviceType: DeviceType;
13
- /**
14
- * Device slot
15
- */
16
- deviceSlot: number;
17
- /**
18
- * Input array index
19
- */
20
- inputIndex: number;
21
- /**
22
- * Previous state of given input
23
- */
24
- previousState: Nullable<number>;
25
- /**
26
- * Current state of given input
27
- */
28
- currentState: Nullable<number>;
29
- }
30
5
  /**
31
6
  * Interface for NativeInput object
32
7
  */
@@ -42,7 +17,7 @@ export interface INativeInput extends IDisposable {
42
17
  /**
43
18
  * Callback for when input is changed on a device
44
19
  */
45
- onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>, eventData?: any) => void;
20
+ onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>) => void;
46
21
  /**
47
22
  * Checks for current device input value, given an id and input index.
48
23
  * @param deviceType Type of device
@@ -73,7 +48,7 @@ export interface IDeviceInputSystem extends IDisposable {
73
48
  /**
74
49
  * Callback for when an input is changed
75
50
  */
76
- onInputChanged: (deviceEvent: IDeviceEvent) => void;
51
+ onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
77
52
  /**
78
53
  * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
79
54
  * @param deviceType Enum specifiying device type
@@ -1 +1 @@
1
- {"version":3,"file":"inputInterfaces.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/inputInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { IDisposable } from \"../../scene\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\n\r\n/**\r\n * Interface for Observables in DeviceInputSystem\r\n */\r\nexport interface IDeviceEvent extends IEvent {\r\n /**\r\n * Device type\r\n */\r\n deviceType: DeviceType;\r\n /**\r\n * Device slot\r\n */\r\n deviceSlot: number;\r\n /**\r\n * Input array index\r\n */\r\n inputIndex: number;\r\n /**\r\n * Previous state of given input\r\n */\r\n previousState: Nullable<number>;\r\n /**\r\n * Current state of given input\r\n */\r\n currentState: Nullable<number>;\r\n}\r\n\r\n/**\r\n * Interface for NativeInput object\r\n */\r\nexport interface INativeInput extends IDisposable {\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when input is changed on a device\r\n */\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>, eventData?: any) => void;\r\n\r\n /**\r\n * Checks for current device input value, given an id and input index.\r\n * @param deviceType Type of device\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 pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}\r\n\r\n/**\r\n * Interface for DeviceInputSystem implementations (JS and Native)\r\n */\r\nexport interface IDeviceInputSystem extends IDisposable {\r\n // Callbacks\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when an input is changed\r\n */\r\n onInputChanged: (deviceEvent: IDeviceEvent) => void;\r\n\r\n // 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 pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}"]}
1
+ {"version":3,"file":"inputInterfaces.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/inputInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { IUIEvent } from \"../../Events/deviceInputEvents\";\r\nimport { IDisposable } from \"../../scene\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\n\r\n/**\r\n * Interface for NativeInput object\r\n */\r\nexport interface INativeInput extends IDisposable {\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when input is changed on a device\r\n */\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>) => void;\r\n\r\n /**\r\n * Checks for current device input value, given an id and input index.\r\n * @param deviceType Type of device\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 pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}\r\n\r\n/**\r\n * Interface for DeviceInputSystem implementations (JS and Native)\r\n */\r\nexport interface IDeviceInputSystem extends IDisposable {\r\n // Callbacks\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when an input is changed\r\n */\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;\r\n\r\n // 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 pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}\r\n"]}
@@ -1,10 +1,9 @@
1
1
  import { IDisposable } from '../../scene';
2
2
  import { DeviceType } from './deviceEnums';
3
- import { Nullable } from '../../types';
4
3
  import { Observable } from '../../Misc/observable';
5
- import { IDeviceEvent } from './inputInterfaces';
6
4
  import { DeviceSource } from './deviceSource';
7
5
  import { Engine } from '../../Engines/engine';
6
+ import { IUIEvent } from '../../Events/deviceInputEvents';
8
7
  declare module "../../Engines/engine" {
9
8
  interface Engine {
10
9
  /** @hidden */
@@ -14,38 +13,19 @@ declare module "../../Engines/engine" {
14
13
  /** @hidden */
15
14
  export interface IObservableManager {
16
15
  onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
17
- onInputChangedObservable: Observable<IDeviceEvent>;
18
16
  onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
17
+ _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;
18
+ _addDevice(deviceSource: DeviceSource<DeviceType>): void;
19
+ _removeDevice(deviceType: DeviceType, deviceSlot: number): void;
19
20
  }
20
21
  /** @hidden */
21
22
  export declare class InternalDeviceSourceManager implements IDisposable {
22
23
  private readonly _devices;
23
- private readonly _firstDevice;
24
24
  private readonly _deviceInputSystem;
25
25
  private readonly _registeredManagers;
26
26
  _refCount: number;
27
27
  constructor(engine: Engine);
28
- readonly getDeviceSource: <T extends DeviceType>(deviceType: T, deviceSlot?: number | undefined) => Nullable<DeviceSource<T>>;
29
- readonly getDeviceSources: <T extends DeviceType>(deviceType: T) => readonly DeviceSource<T>[];
30
- readonly getDevices: () => ReadonlyArray<DeviceSource<DeviceType>>;
31
28
  readonly registerManager: (manager: IObservableManager) => void;
32
29
  readonly unregisterManager: (manager: IObservableManager) => void;
33
30
  dispose(): void;
34
- /**
35
- * Function to add device name to device list
36
- * @param deviceType Enum specifying device type
37
- * @param deviceSlot "Slot" or index that device is referenced in
38
- */
39
- private _addDevice;
40
- /**
41
- * Function to remove device name to device list
42
- * @param deviceType Enum specifying device type
43
- * @param deviceSlot "Slot" or index that device is referenced in
44
- */
45
- private _removeDevice;
46
- /**
47
- * Updates array storing first connected device of each type
48
- * @param type Type of Device
49
- */
50
- private _updateFirstDevices;
51
31
  }
@@ -9,29 +9,14 @@ var InternalDeviceSourceManager = /** @class */ (function () {
9
9
  this._registeredManagers = new Array();
10
10
  this._refCount = 0;
11
11
  // Public Functions
12
- this.getDeviceSource = function (deviceType, deviceSlot) {
13
- if (deviceSlot === undefined) {
14
- if (_this._firstDevice[deviceType] === undefined) {
15
- return null;
12
+ this.registerManager = function (manager) {
13
+ for (var deviceType = 0; deviceType < _this._devices.length; deviceType++) {
14
+ var device = _this._devices[deviceType];
15
+ for (var deviceSlotKey in device) {
16
+ var deviceSlot = +deviceSlotKey;
17
+ manager._addDevice(new DeviceSource(_this._deviceInputSystem, deviceType, deviceSlot));
16
18
  }
17
- deviceSlot = _this._firstDevice[deviceType];
18
- }
19
- if (!_this._devices[deviceType] || _this._devices[deviceType][deviceSlot] === undefined) {
20
- return null;
21
19
  }
22
- return _this._devices[deviceType][deviceSlot];
23
- };
24
- this.getDeviceSources = function (deviceType) {
25
- return _this._devices[deviceType].filter(function (source) { return !!source; });
26
- };
27
- this.getDevices = function () {
28
- var deviceArray = new Array();
29
- _this._devices.forEach(function (deviceSet) {
30
- deviceArray.push.apply(deviceArray, deviceSet);
31
- });
32
- return deviceArray;
33
- };
34
- this.registerManager = function (manager) {
35
20
  _this._registeredManagers.push(manager);
36
21
  };
37
22
  this.unregisterManager = function (manager) {
@@ -42,7 +27,6 @@ var InternalDeviceSourceManager = /** @class */ (function () {
42
27
  };
43
28
  var numberOfDeviceTypes = Object.keys(DeviceType).length / 2;
44
29
  this._devices = new Array(numberOfDeviceTypes);
45
- this._firstDevice = new Array(numberOfDeviceTypes);
46
30
  if (typeof _native !== 'undefined') {
47
31
  this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();
48
32
  }
@@ -50,88 +34,40 @@ var InternalDeviceSourceManager = /** @class */ (function () {
50
34
  this._deviceInputSystem = new WebDeviceInputSystem(engine);
51
35
  }
52
36
  this._deviceInputSystem.onDeviceConnected = function (deviceType, deviceSlot) {
53
- _this._addDevice(deviceType, deviceSlot);
54
- var deviceSource = _this.getDeviceSource(deviceType, deviceSlot);
37
+ if (!_this._devices[deviceType]) {
38
+ _this._devices[deviceType] = new Array();
39
+ }
40
+ if (!_this._devices[deviceType][deviceSlot]) {
41
+ _this._devices[deviceType][deviceSlot] = deviceSlot;
42
+ }
55
43
  for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
56
44
  var manager = _a[_i];
57
- manager.onDeviceConnectedObservable.notifyObservers(deviceSource);
45
+ var deviceSource = new DeviceSource(_this._deviceInputSystem, deviceType, deviceSlot);
46
+ manager._addDevice(deviceSource);
58
47
  }
59
48
  };
60
49
  this._deviceInputSystem.onDeviceDisconnected = function (deviceType, deviceSlot) {
61
- var deviceSource = _this.getDeviceSource(deviceType, deviceSlot); // Grab local reference to use before removing from devices
62
- _this._removeDevice(deviceType, deviceSlot);
63
- for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
64
- var manager = _a[_i];
65
- manager.onDeviceDisconnectedObservable.notifyObservers(deviceSource);
50
+ var _a;
51
+ if ((_a = _this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
52
+ delete _this._devices[deviceType][deviceSlot];
53
+ }
54
+ for (var _i = 0, _b = _this._registeredManagers; _i < _b.length; _i++) {
55
+ var manager = _b[_i];
56
+ manager._removeDevice(deviceType, deviceSlot);
66
57
  }
67
58
  };
68
- this._deviceInputSystem.onInputChanged = function (deviceEvent) {
69
- for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
70
- var manager = _a[_i];
71
- manager.onInputChangedObservable.notifyObservers(deviceEvent);
59
+ this._deviceInputSystem.onInputChanged = function (deviceType, deviceSlot, eventData) {
60
+ if (eventData) {
61
+ for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
62
+ var manager = _a[_i];
63
+ manager._onInputChanged(deviceType, deviceSlot, eventData);
64
+ }
72
65
  }
73
66
  };
74
67
  }
75
68
  InternalDeviceSourceManager.prototype.dispose = function () {
76
69
  this._deviceInputSystem.dispose();
77
70
  };
78
- // Private Functions
79
- /**
80
- * Function to add device name to device list
81
- * @param deviceType Enum specifying device type
82
- * @param deviceSlot "Slot" or index that device is referenced in
83
- */
84
- InternalDeviceSourceManager.prototype._addDevice = function (deviceType, deviceSlot) {
85
- if (!this._devices[deviceType]) {
86
- this._devices[deviceType] = new Array();
87
- }
88
- if (!this._devices[deviceType][deviceSlot]) {
89
- this._devices[deviceType][deviceSlot] = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);
90
- this._updateFirstDevices(deviceType);
91
- }
92
- };
93
- /**
94
- * Function to remove device name to device list
95
- * @param deviceType Enum specifying device type
96
- * @param deviceSlot "Slot" or index that device is referenced in
97
- */
98
- InternalDeviceSourceManager.prototype._removeDevice = function (deviceType, deviceSlot) {
99
- var _a;
100
- if ((_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
101
- delete this._devices[deviceType][deviceSlot];
102
- }
103
- // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.
104
- this._updateFirstDevices(deviceType);
105
- };
106
- /**
107
- * Updates array storing first connected device of each type
108
- * @param type Type of Device
109
- */
110
- InternalDeviceSourceManager.prototype._updateFirstDevices = function (type) {
111
- switch (type) {
112
- case DeviceType.Keyboard:
113
- case DeviceType.Mouse:
114
- this._firstDevice[type] = 0;
115
- break;
116
- case DeviceType.Touch:
117
- case DeviceType.DualSense:
118
- case DeviceType.DualShock:
119
- case DeviceType.Xbox:
120
- case DeviceType.Switch:
121
- case DeviceType.Generic:
122
- delete this._firstDevice[type];
123
- var devices = this._devices[type];
124
- if (devices) {
125
- for (var i = 0; i < devices.length; i++) {
126
- if (devices[i]) {
127
- this._firstDevice[type] = i;
128
- break;
129
- }
130
- }
131
- }
132
- break;
133
- }
134
- };
135
71
  return InternalDeviceSourceManager;
136
72
  }());
137
73
  export { InternalDeviceSourceManager };
@@ -1 +1 @@
1
- {"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/internalDeviceSourceManager.ts"],"names":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AAI,OAAO,CAAC,CAAC,CAAC,EAAE;4BACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BAC5B,MAAM;yBACT;qBACJ;iBACJ;gBACD,MAAM;SACb;IACL,CAAC;IACL,kCAAC;AAAD,CAAC,AAtJD,IAsJC","sourcesContent":["import { IDisposable } from '../../scene';\r\nimport { DeviceType } from './deviceEnums';\r\nimport { Nullable } from '../../types';\r\nimport { Observable } from '../../Misc/observable';\r\nimport { IDeviceEvent, IDeviceInputSystem } from './inputInterfaces';\r\nimport { NativeDeviceInputSystem } from './nativeDeviceInputSystem';\r\nimport { WebDeviceInputSystem } from './webDeviceInputSystem';\r\nimport { DeviceSource } from './deviceSource';\r\nimport { INative } from '../../Engines/Native/nativeInterfaces';\r\nimport { Engine } from '../../Engines/engine';\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n interface Engine {\r\n /** @hidden */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @hidden */\r\nexport interface IObservableManager {\r\n onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n onInputChangedObservable: Observable<IDeviceEvent>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n}\r\n\r\n/** @hidden */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Private Members\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n private readonly _registeredManagers = new Array<IObservableManager>();\r\n\r\n public _refCount = 0;\r\n\r\n public constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<DeviceSource<DeviceType>>>(numberOfDeviceTypes);\r\n this._firstDevice = new Array<number>(numberOfDeviceTypes);\r\n\r\n if (typeof _native !== 'undefined') {\r\n this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();\r\n }\r\n else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine);\r\n }\r\n\r\n this._deviceInputSystem.onDeviceConnected = (deviceType, deviceSlot) => {\r\n this._addDevice(deviceType, deviceSlot);\r\n const deviceSource = this.getDeviceSource(deviceType, deviceSlot)!;\r\n for (const manager of this._registeredManagers) {\r\n manager.onDeviceConnectedObservable.notifyObservers(deviceSource);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n const deviceSource = this.getDeviceSource(deviceType, deviceSlot)!; // Grab local reference to use before removing from devices\r\n this._removeDevice(deviceType, deviceSlot);\r\n for (const manager of this._registeredManagers) {\r\n manager.onDeviceDisconnectedObservable.notifyObservers(deviceSource);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onInputChanged = (deviceEvent) => {\r\n for (const manager of this._registeredManagers) {\r\n manager.onInputChangedObservable.notifyObservers(deviceEvent);\r\n }\r\n };\r\n }\r\n\r\n // Public Functions\r\n public readonly getDeviceSource = <T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>> => {\r\n if (deviceSlot === undefined) {\r\n if (this._firstDevice[deviceType] === undefined) {\r\n return null;\r\n }\r\n\r\n deviceSlot = this._firstDevice[deviceType];\r\n }\r\n\r\n if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {\r\n return null;\r\n }\r\n\r\n return this._devices[deviceType][deviceSlot];\r\n }\r\n\r\n public readonly getDeviceSources = <T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> => {\r\n return this._devices[deviceType].filter((source) => { return !!source; });\r\n }\r\n\r\n public readonly getDevices = (): ReadonlyArray<DeviceSource<DeviceType>> => {\r\n const deviceArray = new Array<DeviceSource<DeviceType>>();\r\n this._devices.forEach((deviceSet) => {\r\n deviceArray.push.apply(deviceArray, deviceSet);\r\n });\r\n\r\n return deviceArray;\r\n }\r\n\r\n public readonly registerManager = (manager: IObservableManager): void => {\r\n this._registeredManagers.push(manager);\r\n }\r\n\r\n public readonly unregisterManager = (manager: IObservableManager): void => {\r\n const idx = this._registeredManagers.indexOf(manager);\r\n\r\n if (idx > -1) {\r\n this._registeredManagers.splice(idx, 1);\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n this._deviceInputSystem.dispose();\r\n }\r\n\r\n // Private Functions\r\n /**\r\n * Function to add device name to device list\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _addDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<DeviceSource<DeviceType>>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n this._updateFirstDevices(deviceType);\r\n }\r\n }\r\n\r\n /**\r\n * Function to remove device name to device list\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.\r\n this._updateFirstDevices(deviceType);\r\n }\r\n\r\n /**\r\n * Updates array storing first connected device of each type\r\n * @param type Type of Device\r\n */\r\n private _updateFirstDevices(type: DeviceType): void {\r\n switch (type) {\r\n case DeviceType.Keyboard:\r\n case DeviceType.Mouse:\r\n this._firstDevice[type] = 0;\r\n break;\r\n case DeviceType.Touch:\r\n case DeviceType.DualSense:\r\n case DeviceType.DualShock:\r\n case DeviceType.Xbox:\r\n case DeviceType.Switch:\r\n case DeviceType.Generic:\r\n delete this._firstDevice[type];\r\n const devices = this._devices[type];\r\n if (devices) {\r\n for (let i = 0; i < devices.length; i++) {\r\n if (devices[i]) {\r\n this._firstDevice[type] = i;\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,cAAc;AACd;IAWI,qCAAmB,MAAc;QAAjC,iBAyCC;QA7CgB,wBAAmB,GAAG,IAAI,KAAK,EAAsB,CAAC;QAEhE,cAAS,GAAG,CAAC,CAAC;QA6CrB,mBAAmB;QACH,oBAAe,GAAG,UAAC,OAA2B;YAC1D,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBACtE,IAAM,MAAM,GAAG,KAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACzC,KAAK,IAAM,aAAa,IAAI,MAAM,EAAE;oBAChC,IAAM,UAAU,GAAG,CAAC,aAAa,CAAC;oBAClC,OAAO,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,KAAI,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;iBACzF;aACJ;YACD,KAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC,CAAA;QAEe,sBAAiB,GAAG,UAAC,OAA2B;YAC5D,IAAM,GAAG,GAAG,KAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAEtD,IAAI,GAAG,GAAG,CAAC,CA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C;aACpC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,GAAG,UAAC,UAAU,EAAE,UAAU;;YAClE,IAAI,MAAA,KAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,0CAAG,UAAU,CAAC,EAAE;gBACzC,OAAO,KAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;aAChD;YACD,KAAsB,UAAwB,EAAxB,KAAA,KAAI,CAAC,mBAAmB,EAAxB,cAAwB,EAAxB,IAAwB,EAAE;gBAA3C,IAAM,OAAO,SAAA;gBACd,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;aACjD;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,kBAAkB,CAAC,cAAc,GAAG,UAAC,UAAsB,EAAE,UAAkB,EAAE,SAAmB;YACrG,IAAI,SAAS,EAAE;gBACX,KAAsB,UAAwB,EAAxB,KAAA,KAAI,CAAC,mBAAmB,EAAxB,cAAwB,EAAxB,IAAwB,EAAE;oBAA3C,IAAM,OAAO,SAAA;oBACd,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;iBAC9D;aACJ;QACL,CAAC,CAAC;IACN,CAAC;IAsBM,6CAAO,GAAd;QACI,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IACL,kCAAC;AAAD,CAAC,AA7ED,IA6EC","sourcesContent":["import { IDisposable } from '../../scene';\r\nimport { DeviceType } from './deviceEnums';\r\nimport { Observable } from '../../Misc/observable';\r\nimport { IDeviceInputSystem } from './inputInterfaces';\r\nimport { NativeDeviceInputSystem } from './nativeDeviceInputSystem';\r\nimport { WebDeviceInputSystem } from './webDeviceInputSystem';\r\nimport { DeviceSource } from './deviceSource';\r\nimport { INative } from '../../Engines/Native/nativeInterfaces';\r\nimport { Engine } from '../../Engines/engine';\r\nimport { IUIEvent } from '../../Events/deviceInputEvents';\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n interface Engine {\r\n /** @hidden */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @hidden */\r\nexport interface IObservableManager {\r\n onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n\r\n // Functions\r\n _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;\r\n _addDevice(deviceSource: DeviceSource<DeviceType>): void;\r\n _removeDevice(deviceType: DeviceType, deviceSlot: number): void;\r\n}\r\n\r\n/** @hidden */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Private Members\r\n // This is a master list of all device type/slot combos\r\n private readonly _devices: Array<Array<number>>;\r\n\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n private readonly _registeredManagers = new Array<IObservableManager>();\r\n\r\n public _refCount = 0;\r\n\r\n public constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<number>>(numberOfDeviceTypes);\r\n\r\n if (typeof _native !== 'undefined') {\r\n this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();\r\n }\r\n else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine);\r\n }\r\n\r\n this._deviceInputSystem.onDeviceConnected = (deviceType, deviceSlot) => {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<number>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = deviceSlot;\r\n }\r\n for (const manager of this._registeredManagers) {\r\n const deviceSource = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n manager._addDevice(deviceSource);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n for (const manager of this._registeredManagers) {\r\n manager._removeDevice(deviceType, deviceSlot);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onInputChanged = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => {\r\n if (eventData) {\r\n for (const manager of this._registeredManagers) {\r\n manager._onInputChanged(deviceType, deviceSlot, eventData);\r\n }\r\n }\r\n };\r\n }\r\n\r\n // Public Functions\r\n public readonly registerManager = (manager: IObservableManager): void => {\r\n for (let deviceType = 0; deviceType < this._devices.length; deviceType++) {\r\n const device = this._devices[deviceType];\r\n for (const deviceSlotKey in device) {\r\n const deviceSlot = +deviceSlotKey;\r\n manager._addDevice(new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot));\r\n }\r\n }\r\n this._registeredManagers.push(manager);\r\n }\r\n\r\n public readonly unregisterManager = (manager: IObservableManager): void => {\r\n const idx = this._registeredManagers.indexOf(manager);\r\n\r\n if (idx > -1) {\r\n this._registeredManagers.splice(idx, 1);\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n this._deviceInputSystem.dispose();\r\n }\r\n}\r\n"]}
@@ -1,10 +1,11 @@
1
+ import { IUIEvent } from "../../Events/deviceInputEvents";
1
2
  import { DeviceType } from "./deviceEnums";
2
- import { IDeviceEvent, IDeviceInputSystem, INativeInput } from "./inputInterfaces";
3
+ import { IDeviceInputSystem, INativeInput } from "./inputInterfaces";
3
4
  /** @hidden */
4
5
  export declare class NativeDeviceInputSystem implements IDeviceInputSystem {
5
6
  onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
6
7
  onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
7
- onInputChanged: (deviceEvent: IDeviceEvent) => void;
8
+ onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
8
9
  private readonly _nativeInput;
9
10
  constructor(nativeInput?: INativeInput);
10
11
  /**
@@ -1,12 +1,12 @@
1
1
  import { DeviceEventFactory } from "../Helpers/eventFactory.js";
2
- import { DeviceType, PointerInput } from "./deviceEnums.js";
2
+ import { DeviceType, NativePointerInput, PointerInput } from "./deviceEnums.js";
3
3
  /** @hidden */
4
4
  var NativeDeviceInputSystem = /** @class */ (function () {
5
5
  function NativeDeviceInputSystem(nativeInput) {
6
6
  var _this = this;
7
7
  this.onDeviceConnected = function (deviceType, deviceSlot) { };
8
8
  this.onDeviceDisconnected = function (deviceType, deviceSlot) { };
9
- this.onInputChanged = function (deviceEvent) { };
9
+ this.onInputChanged = function (deviceType, deviceSlot, eventData) { };
10
10
  this._nativeInput = nativeInput || this._createDummyNativeInput();
11
11
  this._nativeInput.onDeviceConnected = function (deviceType, deviceSlot) {
12
12
  _this.onDeviceConnected(deviceType, deviceSlot);
@@ -14,16 +14,10 @@ var NativeDeviceInputSystem = /** @class */ (function () {
14
14
  this._nativeInput.onDeviceDisconnected = function (deviceType, deviceSlot) {
15
15
  _this.onDeviceDisconnected(deviceType, deviceSlot);
16
16
  };
17
- this._nativeInput.onInputChanged = function (deviceType, deviceSlot, inputIndex, previousState, currentState, eventData) {
18
- var idx = (inputIndex === PointerInput.Horizontal || inputIndex === PointerInput.Vertical || inputIndex === PointerInput.DeltaHorizontal || inputIndex === PointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;
19
- var evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, inputIndex, currentState, _this);
20
- var deviceEvent = evt;
21
- deviceEvent.deviceType = deviceType;
22
- deviceEvent.deviceSlot = deviceSlot;
23
- deviceEvent.inputIndex = idx;
24
- deviceEvent.previousState = previousState;
25
- deviceEvent.currentState = currentState;
26
- _this.onInputChanged(deviceEvent);
17
+ this._nativeInput.onInputChanged = function (deviceType, deviceSlot, inputIndex, currentState) {
18
+ var idx = (inputIndex === NativePointerInput.Horizontal || inputIndex === NativePointerInput.Vertical || inputIndex === NativePointerInput.DeltaHorizontal || inputIndex === NativePointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;
19
+ var evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, idx, currentState, _this);
20
+ _this.onInputChanged(deviceType, deviceSlot, evt);
27
21
  };
28
22
  }
29
23
  // Public functions
@@ -62,7 +56,7 @@ var NativeDeviceInputSystem = /** @class */ (function () {
62
56
  var nativeInput = {
63
57
  onDeviceConnected: function (deviceType, deviceSlot) { },
64
58
  onDeviceDisconnected: function (deviceType, deviceSlot) { },
65
- onInputChanged: function (deviceType, deviceSlot, inputIndex, previousState, currentState, eventData) { },
59
+ onInputChanged: function (deviceType, deviceSlot, inputIndex, currentState) { },
66
60
  pollInput: function () { return 0; },
67
61
  isDeviceAvailable: function () { return false; },
68
62
  dispose: function () { },
@@ -1 +1 @@
1
- {"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/nativeDeviceInputSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzD,cAAc;AACd;IAOI,iCAAmB,WAA0B;QAA7C,iBAwBC;QA9BM,sBAAiB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QACxE,yBAAoB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QAC3E,mBAAc,GAAG,UAAC,WAAyB,IAAO,CAAC,CAAC;QAKvD,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAElE,IAAI,CAAC,YAAY,CAAC,iBAAiB,GAAG,UAAC,UAAU,EAAE,UAAU;YACzD,KAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,oBAAoB,GAAG,U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,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAED;;OAEG;IACI,yCAAO,GAAd;QACI,IAAI,CAAC,iBAAiB,GAAG,cAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,oBAAoB,GAAG,cAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,cAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACK,yDAAuB,GAA/B;QACI,IAAI,WAAW,GAAG;YACd,iBAAiB,EAAE,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC;YACtE,oBAAoB,EAAE,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC;YACzE,cAAc,EAAE,UAAC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,aAA+B,EAAE,YAA8B,EAAE,SAAe,IAAO,CAAC;YACzK,SAAS,EAAE,cAAQ,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9B,iBAAiB,EAAE,cAAQ,OAAO,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,EAAE,cAAQ,CAAC;SACrB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IACL,8BAAC;AAAD,CAAC,AAhFD,IAgFC","sourcesContent":["import { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem, INativeInput } from \"./inputInterfaces\";\r\n\r\n/** @hidden */\r\nexport class NativeDeviceInputSystem implements IDeviceInputSystem {\r\n public onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n private readonly _nativeInput: INativeInput;\r\n\r\n public constructor(nativeInput?: INativeInput) {\r\n this._nativeInput = nativeInput || this._createDummyNativeInput();\r\n\r\n this._nativeInput.onDeviceConnected = (deviceType, deviceSlot) => {\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onInputChanged = (deviceType, deviceSlot, inputIndex, previousState, currentState, eventData) => {\r\n const idx = (inputIndex === PointerInput.Horizontal || inputIndex === PointerInput.Vertical || inputIndex === PointerInput.DeltaHorizontal || inputIndex === PointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;\r\n const evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, inputIndex, currentState, this);\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = idx;\r\n deviceEvent.previousState = previousState;\r\n deviceEvent.currentState = currentState;\r\n\r\n this.onInputChanged(deviceEvent);\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 return this._nativeInput.pollInput(deviceType, deviceSlot, inputIndex);\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 //TODO: FIx native side first\r\n return (deviceType === DeviceType.Mouse || deviceType === DeviceType.Touch);\r\n }\r\n\r\n /**\r\n * Dispose of all the observables\r\n */\r\n public dispose(): void {\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n }\r\n\r\n /**\r\n * For versions of BabylonNative that don't have the NativeInput plugin initialized, create a dummy version\r\n * @returns Object with dummy functions\r\n */\r\n private _createDummyNativeInput() {\r\n let nativeInput = {\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>, eventData?: any) => { },\r\n pollInput: () => { return 0; },\r\n isDeviceAvailable: () => { return false; },\r\n dispose: () => { },\r\n };\r\n\r\n return nativeInput;\r\n }\r\n}"]}
1
+ {"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/nativeDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7E,cAAc;AACd;IAOI,iCAAmB,WAA0B;QAA7C,iBAiBC;QAvBM,sBAAiB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QACxE,yBAAoB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QAC3E,mBAAc,GAAG,UAAC,UAAsB,EAAE,UAAkB,EAAE,SAAmB,IAAO,CAAC,CAAC;QAK7F,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAElE,IAAI,CAAC,YAAY,CAAC,iBAAiB,GAAG,UAAC,UAAU,EAAE,UAAU;YACzD,KAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,oBAAoB,GAAG,UAAC,UAAU,EAAE,UAAU;YAC5D,KAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACtD,CAA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AkB,IAAO,CAAC;YACtE,oBAAoB,EAAE,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC;YACzE,cAAc,EAAE,UAAC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,YAA8B,IAAO,CAAC;YACvH,SAAS,EAAE,cAAQ,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9B,iBAAiB,EAAE,cAAQ,OAAO,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,EAAE,cAAQ,CAAC;SACrB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IACL,8BAAC;AAAD,CAAC,AAzED,IAyEC","sourcesContent":["import { IUIEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, NativePointerInput, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceInputSystem, INativeInput } from \"./inputInterfaces\";\r\n\r\n/** @hidden */\r\nexport class NativeDeviceInputSystem implements IDeviceInputSystem {\r\n public onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onInputChanged = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => { };\r\n\r\n private readonly _nativeInput: INativeInput;\r\n\r\n public constructor(nativeInput?: INativeInput) {\r\n this._nativeInput = nativeInput || this._createDummyNativeInput();\r\n\r\n this._nativeInput.onDeviceConnected = (deviceType, deviceSlot) => {\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onInputChanged = (deviceType, deviceSlot, inputIndex, currentState) => {\r\n const idx = (inputIndex === NativePointerInput.Horizontal || inputIndex === NativePointerInput.Vertical || inputIndex === NativePointerInput.DeltaHorizontal || inputIndex === NativePointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;\r\n const evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, idx, currentState, this);\r\n\r\n this.onInputChanged(deviceType, deviceSlot, evt);\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 return this._nativeInput.pollInput(deviceType, deviceSlot, inputIndex);\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 //TODO: FIx native side first\r\n return (deviceType === DeviceType.Mouse || deviceType === DeviceType.Touch);\r\n }\r\n\r\n /**\r\n * Dispose of all the observables\r\n */\r\n public dispose(): void {\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n }\r\n\r\n /**\r\n * For versions of BabylonNative that don't have the NativeInput plugin initialized, create a dummy version\r\n * @returns Object with dummy functions\r\n */\r\n private _createDummyNativeInput() {\r\n let nativeInput = {\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>) => { },\r\n pollInput: () => { return 0; },\r\n isDeviceAvailable: () => { return false; },\r\n dispose: () => { },\r\n };\r\n\r\n return nativeInput;\r\n }\r\n}"]}
@@ -1,13 +1,14 @@
1
1
  import { Engine } from "../../Engines/engine";
2
+ import { IUIEvent } from "../../Events/deviceInputEvents";
2
3
  import { DeviceType } from "./deviceEnums";
3
- import { IDeviceEvent, IDeviceInputSystem } from "./inputInterfaces";
4
+ import { IDeviceInputSystem } from "./inputInterfaces";
4
5
  /** @hidden */
5
6
  export declare class WebDeviceInputSystem implements IDeviceInputSystem {
6
7
  /** onDeviceConnected property */
7
8
  set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
8
9
  get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
9
10
  onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
10
- onInputChanged: (deviceEvent: IDeviceEvent) => void;
11
+ onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
11
12
  private _inputs;
12
13
  private _gamepads;
13
14
  private _keyboardActive;
@@ -22,6 +23,7 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
22
23
  private _pointerMoveEvent;
23
24
  private _pointerDownEvent;
24
25
  private _pointerUpEvent;
26
+ private _pointerCancelEvent;
25
27
  private _pointerWheelEvent;
26
28
  private _pointerBlurEvent;
27
29
  private _wheelEventName;