@babylonjs/core 6.41.0 → 6.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.js +1 -2
- package/Animations/animatable.js.map +1 -1
- package/Animations/animation.js +4 -6
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.js +3 -3
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.js +1 -1
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioEngine.js +3 -5
- package/Audio/audioEngine.js.map +1 -1
- package/Audio/audioSceneComponent.js +1 -2
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.js +48 -74
- package/Audio/sound.js.map +1 -1
- package/Audio/soundTrack.js +6 -12
- package/Audio/soundTrack.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js +1 -2
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js +2 -4
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +1 -2
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Bones/bone.js +4 -6
- package/Bones/bone.js.map +1 -1
- package/Bones/skeleton.js +2 -3
- package/Bones/skeleton.js.map +1 -1
- package/Buffers/buffer.align.js +5 -8
- package/Buffers/buffer.align.js.map +1 -1
- package/Buffers/buffer.js +6 -8
- package/Buffers/buffer.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +3 -4
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +3 -5
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +1 -2
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +5 -0
- package/Cameras/camera.js +18 -11
- package/Cameras/camera.js.map +1 -1
- package/Collisions/pickingInfo.js +1 -1
- package/Collisions/pickingInfo.js.map +1 -1
- package/Compute/computeEffect.js +5 -8
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +12 -9
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Octrees/octreeSceneComponent.js +1 -2
- package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
- package/Culling/boundingBox.js +2 -3
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/ray.d.ts +6 -1
- package/Culling/ray.js +9 -4
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.js +4 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.js +7 -9
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Debug/physicsViewer.js +5 -7
- package/Debug/physicsViewer.js.map +1 -1
- package/Debug/rayHelper.js +1 -2
- package/Debug/rayHelper.js.map +1 -1
- package/Debug/skeletonViewer.js +26 -31
- package/Debug/skeletonViewer.js.map +1 -1
- package/Decorators/nodeDecorator.js +1 -1
- package/Decorators/nodeDecorator.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js +3 -5
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/eventFactory.js +1 -1
- package/DeviceInput/eventFactory.js.map +1 -1
- package/DeviceInput/internalDeviceSourceManager.js +1 -2
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +9 -12
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.js +6 -1
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +3 -4
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +4 -4
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Extensions/engine.readTexture.js +2 -3
- package/Engines/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +9 -5
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.renderTargetCube.js +9 -1
- package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/Extensions/engine.views.js +1 -2
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +6 -7
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +6 -11
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLHardwareTexture.js +1 -2
- package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +3 -5
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +9 -2
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +1 -2
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -6
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +2 -4
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +11 -5
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +11 -3
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js +2 -3
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.js +1 -2
- package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js +1 -2
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.js +6 -7
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +15 -20
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +10 -5
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.js +2 -3
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +1 -2
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
- package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.js +1 -2
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +4 -6
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuMaterialContext.js +2 -3
- package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +3 -5
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +2 -4
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +2 -4
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -4
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +5 -4
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js +1 -2
- package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +40 -43
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +12 -7
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +4 -1
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/engine.js +4 -7
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js +16 -22
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +9 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +11 -16
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +32 -44
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +77 -95
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +2 -3
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +3 -6
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +1 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +2 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/flowGraph.js +1 -2
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.js +2 -4
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.js +1 -2
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.js +4 -7
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js +1 -2
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/serialization.js +2 -3
- package/FlowGraph/serialization.js.map +1 -1
- package/Gamepads/gamepadManager.js +1 -1
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/axisDragGizmo.js +2 -4
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +5 -8
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -3
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.js +4 -7
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.js +3 -4
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +2 -4
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +2 -4
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +8 -2
- package/Helpers/environmentHelper.js.map +1 -1
- package/Helpers/videoDome.js +1 -2
- package/Helpers/videoDome.js.map +1 -1
- package/Inputs/scene.inputManager.js +8 -10
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +16 -10
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +16 -6
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +12 -3
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/layer.js +1 -2
- package/Layers/layer.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +1 -2
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +21 -25
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +18 -21
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/light.js +2 -4
- package/Lights/light.js.map +1 -1
- package/Lights/shadowLight.js +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +1 -2
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.js +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +26 -32
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +22 -27
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -7
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -2
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -2
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +10 -16
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -3
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -2
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -4
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +1 -2
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +24 -26
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +45 -49
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -28
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +43 -33
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/biPlanarBlock.js +1 -2
- package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +2 -3
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +4 -5
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +4 -6
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +2 -4
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +14 -23
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +4 -5
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +16 -11
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +3 -4
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +1 -1
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +25 -28
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +6 -9
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js +4 -7
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js +4 -7
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Packer/packer.js +13 -14
- package/Materials/Textures/Packer/packer.js.map +1 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -2
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +19 -11
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js +2 -4
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +7 -13
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js +1 -2
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +2 -4
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.js +5 -3
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js +3 -5
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +3 -6
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js +5 -8
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/rawTexture.js +1 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +22 -34
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +16 -21
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.js +2 -4
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +12 -10
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +18 -21
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/drawWrapper.js +2 -4
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +4 -0
- package/Materials/effect.js +18 -18
- package/Materials/effect.js.map +1 -1
- package/Materials/effectRenderer.js +2 -3
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/material.decalMapConfiguration.js +3 -3
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.js +1 -2
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/material.js +7 -4
- package/Materials/material.js.map +1 -1
- package/Materials/materialDefines.js +5 -6
- package/Materials/materialDefines.js.map +1 -1
- package/Materials/materialHelper.d.ts +1 -1
- package/Materials/materialHelper.js +3 -4
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/materialPluginManager.js +3 -5
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.js +13 -14
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/multiMaterial.js +1 -2
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +1 -1
- package/Materials/shaderMaterial.js +64 -32
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/shadowDepthWrapper.js +24 -23
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Materials/standardMaterial.js +10 -12
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.js +1 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +26 -29
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +16 -16
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +5 -1
- package/Meshes/Builders/groundBuilder.js +13 -2
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/textBuilder.js +2 -3
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +9 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +141 -12
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +8 -11
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +3 -5
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +13 -18
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +18 -18
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +18 -18
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +6 -3
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +1 -1
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +1 -2
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +1 -2
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.js +6 -10
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.js +1 -2
- package/Meshes/csg.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.js +5 -10
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +13 -22
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js +3 -4
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +18 -15
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/subMesh.js +8 -14
- package/Meshes/subMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +12 -18
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/trailMesh.js +2 -3
- package/Meshes/trailMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -2
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +9 -14
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -3
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/arrayTools.js +1 -1
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/basis.js +2 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/dataStorage.js +1 -1
- package/Misc/dataStorage.js.map +1 -1
- package/Misc/deepCopier.js +1 -1
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/environmentTextureTools.js +3 -4
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/equirectangularCapture.js +2 -3
- package/Misc/equirectangularCapture.js.map +1 -1
- package/Misc/fileTools.js +4 -4
- package/Misc/fileTools.js.map +1 -1
- package/Misc/greasedLineTools.js +3 -5
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/logger.js +1 -2
- package/Misc/logger.js.map +1 -1
- package/Misc/minMaxReducer.js +2 -3
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/pressureObserverWrapper.js +5 -8
- package/Misc/pressureObserverWrapper.js.map +1 -1
- package/Misc/sceneRecorder.js +1 -1
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/screenshotTools.js +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.js +5 -5
- package/Misc/textureTools.js.map +1 -1
- package/Misc/timer.js +3 -5
- package/Misc/timer.js.map +1 -1
- package/Misc/tools.d.ts +3 -2
- package/Misc/tools.js +6 -5
- package/Misc/tools.js.map +1 -1
- package/Misc/trajectoryClassifier.js +3 -3
- package/Misc/trajectoryClassifier.js.map +1 -1
- package/Misc/videoRecorder.js +6 -4
- package/Misc/videoRecorder.js.map +1 -1
- package/Misc/virtualJoystick.js +4 -1
- package/Misc/virtualJoystick.js.map +1 -1
- package/Morph/morphTargetManager.js +1 -2
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +1 -2
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +4 -0
- package/Particles/baseParticleSystem.js +4 -0
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +3 -6
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +2 -2
- package/Particles/gpuParticleSystem.js +30 -20
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +3 -2
- package/Particles/particleSystem.js +33 -30
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemComponent.js +2 -3
- package/Particles/particleSystemComponent.js.map +1 -1
- package/Particles/pointsCloudSystem.js +5 -8
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Particles/solidParticleSystem.js +5 -7
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.js +1 -2
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/castingResult.js +1 -1
- package/Physics/castingResult.js.map +1 -1
- package/Physics/joinedPhysicsEngineComponent.js +2 -2
- package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.js +19 -21
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +20 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +48 -35
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.js +10 -12
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.js +2 -4
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsShape.js +1 -2
- package/Physics/v2/physicsShape.js.map +1 -1
- package/Physics/v2/ragdoll.js +6 -8
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +6 -8
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +14 -22
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js +28 -34
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.js +4 -6
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -2
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +4 -7
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js +2 -4
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js +22 -19
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +2 -3
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +2 -4
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthPeelingSceneComponent.js +2 -4
- package/Rendering/depthPeelingSceneComponent.js.map +1 -1
- package/Rendering/depthRenderer.js +10 -13
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +8 -11
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +6 -11
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.js +3 -5
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +2 -4
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +30 -36
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTextures.js +5 -7
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +3 -2
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +5 -4
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js +3 -6
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.d.ts +1 -0
- package/Rendering/reflectiveShadowMap.js +5 -5
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Shaders/color.fragment.d.ts +2 -0
- package/Shaders/color.fragment.js +4 -0
- package/Shaders/color.fragment.js.map +1 -1
- package/Shaders/color.vertex.d.ts +2 -0
- package/Shaders/color.vertex.js +7 -0
- package/Shaders/color.vertex.js.map +1 -1
- package/Shaders/gpuRenderParticles.fragment.d.ts +2 -0
- package/Shaders/gpuRenderParticles.fragment.js +4 -0
- package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.vertex.d.ts +2 -0
- package/Shaders/gpuRenderParticles.vertex.js +5 -1
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/particles.fragment.d.ts +2 -0
- package/Shaders/particles.fragment.js +4 -0
- package/Shaders/particles.fragment.js.map +1 -1
- package/Shaders/particles.vertex.d.ts +2 -0
- package/Shaders/particles.vertex.js +5 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Sprites/spriteManager.js +1 -2
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +5 -7
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/stencilStateComposer.js +2 -4
- package/States/stencilStateComposer.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.js +6 -2
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js +1 -2
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js +6 -7
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +17 -10
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +1 -2
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +1 -0
- package/XR/features/WebXRControllerTeleportation.js +6 -3
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +3 -5
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +1 -0
- package/XR/features/WebXRHandTracking.js +31 -28
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js +9 -11
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js +3 -6
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js +2 -4
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +21 -18
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js +1 -2
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js +2 -3
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js +1 -1
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +4 -1
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/native/nativeXRFrame.js +1 -2
- package/XR/native/nativeXRFrame.js.map +1 -1
- package/XR/webXRCamera.js +1 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRDefaultExperience.js +28 -6
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXRExperienceHelper.js +5 -7
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.js +4 -1
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +6 -1
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +1 -2
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRSessionManager.js +16 -29
- package/XR/webXRSessionManager.js.map +1 -1
- package/assetContainer.js +4 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +18 -17
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/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,E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e,CAAuB,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,mBAAmB,CAAC,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,MAAM,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;CACJ","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 * @internal\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 * @internal\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 * @internal\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":["../../../../../dev/core/src/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,MAAM,OAAO,mBAAmB;IAkB5B,mBAAmB;IACnB;;;;;OAKG;IACI,eAAe,CAAuB,UAAa,EAAE,UAAmB;QAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;YAC1B,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;gBAC7C,OAAO,IAAI,CAAC;aACf;YAED,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;SAC9C;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACnF,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAoB,CAAC;IACpE,CAAC;IACD;;;;OAIG;IACI,gBAAgB,CAAuB,UAAa;QACvD,2EAA2E;QAC3E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC5B,OAAO,EAAE,CAAC;SACb;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/C,OAAO,CAAC,CAAC,MAAM,CAAC;QACpB,CAAC,CAA2B,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,YAAY,MAAc;QACtB,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,C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BACJ;iBACJ;gBACD,MAAM;aACT;SACJ;IACL,CAAC;CACJ","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 * @internal\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 * @internal\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 * @internal\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"]}
|
|
@@ -54,7 +54,7 @@ export class DeviceEventFactory {
|
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
evt.deviceType = DeviceType.Touch;
|
|
57
|
-
evt.pointerId = pointerId
|
|
57
|
+
evt.pointerId = pointerId ?? deviceSlot;
|
|
58
58
|
evt.pointerType = "touch";
|
|
59
59
|
}
|
|
60
60
|
let buttons = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../dev/core/src/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,MAAM,OAAO,kBAAkB;IAC3B;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,iBAAiB,CAC3B,UAAsB,EACtB,UAAkB,EAClB,UAAkB,EAClB,YAA8B,EAC9B,iBAAqC,EACrC,iBAAuB,EACvB,SAAkB;QAElB,QAAQ,UAAU,EAAE;YAChB,KAAK,UAAU,CAAC,QAAQ;gBACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YACrG,KAAK,UAAU,CAAC,KAAK;gBACjB,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAA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B,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","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 * @param pointerId PointerId to use for pointer events\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 pointerId?: number\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, pointerId);\r\n default:\r\n // eslint-disable-next-line no-throw-literal\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 * @param pointerId PointerId to use for pointer events\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 pointerId?: number\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 = pointerId ?? deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\r\n\r\n let buttons = 0;\r\n\r\n // Populate buttons property with current state of all mouse buttons\r\n // Uses values found on: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.LeftClick);\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.RightClick) * 2;\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MiddleClick) * 4;\r\n evt.buttons = buttons;\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 // While WheelEvents don't generally have a pointerId, we used to add one in the InputManager\r\n // This line has been added to make the InputManager more platform-agnostic\r\n // Similar code exists in the WebDeviceInputSystem to handle browser created events\r\n evt.pointerId = 1;\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
|
+
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../dev/core/src/DeviceInput/eventFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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,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,MAAM,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;IACK,MAAM,CAAC,YAAY,CAAC,iBAAsB;QAC9C,MAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","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 * @param pointerId PointerId to use for pointer events\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 pointerId?: number\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, pointerId);\r\n default:\r\n // eslint-disable-next-line no-throw-literal\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 * @param pointerId PointerId to use for pointer events\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 pointerId?: number\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 = pointerId ?? deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\r\n\r\n let buttons = 0;\r\n\r\n // Populate buttons property with current state of all mouse buttons\r\n // Uses values found on: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.LeftClick);\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.RightClick) * 2;\r\n buttons += deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MiddleClick) * 4;\r\n evt.buttons = buttons;\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 // While WheelEvents don't generally have a pointerId, we used to add one in the InputManager\r\n // This line has been added to make the InputManager more platform-agnostic\r\n // Similar code exists in the WebDeviceInputSystem to handle browser created events\r\n evt.pointerId = 1;\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"]}
|
|
@@ -39,8 +39,7 @@ export class InternalDeviceSourceManager {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const onDeviceDisconnected = (deviceType, deviceSlot) => {
|
|
42
|
-
|
|
43
|
-
if ((_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
|
|
42
|
+
if (this._devices[deviceType]?.[deviceSlot]) {
|
|
44
43
|
delete this._devices[deviceType][deviceSlot];
|
|
45
44
|
}
|
|
46
45
|
for (const manager of this._registeredManagers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../dev/core/src/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,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA6B3D,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAYpC,YAAmB,MAAc;QAJhB,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AU,CAAC;aACnD;YAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,EAAE;gBACxC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;aACtD;YACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC5C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;gBACvF,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;aACpC;QACL,CAAC,CAAC;QAEF,MAAM,oBAAoB,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../dev/core/src/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,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA6B3D,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAYpC,YAAmB,MAAc;QAJhB,wBAAmB,GAAG,IAAI,KAAK,EAAsB,CAAC;QAEhE,cAAS,GAAG,CAAC,CAAC;QA4CrB,mBAAmB;QACH,oBAAe,GAAG,CAAC,OAA2B,EAAQ,EAAE;YACpE,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBACtE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACzC,KAAK,MAAM,aAAa,IAAI,MAAM,EAAE;oBAChC,MAAM,U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YAAY,CAAC,CAAC;aACpC;QACL,CAAC,CAAC;QAEF,MAAM,oBAAoB,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAE,EAAE;YACxE,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;aAChD;YACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC5C,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;aACjD;QACL,CAAC,CAAC;QAEF,MAAM,cAAc,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAE,SAAmB,EAAE,EAAE;YACvF,IAAI,SAAS,EAAE;gBACX,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,mBAAmB,EAAE;oBAC5C,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,UAAU,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,OAAO;QACV,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACJ","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 /** @internal */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @internal */\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/** @internal */\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"]}
|
|
@@ -124,7 +124,7 @@ export class WebDeviceInputSystem {
|
|
|
124
124
|
* Enable listening for user input events
|
|
125
125
|
*/
|
|
126
126
|
_enableEvents() {
|
|
127
|
-
const inputElement = this
|
|
127
|
+
const inputElement = this?._engine.getInputElement();
|
|
128
128
|
if (inputElement && (!this._eventsAttached || this._elementToAttachTo !== inputElement)) {
|
|
129
129
|
// Remove events before adding to avoid double events or simultaneous events on multiple canvases
|
|
130
130
|
this._disableEvents();
|
|
@@ -454,7 +454,6 @@ export class WebDeviceInputSystem {
|
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
456
|
this._pointerUpEvent = (evt) => {
|
|
457
|
-
var _a, _b, _c, _d, _e;
|
|
458
457
|
const deviceType = this._getPointerType(evt);
|
|
459
458
|
const deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);
|
|
460
459
|
if (deviceType === DeviceType.Touch) {
|
|
@@ -466,7 +465,7 @@ export class WebDeviceInputSystem {
|
|
|
466
465
|
this._activeTouchIds[deviceSlot] = -1;
|
|
467
466
|
}
|
|
468
467
|
}
|
|
469
|
-
const pointer =
|
|
468
|
+
const pointer = this._inputs[deviceType]?.[deviceSlot];
|
|
470
469
|
if (pointer && pointer[evt.button + 2] !== 0) {
|
|
471
470
|
const previousHorizontal = pointer[PointerInput.Horizontal];
|
|
472
471
|
const previousVertical = pointer[PointerInput.Vertical];
|
|
@@ -485,10 +484,10 @@ export class WebDeviceInputSystem {
|
|
|
485
484
|
// However, we have our X and Y values front-loaded to group together the touch inputs but not break this progression
|
|
486
485
|
// EG. ([X, Y, Left-click], Middle-click, etc...)
|
|
487
486
|
deviceEvent.inputIndex = evt.button + 2;
|
|
488
|
-
if (deviceType === DeviceType.Mouse && this._mouseId >= 0 &&
|
|
487
|
+
if (deviceType === DeviceType.Mouse && this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
|
|
489
488
|
this._elementToAttachTo.releasePointerCapture(this._mouseId);
|
|
490
489
|
}
|
|
491
|
-
else if (evt.pointerId &&
|
|
490
|
+
else if (evt.pointerId && this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {
|
|
492
491
|
this._elementToAttachTo.releasePointerCapture(evt.pointerId);
|
|
493
492
|
}
|
|
494
493
|
this._onInputChanged(deviceType, deviceSlot, deviceEvent);
|
|
@@ -498,10 +497,9 @@ export class WebDeviceInputSystem {
|
|
|
498
497
|
}
|
|
499
498
|
};
|
|
500
499
|
this._pointerCancelEvent = (evt) => {
|
|
501
|
-
var _a, _b, _c, _d;
|
|
502
500
|
if (evt.pointerType === "mouse") {
|
|
503
501
|
const pointer = this._inputs[DeviceType.Mouse][0];
|
|
504
|
-
if (this._mouseId >= 0 &&
|
|
502
|
+
if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
|
|
505
503
|
this._elementToAttachTo.releasePointerCapture(this._mouseId);
|
|
506
504
|
}
|
|
507
505
|
for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {
|
|
@@ -518,7 +516,7 @@ export class WebDeviceInputSystem {
|
|
|
518
516
|
if (deviceSlot === -1) {
|
|
519
517
|
return;
|
|
520
518
|
}
|
|
521
|
-
if (
|
|
519
|
+
if (this._elementToAttachTo.hasPointerCapture?.(evt.pointerId)) {
|
|
522
520
|
this._elementToAttachTo.releasePointerCapture(evt.pointerId);
|
|
523
521
|
}
|
|
524
522
|
this._inputs[DeviceType.Touch][deviceSlot][PointerInput.LeftClick] = 0;
|
|
@@ -554,11 +552,10 @@ export class WebDeviceInputSystem {
|
|
|
554
552
|
/* */
|
|
555
553
|
}
|
|
556
554
|
this._pointerBlurEvent = () => {
|
|
557
|
-
var _a, _b, _c, _d, _e;
|
|
558
555
|
// Handle mouse buttons
|
|
559
556
|
if (this.isDeviceAvailable(DeviceType.Mouse)) {
|
|
560
557
|
const pointer = this._inputs[DeviceType.Mouse][0];
|
|
561
|
-
if (this._mouseId >= 0 &&
|
|
558
|
+
if (this._mouseId >= 0 && this._elementToAttachTo.hasPointerCapture?.(this._mouseId)) {
|
|
562
559
|
this._elementToAttachTo.releasePointerCapture(this._mouseId);
|
|
563
560
|
}
|
|
564
561
|
for (let inputIndex = PointerInput.LeftClick; inputIndex <= PointerInput.BrowserForward; inputIndex++) {
|
|
@@ -574,10 +571,10 @@ export class WebDeviceInputSystem {
|
|
|
574
571
|
const pointer = this._inputs[DeviceType.Touch];
|
|
575
572
|
for (let deviceSlot = 0; deviceSlot < this._activeTouchIds.length; deviceSlot++) {
|
|
576
573
|
const pointerId = this._activeTouchIds[deviceSlot];
|
|
577
|
-
if (
|
|
574
|
+
if (this._elementToAttachTo.hasPointerCapture?.(pointerId)) {
|
|
578
575
|
this._elementToAttachTo.releasePointerCapture(pointerId);
|
|
579
576
|
}
|
|
580
|
-
if (pointerId !== -1 &&
|
|
577
|
+
if (pointerId !== -1 && pointer[deviceSlot]?.[PointerInput.LeftClick] === 1) {
|
|
581
578
|
pointer[deviceSlot][PointerInput.LeftClick] = 0;
|
|
582
579
|
const deviceEvent = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, deviceSlot, PointerInput.LeftClick, 0, this, this._elementToAttachTo, pointerId);
|
|
583
580
|
this._onInputChanged(DeviceType.Touch, deviceSlot, deviceEvent);
|