@luma.gl/engine 9.2.6 → 9.3.0-alpha.11

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 (198) hide show
  1. package/dist/animation-loop/animation-loop.d.ts +11 -5
  2. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  3. package/dist/animation-loop/animation-loop.js +83 -47
  4. package/dist/animation-loop/animation-loop.js.map +1 -1
  5. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  6. package/dist/animation-loop/make-animation-loop.js +8 -1
  7. package/dist/animation-loop/make-animation-loop.js.map +1 -1
  8. package/dist/animation-loop/request-animation-frame.d.ts.map +1 -1
  9. package/dist/animation-loop/request-animation-frame.js +23 -6
  10. package/dist/animation-loop/request-animation-frame.js.map +1 -1
  11. package/dist/compute/computation.d.ts +3 -7
  12. package/dist/compute/computation.d.ts.map +1 -1
  13. package/dist/compute/computation.js +16 -13
  14. package/dist/compute/computation.js.map +1 -1
  15. package/dist/compute/swap.d.ts +2 -0
  16. package/dist/compute/swap.d.ts.map +1 -1
  17. package/dist/compute/swap.js +10 -5
  18. package/dist/compute/swap.js.map +1 -1
  19. package/dist/debug/debug-framebuffer.d.ts +9 -4
  20. package/dist/debug/debug-framebuffer.d.ts.map +1 -1
  21. package/dist/debug/debug-framebuffer.js +91 -45
  22. package/dist/debug/debug-framebuffer.js.map +1 -1
  23. package/dist/dist.dev.js +2767 -1344
  24. package/dist/dist.min.js +326 -211
  25. package/dist/dynamic-texture/dynamic-texture.d.ts +102 -0
  26. package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -0
  27. package/dist/dynamic-texture/dynamic-texture.js +558 -0
  28. package/dist/dynamic-texture/dynamic-texture.js.map +1 -0
  29. package/dist/dynamic-texture/texture-data.d.ts +144 -0
  30. package/dist/dynamic-texture/texture-data.d.ts.map +1 -0
  31. package/dist/dynamic-texture/texture-data.js +208 -0
  32. package/dist/dynamic-texture/texture-data.js.map +1 -0
  33. package/dist/geometries/cone-geometry.d.ts +3 -1
  34. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  35. package/dist/geometries/cone-geometry.js.map +1 -1
  36. package/dist/geometries/cube-geometry.js +7 -7
  37. package/dist/geometries/cube-geometry.js.map +1 -1
  38. package/dist/geometries/cylinder-geometry.d.ts +2 -1
  39. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  40. package/dist/geometries/cylinder-geometry.js.map +1 -1
  41. package/dist/geometries/ico-sphere-geometry.js +3 -1
  42. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  43. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  44. package/dist/geometry/gpu-geometry.js +11 -3
  45. package/dist/geometry/gpu-geometry.js.map +1 -1
  46. package/dist/index.cjs +2620 -1267
  47. package/dist/index.cjs.map +4 -4
  48. package/dist/index.d.ts +20 -6
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +12 -4
  51. package/dist/index.js.map +1 -1
  52. package/dist/material/material-factory.d.ts +73 -0
  53. package/dist/material/material-factory.d.ts.map +1 -0
  54. package/dist/material/material-factory.js +111 -0
  55. package/dist/material/material-factory.js.map +1 -0
  56. package/dist/material/material.d.ts +84 -0
  57. package/dist/material/material.d.ts.map +1 -0
  58. package/dist/material/material.js +176 -0
  59. package/dist/material/material.js.map +1 -0
  60. package/dist/model/model.d.ts +47 -16
  61. package/dist/model/model.d.ts.map +1 -1
  62. package/dist/model/model.js +148 -71
  63. package/dist/model/model.js.map +1 -1
  64. package/dist/model/split-uniforms-and-bindings.d.ts +4 -3
  65. package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
  66. package/dist/model/split-uniforms-and-bindings.js +2 -2
  67. package/dist/model/split-uniforms-and-bindings.js.map +1 -1
  68. package/dist/models/billboard-texture-model.d.ts +8 -5
  69. package/dist/models/billboard-texture-model.d.ts.map +1 -1
  70. package/dist/models/billboard-texture-model.js +79 -25
  71. package/dist/models/billboard-texture-model.js.map +1 -1
  72. package/dist/models/billboard-texture-module.d.ts +1 -1
  73. package/dist/models/billboard-texture-module.js +1 -1
  74. package/dist/models/clip-space.js +7 -7
  75. package/dist/models/directional-light-model.d.ts +7 -0
  76. package/dist/models/directional-light-model.d.ts.map +1 -0
  77. package/dist/models/directional-light-model.js +23 -0
  78. package/dist/models/directional-light-model.js.map +1 -0
  79. package/dist/models/light-model-utils.d.ts +69 -0
  80. package/dist/models/light-model-utils.d.ts.map +1 -0
  81. package/dist/models/light-model-utils.js +395 -0
  82. package/dist/models/light-model-utils.js.map +1 -0
  83. package/dist/models/point-light-model.d.ts +7 -0
  84. package/dist/models/point-light-model.d.ts.map +1 -0
  85. package/dist/models/point-light-model.js +22 -0
  86. package/dist/models/point-light-model.js.map +1 -0
  87. package/dist/models/spot-light-model.d.ts +7 -0
  88. package/dist/models/spot-light-model.d.ts.map +1 -0
  89. package/dist/models/spot-light-model.js +23 -0
  90. package/dist/models/spot-light-model.js.map +1 -0
  91. package/dist/modules/picking/color-picking.d.ts +5 -9
  92. package/dist/modules/picking/color-picking.d.ts.map +1 -1
  93. package/dist/modules/picking/color-picking.js +122 -115
  94. package/dist/modules/picking/color-picking.js.map +1 -1
  95. package/dist/modules/picking/index-picking.d.ts +4 -4
  96. package/dist/modules/picking/index-picking.d.ts.map +1 -1
  97. package/dist/modules/picking/index-picking.js +36 -16
  98. package/dist/modules/picking/index-picking.js.map +1 -1
  99. package/dist/modules/picking/legacy-color-picking.d.ts +26 -0
  100. package/dist/modules/picking/legacy-color-picking.d.ts.map +1 -0
  101. package/dist/modules/picking/legacy-color-picking.js +7 -0
  102. package/dist/modules/picking/legacy-color-picking.js.map +1 -0
  103. package/dist/modules/picking/picking-manager.d.ts +29 -3
  104. package/dist/modules/picking/picking-manager.d.ts.map +1 -1
  105. package/dist/modules/picking/picking-manager.js +188 -41
  106. package/dist/modules/picking/picking-manager.js.map +1 -1
  107. package/dist/modules/picking/picking-uniforms.d.ts +13 -12
  108. package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
  109. package/dist/modules/picking/picking-uniforms.js +27 -14
  110. package/dist/modules/picking/picking-uniforms.js.map +1 -1
  111. package/dist/modules/picking/picking.d.ts +25 -0
  112. package/dist/modules/picking/picking.d.ts.map +1 -0
  113. package/dist/modules/picking/picking.js +18 -0
  114. package/dist/modules/picking/picking.js.map +1 -0
  115. package/dist/passes/get-fragment-shader.js +12 -27
  116. package/dist/passes/get-fragment-shader.js.map +1 -1
  117. package/dist/passes/shader-pass-renderer.d.ts +5 -7
  118. package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
  119. package/dist/passes/shader-pass-renderer.js +16 -42
  120. package/dist/passes/shader-pass-renderer.js.map +1 -1
  121. package/dist/scenegraph/group-node.d.ts +5 -0
  122. package/dist/scenegraph/group-node.d.ts.map +1 -1
  123. package/dist/scenegraph/group-node.js +12 -0
  124. package/dist/scenegraph/group-node.js.map +1 -1
  125. package/dist/scenegraph/model-node.d.ts +2 -2
  126. package/dist/scenegraph/model-node.d.ts.map +1 -1
  127. package/dist/scenegraph/model-node.js.map +1 -1
  128. package/dist/scenegraph/scenegraph-node.d.ts +1 -1
  129. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  130. package/dist/scenegraph/scenegraph-node.js +23 -15
  131. package/dist/scenegraph/scenegraph-node.js.map +1 -1
  132. package/dist/shader-inputs.d.ts +9 -7
  133. package/dist/shader-inputs.d.ts.map +1 -1
  134. package/dist/shader-inputs.js +90 -13
  135. package/dist/shader-inputs.js.map +1 -1
  136. package/dist/utils/buffer-layout-order.d.ts.map +1 -1
  137. package/dist/utils/buffer-layout-order.js +12 -2
  138. package/dist/utils/buffer-layout-order.js.map +1 -1
  139. package/dist/utils/shader-module-utils.d.ts +7 -0
  140. package/dist/utils/shader-module-utils.d.ts.map +1 -0
  141. package/dist/utils/shader-module-utils.js +46 -0
  142. package/dist/utils/shader-module-utils.js.map +1 -0
  143. package/package.json +6 -6
  144. package/src/animation-loop/animation-loop.ts +89 -50
  145. package/src/animation-loop/make-animation-loop.ts +14 -5
  146. package/src/animation-loop/request-animation-frame.ts +32 -6
  147. package/src/compute/computation.ts +32 -17
  148. package/src/compute/swap.ts +13 -7
  149. package/src/debug/debug-framebuffer.ts +139 -61
  150. package/src/dynamic-texture/dynamic-texture.ts +730 -0
  151. package/src/dynamic-texture/texture-data.ts +336 -0
  152. package/src/{async-texture/texture-setters.ts.disabled → dynamic-texture/texture-data.ts.disabled} +1 -1
  153. package/src/geometries/cone-geometry.ts +6 -1
  154. package/src/geometries/cube-geometry.ts +7 -7
  155. package/src/geometries/cylinder-geometry.ts +5 -1
  156. package/src/geometries/ico-sphere-geometry.ts +3 -1
  157. package/src/geometry/gpu-geometry.ts +11 -3
  158. package/src/index.ts +38 -8
  159. package/src/material/material-factory.ts +157 -0
  160. package/src/material/material.ts +254 -0
  161. package/src/model/model.ts +196 -93
  162. package/src/model/split-uniforms-and-bindings.ts +8 -6
  163. package/src/models/billboard-texture-model.ts +90 -29
  164. package/src/models/billboard-texture-module.ts +1 -1
  165. package/src/models/clip-space.ts +7 -7
  166. package/src/models/directional-light-model.ts +32 -0
  167. package/src/models/light-model-utils.ts +587 -0
  168. package/src/models/point-light-model.ts +31 -0
  169. package/src/models/spot-light-model.ts +32 -0
  170. package/src/modules/picking/color-picking.ts +123 -122
  171. package/src/modules/picking/index-picking.ts +36 -16
  172. package/src/modules/picking/legacy-color-picking.ts +8 -0
  173. package/src/modules/picking/picking-manager.ts +252 -50
  174. package/src/modules/picking/picking-uniforms.ts +39 -24
  175. package/src/modules/picking/picking.ts +22 -0
  176. package/src/passes/get-fragment-shader.ts +12 -27
  177. package/src/passes/shader-pass-renderer.ts +25 -48
  178. package/src/scenegraph/group-node.ts +16 -0
  179. package/src/scenegraph/model-node.ts +2 -2
  180. package/src/scenegraph/scenegraph-node.ts +27 -16
  181. package/src/shader-inputs.ts +167 -26
  182. package/src/utils/buffer-layout-order.ts +18 -2
  183. package/src/utils/shader-module-utils.ts +65 -0
  184. package/dist/async-texture/async-texture.d.ts +0 -166
  185. package/dist/async-texture/async-texture.d.ts.map +0 -1
  186. package/dist/async-texture/async-texture.js +0 -386
  187. package/dist/async-texture/async-texture.js.map +0 -1
  188. package/dist/factories/pipeline-factory.d.ts +0 -37
  189. package/dist/factories/pipeline-factory.d.ts.map +0 -1
  190. package/dist/factories/pipeline-factory.js +0 -181
  191. package/dist/factories/pipeline-factory.js.map +0 -1
  192. package/dist/factories/shader-factory.d.ts +0 -22
  193. package/dist/factories/shader-factory.d.ts.map +0 -1
  194. package/dist/factories/shader-factory.js +0 -88
  195. package/dist/factories/shader-factory.js.map +0 -1
  196. package/src/async-texture/async-texture.ts +0 -551
  197. package/src/factories/pipeline-factory.ts +0 -224
  198. package/src/factories/shader-factory.ts +0 -103
@@ -1,14 +1,12 @@
1
- import type { TypedArray } from '@math.gl/types';
2
- import type { RenderPipelineProps, RenderPipelineParameters, BufferLayout, VertexArray, TransformFeedback, AttributeInfo, Binding, PrimitiveTopology } from '@luma.gl/core';
3
- import { Device, Buffer, RenderPipeline, RenderPass, UniformStore } from '@luma.gl/core';
4
- import type { ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
1
+ import { type TypedArray } from '@math.gl/types';
2
+ import { type RenderPipelineProps, type RenderPipelineParameters, type BufferLayout, type VertexArray, type TransformFeedback, type AttributeInfo, type Binding, type BindingsByGroup, type PrimitiveTopology, Device, Buffer, RenderPipeline, RenderPass, PipelineFactory, ShaderFactory, UniformStore } from '@luma.gl/core';
3
+ import type { ShaderBindingDebugRow, ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
5
4
  import { ShaderAssembler } from '@luma.gl/shadertools';
6
5
  import type { Geometry } from "../geometry/geometry.js";
7
6
  import { GPUGeometry } from "../geometry/gpu-geometry.js";
8
- import { PipelineFactory } from "../factories/pipeline-factory.js";
9
- import { ShaderFactory } from "../factories/shader-factory.js";
10
7
  import { ShaderInputs } from "../shader-inputs.js";
11
- import { AsyncTexture } from "../async-texture/async-texture.js";
8
+ import { DynamicTexture } from "../dynamic-texture/dynamic-texture.js";
9
+ import { Material } from "../material/material.js";
12
10
  export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindings'> & {
13
11
  source?: string;
14
12
  vs?: string | null;
@@ -19,8 +17,12 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindings'> & {
19
17
  defines?: Record<string, boolean>;
20
18
  /** Shader inputs, used to generated uniform buffers and bindings */
21
19
  shaderInputs?: ShaderInputs;
20
+ /** Material-owned group-3 bindings */
21
+ material?: Material;
22
22
  /** Bindings */
23
- bindings?: Record<string, Binding | AsyncTexture>;
23
+ bindings?: Record<string, Binding | DynamicTexture>;
24
+ /** WebGL-only uniforms */
25
+ uniforms?: Record<string, unknown>;
24
26
  /** Parameters that are built into the pipeline */
25
27
  parameters?: RenderPipelineParameters;
26
28
  /** Geometry */
@@ -51,22 +53,37 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindings'> & {
51
53
  shaderAssembler?: ShaderAssembler;
52
54
  };
53
55
  /**
54
- * v9 Model API
55
- * A model
56
- * - automatically reuses pipelines (programs) when possible
57
- * - automatically rebuilds pipelines if necessary to accommodate changed settings
58
- * shadertools integration
59
- * - accepts modules and performs shader transpilation
56
+ * High level draw API for luma.gl.
57
+ *
58
+ * A `Model` encapsulates shaders, geometry attributes, bindings and render
59
+ * pipeline state into a single object. It automatically reuses and rebuilds
60
+ * pipelines as render parameters change and exposes convenient hooks for
61
+ * updating uniforms and attributes.
62
+ *
63
+ * Features:
64
+ * - Reuses and lazily recompiles {@link RenderPipeline | pipelines} as needed.
65
+ * - Integrates with `@luma.gl/shadertools` to assemble GLSL or WGSL from shader modules.
66
+ * - Manages geometry attributes and buffer bindings.
67
+ * - Accepts textures, samplers and uniform buffers as bindings, including `DynamicTexture`.
68
+ * - Provides detailed debug logging and optional shader source inspection.
60
69
  */
61
70
  export declare class Model {
62
71
  static defaultProps: Required<ModelProps>;
72
+ /** Device that created this model */
63
73
  readonly device: Device;
74
+ /** Application provided identifier */
64
75
  readonly id: string;
76
+ /** WGSL shader source when using unified shader */
65
77
  readonly source: string;
78
+ /** GLSL vertex shader source */
66
79
  readonly vs: string;
80
+ /** GLSL fragment shader source */
67
81
  readonly fs: string;
82
+ /** Factory used to create render pipelines */
68
83
  readonly pipelineFactory: PipelineFactory;
84
+ /** Factory used to create shaders */
69
85
  readonly shaderFactory: ShaderFactory;
86
+ /** User-supplied per-model data */
70
87
  userData: {
71
88
  [key: string]: any;
72
89
  };
@@ -89,7 +106,7 @@ export declare class Model {
89
106
  /** Constant-valued attributes */
90
107
  constantAttributes: Record<string, TypedArray>;
91
108
  /** Bindings (textures, samplers, uniform buffers) */
92
- bindings: Record<string, Binding | AsyncTexture>;
109
+ bindings: Record<string, Binding | DynamicTexture>;
93
110
  /**
94
111
  * VertexArray
95
112
  * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
@@ -102,6 +119,7 @@ export declare class Model {
102
119
  pipeline: RenderPipeline;
103
120
  /** ShaderInputs instance */
104
121
  shaderInputs: ShaderInputs;
122
+ material: Material | null;
105
123
  _uniformStore: UniformStore;
106
124
  _attributeInfos: Record<string, AttributeInfo>;
107
125
  _gpuGeometry: GPUGeometry | null;
@@ -111,6 +129,7 @@ export declare class Model {
111
129
  private _destroyed;
112
130
  /** "Time" of last draw. Monotonically increasing timestamp */
113
131
  _lastDrawTimestamp: number;
132
+ private _bindingTable;
114
133
  get [Symbol.toStringTag](): string;
115
134
  toString(): string;
116
135
  constructor(device: Device, props: ModelProps);
@@ -119,7 +138,15 @@ export declare class Model {
119
138
  needsRedraw(): false | string;
120
139
  /** Mark the model as needing a redraw */
121
140
  setNeedsRedraw(reason: string): void;
141
+ /** Returns WGSL binding debug rows for the assembled shader. Returns an empty array for GLSL models. */
142
+ getBindingDebugTable(): readonly ShaderBindingDebugRow[];
143
+ /** Update uniforms and pipeline state prior to drawing. */
122
144
  predraw(): void;
145
+ /**
146
+ * Issue one draw call.
147
+ * @param renderPass - render pass to draw into
148
+ * @returns `true` if the draw call was executed, `false` if resources were not ready.
149
+ */
123
150
  draw(renderPass: RenderPass): boolean;
124
151
  /**
125
152
  * Updates the optional geometry
@@ -155,12 +182,13 @@ export declare class Model {
155
182
  setVertexCount(vertexCount: number): void;
156
183
  /** Set the shader inputs */
157
184
  setShaderInputs(shaderInputs: ShaderInputs): void;
185
+ setMaterial(material: Material | null): void;
158
186
  /** Update uniform buffers from the model's shader inputs */
159
187
  updateShaderInputs(): void;
160
188
  /**
161
189
  * Sets bindings (textures, samplers, uniform buffers)
162
190
  */
163
- setBindings(bindings: Record<string, Binding | AsyncTexture>): void;
191
+ setBindings(bindings: Record<string, Binding | DynamicTexture>): void;
164
192
  /**
165
193
  * Updates optional transform feedback. WebGL only.
166
194
  */
@@ -192,6 +220,8 @@ export declare class Model {
192
220
  _areBindingsLoading(): string | false;
193
221
  /** Extracts texture view from loaded async textures. Returns null if any textures have not yet been loaded. */
194
222
  _getBindings(): Record<string, Binding>;
223
+ _getBindGroups(): BindingsByGroup;
224
+ _getBindGroupCacheKeys(): Partial<Record<number, object>>;
195
225
  /** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
196
226
  _getBindingsUpdateTimestamp(): number;
197
227
  /**
@@ -213,6 +243,7 @@ export declare class Model {
213
243
  _logFramebuffer(renderPass: RenderPass): void;
214
244
  _getAttributeDebugTable(): Record<string, Record<string, unknown>>;
215
245
  _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string;
246
+ private _getNonMaterialBindings;
216
247
  }
217
248
  /** Create a shadertools platform info from the Device */
218
249
  export declare function getPlatformInfo(device: Device): PlatformInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,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AAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM;IAOjF,OAAO,CAAC,uBAAuB;CAehC;AAID,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS5D"}
@@ -1,28 +1,35 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { Buffer, Texture, TextureView, Sampler, RenderPipeline, UniformStore, log, getTypedArrayConstructor, getAttributeInfosFromLayouts } from '@luma.gl/core';
5
- import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
4
+ import { Buffer, Texture, TextureView, Sampler, RenderPipeline, PipelineFactory, ShaderFactory, UniformStore, log, dataTypeDecoder, getAttributeInfosFromLayouts, normalizeBindingsByGroup } from '@luma.gl/core';
5
+ import { ShaderAssembler } from '@luma.gl/shadertools';
6
6
  import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
7
- import { PipelineFactory } from "../factories/pipeline-factory.js";
8
- import { ShaderFactory } from "../factories/shader-factory.js";
9
7
  import { getDebugTableForShaderLayout } from "../debug/debug-shader-layout.js";
10
8
  import { debugFramebuffer } from "../debug/debug-framebuffer.js";
11
9
  import { deepEqual } from "../utils/deep-equal.js";
12
10
  import { BufferLayoutHelper } from "../utils/buffer-layout-helper.js";
13
11
  import { sortedBufferLayoutByShaderSourceLocations } from "../utils/buffer-layout-order.js";
12
+ import { mergeShaderModuleBindingsIntoLayout, shaderModuleHasUniforms } from "../utils/shader-module-utils.js";
14
13
  import { uid } from "../utils/uid.js";
15
14
  import { ShaderInputs } from "../shader-inputs.js";
16
- import { AsyncTexture } from "../async-texture/async-texture.js";
15
+ import { DynamicTexture } from "../dynamic-texture/dynamic-texture.js";
17
16
  const LOG_DRAW_PRIORITY = 2;
18
17
  const LOG_DRAW_TIMEOUT = 10000;
18
+ const PIPELINE_INITIALIZATION_FAILED = 'render pipeline initialization failed';
19
19
  /**
20
- * v9 Model API
21
- * A model
22
- * - automatically reuses pipelines (programs) when possible
23
- * - automatically rebuilds pipelines if necessary to accommodate changed settings
24
- * shadertools integration
25
- * - accepts modules and performs shader transpilation
20
+ * High level draw API for luma.gl.
21
+ *
22
+ * A `Model` encapsulates shaders, geometry attributes, bindings and render
23
+ * pipeline state into a single object. It automatically reuses and rebuilds
24
+ * pipelines as render parameters change and exposes convenient hooks for
25
+ * updating uniforms and attributes.
26
+ *
27
+ * Features:
28
+ * - Reuses and lazily recompiles {@link RenderPipeline | pipelines} as needed.
29
+ * - Integrates with `@luma.gl/shadertools` to assemble GLSL or WGSL from shader modules.
30
+ * - Manages geometry attributes and buffer bindings.
31
+ * - Accepts textures, samplers and uniform buffers as bindings, including `DynamicTexture`.
32
+ * - Provides detailed debug logging and optional shader source inspection.
26
33
  */
27
34
  export class Model {
28
35
  static defaultProps = {
@@ -39,11 +46,14 @@ export class Model {
39
46
  indexBuffer: null,
40
47
  attributes: {},
41
48
  constantAttributes: {},
49
+ bindings: {},
50
+ uniforms: {},
42
51
  varyings: [],
43
52
  isInstanced: undefined,
44
53
  instanceCount: 0,
45
54
  vertexCount: 0,
46
55
  shaderInputs: undefined,
56
+ material: undefined,
47
57
  pipelineFactory: undefined,
48
58
  shaderFactory: undefined,
49
59
  transformFeedback: undefined,
@@ -51,16 +61,24 @@ export class Model {
51
61
  debugShaders: undefined,
52
62
  disableWarnings: undefined
53
63
  };
64
+ /** Device that created this model */
54
65
  device;
66
+ /** Application provided identifier */
55
67
  id;
68
+ /** WGSL shader source when using unified shader */
56
69
  // @ts-expect-error assigned in function called from constructor
57
70
  source;
71
+ /** GLSL vertex shader source */
58
72
  // @ts-expect-error assigned in function called from constructor
59
73
  vs;
74
+ /** GLSL fragment shader source */
60
75
  // @ts-expect-error assigned in function called from constructor
61
76
  fs;
77
+ /** Factory used to create render pipelines */
62
78
  pipelineFactory;
79
+ /** Factory used to create shaders */
63
80
  shaderFactory;
81
+ /** User-supplied per-model data */
64
82
  userData = {};
65
83
  // Fixed properties (change can trigger pipeline rebuild)
66
84
  /** The render pipeline GPU parameters, depth testing etc */
@@ -97,6 +115,7 @@ export class Model {
97
115
  /** ShaderInputs instance */
98
116
  // @ts-expect-error Assigned in function called by constructor
99
117
  shaderInputs;
118
+ material = null;
100
119
  // @ts-expect-error Assigned in function called by constructor
101
120
  _uniformStore;
102
121
  _attributeInfos = {};
@@ -107,6 +126,7 @@ export class Model {
107
126
  _destroyed = false;
108
127
  /** "Time" of last draw. Monotonically increasing timestamp */
109
128
  _lastDrawTimestamp = -1;
129
+ _bindingTable = [];
110
130
  get [Symbol.toStringTag]() {
111
131
  return 'Model';
112
132
  }
@@ -119,6 +139,7 @@ export class Model {
119
139
  this.id = props.id || uid('model');
120
140
  this.device = device;
121
141
  Object.assign(this.userData, props.userData);
142
+ this.material = props.material || null;
122
143
  // Setup shader module inputs
123
144
  const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);
124
145
  const shaderInputs = props.shaderInputs ||
@@ -131,13 +152,15 @@ export class Model {
131
152
  const modules =
132
153
  // @ts-ignore shaderInputs is assigned in setShaderInputs above.
133
154
  (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
155
+ this.props.shaderLayout =
156
+ mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
134
157
  const isWebGPU = this.device.type === 'webgpu';
135
158
  // WebGPU
136
159
  // TODO - hack to support unified WGSL shader
137
160
  // TODO - this is wrong, compile a single shader
138
161
  if (isWebGPU && this.props.source) {
139
162
  // WGSL
140
- const { source, getUniforms } = this.props.shaderAssembler.assembleWGSLShader({
163
+ const { source, getUniforms, bindingTable } = this.props.shaderAssembler.assembleWGSLShader({
141
164
  platformInfo,
142
165
  ...this.props,
143
166
  modules
@@ -145,8 +168,11 @@ export class Model {
145
168
  this.source = source;
146
169
  // @ts-expect-error
147
170
  this._getModuleUniforms = getUniforms;
171
+ this._bindingTable = bindingTable;
148
172
  // Extract shader layout after modules have been added to WGSL source, to include any bindings added by modules
149
- this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.source);
173
+ const inferredShaderLayout = device.getShaderLayout?.(this.source);
174
+ this.props.shaderLayout =
175
+ mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout || inferredShaderLayout || null, modules) || null;
150
176
  }
151
177
  else {
152
178
  // GLSL
@@ -159,6 +185,7 @@ export class Model {
159
185
  this.fs = fs;
160
186
  // @ts-expect-error
161
187
  this._getModuleUniforms = getUniforms;
188
+ this._bindingTable = [];
162
189
  }
163
190
  this.vertexCount = this.props.vertexCount;
164
191
  this.instanceCount = this.props.instanceCount;
@@ -208,8 +235,6 @@ export class Model {
208
235
  if (props.transformFeedback) {
209
236
  this.transformFeedback = props.transformFeedback;
210
237
  }
211
- // Catch any access to non-standard props
212
- Object.seal(this);
213
238
  }
214
239
  destroy() {
215
240
  if (!this._destroyed) {
@@ -217,7 +242,7 @@ export class Model {
217
242
  this.pipelineFactory.release(this.pipeline);
218
243
  // Release the shaders
219
244
  this.shaderFactory.release(this.pipeline.vs);
220
- if (this.pipeline.fs) {
245
+ if (this.pipeline.fs && this.pipeline.fs !== this.pipeline.vs) {
221
246
  this.shaderFactory.release(this.pipeline.fs);
222
247
  }
223
248
  this._uniformStore.destroy();
@@ -241,12 +266,22 @@ export class Model {
241
266
  setNeedsRedraw(reason) {
242
267
  this._needsRedraw ||= reason;
243
268
  }
269
+ /** Returns WGSL binding debug rows for the assembled shader. Returns an empty array for GLSL models. */
270
+ getBindingDebugTable() {
271
+ return this._bindingTable;
272
+ }
273
+ /** Update uniforms and pipeline state prior to drawing. */
244
274
  predraw() {
245
275
  // Update uniform buffers if needed
246
276
  this.updateShaderInputs();
247
277
  // Check if the pipeline is invalidated
248
278
  this.pipeline = this._updatePipeline();
249
279
  }
280
+ /**
281
+ * Issue one draw call.
282
+ * @param renderPass - render pass to draw into
283
+ * @returns `true` if the draw call was executed, `false` if resources were not ready.
284
+ */
250
285
  draw(renderPass) {
251
286
  const loadingBinding = this._areBindingsLoading();
252
287
  if (loadingBinding) {
@@ -261,6 +296,7 @@ export class Model {
261
296
  renderPass.popDebugGroup();
262
297
  }
263
298
  let drawSuccess;
299
+ let pipelineErrored = this.pipeline.isErrored;
264
300
  try {
265
301
  renderPass.pushDebugGroup(`${this}.draw(${renderPass})`);
266
302
  this._logDrawCallStart();
@@ -268,31 +304,40 @@ export class Model {
268
304
  // TODO - inside RenderPass is likely the worst place to do this from performance perspective.
269
305
  // Application can call Model.predraw() to avoid this.
270
306
  this.pipeline = this._updatePipeline();
271
- // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
272
- // Any caching needs to be done inside the pipeline functions
273
- // TODO this is a busy initialized check for all bindings every frame
274
- const syncBindings = this._getBindings();
275
- this.pipeline.setBindings(syncBindings, {
276
- disableWarnings: this.props.disableWarnings
277
- });
278
- const { indexBuffer } = this.vertexArray;
279
- const indexCount = indexBuffer
280
- ? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)
281
- : undefined;
282
- drawSuccess = this.pipeline.draw({
283
- renderPass,
284
- vertexArray: this.vertexArray,
285
- isInstanced: this.isInstanced,
286
- vertexCount: this.vertexCount,
287
- instanceCount: this.instanceCount,
288
- indexCount,
289
- transformFeedback: this.transformFeedback || undefined,
290
- // WebGL shares underlying cached pipelines even for models that have different parameters and topology,
291
- // so we must provide our unique parameters to each draw
292
- // (In WebGPU most parameters are encoded in the pipeline and cannot be changed per draw call)
293
- parameters: this.parameters,
294
- topology: this.topology
295
- });
307
+ pipelineErrored = this.pipeline.isErrored;
308
+ if (pipelineErrored) {
309
+ log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`)();
310
+ drawSuccess = false;
311
+ }
312
+ else {
313
+ const syncBindings = this._getBindings();
314
+ const syncBindGroups = this._getBindGroups();
315
+ const { indexBuffer } = this.vertexArray;
316
+ const indexCount = indexBuffer
317
+ ? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)
318
+ : undefined;
319
+ drawSuccess = this.pipeline.draw({
320
+ renderPass,
321
+ vertexArray: this.vertexArray,
322
+ isInstanced: this.isInstanced,
323
+ vertexCount: this.vertexCount,
324
+ instanceCount: this.instanceCount,
325
+ indexCount,
326
+ transformFeedback: this.transformFeedback || undefined,
327
+ // Pipelines may be shared across models when caching is enabled, so bindings
328
+ // and WebGL uniforms must be supplied on every draw instead of being stored
329
+ // on the pipeline instance.
330
+ bindings: syncBindings,
331
+ bindGroups: syncBindGroups,
332
+ _bindGroupCacheKeys: this._getBindGroupCacheKeys(),
333
+ uniforms: this.props.uniforms,
334
+ // WebGL shares underlying cached pipelines even for models that have different parameters and topology,
335
+ // so we must provide our unique parameters to each draw
336
+ // (In WebGPU most parameters are encoded in the pipeline and cannot be changed per draw call)
337
+ parameters: this.parameters,
338
+ topology: this.topology
339
+ });
340
+ }
296
341
  }
297
342
  finally {
298
343
  renderPass.popDebugGroup();
@@ -304,6 +349,9 @@ export class Model {
304
349
  this._lastDrawTimestamp = this.device.timestamp;
305
350
  this._needsRedraw = false;
306
351
  }
352
+ else if (pipelineErrored) {
353
+ this._needsRedraw = PIPELINE_INITIALIZATION_FAILED;
354
+ }
307
355
  else {
308
356
  this._needsRedraw = 'waiting for resource initialization';
309
357
  }
@@ -397,20 +445,24 @@ export class Model {
397
445
  /** Set the shader inputs */
398
446
  setShaderInputs(shaderInputs) {
399
447
  this.shaderInputs = shaderInputs;
400
- this._uniformStore = new UniformStore(this.shaderInputs.modules);
448
+ this._uniformStore = new UniformStore(this.device, this.shaderInputs.modules);
401
449
  // Create uniform buffer bindings for all modules that actually have uniforms
402
450
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
403
- if (shaderModuleHasUniforms(module)) {
404
- const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
451
+ if (shaderModuleHasUniforms(module) && !this.material?.ownsModule(moduleName)) {
452
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
405
453
  this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
406
454
  }
407
455
  }
408
456
  this.setNeedsRedraw('shaderInputs');
409
457
  }
458
+ setMaterial(material) {
459
+ this.material = material;
460
+ this.setNeedsRedraw('material');
461
+ }
410
462
  /** Update uniform buffers from the model's shader inputs */
411
463
  updateShaderInputs() {
412
464
  this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
413
- this.setBindings(this.shaderInputs.getBindingValues());
465
+ this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues()));
414
466
  // TODO - this is already tracked through buffer/texture update times?
415
467
  this.setNeedsRedraw('shaderInputs');
416
468
  }
@@ -502,7 +554,12 @@ export class Model {
502
554
  /** Check that bindings are loaded. Returns id of first binding that is still loading. */
503
555
  _areBindingsLoading() {
504
556
  for (const binding of Object.values(this.bindings)) {
505
- if (binding instanceof AsyncTexture && !binding.isReady) {
557
+ if (binding instanceof DynamicTexture && !binding.isReady) {
558
+ return binding.id;
559
+ }
560
+ }
561
+ for (const binding of Object.values(this.material?.bindings || {})) {
562
+ if (binding instanceof DynamicTexture && !binding.isReady) {
506
563
  return binding.id;
507
564
  }
508
565
  }
@@ -512,7 +569,7 @@ export class Model {
512
569
  _getBindings() {
513
570
  const validBindings = {};
514
571
  for (const [name, binding] of Object.entries(this.bindings)) {
515
- if (binding instanceof AsyncTexture) {
572
+ if (binding instanceof DynamicTexture) {
516
573
  // Check that async textures are loaded
517
574
  if (binding.isReady) {
518
575
  validBindings[name] = binding.texture;
@@ -524,6 +581,27 @@ export class Model {
524
581
  }
525
582
  return validBindings;
526
583
  }
584
+ _getBindGroups() {
585
+ const shaderLayout = this.pipeline?.shaderLayout || this.props.shaderLayout || { bindings: [] };
586
+ const bindGroups = shaderLayout.bindings.length
587
+ ? normalizeBindingsByGroup(shaderLayout, this._getBindings())
588
+ : { 0: this._getBindings() };
589
+ if (!this.material) {
590
+ return bindGroups;
591
+ }
592
+ for (const [groupKey, groupBindings] of Object.entries(this.material.getBindingsByGroup())) {
593
+ const group = Number(groupKey);
594
+ bindGroups[group] = {
595
+ ...(bindGroups[group] || {}),
596
+ ...groupBindings
597
+ };
598
+ }
599
+ return bindGroups;
600
+ }
601
+ _getBindGroupCacheKeys() {
602
+ const bindGroupCacheKey = this.material?.getBindGroupCacheKey(3);
603
+ return bindGroupCacheKey ? { 3: bindGroupCacheKey } : {};
604
+ }
527
605
  /** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
528
606
  _getBindingsUpdateTimestamp() {
529
607
  let timestamp = 0;
@@ -534,7 +612,7 @@ export class Model {
534
612
  else if (binding instanceof Buffer || binding instanceof Texture) {
535
613
  timestamp = Math.max(timestamp, binding.updateTimestamp);
536
614
  }
537
- else if (binding instanceof AsyncTexture) {
615
+ else if (binding instanceof DynamicTexture) {
538
616
  timestamp = binding.texture
539
617
  ? Math.max(timestamp, binding.texture.updateTimestamp)
540
618
  : // The texture will become available in the future
@@ -544,7 +622,7 @@ export class Model {
544
622
  timestamp = Math.max(timestamp, binding.buffer.updateTimestamp);
545
623
  }
546
624
  }
547
- return timestamp;
625
+ return Math.max(timestamp, this.material?.getBindingsUpdateTimestamp() || 0);
548
626
  }
549
627
  /**
550
628
  * Updates the optional geometry attributes
@@ -603,20 +681,20 @@ export class Model {
603
681
  }
604
682
  this.pipeline = this.pipelineFactory.createRenderPipeline({
605
683
  ...this.props,
684
+ bindings: undefined,
606
685
  bufferLayout: this.bufferLayout,
607
686
  topology: this.topology,
608
687
  parameters: this.parameters,
609
- // TODO - why set bindings here when we reset them every frame?
610
- // Should we expose a BindGroup abstraction?
611
- bindings: this._getBindings(),
688
+ bindGroups: this._getBindGroups(),
612
689
  vs,
613
690
  fs
614
691
  });
615
692
  this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
616
693
  if (prevShaderVs)
617
694
  this.shaderFactory.release(prevShaderVs);
618
- if (prevShaderFs)
695
+ if (prevShaderFs && prevShaderFs !== prevShaderVs) {
619
696
  this.shaderFactory.release(prevShaderFs);
697
+ }
620
698
  }
621
699
  return this.pipeline;
622
700
  }
@@ -657,12 +735,11 @@ export class Model {
657
735
  // } || (this._drawCount++ > 3 && this._drawCount % 60)) {
658
736
  return;
659
737
  }
660
- // TODO - display framebuffer output in debug window
661
738
  const framebuffer = renderPass.props.framebuffer;
662
- if (framebuffer) {
663
- debugFramebuffer(framebuffer, { id: framebuffer.id, minimap: true });
664
- // log.image({logLevel: LOG_DRAW_PRIORITY, message: `${framebuffer.id} %c sup?`, image})();
665
- }
739
+ debugFramebuffer(renderPass, framebuffer, {
740
+ id: framebuffer?.id || `${this.id}-framebuffer`,
741
+ minimap: true
742
+ });
666
743
  }
667
744
  _getAttributeDebugTable() {
668
745
  const table = {};
@@ -691,13 +768,22 @@ export class Model {
691
768
  }
692
769
  // TODO - fix typing of luma data types
693
770
  _getBufferOrConstantValues(attribute, dataType) {
694
- const TypedArrayConstructor = getTypedArrayConstructor(dataType);
771
+ const TypedArrayConstructor = dataTypeDecoder.getTypedArrayConstructor(dataType);
695
772
  const typedArray = attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
696
773
  return typedArray.toString();
697
774
  }
698
- }
699
- function shaderModuleHasUniforms(module) {
700
- return Boolean(module.uniformTypes && !isObjectEmpty(module.uniformTypes));
775
+ _getNonMaterialBindings(bindings) {
776
+ if (!this.material) {
777
+ return bindings;
778
+ }
779
+ const filteredBindings = {};
780
+ for (const [name, binding] of Object.entries(bindings)) {
781
+ if (!this.material.ownsBinding(name)) {
782
+ filteredBindings[name] = binding;
783
+ }
784
+ }
785
+ return filteredBindings;
786
+ }
701
787
  }
702
788
  // HELPERS
703
789
  /** Create a shadertools platform info from the Device */
@@ -711,13 +797,4 @@ export function getPlatformInfo(device) {
711
797
  features: device.features
712
798
  };
713
799
  }
714
- /** Returns true if given object is empty, false otherwise. */
715
- function isObjectEmpty(obj) {
716
- // @ts-ignore key is unused
717
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
718
- for (const key in obj) {
719
- return false;
720
- }
721
- return true;
722
- }
723
800
  //# sourceMappingURL=model.js.map