@babylonjs/core 5.17.1 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Debug/debugLayer.d.ts +36 -0
- package/Debug/debugLayer.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/{Helpers/eventFactory.d.ts → eventFactory.d.ts} +4 -4
- package/DeviceInput/{Helpers/eventFactory.js → eventFactory.js} +2 -2
- package/DeviceInput/eventFactory.js.map +1 -0
- package/DeviceInput/{InputDevices/inputInterfaces.d.ts → inputInterfaces.d.ts} +2 -2
- package/DeviceInput/{InputDevices/inputInterfaces.js → inputInterfaces.js} +0 -0
- package/DeviceInput/inputInterfaces.js.map +1 -0
- package/DeviceInput/{InputDevices/internalDeviceSourceManager.d.ts → internalDeviceSourceManager.d.ts} +7 -7
- package/DeviceInput/{InputDevices/internalDeviceSourceManager.js → internalDeviceSourceManager.js} +2 -2
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -0
- package/DeviceInput/{InputDevices/nativeDeviceInputSystem.d.ts → nativeDeviceInputSystem.d.ts} +2 -2
- package/DeviceInput/{InputDevices/nativeDeviceInputSystem.js → nativeDeviceInputSystem.js} +2 -2
- package/DeviceInput/nativeDeviceInputSystem.js.map +1 -0
- package/DeviceInput/{InputDevices/webDeviceInputSystem.d.ts → webDeviceInputSystem.d.ts} +3 -3
- package/DeviceInput/{InputDevices/webDeviceInputSystem.js → webDeviceInputSystem.js} +4 -4
- package/DeviceInput/webDeviceInputSystem.js.map +1 -0
- package/Engines/Extensions/engine.query.js +5 -1
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.transformFeedback.js +5 -1
- package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +13 -0
- package/Engines/Extensions/engine.views.js +16 -1
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/engine.d.ts +15 -240
- package/Engines/engineFeatures.d.ts +2 -0
- package/Engines/engineFeatures.js.map +1 -1
- package/Engines/nativeEngine.js +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -1
- package/Engines/thinEngine.js +14 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +31 -9
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +46 -14
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +94 -19
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +23 -6
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +48 -6
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.d.ts +25 -17
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/lightGizmo.d.ts +25 -8
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +30 -9
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +45 -15
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +53 -17
- package/Gizmos/positionGizmo.js +1 -1
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +35 -10
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +49 -18
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +16 -4
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +39 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +97 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -0
- package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
- package/Materials/Node/Blocks/Fragment/index.js +1 -0
- package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +18 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +85 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +6 -0
- package/Materials/Node/nodeMaterial.js +11 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +5 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +3 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +9 -5
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.vector.d.ts +134 -8
- package/Maths/math.vector.js +168 -36
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js +1 -1
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/groundMesh.js +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/mesh.js +1 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.js +1 -0
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/assetsManager.d.ts +9 -0
- package/Misc/assetsManager.js +3 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/basis.js +10 -4
- package/Misc/basis.js.map +1 -1
- package/Misc/computePressure.d.ts +9 -3
- package/Misc/computePressure.js +13 -5
- package/Misc/computePressure.js.map +1 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/Misc/iInspectable.d.ts +12 -2
- package/Misc/iInspectable.js +4 -0
- package/Misc/iInspectable.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +1 -1
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/sceneSerializer.js +1 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/tools.d.ts +2 -2
- package/Misc/tools.js +4 -1
- package/Misc/tools.js.map +1 -1
- package/Offline/database.js +6 -8
- package/Offline/database.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -0
- package/Particles/solidParticleSystem.js +4 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/Plugins/ammoJSPlugin.d.ts +2 -2
- package/Physics/Plugins/ammoJSPlugin.js +29 -29
- package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/Plugins/cannonJSPlugin.d.ts +2 -2
- package/Physics/Plugins/cannonJSPlugin.js +26 -26
- package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/Plugins/oimoJSPlugin.js +9 -11
- package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/physicsImpostor.d.ts +6 -6
- package/Physics/physicsImpostor.js +15 -8
- package/Physics/physicsImpostor.js.map +1 -1
- package/Shaders/sprites.fragment.js +1 -1
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -1
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/webXRDefaultExperience.d.ts +10 -0
- package/XR/webXRDefaultExperience.js +2 -12
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXRExperienceHelper.js +12 -12
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/node.d.ts +2 -0
- package/node.js +2 -0
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js +5 -3
- package/scene.js.map +1 -1
- package/DeviceInput/Helpers/eventFactory.js.map +0 -1
- package/DeviceInput/InputDevices/inputInterfaces.js.map +0 -1
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +0 -1
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +0 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +0 -1
package/Debug/debugLayer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Scene } from "../scene";
|
|
2
|
+
import type { IInspectable } from "../Misc/iInspectable";
|
|
2
3
|
/**
|
|
3
4
|
* Interface used to define scene explorer extensibility option
|
|
4
5
|
*/
|
|
@@ -25,6 +26,37 @@ export interface IExplorerExtensibilityGroup {
|
|
|
25
26
|
*/
|
|
26
27
|
entries: IExplorerExtensibilityOption[];
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Defines a new node that will be displayed as top level node in the explorer
|
|
31
|
+
*/
|
|
32
|
+
export interface IExplorerAdditionalChild {
|
|
33
|
+
/**
|
|
34
|
+
* Gets the name of the additional node
|
|
35
|
+
*/
|
|
36
|
+
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Function used to return the class name of the child node
|
|
39
|
+
*/
|
|
40
|
+
getClassName(): string;
|
|
41
|
+
/**
|
|
42
|
+
* List of inspectable custom properties (used by the Inspector)
|
|
43
|
+
* @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
|
|
44
|
+
*/
|
|
45
|
+
inspectableCustomProperties: IInspectable[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Defines a new node that will be displayed as top level node in the explorer
|
|
49
|
+
*/
|
|
50
|
+
export interface IExplorerAdditionalNode {
|
|
51
|
+
/**
|
|
52
|
+
* Gets the name of the additional node
|
|
53
|
+
*/
|
|
54
|
+
name: string;
|
|
55
|
+
/**
|
|
56
|
+
* Function used to return the list of child entries
|
|
57
|
+
*/
|
|
58
|
+
getContent(): IExplorerAdditionalChild[];
|
|
59
|
+
}
|
|
28
60
|
/**
|
|
29
61
|
* Interface used to define the options to use to create the Inspector
|
|
30
62
|
*/
|
|
@@ -65,6 +97,10 @@ export interface IInspectorOptions {
|
|
|
65
97
|
* Optional list of extensibility entries
|
|
66
98
|
*/
|
|
67
99
|
explorerExtensibility?: IExplorerExtensibilityGroup[];
|
|
100
|
+
/**
|
|
101
|
+
* Optional list of additional top level nodes
|
|
102
|
+
*/
|
|
103
|
+
additionalNodes?: IExplorerAdditionalNode[];
|
|
68
104
|
/**
|
|
69
105
|
* Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
|
|
70
106
|
*/
|
package/Debug/debugLayer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Debug/debugLayer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAoGrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,EAAE;IACjD,GAAG,EAAE;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAA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G;IACI,qCAAgB,GAAvB;QACI,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACzD;IACL,CAAC;IAED;;;;OAIG;IACI,yBAAI,GAAX,UAAY,MAA0B;QAAtC,iBAgBC;QAfG,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;YACvB,IAAI,OAAO,KAAI,CAAC,YAAY,IAAI,WAAW,EAAE;gBACzC,IAAM,YAAY,GAAG,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;gBAEnG,uCAAuC;gBACvC,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE;oBAC3B,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;oBAC9B,OAAO,CAAC,KAAI,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,kCAAkC;gBAClC,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC9B,OAAO,CAAC,KAAI,CAAC,CAAC;aACjB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAxLD;;;;OAIG;IACW,uBAAY,GAAG,gDAAyC,MAAM,CAAC,OAAO,iCAA8B,CAAC;IAoLvH,iBAAC;CAAA,AA1LD,IA0LC;SA1LY,UAAU","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n// declare INSPECTOR namespace for compilation issue\r\ndeclare let INSPECTOR: any;\r\ndeclare let BABYLON: any;\r\n// load the inspector using require, if not present in the global namespace.\r\n\r\n/**\r\n * Interface used to define scene explorer extensibility option\r\n */\r\nexport interface IExplorerExtensibilityOption {\r\n /**\r\n * Define the option label\r\n */\r\n label: string;\r\n /**\r\n * Defines the action to execute on click\r\n */\r\n action: (entity: any) => void;\r\n}\r\n\r\n/**\r\n * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer\r\n */\r\nexport interface IExplorerExtensibilityGroup {\r\n /**\r\n * Defines a predicate to test if a given type mut be extended\r\n */\r\n predicate: (entity: any) => boolean;\r\n /**\r\n * Gets the list of options added to a type\r\n */\r\n entries: IExplorerExtensibilityOption[];\r\n}\r\n\r\n/**\r\n * Interface used to define the options to use to create the Inspector\r\n */\r\nexport interface IInspectorOptions {\r\n /**\r\n * Display in overlay mode (default: false)\r\n */\r\n overlay?: boolean;\r\n /**\r\n * HTML element to use as root (the parent of the rendering canvas will be used as default value)\r\n */\r\n globalRoot?: HTMLElement;\r\n /**\r\n * Display the Scene explorer\r\n */\r\n showExplorer?: boolean;\r\n /**\r\n * Display the property inspector\r\n */\r\n showInspector?: boolean;\r\n /**\r\n * Display in embed mode (both panes on the right)\r\n */\r\n embedMode?: boolean;\r\n /**\r\n * let the Inspector handles resize of the canvas when panes are resized (default to true)\r\n */\r\n handleResize?: boolean;\r\n /**\r\n * Allow the panes to popup (default: true)\r\n */\r\n enablePopup?: boolean;\r\n /**\r\n * Allow the panes to be closed by users (default: true)\r\n */\r\n enableClose?: boolean;\r\n /**\r\n * Optional list of extensibility entries\r\n */\r\n explorerExtensibility?: IExplorerExtensibilityGroup[];\r\n /**\r\n * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).\r\n */\r\n inspectorURL?: string;\r\n /**\r\n * Optional initial tab (default to DebugLayerTab.Properties)\r\n */\r\n initialTab?: DebugLayerTab;\r\n}\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /**\r\n * @hidden\r\n * Backing field\r\n */\r\n _debugLayer: DebugLayer;\r\n\r\n /**\r\n * Gets the debug layer (aka Inspector) associated with the scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n */\r\n debugLayer: DebugLayer;\r\n }\r\n}\r\nObject.defineProperty(Scene.prototype, \"debugLayer\", {\r\n get: function (this: Scene) {\r\n if (!this._debugLayer) {\r\n this._debugLayer = new DebugLayer(this);\r\n }\r\n return this._debugLayer;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Enum of inspector action tab\r\n */\r\nexport enum DebugLayerTab {\r\n /**\r\n * Properties tag (default)\r\n */\r\n Properties = 0,\r\n /**\r\n * Debug tab\r\n */\r\n Debug = 1,\r\n /**\r\n * Statistics tab\r\n */\r\n Statistics = 2,\r\n /**\r\n * Tools tab\r\n */\r\n Tools = 3,\r\n /**\r\n * Settings tab\r\n */\r\n Settings = 4,\r\n}\r\n\r\n/**\r\n * The debug layer (aka Inspector) is the go to tool in order to better understand\r\n * what is happening in your scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n */\r\nexport class DebugLayer {\r\n /**\r\n * Define the url to get the inspector script from.\r\n * By default it uses the babylonjs CDN.\r\n * @ignoreNaming\r\n */\r\n public static InspectorURL = `https://unpkg.com/babylonjs-inspector@${Engine.Version}/babylon.inspector.bundle.js`;\r\n\r\n private _scene: Scene;\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private BJSINSPECTOR = this._getGlobalInspector();\r\n\r\n private _onPropertyChangedObservable?: Observable<{ object: any; property: string; value: any; initialValue: any }>;\r\n /**\r\n * Observable triggered when a property is changed through the inspector.\r\n */\r\n public get onPropertyChangedObservable() {\r\n if (this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector) {\r\n return this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable;\r\n }\r\n\r\n if (!this._onPropertyChangedObservable) {\r\n this._onPropertyChangedObservable = new Observable<{ object: any; property: string; value: any; initialValue: any }>();\r\n }\r\n\r\n return this._onPropertyChangedObservable;\r\n }\r\n\r\n private _onSelectionChangedObservable?: Observable<any>;\r\n /**\r\n * Observable triggered when the selection is changed through the inspector.\r\n */\r\n public get onSelectionChangedObservable() {\r\n if (this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector) {\r\n return this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable;\r\n }\r\n\r\n if (!this._onSelectionChangedObservable) {\r\n this._onSelectionChangedObservable = new Observable<any>();\r\n }\r\n\r\n return this._onSelectionChangedObservable;\r\n }\r\n\r\n /**\r\n * Instantiates a new debug layer.\r\n * The debug layer (aka Inspector) is the go to tool in order to better understand\r\n * what is happening in your scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n * @param scene Defines the scene to inspect\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || <Scene>EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n this._scene.onDisposeObservable.add(() => {\r\n // Debug layer\r\n if (this._scene._debugLayer) {\r\n this._scene._debugLayer.hide();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Creates the inspector window.\r\n * @param config\r\n */\r\n private _createInspector(config?: Partial<IInspectorOptions>) {\r\n if (this.isVisible()) {\r\n return;\r\n }\r\n\r\n if (this._onPropertyChangedObservable) {\r\n for (const observer of this._onPropertyChangedObservable!.observers) {\r\n this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(observer);\r\n }\r\n this._onPropertyChangedObservable.clear();\r\n this._onPropertyChangedObservable = undefined;\r\n }\r\n\r\n if (this._onSelectionChangedObservable) {\r\n for (const observer of this._onSelectionChangedObservable!.observers) {\r\n this.BJSINSPECTOR.Inspector.OnSelectionChangedObservable.add(observer);\r\n }\r\n this._onSelectionChangedObservable.clear();\r\n this._onSelectionChangedObservable = undefined;\r\n }\r\n\r\n const userOptions: IInspectorOptions = {\r\n overlay: false,\r\n showExplorer: true,\r\n showInspector: true,\r\n embedMode: false,\r\n handleResize: true,\r\n enablePopup: true,\r\n ...config,\r\n };\r\n\r\n this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();\r\n\r\n this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);\r\n }\r\n\r\n /**\r\n * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid\r\n * @param entity defines the entity to select\r\n * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)\r\n */\r\n public select(entity: any, lineContainerTitles?: string | string[]) {\r\n if (this.BJSINSPECTOR) {\r\n if (lineContainerTitles) {\r\n if (Object.prototype.toString.call(lineContainerTitles) == \"[object String]\") {\r\n this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitles);\r\n } else {\r\n this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(lineContainerTitles);\r\n }\r\n }\r\n this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);\r\n }\r\n }\r\n\r\n /** Get the inspector from bundle or global */\r\n private _getGlobalInspector(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof INSPECTOR !== \"undefined\") {\r\n return INSPECTOR;\r\n }\r\n\r\n // In case of module let s check the global emitted from the Inspector entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.Inspector !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get if the inspector is visible or not.\r\n * @returns true if visible otherwise, false\r\n */\r\n public isVisible(): boolean {\r\n return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;\r\n }\r\n\r\n /**\r\n * Hide the inspector and close its window.\r\n */\r\n public hide() {\r\n if (this.BJSINSPECTOR) {\r\n this.BJSINSPECTOR.Inspector.Hide();\r\n }\r\n }\r\n\r\n /**\r\n * Update the scene in the inspector\r\n */\r\n public setAsActiveScene() {\r\n if (this.BJSINSPECTOR) {\r\n this.BJSINSPECTOR.Inspector._SetNewScene(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Launch the debugLayer.\r\n * @param config Define the configuration of the inspector\r\n * @return a promise fulfilled when the debug layer is visible\r\n */\r\n public show(config?: IInspectorOptions): Promise<DebugLayer> {\r\n return new Promise((resolve) => {\r\n if (typeof this.BJSINSPECTOR == \"undefined\") {\r\n const inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;\r\n\r\n // Load inspector and add it to the DOM\r\n Tools.LoadScript(inspectorUrl, () => {\r\n this._createInspector(config);\r\n resolve(this);\r\n });\r\n } else {\r\n // Otherwise creates the inspector\r\n this._createInspector(config);\r\n resolve(this);\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"debugLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Debug/debugLayer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA0IrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,EAAE;IACjD,GAAG,EAAE;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,aAqBX;AArBD,WAAY,aAAa;IACrB;;OAEG;IACH,6DAAc,CAAA;IACd;;OAEG;IACH,mDAAS,CAAA;IACT;;OAEG;IACH,6DAAc,CAAA;IACd;;OAEG;IACH,mDAAS,CAAA;IACT;;OAEG;IACH,yDAAY,CAAA;AAChB,CAAC,EArBW,aAAa,KAAb,aAAa,QAqBxB;AAED;;;;GAIG;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CAAC,UAAC,OAAO;YACvB,IAAI,OAAO,KAAI,CAAC,YAAY,IAAI,WAAW,EAAE;gBACzC,IAAM,YAAY,GAAG,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;gBAEnG,uCAAuC;gBACvC,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE;oBAC3B,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;oBAC9B,OAAO,CAAC,KAAI,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,kCAAkC;gBAClC,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC9B,OAAO,CAAC,KAAI,CAAC,CAAC;aACjB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAxLD;;;;OAIG;IACW,uBAAY,GAAG,gDAAyC,MAAM,CAAC,OAAO,iCAA8B,CAAC;IAoLvH,iBAAC;CAAA,AA1LD,IA0LC;SA1LY,UAAU","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { IInspectable } from \"../Misc/iInspectable\";\r\n\r\n// declare INSPECTOR namespace for compilation issue\r\ndeclare let INSPECTOR: any;\r\ndeclare let BABYLON: any;\r\n// load the inspector using require, if not present in the global namespace.\r\n\r\n/**\r\n * Interface used to define scene explorer extensibility option\r\n */\r\nexport interface IExplorerExtensibilityOption {\r\n /**\r\n * Define the option label\r\n */\r\n label: string;\r\n /**\r\n * Defines the action to execute on click\r\n */\r\n action: (entity: any) => void;\r\n}\r\n\r\n/**\r\n * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer\r\n */\r\nexport interface IExplorerExtensibilityGroup {\r\n /**\r\n * Defines a predicate to test if a given type mut be extended\r\n */\r\n predicate: (entity: any) => boolean;\r\n /**\r\n * Gets the list of options added to a type\r\n */\r\n entries: IExplorerExtensibilityOption[];\r\n}\r\n\r\n/**\r\n * Defines a new node that will be displayed as top level node in the explorer\r\n */\r\nexport interface IExplorerAdditionalChild {\r\n /**\r\n * Gets the name of the additional node\r\n */\r\n name: string;\r\n /**\r\n * Function used to return the class name of the child node\r\n */\r\n getClassName(): string;\r\n /**\r\n * List of inspectable custom properties (used by the Inspector)\r\n * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility\r\n */\r\n inspectableCustomProperties: IInspectable[];\r\n}\r\n\r\n/**\r\n * Defines a new node that will be displayed as top level node in the explorer\r\n */\r\nexport interface IExplorerAdditionalNode {\r\n /**\r\n * Gets the name of the additional node\r\n */\r\n name: string;\r\n /**\r\n * Function used to return the list of child entries\r\n */\r\n getContent(): IExplorerAdditionalChild[];\r\n}\r\n\r\n/**\r\n * Interface used to define the options to use to create the Inspector\r\n */\r\nexport interface IInspectorOptions {\r\n /**\r\n * Display in overlay mode (default: false)\r\n */\r\n overlay?: boolean;\r\n /**\r\n * HTML element to use as root (the parent of the rendering canvas will be used as default value)\r\n */\r\n globalRoot?: HTMLElement;\r\n /**\r\n * Display the Scene explorer\r\n */\r\n showExplorer?: boolean;\r\n /**\r\n * Display the property inspector\r\n */\r\n showInspector?: boolean;\r\n /**\r\n * Display in embed mode (both panes on the right)\r\n */\r\n embedMode?: boolean;\r\n /**\r\n * let the Inspector handles resize of the canvas when panes are resized (default to true)\r\n */\r\n handleResize?: boolean;\r\n /**\r\n * Allow the panes to popup (default: true)\r\n */\r\n enablePopup?: boolean;\r\n /**\r\n * Allow the panes to be closed by users (default: true)\r\n */\r\n enableClose?: boolean;\r\n /**\r\n * Optional list of extensibility entries\r\n */\r\n explorerExtensibility?: IExplorerExtensibilityGroup[];\r\n /**\r\n * Optional list of additional top level nodes\r\n */\r\n additionalNodes?: IExplorerAdditionalNode[];\r\n /**\r\n * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).\r\n */\r\n inspectorURL?: string;\r\n /**\r\n * Optional initial tab (default to DebugLayerTab.Properties)\r\n */\r\n initialTab?: DebugLayerTab;\r\n}\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /**\r\n * @hidden\r\n * Backing field\r\n */\r\n _debugLayer: DebugLayer;\r\n\r\n /**\r\n * Gets the debug layer (aka Inspector) associated with the scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n */\r\n debugLayer: DebugLayer;\r\n }\r\n}\r\nObject.defineProperty(Scene.prototype, \"debugLayer\", {\r\n get: function (this: Scene) {\r\n if (!this._debugLayer) {\r\n this._debugLayer = new DebugLayer(this);\r\n }\r\n return this._debugLayer;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Enum of inspector action tab\r\n */\r\nexport enum DebugLayerTab {\r\n /**\r\n * Properties tag (default)\r\n */\r\n Properties = 0,\r\n /**\r\n * Debug tab\r\n */\r\n Debug = 1,\r\n /**\r\n * Statistics tab\r\n */\r\n Statistics = 2,\r\n /**\r\n * Tools tab\r\n */\r\n Tools = 3,\r\n /**\r\n * Settings tab\r\n */\r\n Settings = 4,\r\n}\r\n\r\n/**\r\n * The debug layer (aka Inspector) is the go to tool in order to better understand\r\n * what is happening in your scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n */\r\nexport class DebugLayer {\r\n /**\r\n * Define the url to get the inspector script from.\r\n * By default it uses the babylonjs CDN.\r\n * @ignoreNaming\r\n */\r\n public static InspectorURL = `https://unpkg.com/babylonjs-inspector@${Engine.Version}/babylon.inspector.bundle.js`;\r\n\r\n private _scene: Scene;\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private BJSINSPECTOR = this._getGlobalInspector();\r\n\r\n private _onPropertyChangedObservable?: Observable<{ object: any; property: string; value: any; initialValue: any }>;\r\n /**\r\n * Observable triggered when a property is changed through the inspector.\r\n */\r\n public get onPropertyChangedObservable() {\r\n if (this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector) {\r\n return this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable;\r\n }\r\n\r\n if (!this._onPropertyChangedObservable) {\r\n this._onPropertyChangedObservable = new Observable<{ object: any; property: string; value: any; initialValue: any }>();\r\n }\r\n\r\n return this._onPropertyChangedObservable;\r\n }\r\n\r\n private _onSelectionChangedObservable?: Observable<any>;\r\n /**\r\n * Observable triggered when the selection is changed through the inspector.\r\n */\r\n public get onSelectionChangedObservable() {\r\n if (this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector) {\r\n return this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable;\r\n }\r\n\r\n if (!this._onSelectionChangedObservable) {\r\n this._onSelectionChangedObservable = new Observable<any>();\r\n }\r\n\r\n return this._onSelectionChangedObservable;\r\n }\r\n\r\n /**\r\n * Instantiates a new debug layer.\r\n * The debug layer (aka Inspector) is the go to tool in order to better understand\r\n * what is happening in your scene\r\n * @see https://doc.babylonjs.com/features/playground_debuglayer\r\n * @param scene Defines the scene to inspect\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || <Scene>EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n this._scene.onDisposeObservable.add(() => {\r\n // Debug layer\r\n if (this._scene._debugLayer) {\r\n this._scene._debugLayer.hide();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Creates the inspector window.\r\n * @param config\r\n */\r\n private _createInspector(config?: Partial<IInspectorOptions>) {\r\n if (this.isVisible()) {\r\n return;\r\n }\r\n\r\n if (this._onPropertyChangedObservable) {\r\n for (const observer of this._onPropertyChangedObservable!.observers) {\r\n this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(observer);\r\n }\r\n this._onPropertyChangedObservable.clear();\r\n this._onPropertyChangedObservable = undefined;\r\n }\r\n\r\n if (this._onSelectionChangedObservable) {\r\n for (const observer of this._onSelectionChangedObservable!.observers) {\r\n this.BJSINSPECTOR.Inspector.OnSelectionChangedObservable.add(observer);\r\n }\r\n this._onSelectionChangedObservable.clear();\r\n this._onSelectionChangedObservable = undefined;\r\n }\r\n\r\n const userOptions: IInspectorOptions = {\r\n overlay: false,\r\n showExplorer: true,\r\n showInspector: true,\r\n embedMode: false,\r\n handleResize: true,\r\n enablePopup: true,\r\n ...config,\r\n };\r\n\r\n this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();\r\n\r\n this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);\r\n }\r\n\r\n /**\r\n * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid\r\n * @param entity defines the entity to select\r\n * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)\r\n */\r\n public select(entity: any, lineContainerTitles?: string | string[]) {\r\n if (this.BJSINSPECTOR) {\r\n if (lineContainerTitles) {\r\n if (Object.prototype.toString.call(lineContainerTitles) == \"[object String]\") {\r\n this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitles);\r\n } else {\r\n this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(lineContainerTitles);\r\n }\r\n }\r\n this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);\r\n }\r\n }\r\n\r\n /** Get the inspector from bundle or global */\r\n private _getGlobalInspector(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof INSPECTOR !== \"undefined\") {\r\n return INSPECTOR;\r\n }\r\n\r\n // In case of module let s check the global emitted from the Inspector entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.Inspector !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get if the inspector is visible or not.\r\n * @returns true if visible otherwise, false\r\n */\r\n public isVisible(): boolean {\r\n return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;\r\n }\r\n\r\n /**\r\n * Hide the inspector and close its window.\r\n */\r\n public hide() {\r\n if (this.BJSINSPECTOR) {\r\n this.BJSINSPECTOR.Inspector.Hide();\r\n }\r\n }\r\n\r\n /**\r\n * Update the scene in the inspector\r\n */\r\n public setAsActiveScene() {\r\n if (this.BJSINSPECTOR) {\r\n this.BJSINSPECTOR.Inspector._SetNewScene(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Launch the debugLayer.\r\n * @param config Define the configuration of the inspector\r\n * @return a promise fulfilled when the debug layer is visible\r\n */\r\n public show(config?: IInspectorOptions): Promise<DebugLayer> {\r\n return new Promise((resolve) => {\r\n if (typeof this.BJSINSPECTOR == \"undefined\") {\r\n const inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;\r\n\r\n // Load inspector and add it to the DOM\r\n Tools.LoadScript(inspectorUrl, () => {\r\n this._createInspector(config);\r\n resolve(this);\r\n });\r\n } else {\r\n // Otherwise creates the inspector\r\n this._createInspector(config);\r\n resolve(this);\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DeviceType } from "./deviceEnums";
|
|
2
2
|
import { Observable } from "../../Misc/observable";
|
|
3
3
|
import type { DeviceInput } from "./deviceTypes";
|
|
4
|
-
import type { IDeviceInputSystem } from "
|
|
4
|
+
import type { IDeviceInputSystem } from "../inputInterfaces";
|
|
5
5
|
import type { IKeyboardEvent, IPointerEvent, IWheelEvent } from "../../Events/deviceInputEvents";
|
|
6
6
|
/**
|
|
7
7
|
* Subset of DeviceInput that only handles pointers and keyboard
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSource.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/DeviceInput/InputDevices/deviceSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAgBnD;;GAEG;AACH;IAUI;;;;;OAKG;IACH,sBACI,iBAAqC;IACrC,qBAAqB;IACL,UAAa;IAC7B,mDAAmD;IACnC,UAAsB;QAAtB,2BAAA,EAAA,cAAsB;QAFtB,eAAU,GAAV,UAAU,CAAG;QAEb,eAAU,GAAV,UAAU,CAAY;QApB1C,iBAAiB;QACjB;;WAEG;QACa,6BAAwB,GAAG,IAAI,UAAU,EAAwB,CAAC;QAkB9E,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,+BAAQ,GAAf,UAAgB,UAA0B;QACtC,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;IACL,mBAAC;AAAD,CAAC,AAlCD,IAkCC","sourcesContent":["import type { DeviceType } from \"./deviceEnums\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceInput } from \"./deviceTypes\";\r\nimport type { IDeviceInputSystem } from \"
|
|
1
|
+
{"version":3,"file":"deviceSource.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/DeviceInput/InputDevices/deviceSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAgBnD;;GAEG;AACH;IAUI;;;;;OAKG;IACH,sBACI,iBAAqC;IACrC,qBAAqB;IACL,UAAa;IAC7B,mDAAmD;IACnC,UAAsB;QAAtB,2BAAA,EAAA,cAAsB;QAFtB,eAAU,GAAV,UAAU,CAAG;QAEb,eAAU,GAAV,UAAU,CAAY;QApB1C,iBAAiB;QACjB;;WAEG;QACa,6BAAwB,GAAG,IAAI,UAAU,EAAwB,CAAC;QAkB9E,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,+BAAQ,GAAf,UAAgB,UAA0B;QACtC,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;IACL,mBAAC;AAAD,CAAC,AAlCD,IAkCC","sourcesContent":["import type { DeviceType } from \"./deviceEnums\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceInput } from \"./deviceTypes\";\r\nimport type { IDeviceInputSystem } from \"../inputInterfaces\";\r\nimport type { IKeyboardEvent, IPointerEvent, IWheelEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Subset of DeviceInput that only handles pointers and keyboard\r\n */\r\nexport type DeviceSourceEvent<T extends DeviceType> = T extends DeviceType.Keyboard\r\n ? IKeyboardEvent\r\n : T extends DeviceType.Mouse\r\n ? IWheelEvent | IPointerEvent\r\n : T extends DeviceType.Touch\r\n ? IPointerEvent\r\n : never;\r\n\r\n/**\r\n * Class that handles all input for a specific device\r\n */\r\nexport class DeviceSource<T extends DeviceType> {\r\n // Public Members\r\n /**\r\n * Observable to handle device input changes per device\r\n */\r\n public readonly onInputChangedObservable = new Observable<DeviceSourceEvent<T>>();\r\n\r\n // Private Members\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n /**\r\n * Default Constructor\r\n * @param deviceInputSystem - Reference to DeviceInputSystem\r\n * @param deviceType - Type of device\r\n * @param deviceSlot - \"Slot\" or index that device is referenced in\r\n */\r\n constructor(\r\n deviceInputSystem: IDeviceInputSystem,\r\n /** Type of device */\r\n public readonly deviceType: T,\r\n /** \"Slot\" or index that device is referenced in */\r\n public readonly deviceSlot: number = 0\r\n ) {\r\n this._deviceInputSystem = deviceInputSystem;\r\n }\r\n\r\n /**\r\n * Get input for specific input\r\n * @param inputIndex - index of specific input on device\r\n * @returns Input value from DeviceInputSystem\r\n */\r\n public getInput(inputIndex: DeviceInput<T>): number {\r\n return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, inputIndex);\r\n }\r\n}\r\n"]}
|
|
@@ -3,7 +3,7 @@ import { DeviceType } from "./deviceEnums";
|
|
|
3
3
|
import type { Nullable } from "../../types";
|
|
4
4
|
import { Observable } from "../../Misc/observable";
|
|
5
5
|
import type { DeviceSource } from "./deviceSource";
|
|
6
|
-
import type { IObservableManager, DeviceSourceType } from "
|
|
6
|
+
import type { IObservableManager, DeviceSourceType } from "../internalDeviceSourceManager";
|
|
7
7
|
import type { IDisposable } from "../../scene";
|
|
8
8
|
import type { IUIEvent } from "../../Events/deviceInputEvents";
|
|
9
9
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeviceType } from "./deviceEnums.js";
|
|
2
2
|
import { Observable } from "../../Misc/observable.js";
|
|
3
|
-
import { InternalDeviceSourceManager } from "
|
|
3
|
+
import { InternalDeviceSourceManager } from "../internalDeviceSourceManager.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class to keep track of devices
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E;;GAEG;AACH;IAuDI;;;OAGG;IACH,6BAAY,MAAc;QAA1B,iBA8BC;QA7BG,IAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACpC,IAAI,CAAC,OAAO,CAAC,oBAAoB,GAAG,IAAI,2BAA2B,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C,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,CAAC,CAAC;gBACrB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,gDAAgD;gBAChD,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;aACT;SACJ;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AApLD,IAoLC","sourcesContent":["import type { Engine } from \"../../Engines/engine\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceSource } from \"./deviceSource\";\r\nimport type { IObservableManager, DeviceSourceType } from \"./internalDeviceSourceManager\";\r\nimport { InternalDeviceSourceManager } from \"./internalDeviceSourceManager\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { IKeyboardEvent, IPointerEvent, IUIEvent, IWheelEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Class to keep track of devices\r\n */\r\nexport class DeviceSourceManager implements IDisposable, IObservableManager {\r\n // Public Members\r\n /**\r\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\r\n */\r\n public readonly onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n\r\n /**\r\n * Observable to be triggered when after a device is disconnected\r\n */\r\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Private Members\r\n private _engine: Engine;\r\n private _onDisposeObserver: Nullable<Observer<ThinEngine>>;\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n\r\n // Public Functions\r\n /**\r\n * Gets a DeviceSource, given a type and slot\r\n * @param deviceType - Type of Device\r\n * @param deviceSlot - Slot or ID of device\r\n * @returns DeviceSource\r\n */\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 return this._devices[deviceType][deviceSlot] as DeviceSource<T>;\r\n }\r\n /**\r\n * Gets an array of DeviceSource objects for a given device type\r\n * @param deviceType - Type of Device\r\n * @returns All available DeviceSources of a given type\r\n */\r\n public getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> {\r\n // If device type hasn't had any devices connected yet, return empty array.\r\n if (!this._devices[deviceType]) {\r\n return [];\r\n }\r\n return this._devices[deviceType].filter((source) => {\r\n return !!source;\r\n }) as Array<DeviceSource<T>>;\r\n }\r\n\r\n /**\r\n * Default constructor\r\n * @param engine - Used to get canvas (if applicable)\r\n */\r\n constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array(numberOfDeviceTypes);\r\n this._firstDevice = new Array(numberOfDeviceTypes);\r\n this._engine = engine;\r\n\r\n if (!this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n }\r\n this._engine._deviceSourceManager._refCount++;\r\n\r\n // Observables\r\n this.onDeviceConnectedObservable = new Observable((observer) => {\r\n for (const devices of this._devices) {\r\n if (devices) {\r\n for (const device of devices) {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device as DeviceSourceType);\r\n }\r\n }\r\n }\r\n }\r\n });\r\n this.onDeviceDisconnectedObservable = new Observable();\r\n\r\n this._engine._deviceSourceManager.registerManager(this);\r\n\r\n this._onDisposeObserver = engine.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Dispose of DeviceSourceManager\r\n */\r\n public dispose(): void {\r\n // Null out observable refs\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\r\n\r\n if (this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager.unregisterManager(this);\r\n if (--this._engine._deviceSourceManager._refCount < 1) {\r\n this._engine._deviceSourceManager.dispose();\r\n delete this._engine._deviceSourceManager;\r\n }\r\n }\r\n this._engine.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n\r\n // Hidden Functions\r\n /**\r\n * @param deviceSource - Source to add\r\n * @hidden\r\n */\r\n public _addDevice(deviceSource: DeviceSourceType): void {\r\n if (!this._devices[deviceSource.deviceType]) {\r\n this._devices[deviceSource.deviceType] = new Array();\r\n }\r\n\r\n if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {\r\n this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;\r\n this._updateFirstDevices(deviceSource.deviceType);\r\n }\r\n\r\n this.onDeviceConnectedObservable.notifyObservers(deviceSource);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @hidden\r\n */\r\n public _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n const deviceSource = this._devices[deviceType]?.[deviceSlot]; // Grab local reference to use before removing from devices\r\n this.onDeviceDisconnectedObservable.notifyObservers(deviceSource as DeviceSourceType);\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 * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @param eventData - Event\r\n * @hidden\r\n */\r\n public _onInputChanged<T extends DeviceType>(deviceType: T, deviceSlot: number, eventData: IUIEvent): void {\r\n this._devices[deviceType]?.[deviceSlot]?.onInputChangedObservable.notifyObservers(eventData as IKeyboardEvent | IWheelEvent | IPointerEvent);\r\n }\r\n\r\n // Private Functions\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 // eslint-disable-next-line no-case-declarations\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}\r\n"]}
|
|
1
|
+
{"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAK7E;;GAEG;AACH;IAuDI;;;OAGG;IACH,6BAAY,MAAc;QAA1B,iBA8BC;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I,6CAAe,GAAtB,UAA6C,UAAa,EAAE,UAAkB,EAAE,SAAmB;;QAC/F,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,0CAAG,UAAU,CAAC,0CAAE,wBAAwB,CAAC,eAAe,CAAC,SAAyD,CAAC,CAAC;IACjJ,CAAC;IAED,oBAAoB;IACZ,iDAAmB,GAA3B,UAA4B,IAAgB;QACxC,QAAQ,IAAI,EAAE;YACV,KAAK,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,CAAC,CAAC;gBACrB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,gDAAgD;gBAChD,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;aACT;SACJ;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AApLD,IAoLC","sourcesContent":["import type { Engine } from \"../../Engines/engine\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { DeviceSource } from \"./deviceSource\";\r\nimport type { IObservableManager, DeviceSourceType } from \"../internalDeviceSourceManager\";\r\nimport { InternalDeviceSourceManager } from \"../internalDeviceSourceManager\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { IKeyboardEvent, IPointerEvent, IUIEvent, IWheelEvent } from \"../../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Class to keep track of devices\r\n */\r\nexport class DeviceSourceManager implements IDisposable, IObservableManager {\r\n // Public Members\r\n /**\r\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\r\n */\r\n public readonly onDeviceConnectedObservable: Observable<DeviceSourceType>;\r\n\r\n /**\r\n * Observable to be triggered when after a device is disconnected\r\n */\r\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\r\n\r\n // Private Members\r\n private _engine: Engine;\r\n private _onDisposeObserver: Nullable<Observer<ThinEngine>>;\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n\r\n // Public Functions\r\n /**\r\n * Gets a DeviceSource, given a type and slot\r\n * @param deviceType - Type of Device\r\n * @param deviceSlot - Slot or ID of device\r\n * @returns DeviceSource\r\n */\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 return this._devices[deviceType][deviceSlot] as DeviceSource<T>;\r\n }\r\n /**\r\n * Gets an array of DeviceSource objects for a given device type\r\n * @param deviceType - Type of Device\r\n * @returns All available DeviceSources of a given type\r\n */\r\n public getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> {\r\n // If device type hasn't had any devices connected yet, return empty array.\r\n if (!this._devices[deviceType]) {\r\n return [];\r\n }\r\n return this._devices[deviceType].filter((source) => {\r\n return !!source;\r\n }) as Array<DeviceSource<T>>;\r\n }\r\n\r\n /**\r\n * Default constructor\r\n * @param engine - Used to get canvas (if applicable)\r\n */\r\n constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array(numberOfDeviceTypes);\r\n this._firstDevice = new Array(numberOfDeviceTypes);\r\n this._engine = engine;\r\n\r\n if (!this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n }\r\n this._engine._deviceSourceManager._refCount++;\r\n\r\n // Observables\r\n this.onDeviceConnectedObservable = new Observable((observer) => {\r\n for (const devices of this._devices) {\r\n if (devices) {\r\n for (const device of devices) {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device as DeviceSourceType);\r\n }\r\n }\r\n }\r\n }\r\n });\r\n this.onDeviceDisconnectedObservable = new Observable();\r\n\r\n this._engine._deviceSourceManager.registerManager(this);\r\n\r\n this._onDisposeObserver = engine.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Dispose of DeviceSourceManager\r\n */\r\n public dispose(): void {\r\n // Null out observable refs\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\r\n\r\n if (this._engine._deviceSourceManager) {\r\n this._engine._deviceSourceManager.unregisterManager(this);\r\n if (--this._engine._deviceSourceManager._refCount < 1) {\r\n this._engine._deviceSourceManager.dispose();\r\n delete this._engine._deviceSourceManager;\r\n }\r\n }\r\n this._engine.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n\r\n // Hidden Functions\r\n /**\r\n * @param deviceSource - Source to add\r\n * @hidden\r\n */\r\n public _addDevice(deviceSource: DeviceSourceType): void {\r\n if (!this._devices[deviceSource.deviceType]) {\r\n this._devices[deviceSource.deviceType] = new Array();\r\n }\r\n\r\n if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {\r\n this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;\r\n this._updateFirstDevices(deviceSource.deviceType);\r\n }\r\n\r\n this.onDeviceConnectedObservable.notifyObservers(deviceSource);\r\n }\r\n\r\n /**\r\n * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @hidden\r\n */\r\n public _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n const deviceSource = this._devices[deviceType]?.[deviceSlot]; // Grab local reference to use before removing from devices\r\n this.onDeviceDisconnectedObservable.notifyObservers(deviceSource as DeviceSourceType);\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 * @param deviceType - DeviceType\r\n * @param deviceSlot - DeviceSlot\r\n * @param eventData - Event\r\n * @hidden\r\n */\r\n public _onInputChanged<T extends DeviceType>(deviceType: T, deviceSlot: number, eventData: IUIEvent): void {\r\n this._devices[deviceType]?.[deviceSlot]?.onInputChangedObservable.notifyObservers(eventData as IKeyboardEvent | IWheelEvent | IPointerEvent);\r\n }\r\n\r\n // Private Functions\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 // eslint-disable-next-line no-case-declarations\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}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IUIEvent } from "
|
|
2
|
-
import type { Nullable } from "
|
|
3
|
-
import { DeviceType } from "
|
|
4
|
-
import type { IDeviceInputSystem } from "
|
|
1
|
+
import type { IUIEvent } from "../Events/deviceInputEvents";
|
|
2
|
+
import type { Nullable } from "../types";
|
|
3
|
+
import { DeviceType } from "./InputDevices/deviceEnums";
|
|
4
|
+
import type { IDeviceInputSystem } from "./inputInterfaces";
|
|
5
5
|
/**
|
|
6
6
|
* Class to wrap DeviceInputSystem data into an event object
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { EventConstants } from "
|
|
3
|
-
import { DeviceType, NativePointerInput, PointerInput } from "
|
|
2
|
+
import { EventConstants } from "../Events/deviceInputEvents.js";
|
|
3
|
+
import { DeviceType, NativePointerInput, PointerInput } from "./InputDevices/deviceEnums.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class to wrap DeviceInputSystem data into an event object
|
|
6
6
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../../lts/core/generated/DeviceInput/eventFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1F;;GAEG;AACH;IAAA;IA6NA,CAAC;IA5NG;;;;;;;;;;OAUG;IACW,oCAAiB,GAA/B,UACI,UAAsB,EACtB,UAAkB,EAClB,UAAkB,EAClB,YAA8B,EAC9B,iBAAqC,EACrC,iBAAuB;QAEvB,QAAQ,UAAU,EAAE;YAChB,KAAK,UAAU,CAAC,QAAQ;gBAC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EAAE,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACxH,IAAM,OAAO,GACT,gBAAgB;YAChB,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC;gBACjF,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC;gBACpF,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9F,IAAM,QAAQ,GAAG,gBAAgB,IAAI,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAE1H,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACY,+BAAY,GAA3B,UAA4B,iBAAsB;QAC9C,IAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,cAAO,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IACL,yBAAC;AAAD,CAAC,AA7ND,IA6NC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { EventConstants } from \"../Events/deviceInputEvents\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceType, NativePointerInput, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n/**\r\n * Class to wrap DeviceInputSystem data into an event object\r\n */\r\nexport class DeviceEventFactory {\r\n /**\r\n * Create device input events based on provided type and slot\r\n *\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 * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object\r\n */\r\n public static CreateDeviceEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any\r\n ): IUIEvent {\r\n switch (deviceType) {\r\n case DeviceType.Keyboard:\r\n return this._CreateKeyboardEvent(inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n case DeviceType.Mouse:\r\n if (inputIndex === PointerInput.MouseWheelX || inputIndex === PointerInput.MouseWheelY || inputIndex === PointerInput.MouseWheelZ) {\r\n return this._CreateWheelEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n }\r\n // eslint-disable-next-line no-fallthrough\r\n case DeviceType.Touch:\r\n return this._CreatePointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n default:\r\n throw `Unable to generate event for device ${DeviceType[deviceType]}`;\r\n }\r\n }\r\n\r\n /**\r\n * Creates pointer event\r\n *\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 * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Pointer)\r\n */\r\n private static _CreatePointerEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n evt.deviceType = DeviceType.Mouse;\r\n evt.pointerId = 1;\r\n evt.pointerType = \"mouse\";\r\n } else {\r\n evt.deviceType = DeviceType.Touch;\r\n evt.pointerId = deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n evt.type = \"pointermove\";\r\n } else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {\r\n evt.type = currentState === 1 ? \"pointerdown\" : \"pointerup\";\r\n evt.button = inputIndex - 2;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Wheel Event\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 * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Wheel)\r\n */\r\n private static _CreateWheelEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo: any\r\n ): any {\r\n const evt = this._CreateMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n evt.type = \"wheel\";\r\n evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;\r\n evt.deltaX = 0;\r\n evt.deltaY = 0;\r\n evt.deltaZ = 0;\r\n\r\n switch (inputIndex) {\r\n case PointerInput.MouseWheelX:\r\n evt.deltaX = currentState;\r\n break;\r\n case PointerInput.MouseWheelY:\r\n evt.deltaY = currentState;\r\n break;\r\n case PointerInput.MouseWheelZ:\r\n evt.deltaZ = currentState;\r\n break;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Event\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 * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IUIEvent object (Mouse)\r\n */\r\n private static _CreateMouseEvent(\r\n deviceType: DeviceType,\r\n deviceSlot: number,\r\n inputIndex: number,\r\n currentState: Nullable<number>,\r\n deviceInputSystem: IDeviceInputSystem,\r\n elementToAttachTo?: any\r\n ): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n const pointerX = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Horizontal);\r\n const pointerY = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Vertical);\r\n\r\n // Handle offsets/deltas based on existence of HTMLElement\r\n if (elementToAttachTo) {\r\n evt.movementX = 0;\r\n evt.movementY = 0;\r\n evt.offsetX = evt.movementX - elementToAttachTo.getBoundingClientRect().x;\r\n evt.offsetY = evt.movementY - elementToAttachTo.getBoundingClientRect().y;\r\n } else {\r\n evt.movementX = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaHorizontal); // DeltaHorizontal\r\n evt.movementY = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaVertical); // DeltaVertical\r\n evt.offsetX = 0;\r\n evt.offsetY = 0;\r\n }\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n evt.deviceType = deviceType;\r\n evt.deviceSlot = deviceSlot;\r\n evt.inputIndex = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Keyboard Event\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Keyboard)\r\n */\r\n private static _CreateKeyboardEvent(inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._CreateEvent(elementToAttachTo);\r\n this._CheckNonCharacterKeys(evt, deviceInputSystem);\r\n evt.deviceType = DeviceType.Keyboard;\r\n evt.deviceSlot = 0;\r\n evt.inputIndex = inputIndex;\r\n\r\n evt.type = currentState === 1 ? \"keydown\" : \"keyup\";\r\n evt.key = String.fromCharCode(inputIndex);\r\n evt.keyCode = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Add parameters for non-character keys (Ctrl, Alt, Meta, Shift)\r\n * @param evt Event object to add parameters to\r\n * @param deviceInputSystem DeviceInputSystem to pull values from\r\n */\r\n private static _CheckNonCharacterKeys(evt: any, deviceInputSystem: IDeviceInputSystem): void {\r\n const isKeyboardActive = deviceInputSystem.isDeviceAvailable(DeviceType.Keyboard);\r\n const altKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_ALT_KEY) === 1;\r\n const ctrlKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_CTRL_KEY) === 1;\r\n const metaKey =\r\n isKeyboardActive &&\r\n (deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY1) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY2) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_META_KEY3) === 1);\r\n const shiftKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, Constants.INPUT_SHIFT_KEY) === 1;\r\n\r\n evt.altKey = altKey;\r\n evt.ctrlKey = ctrlKey;\r\n evt.metaKey = metaKey;\r\n evt.shiftKey = shiftKey;\r\n }\r\n\r\n /**\r\n * Create base event object\r\n * @param elementToAttachTo Value to use as event target\r\n * @returns\r\n */\r\n private static _CreateEvent(elementToAttachTo: any): any {\r\n const evt: { [k: string]: any } = {};\r\n evt.preventDefault = () => {};\r\n evt.target = elementToAttachTo;\r\n\r\n return evt;\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IDisposable } from "
|
|
2
|
-
import type { DeviceType } from "./deviceEnums";
|
|
1
|
+
import type { IDisposable } from "../scene";
|
|
2
|
+
import type { DeviceType } from "./InputDevices/deviceEnums";
|
|
3
3
|
/**
|
|
4
4
|
* Interface for DeviceInputSystem implementations (JS and Native)
|
|
5
5
|
*/
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputInterfaces.js","sourceRoot":"","sources":["../../../../../lts/core/generated/DeviceInput/inputInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { IDisposable } from \"../scene\";\r\nimport type { DeviceType } from \"./InputDevices/deviceEnums\";\r\n\r\n/**\r\n * Interface for DeviceInputSystem implementations (JS and Native)\r\n */\r\nexport interface IDeviceInputSystem extends IDisposable {\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 specifying 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,13 +1,13 @@
|
|
|
1
|
-
import type { IDisposable } from "
|
|
2
|
-
import { DeviceType } from "./deviceEnums";
|
|
3
|
-
import type { Observable } from "
|
|
1
|
+
import type { IDisposable } from "../scene";
|
|
2
|
+
import { DeviceType } from "./InputDevices/deviceEnums";
|
|
3
|
+
import type { Observable } from "../Misc/observable";
|
|
4
4
|
import type { IDeviceInputSystem } from "./inputInterfaces";
|
|
5
|
-
import { DeviceSource } from "./deviceSource";
|
|
6
|
-
import type { Engine } from "
|
|
7
|
-
import type { IUIEvent } from "
|
|
5
|
+
import { DeviceSource } from "./InputDevices/deviceSource";
|
|
6
|
+
import type { Engine } from "../Engines/engine";
|
|
7
|
+
import type { IUIEvent } from "../Events/deviceInputEvents";
|
|
8
8
|
declare type Distribute<T> = T extends DeviceType ? DeviceSource<T> : never;
|
|
9
9
|
export declare type DeviceSourceType = Distribute<DeviceType>;
|
|
10
|
-
declare module "
|
|
10
|
+
declare module "../Engines/engine" {
|
|
11
11
|
interface Engine {
|
|
12
12
|
/** @hidden */
|
|
13
13
|
_deviceSourceManager?: InternalDeviceSourceManager;
|
package/DeviceInput/{InputDevices/internalDeviceSourceManager.js → internalDeviceSourceManager.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DeviceType } from "./deviceEnums.js";
|
|
1
|
+
import { DeviceType } from "./InputDevices/deviceEnums.js";
|
|
2
2
|
import { NativeDeviceInputSystem } from "./nativeDeviceInputSystem.js";
|
|
3
3
|
import { WebDeviceInputSystem } from "./webDeviceInputSystem.js";
|
|
4
|
-
import { DeviceSource } from "./deviceSource.js";
|
|
4
|
+
import { DeviceSource } from "./InputDevices/deviceSource.js";
|
|
5
5
|
/** @hidden */
|
|
6
6
|
var InternalDeviceSourceManager = /** @class */ (function () {
|
|
7
7
|
function InternalDeviceSourceManager(engine) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/DeviceInput/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EA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,EAAE,SAAS,CAAC,CAAC;iBAC9D;aACJ;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAChC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SAClH;aAAM;YACH,IAAI,CAAC,kBAAkB,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;SACvH;IACL,CAAC;IAsBM,6CAAO,GAAd;QACI,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IACL,kCAAC;AAAD,CAAC,AA7ED,IA6EC","sourcesContent":["import type { IDisposable } from \"../scene\";\r\nimport { DeviceType } from \"./InputDevices/deviceEnums\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\nimport { NativeDeviceInputSystem } from \"./nativeDeviceInputSystem\";\r\nimport { WebDeviceInputSystem } from \"./webDeviceInputSystem\";\r\nimport { DeviceSource } from \"./InputDevices/deviceSource\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\n\r\ntype Distribute<T> = T extends DeviceType ? DeviceSource<T> : never;\r\n\r\nexport type DeviceSourceType = Distribute<DeviceType>;\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<DeviceSourceType>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSourceType>;\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 // Public Members\r\n public readonly _deviceInputSystem: IDeviceInputSystem;\r\n\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 _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 const onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => {\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 const onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => {\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 const 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 if (typeof _native !== \"undefined\") {\r\n this._deviceInputSystem = new NativeDeviceInputSystem(onDeviceConnected, onDeviceDisconnected, onInputChanged);\r\n } else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine, onDeviceConnected, onDeviceDisconnected, onInputChanged);\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"]}
|
package/DeviceInput/{InputDevices/nativeDeviceInputSystem.d.ts → nativeDeviceInputSystem.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IUIEvent } from "
|
|
2
|
-
import { DeviceType } from "./deviceEnums";
|
|
1
|
+
import type { IUIEvent } from "../Events/deviceInputEvents";
|
|
2
|
+
import { DeviceType } from "./InputDevices/deviceEnums";
|
|
3
3
|
import type { IDeviceInputSystem } from "./inputInterfaces";
|
|
4
4
|
/** @hidden */
|
|
5
5
|
export declare class NativeDeviceInputSystem implements IDeviceInputSystem {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeviceEventFactory } from "
|
|
2
|
-
import { DeviceType } from "./deviceEnums.js";
|
|
1
|
+
import { DeviceEventFactory } from "./eventFactory.js";
|
|
2
|
+
import { DeviceType } from "./InputDevices/deviceEnums.js";
|
|
3
3
|
/** @hidden */
|
|
4
4
|
var NativeDeviceInputSystem = /** @class */ (function () {
|
|
5
5
|
function NativeDeviceInputSystem(onDeviceConnected, onDeviceDisconnected, onInputChanged) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../../lts/core/generated/DeviceInput/nativeDeviceInputSystem.ts"],"names":[],"mappings":"AAEA,O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;YACD,OAAO,EAAE,cAAO,CAAC;SACpB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IACL,8BAAC;AAAD,CAAC,AA/DD,IA+DC","sourcesContent":["import type { INative } from \"../Engines/Native/nativeInterfaces\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { DeviceEventFactory } from \"./eventFactory\";\r\nimport { DeviceType } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\ndeclare const _native: INative;\r\n\r\n/** @hidden */\r\nexport class NativeDeviceInputSystem implements IDeviceInputSystem {\r\n private readonly _nativeInput: IDeviceInputSystem;\r\n\r\n public constructor(\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void\r\n ) {\r\n this._nativeInput = _native.DeviceInputSystem\r\n ? new _native.DeviceInputSystem(onDeviceConnected, onDeviceDisconnected, (deviceType, deviceSlot, inputIndex, currentState) => {\r\n const evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, inputIndex, currentState, this);\r\n\r\n onInputChanged(deviceType, deviceSlot, evt);\r\n })\r\n : this._createDummyNativeInput();\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 specifying 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._nativeInput.dispose();\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 const nativeInput = {\r\n pollInput: () => {\r\n return 0;\r\n },\r\n isDeviceAvailable: () => {\r\n return false;\r\n },\r\n dispose: () => {},\r\n };\r\n\r\n return nativeInput;\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Engine } from "
|
|
2
|
-
import type { IUIEvent } from "
|
|
3
|
-
import { DeviceType } from "./deviceEnums";
|
|
1
|
+
import type { Engine } from "../Engines/engine";
|
|
2
|
+
import type { IUIEvent } from "../Events/deviceInputEvents";
|
|
3
|
+
import { DeviceType } from "./InputDevices/deviceEnums";
|
|
4
4
|
import type { IDeviceInputSystem } from "./inputInterfaces";
|
|
5
5
|
/** @hidden */
|
|
6
6
|
export declare class WebDeviceInputSystem implements IDeviceInputSystem {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DomManagement } from "
|
|
2
|
-
import { Tools } from "
|
|
3
|
-
import { DeviceEventFactory } from "
|
|
4
|
-
import { DeviceType, PointerInput } from "./deviceEnums.js";
|
|
1
|
+
import { DomManagement } from "../Misc/domManagement.js";
|
|
2
|
+
import { Tools } from "../Misc/tools.js";
|
|
3
|
+
import { DeviceEventFactory } from "./eventFactory.js";
|
|
4
|
+
import { DeviceType, PointerInput } from "./InputDevices/deviceEnums.js";
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
6
6
|
var MAX_KEYCODES = 255;
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webDeviceInputSystem.js","sourceRoot":"","sources":["../../../../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jB,OAAO,UAAU,CAAC,MAAM,CAAC;SAC5B;QAED,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACK,8CAAe,GAAvB,UAAwB,GAAQ;QAC5B,IAAI,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;QAElC,IAAI,GAAG,CAAC,WAAW,KAAK,OAAO,IAAI,GAAG,CAAC,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE;YACzE,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;SACjC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IACL,2BAAC;AAAD,CAAC,AAtxBD,IAsxBC","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport type { IUIEvent } from \"../Events/deviceInputEvents\";\r\nimport { DomManagement } from \"../Misc/domManagement\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { DeviceEventFactory } from \"./eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"./inputInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_KEYCODES = 255;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nconst MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2;\r\n\r\n/** @hidden */\r\nexport class WebDeviceInputSystem implements IDeviceInputSystem {\r\n // Private Members\r\n private _inputs: Array<{ [deviceSlot: number]: Array<number> }> = [];\r\n private _gamepads: Array<DeviceType>;\r\n private _keyboardActive: boolean = false;\r\n private _pointerActive: boolean = false;\r\n private _elementToAttachTo: HTMLElement;\r\n private _metaKeys: Array<number>;\r\n private readonly _engine: Engine;\r\n private readonly _usingSafari: boolean = Tools.IsSafari();\r\n // Found solution for determining if MacOS is being used here:\r\n // https://stackoverflow.com/questions/10527983/best-way-to-detect-mac-os-x-or-windows-computers-with-javascript-or-jquery\r\n private readonly _usingMacOS: boolean = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\r\n\r\n private _onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n private _onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _keyboardBlurEvent = (evt: any) => {};\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerMoveEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerDownEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerUpEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerCancelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerWheelEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _pointerBlurEvent = (evt: any) => {};\r\n private _wheelEventName: string;\r\n private _eventsAttached: boolean = false;\r\n\r\n private _mouseId = -1;\r\n private readonly _isUsingFirefox = DomManagement.IsNavigatorAvailable() && navigator.userAgent && navigator.userAgent.indexOf(\"Firefox\") !== -1;\r\n\r\n // Array to store active Pointer ID values; prevents issues with negative pointerIds\r\n private _activeTouchIds: Array<number>;\r\n private _maxTouchPoints: number = 0;\r\n\r\n private _pointerInputClearObserver: Nullable<Observer<Engine>> = null;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadConnectedEvent = (evt: any) => {};\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private _gamepadDisconnectedEvent = (evt: any) => {};\r\n\r\n private _eventPrefix: string;\r\n\r\n constructor(\r\n engine: Engine,\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void\r\n ) {\r\n this._eventPrefix = Tools.GetPointerPrefix(engine);\r\n this._engine = engine;\r\n\r\n this._onDeviceConnected = onDeviceConnected;\r\n this._onDeviceDisconnected = onDeviceDisconnected;\r\n this._onInputChanged = onInputChanged;\r\n\r\n this._enableEvents();\r\n\r\n if (this._usingMacOS) {\r\n this._metaKeys = [];\r\n }\r\n\r\n // Set callback to enable event handler switching when inputElement changes\r\n if (!this._engine._onEngineViewChanged) {\r\n this._engine._onEngineViewChanged = () => {\r\n this._enableEvents();\r\n };\r\n }\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (!device) {\r\n throw `Unable to find device ${DeviceType[deviceType]}`;\r\n }\r\n\r\n if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense) {\r\n this._updateDevice(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n const currentValue = device[inputIndex];\r\n if (currentValue === undefined) {\r\n throw `Unable to find input ${inputIndex} for device ${DeviceType[deviceType]} in slot ${deviceSlot}`;\r\n }\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n Tools.Warn(`Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data.`);\r\n }\r\n\r\n return currentValue;\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n return this._inputs[deviceType] !== undefined;\r\n }\r\n\r\n /**\r\n * Dispose of all the eventlisteners\r\n */\r\n public dispose(): void {\r\n // Callbacks\r\n this._onDeviceConnected = () => {};\r\n this._onDeviceDisconnected = () => {};\r\n this._onInputChanged = () => {};\r\n delete this._engine._onEngineViewChanged;\r\n\r\n if (this._elementToAttachTo) {\r\n this._disableEvents();\r\n }\r\n }\r\n\r\n /**\r\n * Enable listening for user input events\r\n */\r\n private _enableEvents(): void {\r\n const inputElement = this?._engine.getInputElement();\r\n if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {\r\n // Remove events before adding to avoid double events or simultaneous events on multiple canvases\r\n this._disableEvents();\r\n\r\n // If the inputs array has already been created, zero it out to before setting up events\r\n if (this._inputs) {\r\n for (const inputs of this._inputs) {\r\n if (inputs) {\r\n for (const deviceSlotKey in inputs) {\r\n const deviceSlot = +deviceSlotKey;\r\n const device = inputs[deviceSlot];\r\n if (device) {\r\n for (let inputIndex = 0; inputIndex < device.length; inputIndex++) {\r\n device[inputIndex] = 0;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._elementToAttachTo = inputElement;\r\n // Set tab index for the inputElement to the engine's canvasTabIndex, if and only if the element's tab index is -1\r\n this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex;\r\n this._handleKeyActions();\r\n this._handlePointerActions();\r\n this._handleGamepadActions();\r\n this._eventsAttached = true;\r\n\r\n // Check for devices that are already connected but aren't registered. Currently, only checks for gamepads and mouse\r\n this._checkForConnectedDevices();\r\n }\r\n }\r\n\r\n /**\r\n * Disable listening for user input events\r\n */\r\n private _disableEvents(): void {\r\n if (this._elementToAttachTo) {\r\n // Blur Events\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._keyboardBlurEvent);\r\n this._elementToAttachTo.removeEventListener(\"blur\", this._pointerBlurEvent);\r\n\r\n // Keyboard Events\r\n this._elementToAttachTo.removeEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.removeEventListener(\"keyup\", this._keyboardUpEvent);\r\n\r\n // Pointer Events\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.removeEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent);\r\n\r\n // Gamepad Events\r\n window.removeEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.removeEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n if (this._pointerInputClearObserver) {\r\n this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver);\r\n }\r\n\r\n this._eventsAttached = false;\r\n }\r\n\r\n /**\r\n * Checks for existing connections to devices and register them, if necessary\r\n * Currently handles gamepads and mouse\r\n */\r\n private _checkForConnectedDevices(): void {\r\n if (navigator.getGamepads) {\r\n const gamepads = navigator.getGamepads();\r\n\r\n for (const gamepad of gamepads) {\r\n if (gamepad) {\r\n this._addGamePad(gamepad);\r\n }\r\n }\r\n }\r\n\r\n // If the device in use has mouse capabilities, pre-register mouse\r\n if (typeof matchMedia === \"function\" && matchMedia(\"(pointer:fine)\").matches) {\r\n // This will provide a dummy value for the cursor position and is expected to be overridden when the first mouse event happens.\r\n // There isn't any good way to get the current position outside of a pointer event so that's why this was done.\r\n this._addPointerDevice(DeviceType.Mouse, 0, 0, 0);\r\n }\r\n }\r\n\r\n // Private functions\r\n /**\r\n * Add a gamepad to the DeviceInputSystem\r\n * @param gamepad A single DOM Gamepad object\r\n */\r\n private _addGamePad(gamepad: any): void {\r\n const deviceType = this._getGamepadDeviceType(gamepad.id);\r\n const deviceSlot = gamepad.index;\r\n\r\n this._gamepads = this._gamepads || new Array<DeviceType>(gamepad.index + 1);\r\n this._registerDevice(deviceType, deviceSlot, gamepad.buttons.length + gamepad.axes.length);\r\n\r\n this._gamepads[deviceSlot] = deviceType;\r\n }\r\n\r\n /**\r\n * Add pointer device to DeviceInputSystem\r\n * @param deviceType Type of Pointer to add\r\n * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)\r\n * @param currentX Current X at point of adding\r\n * @param currentY Current Y at point of adding\r\n */\r\n private _addPointerDevice(deviceType: DeviceType, deviceSlot: number, currentX: number, currentY: number): void {\r\n if (!this._pointerActive) {\r\n this._pointerActive = true;\r\n }\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n const pointer = this._inputs[deviceType][deviceSlot]; /* initialize our pointer position immediately after registration */\r\n pointer[0] = currentX;\r\n pointer[1] = currentY;\r\n }\r\n\r\n /**\r\n * Add device and inputs to device array\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param numberOfInputs Number of input entries to create for given device\r\n */\r\n private _registerDevice(deviceType: DeviceType, deviceSlot: number, numberOfInputs: number): void {\r\n if (deviceSlot === undefined) {\r\n throw `Unable to register device ${DeviceType[deviceType]} to undefined slot.`;\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n const device = new Array<number>(numberOfInputs);\r\n\r\n device.fill(0);\r\n\r\n this._inputs[deviceType][deviceSlot] = device;\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Given a specific device name, remove that device from the device map\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _unregisterDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._inputs[deviceType][deviceSlot]) {\r\n delete this._inputs[deviceType][deviceSlot];\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n\r\n /**\r\n * Handle all actions that come from keyboard interaction\r\n */\r\n private _handleKeyActions(): void {\r\n this._keyboardDownEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.metaKey && evt.key !== \"Meta\") {\r\n if (!this._metaKeys.includes(evt.keyCode)) {\r\n this._metaKeys.push(evt.keyCode);\r\n }\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardUpEvent = (evt) => {\r\n if (!this._keyboardActive) {\r\n this._keyboardActive = true;\r\n this._registerDevice(DeviceType.Keyboard, 0, MAX_KEYCODES);\r\n }\r\n\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n if (kbKey) {\r\n kbKey[evt.keyCode] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = evt.keyCode;\r\n\r\n if (this._usingMacOS && evt.key === \"Meta\" && this._metaKeys.length > 0) {\r\n for (const keyCode of this._metaKeys) {\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, keyCode, 0, this, this._elementToAttachTo);\r\n kbKey[keyCode] = 0;\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n };\r\n\r\n this._keyboardBlurEvent = () => {\r\n if (this._keyboardActive) {\r\n const kbKey = this._inputs[DeviceType.Keyboard][0];\r\n\r\n for (let i = 0; i < kbKey.length; i++) {\r\n if (kbKey[i] !== 0) {\r\n kbKey[i] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, i, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Keyboard, 0, deviceEvent);\r\n }\r\n }\r\n if (this._usingMacOS) {\r\n this._metaKeys.splice(0, this._metaKeys.length);\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(\"keydown\", this._keyboardDownEvent);\r\n this._elementToAttachTo.addEventListener(\"keyup\", this._keyboardUpEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._keyboardBlurEvent);\r\n }\r\n\r\n /**\r\n * Handle all actions that come from pointer interaction\r\n */\r\n private _handlePointerActions(): void {\r\n // If maxTouchPoints is defined, use that value. Otherwise, allow for a minimum for supported gestures like pinch\r\n this._maxTouchPoints = (DomManagement.IsNavigatorAvailable() && navigator.maxTouchPoints) || 2;\r\n if (!this._activeTouchIds) {\r\n this._activeTouchIds = new Array<number>(this._maxTouchPoints);\r\n }\r\n\r\n for (let i = 0; i < this._maxTouchPoints; i++) {\r\n this._activeTouchIds[i] = -1;\r\n }\r\n\r\n this._pointerMoveEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n // Lets Propagate the event for move with same position.\r\n if (!this._usingSafari && evt.button !== -1) {\r\n deviceEvent.inputIndex = evt.button + 2;\r\n pointer[evt.button + 2] = pointer[evt.button + 2] ? 0 : 1; // Reverse state of button if evt.button has value\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerDownEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n const idx = this._activeTouchIds.indexOf(-1);\r\n\r\n if (idx >= 0) {\r\n deviceSlot = idx;\r\n this._activeTouchIds[idx] = evt.pointerId;\r\n } else {\r\n // We can't find an open slot to store new pointer so just return (can only support max number of touches)\r\n Tools.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);\r\n return;\r\n }\r\n }\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = {};\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._addPointerDevice(deviceType, deviceSlot, evt.clientX, evt.clientY);\r\n } else if (deviceType === DeviceType.Touch) {\r\n this._onDeviceConnected(deviceType, deviceSlot);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n if (deviceType === DeviceType.Mouse) {\r\n // Mouse; Among supported browsers, value is either 1 or 0 for mouse\r\n if (this._mouseId === -1) {\r\n if (evt.pointerId === undefined) {\r\n // If there is no pointerId (eg. manually dispatched MouseEvent)\r\n this._mouseId = this._isUsingFirefox ? 0 : 1;\r\n } else {\r\n this._mouseId = evt.pointerId;\r\n }\r\n }\r\n\r\n if (!document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(this._mouseId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n } else {\r\n // Touch; Since touches are dynamically assigned, only set capture if we have an id\r\n if (evt.pointerId && !document.pointerLockElement) {\r\n try {\r\n this._elementToAttachTo.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n // DO NOTHING\r\n }\r\n }\r\n }\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 1;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._pointerUpEvent = (evt) => {\r\n const deviceType = this._getPointerType(evt);\r\n const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n if (deviceSlot === -1) {\r\n return;\r\n } else {\r\n this._activeTouchIds[deviceSlot] = -1;\r\n }\r\n }\r\n\r\n const pointer = this._inputs[deviceType]?.[deviceSlot];\r\n if (pointer && pointer[evt.button + 2] !== 0) {\r\n const previousHorizontal = pointer[PointerInput.Horizontal];\r\n const previousVertical = pointer[PointerInput.Vertical];\r\n\r\n pointer[PointerInput.Horizontal] = evt.clientX;\r\n pointer[PointerInput.Vertical] = evt.clientY;\r\n pointer[evt.button + 2] = 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {\r\n deviceEvent.inputIndex = PointerInput.Move;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n\r\n // NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button\r\n // However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression\r\n // EG. ([X, Y, Left-click], Middle-click, etc...)\r\n deviceEvent.inputIndex = evt.button + 2;\r\n\r\n if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n } else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n\r\n if (deviceType === DeviceType.Touch) {\r\n this._onDeviceDisconnected(deviceType, deviceSlot);\r\n }\r\n }\r\n };\r\n\r\n this._pointerCancelEvent = (evt) => {\r\n if (evt.pointerType === \"mouse\") {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n } else {\r\n const deviceSlot = this._activeTouchIds.indexOf(evt.pointerId);\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(evt.pointerId);\r\n }\r\n\r\n this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n };\r\n\r\n // Set Wheel Event Name, code originally from scene.inputManager\r\n this._wheelEventName =\r\n \"onwheel\" in document.createElement(\"div\")\r\n ? \"wheel\" // Modern browsers support \"wheel\"\r\n : (<any>document).onmousewheel !== undefined\r\n ? \"mousewheel\" // Webkit and IE support at least \"mousewheel\"\r\n : \"DOMMouseScroll\"; // let's assume that remaining browsers are older Firefox\r\n\r\n // Code originally in scene.inputManager.ts\r\n // Chrome reports warning in console if wheel listener doesn't set an explicit passive option.\r\n // IE11 only supports captureEvent:boolean, not options:object, and it defaults to false.\r\n // Feature detection technique copied from: https://github.com/github/eventlistener-polyfill (MIT license)\r\n let passiveSupported = false;\r\n const noop = function () {};\r\n\r\n try {\r\n const options = Object.defineProperty({}, \"passive\", {\r\n get: function () {\r\n passiveSupported = true;\r\n },\r\n });\r\n\r\n this._elementToAttachTo.addEventListener(\"test\", noop, options);\r\n this._elementToAttachTo.removeEventListener(\"test\", noop, options);\r\n } catch (e) {\r\n /* */\r\n }\r\n\r\n this._pointerBlurEvent = () => {\r\n // Handle mouse buttons\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n\r\n if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {\r\n this._elementToAttachTo.releasePointerCapture(this._mouseId);\r\n }\r\n\r\n for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {\r\n if (pointer[inputIndex] === 1) {\r\n pointer[inputIndex] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, inputIndex, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Mouse, 0, deviceEvent);\r\n }\r\n }\r\n }\r\n\r\n // Handle Active Touches\r\n if (this.isDeviceAvailable(DeviceType.Touch)) {\r\n const pointer = this._inputs[DeviceType.Touch];\r\n\r\n for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {\r\n const pointerId = this._activeTouchIds[deviceSlot];\r\n\r\n if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {\r\n this._elementToAttachTo.releasePointerCapture(pointerId);\r\n }\r\n\r\n if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {\r\n pointer[deviceSlot][PointerInput.LeftClick] = 0;\r\n\r\n const deviceEvent: IUIEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo);\r\n\r\n this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);\r\n\r\n this._activeTouchIds[deviceSlot] = -1;\r\n this._onDeviceDisconnected(DeviceType.Touch, deviceSlot);\r\n }\r\n }\r\n }\r\n };\r\n\r\n this._pointerWheelEvent = (evt) => {\r\n const deviceType = DeviceType.Mouse;\r\n const deviceSlot = 0;\r\n\r\n if (!this._inputs[deviceType]) {\r\n this._inputs[deviceType] = [];\r\n }\r\n\r\n if (!this._inputs[deviceType][deviceSlot]) {\r\n this._pointerActive = true;\r\n this._registerDevice(deviceType, deviceSlot, MAX_POINTER_INPUTS);\r\n }\r\n\r\n const pointer = this._inputs[deviceType][deviceSlot];\r\n if (pointer) {\r\n pointer[PointerInput.MouseWheelX] = evt.deltaX || 0;\r\n pointer[PointerInput.MouseWheelY] = evt.deltaY || evt.wheelDelta || 0;\r\n pointer[PointerInput.MouseWheelZ] = evt.deltaZ || 0;\r\n\r\n const deviceEvent = evt as IUIEvent;\r\n\r\n if (pointer[PointerInput.MouseWheelX] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelX;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelY] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelY;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n if (pointer[PointerInput.MouseWheelZ] !== 0) {\r\n deviceEvent.inputIndex = PointerInput.MouseWheelZ;\r\n this._onInputChanged(deviceType, deviceSlot, deviceEvent);\r\n }\r\n }\r\n };\r\n\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"move\", this._pointerMoveEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"down\", this._pointerDownEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"up\", this._pointerUpEvent);\r\n this._elementToAttachTo.addEventListener(this._eventPrefix + \"cancel\", this._pointerCancelEvent);\r\n this._elementToAttachTo.addEventListener(\"blur\", this._pointerBlurEvent);\r\n this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false);\r\n\r\n // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame\r\n this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {\r\n if (this.isDeviceAvailable(DeviceType.Mouse)) {\r\n const pointer = this._inputs[DeviceType.Mouse][0];\r\n pointer[PointerInput.MouseWheelX] = 0;\r\n pointer[PointerInput.MouseWheelY] = 0;\r\n pointer[PointerInput.MouseWheelZ] = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Handle all actions that come from gamepad interaction\r\n */\r\n private _handleGamepadActions(): void {\r\n this._gamepadConnectedEvent = (evt: any) => {\r\n this._addGamePad(evt.gamepad);\r\n };\r\n\r\n this._gamepadDisconnectedEvent = (evt: any) => {\r\n if (this._gamepads) {\r\n const deviceType = this._getGamepadDeviceType(evt.gamepad.id);\r\n const deviceSlot = evt.gamepad.index;\r\n\r\n this._unregisterDevice(deviceType, deviceSlot);\r\n delete this._gamepads[deviceSlot];\r\n }\r\n };\r\n\r\n window.addEventListener(\"gamepadconnected\", this._gamepadConnectedEvent);\r\n window.addEventListener(\"gamepaddisconnected\", this._gamepadDisconnectedEvent);\r\n }\r\n\r\n /**\r\n * Update all non-event based devices with each frame\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n */\r\n private _updateDevice(deviceType: DeviceType, deviceSlot: number, inputIndex: number): void {\r\n // Gamepads\r\n const gp = navigator.getGamepads()[deviceSlot];\r\n\r\n if (gp && deviceType === this._gamepads[deviceSlot]) {\r\n const device = this._inputs[deviceType][deviceSlot];\r\n\r\n if (inputIndex >= gp.buttons.length) {\r\n device[inputIndex] = gp.axes[inputIndex - gp.buttons.length].valueOf();\r\n } else {\r\n device[inputIndex] = gp.buttons[inputIndex].value;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets DeviceType from the device name\r\n * @param deviceName Name of Device from DeviceInputSystem\r\n * @returns DeviceType enum value\r\n */\r\n private _getGamepadDeviceType(deviceName: string): DeviceType {\r\n if (deviceName.indexOf(\"054c\") !== -1) {\r\n // DualShock 4 Gamepad\r\n return deviceName.indexOf(\"0ce6\") !== -1 ? DeviceType.DualSense : DeviceType.DualShock;\r\n } else if (deviceName.indexOf(\"Xbox One\") !== -1 || deviceName.search(\"Xbox 360\") !== -1 || deviceName.search(\"xinput\") !== -1) {\r\n // Xbox Gamepad\r\n return DeviceType.Xbox;\r\n } else if (deviceName.indexOf(\"057e\") !== -1) {\r\n // Switch Gamepad\r\n return DeviceType.Switch;\r\n }\r\n\r\n return DeviceType.Generic;\r\n }\r\n\r\n /**\r\n * Get DeviceType from a given pointer/mouse/touch event.\r\n * @param evt PointerEvent to evaluate\r\n * @returns DeviceType interpreted from event\r\n */\r\n private _getPointerType(evt: any): DeviceType {\r\n let deviceType = DeviceType.Mouse;\r\n\r\n if (evt.pointerType === \"touch\" || evt.pointerType === \"pen\" || evt.touches) {\r\n deviceType = DeviceType.Touch;\r\n }\r\n\r\n return deviceType;\r\n }\r\n}\r\n"]}
|