@luma.gl/engine 9.3.0-alpha.6 → 9.3.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  2. package/dist/animation-loop/animation-loop.js +3 -0
  3. package/dist/animation-loop/animation-loop.js.map +1 -1
  4. package/dist/compute/computation.d.ts +3 -7
  5. package/dist/compute/computation.d.ts.map +1 -1
  6. package/dist/compute/computation.js +14 -12
  7. package/dist/compute/computation.js.map +1 -1
  8. package/dist/dist.dev.js +1751 -831
  9. package/dist/dist.min.js +296 -148
  10. package/dist/dynamic-texture/dynamic-texture.d.ts +9 -2
  11. package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
  12. package/dist/dynamic-texture/dynamic-texture.js +54 -5
  13. package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
  14. package/dist/dynamic-texture/texture-data.d.ts +4 -1
  15. package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
  16. package/dist/dynamic-texture/texture-data.js +19 -2
  17. package/dist/dynamic-texture/texture-data.js.map +1 -1
  18. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  19. package/dist/geometry/gpu-geometry.js +8 -3
  20. package/dist/geometry/gpu-geometry.js.map +1 -1
  21. package/dist/index.cjs +1711 -847
  22. package/dist/index.cjs.map +4 -4
  23. package/dist/index.d.ts +12 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +8 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/material/material-factory.d.ts +73 -0
  28. package/dist/material/material-factory.d.ts.map +1 -0
  29. package/dist/material/material-factory.js +111 -0
  30. package/dist/material/material-factory.js.map +1 -0
  31. package/dist/material/material.d.ts +84 -0
  32. package/dist/material/material.d.ts.map +1 -0
  33. package/dist/material/material.js +176 -0
  34. package/dist/material/material.js.map +1 -0
  35. package/dist/model/model.d.ts +14 -6
  36. package/dist/model/model.d.ts.map +1 -1
  37. package/dist/model/model.js +69 -25
  38. package/dist/model/model.js.map +1 -1
  39. package/dist/model/split-uniforms-and-bindings.d.ts +4 -3
  40. package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
  41. package/dist/model/split-uniforms-and-bindings.js +2 -2
  42. package/dist/model/split-uniforms-and-bindings.js.map +1 -1
  43. package/dist/models/directional-light-model.d.ts +7 -0
  44. package/dist/models/directional-light-model.d.ts.map +1 -0
  45. package/dist/models/directional-light-model.js +23 -0
  46. package/dist/models/directional-light-model.js.map +1 -0
  47. package/dist/models/light-model-utils.d.ts +69 -0
  48. package/dist/models/light-model-utils.d.ts.map +1 -0
  49. package/dist/models/light-model-utils.js +395 -0
  50. package/dist/models/light-model-utils.js.map +1 -0
  51. package/dist/models/point-light-model.d.ts +7 -0
  52. package/dist/models/point-light-model.d.ts.map +1 -0
  53. package/dist/models/point-light-model.js +22 -0
  54. package/dist/models/point-light-model.js.map +1 -0
  55. package/dist/models/spot-light-model.d.ts +7 -0
  56. package/dist/models/spot-light-model.d.ts.map +1 -0
  57. package/dist/models/spot-light-model.js +23 -0
  58. package/dist/models/spot-light-model.js.map +1 -0
  59. package/dist/modules/picking/color-picking.d.ts +5 -9
  60. package/dist/modules/picking/color-picking.d.ts.map +1 -1
  61. package/dist/modules/picking/color-picking.js +122 -115
  62. package/dist/modules/picking/color-picking.js.map +1 -1
  63. package/dist/modules/picking/index-picking.d.ts +2 -2
  64. package/dist/modules/picking/index-picking.d.ts.map +1 -1
  65. package/dist/modules/picking/index-picking.js +36 -10
  66. package/dist/modules/picking/index-picking.js.map +1 -1
  67. package/dist/modules/picking/legacy-color-picking.d.ts +26 -0
  68. package/dist/modules/picking/legacy-color-picking.d.ts.map +1 -0
  69. package/dist/modules/picking/legacy-color-picking.js +7 -0
  70. package/dist/modules/picking/legacy-color-picking.js.map +1 -0
  71. package/dist/modules/picking/picking-manager.d.ts +29 -3
  72. package/dist/modules/picking/picking-manager.d.ts.map +1 -1
  73. package/dist/modules/picking/picking-manager.js +188 -41
  74. package/dist/modules/picking/picking-manager.js.map +1 -1
  75. package/dist/modules/picking/picking-uniforms.d.ts +12 -11
  76. package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
  77. package/dist/modules/picking/picking-uniforms.js +26 -13
  78. package/dist/modules/picking/picking-uniforms.js.map +1 -1
  79. package/dist/modules/picking/picking.d.ts +25 -0
  80. package/dist/modules/picking/picking.d.ts.map +1 -0
  81. package/dist/modules/picking/picking.js +18 -0
  82. package/dist/modules/picking/picking.js.map +1 -0
  83. package/dist/shader-inputs.d.ts +9 -7
  84. package/dist/shader-inputs.d.ts.map +1 -1
  85. package/dist/shader-inputs.js +84 -4
  86. package/dist/shader-inputs.js.map +1 -1
  87. package/dist/utils/shader-module-utils.d.ts +7 -0
  88. package/dist/utils/shader-module-utils.d.ts.map +1 -0
  89. package/dist/utils/shader-module-utils.js +46 -0
  90. package/dist/utils/shader-module-utils.js.map +1 -0
  91. package/package.json +4 -4
  92. package/src/animation-loop/animation-loop.ts +3 -0
  93. package/src/compute/computation.ts +31 -17
  94. package/src/dynamic-texture/dynamic-texture.ts +79 -7
  95. package/src/dynamic-texture/texture-data.ts +25 -4
  96. package/src/geometry/gpu-geometry.ts +8 -3
  97. package/src/index.ts +29 -4
  98. package/src/material/material-factory.ts +157 -0
  99. package/src/material/material.ts +254 -0
  100. package/src/model/model.ts +108 -40
  101. package/src/model/split-uniforms-and-bindings.ts +8 -6
  102. package/src/models/directional-light-model.ts +32 -0
  103. package/src/models/light-model-utils.ts +587 -0
  104. package/src/models/point-light-model.ts +31 -0
  105. package/src/models/spot-light-model.ts +32 -0
  106. package/src/modules/picking/color-picking.ts +123 -122
  107. package/src/modules/picking/index-picking.ts +36 -10
  108. package/src/modules/picking/legacy-color-picking.ts +8 -0
  109. package/src/modules/picking/picking-manager.ts +252 -50
  110. package/src/modules/picking/picking-uniforms.ts +38 -23
  111. package/src/modules/picking/picking.ts +22 -0
  112. package/src/shader-inputs.ts +165 -15
  113. package/src/utils/shader-module-utils.ts +65 -0
  114. package/dist/factories/pipeline-factory.d.ts +0 -39
  115. package/dist/factories/pipeline-factory.d.ts.map +0 -1
  116. package/dist/factories/pipeline-factory.js +0 -216
  117. package/dist/factories/pipeline-factory.js.map +0 -1
  118. package/dist/factories/shader-factory.d.ts +0 -19
  119. package/dist/factories/shader-factory.d.ts.map +0 -1
  120. package/dist/factories/shader-factory.js +0 -83
  121. package/dist/factories/shader-factory.js.map +0 -1
  122. package/dist/types.d.ts +0 -7
  123. package/dist/types.d.ts.map +0 -1
  124. package/dist/types.js +0 -5
  125. package/dist/types.js.map +0 -1
  126. package/src/factories/pipeline-factory.ts +0 -266
  127. package/src/factories/shader-factory.ts +0 -101
  128. package/src/types.ts +0 -11
@@ -37,7 +37,7 @@ export class ShaderInputs {
37
37
  modules, options) {
38
38
  Object.assign(this.options, options);
39
39
  // Extract modules with dependencies
40
- const resolvedModules = getShaderModuleDependencies(Object.values(modules).filter(module => module.dependencies));
40
+ const resolvedModules = getShaderModuleDependencies(Object.values(modules).filter(isShaderInputsModuleWithDependencies));
41
41
  for (const resolvedModule of resolvedModules) {
42
42
  // @ts-ignore
43
43
  modules[resolvedModule.name] = resolvedModule;
@@ -50,6 +50,9 @@ export class ShaderInputs {
50
50
  this.moduleBindings = {};
51
51
  // Initialize the modules
52
52
  for (const [name, module] of Object.entries(modules)) {
53
+ if (!module) {
54
+ continue;
55
+ }
53
56
  this._addModule(module);
54
57
  if (module.name && name !== module.name && !this.options.disableWarnings) {
55
58
  log.warn(`Module name: ${name} vs ${module.name}`)();
@@ -76,8 +79,8 @@ export class ShaderInputs {
76
79
  const oldUniforms = this.moduleUniforms[moduleName];
77
80
  const oldBindings = this.moduleBindings[moduleName];
78
81
  const uniformsAndBindings = module.getUniforms?.(moduleProps, oldUniforms) || moduleProps;
79
- const { uniforms, bindings } = splitUniformsAndBindings(uniformsAndBindings);
80
- this.moduleUniforms[moduleName] = { ...oldUniforms, ...uniforms };
82
+ const { uniforms, bindings } = splitUniformsAndBindings(uniformsAndBindings, module.uniformTypes);
83
+ this.moduleUniforms[moduleName] = mergeModuleUniforms(oldUniforms, uniforms, module.uniformTypes);
81
84
  this.moduleBindings[moduleName] = { ...oldBindings, ...bindings };
82
85
  // this.moduleUniformsChanged ||= moduleName;
83
86
  // console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])
@@ -119,8 +122,85 @@ export class ShaderInputs {
119
122
  _addModule(module) {
120
123
  const moduleName = module.name;
121
124
  // Get default uniforms from module
122
- this.moduleUniforms[moduleName] = module.defaultUniforms || {};
125
+ this.moduleUniforms[moduleName] = mergeModuleUniforms({}, (module.defaultUniforms || {}), module.uniformTypes);
123
126
  this.moduleBindings[moduleName] = {};
124
127
  }
125
128
  }
129
+ function mergeModuleUniforms(currentUniforms = {}, nextUniforms = {}, uniformTypes = {}) {
130
+ const mergedUniforms = { ...currentUniforms };
131
+ for (const [key, value] of Object.entries(nextUniforms)) {
132
+ if (value === undefined) {
133
+ continue;
134
+ }
135
+ mergedUniforms[key] = mergeModuleUniformValue(currentUniforms[key], value, uniformTypes[key]);
136
+ }
137
+ return mergedUniforms;
138
+ }
139
+ function mergeModuleUniformValue(currentValue, nextValue, uniformType) {
140
+ if (!uniformType || typeof uniformType === 'string') {
141
+ return cloneModuleUniformValue(nextValue);
142
+ }
143
+ if (Array.isArray(uniformType)) {
144
+ if (isPackedUniformArrayValue(nextValue) || !Array.isArray(nextValue)) {
145
+ return cloneModuleUniformValue(nextValue);
146
+ }
147
+ const currentArray = Array.isArray(currentValue) && !isPackedUniformArrayValue(currentValue)
148
+ ? [...currentValue]
149
+ : [];
150
+ const mergedArray = currentArray.slice();
151
+ for (let index = 0; index < nextValue.length; index++) {
152
+ const elementValue = nextValue[index];
153
+ if (elementValue === undefined) {
154
+ continue;
155
+ }
156
+ mergedArray[index] = mergeModuleUniformValue(currentArray[index], elementValue, uniformType[0]);
157
+ }
158
+ return mergedArray;
159
+ }
160
+ if (!isPlainUniformObject(nextValue)) {
161
+ return cloneModuleUniformValue(nextValue);
162
+ }
163
+ const uniformStruct = uniformType;
164
+ const currentObject = isPlainUniformObject(currentValue) ? currentValue : {};
165
+ const mergedObject = { ...currentObject };
166
+ for (const [key, value] of Object.entries(nextValue)) {
167
+ if (value === undefined) {
168
+ continue;
169
+ }
170
+ mergedObject[key] = mergeModuleUniformValue(currentObject[key], value, uniformStruct[key]);
171
+ }
172
+ return mergedObject;
173
+ }
174
+ function cloneModuleUniformValue(value) {
175
+ if (ArrayBuffer.isView(value)) {
176
+ return Array.prototype.slice.call(value);
177
+ }
178
+ if (Array.isArray(value)) {
179
+ if (isPackedUniformArrayValue(value)) {
180
+ return value.slice();
181
+ }
182
+ const compositeArray = value;
183
+ return compositeArray.map(element => element === undefined ? undefined : cloneModuleUniformValue(element));
184
+ }
185
+ if (isPlainUniformObject(value)) {
186
+ return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => [
187
+ key,
188
+ nestedValue === undefined ? undefined : cloneModuleUniformValue(nestedValue)
189
+ ]));
190
+ }
191
+ return value;
192
+ }
193
+ function isPackedUniformArrayValue(value) {
194
+ return (ArrayBuffer.isView(value) ||
195
+ (Array.isArray(value) && (value.length === 0 || typeof value[0] === 'number')));
196
+ }
197
+ function isPlainUniformObject(value) {
198
+ return (Boolean(value) &&
199
+ typeof value === 'object' &&
200
+ !Array.isArray(value) &&
201
+ !ArrayBuffer.isView(value));
202
+ }
203
+ function isShaderInputsModuleWithDependencies(module) {
204
+ return Boolean(module?.dependencies);
205
+ }
126
206
  //# sourceMappingURL=shader-inputs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shader-inputs.js","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAClC,2HAA2H;AAC3H,OAAO,EAAC,2BAA2B,EAAe,MAAM,s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WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAC/E,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,KAAc;IAEd,OAAO,CACL,OAAO,CAAC,KAAK,CAAC;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,SAAS,oCAAoC,CAC3C,MAAsC;IAEtC,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ComputeShaderLayout, ShaderLayout } from '@luma.gl/core';
2
+ import type { ShaderModule } from '@luma.gl/shadertools';
3
+ type AnyShaderLayout = ShaderLayout | ComputeShaderLayout;
4
+ export declare function mergeShaderModuleBindingsIntoLayout<TShaderLayout extends AnyShaderLayout>(shaderLayout: TShaderLayout | null | undefined, modules: ShaderModule[]): TShaderLayout | null | undefined;
5
+ export declare function shaderModuleHasUniforms(module: ShaderModule): boolean;
6
+ export {};
7
+ //# sourceMappingURL=shader-module-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader-module-utils.d.ts","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,KAAK,eAAe,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAE1D,wBAAgB,mCAAmC,CAAC,aAAa,SAAS,eAAe,EACvF,YAAY,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EAC9C,OAAO,EAAE,YAAY,EAAE,GACtB,aAAa,GAAG,IAAI,GAAG,SAAS,CA4BlC;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAErE"}
@@ -0,0 +1,46 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export function mergeShaderModuleBindingsIntoLayout(shaderLayout, modules) {
5
+ if (!shaderLayout || !modules.some(module => module.bindingLayout?.length)) {
6
+ return shaderLayout;
7
+ }
8
+ const mergedLayout = {
9
+ ...shaderLayout,
10
+ bindings: shaderLayout.bindings.map(binding => ({ ...binding }))
11
+ };
12
+ if ('attributes' in (shaderLayout || {})) {
13
+ mergedLayout.attributes = shaderLayout?.attributes || [];
14
+ }
15
+ for (const module of modules) {
16
+ for (const bindingLayout of module.bindingLayout || []) {
17
+ for (const relatedBindingName of getRelatedBindingNames(bindingLayout.name)) {
18
+ const binding = mergedLayout.bindings.find(candidate => candidate.name === relatedBindingName);
19
+ if (binding?.group === 0) {
20
+ binding.group = bindingLayout.group;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ return mergedLayout;
26
+ }
27
+ export function shaderModuleHasUniforms(module) {
28
+ return Boolean(module.uniformTypes && !isObjectEmpty(module.uniformTypes));
29
+ }
30
+ /** Returns binding-name aliases that should share the module-declared bind group. */
31
+ function getRelatedBindingNames(bindingName) {
32
+ const bindingNames = new Set([bindingName, `${bindingName}Uniforms`]);
33
+ if (!bindingName.endsWith('Uniforms')) {
34
+ bindingNames.add(`${bindingName}Sampler`);
35
+ }
36
+ return [...bindingNames];
37
+ }
38
+ function isObjectEmpty(obj) {
39
+ // @ts-ignore key is intentionally unused
40
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
+ for (const key in obj) {
42
+ return false;
43
+ }
44
+ return true;
45
+ }
46
+ //# sourceMappingURL=shader-module-utils.js.map
@@ -0,0 +1 @@
1
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B;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,qFAAqF;AACrF,SAAS,sBAAsB,CAAC,WAAmB;IACjD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS,CAAC,WAAW,EAAE,GAAG,WAAW,UAAU,CAAC,CAAC,CAAC;IAE9E,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,yCAAyC;IACzC,6DAA6D;IAC7D,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/engine",
3
- "version": "9.3.0-alpha.6",
3
+ "version": "9.3.0-alpha.9",
4
4
  "description": "3D Engine Components for luma.gl",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,8 +40,8 @@
40
40
  "prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
41
41
  },
42
42
  "peerDependencies": {
43
- "@luma.gl/core": "9.2.0-alpha.6",
44
- "@luma.gl/shadertools": "9.2.0-alpha.6"
43
+ "@luma.gl/core": "9.3.0-alpha.6",
44
+ "@luma.gl/shadertools": "9.3.0-alpha.6"
45
45
  },
46
46
  "dependencies": {
47
47
  "@math.gl/core": "^4.1.0",
@@ -49,5 +49,5 @@
49
49
  "@probe.gl/log": "^4.1.1",
50
50
  "@probe.gl/stats": "^4.1.1"
51
51
  },
52
- "gitHead": "59fda5480c4d0bb3d64545d4621175221f2b6c7c"
52
+ "gitHead": "737b0f752b3f8a6ae920b394d5ca028427275b37"
53
53
  }
@@ -156,6 +156,9 @@ export class AnimationLoop {
156
156
  // Create the WebGL context
157
157
  await this._initDevice();
158
158
  this._initialize();
159
+ if (!this._running) {
160
+ return null;
161
+ }
159
162
 
160
163
  // Note: onIntialize can return a promise (e.g. in case app needs to load resources)
161
164
  await this.props.onInitialize(this._getAnimationProps());
@@ -2,22 +2,28 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {DeviceFeature, ComputePipelineProps, Shader, Binding} from '@luma.gl/core';
6
5
  import {
6
+ type DeviceFeature,
7
+ type ComputePipelineProps,
8
+ type Shader,
9
+ type Binding,
7
10
  Device,
8
11
  Buffer,
9
12
  ComputePipeline,
10
13
  ComputePass,
14
+ PipelineFactory,
15
+ ShaderFactory,
11
16
  UniformStore,
12
17
  log,
13
- getTypedArrayConstructor
18
+ dataTypeDecoder
14
19
  } from '@luma.gl/core';
15
- import type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';
16
- import {ShaderAssembler} from '@luma.gl/shadertools';
17
- import {TypedArray, isNumericArray} from '@math.gl/types';
20
+ import {type ShaderModule, type PlatformInfo, ShaderAssembler} from '@luma.gl/shadertools';
21
+ import {type TypedArray, isNumericArray} from '@math.gl/types';
18
22
  import {ShaderInputs} from '../shader-inputs';
19
- import {PipelineFactory} from '../factories/pipeline-factory';
20
- import {ShaderFactory} from '../factories/shader-factory';
23
+ import {
24
+ mergeShaderModuleBindingsIntoLayout,
25
+ shaderModuleHasUniforms
26
+ } from '../utils/shader-module-utils';
21
27
  import {uid} from '../utils/uid';
22
28
  // import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
23
29
 
@@ -131,11 +137,6 @@ export class Computation {
131
137
  this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
132
138
  this.setShaderInputs(this.shaderInputs);
133
139
 
134
- // Support WGSL shader layout introspection
135
- // TODO - Don't modify props!!
136
- // @ts-expect-error method on WebGPUDevice
137
- this.props.shaderLayout ||= device.getShaderLayout(this.props.source);
138
-
139
140
  // Setup shader assembler
140
141
  const platformInfo = getPlatformInfo(device);
141
142
 
@@ -143,6 +144,9 @@ export class Computation {
143
144
  const modules =
144
145
  (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
145
146
 
147
+ this.props.shaderLayout =
148
+ mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
149
+
146
150
  this.pipelineFactory =
147
151
  props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
148
152
  this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
@@ -156,6 +160,14 @@ export class Computation {
156
160
  this.source = source;
157
161
  // @ts-ignore
158
162
  this._getModuleUniforms = getUniforms;
163
+ const inferredShaderLayout = (
164
+ device as Device & {getShaderLayout?: (source: string) => any}
165
+ ).getShaderLayout?.(this.source);
166
+ this.props.shaderLayout =
167
+ mergeShaderModuleBindingsIntoLayout(
168
+ this.props.shaderLayout || inferredShaderLayout || null,
169
+ modules
170
+ ) || null;
159
171
 
160
172
  // Create the pipeline
161
173
  // @note order is important
@@ -198,7 +210,7 @@ export class Computation {
198
210
  this.pipeline.setBindings(this.bindings);
199
211
  computePass.setPipeline(this.pipeline);
200
212
  // @ts-expect-error
201
- computePass.setBindings([]);
213
+ computePass.setBindings({});
202
214
 
203
215
  computePass.dispatch(x, y, z);
204
216
  } finally {
@@ -230,9 +242,11 @@ export class Computation {
230
242
  this.shaderInputs = shaderInputs;
231
243
  this._uniformStore = new UniformStore(this.shaderInputs.modules);
232
244
  // Create uniform buffer bindings for all modules
233
- for (const moduleName of Object.keys(this.shaderInputs.modules)) {
234
- const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
235
- this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
245
+ for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
246
+ if (shaderModuleHasUniforms(module)) {
247
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
248
+ this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
249
+ }
236
250
  }
237
251
  }
238
252
 
@@ -341,7 +355,7 @@ export class Computation {
341
355
 
342
356
  // TODO - fix typing of luma data types
343
357
  _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string {
344
- const TypedArrayConstructor = getTypedArrayConstructor(dataType);
358
+ const TypedArrayConstructor = dataTypeDecoder.getTypedArrayConstructor(dataType);
345
359
  const typedArray =
346
360
  attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
347
361
  return typedArray.toString();
@@ -1,9 +1,16 @@
1
1
  // luma.gl, MIT license
2
2
  // Copyright (c) vis.gl contributors
3
3
 
4
- import type {TextureProps, SamplerProps, TextureView, Device, TextureFormat} from '@luma.gl/core';
4
+ import type {
5
+ TextureProps,
6
+ SamplerProps,
7
+ TextureView,
8
+ Device,
9
+ TextureFormat,
10
+ TextureReadOptions
11
+ } from '@luma.gl/core';
5
12
 
6
- import {Texture, Sampler, log} from '@luma.gl/core';
13
+ import {Buffer, Texture, Sampler, log} from '@luma.gl/core';
7
14
 
8
15
  // import {loadImageBitmap} from '../application-utils/load-file';
9
16
  import {uid} from '../utils/uid';
@@ -140,7 +147,14 @@ export class DynamicTexture {
140
147
 
141
148
  const propsWithSyncData = await this._loadAllData(originalPropsWithAsyncData);
142
149
  this._checkNotDestroyed();
143
- const subresources = propsWithSyncData.data ? getTextureSubresources(propsWithSyncData) : [];
150
+ const subresources = propsWithSyncData.data
151
+ ? getTextureSubresources({
152
+ ...propsWithSyncData,
153
+ width: originalPropsWithAsyncData.width,
154
+ height: originalPropsWithAsyncData.height,
155
+ format: originalPropsWithAsyncData.format
156
+ })
157
+ : [];
144
158
  const userProvidedFormat =
145
159
  'format' in originalPropsWithAsyncData && originalPropsWithAsyncData.format !== undefined;
146
160
  const userProvidedUsage =
@@ -233,7 +247,6 @@ export class DynamicTexture {
233
247
  } catch (e) {
234
248
  const err = e instanceof Error ? e : new Error(String(e));
235
249
  this.rejectReady(err);
236
- throw err;
237
250
  }
238
251
  }
239
252
 
@@ -265,6 +278,59 @@ export class DynamicTexture {
265
278
  this._sampler = s;
266
279
  }
267
280
 
281
+ /**
282
+ * Copies texture contents into a GPU buffer and waits until the copy is complete.
283
+ * The caller owns the returned buffer and must destroy it when finished.
284
+ */
285
+ async readBuffer(options: TextureReadOptions = {}): Promise<Buffer> {
286
+ if (!this.isReady) {
287
+ await this.ready;
288
+ }
289
+
290
+ const width = options.width ?? this.texture.width;
291
+ const height = options.height ?? this.texture.height;
292
+ const depthOrArrayLayers = options.depthOrArrayLayers ?? this.texture.depth;
293
+ const layout = this.texture.computeMemoryLayout({width, height, depthOrArrayLayers});
294
+
295
+ const buffer = this.device.createBuffer({
296
+ byteLength: layout.byteLength,
297
+ usage: Buffer.COPY_DST | Buffer.MAP_READ
298
+ });
299
+
300
+ this.texture.readBuffer(
301
+ {
302
+ ...options,
303
+ width,
304
+ height,
305
+ depthOrArrayLayers
306
+ },
307
+ buffer
308
+ );
309
+
310
+ const fence = this.device.createFence();
311
+ await fence.signaled;
312
+ fence.destroy();
313
+
314
+ return buffer;
315
+ }
316
+
317
+ /** Reads texture contents back to CPU memory. */
318
+ async readAsync(options: TextureReadOptions = {}): Promise<ArrayBuffer> {
319
+ if (!this.isReady) {
320
+ await this.ready;
321
+ }
322
+
323
+ const width = options.width ?? this.texture.width;
324
+ const height = options.height ?? this.texture.height;
325
+ const depthOrArrayLayers = options.depthOrArrayLayers ?? this.texture.depth;
326
+ const layout = this.texture.computeMemoryLayout({width, height, depthOrArrayLayers});
327
+
328
+ const buffer = await this.readBuffer(options);
329
+ const data = await buffer.readAsync(0, layout.byteLength);
330
+ buffer.destroy();
331
+ return data.buffer;
332
+ }
333
+
268
334
  /**
269
335
  * Resize by cloning the underlying immutable texture.
270
336
  * Does not copy contents; caller may need to re-upload and/or regenerate mips.
@@ -430,16 +496,22 @@ type TextureSubresourceAnalysis = {
430
496
  };
431
497
 
432
498
  // Flatten dimension-specific texture data into one list of uploadable subresources.
433
- function getTextureSubresources(props: TextureDataProps): TextureSubresource[] {
499
+ function getTextureSubresources(
500
+ props: TextureDataProps & Partial<Pick<TextureProps, 'width' | 'height' | 'format'>>
501
+ ): TextureSubresource[] {
434
502
  if (!props.data) {
435
503
  return [];
436
504
  }
437
505
 
506
+ const baseLevelSize =
507
+ props.width && props.height ? {width: props.width, height: props.height} : undefined;
508
+ const textureFormat = 'format' in props ? props.format : undefined;
509
+
438
510
  switch (props.dimension) {
439
511
  case '1d':
440
512
  return getTexture1DSubresources(props.data);
441
513
  case '2d':
442
- return getTexture2DSubresources(0, props.data);
514
+ return getTexture2DSubresources(0, props.data, baseLevelSize, textureFormat);
443
515
  case '3d':
444
516
  return getTexture3DSubresources(props.data);
445
517
  case '2d-array':
@@ -618,7 +690,7 @@ async function awaitAllPromises(x: any): Promise<any> {
618
690
  }
619
691
  if (x && typeof x === 'object' && x.constructor === Object) {
620
692
  const object: Record<string, any> = x;
621
- const values = await Promise.all(Object.values(object));
693
+ const values = await Promise.all(Object.values(object).map(awaitAllPromises));
622
694
  const keys = Object.keys(object);
623
695
  const resolvedObject: Record<string, any> = {};
624
696
  for (let i = 0; i < keys.length; i++) {
@@ -176,8 +176,8 @@ function getTextureMipLevelSize(data: TextureMipLevelData): {width: number; heig
176
176
  throw new Error('Unsupported mip-level data');
177
177
  }
178
178
 
179
- /** Type guard: is a mip-level `TextureImageData` (vs ExternalImage) */
180
- function isTextureImageData(data: TextureMipLevelData): data is TextureImageData {
179
+ /** Type guard: is a mip-level `TextureImageData` (vs ExternalImage or bare typed array) */
180
+ function isTextureImageData(data: unknown): data is TextureImageData {
181
181
  return (
182
182
  typeof data === 'object' &&
183
183
  data !== null &&
@@ -187,6 +187,10 @@ function isTextureImageData(data: TextureMipLevelData): data is TextureImageData
187
187
  );
188
188
  }
189
189
 
190
+ function isTypedArrayMipLevelData(data: unknown): data is TypedArray {
191
+ return ArrayBuffer.isView(data);
192
+ }
193
+
190
194
  export function resolveTextureImageFormat(data: TextureImageData): TextureFormat | undefined {
191
195
  const {textureFormat, format} = data;
192
196
  if (textureFormat && format && textureFormat !== format) {
@@ -235,14 +239,18 @@ export function getTexture1DSubresources(data: Texture1DData): TextureSubresourc
235
239
  }
236
240
 
237
241
  /** Normalize 2D layer payload into an array of mip-level items */
238
- function _normalizeTexture2DData(data: Texture2DData): (TextureImageData | ExternalImage)[] {
242
+ function _normalizeTexture2DData(
243
+ data: Texture2DData
244
+ ): (TextureImageData | ExternalImage | TypedArray)[] {
239
245
  return Array.isArray(data) ? data : [data];
240
246
  }
241
247
 
242
248
  /** Experimental: Set multiple mip levels (2D), optionally at `z` (depth/array index) */
243
249
  export function getTexture2DSubresources(
244
250
  slice: number,
245
- lodData: Texture2DData
251
+ lodData: Texture2DData,
252
+ baseLevelSize?: {width: number; height: number},
253
+ textureFormat?: TextureFormat
246
254
  ): TextureSubresource[] {
247
255
  const lodArray = _normalizeTexture2DData(lodData);
248
256
  const z = slice;
@@ -266,6 +274,19 @@ export function getTexture2DSubresources(
266
274
  z,
267
275
  mipLevel
268
276
  });
277
+ } else if (isTypedArrayMipLevelData(imageData) && baseLevelSize) {
278
+ subresources.push({
279
+ type: 'texture-data',
280
+ data: {
281
+ data: imageData,
282
+ width: Math.max(1, baseLevelSize.width >> mipLevel),
283
+ height: Math.max(1, baseLevelSize.height >> mipLevel),
284
+ ...(textureFormat ? {format: textureFormat} : {})
285
+ },
286
+ textureFormat,
287
+ z,
288
+ mipLevel
289
+ });
269
290
  } else {
270
291
  throw new Error('Unsupported 2D mip-level payload');
271
292
  }
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';
6
- import {Device, Buffer, getVertexFormatFromAttribute} from '@luma.gl/core';
6
+ import {Device, Buffer, vertexFormatDecoder} from '@luma.gl/core';
7
7
  import type {Geometry} from '../geometry/geometry';
8
8
  import {uid} from '../utils/uid';
9
9
 
@@ -127,8 +127,13 @@ export function getAttributeBuffersFromGeometry(
127
127
  id: `${attributeName}-buffer`
128
128
  });
129
129
  const {value, size, normalized} = attribute;
130
- // @ts-expect-error
131
- bufferLayout.push({name, format: getVertexFormatFromAttribute(value, size, normalized)});
130
+ if (size === undefined) {
131
+ throw new Error(`Attribute ${attributeName} is missing a size`);
132
+ }
133
+ bufferLayout.push({
134
+ name,
135
+ format: vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized)
136
+ });
132
137
  }
133
138
  }
134
139
 
package/src/index.ts CHANGED
@@ -19,6 +19,10 @@ export {makeAnimationLoop} from './animation-loop/make-animation-loop';
19
19
 
20
20
  export type {ModelProps} from './model/model';
21
21
  export {Model} from './model/model';
22
+ export type {MaterialProps} from './material/material';
23
+ export {Material} from './material/material';
24
+ export type {MaterialFactoryProps} from './material/material-factory';
25
+ export {MaterialFactory} from './material/material-factory';
22
26
 
23
27
  // Transforms
24
28
  export type {BufferTransformProps} from './compute/buffer-transform';
@@ -26,14 +30,20 @@ export {BufferTransform} from './compute/buffer-transform';
26
30
  export type {TextureTransformProps} from './compute/texture-transform';
27
31
  export {TextureTransform} from './compute/texture-transform';
28
32
 
29
- export {PipelineFactory} from './factories/pipeline-factory';
30
- export {ShaderFactory} from './factories/shader-factory';
31
-
32
33
  // Models
33
34
  export type {ClipSpaceProps} from './models/clip-space';
34
35
  export {ClipSpace} from './models/clip-space';
35
36
  export type {BackgroundTextureModelProps} from './models/billboard-texture-model';
36
37
  export {BackgroundTextureModel} from './models/billboard-texture-model';
38
+ export type {
39
+ BaseLightModelProps,
40
+ PointLightModelProps,
41
+ SpotLightModelProps,
42
+ DirectionalLightModelProps
43
+ } from './models/light-model-utils';
44
+ export {PointLightModel} from './models/point-light-model';
45
+ export {SpotLightModel} from './models/spot-light-model';
46
+ export {DirectionalLightModel} from './models/directional-light-model';
37
47
 
38
48
  // Scenegraph Core nodes
39
49
  export {ScenegraphNode} from './scenegraph/scenegraph-node';
@@ -94,7 +104,21 @@ export type {
94
104
  export type {DynamicTextureProps} from './dynamic-texture/dynamic-texture';
95
105
  export {DynamicTexture} from './dynamic-texture/dynamic-texture';
96
106
 
97
- export {PickingManager} from './modules/picking/picking-manager';
107
+ export type {
108
+ PickInfo,
109
+ PickingMode,
110
+ ResolvedPickingMode,
111
+ PickingBackend,
112
+ PickingManagerProps,
113
+ ResolvedPickingBackend
114
+ } from './modules/picking/picking-manager';
115
+ export {
116
+ PickingManager,
117
+ supportsIndexPicking,
118
+ resolvePickingMode,
119
+ resolvePickingBackend
120
+ } from './modules/picking/picking-manager';
121
+ export {picking} from './modules/picking/picking';
98
122
  export {picking as indexPicking} from './modules/picking/index-picking';
99
123
  export {picking as colorPicking} from './modules/picking/color-picking';
100
124
 
@@ -106,6 +130,7 @@ export {
106
130
  // DEPRECATED
107
131
 
108
132
  export {LegacyPickingManager} from './modules/picking/legacy-picking-manager';
133
+ export {legacyColorPicking} from './modules/picking/legacy-color-picking';
109
134
 
110
135
  import {DynamicTexture, type DynamicTextureProps} from './dynamic-texture/dynamic-texture';
111
136
  /** @deprecated use DynamicTexture */