@onerjs/core 8.42.1 → 8.42.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.
@@ -61,38 +61,46 @@ export function _ProcessShaderCode(processorOptions, baseName, processFinalCode,
61
61
  else {
62
62
  fragmentSource = baseName.fragment || baseName;
63
63
  }
64
+ // Important:
65
+ // The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.
66
+ // Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.
67
+ // Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.
68
+ // This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel
69
+ // as long as we wait for both shaders to be loaded before starting the processing.
64
70
  const shaderCodes = [undefined, undefined];
65
71
  const shadersLoaded = () => {
66
72
  if (shaderCodes[0] && shaderCodes[1]) {
67
- processorOptions.isFragment = true;
68
- const [migratedVertexCode, fragmentCode] = shaderCodes;
69
- Process(fragmentCode, processorOptions, (migratedFragmentCode, codeBeforeMigration) => {
73
+ const [vertexCode, fragmentCode] = shaderCodes;
74
+ Initialize(processorOptions);
75
+ Process(vertexCode, processorOptions, (migratedVertexCode, codeBeforeMigration) => {
70
76
  if (effectContext) {
71
- effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;
77
+ effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;
72
78
  }
73
79
  if (processFinalCode) {
74
- migratedFragmentCode = processFinalCode("fragment", migratedFragmentCode);
80
+ migratedVertexCode = processFinalCode("vertex", migratedVertexCode);
75
81
  }
76
- const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);
77
- processorOptions = null;
78
- const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);
79
- onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);
82
+ processorOptions.isFragment = true;
83
+ Process(fragmentCode, processorOptions, (migratedFragmentCode, codeBeforeMigration) => {
84
+ if (effectContext) {
85
+ effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;
86
+ }
87
+ if (processFinalCode) {
88
+ migratedFragmentCode = processFinalCode("fragment", migratedFragmentCode);
89
+ }
90
+ const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);
91
+ processorOptions = null;
92
+ const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);
93
+ onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);
94
+ }, engine);
80
95
  }, engine);
81
96
  }
82
97
  };
83
98
  LoadShader(vertexSource, "Vertex", "", (vertexCode) => {
84
- Initialize(processorOptions);
85
- Process(vertexCode, processorOptions, (migratedVertexCode, codeBeforeMigration) => {
86
- if (effectContext) {
87
- effectContext._rawVertexSourceCode = vertexCode;
88
- effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;
89
- }
90
- if (processFinalCode) {
91
- migratedVertexCode = processFinalCode("vertex", migratedVertexCode);
92
- }
93
- shaderCodes[0] = migratedVertexCode;
94
- shadersLoaded();
95
- }, engine);
99
+ if (effectContext) {
100
+ effectContext._rawVertexSourceCode = vertexCode;
101
+ }
102
+ shaderCodes[0] = vertexCode;
103
+ shadersLoaded();
96
104
  }, shaderLanguage);
97
105
  LoadShader(fragmentSource, "Fragment", "Pixel", (fragmentCode) => {
98
106
  if (effectContext) {
@@ -1 +1 @@
1
- {"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAI/E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,E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C,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction, _IShaderProcessingContext } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"../Misc/domManagement\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"../Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"../Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"../Engines/IPipelineContext\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"../Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"../Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"../Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n processorOptions.isFragment = true;\r\n const [migratedVertexCode, fragmentCode] = shaderCodes;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n shaderCodes[0] = migratedVertexCode;\r\n shadersLoaded();\r\n },\r\n engine\r\n );\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"effect.functions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CAAC,IAAI,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC;YAC9B,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;QAChE,CAAC;QAED,sEAAsE;QACtE,oGAAoG;QACpG,uBAAuB,CACnB,eAAe,EACf,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,CAAC,CAAC,OAAO,CAAC,WAAW,EACrB,EAAE,EACF,EAAE,EACF,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,yBAAyB,EACjC,EAAE,EACF,GAAG,EAAE;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction, _IShaderProcessingContext } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"../Misc/domManagement\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"../Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"../Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"../Engines/IPipelineContext\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"../Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"../Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"../Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n // Important:\r\n // The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.\r\n // Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.\r\n // Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.\r\n // This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel\r\n // as long as we wait for both shaders to be loaded before starting the processing.\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n const [vertexCode, fragmentCode] = shaderCodes;\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n processorOptions.isFragment = true;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode: string, codeBeforeMigration: string) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n }\r\n shaderCodes[0] = vertexCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
@@ -117,7 +117,7 @@ export declare function CreateGreasedLineMaterial(name: string, options: Greased
117
117
  * @param scene scene where the mesh will be created
118
118
  * @returns instance of GreasedLineMesh
119
119
  */
120
- export declare function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>): import("../GreasedLine/greasedLineBaseMesh.js").GreasedLineBaseMesh | GreasedLineMesh | GreasedLineRibbonMesh;
120
+ export declare function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>): GreasedLineMesh | import("../GreasedLine/greasedLineBaseMesh.js").GreasedLineBaseMesh | GreasedLineRibbonMesh;
121
121
  /**
122
122
  * Counts the number of points
123
123
  * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]
@@ -174,9 +174,10 @@ export declare class SubMesh implements ICullable {
174
174
  /**
175
175
  * Returns the submesh material
176
176
  * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.
177
+ * @param doNotCheck Defines if should check material render for camera
177
178
  * @returns null or the current material
178
179
  */
179
- getMaterial(getDefaultMaterial?: boolean): Nullable<Material>;
180
+ getMaterial(getDefaultMaterial?: boolean, doNotCheck?: boolean): Nullable<Material>;
180
181
  private _isMultiMaterial;
181
182
  /**
182
183
  * Sets a new updated BoundingInfo object to the submesh
package/Meshes/subMesh.js CHANGED
@@ -231,14 +231,15 @@ export class SubMesh {
231
231
  /**
232
232
  * Returns the submesh material
233
233
  * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.
234
+ * @param doNotCheck Defines if should check material render for camera
234
235
  * @returns null or the current material
235
236
  */
236
- getMaterial(getDefaultMaterial = true) {
237
+ getMaterial(getDefaultMaterial = true, doNotCheck = false) {
237
238
  const scene = this._mesh.getScene();
238
239
  const camera = scene._activeCamera;
239
240
  const shouldCameraNotRenderMaterial = camera ? (this._renderingMesh.doNotRenderMaterialCameraUniqueIds || []).includes(camera.uniqueId) : false;
240
241
  const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ??
241
- (this._renderingMesh.materialEnabled ? (!shouldCameraNotRenderMaterial ? this._renderingMesh.material : null) : null);
242
+ (this._renderingMesh.materialEnabled ? (!shouldCameraNotRenderMaterial || doNotCheck ? this._renderingMesh.material : null) : null);
242
243
  if (!rootMaterial) {
243
244
  return getDefaultMaterial && this._mesh.getScene()._hasDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;
244
245
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/subMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gC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AAM,CAAC,SAAS,CAAC;QACtC,IAAI,cAAc,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEvC,MAAM,cAAc,GAAG,aAAa,IAAI,IAAI,CAAC;QAC7C,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAG,CAAC;QAE7C,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACpE,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;YACD,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\nimport type { Collider } from \"../Collisions/collider\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { MaterialDefines } from \"../Materials/materialDefines\";\r\nimport type { MultiMaterial } from \"../Materials/multiMaterial\";\r\nimport type { AbstractMesh } from \"./abstractMesh\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { Ray } from \"../Culling/ray\";\r\nimport type { TrianglePickingPredicate } from \"../Culling/ray\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: AbstractEngine;\r\n /** @internal */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true, immediate = false): void {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose(immediate);\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (this._getDrawWrapper()?.effect ?? null);\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n * @param immediate If true, the draw wrapper will dispose the effect immediately (false by default)\r\n */\r\n public resetDrawCache(passId?: number, immediate = false): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId, true, immediate);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose(immediate);\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @internal */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @internal */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @internal */\r\n public _trianglePlanes: Plane[];\r\n /** @internal */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /** @internal */\r\n public _renderId = 0;\r\n /** @internal */\r\n public _alphaIndex: number = 0;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal || this._mesh.hasThinInstances) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @returns the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.\r\n * @returns null or the current material\r\n */\r\n public getMaterial(getDefaultMaterial = true): Nullable<Material> {\r\n const scene = this._mesh.getScene();\r\n const camera = scene._activeCamera;\r\n const shouldCameraNotRenderMaterial = camera ? (this._renderingMesh.doNotRenderMaterialCameraUniqueIds || []).includes(camera.uniqueId) : false;\r\n const rootMaterial =\r\n this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ??\r\n (this._renderingMesh.materialEnabled ? (!shouldCameraNotRenderMaterial ? this._renderingMesh.material : null) : null);\r\n\r\n if (!rootMaterial) {\r\n return getDefaultMaterial && this._mesh.getScene()._hasDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n boundingInfo.update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: AbstractEngine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const adjustedIndexCount = Math.floor(this.indexCount / 3) * 6;\r\n const shouldUseUint32 = this.verticesStart + this.verticesCount > 65535;\r\n const linesIndices = shouldUseUint32 ? new Uint32Array(adjustedIndexCount) : new Uint16Array(adjustedIndexCount);\r\n\r\n let offset = 0;\r\n if (indices.length === 0) {\r\n // Unindexed mesh\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = index;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index;\r\n }\r\n } else {\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = indices[index];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index];\r\n }\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, indexA, indexB, indexC)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, -1, -1, -1)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n * @param immediate If true, the effect will be disposed immediately (false by default)\r\n */\r\n public dispose(immediate = false): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache(undefined, immediate);\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/subMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CA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;QACtC,IAAI,cAAc,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEvC,MAAM,cAAc,GAAG,aAAa,IAAI,IAAI,CAAC;QAC7C,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAG,CAAC;QAE7C,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACpE,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;YACD,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\nimport type { Collider } from \"../Collisions/collider\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { MaterialDefines } from \"../Materials/materialDefines\";\r\nimport type { MultiMaterial } from \"../Materials/multiMaterial\";\r\nimport type { AbstractMesh } from \"./abstractMesh\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { Ray } from \"../Culling/ray\";\r\nimport type { TrianglePickingPredicate } from \"../Culling/ray\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: AbstractEngine;\r\n /** @internal */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true, immediate = false): void {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose(immediate);\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (this._getDrawWrapper()?.effect ?? null);\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n * @param immediate If true, the draw wrapper will dispose the effect immediately (false by default)\r\n */\r\n public resetDrawCache(passId?: number, immediate = false): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId, true, immediate);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose(immediate);\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @internal */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @internal */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @internal */\r\n public _trianglePlanes: Plane[];\r\n /** @internal */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /** @internal */\r\n public _renderId = 0;\r\n /** @internal */\r\n public _alphaIndex: number = 0;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal || this._mesh.hasThinInstances) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @returns the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.\r\n * @param doNotCheck Defines if should check material render for camera\r\n * @returns null or the current material\r\n */\r\n public getMaterial(getDefaultMaterial = true, doNotCheck = false): Nullable<Material> {\r\n const scene = this._mesh.getScene();\r\n const camera = scene._activeCamera;\r\n const shouldCameraNotRenderMaterial = camera ? (this._renderingMesh.doNotRenderMaterialCameraUniqueIds || []).includes(camera.uniqueId) : false;\r\n const rootMaterial =\r\n this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ??\r\n (this._renderingMesh.materialEnabled ? (!shouldCameraNotRenderMaterial || doNotCheck ? this._renderingMesh.material : null) : null);\r\n\r\n if (!rootMaterial) {\r\n return getDefaultMaterial && this._mesh.getScene()._hasDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n boundingInfo.update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: AbstractEngine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const adjustedIndexCount = Math.floor(this.indexCount / 3) * 6;\r\n const shouldUseUint32 = this.verticesStart + this.verticesCount > 65535;\r\n const linesIndices = shouldUseUint32 ? new Uint32Array(adjustedIndexCount) : new Uint16Array(adjustedIndexCount);\r\n\r\n let offset = 0;\r\n if (indices.length === 0) {\r\n // Unindexed mesh\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = index;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index;\r\n }\r\n } else {\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = indices[index];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index];\r\n }\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, indexA, indexB, indexC)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, -1, -1, -1)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n * @param immediate If true, the effect will be disposed immediately (false by default)\r\n */\r\n public dispose(immediate = false): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache(undefined, immediate);\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
@@ -18,12 +18,19 @@ export declare class DepthRenderer {
18
18
  private _depthMap;
19
19
  private readonly _storeNonLinearDepth;
20
20
  private readonly _storeCameraSpaceZ;
21
+ private _autoResize;
22
+ private _resizeObserver;
21
23
  /** Shader language used by the material */
22
24
  protected _shaderLanguage: ShaderLanguage;
23
25
  /**
24
26
  * Gets the shader language used in this material.
25
27
  */
26
28
  get shaderLanguage(): ShaderLanguage;
29
+ /**
30
+ * Defines if auto resize the layer is enabled
31
+ */
32
+ get autoResize(): boolean;
33
+ set autoResize(value: boolean);
27
34
  /**
28
35
  * Force all the depth renderer to compile to glsl even on WebGPU engines.
29
36
  * False by default. This is mostly meant for backward compatibility.
@@ -81,6 +88,10 @@ export declare class DepthRenderer {
81
88
  constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, samplingMode?: number, storeCameraSpaceZ?: boolean, name?: string, existingRenderTargetTexture?: RenderTargetTexture);
82
89
  private _shadersLoaded;
83
90
  private _initShaderSourceAsync;
91
+ /**
92
+ * Resize the depth map
93
+ */
94
+ resize(): void;
84
95
  /**
85
96
  * Creates the depth rendering effect and checks if the effect is ready.
86
97
  * @param subMesh The submesh to be used to render the depth map of
@@ -21,6 +21,31 @@ export class DepthRenderer {
21
21
  get shaderLanguage() {
22
22
  return this._shaderLanguage;
23
23
  }
24
+ /**
25
+ * Defines if auto resize the layer is enabled
26
+ */
27
+ get autoResize() {
28
+ return this._autoResize;
29
+ }
30
+ set autoResize(value) {
31
+ if (this._autoResize !== value) {
32
+ this._autoResize = value;
33
+ }
34
+ if (value) {
35
+ const engine = this._scene.getEngine();
36
+ if (!this._resizeObserver && engine) {
37
+ this._resizeObserver = engine.onResizeObservable.add(() => {
38
+ this.resize();
39
+ });
40
+ }
41
+ }
42
+ else {
43
+ if (this._resizeObserver) {
44
+ this._resizeObserver.remove();
45
+ this._resizeObserver = null;
46
+ }
47
+ }
48
+ }
24
49
  /**
25
50
  * Enable or disable the alpha blending for depth rendering. When enabled,
26
51
  * the depth renderer will blend the depth values with the alpha values of
@@ -57,6 +82,8 @@ export class DepthRenderer {
57
82
  * @param existingRenderTargetTexture An existing render target texture to use (default: undefined). If not provided, a new render target texture will be created.
58
83
  */
59
84
  constructor(scene, type = 1, camera = null, storeNonLinearDepth = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, storeCameraSpaceZ = false, name, existingRenderTargetTexture) {
85
+ this._autoResize = false;
86
+ this._resizeObserver = null;
60
87
  /** Shader language used by the material */
61
88
  this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;
62
89
  /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
@@ -305,6 +332,15 @@ export class DepthRenderer {
305
332
  }
306
333
  this._shadersLoaded = true;
307
334
  }
335
+ /**
336
+ * Resize the depth map
337
+ */
338
+ resize() {
339
+ const engine = this._scene.getEngine();
340
+ if (this._depthMap) {
341
+ this._depthMap.resize({ width: engine.getRenderWidth(), height: engine.getRenderHeight() });
342
+ }
343
+ }
308
344
  /**
309
345
  * Creates the depth rendering effect and checks if the effect is ready.
310
346
  * @param subMesh The submesh to be used to render the depth map of
@@ -464,6 +500,10 @@ export class DepthRenderer {
464
500
  * Disposes of the depth renderer.
465
501
  */
466
502
  dispose() {
503
+ if (this._resizeObserver) {
504
+ this._resizeObserver.remove();
505
+ this._resizeObserver = null;
506
+ }
467
507
  const keysToDelete = [];
468
508
  for (const key in this._scene._depthRenderer) {
469
509
  const depthRenderer = this._scene._depthRenderer[key];