@luma.gl/engine 9.0.0-alpha.52 → 9.0.0-alpha.54

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.
@@ -1 +1 @@
1
- {"version":3,"file":"shader-inputs.js","names":["log","_resolveModules","ShaderInputs","constructor","modules","moduleUniforms","moduleBindings","moduleUniformsChanged","allModules","Object","values","map","m","name","module","entries","moduleName","defaultUniforms","destroy","setProps","props","keys","_module$getUniforms","moduleProps","warn","oldUniforms","uniforms","getUniforms","call","getModules","getUniformValues","getBindings","bindings","assign"],"sources":["../src/shader-inputs.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {UniformValue, Texture, Sampler} from '@luma.gl/core';\nimport {log} from '@luma.gl/core';\n// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';\nimport {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools'\n\n\n/** Minimal ShaderModule subset, we don't need shader code etc */\nexport type ShaderModuleInputs<\n PropsT extends Record<string, unknown> = Record<string, unknown>,\n UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>,\n BindingsT extends Record<string, Texture | Sampler> = Record<string, Texture | Sampler>\n> = {\n defaultUniforms?: UniformsT;\n getUniforms?: (settings: Partial<PropsT>, prevUniforms?: UniformsT) => UniformsT;\n\n /** Not used. Used to access props type */\n props?: PropsT;\n\n bindings?: Record<\n keyof BindingsT,\n {\n location: number;\n type: 'texture' | 'sampler' | 'uniforms';\n }\n >;\n\n uniformTypes?: any;\n};\n\n/**\n * ShaderInputs holds uniform and binding values for one or more shader modules,\n * - It can generate binary data for any uniform buffer\n * - It can manage a uniform buffer for each block\n * - It can update managed uniform buffers with a single call\n * - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.\n */\nexport class ShaderInputs<\n ShaderPropsT extends Partial<Record<string, Record<string, unknown>>> = Partial<\n Record<string, Record<string, unknown>>\n >\n> {\n /** \n * The map of modules \n * @todo should should this include the resolved dependencies?\n */\n modules: Readonly<{[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}>;\n\n /** Stores the uniform values for each module */\n moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n /** Stores the uniform bindings for each module */\n moduleBindings: Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n /** Tracks if uniforms have changed */\n moduleUniformsChanged: Record<keyof ShaderPropsT, false | string>;\n\n /**\n * Create a new UniformStore instance\n * @param modules\n */\n constructor(modules: {[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}) {\n // TODO - get all dependencies from modules\n const allModules =_resolveModules(Object.values(modules));\n log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();\n\n // Store the module definitions and create storage for uniform values and binding values, per module\n this.modules = modules;\n this.moduleUniforms = {} as Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n this.moduleBindings = {} as Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n\n // Initialize the modules\n for (const [name, module] of Object.entries(modules)) {\n const moduleName = name as keyof ShaderPropsT;\n\n // Get default uniforms from module\n this.moduleUniforms[moduleName] = module.defaultUniforms || {};\n this.moduleBindings[moduleName] = {};\n }\n }\n\n /** Destroy */\n destroy(): void {}\n\n /**\n * Set module props\n */\n setProps(props: Partial<{[P in keyof ShaderPropsT]?: Partial<ShaderPropsT[P]>}>): void {\n for (const name of Object.keys(props)) {\n const moduleName = name as keyof ShaderPropsT;\n const moduleProps = props[moduleName];\n const module = this.modules[moduleName];\n if (!module) {\n // Ignore props for unregistered modules\n log.warn(`Module ${name} not found`)();\n continue;\n }\n\n const oldUniforms = this.moduleUniforms[moduleName]; \n const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps as any;\n // console.error(uniforms)\n this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};\n // this.moduleUniformsChanged ||= moduleName;\n\n // console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])\n\n // TODO - Get Module bindings\n // const bindings = module.getBindings?.(moduleProps);\n // this.moduleUniforms[moduleName] = bindings;\n }\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n // getUniformBlocks(): Record<string, Texture | Sampler> {\n // return this.moduleUniforms;\n // }\n\n /** \n * Return the map of modules \n * @todo should should this include the resolved dependencies?\n */\n getModules(): ShaderModuleInstance[] {\n return Object.values(this.modules);\n }\n\n /** Get all uniform values for all modules */\n getUniformValues(): Record<keyof ShaderPropsT, Record<string, UniformValue>> {\n return this.moduleUniforms;\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n getBindings(): Record<string, Texture | Sampler> {\n const bindings = {} as Record<string, Texture | Sampler>;\n for (const moduleBindings of Object.values(this.moduleBindings)) {\n Object.assign(bindings, moduleBindings);\n }\n return bindings;\n }\n}\n"],"mappings":"AAEA,SAAQA,GAAG,QAAO,eAAe;AAEjC,SAAQC,eAAe,QAA6B,sBAAsB;AAiC1E,OAAO,MAAMC,YAAY,CAIvB;EAkBAC,WAAWA,CAACC,OAAyE,EAAE;IAAA,KAbvFA,OAAO;IAAA,KAGPC,cAAc;IAAA,KAEdC,cAAc;IAAA,KAEdC,qBAAqB;IAQnB,MAAMC,UAAU,GAAEP,eAAe,CAACQ,MAAM,CAACC,MAAM,CAACN,OAAO,CAAC,CAAC;IACzDJ,GAAG,CAACA,GAAG,CAAC,CAAC,EAAE,oCAAoC,EAAEQ,UAAU,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;IAG/E,IAAI,CAACT,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAG,CAAC,CAA6D;IACpF,IAAI,CAACC,cAAc,GAAG,CAAC,CAAkE;IAGzF,KAAK,MAAM,CAACO,IAAI,EAAEC,MAAM,CAAC,IAAIL,MAAM,CAACM,OAAO,CAACX,OAAO,CAAC,EAAE;MACpD,MAAMY,UAAU,GAAGH,I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AAM,CAACC,MAAM,CAAC,IAAI,CAACJ,cAAc,CAAC,EAAE;MAC/DG,MAAM,CAACwB,MAAM,CAACD,QAAQ,EAAE1B,cAAc,CAAC;IACzC;IACA,OAAO0B,QAAQ;EACjB;AACF"}
1
+ {"version":3,"file":"shader-inputs.js","names":["log","_resolveModules","ShaderInputs","constructor","modules","moduleUniforms","moduleBindings","moduleUniformsChanged","allModules","Object","values","map","m","name","module","entries","moduleName","defaultUniforms","destroy","setProps","props","keys","_module$getUniforms","moduleProps","warn","oldUniforms","uniforms","getUniforms","call","getModules","getUniformValues","getBindings","bindings","assign","getDebugTable","table","key","value","_this$modules$moduleN","type","uniformTypes","String"],"sources":["../src/shader-inputs.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {UniformValue, Texture, Sampler} from '@luma.gl/core';\nimport {log} from '@luma.gl/core';\n// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';\nimport {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools'\n\n\n/** Minimal ShaderModule subset, we don't need shader code etc */\nexport type ShaderModuleInputs<\n PropsT extends Record<string, unknown> = Record<string, unknown>,\n UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>,\n BindingsT extends Record<string, Texture | Sampler> = Record<string, Texture | Sampler>\n> = {\n defaultUniforms?: UniformsT;\n getUniforms?: (settings: Partial<PropsT>, prevUniforms?: UniformsT) => UniformsT;\n\n /** Not used. Used to access props type */\n props?: PropsT;\n\n bindings?: Record<\n keyof BindingsT,\n {\n location: number;\n type: 'texture' | 'sampler' | 'uniforms';\n }\n >;\n\n uniformTypes?: any;\n};\n\n/**\n * ShaderInputs holds uniform and binding values for one or more shader modules,\n * - It can generate binary data for any uniform buffer\n * - It can manage a uniform buffer for each block\n * - It can update managed uniform buffers with a single call\n * - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.\n */\nexport class ShaderInputs<\n ShaderPropsT extends Partial<Record<string, Record<string, unknown>>> = Partial<\n Record<string, Record<string, unknown>>\n >\n> {\n /** \n * The map of modules \n * @todo should should this include the resolved dependencies?\n */\n modules: Readonly<{[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}>;\n\n /** Stores the uniform values for each module */\n moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n /** Stores the uniform bindings for each module */\n moduleBindings: Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n /** Tracks if uniforms have changed */\n moduleUniformsChanged: Record<keyof ShaderPropsT, false | string>;\n\n /**\n * Create a new UniformStore instance\n * @param modules\n */\n constructor(modules: {[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}) {\n // TODO - get all dependencies from modules\n const allModules =_resolveModules(Object.values(modules));\n log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();\n\n // Store the module definitions and create storage for uniform values and binding values, per module\n this.modules = modules;\n this.moduleUniforms = {} as Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n this.moduleBindings = {} as Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n\n // Initialize the modules\n for (const [name, module] of Object.entries(modules)) {\n const moduleName = name as keyof ShaderPropsT;\n\n // Get default uniforms from module\n this.moduleUniforms[moduleName] = module.defaultUniforms || {};\n this.moduleBindings[moduleName] = {};\n }\n }\n\n /** Destroy */\n destroy(): void {}\n\n /**\n * Set module props\n */\n setProps(props: Partial<{[P in keyof ShaderPropsT]?: Partial<ShaderPropsT[P]>}>): void {\n for (const name of Object.keys(props)) {\n const moduleName = name as keyof ShaderPropsT;\n const moduleProps = props[moduleName];\n const module = this.modules[moduleName];\n if (!module) {\n // Ignore props for unregistered modules\n log.warn(`Module ${name} not found`)();\n continue; // eslint-disable-line no-continue\n }\n\n const oldUniforms = this.moduleUniforms[moduleName]; \n const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps as any;\n // console.error(uniforms)\n this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};\n // this.moduleUniformsChanged ||= moduleName;\n\n // console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])\n\n // TODO - Get Module bindings\n // const bindings = module.getBindings?.(moduleProps);\n // this.moduleUniforms[moduleName] = bindings;\n }\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n // getUniformBlocks(): Record<string, Texture | Sampler> {\n // return this.moduleUniforms;\n // }\n\n /** \n * Return the map of modules \n * @todo should should this include the resolved dependencies?\n */\n getModules(): ShaderModuleInstance[] {\n return Object.values(this.modules);\n }\n\n /** Get all uniform values for all modules */\n getUniformValues(): Record<keyof ShaderPropsT, Record<string, UniformValue>> {\n return this.moduleUniforms;\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n getBindings(): Record<string, Texture | Sampler> {\n const bindings = {} as Record<string, Texture | Sampler>;\n for (const moduleBindings of Object.values(this.moduleBindings)) {\n Object.assign(bindings, moduleBindings);\n }\n return bindings;\n }\n\n getDebugTable(): Record<string, Record<string, unknown>> {\n const table: Record<string,Record<string, unknown>> = {};\n for (const [moduleName, module] of Object.entries(this.moduleUniforms)) {\n for (const [key, value] of Object.entries(module)) {\n table[`${moduleName}.${key}`] = {\n type: this.modules[moduleName].uniformTypes?.[key],\n value: String(value)\n };\n }\n }\n return table;\n }\n}\n"],"mappings":"AAEA,SAAQA,GAAG,QAAO,eAAe;AAEjC,SAAQC,eAAe,QAA6B,sBAAsB;AAiC1E,OAAO,MAAMC,YAAY,CAIvB;EAkBAC,WAAWA,CAACC,OAAyE,EAAE;IAAA,KAbvFA,OAAO;IAAA,KAGPC,cAAc;IAAA,KAEdC,cAAc;IAAA,KAEdC,qBAAqB;IAQnB,MAAMC,UAAU,GAAEP,eAAe,CAACQ,MAAM,CAACC,MAAM,CAACN,OAAO,CAAC,CAAC;IACzDJ,GAAG,CAACA,GAAG,CAAC,CAAC,EAAE,oCAAoC,EAAEQ,UAAU,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,I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