@onerjs/core 8.54.4 → 8.54.6
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/Engines/Native/nativeHelpers.js +5 -0
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js +2 -2
- package/Engines/WebGPU/Extensions/engine.rawTexture.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -4
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +13 -0
- package/Engines/WebGPU/webgpuCacheTextureView.js +32 -0
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.d.ts +10 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.js +10 -0
- package/Engines/WebGPU/webgpuRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js +57 -4
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +5 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +5 -0
- package/Engines/thinNativeEngine.pure.js +52 -10
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +1 -0
- package/Engines/webgpuEngine.pure.js +22 -8
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.d.ts +95 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js +169 -4
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.d.ts +21 -6
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js +28 -26
- package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.d.ts +30 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js +111 -29
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.d.ts +56 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js +99 -14
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js +10 -2
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js +21 -1
- package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +18 -0
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +29 -2
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.d.ts +15 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js +44 -7
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.d.ts +9 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js +9 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +7 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +8 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.d.ts +37 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js +44 -0
- package/FlowGraph/Blocks/Event/flowGraphStopEventPropagationBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.d.ts +4 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js +67 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +13 -0
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +102 -7
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.d.ts +11 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js +21 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js +25 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +18 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +9 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +9 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +17 -3
- package/FlowGraph/CustomTypes/flowGraphMatrix.js +27 -21
- package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +23 -0
- package/FlowGraph/flowGraphContext.js +29 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +58 -1
- package/FlowGraph/flowGraphCoordinator.js +72 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDelayRegistry.d.ts +31 -0
- package/FlowGraph/flowGraphDelayRegistry.js +50 -0
- package/FlowGraph/flowGraphDelayRegistry.js.map +1 -0
- package/FlowGraph/flowGraphHostResolver.d.ts +69 -0
- package/FlowGraph/flowGraphHostResolver.js +25 -0
- package/FlowGraph/flowGraphHostResolver.js.map +1 -0
- package/FlowGraph/flowGraphMath.d.ts +48 -1
- package/FlowGraph/flowGraphMath.js +169 -4
- package/FlowGraph/flowGraphMath.js.map +1 -1
- package/FlowGraph/flowGraphPathConverterComponent.d.ts +14 -3
- package/FlowGraph/flowGraphPathConverterComponent.js +110 -18
- package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.pure.js +7 -1
- package/FlowGraph/flowGraphSignalConnection.pure.js.map +1 -1
- package/FlowGraph/index.d.ts +2 -0
- package/FlowGraph/index.js +2 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +2 -0
- package/FlowGraph/pure.js +2 -0
- package/FlowGraph/pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +3 -1
- package/Materials/Node/nodeMaterial.pure.js +18 -1
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Textures/envCubeTexture.pure.js +7 -2
- package/Materials/Textures/envCubeTexture.pure.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +14 -0
- package/Materials/materialHelper.functions.js +67 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Maths/math.vector.pure.d.ts +11 -1
- package/Maths/math.vector.pure.js +13 -0
- package/Maths/math.vector.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +216 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +714 -67
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +81 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +466 -52
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.d.ts +19 -0
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js +24 -0
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +31 -6
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +5 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +1 -0
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +5 -0
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/transformNode.pure.js +1 -0
- package/Meshes/transformNode.pure.js.map +1 -1
- package/Misc/areaLightsTextureTools.js +1 -1
- package/Misc/areaLightsTextureTools.js.map +1 -1
- package/Misc/greasedLineTools.js +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/tools.pure.js +14 -2
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +66 -1
- package/Particles/gpuParticleSystem.pure.js +189 -49
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Physics/v2/characterController.js +69 -17
- package/Physics/v2/characterController.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.d.ts +79 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js +171 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js.map +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +5 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +6 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/pure.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js.map +1 -1
- package/PostProcesses/thinFSR1SharpenPostProcess.d.ts +32 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js +58 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js.map +1 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.d.ts +37 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js +68 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js.map +1 -0
- package/Shaders/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/ffxFunctions.js +18 -0
- package/Shaders/ShadersInclude/ffxFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +2 -2
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +1 -6
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/Shaders/fsr1Sharpen.fragment.d.ts +5 -0
- package/Shaders/fsr1Sharpen.fragment.js +26 -0
- package/Shaders/fsr1Sharpen.fragment.js.map +1 -0
- package/Shaders/fsr1Upscale.fragment.d.ts +5 -0
- package/Shaders/fsr1Upscale.fragment.js +77 -0
- package/Shaders/fsr1Upscale.fragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js +18 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js.map +1 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js +34 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js.map +1 -0
- package/ShadersWGSL/fsr1Upscale.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js +68 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js.map +1 -0
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +3 -9
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +4 -11
- package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.d.ts +9 -0
- package/XR/features/WebXRAbstractFeature.js +16 -0
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRDepthSensing.pure.d.ts +7 -0
- package/XR/features/WebXRDepthSensing.pure.js +350 -39
- package/XR/features/WebXRDepthSensing.pure.js.map +1 -1
- package/XR/features/WebXRImageTracking.pure.js.map +1 -1
- package/XR/features/WebXRLayers.pure.d.ts +6 -5
- package/XR/features/WebXRLayers.pure.js +65 -8
- package/XR/features/WebXRLayers.pure.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.pure.js +9 -2
- package/XR/features/WebXRRawCameraAccess.pure.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.pure.d.ts +0 -1
- package/XR/features/WebXRSpaceWarp.pure.js +13 -4
- package/XR/features/WebXRSpaceWarp.pure.js.map +1 -1
- package/XR/features/WebXRWalkingLocomotion.pure.js.map +1 -1
- package/XR/webXRCamera.js +27 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRFeatureWarningRegistry.d.ts +14 -0
- package/XR/webXRFeatureWarningRegistry.js +19 -0
- package/XR/webXRFeatureWarningRegistry.js.map +1 -0
- package/XR/webXRFeaturesManager.d.ts +5 -0
- package/XR/webXRFeaturesManager.js +23 -4
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRGraphicsBinding.d.ts +17 -10
- package/XR/webXRGraphicsBinding.js +8 -5
- package/XR/webXRGraphicsBinding.js.map +1 -1
- package/XR/webXRSessionManager.d.ts +3 -5
- package/XR/webXRSessionManager.js +1 -3
- package/XR/webXRSessionManager.js.map +1 -1
- package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +21 -5
- package/XR/webXRWebGPURenderTargetTextureProvider.js +38 -10
- package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _MarkWebXRFeatureWithSpecificDisableWarning } from "../webXRFeatureWarningRegistry.js";
|
|
1
2
|
import { Observable } from "../../Misc/observable.js";
|
|
2
3
|
import { Logger } from "../../Misc/logger.js";
|
|
3
4
|
/**
|
|
@@ -26,6 +27,7 @@ export class WebXRAbstractFeature {
|
|
|
26
27
|
constructor(_xrSessionManager) {
|
|
27
28
|
this._xrSessionManager = _xrSessionManager;
|
|
28
29
|
this._attached = false;
|
|
30
|
+
this._disableAutoAttachWarningEmitted = false;
|
|
29
31
|
this._removeOnDetach = [];
|
|
30
32
|
/**
|
|
31
33
|
* Is this feature disposed?
|
|
@@ -122,6 +124,20 @@ export class WebXRAbstractFeature {
|
|
|
122
124
|
isCompatible() {
|
|
123
125
|
return true;
|
|
124
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Disables future automatic attachment when a runtime capability required by the feature is unavailable.
|
|
129
|
+
* @param warning the specific warning explaining why the feature was disabled
|
|
130
|
+
* @returns false so feature attach implementations can return the result directly
|
|
131
|
+
*/
|
|
132
|
+
_disableAutoAttach(warning) {
|
|
133
|
+
if (!this._disableAutoAttachWarningEmitted) {
|
|
134
|
+
Logger.Warn(warning);
|
|
135
|
+
this._disableAutoAttachWarningEmitted = true;
|
|
136
|
+
}
|
|
137
|
+
_MarkWebXRFeatureWithSpecificDisableWarning(this);
|
|
138
|
+
this.disableAutoAttach = true;
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
125
141
|
/**
|
|
126
142
|
* This is used to register callbacks that will automatically be removed when detach is called.
|
|
127
143
|
* @param observable the observable to which the observer will be attached
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRAbstractFeature.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRAbstractFeature.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnF,OAAO,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,yBAAyB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACI,YAAY;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACO,qBAAqB,CAAI,UAAyB,EAAE,QAAwD,EAAE,WAAqB;QACzI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YACtB,UAAU;YACV,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC;SAC7D,CAAC,CAAC;IACP,CAAC;CAQJ","sourcesContent":["import { type IWebXRFeature } from \"../webXRFeaturesManager\";\r\nimport { type Observer, type EventState, Observable } from \"../../Misc/observable\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * This is the base class for all WebXR features.\r\n * Since most features require almost the same resources and callbacks, this class can be used to simplify the development\r\n * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class\r\n */\r\nexport abstract class WebXRAbstractFeature implements IWebXRFeature {\r\n private _attached: boolean = false;\r\n private _removeOnDetach: {\r\n observer: Nullable<Observer<any>>;\r\n observable: Observable<any>;\r\n }[] = [];\r\n\r\n /**\r\n * Is this feature disposed?\r\n */\r\n public isDisposed: boolean = false;\r\n\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n public disableAutoAttach: boolean = false;\r\n\r\n protected _xrNativeFeatureName: string = \"\";\r\n\r\n /**\r\n * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)\r\n */\r\n public get xrNativeFeatureName() {\r\n return this._xrNativeFeatureName;\r\n }\r\n\r\n public set xrNativeFeatureName(name: string) {\r\n // check if feature was initialized while in session but needs to be initialized before the session starts\r\n if (!this._xrSessionManager.isNative && name && this._xrSessionManager.inXRSession && this._xrSessionManager.enabledFeatures?.indexOf(name) === -1) {\r\n Logger.Warn(`The feature ${name} needs to be enabled before starting the XR session. Note - It is still possible it is not supported.`);\r\n }\r\n this._xrNativeFeatureName = name;\r\n }\r\n\r\n /**\r\n * Observers registered here will be executed when the feature is attached\r\n */\r\n public onFeatureAttachObservable: Observable<IWebXRFeature> = new Observable();\r\n /**\r\n * Observers registered here will be executed when the feature is detached\r\n */\r\n public onFeatureDetachObservable: Observable<IWebXRFeature> = new Observable();\r\n\r\n /**\r\n * The dependencies of this feature, if any\r\n */\r\n public dependsOn?: string[];\r\n\r\n /**\r\n * Construct a new (abstract) WebXR feature\r\n * @param _xrSessionManager the xr session manager for this feature\r\n */\r\n constructor(protected _xrSessionManager: WebXRSessionManager) {}\r\n\r\n /**\r\n * Is this feature attached\r\n */\r\n public get attached() {\r\n return this._attached;\r\n }\r\n\r\n /**\r\n * attach this feature\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful, false is failed or already attached\r\n */\r\n public attach(force?: boolean): boolean {\r\n // do not attach a disposed feature\r\n if (this.isDisposed) {\r\n return false;\r\n }\r\n if (!force) {\r\n if (this.attached) {\r\n return false;\r\n }\r\n } else {\r\n if (this.attached) {\r\n // detach first, to be sure\r\n this.detach();\r\n }\r\n }\r\n\r\n // if this is a native WebXR feature, check if it is enabled on the session\r\n // For now only check if not using babylon native\r\n // vision OS doesn't support the enabledFeatures array, so just warn instead of failing\r\n if (!this._xrSessionManager.enabledFeatures) {\r\n Logger.Warn(\"session.enabledFeatures is not available on this device. It is possible that this feature is not supported.\");\r\n } else if (!this._xrSessionManager.isNative && this.xrNativeFeatureName && this._xrSessionManager.enabledFeatures.indexOf(this.xrNativeFeatureName) === -1) {\r\n return false;\r\n }\r\n\r\n this._attached = true;\r\n this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, (frame) => this._onXRFrame(frame));\r\n this.onFeatureAttachObservable.notifyObservers(this);\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n *\r\n * @returns true if successful, false if failed or already detached\r\n */\r\n public detach(): boolean {\r\n if (!this._attached) {\r\n this.disableAutoAttach = true;\r\n return false;\r\n }\r\n this._attached = false;\r\n for (const toRemove of this._removeOnDetach) {\r\n toRemove.observable.remove(toRemove.observer);\r\n }\r\n this.onFeatureDetachObservable.notifyObservers(this);\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached\r\n */\r\n public dispose(): void {\r\n this.detach();\r\n this.isDisposed = true;\r\n this.onFeatureAttachObservable.clear();\r\n this.onFeatureDetachObservable.clear();\r\n }\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n public isCompatible(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * This is used to register callbacks that will automatically be removed when detach is called.\r\n * @param observable the observable to which the observer will be attached\r\n * @param callback the callback to register\r\n * @param insertFirst should the callback be executed as soon as it is registered\r\n */\r\n protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void, insertFirst?: boolean) {\r\n this._removeOnDetach.push({\r\n observable,\r\n observer: observable.add(callback, undefined, insertFirst),\r\n });\r\n }\r\n\r\n /**\r\n * Code in this function will be executed on each xrFrame received from the browser.\r\n * This function will not execute after the feature is detached.\r\n * @param _xrFrame the current frame\r\n */\r\n protected abstract _onXRFrame(_xrFrame: XRFrame): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRAbstractFeature.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRAbstractFeature.ts"],"names":[],"mappings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AAM,QAAQ,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1C,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACI,YAAY;QACf,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACO,kBAAkB,CAAC,OAAe;QACxC,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,IAAI,CAAC,gCAAgC,GAAG,IAAI,CAAC;QACjD,CAAC;QACD,2CAA2C,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACO,qBAAqB,CAAI,UAAyB,EAAE,QAAwD,EAAE,WAAqB;QACzI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YACtB,UAAU;YACV,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC;SAC7D,CAAC,CAAC;IACP,CAAC;CAQJ","sourcesContent":["import { type IWebXRFeature } from \"../webXRFeaturesManager\";\r\nimport { _MarkWebXRFeatureWithSpecificDisableWarning } from \"../webXRFeatureWarningRegistry\";\r\nimport { type Observer, type EventState, Observable } from \"../../Misc/observable\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * This is the base class for all WebXR features.\r\n * Since most features require almost the same resources and callbacks, this class can be used to simplify the development\r\n * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class\r\n */\r\nexport abstract class WebXRAbstractFeature implements IWebXRFeature {\r\n private _attached: boolean = false;\r\n private _disableAutoAttachWarningEmitted: boolean = false;\r\n private _removeOnDetach: {\r\n observer: Nullable<Observer<any>>;\r\n observable: Observable<any>;\r\n }[] = [];\r\n\r\n /**\r\n * Is this feature disposed?\r\n */\r\n public isDisposed: boolean = false;\r\n\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n public disableAutoAttach: boolean = false;\r\n\r\n /** @internal */\r\n public _autoAttachPolicyBeforeAttach?: boolean;\r\n\r\n protected _xrNativeFeatureName: string = \"\";\r\n\r\n /**\r\n * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)\r\n */\r\n public get xrNativeFeatureName() {\r\n return this._xrNativeFeatureName;\r\n }\r\n\r\n public set xrNativeFeatureName(name: string) {\r\n // check if feature was initialized while in session but needs to be initialized before the session starts\r\n if (!this._xrSessionManager.isNative && name && this._xrSessionManager.inXRSession && this._xrSessionManager.enabledFeatures?.indexOf(name) === -1) {\r\n Logger.Warn(`The feature ${name} needs to be enabled before starting the XR session. Note - It is still possible it is not supported.`);\r\n }\r\n this._xrNativeFeatureName = name;\r\n }\r\n\r\n /**\r\n * Observers registered here will be executed when the feature is attached\r\n */\r\n public onFeatureAttachObservable: Observable<IWebXRFeature> = new Observable();\r\n /**\r\n * Observers registered here will be executed when the feature is detached\r\n */\r\n public onFeatureDetachObservable: Observable<IWebXRFeature> = new Observable();\r\n\r\n /**\r\n * The dependencies of this feature, if any\r\n */\r\n public dependsOn?: string[];\r\n\r\n /**\r\n * Construct a new (abstract) WebXR feature\r\n * @param _xrSessionManager the xr session manager for this feature\r\n */\r\n constructor(protected _xrSessionManager: WebXRSessionManager) {}\r\n\r\n /**\r\n * Is this feature attached\r\n */\r\n public get attached() {\r\n return this._attached;\r\n }\r\n\r\n /**\r\n * attach this feature\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful, false is failed or already attached\r\n */\r\n public attach(force?: boolean): boolean {\r\n // do not attach a disposed feature\r\n if (this.isDisposed) {\r\n return false;\r\n }\r\n if (!force) {\r\n if (this.attached) {\r\n return false;\r\n }\r\n } else {\r\n if (this.attached) {\r\n // detach first, to be sure\r\n this.detach();\r\n }\r\n }\r\n\r\n // if this is a native WebXR feature, check if it is enabled on the session\r\n // For now only check if not using babylon native\r\n // vision OS doesn't support the enabledFeatures array, so just warn instead of failing\r\n if (!this._xrSessionManager.enabledFeatures) {\r\n Logger.Warn(\"session.enabledFeatures is not available on this device. It is possible that this feature is not supported.\");\r\n } else if (!this._xrSessionManager.isNative && this.xrNativeFeatureName && this._xrSessionManager.enabledFeatures.indexOf(this.xrNativeFeatureName) === -1) {\r\n return false;\r\n }\r\n\r\n this._attached = true;\r\n this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, (frame) => this._onXRFrame(frame));\r\n this.onFeatureAttachObservable.notifyObservers(this);\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n *\r\n * @returns true if successful, false if failed or already detached\r\n */\r\n public detach(): boolean {\r\n if (!this._attached) {\r\n this.disableAutoAttach = true;\r\n return false;\r\n }\r\n this._attached = false;\r\n for (const toRemove of this._removeOnDetach) {\r\n toRemove.observable.remove(toRemove.observer);\r\n }\r\n this.onFeatureDetachObservable.notifyObservers(this);\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached\r\n */\r\n public dispose(): void {\r\n this.detach();\r\n this.isDisposed = true;\r\n this.onFeatureAttachObservable.clear();\r\n this.onFeatureDetachObservable.clear();\r\n }\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n public isCompatible(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Disables future automatic attachment when a runtime capability required by the feature is unavailable.\r\n * @param warning the specific warning explaining why the feature was disabled\r\n * @returns false so feature attach implementations can return the result directly\r\n */\r\n protected _disableAutoAttach(warning: string): false {\r\n if (!this._disableAutoAttachWarningEmitted) {\r\n Logger.Warn(warning);\r\n this._disableAutoAttachWarningEmitted = true;\r\n }\r\n _MarkWebXRFeatureWithSpecificDisableWarning(this);\r\n this.disableAutoAttach = true;\r\n return false;\r\n }\r\n\r\n /**\r\n * This is used to register callbacks that will automatically be removed when detach is called.\r\n * @param observable the observable to which the observer will be attached\r\n * @param callback the callback to register\r\n * @param insertFirst should the callback be executed as soon as it is registered\r\n */\r\n protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void, insertFirst?: boolean) {\r\n this._removeOnDetach.push({\r\n observable,\r\n observer: observable.add(callback, undefined, insertFirst),\r\n });\r\n }\r\n\r\n /**\r\n * Code in this function will be executed on each xrFrame received from the browser.\r\n * This function will not execute after the feature is detached.\r\n * @param _xrFrame the current frame\r\n */\r\n protected abstract _onXRFrame(_xrFrame: XRFrame): void;\r\n}\r\n"]}
|
|
@@ -52,7 +52,12 @@ export declare class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
52
52
|
private _cachedDepthBuffer;
|
|
53
53
|
private _cachedWebGLTexture;
|
|
54
54
|
private _cachedDepthImageTexture;
|
|
55
|
+
private _cachedDepthImageTextureWrapsExternalTexture;
|
|
56
|
+
private _cpuDepthViewStates;
|
|
57
|
+
private _disableAutoAttachBeforeWebGPUGPUDepth;
|
|
58
|
+
private _disabledForWebGPUGPUDepth;
|
|
55
59
|
private _onCameraObserver;
|
|
60
|
+
private _onSessionEndedObserver;
|
|
56
61
|
/**
|
|
57
62
|
* Width of depth data. If depth data is not exist, returns null.
|
|
58
63
|
*/
|
|
@@ -130,6 +135,8 @@ export declare class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
130
135
|
dispose(): void;
|
|
131
136
|
protected _onXRFrame(_xrFrame: XRFrame): void;
|
|
132
137
|
private _updateDepthInformationAndTextureCPUDepthUsage;
|
|
138
|
+
private _clearCPUDepthBinding;
|
|
139
|
+
private _bindCPUDepthView;
|
|
133
140
|
private _updateDepthInformationAndTextureWebGLDepthUsage;
|
|
134
141
|
/**
|
|
135
142
|
* Extends the session init object if needed
|
|
@@ -37,14 +37,22 @@ class DepthSensingMaterialDefines extends MaterialDefines {
|
|
|
37
37
|
}
|
|
38
38
|
let IsPluginEnabled = false;
|
|
39
39
|
let DepthTexture = null;
|
|
40
|
+
let DepthTextureRight = null;
|
|
40
41
|
let AlphaLuminanceTexture = false;
|
|
41
42
|
const ScreenSize = { width: 512, height: 512 };
|
|
42
43
|
const ShaderViewport = { x: 0, y: 0, width: 1, height: 1 };
|
|
43
44
|
let GlobalRawValueToMeters = 1;
|
|
45
|
+
let GlobalRawValueToMetersRight = 1;
|
|
46
|
+
let GlobalDepthAvailableLeft = 0;
|
|
47
|
+
let GlobalDepthAvailableRight = 0;
|
|
48
|
+
let GlobalWorldScale = 1;
|
|
44
49
|
let ViewIndex = 0;
|
|
45
50
|
let EnableDiscard = true;
|
|
46
51
|
const UvTransform = /*#__PURE__*/ Matrix.Identity();
|
|
52
|
+
const UvTransformRight = /*#__PURE__*/ Matrix.Identity();
|
|
53
|
+
const RightView = /*#__PURE__*/ Matrix.Identity();
|
|
47
54
|
const ManagedMaterialPlugins = [];
|
|
55
|
+
const WebGPUGPUDepthWarning = "WebXR Depth Sensing is unavailable with WebGPU XR when the session negotiates gpu-optimized depth because XRGPUBinding has no environment-depth equivalent; request cpu-optimized depth to use the feature.";
|
|
48
56
|
/**
|
|
49
57
|
* @internal
|
|
50
58
|
*/
|
|
@@ -79,11 +87,10 @@ class WebXRDepthSensingMaterialPlugin extends MaterialPluginBase {
|
|
|
79
87
|
isCompatible(shaderLanguage) {
|
|
80
88
|
switch (shaderLanguage) {
|
|
81
89
|
case 0 /* ShaderLanguage.GLSL */:
|
|
90
|
+
case 1 /* ShaderLanguage.WGSL */:
|
|
82
91
|
return true;
|
|
83
92
|
default:
|
|
84
|
-
|
|
85
|
-
// webxr is currently only supported on webgl, and the plugin is disabled per default.
|
|
86
|
-
return true;
|
|
93
|
+
return false;
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
constructor(material) {
|
|
@@ -103,44 +110,175 @@ class WebXRDepthSensingMaterialPlugin extends MaterialPluginBase {
|
|
|
103
110
|
defines.DEPTH_SENSING_TEXTURE_AL = AlphaLuminanceTexture;
|
|
104
111
|
defines.DEPTH_SENSING_DISCARD = EnableDiscard;
|
|
105
112
|
}
|
|
106
|
-
getUniforms() {
|
|
113
|
+
getUniforms(shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
114
|
+
const ubo = [
|
|
115
|
+
{ name: "ds_invScreenSize", size: 2, type: "vec2" },
|
|
116
|
+
{ name: "ds_rawValueToMeters", size: 1, type: "float" },
|
|
117
|
+
{ name: "ds_viewIndex", size: 1, type: "float" },
|
|
118
|
+
{ name: "ds_shaderViewport", size: 4, type: "vec4" },
|
|
119
|
+
{ name: "ds_uvTransform", size: 16, type: "mat4" },
|
|
120
|
+
];
|
|
121
|
+
if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
122
|
+
ubo.push({ name: "ds_rawValueToMetersRight", size: 1, type: "float" }, { name: "ds_depthAvailableLeft", size: 1, type: "float" }, { name: "ds_depthAvailableRight", size: 1, type: "float" }, { name: "ds_worldScale", size: 1, type: "float" }, { name: "ds_viewDepthSign", size: 1, type: "float" }, { name: "ds_uvTransformRight", size: 16, type: "mat4" }, { name: "ds_viewRight", size: 16, type: "mat4" });
|
|
123
|
+
}
|
|
107
124
|
return {
|
|
108
125
|
// first, define the UBO with the correct type and size.
|
|
109
|
-
ubo
|
|
110
|
-
{ name: "ds_invScreenSize", size: 2, type: "vec2" },
|
|
111
|
-
{ name: "ds_rawValueToMeters", size: 1, type: "float" },
|
|
112
|
-
{ name: "ds_viewIndex", size: 1, type: "float" },
|
|
113
|
-
{ name: "ds_shaderViewport", size: 4, type: "vec4" },
|
|
114
|
-
{ name: "ds_uvTransform", size: 16, type: "mat4" },
|
|
115
|
-
],
|
|
126
|
+
ubo,
|
|
116
127
|
// now, on the fragment shader, add the uniform itself in case uniform buffers are not supported by the engine
|
|
117
|
-
fragment:
|
|
128
|
+
fragment: shaderLanguage === 0 /* ShaderLanguage.GLSL */
|
|
129
|
+
? `#ifdef DEPTH_SENSING
|
|
118
130
|
uniform vec2 ds_invScreenSize;
|
|
119
131
|
uniform float ds_rawValueToMeters;
|
|
120
132
|
uniform float ds_viewIndex;
|
|
121
133
|
uniform vec4 ds_shaderViewport;
|
|
122
134
|
uniform mat4 ds_uvTransform;
|
|
123
135
|
#endif
|
|
124
|
-
|
|
136
|
+
`
|
|
137
|
+
: "",
|
|
125
138
|
};
|
|
126
139
|
}
|
|
127
140
|
getSamplers(samplers) {
|
|
128
141
|
samplers.push("ds_depthSampler");
|
|
142
|
+
samplers.push("ds_depthSamplerRight");
|
|
129
143
|
}
|
|
130
144
|
bindForSubMesh(uniformBuffer) {
|
|
131
145
|
if (IsPluginEnabled && DepthTexture) {
|
|
146
|
+
const isWGSL = this._material.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
|
|
132
147
|
uniformBuffer.updateFloat2("ds_invScreenSize", 1 / ScreenSize.width, 1 / ScreenSize.height);
|
|
133
148
|
uniformBuffer.updateFloat("ds_rawValueToMeters", GlobalRawValueToMeters);
|
|
134
149
|
uniformBuffer.updateFloat("ds_viewIndex", ViewIndex);
|
|
135
150
|
uniformBuffer.updateFloat4("ds_shaderViewport", ShaderViewport.x, ShaderViewport.y, ShaderViewport.width, ShaderViewport.height);
|
|
136
151
|
uniformBuffer.setTexture("ds_depthSampler", DepthTexture);
|
|
137
152
|
uniformBuffer.updateMatrix("ds_uvTransform", UvTransform);
|
|
153
|
+
if (isWGSL) {
|
|
154
|
+
uniformBuffer.updateFloat("ds_rawValueToMetersRight", GlobalRawValueToMetersRight);
|
|
155
|
+
uniformBuffer.updateFloat("ds_depthAvailableLeft", GlobalDepthAvailableLeft);
|
|
156
|
+
uniformBuffer.updateFloat("ds_depthAvailableRight", GlobalDepthAvailableRight);
|
|
157
|
+
uniformBuffer.updateFloat("ds_worldScale", GlobalWorldScale);
|
|
158
|
+
uniformBuffer.updateFloat("ds_viewDepthSign", this._material.getScene().useRightHandedSystem ? -1 : 1);
|
|
159
|
+
uniformBuffer.setTexture("ds_depthSamplerRight", DepthTextureRight);
|
|
160
|
+
uniformBuffer.updateMatrix("ds_uvTransformRight", UvTransformRight);
|
|
161
|
+
uniformBuffer.updateMatrix("ds_viewRight", RightView);
|
|
162
|
+
}
|
|
138
163
|
}
|
|
139
164
|
}
|
|
140
165
|
getClassName() {
|
|
141
166
|
return "DepthSensingMaterialPlugin";
|
|
142
167
|
}
|
|
143
|
-
getCustomCode(shaderType) {
|
|
168
|
+
getCustomCode(shaderType, shaderLanguage = 0 /* ShaderLanguage.GLSL */) {
|
|
169
|
+
if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
170
|
+
return shaderType === "vertex"
|
|
171
|
+
? {
|
|
172
|
+
CUSTOM_VERTEX_MAIN_BEGIN: `
|
|
173
|
+
#ifdef DEPTH_SENSING
|
|
174
|
+
#ifdef MULTIVIEW
|
|
175
|
+
vertexOutputs.ds_viewIndexMultiview = f32(gl_ViewID_OVR);
|
|
176
|
+
#endif
|
|
177
|
+
#endif
|
|
178
|
+
`,
|
|
179
|
+
CUSTOM_VERTEX_DEFINITIONS: `
|
|
180
|
+
#ifdef DEPTH_SENSING
|
|
181
|
+
#ifdef MULTIVIEW
|
|
182
|
+
varying ds_viewIndexMultiview: f32;
|
|
183
|
+
#endif
|
|
184
|
+
#endif
|
|
185
|
+
`,
|
|
186
|
+
}
|
|
187
|
+
: {
|
|
188
|
+
CUSTOM_FRAGMENT_DEFINITIONS: `
|
|
189
|
+
#ifdef DEPTH_SENSING
|
|
190
|
+
#ifdef DEPTH_SENSING_TEXTURE_ARRAY
|
|
191
|
+
var ds_depthSampler: texture_2d_array<f32>;
|
|
192
|
+
#else
|
|
193
|
+
var ds_depthSampler: texture_2d<f32>;
|
|
194
|
+
#endif
|
|
195
|
+
var ds_depthSamplerSampler: sampler;
|
|
196
|
+
#if defined(MULTIVIEW) && !defined(DEPTH_SENSING_TEXTURE_ARRAY)
|
|
197
|
+
var ds_depthSamplerRight: texture_2d<f32>;
|
|
198
|
+
var ds_depthSamplerRightSampler: sampler;
|
|
199
|
+
#endif
|
|
200
|
+
#ifdef MULTIVIEW
|
|
201
|
+
varying ds_viewIndexMultiview: f32;
|
|
202
|
+
#endif
|
|
203
|
+
#endif
|
|
204
|
+
`,
|
|
205
|
+
CUSTOM_FRAGMENT_MAIN_BEGIN: `
|
|
206
|
+
#ifdef DEPTH_SENSING
|
|
207
|
+
#ifdef MULTIVIEW
|
|
208
|
+
let ds_viewIndexSet: f32 = fragmentInputs.ds_viewIndexMultiview;
|
|
209
|
+
let ds_compensation: vec2f = vec2f(0.0, 0.0);
|
|
210
|
+
#else
|
|
211
|
+
let ds_viewIndexSet: f32 = uniforms.ds_viewIndex;
|
|
212
|
+
let ds_compensation: vec2f = vec2f(ds_viewIndexSet, 0.0);
|
|
213
|
+
#endif
|
|
214
|
+
let ds_baseUvBottomLeft: vec2f = (fragmentInputs.position.xy * uniforms.ds_invScreenSize - uniforms.ds_shaderViewport.xy) / uniforms.ds_shaderViewport.zw;
|
|
215
|
+
let ds_baseUv: vec2f = vec2f(ds_baseUvBottomLeft.x, 1.0 - ds_baseUvBottomLeft.y);
|
|
216
|
+
var ds_depthSample: vec4f = vec4f(0.0);
|
|
217
|
+
var ds_rawValueToMetersSet: f32 = uniforms.ds_rawValueToMeters;
|
|
218
|
+
#if defined(MULTIVIEW) && !defined(DEPTH_SENSING_TEXTURE_ARRAY)
|
|
219
|
+
var ds_depthAvailable: f32 = uniforms.ds_depthAvailableLeft;
|
|
220
|
+
if (ds_viewIndexSet < 0.5) {
|
|
221
|
+
if (ds_depthAvailable > 0.5) {
|
|
222
|
+
let ds_depthUv: vec2f = (uniforms.ds_uvTransform * vec4f(ds_baseUv, 0.0, 1.0)).xy;
|
|
223
|
+
ds_depthSample = textureSampleLevel(ds_depthSampler, ds_depthSamplerSampler, ds_depthUv, 0.0);
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
ds_depthAvailable = uniforms.ds_depthAvailableRight;
|
|
227
|
+
if (ds_depthAvailable > 0.5) {
|
|
228
|
+
let ds_depthUv: vec2f = (uniforms.ds_uvTransformRight * vec4f(ds_baseUv, 0.0, 1.0)).xy;
|
|
229
|
+
ds_depthSample = textureSampleLevel(ds_depthSamplerRight, ds_depthSamplerRightSampler, ds_depthUv, 0.0);
|
|
230
|
+
}
|
|
231
|
+
ds_rawValueToMetersSet = uniforms.ds_rawValueToMetersRight;
|
|
232
|
+
}
|
|
233
|
+
#else
|
|
234
|
+
let ds_depthAvailable: f32 = 1.0;
|
|
235
|
+
#ifdef DEPTH_SENSING_TEXTURE_ARRAY
|
|
236
|
+
let ds_uv: vec2f = ds_baseUv - ds_compensation;
|
|
237
|
+
let ds_depthUv: vec2f = (uniforms.ds_uvTransform * vec4f(ds_uv, 0.0, 1.0)).xy;
|
|
238
|
+
ds_depthSample = textureSample(ds_depthSampler, ds_depthSamplerSampler, ds_depthUv, i32(ds_viewIndexSet));
|
|
239
|
+
#else
|
|
240
|
+
let ds_depthUv: vec2f = (uniforms.ds_uvTransform * vec4f(ds_baseUv, 0.0, 1.0)).xy;
|
|
241
|
+
ds_depthSample = textureSample(ds_depthSampler, ds_depthSamplerSampler, ds_depthUv);
|
|
242
|
+
#endif
|
|
243
|
+
#endif
|
|
244
|
+
var ds_cameraDepth: f32;
|
|
245
|
+
#ifdef DEPTH_SENSING_TEXTURE_AL
|
|
246
|
+
let ds_alphaLuminance: vec2f = ds_depthSample.ra;
|
|
247
|
+
ds_cameraDepth = dot(ds_alphaLuminance, vec2f(255.0, 256.0 * 255.0));
|
|
248
|
+
#else
|
|
249
|
+
ds_cameraDepth = ds_depthSample.r;
|
|
250
|
+
#endif
|
|
251
|
+
|
|
252
|
+
ds_cameraDepth = ds_cameraDepth * ds_rawValueToMetersSet;
|
|
253
|
+
|
|
254
|
+
var ds_viewPosition: vec4f = scene.view * vec4f(fragmentInputs.vPositionW, 1.0);
|
|
255
|
+
#ifdef MULTIVIEW
|
|
256
|
+
if (ds_viewIndexSet >= 0.5) {
|
|
257
|
+
ds_viewPosition = uniforms.ds_viewRight * vec4f(fragmentInputs.vPositionW, 1.0);
|
|
258
|
+
}
|
|
259
|
+
#endif
|
|
260
|
+
let ds_assetDepth: f32 = (ds_viewPosition.z * uniforms.ds_viewDepthSign) / uniforms.ds_worldScale;
|
|
261
|
+
#ifdef DEPTH_SENSING_DISCARD
|
|
262
|
+
if (ds_depthAvailable > 0.5 && ds_cameraDepth > 0.0 && ds_cameraDepth < ds_assetDepth) {
|
|
263
|
+
discard;
|
|
264
|
+
}
|
|
265
|
+
#endif
|
|
266
|
+
#endif
|
|
267
|
+
`,
|
|
268
|
+
CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `
|
|
269
|
+
#ifdef DEPTH_SENSING
|
|
270
|
+
#ifndef DEPTH_SENSING_DISCARD
|
|
271
|
+
if (ds_depthAvailable > 0.5 && ds_cameraDepth > 0.0) {
|
|
272
|
+
let ds_depthTolerancePerM: f32 = 0.005;
|
|
273
|
+
let ds_occlusion: f32 = clamp(1.0 - 0.5 * (ds_cameraDepth - ds_assetDepth) / (ds_depthTolerancePerM * ds_assetDepth) +
|
|
274
|
+
0.5, 0.0, 1.0);
|
|
275
|
+
${this._varColorName} *= (1.0 - ds_occlusion);
|
|
276
|
+
}
|
|
277
|
+
#endif
|
|
278
|
+
#endif
|
|
279
|
+
`,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
144
282
|
return shaderType === "vertex"
|
|
145
283
|
? {
|
|
146
284
|
CUSTOM_VERTEX_MAIN_BEGIN: `
|
|
@@ -320,7 +458,12 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
320
458
|
this._cachedDepthBuffer = null;
|
|
321
459
|
this._cachedWebGLTexture = null;
|
|
322
460
|
this._cachedDepthImageTexture = null;
|
|
461
|
+
this._cachedDepthImageTextureWrapsExternalTexture = false;
|
|
462
|
+
this._cpuDepthViewStates = [];
|
|
463
|
+
this._disableAutoAttachBeforeWebGPUGPUDepth = false;
|
|
464
|
+
this._disabledForWebGPUGPUDepth = false;
|
|
323
465
|
this._onCameraObserver = null;
|
|
466
|
+
this._onSessionEndedObserver = null;
|
|
324
467
|
/**
|
|
325
468
|
* Event that notify when `DepthInformation.getDepthInMeters` is available.
|
|
326
469
|
* `getDepthInMeters` method needs active XRFrame (not available for cached XRFrame)
|
|
@@ -328,9 +471,17 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
328
471
|
this.onGetDepthInMetersAvailable = new Observable();
|
|
329
472
|
this.xrNativeFeatureName = "depth-sensing";
|
|
330
473
|
// https://immersive-web.github.io/depth-sensing/
|
|
331
|
-
|
|
474
|
+
if (!this._xrSessionManager.scene.getEngine().isWebGPU) {
|
|
475
|
+
Logger.Warn("depth-sensing is an experimental and unstable feature.");
|
|
476
|
+
}
|
|
332
477
|
EnableDiscard = !options.useToleranceFactorForDepthSensing;
|
|
333
478
|
RegisterMaterialPlugin("WebXRDepthSensingMaterialPlugin", (material) => new WebXRDepthSensingMaterialPlugin(material));
|
|
479
|
+
this._onSessionEndedObserver = this._xrSessionManager.onXRSessionEnded.add(() => {
|
|
480
|
+
if (this._disabledForWebGPUGPUDepth) {
|
|
481
|
+
this._disabledForWebGPUGPUDepth = false;
|
|
482
|
+
this.disableAutoAttach = this._disableAutoAttachBeforeWebGPUGPUDepth;
|
|
483
|
+
}
|
|
484
|
+
});
|
|
334
485
|
}
|
|
335
486
|
/**
|
|
336
487
|
* attach this feature
|
|
@@ -339,14 +490,31 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
339
490
|
* @returns true if successful.
|
|
340
491
|
*/
|
|
341
492
|
attach(force) {
|
|
342
|
-
|
|
493
|
+
const engine = this._xrSessionManager.scene.getEngine();
|
|
494
|
+
const depthUsage = this._xrSessionManager.session.depthUsage;
|
|
495
|
+
const depthDataFormat = this._xrSessionManager.session.depthDataFormat;
|
|
496
|
+
if (engine.isWebGPU && depthUsage === "gpu-optimized") {
|
|
497
|
+
if (this._disabledForWebGPUGPUDepth) {
|
|
498
|
+
this.disableAutoAttach = true;
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
this._disableAutoAttachBeforeWebGPUGPUDepth = this._autoAttachPolicyBeforeAttach ?? this.disableAutoAttach;
|
|
502
|
+
this._disabledForWebGPUGPUDepth = true;
|
|
503
|
+
return this._disableAutoAttach(WebGPUGPUDepthWarning);
|
|
504
|
+
}
|
|
505
|
+
if (depthUsage == null || depthDataFormat == null) {
|
|
343
506
|
return false;
|
|
344
507
|
}
|
|
345
|
-
|
|
346
|
-
if (isBothDepthUsageAndFormatNull) {
|
|
508
|
+
if (!super.attach(force)) {
|
|
347
509
|
return false;
|
|
348
510
|
}
|
|
349
|
-
|
|
511
|
+
if (!engine.isWebGPU) {
|
|
512
|
+
const graphicsBinding = this._xrSessionManager._getGraphicsBinding();
|
|
513
|
+
if (graphicsBinding.bindingType !== 0 /* WebXRGraphicsBindingType.WebGL */) {
|
|
514
|
+
throw new Error("Expected a WebGL graphics binding for WebXR Depth Sensing.");
|
|
515
|
+
}
|
|
516
|
+
this._glBinding = graphicsBinding.binding;
|
|
517
|
+
}
|
|
350
518
|
IsPluginEnabled = !this.options.disableDepthSensingOnMaterials;
|
|
351
519
|
if (IsPluginEnabled) {
|
|
352
520
|
for (const plugin of ManagedMaterialPlugins) {
|
|
@@ -359,16 +527,28 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
359
527
|
// make sure this is a webxr camera
|
|
360
528
|
if (camera.outputRenderTarget) {
|
|
361
529
|
const viewport = camera.rigCameras.length > 0 ? camera.rigCameras[0].viewport : camera.viewport;
|
|
362
|
-
ScreenSize.width = camera.outputRenderTarget.getRenderWidth() / (camera.rigParent ? camera.rigParent.rigCameras.length || 1 : 1);
|
|
530
|
+
ScreenSize.width = camera.outputRenderTarget.getRenderWidth() / (!engine.isWebGPU && camera.rigParent ? camera.rigParent.rigCameras.length || 1 : 1);
|
|
363
531
|
ScreenSize.height = camera.outputRenderTarget.getRenderHeight();
|
|
364
532
|
ShaderViewport.x = viewport.x;
|
|
365
533
|
ShaderViewport.y = viewport.y;
|
|
366
534
|
ShaderViewport.width = viewport.width;
|
|
367
535
|
ShaderViewport.height = viewport.height;
|
|
536
|
+
GlobalWorldScale = this._xrSessionManager.worldScalingFactor;
|
|
368
537
|
// find the viewIndex
|
|
369
538
|
if (camera.rigParent) {
|
|
370
|
-
|
|
371
|
-
ViewIndex =
|
|
539
|
+
const viewIndex = camera.rigParent.rigCameras.indexOf(camera);
|
|
540
|
+
ViewIndex = viewIndex === -1 ? 0 : viewIndex;
|
|
541
|
+
if (engine.isWebGPU && this.depthUsage === "cpu") {
|
|
542
|
+
this._bindCPUDepthView(ViewIndex, false);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
else if (camera._renderingMultiview && engine.isWebGPU && this.depthUsage === "cpu") {
|
|
546
|
+
ViewIndex = 0;
|
|
547
|
+
const rightCamera = camera.rigCameras[1];
|
|
548
|
+
if (rightCamera) {
|
|
549
|
+
RightView.copyFrom(rightCamera.getViewMatrix());
|
|
550
|
+
}
|
|
551
|
+
this._bindCPUDepthView(0, true);
|
|
372
552
|
}
|
|
373
553
|
}
|
|
374
554
|
});
|
|
@@ -378,13 +558,34 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
378
558
|
detach() {
|
|
379
559
|
IsPluginEnabled = false;
|
|
380
560
|
DepthTexture = null;
|
|
561
|
+
DepthTextureRight = null;
|
|
381
562
|
this._cachedWebGLTexture = null;
|
|
382
563
|
this._cachedDepthBuffer = null;
|
|
564
|
+
this._width = null;
|
|
565
|
+
this._height = null;
|
|
566
|
+
this._rawValueToMeters = null;
|
|
567
|
+
this._textureType = null;
|
|
568
|
+
this._normDepthBufferFromNormView = null;
|
|
569
|
+
let cachedTextureDisposed = false;
|
|
570
|
+
for (const viewState of this._cpuDepthViewStates) {
|
|
571
|
+
viewState.texture?.dispose();
|
|
572
|
+
cachedTextureDisposed || (cachedTextureDisposed = viewState.texture === this._cachedDepthImageTexture);
|
|
573
|
+
}
|
|
574
|
+
this._cpuDepthViewStates.length = 0;
|
|
575
|
+
if (!cachedTextureDisposed) {
|
|
576
|
+
if (this._cachedDepthImageTextureWrapsExternalTexture && this._cachedDepthImageTexture?._texture) {
|
|
577
|
+
this._cachedDepthImageTexture._texture._hardwareTexture = null;
|
|
578
|
+
}
|
|
579
|
+
this._cachedDepthImageTexture?.dispose();
|
|
580
|
+
}
|
|
581
|
+
this._cachedDepthImageTexture = null;
|
|
582
|
+
this._cachedDepthImageTextureWrapsExternalTexture = false;
|
|
383
583
|
for (const plugin of ManagedMaterialPlugins) {
|
|
384
584
|
plugin.isEnabled = false;
|
|
385
585
|
}
|
|
386
586
|
if (this._onCameraObserver) {
|
|
387
587
|
this._xrSessionManager.scene.onBeforeCameraRenderObservable.remove(this._onCameraObserver);
|
|
588
|
+
this._onCameraObserver = null;
|
|
388
589
|
}
|
|
389
590
|
return super.detach();
|
|
390
591
|
}
|
|
@@ -392,9 +593,12 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
392
593
|
* Dispose this feature and all of the resources attached
|
|
393
594
|
*/
|
|
394
595
|
dispose() {
|
|
596
|
+
if (this._onSessionEndedObserver) {
|
|
597
|
+
this._xrSessionManager.onXRSessionEnded.remove(this._onSessionEndedObserver);
|
|
598
|
+
this._onSessionEndedObserver = null;
|
|
599
|
+
}
|
|
395
600
|
super.dispose();
|
|
396
601
|
UnregisterMaterialPlugin("WebXRDepthSensingMaterialPlugin");
|
|
397
|
-
this._cachedDepthImageTexture?.dispose();
|
|
398
602
|
this.onGetDepthInMetersAvailable.clear();
|
|
399
603
|
// cleanup
|
|
400
604
|
if (this._onCameraObserver) {
|
|
@@ -407,14 +611,24 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
407
611
|
}
|
|
408
612
|
_onXRFrame(_xrFrame) {
|
|
409
613
|
const referenceSPace = this._xrSessionManager.referenceSpace;
|
|
614
|
+
const depthUsage = this.depthUsage;
|
|
615
|
+
if (depthUsage === "cpu") {
|
|
616
|
+
for (const viewState of this._cpuDepthViewStates) {
|
|
617
|
+
viewState.available = false;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
410
620
|
const pose = _xrFrame.getViewerPose(referenceSPace);
|
|
411
621
|
if (pose == null) {
|
|
622
|
+
if (depthUsage === "cpu") {
|
|
623
|
+
this._clearCPUDepthBinding();
|
|
624
|
+
}
|
|
412
625
|
return;
|
|
413
626
|
}
|
|
414
|
-
for (
|
|
415
|
-
|
|
627
|
+
for (let viewIndex = 0; viewIndex < pose.views.length; viewIndex++) {
|
|
628
|
+
const view = pose.views[viewIndex];
|
|
629
|
+
switch (depthUsage) {
|
|
416
630
|
case "cpu":
|
|
417
|
-
this._updateDepthInformationAndTextureCPUDepthUsage(_xrFrame, view, this.depthDataFormat);
|
|
631
|
+
this._updateDepthInformationAndTextureCPUDepthUsage(_xrFrame, view, viewIndex, this.depthDataFormat);
|
|
418
632
|
break;
|
|
419
633
|
case "gpu":
|
|
420
634
|
if (!this._glBinding) {
|
|
@@ -428,43 +642,138 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
428
642
|
break;
|
|
429
643
|
}
|
|
430
644
|
}
|
|
645
|
+
if (depthUsage === "cpu" && !this._cpuDepthViewStates.some((viewState) => viewState.available)) {
|
|
646
|
+
this._clearCPUDepthBinding();
|
|
647
|
+
}
|
|
431
648
|
}
|
|
432
|
-
_updateDepthInformationAndTextureCPUDepthUsage(frame, view, dataFormat) {
|
|
649
|
+
_updateDepthInformationAndTextureCPUDepthUsage(frame, view, viewIndex, dataFormat) {
|
|
433
650
|
const depthInfo = frame.getDepthInformation(view);
|
|
434
|
-
if (depthInfo
|
|
651
|
+
if (depthInfo == null) {
|
|
435
652
|
return;
|
|
436
653
|
}
|
|
437
654
|
const { data, width, height, rawValueToMeters, getDepthInMeters, normDepthBufferFromNormView } = depthInfo;
|
|
655
|
+
let viewState = this._cpuDepthViewStates[viewIndex];
|
|
656
|
+
if (!viewState) {
|
|
657
|
+
viewState = {
|
|
658
|
+
available: true,
|
|
659
|
+
height,
|
|
660
|
+
rawValueToMeters,
|
|
661
|
+
texture: null,
|
|
662
|
+
uvTransform: Matrix.Identity(),
|
|
663
|
+
visualizationDepthBuffer: null,
|
|
664
|
+
width,
|
|
665
|
+
};
|
|
666
|
+
this._cpuDepthViewStates[viewIndex] = viewState;
|
|
667
|
+
}
|
|
668
|
+
const textureSizeChanged = viewState.width !== width || viewState.height !== height;
|
|
438
669
|
this._width = width;
|
|
439
670
|
this._height = height;
|
|
440
671
|
this._rawValueToMeters = rawValueToMeters;
|
|
672
|
+
this._normDepthBufferFromNormView = normDepthBufferFromNormView;
|
|
441
673
|
this._cachedDepthBuffer = data;
|
|
442
|
-
GlobalRawValueToMeters = rawValueToMeters;
|
|
443
674
|
AlphaLuminanceTexture = dataFormat === "luminance-alpha";
|
|
444
|
-
|
|
675
|
+
viewState.height = height;
|
|
676
|
+
viewState.available = true;
|
|
677
|
+
viewState.rawValueToMeters = rawValueToMeters;
|
|
678
|
+
viewState.uvTransform.fromArray(normDepthBufferFromNormView.matrix);
|
|
679
|
+
viewState.width = width;
|
|
445
680
|
// to avoid Illegal Invocation error, bind `this`
|
|
446
681
|
this.onGetDepthInMetersAvailable.notifyObservers(getDepthInMeters.bind(depthInfo));
|
|
447
|
-
if (!
|
|
448
|
-
|
|
449
|
-
|
|
682
|
+
if (!viewState.texture || textureSizeChanged) {
|
|
683
|
+
viewState.texture?.dispose();
|
|
684
|
+
viewState.texture = RawTexture.CreateRTexture(null, width, height, this._xrSessionManager.scene, false, false, Texture.NEAREST_SAMPLINGMODE, 1);
|
|
450
685
|
}
|
|
451
|
-
|
|
686
|
+
this._cachedDepthImageTextureWrapsExternalTexture = false;
|
|
687
|
+
this._cachedDepthImageTexture = viewState.texture;
|
|
688
|
+
let depthValues = null;
|
|
452
689
|
switch (dataFormat) {
|
|
453
690
|
case "ushort":
|
|
454
691
|
case "luminance-alpha":
|
|
455
|
-
|
|
692
|
+
depthValues = new Uint16Array(data);
|
|
456
693
|
break;
|
|
457
694
|
case "float":
|
|
458
|
-
|
|
695
|
+
depthValues = new Float32Array(data);
|
|
459
696
|
break;
|
|
460
697
|
default:
|
|
461
698
|
break;
|
|
462
699
|
}
|
|
463
|
-
if (
|
|
700
|
+
if (depthValues) {
|
|
701
|
+
let uploadData;
|
|
464
702
|
if (this.options.prepareTextureForVisualization) {
|
|
465
|
-
|
|
703
|
+
if (!viewState.visualizationDepthBuffer || viewState.visualizationDepthBuffer.length !== depthValues.length) {
|
|
704
|
+
viewState.visualizationDepthBuffer = new Float32Array(depthValues.length);
|
|
705
|
+
}
|
|
706
|
+
uploadData = viewState.visualizationDepthBuffer;
|
|
707
|
+
for (let index = 0; index < depthValues.length; index++) {
|
|
708
|
+
uploadData[index] = depthValues[index] * rawValueToMeters;
|
|
709
|
+
}
|
|
466
710
|
}
|
|
467
|
-
|
|
711
|
+
else {
|
|
712
|
+
uploadData = depthValues instanceof Float32Array ? depthValues : Float32Array.from(depthValues);
|
|
713
|
+
}
|
|
714
|
+
viewState.texture.update(uploadData);
|
|
715
|
+
}
|
|
716
|
+
if (!this._xrSessionManager.scene.getEngine().isWebGPU) {
|
|
717
|
+
const hadDepthTexture = !!DepthTexture;
|
|
718
|
+
DepthTexture = viewState.texture;
|
|
719
|
+
DepthTextureRight = null;
|
|
720
|
+
GlobalDepthAvailableLeft = 1;
|
|
721
|
+
GlobalDepthAvailableRight = 0;
|
|
722
|
+
GlobalRawValueToMeters = viewState.rawValueToMeters;
|
|
723
|
+
UvTransform.copyFrom(viewState.uvTransform);
|
|
724
|
+
if (!hadDepthTexture) {
|
|
725
|
+
this._xrSessionManager.scene.markAllMaterialsAsDirty(1);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
_clearCPUDepthBinding() {
|
|
730
|
+
if (DepthTexture) {
|
|
731
|
+
DepthTexture = null;
|
|
732
|
+
DepthTextureRight = null;
|
|
733
|
+
this._xrSessionManager.scene.markAllMaterialsAsDirty(1);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
_bindCPUDepthView(viewIndex, multiview) {
|
|
737
|
+
const leftViewState = this._cpuDepthViewStates[0];
|
|
738
|
+
const rightViewState = multiview ? this._cpuDepthViewStates[1] : null;
|
|
739
|
+
const viewState = multiview
|
|
740
|
+
? leftViewState?.available && leftViewState.texture
|
|
741
|
+
? leftViewState
|
|
742
|
+
: rightViewState?.available && rightViewState.texture
|
|
743
|
+
? rightViewState
|
|
744
|
+
: null
|
|
745
|
+
: this._cpuDepthViewStates[viewIndex];
|
|
746
|
+
if (!viewState?.available || !viewState.texture) {
|
|
747
|
+
this._clearCPUDepthBinding();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const hadDepthTexture = !!DepthTexture;
|
|
751
|
+
if (multiview && leftViewState?.available && leftViewState.texture) {
|
|
752
|
+
GlobalDepthAvailableLeft = 1;
|
|
753
|
+
DepthTexture = leftViewState.texture;
|
|
754
|
+
GlobalRawValueToMeters = leftViewState.rawValueToMeters;
|
|
755
|
+
UvTransform.copyFrom(leftViewState.uvTransform);
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
GlobalDepthAvailableLeft = multiview ? 0 : 1;
|
|
759
|
+
DepthTexture = viewState.texture;
|
|
760
|
+
GlobalRawValueToMeters = viewState.rawValueToMeters;
|
|
761
|
+
UvTransform.copyFrom(viewState.uvTransform);
|
|
762
|
+
}
|
|
763
|
+
if (multiview && rightViewState?.available && rightViewState.texture) {
|
|
764
|
+
GlobalDepthAvailableRight = 1;
|
|
765
|
+
DepthTextureRight = rightViewState.texture;
|
|
766
|
+
GlobalRawValueToMetersRight = rightViewState.rawValueToMeters;
|
|
767
|
+
UvTransformRight.copyFrom(rightViewState.uvTransform);
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
GlobalDepthAvailableRight = 0;
|
|
771
|
+
DepthTextureRight = viewState.texture;
|
|
772
|
+
GlobalRawValueToMetersRight = viewState.rawValueToMeters;
|
|
773
|
+
UvTransformRight.copyFrom(viewState.uvTransform);
|
|
774
|
+
}
|
|
775
|
+
if (!hadDepthTexture) {
|
|
776
|
+
this._xrSessionManager.scene.markAllMaterialsAsDirty(1);
|
|
468
777
|
}
|
|
469
778
|
}
|
|
470
779
|
_updateDepthInformationAndTextureWebGLDepthUsage(webglBinding, view, dataFormat) {
|
|
@@ -487,8 +796,10 @@ export class WebXRDepthSensing extends WebXRAbstractFeature {
|
|
|
487
796
|
const internalTexture = this._getInternalTextureFromDepthInfo();
|
|
488
797
|
if (!this._cachedDepthImageTexture) {
|
|
489
798
|
this._cachedDepthImageTexture = RawTexture.CreateRTexture(null, width, height, scene, false, true, Texture.NEAREST_SAMPLINGMODE, dataFormat === "float" ? 1 : 0);
|
|
799
|
+
this._cachedDepthImageTexture._texture?.dispose();
|
|
490
800
|
}
|
|
491
801
|
this._cachedDepthImageTexture._texture = internalTexture;
|
|
802
|
+
this._cachedDepthImageTextureWrapsExternalTexture = true;
|
|
492
803
|
DepthTexture = this._cachedDepthImageTexture;
|
|
493
804
|
this._xrSessionManager.scene.markAllMaterialsAsDirty(1);
|
|
494
805
|
}
|