@onerjs/core 8.36.1 → 8.36.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 (98) hide show
  1. package/Animations/animation.d.ts +4 -0
  2. package/Animations/animation.js +7 -0
  3. package/Animations/animation.js.map +1 -1
  4. package/Engines/abstractEngine.js +2 -2
  5. package/Engines/abstractEngine.js.map +1 -1
  6. package/Engines/constants.d.ts +1 -1
  7. package/Engines/constants.js +1 -1
  8. package/Engines/constants.js.map +1 -1
  9. package/Lights/areaLight.d.ts +1 -1
  10. package/Lights/areaLight.js +1 -1
  11. package/Lights/areaLight.js.map +1 -1
  12. package/Lights/rectAreaLight.d.ts +20 -0
  13. package/Lights/rectAreaLight.js +45 -0
  14. package/Lights/rectAreaLight.js.map +1 -1
  15. package/Materials/Node/Blocks/Dual/lightBlock.js +1 -1
  16. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  17. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -1
  18. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  19. package/Materials/material.d.ts +1 -1
  20. package/Materials/material.js +1 -1
  21. package/Materials/material.js.map +1 -1
  22. package/Materials/materialHelper.functions.d.ts +2 -1
  23. package/Materials/materialHelper.functions.js +6 -2
  24. package/Materials/materialHelper.functions.js.map +1 -1
  25. package/Materials/materialPluginManager.js +2 -2
  26. package/Materials/materialPluginManager.js.map +1 -1
  27. package/Meshes/Builders/greasedLineBuilder.d.ts +4 -0
  28. package/Meshes/Builders/greasedLineBuilder.js +37 -23
  29. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  30. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -5
  31. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  32. package/Misc/areaLightsTextureTools.d.ts +52 -0
  33. package/Misc/areaLightsTextureTools.js +227 -0
  34. package/Misc/areaLightsTextureTools.js.map +1 -0
  35. package/Misc/decorators.serialization.js +6 -1
  36. package/Misc/decorators.serialization.js.map +1 -1
  37. package/Misc/index.d.ts +3 -0
  38. package/Misc/index.js +4 -0
  39. package/Misc/index.js.map +1 -1
  40. package/Particles/Node/Blocks/index.d.ts +3 -0
  41. package/Particles/Node/Blocks/index.js +3 -0
  42. package/Particles/Node/Blocks/index.js.map +1 -1
  43. package/Particles/Node/Blocks/particleNLerpBlock.d.ts +35 -0
  44. package/Particles/Node/Blocks/particleNLerpBlock.js +97 -0
  45. package/Particles/Node/Blocks/particleNLerpBlock.js.map +1 -0
  46. package/Particles/Node/Blocks/particleSmoothStepBlock.d.ts +34 -0
  47. package/Particles/Node/Blocks/particleSmoothStepBlock.js +91 -0
  48. package/Particles/Node/Blocks/particleSmoothStepBlock.js.map +1 -0
  49. package/Particles/Node/Blocks/particleStepBlock.d.ts +30 -0
  50. package/Particles/Node/Blocks/particleStepBlock.js +84 -0
  51. package/Particles/Node/Blocks/particleStepBlock.js.map +1 -0
  52. package/Particles/Node/nodeParticleSystemSet.d.ts +2 -0
  53. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  54. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  55. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  56. package/Physics/v2/Plugins/havokPlugin.d.ts +10 -0
  57. package/Physics/v2/Plugins/havokPlugin.js +13 -0
  58. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  59. package/Physics/v2/physicsBody.d.ts +10 -0
  60. package/Physics/v2/physicsBody.js +12 -0
  61. package/Physics/v2/physicsBody.js.map +1 -1
  62. package/Physics/v2/physicsEngineComponent.d.ts +5 -0
  63. package/Physics/v2/physicsEngineComponent.js +13 -0
  64. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  65. package/Rendering/utilityLayerRenderer.d.ts +6 -0
  66. package/Rendering/utilityLayerRenderer.js +14 -5
  67. package/Rendering/utilityLayerRenderer.js.map +1 -1
  68. package/Shaders/ShadersInclude/lightFragment.js +13 -0
  69. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  70. package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
  71. package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
  72. package/Shaders/ShadersInclude/lightUboDeclaration.js +3 -0
  73. package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
  74. package/Shaders/ShadersInclude/lightsFragmentFunctions.js +6 -0
  75. package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  76. package/Shaders/ShadersInclude/ltcHelperFunctions.js +17 -1
  77. package/Shaders/ShadersInclude/ltcHelperFunctions.js.map +1 -1
  78. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +6 -0
  79. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  80. package/Shaders/areaLightTextureProcessing.fragment.d.ts +5 -0
  81. package/Shaders/areaLightTextureProcessing.fragment.js +13 -0
  82. package/Shaders/areaLightTextureProcessing.fragment.js.map +1 -0
  83. package/ShadersWGSL/ShadersInclude/lightFragment.js +14 -0
  84. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  85. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +3 -0
  86. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
  87. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +6 -0
  88. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  89. package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js +19 -1
  90. package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js.map +1 -1
  91. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +5 -0
  92. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  93. package/ShadersWGSL/areaLightTextureProcessing.fragment.d.ts +5 -0
  94. package/ShadersWGSL/areaLightTextureProcessing.fragment.js +12 -0
  95. package/ShadersWGSL/areaLightTextureProcessing.fragment.js.map +1 -0
  96. package/States/alphaCullingState.js +0 -1
  97. package/States/alphaCullingState.js.map +1 -1
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"materialPluginManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialPluginManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAYrD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IA2B9B;;;OAGG;IACH,YAAY,QAAkB;QAvB9B,gBAAgB;QACT,aAAQ,GAAyB,EAAE,CAAC;QACjC,mBAAc,GAAyB,EAAE,CAAC;QAC1C,iCAA4B,GAAyB,EAAE,CAAC;QAqB9D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,MAA0B;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;gBACxC,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,yBAAyB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;IACf,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACpD,gBAAgB,GAAG,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Material } from \"./material\";\r\nimport type {\r\n MaterialPluginPrepareEffect,\r\n MaterialPluginBindForSubMesh,\r\n MaterialPluginDisposed,\r\n MaterialPluginGetActiveTextures,\r\n MaterialPluginGetAnimatables,\r\n MaterialPluginGetDefineNames,\r\n MaterialPluginHasTexture,\r\n MaterialPluginIsReadyForSubMesh,\r\n MaterialPluginPrepareDefines,\r\n MaterialPluginPrepareUniformBuffer,\r\n MaterialPluginHardBindForSubMesh,\r\n MaterialPluginHasRenderTargetTextures,\r\n MaterialPluginFillRenderTargetTextures,\r\n} from \"./materialPluginEvent\";\r\nimport { MaterialPluginEvent } from \"./materialPluginEvent\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { MaterialPluginBase } from \"./materialPluginBase\";\r\nimport { ProcessIncludes } from \"../Engines/Processors/shaderProcessor\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\n\r\ndeclare module \"./material\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Material {\r\n /**\r\n * Plugin manager for this material\r\n */\r\n pluginManager?: MaterialPluginManager;\r\n }\r\n}\r\n\r\nconst RxOption = new RegExp(\"^([gimus]+)!\");\r\n\r\n/**\r\n * Class that manages the plugins of a material\r\n * @since 5.0\r\n */\r\nexport class MaterialPluginManager {\r\n /** Map a plugin class name to a #define name (used in the vertex/fragment shaders as a marker of the plugin usage) */\r\n private static _MaterialPluginClassToMainDefine: { [name: string]: string } = {};\r\n private static _MaterialPluginCounter: number = 0;\r\n\r\n protected _material: Material;\r\n protected _scene: Scene;\r\n protected _engine: AbstractEngine;\r\n /** @internal */\r\n public _plugins: MaterialPluginBase[] = [];\r\n protected _activePlugins: MaterialPluginBase[] = [];\r\n protected _activePluginsForExtraEvents: MaterialPluginBase[] = [];\r\n protected _codeInjectionPoints: { [shaderType: string]: { [codeName: string]: boolean } };\r\n protected _defineNamesFromPlugins?: { [name: string]: { type: string; default: any } };\r\n protected _uboDeclaration: string;\r\n protected _vertexDeclaration: string;\r\n protected _fragmentDeclaration: string;\r\n protected _uniformList: string[];\r\n protected _samplerList: string[];\r\n protected _uboList: string[];\r\n\r\n static {\r\n EngineStore.OnEnginesDisposedObservable.add(() => {\r\n UnregisterAllMaterialPlugins();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a new instance of the plugin manager\r\n * @param material material that this manager will manage the plugins for\r\n */\r\n constructor(material: Material) {\r\n this._material = material;\r\n this._scene = material.getScene();\r\n this._engine = this._scene.getEngine();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _addPlugin(plugin: MaterialPluginBase): boolean {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === plugin.name) {\r\n return false;\r\n }\r\n }\r\n\r\n if (this._material._uniformBufferLayoutBuilt) {\r\n this._material.resetDrawCache();\r\n this._material._createUniformBuffer();\r\n }\r\n\r\n if (!plugin.isCompatible(this._material.shaderLanguage)) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `The plugin \"${plugin.name}\" can't be added to the material \"${this._material.name}\" because the plugin is not compatible with the shader language of the material.`;\r\n }\r\n\r\n const pluginClassName = plugin.getClassName();\r\n if (!MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName]) {\r\n MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName] = \"MATERIALPLUGIN_\" + ++MaterialPluginManager._MaterialPluginCounter;\r\n }\r\n\r\n this._material._callbackPluginEventGeneric = (id, info) => this._handlePluginEvent(id, info);\r\n\r\n this._plugins.push(plugin);\r\n this._plugins.sort((a, b) => a.priority - b.priority);\r\n\r\n this._codeInjectionPoints = {};\r\n\r\n const defineNamesFromPlugins: { [name: string]: { type: string; default: any } } = {};\r\n defineNamesFromPlugins[MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName]] = {\r\n type: \"boolean\",\r\n default: true,\r\n };\r\n\r\n for (const plugin of this._plugins) {\r\n plugin.collectDefines(defineNamesFromPlugins);\r\n this._collectPointNames(\"vertex\", plugin.getCustomCode(\"vertex\", this._material.shaderLanguage));\r\n this._collectPointNames(\"fragment\", plugin.getCustomCode(\"fragment\", this._material.shaderLanguage));\r\n }\r\n\r\n this._defineNamesFromPlugins = defineNamesFromPlugins;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _activatePlugin(plugin: MaterialPluginBase): void {\r\n if (this._activePlugins.indexOf(plugin) === -1) {\r\n this._activePlugins.push(plugin);\r\n this._activePlugins.sort((a, b) => a.priority - b.priority);\r\n\r\n this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this);\r\n this._material._callbackPluginEventPrepareDefinesBeforeAttributes = this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this);\r\n this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this);\r\n this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this);\r\n\r\n if (plugin.registerForExtraEvents) {\r\n this._activePluginsForExtraEvents.push(plugin);\r\n this._activePluginsForExtraEvents.sort((a, b) => a.priority - b.priority);\r\n this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this);\r\n this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this);\r\n this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets a plugin from the list of plugins managed by this manager\r\n * @param name name of the plugin\r\n * @returns the plugin if found, else null\r\n */\r\n public getPlugin<T = MaterialPluginBase>(name: string): Nullable<T> {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === name) {\r\n return this._plugins[i] as T;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n protected _handlePluginEventIsReadyForSubMesh(eventData: MaterialPluginIsReadyForSubMesh): void {\r\n let isReady = true;\r\n for (const plugin of this._activePlugins) {\r\n isReady = isReady && plugin.isReadyForSubMesh(eventData.defines, this._scene, this._engine, eventData.subMesh);\r\n }\r\n eventData.isReadyForSubMesh = isReady;\r\n }\r\n\r\n protected _handlePluginEventPrepareDefinesBeforeAttributes(eventData: MaterialPluginPrepareDefines): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.prepareDefinesBeforeAttributes(eventData.defines, this._scene, eventData.mesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventPrepareDefines(eventData: MaterialPluginPrepareDefines): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.prepareDefines(eventData.defines, this._scene, eventData.mesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventHardBindForSubMesh(eventData: MaterialPluginHardBindForSubMesh): void {\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n plugin.hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, eventData.subMesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventBindForSubMesh(eventData: MaterialPluginBindForSubMesh): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, eventData.subMesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventHasRenderTargetTextures(eventData: MaterialPluginHasRenderTargetTextures): void {\r\n let hasRenderTargetTextures = false;\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n hasRenderTargetTextures = plugin.hasRenderTargetTextures();\r\n if (hasRenderTargetTextures) {\r\n break;\r\n }\r\n }\r\n eventData.hasRenderTargetTextures = hasRenderTargetTextures;\r\n }\r\n\r\n protected _handlePluginEventFillRenderTargetTextures(eventData: MaterialPluginFillRenderTargetTextures): void {\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n plugin.fillRenderTargetTextures(eventData.renderTargets);\r\n }\r\n }\r\n\r\n protected _handlePluginEvent(\r\n id: number,\r\n info:\r\n | MaterialPluginGetActiveTextures\r\n | MaterialPluginGetAnimatables\r\n | MaterialPluginHasTexture\r\n | MaterialPluginDisposed\r\n | MaterialPluginGetDefineNames\r\n | MaterialPluginPrepareEffect\r\n | MaterialPluginPrepareUniformBuffer\r\n ): void {\r\n switch (id) {\r\n case MaterialPluginEvent.GetActiveTextures: {\r\n const eventData = info as MaterialPluginGetActiveTextures;\r\n for (const plugin of this._activePlugins) {\r\n plugin.getActiveTextures(eventData.activeTextures);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.GetAnimatables: {\r\n const eventData = info as MaterialPluginGetAnimatables;\r\n for (const plugin of this._activePlugins) {\r\n plugin.getAnimatables(eventData.animatables);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.HasTexture: {\r\n const eventData = info as MaterialPluginHasTexture;\r\n let hasTexture = false;\r\n for (const plugin of this._activePlugins) {\r\n hasTexture = plugin.hasTexture(eventData.texture);\r\n if (hasTexture) {\r\n break;\r\n }\r\n }\r\n eventData.hasTexture = hasTexture;\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.Disposed: {\r\n const eventData = info as MaterialPluginDisposed;\r\n for (const plugin of this._plugins) {\r\n plugin.dispose(eventData.forceDisposeTextures);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.GetDefineNames: {\r\n const eventData = info as MaterialPluginGetDefineNames;\r\n eventData.defineNames = this._defineNamesFromPlugins;\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.PrepareEffect: {\r\n const eventData = info as MaterialPluginPrepareEffect;\r\n for (const plugin of this._activePlugins) {\r\n eventData.fallbackRank = plugin.addFallbacks(eventData.defines, eventData.fallbacks, eventData.fallbackRank);\r\n plugin.getAttributes(eventData.attributes, this._scene, eventData.mesh);\r\n }\r\n if (this._uniformList.length > 0) {\r\n eventData.uniforms.push(...this._uniformList);\r\n }\r\n if (this._samplerList.length > 0) {\r\n eventData.samplers.push(...this._samplerList);\r\n }\r\n if (this._uboList.length > 0) {\r\n eventData.uniformBuffersNames.push(...this._uboList);\r\n }\r\n eventData.customCode = this._injectCustomCode(eventData, eventData.customCode);\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.PrepareUniformBuffer: {\r\n const eventData = info as MaterialPluginPrepareUniformBuffer;\r\n this._uboDeclaration = \"\";\r\n this._vertexDeclaration = \"\";\r\n this._fragmentDeclaration = \"\";\r\n this._uniformList = [];\r\n this._samplerList = [];\r\n this._uboList = [];\r\n const isWebGPU = this._material.shaderLanguage === ShaderLanguage.WGSL;\r\n for (const plugin of this._plugins) {\r\n const uniforms = plugin.getUniforms(this._material.shaderLanguage);\r\n if (uniforms) {\r\n if (uniforms.ubo) {\r\n for (const uniform of uniforms.ubo) {\r\n if (uniform.size && uniform.type) {\r\n const arraySize = uniform.arraySize ?? 0;\r\n eventData.ubo.addUniform(uniform.name, uniform.size, arraySize);\r\n if (isWebGPU) {\r\n let type: string;\r\n switch (uniform.type) {\r\n case \"mat4\":\r\n type = \"mat4x4f\";\r\n break;\r\n case \"float\":\r\n type = \"f32\";\r\n break;\r\n default:\r\n type = `${uniform.type}f`;\r\n break;\r\n }\r\n\r\n if (arraySize > 0) {\r\n this._uboDeclaration += `uniform ${uniform.name}: array<${type}, ${arraySize}>;\\n`;\r\n } else {\r\n this._uboDeclaration += `uniform ${uniform.name}: ${type};\\n`;\r\n }\r\n } else {\r\n this._uboDeclaration += `${uniform.type} ${uniform.name}${arraySize > 0 ? `[${arraySize}]` : \"\"};\\n`;\r\n }\r\n }\r\n this._uniformList.push(uniform.name);\r\n }\r\n }\r\n if (uniforms.vertex) {\r\n this._vertexDeclaration += uniforms.vertex + \"\\n\";\r\n }\r\n if (uniforms.fragment) {\r\n this._fragmentDeclaration += uniforms.fragment + \"\\n\";\r\n }\r\n\r\n // These are uniforms which are used by the shader but not updated by the plugin directly.\r\n // They still need to be present in the _uniformList so the Effect can determine their locations.\r\n if (uniforms.externalUniforms) {\r\n this._uniformList.push(...uniforms.externalUniforms);\r\n }\r\n }\r\n plugin.getSamplers(this._samplerList);\r\n plugin.getUniformBuffersNames(this._uboList);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n protected _collectPointNames(shaderType: string, customCode: Nullable<{ [pointName: string]: string }> | undefined): void {\r\n if (!customCode) {\r\n return;\r\n }\r\n for (const pointName in customCode) {\r\n if (!this._codeInjectionPoints[shaderType]) {\r\n this._codeInjectionPoints[shaderType] = {};\r\n }\r\n this._codeInjectionPoints[shaderType][pointName] = true;\r\n }\r\n }\r\n\r\n protected _injectCustomCode(eventData: MaterialPluginPrepareEffect, existingCallback?: (shaderType: string, code: string) => string): ShaderCustomProcessingFunction {\r\n return (shaderType: string, code: string) => {\r\n if (existingCallback) {\r\n code = existingCallback(shaderType, code);\r\n }\r\n if (this._uboDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_UBO_DECLARATION\", this._uboDeclaration);\r\n }\r\n if (this._vertexDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_VERTEX_DECLARATION\", this._vertexDeclaration);\r\n }\r\n if (this._fragmentDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_FRAGMENT_DECLARATION\", this._fragmentDeclaration);\r\n }\r\n const points = this._codeInjectionPoints?.[shaderType];\r\n if (!points) {\r\n return code;\r\n }\r\n let processorOptions: Nullable<_IProcessingOptions> = null;\r\n for (let pointName in points) {\r\n let injectedCode = \"\";\r\n for (const plugin of this._activePlugins) {\r\n let customCode = plugin.getCustomCode(shaderType, this._material.shaderLanguage)?.[pointName];\r\n if (!customCode) {\r\n continue;\r\n }\r\n if (plugin.resolveIncludes) {\r\n if (processorOptions === null) {\r\n const shaderLanguage = ShaderLanguage.GLSL;\r\n processorOptions = {\r\n defines: [], // not used by _ProcessIncludes\r\n indexParameters: eventData.indexParameters,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,\r\n processor: undefined as any, // not used by _ProcessIncludes\r\n supportsUniformBuffers: this._engine.supportsUniformBuffers,\r\n shadersRepository: ShaderStore.GetShadersRepository(shaderLanguage),\r\n includesShadersStore: ShaderStore.GetIncludesShadersStore(shaderLanguage),\r\n version: undefined as any, // not used by _ProcessIncludes\r\n platformName: this._engine.shaderPlatformName,\r\n processingContext: undefined as any, // not used by _ProcessIncludes\r\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\r\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer,\r\n processCodeAfterIncludes: undefined as any, // not used by _ProcessIncludes\r\n };\r\n }\r\n processorOptions.isFragment = shaderType === \"fragment\";\r\n ProcessIncludes(customCode, processorOptions, (code) => (customCode = code));\r\n }\r\n injectedCode += customCode + \"\\n\";\r\n }\r\n if (injectedCode.length > 0) {\r\n if (pointName.charAt(0) === \"!\") {\r\n // pointName is a regular expression\r\n pointName = pointName.substring(1);\r\n\r\n let regexFlags = \"g\";\r\n if (pointName.charAt(0) === \"!\") {\r\n // no flags\r\n regexFlags = \"\";\r\n pointName = pointName.substring(1);\r\n } else {\r\n // get the flag(s)\r\n const matchOption = RxOption.exec(pointName);\r\n if (matchOption && matchOption.length >= 2) {\r\n regexFlags = matchOption[1];\r\n pointName = pointName.substring(regexFlags.length + 1);\r\n }\r\n }\r\n\r\n if (regexFlags.indexOf(\"g\") < 0) {\r\n // we force the \"g\" flag so that the regexp object is stateful!\r\n regexFlags += \"g\";\r\n }\r\n\r\n const sourceCode = code;\r\n const rx = new RegExp(pointName, regexFlags);\r\n let match = rx.exec(sourceCode);\r\n while (match !== null) {\r\n let newCode = injectedCode;\r\n for (let i = 0; i < match.length; ++i) {\r\n newCode = newCode.replace(\"$\" + i, match[i]);\r\n }\r\n code = code.replace(match[0], newCode);\r\n match = rx.exec(sourceCode);\r\n }\r\n } else {\r\n const fullPointName = \"#define \" + pointName;\r\n code = code.replace(fullPointName, \"\\n\" + injectedCode + \"\\n\" + fullPointName);\r\n }\r\n }\r\n }\r\n return code;\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Type for plugin material factories.\r\n */\r\nexport type PluginMaterialFactory = (material: Material) => Nullable<MaterialPluginBase>;\r\n\r\nconst Plugins: Array<[string, PluginMaterialFactory]> = [];\r\nlet Inited = false;\r\nlet MaterialObserver: Nullable<Observer<Material>> = null;\r\n\r\n/**\r\n * Registers a new material plugin through a factory, or updates it. This makes the plugin available to all materials instantiated after its registration.\r\n * @param pluginName The plugin name\r\n * @param factory The factory function which allows to create the plugin\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterMaterialPlugin(pluginName: string, factory: PluginMaterialFactory): void {\r\n if (!Inited) {\r\n MaterialObserver = Material.OnEventObservable.add((material: Material) => {\r\n for (const [, factory] of Plugins) {\r\n factory(material);\r\n }\r\n }, MaterialPluginEvent.Created);\r\n Inited = true;\r\n }\r\n const existing = Plugins.filter(([name, _factory]) => name === pluginName);\r\n if (existing.length > 0) {\r\n existing[0][1] = factory;\r\n } else {\r\n Plugins.push([pluginName, factory]);\r\n }\r\n}\r\n\r\n/**\r\n * Removes a material plugin from the list of global plugins.\r\n * @param pluginName The plugin name\r\n * @returns true if the plugin has been removed, else false\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function UnregisterMaterialPlugin(pluginName: string): boolean {\r\n for (let i = 0; i < Plugins.length; ++i) {\r\n if (Plugins[i][0] === pluginName) {\r\n Plugins.splice(i, 1);\r\n if (Plugins.length === 0) {\r\n UnregisterAllMaterialPlugins();\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Clear the list of global material plugins\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function UnregisterAllMaterialPlugins(): void {\r\n Plugins.length = 0;\r\n Inited = false;\r\n Material.OnEventObservable.remove(MaterialObserver);\r\n MaterialObserver = null;\r\n}\r\n"]}
1
+ {"version":3,"file":"materialPluginManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/materialPluginManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAYrD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IA2B9B;;;OAGG;IACH,YAAY,QAAkB;QAvB9B,gBAAgB;QACT,aAAQ,GAAyB,EAAE,CAAC;QACjC,mBAAc,GAAyB,EAAE,CAAC;QAC1C,iCAA4B,GAAyB,EAAE,CAAC;QAqB9D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,MAA0B;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;gBACxC,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,yB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K,CAAC;IACf,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACpD,gBAAgB,GAAG,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Material } from \"./material\";\r\nimport type {\r\n MaterialPluginPrepareEffect,\r\n MaterialPluginBindForSubMesh,\r\n MaterialPluginDisposed,\r\n MaterialPluginGetActiveTextures,\r\n MaterialPluginGetAnimatables,\r\n MaterialPluginGetDefineNames,\r\n MaterialPluginHasTexture,\r\n MaterialPluginIsReadyForSubMesh,\r\n MaterialPluginPrepareDefines,\r\n MaterialPluginPrepareUniformBuffer,\r\n MaterialPluginHardBindForSubMesh,\r\n MaterialPluginHasRenderTargetTextures,\r\n MaterialPluginFillRenderTargetTextures,\r\n} from \"./materialPluginEvent\";\r\nimport { MaterialPluginEvent } from \"./materialPluginEvent\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { MaterialPluginBase } from \"./materialPluginBase\";\r\nimport { ProcessIncludes } from \"../Engines/Processors/shaderProcessor\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\n\r\ndeclare module \"./material\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Material {\r\n /**\r\n * Plugin manager for this material\r\n */\r\n pluginManager?: MaterialPluginManager;\r\n }\r\n}\r\n\r\nconst RxOption = new RegExp(\"^([gimus]+)!\");\r\n\r\n/**\r\n * Class that manages the plugins of a material\r\n * @since 5.0\r\n */\r\nexport class MaterialPluginManager {\r\n /** Map a plugin class name to a #define name (used in the vertex/fragment shaders as a marker of the plugin usage) */\r\n private static _MaterialPluginClassToMainDefine: { [name: string]: string } = {};\r\n private static _MaterialPluginCounter: number = 0;\r\n\r\n protected _material: Material;\r\n protected _scene: Scene;\r\n protected _engine: AbstractEngine;\r\n /** @internal */\r\n public _plugins: MaterialPluginBase[] = [];\r\n protected _activePlugins: MaterialPluginBase[] = [];\r\n protected _activePluginsForExtraEvents: MaterialPluginBase[] = [];\r\n protected _codeInjectionPoints: { [shaderType: string]: { [codeName: string]: boolean } };\r\n protected _defineNamesFromPlugins?: { [name: string]: { type: string; default: any } };\r\n protected _uboDeclaration: string;\r\n protected _vertexDeclaration: string;\r\n protected _fragmentDeclaration: string;\r\n protected _uniformList: string[];\r\n protected _samplerList: string[];\r\n protected _uboList: string[];\r\n\r\n static {\r\n EngineStore.OnEnginesDisposedObservable.add(() => {\r\n UnregisterAllMaterialPlugins();\r\n });\r\n }\r\n\r\n /**\r\n * Creates a new instance of the plugin manager\r\n * @param material material that this manager will manage the plugins for\r\n */\r\n constructor(material: Material) {\r\n this._material = material;\r\n this._scene = material.getScene();\r\n this._engine = this._scene.getEngine();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _addPlugin(plugin: MaterialPluginBase): boolean {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === plugin.name) {\r\n return false;\r\n }\r\n }\r\n\r\n if (this._material._uniformBufferLayoutBuilt) {\r\n this._material.resetDrawCache();\r\n this._material._createUniformBuffer();\r\n }\r\n\r\n if (!plugin.isCompatible(this._material.shaderLanguage)) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw `The plugin \"${plugin.name}\" can't be added to the material \"${this._material.name}\" because the plugin is not compatible with the shader language of the material.`;\r\n }\r\n\r\n const pluginClassName = plugin.getClassName();\r\n if (!MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName]) {\r\n MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName] = \"MATERIALPLUGIN_\" + ++MaterialPluginManager._MaterialPluginCounter;\r\n }\r\n\r\n this._material._callbackPluginEventGeneric = (id, info) => this._handlePluginEvent(id, info);\r\n\r\n this._plugins.push(plugin);\r\n this._plugins.sort((a, b) => a.priority - b.priority);\r\n\r\n this._codeInjectionPoints = {};\r\n\r\n const defineNamesFromPlugins: { [name: string]: { type: string; default: any } } = {};\r\n defineNamesFromPlugins[MaterialPluginManager._MaterialPluginClassToMainDefine[pluginClassName]] = {\r\n type: \"boolean\",\r\n default: true,\r\n };\r\n\r\n for (const plugin of this._plugins) {\r\n plugin.collectDefines(defineNamesFromPlugins);\r\n this._collectPointNames(\"vertex\", plugin.getCustomCode(\"vertex\", this._material.shaderLanguage));\r\n this._collectPointNames(\"fragment\", plugin.getCustomCode(\"fragment\", this._material.shaderLanguage));\r\n }\r\n\r\n this._defineNamesFromPlugins = defineNamesFromPlugins;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _activatePlugin(plugin: MaterialPluginBase): void {\r\n if (this._activePlugins.indexOf(plugin) === -1) {\r\n this._activePlugins.push(plugin);\r\n this._activePlugins.sort((a, b) => a.priority - b.priority);\r\n\r\n this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this);\r\n this._material._callbackPluginEventPrepareDefinesBeforeAttributes = this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this);\r\n this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this);\r\n this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this);\r\n\r\n if (plugin.registerForExtraEvents) {\r\n this._activePluginsForExtraEvents.push(plugin);\r\n this._activePluginsForExtraEvents.sort((a, b) => a.priority - b.priority);\r\n this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this);\r\n this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this);\r\n this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets a plugin from the list of plugins managed by this manager\r\n * @param name name of the plugin\r\n * @returns the plugin if found, else null\r\n */\r\n public getPlugin<T = MaterialPluginBase>(name: string): Nullable<T> {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === name) {\r\n return this._plugins[i] as T;\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n protected _handlePluginEventIsReadyForSubMesh(eventData: MaterialPluginIsReadyForSubMesh): void {\r\n let isReady = true;\r\n for (const plugin of this._activePlugins) {\r\n isReady = isReady && plugin.isReadyForSubMesh(eventData.defines, this._scene, this._engine, eventData.subMesh);\r\n }\r\n eventData.isReadyForSubMesh = isReady;\r\n }\r\n\r\n protected _handlePluginEventPrepareDefinesBeforeAttributes(eventData: MaterialPluginPrepareDefines): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.prepareDefinesBeforeAttributes(eventData.defines, this._scene, eventData.mesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventPrepareDefines(eventData: MaterialPluginPrepareDefines): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.prepareDefines(eventData.defines, this._scene, eventData.mesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventHardBindForSubMesh(eventData: MaterialPluginHardBindForSubMesh): void {\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n plugin.hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, eventData.subMesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventBindForSubMesh(eventData: MaterialPluginBindForSubMesh): void {\r\n for (const plugin of this._activePlugins) {\r\n plugin.bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, eventData.subMesh);\r\n }\r\n }\r\n\r\n protected _handlePluginEventHasRenderTargetTextures(eventData: MaterialPluginHasRenderTargetTextures): void {\r\n let hasRenderTargetTextures = false;\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n hasRenderTargetTextures = plugin.hasRenderTargetTextures();\r\n if (hasRenderTargetTextures) {\r\n break;\r\n }\r\n }\r\n eventData.hasRenderTargetTextures = hasRenderTargetTextures;\r\n }\r\n\r\n protected _handlePluginEventFillRenderTargetTextures(eventData: MaterialPluginFillRenderTargetTextures): void {\r\n for (const plugin of this._activePluginsForExtraEvents) {\r\n plugin.fillRenderTargetTextures(eventData.renderTargets);\r\n }\r\n }\r\n\r\n protected _handlePluginEvent(\r\n id: number,\r\n info:\r\n | MaterialPluginGetActiveTextures\r\n | MaterialPluginGetAnimatables\r\n | MaterialPluginHasTexture\r\n | MaterialPluginDisposed\r\n | MaterialPluginGetDefineNames\r\n | MaterialPluginPrepareEffect\r\n | MaterialPluginPrepareUniformBuffer\r\n ): void {\r\n switch (id) {\r\n case MaterialPluginEvent.GetActiveTextures: {\r\n const eventData = info as MaterialPluginGetActiveTextures;\r\n for (const plugin of this._activePlugins) {\r\n plugin.getActiveTextures(eventData.activeTextures);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.GetAnimatables: {\r\n const eventData = info as MaterialPluginGetAnimatables;\r\n for (const plugin of this._activePlugins) {\r\n plugin.getAnimatables(eventData.animatables);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.HasTexture: {\r\n const eventData = info as MaterialPluginHasTexture;\r\n let hasTexture = false;\r\n for (const plugin of this._activePlugins) {\r\n hasTexture = plugin.hasTexture(eventData.texture);\r\n if (hasTexture) {\r\n break;\r\n }\r\n }\r\n eventData.hasTexture = hasTexture;\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.Disposed: {\r\n const eventData = info as MaterialPluginDisposed;\r\n for (const plugin of this._plugins) {\r\n plugin.dispose(eventData.forceDisposeTextures);\r\n }\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.GetDefineNames: {\r\n const eventData = info as MaterialPluginGetDefineNames;\r\n eventData.defineNames = this._defineNamesFromPlugins;\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.PrepareEffect: {\r\n const eventData = info as MaterialPluginPrepareEffect;\r\n for (const plugin of this._activePlugins) {\r\n eventData.fallbackRank = plugin.addFallbacks(eventData.defines, eventData.fallbacks, eventData.fallbackRank);\r\n plugin.getAttributes(eventData.attributes, this._scene, eventData.mesh);\r\n }\r\n if (this._uniformList.length > 0) {\r\n eventData.uniforms.push(...this._uniformList);\r\n }\r\n if (this._samplerList.length > 0) {\r\n eventData.samplers.push(...this._samplerList);\r\n }\r\n if (this._uboList.length > 0) {\r\n eventData.uniformBuffersNames.push(...this._uboList);\r\n }\r\n eventData.customCode = this._injectCustomCode(eventData, eventData.customCode);\r\n break;\r\n }\r\n\r\n case MaterialPluginEvent.PrepareUniformBuffer: {\r\n const eventData = info as MaterialPluginPrepareUniformBuffer;\r\n this._uboDeclaration = \"\";\r\n this._vertexDeclaration = \"\";\r\n this._fragmentDeclaration = \"\";\r\n this._uniformList = [];\r\n this._samplerList = [];\r\n this._uboList = [];\r\n const isWebGPU = this._material.shaderLanguage === ShaderLanguage.WGSL;\r\n for (const plugin of this._plugins) {\r\n const uniforms = plugin.getUniforms(this._material.shaderLanguage);\r\n if (uniforms) {\r\n if (uniforms.ubo) {\r\n for (const uniform of uniforms.ubo) {\r\n if (uniform.size && uniform.type) {\r\n const arraySize = uniform.arraySize ?? 0;\r\n eventData.ubo.addUniform(uniform.name, uniform.size, arraySize);\r\n if (isWebGPU) {\r\n let type: string;\r\n switch (uniform.type) {\r\n case \"mat4\":\r\n type = \"mat4x4f\";\r\n break;\r\n case \"float\":\r\n type = \"f32\";\r\n break;\r\n default:\r\n type = `${uniform.type}f`;\r\n break;\r\n }\r\n\r\n if (arraySize > 0) {\r\n this._uboDeclaration += `uniform ${uniform.name}: array<${type}, ${arraySize}>;\\n`;\r\n } else {\r\n this._uboDeclaration += `uniform ${uniform.name}: ${type};\\n`;\r\n }\r\n } else {\r\n this._uboDeclaration += `${uniform.type} ${uniform.name}${arraySize > 0 ? `[${arraySize}]` : \"\"};\\n`;\r\n }\r\n }\r\n this._uniformList.push(uniform.name);\r\n }\r\n }\r\n if (uniforms.vertex) {\r\n this._vertexDeclaration += uniforms.vertex + \"\\n\";\r\n }\r\n if (uniforms.fragment) {\r\n this._fragmentDeclaration += uniforms.fragment + \"\\n\";\r\n }\r\n\r\n // These are uniforms which are used by the shader but not updated by the plugin directly.\r\n // They still need to be present in the _uniformList so the Effect can determine their locations.\r\n if (uniforms.externalUniforms) {\r\n this._uniformList.push(...uniforms.externalUniforms);\r\n }\r\n }\r\n plugin.getSamplers(this._samplerList);\r\n plugin.getUniformBuffersNames(this._uboList);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n protected _collectPointNames(shaderType: string, customCode: Nullable<{ [pointName: string]: string }> | undefined): void {\r\n if (!customCode) {\r\n return;\r\n }\r\n for (const pointName in customCode) {\r\n if (!this._codeInjectionPoints[shaderType]) {\r\n this._codeInjectionPoints[shaderType] = {};\r\n }\r\n this._codeInjectionPoints[shaderType][pointName] = true;\r\n }\r\n }\r\n\r\n protected _injectCustomCode(eventData: MaterialPluginPrepareEffect, existingCallback?: (shaderType: string, code: string) => string): ShaderCustomProcessingFunction {\r\n return (shaderType: string, code: string) => {\r\n if (existingCallback) {\r\n code = existingCallback(shaderType, code);\r\n }\r\n if (this._uboDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_UBO_DECLARATION\", this._uboDeclaration);\r\n }\r\n if (this._vertexDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_VERTEX_DECLARATION\", this._vertexDeclaration);\r\n }\r\n if (this._fragmentDeclaration) {\r\n code = code.replace(\"#define ADDITIONAL_FRAGMENT_DECLARATION\", this._fragmentDeclaration);\r\n }\r\n const points = this._codeInjectionPoints?.[shaderType];\r\n if (!points) {\r\n return code;\r\n }\r\n let processorOptions: Nullable<_IProcessingOptions> = null;\r\n for (let pointName in points) {\r\n let injectedCode = \"\";\r\n for (const plugin of this._activePlugins) {\r\n const shaderLanguage = this._material.shaderLanguage;\r\n let customCode = plugin.getCustomCode(shaderType, shaderLanguage)?.[pointName];\r\n if (!customCode) {\r\n continue;\r\n }\r\n if (plugin.resolveIncludes) {\r\n if (processorOptions === null) {\r\n processorOptions = {\r\n defines: [], // not used by _ProcessIncludes\r\n indexParameters: eventData.indexParameters,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,\r\n processor: undefined as any, // not used by _ProcessIncludes\r\n supportsUniformBuffers: this._engine.supportsUniformBuffers,\r\n shadersRepository: ShaderStore.GetShadersRepository(shaderLanguage),\r\n includesShadersStore: ShaderStore.GetIncludesShadersStore(shaderLanguage),\r\n version: undefined as any, // not used by _ProcessIncludes\r\n platformName: this._engine.shaderPlatformName,\r\n processingContext: undefined as any, // not used by _ProcessIncludes\r\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\r\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer,\r\n processCodeAfterIncludes: undefined as any, // not used by _ProcessIncludes\r\n };\r\n }\r\n processorOptions.isFragment = shaderType === \"fragment\";\r\n ProcessIncludes(customCode, processorOptions, (code) => (customCode = code));\r\n }\r\n injectedCode += customCode + \"\\n\";\r\n }\r\n if (injectedCode.length > 0) {\r\n if (pointName.charAt(0) === \"!\") {\r\n // pointName is a regular expression\r\n pointName = pointName.substring(1);\r\n\r\n let regexFlags = \"g\";\r\n if (pointName.charAt(0) === \"!\") {\r\n // no flags\r\n regexFlags = \"\";\r\n pointName = pointName.substring(1);\r\n } else {\r\n // get the flag(s)\r\n const matchOption = RxOption.exec(pointName);\r\n if (matchOption && matchOption.length >= 2) {\r\n regexFlags = matchOption[1];\r\n pointName = pointName.substring(regexFlags.length + 1);\r\n }\r\n }\r\n\r\n if (regexFlags.indexOf(\"g\") < 0) {\r\n // we force the \"g\" flag so that the regexp object is stateful!\r\n regexFlags += \"g\";\r\n }\r\n\r\n const sourceCode = code;\r\n const rx = new RegExp(pointName, regexFlags);\r\n let match = rx.exec(sourceCode);\r\n while (match !== null) {\r\n let newCode = injectedCode;\r\n for (let i = 0; i < match.length; ++i) {\r\n newCode = newCode.replace(\"$\" + i, match[i]);\r\n }\r\n code = code.replace(match[0], newCode);\r\n match = rx.exec(sourceCode);\r\n }\r\n } else {\r\n const fullPointName = \"#define \" + pointName;\r\n code = code.replace(fullPointName, \"\\n\" + injectedCode + \"\\n\" + fullPointName);\r\n }\r\n }\r\n }\r\n return code;\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Type for plugin material factories.\r\n */\r\nexport type PluginMaterialFactory = (material: Material) => Nullable<MaterialPluginBase>;\r\n\r\nconst Plugins: Array<[string, PluginMaterialFactory]> = [];\r\nlet Inited = false;\r\nlet MaterialObserver: Nullable<Observer<Material>> = null;\r\n\r\n/**\r\n * Registers a new material plugin through a factory, or updates it. This makes the plugin available to all materials instantiated after its registration.\r\n * @param pluginName The plugin name\r\n * @param factory The factory function which allows to create the plugin\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterMaterialPlugin(pluginName: string, factory: PluginMaterialFactory): void {\r\n if (!Inited) {\r\n MaterialObserver = Material.OnEventObservable.add((material: Material) => {\r\n for (const [, factory] of Plugins) {\r\n factory(material);\r\n }\r\n }, MaterialPluginEvent.Created);\r\n Inited = true;\r\n }\r\n const existing = Plugins.filter(([name, _factory]) => name === pluginName);\r\n if (existing.length > 0) {\r\n existing[0][1] = factory;\r\n } else {\r\n Plugins.push([pluginName, factory]);\r\n }\r\n}\r\n\r\n/**\r\n * Removes a material plugin from the list of global plugins.\r\n * @param pluginName The plugin name\r\n * @returns true if the plugin has been removed, else false\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function UnregisterMaterialPlugin(pluginName: string): boolean {\r\n for (let i = 0; i < Plugins.length; ++i) {\r\n if (Plugins[i][0] === pluginName) {\r\n Plugins.splice(i, 1);\r\n if (Plugins.length === 0) {\r\n UnregisterAllMaterialPlugins();\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Clear the list of global material plugins\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function UnregisterAllMaterialPlugins(): void {\r\n Plugins.length = 0;\r\n Inited = false;\r\n Material.OnEventObservable.remove(MaterialObserver);\r\n MaterialObserver = null;\r\n}\r\n"]}
@@ -93,6 +93,10 @@ export interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {
93
93
  * @see CompleteGreasedLineWidthTable
94
94
  */
95
95
  widthDistribution?: GreasedLineMeshWidthDistribution;
96
+ /**
97
+ * Defines if it should update data in place
98
+ */
99
+ inPlace?: boolean;
96
100
  }
97
101
  /**
98
102
  * Builder functions for creating GreasedLineMeshes
@@ -183,30 +183,39 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
183
183
  instance.addPoints(allPoints, initialGreasedLineOptions);
184
184
  }
185
185
  else {
186
- // add widths
187
- const currentWidths = instance.widths;
188
- if (currentWidths) {
189
- const newWidths = currentWidths.slice();
190
- for (const w of widths) {
191
- newWidths.push(w);
186
+ if (options.inPlace) {
187
+ instance.widths = widths;
188
+ instance.setPoints(allPoints);
189
+ if (options.uvs) {
190
+ instance.uvs = options.uvs;
192
191
  }
193
- instance.widths = newWidths;
194
192
  }
195
193
  else {
196
- instance.widths = widths;
197
- }
198
- instance.addPoints(allPoints);
199
- // add UVs
200
- if (options.uvs) {
201
- const currentUVs = instance.uvs;
202
- if (currentUVs) {
203
- const newUVs = new Float32Array(currentUVs.length + options.uvs.length);
204
- newUVs.set(currentUVs, 0);
205
- newUVs.set(options.uvs, currentUVs.length);
206
- instance.uvs = newUVs;
194
+ // add widths
195
+ const currentWidths = instance.widths;
196
+ if (currentWidths) {
197
+ const newWidths = currentWidths.slice();
198
+ for (const w of widths) {
199
+ newWidths.push(w);
200
+ }
201
+ instance.widths = newWidths;
207
202
  }
208
203
  else {
209
- instance.uvs = options.uvs;
204
+ instance.widths = widths;
205
+ }
206
+ instance.addPoints(allPoints);
207
+ // add UVs
208
+ if (options.uvs) {
209
+ const currentUVs = instance.uvs;
210
+ if (currentUVs) {
211
+ const newUVs = new Float32Array(currentUVs.length + options.uvs.length);
212
+ newUVs.set(currentUVs, 0);
213
+ newUVs.set(options.uvs, currentUVs.length);
214
+ instance.uvs = newUVs;
215
+ }
216
+ else {
217
+ instance.uvs = options.uvs;
218
+ }
210
219
  }
211
220
  }
212
221
  }
@@ -215,10 +224,15 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
215
224
  // it will merge if any colors already on the instance
216
225
  if (colors && options.instance) {
217
226
  if (options.instance.greasedLineMaterial) {
218
- const currentColors = options.instance.greasedLineMaterial.colors;
219
- if (currentColors) {
220
- const newColors = currentColors.concat(colors);
221
- options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());
227
+ if (!options.inPlace) {
228
+ const currentColors = options.instance.greasedLineMaterial.colors;
229
+ if (currentColors) {
230
+ const newColors = currentColors.concat(colors);
231
+ options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());
232
+ }
233
+ }
234
+ else {
235
+ options.instance.greasedLineMaterial.setColors(colors, instance.isLazy());
222
236
  }
223
237
  }
224
238
  }
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAA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MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACrC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += points.length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,E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terial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { GreasedLineMesh } from \"../GreasedLine/greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"../../Maths/math.color\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport { GreasedLineTools } from \"../../Misc/greasedLineTools\";\r\nimport type { GreasedLineMeshOptions } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonAutoDirectionMode, GreasedLineRibbonFacesMode, GreasedLineRibbonPointsMode } from \"../GreasedLine/greasedLineBaseMesh\";\r\nimport { GreasedLineRibbonMesh } from \"../GreasedLine/greasedLineRibbonMesh\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLineMeshMaterialType } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { GreasedLineMaterialDefaults } from \"../../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport const enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport const enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n /**\r\n * Defines if it should update data in place\r\n */\r\n inPlace?: boolean;\r\n}\r\n\r\n/**\r\n * Builder functions for creating GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let material;\r\n switch (options.materialType) {\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR:\r\n material = new PBRMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n case GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE:\r\n material = new GreasedLineSimpleMaterial(name, scene, options);\r\n break;\r\n default:\r\n material = new StandardMaterial(name, scene, options.forceGLSL);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n break;\r\n }\r\n\r\n return material;\r\n}\r\n\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineTools.ConvertPoints(options.points, options.pointsOptions);\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n if (options.ribbonOptions) {\r\n options.ribbonOptions.facesMode = options.ribbonOptions.facesMode ?? GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING;\r\n options.ribbonOptions.pointsMode = options.ribbonOptions.pointsMode ?? GreasedLineRibbonPointsMode.POINTS_MODE_POINTS;\r\n options.ribbonOptions.directionsAutoMode =\r\n options.ribbonOptions.directionsAutoMode ??\r\n (options.ribbonOptions.directions ? GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE : GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT);\r\n }\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLineMaterialDefaults.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n materialOptions.materialType = materialOptions.materialType ?? GreasedLineMeshMaterialType.MATERIAL_TYPE_STANDARD;\r\n\r\n const pointsCount = GetPointsCount(allPoints);\r\n const widths = CompleteGreasedLineWidthTable(pointsCount, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(pointsCount, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLineMaterialDefaults.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n ribbonOptions: options.ribbonOptions,\r\n uvs: options.uvs,\r\n colorPointers: options.colorPointers,\r\n };\r\n\r\n if (initialGreasedLineOptions.ribbonOptions) {\r\n if (initialGreasedLineOptions.ribbonOptions.pointsMode === GreasedLineRibbonPointsMode.POINTS_MODE_POINTS) {\r\n initialGreasedLineOptions.ribbonOptions.width = materialOptions.width ?? initialGreasedLineOptions.ribbonOptions.width ?? GreasedLineMaterialDefaults.DEFAULT_WIDTH;\r\n }\r\n }\r\n\r\n if (!options.instance) {\r\n instance = initialGreasedLineOptions.ribbonOptions\r\n ? new GreasedLineRibbonMesh(name, scene, initialGreasedLineOptions)\r\n : new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n cameraFacing: !options.ribbonOptions,\r\n colorsTexture: materialOptions.colorsTexture,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = CreateGreasedLineMaterial(name, initialMaterialOptions, scene);\r\n instance.material = material;\r\n\r\n if (options.ribbonOptions?.facesMode === GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING) {\r\n material.backFaceCulling = false;\r\n }\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n if (instance instanceof GreasedLineRibbonMesh) {\r\n instance.addPoints(allPoints, initialGreasedLineOptions);\r\n } else {\r\n if (options.inPlace) {\r\n instance.widths = widths;\r\n instance.setPoints(allPoints);\r\n if (options.uvs) {\r\n instance.uvs = options.uvs;\r\n }\r\n } else {\r\n // add widths\r\n const currentWidths = instance.widths;\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n instance.addPoints(allPoints);\r\n\r\n // add UVs\r\n if (options.uvs) {\r\n const currentUVs = instance.uvs;\r\n if (currentUVs) {\r\n const newUVs = new Float32Array(currentUVs.length + options.uvs.length);\r\n newUVs.set(currentUVs, 0);\r\n newUVs.set(options.uvs, currentUVs.length);\r\n instance.uvs = newUVs;\r\n } else {\r\n instance.uvs = options.uvs;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.greasedLineMaterial) {\r\n if (!options.inPlace) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n } else {\r\n options.instance.greasedLineMaterial.setColors(colors, instance.isLazy());\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Counts the number of points\r\n * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]\r\n * @returns total number of points\r\n */\r\nexport function GetPointsCount(allPoints: number[][]) {\r\n let pointCount = 0;\r\n for (const points of allPoints) {\r\n pointCount += points.length / 3;\r\n }\r\n return pointCount;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n if (widths.length % 2 != 0) {\r\n widths.push(defaultWidthUpper);\r\n }\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n pointCount = Math.max(colors.length, pointCount);\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
@@ -48,10 +48,6 @@ export class CubeMapToSphericalPolynomialTools {
48
48
  const gammaSpace = texture.gammaSpace;
49
49
  // Always read as RGBA.
50
50
  const format = 5;
51
- let type = 0;
52
- if (texture.textureType == 1 || texture.textureType == 2) {
53
- type = 1;
54
- }
55
51
  return new Promise((resolve) => {
56
52
  // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
57
53
  Promise.all([leftPromise, rightPromise, upPromise, downPromise, frontPromise, backPromise]).then(([left, right, up, down, front, back]) => {
@@ -64,7 +60,7 @@ export class CubeMapToSphericalPolynomialTools {
64
60
  front,
65
61
  back,
66
62
  format,
67
- type,
63
+ type: left instanceof Float32Array ? 1 : 0,
68
64
  gammaSpace,
69
65
  };
70
66
  resolve(this.ConvertCubeMapToSphericalPolynomial(cubeInfo));
@@ -1 +1 @@
1
- {"version":3,"file":"cubemapToSphericalPolynomial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG1F,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,MAAM,mBAAmB;IAMrB,YAAmB,IAAY,EAAE,kBAA2B,EAAE,iBAA0B,EAAE,iBAA0B;QAChH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,iCAAiC;IAe1C;;;;;;OAMG;IACI,MAAM,CAAC,0CAA0C,CAAC,OAAoB;QACzE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAClB,yCAAyC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACrC,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,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AE,WAAW;IAChH,IAAI,mBAAmB,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS;IAC9G,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY;CACrH,CAAC;AAEF,gBAAgB;AACF,gDAAc,GAAG,IAAI,CAAC;AACpC,gBAAgB;AACF,yDAAuB,GAAG,KAAK,CAAC","sourcesContent":["import { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Clamp } from \"../../Maths/math.scalar.functions\";\r\nimport { SphericalPolynomial, SphericalHarmonics } from \"../../Maths/sphericalPolynomial\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { CubeMapInfo } from \"./panoramaToCubemap\";\r\nimport { ToLinearSpace } from \"../../Maths/math.constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\n\r\nclass FileFaceOrientation {\r\n public name: string;\r\n public worldAxisForNormal: Vector3; // the world axis corresponding to the normal to the face\r\n public worldAxisForFileX: Vector3; // the world axis corresponding to texture right x-axis in file\r\n public worldAxisForFileY: Vector3; // the world axis corresponding to texture down y-axis in file\r\n\r\n public constructor(name: string, worldAxisForNormal: Vector3, worldAxisForFileX: Vector3, worldAxisForFileY: Vector3) {\r\n this.name = name;\r\n this.worldAxisForNormal = worldAxisForNormal;\r\n this.worldAxisForFileX = worldAxisForFileX;\r\n this.worldAxisForFileY = worldAxisForFileY;\r\n }\r\n}\r\n\r\n/**\r\n * Helper class dealing with the extraction of spherical polynomial dataArray\r\n * from a cube map.\r\n */\r\nexport class CubeMapToSphericalPolynomialTools {\r\n private static _FileFaces: FileFaceOrientation[] = [\r\n new FileFaceOrientation(\"right\", new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)), // +X east\r\n new FileFaceOrientation(\"left\", new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, -1, 0)), // -X west\r\n new FileFaceOrientation(\"up\", new Vector3(0, 1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)), // +Y north\r\n new FileFaceOrientation(\"down\", new Vector3(0, -1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, -1)), // -Y south\r\n new FileFaceOrientation(\"front\", new Vector3(0, 0, 1), new Vector3(1, 0, 0), new Vector3(0, -1, 0)), // +Z top\r\n new FileFaceOrientation(\"back\", new Vector3(0, 0, -1), new Vector3(-1, 0, 0), new Vector3(0, -1, 0)), // -Z bottom\r\n ];\r\n\r\n /** @internal */\r\n public static MAX_HDRI_VALUE = 4096;\r\n /** @internal */\r\n public static PRESERVE_CLAMPED_COLORS = false;\r\n\r\n /**\r\n * Converts a texture to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param texture The texture to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>> {\r\n if (!texture.isCube) {\r\n // Only supports cube Textures currently.\r\n return null;\r\n }\r\n\r\n texture.getScene()?.getEngine().flushFramebuffer();\r\n\r\n const size = texture.getSize().width;\r\n const rightPromise = texture.readPixels(0, undefined, undefined, false);\r\n const leftPromise = texture.readPixels(1, undefined, undefined, false);\r\n\r\n let upPromise: Nullable<Promise<ArrayBufferView>>;\r\n let downPromise: Nullable<Promise<ArrayBufferView>>;\r\n if (texture.isRenderTarget) {\r\n upPromise = texture.readPixels(3, undefined, undefined, false);\r\n downPromise = texture.readPixels(2, undefined, undefined, false);\r\n } else {\r\n upPromise = texture.readPixels(2, undefined, undefined, false);\r\n downPromise = texture.readPixels(3, undefined, undefined, false);\r\n }\r\n\r\n const frontPromise = texture.readPixels(4, undefined, undefined, false);\r\n const backPromise = texture.readPixels(5, undefined, undefined, false);\r\n\r\n const gammaSpace = texture.gammaSpace;\r\n // Always read as RGBA.\r\n const format = Constants.TEXTUREFORMAT_RGBA;\r\n let type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (texture.textureType == Constants.TEXTURETYPE_FLOAT || texture.textureType == Constants.TEXTURETYPE_HALF_FLOAT) {\r\n type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n Promise.all([leftPromise, rightPromise, upPromise, downPromise, frontPromise, backPromise]).then(([left, right, up, down, front, back]) => {\r\n const cubeInfo: CubeMapInfo = {\r\n size,\r\n right,\r\n left,\r\n up,\r\n down,\r\n front,\r\n back,\r\n format,\r\n type,\r\n gammaSpace,\r\n };\r\n\r\n resolve(this.ConvertCubeMapToSphericalPolynomial(cubeInfo));\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Compute the area on the unit sphere of the rectangle defined by (x,y) and the origin\r\n * See https://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/\r\n * @param x\r\n * @param y\r\n * @returns the area\r\n */\r\n private static _AreaElement(x: number, y: number): number {\r\n return Math.atan2(x * y, Math.sqrt(x * x + y * y + 1));\r\n }\r\n\r\n /**\r\n * Converts a cubemap to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param cubeInfo The Cube map to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial {\r\n const sphericalHarmonics = new SphericalHarmonics();\r\n let totalSolidAngle = 0.0;\r\n\r\n // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.\r\n const du = 2.0 / cubeInfo.size;\r\n const dv = du;\r\n\r\n const halfTexel = 0.5 * du;\r\n\r\n // The (u,v) of the first texel is half a texel from the corner (-1,-1).\r\n const minUV = halfTexel - 1.0;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n const fileFace = this._FileFaces[faceIndex];\r\n const dataArray = (<any>cubeInfo)[fileFace.name];\r\n let v = minUV;\r\n\r\n // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).\r\n // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.\r\n // Because SP is still linear, so summation is fine in that basis.\r\n const stride = cubeInfo.format === Constants.TEXTUREFORMAT_RGBA ? 4 : 3;\r\n for (let y = 0; y < cubeInfo.size; y++) {\r\n let u = minUV;\r\n\r\n for (let x = 0; x < cubeInfo.size; x++) {\r\n // World direction (not normalised)\r\n const worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);\r\n worldDirection.normalize();\r\n\r\n const deltaSolidAngle =\r\n this._AreaElement(u - halfTexel, v - halfTexel) -\r\n this._AreaElement(u - halfTexel, v + halfTexel) -\r\n this._AreaElement(u + halfTexel, v - halfTexel) +\r\n this._AreaElement(u + halfTexel, v + halfTexel);\r\n\r\n let r = dataArray[y * cubeInfo.size * stride + x * stride + 0];\r\n let g = dataArray[y * cubeInfo.size * stride + x * stride + 1];\r\n let b = dataArray[y * cubeInfo.size * stride + x * stride + 2];\r\n\r\n // Prevent NaN harmonics with extreme HDRI data.\r\n if (isNaN(r)) {\r\n r = 0;\r\n }\r\n if (isNaN(g)) {\r\n g = 0;\r\n }\r\n if (isNaN(b)) {\r\n b = 0;\r\n }\r\n\r\n // Handle Integer types.\r\n if (cubeInfo.type === Constants.TEXTURETYPE_UNSIGNED_BYTE) {\r\n r /= 255;\r\n g /= 255;\r\n b /= 255;\r\n }\r\n\r\n // Handle Gamma space textures.\r\n if (cubeInfo.gammaSpace) {\r\n r = Math.pow(Clamp(r), ToLinearSpace);\r\n g = Math.pow(Clamp(g), ToLinearSpace);\r\n b = Math.pow(Clamp(b), ToLinearSpace);\r\n }\r\n\r\n // Prevent to explode in case of really high dynamic ranges.\r\n // sh 3 would not be enough to accurately represent it.\r\n const max = this.MAX_HDRI_VALUE;\r\n if (this.PRESERVE_CLAMPED_COLORS) {\r\n const currentMax = Math.max(r, g, b);\r\n if (currentMax > max) {\r\n const factor = max / currentMax;\r\n r *= factor;\r\n g *= factor;\r\n b *= factor;\r\n }\r\n } else {\r\n r = Clamp(r, 0, max);\r\n g = Clamp(g, 0, max);\r\n b = Clamp(b, 0, max);\r\n }\r\n\r\n const color = new Color3(r, g, b);\r\n\r\n sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);\r\n\r\n totalSolidAngle += deltaSolidAngle;\r\n\r\n u += du;\r\n }\r\n\r\n v += dv;\r\n }\r\n }\r\n\r\n // Solid angle for entire sphere is 4*pi\r\n const sphereSolidAngle = 4.0 * Math.PI;\r\n\r\n // Adjust the solid angle to allow for how many faces we processed.\r\n const facesProcessed = 6.0;\r\n const expectedSolidAngle = (sphereSolidAngle * facesProcessed) / 6.0;\r\n\r\n // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.\r\n // This is needed because the numerical integration over the cube uses a\r\n // small angle approximation of solid angle for each texel (see deltaSolidAngle),\r\n // and also to compensate for accumulative error due to float precision in the summation.\r\n const correctionFactor = expectedSolidAngle / totalSolidAngle;\r\n sphericalHarmonics.scaleInPlace(correctionFactor);\r\n\r\n sphericalHarmonics.convertIncidentRadianceToIrradiance();\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n\r\n return SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"cubemapToSphericalPolynomial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG1F,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,MAAM,mBAAmB;IAMrB,YAAmB,IAAY,EAAE,kBAA2B,EAAE,iBAA0B,EAAE,iBAA0B;QAChH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,iCAAiC;IAe1C;;;;;;OAMG;IACI,MAAM,CAAC,0CAA0C,CAAC,OAAoB;QACzE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAClB,yCAAyC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACrC,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACxE,MAAM,WAAW,GAAG,OAAO,CAAC,UA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AAC,CAAC,CAAC,EAAE,SAAS;IAC9G,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY;CACrH,CAAC;AAEF,gBAAgB;AACF,gDAAc,GAAG,IAAI,CAAC;AACpC,gBAAgB;AACF,yDAAuB,GAAG,KAAK,CAAC","sourcesContent":["import { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Clamp } from \"../../Maths/math.scalar.functions\";\r\nimport { SphericalPolynomial, SphericalHarmonics } from \"../../Maths/sphericalPolynomial\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { CubeMapInfo } from \"./panoramaToCubemap\";\r\nimport { ToLinearSpace } from \"../../Maths/math.constants\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\n\r\nclass FileFaceOrientation {\r\n public name: string;\r\n public worldAxisForNormal: Vector3; // the world axis corresponding to the normal to the face\r\n public worldAxisForFileX: Vector3; // the world axis corresponding to texture right x-axis in file\r\n public worldAxisForFileY: Vector3; // the world axis corresponding to texture down y-axis in file\r\n\r\n public constructor(name: string, worldAxisForNormal: Vector3, worldAxisForFileX: Vector3, worldAxisForFileY: Vector3) {\r\n this.name = name;\r\n this.worldAxisForNormal = worldAxisForNormal;\r\n this.worldAxisForFileX = worldAxisForFileX;\r\n this.worldAxisForFileY = worldAxisForFileY;\r\n }\r\n}\r\n\r\n/**\r\n * Helper class dealing with the extraction of spherical polynomial dataArray\r\n * from a cube map.\r\n */\r\nexport class CubeMapToSphericalPolynomialTools {\r\n private static _FileFaces: FileFaceOrientation[] = [\r\n new FileFaceOrientation(\"right\", new Vector3(1, 0, 0), new Vector3(0, 0, -1), new Vector3(0, -1, 0)), // +X east\r\n new FileFaceOrientation(\"left\", new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, -1, 0)), // -X west\r\n new FileFaceOrientation(\"up\", new Vector3(0, 1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)), // +Y north\r\n new FileFaceOrientation(\"down\", new Vector3(0, -1, 0), new Vector3(1, 0, 0), new Vector3(0, 0, -1)), // -Y south\r\n new FileFaceOrientation(\"front\", new Vector3(0, 0, 1), new Vector3(1, 0, 0), new Vector3(0, -1, 0)), // +Z top\r\n new FileFaceOrientation(\"back\", new Vector3(0, 0, -1), new Vector3(-1, 0, 0), new Vector3(0, -1, 0)), // -Z bottom\r\n ];\r\n\r\n /** @internal */\r\n public static MAX_HDRI_VALUE = 4096;\r\n /** @internal */\r\n public static PRESERVE_CLAMPED_COLORS = false;\r\n\r\n /**\r\n * Converts a texture to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param texture The texture to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>> {\r\n if (!texture.isCube) {\r\n // Only supports cube Textures currently.\r\n return null;\r\n }\r\n\r\n texture.getScene()?.getEngine().flushFramebuffer();\r\n\r\n const size = texture.getSize().width;\r\n const rightPromise = texture.readPixels(0, undefined, undefined, false);\r\n const leftPromise = texture.readPixels(1, undefined, undefined, false);\r\n\r\n let upPromise: Nullable<Promise<ArrayBufferView>>;\r\n let downPromise: Nullable<Promise<ArrayBufferView>>;\r\n if (texture.isRenderTarget) {\r\n upPromise = texture.readPixels(3, undefined, undefined, false);\r\n downPromise = texture.readPixels(2, undefined, undefined, false);\r\n } else {\r\n upPromise = texture.readPixels(2, undefined, undefined, false);\r\n downPromise = texture.readPixels(3, undefined, undefined, false);\r\n }\r\n\r\n const frontPromise = texture.readPixels(4, undefined, undefined, false);\r\n const backPromise = texture.readPixels(5, undefined, undefined, false);\r\n\r\n const gammaSpace = texture.gammaSpace;\r\n // Always read as RGBA.\r\n const format = Constants.TEXTUREFORMAT_RGBA;\r\n\r\n return new Promise((resolve) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n Promise.all([leftPromise, rightPromise, upPromise, downPromise, frontPromise, backPromise]).then(([left, right, up, down, front, back]) => {\r\n const cubeInfo: CubeMapInfo = {\r\n size,\r\n right,\r\n left,\r\n up,\r\n down,\r\n front,\r\n back,\r\n format,\r\n type: left instanceof Float32Array ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n gammaSpace,\r\n };\r\n\r\n resolve(this.ConvertCubeMapToSphericalPolynomial(cubeInfo));\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Compute the area on the unit sphere of the rectangle defined by (x,y) and the origin\r\n * See https://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/\r\n * @param x\r\n * @param y\r\n * @returns the area\r\n */\r\n private static _AreaElement(x: number, y: number): number {\r\n return Math.atan2(x * y, Math.sqrt(x * x + y * y + 1));\r\n }\r\n\r\n /**\r\n * Converts a cubemap to the according Spherical Polynomial data.\r\n * This extracts the first 3 orders only as they are the only one used in the lighting.\r\n *\r\n * @param cubeInfo The Cube map to extract the information from.\r\n * @returns The Spherical Polynomial data.\r\n */\r\n public static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial {\r\n const sphericalHarmonics = new SphericalHarmonics();\r\n let totalSolidAngle = 0.0;\r\n\r\n // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.\r\n const du = 2.0 / cubeInfo.size;\r\n const dv = du;\r\n\r\n const halfTexel = 0.5 * du;\r\n\r\n // The (u,v) of the first texel is half a texel from the corner (-1,-1).\r\n const minUV = halfTexel - 1.0;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n const fileFace = this._FileFaces[faceIndex];\r\n const dataArray = (<any>cubeInfo)[fileFace.name];\r\n let v = minUV;\r\n\r\n // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).\r\n // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.\r\n // Because SP is still linear, so summation is fine in that basis.\r\n const stride = cubeInfo.format === Constants.TEXTUREFORMAT_RGBA ? 4 : 3;\r\n for (let y = 0; y < cubeInfo.size; y++) {\r\n let u = minUV;\r\n\r\n for (let x = 0; x < cubeInfo.size; x++) {\r\n // World direction (not normalised)\r\n const worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);\r\n worldDirection.normalize();\r\n\r\n const deltaSolidAngle =\r\n this._AreaElement(u - halfTexel, v - halfTexel) -\r\n this._AreaElement(u - halfTexel, v + halfTexel) -\r\n this._AreaElement(u + halfTexel, v - halfTexel) +\r\n this._AreaElement(u + halfTexel, v + halfTexel);\r\n\r\n let r = dataArray[y * cubeInfo.size * stride + x * stride + 0];\r\n let g = dataArray[y * cubeInfo.size * stride + x * stride + 1];\r\n let b = dataArray[y * cubeInfo.size * stride + x * stride + 2];\r\n\r\n // Prevent NaN harmonics with extreme HDRI data.\r\n if (isNaN(r)) {\r\n r = 0;\r\n }\r\n if (isNaN(g)) {\r\n g = 0;\r\n }\r\n if (isNaN(b)) {\r\n b = 0;\r\n }\r\n\r\n // Handle Integer types.\r\n if (cubeInfo.type === Constants.TEXTURETYPE_UNSIGNED_BYTE) {\r\n r /= 255;\r\n g /= 255;\r\n b /= 255;\r\n }\r\n\r\n // Handle Gamma space textures.\r\n if (cubeInfo.gammaSpace) {\r\n r = Math.pow(Clamp(r), ToLinearSpace);\r\n g = Math.pow(Clamp(g), ToLinearSpace);\r\n b = Math.pow(Clamp(b), ToLinearSpace);\r\n }\r\n\r\n // Prevent to explode in case of really high dynamic ranges.\r\n // sh 3 would not be enough to accurately represent it.\r\n const max = this.MAX_HDRI_VALUE;\r\n if (this.PRESERVE_CLAMPED_COLORS) {\r\n const currentMax = Math.max(r, g, b);\r\n if (currentMax > max) {\r\n const factor = max / currentMax;\r\n r *= factor;\r\n g *= factor;\r\n b *= factor;\r\n }\r\n } else {\r\n r = Clamp(r, 0, max);\r\n g = Clamp(g, 0, max);\r\n b = Clamp(b, 0, max);\r\n }\r\n\r\n const color = new Color3(r, g, b);\r\n\r\n sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);\r\n\r\n totalSolidAngle += deltaSolidAngle;\r\n\r\n u += du;\r\n }\r\n\r\n v += dv;\r\n }\r\n }\r\n\r\n // Solid angle for entire sphere is 4*pi\r\n const sphereSolidAngle = 4.0 * Math.PI;\r\n\r\n // Adjust the solid angle to allow for how many faces we processed.\r\n const facesProcessed = 6.0;\r\n const expectedSolidAngle = (sphereSolidAngle * facesProcessed) / 6.0;\r\n\r\n // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.\r\n // This is needed because the numerical integration over the cube uses a\r\n // small angle approximation of solid angle for each texel (see deltaSolidAngle),\r\n // and also to compensate for accumulative error due to float precision in the summation.\r\n const correctionFactor = expectedSolidAngle / totalSolidAngle;\r\n sphericalHarmonics.scaleInPlace(correctionFactor);\r\n\r\n sphericalHarmonics.convertIncidentRadianceToIrradiance();\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n\r\n return SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n }\r\n}\r\n"]}