@onerjs/core 8.30.4 → 8.30.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/action.d.ts +5 -0
- package/Actions/action.js.map +1 -1
- package/Actions/actionManager.js +6 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +0 -2
- package/Animations/runtimeAnimation.js +3 -5
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.d.ts +9 -5
- package/Audio/audioSceneComponent.js +1 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +1 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +8 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +10 -5
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/camera.d.ts +4 -0
- package/Cameras/camera.js +18 -9
- package/Cameras/camera.js.map +1 -1
- package/Collisions/gpuPicker.js +0 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +3 -1
- package/Decorators/nodeDecorator.js +2 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -13
- package/Engines/nativeEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
- package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
- package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -1
- package/FrameGraph/Passes/pass.js +11 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -1
- package/FrameGraph/frameGraph.js +3 -6
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +8 -1
- package/FrameGraph/frameGraphContext.js +9 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
- package/FrameGraph/frameGraphRenderContext.js +11 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +11 -2
- package/FrameGraph/frameGraphTask.js +17 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +2 -2
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Lights/directionalLight.js +1 -4
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/pointLight.js +2 -5
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +4 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +8 -0
- package/Materials/materialHelper.functions.js +31 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +21 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +55 -16
- package/Maths/math.vector.functions.js +68 -10
- package/Maths/math.vector.functions.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +10 -0
- package/Misc/copyTextureToTexture.js +15 -0
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/decorators.d.ts +1 -1
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.d.ts +20 -0
- package/Misc/dumpTools.js +60 -49
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/index.d.ts +1 -2
- package/Misc/index.js +1 -2
- package/Misc/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
- package/Particles/Node/Blocks/Emitters/index.js +5 -4
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
- package/Particles/Node/Blocks/systemBlock.js +82 -3
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +12 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
- package/Particles/Node/nodeParticleSystemSet.helper.js +344 -112
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
- package/Physics/v2/Plugins/havokPlugin.js +73 -9
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +12 -2
- package/Physics/v2/physicsEngine.js +15 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
- package/PostProcesses/thinSSAO2PostProcess.js +18 -6
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/particles.vertex.js +1 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Shaders/picking.fragment.js +1 -1
- package/Shaders/picking.fragment.js.map +1 -1
- package/Shaders/picking.vertex.js +1 -1
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -4
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +1 -1
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +1 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +1 -1
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +10 -8
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +8 -0
- package/XR/features/WebXRLightEstimation.js +6 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/assetContainer.d.ts +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +7 -2
- package/scene.js +11 -8
- package/scene.js.map +1 -1
|
@@ -53,6 +53,10 @@ export class WebXRLightEstimation extends WebXRAbstractFeature {
|
|
|
53
53
|
* This light will be updated whenever the light estimation values change.
|
|
54
54
|
*/
|
|
55
55
|
this.directionalLight = null;
|
|
56
|
+
/**
|
|
57
|
+
* The scale factor to multiply the intensity of the directional light by. Defaults to 1.0.
|
|
58
|
+
*/
|
|
59
|
+
this.directionalLightIntensityFactor = 1.0;
|
|
56
60
|
/**
|
|
57
61
|
* This observable will notify when the reflection cube map is updated.
|
|
58
62
|
*/
|
|
@@ -118,6 +122,7 @@ export class WebXRLightEstimation extends WebXRAbstractFeature {
|
|
|
118
122
|
this.directionalLight.intensity = 0;
|
|
119
123
|
this.directionalLight.falloffType = LightConstants.FALLOFF_GLTF;
|
|
120
124
|
}
|
|
125
|
+
this.directionalLightIntensityFactor = this.options.directionalLightIntensityFactor ?? 1.0;
|
|
121
126
|
this._hdrFilter = new HDRFiltering(this._xrSessionManager.scene.getEngine());
|
|
122
127
|
// https://immersive-web.github.io/lighting-estimation/
|
|
123
128
|
Tools.Warn("light-estimation is an experimental and unstable feature.");
|
|
@@ -261,7 +266,7 @@ export class WebXRLightEstimation extends WebXRAbstractFeature {
|
|
|
261
266
|
// set the values after calculating them
|
|
262
267
|
if (this.directionalLight) {
|
|
263
268
|
this.directionalLight.direction.copyFrom(this._lightDirection);
|
|
264
|
-
this.directionalLight.intensity = Math.min(this._intensity, 1.0);
|
|
269
|
+
this.directionalLight.intensity = Math.min(this._intensity, 1.0) * this.directionalLightIntensityFactor;
|
|
265
270
|
this.directionalLight.diffuse.copyFrom(this._lightColor);
|
|
266
271
|
}
|
|
267
272
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRLightEstimation.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRLightEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAyB,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,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,2DAAuD;AA0E9E;;;;GAIG;A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I,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;oBACjE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC7D,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;;AAlSD;;GAEG;AACoB,yBAAI,GAAG,gBAAgB,CAAC,gBAAgB,AAApC,CAAqC;AAChE;;;;GAIG;AACoB,4BAAO,GAAG,CAAC,AAAJ,CAAK;AA4RvC,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\nimport { HDRFiltering } from \"core/Materials/Textures/Filtering/hdrFiltering\";\r\nimport type { ThinEngine } from \"core/Engines\";\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 * disable prefiltering the cube map texture\r\n */\r\n disablePreFiltering?: 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 private _hdrFilter: HDRFiltering;\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 this._hdrFilter = new HDRFiltering(this._xrSessionManager.scene.getEngine() as ThinEngine);\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() as ThinEngine)._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 if (!this.options.disablePreFiltering) {\r\n this._xrLightProbe.removeEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._hdrFilter.prefilter(this._reflectionCubeMap).then(() => {\r\n this._xrSessionManager.scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n this.onReflectionCubeMapUpdatedObservable.notifyObservers(this._reflectionCubeMap!);\r\n this._xrLightProbe!.addEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n });\r\n } else {\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 /**\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 override 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 // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._xrSessionManager.session\r\n .requestLightProbe({\r\n reflectionFormat,\r\n })\r\n // eslint-disable-next-line github/no-then\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 override 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 override 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":["../../../../../dev/core/src/XR/features/WebXRLightEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAyB,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,yB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,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\nimport { HDRFiltering } from \"core/Materials/Textures/Filtering/hdrFiltering\";\r\nimport type { ThinEngine } from \"core/Engines\";\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 * The scale factor to multiply the intensity of the directional light by. Defaults to 1.0.\r\n */\r\n directionalLightIntensityFactor?: number;\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 * disable prefiltering the cube map texture\r\n */\r\n disablePreFiltering?: 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 private _hdrFilter: HDRFiltering;\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 * The scale factor to multiply the intensity of the directional light by. Defaults to 1.0.\r\n */\r\n public directionalLightIntensityFactor: number = 1.0;\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 this.directionalLightIntensityFactor = this.options.directionalLightIntensityFactor ?? 1.0;\r\n\r\n this._hdrFilter = new HDRFiltering(this._xrSessionManager.scene.getEngine() as ThinEngine);\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() as ThinEngine)._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 if (!this.options.disablePreFiltering) {\r\n this._xrLightProbe.removeEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._hdrFilter.prefilter(this._reflectionCubeMap).then(() => {\r\n this._xrSessionManager.scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n this.onReflectionCubeMapUpdatedObservable.notifyObservers(this._reflectionCubeMap!);\r\n this._xrLightProbe!.addEventListener(\"reflectionchange\", this._updateReflectionCubeMap);\r\n });\r\n } else {\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 /**\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 override 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 // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._xrSessionManager.session\r\n .requestLightProbe({\r\n reflectionFormat,\r\n })\r\n // eslint-disable-next-line github/no-then\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 override 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 override 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) * this.directionalLightIntensityFactor;\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/assetContainer.d.ts
CHANGED
|
@@ -269,7 +269,7 @@ export declare class AssetContainer extends AbstractAssetContainer {
|
|
|
269
269
|
populateRootNodes(): void;
|
|
270
270
|
/**
|
|
271
271
|
* @since 6.26.0
|
|
272
|
-
* Given a root asset, this method will traverse its hierarchy and add it, its children and any materials/skeletons
|
|
272
|
+
* Given a root asset, this method will traverse its hierarchy and add it, its children and any materials/skeletons to the container.
|
|
273
273
|
* @param root root node
|
|
274
274
|
*/
|
|
275
275
|
addAllAssetsToContainer(root: Node): void;
|
package/assetContainer.js
CHANGED
|
@@ -1066,7 +1066,7 @@ export class AssetContainer extends AbstractAssetContainer {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
/**
|
|
1068
1068
|
* @since 6.26.0
|
|
1069
|
-
* Given a root asset, this method will traverse its hierarchy and add it, its children and any materials/skeletons
|
|
1069
|
+
* Given a root asset, this method will traverse its hierarchy and add it, its children and any materials/skeletons to the container.
|
|
1070
1070
|
* @param root root node
|
|
1071
1071
|
*/
|
|
1072
1072
|
addAllAssetsToContainer(root) {
|