@onerjs/core 8.31.9 → 8.32.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.
Files changed (71) hide show
  1. package/Behaviors/Cameras/autoRotationBehavior.d.ts +4 -0
  2. package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
  3. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  4. package/Behaviors/Cameras/bouncingBehavior.d.ts +5 -0
  5. package/Behaviors/Cameras/bouncingBehavior.js +8 -0
  6. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  7. package/Behaviors/Cameras/framingBehavior.d.ts +4 -0
  8. package/Behaviors/Cameras/framingBehavior.js +7 -0
  9. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  10. package/Behaviors/Cameras/interpolatingBehavior.d.ts +7 -2
  11. package/Behaviors/Cameras/interpolatingBehavior.js +12 -4
  12. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  13. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +5 -0
  14. package/Behaviors/Meshes/attachToBoxBehavior.js +8 -1
  15. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  16. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -2
  17. package/Behaviors/Meshes/baseSixDofDragBehavior.js +8 -0
  18. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  19. package/Behaviors/Meshes/fadeInOutBehavior.d.ts +5 -0
  20. package/Behaviors/Meshes/fadeInOutBehavior.js +6 -0
  21. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  22. package/Behaviors/Meshes/handConstraintBehavior.d.ts +5 -0
  23. package/Behaviors/Meshes/handConstraintBehavior.js +8 -0
  24. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  25. package/Behaviors/Meshes/multiPointerScaleBehavior.d.ts +5 -0
  26. package/Behaviors/Meshes/multiPointerScaleBehavior.js +8 -0
  27. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  28. package/Behaviors/Meshes/pointerDragBehavior.d.ts +1 -1
  29. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  30. package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
  31. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  32. package/Behaviors/Meshes/surfaceMagnetismBehavior.d.ts +5 -0
  33. package/Behaviors/Meshes/surfaceMagnetismBehavior.js +7 -0
  34. package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
  35. package/Behaviors/behavior.d.ts +4 -0
  36. package/Behaviors/behavior.js.map +1 -1
  37. package/Cameras/geospatialCamera.d.ts +4 -5
  38. package/Cameras/geospatialCamera.js +42 -29
  39. package/Cameras/geospatialCamera.js.map +1 -1
  40. package/Cameras/geospatialCameraMovement.js +1 -1
  41. package/Cameras/geospatialCameraMovement.js.map +1 -1
  42. package/Engines/abstractEngine.js +2 -2
  43. package/Engines/abstractEngine.js.map +1 -1
  44. package/Helpers/sceneHelpers.js +1 -1
  45. package/Helpers/sceneHelpers.js.map +1 -1
  46. package/Lights/index.d.ts +1 -0
  47. package/Lights/index.js +1 -0
  48. package/Lights/index.js.map +1 -1
  49. package/Lights/lightingVolume.d.ts +89 -0
  50. package/Lights/lightingVolume.js +426 -0
  51. package/Lights/lightingVolume.js.map +1 -0
  52. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +7 -0
  53. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +19 -5
  54. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  55. package/Materials/floatingOriginMatrixOverrides.js +6 -5
  56. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  57. package/Materials/uniformBuffer.d.ts +1 -0
  58. package/Materials/uniformBuffer.js +8 -1
  59. package/Materials/uniformBuffer.js.map +1 -1
  60. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -2
  61. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +138 -45
  62. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  63. package/ShadersWGSL/gaussianSplattingDepth.fragment.d.ts +0 -1
  64. package/ShadersWGSL/gaussianSplattingDepth.fragment.js +0 -2
  65. package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
  66. package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
  67. package/ShadersWGSL/lightingVolume.compute.js +27 -0
  68. package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
  69. package/package.json +1 -1
  70. package/scene.js +6 -4
  71. package/scene.js.map +1 -1
@@ -47,7 +47,7 @@ Scene.prototype.createDefaultCamera = function (createArcRotateCamera = false, r
47
47
  let camera;
48
48
  let radius = worldSize.length() * 1.5;
49
49
  // empty scene scenario!
50
- if (!isFinite(radius)) {
50
+ if (!isFinite(radius) || radius === 0) {
51
51
  radius = 1;
52
52
  worldCenter.copyFromFloats(0, 0, 0);
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sceneHelpers.js","sourceRoot":"","sources":["../../../../dev/core/src/Helpers/sceneHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,O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IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,eAA0C,EAAE;IAC9F,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,CAAC,8BAA8B,GAAG,KAAK,WAAW,UAAyC,EAAE;IACxG,OAAO,MAAM,sBAAsB,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC,CAAC","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../Materials/PBR/pbrMaterial\";\r\nimport { HemisphericLight } from \"../Lights/hemisphericLight\";\r\nimport type { IEnvironmentHelperOptions } from \"./environmentHelper\";\r\nimport { EnvironmentHelper } from \"./environmentHelper\";\r\nimport { FreeCamera } from \"../Cameras/freeCamera\";\r\nimport { ArcRotateCamera } from \"../Cameras/arcRotateCamera\";\r\nimport type { TargetCamera } from \"../Cameras/targetCamera\";\r\nimport type { VRExperienceHelperOptions } from \"../Cameras/VR/vrExperienceHelper\";\r\nimport { VRExperienceHelper } from \"../Cameras/VR/vrExperienceHelper\";\r\n\r\nimport \"../Materials/Textures/Loaders/ddsTextureLoader\";\r\nimport \"../Materials/Textures/Loaders/envTextureLoader\";\r\nimport \"../Materials/Textures/Loaders/ktxTextureLoader\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport type { WebXRDefaultExperienceOptions } from \"../XR/webXRDefaultExperience\";\r\nimport { WebXRDefaultExperience } from \"../XR/webXRDefaultExperience\";\r\n\r\n/** @internal */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var _forceSceneHelpersToBundle = true;\r\n\r\ndeclare module \"../scene\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Scene {\r\n /**\r\n * Creates a default light for the scene.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-light\r\n * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light\r\n */\r\n createDefaultLight(replace?: boolean): void;\r\n\r\n /**\r\n * Creates a default camera for the scene.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-camera\r\n * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera\r\n * @param replace has default false, when true replaces the active camera in the scene\r\n * @param attachCameraControls has default false, when true attaches camera controls to the canvas.\r\n */\r\n createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;\r\n\r\n /**\r\n * Creates a default camera and a default light.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-camera-or-light\r\n * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera\r\n * @param replace has the default false, when true replaces the active camera/light in the scene\r\n * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.\r\n */\r\n createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;\r\n\r\n /**\r\n * Creates a new sky box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-skybox\r\n * @param environmentTexture defines the texture to use as environment texture\r\n * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used\r\n * @param scale defines the overall scale of the skybox\r\n * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1\r\n * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture\r\n * @returns a new mesh holding the sky box\r\n */\r\n createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;\r\n\r\n /**\r\n * Creates a new environment\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-environment\r\n * @param options defines the options you can use to configure the environment\r\n * @returns the new EnvironmentHelper\r\n */\r\n createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;\r\n\r\n /**\r\n * Creates a new VREXperienceHelper\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/webVRHelper\r\n * @param webVROptions defines the options used to create the new VREXperienceHelper\r\n * @deprecated Please use createDefaultXRExperienceAsync instead\r\n * @returns a new VREXperienceHelper\r\n */\r\n createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;\r\n\r\n /**\r\n * Creates a new WebXRDefaultExperience\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/introToWebXR\r\n * @param options experience options\r\n * @returns a promise for a new WebXRDefaultExperience\r\n */\r\n createDefaultXRExperienceAsync(options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;\r\n }\r\n}\r\n\r\nScene.prototype.createDefaultLight = function (replace = false): void {\r\n // Dispose existing light in replace mode.\r\n if (replace) {\r\n if (this.lights) {\r\n for (let i = 0; i < this.lights.length; i++) {\r\n this.lights[i].dispose();\r\n }\r\n }\r\n }\r\n\r\n // Light\r\n if (this.lights.length === 0) {\r\n new HemisphericLight(\"default light\", Vector3.Up(), this);\r\n }\r\n};\r\n\r\nScene.prototype.createDefaultCamera = function (createArcRotateCamera = false, replace = false, attachCameraControls = false): void {\r\n // Dispose existing camera in replace mode.\r\n if (replace) {\r\n if (this.activeCamera) {\r\n this.activeCamera.dispose();\r\n this.activeCamera = null;\r\n }\r\n }\r\n\r\n // Camera\r\n if (!this.activeCamera) {\r\n const worldExtends = this.getWorldExtends((mesh) => mesh.isVisible && mesh.isEnabled());\r\n const worldSize = worldExtends.max.subtract(worldExtends.min);\r\n const worldCenter = worldExtends.min.add(worldSize.scale(0.5));\r\n\r\n let camera: TargetCamera;\r\n let radius = worldSize.length() * 1.5;\r\n // empty scene scenario!\r\n if (!isFinite(radius)) {\r\n radius = 1;\r\n worldCenter.copyFromFloats(0, 0, 0);\r\n }\r\n if (createArcRotateCamera) {\r\n const arcRotateCamera = new ArcRotateCamera(\"default camera\", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);\r\n arcRotateCamera.lowerRadiusLimit = radius * 0.01;\r\n arcRotateCamera.wheelPrecision = 100 / radius;\r\n camera = arcRotateCamera;\r\n } else {\r\n const freeCamera = new FreeCamera(\"default camera\", new Vector3(worldCenter.x, worldCenter.y, -radius), this);\r\n freeCamera.setTarget(worldCenter);\r\n camera = freeCamera;\r\n }\r\n camera.minZ = radius * 0.01;\r\n camera.maxZ = radius * 1000;\r\n camera.speed = radius * 0.2;\r\n this.activeCamera = camera;\r\n\r\n if (attachCameraControls) {\r\n camera.attachControl();\r\n }\r\n }\r\n};\r\n\r\nScene.prototype.createDefaultCameraOrLight = function (createArcRotateCamera = false, replace = false, attachCameraControls = false): void {\r\n this.createDefaultLight(replace);\r\n this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);\r\n};\r\n\r\nScene.prototype.createDefaultSkybox = function (environmentTexture?: BaseTexture, pbr = false, scale = 1000, blur = 0, setGlobalEnvTexture = true): Nullable<Mesh> {\r\n if (!environmentTexture) {\r\n Logger.Warn(\"Can not create default skybox without environment texture.\");\r\n return null;\r\n }\r\n\r\n if (setGlobalEnvTexture) {\r\n if (environmentTexture) {\r\n this.environmentTexture = environmentTexture;\r\n }\r\n }\r\n\r\n // Skybox\r\n const hdrSkybox = CreateBox(\"hdrSkyBox\", { size: scale }, this);\r\n if (pbr) {\r\n const hdrSkyboxMaterial = new PBRMaterial(\"skyBox\", this);\r\n hdrSkyboxMaterial.backFaceCulling = false;\r\n hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();\r\n if (hdrSkyboxMaterial.reflectionTexture) {\r\n hdrSkyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;\r\n }\r\n hdrSkyboxMaterial.microSurface = 1.0 - blur;\r\n hdrSkyboxMaterial.disableLighting = true;\r\n hdrSkyboxMaterial.twoSidedLighting = true;\r\n hdrSkybox.material = hdrSkyboxMaterial;\r\n } else {\r\n const skyboxMaterial = new StandardMaterial(\"skyBox\", this);\r\n skyboxMaterial.backFaceCulling = false;\r\n skyboxMaterial.reflectionTexture = environmentTexture.clone();\r\n if (skyboxMaterial.reflectionTexture) {\r\n skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;\r\n }\r\n skyboxMaterial.disableLighting = true;\r\n hdrSkybox.material = skyboxMaterial;\r\n }\r\n hdrSkybox.isPickable = false;\r\n hdrSkybox.infiniteDistance = true;\r\n hdrSkybox.ignoreCameraMaxZ = true;\r\n return hdrSkybox;\r\n};\r\n\r\nScene.prototype.createDefaultEnvironment = function (options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper> {\r\n if (EnvironmentHelper) {\r\n return new EnvironmentHelper(options, this);\r\n }\r\n return null;\r\n};\r\n\r\nScene.prototype.createDefaultVRExperience = function (webVROptions: VRExperienceHelperOptions = {}): VRExperienceHelper {\r\n return new VRExperienceHelper(this, webVROptions);\r\n};\r\n\r\nScene.prototype.createDefaultXRExperienceAsync = async function (options: WebXRDefaultExperienceOptions = {}): Promise<WebXRDefaultExperience> {\r\n return await WebXRDefaultExperience.CreateAsync(this, options);\r\n};\r\n"]}
1
+ {"version":3,"file":"sceneHelpers.js","sourceRoot":"","sources":["../../../../dev/core/src/Helpers/sceneHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,M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C3E,CAAC;QACD,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC;QACtC,SAAS,CAAC,QAAQ,GAAG,cAAc,CAAC;IACxC,CAAC;IACD,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAClC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAClC,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,CAAC,wBAAwB,GAAG,UAAU,OAA2C;IAC5F,IAAI,iBAAiB,EAAE,CAAC;QACpB,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,eAA0C,EAAE;IAC9F,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,KAAK,CAAC,SAAS,CAAC,8BAA8B,GAAG,KAAK,WAAW,UAAyC,EAAE;IACxG,OAAO,MAAM,sBAAsB,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC,CAAC","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../Materials/PBR/pbrMaterial\";\r\nimport { HemisphericLight } from \"../Lights/hemisphericLight\";\r\nimport type { IEnvironmentHelperOptions } from \"./environmentHelper\";\r\nimport { EnvironmentHelper } from \"./environmentHelper\";\r\nimport { FreeCamera } from \"../Cameras/freeCamera\";\r\nimport { ArcRotateCamera } from \"../Cameras/arcRotateCamera\";\r\nimport type { TargetCamera } from \"../Cameras/targetCamera\";\r\nimport type { VRExperienceHelperOptions } from \"../Cameras/VR/vrExperienceHelper\";\r\nimport { VRExperienceHelper } from \"../Cameras/VR/vrExperienceHelper\";\r\n\r\nimport \"../Materials/Textures/Loaders/ddsTextureLoader\";\r\nimport \"../Materials/Textures/Loaders/envTextureLoader\";\r\nimport \"../Materials/Textures/Loaders/ktxTextureLoader\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport type { WebXRDefaultExperienceOptions } from \"../XR/webXRDefaultExperience\";\r\nimport { WebXRDefaultExperience } from \"../XR/webXRDefaultExperience\";\r\n\r\n/** @internal */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var _forceSceneHelpersToBundle = true;\r\n\r\ndeclare module \"../scene\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Scene {\r\n /**\r\n * Creates a default light for the scene.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-light\r\n * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light\r\n */\r\n createDefaultLight(replace?: boolean): void;\r\n\r\n /**\r\n * Creates a default camera for the scene.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-camera\r\n * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera\r\n * @param replace has default false, when true replaces the active camera in the scene\r\n * @param attachCameraControls has default false, when true attaches camera controls to the canvas.\r\n */\r\n createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;\r\n\r\n /**\r\n * Creates a default camera and a default light.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-camera-or-light\r\n * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera\r\n * @param replace has the default false, when true replaces the active camera/light in the scene\r\n * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.\r\n */\r\n createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;\r\n\r\n /**\r\n * Creates a new sky box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-skybox\r\n * @param environmentTexture defines the texture to use as environment texture\r\n * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used\r\n * @param scale defines the overall scale of the skybox\r\n * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1\r\n * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture\r\n * @returns a new mesh holding the sky box\r\n */\r\n createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;\r\n\r\n /**\r\n * Creates a new environment\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/fastBuildWorld#create-default-environment\r\n * @param options defines the options you can use to configure the environment\r\n * @returns the new EnvironmentHelper\r\n */\r\n createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;\r\n\r\n /**\r\n * Creates a new VREXperienceHelper\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/webVRHelper\r\n * @param webVROptions defines the options used to create the new VREXperienceHelper\r\n * @deprecated Please use createDefaultXRExperienceAsync instead\r\n * @returns a new VREXperienceHelper\r\n */\r\n createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;\r\n\r\n /**\r\n * Creates a new WebXRDefaultExperience\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/introToWebXR\r\n * @param options experience options\r\n * @returns a promise for a new WebXRDefaultExperience\r\n */\r\n createDefaultXRExperienceAsync(options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;\r\n }\r\n}\r\n\r\nScene.prototype.createDefaultLight = function (replace = false): void {\r\n // Dispose existing light in replace mode.\r\n if (replace) {\r\n if (this.lights) {\r\n for (let i = 0; i < this.lights.length; i++) {\r\n this.lights[i].dispose();\r\n }\r\n }\r\n }\r\n\r\n // Light\r\n if (this.lights.length === 0) {\r\n new HemisphericLight(\"default light\", Vector3.Up(), this);\r\n }\r\n};\r\n\r\nScene.prototype.createDefaultCamera = function (createArcRotateCamera = false, replace = false, attachCameraControls = false): void {\r\n // Dispose existing camera in replace mode.\r\n if (replace) {\r\n if (this.activeCamera) {\r\n this.activeCamera.dispose();\r\n this.activeCamera = null;\r\n }\r\n }\r\n\r\n // Camera\r\n if (!this.activeCamera) {\r\n const worldExtends = this.getWorldExtends((mesh) => mesh.isVisible && mesh.isEnabled());\r\n const worldSize = worldExtends.max.subtract(worldExtends.min);\r\n const worldCenter = worldExtends.min.add(worldSize.scale(0.5));\r\n\r\n let camera: TargetCamera;\r\n let radius = worldSize.length() * 1.5;\r\n // empty scene scenario!\r\n if (!isFinite(radius) || radius === 0) {\r\n radius = 1;\r\n worldCenter.copyFromFloats(0, 0, 0);\r\n }\r\n if (createArcRotateCamera) {\r\n const arcRotateCamera = new ArcRotateCamera(\"default camera\", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);\r\n arcRotateCamera.lowerRadiusLimit = radius * 0.01;\r\n arcRotateCamera.wheelPrecision = 100 / radius;\r\n camera = arcRotateCamera;\r\n } else {\r\n const freeCamera = new FreeCamera(\"default camera\", new Vector3(worldCenter.x, worldCenter.y, -radius), this);\r\n freeCamera.setTarget(worldCenter);\r\n camera = freeCamera;\r\n }\r\n camera.minZ = radius * 0.01;\r\n camera.maxZ = radius * 1000;\r\n camera.speed = radius * 0.2;\r\n this.activeCamera = camera;\r\n\r\n if (attachCameraControls) {\r\n camera.attachControl();\r\n }\r\n }\r\n};\r\n\r\nScene.prototype.createDefaultCameraOrLight = function (createArcRotateCamera = false, replace = false, attachCameraControls = false): void {\r\n this.createDefaultLight(replace);\r\n this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);\r\n};\r\n\r\nScene.prototype.createDefaultSkybox = function (environmentTexture?: BaseTexture, pbr = false, scale = 1000, blur = 0, setGlobalEnvTexture = true): Nullable<Mesh> {\r\n if (!environmentTexture) {\r\n Logger.Warn(\"Can not create default skybox without environment texture.\");\r\n return null;\r\n }\r\n\r\n if (setGlobalEnvTexture) {\r\n if (environmentTexture) {\r\n this.environmentTexture = environmentTexture;\r\n }\r\n }\r\n\r\n // Skybox\r\n const hdrSkybox = CreateBox(\"hdrSkyBox\", { size: scale }, this);\r\n if (pbr) {\r\n const hdrSkyboxMaterial = new PBRMaterial(\"skyBox\", this);\r\n hdrSkyboxMaterial.backFaceCulling = false;\r\n hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();\r\n if (hdrSkyboxMaterial.reflectionTexture) {\r\n hdrSkyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;\r\n }\r\n hdrSkyboxMaterial.microSurface = 1.0 - blur;\r\n hdrSkyboxMaterial.disableLighting = true;\r\n hdrSkyboxMaterial.twoSidedLighting = true;\r\n hdrSkybox.material = hdrSkyboxMaterial;\r\n } else {\r\n const skyboxMaterial = new StandardMaterial(\"skyBox\", this);\r\n skyboxMaterial.backFaceCulling = false;\r\n skyboxMaterial.reflectionTexture = environmentTexture.clone();\r\n if (skyboxMaterial.reflectionTexture) {\r\n skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;\r\n }\r\n skyboxMaterial.disableLighting = true;\r\n hdrSkybox.material = skyboxMaterial;\r\n }\r\n hdrSkybox.isPickable = false;\r\n hdrSkybox.infiniteDistance = true;\r\n hdrSkybox.ignoreCameraMaxZ = true;\r\n return hdrSkybox;\r\n};\r\n\r\nScene.prototype.createDefaultEnvironment = function (options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper> {\r\n if (EnvironmentHelper) {\r\n return new EnvironmentHelper(options, this);\r\n }\r\n return null;\r\n};\r\n\r\nScene.prototype.createDefaultVRExperience = function (webVROptions: VRExperienceHelperOptions = {}): VRExperienceHelper {\r\n return new VRExperienceHelper(this, webVROptions);\r\n};\r\n\r\nScene.prototype.createDefaultXRExperienceAsync = async function (options: WebXRDefaultExperienceOptions = {}): Promise<WebXRDefaultExperience> {\r\n return await WebXRDefaultExperience.CreateAsync(this, options);\r\n};\r\n"]}
package/Lights/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./rectAreaLight.js";
10
10
  export * from "./Clustered/index.js";
11
11
  export * from "./IES/iesLoader.js";
12
12
  export * from "./lightConstants.js";
13
+ export * from "./lightingVolume.js";
package/Lights/index.js CHANGED
@@ -11,4 +11,5 @@ export * from "./rectAreaLight.js";
11
11
  export * from "./Clustered/index.js";
12
12
  export * from "./IES/iesLoader.js";
13
13
  export * from "./lightConstants.js";
14
+ export * from "./lightingVolume.js";
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\nexport * from \"./areaLight\";\r\nexport * from \"./rectAreaLight\";\r\nexport * from \"./Clustered/index\";\r\nexport * from \"./IES/iesLoader\";\r\nexport * from \"./lightConstants\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\nexport * from \"./areaLight\";\r\nexport * from \"./rectAreaLight\";\r\nexport * from \"./Clustered/index\";\r\nexport * from \"./IES/iesLoader\";\r\nexport * from \"./lightConstants\";\r\nexport * from \"./lightingVolume\";\r\n"]}
@@ -0,0 +1,89 @@
1
+ import type { Scene, ShadowGenerator } from "../index.js";
2
+ import { Mesh } from "../Meshes/mesh.js";
3
+ import "../ShadersWGSL/lightingVolume.compute.js";
4
+ /**
5
+ * Class used to create a lighting volume from a directional light's shadow generator.
6
+ */
7
+ export declare class LightingVolume {
8
+ private readonly _engine;
9
+ private readonly _scene;
10
+ private readonly _mesh;
11
+ private readonly _copyTexture?;
12
+ private readonly _uBuffer?;
13
+ private _name;
14
+ private _cs?;
15
+ private _light?;
16
+ private _fallbackTexture?;
17
+ private _storageBuffer?;
18
+ private _depthCopy?;
19
+ private _readPixelPromise;
20
+ private _readPixelAbortController;
21
+ private _numFrames;
22
+ private _firstUpdate;
23
+ private _shadowGenerator?;
24
+ /**
25
+ * The shadow generator used to create the lighting volume.
26
+ */
27
+ get shadowGenerator(): ShadowGenerator;
28
+ set shadowGenerator(sg: ShadowGenerator);
29
+ private _tesselation;
30
+ /**
31
+ * The tesselation level of the lighting volume.
32
+ */
33
+ get tesselation(): number;
34
+ set tesselation(n: number);
35
+ private _buildFullVolume;
36
+ /**
37
+ * Indicates whether to build the full volume (true) or only the far plane (false). Default is false.
38
+ */
39
+ get buildFullVolume(): boolean;
40
+ set buildFullVolume(value: boolean);
41
+ /**
42
+ * The mesh used as a support for the lighting volume.
43
+ * Note that this mesh is not automatically added to the scene's mesh array.
44
+ * If you want to render it, you need to add it manually.
45
+ */
46
+ get mesh(): Mesh;
47
+ private _frequency;
48
+ /**
49
+ * The frequency (in number of times you call updateMesh) at which the lighting volume is updated.
50
+ */
51
+ get frequency(): number;
52
+ set frequency(value: number);
53
+ /**
54
+ * The name of the lighting volume.
55
+ */
56
+ get name(): string;
57
+ set name(name: string);
58
+ /**
59
+ * Indicates whether this is the first update of the lighting volume.
60
+ * If true, the volume has not yet been updated for the first time.
61
+ */
62
+ get firstUpdate(): boolean;
63
+ /**
64
+ * Creates a new LightingVolume.
65
+ * @param name The name of the lighting volume.
66
+ * @param scene The scene the lighting volume belongs to.
67
+ * @param shadowGenerator The shadow generator used to create the lighting volume. This is optional in the constructor, but must be set before calling updateMesh.
68
+ * @param tesselation The tesselation level of the lighting volume (default: 64).
69
+ */
70
+ constructor(name: string, scene: Scene, shadowGenerator?: ShadowGenerator, tesselation?: number);
71
+ /**
72
+ * Checks if the lighting volume is ready to be updated.
73
+ * @returns True if the volume is ready to be updated.
74
+ */
75
+ isReady(): boolean;
76
+ /**
77
+ * Updates the lighting volume mesh.
78
+ * @param forceUpdate If true, forces the update even if the frequency condition is not met.
79
+ */
80
+ update(forceUpdate?: boolean): void;
81
+ /**
82
+ * Disposes the lighting volume and associated resources.
83
+ */
84
+ dispose(): void;
85
+ private _createComputeShader;
86
+ private _createFallbackTextures;
87
+ private _fallbackReadPixelAsync;
88
+ private _createGeometry;
89
+ }
@@ -0,0 +1,426 @@
1
+ import { AbortError } from "../Misc/error.js";
2
+
3
+ import { Matrix, Vector3 } from "../Maths/math.vector.js";
4
+ import { DirectionalLight } from "./directionalLight.js";
5
+ import { Mesh } from "../Meshes/mesh.js";
6
+ import { ComputeShader } from "../Compute/computeShader.js";
7
+ import { CopyTextureToTexture } from "../Misc/copyTextureToTexture.js";
8
+ import { UniformBuffer } from "../Materials/uniformBuffer.js";
9
+ import { StorageBuffer } from "../Buffers/storageBuffer.js";
10
+ import { BaseTexture } from "../Materials/Textures/baseTexture.js";
11
+ import { VertexBuffer } from "../Buffers/buffer.js";
12
+ import "../ShadersWGSL/lightingVolume.compute.js";
13
+ const InvViewProjMatrix = new Matrix();
14
+ const TmpVec3 = new Vector3();
15
+ /**
16
+ * Class used to create a lighting volume from a directional light's shadow generator.
17
+ */
18
+ export class LightingVolume {
19
+ /**
20
+ * The shadow generator used to create the lighting volume.
21
+ */
22
+ get shadowGenerator() {
23
+ return this._shadowGenerator;
24
+ }
25
+ set shadowGenerator(sg) {
26
+ const light = sg.getLight();
27
+ if (!(light instanceof DirectionalLight)) {
28
+ throw new Error(`LightingVolumeMesh ${this._name}: light must be a directional light`);
29
+ }
30
+ this._shadowGenerator = sg;
31
+ this._light = light;
32
+ this._createGeometry();
33
+ if (!this._engine.isWebGPU) {
34
+ this._createFallbackTextures();
35
+ }
36
+ const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
37
+ if (this._cs && depthTexture) {
38
+ this._cs.setInternalTexture("shadowMap", depthTexture);
39
+ }
40
+ }
41
+ /**
42
+ * The tesselation level of the lighting volume.
43
+ */
44
+ get tesselation() {
45
+ return this._tesselation;
46
+ }
47
+ set tesselation(n) {
48
+ this._tesselation = n;
49
+ this._createGeometry();
50
+ }
51
+ /**
52
+ * Indicates whether to build the full volume (true) or only the far plane (false). Default is false.
53
+ */
54
+ get buildFullVolume() {
55
+ return this._buildFullVolume;
56
+ }
57
+ set buildFullVolume(value) {
58
+ if (this._buildFullVolume === value) {
59
+ return;
60
+ }
61
+ this._buildFullVolume = value;
62
+ this._createGeometry();
63
+ this._createComputeShader();
64
+ }
65
+ /**
66
+ * The mesh used as a support for the lighting volume.
67
+ * Note that this mesh is not automatically added to the scene's mesh array.
68
+ * If you want to render it, you need to add it manually.
69
+ */
70
+ get mesh() {
71
+ return this._mesh;
72
+ }
73
+ /**
74
+ * The frequency (in number of times you call updateMesh) at which the lighting volume is updated.
75
+ */
76
+ get frequency() {
77
+ return this._frequency;
78
+ }
79
+ set frequency(value) {
80
+ this._frequency = value;
81
+ this._firstUpdate = true;
82
+ }
83
+ /**
84
+ * The name of the lighting volume.
85
+ */
86
+ get name() {
87
+ return this._name;
88
+ }
89
+ set name(name) {
90
+ this._name = name;
91
+ if (this._mesh) {
92
+ this._mesh.name = name;
93
+ }
94
+ }
95
+ /**
96
+ * Indicates whether this is the first update of the lighting volume.
97
+ * If true, the volume has not yet been updated for the first time.
98
+ */
99
+ get firstUpdate() {
100
+ return this._firstUpdate;
101
+ }
102
+ /**
103
+ * Creates a new LightingVolume.
104
+ * @param name The name of the lighting volume.
105
+ * @param scene The scene the lighting volume belongs to.
106
+ * @param shadowGenerator The shadow generator used to create the lighting volume. This is optional in the constructor, but must be set before calling updateMesh.
107
+ * @param tesselation The tesselation level of the lighting volume (default: 64).
108
+ */
109
+ constructor(name, scene, shadowGenerator, tesselation = 64) {
110
+ this._readPixelPromise = null;
111
+ this._readPixelAbortController = null;
112
+ this._numFrames = 0;
113
+ this._firstUpdate = true;
114
+ this._tesselation = 0;
115
+ this._buildFullVolume = false;
116
+ this._frequency = 1;
117
+ const light = shadowGenerator ? shadowGenerator.getLight() : undefined;
118
+ if (light && !(light instanceof DirectionalLight)) {
119
+ throw new Error(`LightingVolumeMesh ${name}: light must be a directional light`);
120
+ }
121
+ this._name = name;
122
+ this._shadowGenerator = shadowGenerator;
123
+ this._light = light;
124
+ this._engine = scene.getEngine();
125
+ this._scene = scene;
126
+ this._mesh = new Mesh(name, this._scene);
127
+ scene.meshes.splice(scene.meshes.indexOf(this._mesh), 1);
128
+ if (this._engine.isWebGPU) {
129
+ this._uBuffer = new UniformBuffer(this._engine);
130
+ this._uBuffer.addUniform("invViewProjMatrix", 16);
131
+ this._uBuffer.addUniform("startVertexIndex", 1);
132
+ this._uBuffer.addUniform("step", 1);
133
+ this._uBuffer.addUniform("tesselation", 1);
134
+ this._uBuffer.update();
135
+ this._createComputeShader();
136
+ }
137
+ else {
138
+ this._copyTexture = new CopyTextureToTexture(this._engine, false, true);
139
+ this._createFallbackTextures();
140
+ }
141
+ this._tesselation = tesselation;
142
+ this._createGeometry();
143
+ }
144
+ /**
145
+ * Checks if the lighting volume is ready to be updated.
146
+ * @returns True if the volume is ready to be updated.
147
+ */
148
+ isReady() {
149
+ let isReady = this._mesh.isReady(true);
150
+ if (this._cs) {
151
+ isReady = this._cs.isReady() && isReady;
152
+ }
153
+ return isReady;
154
+ }
155
+ /**
156
+ * Updates the lighting volume mesh.
157
+ * @param forceUpdate If true, forces the update even if the frequency condition is not met.
158
+ */
159
+ update(forceUpdate = false) {
160
+ if (this._tesselation === 0 || !this._shadowGenerator) {
161
+ return;
162
+ }
163
+ if (!forceUpdate && !this._firstUpdate && (this.frequency === 0 || ++this._numFrames < this.frequency)) {
164
+ return;
165
+ }
166
+ this._numFrames = 0;
167
+ if (this._cs && this._uBuffer) {
168
+ const dispatchSize = Math.ceil((this._tesselation + 1) / 8);
169
+ const viewProjMatrix = this._shadowGenerator.getTransformMatrix();
170
+ viewProjMatrix.invertToRef(InvViewProjMatrix);
171
+ this._uBuffer.updateMatrix("invViewProjMatrix", InvViewProjMatrix);
172
+ this._uBuffer.update();
173
+ this._engine._debugPushGroup?.(`Generate lighting volume (${this._name})`);
174
+ this._cs.dispatch(dispatchSize, dispatchSize, 1);
175
+ this._engine._debugPopGroup?.();
176
+ this._firstUpdate = false;
177
+ }
178
+ else {
179
+ try {
180
+ void this._fallbackReadPixelAsync();
181
+ }
182
+ catch {
183
+ this._readPixelPromise = null;
184
+ }
185
+ }
186
+ }
187
+ /**
188
+ * Disposes the lighting volume and associated resources.
189
+ */
190
+ dispose() {
191
+ this._readPixelAbortController?.abort(new AbortError("LightingVolume is disposed"));
192
+ this._readPixelAbortController = null;
193
+ this._mesh.dispose();
194
+ if (this._fallbackTexture) {
195
+ this._fallbackTexture._texture = null;
196
+ }
197
+ this._fallbackTexture?.dispose();
198
+ this._copyTexture?.dispose();
199
+ this._storageBuffer?.dispose();
200
+ this._uBuffer?.dispose();
201
+ this._depthCopy?.dispose();
202
+ }
203
+ _createComputeShader() {
204
+ this._cs = new ComputeShader("createLightVolume", this._engine, "lightingVolume", {
205
+ bindingsMapping: {
206
+ shadowMap: { group: 0, binding: 0 },
207
+ params: { group: 0, binding: 1 },
208
+ positions: { group: 0, binding: 2 },
209
+ },
210
+ defines: !this._buildFullVolume ? ["#define KEEP_EDGES", "#define MOVE_FAR_DEPTH_TO_NEAR"] : undefined,
211
+ });
212
+ if (this._shadowGenerator) {
213
+ const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;
214
+ if (depthTexture) {
215
+ this._cs.setInternalTexture("shadowMap", depthTexture);
216
+ }
217
+ }
218
+ if (this._uBuffer) {
219
+ this._cs.setUniformBuffer("params", this._uBuffer);
220
+ }
221
+ if (this._storageBuffer) {
222
+ this._cs.setStorageBuffer("positions", this._storageBuffer);
223
+ }
224
+ }
225
+ _createFallbackTextures() {
226
+ if (!this._shadowGenerator) {
227
+ return;
228
+ }
229
+ this._readPixelAbortController?.abort(new AbortError("Fallback textures are being (re)created"));
230
+ this._readPixelAbortController = new AbortController();
231
+ const mapSize = this._shadowGenerator.mapSize;
232
+ this._depthCopy?.dispose();
233
+ this._depthCopy = this._engine.createRenderTargetTexture({ width: mapSize, height: mapSize }, {
234
+ type: 1,
235
+ format: 6,
236
+ samples: 1,
237
+ label: `${this._name} - fallback internal texture`,
238
+ generateDepthBuffer: false,
239
+ });
240
+ this._fallbackTexture?.dispose();
241
+ this._fallbackTexture = new BaseTexture(this._scene, this._depthCopy.texture);
242
+ this._fallbackTexture.name = `${this._name} - fallback texture`;
243
+ }
244
+ async _fallbackReadPixelAsync() {
245
+ if (this._readPixelPromise || !this._fallbackTexture || !this._copyTexture) {
246
+ return;
247
+ }
248
+ const abortController = this._readPixelAbortController;
249
+ abortController?.signal.throwIfAborted();
250
+ const engine = this._engine;
251
+ const shadowGenerator = this._shadowGenerator;
252
+ const shadowMapDepthTexture = shadowGenerator?.getShadowMap()?.depthStencilTexture;
253
+ if (!shadowMapDepthTexture) {
254
+ return;
255
+ }
256
+ // Copies the shadow map of the shadow generator into _depthCopy
257
+ // That's because we can't read from a depth attachment texture in WebGL. We must first copy it to a regular texture.
258
+ engine.updateTextureSamplingMode(1, shadowMapDepthTexture);
259
+ engine.updateTextureComparisonFunction(shadowMapDepthTexture, 0);
260
+ this._copyTexture.copy(shadowMapDepthTexture, this._depthCopy);
261
+ engine.updateTextureComparisonFunction(shadowMapDepthTexture, 513);
262
+ // Gets the texture from GPU to CPU
263
+ this._readPixelPromise = this._fallbackTexture.readPixels(0, 0, undefined, true, false);
264
+ if (!this._readPixelPromise) {
265
+ return;
266
+ }
267
+ const buffer = await this._readPixelPromise;
268
+ abortController?.signal.throwIfAborted();
269
+ const depthValues = buffer;
270
+ const positions = this._mesh.getVerticesData("position");
271
+ const numTesselation = this._tesselation;
272
+ const startPos = this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3;
273
+ const mapSize = shadowGenerator.mapSize;
274
+ const step = (mapSize - 1) / numTesselation;
275
+ if (!positions) {
276
+ this._readPixelPromise = null;
277
+ return;
278
+ }
279
+ const halfTesselation = numTesselation / 2;
280
+ const invViewProjMatrix = shadowGenerator.getTransformMatrix().clone();
281
+ invViewProjMatrix.invertToRef(invViewProjMatrix);
282
+ const factor = 4;
283
+ let posIndex = startPos;
284
+ let stepY = 0;
285
+ for (let y = 0; y < numTesselation + 1; ++y) {
286
+ for (let x = 0; x < numTesselation + 1; ++x) {
287
+ let depth = depthValues[Math.floor(mapSize * Math.floor(stepY) + x * step) * factor];
288
+ if (!this._buildFullVolume && (depth === 1 || y === 0 || x === 0 || y === numTesselation || x === numTesselation)) {
289
+ depth = 0;
290
+ }
291
+ TmpVec3.set((x - halfTesselation) / halfTesselation, (y - halfTesselation) / halfTesselation, -1 + 2 * depth);
292
+ Vector3.TransformCoordinatesToRef(TmpVec3, invViewProjMatrix, TmpVec3);
293
+ positions[posIndex] = TmpVec3.x;
294
+ positions[posIndex + 1] = TmpVec3.y;
295
+ positions[posIndex + 2] = TmpVec3.z;
296
+ posIndex += 3;
297
+ }
298
+ stepY += step;
299
+ }
300
+ this._mesh.setVerticesData("position", positions);
301
+ this._readPixelPromise = null;
302
+ this._firstUpdate = false;
303
+ }
304
+ _createGeometry() {
305
+ if (!this._light) {
306
+ return;
307
+ }
308
+ this._tesselation = Math.max(Math.ceil(this._tesselation) & ~1, 2);
309
+ const light = this._light;
310
+ const min = new Vector3(light.orthoLeft, light.orthoBottom, light.shadowMinZ ?? 0);
311
+ const max = new Vector3(light.orthoRight, light.orthoTop, light.shadowMaxZ ?? 10000);
312
+ const invViewMatrix = Matrix.LookAtLH(light.position, light.position.add(light.direction), Vector3.UpReadOnly);
313
+ invViewMatrix.invertToRef(invViewMatrix);
314
+ const positions = [];
315
+ const indices = [];
316
+ const numTesselation = this._tesselation;
317
+ const stepX = (max.x - min.x) / numTesselation;
318
+ const stepY = (max.y - min.y) / numTesselation;
319
+ const v = new Vector3();
320
+ const startFarIndices = this._buildFullVolume ? (numTesselation + 1) * 4 : 4;
321
+ if (this._buildFullVolume) {
322
+ let startIndices = 0;
323
+ // Right faces of the frustum
324
+ for (let i = 0; i <= numTesselation; ++i) {
325
+ v.set(max.x, min.y + i * stepY, min.z);
326
+ const p = Vector3.TransformCoordinates(v, invViewMatrix);
327
+ positions.push(p.x, p.y, p.z);
328
+ if (i < numTesselation) {
329
+ indices.push(startIndices + i, startFarIndices + numTesselation + (i + 1) * (numTesselation + 1), startFarIndices + numTesselation + i * (numTesselation + 1));
330
+ indices.push(startIndices + i, startIndices + i + 1, startFarIndices + numTesselation + (i + 1) * (numTesselation + 1));
331
+ }
332
+ }
333
+ const n0 = 0;
334
+ const n1 = positions.length / 3 - 1;
335
+ const n2 = n1 + 1;
336
+ startIndices = positions.length / 3;
337
+ // Left faces of the frustum
338
+ for (let i = 0; i <= numTesselation; ++i) {
339
+ v.set(min.x, min.y + i * stepY, min.z);
340
+ const p = Vector3.TransformCoordinates(v, invViewMatrix);
341
+ positions.push(p.x, p.y, p.z);
342
+ if (i < numTesselation) {
343
+ indices.push(startIndices + i, startFarIndices + 0 + i * (numTesselation + 1), startFarIndices + 0 + (i + 1) * (numTesselation + 1));
344
+ indices.push(startIndices + i, startFarIndices + 0 + (i + 1) * (numTesselation + 1), startIndices + i + 1);
345
+ }
346
+ }
347
+ const n3 = positions.length / 3 - 1;
348
+ startIndices = positions.length / 3;
349
+ // Bottom faces of the frustum
350
+ for (let i = 0; i <= numTesselation; ++i) {
351
+ v.set(min.x + i * stepX, min.y, min.z);
352
+ const p = Vector3.TransformCoordinates(v, invViewMatrix);
353
+ positions.push(p.x, p.y, p.z);
354
+ if (i < numTesselation) {
355
+ indices.push(startIndices + i, startIndices + i + 1, startFarIndices + i + 0 * (numTesselation + 1));
356
+ indices.push(startIndices + i + 1, startFarIndices + i + 1 + 0 * (numTesselation + 1), startFarIndices + i + 0 * (numTesselation + 1));
357
+ }
358
+ }
359
+ startIndices = positions.length / 3;
360
+ // Top faces of the frustum
361
+ for (let i = 0; i <= numTesselation; ++i) {
362
+ v.set(min.x + i * stepX, max.y, min.z);
363
+ const p = Vector3.TransformCoordinates(v, invViewMatrix);
364
+ positions.push(p.x, p.y, p.z);
365
+ if (i < numTesselation) {
366
+ indices.push(startIndices + i, startFarIndices + i + numTesselation * (numTesselation + 1), startIndices + i + 1);
367
+ indices.push(startIndices + i + 1, startFarIndices + i + numTesselation * (numTesselation + 1), startFarIndices + i + 1 + numTesselation * (numTesselation + 1));
368
+ }
369
+ }
370
+ startIndices = positions.length / 3;
371
+ // Near faces of the frustum
372
+ indices.push(n0, n2, n1);
373
+ indices.push(n2, n3, n1);
374
+ }
375
+ else {
376
+ let p;
377
+ v.set(max.x, min.y, min.z);
378
+ p = Vector3.TransformCoordinates(v, invViewMatrix);
379
+ positions.push(p.x, p.y, p.z);
380
+ v.set(max.x, max.y, min.z);
381
+ p = Vector3.TransformCoordinates(v, invViewMatrix);
382
+ positions.push(p.x, p.y, p.z);
383
+ v.set(min.x, min.y, min.z);
384
+ p = Vector3.TransformCoordinates(v, invViewMatrix);
385
+ positions.push(p.x, p.y, p.z);
386
+ v.set(min.x, max.y, min.z);
387
+ p = Vector3.TransformCoordinates(v, invViewMatrix);
388
+ positions.push(p.x, p.y, p.z);
389
+ indices.push(0, 2, 1);
390
+ indices.push(2, 3, 1);
391
+ }
392
+ // Tesselate the far plane
393
+ let y = min.y;
394
+ for (let iy = 0; iy <= numTesselation; ++iy) {
395
+ let x = min.x;
396
+ for (let ix = 0; ix <= numTesselation; ++ix) {
397
+ v.set(x, y, min.z);
398
+ const p = Vector3.TransformCoordinates(v, invViewMatrix);
399
+ positions.push(p.x, p.y, p.z);
400
+ if (ix < numTesselation && iy < numTesselation) {
401
+ indices.push(startFarIndices + ix + iy * (numTesselation + 1), startFarIndices + ix + 1 + iy * (numTesselation + 1), startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1));
402
+ indices.push(startFarIndices + ix + iy * (numTesselation + 1), startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1), startFarIndices + ix + (iy + 1) * (numTesselation + 1));
403
+ }
404
+ x += stepX;
405
+ }
406
+ y += stepY;
407
+ }
408
+ if (this._uBuffer && this._cs) {
409
+ const webGPUEngine = this._engine;
410
+ this._storageBuffer?.dispose();
411
+ this._storageBuffer = new StorageBuffer(webGPUEngine, positions.length * 4, 8 | 3);
412
+ this._storageBuffer.update(positions);
413
+ const vertexBuffer = new VertexBuffer(webGPUEngine, this._storageBuffer.getBuffer(), "position");
414
+ this._mesh.setVerticesBuffer(vertexBuffer);
415
+ this._cs.setStorageBuffer("positions", this._storageBuffer);
416
+ this._uBuffer.updateUInt("startVertexIndex", this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3);
417
+ this._uBuffer.updateFloat("step", ((this._shadowGenerator?.mapSize ?? 128) - 1) / numTesselation);
418
+ this._uBuffer.updateUInt("tesselation", numTesselation);
419
+ }
420
+ else {
421
+ this._mesh.setVerticesData("position", positions);
422
+ }
423
+ this._mesh.setIndices(indices, positions.length / 3);
424
+ }
425
+ }
426
+ //# sourceMappingURL=lightingVolume.js.map