@babylonjs/core 5.0.0-beta.8 → 5.0.0-rc.1

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 (158) 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/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  10. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  11. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +1 -0
  12. package/Cameras/Inputs/BaseCameraPointersInput.js +4 -3
  13. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  14. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +7 -5
  15. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  16. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  17. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  18. package/Cameras/arcRotateCamera.js +3 -3
  19. package/Cameras/arcRotateCamera.js.map +1 -1
  20. package/DeviceInput/Helpers/eventFactory.d.ts +6 -6
  21. package/DeviceInput/Helpers/eventFactory.js +34 -16
  22. package/DeviceInput/Helpers/eventFactory.js.map +1 -1
  23. package/DeviceInput/InputDevices/deviceEnums.d.ts +26 -3
  24. package/DeviceInput/InputDevices/deviceEnums.js +31 -7
  25. package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
  26. package/DeviceInput/InputDevices/deviceSource.d.ts +11 -3
  27. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  28. package/DeviceInput/InputDevices/deviceSourceManager.d.ts +28 -10
  29. package/DeviceInput/InputDevices/deviceSourceManager.js +131 -7
  30. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  31. package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
  32. package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
  33. package/DeviceInput/InputDevices/inputInterfaces.d.ts +3 -28
  34. package/DeviceInput/InputDevices/inputInterfaces.js.map +1 -1
  35. package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +15 -30
  36. package/DeviceInput/InputDevices/internalDeviceSourceManager.js +40 -110
  37. package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
  38. package/DeviceInput/InputDevices/nativeDeviceInputSystem.d.ts +3 -2
  39. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +7 -13
  40. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
  41. package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +11 -8
  42. package/DeviceInput/InputDevices/webDeviceInputSystem.js +116 -110
  43. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
  44. package/Engines/Extensions/engine.query.d.ts +7 -0
  45. package/Engines/Extensions/engine.query.js +12 -0
  46. package/Engines/Extensions/engine.query.js.map +1 -1
  47. package/Engines/Extensions/engine.renderTarget.d.ts +5 -0
  48. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  49. package/Engines/Extensions/engine.views.d.ts +7 -0
  50. package/Engines/Extensions/engine.views.js +12 -0
  51. package/Engines/Extensions/engine.views.js.map +1 -1
  52. package/Engines/engine.d.ts +6 -2
  53. package/Engines/engine.js.map +1 -1
  54. package/Engines/index.d.ts +1 -0
  55. package/Engines/index.js +1 -0
  56. package/Engines/index.js.map +1 -1
  57. package/Engines/nativeEngine.js +12 -11
  58. package/Engines/nativeEngine.js.map +1 -1
  59. package/Engines/thinEngine.js +2 -2
  60. package/Engines/thinEngine.js.map +1 -1
  61. package/Engines/webgpuEngine.js +2 -2
  62. package/Engines/webgpuEngine.js.map +1 -1
  63. package/Events/deviceInputEvents.d.ts +17 -18
  64. package/Events/deviceInputEvents.js.map +1 -1
  65. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  66. package/Helpers/environmentHelper.js +2 -2
  67. package/Helpers/environmentHelper.js.map +1 -1
  68. package/Inputs/scene.inputManager.d.ts +0 -1
  69. package/Inputs/scene.inputManager.js +54 -28
  70. package/Inputs/scene.inputManager.js.map +1 -1
  71. package/Layers/effectLayer.d.ts +1 -0
  72. package/Layers/effectLayer.js +24 -0
  73. package/Layers/effectLayer.js.map +1 -1
  74. package/Loading/sceneLoader.js +4 -3
  75. package/Loading/sceneLoader.js.map +1 -1
  76. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -2
  77. package/Materials/Node/Blocks/Dual/textureBlock.js +50 -8
  78. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  79. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  80. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  81. package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
  82. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  83. package/Materials/Textures/dynamicTexture.d.ts +1 -1
  84. package/Materials/Textures/dynamicTexture.js.map +1 -1
  85. package/Materials/materialPluginBase.d.ts +5 -0
  86. package/Materials/materialPluginBase.js +5 -0
  87. package/Materials/materialPluginBase.js.map +1 -1
  88. package/Materials/materialPluginEvent.d.ts +1 -0
  89. package/Materials/materialPluginEvent.js.map +1 -1
  90. package/Materials/materialPluginManager.d.ts +1 -0
  91. package/Materials/materialPluginManager.js +20 -15
  92. package/Materials/materialPluginManager.js.map +1 -1
  93. package/Materials/standardMaterial.js +1 -0
  94. package/Materials/standardMaterial.js.map +1 -1
  95. package/Maths/math.vector.d.ts +5 -0
  96. package/Maths/math.vector.js +11 -0
  97. package/Maths/math.vector.js.map +1 -1
  98. package/Meshes/Builders/polygonBuilder.js +2 -1
  99. package/Meshes/Builders/polygonBuilder.js.map +1 -1
  100. package/Meshes/abstractMesh.d.ts +1 -1
  101. package/Meshes/abstractMesh.js.map +1 -1
  102. package/Meshes/instancedMesh.js +7 -4
  103. package/Meshes/instancedMesh.js.map +1 -1
  104. package/Meshes/mesh.js +21 -22
  105. package/Meshes/mesh.js.map +1 -1
  106. package/Meshes/mesh.vertexData.d.ts +2 -2
  107. package/Meshes/mesh.vertexData.js +100 -76
  108. package/Meshes/mesh.vertexData.js.map +1 -1
  109. package/Meshes/transformNode.d.ts +0 -2
  110. package/Meshes/transformNode.js +6 -5
  111. package/Meshes/transformNode.js.map +1 -1
  112. package/Misc/error.d.ts +51 -0
  113. package/Misc/error.js +66 -0
  114. package/Misc/error.js.map +1 -0
  115. package/Misc/fileTools.d.ts +4 -4
  116. package/Misc/fileTools.js +30 -16
  117. package/Misc/fileTools.js.map +1 -1
  118. package/Misc/index.d.ts +1 -0
  119. package/Misc/index.js +1 -0
  120. package/Misc/index.js.map +1 -1
  121. package/Misc/khronosTextureContainer2.d.ts +8 -7
  122. package/Misc/khronosTextureContainer2.js.map +1 -1
  123. package/Misc/videoRecorder.d.ts +1 -1
  124. package/Misc/videoRecorder.js +1 -1
  125. package/Misc/videoRecorder.js.map +1 -1
  126. package/Morph/morphTarget.d.ts +2 -1
  127. package/Morph/morphTarget.js +5 -1
  128. package/Morph/morphTarget.js.map +1 -1
  129. package/Morph/morphTargetManager.js +1 -1
  130. package/Morph/morphTargetManager.js.map +1 -1
  131. package/Particles/particleSystem.d.ts +13 -1
  132. package/Particles/particleSystem.js +27 -1
  133. package/Particles/particleSystem.js.map +1 -1
  134. package/Rendering/prePassRenderer.js +12 -2
  135. package/Rendering/prePassRenderer.js.map +1 -1
  136. package/Rendering/subSurfaceConfiguration.js +1 -1
  137. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  138. package/Rendering/utilityLayerRenderer.js +2 -0
  139. package/Rendering/utilityLayerRenderer.js.map +1 -1
  140. package/Shaders/ShadersInclude/pointCloudVertex.js +1 -1
  141. package/Shaders/ShadersInclude/pointCloudVertex.js.map +1 -1
  142. package/Shaders/background.vertex.js +1 -1
  143. package/Shaders/background.vertex.js.map +1 -1
  144. package/Shaders/pbr.vertex.js +1 -1
  145. package/Shaders/pbr.vertex.js.map +1 -1
  146. package/XR/features/WebXRNearInteraction.js +4 -2
  147. package/XR/features/WebXRNearInteraction.js.map +1 -1
  148. package/XR/webXRSessionManager.js +1 -0
  149. package/XR/webXRSessionManager.js.map +1 -1
  150. package/package.json +4 -4
  151. package/scene.d.ts +1 -10
  152. package/scene.js +20 -39
  153. package/scene.js.map +1 -1
  154. package/types.d.ts +1 -1
  155. package/types.js.map +1 -1
  156. package/Misc/baseError.d.ts +0 -7
  157. package/Misc/baseError.js +0 -18
  158. package/Misc/baseError.js.map +0 -1
@@ -1,46 +1,31 @@
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 */
11
- _deviceSourceManager: InternalDeviceSourceManager;
10
+ _deviceSourceManager?: InternalDeviceSourceManager;
12
11
  }
13
12
  }
14
13
  /** @hidden */
14
+ export interface IObservableManager {
15
+ onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
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;
20
+ }
21
+ /** @hidden */
15
22
  export declare class InternalDeviceSourceManager implements IDisposable {
16
- readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
17
- readonly onInputChangedObservable: Observable<IDeviceEvent>;
18
- readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
19
23
  private readonly _devices;
20
- private readonly _firstDevice;
21
24
  private readonly _deviceInputSystem;
22
- private _oninputChangedObserver;
23
- static _Create(engine: Engine): InternalDeviceSourceManager;
24
- private constructor();
25
- getDeviceSource: <T extends DeviceType>(deviceType: T, deviceSlot?: number | undefined) => Nullable<DeviceSource<T>>;
26
- getDeviceSources: <T extends DeviceType>(deviceType: T) => readonly DeviceSource<T>[];
27
- getDevices: () => ReadonlyArray<DeviceSource<DeviceType>>;
25
+ private readonly _registeredManagers;
26
+ _refCount: number;
27
+ constructor(engine: Engine);
28
+ readonly registerManager: (manager: IObservableManager) => void;
29
+ readonly unregisterManager: (manager: IObservableManager) => void;
28
30
  dispose(): void;
29
- /**
30
- * Function to add device name to device list
31
- * @param deviceType Enum specifying device type
32
- * @param deviceSlot "Slot" or index that device is referenced in
33
- */
34
- private _addDevice;
35
- /**
36
- * Function to remove device name to device list
37
- * @param deviceType Enum specifying device type
38
- * @param deviceSlot "Slot" or index that device is referenced in
39
- */
40
- private _removeDevice;
41
- /**
42
- * Updates array storing first connected device of each type
43
- * @param type Type of Device
44
- */
45
- private _updateFirstDevices;
46
31
  }
@@ -1,5 +1,4 @@
1
1
  import { DeviceType } from './deviceEnums.js';
2
- import { Observable } from '../../Misc/observable.js';
3
2
  import { NativeDeviceInputSystem } from './nativeDeviceInputSystem.js';
4
3
  import { WebDeviceInputSystem } from './webDeviceInputSystem.js';
5
4
  import { DeviceSource } from './deviceSource.js';
@@ -7,47 +6,27 @@ import { DeviceSource } from './deviceSource.js';
7
6
  var InternalDeviceSourceManager = /** @class */ (function () {
8
7
  function InternalDeviceSourceManager(engine) {
9
8
  var _this = this;
10
- // Public Members
11
- this.onDeviceConnectedObservable = new Observable(function (observer) {
12
- _this.getDevices().forEach(function (device) {
13
- if (device) {
14
- _this.onDeviceConnectedObservable.notifyObserver(observer, device);
15
- }
16
- });
17
- });
18
- this.onInputChangedObservable = new Observable();
19
- this.onDeviceDisconnectedObservable = new Observable();
9
+ this._registeredManagers = new Array();
10
+ this._refCount = 0;
20
11
  // Public Functions
21
- this.getDeviceSource = function (deviceType, deviceSlot) {
22
- if (deviceSlot === undefined) {
23
- if (_this._firstDevice[deviceType] === undefined) {
24
- 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));
25
18
  }
26
- deviceSlot = _this._firstDevice[deviceType];
27
- }
28
- if (!_this._devices[deviceType] || _this._devices[deviceType][deviceSlot] === undefined) {
29
- return null;
30
- }
31
- if (!_this._oninputChangedObserver) {
32
- _this._oninputChangedObserver = _this.onInputChangedObservable.add(function (eventData) {
33
- _this._devices[eventData.deviceType][eventData.deviceSlot].onInputChangedObservable.notifyObservers(eventData);
34
- });
35
19
  }
36
- return _this._devices[deviceType][deviceSlot];
20
+ _this._registeredManagers.push(manager);
37
21
  };
38
- this.getDeviceSources = function (deviceType) {
39
- return _this._devices[deviceType].filter(function (source) { return !!source; });
40
- };
41
- this.getDevices = function () {
42
- var deviceArray = new Array();
43
- _this._devices.forEach(function (deviceSet) {
44
- deviceArray.push.apply(deviceArray, deviceSet);
45
- });
46
- return deviceArray;
22
+ this.unregisterManager = function (manager) {
23
+ var idx = _this._registeredManagers.indexOf(manager);
24
+ if (idx > -1) {
25
+ _this._registeredManagers.splice(idx, 1);
26
+ }
47
27
  };
48
28
  var numberOfDeviceTypes = Object.keys(DeviceType).length / 2;
49
29
  this._devices = new Array(numberOfDeviceTypes);
50
- this._firstDevice = new Array(numberOfDeviceTypes);
51
30
  if (typeof _native !== 'undefined') {
52
31
  this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();
53
32
  }
@@ -55,89 +34,40 @@ var InternalDeviceSourceManager = /** @class */ (function () {
55
34
  this._deviceInputSystem = new WebDeviceInputSystem(engine);
56
35
  }
57
36
  this._deviceInputSystem.onDeviceConnected = function (deviceType, deviceSlot) {
58
- _this._addDevice(deviceType, deviceSlot);
59
- _this.onDeviceConnectedObservable.notifyObservers(_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
+ }
43
+ for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
44
+ var manager = _a[_i];
45
+ var deviceSource = new DeviceSource(_this._deviceInputSystem, deviceType, deviceSlot);
46
+ manager._addDevice(deviceSource);
47
+ }
60
48
  };
61
49
  this._deviceInputSystem.onDeviceDisconnected = function (deviceType, deviceSlot) {
62
- var device = _this.getDeviceSource(deviceType, deviceSlot); // Grab local reference to use before removing from devices
63
- _this._removeDevice(deviceType, deviceSlot);
64
- _this.onDeviceDisconnectedObservable.notifyObservers(device);
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);
57
+ }
65
58
  };
66
- this._deviceInputSystem.onInputChanged = function (deviceEvent) {
67
- _this.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
+ }
65
+ }
68
66
  };
69
67
  }
70
- InternalDeviceSourceManager._Create = function (engine) {
71
- if (!engine._deviceSourceManager) {
72
- engine._deviceSourceManager = new InternalDeviceSourceManager(engine);
73
- engine.onDisposeObservable.add(function () {
74
- engine._deviceSourceManager.dispose();
75
- });
76
- }
77
- return engine._deviceSourceManager;
78
- };
79
68
  InternalDeviceSourceManager.prototype.dispose = function () {
80
- this.onDeviceConnectedObservable.clear();
81
- this.onDeviceDisconnectedObservable.clear();
82
69
  this._deviceInputSystem.dispose();
83
70
  };
84
- // Private Functions
85
- /**
86
- * Function to add device name to device list
87
- * @param deviceType Enum specifying device type
88
- * @param deviceSlot "Slot" or index that device is referenced in
89
- */
90
- InternalDeviceSourceManager.prototype._addDevice = function (deviceType, deviceSlot) {
91
- if (!this._devices[deviceType]) {
92
- this._devices[deviceType] = new Array();
93
- }
94
- if (!this._devices[deviceType][deviceSlot]) {
95
- this._devices[deviceType][deviceSlot] = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);
96
- this._updateFirstDevices(deviceType);
97
- }
98
- };
99
- /**
100
- * Function to remove device name to device list
101
- * @param deviceType Enum specifying device type
102
- * @param deviceSlot "Slot" or index that device is referenced in
103
- */
104
- InternalDeviceSourceManager.prototype._removeDevice = function (deviceType, deviceSlot) {
105
- var _a;
106
- if ((_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
107
- delete this._devices[deviceType][deviceSlot];
108
- }
109
- // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.
110
- this._updateFirstDevices(deviceType);
111
- };
112
- /**
113
- * Updates array storing first connected device of each type
114
- * @param type Type of Device
115
- */
116
- InternalDeviceSourceManager.prototype._updateFirstDevices = function (type) {
117
- switch (type) {
118
- case DeviceType.Keyboard:
119
- case DeviceType.Mouse:
120
- this._firstDevice[type] = 0;
121
- break;
122
- case DeviceType.Touch:
123
- case DeviceType.DualSense:
124
- case DeviceType.DualShock:
125
- case DeviceType.Xbox:
126
- case DeviceType.Switch:
127
- case DeviceType.Generic:
128
- delete this._firstDevice[type];
129
- var devices = this._devices[type];
130
- if (devices) {
131
- for (var i = 0; i < devices.length; i++) {
132
- if (devices[i]) {
133
- this._firstDevice[type] = i;
134
- break;
135
- }
136
- }
137
- }
138
- break;
139
- }
140
- };
141
71
  return InternalDeviceSourceManager;
142
72
  }());
143
73
  export { InternalDeviceSourceManager };
@@ -1 +1 @@
1
- {"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAa9C,cAAc;AACd;IAgCI,qCAAoB,MAAc;QAAlC,iBA0BC;QAzDD,iBAAiB;QACD,gCAA2B,GAAG,IAAI,UAAU,CAA2B,UAAC,QAAQ;YAC5F,KAAI,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,UAAC,MAAM;gBAC7B,IAAI,MAAM,EAAE;oBACR,KAAI,CAAC,2BAA2B,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;iBACrE;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEa,6BAAwB,GAAG,IAAI,UAAU,EAAgB,CAAC;QAE1D,mCAA8B,GAAG,IAAI,UAAU,EAA4B,CAAC;QAgD5F,mBAAmB;QACZ,oBAAe,GAAG,UAAuB,UAAa,EAAE,UAAmB;YAC9E,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC1B,IAAI,KAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBAC7C,OAAO,IAAI,CAAC;iBACf;gBAED,UAAU,GAAG,KAAI,CAAC,YAAY,CAAC,U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UAAU,CAAC,QAAQ,CAAC;YACzB,KAAK,UAAU,CAAC,KAAK;gBACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC5B,MAAM;YACV,KAAK,UAAU,CAAC,KAAK,CAAC;YACtB,KAAK,UAAU,CAAC,SAAS,CAAC;YAC1B,KAAK,UAAU,CAAC,SAAS,CAAC;YAC1B,KAAK,UAAU,CAAC,IAAI,CAAC;YACrB,KAAK,UAAU,CAAC,MAAM,CAAC;YACvB,KAAK,UAAU,CAAC,OAAO;gBACnB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,OAAO,EAAE;oBACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACrC,IAAI,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,AAjKD,IAiKC","sourcesContent":["import { IDisposable } from '../../scene';\r\nimport { DeviceType } from './deviceEnums';\r\nimport { Nullable } from '../../types';\r\nimport { Observable, Observer } 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 class InternalDeviceSourceManager implements IDisposable {\r\n // Public Members\r\n public readonly onDeviceConnectedObservable = new Observable<DeviceSource<DeviceType>>((observer) => {\r\n this.getDevices().forEach((device) => {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device);\r\n }\r\n });\r\n });\r\n\r\n public readonly onInputChangedObservable = new Observable<IDeviceEvent>();\r\n\r\n public readonly onDeviceDisconnectedObservable = new Observable<DeviceSource<DeviceType>>();\r\n\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 _oninputChangedObserver: Nullable<Observer<IDeviceEvent>>;\r\n\r\n public static _Create(engine: Engine): InternalDeviceSourceManager {\r\n if (!engine._deviceSourceManager) {\r\n engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n\r\n engine.onDisposeObservable.add(() => {\r\n engine._deviceSourceManager.dispose();\r\n });\r\n }\r\n return engine._deviceSourceManager;\r\n }\r\n\r\n private 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 this.onDeviceConnectedObservable.notifyObservers(this.getDeviceSource(deviceType, deviceSlot)!);\r\n };\r\n\r\n this._deviceInputSystem.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n const device = this.getDeviceSource(deviceType, deviceSlot)!; // Grab local reference to use before removing from devices\r\n this._removeDevice(deviceType, deviceSlot);\r\n this.onDeviceDisconnectedObservable.notifyObservers(device);\r\n };\r\n\r\n this._deviceInputSystem.onInputChanged = (deviceEvent) => {\r\n this.onInputChangedObservable.notifyObservers(deviceEvent);\r\n };\r\n }\r\n\r\n // Public Functions\r\n public 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 if (!this._oninputChangedObserver) {\r\n this._oninputChangedObserver = this.onInputChangedObservable.add((eventData) => {\r\n this._devices[eventData.deviceType][eventData.deviceSlot].onInputChangedObservable.notifyObservers(eventData);\r\n });\r\n }\r\n\r\n return this._devices[deviceType][deviceSlot];\r\n }\r\n\r\n public 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 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 dispose(): void {\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\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,i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AAkB,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,UAAC,UAAU,EAAE,UAAU;YAC5D,KAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,cAAc,GAAG,UAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS;YAC1G,IAAM,GAAG,GAAG,CAAC,UAAU,KAAK,YAAY,CAAC,UAAU,IAAI,UAAU,KAAK,YAAY,CAAC,QAAQ,IAAI,UAAU,KAAK,YAAY,CAAC,eAAe,IAAI,UAAU,KAAK,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;YAC1N,IAAM,G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AE,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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AAI,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC;IAED,mBAAmB;IACnB;;;;;;OAMG;IACI,2CAAS,GAAhB,UAAiB,UAAsB,EAAE,UAAkB,EAAE,UAAkB;QAC3E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,mDAAiB,GAAxB,UAAyB,UAAsB;QAC3C,6BAA6B;QAC7B,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,KAAK,IAAI,UAAU,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,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,9 +23,11 @@ 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;
30
+ private _eventsAttached;
28
31
  private _mouseId;
29
32
  private readonly _isUsingFirefox;
30
33
  private _activeTouchIds;
@@ -53,9 +56,13 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
53
56
  */
54
57
  dispose(): void;
55
58
  /**
56
- * Configures events to work with an engine's active element
59
+ * Enable listening for user input events
57
60
  */
58
- private _configureEvents;
61
+ private _enableEvents;
62
+ /**
63
+ * Disable listening for user input events
64
+ */
65
+ private _disableEvents;
59
66
  /**
60
67
  * Checks for existing connections to devices and register them, if necessary
61
68
  * Currently handles gamepads and mouse
@@ -118,8 +125,4 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
118
125
  * @returns DeviceType interpreted from event
119
126
  */
120
127
  private _getPointerType;
121
- /**
122
- * Remove events from active input element
123
- */
124
- private _removeEvents;
125
128
  }