@babylonjs/core 8.8.0 → 8.8.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/Actions/actionManager.js +2 -0
- package/Actions/actionManager.js.map +1 -1
- package/Animations/animatable.core.js +1 -1
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animation.js +4 -2
- package/Animations/animation.js.map +1 -1
- package/Audio/audioEngine.d.ts +1 -1
- package/Audio/audioEngine.js +20 -10
- package/Audio/audioEngine.js.map +1 -1
- package/Audio/audioSceneComponent.js +2 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.js +2 -0
- package/Audio/sound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.js +8 -1
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.js +3 -1
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +6 -2
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +3 -0
- package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +1 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +5 -1
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +2 -0
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +3 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioUnmuteUI.js +1 -0
- package/AudioV2/webAudio/webAudioUnmuteUI.js.map +1 -1
- package/BakedVertexAnimation/vertexAnimationBaker.d.ts +1 -0
- package/BakedVertexAnimation/vertexAnimationBaker.js +3 -1
- package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js +1 -0
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
- package/Buffers/storageBuffer.js +1 -1
- package/Buffers/storageBuffer.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.js +2 -0
- package/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +6 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +2 -0
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Collisions/gpuPicker.js +9 -6
- package/Collisions/gpuPicker.js.map +1 -1
- package/Compute/computeShader.js +1 -1
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Helper/boundingInfoHelper.js +3 -3
- package/Culling/Helper/boundingInfoHelper.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +3 -1
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js +3 -0
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
- package/Debug/debugLayer.js +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js +1 -0
- package/Engines/AbstractEngine/abstractEngine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +1 -0
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.readTexture.js +1 -0
- package/Engines/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +1 -0
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.readTexture.js +1 -0
- package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js +2 -0
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +3 -1
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +1 -0
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js +15 -9
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +1 -0
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +4 -2
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +1 -0
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/abstractEngine.js +5 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +23 -0
- package/Engines/constants.js +23 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.common.js +7 -1
- package/Engines/engine.common.js.map +1 -1
- package/Engines/engine.js +5 -3
- package/Engines/engine.js.map +1 -1
- package/Engines/engineFactory.js +1 -1
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.js +19 -11
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +22 -18
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +30 -11
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +2 -2
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +5 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/frameGraph.js +1 -1
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Helpers/sceneHelpers.js +1 -3
- package/Helpers/sceneHelpers.js.map +1 -1
- package/Helpers/videoDome.js +1 -0
- package/Helpers/videoDome.js.map +1 -1
- package/Layers/thinEffectLayer.js +1 -0
- package/Layers/thinEffectLayer.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +1 -0
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/areaLight.js +2 -0
- package/Lights/areaLight.js.map +1 -1
- package/Loading/sceneLoader.js +56 -22
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +15 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +34 -7
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +1 -0
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +1 -0
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +1 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +1 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +1 -0
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +1 -0
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +9 -11
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +6 -2
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +1 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +1 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +11 -3
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +1 -0
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.d.ts +11 -0
- package/Materials/PBR/pbrBRDFConfiguration.js +16 -0
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +4 -0
- package/Materials/PBR/pbrBaseMaterial.js +12 -8
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +8 -0
- package/Materials/PBR/pbrMaterial.js +16 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +1 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/basisTextureLoader.js +4 -0
- package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +1 -0
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/exrTextureLoader.js +2 -0
- package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -0
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/textureLoaderManager.js +9 -9
- package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
- package/Materials/Textures/Packer/packer.js +3 -1
- package/Materials/Textures/Packer/packer.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -0
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.polynomial.js +1 -0
- package/Materials/Textures/baseTexture.polynomial.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +1 -0
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js +1 -0
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.js +3 -0
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +6 -0
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/effect.js +2 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +3 -1
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/effectRenderer.js +1 -0
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/material.js +2 -1
- package/Materials/material.js.map +1 -1
- package/Materials/shaderMaterial.js +4 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCodec.js +5 -1
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js +4 -3
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js +5 -2
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.js +5 -1
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.js +3 -2
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +18 -18
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +14 -15
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +20 -10
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -0
- package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +5 -1
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +1 -0
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -0
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/assetsManager.js +2 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/asyncLock.js +5 -2
- package/Misc/asyncLock.js.map +1 -1
- package/Misc/basis.js +9 -2
- package/Misc/basis.js.map +1 -1
- package/Misc/basisWorker.js +3 -1
- package/Misc/basisWorker.js.map +1 -1
- package/Misc/copyTextureToTexture.js +1 -0
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/coroutine.js +2 -1
- package/Misc/coroutine.js.map +1 -1
- package/Misc/dataReader.js +3 -4
- package/Misc/dataReader.js.map +1 -1
- package/Misc/dumpTools.js +7 -1
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.d.ts +0 -2
- package/Misc/environmentTextureTools.js +20 -7
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/equirectangularCapture.js +2 -1
- package/Misc/equirectangularCapture.js.map +1 -1
- package/Misc/fileTools.js +2 -0
- package/Misc/fileTools.js.map +1 -1
- package/Misc/filesInput.js +5 -1
- package/Misc/filesInput.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +10 -3
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Worker.js +4 -1
- package/Misc/khronosTextureContainer2Worker.js.map +1 -1
- package/Misc/minMaxReducer.js +1 -0
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/observable.extensions.js +3 -1
- package/Misc/observable.extensions.js.map +1 -1
- package/Misc/observable.js +2 -0
- package/Misc/observable.js.map +1 -1
- package/Misc/observableCoroutine.js +1 -0
- package/Misc/observableCoroutine.js.map +1 -1
- package/Misc/reflector.js +1 -0
- package/Misc/reflector.js.map +1 -1
- package/Misc/rgbdTextureTools.js +2 -1
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/sceneSerializer.js +2 -2
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/screenshotTools.js +9 -4
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.js +2 -0
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.internals.js +2 -1
- package/Misc/tools.internals.js.map +1 -1
- package/Misc/tools.js +9 -3
- package/Misc/tools.js.map +1 -1
- package/Misc/videoRecorder.js +1 -0
- package/Misc/videoRecorder.js.map +1 -1
- package/Misc/webRequest.fetch.js +2 -1
- package/Misc/webRequest.fetch.js.map +1 -1
- package/Misc/workerPool.js +3 -0
- package/Misc/workerPool.js.map +1 -1
- package/Particles/flowMap.js +1 -1
- package/Particles/flowMap.js.map +1 -1
- package/Particles/particleHelper.js +7 -0
- package/Particles/particleHelper.js.map +1 -1
- package/Particles/pointsCloudSystem.js +7 -7
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js +2 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsHelper.js +2 -2
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v1/Plugins/oimoJSPlugin.js +1 -1
- package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js +1 -0
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +1 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +1 -0
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +4 -1
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +5 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +12 -5
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js +3 -0
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +21 -8
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js +3 -0
- package/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +6 -6
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js +2 -7
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js +20 -16
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +6 -8
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDebug.js +2 -2
- package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -5
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/pbr.fragment.js +7 -3
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +5 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +5 -5
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +21 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +6 -6
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js +2 -7
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js +22 -15
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +6 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDebug.js +2 -2
- package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -7
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +7 -3
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/Sprites/spriteManager.js +5 -1
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -0
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js +4 -3
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +4 -1
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js +4 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.js +6 -5
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/features/WebXRImageTracking.js +2 -1
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js +3 -0
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +2 -0
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js +2 -2
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +3 -2
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/motionController/webXRMicrosoftMixedRealityController.js +6 -6
- package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
- package/XR/motionController/webXRMotionControllerManager.js +15 -9
- package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
- package/XR/motionController/webXRProfiledMotionController.js +1 -1
- package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
- package/XR/native/nativeXRFrame.js +1 -0
- package/XR/native/nativeXRFrame.js.map +1 -1
- package/XR/webXRDefaultExperience.js +10 -12
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXREnterExitUI.js +2 -1
- package/XR/webXREnterExitUI.js.map +1 -1
- package/XR/webXRExperienceHelper.js +5 -2
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.js +1 -0
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +1 -0
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +2 -0
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +5 -1
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRSessionManager.js +56 -60
- package/XR/webXRSessionManager.js.map +1 -1
- package/assetContainer.js +28 -28
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +5 -4
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRAbstractMotionController.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRAbstractMotionController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAyNzC;;;;GAIG;AACH,MAAM,OAAgB,6BAA6B;IA4C/C;;;;;;;;OAQG;IACH;IACI,gEAAgE;IACtD,KAAY;IACtB,gEAAgE;IACtD,MAA+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E,IAAI,CAAC,KAAK,CAAC,CAAC;QAE7E,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACf,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,kBAAkB,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;CACJ","sourcesContent":["import type { IDisposable, Scene } from \"../../scene\";\r\nimport { WebXRControllerComponent } from \"./webXRControllerComponent\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\n\r\n/**\r\n * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.\r\n */\r\nexport type MotionControllerHandedness = \"none\" | \"left\" | \"right\";\r\n/**\r\n * The type of components available in motion controllers.\r\n * This is not the name of the component.\r\n */\r\nexport type MotionControllerComponentType = \"trigger\" | \"squeeze\" | \"touchpad\" | \"thumbstick\" | \"button\";\r\n\r\n/**\r\n * The state of a controller component\r\n */\r\nexport type MotionControllerComponentStateType = \"default\" | \"touched\" | \"pressed\";\r\n\r\n/**\r\n * The schema of motion controller layout.\r\n * No object will be initialized using this interface\r\n * This is used just to define the profile.\r\n */\r\nexport interface IMotionControllerLayout {\r\n /**\r\n * Path to load the assets. Usually relative to the base path\r\n */\r\n assetPath: string;\r\n /**\r\n * Available components (unsorted)\r\n */\r\n components: {\r\n /**\r\n * A map of component Ids\r\n */\r\n [componentId: string]: {\r\n /**\r\n * The type of input the component outputs\r\n */\r\n type: MotionControllerComponentType;\r\n /**\r\n * The indices of this component in the gamepad object\r\n */\r\n gamepadIndices: {\r\n /**\r\n * Index of button\r\n */\r\n button?: number;\r\n /**\r\n * If available, index of x-axis\r\n */\r\n xAxis?: number;\r\n /**\r\n * If available, index of y-axis\r\n */\r\n yAxis?: number;\r\n };\r\n /**\r\n * The mesh's root node name\r\n */\r\n rootNodeName: string;\r\n /**\r\n * Animation definitions for this model\r\n */\r\n visualResponses: {\r\n [stateKey: string]: {\r\n /**\r\n * What property will be animated\r\n */\r\n componentProperty: \"xAxis\" | \"yAxis\" | \"button\" | \"state\";\r\n /**\r\n * What states influence this visual response\r\n */\r\n states: MotionControllerComponentStateType[];\r\n /**\r\n * Type of animation - movement or visibility\r\n */\r\n valueNodeProperty: \"transform\" | \"visibility\";\r\n /**\r\n * Base node name to move. Its position will be calculated according to the min and max nodes\r\n */\r\n valueNodeName?: string;\r\n /**\r\n * Minimum movement node\r\n */\r\n minNodeName?: string;\r\n /**\r\n * Max movement node\r\n */\r\n maxNodeName?: string;\r\n };\r\n };\r\n /**\r\n * If touch enabled, what is the name of node to display user feedback\r\n */\r\n touchPointNodeName?: string;\r\n };\r\n };\r\n /**\r\n * Is it xr standard mapping or not\r\n */\r\n gamepadMapping: \"\" | \"xr-standard\";\r\n /**\r\n * Base root node of this entire model\r\n */\r\n rootNodeName: string;\r\n /**\r\n * Defines the main button component id\r\n */\r\n selectComponentId: string;\r\n}\r\n\r\n/**\r\n * A definition for the layout map in the input profile\r\n */\r\nexport interface IMotionControllerLayoutMap {\r\n /**\r\n * Layouts with handedness type as a key\r\n */\r\n [handedness: string /* handedness */]: IMotionControllerLayout;\r\n}\r\n\r\n/**\r\n * The XR Input profile schema\r\n * Profiles can be found here:\r\n * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles\r\n */\r\nexport interface IMotionControllerProfile {\r\n /**\r\n * fallback profiles for this profileId\r\n */\r\n fallbackProfileIds: string[];\r\n /**\r\n * The layout map, with handedness as key\r\n */\r\n layouts: IMotionControllerLayoutMap;\r\n /**\r\n * The id of this profile\r\n * correlates to the profile(s) in the xrInput.profiles array\r\n */\r\n profileId: string;\r\n}\r\n\r\n/**\r\n * A helper-interface for the 3 meshes needed for controller button animation\r\n * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh\r\n */\r\nexport interface IMotionControllerButtonMeshMap {\r\n /**\r\n * the mesh that defines the pressed value mesh position.\r\n * This is used to find the max-position of this button\r\n */\r\n pressedMesh: AbstractMesh;\r\n /**\r\n * the mesh that defines the unpressed value mesh position.\r\n * This is used to find the min (or initial) position of this button\r\n */\r\n unpressedMesh: AbstractMesh;\r\n /**\r\n * The mesh that will be changed when value changes\r\n */\r\n valueMesh: AbstractMesh;\r\n}\r\n\r\n/**\r\n * A helper-interface for the 3 meshes needed for controller axis animation.\r\n * This will be expanded when touchpad animations are fully supported\r\n * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh\r\n */\r\nexport interface IMotionControllerMeshMap {\r\n /**\r\n * the mesh that defines the maximum value mesh position.\r\n */\r\n maxMesh?: AbstractMesh;\r\n /**\r\n * the mesh that defines the minimum value mesh position.\r\n */\r\n minMesh?: AbstractMesh;\r\n /**\r\n * The mesh that will be changed when axis value changes\r\n */\r\n valueMesh?: AbstractMesh;\r\n}\r\n\r\n/**\r\n * The elements needed for change-detection of the gamepad objects in motion controllers\r\n */\r\nexport interface IMinimalMotionControllerObject {\r\n /**\r\n * Available axes of this controller\r\n */\r\n axes: number[];\r\n /**\r\n * An array of available buttons\r\n */\r\n buttons: Array<{\r\n /**\r\n * Value of the button/trigger\r\n */\r\n value: number;\r\n /**\r\n * If the button/trigger is currently touched\r\n */\r\n touched: boolean;\r\n /**\r\n * If the button/trigger is currently pressed\r\n */\r\n pressed: boolean;\r\n }>;\r\n\r\n /**\r\n * EXPERIMENTAL haptic support.\r\n */\r\n hapticActuators?: Array<{\r\n pulse: (value: number, duration: number) => Promise<boolean>;\r\n }>;\r\n}\r\n\r\n/**\r\n * An Abstract Motion controller\r\n * This class receives an xrInput and a profile layout and uses those to initialize the components\r\n * Each component has an observable to check for changes in value and state\r\n */\r\nexport abstract class WebXRAbstractMotionController implements IDisposable {\r\n private _initComponent = (id: string) => {\r\n if (!id) {\r\n return;\r\n }\r\n const componentDef = this.layout.components[id];\r\n const type = componentDef.type;\r\n const buttonIndex = componentDef.gamepadIndices.button;\r\n // search for axes\r\n const axes: number[] = [];\r\n if (componentDef.gamepadIndices.xAxis !== undefined && componentDef.gamepadIndices.yAxis !== undefined) {\r\n axes.push(componentDef.gamepadIndices.xAxis, componentDef.gamepadIndices.yAxis);\r\n }\r\n\r\n this.components[id] = new WebXRControllerComponent(id, type, buttonIndex, axes);\r\n };\r\n\r\n private _modelReady: boolean = false;\r\n\r\n /**\r\n * A map of components (WebXRControllerComponent) in this motion controller\r\n * Components have a ComponentType and can also have both button and axis definitions\r\n */\r\n public readonly components: {\r\n [id: string]: WebXRControllerComponent;\r\n } = {};\r\n\r\n /**\r\n * Disable the model's animation. Can be set at any time.\r\n */\r\n public disableAnimation: boolean = false;\r\n /**\r\n * Observers registered here will be triggered when the model of this controller is done loading\r\n */\r\n public onModelLoadedObservable: Observable<WebXRAbstractMotionController> = new Observable();\r\n /**\r\n * The profile id of this motion controller\r\n */\r\n public abstract profileId: string;\r\n /**\r\n * The root mesh of the model. It is null if the model was not yet initialized\r\n */\r\n public rootMesh: Nullable<AbstractMesh>;\r\n\r\n /**\r\n * constructs a new abstract motion controller\r\n * @param scene the scene to which the model of the controller will be added\r\n * @param layout The profile layout to load\r\n * @param gamepadObject The gamepad object correlating to this controller\r\n * @param handedness handedness (left/right/none) of this controller\r\n * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading\r\n * @param _controllerCache a cache holding controller models already loaded in this session\r\n */\r\n constructor(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected scene: Scene,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected layout: IMotionControllerLayout,\r\n /**\r\n * The gamepad object correlating to this controller\r\n */\r\n public gamepadObject: IMinimalMotionControllerObject,\r\n /**\r\n * handedness (left/right/none) of this controller\r\n */\r\n public handedness: MotionControllerHandedness,\r\n /**\r\n * @internal\r\n * [false]\r\n */\r\n public _doNotLoadControllerMesh: boolean = false,\r\n private _controllerCache?: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n }>\r\n ) {\r\n // initialize the components\r\n if (layout.components) {\r\n const keys = Object.keys(layout.components);\r\n for (const key of keys) {\r\n this._initComponent(key);\r\n }\r\n }\r\n // Model is loaded in WebXRInput\r\n }\r\n\r\n /**\r\n * Dispose this controller, the model mesh and all its components\r\n */\r\n public dispose(): void {\r\n const ids = this.getComponentIds();\r\n for (const id of ids) {\r\n this.getComponent(id).dispose();\r\n }\r\n if (this.rootMesh) {\r\n const nodes = this.rootMesh.getChildren(undefined, true);\r\n for (const node of nodes) {\r\n node.setEnabled(false);\r\n }\r\n this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache);\r\n }\r\n this.onModelLoadedObservable.clear();\r\n }\r\n\r\n /**\r\n * Returns all components of specific type\r\n * @param type the type to search for\r\n * @returns an array of components with this type\r\n */\r\n public getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[] {\r\n return this.getComponentIds()\r\n .map((id) => this.components[id])\r\n .filter((component) => component.type === type);\r\n }\r\n\r\n /**\r\n * get a component based an its component id as defined in layout.components\r\n * @param id the id of the component\r\n * @returns the component correlates to the id or undefined if not found\r\n */\r\n public getComponent(id: string): WebXRControllerComponent {\r\n return this.components[id];\r\n }\r\n\r\n /**\r\n * Get the list of components available in this motion controller\r\n * @returns an array of strings correlating to available components\r\n */\r\n public getComponentIds(): string[] {\r\n return Object.keys(this.components);\r\n }\r\n\r\n /**\r\n * Get the first component of specific type\r\n * @param type type of component to find\r\n * @returns a controller component or null if not found\r\n */\r\n public getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent> {\r\n return this.getAllComponentsOfType(type)[0] || null;\r\n }\r\n\r\n /**\r\n * Get the main (Select) component of this controller as defined in the layout\r\n * @returns the main component of this controller\r\n */\r\n public getMainComponent(): WebXRControllerComponent {\r\n return this.getComponent(this.layout.selectComponentId);\r\n }\r\n\r\n /**\r\n * Loads the model correlating to this controller\r\n * When the mesh is loaded, the onModelLoadedObservable will be triggered\r\n * @returns A promise fulfilled with the result of the model loading\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async loadModel(): Promise<boolean> {\r\n const useGeneric = !this._getModelLoadingConstraints();\r\n let loadingParams = this._getGenericFilenameAndPath();\r\n // Checking if GLB loader is present\r\n if (useGeneric) {\r\n Logger.Warn(\"Falling back to generic models\");\r\n } else {\r\n loadingParams = this._getFilenameAndPath();\r\n }\r\n return new Promise((resolve, reject) => {\r\n const meshesLoaded = (meshes: AbstractMesh[]) => {\r\n if (useGeneric) {\r\n this._getGenericParentMesh(meshes);\r\n } else {\r\n this._setRootMesh(meshes);\r\n }\r\n this._processLoadedModel(meshes);\r\n this._modelReady = true;\r\n this.onModelLoadedObservable.notifyObservers(this);\r\n resolve(true);\r\n };\r\n if (this._controllerCache) {\r\n // look for it in the cache\r\n const found = this._controllerCache.filter((c) => {\r\n return c.filename === loadingParams.filename && c.path === loadingParams.path;\r\n });\r\n if (found[0]) {\r\n for (const mesh of found[0].meshes) {\r\n mesh.setEnabled(true);\r\n }\r\n meshesLoaded(found[0].meshes);\r\n return;\r\n // found, don't continue to load\r\n }\r\n }\r\n SceneLoader.ImportMesh(\r\n \"\",\r\n loadingParams.path,\r\n loadingParams.filename,\r\n this.scene,\r\n (meshes) => {\r\n if (this._controllerCache) {\r\n this._controllerCache.push({\r\n ...loadingParams,\r\n meshes,\r\n });\r\n }\r\n meshesLoaded(meshes);\r\n },\r\n null,\r\n (_scene: Scene, message: string) => {\r\n Logger.Log(message);\r\n Logger.Warn(`Failed to retrieve controller model of type ${this.profileId} from the remote server: ${loadingParams.path}${loadingParams.filename}`);\r\n reject(message);\r\n }\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Update this model using the current XRFrame\r\n * @param xrFrame the current xr frame to use and update the model\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame): void {\r\n for (const id of this.getComponentIds()) {\r\n this.getComponent(id).update(this.gamepadObject);\r\n }\r\n this.updateModel(xrFrame);\r\n }\r\n\r\n /**\r\n * Backwards compatibility due to a deeply-integrated typo\r\n */\r\n public get handness() {\r\n return this.handedness;\r\n }\r\n\r\n /**\r\n * Pulse (vibrate) this controller\r\n * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called\r\n * Consecutive calls to this function will cancel the last pulse call\r\n *\r\n * @param value the strength of the pulse in 0.0...1.0 range\r\n * @param duration Duration of the pulse in milliseconds\r\n * @param hapticActuatorIndex optional index of actuator (will usually be 0)\r\n * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async pulse(value: number, duration: number, hapticActuatorIndex: number = 0): Promise<boolean> {\r\n if (this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[hapticActuatorIndex]) {\r\n return this.gamepadObject.hapticActuators[hapticActuatorIndex].pulse(value, duration);\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n // Look through all children recursively. This will return null if no mesh exists with the given name.\r\n protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined {\r\n return <AbstractMesh | undefined>node.getChildren((n) => n.name === name, false)[0];\r\n }\r\n\r\n // Look through only immediate children. This will return null if no mesh exists with the given name.\r\n protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined {\r\n return <AbstractMesh | undefined>node.getChildren((n) => n.name == name, true)[0];\r\n }\r\n\r\n /**\r\n * Moves the axis on the controller mesh based on its current state\r\n * @param axisMap\r\n * @param axisValue the value of the axis which determines the meshes new position\r\n * @internal\r\n */\r\n protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void {\r\n if (!axisMap.minMesh || !axisMap.maxMesh || !axisMap.valueMesh) {\r\n return;\r\n }\r\n\r\n if (!axisMap.minMesh.rotationQuaternion || !axisMap.maxMesh.rotationQuaternion || !axisMap.valueMesh.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)\r\n const lerpValue = fixValueCoordinates ? axisValue * 0.5 + 0.5 : axisValue;\r\n Quaternion.SlerpToRef(axisMap.minMesh.rotationQuaternion, axisMap.maxMesh.rotationQuaternion, lerpValue, axisMap.valueMesh.rotationQuaternion);\r\n Vector3.LerpToRef(axisMap.minMesh.position, axisMap.maxMesh.position, lerpValue, axisMap.valueMesh.position);\r\n }\r\n\r\n /**\r\n * Update the model itself with the current frame data\r\n * @param xrFrame the frame to use for updating the model mesh\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected updateModel(xrFrame: XRFrame): void {\r\n if (!this._modelReady) {\r\n return;\r\n }\r\n this._updateModel(xrFrame);\r\n }\r\n\r\n /**\r\n * Get the filename and path for this controller's model\r\n * @returns a map of filename and path\r\n */\r\n protected abstract _getFilenameAndPath(): { filename: string; path: string };\r\n /**\r\n * This function is called before the mesh is loaded. It checks for loading constraints.\r\n * For example, this function can check if the GLB loader is available\r\n * If this function returns false, the generic controller will be loaded instead\r\n * @returns Is the client ready to load the mesh\r\n */\r\n protected abstract _getModelLoadingConstraints(): boolean;\r\n /**\r\n * This function will be called after the model was successfully loaded and can be used\r\n * for mesh transformations before it is available for the user\r\n * @param meshes the loaded meshes\r\n */\r\n protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;\r\n /**\r\n * Set the root mesh for this controller. Important for the WebXR controller class\r\n * @param meshes the loaded meshes\r\n */\r\n protected abstract _setRootMesh(meshes: AbstractMesh[]): void;\r\n /**\r\n * A function executed each frame that updates the mesh (if needed)\r\n * @param xrFrame the current xrFrame\r\n */\r\n protected abstract _updateModel(xrFrame: XRFrame): void;\r\n\r\n private _getGenericFilenameAndPath(): { filename: string; path: string } {\r\n return {\r\n filename: \"generic.babylon\",\r\n path: \"https://controllers.babylonjs.com/generic/\",\r\n };\r\n }\r\n\r\n private _getGenericParentMesh(meshes: AbstractMesh[]): void {\r\n this.rootMesh = new Mesh(this.profileId + \" \" + this.handedness, this.scene);\r\n\r\n for (const mesh of meshes) {\r\n if (!mesh.parent) {\r\n mesh.isPickable = false;\r\n mesh.setParent(this.rootMesh);\r\n }\r\n }\r\n\r\n this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRAbstractMotionController.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRAbstractMotionController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAyNzC;;;;GAIG;AACH,MAAM,OAAgB,6BAA6B;IA4C/C;;;;;;;;OAQG;IACH;IACI,gEAAgE;IACtD,KAAY;IACtB,gEAAgE;IACtD,MAA+B;IACzC;;OAEG;IACI,aAA6C;IACpD;;OAEG;IACI,UAAsC;IAC7C;;;OAGG;IACI,2BAAoC,KAAK,EACxC,gBAIN;QApBQ,UAAK,GAAL,KAAK,CAAO;QAEZ,WAAM,GAAN,MAAM,CAAyB;QAIlC,kBAAa,GAAb,aAAa,CAAgC;QAI7C,eAAU,GAAV,UAAU,CA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AAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,kBAAkB,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;CACJ","sourcesContent":["import type { IDisposable, Scene } from \"../../scene\";\r\nimport { WebXRControllerComponent } from \"./webXRControllerComponent\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\n\r\n/**\r\n * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.\r\n */\r\nexport type MotionControllerHandedness = \"none\" | \"left\" | \"right\";\r\n/**\r\n * The type of components available in motion controllers.\r\n * This is not the name of the component.\r\n */\r\nexport type MotionControllerComponentType = \"trigger\" | \"squeeze\" | \"touchpad\" | \"thumbstick\" | \"button\";\r\n\r\n/**\r\n * The state of a controller component\r\n */\r\nexport type MotionControllerComponentStateType = \"default\" | \"touched\" | \"pressed\";\r\n\r\n/**\r\n * The schema of motion controller layout.\r\n * No object will be initialized using this interface\r\n * This is used just to define the profile.\r\n */\r\nexport interface IMotionControllerLayout {\r\n /**\r\n * Path to load the assets. Usually relative to the base path\r\n */\r\n assetPath: string;\r\n /**\r\n * Available components (unsorted)\r\n */\r\n components: {\r\n /**\r\n * A map of component Ids\r\n */\r\n [componentId: string]: {\r\n /**\r\n * The type of input the component outputs\r\n */\r\n type: MotionControllerComponentType;\r\n /**\r\n * The indices of this component in the gamepad object\r\n */\r\n gamepadIndices: {\r\n /**\r\n * Index of button\r\n */\r\n button?: number;\r\n /**\r\n * If available, index of x-axis\r\n */\r\n xAxis?: number;\r\n /**\r\n * If available, index of y-axis\r\n */\r\n yAxis?: number;\r\n };\r\n /**\r\n * The mesh's root node name\r\n */\r\n rootNodeName: string;\r\n /**\r\n * Animation definitions for this model\r\n */\r\n visualResponses: {\r\n [stateKey: string]: {\r\n /**\r\n * What property will be animated\r\n */\r\n componentProperty: \"xAxis\" | \"yAxis\" | \"button\" | \"state\";\r\n /**\r\n * What states influence this visual response\r\n */\r\n states: MotionControllerComponentStateType[];\r\n /**\r\n * Type of animation - movement or visibility\r\n */\r\n valueNodeProperty: \"transform\" | \"visibility\";\r\n /**\r\n * Base node name to move. Its position will be calculated according to the min and max nodes\r\n */\r\n valueNodeName?: string;\r\n /**\r\n * Minimum movement node\r\n */\r\n minNodeName?: string;\r\n /**\r\n * Max movement node\r\n */\r\n maxNodeName?: string;\r\n };\r\n };\r\n /**\r\n * If touch enabled, what is the name of node to display user feedback\r\n */\r\n touchPointNodeName?: string;\r\n };\r\n };\r\n /**\r\n * Is it xr standard mapping or not\r\n */\r\n gamepadMapping: \"\" | \"xr-standard\";\r\n /**\r\n * Base root node of this entire model\r\n */\r\n rootNodeName: string;\r\n /**\r\n * Defines the main button component id\r\n */\r\n selectComponentId: string;\r\n}\r\n\r\n/**\r\n * A definition for the layout map in the input profile\r\n */\r\nexport interface IMotionControllerLayoutMap {\r\n /**\r\n * Layouts with handedness type as a key\r\n */\r\n [handedness: string /* handedness */]: IMotionControllerLayout;\r\n}\r\n\r\n/**\r\n * The XR Input profile schema\r\n * Profiles can be found here:\r\n * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles\r\n */\r\nexport interface IMotionControllerProfile {\r\n /**\r\n * fallback profiles for this profileId\r\n */\r\n fallbackProfileIds: string[];\r\n /**\r\n * The layout map, with handedness as key\r\n */\r\n layouts: IMotionControllerLayoutMap;\r\n /**\r\n * The id of this profile\r\n * correlates to the profile(s) in the xrInput.profiles array\r\n */\r\n profileId: string;\r\n}\r\n\r\n/**\r\n * A helper-interface for the 3 meshes needed for controller button animation\r\n * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh\r\n */\r\nexport interface IMotionControllerButtonMeshMap {\r\n /**\r\n * the mesh that defines the pressed value mesh position.\r\n * This is used to find the max-position of this button\r\n */\r\n pressedMesh: AbstractMesh;\r\n /**\r\n * the mesh that defines the unpressed value mesh position.\r\n * This is used to find the min (or initial) position of this button\r\n */\r\n unpressedMesh: AbstractMesh;\r\n /**\r\n * The mesh that will be changed when value changes\r\n */\r\n valueMesh: AbstractMesh;\r\n}\r\n\r\n/**\r\n * A helper-interface for the 3 meshes needed for controller axis animation.\r\n * This will be expanded when touchpad animations are fully supported\r\n * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh\r\n */\r\nexport interface IMotionControllerMeshMap {\r\n /**\r\n * the mesh that defines the maximum value mesh position.\r\n */\r\n maxMesh?: AbstractMesh;\r\n /**\r\n * the mesh that defines the minimum value mesh position.\r\n */\r\n minMesh?: AbstractMesh;\r\n /**\r\n * The mesh that will be changed when axis value changes\r\n */\r\n valueMesh?: AbstractMesh;\r\n}\r\n\r\n/**\r\n * The elements needed for change-detection of the gamepad objects in motion controllers\r\n */\r\nexport interface IMinimalMotionControllerObject {\r\n /**\r\n * Available axes of this controller\r\n */\r\n axes: number[];\r\n /**\r\n * An array of available buttons\r\n */\r\n buttons: Array<{\r\n /**\r\n * Value of the button/trigger\r\n */\r\n value: number;\r\n /**\r\n * If the button/trigger is currently touched\r\n */\r\n touched: boolean;\r\n /**\r\n * If the button/trigger is currently pressed\r\n */\r\n pressed: boolean;\r\n }>;\r\n\r\n /**\r\n * EXPERIMENTAL haptic support.\r\n */\r\n hapticActuators?: Array<{\r\n pulse: (value: number, duration: number) => Promise<boolean>;\r\n }>;\r\n}\r\n\r\n/**\r\n * An Abstract Motion controller\r\n * This class receives an xrInput and a profile layout and uses those to initialize the components\r\n * Each component has an observable to check for changes in value and state\r\n */\r\nexport abstract class WebXRAbstractMotionController implements IDisposable {\r\n private _initComponent = (id: string) => {\r\n if (!id) {\r\n return;\r\n }\r\n const componentDef = this.layout.components[id];\r\n const type = componentDef.type;\r\n const buttonIndex = componentDef.gamepadIndices.button;\r\n // search for axes\r\n const axes: number[] = [];\r\n if (componentDef.gamepadIndices.xAxis !== undefined && componentDef.gamepadIndices.yAxis !== undefined) {\r\n axes.push(componentDef.gamepadIndices.xAxis, componentDef.gamepadIndices.yAxis);\r\n }\r\n\r\n this.components[id] = new WebXRControllerComponent(id, type, buttonIndex, axes);\r\n };\r\n\r\n private _modelReady: boolean = false;\r\n\r\n /**\r\n * A map of components (WebXRControllerComponent) in this motion controller\r\n * Components have a ComponentType and can also have both button and axis definitions\r\n */\r\n public readonly components: {\r\n [id: string]: WebXRControllerComponent;\r\n } = {};\r\n\r\n /**\r\n * Disable the model's animation. Can be set at any time.\r\n */\r\n public disableAnimation: boolean = false;\r\n /**\r\n * Observers registered here will be triggered when the model of this controller is done loading\r\n */\r\n public onModelLoadedObservable: Observable<WebXRAbstractMotionController> = new Observable();\r\n /**\r\n * The profile id of this motion controller\r\n */\r\n public abstract profileId: string;\r\n /**\r\n * The root mesh of the model. It is null if the model was not yet initialized\r\n */\r\n public rootMesh: Nullable<AbstractMesh>;\r\n\r\n /**\r\n * constructs a new abstract motion controller\r\n * @param scene the scene to which the model of the controller will be added\r\n * @param layout The profile layout to load\r\n * @param gamepadObject The gamepad object correlating to this controller\r\n * @param handedness handedness (left/right/none) of this controller\r\n * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading\r\n * @param _controllerCache a cache holding controller models already loaded in this session\r\n */\r\n constructor(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected scene: Scene,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected layout: IMotionControllerLayout,\r\n /**\r\n * The gamepad object correlating to this controller\r\n */\r\n public gamepadObject: IMinimalMotionControllerObject,\r\n /**\r\n * handedness (left/right/none) of this controller\r\n */\r\n public handedness: MotionControllerHandedness,\r\n /**\r\n * @internal\r\n * [false]\r\n */\r\n public _doNotLoadControllerMesh: boolean = false,\r\n private _controllerCache?: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n }>\r\n ) {\r\n // initialize the components\r\n if (layout.components) {\r\n const keys = Object.keys(layout.components);\r\n for (const key of keys) {\r\n this._initComponent(key);\r\n }\r\n }\r\n // Model is loaded in WebXRInput\r\n }\r\n\r\n /**\r\n * Dispose this controller, the model mesh and all its components\r\n */\r\n public dispose(): void {\r\n const ids = this.getComponentIds();\r\n for (const id of ids) {\r\n this.getComponent(id).dispose();\r\n }\r\n if (this.rootMesh) {\r\n const nodes = this.rootMesh.getChildren(undefined, true);\r\n for (const node of nodes) {\r\n node.setEnabled(false);\r\n }\r\n this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache);\r\n }\r\n this.onModelLoadedObservable.clear();\r\n }\r\n\r\n /**\r\n * Returns all components of specific type\r\n * @param type the type to search for\r\n * @returns an array of components with this type\r\n */\r\n public getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[] {\r\n return this.getComponentIds()\r\n .map((id) => this.components[id])\r\n .filter((component) => component.type === type);\r\n }\r\n\r\n /**\r\n * get a component based an its component id as defined in layout.components\r\n * @param id the id of the component\r\n * @returns the component correlates to the id or undefined if not found\r\n */\r\n public getComponent(id: string): WebXRControllerComponent {\r\n return this.components[id];\r\n }\r\n\r\n /**\r\n * Get the list of components available in this motion controller\r\n * @returns an array of strings correlating to available components\r\n */\r\n public getComponentIds(): string[] {\r\n return Object.keys(this.components);\r\n }\r\n\r\n /**\r\n * Get the first component of specific type\r\n * @param type type of component to find\r\n * @returns a controller component or null if not found\r\n */\r\n public getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent> {\r\n return this.getAllComponentsOfType(type)[0] || null;\r\n }\r\n\r\n /**\r\n * Get the main (Select) component of this controller as defined in the layout\r\n * @returns the main component of this controller\r\n */\r\n public getMainComponent(): WebXRControllerComponent {\r\n return this.getComponent(this.layout.selectComponentId);\r\n }\r\n\r\n /**\r\n * Loads the model correlating to this controller\r\n * When the mesh is loaded, the onModelLoadedObservable will be triggered\r\n * @returns A promise fulfilled with the result of the model loading\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async loadModel(): Promise<boolean> {\r\n const useGeneric = !this._getModelLoadingConstraints();\r\n let loadingParams = this._getGenericFilenameAndPath();\r\n // Checking if GLB loader is present\r\n if (useGeneric) {\r\n Logger.Warn(\"Falling back to generic models\");\r\n } else {\r\n loadingParams = this._getFilenameAndPath();\r\n }\r\n return await new Promise((resolve, reject) => {\r\n const meshesLoaded = (meshes: AbstractMesh[]) => {\r\n if (useGeneric) {\r\n this._getGenericParentMesh(meshes);\r\n } else {\r\n this._setRootMesh(meshes);\r\n }\r\n this._processLoadedModel(meshes);\r\n this._modelReady = true;\r\n this.onModelLoadedObservable.notifyObservers(this);\r\n resolve(true);\r\n };\r\n if (this._controllerCache) {\r\n // look for it in the cache\r\n const found = this._controllerCache.filter((c) => {\r\n return c.filename === loadingParams.filename && c.path === loadingParams.path;\r\n });\r\n if (found[0]) {\r\n for (const mesh of found[0].meshes) {\r\n mesh.setEnabled(true);\r\n }\r\n meshesLoaded(found[0].meshes);\r\n return;\r\n // found, don't continue to load\r\n }\r\n }\r\n SceneLoader.ImportMesh(\r\n \"\",\r\n loadingParams.path,\r\n loadingParams.filename,\r\n this.scene,\r\n (meshes) => {\r\n if (this._controllerCache) {\r\n this._controllerCache.push({\r\n ...loadingParams,\r\n meshes,\r\n });\r\n }\r\n meshesLoaded(meshes);\r\n },\r\n null,\r\n (_scene: Scene, message: string) => {\r\n Logger.Log(message);\r\n Logger.Warn(`Failed to retrieve controller model of type ${this.profileId} from the remote server: ${loadingParams.path}${loadingParams.filename}`);\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(message);\r\n }\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Update this model using the current XRFrame\r\n * @param xrFrame the current xr frame to use and update the model\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame): void {\r\n for (const id of this.getComponentIds()) {\r\n this.getComponent(id).update(this.gamepadObject);\r\n }\r\n this.updateModel(xrFrame);\r\n }\r\n\r\n /**\r\n * Backwards compatibility due to a deeply-integrated typo\r\n */\r\n public get handness() {\r\n return this.handedness;\r\n }\r\n\r\n /**\r\n * Pulse (vibrate) this controller\r\n * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called\r\n * Consecutive calls to this function will cancel the last pulse call\r\n *\r\n * @param value the strength of the pulse in 0.0...1.0 range\r\n * @param duration Duration of the pulse in milliseconds\r\n * @param hapticActuatorIndex optional index of actuator (will usually be 0)\r\n * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async pulse(value: number, duration: number, hapticActuatorIndex: number = 0): Promise<boolean> {\r\n if (this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[hapticActuatorIndex]) {\r\n return await this.gamepadObject.hapticActuators[hapticActuatorIndex].pulse(value, duration);\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n // Look through all children recursively. This will return null if no mesh exists with the given name.\r\n protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined {\r\n return <AbstractMesh | undefined>node.getChildren((n) => n.name === name, false)[0];\r\n }\r\n\r\n // Look through only immediate children. This will return null if no mesh exists with the given name.\r\n protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined {\r\n return <AbstractMesh | undefined>node.getChildren((n) => n.name == name, true)[0];\r\n }\r\n\r\n /**\r\n * Moves the axis on the controller mesh based on its current state\r\n * @param axisMap\r\n * @param axisValue the value of the axis which determines the meshes new position\r\n * @internal\r\n */\r\n protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void {\r\n if (!axisMap.minMesh || !axisMap.maxMesh || !axisMap.valueMesh) {\r\n return;\r\n }\r\n\r\n if (!axisMap.minMesh.rotationQuaternion || !axisMap.maxMesh.rotationQuaternion || !axisMap.valueMesh.rotationQuaternion) {\r\n return;\r\n }\r\n\r\n // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)\r\n const lerpValue = fixValueCoordinates ? axisValue * 0.5 + 0.5 : axisValue;\r\n Quaternion.SlerpToRef(axisMap.minMesh.rotationQuaternion, axisMap.maxMesh.rotationQuaternion, lerpValue, axisMap.valueMesh.rotationQuaternion);\r\n Vector3.LerpToRef(axisMap.minMesh.position, axisMap.maxMesh.position, lerpValue, axisMap.valueMesh.position);\r\n }\r\n\r\n /**\r\n * Update the model itself with the current frame data\r\n * @param xrFrame the frame to use for updating the model mesh\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected updateModel(xrFrame: XRFrame): void {\r\n if (!this._modelReady) {\r\n return;\r\n }\r\n this._updateModel(xrFrame);\r\n }\r\n\r\n /**\r\n * Get the filename and path for this controller's model\r\n * @returns a map of filename and path\r\n */\r\n protected abstract _getFilenameAndPath(): { filename: string; path: string };\r\n /**\r\n * This function is called before the mesh is loaded. It checks for loading constraints.\r\n * For example, this function can check if the GLB loader is available\r\n * If this function returns false, the generic controller will be loaded instead\r\n * @returns Is the client ready to load the mesh\r\n */\r\n protected abstract _getModelLoadingConstraints(): boolean;\r\n /**\r\n * This function will be called after the model was successfully loaded and can be used\r\n * for mesh transformations before it is available for the user\r\n * @param meshes the loaded meshes\r\n */\r\n protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;\r\n /**\r\n * Set the root mesh for this controller. Important for the WebXR controller class\r\n * @param meshes the loaded meshes\r\n */\r\n protected abstract _setRootMesh(meshes: AbstractMesh[]): void;\r\n /**\r\n * A function executed each frame that updates the mesh (if needed)\r\n * @param xrFrame the current xrFrame\r\n */\r\n protected abstract _updateModel(xrFrame: XRFrame): void;\r\n\r\n private _getGenericFilenameAndPath(): { filename: string; path: string } {\r\n return {\r\n filename: \"generic.babylon\",\r\n path: \"https://controllers.babylonjs.com/generic/\",\r\n };\r\n }\r\n\r\n private _getGenericParentMesh(meshes: AbstractMesh[]): void {\r\n this.rootMesh = new Mesh(this.profileId + \" \" + this.handedness, this.scene);\r\n\r\n for (const mesh of meshes) {\r\n if (!mesh.parent) {\r\n mesh.isPickable = false;\r\n mesh.setParent(this.rootMesh);\r\n }\r\n }\r\n\r\n this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0);\r\n }\r\n}\r\n"]}
|
|
@@ -97,19 +97,19 @@ export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionCon
|
|
|
97
97
|
for (let i = 0; i < ids.length; i++) {
|
|
98
98
|
const id = ids[i];
|
|
99
99
|
if (this.disableAnimation) {
|
|
100
|
-
|
|
100
|
+
continue;
|
|
101
101
|
}
|
|
102
102
|
if (id && this.rootMesh) {
|
|
103
103
|
const buttonMap = this._mapping.buttons[id];
|
|
104
104
|
const buttonMeshName = buttonMap.rootNodeName;
|
|
105
105
|
if (!buttonMeshName) {
|
|
106
106
|
Logger.Log("Skipping unknown button at index: " + i + " with mapped name: " + id);
|
|
107
|
-
|
|
107
|
+
continue;
|
|
108
108
|
}
|
|
109
109
|
const buttonMesh = this._getChildByName(this.rootMesh, buttonMeshName);
|
|
110
110
|
if (!buttonMesh) {
|
|
111
111
|
Logger.Warn("Missing button mesh with name: " + buttonMeshName);
|
|
112
|
-
|
|
112
|
+
continue;
|
|
113
113
|
}
|
|
114
114
|
buttonMap.valueMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.valueNodeName);
|
|
115
115
|
buttonMap.pressedMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.pressedNodeName);
|
|
@@ -132,18 +132,18 @@ export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionCon
|
|
|
132
132
|
for (const id of ids) {
|
|
133
133
|
const comp = this.getComponent(id);
|
|
134
134
|
if (!comp.isAxes()) {
|
|
135
|
-
|
|
135
|
+
continue;
|
|
136
136
|
}
|
|
137
137
|
const axisArray = ["x-axis", "y-axis"];
|
|
138
138
|
for (const axis of axisArray) {
|
|
139
139
|
if (!this.rootMesh) {
|
|
140
|
-
|
|
140
|
+
continue;
|
|
141
141
|
}
|
|
142
142
|
const axisMap = this._mapping.axes[id][axis];
|
|
143
143
|
const axisMesh = this._getChildByName(this.rootMesh, axisMap.rootNodeName);
|
|
144
144
|
if (!axisMesh) {
|
|
145
145
|
Logger.Warn("Missing axis mesh with name: " + axisMap.rootNodeName);
|
|
146
|
-
|
|
146
|
+
continue;
|
|
147
147
|
}
|
|
148
148
|
axisMap.valueMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.valueNodeName);
|
|
149
149
|
axisMap.minMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.minNodeName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRMicrosoftMixedRealityController.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMicrosoftMixedRealityController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,6BAA6B;IAsEnF,YAAY,KAAY,EAAE,aAA6C,EAAE,UAAsC;QAC3G,KAAK,CAAC,KAAK,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QAtE/E,gIAAgI;QAC7G,aAAQ,GAAG;YAC1B,aAAa,EAAE;gBACX,aAAa,EAAE,OAAO;gBAC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AC3D;iBACJ;gBACD,kBAAkB,EAAE,yCAAyC;aAChE;YACD,wBAAwB,EAAE;gBACtB,IAAI,EAAE,YAAY;gBAClB,cAAc,EAAE;oBACZ,MAAM,EAAE,CAAC;oBACT,KAAK,EAAE,CAAC;oBACR,KAAK,EAAE,CAAC;iBACX;gBACD,YAAY,EAAE,wBAAwB;gBACtC,eAAe,EAAE;oBACb,8BAA8B,EAAE;wBAC5B,iBAAiB,EAAE,QAAQ;wBAC3B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;wBACzC,iBAAiB,EAAE,WAAW;wBAC9B,aAAa,EAAE,sCAAsC;wBACrD,WAAW,EAAE,oCAAoC;wBACjD,WAAW,EAAE,oCAAoC;qBACpD;oBACD,oCAAoC,EAAE;wBAClC,iBAAiB,EAAE,OAAO;wBAC1B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;wBACzC,iBAAiB,EAAE,WAAW;wBAC9B,aAAa,EAAE,4CAA4C;wBAC3D,WAAW,EAAE,0CAA0C;wBACvD,WAAW,EAAE,0CAA0C;qBAC1D;oBACD,oCAAoC,EAAE;wBAClC,iBAAiB,EAAE,OAAO;wBAC1B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;wBACzC,iBAAiB,EAAE,WAAW;wBAC9B,aAAa,EAAE,4CAA4C;wBAC3D,WAAW,EAAE,0CAA0C;wBACvD,WAAW,EAAE,0CAA0C;qBAC1D;iBACJ;aACJ;SACJ;QACD,cAAc,EAAE,aAAa;QAC7B,YAAY,EAAE,+BAA+B;QAC7C,SAAS,EAAE,WAAW;KACzB;CACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IMinimalMotionControllerObject, MotionControllerHandedness, IMotionControllerLayoutMap } from \"./webXRAbstractMotionController\";\r\nimport { WebXRAbstractMotionController } from \"./webXRAbstractMotionController\";\r\nimport { WebXRMotionControllerManager } from \"./webXRMotionControllerManager\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport { Logger } from \"../../Misc/logger\";\r\n\r\n/**\r\n * The motion controller class for all microsoft mixed reality controllers\r\n */\r\nexport class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {\r\n // use this in the future - https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets/profiles/microsoft\r\n protected readonly _mapping = {\r\n defaultButton: {\r\n valueNodeName: \"VALUE\",\r\n unpressedNodeName: \"UNPRESSED\",\r\n pressedNodeName: \"PRESSED\",\r\n },\r\n defaultAxis: {\r\n valueNodeName: \"VALUE\",\r\n minNodeName: \"MIN\",\r\n maxNodeName: \"MAX\",\r\n },\r\n buttons: {\r\n \"xr-standard-trigger\": {\r\n rootNodeName: \"SELECT\",\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n },\r\n \"xr-standard-squeeze\": {\r\n rootNodeName: \"GRASP\",\r\n componentProperty: \"state\",\r\n states: [\"pressed\"],\r\n },\r\n \"xr-standard-touchpad\": {\r\n rootNodeName: \"TOUCHPAD_PRESS\",\r\n labelAnchorNodeName: \"squeeze-label\",\r\n touchPointNodeName: \"TOUCH\", // TODO - use this for visual feedback\r\n },\r\n \"xr-standard-thumbstick\": {\r\n rootNodeName: \"THUMBSTICK_PRESS\",\r\n componentProperty: \"state\",\r\n states: [\"pressed\"],\r\n },\r\n },\r\n axes: {\r\n \"xr-standard-touchpad\": {\r\n \"x-axis\": {\r\n rootNodeName: \"TOUCHPAD_TOUCH_X\",\r\n },\r\n \"y-axis\": {\r\n rootNodeName: \"TOUCHPAD_TOUCH_Y\",\r\n },\r\n },\r\n \"xr-standard-thumbstick\": {\r\n \"x-axis\": {\r\n rootNodeName: \"THUMBSTICK_X\",\r\n },\r\n \"y-axis\": {\r\n rootNodeName: \"THUMBSTICK_Y\",\r\n },\r\n },\r\n },\r\n };\r\n\r\n /**\r\n * The base url used to load the left and right controller models\r\n */\r\n public static MODEL_BASE_URL: string = \"https://controllers.babylonjs.com/microsoft/\";\r\n /**\r\n * The name of the left controller model file\r\n */\r\n public static MODEL_LEFT_FILENAME: string = \"left.glb\";\r\n /**\r\n * The name of the right controller model file\r\n */\r\n public static MODEL_RIGHT_FILENAME: string = \"right.glb\";\r\n\r\n public profileId = \"microsoft-mixed-reality\";\r\n\r\n constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness) {\r\n super(scene, MixedRealityProfile[\"left-right\"], gamepadObject, handedness);\r\n }\r\n\r\n protected _getFilenameAndPath(): { filename: string; path: string } {\r\n let filename = \"\";\r\n if (this.handedness === \"left\") {\r\n filename = WebXRMicrosoftMixedRealityController.MODEL_LEFT_FILENAME;\r\n } else {\r\n // Right is the default if no hand is specified\r\n filename = WebXRMicrosoftMixedRealityController.MODEL_RIGHT_FILENAME;\r\n }\r\n\r\n const device = \"default\";\r\n const path = WebXRMicrosoftMixedRealityController.MODEL_BASE_URL + device + \"/\";\r\n return {\r\n filename,\r\n path,\r\n };\r\n }\r\n\r\n protected _getModelLoadingConstraints(): boolean {\r\n const glbLoaded = SceneLoader.IsPluginForExtensionAvailable(\".glb\");\r\n if (!glbLoaded) {\r\n Logger.Warn(\"glTF / glb loaded was not registered, using generic controller instead\");\r\n }\r\n return glbLoaded;\r\n }\r\n\r\n protected _processLoadedModel(_meshes: AbstractMesh[]): void {\r\n if (!this.rootMesh) {\r\n return;\r\n }\r\n\r\n // Button Meshes\r\n const ids = this.getComponentIds();\r\n for (let i = 0; i < ids.length; i++) {\r\n const id = ids[i];\r\n if (this.disableAnimation) {\r\n return;\r\n }\r\n if (id && this.rootMesh) {\r\n const buttonMap = (<any>this._mapping.buttons)[id];\r\n const buttonMeshName = buttonMap.rootNodeName;\r\n if (!buttonMeshName) {\r\n Logger.Log(\"Skipping unknown button at index: \" + i + \" with mapped name: \" + id);\r\n return;\r\n }\r\n\r\n const buttonMesh = this._getChildByName(this.rootMesh, buttonMeshName);\r\n if (!buttonMesh) {\r\n Logger.Warn(\"Missing button mesh with name: \" + buttonMeshName);\r\n return;\r\n }\r\n\r\n buttonMap.valueMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.valueNodeName);\r\n buttonMap.pressedMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.pressedNodeName);\r\n buttonMap.unpressedMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.unpressedNodeName);\r\n\r\n if (buttonMap.valueMesh && buttonMap.pressedMesh && buttonMap.unpressedMesh) {\r\n const comp = this.getComponent(id);\r\n if (comp) {\r\n comp.onButtonStateChangedObservable.add(\r\n (component) => {\r\n this._lerpTransform(buttonMap, component.value);\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n } else {\r\n // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.\r\n Logger.Warn(\"Missing button submesh under mesh with name: \" + buttonMeshName);\r\n }\r\n }\r\n }\r\n\r\n // Axis Meshes\r\n for (const id of ids) {\r\n const comp = this.getComponent(id);\r\n if (!comp.isAxes()) {\r\n return;\r\n }\r\n\r\n const axisArray = [\"x-axis\", \"y-axis\"];\r\n\r\n for (const axis of axisArray) {\r\n if (!this.rootMesh) {\r\n return;\r\n }\r\n const axisMap = (<any>this._mapping.axes)[id][axis];\r\n\r\n const axisMesh = this._getChildByName(this.rootMesh, axisMap.rootNodeName);\r\n if (!axisMesh) {\r\n Logger.Warn(\"Missing axis mesh with name: \" + axisMap.rootNodeName);\r\n return;\r\n }\r\n\r\n axisMap.valueMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.valueNodeName);\r\n axisMap.minMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.minNodeName);\r\n axisMap.maxMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.maxNodeName);\r\n\r\n if (axisMap.valueMesh && axisMap.minMesh && axisMap.maxMesh) {\r\n if (comp) {\r\n comp.onAxisValueChangedObservable.add(\r\n (axisValues) => {\r\n const value = axis === \"x-axis\" ? axisValues.x : axisValues.y;\r\n this._lerpTransform(axisMap, value, true);\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n } else {\r\n // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.\r\n Logger.Warn(\"Missing axis submesh under mesh with name: \" + axisMap.rootNodeName);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _setRootMesh(meshes: AbstractMesh[]): void {\r\n this.rootMesh = new Mesh(this.profileId + \" \" + this.handedness, this.scene);\r\n this.rootMesh.isPickable = false;\r\n let rootMesh;\r\n // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'\r\n for (let i = 0; i < meshes.length; i++) {\r\n const mesh = meshes[i];\r\n\r\n mesh.isPickable = false;\r\n\r\n if (!mesh.parent) {\r\n // Handle root node, attach to the new parentMesh\r\n rootMesh = mesh;\r\n }\r\n }\r\n\r\n if (rootMesh) {\r\n rootMesh.setParent(this.rootMesh);\r\n }\r\n\r\n if (!this.scene.useRightHandedSystem) {\r\n this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0);\r\n }\r\n }\r\n\r\n protected _updateModel(): void {\r\n // no-op. model is updated using observables.\r\n }\r\n}\r\n\r\n// register the profile\r\nWebXRMotionControllerManager.RegisterController(\"windows-mixed-reality\", (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRMicrosoftMixedRealityController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/microsoft/microsoft-mixed-reality.json\r\nconst MixedRealityProfile: IMotionControllerLayoutMap = {\r\n left: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr_standard_trigger\",\r\n visualResponses: {\r\n xr_standard_trigger_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_trigger_pressed_value\",\r\n minNodeName: \"xr_standard_trigger_pressed_min\",\r\n maxNodeName: \"xr_standard_trigger_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-squeeze\": {\r\n type: \"squeeze\",\r\n gamepadIndices: {\r\n button: 1,\r\n },\r\n rootNodeName: \"xr_standard_squeeze\",\r\n visualResponses: {\r\n xr_standard_squeeze_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_squeeze_pressed_value\",\r\n minNodeName: \"xr_standard_squeeze_pressed_min\",\r\n maxNodeName: \"xr_standard_squeeze_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-touchpad\": {\r\n type: \"touchpad\",\r\n gamepadIndices: {\r\n button: 2,\r\n xAxis: 0,\r\n yAxis: 1,\r\n },\r\n rootNodeName: \"xr_standard_touchpad\",\r\n visualResponses: {\r\n xr_standard_touchpad_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_touched: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_yaxis_touched: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_axes_touched: {\r\n componentProperty: \"state\",\r\n states: [\"touched\", \"pressed\"],\r\n valueNodeProperty: \"visibility\",\r\n valueNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n },\r\n touchPointNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n \"xr-standard-thumbstick\": {\r\n type: \"thumbstick\",\r\n gamepadIndices: {\r\n button: 3,\r\n xAxis: 2,\r\n yAxis: 3,\r\n },\r\n rootNodeName: \"xr_standard_thumbstick\",\r\n visualResponses: {\r\n xr_standard_thumbstick_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_pressed_max\",\r\n },\r\n xr_standard_thumbstick_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_xaxis_pressed_max\",\r\n },\r\n xr_standard_thumbstick_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_yaxis_pressed_max\",\r\n },\r\n },\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"microsoft-mixed-reality-left\",\r\n assetPath: \"left.glb\",\r\n },\r\n right: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr_standard_trigger\",\r\n visualResponses: {\r\n xr_standard_trigger_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_trigger_pressed_value\",\r\n minNodeName: \"xr_standard_trigger_pressed_min\",\r\n maxNodeName: \"xr_standard_trigger_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-squeeze\": {\r\n type: \"squeeze\",\r\n gamepadIndices: {\r\n button: 1,\r\n },\r\n rootNodeName: \"xr_standard_squeeze\",\r\n visualResponses: {\r\n xr_standard_squeeze_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_squeeze_pressed_value\",\r\n minNodeName: \"xr_standard_squeeze_pressed_min\",\r\n maxNodeName: \"xr_standard_squeeze_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-touchpad\": {\r\n type: \"touchpad\",\r\n gamepadIndices: {\r\n button: 2,\r\n xAxis: 0,\r\n yAxis: 1,\r\n },\r\n rootNodeName: \"xr_standard_touchpad\",\r\n visualResponses: {\r\n xr_standard_touchpad_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_touched: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_yaxis_touched: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_axes_touched: {\r\n componentProperty: \"state\",\r\n states: [\"touched\", \"pressed\"],\r\n valueNodeProperty: \"visibility\",\r\n valueNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n },\r\n touchPointNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n \"xr-standard-thumbstick\": {\r\n type: \"thumbstick\",\r\n gamepadIndices: {\r\n button: 3,\r\n xAxis: 2,\r\n yAxis: 3,\r\n },\r\n rootNodeName: \"xr_standard_thumbstick\",\r\n visualResponses: {\r\n xr_standard_thumbstick_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_pressed_max\",\r\n },\r\n xr_standard_thumbstick_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_xaxis_pressed_max\",\r\n },\r\n xr_standard_thumbstick_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_yaxis_pressed_max\",\r\n },\r\n },\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"microsoft-mixed-reality-right\",\r\n assetPath: \"right.glb\",\r\n },\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRMicrosoftMixedRealityController.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMicrosoftMixedRealityController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,6BAA6B;IAsEnF,YAAY,KAAY,EAAE,aAA6C,EAAE,UAAsC;QAC3G,KAAK,CAAC,KAAK,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QAtE/E,gIAAgI;QAC7G,aAAQ,GAAG;YAC1B,aAAa,EAAE;gBACX,aAAa,EAAE,OAAO;gBACtB,iBAAiB,EAAE,WAAW;gBAC9B,eAAe,EAAE,SAAS;aAC7B;YACD,WAAW,EAAE;gBACT,aAAa,EAAE,OAAO;gBACtB,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,KAAK;aACrB;YACD,OAAO,EAAE;gBACL,qBAAqB,EAAE;oBACnB,YAAY,EAAE,QAAQ;oBACtB,iBAAiB,EAAE,QAAQ;oBAC3B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;iBAC5C;gBACD,qBAAqB,EAAE;oBACnB,YAAY,EAAE,OAAO;oBACr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E,WAAW;wBAC9B,aAAa,EAAE,sCAAsC;wBACrD,WAAW,EAAE,oCAAoC;wBACjD,WAAW,EAAE,oCAAoC;qBACpD;oBACD,oCAAoC,EAAE;wBAClC,iBAAiB,EAAE,OAAO;wBAC1B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;wBACzC,iBAAiB,EAAE,WAAW;wBAC9B,aAAa,EAAE,4CAA4C;wBAC3D,WAAW,EAAE,0CAA0C;wBACvD,WAAW,EAAE,0CAA0C;qBAC1D;oBACD,oCAAoC,EAAE;wBAClC,iBAAiB,EAAE,OAAO;wBAC1B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;wBACzC,iBAAiB,EAAE,WAAW;wBAC9B,aAAa,EAAE,4CAA4C;wBAC3D,WAAW,EAAE,0CAA0C;wBACvD,WAAW,EAAE,0CAA0C;qBAC1D;iBACJ;aACJ;SACJ;QACD,cAAc,EAAE,aAAa;QAC7B,YAAY,EAAE,+BAA+B;QAC7C,SAAS,EAAE,WAAW;KACzB;CACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IMinimalMotionControllerObject, MotionControllerHandedness, IMotionControllerLayoutMap } from \"./webXRAbstractMotionController\";\r\nimport { WebXRAbstractMotionController } from \"./webXRAbstractMotionController\";\r\nimport { WebXRMotionControllerManager } from \"./webXRMotionControllerManager\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport { Logger } from \"../../Misc/logger\";\r\n\r\n/**\r\n * The motion controller class for all microsoft mixed reality controllers\r\n */\r\nexport class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {\r\n // use this in the future - https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets/profiles/microsoft\r\n protected readonly _mapping = {\r\n defaultButton: {\r\n valueNodeName: \"VALUE\",\r\n unpressedNodeName: \"UNPRESSED\",\r\n pressedNodeName: \"PRESSED\",\r\n },\r\n defaultAxis: {\r\n valueNodeName: \"VALUE\",\r\n minNodeName: \"MIN\",\r\n maxNodeName: \"MAX\",\r\n },\r\n buttons: {\r\n \"xr-standard-trigger\": {\r\n rootNodeName: \"SELECT\",\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n },\r\n \"xr-standard-squeeze\": {\r\n rootNodeName: \"GRASP\",\r\n componentProperty: \"state\",\r\n states: [\"pressed\"],\r\n },\r\n \"xr-standard-touchpad\": {\r\n rootNodeName: \"TOUCHPAD_PRESS\",\r\n labelAnchorNodeName: \"squeeze-label\",\r\n touchPointNodeName: \"TOUCH\", // TODO - use this for visual feedback\r\n },\r\n \"xr-standard-thumbstick\": {\r\n rootNodeName: \"THUMBSTICK_PRESS\",\r\n componentProperty: \"state\",\r\n states: [\"pressed\"],\r\n },\r\n },\r\n axes: {\r\n \"xr-standard-touchpad\": {\r\n \"x-axis\": {\r\n rootNodeName: \"TOUCHPAD_TOUCH_X\",\r\n },\r\n \"y-axis\": {\r\n rootNodeName: \"TOUCHPAD_TOUCH_Y\",\r\n },\r\n },\r\n \"xr-standard-thumbstick\": {\r\n \"x-axis\": {\r\n rootNodeName: \"THUMBSTICK_X\",\r\n },\r\n \"y-axis\": {\r\n rootNodeName: \"THUMBSTICK_Y\",\r\n },\r\n },\r\n },\r\n };\r\n\r\n /**\r\n * The base url used to load the left and right controller models\r\n */\r\n public static MODEL_BASE_URL: string = \"https://controllers.babylonjs.com/microsoft/\";\r\n /**\r\n * The name of the left controller model file\r\n */\r\n public static MODEL_LEFT_FILENAME: string = \"left.glb\";\r\n /**\r\n * The name of the right controller model file\r\n */\r\n public static MODEL_RIGHT_FILENAME: string = \"right.glb\";\r\n\r\n public profileId = \"microsoft-mixed-reality\";\r\n\r\n constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness) {\r\n super(scene, MixedRealityProfile[\"left-right\"], gamepadObject, handedness);\r\n }\r\n\r\n protected _getFilenameAndPath(): { filename: string; path: string } {\r\n let filename = \"\";\r\n if (this.handedness === \"left\") {\r\n filename = WebXRMicrosoftMixedRealityController.MODEL_LEFT_FILENAME;\r\n } else {\r\n // Right is the default if no hand is specified\r\n filename = WebXRMicrosoftMixedRealityController.MODEL_RIGHT_FILENAME;\r\n }\r\n\r\n const device = \"default\";\r\n const path = WebXRMicrosoftMixedRealityController.MODEL_BASE_URL + device + \"/\";\r\n return {\r\n filename,\r\n path,\r\n };\r\n }\r\n\r\n protected _getModelLoadingConstraints(): boolean {\r\n const glbLoaded = SceneLoader.IsPluginForExtensionAvailable(\".glb\");\r\n if (!glbLoaded) {\r\n Logger.Warn(\"glTF / glb loaded was not registered, using generic controller instead\");\r\n }\r\n return glbLoaded;\r\n }\r\n\r\n protected _processLoadedModel(_meshes: AbstractMesh[]): void {\r\n if (!this.rootMesh) {\r\n return;\r\n }\r\n\r\n // Button Meshes\r\n const ids = this.getComponentIds();\r\n for (let i = 0; i < ids.length; i++) {\r\n const id = ids[i];\r\n if (this.disableAnimation) {\r\n continue;\r\n }\r\n if (id && this.rootMesh) {\r\n const buttonMap = (<any>this._mapping.buttons)[id];\r\n const buttonMeshName = buttonMap.rootNodeName;\r\n if (!buttonMeshName) {\r\n Logger.Log(\"Skipping unknown button at index: \" + i + \" with mapped name: \" + id);\r\n continue;\r\n }\r\n\r\n const buttonMesh = this._getChildByName(this.rootMesh, buttonMeshName);\r\n if (!buttonMesh) {\r\n Logger.Warn(\"Missing button mesh with name: \" + buttonMeshName);\r\n continue;\r\n }\r\n\r\n buttonMap.valueMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.valueNodeName);\r\n buttonMap.pressedMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.pressedNodeName);\r\n buttonMap.unpressedMesh = this._getImmediateChildByName(buttonMesh, this._mapping.defaultButton.unpressedNodeName);\r\n\r\n if (buttonMap.valueMesh && buttonMap.pressedMesh && buttonMap.unpressedMesh) {\r\n const comp = this.getComponent(id);\r\n if (comp) {\r\n comp.onButtonStateChangedObservable.add(\r\n (component) => {\r\n this._lerpTransform(buttonMap, component.value);\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n } else {\r\n // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.\r\n Logger.Warn(\"Missing button submesh under mesh with name: \" + buttonMeshName);\r\n }\r\n }\r\n }\r\n\r\n // Axis Meshes\r\n for (const id of ids) {\r\n const comp = this.getComponent(id);\r\n if (!comp.isAxes()) {\r\n continue;\r\n }\r\n\r\n const axisArray = [\"x-axis\", \"y-axis\"];\r\n\r\n for (const axis of axisArray) {\r\n if (!this.rootMesh) {\r\n continue;\r\n }\r\n const axisMap = (<any>this._mapping.axes)[id][axis];\r\n\r\n const axisMesh = this._getChildByName(this.rootMesh, axisMap.rootNodeName);\r\n if (!axisMesh) {\r\n Logger.Warn(\"Missing axis mesh with name: \" + axisMap.rootNodeName);\r\n continue;\r\n }\r\n\r\n axisMap.valueMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.valueNodeName);\r\n axisMap.minMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.minNodeName);\r\n axisMap.maxMesh = this._getImmediateChildByName(axisMesh, this._mapping.defaultAxis.maxNodeName);\r\n\r\n if (axisMap.valueMesh && axisMap.minMesh && axisMap.maxMesh) {\r\n if (comp) {\r\n comp.onAxisValueChangedObservable.add(\r\n (axisValues) => {\r\n const value = axis === \"x-axis\" ? axisValues.x : axisValues.y;\r\n this._lerpTransform(axisMap, value, true);\r\n },\r\n undefined,\r\n true\r\n );\r\n }\r\n } else {\r\n // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.\r\n Logger.Warn(\"Missing axis submesh under mesh with name: \" + axisMap.rootNodeName);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _setRootMesh(meshes: AbstractMesh[]): void {\r\n this.rootMesh = new Mesh(this.profileId + \" \" + this.handedness, this.scene);\r\n this.rootMesh.isPickable = false;\r\n let rootMesh;\r\n // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'\r\n for (let i = 0; i < meshes.length; i++) {\r\n const mesh = meshes[i];\r\n\r\n mesh.isPickable = false;\r\n\r\n if (!mesh.parent) {\r\n // Handle root node, attach to the new parentMesh\r\n rootMesh = mesh;\r\n }\r\n }\r\n\r\n if (rootMesh) {\r\n rootMesh.setParent(this.rootMesh);\r\n }\r\n\r\n if (!this.scene.useRightHandedSystem) {\r\n this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0);\r\n }\r\n }\r\n\r\n protected _updateModel(): void {\r\n // no-op. model is updated using observables.\r\n }\r\n}\r\n\r\n// register the profile\r\nWebXRMotionControllerManager.RegisterController(\"windows-mixed-reality\", (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRMicrosoftMixedRealityController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/microsoft/microsoft-mixed-reality.json\r\nconst MixedRealityProfile: IMotionControllerLayoutMap = {\r\n left: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr_standard_trigger\",\r\n visualResponses: {\r\n xr_standard_trigger_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_trigger_pressed_value\",\r\n minNodeName: \"xr_standard_trigger_pressed_min\",\r\n maxNodeName: \"xr_standard_trigger_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-squeeze\": {\r\n type: \"squeeze\",\r\n gamepadIndices: {\r\n button: 1,\r\n },\r\n rootNodeName: \"xr_standard_squeeze\",\r\n visualResponses: {\r\n xr_standard_squeeze_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_squeeze_pressed_value\",\r\n minNodeName: \"xr_standard_squeeze_pressed_min\",\r\n maxNodeName: \"xr_standard_squeeze_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-touchpad\": {\r\n type: \"touchpad\",\r\n gamepadIndices: {\r\n button: 2,\r\n xAxis: 0,\r\n yAxis: 1,\r\n },\r\n rootNodeName: \"xr_standard_touchpad\",\r\n visualResponses: {\r\n xr_standard_touchpad_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_touched: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_yaxis_touched: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_axes_touched: {\r\n componentProperty: \"state\",\r\n states: [\"touched\", \"pressed\"],\r\n valueNodeProperty: \"visibility\",\r\n valueNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n },\r\n touchPointNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n \"xr-standard-thumbstick\": {\r\n type: \"thumbstick\",\r\n gamepadIndices: {\r\n button: 3,\r\n xAxis: 2,\r\n yAxis: 3,\r\n },\r\n rootNodeName: \"xr_standard_thumbstick\",\r\n visualResponses: {\r\n xr_standard_thumbstick_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_pressed_max\",\r\n },\r\n xr_standard_thumbstick_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_xaxis_pressed_max\",\r\n },\r\n xr_standard_thumbstick_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_yaxis_pressed_max\",\r\n },\r\n },\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"microsoft-mixed-reality-left\",\r\n assetPath: \"left.glb\",\r\n },\r\n right: {\r\n selectComponentId: \"xr-standard-trigger\",\r\n components: {\r\n \"xr-standard-trigger\": {\r\n type: \"trigger\",\r\n gamepadIndices: {\r\n button: 0,\r\n },\r\n rootNodeName: \"xr_standard_trigger\",\r\n visualResponses: {\r\n xr_standard_trigger_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_trigger_pressed_value\",\r\n minNodeName: \"xr_standard_trigger_pressed_min\",\r\n maxNodeName: \"xr_standard_trigger_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-squeeze\": {\r\n type: \"squeeze\",\r\n gamepadIndices: {\r\n button: 1,\r\n },\r\n rootNodeName: \"xr_standard_squeeze\",\r\n visualResponses: {\r\n xr_standard_squeeze_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_squeeze_pressed_value\",\r\n minNodeName: \"xr_standard_squeeze_pressed_min\",\r\n maxNodeName: \"xr_standard_squeeze_pressed_max\",\r\n },\r\n },\r\n },\r\n \"xr-standard-touchpad\": {\r\n type: \"touchpad\",\r\n gamepadIndices: {\r\n button: 2,\r\n xAxis: 0,\r\n yAxis: 1,\r\n },\r\n rootNodeName: \"xr_standard_touchpad\",\r\n visualResponses: {\r\n xr_standard_touchpad_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_pressed_max\",\r\n },\r\n xr_standard_touchpad_xaxis_touched: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_xaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_xaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_xaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_yaxis_touched: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_touchpad_yaxis_touched_value\",\r\n minNodeName: \"xr_standard_touchpad_yaxis_touched_min\",\r\n maxNodeName: \"xr_standard_touchpad_yaxis_touched_max\",\r\n },\r\n xr_standard_touchpad_axes_touched: {\r\n componentProperty: \"state\",\r\n states: [\"touched\", \"pressed\"],\r\n valueNodeProperty: \"visibility\",\r\n valueNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n },\r\n touchPointNodeName: \"xr_standard_touchpad_axes_touched_value\",\r\n },\r\n \"xr-standard-thumbstick\": {\r\n type: \"thumbstick\",\r\n gamepadIndices: {\r\n button: 3,\r\n xAxis: 2,\r\n yAxis: 3,\r\n },\r\n rootNodeName: \"xr_standard_thumbstick\",\r\n visualResponses: {\r\n xr_standard_thumbstick_pressed: {\r\n componentProperty: \"button\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_pressed_max\",\r\n },\r\n xr_standard_thumbstick_xaxis_pressed: {\r\n componentProperty: \"xAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_xaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_xaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_xaxis_pressed_max\",\r\n },\r\n xr_standard_thumbstick_yaxis_pressed: {\r\n componentProperty: \"yAxis\",\r\n states: [\"default\", \"touched\", \"pressed\"],\r\n valueNodeProperty: \"transform\",\r\n valueNodeName: \"xr_standard_thumbstick_yaxis_pressed_value\",\r\n minNodeName: \"xr_standard_thumbstick_yaxis_pressed_min\",\r\n maxNodeName: \"xr_standard_thumbstick_yaxis_pressed_max\",\r\n },\r\n },\r\n },\r\n },\r\n gamepadMapping: \"xr-standard\",\r\n rootNodeName: \"microsoft-mixed-reality-right\",\r\n assetPath: \"right.glb\",\r\n },\r\n};\r\n"]}
|
|
@@ -96,13 +96,14 @@ export class WebXRMotionControllerManager {
|
|
|
96
96
|
if (this.UseOnlineRepository) {
|
|
97
97
|
const firstFunction = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepositoryAsync : this._LoadProfilesFromAvailableControllersAsync;
|
|
98
98
|
const secondFunction = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllersAsync : this._LoadProfileFromRepositoryAsync;
|
|
99
|
+
// eslint-disable-next-line github/no-then
|
|
99
100
|
return firstFunction.call(this, profileArray, xrInput, scene).catch(() => {
|
|
100
101
|
return secondFunction.call(this, profileArray, xrInput, scene);
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
104
105
|
// use only available functions
|
|
105
|
-
return this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);
|
|
106
|
+
return await this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
@@ -135,10 +136,9 @@ export class WebXRMotionControllerManager {
|
|
|
135
136
|
*/
|
|
136
137
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
137
138
|
static async UpdateProfilesList() {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return this._ProfilesList;
|
|
139
|
+
const data = await Tools.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", false);
|
|
140
|
+
this._ProfilesList = JSON.parse(data);
|
|
141
|
+
return await this._ProfilesList;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Clear the controller's cache (usually happens at the end of a session)
|
|
@@ -152,15 +152,17 @@ export class WebXRMotionControllerManager {
|
|
|
152
152
|
ControllerCache.length = 0;
|
|
153
153
|
}
|
|
154
154
|
static async _LoadProfileFromRepositoryAsync(profileArray, xrInput, scene) {
|
|
155
|
-
return Promise.resolve()
|
|
155
|
+
return await Promise.resolve()
|
|
156
|
+
// eslint-disable-next-line github/no-then
|
|
156
157
|
.then(async () => {
|
|
157
158
|
if (!this._ProfilesList) {
|
|
158
|
-
return this.UpdateProfilesList();
|
|
159
|
+
return await this.UpdateProfilesList();
|
|
159
160
|
}
|
|
160
161
|
else {
|
|
161
|
-
return this._ProfilesList;
|
|
162
|
+
return await this._ProfilesList;
|
|
162
163
|
}
|
|
163
164
|
})
|
|
165
|
+
// eslint-disable-next-line github/no-then
|
|
164
166
|
.then((profilesList) => {
|
|
165
167
|
// load the right profile
|
|
166
168
|
for (let i = 0; i < profileArray.length; ++i) {
|
|
@@ -174,13 +176,17 @@ export class WebXRMotionControllerManager {
|
|
|
174
176
|
}
|
|
175
177
|
throw new Error(`neither controller ${profileArray[0]} nor all fallbacks were found in the repository,`);
|
|
176
178
|
})
|
|
179
|
+
// eslint-disable-next-line github/no-then
|
|
177
180
|
.then(async (profileToLoad) => {
|
|
178
181
|
// load the profile
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
179
183
|
if (!this._ProfileLoadingPromises[profileToLoad]) {
|
|
184
|
+
// eslint-disable-next-line github/no-then
|
|
180
185
|
this._ProfileLoadingPromises[profileToLoad] = Tools.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${profileToLoad}/profile.json`, false).then((data) => JSON.parse(data));
|
|
181
186
|
}
|
|
182
|
-
return this._ProfileLoadingPromises[profileToLoad];
|
|
187
|
+
return await this._ProfileLoadingPromises[profileToLoad];
|
|
183
188
|
})
|
|
189
|
+
// eslint-disable-next-line github/no-then
|
|
184
190
|
.then((profile) => {
|
|
185
191
|
return new WebXRProfiledMotionController(scene, xrInput, profile, this.BaseRepositoryUrl, this.DisableControllerCache ? undefined : ControllerCache);
|
|
186
192
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRMotionControllerManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMotionControllerManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAShF;;;;;;;GAOG;AAEH,MAAM,eAAe,GAIhB,EAAE,CAAC;AAER;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IA0B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AAC,EAAE,CAAC;YAC3C,YAAY;YACZ,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnB,SAAS;YACb,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBACxC,MAAM,oBAAoB,GAAG,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtE,IAAI,oBAAoB,EAAE,CAAC;oBACvB,OAAO,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAChD,CAAC;YACL,CAAC;QACL,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;;AApOc,kDAAqB,GAAoD,EAAE,CAAC;AAC5E,uCAAU,GAAsC,EAAE,CAAC;AAClE,oBAAoB;AACL,oDAAuB,GAAiE,EAAE,CAAC;AAG1G;;GAEG;AACW,8CAAiB,GAAG,2EAA2E,CAAC;AAC9G;;GAEG;AACW,uDAA0B,GAAY,IAAI,CAAC;AACzD;;GAEG;AACW,gDAAmB,GAAY,IAAI,CAAC;AAElD;;;GAGG;AACW,mDAAsB,GAAY,IAAI,CAAC;AAgNzD,qEAAqE;AACrE,4BAA4B,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,SAAS,EAAE,CAAC,OAAsB,EAAE,KAAY,EAAE,EAAE;IACpI,OAAO,IAAI,mCAAmC,CAAC,KAAK,EAAO,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACpG,CAAC,CAAC,CAAC;AAEH,qBAAqB;AACrB,4BAA4B,CAAC,gBAAgB,EAAE,CAAC","sourcesContent":["import type { WebXRAbstractMotionController, IMotionControllerProfile } from \"./webXRAbstractMotionController\";\r\nimport { WebXRGenericTriggerMotionController } from \"./webXRGenericMotionController\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { WebXRProfiledMotionController } from \"./webXRProfiledMotionController\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\n\r\n/**\r\n * A construction function type to create a new controller based on an xrInput object\r\n */\r\nexport type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;\r\n\r\n/**\r\n * The MotionController Manager manages all registered motion controllers and loads the right one when needed.\r\n *\r\n * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets\r\n * it should be replaced with auto-loaded controllers.\r\n *\r\n * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes\r\n */\r\n\r\nconst ControllerCache: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n}> = [];\r\n\r\n/**\r\n * Motion controller manager is managing the different webxr profiles and makes sure the right\r\n * controller is being loaded.\r\n */\r\nexport class WebXRMotionControllerManager {\r\n private static _AvailableControllers: { [type: string]: MotionControllerConstructor } = {};\r\n private static _Fallbacks: { [profileId: string]: string[] } = {};\r\n // cache for loading\r\n private static _ProfileLoadingPromises: { [profileName: string]: Promise<IMotionControllerProfile> } = {};\r\n private static _ProfilesList: Nullable<Promise<{ [profile: string]: string }>>;\r\n\r\n /**\r\n * The base URL of the online controller repository. Can be changed at any time.\r\n */\r\n public static BaseRepositoryUrl = \"https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist\";\r\n /**\r\n * Which repository gets priority - local or online\r\n */\r\n public static PrioritizeOnlineRepository: boolean = true;\r\n /**\r\n * Use the online repository, or use only locally-defined controllers\r\n */\r\n public static UseOnlineRepository: boolean = true;\r\n\r\n /**\r\n * Disable the controller cache and load the models each time a new WebXRProfileMotionController is loaded.\r\n * Defaults to true.\r\n */\r\n public static DisableControllerCache: boolean = true;\r\n\r\n /**\r\n * Clear the cache used for profile loading and reload when requested again\r\n */\r\n public static ClearProfilesCache() {\r\n this._ProfilesList = null;\r\n this._ProfileLoadingPromises = {};\r\n }\r\n\r\n /**\r\n * Register the default fallbacks.\r\n * This function is called automatically when this file is imported.\r\n */\r\n public static DefaultFallbacks() {\r\n this.RegisterFallbacksForProfileId(\"google-daydream\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive-focus\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"magicleap-one\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"windows-mixed-reality\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"microsoft-mixed-reality\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-go\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch-v2\", [\"oculus-touch\", \"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch\", [\"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-gearvr\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-odyssey\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"valve-index\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"generic-hand-select\", [\"generic-trigger\"]);\r\n }\r\n\r\n /**\r\n * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.\r\n * @param profileId the profile to which a fallback needs to be found\r\n * @returns an array with corresponding fallback profiles\r\n */\r\n public static FindFallbackWithProfileId(profileId: string): string[] {\r\n const returnArray = this._Fallbacks[profileId] || [];\r\n\r\n returnArray.unshift(profileId);\r\n return returnArray;\r\n }\r\n\r\n /**\r\n * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.\r\n * The order of search:\r\n *\r\n * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller\r\n * 2) (If not found) search in the gamepad id and try using it (legacy versions only)\r\n * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)\r\n * 4) return the generic trigger controller if none were found\r\n *\r\n * @param xrInput the xrInput to which a new controller is initialized\r\n * @param scene the scene to which the model will be added\r\n * @param forceProfile force a certain profile for this controller\r\n * @returns A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found\r\n */\r\n public static async GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController> {\r\n const profileArray: string[] = [];\r\n if (forceProfile) {\r\n profileArray.push(forceProfile);\r\n }\r\n profileArray.push(...(xrInput.profiles || []));\r\n\r\n // emulator support\r\n if (profileArray.length && !profileArray[0]) {\r\n // remove the first \"undefined\" that the emulator is adding\r\n profileArray.pop();\r\n }\r\n\r\n // legacy support - try using the gamepad id\r\n if (xrInput.gamepad && xrInput.gamepad.id) {\r\n switch (xrInput.gamepad.id) {\r\n case xrInput.gamepad.id.match(/oculus touch/gi) ? xrInput.gamepad.id : undefined:\r\n // oculus in gamepad id\r\n profileArray.push(\"oculus-touch-v2\");\r\n break;\r\n }\r\n }\r\n\r\n // make sure microsoft/windows mixed reality works correctly\r\n const windowsMRIdx = profileArray.indexOf(\"windows-mixed-reality\");\r\n if (windowsMRIdx !== -1) {\r\n profileArray.splice(windowsMRIdx, 0, \"microsoft-mixed-reality\");\r\n }\r\n\r\n if (!profileArray.length) {\r\n profileArray.push(\"generic-trigger\");\r\n }\r\n\r\n if (this.UseOnlineRepository) {\r\n const firstFunction = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepositoryAsync : this._LoadProfilesFromAvailableControllersAsync;\r\n const secondFunction = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllersAsync : this._LoadProfileFromRepositoryAsync;\r\n\r\n return firstFunction.call(this, profileArray, xrInput, scene).catch(() => {\r\n return secondFunction.call(this, profileArray, xrInput, scene);\r\n });\r\n } else {\r\n // use only available functions\r\n return this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);\r\n }\r\n }\r\n\r\n /**\r\n * Register a new controller based on its profile. This function will be called by the controller classes themselves.\r\n *\r\n * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.\r\n *\r\n * @param type the profile type to register\r\n * @param constructFunction the function to be called when loading this profile\r\n */\r\n public static RegisterController(type: string, constructFunction: MotionControllerConstructor) {\r\n this._AvailableControllers[type] = constructFunction;\r\n }\r\n\r\n /**\r\n * Register a fallback to a specific profile.\r\n * @param profileId the profileId that will receive the fallbacks\r\n * @param fallbacks A list of fallback profiles\r\n */\r\n public static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void {\r\n if (this._Fallbacks[profileId]) {\r\n this._Fallbacks[profileId].push(...fallbacks);\r\n } else {\r\n this._Fallbacks[profileId] = fallbacks;\r\n }\r\n }\r\n\r\n /**\r\n * Will update the list of profiles available in the repository\r\n * @returns a promise that resolves to a map of profiles available online\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static async UpdateProfilesList() {\r\n this._ProfilesList = Tools.LoadFileAsync(this.BaseRepositoryUrl + \"/profiles/profilesList.json\", false).then((data) => {\r\n return JSON.parse(data);\r\n });\r\n return this._ProfilesList;\r\n }\r\n\r\n /**\r\n * Clear the controller's cache (usually happens at the end of a session)\r\n */\r\n public static ClearControllerCache() {\r\n for (const cacheItem of ControllerCache) {\r\n for (const mesh of cacheItem.meshes) {\r\n mesh.dispose(false, true);\r\n }\r\n }\r\n ControllerCache.length = 0;\r\n }\r\n\r\n private static async _LoadProfileFromRepositoryAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene): Promise<WebXRAbstractMotionController> {\r\n return Promise.resolve()\r\n .then(async () => {\r\n if (!this._ProfilesList) {\r\n return this.UpdateProfilesList();\r\n } else {\r\n return this._ProfilesList;\r\n }\r\n })\r\n .then((profilesList: { [profile: string]: string }) => {\r\n // load the right profile\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n if (profilesList[profileArray[i]]) {\r\n return profileArray[i];\r\n }\r\n }\r\n\r\n throw new Error(`neither controller ${profileArray[0]} nor all fallbacks were found in the repository,`);\r\n })\r\n .then(async (profileToLoad: string) => {\r\n // load the profile\r\n if (!this._ProfileLoadingPromises[profileToLoad]) {\r\n this._ProfileLoadingPromises[profileToLoad] = Tools.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${profileToLoad}/profile.json`, false).then(\r\n (data) => <IMotionControllerProfile>JSON.parse(data)\r\n );\r\n }\r\n return this._ProfileLoadingPromises[profileToLoad];\r\n })\r\n .then((profile: IMotionControllerProfile) => {\r\n return new WebXRProfiledMotionController(scene, xrInput, profile, this.BaseRepositoryUrl, this.DisableControllerCache ? undefined : ControllerCache);\r\n });\r\n }\r\n\r\n private static async _LoadProfilesFromAvailableControllersAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene) {\r\n // check fallbacks\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n const fallbacks = this.FindFallbackWithProfileId(profileArray[i]);\r\n for (let j = 0; j < fallbacks.length; ++j) {\r\n const constructionFunction = this._AvailableControllers[fallbacks[j]];\r\n if (constructionFunction) {\r\n return constructionFunction(xrInput, scene);\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`no controller requested was found in the available controllers list`);\r\n }\r\n}\r\n\r\n// register the generic profile(s) here so we will at least have them\r\nWebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRGenericTriggerMotionController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// register fallbacks\r\nWebXRMotionControllerManager.DefaultFallbacks();\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRMotionControllerManager.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/motionController/webXRMotionControllerManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAShF;;;;;;;GAOG;AAEH,MAAM,eAAe,GAIhB,EAAE,CAAC;AAER;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IA0BrC;;OAEG;IACI,MAAM,CAAC,kBAAkB;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB;QAC1B,IAAI,CAAC,6BAA6B,CAAC,iBAAiB,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,6BAA6B,CAAC,UAAU,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC,6BAA6B,CAAC,eAAe,EAAE,CAAC,kCAAkC,CAAC,CAAC,CAAC;QAC1F,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE,CAAC,6CAA6C,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,6BAA6B,CAAC,yBAAyB,EAAE,CAAC,uBAAuB,EAAE,6CAA6C,CAAC,CAAC,CAAC;QACxI,IAAI,CAAC,6BAA6B,CAAC,WAAW,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,6BAA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oDAAuB,GAAiE,EAAE,CAAC;AAG1G;;GAEG;AACW,8CAAiB,GAAG,2EAA2E,CAAC;AAC9G;;GAEG;AACW,uDAA0B,GAAY,IAAI,CAAC;AACzD;;GAEG;AACW,gDAAmB,GAAY,IAAI,CAAC;AAElD;;;GAGG;AACW,mDAAsB,GAAY,IAAI,CAAC;AAwNzD,qEAAqE;AACrE,4BAA4B,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,SAAS,EAAE,CAAC,OAAsB,EAAE,KAAY,EAAE,EAAE;IACpI,OAAO,IAAI,mCAAmC,CAAC,KAAK,EAAO,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACpG,CAAC,CAAC,CAAC;AAEH,qBAAqB;AACrB,4BAA4B,CAAC,gBAAgB,EAAE,CAAC","sourcesContent":["import type { WebXRAbstractMotionController, IMotionControllerProfile } from \"./webXRAbstractMotionController\";\r\nimport { WebXRGenericTriggerMotionController } from \"./webXRGenericMotionController\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { WebXRProfiledMotionController } from \"./webXRProfiledMotionController\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\n\r\n/**\r\n * A construction function type to create a new controller based on an xrInput object\r\n */\r\nexport type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;\r\n\r\n/**\r\n * The MotionController Manager manages all registered motion controllers and loads the right one when needed.\r\n *\r\n * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets\r\n * it should be replaced with auto-loaded controllers.\r\n *\r\n * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes\r\n */\r\n\r\nconst ControllerCache: Array<{\r\n filename: string;\r\n path: string;\r\n meshes: AbstractMesh[];\r\n}> = [];\r\n\r\n/**\r\n * Motion controller manager is managing the different webxr profiles and makes sure the right\r\n * controller is being loaded.\r\n */\r\nexport class WebXRMotionControllerManager {\r\n private static _AvailableControllers: { [type: string]: MotionControllerConstructor } = {};\r\n private static _Fallbacks: { [profileId: string]: string[] } = {};\r\n // cache for loading\r\n private static _ProfileLoadingPromises: { [profileName: string]: Promise<IMotionControllerProfile> } = {};\r\n private static _ProfilesList: Nullable<Promise<{ [profile: string]: string }>>;\r\n\r\n /**\r\n * The base URL of the online controller repository. Can be changed at any time.\r\n */\r\n public static BaseRepositoryUrl = \"https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist\";\r\n /**\r\n * Which repository gets priority - local or online\r\n */\r\n public static PrioritizeOnlineRepository: boolean = true;\r\n /**\r\n * Use the online repository, or use only locally-defined controllers\r\n */\r\n public static UseOnlineRepository: boolean = true;\r\n\r\n /**\r\n * Disable the controller cache and load the models each time a new WebXRProfileMotionController is loaded.\r\n * Defaults to true.\r\n */\r\n public static DisableControllerCache: boolean = true;\r\n\r\n /**\r\n * Clear the cache used for profile loading and reload when requested again\r\n */\r\n public static ClearProfilesCache() {\r\n this._ProfilesList = null;\r\n this._ProfileLoadingPromises = {};\r\n }\r\n\r\n /**\r\n * Register the default fallbacks.\r\n * This function is called automatically when this file is imported.\r\n */\r\n public static DefaultFallbacks() {\r\n this.RegisterFallbacksForProfileId(\"google-daydream\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive-focus\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"htc-vive\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"magicleap-one\", [\"generic-trigger-squeeze-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"windows-mixed-reality\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"microsoft-mixed-reality\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-go\", [\"generic-trigger-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch-v2\", [\"oculus-touch\", \"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"oculus-touch\", [\"generic-trigger-squeeze-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-gearvr\", [\"windows-mixed-reality\", \"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"samsung-odyssey\", [\"generic-touchpad\"]);\r\n this.RegisterFallbacksForProfileId(\"valve-index\", [\"generic-trigger-squeeze-touchpad-thumbstick\"]);\r\n this.RegisterFallbacksForProfileId(\"generic-hand-select\", [\"generic-trigger\"]);\r\n }\r\n\r\n /**\r\n * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.\r\n * @param profileId the profile to which a fallback needs to be found\r\n * @returns an array with corresponding fallback profiles\r\n */\r\n public static FindFallbackWithProfileId(profileId: string): string[] {\r\n const returnArray = this._Fallbacks[profileId] || [];\r\n\r\n returnArray.unshift(profileId);\r\n return returnArray;\r\n }\r\n\r\n /**\r\n * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.\r\n * The order of search:\r\n *\r\n * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller\r\n * 2) (If not found) search in the gamepad id and try using it (legacy versions only)\r\n * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)\r\n * 4) return the generic trigger controller if none were found\r\n *\r\n * @param xrInput the xrInput to which a new controller is initialized\r\n * @param scene the scene to which the model will be added\r\n * @param forceProfile force a certain profile for this controller\r\n * @returns A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found\r\n */\r\n public static async GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController> {\r\n const profileArray: string[] = [];\r\n if (forceProfile) {\r\n profileArray.push(forceProfile);\r\n }\r\n profileArray.push(...(xrInput.profiles || []));\r\n\r\n // emulator support\r\n if (profileArray.length && !profileArray[0]) {\r\n // remove the first \"undefined\" that the emulator is adding\r\n profileArray.pop();\r\n }\r\n\r\n // legacy support - try using the gamepad id\r\n if (xrInput.gamepad && xrInput.gamepad.id) {\r\n switch (xrInput.gamepad.id) {\r\n case xrInput.gamepad.id.match(/oculus touch/gi) ? xrInput.gamepad.id : undefined:\r\n // oculus in gamepad id\r\n profileArray.push(\"oculus-touch-v2\");\r\n break;\r\n }\r\n }\r\n\r\n // make sure microsoft/windows mixed reality works correctly\r\n const windowsMRIdx = profileArray.indexOf(\"windows-mixed-reality\");\r\n if (windowsMRIdx !== -1) {\r\n profileArray.splice(windowsMRIdx, 0, \"microsoft-mixed-reality\");\r\n }\r\n\r\n if (!profileArray.length) {\r\n profileArray.push(\"generic-trigger\");\r\n }\r\n\r\n if (this.UseOnlineRepository) {\r\n const firstFunction = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepositoryAsync : this._LoadProfilesFromAvailableControllersAsync;\r\n const secondFunction = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllersAsync : this._LoadProfileFromRepositoryAsync;\r\n\r\n // eslint-disable-next-line github/no-then\r\n return firstFunction.call(this, profileArray, xrInput, scene).catch(() => {\r\n return secondFunction.call(this, profileArray, xrInput, scene);\r\n });\r\n } else {\r\n // use only available functions\r\n return await this._LoadProfilesFromAvailableControllersAsync(profileArray, xrInput, scene);\r\n }\r\n }\r\n\r\n /**\r\n * Register a new controller based on its profile. This function will be called by the controller classes themselves.\r\n *\r\n * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.\r\n *\r\n * @param type the profile type to register\r\n * @param constructFunction the function to be called when loading this profile\r\n */\r\n public static RegisterController(type: string, constructFunction: MotionControllerConstructor) {\r\n this._AvailableControllers[type] = constructFunction;\r\n }\r\n\r\n /**\r\n * Register a fallback to a specific profile.\r\n * @param profileId the profileId that will receive the fallbacks\r\n * @param fallbacks A list of fallback profiles\r\n */\r\n public static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void {\r\n if (this._Fallbacks[profileId]) {\r\n this._Fallbacks[profileId].push(...fallbacks);\r\n } else {\r\n this._Fallbacks[profileId] = fallbacks;\r\n }\r\n }\r\n\r\n /**\r\n * Will update the list of profiles available in the repository\r\n * @returns a promise that resolves to a map of profiles available online\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static async UpdateProfilesList(): Promise<{\r\n [profile: string]: string;\r\n }> {\r\n const data = await Tools.LoadFileAsync(this.BaseRepositoryUrl + \"/profiles/profilesList.json\", false);\r\n this._ProfilesList = JSON.parse(data);\r\n return await this._ProfilesList!;\r\n }\r\n\r\n /**\r\n * Clear the controller's cache (usually happens at the end of a session)\r\n */\r\n public static ClearControllerCache() {\r\n for (const cacheItem of ControllerCache) {\r\n for (const mesh of cacheItem.meshes) {\r\n mesh.dispose(false, true);\r\n }\r\n }\r\n ControllerCache.length = 0;\r\n }\r\n\r\n private static async _LoadProfileFromRepositoryAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene): Promise<WebXRAbstractMotionController> {\r\n return await Promise.resolve()\r\n // eslint-disable-next-line github/no-then\r\n .then(async () => {\r\n if (!this._ProfilesList) {\r\n return await this.UpdateProfilesList();\r\n } else {\r\n return await this._ProfilesList;\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profilesList: { [profile: string]: string }) => {\r\n // load the right profile\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n if (profilesList[profileArray[i]]) {\r\n return profileArray[i];\r\n }\r\n }\r\n\r\n throw new Error(`neither controller ${profileArray[0]} nor all fallbacks were found in the repository,`);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then(async (profileToLoad: string) => {\r\n // load the profile\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n if (!this._ProfileLoadingPromises[profileToLoad]) {\r\n // eslint-disable-next-line github/no-then\r\n this._ProfileLoadingPromises[profileToLoad] = Tools.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${profileToLoad}/profile.json`, false).then(\r\n (data) => <IMotionControllerProfile>JSON.parse(data)\r\n );\r\n }\r\n return await this._ProfileLoadingPromises[profileToLoad];\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .then((profile: IMotionControllerProfile) => {\r\n return new WebXRProfiledMotionController(scene, xrInput, profile, this.BaseRepositoryUrl, this.DisableControllerCache ? undefined : ControllerCache);\r\n });\r\n }\r\n\r\n private static async _LoadProfilesFromAvailableControllersAsync(profileArray: string[], xrInput: XRInputSource, scene: Scene) {\r\n // check fallbacks\r\n for (let i = 0; i < profileArray.length; ++i) {\r\n // defensive\r\n if (!profileArray[i]) {\r\n continue;\r\n }\r\n const fallbacks = this.FindFallbackWithProfileId(profileArray[i]);\r\n for (let j = 0; j < fallbacks.length; ++j) {\r\n const constructionFunction = this._AvailableControllers[fallbacks[j]];\r\n if (constructionFunction) {\r\n return constructionFunction(xrInput, scene);\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`no controller requested was found in the available controllers list`);\r\n }\r\n}\r\n\r\n// register the generic profile(s) here so we will at least have them\r\nWebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, (xrInput: XRInputSource, scene: Scene) => {\r\n return new WebXRGenericTriggerMotionController(scene, <any>xrInput.gamepad, xrInput.handedness);\r\n});\r\n\r\n// register fallbacks\r\nWebXRMotionControllerManager.DefaultFallbacks();\r\n"]}
|
|
@@ -113,7 +113,7 @@ export class WebXRProfiledMotionController extends WebXRAbstractMotionController
|
|
|
113
113
|
for (const id of ids) {
|
|
114
114
|
const component = this.getComponent(id);
|
|
115
115
|
if (!component.hasChanges) {
|
|
116
|
-
|
|
116
|
+
continue;
|
|
117
117
|
}
|
|
118
118
|
const meshes = this._buttonMeshMapping[id];
|
|
119
119
|
const componentInLayout = this.layout.components[id];
|