@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.1

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 (191) hide show
  1. package/LICENSE +3 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +6 -27
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +8 -8
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +18 -49
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/animation-loop/animation-loop-template.d.ts +23 -0
  11. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
  12. package/dist/animation-loop/animation-loop-template.js +7 -0
  13. package/dist/animation-loop/animation-loop-template.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
  15. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  16. package/dist/{lib → animation-loop}/animation-loop.js +77 -192
  17. package/dist/animation-loop/animation-loop.js.map +1 -0
  18. package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
  19. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  20. package/dist/animation-loop/animation-props.js.map +1 -0
  21. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  22. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/make-animation-loop.js +28 -0
  24. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  25. package/dist/debug/copy-texture-to-image.d.ts +26 -0
  26. package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
  27. package/dist/debug/copy-texture-to-image.js +46 -0
  28. package/dist/debug/copy-texture-to-image.js.map +1 -0
  29. package/dist/debug/debug-framebuffer.d.ts +11 -0
  30. package/dist/debug/debug-framebuffer.d.ts.map +1 -0
  31. package/dist/debug/debug-framebuffer.js +43 -0
  32. package/dist/debug/debug-framebuffer.js.map +1 -0
  33. package/dist/debug/debug-shader-layout.d.ts +9 -0
  34. package/dist/debug/debug-shader-layout.d.ts.map +1 -0
  35. package/dist/debug/debug-shader-layout.js +28 -0
  36. package/dist/debug/debug-shader-layout.js.map +1 -0
  37. package/dist/debug/pixel-data-utils.d.ts +24 -0
  38. package/dist/debug/pixel-data-utils.d.ts.map +1 -0
  39. package/dist/debug/pixel-data-utils.js +41 -0
  40. package/dist/debug/pixel-data-utils.js.map +1 -0
  41. package/dist/dist.dev.js +10081 -0
  42. package/dist/geometries/cone-geometry.d.ts +1 -1
  43. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/cone-geometry.js +6 -5
  45. package/dist/geometries/cone-geometry.js.map +1 -1
  46. package/dist/geometries/cube-geometry.d.ts +2 -2
  47. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  48. package/dist/geometries/cube-geometry.js +16 -10
  49. package/dist/geometries/cube-geometry.js.map +1 -1
  50. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  51. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  52. package/dist/geometries/cylinder-geometry.js +6 -5
  53. package/dist/geometries/cylinder-geometry.js.map +1 -1
  54. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  55. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  56. package/dist/geometries/ico-sphere-geometry.js +10 -19
  57. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  58. package/dist/geometries/plane-geometry.d.ts +2 -2
  59. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  60. package/dist/geometries/plane-geometry.js +14 -23
  61. package/dist/geometries/plane-geometry.js.map +1 -1
  62. package/dist/geometries/sphere-geometry.d.ts +2 -2
  63. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  64. package/dist/geometries/sphere-geometry.js +9 -13
  65. package/dist/geometries/sphere-geometry.js.map +1 -1
  66. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  67. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  68. package/dist/geometries/truncated-cone-geometry.js +9 -25
  69. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  70. package/dist/geometry/geometry-table.d.ts +2 -2
  71. package/dist/geometry/geometry-table.d.ts.map +1 -1
  72. package/dist/geometry/geometry-table.js.map +1 -1
  73. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  74. package/dist/geometry/geometry-utils.js +0 -9
  75. package/dist/geometry/geometry-utils.js.map +1 -1
  76. package/dist/geometry/geometry.d.ts +43 -43
  77. package/dist/geometry/geometry.d.ts.map +1 -1
  78. package/dist/geometry/geometry.js +20 -86
  79. package/dist/geometry/geometry.js.map +1 -1
  80. package/dist/geometry/gpu-geometry.d.ts +37 -0
  81. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  82. package/dist/geometry/gpu-geometry.js +110 -0
  83. package/dist/geometry/gpu-geometry.js.map +1 -0
  84. package/dist/geometry/gpu-table.d.ts +1 -0
  85. package/dist/geometry/gpu-table.d.ts.map +1 -0
  86. package/dist/geometry/gpu-table.js +2 -0
  87. package/dist/geometry/gpu-table.js.map +1 -0
  88. package/dist/index.cjs +3128 -0
  89. package/dist/index.d.ts +24 -8
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +23 -14
  92. package/dist/index.js.map +1 -1
  93. package/dist/lib/clip-space.d.ts +8 -0
  94. package/dist/lib/clip-space.d.ts.map +1 -1
  95. package/dist/lib/clip-space.js +47 -0
  96. package/dist/lib/clip-space.js.map +1 -1
  97. package/dist/lib/pipeline-factory.d.ts +12 -45
  98. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  99. package/dist/lib/pipeline-factory.js +42 -168
  100. package/dist/lib/pipeline-factory.js.map +1 -1
  101. package/dist/model/model.d.ts +206 -0
  102. package/dist/model/model.d.ts.map +1 -0
  103. package/dist/model/model.js +435 -0
  104. package/dist/model/model.js.map +1 -0
  105. package/dist/scenegraph/group-node.d.ts +21 -0
  106. package/dist/scenegraph/group-node.d.ts.map +1 -0
  107. package/dist/scenegraph/group-node.js +94 -0
  108. package/dist/scenegraph/group-node.js.map +1 -0
  109. package/dist/scenegraph/model-node.d.ts +18 -0
  110. package/dist/scenegraph/model-node.d.ts.map +1 -0
  111. package/dist/scenegraph/model-node.js +28 -0
  112. package/dist/scenegraph/model-node.js.map +1 -0
  113. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  114. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  115. package/dist/scenegraph/scenegraph-node.js +141 -0
  116. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  117. package/dist/shader-inputs.d.ts +63 -0
  118. package/dist/shader-inputs.d.ts.map +1 -0
  119. package/dist/shader-inputs.js +66 -0
  120. package/dist/shader-inputs.js.map +1 -0
  121. package/dist/transform/buffer-transform.d.ts +35 -0
  122. package/dist/transform/buffer-transform.d.ts.map +1 -0
  123. package/dist/transform/buffer-transform.js +62 -0
  124. package/dist/transform/buffer-transform.js.map +1 -0
  125. package/dist/transform/texture-transform.d.ts +57 -0
  126. package/dist/transform/texture-transform.d.ts.map +1 -0
  127. package/dist/transform/texture-transform.js +122 -0
  128. package/dist/transform/texture-transform.js.map +1 -0
  129. package/dist.min.js +293 -0
  130. package/package.json +21 -12
  131. package/src/animation/timeline.ts +15 -14
  132. package/src/animation-loop/animation-loop-template.ts +23 -0
  133. package/src/{lib → animation-loop}/animation-loop.ts +99 -88
  134. package/src/{lib → animation-loop}/animation-props.ts +1 -1
  135. package/src/animation-loop/make-animation-loop.ts +44 -0
  136. package/src/debug/copy-texture-to-image.ts +72 -0
  137. package/src/debug/debug-framebuffer.ts +57 -0
  138. package/src/debug/debug-shader-layout.ts +38 -0
  139. package/src/debug/pixel-data-utils.ts +57 -0
  140. package/src/geometries/cone-geometry.ts +1 -1
  141. package/src/geometries/cube-geometry.ts +47 -45
  142. package/src/geometries/cylinder-geometry.ts +2 -2
  143. package/src/geometries/ico-sphere-geometry.ts +6 -5
  144. package/src/geometries/plane-geometry.ts +5 -4
  145. package/src/geometries/sphere-geometry.ts +4 -3
  146. package/src/geometries/truncated-cone-geometry.ts +4 -13
  147. package/src/geometry/geometry-table.ts +1 -1
  148. package/src/geometry/geometry-utils.ts +3 -3
  149. package/src/geometry/geometry.ts +65 -110
  150. package/src/geometry/gpu-geometry.ts +125 -0
  151. package/src/geometry/gpu-table.ts +41 -0
  152. package/src/index.ts +34 -10
  153. package/src/lib/clip-space.ts +22 -21
  154. package/src/lib/pipeline-factory.ts +51 -168
  155. package/src/model/model.ts +726 -0
  156. package/src/scenegraph/group-node.ts +103 -0
  157. package/src/scenegraph/model-node.ts +50 -0
  158. package/src/scenegraph/scenegraph-node.ts +204 -0
  159. package/src/shader-inputs.ts +150 -0
  160. package/src/transform/buffer-transform.ts +94 -0
  161. package/src/transform/texture-transform.ts +169 -0
  162. package/dist/bundle.d.ts +0 -2
  163. package/dist/bundle.d.ts.map +0 -1
  164. package/dist/bundle.js +0 -5
  165. package/dist/bundle.js.map +0 -1
  166. package/dist/geometry/primitive-utils.d.ts +0 -1
  167. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  168. package/dist/geometry/primitive-utils.js +0 -2
  169. package/dist/geometry/primitive-utils.js.map +0 -1
  170. package/dist/lib/animation-loop.d.ts.map +0 -1
  171. package/dist/lib/animation-loop.js.map +0 -1
  172. package/dist/lib/animation-props.d.ts.map +0 -1
  173. package/dist/lib/animation-props.js.map +0 -1
  174. package/dist/lib/model-utils.d.ts +0 -5
  175. package/dist/lib/model-utils.d.ts.map +0 -1
  176. package/dist/lib/model-utils.js +0 -45
  177. package/dist/lib/model-utils.js.map +0 -1
  178. package/dist/lib/model.d.ts +0 -41
  179. package/dist/lib/model.d.ts.map +0 -1
  180. package/dist/lib/model.js +0 -182
  181. package/dist/lib/model.js.map +0 -1
  182. package/dist/lib/render-loop.d.ts +0 -14
  183. package/dist/lib/render-loop.d.ts.map +0 -1
  184. package/dist/lib/render-loop.js +0 -49
  185. package/dist/lib/render-loop.js.map +0 -1
  186. package/src/bundle.ts +0 -4
  187. package/src/geometry/primitive-utils.ts +0 -30
  188. package/src/lib/model-utils.ts +0 -124
  189. package/src/lib/model.ts +0 -183
  190. package/src/lib/render-loop.ts +0 -58
  191. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
@@ -0,0 +1,206 @@
1
+ import type { TypedArray, RenderPipelineProps, RenderPipelineParameters } from '@luma.gl/core';
2
+ import type { BufferLayout, VertexArray, TransformFeedback } from '@luma.gl/core';
3
+ import type { AttributeInfo, Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';
4
+ import { Device, Buffer, RenderPipeline, RenderPass, UniformStore } from '@luma.gl/core';
5
+ import type { ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
6
+ import { ShaderAssembler } from '@luma.gl/shadertools';
7
+ import { ShaderInputs } from '../shader-inputs';
8
+ import type { Geometry } from '../geometry/geometry';
9
+ import { GPUGeometry } from '../geometry/gpu-geometry';
10
+ import { PipelineFactory } from '../lib/pipeline-factory';
11
+ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
12
+ source?: string;
13
+ vs: {
14
+ glsl?: string;
15
+ wgsl?: string;
16
+ } | string | null;
17
+ fs: {
18
+ glsl?: string;
19
+ wgsl?: string;
20
+ } | string | null;
21
+ /** shadertool shader modules (added to shader code) */
22
+ modules?: ShaderModule[];
23
+ /** Shadertool module defines (configures shader code)*/
24
+ defines?: Record<string, string | number | boolean>;
25
+ /** Shader inputs, used to generated uniform buffers and bindings */
26
+ shaderInputs?: ShaderInputs;
27
+ /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */
28
+ pipelineFactory?: PipelineFactory;
29
+ /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
30
+ shaderAssembler?: ShaderAssembler;
31
+ /** Parameters that are built into the pipeline */
32
+ parameters?: RenderPipelineParameters;
33
+ /** Geometry */
34
+ geometry?: GPUGeometry | Geometry | null;
35
+ /** Vertex count */
36
+ vertexCount?: number;
37
+ /** instance count */
38
+ instanceCount?: number;
39
+ indexBuffer?: Buffer | null;
40
+ /** @note this is really a map of buffers, not a map of attributes */
41
+ attributes?: Record<string, Buffer>;
42
+ /** */
43
+ constantAttributes?: Record<string, TypedArray>;
44
+ /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */
45
+ varyings?: string[];
46
+ transformFeedback?: TransformFeedback;
47
+ /** Mapped uniforms for shadertool modules */
48
+ moduleSettings?: Record<string, Record<string, any>>;
49
+ };
50
+ /**
51
+ * v9 Model API
52
+ * A model
53
+ * - automatically reuses pipelines (programs) when possible
54
+ * - automatically rebuilds pipelines if necessary to accommodate changed settings
55
+ * shadertools integration
56
+ * - accepts modules and performs shader transpilation
57
+ */
58
+ export declare class Model {
59
+ static defaultProps: Required<ModelProps>;
60
+ readonly device: Device;
61
+ readonly id: string;
62
+ readonly vs: string;
63
+ readonly fs: string;
64
+ readonly pipelineFactory: PipelineFactory;
65
+ userData: {
66
+ [key: string]: any;
67
+ };
68
+ /** The render pipeline GPU parameters, depth testing etc */
69
+ parameters: RenderPipelineParameters;
70
+ /** The primitive topology */
71
+ topology: PrimitiveTopology;
72
+ /** Buffer layout */
73
+ bufferLayout: BufferLayout[];
74
+ /** Vertex count */
75
+ vertexCount: number;
76
+ /** instance count */
77
+ instanceCount: number;
78
+ /** Index buffer */
79
+ indexBuffer: Buffer | null;
80
+ /** Buffer-valued attributes */
81
+ bufferAttributes: Record<string, Buffer>;
82
+ /** Constant-valued attributes */
83
+ constantAttributes: Record<string, TypedArray>;
84
+ /** Bindings (textures, samplers, uniform buffers) */
85
+ bindings: Record<string, Binding>;
86
+ /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/
87
+ uniforms: Record<string, UniformValue>;
88
+ /**
89
+ * VertexArray
90
+ * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
91
+ * @todo - allow application to define multiple vertex arrays?
92
+ * */
93
+ vertexArray: VertexArray;
94
+ /** TransformFeedback, WebGL 2 only. */
95
+ transformFeedback: TransformFeedback | null;
96
+ /** The underlying GPU "program". @note May be recreated if parameters change */
97
+ pipeline: RenderPipeline;
98
+ /** ShaderInputs instance */
99
+ shaderInputs: ShaderInputs;
100
+ _uniformStore: UniformStore;
101
+ _pipelineNeedsUpdate: string | false;
102
+ _attributeInfos: Record<string, AttributeInfo>;
103
+ _gpuGeometry: GPUGeometry | null;
104
+ private _getModuleUniforms;
105
+ private props;
106
+ constructor(device: Device, props: ModelProps);
107
+ destroy(): void;
108
+ predraw(): void;
109
+ draw(renderPass: RenderPass): void;
110
+ /**
111
+ * Updates the optional geometry
112
+ * Geometry, set topology and bufferLayout
113
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
114
+ */
115
+ setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry;
116
+ /**
117
+ * Updates the optional geometry attributes
118
+ * Geometry, sets several attributes, indexBuffer, and also vertex count
119
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
120
+ */
121
+ _setGeometryAttributes(gpuGeometry: GPUGeometry): void;
122
+ /**
123
+ * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
124
+ * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
125
+ */
126
+ setTopology(topology: PrimitiveTopology): void;
127
+ /**
128
+ * Updates the buffer layout.
129
+ * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
130
+ */
131
+ setBufferLayout(bufferLayout: BufferLayout[]): void;
132
+ /**
133
+ * Set GPU parameters.
134
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch.
135
+ * @param parameters
136
+ */
137
+ setParameters(parameters: RenderPipelineParameters): void;
138
+ /**
139
+ * Updates the vertex count (used in draw calls)
140
+ * @note Any attributes with stepMode=vertex need to be at least this big
141
+ */
142
+ setVertexCount(vertexCount: number): void;
143
+ /**
144
+ * Updates the instance count (used in draw calls)
145
+ * @note Any attributes with stepMode=instance need to be at least this big
146
+ */
147
+ setInstanceCount(instanceCount: number): void;
148
+ setShaderInputs(shaderInputs: ShaderInputs): void;
149
+ /**
150
+ * Updates shader module settings (which results in uniforms being set)
151
+ */
152
+ setShaderModuleProps(props: Record<string, any>): void;
153
+ updateShaderInputs(): void;
154
+ /**
155
+ * @deprecated Updates shader module settings (which results in uniforms being set)
156
+ */
157
+ updateModuleSettings(props: Record<string, any>): void;
158
+ /**
159
+ * Sets bindings (textures, samplers, uniform buffers)
160
+ */
161
+ setBindings(bindings: Record<string, Binding>): void;
162
+ /**
163
+ * Sets individual uniforms
164
+ * @deprecated WebGL only, use uniform buffers for portability
165
+ * @param uniforms
166
+ * @returns self for chaining
167
+ */
168
+ setUniforms(uniforms: Record<string, UniformValue>): void;
169
+ /**
170
+ * Sets the index buffer
171
+ * @todo - how to unset it if we change geometry?
172
+ */
173
+ setIndexBuffer(indexBuffer: Buffer | null): void;
174
+ /**
175
+ * Updates optional transform feedback. WebGL 2 only.
176
+ */
177
+ setTransformFeedback(transformFeedback: TransformFeedback | null): void;
178
+ /**
179
+ * Sets attributes (buffers)
180
+ * @note Overrides any attributes previously set with the same name
181
+ */
182
+ setAttributes(buffers: Record<string, Buffer>, _option?: 'ignore-unknown'): void;
183
+ /**
184
+ * Sets constant attributes
185
+ * @note Overrides any attributes previously set with the same name
186
+ * Constant attributes are only supported in WebGL, not in WebGPU
187
+ * Any attribute that is disabled in the current vertex array object
188
+ * is read from the context's global constant value for that attribute location.
189
+ * @param constantAttributes
190
+ */
191
+ setConstantAttributes(attributes: Record<string, TypedArray>): void;
192
+ _setPipelineNeedsUpdate(reason: string): void;
193
+ _updatePipeline(): RenderPipeline;
194
+ /** Throttle draw call logging */
195
+ _lastLogTime: number;
196
+ _logOpen: boolean;
197
+ _logDrawCallStart(): void;
198
+ _logDrawCallEnd(): void;
199
+ protected _drawCount: number;
200
+ _logFramebuffer(renderPass: RenderPass): void;
201
+ _getAttributeDebugTable(): Record<string, Record<string, unknown>>;
202
+ _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string;
203
+ }
204
+ /** Create a shadertools platform info from the Device */
205
+ export declare function getPlatformInfo(device: Device): PlatformInfo;
206
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EACL,MAAM,EACN,MAAM,EACN,cAAc,EACd,UAAU,EACV,YAAY,EAEb,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAA0B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAkB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAOxD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACnD,EAAE,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KA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G;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI;IA+BhF;;;;;;;OAOG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAanE,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;IA0CjC,iCAAiC;IACjC,YAAY,SAAK;IACjB,QAAQ,UAAS;IAEjB,iBAAiB,IAAI,IAAI;IAazB,eAAe,IAAI,IAAI;IAwBvB,SAAS,CAAC,UAAU,SAAK;IACzB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAe7C,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA4BlE,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM;CAMlF;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAQ5D"}
@@ -0,0 +1,435 @@
1
+ import { Buffer, RenderPipeline, UniformStore, getTypedArrayFromDataType } from '@luma.gl/core';
2
+ import { log, uid, deepEqual, splitUniformsAndBindings, isNumberArray } from '@luma.gl/core';
3
+ import { getAttributeInfosFromLayouts } from '@luma.gl/core';
4
+ import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
5
+ import { ShaderInputs } from "../shader-inputs.js";
6
+ import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
7
+ import { PipelineFactory } from "../lib/pipeline-factory.js";
8
+ import { getDebugTableForShaderLayout } from "../debug/debug-shader-layout.js";
9
+ import { debugFramebuffer } from "../debug/debug-framebuffer.js";
10
+ const LOG_DRAW_PRIORITY = 2;
11
+ const LOG_DRAW_TIMEOUT = 10000;
12
+ export class Model {
13
+ constructor(device, props) {
14
+ var _this$props$modules, _this$props$modules2, _this$shaderInputs;
15
+ this.device = void 0;
16
+ this.id = void 0;
17
+ this.vs = void 0;
18
+ this.fs = void 0;
19
+ this.pipelineFactory = void 0;
20
+ this.userData = {};
21
+ this.parameters = void 0;
22
+ this.topology = void 0;
23
+ this.bufferLayout = void 0;
24
+ this.vertexCount = void 0;
25
+ this.instanceCount = 0;
26
+ this.indexBuffer = null;
27
+ this.bufferAttributes = {};
28
+ this.constantAttributes = {};
29
+ this.bindings = {};
30
+ this.uniforms = {};
31
+ this.vertexArray = void 0;
32
+ this.transformFeedback = null;
33
+ this.pipeline = void 0;
34
+ this.shaderInputs = void 0;
35
+ this._uniformStore = void 0;
36
+ this._pipelineNeedsUpdate = 'newly created';
37
+ this._attributeInfos = {};
38
+ this._gpuGeometry = null;
39
+ this._getModuleUniforms = void 0;
40
+ this.props = void 0;
41
+ this._lastLogTime = 0;
42
+ this._logOpen = false;
43
+ this._drawCount = 0;
44
+ this.props = {
45
+ ...Model.defaultProps,
46
+ ...props
47
+ };
48
+ props = this.props;
49
+ this.id = props.id || uid('model');
50
+ this.device = device;
51
+ Object.assign(this.userData, props.userData);
52
+ const moduleMap = Object.fromEntries(((_this$props$modules = this.props.modules) === null || _this$props$modules === void 0 ? void 0 : _this$props$modules.map(module => [module.name, module])) || []);
53
+ this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));
54
+ const isWebGPU = this.device.info.type === 'webgpu';
55
+ if (this.props.source) {
56
+ if (isWebGPU) {
57
+ var _this$props;
58
+ (_this$props = this.props).shaderLayout || (_this$props.shaderLayout = getShaderLayoutFromWGSL(this.props.source));
59
+ }
60
+ this.props.fs = this.props.source;
61
+ this.props.vs = this.props.source;
62
+ }
63
+ if (isWebGPU && typeof this.props.vs !== 'string') {
64
+ var _this$props2;
65
+ (_this$props2 = this.props).shaderLayout || (_this$props2.shaderLayout = getShaderLayoutFromWGSL(this.props.vs.wgsl));
66
+ }
67
+ const platformInfo = getPlatformInfo(device);
68
+ const modules = (((_this$props$modules2 = this.props.modules) === null || _this$props$modules2 === void 0 ? void 0 : _this$props$modules2.length) > 0 ? this.props.modules : (_this$shaderInputs = this.shaderInputs) === null || _this$shaderInputs === void 0 ? void 0 : _this$shaderInputs.getModules()) || [];
69
+ const {
70
+ vs,
71
+ fs,
72
+ getUniforms
73
+ } = this.props.shaderAssembler.assembleShaders({
74
+ platformInfo,
75
+ ...this.props,
76
+ modules
77
+ });
78
+ this.vs = vs;
79
+ this.fs = fs;
80
+ this._getModuleUniforms = getUniforms;
81
+ this.vertexCount = this.props.vertexCount;
82
+ this.instanceCount = this.props.instanceCount;
83
+ this.topology = this.props.topology;
84
+ this.bufferLayout = this.props.bufferLayout;
85
+ this.parameters = this.props.parameters;
86
+ if (props.geometry) {
87
+ this._gpuGeometry = this.setGeometry(props.geometry);
88
+ }
89
+ this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
90
+ this.pipeline = this._updatePipeline();
91
+ this.vertexArray = device.createVertexArray({
92
+ renderPipeline: this.pipeline
93
+ });
94
+ if (this._gpuGeometry) {
95
+ this._setGeometryAttributes(this._gpuGeometry);
96
+ }
97
+ if (props.vertexCount) {
98
+ this.setVertexCount(props.vertexCount);
99
+ }
100
+ if (props.instanceCount) {
101
+ this.setInstanceCount(props.instanceCount);
102
+ }
103
+ if (props.indices) {
104
+ throw new Error('Model.props.indices removed. Use props.indexBuffer');
105
+ }
106
+ if (props.indexBuffer) {
107
+ this.setIndexBuffer(props.indexBuffer);
108
+ }
109
+ if (props.attributes) {
110
+ this.setAttributes(props.attributes);
111
+ }
112
+ if (props.constantAttributes) {
113
+ this.setConstantAttributes(props.constantAttributes);
114
+ }
115
+ if (props.bindings) {
116
+ this.setBindings(props.bindings);
117
+ }
118
+ if (props.uniforms) {
119
+ this.setUniforms(props.uniforms);
120
+ }
121
+ if (props.moduleSettings) {
122
+ log.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()')();
123
+ this.updateModuleSettings(props.moduleSettings);
124
+ }
125
+ if (props.transformFeedback) {
126
+ this.transformFeedback = props.transformFeedback;
127
+ }
128
+ Object.seal(this);
129
+ }
130
+ destroy() {
131
+ this.pipelineFactory.release(this.pipeline);
132
+ this._uniformStore.destroy();
133
+ }
134
+ predraw() {
135
+ this.updateShaderInputs();
136
+ }
137
+ draw(renderPass) {
138
+ this.predraw();
139
+ try {
140
+ this._logDrawCallStart();
141
+ this.pipeline = this._updatePipeline();
142
+ this.pipeline.setBindings(this.bindings);
143
+ this.pipeline.setUniforms(this.uniforms);
144
+ this.pipeline.draw({
145
+ renderPass,
146
+ vertexArray: this.vertexArray,
147
+ vertexCount: this.vertexCount,
148
+ instanceCount: this.instanceCount,
149
+ transformFeedback: this.transformFeedback
150
+ });
151
+ } finally {
152
+ this._logDrawCallEnd();
153
+ }
154
+ this._logFramebuffer(renderPass);
155
+ }
156
+ setGeometry(geometry) {
157
+ const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
158
+ this.setTopology(gpuGeometry.topology || 'triangle-list');
159
+ this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
160
+ if (this.vertexArray) {
161
+ this._setGeometryAttributes(gpuGeometry);
162
+ }
163
+ return gpuGeometry;
164
+ }
165
+ _setGeometryAttributes(gpuGeometry) {
166
+ const attributes = {
167
+ ...gpuGeometry.attributes
168
+ };
169
+ for (const [attributeName] of Object.entries(attributes)) {
170
+ if (!this.pipeline.shaderLayout.attributes.find(layout => layout.name === attributeName) && attributeName !== 'positions') {
171
+ delete attributes[attributeName];
172
+ }
173
+ }
174
+ this.vertexCount = gpuGeometry.vertexCount;
175
+ this.setIndexBuffer(gpuGeometry.indices);
176
+ this.setAttributes(gpuGeometry.attributes, 'ignore-unknown');
177
+ this.setAttributes(attributes);
178
+ }
179
+ setTopology(topology) {
180
+ if (topology !== this.topology) {
181
+ this.topology = topology;
182
+ this._setPipelineNeedsUpdate('topology');
183
+ }
184
+ }
185
+ setBufferLayout(bufferLayout) {
186
+ this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
187
+ this._setPipelineNeedsUpdate('bufferLayout');
188
+ this.pipeline = this._updatePipeline();
189
+ this.vertexArray = this.device.createVertexArray({
190
+ renderPipeline: this.pipeline
191
+ });
192
+ if (this._gpuGeometry) {
193
+ this._setGeometryAttributes(this._gpuGeometry);
194
+ }
195
+ }
196
+ setParameters(parameters) {
197
+ if (!deepEqual(parameters, this.parameters, 2)) {
198
+ this.parameters = parameters;
199
+ this._setPipelineNeedsUpdate('parameters');
200
+ }
201
+ }
202
+ setVertexCount(vertexCount) {
203
+ this.vertexCount = vertexCount;
204
+ }
205
+ setInstanceCount(instanceCount) {
206
+ this.instanceCount = instanceCount;
207
+ }
208
+ setShaderInputs(shaderInputs) {
209
+ this.shaderInputs = shaderInputs;
210
+ this._uniformStore = new UniformStore(this.shaderInputs.modules);
211
+ for (const moduleName of Object.keys(this.shaderInputs.modules)) {
212
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
213
+ this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
214
+ }
215
+ }
216
+ setShaderModuleProps(props) {
217
+ const uniforms = this._getModuleUniforms(props);
218
+ const keys = Object.keys(uniforms).filter(k => {
219
+ const uniform = uniforms[k];
220
+ return !isNumberArray(uniform) && typeof uniform !== 'number' && typeof uniform !== 'boolean';
221
+ });
222
+ const bindings = {};
223
+ for (const k of keys) {
224
+ bindings[k] = uniforms[k];
225
+ delete uniforms[k];
226
+ }
227
+ }
228
+ updateShaderInputs() {
229
+ this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
230
+ }
231
+ updateModuleSettings(props) {
232
+ log.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()')();
233
+ const {
234
+ bindings,
235
+ uniforms
236
+ } = splitUniformsAndBindings(this._getModuleUniforms(props));
237
+ Object.assign(this.bindings, bindings);
238
+ Object.assign(this.uniforms, uniforms);
239
+ }
240
+ setBindings(bindings) {
241
+ Object.assign(this.bindings, bindings);
242
+ }
243
+ setUniforms(uniforms) {
244
+ this.pipeline.setUniforms(uniforms);
245
+ Object.assign(this.uniforms, uniforms);
246
+ }
247
+ setIndexBuffer(indexBuffer) {
248
+ this.vertexArray.setIndexBuffer(indexBuffer);
249
+ }
250
+ setTransformFeedback(transformFeedback) {
251
+ this.transformFeedback = transformFeedback;
252
+ }
253
+ setAttributes(buffers, _option) {
254
+ if (buffers.indices) {
255
+ log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
256
+ }
257
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
258
+ const bufferLayout = this.bufferLayout.find(layout => getAttributeNames(layout).includes(bufferName));
259
+ if (!bufferLayout) {
260
+ log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
261
+ continue;
262
+ }
263
+ const attributeNames = getAttributeNames(bufferLayout);
264
+ let set = false;
265
+ for (const attributeName of attributeNames) {
266
+ const attributeInfo = this._attributeInfos[attributeName];
267
+ if (attributeInfo) {
268
+ this.vertexArray.setBuffer(attributeInfo.location, buffer);
269
+ set = true;
270
+ }
271
+ }
272
+ if (!set && _option !== 'ignore-unknown') {
273
+ log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
274
+ }
275
+ }
276
+ }
277
+ setConstantAttributes(attributes) {
278
+ for (const [attributeName, value] of Object.entries(attributes)) {
279
+ const attributeInfo = this._attributeInfos[attributeName];
280
+ if (attributeInfo) {
281
+ this.vertexArray.setConstant(attributeInfo.location, value);
282
+ } else {
283
+ log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
284
+ }
285
+ }
286
+ }
287
+ _setPipelineNeedsUpdate(reason) {
288
+ this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
289
+ }
290
+ _updatePipeline() {
291
+ if (this._pipelineNeedsUpdate) {
292
+ if (this.pipeline) {
293
+ log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
294
+ }
295
+ this._pipelineNeedsUpdate = false;
296
+ const vs = this.device.createShader({
297
+ id: `${this.id}-vertex`,
298
+ stage: 'vertex',
299
+ source: this.vs
300
+ });
301
+ const fs = this.fs ? this.device.createShader({
302
+ id: `${this.id}-fragment`,
303
+ stage: 'fragment',
304
+ source: this.fs
305
+ }) : null;
306
+ this.pipeline = this.device.createRenderPipeline({
307
+ ...this.props,
308
+ bufferLayout: this.bufferLayout,
309
+ topology: this.topology,
310
+ parameters: this.parameters,
311
+ vs,
312
+ fs
313
+ });
314
+ this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
315
+ }
316
+ return this.pipeline;
317
+ }
318
+ _logDrawCallStart() {
319
+ const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
320
+ if (log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
321
+ return;
322
+ }
323
+ this._lastLogTime = Date.now();
324
+ this._logOpen = true;
325
+ log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, {
326
+ collapsed: log.level <= 2
327
+ })();
328
+ }
329
+ _logDrawCallEnd() {
330
+ if (this._logOpen) {
331
+ const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
332
+ log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
333
+ const uniformTable = this.shaderInputs.getDebugTable();
334
+ for (const [name, value] of Object.entries(this.uniforms)) {
335
+ uniformTable[name] = {
336
+ value
337
+ };
338
+ }
339
+ log.table(LOG_DRAW_PRIORITY, uniformTable)();
340
+ const attributeTable = this._getAttributeDebugTable();
341
+ log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
342
+ log.table(LOG_DRAW_PRIORITY, attributeTable)();
343
+ log.groupEnd(LOG_DRAW_PRIORITY)();
344
+ this._logOpen = false;
345
+ }
346
+ }
347
+ _logFramebuffer(renderPass) {
348
+ const debugFramebuffers = log.get('framebuffer');
349
+ this._drawCount++;
350
+ if (!debugFramebuffers || this._drawCount++ > 3 && this._drawCount % 60) {
351
+ return;
352
+ }
353
+ const framebuffer = renderPass.props.framebuffer;
354
+ if (framebuffer) {
355
+ debugFramebuffer(framebuffer, {
356
+ id: framebuffer.id,
357
+ minimap: true
358
+ });
359
+ }
360
+ }
361
+ _getAttributeDebugTable() {
362
+ const table = {};
363
+ for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
364
+ table[attributeInfo.location] = {
365
+ name,
366
+ type: attributeInfo.shaderType,
367
+ values: this._getBufferOrConstantValues(this.vertexArray.attributes[attributeInfo.location], attributeInfo.bufferDataType)
368
+ };
369
+ }
370
+ if (this.vertexArray.indexBuffer) {
371
+ const {
372
+ indexBuffer
373
+ } = this.vertexArray;
374
+ const values = indexBuffer.indexType === 'uint32' ? new Uint32Array(indexBuffer.debugData) : new Uint16Array(indexBuffer.debugData);
375
+ table.indices = {
376
+ name: 'indices',
377
+ type: indexBuffer.indexType,
378
+ values: values.toString()
379
+ };
380
+ }
381
+ return table;
382
+ }
383
+ _getBufferOrConstantValues(attribute, dataType) {
384
+ const TypedArrayConstructor = getTypedArrayFromDataType(dataType);
385
+ const typedArray = attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
386
+ return typedArray.toString();
387
+ }
388
+ }
389
+ Model.defaultProps = {
390
+ ...RenderPipeline.defaultProps,
391
+ source: null,
392
+ vs: null,
393
+ fs: null,
394
+ id: 'unnamed',
395
+ handle: undefined,
396
+ userData: {},
397
+ defines: {},
398
+ modules: [],
399
+ moduleSettings: undefined,
400
+ geometry: null,
401
+ indexBuffer: null,
402
+ attributes: {},
403
+ constantAttributes: {},
404
+ varyings: [],
405
+ shaderInputs: undefined,
406
+ pipelineFactory: undefined,
407
+ transformFeedback: undefined,
408
+ shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
409
+ };
410
+ function mergeBufferLayouts(layouts1, layouts2) {
411
+ const layouts = [...layouts1];
412
+ for (const attribute of layouts2) {
413
+ const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);
414
+ if (index < 0) {
415
+ layouts.push(attribute);
416
+ } else {
417
+ layouts[index] = attribute;
418
+ }
419
+ }
420
+ return layouts;
421
+ }
422
+ export function getPlatformInfo(device) {
423
+ return {
424
+ type: device.info.type,
425
+ shaderLanguage: device.info.shadingLanguage,
426
+ shaderLanguageVersion: device.info.shadingLanguageVersion,
427
+ gpu: device.info.gpu,
428
+ features: device.features
429
+ };
430
+ }
431
+ function getAttributeNames(bufferLayout) {
432
+ var _bufferLayout$attribu;
433
+ return bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map(layout => layout.attribute) : [bufferLayout.name];
434
+ }
435
+ //# sourceMappingURL=model.js.map