@babylonjs/core 5.27.1 → 5.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/actionManager.js +2 -0
- package/Actions/actionManager.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +4 -4
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Cameras/camera.js +4 -4
- package/Cameras/camera.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +0 -2
- package/Collisions/pickingInfo.js +0 -2
- package/Collisions/pickingInfo.js.map +1 -1
- package/Culling/ray.js +5 -0
- package/Culling/ray.js.map +1 -1
- package/Engines/Extensions/engine.videoTexture.js +6 -3
- package/Engines/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/engine.d.ts +898 -273
- package/Engines/nullEngine.d.ts +7 -0
- package/Engines/nullEngine.js +42 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +2 -1
- package/Engines/renderTargetWrapper.js +1 -0
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Events/pointerEvents.d.ts +11 -6
- package/Events/pointerEvents.js +24 -6
- package/Events/pointerEvents.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +9 -1
- package/Inputs/scene.inputManager.js +76 -37
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +2 -6
- package/Layers/effectLayer.js.map +1 -1
- package/Loading/sceneLoader.d.ts +1 -1
- package/Loading/sceneLoader.js +2 -2
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +5 -4
- package/Materials/Textures/baseTexture.js +1 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.d.ts +5 -0
- package/Materials/Textures/htmlElementTexture.js +4 -1
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/thinTexture.d.ts +3 -3
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +6 -1
- package/Materials/Textures/videoTexture.js +7 -2
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Maths/math.vector.d.ts +390 -319
- package/Maths/math.vector.js +298 -153
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/decalBuilder.d.ts +8 -0
- package/Meshes/Builders/decalBuilder.js +270 -51
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/mesh.d.ts +1 -1
- package/Meshes/mesh.js +42 -1
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +7 -1
- package/Meshes/transformNode.js +15 -4
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/assetsManager.d.ts +22 -4
- package/Misc/assetsManager.js +20 -8
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/dds.js +1 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/environmentTextureTools.js +1 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.d.ts +14 -8
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +16 -6
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +4 -2
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +2 -1
- package/PostProcesses/blurPostProcess.js +3 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js +2 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js +3 -5
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.js +9 -4
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +2 -6
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +2 -6
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +2 -6
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/renderingGroup.d.ts +4 -0
- package/Rendering/renderingGroup.js +7 -1
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.d.ts +5 -0
- package/Rendering/renderingManager.js +15 -0
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +3 -3
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/circleOfConfusion.fragment.js +1 -1
- package/Shaders/circleOfConfusion.fragment.js.map +1 -1
- package/Shaders/depthOfFieldMerge.fragment.js +1 -1
- package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
- package/Shaders/kernelBlur.fragment.js +2 -2
- package/Shaders/kernelBlur.fragment.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +3 -3
- package/XR/features/WebXRHandTracking.js +100 -100
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js +1 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +0 -1
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.js +1 -0
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/XR/webXRWebGLLayer.js +3 -0
- package/XR/webXRWebGLLayer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +5 -0
- package/scene.js +10 -6
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRHitTest.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/XR/features/WebXRHitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAkEzC;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,oBAAoB;IA0DlD;;;;OAIG;IACH,YACI,iBAAsC;IACtC;;OAEG;IACa,UAAgC,EAAE;QAElD,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAFT,YAAO,GAAP,OAAO,CAA2B;QAnE9C,YAAO,GAAW,IAAI,MAAM,EAAE,CAAC;QAC/B,YAAO,GAAY,IAAI,OAAO,EAAE,CAAC;QACjC,aAAQ,GAAe,IAAI,UAAU,EAAE,CAAC;QAIxC,uBAAkB,GAAG,CAAC,cAAgC,EAAE,EAAE;YAC9D,IAAI,CAAC,cAAc,EAAE;gBACjB,OAAO;aACV;YACD,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAC1D,MAAM,cAAc,GAAyB;gBACzC,KAAK,EAAE,IAA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AO,CAAC,CAAC;IAC5D,CAAC;;AAhKD;;GAEG;AACoB,iBAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AACxD;;;;GAIG;AACoB,oBAAO,GAAG,CAAC,CAAC;AA0JvC,8BAA8B;AAC9B,oBAAoB,CAAC,eAAe,CAChC,YAAY,CAAC,IAAI,EACjB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC,EACD,YAAY,CAAC,OAAO,EACpB,KAAK,CACR,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Vector3, Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from \"./WebXRHitTestLegacy\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Options used for hit testing (version 2)\r\n */\r\nexport interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {\r\n /**\r\n * Do not create a permanent hit test. Will usually be used when only\r\n * transient inputs are needed.\r\n */\r\n disablePermanentHitTest?: boolean;\r\n /**\r\n * Enable transient (for example touch-based) hit test inspections\r\n */\r\n enableTransientHitTest?: boolean;\r\n /**\r\n * Override the default transient hit test profile (generic-touchscreen).\r\n */\r\n transientHitTestProfile?: string;\r\n /**\r\n * Offset ray for the permanent hit test\r\n */\r\n offsetRay?: Vector3;\r\n /**\r\n * Offset ray for the transient hit test\r\n */\r\n transientOffsetRay?: Vector3;\r\n /**\r\n * Instead of using viewer space for hit tests, use the reference space defined in the session manager\r\n */\r\n useReferenceSpace?: boolean;\r\n\r\n /**\r\n * Override the default entity type(s) of the hit-test result\r\n */\r\n entityTypes?: XRHitTestTrackableType[];\r\n}\r\n\r\n/**\r\n * Interface defining the babylon result of hit-test\r\n */\r\nexport interface IWebXRHitResult extends IWebXRLegacyHitResult {\r\n /**\r\n * The input source that generated this hit test (if transient)\r\n */\r\n inputSource?: XRInputSource;\r\n /**\r\n * Is this a transient hit test\r\n */\r\n isTransient?: boolean;\r\n /**\r\n * Position of the hit test result\r\n */\r\n position: Vector3;\r\n /**\r\n * Rotation of the hit test result\r\n */\r\n rotationQuaternion: Quaternion;\r\n\r\n /**\r\n * The native hit test result\r\n */\r\n xrHitResult: XRHitTestResult;\r\n}\r\n\r\n/**\r\n * The currently-working hit-test module.\r\n * Hit test (or Ray-casting) is used to interact with the real world.\r\n * For further information read here - https://github.com/immersive-web/hit-test\r\n *\r\n * Tested on chrome (mobile) 80.\r\n */\r\nexport class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {\r\n private _tmpMat: Matrix = new Matrix();\r\n private _tmpPos: Vector3 = new Vector3();\r\n private _tmpQuat: Quaternion = new Quaternion();\r\n private _transientXrHitTestSource: Nullable<XRTransientInputHitTestSource>;\r\n // in XR space z-forward is negative\r\n private _xrHitTestSource: Nullable<XRHitTestSource>;\r\n private _initHitTestSource = (referenceSpace: XRReferenceSpace) => {\r\n if (!referenceSpace) {\r\n return;\r\n }\r\n const offsetRay = new XRRay(this.options.offsetRay || {});\r\n const hitTestOptions: XRHitTestOptionsInit = {\r\n space: this.options.useReferenceSpace ? referenceSpace : this._xrSessionManager.viewerReferenceSpace,\r\n offsetRay: offsetRay,\r\n };\r\n if (this.options.entityTypes) {\r\n hitTestOptions.entityTypes = this.options.entityTypes;\r\n }\r\n if (!hitTestOptions.space) {\r\n Tools.Warn(\"waiting for viewer reference space to initialize\");\r\n return;\r\n }\r\n this._xrSessionManager.session.requestHitTestSource!(hitTestOptions).then((hitTestSource) => {\r\n if (this._xrHitTestSource) {\r\n this._xrHitTestSource.cancel();\r\n }\r\n this._xrHitTestSource = hitTestSource;\r\n });\r\n };\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.HIT_TEST;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 2;\r\n\r\n /**\r\n * When set to true, each hit test will have its own position/rotation objects\r\n * When set to false, position and rotation objects will be reused for each hit test. It is expected that\r\n * the developers will clone them or copy them as they see fit.\r\n */\r\n public autoCloneTransformation: boolean = false;\r\n /**\r\n * Triggered when new babylon (transformed) hit test results are available\r\n * Note - this will be called when results come back from the device. It can be an empty array!!\r\n */\r\n public onHitTestResultObservable: Observable<IWebXRHitResult[]> = new Observable();\r\n /**\r\n * Use this to temporarily pause hit test checks.\r\n */\r\n public paused: boolean = false;\r\n\r\n /**\r\n * Creates a new instance of the hit test feature\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options options to use when constructing this feature\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /**\r\n * options to use when constructing this feature\r\n */\r\n public readonly options: IWebXRHitTestOptions = {}\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"hit-test\";\r\n Tools.Warn(\"Hit test is an experimental and unstable feature.\");\r\n }\r\n\r\n /**\r\n * attach this feature\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n // Feature enabled, but not available\r\n if (!this._xrSessionManager.session.requestHitTestSource) {\r\n return false;\r\n }\r\n\r\n if (!this.options.disablePermanentHitTest) {\r\n if (this._xrSessionManager.referenceSpace) {\r\n this._initHitTestSource(this._xrSessionManager.referenceSpace);\r\n }\r\n this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource);\r\n }\r\n if (this.options.enableTransientHitTest) {\r\n const offsetRay = new XRRay(this.options.transientOffsetRay || {});\r\n this._xrSessionManager.session.requestHitTestSourceForTransientInput!({\r\n profile: this.options.transientHitTestProfile || \"generic-touchscreen\",\r\n offsetRay,\r\n entityTypes: this.options.entityTypes,\r\n }).then((hitSource) => {\r\n this._transientXrHitTestSource = hitSource;\r\n });\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n if (this._xrHitTestSource) {\r\n this._xrHitTestSource.cancel();\r\n this._xrHitTestSource = null;\r\n }\r\n this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource);\r\n if (this._transientXrHitTestSource) {\r\n this._transientXrHitTestSource.cancel();\r\n this._transientXrHitTestSource = null;\r\n }\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 super.dispose();\r\n this.onHitTestResultObservable.clear();\r\n }\r\n\r\n protected _onXRFrame(frame: XRFrame) {\r\n // make sure we do nothing if (async) not attached\r\n if (!this.attached || this.paused) {\r\n return;\r\n }\r\n\r\n if (this._xrHitTestSource) {\r\n const results = frame.getHitTestResults(this._xrHitTestSource);\r\n this._processWebXRHitTestResult(results);\r\n }\r\n if (this._transientXrHitTestSource) {\r\n const hitTestResultsPerInputSource = frame.getHitTestResultsForTransientInput(this._transientXrHitTestSource);\r\n\r\n hitTestResultsPerInputSource.forEach((resultsPerInputSource) => {\r\n this._processWebXRHitTestResult(resultsPerInputSource.results, resultsPerInputSource.inputSource);\r\n });\r\n }\r\n }\r\n\r\n private _processWebXRHitTestResult(hitTestResults: XRHitTestResult[], inputSource?: XRInputSource) {\r\n const results: IWebXRHitResult[] = [];\r\n hitTestResults.forEach((hitTestResult) => {\r\n const pose = hitTestResult.getPose(this._xrSessionManager.referenceSpace);\r\n if (!pose) {\r\n return;\r\n }\r\n const pos = pose.transform.position;\r\n const quat = pose.transform.orientation;\r\n this._tmpPos.set(pos.x, pos.y, pos.z);\r\n this._tmpQuat.set(quat.x, quat.y, quat.z, quat.w);\r\n Matrix.FromFloat32ArrayToRefScaled(pose.transform.matrix, 0, 1, this._tmpMat);\r\n if (!this._xrSessionManager.scene.useRightHandedSystem) {\r\n this._tmpPos.z *= -1;\r\n this._tmpQuat.z *= -1;\r\n this._tmpQuat.w *= -1;\r\n this._tmpMat.toggleModelMatrixHandInPlace();\r\n }\r\n\r\n const result: IWebXRHitResult = {\r\n position: this.autoCloneTransformation ? this._tmpPos.clone() : this._tmpPos,\r\n rotationQuaternion: this.autoCloneTransformation ? this._tmpQuat.clone() : this._tmpQuat,\r\n transformationMatrix: this.autoCloneTransformation ? this._tmpMat.clone() : this._tmpMat,\r\n inputSource: inputSource,\r\n isTransient: !!inputSource,\r\n xrHitResult: hitTestResult,\r\n };\r\n results.push(result);\r\n });\r\n\r\n this.onHitTestResultObservable.notifyObservers(results);\r\n }\r\n}\r\n\r\n//register the plugin versions\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRHitTest.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRHitTest(xrSessionManager, options);\r\n },\r\n WebXRHitTest.Version,\r\n false\r\n);\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRHitTest.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/XR/features/WebXRHitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAkEzC;;;;;;GAMG;A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O,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;gBAC5E,kBAAkB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;gBACxF,oBAAoB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;gBACxF,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,WAAW,EAAE,aAAa;aAC7B,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;;AAhKD;;GAEG;AACoB,iBAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AACxD;;;;GAIG;AACoB,oBAAO,GAAG,CAAC,CAAC;AA0JvC,8BAA8B;AAC9B,oBAAoB,CAAC,eAAe,CAChC,YAAY,CAAC,IAAI,EACjB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC,EACD,YAAY,CAAC,OAAO,EACpB,KAAK,CACR,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Vector3, Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from \"./WebXRHitTestLegacy\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Options used for hit testing (version 2)\r\n */\r\nexport interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {\r\n /**\r\n * Do not create a permanent hit test. Will usually be used when only\r\n * transient inputs are needed.\r\n */\r\n disablePermanentHitTest?: boolean;\r\n /**\r\n * Enable transient (for example touch-based) hit test inspections\r\n */\r\n enableTransientHitTest?: boolean;\r\n /**\r\n * Override the default transient hit test profile (generic-touchscreen).\r\n */\r\n transientHitTestProfile?: string;\r\n /**\r\n * Offset ray for the permanent hit test\r\n */\r\n offsetRay?: Vector3;\r\n /**\r\n * Offset ray for the transient hit test\r\n */\r\n transientOffsetRay?: Vector3;\r\n /**\r\n * Instead of using viewer space for hit tests, use the reference space defined in the session manager\r\n */\r\n useReferenceSpace?: boolean;\r\n\r\n /**\r\n * Override the default entity type(s) of the hit-test result\r\n */\r\n entityTypes?: XRHitTestTrackableType[];\r\n}\r\n\r\n/**\r\n * Interface defining the babylon result of hit-test\r\n */\r\nexport interface IWebXRHitResult extends IWebXRLegacyHitResult {\r\n /**\r\n * The input source that generated this hit test (if transient)\r\n */\r\n inputSource?: XRInputSource;\r\n /**\r\n * Is this a transient hit test\r\n */\r\n isTransient?: boolean;\r\n /**\r\n * Position of the hit test result\r\n */\r\n position: Vector3;\r\n /**\r\n * Rotation of the hit test result\r\n */\r\n rotationQuaternion: Quaternion;\r\n\r\n /**\r\n * The native hit test result\r\n */\r\n xrHitResult: XRHitTestResult;\r\n}\r\n\r\n/**\r\n * The currently-working hit-test module.\r\n * Hit test (or Ray-casting) is used to interact with the real world.\r\n * For further information read here - https://github.com/immersive-web/hit-test\r\n *\r\n * Tested on chrome (mobile) 80.\r\n */\r\nexport class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {\r\n private _tmpMat: Matrix = new Matrix();\r\n private _tmpPos: Vector3 = new Vector3();\r\n private _tmpQuat: Quaternion = new Quaternion();\r\n private _transientXrHitTestSource: Nullable<XRTransientInputHitTestSource>;\r\n // in XR space z-forward is negative\r\n private _xrHitTestSource: Nullable<XRHitTestSource>;\r\n private _initHitTestSource = (referenceSpace: XRReferenceSpace) => {\r\n if (!referenceSpace) {\r\n return;\r\n }\r\n const offsetRay = new XRRay(this.options.offsetRay || {});\r\n const hitTestOptions: XRHitTestOptionsInit = {\r\n space: this.options.useReferenceSpace ? referenceSpace : this._xrSessionManager.viewerReferenceSpace,\r\n offsetRay: offsetRay,\r\n };\r\n if (this.options.entityTypes) {\r\n hitTestOptions.entityTypes = this.options.entityTypes;\r\n }\r\n if (!hitTestOptions.space) {\r\n Tools.Warn(\"waiting for viewer reference space to initialize\");\r\n return;\r\n }\r\n this._xrSessionManager.session.requestHitTestSource!(hitTestOptions).then((hitTestSource) => {\r\n if (this._xrHitTestSource) {\r\n this._xrHitTestSource.cancel();\r\n }\r\n this._xrHitTestSource = hitTestSource;\r\n });\r\n };\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.HIT_TEST;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 2;\r\n\r\n /**\r\n * When set to true, each hit test will have its own position/rotation objects\r\n * When set to false, position and rotation objects will be reused for each hit test. It is expected that\r\n * the developers will clone them or copy them as they see fit.\r\n */\r\n public autoCloneTransformation: boolean = false;\r\n /**\r\n * Triggered when new babylon (transformed) hit test results are available\r\n * Note - this will be called when results come back from the device. It can be an empty array!!\r\n */\r\n public onHitTestResultObservable: Observable<IWebXRHitResult[]> = new Observable();\r\n /**\r\n * Use this to temporarily pause hit test checks.\r\n */\r\n public paused: boolean = false;\r\n\r\n /**\r\n * Creates a new instance of the hit test feature\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options options to use when constructing this feature\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /**\r\n * options to use when constructing this feature\r\n */\r\n public readonly options: IWebXRHitTestOptions = {}\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"hit-test\";\r\n Tools.Warn(\"Hit test is an experimental and unstable feature.\");\r\n }\r\n\r\n /**\r\n * attach this feature\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n // Feature enabled, but not available\r\n if (!this._xrSessionManager.session.requestHitTestSource) {\r\n return false;\r\n }\r\n\r\n if (!this.options.disablePermanentHitTest) {\r\n if (this._xrSessionManager.referenceSpace) {\r\n this._initHitTestSource(this._xrSessionManager.referenceSpace);\r\n }\r\n this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource);\r\n }\r\n if (this.options.enableTransientHitTest) {\r\n const offsetRay = new XRRay(this.options.transientOffsetRay || {});\r\n this._xrSessionManager.session.requestHitTestSourceForTransientInput!({\r\n profile: this.options.transientHitTestProfile || \"generic-touchscreen\",\r\n offsetRay,\r\n entityTypes: this.options.entityTypes,\r\n }).then((hitSource) => {\r\n this._transientXrHitTestSource = hitSource;\r\n });\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n if (this._xrHitTestSource) {\r\n this._xrHitTestSource.cancel();\r\n this._xrHitTestSource = null;\r\n }\r\n this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource);\r\n if (this._transientXrHitTestSource) {\r\n this._transientXrHitTestSource.cancel();\r\n this._transientXrHitTestSource = null;\r\n }\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 super.dispose();\r\n this.onHitTestResultObservable.clear();\r\n }\r\n\r\n protected _onXRFrame(frame: XRFrame) {\r\n // make sure we do nothing if (async) not attached\r\n if (!this.attached || this.paused) {\r\n return;\r\n }\r\n\r\n if (this._xrHitTestSource) {\r\n const results = frame.getHitTestResults(this._xrHitTestSource);\r\n this._processWebXRHitTestResult(results);\r\n }\r\n if (this._transientXrHitTestSource) {\r\n const hitTestResultsPerInputSource = frame.getHitTestResultsForTransientInput(this._transientXrHitTestSource);\r\n\r\n hitTestResultsPerInputSource.forEach((resultsPerInputSource) => {\r\n this._processWebXRHitTestResult(resultsPerInputSource.results, resultsPerInputSource.inputSource);\r\n });\r\n }\r\n }\r\n\r\n private _processWebXRHitTestResult(hitTestResults: readonly XRHitTestResult[], inputSource?: XRInputSource) {\r\n const results: IWebXRHitResult[] = [];\r\n hitTestResults.forEach((hitTestResult) => {\r\n const pose = hitTestResult.getPose(this._xrSessionManager.referenceSpace);\r\n if (!pose) {\r\n return;\r\n }\r\n const pos = pose.transform.position;\r\n const quat = pose.transform.orientation;\r\n this._tmpPos.set(pos.x, pos.y, pos.z);\r\n this._tmpQuat.set(quat.x, quat.y, quat.z, quat.w);\r\n Matrix.FromFloat32ArrayToRefScaled(pose.transform.matrix, 0, 1, this._tmpMat);\r\n if (!this._xrSessionManager.scene.useRightHandedSystem) {\r\n this._tmpPos.z *= -1;\r\n this._tmpQuat.z *= -1;\r\n this._tmpQuat.w *= -1;\r\n this._tmpMat.toggleModelMatrixHandInPlace();\r\n }\r\n\r\n const result: IWebXRHitResult = {\r\n position: this.autoCloneTransformation ? this._tmpPos.clone() : this._tmpPos,\r\n rotationQuaternion: this.autoCloneTransformation ? this._tmpQuat.clone() : this._tmpQuat,\r\n transformationMatrix: this.autoCloneTransformation ? this._tmpMat.clone() : this._tmpMat,\r\n inputSource: inputSource,\r\n isTransient: !!inputSource,\r\n xrHitResult: hitTestResult,\r\n };\r\n results.push(result);\r\n });\r\n\r\n this.onHitTestResultObservable.notifyObservers(results);\r\n }\r\n}\r\n\r\n//register the plugin versions\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRHitTest.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRHitTest(xrSessionManager, options);\r\n },\r\n WebXRHitTest.Version,\r\n false\r\n);\r\n"]}
|
|
@@ -167,7 +167,7 @@ export class WebXRLightEstimation extends WebXRAbstractFeature {
|
|
|
167
167
|
if (!this.options.disableCubeMapReflection) {
|
|
168
168
|
if (!this._reflectionCubeMap) {
|
|
169
169
|
this._reflectionCubeMap = new BaseTexture(this._xrSessionManager.scene);
|
|
170
|
-
this._reflectionCubeMap.
|
|
170
|
+
this._reflectionCubeMap._isCube = true;
|
|
171
171
|
this._reflectionCubeMap.coordinatesMode = 3;
|
|
172
172
|
if (this.options.setSceneEnvironmentTexture) {
|
|
173
173
|
this._xrSessionManager.scene.environmentTexture = this._reflectionCubeMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRLightEstimation.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/XR/features/WebXRLightEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE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CAAC;oBACvH,MAAA,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,0CAAE,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;iBAC9F;gBAED,yCAAyC;gBACzC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;gBACrC,wCAAwC;gBACxC,IAAI,IAAI,CAAC,gBAAgB,EAAE;oBACvB,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;oBAC/D,IAAI,CAAC,gBAAgB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;oBACjE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBAC5D;aACJ;SACJ;IACL,CAAC;;AAlRD;;GAEG;AACoB,yBAAI,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;AAChE;;;;GAIG;AACoB,4BAAO,GAAG,CAAC,CAAC;AA4QvC,sBAAsB;AACtB,oBAAoB,CAAC,eAAe,CAChC,oBAAoB,CAAC,IAAI,EACzB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC,EACD,oBAAoB,CAAC,OAAO,EAC5B,KAAK,CACR,CAAC","sourcesContent":["import { WebGLHardwareTexture } from \"../../Engines/WebGL/webGLHardwareTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"../../Materials/Textures/internalTexture\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName, WebXRFeaturesManager } from \"../webXRFeaturesManager\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { DirectionalLight } from \"../../Lights/directionalLight\";\r\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\nimport { LightConstants } from \"../../Lights/lightConstants\";\r\n\r\n/**\r\n * Options for Light Estimation feature\r\n */\r\nexport interface IWebXRLightEstimationOptions {\r\n /**\r\n * Disable the cube map reflection feature. In this case only light direction and color will be updated\r\n */\r\n disableCubeMapReflection?: boolean;\r\n /**\r\n * Should the scene's env texture be set to the cube map reflection texture\r\n * Note that this doesn't work is disableCubeMapReflection if set to false\r\n */\r\n setSceneEnvironmentTexture?: boolean;\r\n /**\r\n * How often should the cubemap update in ms.\r\n * If not set the cubemap will be updated every time the underlying system updates the environment texture.\r\n */\r\n cubeMapPollInterval?: number;\r\n /**\r\n * How often should the light estimation properties update in ms.\r\n * If not set the light estimation properties will be updated on every frame (depending on the underlying system)\r\n */\r\n lightEstimationPollInterval?: number;\r\n /**\r\n * Should a directional light source be created.\r\n * If created, this light source will be updated whenever the light estimation values change\r\n */\r\n createDirectionalLightSource?: boolean;\r\n /**\r\n * Define the format to be used for the light estimation texture.\r\n */\r\n reflectionFormat?: XRReflectionFormat;\r\n /**\r\n * Should the light estimation's needed vectors be constructed on each frame.\r\n * Use this when you use those vectors and don't want their values to change outside of the light estimation feature\r\n */\r\n disableVectorReuse?: boolean;\r\n\r\n /**\r\n * disable applying the spherical polynomial to the cube map texture\r\n */\r\n disableSphericalPolynomial?: boolean;\r\n}\r\n\r\n/**\r\n * An interface describing the result of a light estimation\r\n */\r\nexport interface IWebXRLightEstimation {\r\n /**\r\n * The intensity of the light source\r\n */\r\n lightIntensity: number;\r\n /**\r\n * Color of light source\r\n */\r\n lightColor: Color3;\r\n /**\r\n * The direction from the light source\r\n */\r\n lightDirection: Vector3;\r\n /**\r\n * Spherical harmonics coefficients of the light source\r\n */\r\n sphericalHarmonics: SphericalHarmonics;\r\n}\r\n\r\n/**\r\n * Light Estimation Feature\r\n *\r\n * @since 5.0.0\r\n */\r\nexport class WebXRLightEstimation extends WebXRAbstractFeature {\r\n private _canvasContext: Nullable<WebGLRenderingContext | WebGL2RenderingContext> = null;\r\n private _reflectionCubeMap: Nullable<BaseTexture> = null;\r\n private _xrLightEstimate: Nullable<XRLightEstimate> = null;\r\n private _xrLightProbe: Nullable<XRLightProbe> = null;\r\n private _xrWebGLBinding: Nullable<XRWebGLBinding> = null;\r\n private _lightDirection: Vector3 = Vector3.Up().negateInPlace();\r\n private _lightColor: Color3 = Color3.White();\r\n private _intensity: number = 1;\r\n private _sphericalHarmonics: SphericalHarmonics = new SphericalHarmonics();\r\n private _cubeMapPollTime = Date.now();\r\n private _lightEstimationPollTime = Date.now();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.LIGHT_ESTIMATION;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * ARCore's reflection cube map size is 16x16.\r\n * Once other systems support this feature we will need to change this to be dynamic.\r\n * see https://github.com/immersive-web/lighting-estimation/blob/main/lighting-estimation-explainer.md#cube-map-open-questions\r\n */\r\n private _reflectionCubeMapTextureSize: number = 16;\r\n\r\n /**\r\n * If createDirectionalLightSource is set to true this light source will be created automatically.\r\n * Otherwise this can be set with an external directional light source.\r\n * This light will be updated whenever the light estimation values change.\r\n */\r\n public directionalLight: Nullable<DirectionalLight> = null;\r\n\r\n /**\r\n * This observable will notify when the reflection cube map is updated.\r\n */\r\n public onReflectionCubeMapUpdatedObservable: Observable<BaseTexture> = new Observable();\r\n\r\n /**\r\n * Creates a new instance of the light estimation feature\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options options to use when constructing this feature\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /**\r\n * options to use when constructing this feature\r\n */\r\n public readonly options: IWebXRLightEstimationOptions\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"light-estimation\";\r\n\r\n if (this.options.createDirectionalLightSource) {\r\n this.directionalLight = new DirectionalLight(\"light estimation directional\", this._lightDirection, this._xrSessionManager.scene);\r\n this.directionalLight.position = new Vector3(0, 8, 0);\r\n // intensity will be set later\r\n this.directionalLight.intensity = 0;\r\n this.directionalLight.falloffType = LightConstants.FALLOFF_GLTF;\r\n }\r\n\r\n // https://immersive-web.github.io/lighting-estimation/\r\n Tools.Warn(\"light-estimation is an experimental and unstable feature.\");\r\n }\r\n\r\n /**\r\n * While the estimated cube map is expected to update over time to better reflect the user's environment as they move around those changes are unlikely to happen with every XRFrame.\r\n * Since creating and processing the cube map is potentially expensive, especially if mip maps are needed, you can listen to the onReflectionCubeMapUpdatedObservable to determine\r\n * when it has been updated.\r\n */\r\n public get reflectionCubeMapTexture(): Nullable<BaseTexture> {\r\n return this._reflectionCubeMap;\r\n }\r\n\r\n /**\r\n * The most recent light estimate. Available starting on the first frame where the device provides a light probe.\r\n */\r\n public get xrLightingEstimate(): Nullable<IWebXRLightEstimation> {\r\n if (this._xrLightEstimate) {\r\n return {\r\n lightColor: this._lightColor,\r\n lightDirection: this._lightDirection,\r\n lightIntensity: this._intensity,\r\n sphericalHarmonics: this._sphericalHarmonics,\r\n };\r\n }\r\n return this._xrLightEstimate;\r\n }\r\n\r\n private _getCanvasContext(): WebGLRenderingContext | WebGL2RenderingContext {\r\n if (this._canvasContext === null) {\r\n this._canvasContext = this._xrSessionManager.scene.getEngine()._gl;\r\n }\r\n return this._canvasContext;\r\n }\r\n\r\n private _getXRGLBinding(): XRWebGLBinding {\r\n if (this._xrWebGLBinding === null) {\r\n const context = this._getCanvasContext();\r\n this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, context);\r\n }\r\n return this._xrWebGLBinding;\r\n }\r\n\r\n /**\r\n * Event Listener for \"reflectionchange\" events.\r\n */\r\n private _updateReflectionCubeMap = (): void => {\r\n if (!this._xrLightProbe) {\r\n return;\r\n }\r\n // check poll time, do not update if it has not been long enough\r\n if (this.options.cubeMapPollInterval) {\r\n const now = Date.now();\r\n if (now - this._cubeMapPollTime < this.options.cubeMapPollInterval) {\r\n return;\r\n }\r\n this._cubeMapPollTime = now;\r\n }\r\n const lp = this._getXRGLBinding().getReflectionCubeMap(this._xrLightProbe);\r\n if (lp && this._reflectionCubeMap) {\r\n if (!this._reflectionCubeMap._texture) {\r\n const internalTexture = new InternalTexture(this._xrSessionManager.scene.getEngine(), InternalTextureSource.Unknown);\r\n internalTexture.isCube = true;\r\n internalTexture.invertY = false;\r\n internalTexture._useSRGBBuffer = this.options.reflectionFormat === \"srgba8\";\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.generateMipMaps = true;\r\n internalTexture.type = this.options.reflectionFormat !== \"srgba8\" ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n internalTexture.samplingMode = Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR;\r\n internalTexture.width = this._reflectionCubeMapTextureSize;\r\n internalTexture.height = this._reflectionCubeMapTextureSize;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n internalTexture._hardwareTexture = new WebGLHardwareTexture(lp, this._getCanvasContext() as WebGLRenderingContext);\r\n this._reflectionCubeMap._texture = internalTexture;\r\n } else {\r\n this._reflectionCubeMap._texture._hardwareTexture?.set(lp);\r\n this._reflectionCubeMap._texture.getEngine().resetTextureCache();\r\n }\r\n this._reflectionCubeMap._texture.isReady = true;\r\n this._xrSessionManager.scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n\r\n this.onReflectionCubeMapUpdatedObservable.notifyObservers(this._reflectionCubeMap);\r\n }\r\n };\r\n\r\n /**\r\n * attach this feature\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n const reflectionFormat = this.options.reflectionFormat ?? (this._xrSessionManager.session.preferredReflectionFormat || \"srgba8\");\r\n this.options.reflectionFormat = reflectionFormat;\r\n this._xrSessionManager.session\r\n .requestLightProbe({\r\n reflectionFormat,\r\n })\r\n .then((xrLightProbe: XRLightProbe) => {\r\n this._xrLightProbe = xrLightProbe;\r\n if (!this.options.disableCubeMapReflection) {\r\n if (!this._reflectionCubeMap) {\r\n this._reflectionCubeMap = new BaseTexture(this._xrSessionManager.scene);\r\n this._reflectionCubeMap.isCube = true;\r\n this._reflectionCubeMap.coordinatesMode = Constants.TEXTURE_CUBIC_MODE;\r\n if (this.options.setSceneEnvironmentTexture) {\r\n this._xrSessionManager.scene.environmentTexture = this._reflectionCubeMap;\r\n }\r\n }\r\n this._xrLightProbe.addEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n }\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n const detached = super.detach();\r\n\r\n if (this._xrLightProbe !== null && !this.options.disableCubeMapReflection) {\r\n this._xrLightProbe.removeEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n this._xrLightProbe = null;\r\n }\r\n\r\n this._canvasContext = null;\r\n this._xrLightEstimate = null;\r\n // When the session ends (on detach) we must clear our XRWebGLBinging instance, which references the ended session.\r\n this._xrWebGLBinding = null;\r\n\r\n return detached;\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 super.dispose();\r\n\r\n this.onReflectionCubeMapUpdatedObservable.clear();\r\n\r\n if (this.directionalLight) {\r\n this.directionalLight.dispose();\r\n this.directionalLight = null;\r\n }\r\n\r\n if (this._reflectionCubeMap !== null) {\r\n if (this._reflectionCubeMap._texture) {\r\n this._reflectionCubeMap._texture.dispose();\r\n }\r\n this._reflectionCubeMap.dispose();\r\n this._reflectionCubeMap = null;\r\n }\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n if (this._xrLightProbe !== null) {\r\n if (this.options.lightEstimationPollInterval) {\r\n const now = Date.now();\r\n if (now - this._lightEstimationPollTime < this.options.lightEstimationPollInterval) {\r\n return;\r\n }\r\n this._lightEstimationPollTime = now;\r\n }\r\n this._xrLightEstimate = _xrFrame.getLightEstimate(this._xrLightProbe);\r\n if (this._xrLightEstimate) {\r\n this._intensity = Math.max(\r\n 1.0,\r\n this._xrLightEstimate.primaryLightIntensity.x,\r\n this._xrLightEstimate.primaryLightIntensity.y,\r\n this._xrLightEstimate.primaryLightIntensity.z\r\n );\r\n\r\n const rhsFactor = this._xrSessionManager.scene.useRightHandedSystem ? 1.0 : -1.0;\r\n\r\n // recreate the vector caches, so that the last one provided to the user will persist\r\n if (this.options.disableVectorReuse) {\r\n this._lightDirection = new Vector3();\r\n this._lightColor = new Color3();\r\n if (this.directionalLight) {\r\n this.directionalLight.direction = this._lightDirection;\r\n this.directionalLight.diffuse = this._lightColor;\r\n }\r\n }\r\n\r\n this._lightDirection.copyFromFloats(\r\n this._xrLightEstimate.primaryLightDirection.x,\r\n this._xrLightEstimate.primaryLightDirection.y,\r\n this._xrLightEstimate.primaryLightDirection.z * rhsFactor\r\n );\r\n this._lightColor.copyFromFloats(\r\n this._xrLightEstimate.primaryLightIntensity.x / this._intensity,\r\n this._xrLightEstimate.primaryLightIntensity.y / this._intensity,\r\n this._xrLightEstimate.primaryLightIntensity.z / this._intensity\r\n );\r\n this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients);\r\n if (this._reflectionCubeMap && !this.options.disableSphericalPolynomial) {\r\n this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new SphericalPolynomial();\r\n this._reflectionCubeMap.sphericalPolynomial?.updateFromHarmonics(this._sphericalHarmonics);\r\n }\r\n\r\n // direction from instead of direction to\r\n this._lightDirection.negateInPlace();\r\n // set the values after calculating them\r\n if (this.directionalLight) {\r\n this.directionalLight.direction.copyFrom(this._lightDirection);\r\n this.directionalLight.intensity = Math.min(this._intensity, 1.0);\r\n this.directionalLight.diffuse.copyFrom(this._lightColor);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n// register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRLightEstimation.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRLightEstimation(xrSessionManager, options);\r\n },\r\n WebXRLightEstimation.Version,\r\n false\r\n);\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRLightEstimation.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/XR/features/WebXRLightEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,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AAI,mBAAmB,EAAE,CAAC;oBACvH,MAAA,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,0CAAE,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;iBAC9F;gBAED,yCAAyC;gBACzC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;gBACrC,wCAAwC;gBACxC,IAAI,IAAI,CAAC,gBAAgB,EAAE;oBACvB,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;oBAC/D,IAAI,CAAC,gBAAgB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;oBACjE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBAC5D;aACJ;SACJ;IACL,CAAC;;AAlRD;;GAEG;AACoB,yBAAI,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;AAChE;;;;GAIG;AACoB,4BAAO,GAAG,CAAC,CAAC;AA4QvC,sBAAsB;AACtB,oBAAoB,CAAC,eAAe,CAChC,oBAAoB,CAAC,IAAI,EACzB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC,EACD,oBAAoB,CAAC,OAAO,EAC5B,KAAK,CACR,CAAC","sourcesContent":["import { WebGLHardwareTexture } from \"../../Engines/WebGL/webGLHardwareTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"../../Materials/Textures/internalTexture\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { WebXRFeatureName, WebXRFeaturesManager } from \"../webXRFeaturesManager\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { DirectionalLight } from \"../../Lights/directionalLight\";\r\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\nimport { LightConstants } from \"../../Lights/lightConstants\";\r\n\r\n/**\r\n * Options for Light Estimation feature\r\n */\r\nexport interface IWebXRLightEstimationOptions {\r\n /**\r\n * Disable the cube map reflection feature. In this case only light direction and color will be updated\r\n */\r\n disableCubeMapReflection?: boolean;\r\n /**\r\n * Should the scene's env texture be set to the cube map reflection texture\r\n * Note that this doesn't work is disableCubeMapReflection if set to false\r\n */\r\n setSceneEnvironmentTexture?: boolean;\r\n /**\r\n * How often should the cubemap update in ms.\r\n * If not set the cubemap will be updated every time the underlying system updates the environment texture.\r\n */\r\n cubeMapPollInterval?: number;\r\n /**\r\n * How often should the light estimation properties update in ms.\r\n * If not set the light estimation properties will be updated on every frame (depending on the underlying system)\r\n */\r\n lightEstimationPollInterval?: number;\r\n /**\r\n * Should a directional light source be created.\r\n * If created, this light source will be updated whenever the light estimation values change\r\n */\r\n createDirectionalLightSource?: boolean;\r\n /**\r\n * Define the format to be used for the light estimation texture.\r\n */\r\n reflectionFormat?: XRReflectionFormat;\r\n /**\r\n * Should the light estimation's needed vectors be constructed on each frame.\r\n * Use this when you use those vectors and don't want their values to change outside of the light estimation feature\r\n */\r\n disableVectorReuse?: boolean;\r\n\r\n /**\r\n * disable applying the spherical polynomial to the cube map texture\r\n */\r\n disableSphericalPolynomial?: boolean;\r\n}\r\n\r\n/**\r\n * An interface describing the result of a light estimation\r\n */\r\nexport interface IWebXRLightEstimation {\r\n /**\r\n * The intensity of the light source\r\n */\r\n lightIntensity: number;\r\n /**\r\n * Color of light source\r\n */\r\n lightColor: Color3;\r\n /**\r\n * The direction from the light source\r\n */\r\n lightDirection: Vector3;\r\n /**\r\n * Spherical harmonics coefficients of the light source\r\n */\r\n sphericalHarmonics: SphericalHarmonics;\r\n}\r\n\r\n/**\r\n * Light Estimation Feature\r\n *\r\n * @since 5.0.0\r\n */\r\nexport class WebXRLightEstimation extends WebXRAbstractFeature {\r\n private _canvasContext: Nullable<WebGLRenderingContext | WebGL2RenderingContext> = null;\r\n private _reflectionCubeMap: Nullable<BaseTexture> = null;\r\n private _xrLightEstimate: Nullable<XRLightEstimate> = null;\r\n private _xrLightProbe: Nullable<XRLightProbe> = null;\r\n private _xrWebGLBinding: Nullable<XRWebGLBinding> = null;\r\n private _lightDirection: Vector3 = Vector3.Up().negateInPlace();\r\n private _lightColor: Color3 = Color3.White();\r\n private _intensity: number = 1;\r\n private _sphericalHarmonics: SphericalHarmonics = new SphericalHarmonics();\r\n private _cubeMapPollTime = Date.now();\r\n private _lightEstimationPollTime = Date.now();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.LIGHT_ESTIMATION;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * ARCore's reflection cube map size is 16x16.\r\n * Once other systems support this feature we will need to change this to be dynamic.\r\n * see https://github.com/immersive-web/lighting-estimation/blob/main/lighting-estimation-explainer.md#cube-map-open-questions\r\n */\r\n private _reflectionCubeMapTextureSize: number = 16;\r\n\r\n /**\r\n * If createDirectionalLightSource is set to true this light source will be created automatically.\r\n * Otherwise this can be set with an external directional light source.\r\n * This light will be updated whenever the light estimation values change.\r\n */\r\n public directionalLight: Nullable<DirectionalLight> = null;\r\n\r\n /**\r\n * This observable will notify when the reflection cube map is updated.\r\n */\r\n public onReflectionCubeMapUpdatedObservable: Observable<BaseTexture> = new Observable();\r\n\r\n /**\r\n * Creates a new instance of the light estimation feature\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n * @param options options to use when constructing this feature\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /**\r\n * options to use when constructing this feature\r\n */\r\n public readonly options: IWebXRLightEstimationOptions\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"light-estimation\";\r\n\r\n if (this.options.createDirectionalLightSource) {\r\n this.directionalLight = new DirectionalLight(\"light estimation directional\", this._lightDirection, this._xrSessionManager.scene);\r\n this.directionalLight.position = new Vector3(0, 8, 0);\r\n // intensity will be set later\r\n this.directionalLight.intensity = 0;\r\n this.directionalLight.falloffType = LightConstants.FALLOFF_GLTF;\r\n }\r\n\r\n // https://immersive-web.github.io/lighting-estimation/\r\n Tools.Warn(\"light-estimation is an experimental and unstable feature.\");\r\n }\r\n\r\n /**\r\n * While the estimated cube map is expected to update over time to better reflect the user's environment as they move around those changes are unlikely to happen with every XRFrame.\r\n * Since creating and processing the cube map is potentially expensive, especially if mip maps are needed, you can listen to the onReflectionCubeMapUpdatedObservable to determine\r\n * when it has been updated.\r\n */\r\n public get reflectionCubeMapTexture(): Nullable<BaseTexture> {\r\n return this._reflectionCubeMap;\r\n }\r\n\r\n /**\r\n * The most recent light estimate. Available starting on the first frame where the device provides a light probe.\r\n */\r\n public get xrLightingEstimate(): Nullable<IWebXRLightEstimation> {\r\n if (this._xrLightEstimate) {\r\n return {\r\n lightColor: this._lightColor,\r\n lightDirection: this._lightDirection,\r\n lightIntensity: this._intensity,\r\n sphericalHarmonics: this._sphericalHarmonics,\r\n };\r\n }\r\n return this._xrLightEstimate;\r\n }\r\n\r\n private _getCanvasContext(): WebGLRenderingContext | WebGL2RenderingContext {\r\n if (this._canvasContext === null) {\r\n this._canvasContext = this._xrSessionManager.scene.getEngine()._gl;\r\n }\r\n return this._canvasContext;\r\n }\r\n\r\n private _getXRGLBinding(): XRWebGLBinding {\r\n if (this._xrWebGLBinding === null) {\r\n const context = this._getCanvasContext();\r\n this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session, context);\r\n }\r\n return this._xrWebGLBinding;\r\n }\r\n\r\n /**\r\n * Event Listener for \"reflectionchange\" events.\r\n */\r\n private _updateReflectionCubeMap = (): void => {\r\n if (!this._xrLightProbe) {\r\n return;\r\n }\r\n // check poll time, do not update if it has not been long enough\r\n if (this.options.cubeMapPollInterval) {\r\n const now = Date.now();\r\n if (now - this._cubeMapPollTime < this.options.cubeMapPollInterval) {\r\n return;\r\n }\r\n this._cubeMapPollTime = now;\r\n }\r\n const lp = this._getXRGLBinding().getReflectionCubeMap(this._xrLightProbe);\r\n if (lp && this._reflectionCubeMap) {\r\n if (!this._reflectionCubeMap._texture) {\r\n const internalTexture = new InternalTexture(this._xrSessionManager.scene.getEngine(), InternalTextureSource.Unknown);\r\n internalTexture.isCube = true;\r\n internalTexture.invertY = false;\r\n internalTexture._useSRGBBuffer = this.options.reflectionFormat === \"srgba8\";\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.generateMipMaps = true;\r\n internalTexture.type = this.options.reflectionFormat !== \"srgba8\" ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n internalTexture.samplingMode = Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR;\r\n internalTexture.width = this._reflectionCubeMapTextureSize;\r\n internalTexture.height = this._reflectionCubeMapTextureSize;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n internalTexture._hardwareTexture = new WebGLHardwareTexture(lp, this._getCanvasContext() as WebGLRenderingContext);\r\n this._reflectionCubeMap._texture = internalTexture;\r\n } else {\r\n this._reflectionCubeMap._texture._hardwareTexture?.set(lp);\r\n this._reflectionCubeMap._texture.getEngine().resetTextureCache();\r\n }\r\n this._reflectionCubeMap._texture.isReady = true;\r\n this._xrSessionManager.scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n\r\n this.onReflectionCubeMapUpdatedObservable.notifyObservers(this._reflectionCubeMap);\r\n }\r\n };\r\n\r\n /**\r\n * attach this feature\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n const reflectionFormat = this.options.reflectionFormat ?? (this._xrSessionManager.session.preferredReflectionFormat || \"srgba8\");\r\n this.options.reflectionFormat = reflectionFormat;\r\n this._xrSessionManager.session\r\n .requestLightProbe({\r\n reflectionFormat,\r\n })\r\n .then((xrLightProbe: XRLightProbe) => {\r\n this._xrLightProbe = xrLightProbe;\r\n if (!this.options.disableCubeMapReflection) {\r\n if (!this._reflectionCubeMap) {\r\n this._reflectionCubeMap = new BaseTexture(this._xrSessionManager.scene);\r\n this._reflectionCubeMap._isCube = true;\r\n this._reflectionCubeMap.coordinatesMode = Constants.TEXTURE_CUBIC_MODE;\r\n if (this.options.setSceneEnvironmentTexture) {\r\n this._xrSessionManager.scene.environmentTexture = this._reflectionCubeMap;\r\n }\r\n }\r\n this._xrLightProbe.addEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n }\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n const detached = super.detach();\r\n\r\n if (this._xrLightProbe !== null && !this.options.disableCubeMapReflection) {\r\n this._xrLightProbe.removeEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n this._xrLightProbe = null;\r\n }\r\n\r\n this._canvasContext = null;\r\n this._xrLightEstimate = null;\r\n // When the session ends (on detach) we must clear our XRWebGLBinging instance, which references the ended session.\r\n this._xrWebGLBinding = null;\r\n\r\n return detached;\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 super.dispose();\r\n\r\n this.onReflectionCubeMapUpdatedObservable.clear();\r\n\r\n if (this.directionalLight) {\r\n this.directionalLight.dispose();\r\n this.directionalLight = null;\r\n }\r\n\r\n if (this._reflectionCubeMap !== null) {\r\n if (this._reflectionCubeMap._texture) {\r\n this._reflectionCubeMap._texture.dispose();\r\n }\r\n this._reflectionCubeMap.dispose();\r\n this._reflectionCubeMap = null;\r\n }\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n if (this._xrLightProbe !== null) {\r\n if (this.options.lightEstimationPollInterval) {\r\n const now = Date.now();\r\n if (now - this._lightEstimationPollTime < this.options.lightEstimationPollInterval) {\r\n return;\r\n }\r\n this._lightEstimationPollTime = now;\r\n }\r\n this._xrLightEstimate = _xrFrame.getLightEstimate(this._xrLightProbe);\r\n if (this._xrLightEstimate) {\r\n this._intensity = Math.max(\r\n 1.0,\r\n this._xrLightEstimate.primaryLightIntensity.x,\r\n this._xrLightEstimate.primaryLightIntensity.y,\r\n this._xrLightEstimate.primaryLightIntensity.z\r\n );\r\n\r\n const rhsFactor = this._xrSessionManager.scene.useRightHandedSystem ? 1.0 : -1.0;\r\n\r\n // recreate the vector caches, so that the last one provided to the user will persist\r\n if (this.options.disableVectorReuse) {\r\n this._lightDirection = new Vector3();\r\n this._lightColor = new Color3();\r\n if (this.directionalLight) {\r\n this.directionalLight.direction = this._lightDirection;\r\n this.directionalLight.diffuse = this._lightColor;\r\n }\r\n }\r\n\r\n this._lightDirection.copyFromFloats(\r\n this._xrLightEstimate.primaryLightDirection.x,\r\n this._xrLightEstimate.primaryLightDirection.y,\r\n this._xrLightEstimate.primaryLightDirection.z * rhsFactor\r\n );\r\n this._lightColor.copyFromFloats(\r\n this._xrLightEstimate.primaryLightIntensity.x / this._intensity,\r\n this._xrLightEstimate.primaryLightIntensity.y / this._intensity,\r\n this._xrLightEstimate.primaryLightIntensity.z / this._intensity\r\n );\r\n this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients);\r\n if (this._reflectionCubeMap && !this.options.disableSphericalPolynomial) {\r\n this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new SphericalPolynomial();\r\n this._reflectionCubeMap.sphericalPolynomial?.updateFromHarmonics(this._sphericalHarmonics);\r\n }\r\n\r\n // direction from instead of direction to\r\n this._lightDirection.negateInPlace();\r\n // set the values after calculating them\r\n if (this.directionalLight) {\r\n this.directionalLight.direction.copyFrom(this._lightDirection);\r\n this.directionalLight.intensity = Math.min(this._intensity, 1.0);\r\n this.directionalLight.diffuse.copyFrom(this._lightColor);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n// register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRLightEstimation.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRLightEstimation(xrSessionManager, options);\r\n },\r\n WebXRLightEstimation.Version,\r\n false\r\n);\r\n"]}
|
package/XR/webXRInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRInput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAwC/F;;GAEG;AACH,MAAM,OAAO,UAAU;IAiBnB;;;;;OAKG;IACH;IACI;;OAEG;IACI,gBAAqC;IAC5C;;OAEG;IACI,QAAqB,EACX,WAA+B,EAAE;QAL3C,qBAAgB,GAAhB,gBAAgB,CAAqB;QAIrC,aAAQ,GAAR,QAAQ,CAAa;QACX,aAAQ,GAAR,QAAQ,CAAyB;QA/BtD;;WAEG;QACI,gBAAW,GAA4B,EAAE,CAAC;QAIjD;;WAEG;QACI,gCAA2B,GAAG,IAAI,UAAU,EAAoB,CAAC;QACxE;;WAEG;QACI,kCAA6B,GAAG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CAAC;QACvD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5C,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC3B;iBAAM;gBACH,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC9B;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC;QACnC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7B,IAAI,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,CAAC,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtE,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACxE,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC1E,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,6BAA6B,CAAC,KAAK,EAAE,CAAC;QAE3C,6BAA6B;QAC7B,4BAA4B,CAAC,oBAAoB,EAAE,CAAC;IACxD,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport type { IWebXRControllerOptions } from \"./webXRInputSource\";\r\nimport { WebXRInputSource } from \"./webXRInputSource\";\r\nimport type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport type { WebXRCamera } from \"./webXRCamera\";\r\nimport { WebXRMotionControllerManager } from \"./motionController/webXRMotionControllerManager\";\r\n\r\n/**\r\n * The schema for initialization options of the XR Input class\r\n */\r\nexport interface IWebXRInputOptions {\r\n /**\r\n * If set to true no model will be automatically loaded\r\n */\r\n doNotLoadControllerMeshes?: boolean;\r\n\r\n /**\r\n * If set, this profile will be used for all controllers loaded (for example \"microsoft-mixed-reality\")\r\n * If not found, the xr input profile data will be used.\r\n * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/\r\n */\r\n forceInputProfile?: string;\r\n\r\n /**\r\n * Do not send a request to the controller repository to load the profile.\r\n *\r\n * Instead, use the controllers available in babylon itself.\r\n */\r\n disableOnlineControllerRepository?: boolean;\r\n\r\n /**\r\n * A custom URL for the controllers repository\r\n */\r\n customControllersRepositoryURL?: string;\r\n\r\n /**\r\n * Should the controller model's components not move according to the user input\r\n */\r\n disableControllerAnimation?: boolean;\r\n\r\n /**\r\n * Optional options to pass to the controller. Will be overridden by the Input options where applicable\r\n */\r\n controllerOptions?: IWebXRControllerOptions;\r\n}\r\n/**\r\n * XR input used to track XR inputs such as controllers/rays\r\n */\r\nexport class WebXRInput implements IDisposable {\r\n /**\r\n * XR controllers being tracked\r\n */\r\n public controllers: Array<WebXRInputSource> = [];\r\n private _frameObserver: Nullable<Observer<any>>;\r\n private _sessionEndedObserver: Nullable<Observer<any>>;\r\n private _sessionInitObserver: Nullable<Observer<any>>;\r\n /**\r\n * Event when a controller has been connected/added\r\n */\r\n public onControllerAddedObservable = new Observable<WebXRInputSource>();\r\n /**\r\n * Event when a controller has been removed/disconnected\r\n */\r\n public onControllerRemovedObservable = new Observable<WebXRInputSource>();\r\n\r\n /**\r\n * Initializes the WebXRInput\r\n * @param xrSessionManager the xr session manager for this session\r\n * @param xrCamera the WebXR camera for this session. Mainly used for teleportation\r\n * @param _options = initialization options for this xr input\r\n */\r\n public constructor(\r\n /**\r\n * the xr session manager for this session\r\n */\r\n public xrSessionManager: WebXRSessionManager,\r\n /**\r\n * the WebXR camera for this session. Mainly used for teleportation\r\n */\r\n public xrCamera: WebXRCamera,\r\n private readonly _options: IWebXRInputOptions = {}\r\n ) {\r\n // Remove controllers when exiting XR\r\n this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(() => {\r\n this._addAndRemoveControllers(\r\n [],\r\n this.controllers.map((c) => {\r\n return c.inputSource;\r\n })\r\n );\r\n });\r\n\r\n this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((session) => {\r\n session.addEventListener(\"inputsourceschange\", this._onInputSourcesChange);\r\n });\r\n\r\n this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((frame) => {\r\n // Update controller pose info\r\n this.controllers.forEach((controller) => {\r\n controller.updateFromXRFrame(frame, this.xrSessionManager.referenceSpace, this.xrCamera);\r\n });\r\n });\r\n\r\n if (this._options.customControllersRepositoryURL) {\r\n WebXRMotionControllerManager.BaseRepositoryUrl = this._options.customControllersRepositoryURL;\r\n }\r\n\r\n WebXRMotionControllerManager.UseOnlineRepository = !this._options.disableOnlineControllerRepository;\r\n if (WebXRMotionControllerManager.UseOnlineRepository) {\r\n // pre-load the profiles list to load the controllers quicker afterwards\r\n try {\r\n WebXRMotionControllerManager.UpdateProfilesList().catch(() => {\r\n WebXRMotionControllerManager.UseOnlineRepository = false;\r\n });\r\n } catch (e) {\r\n WebXRMotionControllerManager.UseOnlineRepository = false;\r\n }\r\n }\r\n }\r\n\r\n private _onInputSourcesChange = (event: XRInputSourceChangeEvent) => {\r\n this._addAndRemoveControllers(event.added, event.removed);\r\n };\r\n\r\n private _addAndRemoveControllers(addInputs: Array<XRInputSource>, removeInputs: Array<XRInputSource>) {\r\n // Add controllers if they don't already exist\r\n const sources = this.controllers.map((c) => {\r\n return c.inputSource;\r\n });\r\n for (const input of addInputs) {\r\n if (sources.indexOf(input) === -1) {\r\n const controller = new WebXRInputSource(this.xrSessionManager.scene, input, {\r\n ...(this._options.controllerOptions || {}),\r\n forceControllerProfile: this._options.forceInputProfile,\r\n doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes,\r\n disableMotionControllerAnimation: this._options.disableControllerAnimation,\r\n });\r\n this.controllers.push(controller);\r\n this.onControllerAddedObservable.notifyObservers(controller);\r\n }\r\n }\r\n\r\n // Remove and dispose of controllers to be disposed\r\n const keepControllers: Array<WebXRInputSource> = [];\r\n const removedControllers: Array<WebXRInputSource> = [];\r\n this.controllers.forEach((c) => {\r\n if (removeInputs.indexOf(c.inputSource) === -1) {\r\n keepControllers.push(c);\r\n } else {\r\n removedControllers.push(c);\r\n }\r\n });\r\n this.controllers = keepControllers;\r\n removedControllers.forEach((c) => {\r\n this.onControllerRemovedObservable.notifyObservers(c);\r\n c.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n this.controllers.forEach((c) => {\r\n c.dispose();\r\n });\r\n this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver);\r\n this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver);\r\n this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver);\r\n this.onControllerAddedObservable.clear();\r\n this.onControllerRemovedObservable.clear();\r\n\r\n // clear the controller cache\r\n WebXRMotionControllerManager.ClearControllerCache();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRInput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAwC/F;;GAEG;AACH,MAAM,OAAO,UAAU;I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AgB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC1E,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,6BAA6B,CAAC,KAAK,EAAE,CAAC;QAE3C,6BAA6B;QAC7B,4BAA4B,CAAC,oBAAoB,EAAE,CAAC;IACxD,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport type { IWebXRControllerOptions } from \"./webXRInputSource\";\r\nimport { WebXRInputSource } from \"./webXRInputSource\";\r\nimport type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport type { WebXRCamera } from \"./webXRCamera\";\r\nimport { WebXRMotionControllerManager } from \"./motionController/webXRMotionControllerManager\";\r\n\r\n/**\r\n * The schema for initialization options of the XR Input class\r\n */\r\nexport interface IWebXRInputOptions {\r\n /**\r\n * If set to true no model will be automatically loaded\r\n */\r\n doNotLoadControllerMeshes?: boolean;\r\n\r\n /**\r\n * If set, this profile will be used for all controllers loaded (for example \"microsoft-mixed-reality\")\r\n * If not found, the xr input profile data will be used.\r\n * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/\r\n */\r\n forceInputProfile?: string;\r\n\r\n /**\r\n * Do not send a request to the controller repository to load the profile.\r\n *\r\n * Instead, use the controllers available in babylon itself.\r\n */\r\n disableOnlineControllerRepository?: boolean;\r\n\r\n /**\r\n * A custom URL for the controllers repository\r\n */\r\n customControllersRepositoryURL?: string;\r\n\r\n /**\r\n * Should the controller model's components not move according to the user input\r\n */\r\n disableControllerAnimation?: boolean;\r\n\r\n /**\r\n * Optional options to pass to the controller. Will be overridden by the Input options where applicable\r\n */\r\n controllerOptions?: IWebXRControllerOptions;\r\n}\r\n/**\r\n * XR input used to track XR inputs such as controllers/rays\r\n */\r\nexport class WebXRInput implements IDisposable {\r\n /**\r\n * XR controllers being tracked\r\n */\r\n public controllers: Array<WebXRInputSource> = [];\r\n private _frameObserver: Nullable<Observer<any>>;\r\n private _sessionEndedObserver: Nullable<Observer<any>>;\r\n private _sessionInitObserver: Nullable<Observer<any>>;\r\n /**\r\n * Event when a controller has been connected/added\r\n */\r\n public onControllerAddedObservable = new Observable<WebXRInputSource>();\r\n /**\r\n * Event when a controller has been removed/disconnected\r\n */\r\n public onControllerRemovedObservable = new Observable<WebXRInputSource>();\r\n\r\n /**\r\n * Initializes the WebXRInput\r\n * @param xrSessionManager the xr session manager for this session\r\n * @param xrCamera the WebXR camera for this session. Mainly used for teleportation\r\n * @param _options = initialization options for this xr input\r\n */\r\n public constructor(\r\n /**\r\n * the xr session manager for this session\r\n */\r\n public xrSessionManager: WebXRSessionManager,\r\n /**\r\n * the WebXR camera for this session. Mainly used for teleportation\r\n */\r\n public xrCamera: WebXRCamera,\r\n private readonly _options: IWebXRInputOptions = {}\r\n ) {\r\n // Remove controllers when exiting XR\r\n this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(() => {\r\n this._addAndRemoveControllers(\r\n [],\r\n this.controllers.map((c) => {\r\n return c.inputSource;\r\n })\r\n );\r\n });\r\n\r\n this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((session) => {\r\n session.addEventListener(\"inputsourceschange\", this._onInputSourcesChange);\r\n });\r\n\r\n this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((frame) => {\r\n // Update controller pose info\r\n this.controllers.forEach((controller) => {\r\n controller.updateFromXRFrame(frame, this.xrSessionManager.referenceSpace, this.xrCamera);\r\n });\r\n });\r\n\r\n if (this._options.customControllersRepositoryURL) {\r\n WebXRMotionControllerManager.BaseRepositoryUrl = this._options.customControllersRepositoryURL;\r\n }\r\n\r\n WebXRMotionControllerManager.UseOnlineRepository = !this._options.disableOnlineControllerRepository;\r\n if (WebXRMotionControllerManager.UseOnlineRepository) {\r\n // pre-load the profiles list to load the controllers quicker afterwards\r\n try {\r\n WebXRMotionControllerManager.UpdateProfilesList().catch(() => {\r\n WebXRMotionControllerManager.UseOnlineRepository = false;\r\n });\r\n } catch (e) {\r\n WebXRMotionControllerManager.UseOnlineRepository = false;\r\n }\r\n }\r\n }\r\n\r\n private _onInputSourcesChange = (event: XRInputSourceChangeEvent) => {\r\n this._addAndRemoveControllers(event.added, event.removed);\r\n };\r\n\r\n private _addAndRemoveControllers(addInputs: readonly XRInputSource[], removeInputs: readonly XRInputSource[]) {\r\n // Add controllers if they don't already exist\r\n const sources = this.controllers.map((c) => {\r\n return c.inputSource;\r\n });\r\n for (const input of addInputs) {\r\n if (sources.indexOf(input) === -1) {\r\n const controller = new WebXRInputSource(this.xrSessionManager.scene, input, {\r\n ...(this._options.controllerOptions || {}),\r\n forceControllerProfile: this._options.forceInputProfile,\r\n doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes,\r\n disableMotionControllerAnimation: this._options.disableControllerAnimation,\r\n });\r\n this.controllers.push(controller);\r\n this.onControllerAddedObservable.notifyObservers(controller);\r\n }\r\n }\r\n\r\n // Remove and dispose of controllers to be disposed\r\n const keepControllers: Array<WebXRInputSource> = [];\r\n const removedControllers: Array<WebXRInputSource> = [];\r\n this.controllers.forEach((c) => {\r\n if (removeInputs.indexOf(c.inputSource) === -1) {\r\n keepControllers.push(c);\r\n } else {\r\n removedControllers.push(c);\r\n }\r\n });\r\n this.controllers = keepControllers;\r\n removedControllers.forEach((c) => {\r\n this.onControllerRemovedObservable.notifyObservers(c);\r\n c.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n this.controllers.forEach((c) => {\r\n c.dispose();\r\n });\r\n this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver);\r\n this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver);\r\n this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver);\r\n this.onControllerAddedObservable.clear();\r\n this.onControllerRemovedObservable.clear();\r\n\r\n // clear the controller cache\r\n WebXRMotionControllerManager.ClearControllerCache();\r\n }\r\n}\r\n"]}
|
|
@@ -17,7 +17,6 @@ export class WebXRManagedOutputCanvasOptions {
|
|
|
17
17
|
depth: true,
|
|
18
18
|
stencil: engine ? engine.isStencilEnable : true,
|
|
19
19
|
alpha: true,
|
|
20
|
-
multiview: false,
|
|
21
20
|
framebufferScaleFactor: 1,
|
|
22
21
|
};
|
|
23
22
|
defaults.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRManagedOutputCanvas.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRManagedOutputCanvas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAexC;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,MAAmB;QACzC,MAAM,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAC;QACvD,QAAQ,CAAC,aAAa,GAAG;YACrB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI;YAC/C,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,KAAK;YAChB,sBAAsB,EAAE,CAAC;SAC5B,CAAC;QAEF,QAAQ,CAAC,iBAAiB,GAAG,qGAAqG,CAAC;QAEnI,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AACD;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAyBjC;;;;OAIG;IACH,YAAY,iBAAsC,EAAU,WAA4C,+BAA+B,CAAC,WAAW,EAAE;QAAzF,aAAQ,GAAR,QA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AAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC;iBACtE;qBAAM;oBACH,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;iBACzF;aACJ;SACJ;IACL,CAAC;IAEO,uBAAuB,CAAC,MAAmC;QAC/D,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE;YACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,aAAqB,GAAG,IAAI,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,mBAAmB,GAAG;gBACvB,KAAK,EAAE,MAAM,CAAC,WAAW;gBACzB,MAAM,EAAE,MAAM,CAAC,YAAY;aAC9B,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,CAAC,aAAa,GAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC5D,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACrB,IAAI,CAAC,aAAa,GAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC9D;SACJ;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRWebGLLayerWrapper } from \"./webXRWebGLLayer\";\r\n\r\n/**\r\n * Configuration object for WebXR output canvas\r\n */\r\nexport class WebXRManagedOutputCanvasOptions {\r\n /**\r\n * An optional canvas in case you wish to create it yourself and provide it here.\r\n * If not provided, a new canvas will be created\r\n */\r\n public canvasElement?: HTMLCanvasElement;\r\n /**\r\n * Options for this XR Layer output\r\n */\r\n public canvasOptions?: XRWebGLLayerInit;\r\n /**\r\n * CSS styling for a newly created canvas (if not provided)\r\n */\r\n public newCanvasCssStyle?: string;\r\n\r\n /**\r\n * Get the default values of the configuration object\r\n * @param engine defines the engine to use (can be null)\r\n * @returns default values of this configuration object\r\n */\r\n public static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions {\r\n const defaults = new WebXRManagedOutputCanvasOptions();\r\n defaults.canvasOptions = {\r\n antialias: true,\r\n depth: true,\r\n stencil: engine ? engine.isStencilEnable : true,\r\n alpha: true,\r\n multiview: false,\r\n framebufferScaleFactor: 1,\r\n };\r\n\r\n defaults.newCanvasCssStyle = \"position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;\";\r\n\r\n return defaults;\r\n }\r\n}\r\n/**\r\n * Creates a canvas that is added/removed from the webpage when entering/exiting XR\r\n */\r\nexport class WebXRManagedOutputCanvas implements WebXRRenderTarget {\r\n private _canvas: Nullable<HTMLCanvasElement> = null;\r\n private _engine: Nullable<ThinEngine> = null;\r\n private _originalCanvasSize: {\r\n width: number;\r\n height: number;\r\n };\r\n\r\n /**\r\n * Rendering context of the canvas which can be used to display/mirror xr content\r\n */\r\n public canvasContext: WebGLRenderingContext;\r\n\r\n /**\r\n * xr layer for the canvas\r\n */\r\n public xrLayer: Nullable<XRWebGLLayer> = null;\r\n\r\n private _xrLayerWrapper: Nullable<WebXRLayerWrapper> = null;\r\n\r\n /**\r\n * Observers registered here will be triggered when the xr layer was initialized\r\n */\r\n public onXRLayerInitObservable: Observable<XRWebGLLayer> = new Observable();\r\n\r\n /**\r\n * Initializes the canvas to be added/removed upon entering/exiting xr\r\n * @param _xrSessionManager The XR Session manager\r\n * @param _options optional configuration for this canvas output. defaults will be used if not provided\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, private _options: WebXRManagedOutputCanvasOptions = WebXRManagedOutputCanvasOptions.GetDefaults()) {\r\n this._engine = _xrSessionManager.scene.getEngine();\r\n this._engine.onDisposeObservable.addOnce(() => {\r\n this._engine = null;\r\n });\r\n\r\n if (!_options.canvasElement) {\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.style.cssText = this._options.newCanvasCssStyle || \"position:absolute; bottom:0px;right:0px;\";\r\n this._setManagedOutputCanvas(canvas);\r\n } else {\r\n this._setManagedOutputCanvas(_options.canvasElement);\r\n }\r\n\r\n _xrSessionManager.onXRSessionInit.add(() => {\r\n this._addCanvas();\r\n });\r\n\r\n _xrSessionManager.onXRSessionEnded.add(() => {\r\n this._removeCanvas();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n this._removeCanvas();\r\n this._setManagedOutputCanvas(null);\r\n }\r\n\r\n /**\r\n * Initializes a XRWebGLLayer to be used as the session's baseLayer.\r\n * @param xrSession xr session\r\n * @returns a promise that will resolve once the XR Layer has been created\r\n */\r\n public async initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer> {\r\n const createLayer = () => {\r\n this.xrLayer = new XRWebGLLayer(xrSession, this.canvasContext, this._options.canvasOptions);\r\n this._xrLayerWrapper = new WebXRWebGLLayerWrapper(this.xrLayer);\r\n this.onXRLayerInitObservable.notifyObservers(this.xrLayer);\r\n return this.xrLayer;\r\n };\r\n\r\n // support canvases without makeXRCompatible\r\n if (!(this.canvasContext as any).makeXRCompatible) {\r\n return Promise.resolve(createLayer());\r\n }\r\n\r\n return (this.canvasContext as any)\r\n .makeXRCompatible()\r\n .then(\r\n // catch any error and continue. When using the emulator is throws this error for no apparent reason.\r\n () => {},\r\n () => {\r\n // log the error, continue nonetheless!\r\n Tools.Warn(\"Error executing makeXRCompatible. This does not mean that the session will work incorrectly.\");\r\n }\r\n )\r\n .then(() => {\r\n return createLayer();\r\n });\r\n }\r\n\r\n private _addCanvas() {\r\n if (this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas()) {\r\n document.body.appendChild(this._canvas);\r\n }\r\n if (this.xrLayer) {\r\n this._setCanvasSize(true);\r\n } else {\r\n this.onXRLayerInitObservable.addOnce(() => {\r\n this._setCanvasSize(true);\r\n });\r\n }\r\n }\r\n\r\n private _removeCanvas() {\r\n if (this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas()) {\r\n document.body.removeChild(this._canvas);\r\n }\r\n this._setCanvasSize(false);\r\n }\r\n\r\n private _setCanvasSize(init: boolean = true, xrLayer = this._xrLayerWrapper) {\r\n if (!this._canvas || !this._engine) {\r\n return;\r\n }\r\n if (init) {\r\n if (xrLayer) {\r\n if (this._canvas !== this._engine.getRenderingCanvas()) {\r\n this._canvas.style.width = xrLayer.getWidth() + \"px\";\r\n this._canvas.style.height = xrLayer.getHeight() + \"px\";\r\n } else {\r\n this._engine.setSize(xrLayer.getWidth(), xrLayer.getHeight());\r\n }\r\n }\r\n } else {\r\n if (this._originalCanvasSize) {\r\n if (this._canvas !== this._engine.getRenderingCanvas()) {\r\n this._canvas.style.width = this._originalCanvasSize.width + \"px\";\r\n this._canvas.style.height = this._originalCanvasSize.height + \"px\";\r\n } else {\r\n this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _setManagedOutputCanvas(canvas: Nullable<HTMLCanvasElement>) {\r\n this._removeCanvas();\r\n if (!canvas) {\r\n this._canvas = null;\r\n (this.canvasContext as any) = null;\r\n } else {\r\n this._originalCanvasSize = {\r\n width: canvas.offsetWidth,\r\n height: canvas.offsetHeight,\r\n };\r\n this._canvas = canvas;\r\n this.canvasContext = <any>this._canvas.getContext(\"webgl2\");\r\n if (!this.canvasContext) {\r\n this.canvasContext = <any>this._canvas.getContext(\"webgl\");\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRManagedOutputCanvas.js","sourceRoot":"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,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,mBAAmB,GAAG;gBACvB,KAAK,EAAE,MAAM,CAAC,WAAW;gBACzB,MAAM,EAAE,MAAM,CAAC,YAAY;aAC9B,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,CAAC,aAAa,GAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC5D,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACrB,IAAI,CAAC,aAAa,GAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC9D;SACJ;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { WebXRRenderTarget } from \"./webXRTypes\";\r\nimport type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRWebGLLayerWrapper } from \"./webXRWebGLLayer\";\r\n\r\n/**\r\n * Configuration object for WebXR output canvas\r\n */\r\nexport class WebXRManagedOutputCanvasOptions {\r\n /**\r\n * An optional canvas in case you wish to create it yourself and provide it here.\r\n * If not provided, a new canvas will be created\r\n */\r\n public canvasElement?: HTMLCanvasElement;\r\n /**\r\n * Options for this XR Layer output\r\n */\r\n public canvasOptions?: XRWebGLLayerInit;\r\n /**\r\n * CSS styling for a newly created canvas (if not provided)\r\n */\r\n public newCanvasCssStyle?: string;\r\n\r\n /**\r\n * Get the default values of the configuration object\r\n * @param engine defines the engine to use (can be null)\r\n * @returns default values of this configuration object\r\n */\r\n public static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions {\r\n const defaults = new WebXRManagedOutputCanvasOptions();\r\n defaults.canvasOptions = {\r\n antialias: true,\r\n depth: true,\r\n stencil: engine ? engine.isStencilEnable : true,\r\n alpha: true,\r\n framebufferScaleFactor: 1,\r\n };\r\n\r\n defaults.newCanvasCssStyle = \"position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;\";\r\n\r\n return defaults;\r\n }\r\n}\r\n/**\r\n * Creates a canvas that is added/removed from the webpage when entering/exiting XR\r\n */\r\nexport class WebXRManagedOutputCanvas implements WebXRRenderTarget {\r\n private _canvas: Nullable<HTMLCanvasElement> = null;\r\n private _engine: Nullable<ThinEngine> = null;\r\n private _originalCanvasSize: {\r\n width: number;\r\n height: number;\r\n };\r\n\r\n /**\r\n * Rendering context of the canvas which can be used to display/mirror xr content\r\n */\r\n public canvasContext: WebGLRenderingContext;\r\n\r\n /**\r\n * xr layer for the canvas\r\n */\r\n public xrLayer: Nullable<XRWebGLLayer> = null;\r\n\r\n private _xrLayerWrapper: Nullable<WebXRLayerWrapper> = null;\r\n\r\n /**\r\n * Observers registered here will be triggered when the xr layer was initialized\r\n */\r\n public onXRLayerInitObservable: Observable<XRWebGLLayer> = new Observable();\r\n\r\n /**\r\n * Initializes the canvas to be added/removed upon entering/exiting xr\r\n * @param _xrSessionManager The XR Session manager\r\n * @param _options optional configuration for this canvas output. defaults will be used if not provided\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, private _options: WebXRManagedOutputCanvasOptions = WebXRManagedOutputCanvasOptions.GetDefaults()) {\r\n this._engine = _xrSessionManager.scene.getEngine();\r\n this._engine.onDisposeObservable.addOnce(() => {\r\n this._engine = null;\r\n });\r\n\r\n if (!_options.canvasElement) {\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.style.cssText = this._options.newCanvasCssStyle || \"position:absolute; bottom:0px;right:0px;\";\r\n this._setManagedOutputCanvas(canvas);\r\n } else {\r\n this._setManagedOutputCanvas(_options.canvasElement);\r\n }\r\n\r\n _xrSessionManager.onXRSessionInit.add(() => {\r\n this._addCanvas();\r\n });\r\n\r\n _xrSessionManager.onXRSessionEnded.add(() => {\r\n this._removeCanvas();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the object\r\n */\r\n public dispose() {\r\n this._removeCanvas();\r\n this._setManagedOutputCanvas(null);\r\n }\r\n\r\n /**\r\n * Initializes a XRWebGLLayer to be used as the session's baseLayer.\r\n * @param xrSession xr session\r\n * @returns a promise that will resolve once the XR Layer has been created\r\n */\r\n public async initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer> {\r\n const createLayer = () => {\r\n this.xrLayer = new XRWebGLLayer(xrSession, this.canvasContext, this._options.canvasOptions);\r\n this._xrLayerWrapper = new WebXRWebGLLayerWrapper(this.xrLayer);\r\n this.onXRLayerInitObservable.notifyObservers(this.xrLayer);\r\n return this.xrLayer;\r\n };\r\n\r\n // support canvases without makeXRCompatible\r\n if (!(this.canvasContext as any).makeXRCompatible) {\r\n return Promise.resolve(createLayer());\r\n }\r\n\r\n return (this.canvasContext as any)\r\n .makeXRCompatible()\r\n .then(\r\n // catch any error and continue. When using the emulator is throws this error for no apparent reason.\r\n () => {},\r\n () => {\r\n // log the error, continue nonetheless!\r\n Tools.Warn(\"Error executing makeXRCompatible. This does not mean that the session will work incorrectly.\");\r\n }\r\n )\r\n .then(() => {\r\n return createLayer();\r\n });\r\n }\r\n\r\n private _addCanvas() {\r\n if (this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas()) {\r\n document.body.appendChild(this._canvas);\r\n }\r\n if (this.xrLayer) {\r\n this._setCanvasSize(true);\r\n } else {\r\n this.onXRLayerInitObservable.addOnce(() => {\r\n this._setCanvasSize(true);\r\n });\r\n }\r\n }\r\n\r\n private _removeCanvas() {\r\n if (this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas()) {\r\n document.body.removeChild(this._canvas);\r\n }\r\n this._setCanvasSize(false);\r\n }\r\n\r\n private _setCanvasSize(init: boolean = true, xrLayer = this._xrLayerWrapper) {\r\n if (!this._canvas || !this._engine) {\r\n return;\r\n }\r\n if (init) {\r\n if (xrLayer) {\r\n if (this._canvas !== this._engine.getRenderingCanvas()) {\r\n this._canvas.style.width = xrLayer.getWidth() + \"px\";\r\n this._canvas.style.height = xrLayer.getHeight() + \"px\";\r\n } else {\r\n this._engine.setSize(xrLayer.getWidth(), xrLayer.getHeight());\r\n }\r\n }\r\n } else {\r\n if (this._originalCanvasSize) {\r\n if (this._canvas !== this._engine.getRenderingCanvas()) {\r\n this._canvas.style.width = this._originalCanvasSize.width + \"px\";\r\n this._canvas.style.height = this._originalCanvasSize.height + \"px\";\r\n } else {\r\n this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _setManagedOutputCanvas(canvas: Nullable<HTMLCanvasElement>) {\r\n this._removeCanvas();\r\n if (!canvas) {\r\n this._canvas = null;\r\n (this.canvasContext as any) = null;\r\n } else {\r\n this._originalCanvasSize = {\r\n width: canvas.offsetWidth,\r\n height: canvas.offsetHeight,\r\n };\r\n this._canvas = canvas;\r\n this.canvasContext = <any>this._canvas.getContext(\"webgl2\");\r\n if (!this.canvasContext) {\r\n this.canvasContext = <any>this._canvas.getContext(\"webgl\");\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -29,6 +29,7 @@ export class WebXRLayerRenderTargetTextureProvider {
|
|
|
29
29
|
// Create render target texture from the internal texture
|
|
30
30
|
const renderTargetTexture = multiview ? new MultiviewRenderTarget(this._scene, textureSize) : new RenderTargetTexture("XR renderTargetTexture", textureSize, this._scene);
|
|
31
31
|
const renderTargetWrapper = renderTargetTexture.renderTarget;
|
|
32
|
+
renderTargetWrapper._samples = renderTargetTexture.samples;
|
|
32
33
|
// Set the framebuffer, make sure it works in all scenarios - emulator, no layers and layers
|
|
33
34
|
if (framebuffer || !colorTexture) {
|
|
34
35
|
renderTargetWrapper._framebuffer = framebuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRRenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../../lts/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,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,mBAAmB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,wBAAwB;QAC3B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport { WebGLHardwareTexture } from \"../Engines/WebGL/webGLHardwareTexture\";\r\nimport type { WebGLRenderTargetWrapper } from \"../Engines/WebGL/webGLRenderTargetWrapper\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { MultiviewRenderTarget } from \"../Materials/Textures/MultiviewRenderTarget\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\n\r\n/**\r\n * An interface for objects that provide render target textures for XR rendering.\r\n */\r\nexport interface IWebXRRenderTargetTextureProvider extends IDisposable {\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRLayer.\r\n * @internal\r\n */\r\nexport abstract class WebXRLayerRenderTargetTextureProvider implements IWebXRRenderTargetTextureProvider {\r\n public abstract trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n public abstract getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n public abstract getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n\r\n protected _renderTargetTextures = new Array<RenderTargetTexture>();\r\n protected _framebufferDimensions: Nullable<{ framebufferWidth: number; framebufferHeight: number }>;\r\n\r\n private _engine: Engine;\r\n\r\n constructor(private readonly _scene: Scene, public readonly layerWrapper: WebXRLayerWrapper) {\r\n this._engine = _scene.getEngine();\r\n }\r\n\r\n private _createInternalTexture(textureSize: { width: number; height: number }, texture: WebGLTexture): InternalTexture {\r\n const internalTexture = new InternalTexture(this._engine, InternalTextureSource.Unknown, true);\r\n internalTexture.width = textureSize.width;\r\n internalTexture.height = textureSize.height;\r\n internalTexture._hardwareTexture = new WebGLHardwareTexture(texture, this._engine._gl);\r\n internalTexture.isReady = true;\r\n return internalTexture;\r\n }\r\n\r\n protected _createRenderTargetTexture(\r\n width: number,\r\n height: number,\r\n framebuffer: Nullable<WebGLFramebuffer>,\r\n colorTexture?: WebGLTexture,\r\n depthStencilTexture?: WebGLTexture,\r\n multiview?: boolean\r\n ): RenderTargetTexture {\r\n if (!this._engine) {\r\n throw new Error(\"Engine is disposed\");\r\n }\r\n\r\n const textureSize = { width, height };\r\n\r\n // Create render target texture from the internal texture\r\n const renderTargetTexture = multiview ? new MultiviewRenderTarget(this._scene, textureSize) : new RenderTargetTexture(\"XR renderTargetTexture\", textureSize, this._scene);\r\n const renderTargetWrapper = renderTargetTexture.renderTarget as WebGLRenderTargetWrapper;\r\n // Set the framebuffer, make sure it works in all scenarios - emulator, no layers and layers\r\n if (framebuffer || !colorTexture) {\r\n renderTargetWrapper._framebuffer = framebuffer;\r\n }\r\n\r\n // Create internal texture\r\n if (colorTexture) {\r\n if (multiview) {\r\n renderTargetWrapper._colorTextureArray = colorTexture;\r\n } else {\r\n const internalTexture = this._createInternalTexture(textureSize, colorTexture);\r\n renderTargetWrapper.setTexture(internalTexture, 0);\r\n renderTargetTexture._texture = internalTexture;\r\n }\r\n }\r\n\r\n if (depthStencilTexture) {\r\n if (multiview) {\r\n renderTargetWrapper._depthStencilTextureArray = depthStencilTexture;\r\n } else {\r\n renderTargetWrapper._depthStencilTexture = this._createInternalTexture(textureSize, depthStencilTexture);\r\n }\r\n }\r\n\r\n renderTargetTexture.disableRescaling();\r\n // Firefox reality fails if skipInitialClear is set to true, so make sure only modern XR implementations set it.\r\n if (typeof XRWebGLBinding !== \"undefined\") {\r\n // WebXR pre-clears textures\r\n renderTargetTexture.skipInitialClear = true;\r\n }\r\n\r\n this._renderTargetTextures.push(renderTargetTexture);\r\n\r\n return renderTargetTexture;\r\n }\r\n\r\n protected _destroyRenderTargetTexture(renderTargetTexture: RenderTargetTexture) {\r\n this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(renderTargetTexture), 1);\r\n renderTargetTexture.dispose();\r\n }\r\n\r\n public getFramebufferDimensions(): Nullable<{ framebufferWidth: number; framebufferHeight: number }> {\r\n return this._framebufferDimensions;\r\n }\r\n\r\n public dispose() {\r\n this._renderTargetTextures.forEach((rtt) => rtt.dispose());\r\n this._renderTargetTextures.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRRenderTargetTextureProvider.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRRenderTargetTextureProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAA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,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,mBAAmB,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAEM,wBAAwB;QAC3B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport { WebGLHardwareTexture } from \"../Engines/WebGL/webGLHardwareTexture\";\r\nimport type { WebGLRenderTargetWrapper } from \"../Engines/WebGL/webGLRenderTargetWrapper\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { MultiviewRenderTarget } from \"../Materials/Textures/MultiviewRenderTarget\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\n\r\n/**\r\n * An interface for objects that provide render target textures for XR rendering.\r\n */\r\nexport interface IWebXRRenderTargetTextureProvider extends IDisposable {\r\n /**\r\n * Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view.\r\n * In the event of a failure, the supplied viewport is not updated.\r\n * @param viewport the viewport to which the view will be rendered\r\n * @param view the view for which to set the viewport\r\n * @returns whether the operation was successful\r\n */\r\n trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this eye\r\n * @param eye the eye for which to get the render target\r\n * @returns the render target for the specified eye or null if not available\r\n */\r\n getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n /**\r\n * Gets the correct render target texture to be rendered this frame for this view\r\n * @param view the view for which to get the render target\r\n * @returns the render target for the specified view or null if not available\r\n */\r\n getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRLayer.\r\n * @internal\r\n */\r\nexport abstract class WebXRLayerRenderTargetTextureProvider implements IWebXRRenderTargetTextureProvider {\r\n public abstract trySetViewportForView(viewport: Viewport, view: XRView): boolean;\r\n public abstract getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture>;\r\n public abstract getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture>;\r\n\r\n protected _renderTargetTextures = new Array<RenderTargetTexture>();\r\n protected _framebufferDimensions: Nullable<{ framebufferWidth: number; framebufferHeight: number }>;\r\n\r\n private _engine: Engine;\r\n\r\n constructor(private readonly _scene: Scene, public readonly layerWrapper: WebXRLayerWrapper) {\r\n this._engine = _scene.getEngine();\r\n }\r\n\r\n private _createInternalTexture(textureSize: { width: number; height: number }, texture: WebGLTexture): InternalTexture {\r\n const internalTexture = new InternalTexture(this._engine, InternalTextureSource.Unknown, true);\r\n internalTexture.width = textureSize.width;\r\n internalTexture.height = textureSize.height;\r\n internalTexture._hardwareTexture = new WebGLHardwareTexture(texture, this._engine._gl);\r\n internalTexture.isReady = true;\r\n return internalTexture;\r\n }\r\n\r\n protected _createRenderTargetTexture(\r\n width: number,\r\n height: number,\r\n framebuffer: Nullable<WebGLFramebuffer>,\r\n colorTexture?: WebGLTexture,\r\n depthStencilTexture?: WebGLTexture,\r\n multiview?: boolean\r\n ): RenderTargetTexture {\r\n if (!this._engine) {\r\n throw new Error(\"Engine is disposed\");\r\n }\r\n\r\n const textureSize = { width, height };\r\n\r\n // Create render target texture from the internal texture\r\n const renderTargetTexture = multiview ? new MultiviewRenderTarget(this._scene, textureSize) : new RenderTargetTexture(\"XR renderTargetTexture\", textureSize, this._scene);\r\n const renderTargetWrapper = renderTargetTexture.renderTarget as WebGLRenderTargetWrapper;\r\n renderTargetWrapper._samples = renderTargetTexture.samples;\r\n // Set the framebuffer, make sure it works in all scenarios - emulator, no layers and layers\r\n if (framebuffer || !colorTexture) {\r\n renderTargetWrapper._framebuffer = framebuffer;\r\n }\r\n\r\n // Create internal texture\r\n if (colorTexture) {\r\n if (multiview) {\r\n renderTargetWrapper._colorTextureArray = colorTexture;\r\n } else {\r\n const internalTexture = this._createInternalTexture(textureSize, colorTexture);\r\n renderTargetWrapper.setTexture(internalTexture, 0);\r\n renderTargetTexture._texture = internalTexture;\r\n }\r\n }\r\n\r\n if (depthStencilTexture) {\r\n if (multiview) {\r\n renderTargetWrapper._depthStencilTextureArray = depthStencilTexture;\r\n } else {\r\n renderTargetWrapper._depthStencilTexture = this._createInternalTexture(textureSize, depthStencilTexture);\r\n }\r\n }\r\n\r\n renderTargetTexture.disableRescaling();\r\n // Firefox reality fails if skipInitialClear is set to true, so make sure only modern XR implementations set it.\r\n if (typeof XRWebGLBinding !== \"undefined\") {\r\n // WebXR pre-clears textures\r\n renderTargetTexture.skipInitialClear = true;\r\n }\r\n\r\n this._renderTargetTextures.push(renderTargetTexture);\r\n\r\n return renderTargetTexture;\r\n }\r\n\r\n protected _destroyRenderTargetTexture(renderTargetTexture: RenderTargetTexture) {\r\n this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(renderTargetTexture), 1);\r\n renderTargetTexture.dispose();\r\n }\r\n\r\n public getFramebufferDimensions(): Nullable<{ framebufferWidth: number; framebufferHeight: number }> {\r\n return this._framebufferDimensions;\r\n }\r\n\r\n public dispose() {\r\n this._renderTargetTextures.forEach((rtt) => rtt.dispose());\r\n this._renderTargetTextures.length = 0;\r\n }\r\n}\r\n"]}
|
package/XR/webXRWebGLLayer.js
CHANGED
|
@@ -30,6 +30,9 @@ export class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRender
|
|
|
30
30
|
}
|
|
31
31
|
trySetViewportForView(viewport, view) {
|
|
32
32
|
const xrViewport = this._layer.getViewport(view);
|
|
33
|
+
if (!xrViewport) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
33
36
|
const framebufferWidth = this._framebufferDimensions.framebufferWidth;
|
|
34
37
|
const framebufferHeight = this._framebufferDimensions.framebufferHeight;
|
|
35
38
|
viewport.x = xrViewport.x / framebufferWidth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRWebGLLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRWebGLLayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAE3F;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IACzD;;;OAGG;IACH,YAA4B,KAAmB;QAC3C,KAAK,CACD,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAC5B,GAAG,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAC7B,KAAK,EACL,cAAc,EACd,CAAC,cAAc,EAAE,EAAE,CAAC,IAAI,0CAA0C,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CACjG,CAAC;QAPsB,UAAK,GAAL,KAAK,CAAc;IAQ/C,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,0CAA2C,SAAQ,qCAAqC;IAOjG,YAAY,KAAY,EAAkB,YAAoC;QAC1E,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QADW,iBAAY,GAAZ,YAAY,CAAwB;QAE1E,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,sBAAsB,GAAG;YAC1B,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC9C,iBAAiB,EAAE,IAAI,CAAC,MAAM,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AC;YAC5D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,6BAA6B,CAAC,IAAY;QAC7C,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\n\r\n/**\r\n * Wraps xr webgl layers.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerWrapper extends WebXRLayerWrapper {\r\n /**\r\n * @param layer is the layer to be wrapped.\r\n * @returns a new WebXRLayerWrapper wrapping the provided XRWebGLLayer.\r\n */\r\n constructor(public readonly layer: XRWebGLLayer) {\r\n super(\r\n () => layer.framebufferWidth,\r\n () => layer.framebufferHeight,\r\n layer,\r\n \"XRWebGLLayer\",\r\n (sessionManager) => new WebXRWebGLLayerRenderTargetTextureProvider(sessionManager.scene, this)\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRWebGLLayer.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\r\n // The dimensions will always be defined in this class.\r\n protected _framebufferDimensions: { framebufferWidth: number; framebufferHeight: number };\r\n private _rtt: Nullable<RenderTargetTexture>;\r\n private _framebuffer: WebGLFramebuffer;\r\n private _layer: XRWebGLLayer;\r\n\r\n constructor(scene: Scene, public readonly layerWrapper: WebXRWebGLLayerWrapper) {\r\n super(scene, layerWrapper);\r\n this._layer = layerWrapper.layer;\r\n this._framebufferDimensions = {\r\n framebufferWidth: this._layer.framebufferWidth,\r\n framebufferHeight: this._layer.framebufferHeight,\r\n };\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const xrViewport = this._layer.getViewport(view);\r\n const framebufferWidth = this._framebufferDimensions.framebufferWidth;\r\n const framebufferHeight = this._framebufferDimensions.framebufferHeight;\r\n viewport.x = xrViewport.x / framebufferWidth;\r\n viewport.y = xrViewport.y / framebufferHeight;\r\n viewport.width = xrViewport.width / framebufferWidth;\r\n viewport.height = xrViewport.height / framebufferHeight;\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n const layerWidth = this._layer.framebufferWidth;\r\n const layerHeight = this._layer.framebufferHeight;\r\n const framebuffer = this._layer.framebuffer;\r\n\r\n if (\r\n !this._rtt ||\r\n layerWidth !== this._framebufferDimensions.framebufferWidth ||\r\n layerHeight !== this._framebufferDimensions.framebufferHeight ||\r\n framebuffer !== this._framebuffer\r\n ) {\r\n this._rtt = this._createRenderTargetTexture(layerWidth, layerHeight, framebuffer);\r\n this._framebufferDimensions.framebufferWidth = layerWidth;\r\n this._framebufferDimensions.framebufferHeight = layerHeight;\r\n this._framebuffer = framebuffer;\r\n }\r\n\r\n return this._rtt;\r\n }\r\n\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view.eye);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRWebGLLayer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/XR/webXRWebGLLayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAE3F;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IACzD;;;OAGG;IACH,YAA4B,KAAmB;QAC3C,KAAK,C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,iBAAiB,CAAC;QACxD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,6DAA6D;IACtD,4BAA4B,CAAC,GAAU;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAE5C,IACI,CAAC,IAAI,CAAC,IAAI;YACV,UAAU,KAAK,IAAI,CAAC,sBAAsB,CAAC,gBAAgB;YAC3D,WAAW,KAAK,IAAI,CAAC,sBAAsB,CAAC,iBAAiB;YAC7D,WAAW,KAAK,IAAI,CAAC,YAAY,EACnC;YACE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;YAClF,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG,UAAU,CAAC;YAC1D,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,GAAG,WAAW,CAAC;YAC5D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,6BAA6B,CAAC,IAAY;QAC7C,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Viewport } from \"../Maths/math.viewport\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { WebXRLayerWrapper } from \"./webXRLayerWrapper\";\r\nimport { WebXRLayerRenderTargetTextureProvider } from \"./webXRRenderTargetTextureProvider\";\r\n\r\n/**\r\n * Wraps xr webgl layers.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerWrapper extends WebXRLayerWrapper {\r\n /**\r\n * @param layer is the layer to be wrapped.\r\n * @returns a new WebXRLayerWrapper wrapping the provided XRWebGLLayer.\r\n */\r\n constructor(public readonly layer: XRWebGLLayer) {\r\n super(\r\n () => layer.framebufferWidth,\r\n () => layer.framebufferHeight,\r\n layer,\r\n \"XRWebGLLayer\",\r\n (sessionManager) => new WebXRWebGLLayerRenderTargetTextureProvider(sessionManager.scene, this)\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Provides render target textures and other important rendering information for a given XRWebGLLayer.\r\n * @internal\r\n */\r\nexport class WebXRWebGLLayerRenderTargetTextureProvider extends WebXRLayerRenderTargetTextureProvider {\r\n // The dimensions will always be defined in this class.\r\n protected _framebufferDimensions: { framebufferWidth: number; framebufferHeight: number };\r\n private _rtt: Nullable<RenderTargetTexture>;\r\n private _framebuffer: WebGLFramebuffer;\r\n private _layer: XRWebGLLayer;\r\n\r\n constructor(scene: Scene, public readonly layerWrapper: WebXRWebGLLayerWrapper) {\r\n super(scene, layerWrapper);\r\n this._layer = layerWrapper.layer;\r\n this._framebufferDimensions = {\r\n framebufferWidth: this._layer.framebufferWidth,\r\n framebufferHeight: this._layer.framebufferHeight,\r\n };\r\n }\r\n\r\n public trySetViewportForView(viewport: Viewport, view: XRView): boolean {\r\n const xrViewport = this._layer.getViewport(view);\r\n if (!xrViewport) {\r\n return false;\r\n }\r\n const framebufferWidth = this._framebufferDimensions.framebufferWidth;\r\n const framebufferHeight = this._framebufferDimensions.framebufferHeight;\r\n viewport.x = xrViewport.x / framebufferWidth;\r\n viewport.y = xrViewport.y / framebufferHeight;\r\n viewport.width = xrViewport.width / framebufferWidth;\r\n viewport.height = xrViewport.height / framebufferHeight;\r\n return true;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getRenderTargetTextureForEye(eye: XREye): Nullable<RenderTargetTexture> {\r\n const layerWidth = this._layer.framebufferWidth;\r\n const layerHeight = this._layer.framebufferHeight;\r\n const framebuffer = this._layer.framebuffer;\r\n\r\n if (\r\n !this._rtt ||\r\n layerWidth !== this._framebufferDimensions.framebufferWidth ||\r\n layerHeight !== this._framebufferDimensions.framebufferHeight ||\r\n framebuffer !== this._framebuffer\r\n ) {\r\n this._rtt = this._createRenderTargetTexture(layerWidth, layerHeight, framebuffer);\r\n this._framebufferDimensions.framebufferWidth = layerWidth;\r\n this._framebufferDimensions.framebufferHeight = layerHeight;\r\n this._framebuffer = framebuffer;\r\n }\r\n\r\n return this._rtt;\r\n }\r\n\r\n public getRenderTargetTextureForView(view: XRView): Nullable<RenderTargetTexture> {\r\n return this.getRenderTargetTextureForEye(view.eye);\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
package/scene.d.ts
CHANGED
|
@@ -1833,6 +1833,7 @@ export declare class Scene extends AbstractScene implements IAnimatable, IClipPl
|
|
|
1833
1833
|
getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
|
|
1834
1834
|
/** @internal */
|
|
1835
1835
|
_activeMeshesFrozen: boolean;
|
|
1836
|
+
/** @internal */
|
|
1836
1837
|
_activeMeshesFrozenButKeepClipping: boolean;
|
|
1837
1838
|
private _skipEvaluateActiveMeshesCompletely;
|
|
1838
1839
|
/**
|
|
@@ -1971,6 +1972,10 @@ export declare class Scene extends AbstractScene implements IAnimatable, IClipPl
|
|
|
1971
1972
|
* @returns the current scene
|
|
1972
1973
|
*/
|
|
1973
1974
|
createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
|
|
1975
|
+
/** @internal */
|
|
1976
|
+
get _pickingAvailable(): boolean;
|
|
1977
|
+
/** @internal */
|
|
1978
|
+
_registeredActions: number;
|
|
1974
1979
|
/** Launch a ray to try to pick a mesh in the scene
|
|
1975
1980
|
* @param x position on screen
|
|
1976
1981
|
* @param y position on screen
|
package/scene.js
CHANGED
|
@@ -668,6 +668,7 @@ export class Scene extends AbstractScene {
|
|
|
668
668
|
this._preventFreeActiveMeshesAndRenderingGroups = false;
|
|
669
669
|
/** @internal */
|
|
670
670
|
this._activeMeshesFrozen = false;
|
|
671
|
+
/** @internal */
|
|
671
672
|
this._activeMeshesFrozenButKeepClipping = false;
|
|
672
673
|
this._skipEvaluateActiveMeshesCompletely = false;
|
|
673
674
|
/** @internal */
|
|
@@ -678,6 +679,8 @@ export class Scene extends AbstractScene {
|
|
|
678
679
|
this.getDeterministicFrameTime = () => {
|
|
679
680
|
return this._engine.getTimeStep();
|
|
680
681
|
};
|
|
682
|
+
/** @internal */
|
|
683
|
+
this._registeredActions = 0;
|
|
681
684
|
this._blockMaterialDirtyMechanism = false;
|
|
682
685
|
/**
|
|
683
686
|
* Internal perfCollector instance used for sharing between inspector and playground.
|
|
@@ -3135,6 +3138,7 @@ export class Scene extends AbstractScene {
|
|
|
3135
3138
|
this._activeParticleSystems.data[i].animate();
|
|
3136
3139
|
}
|
|
3137
3140
|
}
|
|
3141
|
+
this._renderingManager.resetSprites();
|
|
3138
3142
|
return;
|
|
3139
3143
|
}
|
|
3140
3144
|
if (!this.activeCamera) {
|
|
@@ -4029,6 +4033,10 @@ export class Scene extends AbstractScene {
|
|
|
4029
4033
|
createPickingRayInCameraSpaceToRef(x, y, result, camera) {
|
|
4030
4034
|
throw _WarnImport("Ray");
|
|
4031
4035
|
}
|
|
4036
|
+
/** @internal */
|
|
4037
|
+
get _pickingAvailable() {
|
|
4038
|
+
return false;
|
|
4039
|
+
}
|
|
4032
4040
|
/** Launch a ray to try to pick a mesh in the scene
|
|
4033
4041
|
* @param x position on screen
|
|
4034
4042
|
* @param y position on screen
|
|
@@ -4040,9 +4048,7 @@ export class Scene extends AbstractScene {
|
|
|
4040
4048
|
*/
|
|
4041
4049
|
pick(x, y, predicate, fastCheck, camera, trianglePredicate) {
|
|
4042
4050
|
// Dummy info if picking as not been imported
|
|
4043
|
-
|
|
4044
|
-
pi._pickingUnavailable = true;
|
|
4045
|
-
return pi;
|
|
4051
|
+
return new PickingInfo();
|
|
4046
4052
|
}
|
|
4047
4053
|
/** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
|
|
4048
4054
|
* @param x position on screen
|
|
@@ -4054,9 +4060,7 @@ export class Scene extends AbstractScene {
|
|
|
4054
4060
|
*/
|
|
4055
4061
|
pickWithBoundingInfo(x, y, predicate, fastCheck, camera) {
|
|
4056
4062
|
// Dummy info if picking as not been imported
|
|
4057
|
-
|
|
4058
|
-
pi._pickingUnavailable = true;
|
|
4059
|
-
return pi;
|
|
4063
|
+
return new PickingInfo();
|
|
4060
4064
|
}
|
|
4061
4065
|
/** Use the given ray to pick a mesh in the scene
|
|
4062
4066
|
* @param ray The ray to use to pick meshes
|