@babylonjs/core 6.3.1 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/audioSceneComponent.js +2 -2
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +10 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Debug/physicsViewer.d.ts +17 -0
- package/Debug/physicsViewer.js +153 -2
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +28 -9
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/engine.d.ts +5 -0
- package/Engines/engine.js +0 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.js +25 -1
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Materials/material.js +0 -5
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginManager.js +7 -0
- package/Materials/materialPluginManager.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +146 -114
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/mesh.d.ts +3 -0
- package/Meshes/mesh.js +3 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +6 -3
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Misc/perfCounter.d.ts +5 -0
- package/Misc/perfCounter.js +7 -0
- package/Misc/perfCounter.js.map +1 -1
- package/Morph/morphTargetManager.js +3 -0
- package/Morph/morphTargetManager.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +12 -2
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.d.ts +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Sprites/spriteManager.js +5 -9
- package/Sprites/spriteManager.js.map +1 -1
- package/XR/webXRSessionManager.d.ts +6 -0
- package/XR/webXRSessionManager.js +9 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +1 -0
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialPluginManager.js","sourceRoot":"","sources":["../../../../lts/core/generated/Materials/materialPluginManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgBtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAgB5D,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAoB9B;;;OAGG;IACH,YAAY,QAAkB;QAhBpB,aAAQ,GAAyB,EAAE,CAAC;QACpC,mBAAc,GAAyB,EAAE,CAAC;QAC1C,iCAA4B,GAAyB,EAAE,CAAC;QAe9D,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;YAC3C,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE;gB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AAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;KAC5B;SAAM;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;KACvC;AACL,CAAC;AAED;;;;GAIG;AACH,gEAAgE;AAChE,MAAM,UAAU,wBAAwB,CAAC,UAAkB;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,4BAA4B,EAAE,CAAC;aAClC;YACD,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,gEAAgE;AAChE,MAAM,UAAU,4BAA4B;IACxC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACnB,MAAM,GAAG,KAAK,CAAC;IACf,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { 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\n\r\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\ndeclare type MaterialPluginBase = import(\"./materialPluginBase\").MaterialPluginBase;\r\n\r\ndeclare module \"./material\" {\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: Engine;\r\n protected _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 /**\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): void {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === plugin.name) {\r\n throw `Plugin \"${plugin.name}\" already added to the material \"${this._material.name}\"!`;\r\n }\r\n }\r\n\r\n if (this._material._uniformBufferLayoutBuilt) {\r\n throw `The plugin \"${plugin.name}\" can't be added to the material \"${this._material.name}\" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.`;\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 = this._handlePluginEvent.bind(this);\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\"));\r\n this._collectPointNames(\"fragment\", plugin.getCustomCode(\"fragment\"));\r\n }\r\n\r\n this._defineNamesFromPlugins = defineNamesFromPlugins;\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(name: string): Nullable<MaterialPluginBase> {\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];\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.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 for (const plugin of this._plugins) {\r\n const uniforms = plugin.getUniforms();\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 this._uboDeclaration += `${uniform.type} ${uniform.name}${arraySize > 0 ? `[${arraySize}]` : \"\"};\\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 + \"\\r\\n\";\r\n }\r\n if (uniforms.fragment) {\r\n this._fragmentDeclaration += uniforms.fragment + \"\\r\\n\";\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(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 for (let pointName in points) {\r\n let injectedCode = \"\";\r\n for (const plugin of this._activePlugins) {\r\n const customCode = plugin.getCustomCode(shaderType);\r\n if (customCode?.[pointName]) {\r\n injectedCode += customCode[pointName] + \"\\r\\n\";\r\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, \"\\r\\n\" + injectedCode + \"\\r\\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 observer: 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 observer = 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(observer);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"materialPluginManager.js","sourceRoot":"","sources":["../../../../lts/core/generated/Materials/materialPluginManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgBtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAerD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IA0B9B;;;OAGG;IACH,YAAY,QAAkB;QAtBpB,aAAQ,GAAyB,EAAE,CAAC;QACpC,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,CA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;QAChC,MAAM,GAAG,IAAI,CAAC;KACjB;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAC3E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;KAC5B;SAAM;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;KACvC;AACL,CAAC;AAED;;;;GAIG;AACH,gEAAgE;AAChE,MAAM,UAAU,wBAAwB,CAAC,UAAkB;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,4BAA4B,EAAE,CAAC;aAClC;YACD,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,gEAAgE;AAChE,MAAM,UAAU,4BAA4B;IACxC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACnB,MAAM,GAAG,KAAK,CAAC;IACf,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,QAAQ,GAAG,IAAI,CAAC;AACpB,CAAC","sourcesContent":["import type { 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\ndeclare type Scene = import(\"../scene\").Scene;\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\ndeclare type MaterialPluginBase = import(\"./materialPluginBase\").MaterialPluginBase;\r\n\r\ndeclare module \"./material\" {\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: Engine;\r\n protected _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): void {\r\n for (let i = 0; i < this._plugins.length; ++i) {\r\n if (this._plugins[i].name === plugin.name) {\r\n throw `Plugin \"${plugin.name}\" already added to the material \"${this._material.name}\"!`;\r\n }\r\n }\r\n\r\n if (this._material._uniformBufferLayoutBuilt) {\r\n throw `The plugin \"${plugin.name}\" can't be added to the material \"${this._material.name}\" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.`;\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 = this._handlePluginEvent.bind(this);\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\"));\r\n this._collectPointNames(\"fragment\", plugin.getCustomCode(\"fragment\"));\r\n }\r\n\r\n this._defineNamesFromPlugins = defineNamesFromPlugins;\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(name: string): Nullable<MaterialPluginBase> {\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];\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.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 for (const plugin of this._plugins) {\r\n const uniforms = plugin.getUniforms();\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 this._uboDeclaration += `${uniform.type} ${uniform.name}${arraySize > 0 ? `[${arraySize}]` : \"\"};\\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 + \"\\r\\n\";\r\n }\r\n if (uniforms.fragment) {\r\n this._fragmentDeclaration += uniforms.fragment + \"\\r\\n\";\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(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 for (let pointName in points) {\r\n let injectedCode = \"\";\r\n for (const plugin of this._activePlugins) {\r\n const customCode = plugin.getCustomCode(shaderType);\r\n if (customCode?.[pointName]) {\r\n injectedCode += customCode[pointName] + \"\\r\\n\";\r\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, \"\\r\\n\" + injectedCode + \"\\r\\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 observer: 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 observer = 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(observer);\r\n observer = null;\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3, Matrix, Vector2 } from "../../Maths/math.vector.js";
|
|
1
|
+
import { Vector3, Matrix, Vector2, TmpVectors } from "../../Maths/math.vector.js";
|
|
2
2
|
import { Scalar } from "../../Maths/math.scalar.js";
|
|
3
3
|
import { Mesh } from "../mesh.js";
|
|
4
4
|
import { VertexBuffer } from "../../Buffers/buffer.js";
|
|
@@ -54,6 +54,7 @@ class DecalVertex {
|
|
|
54
54
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/decals
|
|
55
55
|
*/
|
|
56
56
|
export function CreateDecal(name, sourceMesh, options) {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
57
58
|
const hasSkeleton = !!sourceMesh.skeleton;
|
|
58
59
|
const useLocalComputation = options.localMode || hasSkeleton;
|
|
59
60
|
const meshHasOverridenMaterial = sourceMesh.overrideMaterialSideOrientation !== null && sourceMesh.overrideMaterialSideOrientation !== undefined;
|
|
@@ -81,11 +82,6 @@ export function CreateDecal(name, sourceMesh, options) {
|
|
|
81
82
|
const yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
|
|
82
83
|
const len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
|
|
83
84
|
const pitch = Math.atan2(normal.y, len);
|
|
84
|
-
// Matrix
|
|
85
|
-
const decalWorldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, angle).multiply(Matrix.Translation(position.x, position.y, position.z));
|
|
86
|
-
const inverseDecalWorldMatrix = Matrix.Invert(decalWorldMatrix);
|
|
87
|
-
const meshWorldMatrix = sourceMesh.getWorldMatrix();
|
|
88
|
-
const transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
|
|
89
85
|
const vertexData = new VertexData();
|
|
90
86
|
vertexData.indices = [];
|
|
91
87
|
vertexData.positions = [];
|
|
@@ -96,7 +92,7 @@ export function CreateDecal(name, sourceMesh, options) {
|
|
|
96
92
|
vertexData.matricesIndicesExtra = matIndicesExtra ? [] : null;
|
|
97
93
|
vertexData.matricesWeightsExtra = matWeightsExtra ? [] : null;
|
|
98
94
|
let currentVertexDataIndex = 0;
|
|
99
|
-
const extractDecalVector3 = (indexId) => {
|
|
95
|
+
const extractDecalVector3 = (indexId, transformMatrix) => {
|
|
100
96
|
const result = new DecalVertex();
|
|
101
97
|
if (!indices || !positions || !normals) {
|
|
102
98
|
return result;
|
|
@@ -289,128 +285,164 @@ export function CreateDecal(name, sourceMesh, options) {
|
|
|
289
285
|
}
|
|
290
286
|
return clipResult;
|
|
291
287
|
};
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
288
|
+
const sourceMeshAsMesh = sourceMesh;
|
|
289
|
+
const matrixData = sourceMeshAsMesh._thinInstanceDataStorage.matrixData;
|
|
290
|
+
const numMatrices = sourceMeshAsMesh.thinInstanceCount || 1;
|
|
291
|
+
const thinInstanceMatrix = TmpVectors.Matrix[0];
|
|
292
|
+
thinInstanceMatrix.copyFrom(Matrix.IdentityReadOnly);
|
|
293
|
+
for (let m = 0; m < numMatrices; ++m) {
|
|
294
|
+
if (sourceMeshAsMesh.hasThinInstances && matrixData) {
|
|
295
|
+
const ofst = m * 16;
|
|
296
|
+
thinInstanceMatrix.setRowFromFloats(0, matrixData[ofst + 0], matrixData[ofst + 1], matrixData[ofst + 2], matrixData[ofst + 3]);
|
|
297
|
+
thinInstanceMatrix.setRowFromFloats(1, matrixData[ofst + 4], matrixData[ofst + 5], matrixData[ofst + 6], matrixData[ofst + 7]);
|
|
298
|
+
thinInstanceMatrix.setRowFromFloats(2, matrixData[ofst + 8], matrixData[ofst + 9], matrixData[ofst + 10], matrixData[ofst + 11]);
|
|
299
|
+
thinInstanceMatrix.setRowFromFloats(3, matrixData[ofst + 12], matrixData[ofst + 13], matrixData[ofst + 14], matrixData[ofst + 15]);
|
|
299
300
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
faceVertices = clip(faceVertices, xpAxis);
|
|
313
|
-
if (!faceVertices)
|
|
314
|
-
continue;
|
|
315
|
-
faceVertices = clip(faceVertices, xnAxis);
|
|
316
|
-
if (!faceVertices)
|
|
317
|
-
continue;
|
|
318
|
-
faceVertices = clip(faceVertices, ypAxis);
|
|
319
|
-
if (!faceVertices)
|
|
320
|
-
continue;
|
|
321
|
-
faceVertices = clip(faceVertices, ynAxis);
|
|
322
|
-
if (!faceVertices)
|
|
323
|
-
continue;
|
|
324
|
-
faceVertices = clip(faceVertices, zpAxis);
|
|
325
|
-
if (!faceVertices)
|
|
326
|
-
continue;
|
|
327
|
-
faceVertices = clip(faceVertices, znAxis);
|
|
328
|
-
if (!faceVertices)
|
|
329
|
-
continue;
|
|
330
|
-
// Add UVs and get back to world
|
|
331
|
-
for (let vIndex = 0; vIndex < faceVertices.length; vIndex++) {
|
|
332
|
-
const vertex = faceVertices[vIndex];
|
|
333
|
-
//TODO check for Int32Array | Uint32Array | Uint16Array
|
|
334
|
-
vertexData.indices.push(currentVertexDataIndex);
|
|
335
|
-
if (useLocalComputation) {
|
|
336
|
-
if (vertex.localPositionOverride) {
|
|
337
|
-
vertexData.positions[currentVertexDataIndex * 3] = vertex.localPositionOverride[0];
|
|
338
|
-
vertexData.positions[currentVertexDataIndex * 3 + 1] = vertex.localPositionOverride[1];
|
|
339
|
-
vertexData.positions[currentVertexDataIndex * 3 + 2] = vertex.localPositionOverride[2];
|
|
340
|
-
}
|
|
341
|
-
else if (localPositions) {
|
|
342
|
-
vertexData.positions[currentVertexDataIndex * 3] = localPositions[vertex.vertexIdx];
|
|
343
|
-
vertexData.positions[currentVertexDataIndex * 3 + 1] = localPositions[vertex.vertexIdx + 1];
|
|
344
|
-
vertexData.positions[currentVertexDataIndex * 3 + 2] = localPositions[vertex.vertexIdx + 2];
|
|
345
|
-
}
|
|
346
|
-
if (vertex.localNormalOverride) {
|
|
347
|
-
vertexData.normals[currentVertexDataIndex * 3] = vertex.localNormalOverride[0];
|
|
348
|
-
vertexData.normals[currentVertexDataIndex * 3 + 1] = vertex.localNormalOverride[1];
|
|
349
|
-
vertexData.normals[currentVertexDataIndex * 3 + 2] = vertex.localNormalOverride[2];
|
|
350
|
-
}
|
|
351
|
-
else if (localNormals) {
|
|
352
|
-
vertexData.normals[currentVertexDataIndex * 3] = localNormals[vertex.vertexIdx];
|
|
353
|
-
vertexData.normals[currentVertexDataIndex * 3 + 1] = localNormals[vertex.vertexIdx + 1];
|
|
354
|
-
vertexData.normals[currentVertexDataIndex * 3 + 2] = localNormals[vertex.vertexIdx + 2];
|
|
355
|
-
}
|
|
301
|
+
// Matrix
|
|
302
|
+
const decalWorldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, angle).multiply(Matrix.Translation(position.x, position.y, position.z));
|
|
303
|
+
const inverseDecalWorldMatrix = Matrix.Invert(decalWorldMatrix);
|
|
304
|
+
const meshWorldMatrix = sourceMesh.getWorldMatrix();
|
|
305
|
+
const transformMatrix = thinInstanceMatrix.multiply(meshWorldMatrix).multiply(inverseDecalWorldMatrix);
|
|
306
|
+
const oneFaceVertices = new Array(3);
|
|
307
|
+
for (let index = 0; index < indices.length; index += 3) {
|
|
308
|
+
let faceVertices = oneFaceVertices;
|
|
309
|
+
faceVertices[0] = extractDecalVector3(index, transformMatrix);
|
|
310
|
+
if (meshHasOverridenMaterial && useLocalComputation) {
|
|
311
|
+
faceVertices[1] = extractDecalVector3(index + 2, transformMatrix);
|
|
312
|
+
faceVertices[2] = extractDecalVector3(index + 1, transformMatrix);
|
|
356
313
|
}
|
|
357
314
|
else {
|
|
358
|
-
|
|
359
|
-
|
|
315
|
+
faceVertices[1] = extractDecalVector3(index + 1, transformMatrix);
|
|
316
|
+
faceVertices[2] = extractDecalVector3(index + 2, transformMatrix);
|
|
360
317
|
}
|
|
361
|
-
if (
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = vertex.matrixIndicesOverride[3];
|
|
318
|
+
if (options.cullBackFaces) {
|
|
319
|
+
// If all the normals of the vertices of the face are pointing away from the view direction we discard the face.
|
|
320
|
+
// As computations are done in the decal coordinate space, the viewDirection is (0,0,1), so when dot(vertexNormal, -viewDirection) <= 0 the vertex is culled
|
|
321
|
+
if (-faceVertices[0].normal.z <= 0 && -faceVertices[1].normal.z <= 0 && -faceVertices[2].normal.z <= 0) {
|
|
322
|
+
continue;
|
|
367
323
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
324
|
+
}
|
|
325
|
+
// Clip
|
|
326
|
+
faceVertices = clip(faceVertices, xpAxis);
|
|
327
|
+
if (!faceVertices)
|
|
328
|
+
continue;
|
|
329
|
+
faceVertices = clip(faceVertices, xnAxis);
|
|
330
|
+
if (!faceVertices)
|
|
331
|
+
continue;
|
|
332
|
+
faceVertices = clip(faceVertices, ypAxis);
|
|
333
|
+
if (!faceVertices)
|
|
334
|
+
continue;
|
|
335
|
+
faceVertices = clip(faceVertices, ynAxis);
|
|
336
|
+
if (!faceVertices)
|
|
337
|
+
continue;
|
|
338
|
+
faceVertices = clip(faceVertices, zpAxis);
|
|
339
|
+
if (!faceVertices)
|
|
340
|
+
continue;
|
|
341
|
+
faceVertices = clip(faceVertices, znAxis);
|
|
342
|
+
if (!faceVertices)
|
|
343
|
+
continue;
|
|
344
|
+
// Add UVs and get back to world
|
|
345
|
+
for (let vIndex = 0; vIndex < faceVertices.length; vIndex++) {
|
|
346
|
+
const vertex = faceVertices[vIndex];
|
|
347
|
+
//TODO check for Int32Array | Uint32Array | Uint16Array
|
|
348
|
+
vertexData.indices.push(currentVertexDataIndex);
|
|
349
|
+
if (useLocalComputation) {
|
|
350
|
+
if (vertex.localPositionOverride) {
|
|
351
|
+
vertexData.positions[currentVertexDataIndex * 3] = vertex.localPositionOverride[0];
|
|
352
|
+
vertexData.positions[currentVertexDataIndex * 3 + 1] = vertex.localPositionOverride[1];
|
|
353
|
+
vertexData.positions[currentVertexDataIndex * 3 + 2] = vertex.localPositionOverride[2];
|
|
374
354
|
}
|
|
375
|
-
if (
|
|
376
|
-
vertexData.
|
|
377
|
-
vertexData.
|
|
378
|
-
vertexData.
|
|
379
|
-
|
|
355
|
+
else if (localPositions) {
|
|
356
|
+
vertexData.positions[currentVertexDataIndex * 3] = localPositions[vertex.vertexIdx];
|
|
357
|
+
vertexData.positions[currentVertexDataIndex * 3 + 1] = localPositions[vertex.vertexIdx + 1];
|
|
358
|
+
vertexData.positions[currentVertexDataIndex * 3 + 2] = localPositions[vertex.vertexIdx + 2];
|
|
359
|
+
}
|
|
360
|
+
if (vertex.localNormalOverride) {
|
|
361
|
+
vertexData.normals[currentVertexDataIndex * 3] = vertex.localNormalOverride[0];
|
|
362
|
+
vertexData.normals[currentVertexDataIndex * 3 + 1] = vertex.localNormalOverride[1];
|
|
363
|
+
vertexData.normals[currentVertexDataIndex * 3 + 2] = vertex.localNormalOverride[2];
|
|
364
|
+
}
|
|
365
|
+
else if (localNormals) {
|
|
366
|
+
vertexData.normals[currentVertexDataIndex * 3] = localNormals[vertex.vertexIdx];
|
|
367
|
+
vertexData.normals[currentVertexDataIndex * 3 + 1] = localNormals[vertex.vertexIdx + 1];
|
|
368
|
+
vertexData.normals[currentVertexDataIndex * 3 + 2] = localNormals[vertex.vertexIdx + 2];
|
|
380
369
|
}
|
|
381
|
-
}
|
|
382
|
-
if (vertex.matrixWeightsOverride) {
|
|
383
|
-
vertexData.matricesWeights[currentVertexDataIndex * 4] = vertex.matrixWeightsOverride[0];
|
|
384
|
-
vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = vertex.matrixWeightsOverride[1];
|
|
385
|
-
vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = vertex.matrixWeightsOverride[2];
|
|
386
|
-
vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = vertex.matrixWeightsOverride[3];
|
|
387
370
|
}
|
|
388
371
|
else {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
372
|
+
vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
|
|
373
|
+
vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
|
|
374
|
+
}
|
|
375
|
+
if (vertexData.matricesIndices && vertexData.matricesWeights) {
|
|
376
|
+
if (vertex.matrixIndicesOverride) {
|
|
377
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4] = vertex.matrixIndicesOverride[0];
|
|
378
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = vertex.matrixIndicesOverride[1];
|
|
379
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = vertex.matrixIndicesOverride[2];
|
|
380
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = vertex.matrixIndicesOverride[3];
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
if (matIndices) {
|
|
384
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4] = matIndices[vertex.vertexIdxForBones];
|
|
385
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = matIndices[vertex.vertexIdxForBones + 1];
|
|
386
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = matIndices[vertex.vertexIdxForBones + 2];
|
|
387
|
+
vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = matIndices[vertex.vertexIdxForBones + 3];
|
|
388
|
+
}
|
|
389
|
+
if (matIndicesExtra && vertexData.matricesIndicesExtra) {
|
|
390
|
+
vertexData.matricesIndicesExtra[currentVertexDataIndex * 4] = matIndicesExtra[vertex.vertexIdxForBones];
|
|
391
|
+
vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 1] = matIndicesExtra[vertex.vertexIdxForBones + 1];
|
|
392
|
+
vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 2] = matIndicesExtra[vertex.vertexIdxForBones + 2];
|
|
393
|
+
vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 3] = matIndicesExtra[vertex.vertexIdxForBones + 3];
|
|
394
|
+
}
|
|
394
395
|
}
|
|
395
|
-
if (
|
|
396
|
-
vertexData.
|
|
397
|
-
vertexData.
|
|
398
|
-
vertexData.
|
|
399
|
-
vertexData.
|
|
396
|
+
if (vertex.matrixWeightsOverride) {
|
|
397
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4] = vertex.matrixWeightsOverride[0];
|
|
398
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = vertex.matrixWeightsOverride[1];
|
|
399
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = vertex.matrixWeightsOverride[2];
|
|
400
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = vertex.matrixWeightsOverride[3];
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
if (matWeights) {
|
|
404
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4] = matWeights[vertex.vertexIdxForBones];
|
|
405
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = matWeights[vertex.vertexIdxForBones + 1];
|
|
406
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = matWeights[vertex.vertexIdxForBones + 2];
|
|
407
|
+
vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = matWeights[vertex.vertexIdxForBones + 3];
|
|
408
|
+
}
|
|
409
|
+
if (matWeightsExtra && vertexData.matricesWeightsExtra) {
|
|
410
|
+
vertexData.matricesWeightsExtra[currentVertexDataIndex * 4] = matWeightsExtra[vertex.vertexIdxForBones];
|
|
411
|
+
vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 1] = matWeightsExtra[vertex.vertexIdxForBones + 1];
|
|
412
|
+
vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 2] = matWeightsExtra[vertex.vertexIdxForBones + 2];
|
|
413
|
+
vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 3] = matWeightsExtra[vertex.vertexIdxForBones + 3];
|
|
414
|
+
}
|
|
400
415
|
}
|
|
401
416
|
}
|
|
417
|
+
if (!options.captureUVS) {
|
|
418
|
+
vertexData.uvs.push(0.5 + vertex.position.x / size.x);
|
|
419
|
+
const v = 0.5 + vertex.position.y / size.y;
|
|
420
|
+
vertexData.uvs.push(CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
vertex.uv.toArray(vertexData.uvs, currentVertexDataIndex * 2);
|
|
424
|
+
}
|
|
425
|
+
currentVertexDataIndex++;
|
|
402
426
|
}
|
|
403
|
-
if (!options.captureUVS) {
|
|
404
|
-
vertexData.uvs.push(0.5 + vertex.position.x / size.x);
|
|
405
|
-
const v = 0.5 + vertex.position.y / size.y;
|
|
406
|
-
vertexData.uvs.push(CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
vertex.uv.toArray(vertexData.uvs, currentVertexDataIndex * 2);
|
|
410
|
-
}
|
|
411
|
-
currentVertexDataIndex++;
|
|
412
427
|
}
|
|
413
428
|
}
|
|
429
|
+
// Avoid the "Setting vertex data kind 'XXX' with an empty array" warning when calling vertexData.applyToMesh
|
|
430
|
+
if (vertexData.indices.length === 0)
|
|
431
|
+
vertexData.indices = null;
|
|
432
|
+
if (vertexData.positions.length === 0)
|
|
433
|
+
vertexData.positions = null;
|
|
434
|
+
if (vertexData.normals.length === 0)
|
|
435
|
+
vertexData.normals = null;
|
|
436
|
+
if (vertexData.uvs.length === 0)
|
|
437
|
+
vertexData.uvs = null;
|
|
438
|
+
if (((_a = vertexData.matricesIndices) === null || _a === void 0 ? void 0 : _a.length) === 0)
|
|
439
|
+
vertexData.matricesIndices = null;
|
|
440
|
+
if (((_b = vertexData.matricesWeights) === null || _b === void 0 ? void 0 : _b.length) === 0)
|
|
441
|
+
vertexData.matricesWeights = null;
|
|
442
|
+
if (((_c = vertexData.matricesIndicesExtra) === null || _c === void 0 ? void 0 : _c.length) === 0)
|
|
443
|
+
vertexData.matricesIndicesExtra = null;
|
|
444
|
+
if (((_d = vertexData.matricesWeightsExtra) === null || _d === void 0 ? void 0 : _d.length) === 0)
|
|
445
|
+
vertexData.matricesWeightsExtra = null;
|
|
414
446
|
// Return mesh
|
|
415
447
|
const decal = new Mesh(name, sourceMesh.getScene());
|
|
416
448
|
vertexData.applyToMesh(decal);
|