@onerjs/core 8.47.1 → 8.47.3

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 (47) hide show
  1. package/Animations/animation.js +2 -2
  2. package/Animations/animation.js.map +1 -1
  3. package/Animations/animationGroup.js +1 -1
  4. package/Animations/animationGroup.js.map +1 -1
  5. package/Animations/animatorAvatar.js +13 -12
  6. package/Animations/animatorAvatar.js.map +1 -1
  7. package/Animations/easing.js +1 -1
  8. package/Animations/easing.js.map +1 -1
  9. package/Animations/pathCursor.js +1 -2
  10. package/Animations/pathCursor.js.map +1 -1
  11. package/Cameras/geospatialCameraMovement.js +4 -5
  12. package/Cameras/geospatialCameraMovement.js.map +1 -1
  13. package/Layers/selectionOutlineLayer.d.ts +7 -0
  14. package/Layers/selectionOutlineLayer.js +18 -1
  15. package/Layers/selectionOutlineLayer.js.map +1 -1
  16. package/Layers/thinSelectionOutlineLayer.d.ts +1 -0
  17. package/Layers/thinSelectionOutlineLayer.js +31 -6
  18. package/Layers/thinSelectionOutlineLayer.js.map +1 -1
  19. package/Lights/Clustered/clusteredLightContainer.d.ts +6 -0
  20. package/Lights/Clustered/clusteredLightContainer.js +42 -0
  21. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  22. package/Lights/light.d.ts +7 -0
  23. package/Lights/light.js +10 -0
  24. package/Lights/light.js.map +1 -1
  25. package/Materials/GreasedLine/greasedLineSimpleMaterial.js +13 -3
  26. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
  27. package/Materials/Textures/cubeTexture.js +10 -0
  28. package/Materials/Textures/cubeTexture.js.map +1 -1
  29. package/Meshes/abstractMesh.d.ts +8 -1
  30. package/Meshes/abstractMesh.js +9 -2
  31. package/Meshes/abstractMesh.js.map +1 -1
  32. package/Meshes/mesh.js +31 -4
  33. package/Meshes/mesh.js.map +1 -1
  34. package/Misc/greasedLineTools.js +5 -0
  35. package/Misc/greasedLineTools.js.map +1 -1
  36. package/Particles/EmitterTypes/coneParticleEmitter.js +2 -4
  37. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  38. package/Physics/v2/characterController.d.ts +5 -0
  39. package/Physics/v2/characterController.js +6 -0
  40. package/Physics/v2/characterController.js.map +1 -1
  41. package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
  42. package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
  43. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  44. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  45. package/XR/webXRSessionManager.js +7 -5
  46. package/XR/webXRSessionManager.js.map +1 -1
  47. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"light.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/light.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAe,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAuB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE;;;;GAIG;AACH,MAAM,OAAgB,KAAM,SAAQ,IAAI;IA8HpC;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IACD,IAAW,eAAe,CAAC,KAAc;QACrC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,aAAa,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perty } from \"../Misc/decorators\";\r\nimport { type Nullable } from \"../types\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, TmpColors } from \"../Maths/math.color\";\r\nimport { Node } from \"../node\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type Effect } from \"../Materials/effect\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport { type IShadowGenerator } from \"./Shadows/shadowGenerator\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\nimport { type ISortableLight, LightConstants } from \"./lightConstants\";\r\nimport { type Camera } from \"../Cameras/camera\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n/**\r\n * Base class of all the lights in Babylon. It groups all the generic information about lights.\r\n * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.\r\n * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.\r\n */\r\nexport abstract class Light extends Node implements ISortableLight {\r\n /**\r\n * Falloff Default: light is falling off following the material specification:\r\n * standard material is using standard falloff whereas pbr material can request special falloff per materials.\r\n */\r\n public static readonly FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Falloff Physical: light is falling off following the inverse squared distance law.\r\n */\r\n public static readonly FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL;\r\n\r\n /**\r\n * Falloff gltf: light is falling off as described in the gltf moving to PBR document\r\n * to enhance interoperability with other engines.\r\n */\r\n public static readonly FALLOFF_GLTF = LightConstants.FALLOFF_GLTF;\r\n\r\n /**\r\n * Falloff Standard: light is falling off like in the standard material\r\n * to enhance interoperability with other materials.\r\n */\r\n public static readonly FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD;\r\n\r\n //lightmapMode Consts\r\n /**\r\n * If every light affecting the material is in this lightmapMode,\r\n * material.lightmapTexture adds or multiplies\r\n * (depends on material.useLightmapAsShadowmap)\r\n * after every other light calculations.\r\n */\r\n public static readonly LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT;\r\n /**\r\n * material.lightmapTexture as only diffuse lighting from this light\r\n * adds only specular lighting from this light\r\n * adds dynamic shadows\r\n */\r\n public static readonly LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR;\r\n /**\r\n * material.lightmapTexture as only lighting\r\n * no light calculation from this light\r\n * only adds dynamic shadows from this light\r\n */\r\n public static readonly LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY;\r\n\r\n // Intensity Mode Consts\r\n /**\r\n * Each light type uses the default quantity according to its type:\r\n * point/spot lights use luminous intensity\r\n * directional lights use illuminance\r\n */\r\n public static readonly INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * lumen (lm)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER;\r\n /**\r\n * candela (lm/sr)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY;\r\n /**\r\n * lux (lm/m^2)\r\n */\r\n public static readonly INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE;\r\n /**\r\n * nit (cd/m^2)\r\n */\r\n public static readonly INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE;\r\n\r\n // Light types ids const.\r\n /**\r\n * Light type const id of the point light.\r\n */\r\n public static readonly LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT;\r\n /**\r\n * Light type const id of the directional light.\r\n */\r\n public static readonly LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT;\r\n /**\r\n * Light type const id of the spot light.\r\n */\r\n public static readonly LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT;\r\n /**\r\n * Light type const id of the hemispheric light.\r\n */\r\n public static readonly LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT;\r\n\r\n /**\r\n * Light type const id of the area light.\r\n */\r\n public static readonly LIGHTTYPEID_RECT_AREALIGHT = LightConstants.LIGHTTYPEID_RECT_AREALIGHT;\r\n\r\n /**\r\n * Diffuse gives the basic color to an object.\r\n */\r\n @serializeAsColor3()\r\n public diffuse = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Specular produces a highlight color on an object.\r\n * Note: This is not affecting PBR materials.\r\n */\r\n @serializeAsColor3()\r\n public specular = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Defines the falloff type for this light. This lets overriding how punctual light are\r\n * falling off base on range or angle.\r\n * This can be set to any values in Light.FALLOFF_x.\r\n *\r\n * Note: This is only useful for PBR Materials at the moment. This could be extended if required to\r\n * other types of materials.\r\n */\r\n @serialize()\r\n public falloffType = Light.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Strength of the light.\r\n * Note: By default it is define in the framework own unit.\r\n * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.\r\n */\r\n @serialize()\r\n public intensity = 1.0;\r\n\r\n /** @internal */\r\n private _internalEnabled = true;\r\n /**\r\n * Defines light internal enabled state.\r\n */\r\n public get internalEnabled(): boolean {\r\n return this._internalEnabled;\r\n }\r\n public set internalEnabled(value: boolean) {\r\n this._internalEnabled = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n private _range = Number.MAX_VALUE;\r\n /** @internal */\r\n public _inverseSquaredRange = 0;\r\n\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n @serialize()\r\n public get range(): number {\r\n return this._range;\r\n }\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n public set range(value: number) {\r\n this._range = value;\r\n this._inverseSquaredRange = 1.0 / (this.range * this.range);\r\n }\r\n\r\n /**\r\n * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type\r\n * of light.\r\n */\r\n private _photometricScale = 1.0;\r\n\r\n private _intensityMode: number = Light.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * Gets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n @serialize()\r\n public get intensityMode(): number {\r\n return this._intensityMode;\r\n }\r\n /**\r\n * Sets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n public set intensityMode(value: number) {\r\n this._intensityMode = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n private _radius = 0.00001;\r\n /**\r\n * Gets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n @serialize()\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n /**\r\n * sets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n @serialize()\r\n private _renderPriority: number;\r\n /**\r\n * Defines the rendering priority of the lights. It can help in case of fallback or number of lights\r\n * exceeding the number allowed of the materials.\r\n */\r\n @expandToProperty(\"_reorderLightsInScene\")\r\n public renderPriority: number = 0;\r\n\r\n @serialize(\"shadowEnabled\")\r\n private _shadowEnabled: boolean = true;\r\n /**\r\n * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public get shadowEnabled(): boolean {\r\n return this._shadowEnabled;\r\n }\r\n /**\r\n * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public set shadowEnabled(value: boolean) {\r\n if (this._shadowEnabled === value) {\r\n return;\r\n }\r\n\r\n this._shadowEnabled = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n private _includedOnlyMeshes: AbstractMesh[];\r\n /**\r\n * Gets the only meshes impacted by this light.\r\n */\r\n public get includedOnlyMeshes(): AbstractMesh[] {\r\n return this._includedOnlyMeshes;\r\n }\r\n /**\r\n * Sets the only meshes impacted by this light.\r\n */\r\n public set includedOnlyMeshes(value: AbstractMesh[]) {\r\n this._includedOnlyMeshes = value;\r\n this._hookArrayForIncludedOnly(value);\r\n }\r\n\r\n private _excludedMeshes: AbstractMesh[];\r\n /**\r\n * Gets the meshes not impacted by this light.\r\n */\r\n public get excludedMeshes(): AbstractMesh[] {\r\n return this._excludedMeshes;\r\n }\r\n /**\r\n * Sets the meshes not impacted by this light.\r\n */\r\n public set excludedMeshes(value: AbstractMesh[]) {\r\n this._excludedMeshes = value;\r\n this._hookArrayForExcluded(value);\r\n }\r\n\r\n @serialize(\"excludeWithLayerMask\")\r\n private _excludeWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get excludeWithLayerMask(): number {\r\n return this._excludeWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set excludeWithLayerMask(value: number) {\r\n this._excludeWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"includeOnlyWithLayerMask\")\r\n private _includeOnlyWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get includeOnlyWithLayerMask(): number {\r\n return this._includeOnlyWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set includeOnlyWithLayerMask(value: number) {\r\n this._includeOnlyWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"lightmapMode\")\r\n private _lightmapMode = 0;\r\n /**\r\n * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public get lightmapMode(): number {\r\n return this._lightmapMode;\r\n }\r\n /**\r\n * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public set lightmapMode(value: number) {\r\n if (this._lightmapMode === value) {\r\n return;\r\n }\r\n\r\n this._lightmapMode = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n /**\r\n * Returns the view matrix.\r\n * @param _faceIndex The index of the face for which we want to extract the view matrix. Only used for point light types.\r\n * @returns The view matrix. Can be null, if a view matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getViewMatrix(_faceIndex?: number): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Returns the projection matrix.\r\n * Note that viewMatrix and renderList are optional and are only used by lights that calculate the projection matrix from a list of meshes (e.g. directional lights with automatic extents calculation).\r\n * @param _viewMatrix The view transform matrix of the light (optional).\r\n * @param _renderList The list of meshes to take into account when calculating the projection matrix (optional).\r\n * @returns The projection matrix. Can be null, if a projection matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getProjectionMatrix(_viewMatrix?: Matrix, _renderList?: Array<AbstractMesh>): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Shadow generators associated to the light.\r\n * @internal Internal use only.\r\n */\r\n public _shadowGenerators: Nullable<Map<Nullable<Camera>, IShadowGenerator>> = null;\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _excludedMeshesIds = new Array<string>();\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _includedOnlyMeshesIds = new Array<string>();\r\n\r\n /**\r\n * The current light uniform buffer.\r\n * @internal Internal use only.\r\n */\r\n public _uniformBuffer: UniformBuffer;\r\n\r\n /** @internal */\r\n public _renderId: number;\r\n\r\n private _lastUseSpecular: boolean;\r\n\r\n /**\r\n * Used internally by ClusteredLight to sort lights\r\n * @internal\r\n */\r\n public _currentViewDepth = 0;\r\n\r\n /**\r\n * Creates a Light object in the scene.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The friendly name of the light\r\n * @param scene The scene the light belongs too\r\n * @param dontAddToScene True to not add the light to the scene\r\n */\r\n constructor(name: string, scene?: Scene, dontAddToScene?: boolean) {\r\n super(name, scene, false);\r\n if (!dontAddToScene) {\r\n this.getScene().addLight(this);\r\n }\r\n this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);\r\n this._buildUniformLayout();\r\n\r\n this.includedOnlyMeshes = [] as AbstractMesh[];\r\n this.excludedMeshes = [] as AbstractMesh[];\r\n\r\n if (!dontAddToScene) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n protected abstract _buildUniformLayout(): void;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public abstract transferToEffect(effect: Effect, lightIndex: string): Light;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n // Do nothing by default.\r\n return this;\r\n }\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows = true): void {\r\n const iAsString = lightIndex.toString();\r\n let needUpdate = false;\r\n\r\n this._uniformBuffer.bindToEffect(effect, \"Light\" + iAsString);\r\n\r\n if (this._renderId !== scene.getRenderId() || this._lastUseSpecular !== useSpecular || !this._uniformBuffer.useUbo) {\r\n this._renderId = scene.getRenderId();\r\n this._lastUseSpecular = useSpecular;\r\n\r\n const scaledIntensity = this.getScaledIntensity();\r\n\r\n this.transferToEffect(effect, iAsString);\r\n\r\n this.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\r\n this._uniformBuffer.updateColor4(\"vLightDiffuse\", TmpColors.Color3[0], this.range, iAsString);\r\n if (useSpecular) {\r\n this.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\r\n this._uniformBuffer.updateColor4(\"vLightSpecular\", TmpColors.Color3[1], this.radius, iAsString);\r\n }\r\n needUpdate = true;\r\n }\r\n\r\n // Textures might still need to be rebound.\r\n this.transferTexturesToEffect(effect, iAsString);\r\n\r\n // Shadows\r\n if (scene.shadowsEnabled && this.shadowEnabled && receiveShadows) {\r\n const shadowGenerator = this.getShadowGenerator(scene.activeCamera) ?? this.getShadowGenerator();\r\n if (shadowGenerator) {\r\n shadowGenerator.bindShadowLight(iAsString, effect);\r\n needUpdate = true;\r\n }\r\n }\r\n\r\n if (needUpdate) {\r\n this._uniformBuffer.update();\r\n } else {\r\n this._uniformBuffer.bindUniformBuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightDataUniformName The uniform used to store light data (position or direction)\r\n * @returns The light\r\n */\r\n public abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;\r\n\r\n /**\r\n * Returns the string \"Light\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"Light\";\r\n }\r\n\r\n /** @internal */\r\n public readonly _isLight = true;\r\n\r\n /**\r\n * Converts the light information to a readable string for debug purpose.\r\n * @param fullDetails Supports for multiple levels of logging within scene loading\r\n * @returns the human readable light info\r\n */\r\n public override toString(fullDetails?: boolean): string {\r\n let ret = \"Name: \" + this.name;\r\n ret += \", type: \" + [\"Point\", \"Directional\", \"Spot\", \"Hemispheric\", \"Clustered\"][this.getTypeID()];\r\n if (this.animations) {\r\n for (let i = 0; i < this.animations.length; i++) {\r\n ret += \", animation[0]: \" + this.animations[i].toString(fullDetails);\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n /** @internal */\r\n protected override _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.isDisposed()) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n /**\r\n * Set the enabled state of this node.\r\n * @param value - the new enabled state\r\n */\r\n public override setEnabled(value: boolean): void {\r\n super.setEnabled(value);\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n /**\r\n * Returns the Light associated shadow generator if any.\r\n * @param camera Camera for which the shadow generator should be retrieved (default: null). If null, retrieves the default shadow generator\r\n * @returns the associated shadow generator.\r\n */\r\n public getShadowGenerator(camera: Nullable<Camera> = null): Nullable<IShadowGenerator> {\r\n if (this._shadowGenerators === null) {\r\n return null;\r\n }\r\n\r\n return this._shadowGenerators.get(camera) ?? null;\r\n }\r\n\r\n /**\r\n * Returns all the shadow generators associated to this light\r\n * @returns\r\n */\r\n public getShadowGenerators(): Nullable<Map<Nullable<Camera>, IShadowGenerator>> {\r\n return this._shadowGenerators;\r\n }\r\n\r\n /**\r\n * Returns a Vector3, the absolute light position in the World.\r\n * @returns the world space position of the light\r\n */\r\n public getAbsolutePosition(): Vector3 {\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Specifies if the light will affect the passed mesh.\r\n * @param mesh The mesh to test against the light\r\n * @returns true the mesh is affected otherwise, false.\r\n */\r\n public canAffectMesh(mesh: AbstractMesh): boolean {\r\n if (!this.internalEnabled) {\r\n return false;\r\n }\r\n if (!mesh) {\r\n return true;\r\n }\r\n\r\n if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {\r\n return false;\r\n }\r\n\r\n if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {\r\n return false;\r\n }\r\n\r\n if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {\r\n return false;\r\n }\r\n\r\n if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases resources associated with this node.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n if (this._shadowGenerators) {\r\n const iterator = this._shadowGenerators.values();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const shadowGenerator = key.value;\r\n shadowGenerator.dispose();\r\n }\r\n this._shadowGenerators = null;\r\n }\r\n\r\n // Animations\r\n this.getScene().stopAnimation(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.lights.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.lights.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n // Remove from meshes\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._removeLightSource(this, true);\r\n }\r\n\r\n this._uniformBuffer.dispose();\r\n\r\n // Remove from scene\r\n this.getScene().removeLight(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * Returns the light type ID (integer).\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public getTypeID(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.\r\n * @returns the scaled intensity in intensity mode unit\r\n */\r\n public getScaledIntensity() {\r\n return this._photometricScale * this.intensity;\r\n }\r\n\r\n /**\r\n * Returns a new Light object, named \"name\", from the current one.\r\n * @param name The name of the cloned light\r\n * @param newParent The parent of this light, if it has one\r\n * @returns the new created light\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n const clonedLight = SerializationHelper.Clone(constructor, this);\r\n if (name) {\r\n clonedLight.name = name;\r\n }\r\n if (newParent) {\r\n clonedLight.parent = newParent;\r\n }\r\n clonedLight.setEnabled(this.isEnabled());\r\n\r\n this.onClonedObservable.notifyObservers(clonedLight);\r\n\r\n return clonedLight;\r\n }\r\n\r\n /**\r\n * Serializes the current light into a Serialization object.\r\n * @returns the serialized object.\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.uniqueId = this.uniqueId;\r\n\r\n // Type\r\n serializationObject.type = this.getTypeID();\r\n\r\n // Parent\r\n if (this.parent) {\r\n this.parent._serializeAsParent(serializationObject);\r\n }\r\n\r\n // Inclusion / exclusions\r\n if (this.excludedMeshes.length > 0) {\r\n serializationObject.excludedMeshesIds = [];\r\n for (const mesh of this.excludedMeshes) {\r\n serializationObject.excludedMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n if (this.includedOnlyMeshes.length > 0) {\r\n serializationObject.includedOnlyMeshesIds = [];\r\n for (const mesh of this.includedOnlyMeshes) {\r\n serializationObject.includedOnlyMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n serializationObject.ranges = this.serializeAnimationRanges();\r\n\r\n serializationObject.isEnabled = this.isEnabled();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.\r\n * This new light is named \"name\" and added to the passed scene.\r\n * @param type Type according to the types available in Light.LIGHTTYPEID_x\r\n * @param name The friendly name of the light\r\n * @param scene The scene the new light will belong to\r\n * @returns the constructor function\r\n */\r\n static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light> {\r\n const constructorFunc = Node.Construct(\"Light_Type_\" + type, name, scene);\r\n\r\n if (constructorFunc) {\r\n return <() => Light>constructorFunc;\r\n }\r\n\r\n // Default to no light for none present once.\r\n return null;\r\n }\r\n\r\n /**\r\n * Parses the passed \"parsedLight\" and returns a new instanced Light from this parsing.\r\n * @param parsedLight The JSON representation of the light\r\n * @param scene The scene to create the parsed light in\r\n * @returns the created light after parsing\r\n */\r\n public static Parse(parsedLight: any, scene: Scene): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n\r\n const light = SerializationHelper.Parse(constructor, parsedLight, scene);\r\n\r\n // Inclusion / exclusions\r\n if (parsedLight.excludedMeshesIds) {\r\n light._excludedMeshesIds = parsedLight.excludedMeshesIds;\r\n }\r\n\r\n if (parsedLight.includedOnlyMeshesIds) {\r\n light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;\r\n }\r\n\r\n // Parent\r\n if (parsedLight.parentId !== undefined) {\r\n light._waitingParentId = parsedLight.parentId;\r\n }\r\n\r\n if (parsedLight.parentInstanceIndex !== undefined) {\r\n light._waitingParentInstanceIndex = parsedLight.parentInstanceIndex;\r\n }\r\n\r\n // Falloff\r\n if (parsedLight.falloffType !== undefined) {\r\n light.falloffType = parsedLight.falloffType;\r\n }\r\n\r\n // Lightmaps\r\n if (parsedLight.lightmapMode !== undefined) {\r\n light.lightmapMode = parsedLight.lightmapMode;\r\n }\r\n\r\n // Animations\r\n if (parsedLight.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedLight.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n light.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n Node.ParseAnimationRanges(light, parsedLight, scene);\r\n }\r\n\r\n if (parsedLight.autoAnimate) {\r\n scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);\r\n }\r\n\r\n // Check if isEnabled is defined to be back compatible with prior serialized versions.\r\n if (parsedLight.isEnabled !== undefined) {\r\n light.setEnabled(parsedLight.isEnabled);\r\n }\r\n\r\n return light;\r\n }\r\n\r\n private _hookArrayForExcluded(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n for (const item of items) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.call(array, index, deleteCount ?? array.length);\r\n\r\n for (const item of deleted) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return deleted;\r\n };\r\n\r\n for (const item of array) {\r\n item._resyncLightSource(this);\r\n }\r\n }\r\n\r\n private _hookArrayForIncludedOnly(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n this._resyncMeshes();\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.call(array, index, deleteCount ?? array.length);\r\n\r\n this._resyncMeshes();\r\n\r\n return deleted;\r\n };\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n private _resyncMeshes() {\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._resyncLightSource(this);\r\n }\r\n }\r\n\r\n /**\r\n * Forces the meshes to update their light related information in their rendering used effects\r\n * @internal Internal Use Only\r\n */\r\n public _markMeshesAsLightDirty() {\r\n for (const mesh of this.getScene().meshes) {\r\n if (mesh.lightSources.indexOf(this) !== -1) {\r\n mesh._markSubMeshesAsLightDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recomputes the cached photometric scale if needed.\r\n */\r\n private _computePhotometricScale(): void {\r\n this._photometricScale = this._getPhotometricScale();\r\n this.getScene().resetCachedMaterial();\r\n }\r\n\r\n /**\r\n * @returns the Photometric Scale according to the light type and intensity mode.\r\n */\r\n private _getPhotometricScale() {\r\n let photometricScale = 0.0;\r\n const lightTypeID = this.getTypeID();\r\n\r\n //get photometric mode\r\n let photometricMode = this.intensityMode;\r\n if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {\r\n if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {\r\n photometricMode = Light.INTENSITYMODE_ILLUMINANCE;\r\n } else {\r\n photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;\r\n }\r\n }\r\n\r\n //compute photometric scale\r\n switch (lightTypeID) {\r\n case Light.LIGHTTYPEID_POINTLIGHT:\r\n case Light.LIGHTTYPEID_SPOTLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_LUMINOUSPOWER:\r\n photometricScale = 1.0 / (4.0 * Math.PI);\r\n break;\r\n case Light.INTENSITYMODE_LUMINOUSINTENSITY:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE:\r\n photometricScale = this.radius * this.radius;\r\n break;\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_DIRECTIONALLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_ILLUMINANCE:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE: {\r\n // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.\r\n // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).\r\n let apexAngleRadians = this.radius;\r\n // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).\r\n apexAngleRadians = Math.max(apexAngleRadians, 0.001);\r\n const solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));\r\n photometricScale = solidAngle;\r\n break;\r\n }\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_HEMISPHERICLIGHT:\r\n // No fall off in hemispheric light.\r\n photometricScale = 1.0;\r\n break;\r\n }\r\n return photometricScale;\r\n }\r\n\r\n /**\r\n * Reorder the light in the scene according to their defined priority.\r\n * @internal Internal Use Only\r\n */\r\n public _reorderLightsInScene(): void {\r\n const scene = this.getScene();\r\n if (this._renderPriority != 0) {\r\n scene.requireLightSorting = true;\r\n }\r\n this.getScene().sortLightsByPriority();\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isReady() {\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"light.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/light.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAe,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAuB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE;;;;GAIG;AACH,MAAM,OAAgB,KAAM,SAAQ,IAAI;IA8HpC;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAC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CAAC,uBAAuB,CAAC;6CACR;AAG1B;IADP,SAAS,CAAC,eAAe,CAAC;6CACY;AAoD/B;IADP,SAAS,CAAC,sBAAsB,CAAC;oDACA;AAkB1B;IADP,SAAS,CAAC,0BAA0B,CAAC;wDACA;AAkB9B;IADP,SAAS,CAAC,cAAc,CAAC;4CACA","sourcesContent":["import { serialize, serializeAsColor3, expandToProperty } from \"../Misc/decorators\";\r\nimport { type Nullable } from \"../types\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, TmpColors } from \"../Maths/math.color\";\r\nimport { Node } from \"../node\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { type Effect } from \"../Materials/effect\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport { type IShadowGenerator } from \"./Shadows/shadowGenerator\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\nimport { type ISortableLight, LightConstants } from \"./lightConstants\";\r\nimport { type Camera } from \"../Cameras/camera\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n/**\r\n * Base class of all the lights in Babylon. It groups all the generic information about lights.\r\n * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.\r\n * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.\r\n */\r\nexport abstract class Light extends Node implements ISortableLight {\r\n /**\r\n * Falloff Default: light is falling off following the material specification:\r\n * standard material is using standard falloff whereas pbr material can request special falloff per materials.\r\n */\r\n public static readonly FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Falloff Physical: light is falling off following the inverse squared distance law.\r\n */\r\n public static readonly FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL;\r\n\r\n /**\r\n * Falloff gltf: light is falling off as described in the gltf moving to PBR document\r\n * to enhance interoperability with other engines.\r\n */\r\n public static readonly FALLOFF_GLTF = LightConstants.FALLOFF_GLTF;\r\n\r\n /**\r\n * Falloff Standard: light is falling off like in the standard material\r\n * to enhance interoperability with other materials.\r\n */\r\n public static readonly FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD;\r\n\r\n //lightmapMode Consts\r\n /**\r\n * If every light affecting the material is in this lightmapMode,\r\n * material.lightmapTexture adds or multiplies\r\n * (depends on material.useLightmapAsShadowmap)\r\n * after every other light calculations.\r\n */\r\n public static readonly LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT;\r\n /**\r\n * material.lightmapTexture as only diffuse lighting from this light\r\n * adds only specular lighting from this light\r\n * adds dynamic shadows\r\n */\r\n public static readonly LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR;\r\n /**\r\n * material.lightmapTexture as only lighting\r\n * no light calculation from this light\r\n * only adds dynamic shadows from this light\r\n */\r\n public static readonly LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY;\r\n\r\n // Intensity Mode Consts\r\n /**\r\n * Each light type uses the default quantity according to its type:\r\n * point/spot lights use luminous intensity\r\n * directional lights use illuminance\r\n */\r\n public static readonly INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * lumen (lm)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER;\r\n /**\r\n * candela (lm/sr)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY;\r\n /**\r\n * lux (lm/m^2)\r\n */\r\n public static readonly INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE;\r\n /**\r\n * nit (cd/m^2)\r\n */\r\n public static readonly INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE;\r\n\r\n // Light types ids const.\r\n /**\r\n * Light type const id of the point light.\r\n */\r\n public static readonly LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT;\r\n /**\r\n * Light type const id of the directional light.\r\n */\r\n public static readonly LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT;\r\n /**\r\n * Light type const id of the spot light.\r\n */\r\n public static readonly LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT;\r\n /**\r\n * Light type const id of the hemispheric light.\r\n */\r\n public static readonly LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT;\r\n\r\n /**\r\n * Light type const id of the area light.\r\n */\r\n public static readonly LIGHTTYPEID_RECT_AREALIGHT = LightConstants.LIGHTTYPEID_RECT_AREALIGHT;\r\n\r\n /**\r\n * Diffuse gives the basic color to an object.\r\n */\r\n @serializeAsColor3()\r\n public diffuse = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Specular produces a highlight color on an object.\r\n * Note: This is not affecting PBR materials.\r\n */\r\n @serializeAsColor3()\r\n public specular = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Defines the falloff type for this light. This lets overriding how punctual light are\r\n * falling off base on range or angle.\r\n * This can be set to any values in Light.FALLOFF_x.\r\n *\r\n * Note: This is only useful for PBR Materials at the moment. This could be extended if required to\r\n * other types of materials.\r\n */\r\n @serialize()\r\n public falloffType = Light.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Strength of the light.\r\n * Note: By default it is define in the framework own unit.\r\n * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.\r\n */\r\n @serialize()\r\n public intensity = 1.0;\r\n\r\n /** @internal */\r\n private _internalEnabled = true;\r\n /**\r\n * Defines light internal enabled state.\r\n */\r\n public get internalEnabled(): boolean {\r\n return this._internalEnabled;\r\n }\r\n public set internalEnabled(value: boolean) {\r\n this._internalEnabled = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n private _range = Number.MAX_VALUE;\r\n /** @internal */\r\n public _inverseSquaredRange = 0;\r\n\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n @serialize()\r\n public get range(): number {\r\n return this._range;\r\n }\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n public set range(value: number) {\r\n this._range = value;\r\n this._inverseSquaredRange = 1.0 / (this.range * this.range);\r\n }\r\n\r\n /**\r\n * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type\r\n * of light.\r\n */\r\n private _photometricScale = 1.0;\r\n\r\n private _intensityMode: number = Light.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * Gets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n @serialize()\r\n public get intensityMode(): number {\r\n return this._intensityMode;\r\n }\r\n /**\r\n * Sets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n public set intensityMode(value: number) {\r\n this._intensityMode = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n private _radius = 0.00001;\r\n /**\r\n * Gets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n @serialize()\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n /**\r\n * sets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n @serialize()\r\n private _renderPriority: number;\r\n /**\r\n * Defines the rendering priority of the lights. It can help in case of fallback or number of lights\r\n * exceeding the number allowed of the materials.\r\n */\r\n @expandToProperty(\"_reorderLightsInScene\")\r\n public renderPriority: number = 0;\r\n\r\n @serialize(\"shadowEnabled\")\r\n private _shadowEnabled: boolean = true;\r\n /**\r\n * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public get shadowEnabled(): boolean {\r\n return this._shadowEnabled;\r\n }\r\n /**\r\n * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public set shadowEnabled(value: boolean) {\r\n if (this._shadowEnabled === value) {\r\n return;\r\n }\r\n\r\n this._shadowEnabled = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n private _includedOnlyMeshes: AbstractMesh[];\r\n /**\r\n * Gets the only meshes impacted by this light.\r\n */\r\n public get includedOnlyMeshes(): AbstractMesh[] {\r\n return this._includedOnlyMeshes;\r\n }\r\n /**\r\n * Sets the only meshes impacted by this light.\r\n */\r\n public set includedOnlyMeshes(value: AbstractMesh[]) {\r\n this._includedOnlyMeshes = value;\r\n this._hookArrayForIncludedOnly(value);\r\n }\r\n\r\n private _excludedMeshes: AbstractMesh[];\r\n /**\r\n * Gets the meshes not impacted by this light.\r\n */\r\n public get excludedMeshes(): AbstractMesh[] {\r\n return this._excludedMeshes;\r\n }\r\n /**\r\n * Sets the meshes not impacted by this light.\r\n */\r\n public set excludedMeshes(value: AbstractMesh[]) {\r\n this._excludedMeshes = value;\r\n this._hookArrayForExcluded(value);\r\n }\r\n\r\n @serialize(\"excludeWithLayerMask\")\r\n private _excludeWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get excludeWithLayerMask(): number {\r\n return this._excludeWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set excludeWithLayerMask(value: number) {\r\n this._excludeWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"includeOnlyWithLayerMask\")\r\n private _includeOnlyWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get includeOnlyWithLayerMask(): number {\r\n return this._includeOnlyWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set includeOnlyWithLayerMask(value: number) {\r\n this._includeOnlyWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"lightmapMode\")\r\n private _lightmapMode = 0;\r\n /**\r\n * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public get lightmapMode(): number {\r\n return this._lightmapMode;\r\n }\r\n /**\r\n * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public set lightmapMode(value: number) {\r\n if (this._lightmapMode === value) {\r\n return;\r\n }\r\n\r\n this._lightmapMode = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n /**\r\n * Returns the view matrix.\r\n * @param _faceIndex The index of the face for which we want to extract the view matrix. Only used for point light types.\r\n * @returns The view matrix. Can be null, if a view matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getViewMatrix(_faceIndex?: number): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Returns the projection matrix.\r\n * Note that viewMatrix and renderList are optional and are only used by lights that calculate the projection matrix from a list of meshes (e.g. directional lights with automatic extents calculation).\r\n * @param _viewMatrix The view transform matrix of the light (optional).\r\n * @param _renderList The list of meshes to take into account when calculating the projection matrix (optional).\r\n * @returns The projection matrix. Can be null, if a projection matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getProjectionMatrix(_viewMatrix?: Matrix, _renderList?: Array<AbstractMesh>): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Shadow generators associated to the light.\r\n * @internal Internal use only.\r\n */\r\n public _shadowGenerators: Nullable<Map<Nullable<Camera>, IShadowGenerator>> = null;\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _excludedMeshesIds = new Array<string>();\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _includedOnlyMeshesIds = new Array<string>();\r\n\r\n /**\r\n * The current light uniform buffer.\r\n * @internal Internal use only.\r\n */\r\n public _uniformBuffer: UniformBuffer;\r\n\r\n /** @internal */\r\n public _renderId: number;\r\n\r\n private _lastUseSpecular: boolean;\r\n\r\n /**\r\n * Used internally by ClusteredLight to sort lights\r\n * @internal\r\n */\r\n public _currentViewDepth = 0;\r\n\r\n /**\r\n * Creates a Light object in the scene.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The friendly name of the light\r\n * @param scene The scene the light belongs too\r\n * @param dontAddToScene True to not add the light to the scene\r\n */\r\n constructor(name: string, scene?: Scene, dontAddToScene?: boolean) {\r\n super(name, scene, false);\r\n if (!dontAddToScene) {\r\n this.getScene().addLight(this);\r\n }\r\n this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);\r\n this._buildUniformLayout();\r\n\r\n this.includedOnlyMeshes = [] as AbstractMesh[];\r\n this.excludedMeshes = [] as AbstractMesh[];\r\n\r\n if (!dontAddToScene) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n protected abstract _buildUniformLayout(): void;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public abstract transferToEffect(effect: Effect, lightIndex: string): Light;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n // Do nothing by default.\r\n return this;\r\n }\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows = true): void {\r\n const iAsString = lightIndex.toString();\r\n let needUpdate = false;\r\n\r\n this._uniformBuffer.bindToEffect(effect, \"Light\" + iAsString);\r\n\r\n if (this._renderId !== scene.getRenderId() || this._lastUseSpecular !== useSpecular || !this._uniformBuffer.useUbo) {\r\n this._renderId = scene.getRenderId();\r\n this._lastUseSpecular = useSpecular;\r\n\r\n const scaledIntensity = this.getScaledIntensity();\r\n\r\n this.transferToEffect(effect, iAsString);\r\n\r\n this.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\r\n this._uniformBuffer.updateColor4(\"vLightDiffuse\", TmpColors.Color3[0], this.range, iAsString);\r\n if (useSpecular) {\r\n this.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\r\n this._uniformBuffer.updateColor4(\"vLightSpecular\", TmpColors.Color3[1], this.radius, iAsString);\r\n }\r\n needUpdate = true;\r\n }\r\n\r\n // Textures might still need to be rebound.\r\n this.transferTexturesToEffect(effect, iAsString);\r\n\r\n // Shadows\r\n if (scene.shadowsEnabled && this.shadowEnabled && receiveShadows) {\r\n const shadowGenerator = this.getShadowGenerator(scene.activeCamera) ?? this.getShadowGenerator();\r\n if (shadowGenerator) {\r\n shadowGenerator.bindShadowLight(iAsString, effect);\r\n needUpdate = true;\r\n }\r\n }\r\n\r\n if (needUpdate) {\r\n this._uniformBuffer.update();\r\n } else {\r\n this._uniformBuffer.bindUniformBuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightDataUniformName The uniform used to store light data (position or direction)\r\n * @returns The light\r\n */\r\n public abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;\r\n\r\n /**\r\n * Returns the string \"Light\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"Light\";\r\n }\r\n\r\n /** @internal */\r\n public readonly _isLight = true;\r\n\r\n /**\r\n * Converts the light information to a readable string for debug purpose.\r\n * @param fullDetails Supports for multiple levels of logging within scene loading\r\n * @returns the human readable light info\r\n */\r\n public override toString(fullDetails?: boolean): string {\r\n let ret = \"Name: \" + this.name;\r\n ret += \", type: \" + [\"Point\", \"Directional\", \"Spot\", \"Hemispheric\", \"Clustered\"][this.getTypeID()];\r\n if (this.animations) {\r\n for (let i = 0; i < this.animations.length; i++) {\r\n ret += \", animation[0]: \" + this.animations[i].toString(fullDetails);\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n /** @internal */\r\n protected override _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.isDisposed()) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n /**\r\n * Set the enabled state of this node.\r\n * @param value - the new enabled state\r\n */\r\n public override setEnabled(value: boolean): void {\r\n super.setEnabled(value);\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n /**\r\n * Returns the Light associated shadow generator if any.\r\n * @param camera Camera for which the shadow generator should be retrieved (default: null). If null, retrieves the default shadow generator\r\n * @returns the associated shadow generator.\r\n */\r\n public getShadowGenerator(camera: Nullable<Camera> = null): Nullable<IShadowGenerator> {\r\n if (this._shadowGenerators === null) {\r\n return null;\r\n }\r\n\r\n return this._shadowGenerators.get(camera) ?? null;\r\n }\r\n\r\n /**\r\n * Returns all the shadow generators associated to this light\r\n * @returns\r\n */\r\n public getShadowGenerators(): Nullable<Map<Nullable<Camera>, IShadowGenerator>> {\r\n return this._shadowGenerators;\r\n }\r\n\r\n /**\r\n * Returns a Vector3, the absolute light position in the World.\r\n * @returns the world space position of the light\r\n */\r\n public getAbsolutePosition(): Vector3 {\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Specifies if the light will affect the passed mesh.\r\n * @param mesh The mesh to test against the light\r\n * @returns true the mesh is affected otherwise, false.\r\n */\r\n public canAffectMesh(mesh: AbstractMesh): boolean {\r\n if (!this.internalEnabled) {\r\n return false;\r\n }\r\n if (!mesh) {\r\n return true;\r\n }\r\n\r\n if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {\r\n return false;\r\n }\r\n\r\n if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {\r\n return false;\r\n }\r\n\r\n if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {\r\n return false;\r\n }\r\n\r\n if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases resources associated with this node.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n if (this._shadowGenerators) {\r\n const iterator = this._shadowGenerators.values();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const shadowGenerator = key.value;\r\n shadowGenerator.dispose();\r\n }\r\n this._shadowGenerators = null;\r\n }\r\n\r\n // Animations\r\n this.getScene().stopAnimation(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.lights.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.lights.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n // Remove from meshes\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._removeLightSource(this, true);\r\n }\r\n\r\n this._uniformBuffer.dispose();\r\n\r\n // Remove from scene\r\n this.getScene().removeLight(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * Returns the light type ID (integer).\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public getTypeID(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.\r\n * @returns the scaled intensity in intensity mode unit\r\n */\r\n public getScaledIntensity() {\r\n return this._photometricScale * this.intensity;\r\n }\r\n\r\n /**\r\n * Returns a new Light object, named \"name\", from the current one.\r\n * @param name The name of the cloned light\r\n * @param newParent The parent of this light, if it has one\r\n * @returns the new created light\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n const clonedLight = SerializationHelper.Clone(constructor, this);\r\n if (name) {\r\n clonedLight.name = name;\r\n }\r\n if (newParent) {\r\n clonedLight.parent = newParent;\r\n }\r\n clonedLight.setEnabled(this.isEnabled());\r\n\r\n this.onClonedObservable.notifyObservers(clonedLight);\r\n\r\n return clonedLight;\r\n }\r\n\r\n /**\r\n * Serializes the current light into a Serialization object.\r\n * @returns the serialized object.\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.uniqueId = this.uniqueId;\r\n\r\n // Type\r\n serializationObject.type = this.getTypeID();\r\n\r\n // Parent\r\n if (this.parent) {\r\n this.parent._serializeAsParent(serializationObject);\r\n }\r\n\r\n // Inclusion / exclusions\r\n if (this.excludedMeshes.length > 0) {\r\n serializationObject.excludedMeshesIds = [];\r\n for (const mesh of this.excludedMeshes) {\r\n serializationObject.excludedMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n if (this.includedOnlyMeshes.length > 0) {\r\n serializationObject.includedOnlyMeshesIds = [];\r\n for (const mesh of this.includedOnlyMeshes) {\r\n serializationObject.includedOnlyMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n serializationObject.ranges = this.serializeAnimationRanges();\r\n\r\n serializationObject.isEnabled = this.isEnabled();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.\r\n * This new light is named \"name\" and added to the passed scene.\r\n * @param type Type according to the types available in Light.LIGHTTYPEID_x\r\n * @param name The friendly name of the light\r\n * @param scene The scene the new light will belong to\r\n * @returns the constructor function\r\n */\r\n static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light> {\r\n const constructorFunc = Node.Construct(\"Light_Type_\" + type, name, scene);\r\n\r\n if (constructorFunc) {\r\n return <() => Light>constructorFunc;\r\n }\r\n\r\n // Default to no light for none present once.\r\n return null;\r\n }\r\n\r\n /**\r\n * Parses the passed \"parsedLight\" and returns a new instanced Light from this parsing.\r\n * @param parsedLight The JSON representation of the light\r\n * @param scene The scene to create the parsed light in\r\n * @returns the created light after parsing\r\n */\r\n public static Parse(parsedLight: any, scene: Scene): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n\r\n const light = SerializationHelper.Parse(constructor, parsedLight, scene);\r\n\r\n // Inclusion / exclusions\r\n if (parsedLight.excludedMeshesIds) {\r\n light._excludedMeshesIds = parsedLight.excludedMeshesIds;\r\n }\r\n\r\n if (parsedLight.includedOnlyMeshesIds) {\r\n light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;\r\n }\r\n\r\n // Parent\r\n if (parsedLight.parentId !== undefined) {\r\n light._waitingParentId = parsedLight.parentId;\r\n }\r\n\r\n if (parsedLight.parentInstanceIndex !== undefined) {\r\n light._waitingParentInstanceIndex = parsedLight.parentInstanceIndex;\r\n }\r\n\r\n // Falloff\r\n if (parsedLight.falloffType !== undefined) {\r\n light.falloffType = parsedLight.falloffType;\r\n }\r\n\r\n // Lightmaps\r\n if (parsedLight.lightmapMode !== undefined) {\r\n light.lightmapMode = parsedLight.lightmapMode;\r\n }\r\n\r\n // Animations\r\n if (parsedLight.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedLight.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n light.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n Node.ParseAnimationRanges(light, parsedLight, scene);\r\n }\r\n\r\n if (parsedLight.autoAnimate) {\r\n scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);\r\n }\r\n\r\n // Check if isEnabled is defined to be back compatible with prior serialized versions.\r\n if (parsedLight.isEnabled !== undefined) {\r\n light.setEnabled(parsedLight.isEnabled);\r\n }\r\n\r\n light._onParsed(parsedLight, scene);\r\n\r\n return light;\r\n }\r\n\r\n /**\r\n * Called after the light has been fully parsed and all base properties have been set.\r\n * Override in subclasses to handle custom serialized data.\r\n * @param _parsedLight The JSON representation of the light\r\n * @param _scene The scene the light belongs to\r\n */\r\n protected _onParsed(_parsedLight: any, _scene: Scene): void {\r\n // Override in subclasses\r\n }\r\n\r\n private _hookArrayForExcluded(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n for (const item of items) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.call(array, index, deleteCount ?? array.length);\r\n\r\n for (const item of deleted) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return deleted;\r\n };\r\n\r\n for (const item of array) {\r\n item._resyncLightSource(this);\r\n }\r\n }\r\n\r\n private _hookArrayForIncludedOnly(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n this._resyncMeshes();\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.call(array, index, deleteCount ?? array.length);\r\n\r\n this._resyncMeshes();\r\n\r\n return deleted;\r\n };\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n private _resyncMeshes() {\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._resyncLightSource(this);\r\n }\r\n }\r\n\r\n /**\r\n * Forces the meshes to update their light related information in their rendering used effects\r\n * @internal Internal Use Only\r\n */\r\n public _markMeshesAsLightDirty() {\r\n for (const mesh of this.getScene().meshes) {\r\n if (mesh.lightSources.indexOf(this) !== -1) {\r\n mesh._markSubMeshesAsLightDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recomputes the cached photometric scale if needed.\r\n */\r\n private _computePhotometricScale(): void {\r\n this._photometricScale = this._getPhotometricScale();\r\n this.getScene().resetCachedMaterial();\r\n }\r\n\r\n /**\r\n * @returns the Photometric Scale according to the light type and intensity mode.\r\n */\r\n private _getPhotometricScale() {\r\n let photometricScale = 0.0;\r\n const lightTypeID = this.getTypeID();\r\n\r\n //get photometric mode\r\n let photometricMode = this.intensityMode;\r\n if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {\r\n if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {\r\n photometricMode = Light.INTENSITYMODE_ILLUMINANCE;\r\n } else {\r\n photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;\r\n }\r\n }\r\n\r\n //compute photometric scale\r\n switch (lightTypeID) {\r\n case Light.LIGHTTYPEID_POINTLIGHT:\r\n case Light.LIGHTTYPEID_SPOTLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_LUMINOUSPOWER:\r\n photometricScale = 1.0 / (4.0 * Math.PI);\r\n break;\r\n case Light.INTENSITYMODE_LUMINOUSINTENSITY:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE:\r\n photometricScale = this.radius * this.radius;\r\n break;\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_DIRECTIONALLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_ILLUMINANCE:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE: {\r\n // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.\r\n // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).\r\n let apexAngleRadians = this.radius;\r\n // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).\r\n apexAngleRadians = Math.max(apexAngleRadians, 0.001);\r\n const solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));\r\n photometricScale = solidAngle;\r\n break;\r\n }\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_HEMISPHERICLIGHT:\r\n // No fall off in hemispheric light.\r\n photometricScale = 1.0;\r\n break;\r\n }\r\n return photometricScale;\r\n }\r\n\r\n /**\r\n * Reorder the light in the scene according to their defined priority.\r\n * @internal Internal Use Only\r\n */\r\n public _reorderLightsInScene(): void {\r\n const scene = this.getScene();\r\n if (this._renderPriority != 0) {\r\n scene.requireLightSorting = true;\r\n }\r\n this.getScene().sortLightsByPriority();\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isReady() {\r\n return true;\r\n }\r\n}\r\n"]}
@@ -127,7 +127,9 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
127
127
  * Disposes the plugin material.
128
128
  */
129
129
  dispose() {
130
- this._colorsTexture?.dispose();
130
+ if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {
131
+ this._colorsTexture.dispose();
132
+ }
131
133
  super.dispose();
132
134
  }
133
135
  _setColorModeAndColorDistributionType() {
@@ -163,7 +165,13 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
163
165
  const origColorsCount = this._colors?.length ?? 0;
164
166
  this._colors = colors;
165
167
  if (colors === null || colors.length === 0) {
166
- this._colorsTexture?.dispose();
168
+ if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {
169
+ this._colorsTexture.dispose();
170
+ }
171
+ const scene = this.getScene();
172
+ if (scene) {
173
+ this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);
174
+ }
167
175
  return;
168
176
  }
169
177
  if (lazy && !forceNewTexture) {
@@ -174,7 +182,9 @@ export class GreasedLineSimpleMaterial extends ShaderMaterial {
174
182
  this._colorsTexture.update(colorArray);
175
183
  }
176
184
  else {
177
- this._colorsTexture?.dispose();
185
+ if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {
186
+ this._colorsTexture.dispose();
187
+ }
178
188
  this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, colors, this.colorsSampling, this.getScene());
179
189
  }
180
190
  }
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineSimpleMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GreasedLine/greasedLineSimpleMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,MAAM,CAAC,MA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AgB,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,EAAE,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtK,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,0BAA0B,CAAC,YAAY,IAAI,IAAI,CAAC;QACrE,IAAI,CAAC,SAAS,CAAC,4BAA4B,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACrE,CAAC;;AAhhBD;;GAEG;AACW,mCAAS,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import { type Scene } from \"../../scene\";\r\nimport { RawTexture } from \"../Textures/rawTexture\";\r\nimport { ShaderMaterial } from \"../shaderMaterial\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector2 } from \"../../Maths/math.vector\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\nimport { TextureSampler } from \"../Textures/textureSampler\";\r\n\r\nimport { type GreasedLineMaterialOptions, type IGreasedLineMaterial, GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport { GreasedLineMaterialDefaults } from \"./greasedLineMaterialDefaults\";\r\n\r\nexport const GreasedLineUseOffsetsSimpleMaterialDefine = \"GREASED_LINE_USE_OFFSETS\";\r\n\r\n/**\r\n * GreasedLineSimpleMaterial\r\n */\r\nexport class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {\r\n /**\r\n * Force to use GLSL in WebGPU\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private _visibility: number;\r\n private _width: number;\r\n private _useDash: boolean;\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _dashRatio: number;\r\n private _dashOffset: number;\r\n private _useColors: boolean;\r\n private _color: Color3 = Color3.White();\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType = GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n private _colorMode: GreasedLineMeshColorMode;\r\n private _colorsSampling: number;\r\n private _resolution: Vector2;\r\n private _sizeAttenuation: boolean;\r\n private _colorsTexture: Nullable<RawTexture> = null;\r\n private _cameraFacing: boolean;\r\n\r\n /**\r\n * GreasedLineSimple material constructor\r\n * @param name material name\r\n * @param scene the scene\r\n * @param options material options\r\n */\r\n constructor(name: string, scene: Scene, options: GreasedLineMaterialOptions) {\r\n const engine = scene.getEngine();\r\n const isWGSL = engine.isWebGPU && !(options.forceGLSL || GreasedLineSimpleMaterial.ForceGLSL);\r\n\r\n const defines = [\r\n `COLOR_DISTRIBUTION_TYPE_LINE ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE}.`,\r\n `COLOR_DISTRIBUTION_TYPE_SEGMENT ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT}.`,\r\n `COLOR_MODE_SET ${GreasedLineMeshColorMode.COLOR_MODE_SET}.`,\r\n `COLOR_MODE_ADD ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.`,\r\n `COLOR_MODE_MULTIPLY ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.`,\r\n ];\r\n if (scene.useRightHandedSystem) {\r\n defines.push(\"GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\");\r\n }\r\n\r\n const attributes = [\"position\", \"grl_widths\", \"grl_offsets\", \"grl_colorPointers\"];\r\n\r\n if (options.cameraFacing) {\r\n defines.push(\"GREASED_LINE_CAMERA_FACING\");\r\n attributes.push(\"grl_previousAndSide\", \"grl_nextAndCounters\");\r\n } else {\r\n attributes.push(\"grl_slopes\");\r\n attributes.push(\"grl_counters\");\r\n }\r\n\r\n const uniforms = [\r\n \"grlColorsWidth\",\r\n \"grlUseColors\",\r\n \"grlWidth\",\r\n \"grlColor\",\r\n \"grl_colorModeAndColorDistributionType\",\r\n \"grlResolution\",\r\n \"grlAspect\",\r\n \"grlAizeAttenuation\",\r\n \"grlDashArray\",\r\n \"grlDashOffset\",\r\n \"grlDashRatio\",\r\n \"grlUseDash\",\r\n \"grlVisibility\",\r\n \"grlColors\",\r\n ];\r\n\r\n if (!isWGSL) {\r\n uniforms.push(\"world\", \"viewProjection\", \"view\", \"projection\");\r\n }\r\n\r\n super(\r\n name,\r\n scene,\r\n {\r\n vertex: \"greasedLine\",\r\n fragment: \"greasedLine\",\r\n },\r\n {\r\n uniformBuffers: isWGSL ? [\"Scene\", \"Mesh\"] : undefined,\r\n attributes,\r\n uniforms,\r\n samplers: isWGSL ? [] : [\"grlColors\"],\r\n defines,\r\n extraInitializationsAsync: async () => {\r\n if (isWGSL) {\r\n await Promise.all([import(\"../../ShadersWGSL/greasedLine.vertex\"), import(\"../../ShadersWGSL/greasedLine.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/greasedLine.vertex\"), import(\"../../Shaders/greasedLine.fragment\")]);\r\n }\r\n },\r\n shaderLanguage: isWGSL ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n }\r\n );\r\n\r\n options = options || {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.width = options.width\r\n ? options.width\r\n : options.sizeAttenuation && options.cameraFacing\r\n ? GreasedLineMaterialDefaults.DEFAULT_WIDTH_ATTENUATED\r\n : GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n this.sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.color = options.color ?? Color3.White();\r\n this.useColors = options.useColors ?? false;\r\n this.colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._colors = options.colors ?? null;\r\n this._cameraFacing = options.cameraFacing ?? true;\r\n this.resolution = options.resolution ?? new Vector2(engine.getRenderWidth(), engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (options.colorsTexture) {\r\n this.colorsTexture = options.colorsTexture;\r\n } else {\r\n if (this._colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, this._colors, this.colorsSampling, scene);\r\n } else {\r\n this._color = this._color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n }\r\n\r\n if (isWGSL) {\r\n const sampler = new TextureSampler();\r\n sampler.setParameters(); // use the default values\r\n sampler.samplingMode = this.colorsSampling;\r\n this.setTextureSampler(\"grlColorsSampler\", sampler);\r\n }\r\n\r\n engine.onDisposeObservable.add(() => {\r\n GreasedLineTools.DisposeEmptyColorsTexture();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public override dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setColorModeAndColorDistributionType() {\r\n this.setVector2(\"grl_colorModeAndColorDistributionType\", new Vector2(this._colorMode, this._colorsDistributionType));\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceNewTexture force creation of a new texture\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceNewTexture = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n if (lazy && !forceNewTexture) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {\r\n const colorArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, colors, this.colorsSampling, this.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n get colorsTexture() {\r\n return (this._colorsTexture as RawTexture) ?? null;\r\n }\r\n\r\n /**\r\n * Sets the colorsTexture\r\n */\r\n set colorsTexture(value: RawTexture) {\r\n this._colorsTexture = value;\r\n this.setFloat(\"grlColorsWidth\", this._colorsTexture.getSize().width);\r\n this.setTexture(\"grlColors\", this._colorsTexture);\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n set width(value: number) {\r\n this._width = value;\r\n this.setFloat(\"grlWidth\", value);\r\n }\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n get useColors() {\r\n return this._useColors;\r\n }\r\n\r\n set useColors(value: boolean) {\r\n this._useColors = value;\r\n this.setFloat(\"grlUseColors\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n get colorsSampling() {\r\n return this._colorsSampling;\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n set colorsSampling(value: number) {\r\n this._colorsSampling = value;\r\n }\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n get visibility() {\r\n return this._visibility;\r\n }\r\n\r\n set visibility(value: number) {\r\n this._visibility = value;\r\n this.setFloat(\"grlVisibility\", value);\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n get useDash() {\r\n return this._useDash;\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n set useDash(value: boolean) {\r\n this._useDash = value;\r\n this.setFloat(\"grlUseDash\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the dash offset\r\n */\r\n get dashOffset() {\r\n return this._dashOffset;\r\n }\r\n\r\n /**\r\n * Sets the dash offset\r\n */\r\n set dashOffset(value: number) {\r\n this._dashOffset = value;\r\n this.setFloat(\"grlDashOffset\", value);\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n get dashRatio() {\r\n return this._dashRatio;\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n set dashRatio(value: number) {\r\n this._dashRatio = value;\r\n this.setFloat(\"grlDashRatio\", value);\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n this.setFloat(\"grlDashArray\", this._dashArray);\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.setFloat(\"grlSizeAttenuation\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3\r\n */\r\n set color(value: Color3) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * The simple material always needs a color to be set. If you set it to null it will set the color to the default color (GreasedLineSimpleMaterial.DEFAULT_COLOR).\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>) {\r\n value = value ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this._color = value;\r\n this.setColor3(\"grlColor\", value);\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n get colorMode() {\r\n return this._colorMode;\r\n }\r\n\r\n /**\r\n * Sets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n set colorMode(value: GreasedLineMeshColorMode) {\r\n this._colorMode = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._resolution = value;\r\n this.setVector2(\"grlResolution\", value);\r\n this.setFloat(\"grlAspect\", value.x / value.y);\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this._colorsSampling,\r\n colorMode: this._colorMode,\r\n color: this._color,\r\n dashCount: this._dashCount,\r\n dashOffset: this._dashOffset,\r\n dashRatio: this._dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this._useColors,\r\n useDash: this._useDash,\r\n visibility: this._visibility,\r\n width: this._width,\r\n cameraFacing: this._cameraFacing,\r\n };\r\n\r\n if (this._colors) {\r\n greasedLineMaterialOptions.colors = this._colors;\r\n }\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param _rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, _rootUrl: string): void {\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n if (greasedLineMaterialOptions.color) {\r\n this.color = greasedLineMaterialOptions.color;\r\n }\r\n if (greasedLineMaterialOptions.colorDistributionType) {\r\n this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType;\r\n }\r\n if (greasedLineMaterialOptions.colorsSampling) {\r\n this.colorsSampling = greasedLineMaterialOptions.colorsSampling;\r\n }\r\n if (greasedLineMaterialOptions.colorMode) {\r\n this.colorMode = greasedLineMaterialOptions.colorMode;\r\n }\r\n if (greasedLineMaterialOptions.useColors) {\r\n this.useColors = greasedLineMaterialOptions.useColors;\r\n }\r\n if (greasedLineMaterialOptions.visibility) {\r\n this.visibility = greasedLineMaterialOptions.visibility;\r\n }\r\n if (greasedLineMaterialOptions.useDash) {\r\n this.useDash = greasedLineMaterialOptions.useDash;\r\n }\r\n if (greasedLineMaterialOptions.dashCount) {\r\n this.dashCount = greasedLineMaterialOptions.dashCount;\r\n }\r\n if (greasedLineMaterialOptions.dashRatio) {\r\n this.dashRatio = greasedLineMaterialOptions.dashRatio;\r\n }\r\n if (greasedLineMaterialOptions.dashOffset) {\r\n this.dashOffset = greasedLineMaterialOptions.dashOffset;\r\n }\r\n if (greasedLineMaterialOptions.width) {\r\n this.width = greasedLineMaterialOptions.width;\r\n }\r\n if (greasedLineMaterialOptions.sizeAttenuation) {\r\n this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation;\r\n }\r\n if (greasedLineMaterialOptions.resolution) {\r\n this.resolution = greasedLineMaterialOptions.resolution;\r\n }\r\n if (greasedLineMaterialOptions.colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, greasedLineMaterialOptions.colors, this.colorsSampling, this.getScene());\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n this._cameraFacing = greasedLineMaterialOptions.cameraFacing ?? true;\r\n this.setDefine(\"GREASED_LINE_CAMERA_FACING\", this._cameraFacing);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineSimpleMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/GreasedLine/greasedLineSimpleMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MA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,aAAa,CAAC,CAAC;IACrE,CAAC;;AA1hBD;;GAEG;AACW,mCAAS,GAAG,KAAK,AAAR,CAAS","sourcesContent":["import { type Scene } from \"../../scene\";\r\nimport { RawTexture } from \"../Textures/rawTexture\";\r\nimport { ShaderMaterial } from \"../shaderMaterial\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { Vector2 } from \"../../Maths/math.vector\";\r\nimport { ShaderLanguage } from \"../shaderLanguage\";\r\nimport { TextureSampler } from \"../Textures/textureSampler\";\r\n\r\nimport { type GreasedLineMaterialOptions, type IGreasedLineMaterial, GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from \"./greasedLineMaterialInterfaces\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport { GreasedLineMaterialDefaults } from \"./greasedLineMaterialDefaults\";\r\n\r\nexport const GreasedLineUseOffsetsSimpleMaterialDefine = \"GREASED_LINE_USE_OFFSETS\";\r\n\r\n/**\r\n * GreasedLineSimpleMaterial\r\n */\r\nexport class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {\r\n /**\r\n * Force to use GLSL in WebGPU\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private _visibility: number;\r\n private _width: number;\r\n private _useDash: boolean;\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _dashRatio: number;\r\n private _dashOffset: number;\r\n private _useColors: boolean;\r\n private _color: Color3 = Color3.White();\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType = GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n private _colorMode: GreasedLineMeshColorMode;\r\n private _colorsSampling: number;\r\n private _resolution: Vector2;\r\n private _sizeAttenuation: boolean;\r\n private _colorsTexture: Nullable<RawTexture> = null;\r\n private _cameraFacing: boolean;\r\n\r\n /**\r\n * GreasedLineSimple material constructor\r\n * @param name material name\r\n * @param scene the scene\r\n * @param options material options\r\n */\r\n constructor(name: string, scene: Scene, options: GreasedLineMaterialOptions) {\r\n const engine = scene.getEngine();\r\n const isWGSL = engine.isWebGPU && !(options.forceGLSL || GreasedLineSimpleMaterial.ForceGLSL);\r\n\r\n const defines = [\r\n `COLOR_DISTRIBUTION_TYPE_LINE ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE}.`,\r\n `COLOR_DISTRIBUTION_TYPE_SEGMENT ${GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT}.`,\r\n `COLOR_MODE_SET ${GreasedLineMeshColorMode.COLOR_MODE_SET}.`,\r\n `COLOR_MODE_ADD ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.`,\r\n `COLOR_MODE_MULTIPLY ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.`,\r\n ];\r\n if (scene.useRightHandedSystem) {\r\n defines.push(\"GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM\");\r\n }\r\n\r\n const attributes = [\"position\", \"grl_widths\", \"grl_offsets\", \"grl_colorPointers\"];\r\n\r\n if (options.cameraFacing) {\r\n defines.push(\"GREASED_LINE_CAMERA_FACING\");\r\n attributes.push(\"grl_previousAndSide\", \"grl_nextAndCounters\");\r\n } else {\r\n attributes.push(\"grl_slopes\");\r\n attributes.push(\"grl_counters\");\r\n }\r\n\r\n const uniforms = [\r\n \"grlColorsWidth\",\r\n \"grlUseColors\",\r\n \"grlWidth\",\r\n \"grlColor\",\r\n \"grl_colorModeAndColorDistributionType\",\r\n \"grlResolution\",\r\n \"grlAspect\",\r\n \"grlAizeAttenuation\",\r\n \"grlDashArray\",\r\n \"grlDashOffset\",\r\n \"grlDashRatio\",\r\n \"grlUseDash\",\r\n \"grlVisibility\",\r\n \"grlColors\",\r\n ];\r\n\r\n if (!isWGSL) {\r\n uniforms.push(\"world\", \"viewProjection\", \"view\", \"projection\");\r\n }\r\n\r\n super(\r\n name,\r\n scene,\r\n {\r\n vertex: \"greasedLine\",\r\n fragment: \"greasedLine\",\r\n },\r\n {\r\n uniformBuffers: isWGSL ? [\"Scene\", \"Mesh\"] : undefined,\r\n attributes,\r\n uniforms,\r\n samplers: isWGSL ? [] : [\"grlColors\"],\r\n defines,\r\n extraInitializationsAsync: async () => {\r\n if (isWGSL) {\r\n await Promise.all([import(\"../../ShadersWGSL/greasedLine.vertex\"), import(\"../../ShadersWGSL/greasedLine.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/greasedLine.vertex\"), import(\"../../Shaders/greasedLine.fragment\")]);\r\n }\r\n },\r\n shaderLanguage: isWGSL ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n }\r\n );\r\n\r\n options = options || {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.width = options.width\r\n ? options.width\r\n : options.sizeAttenuation && options.cameraFacing\r\n ? GreasedLineMaterialDefaults.DEFAULT_WIDTH_ATTENUATED\r\n : GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n this.sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.color = options.color ?? Color3.White();\r\n this.useColors = options.useColors ?? false;\r\n this.colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._colors = options.colors ?? null;\r\n this._cameraFacing = options.cameraFacing ?? true;\r\n this.resolution = options.resolution ?? new Vector2(engine.getRenderWidth(), engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (options.colorsTexture) {\r\n this.colorsTexture = options.colorsTexture;\r\n } else {\r\n if (this._colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, this._colors, this.colorsSampling, scene);\r\n } else {\r\n this._color = this._color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n }\r\n\r\n if (isWGSL) {\r\n const sampler = new TextureSampler();\r\n sampler.setParameters(); // use the default values\r\n sampler.samplingMode = this.colorsSampling;\r\n this.setTextureSampler(\"grlColorsSampler\", sampler);\r\n }\r\n\r\n engine.onDisposeObservable.add(() => {\r\n GreasedLineTools.DisposeEmptyColorsTexture();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public override dispose(): void {\r\n if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n this._colorsTexture.dispose();\r\n }\r\n super.dispose();\r\n }\r\n\r\n private _setColorModeAndColorDistributionType() {\r\n this.setVector2(\"grl_colorModeAndColorDistributionType\", new Vector2(this._colorMode, this._colorsDistributionType));\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceNewTexture force creation of a new texture\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceNewTexture = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n this._colorsTexture.dispose();\r\n }\r\n const scene = this.getScene();\r\n if (scene) {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n return;\r\n }\r\n\r\n if (lazy && !forceNewTexture) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {\r\n const colorArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n if (this._colorsTexture && this._colorsTexture !== GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n this._colorsTexture.dispose();\r\n }\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, colors, this.colorsSampling, this.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n get colorsTexture() {\r\n return (this._colorsTexture as RawTexture) ?? null;\r\n }\r\n\r\n /**\r\n * Sets the colorsTexture\r\n */\r\n set colorsTexture(value: RawTexture) {\r\n this._colorsTexture = value;\r\n this.setFloat(\"grlColorsWidth\", this._colorsTexture.getSize().width);\r\n this.setTexture(\"grlColors\", this._colorsTexture);\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n set width(value: number) {\r\n this._width = value;\r\n this.setFloat(\"grlWidth\", value);\r\n }\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n get useColors() {\r\n return this._useColors;\r\n }\r\n\r\n set useColors(value: boolean) {\r\n this._useColors = value;\r\n this.setFloat(\"grlUseColors\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n get colorsSampling() {\r\n return this._colorsSampling;\r\n }\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n set colorsSampling(value: number) {\r\n this._colorsSampling = value;\r\n }\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n get visibility() {\r\n return this._visibility;\r\n }\r\n\r\n set visibility(value: number) {\r\n this._visibility = value;\r\n this.setFloat(\"grlVisibility\", value);\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n get useDash() {\r\n return this._useDash;\r\n }\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n set useDash(value: boolean) {\r\n this._useDash = value;\r\n this.setFloat(\"grlUseDash\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the dash offset\r\n */\r\n get dashOffset() {\r\n return this._dashOffset;\r\n }\r\n\r\n /**\r\n * Sets the dash offset\r\n */\r\n set dashOffset(value: number) {\r\n this._dashOffset = value;\r\n this.setFloat(\"grlDashOffset\", value);\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n get dashRatio() {\r\n return this._dashRatio;\r\n }\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n set dashRatio(value: number) {\r\n this._dashRatio = value;\r\n this.setFloat(\"grlDashRatio\", value);\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n this.setFloat(\"grlDashArray\", this._dashArray);\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.setFloat(\"grlSizeAttenuation\", GreasedLineTools.BooleanToNumber(value));\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3\r\n */\r\n set color(value: Color3) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * The simple material always needs a color to be set. If you set it to null it will set the color to the default color (GreasedLineSimpleMaterial.DEFAULT_COLOR).\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>) {\r\n value = value ?? GreasedLineMaterialDefaults.DEFAULT_COLOR;\r\n this._color = value;\r\n this.setColor3(\"grlColor\", value);\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n get colorMode() {\r\n return this._colorMode;\r\n }\r\n\r\n /**\r\n * Sets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n set colorMode(value: GreasedLineMeshColorMode) {\r\n this._colorMode = value;\r\n this._setColorModeAndColorDistributionType();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._resolution = value;\r\n this.setVector2(\"grlResolution\", value);\r\n this.setFloat(\"grlAspect\", value.x / value.y);\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this._colorsSampling,\r\n colorMode: this._colorMode,\r\n color: this._color,\r\n dashCount: this._dashCount,\r\n dashOffset: this._dashOffset,\r\n dashRatio: this._dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this._useColors,\r\n useDash: this._useDash,\r\n visibility: this._visibility,\r\n width: this._width,\r\n cameraFacing: this._cameraFacing,\r\n };\r\n\r\n if (this._colors) {\r\n greasedLineMaterialOptions.colors = this._colors;\r\n }\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param _rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, _rootUrl: string): void {\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n if (greasedLineMaterialOptions.color) {\r\n this.color = greasedLineMaterialOptions.color;\r\n }\r\n if (greasedLineMaterialOptions.colorDistributionType) {\r\n this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType;\r\n }\r\n if (greasedLineMaterialOptions.colorsSampling) {\r\n this.colorsSampling = greasedLineMaterialOptions.colorsSampling;\r\n }\r\n if (greasedLineMaterialOptions.colorMode) {\r\n this.colorMode = greasedLineMaterialOptions.colorMode;\r\n }\r\n if (greasedLineMaterialOptions.useColors) {\r\n this.useColors = greasedLineMaterialOptions.useColors;\r\n }\r\n if (greasedLineMaterialOptions.visibility) {\r\n this.visibility = greasedLineMaterialOptions.visibility;\r\n }\r\n if (greasedLineMaterialOptions.useDash) {\r\n this.useDash = greasedLineMaterialOptions.useDash;\r\n }\r\n if (greasedLineMaterialOptions.dashCount) {\r\n this.dashCount = greasedLineMaterialOptions.dashCount;\r\n }\r\n if (greasedLineMaterialOptions.dashRatio) {\r\n this.dashRatio = greasedLineMaterialOptions.dashRatio;\r\n }\r\n if (greasedLineMaterialOptions.dashOffset) {\r\n this.dashOffset = greasedLineMaterialOptions.dashOffset;\r\n }\r\n if (greasedLineMaterialOptions.width) {\r\n this.width = greasedLineMaterialOptions.width;\r\n }\r\n if (greasedLineMaterialOptions.sizeAttenuation) {\r\n this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation;\r\n }\r\n if (greasedLineMaterialOptions.resolution) {\r\n this.resolution = greasedLineMaterialOptions.resolution;\r\n }\r\n if (greasedLineMaterialOptions.colors) {\r\n this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this.name}-colors-texture`, greasedLineMaterialOptions.colors, this.colorsSampling, this.getScene());\r\n } else {\r\n this.colorsTexture = GreasedLineTools.PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n this._cameraFacing = greasedLineMaterialOptions.cameraFacing ?? true;\r\n this.setDefine(\"GREASED_LINE_CAMERA_FACING\", this._cameraFacing);\r\n }\r\n}\r\n"]}
@@ -374,12 +374,22 @@ export class CubeTexture extends BaseTexture {
374
374
  */
375
375
  clone() {
376
376
  let uniqueId = 0;
377
+ // Save the irradianceTexture before cloning. The irradianceTexture is
378
+ // stored on the InternalTexture (_texture._irradianceTexture), which may
379
+ // be shared between the source and clone when loaded from cache.
380
+ // BaseTexture.clone() returns null, so CopySource sets the shared
381
+ // irradianceTexture to null, losing it on both the original and the clone.
382
+ const savedIrradianceTexture = this.irradianceTexture;
377
383
  const newCubeTexture = SerializationHelper.Clone(() => {
378
384
  const cubeTexture = new CubeTexture(this.url, this.getScene() || this._getEngine(), this._extensions, this._noMipmap, this._files);
379
385
  uniqueId = cubeTexture.uniqueId;
380
386
  return cubeTexture;
381
387
  }, this);
382
388
  newCubeTexture.uniqueId = uniqueId;
389
+ // Restore the irradianceTexture if it was cleared during cloning.
390
+ if (savedIrradianceTexture && !this.irradianceTexture) {
391
+ this.irradianceTexture = savedIrradianceTexture;
392
+ }
383
393
  return newCubeTexture;
384
394
  }
385
395
  }