@luma.gl/engine 9.0.0-alpha.5 → 9.0.0-alpha.51

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 (171) 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 +9 -9
  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/{lib → animation-loop}/animation-loop.d.ts +30 -31
  11. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  12. package/dist/{lib → animation-loop}/animation-loop.js +115 -199
  13. package/dist/animation-loop/animation-loop.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +6 -7
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js.map +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  19. package/dist/animation-loop/make-animation-loop.js +28 -0
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.d.ts +23 -0
  22. package/dist/animation-loop/render-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/render-loop.js +7 -0
  24. package/dist/animation-loop/render-loop.js.map +1 -0
  25. package/dist/dist.dev.js +7064 -0
  26. package/dist/geometries/cone-geometry.d.ts +1 -1
  27. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/cone-geometry.js +6 -5
  29. package/dist/geometries/cone-geometry.js.map +1 -1
  30. package/dist/geometries/cube-geometry.d.ts +2 -2
  31. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cube-geometry.js +15 -8
  33. package/dist/geometries/cube-geometry.js.map +1 -1
  34. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  35. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  36. package/dist/geometries/cylinder-geometry.js +6 -5
  37. package/dist/geometries/cylinder-geometry.js.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  39. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  40. package/dist/geometries/ico-sphere-geometry.js +10 -19
  41. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  42. package/dist/geometries/plane-geometry.d.ts +2 -2
  43. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  44. package/dist/geometries/plane-geometry.js +14 -23
  45. package/dist/geometries/plane-geometry.js.map +1 -1
  46. package/dist/geometries/sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/sphere-geometry.js +9 -13
  49. package/dist/geometries/sphere-geometry.js.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  51. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  52. package/dist/geometries/truncated-cone-geometry.js +9 -25
  53. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  54. package/dist/geometry/geometry-table.d.ts +2 -2
  55. package/dist/geometry/geometry-table.d.ts.map +1 -1
  56. package/dist/geometry/geometry-table.js.map +1 -1
  57. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  58. package/dist/geometry/geometry-utils.js +0 -9
  59. package/dist/geometry/geometry-utils.js.map +1 -1
  60. package/dist/geometry/geometry.d.ts +50 -59
  61. package/dist/geometry/geometry.d.ts.map +1 -1
  62. package/dist/geometry/geometry.js +32 -97
  63. package/dist/geometry/geometry.js.map +1 -1
  64. package/dist/geometry/gpu-geometry.d.ts +37 -0
  65. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  66. package/dist/geometry/gpu-geometry.js +107 -0
  67. package/dist/geometry/gpu-geometry.js.map +1 -0
  68. package/dist/geometry/gpu-table.d.ts +1 -0
  69. package/dist/geometry/gpu-table.d.ts.map +1 -0
  70. package/dist/geometry/gpu-table.js +2 -0
  71. package/dist/geometry/gpu-table.js.map +1 -0
  72. package/dist/index.cjs +2959 -0
  73. package/dist/index.d.ts +26 -9
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +23 -13
  76. package/dist/index.js.map +1 -1
  77. package/dist/lib/clip-space.d.ts +8 -0
  78. package/dist/lib/clip-space.d.ts.map +1 -1
  79. package/dist/lib/clip-space.js +47 -0
  80. package/dist/lib/clip-space.js.map +1 -1
  81. package/dist/lib/pipeline-factory.d.ts +12 -40
  82. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  83. package/dist/lib/pipeline-factory.js +50 -148
  84. package/dist/lib/pipeline-factory.js.map +1 -1
  85. package/dist/model/model.d.ts +192 -0
  86. package/dist/model/model.d.ts.map +1 -0
  87. package/dist/model/model.js +312 -0
  88. package/dist/model/model.js.map +1 -0
  89. package/dist/scenegraph/group-node.d.ts +21 -0
  90. package/dist/scenegraph/group-node.d.ts.map +1 -0
  91. package/dist/scenegraph/group-node.js +94 -0
  92. package/dist/scenegraph/group-node.js.map +1 -0
  93. package/dist/scenegraph/model-node.d.ts +18 -0
  94. package/dist/scenegraph/model-node.d.ts.map +1 -0
  95. package/dist/scenegraph/model-node.js +28 -0
  96. package/dist/scenegraph/model-node.js.map +1 -0
  97. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  98. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  99. package/dist/scenegraph/scenegraph-node.js +141 -0
  100. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  101. package/dist/shader-inputs.d.ts +62 -0
  102. package/dist/shader-inputs.d.ts.map +1 -0
  103. package/dist/shader-inputs.js +49 -0
  104. package/dist/shader-inputs.js.map +1 -0
  105. package/dist/transform/buffer-transform.d.ts +35 -0
  106. package/dist/transform/buffer-transform.d.ts.map +1 -0
  107. package/dist/transform/buffer-transform.js +62 -0
  108. package/dist/transform/buffer-transform.js.map +1 -0
  109. package/dist/transform/texture-transform.d.ts +57 -0
  110. package/dist/transform/texture-transform.d.ts.map +1 -0
  111. package/dist/transform/texture-transform.js +122 -0
  112. package/dist/transform/texture-transform.js.map +1 -0
  113. package/dist.min.js +286 -0
  114. package/package.json +21 -12
  115. package/src/animation/timeline.ts +16 -15
  116. package/src/{lib → animation-loop}/animation-loop.ts +120 -107
  117. package/src/{lib → animation-loop}/animation-props.ts +5 -5
  118. package/src/animation-loop/make-animation-loop.ts +44 -0
  119. package/src/animation-loop/render-loop.ts +23 -0
  120. package/src/geometries/cone-geometry.ts +1 -1
  121. package/src/geometries/cube-geometry.ts +6 -3
  122. package/src/geometries/cylinder-geometry.ts +2 -2
  123. package/src/geometries/ico-sphere-geometry.ts +7 -6
  124. package/src/geometries/plane-geometry.ts +5 -4
  125. package/src/geometries/sphere-geometry.ts +4 -3
  126. package/src/geometries/truncated-cone-geometry.ts +4 -13
  127. package/src/geometry/geometry-table.ts +1 -1
  128. package/src/geometry/geometry-utils.ts +3 -3
  129. package/src/geometry/geometry.ts +79 -119
  130. package/src/geometry/gpu-geometry.ts +124 -0
  131. package/src/geometry/gpu-table.ts +41 -0
  132. package/src/index.ts +38 -12
  133. package/src/lib/clip-space.ts +22 -21
  134. package/src/lib/pipeline-factory.ts +60 -168
  135. package/src/model/model.ts +549 -0
  136. package/src/scenegraph/group-node.ts +103 -0
  137. package/src/scenegraph/model-node.ts +50 -0
  138. package/src/scenegraph/scenegraph-node.ts +204 -0
  139. package/src/shader-inputs.ts +132 -0
  140. package/src/transform/buffer-transform.ts +94 -0
  141. package/src/transform/texture-transform.ts +169 -0
  142. package/dist/bundle.d.ts +0 -2
  143. package/dist/bundle.d.ts.map +0 -1
  144. package/dist/bundle.js +0 -5
  145. package/dist/bundle.js.map +0 -1
  146. package/dist/geometry/primitive-utils.d.ts +0 -1
  147. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  148. package/dist/geometry/primitive-utils.js +0 -2
  149. package/dist/geometry/primitive-utils.js.map +0 -1
  150. package/dist/lib/animation-loop.d.ts.map +0 -1
  151. package/dist/lib/animation-loop.js.map +0 -1
  152. package/dist/lib/animation-props.d.ts.map +0 -1
  153. package/dist/lib/animation-props.js.map +0 -1
  154. package/dist/lib/model-utils.d.ts +0 -5
  155. package/dist/lib/model-utils.d.ts.map +0 -1
  156. package/dist/lib/model-utils.js +0 -45
  157. package/dist/lib/model-utils.js.map +0 -1
  158. package/dist/lib/model.d.ts +0 -41
  159. package/dist/lib/model.d.ts.map +0 -1
  160. package/dist/lib/model.js +0 -176
  161. package/dist/lib/model.js.map +0 -1
  162. package/dist/lib/render-loop.d.ts +0 -14
  163. package/dist/lib/render-loop.d.ts.map +0 -1
  164. package/dist/lib/render-loop.js +0 -49
  165. package/dist/lib/render-loop.js.map +0 -1
  166. package/src/bundle.ts +0 -4
  167. package/src/geometry/primitive-utils.ts +0 -30
  168. package/src/lib/model-utils.ts +0 -124
  169. package/src/lib/model.ts +0 -179
  170. package/src/lib/render-loop.ts +0 -58
  171. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
@@ -0,0 +1,192 @@
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
+ vs: {
13
+ glsl?: string;
14
+ wgsl?: string;
15
+ } | string | null;
16
+ fs: {
17
+ glsl?: string;
18
+ wgsl?: string;
19
+ } | string | null;
20
+ /** shadertool shader modules (added to shader code) */
21
+ modules?: ShaderModule[];
22
+ /** Shadertool module defines (configures shader code)*/
23
+ defines?: Record<string, string | number | boolean>;
24
+ /** Shader inputs, used to generated uniform buffers and bindings */
25
+ shaderInputs?: ShaderInputs;
26
+ /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */
27
+ pipelineFactory?: PipelineFactory;
28
+ /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
29
+ shaderAssembler?: ShaderAssembler;
30
+ /** Parameters that are built into the pipeline */
31
+ parameters?: RenderPipelineParameters;
32
+ /** Geometry */
33
+ geometry?: GPUGeometry | Geometry | null;
34
+ /** Vertex count */
35
+ vertexCount?: number;
36
+ /** instance count */
37
+ instanceCount?: number;
38
+ indexBuffer?: Buffer | null;
39
+ /** @note this is really a map of buffers, not a map of attributes */
40
+ attributes?: Record<string, Buffer>;
41
+ /** */
42
+ constantAttributes?: Record<string, TypedArray>;
43
+ /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */
44
+ varyings?: string[];
45
+ transformFeedback?: TransformFeedback;
46
+ /** Mapped uniforms for shadertool modules */
47
+ moduleSettings?: Record<string, Record<string, any>>;
48
+ };
49
+ /**
50
+ * v9 Model API
51
+ * A model
52
+ * - automatically reuses pipelines (programs) when possible
53
+ * - automatically rebuilds pipelines if necessary to accommodate changed settings
54
+ * shadertools integration
55
+ * - accepts modules and performs shader transpilation
56
+ */
57
+ export declare class Model {
58
+ static defaultProps: Required<ModelProps>;
59
+ readonly device: Device;
60
+ readonly id: string;
61
+ readonly vs: string;
62
+ readonly fs: string;
63
+ readonly pipelineFactory: PipelineFactory;
64
+ userData: {
65
+ [key: string]: any;
66
+ };
67
+ /** The render pipeline GPU parameters, depth testing etc */
68
+ parameters: RenderPipelineParameters;
69
+ /** The primitive topology */
70
+ topology: PrimitiveTopology;
71
+ /** Buffer layout */
72
+ bufferLayout: BufferLayout[];
73
+ /** Vertex count */
74
+ vertexCount: number;
75
+ /** instance count */
76
+ instanceCount: number;
77
+ /** Index buffer */
78
+ indexBuffer: Buffer | null;
79
+ /** Buffer-valued attributes */
80
+ bufferAttributes: Record<string, Buffer>;
81
+ /** Constant-valued attributes */
82
+ constantAttributes: Record<string, TypedArray>;
83
+ /** Bindings (textures, samplers, uniform buffers) */
84
+ bindings: Record<string, Binding>;
85
+ /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/
86
+ uniforms: Record<string, UniformValue>;
87
+ /**
88
+ * VertexArray
89
+ * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
90
+ * @todo - allow application to define multiple vertex arrays?
91
+ * */
92
+ vertexArray: VertexArray;
93
+ /** TransformFeedback, WebGL 2 only. */
94
+ transformFeedback: TransformFeedback | null;
95
+ /** The underlying GPU "program". @note May be recreated if parameters change */
96
+ pipeline: RenderPipeline;
97
+ /** ShaderInputs instance */
98
+ shaderInputs: ShaderInputs;
99
+ _uniformStore: UniformStore;
100
+ _pipelineNeedsUpdate: string | false;
101
+ _attributeInfos: Record<string, AttributeInfo>;
102
+ _gpuGeometry: GPUGeometry | null;
103
+ private _getModuleUniforms;
104
+ private props;
105
+ constructor(device: Device, props: ModelProps);
106
+ destroy(): void;
107
+ predraw(): void;
108
+ draw(renderPass: RenderPass): void;
109
+ /**
110
+ * Updates the optional geometry
111
+ * Geometry, set topology and bufferLayout
112
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
113
+ */
114
+ setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry;
115
+ /**
116
+ * Updates the optional geometry attributes
117
+ * Geometry, sets several attributes, indexBuffer, and also vertex count
118
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
119
+ */
120
+ _setGeometryAttributes(gpuGeometry: GPUGeometry): void;
121
+ /**
122
+ * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
123
+ * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
124
+ */
125
+ setTopology(topology: PrimitiveTopology): void;
126
+ /**
127
+ * Updates the buffer layout.
128
+ * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
129
+ */
130
+ setBufferLayout(bufferLayout: BufferLayout[]): void;
131
+ /**
132
+ * Set GPU parameters.
133
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch.
134
+ * @param parameters
135
+ */
136
+ setParameters(parameters: RenderPipelineParameters): void;
137
+ /**
138
+ * Updates the vertex count (used in draw calls)
139
+ * @note Any attributes with stepMode=vertex need to be at least this big
140
+ */
141
+ setVertexCount(vertexCount: number): void;
142
+ /**
143
+ * Updates the instance count (used in draw calls)
144
+ * @note Any attributes with stepMode=instance need to be at least this big
145
+ */
146
+ setInstanceCount(instanceCount: number): void;
147
+ setShaderInputs(shaderInputs: ShaderInputs): void;
148
+ updateShaderInputs(): void;
149
+ /**
150
+ * @deprecated Updates shader module settings (which results in uniforms being set)
151
+ */
152
+ updateModuleSettings(props: Record<string, any>): void;
153
+ /**
154
+ * Sets bindings (textures, samplers, uniform buffers)
155
+ */
156
+ setBindings(bindings: Record<string, Binding>): void;
157
+ /**
158
+ * Sets individual uniforms
159
+ * @deprecated WebGL only, use uniform buffers for portability
160
+ * @param uniforms
161
+ * @returns self for chaining
162
+ */
163
+ setUniforms(uniforms: Record<string, UniformValue>): void;
164
+ /**
165
+ * Sets the index buffer
166
+ * @todo - how to unset it if we change geometry?
167
+ */
168
+ setIndexBuffer(indexBuffer: Buffer | null): void;
169
+ /**
170
+ * Updates optional transform feedback. WebGL 2 only.
171
+ */
172
+ setTransformFeedback(transformFeedback: TransformFeedback | null): void;
173
+ /**
174
+ * Sets attributes (buffers)
175
+ * @note Overrides any attributes previously set with the same name
176
+ */
177
+ setAttributes(buffers: Record<string, Buffer>): void;
178
+ /**
179
+ * Sets constant attributes
180
+ * @note Overrides any attributes previously set with the same name
181
+ * Constant attributes are only supported in WebGL, not in WebGPU
182
+ * Any attribute that is disabled in the current vertex array object
183
+ * is read from the context's global constant value for that attribute location.
184
+ * @param constantAttributes
185
+ */
186
+ setConstantAttributes(attributes: Record<string, TypedArray>): void;
187
+ _setPipelineNeedsUpdate(reason: string): void;
188
+ _updatePipeline(): RenderPipeline;
189
+ }
190
+ /** Create a shadertools platform info from the Device */
191
+ export declare function getPlatformInfo(device: Device): PlatformInfo;
192
+ //# 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,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAGvF,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,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;AAExD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAEhE,EAAE,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;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IAAI,GAAG,IAAI;IAIvE;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAiCpD;;;;;;;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;CA8BlC;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAQ5D"}
@@ -0,0 +1,312 @@
1
+ import { RenderPipeline, UniformStore } from '@luma.gl/core';
2
+ import { log, uid, deepEqual, splitUniformsAndBindings } from '@luma.gl/core';
3
+ import { getAttributeInfosFromLayouts } from '@luma.gl/core';
4
+ import { ShaderAssembler } 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
+ export class Model {
9
+ constructor(device, props) {
10
+ var _this$props$modules, _this$props$modules2, _this$shaderInputs;
11
+ this.device = void 0;
12
+ this.id = void 0;
13
+ this.vs = void 0;
14
+ this.fs = void 0;
15
+ this.pipelineFactory = void 0;
16
+ this.userData = {};
17
+ this.parameters = void 0;
18
+ this.topology = void 0;
19
+ this.bufferLayout = void 0;
20
+ this.vertexCount = void 0;
21
+ this.instanceCount = 0;
22
+ this.indexBuffer = null;
23
+ this.bufferAttributes = {};
24
+ this.constantAttributes = {};
25
+ this.bindings = {};
26
+ this.uniforms = {};
27
+ this.vertexArray = void 0;
28
+ this.transformFeedback = null;
29
+ this.pipeline = void 0;
30
+ this.shaderInputs = void 0;
31
+ this._uniformStore = void 0;
32
+ this._pipelineNeedsUpdate = 'newly created';
33
+ this._attributeInfos = {};
34
+ this._gpuGeometry = null;
35
+ this._getModuleUniforms = void 0;
36
+ this.props = void 0;
37
+ this.props = {
38
+ ...Model.defaultProps,
39
+ ...props
40
+ };
41
+ props = this.props;
42
+ this.id = props.id || uid('model');
43
+ this.device = device;
44
+ Object.assign(this.userData, props.userData);
45
+ 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])) || []);
46
+ this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));
47
+ const platformInfo = getPlatformInfo(device);
48
+ 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()) || [];
49
+ const {
50
+ vs,
51
+ fs,
52
+ getUniforms
53
+ } = this.props.shaderAssembler.assembleShaders({
54
+ platformInfo,
55
+ ...this.props,
56
+ modules
57
+ });
58
+ this.vs = vs;
59
+ this.fs = fs;
60
+ this._getModuleUniforms = getUniforms;
61
+ this.vertexCount = this.props.vertexCount;
62
+ this.instanceCount = this.props.instanceCount;
63
+ this.topology = this.props.topology;
64
+ this.bufferLayout = this.props.bufferLayout;
65
+ this.parameters = this.props.parameters;
66
+ if (props.geometry) {
67
+ this._gpuGeometry = this.setGeometry(props.geometry);
68
+ }
69
+ this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
70
+ this.pipeline = this._updatePipeline();
71
+ this.vertexArray = device.createVertexArray({
72
+ renderPipeline: this.pipeline
73
+ });
74
+ if (this._gpuGeometry) {
75
+ this._setGeometryAttributes(this._gpuGeometry);
76
+ }
77
+ if (props.vertexCount) {
78
+ this.setVertexCount(props.vertexCount);
79
+ }
80
+ if (props.instanceCount) {
81
+ this.setInstanceCount(props.instanceCount);
82
+ }
83
+ if (props.indices) {
84
+ throw new Error('Model.props.indices removed. Use props.indexBuffer');
85
+ }
86
+ if (props.indexBuffer) {
87
+ this.setIndexBuffer(props.indexBuffer);
88
+ }
89
+ if (props.attributes) {
90
+ this.setAttributes(props.attributes);
91
+ }
92
+ if (props.constantAttributes) {
93
+ this.setConstantAttributes(props.constantAttributes);
94
+ }
95
+ if (props.bindings) {
96
+ this.setBindings(props.bindings);
97
+ }
98
+ if (props.uniforms) {
99
+ this.setUniforms(props.uniforms);
100
+ }
101
+ if (props.moduleSettings) {
102
+ console.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()');
103
+ this.updateModuleSettings(props.moduleSettings);
104
+ }
105
+ if (props.transformFeedback) {
106
+ this.transformFeedback = props.transformFeedback;
107
+ }
108
+ Object.seal(this);
109
+ }
110
+ destroy() {
111
+ this.pipelineFactory.release(this.pipeline);
112
+ this._uniformStore.destroy();
113
+ }
114
+ predraw() {
115
+ this.updateShaderInputs();
116
+ }
117
+ draw(renderPass) {
118
+ this.predraw();
119
+ this.pipeline = this._updatePipeline();
120
+ this.pipeline.setBindings(this.bindings);
121
+ this.pipeline.setUniforms(this.uniforms);
122
+ this.pipeline.draw({
123
+ renderPass,
124
+ vertexArray: this.vertexArray,
125
+ vertexCount: this.vertexCount,
126
+ instanceCount: this.instanceCount,
127
+ transformFeedback: this.transformFeedback
128
+ });
129
+ }
130
+ setGeometry(geometry) {
131
+ const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
132
+ this.setTopology(gpuGeometry.topology || 'triangle-list');
133
+ this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
134
+ if (this.vertexArray) {
135
+ this._setGeometryAttributes(gpuGeometry);
136
+ }
137
+ return gpuGeometry;
138
+ }
139
+ _setGeometryAttributes(gpuGeometry) {
140
+ this.vertexCount = gpuGeometry.vertexCount;
141
+ this.setAttributes(gpuGeometry.attributes);
142
+ this.setIndexBuffer(gpuGeometry.indices);
143
+ }
144
+ setTopology(topology) {
145
+ if (topology !== this.topology) {
146
+ this.topology = topology;
147
+ this._setPipelineNeedsUpdate('topology');
148
+ }
149
+ }
150
+ setBufferLayout(bufferLayout) {
151
+ this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
152
+ this._setPipelineNeedsUpdate('bufferLayout');
153
+ this.pipeline = this._updatePipeline();
154
+ this.vertexArray = this.device.createVertexArray({
155
+ renderPipeline: this.pipeline
156
+ });
157
+ if (this._gpuGeometry) {
158
+ this._setGeometryAttributes(this._gpuGeometry);
159
+ }
160
+ }
161
+ setParameters(parameters) {
162
+ if (!deepEqual(parameters, this.parameters, 2)) {
163
+ this.parameters = parameters;
164
+ this._setPipelineNeedsUpdate('parameters');
165
+ }
166
+ }
167
+ setVertexCount(vertexCount) {
168
+ this.vertexCount = vertexCount;
169
+ }
170
+ setInstanceCount(instanceCount) {
171
+ this.instanceCount = instanceCount;
172
+ }
173
+ setShaderInputs(shaderInputs) {
174
+ this.shaderInputs = shaderInputs;
175
+ this._uniformStore = new UniformStore(this.shaderInputs.modules);
176
+ for (const moduleName of Object.keys(this.shaderInputs.modules)) {
177
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
178
+ this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
179
+ }
180
+ }
181
+ updateShaderInputs() {
182
+ this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
183
+ }
184
+ updateModuleSettings(props) {
185
+ console.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()');
186
+ const {
187
+ bindings,
188
+ uniforms
189
+ } = splitUniformsAndBindings(this._getModuleUniforms(props));
190
+ Object.assign(this.bindings, bindings);
191
+ Object.assign(this.uniforms, uniforms);
192
+ }
193
+ setBindings(bindings) {
194
+ Object.assign(this.bindings, bindings);
195
+ }
196
+ setUniforms(uniforms) {
197
+ this.pipeline.setUniforms(uniforms);
198
+ Object.assign(this.uniforms, uniforms);
199
+ }
200
+ setIndexBuffer(indexBuffer) {
201
+ this.vertexArray.setIndexBuffer(indexBuffer);
202
+ }
203
+ setTransformFeedback(transformFeedback) {
204
+ this.transformFeedback = transformFeedback;
205
+ }
206
+ setAttributes(buffers) {
207
+ if (buffers.indices) {
208
+ log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
209
+ }
210
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
211
+ var _bufferLayout$attribu;
212
+ const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);
213
+ if (!bufferLayout) {
214
+ log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
215
+ continue;
216
+ }
217
+ const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map(layout => layout.attribute) : [bufferLayout.name];
218
+ let set = false;
219
+ for (const attributeName of attributeNames) {
220
+ const attributeInfo = this._attributeInfos[attributeName];
221
+ if (attributeInfo) {
222
+ this.vertexArray.setBuffer(attributeInfo.location, buffer);
223
+ set = true;
224
+ }
225
+ }
226
+ if (!set) {
227
+ log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
228
+ }
229
+ }
230
+ }
231
+ setConstantAttributes(attributes) {
232
+ for (const [attributeName, value] of Object.entries(attributes)) {
233
+ const attributeInfo = this._attributeInfos[attributeName];
234
+ if (attributeInfo) {
235
+ this.vertexArray.setConstant(attributeInfo.location, value);
236
+ } else {
237
+ log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
238
+ }
239
+ }
240
+ }
241
+ _setPipelineNeedsUpdate(reason) {
242
+ this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
243
+ }
244
+ _updatePipeline() {
245
+ if (this._pipelineNeedsUpdate) {
246
+ if (this.pipeline) {
247
+ log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
248
+ }
249
+ this._pipelineNeedsUpdate = false;
250
+ this.pipeline = this.device.createRenderPipeline({
251
+ ...this.props,
252
+ bufferLayout: this.bufferLayout,
253
+ topology: this.topology,
254
+ parameters: this.parameters,
255
+ vs: this.device.createShader({
256
+ id: '{$this.id}-vertex',
257
+ stage: 'vertex',
258
+ source: this.vs
259
+ }),
260
+ fs: this.fs ? this.device.createShader({
261
+ id: '{$this.id}-fragment',
262
+ stage: 'fragment',
263
+ source: this.fs
264
+ }) : null
265
+ });
266
+ this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
267
+ }
268
+ return this.pipeline;
269
+ }
270
+ }
271
+ Model.defaultProps = {
272
+ ...RenderPipeline.defaultProps,
273
+ vs: null,
274
+ fs: null,
275
+ id: 'unnamed',
276
+ handle: undefined,
277
+ userData: {},
278
+ defines: {},
279
+ modules: [],
280
+ moduleSettings: undefined,
281
+ geometry: null,
282
+ indexBuffer: null,
283
+ attributes: {},
284
+ constantAttributes: {},
285
+ varyings: [],
286
+ shaderInputs: undefined,
287
+ pipelineFactory: undefined,
288
+ transformFeedback: undefined,
289
+ shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
290
+ };
291
+ function mergeBufferLayouts(layouts1, layouts2) {
292
+ const layouts = [...layouts1];
293
+ for (const attribute of layouts2) {
294
+ const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);
295
+ if (index < 0) {
296
+ layouts.push(attribute);
297
+ } else {
298
+ layouts[index] = attribute;
299
+ }
300
+ }
301
+ return layouts;
302
+ }
303
+ export function getPlatformInfo(device) {
304
+ return {
305
+ type: device.info.type,
306
+ shaderLanguage: device.info.shadingLanguage,
307
+ shaderLanguageVersion: device.info.shadingLanguageVersion,
308
+ gpu: device.info.gpu,
309
+ features: device.features
310
+ };
311
+ }
312
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":["RenderPipeline","UniformStore","log","uid","deepEqual","splitUniformsAndBindings","getAttributeInfosFromLayouts","ShaderAssembler","ShaderInputs","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","_this$props$modules","_this$props$modules2","_this$shaderInputs","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","vertexArray","transformFeedback","pipeline","shaderInputs","_uniformStore","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","moduleMap","fromEntries","modules","map","module","name","setShaderInputs","platformInfo","getPlatformInfo","length","getModules","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","console","warn","updateModuleSettings","seal","destroy","release","predraw","updateShaderInputs","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","moduleName","keys","uniformBuffer","getManagedUniformBuffer","getUniformValues","setTransformFeedback","buffers","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","attributeNames","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","varyings","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push","type","info","shaderLanguage","shadingLanguage","shaderLanguageVersion","shadingLanguageVersion","gpu","features"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';\nimport type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';\nimport type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core';\nimport {log, uid, deepEqual, splitUniformsAndBindings} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport {ShaderInputs} from '../shader-inputs';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string shaders\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** Shader inputs, used to generated uniform buffers and bindings */\n shaderInputs?: ShaderInputs;\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */\n varyings?: string[];\n\n transformFeedback?: TransformFeedback;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: undefined!,\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n varyings: [],\n\n shaderInputs: undefined!,\n pipelineFactory: undefined!,\n transformFeedback: undefined,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n /** TransformFeedback, WebGL 2 only. */\n transformFeedback: TransformFeedback | null = null;\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /** ShaderInputs instance */\n shaderInputs: ShaderInputs;\n\n _uniformStore: UniformStore;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n // Setup shader module inputs\n const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);\n this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));\n\n // Setup shader assembler\n const platformInfo = getPlatformInfo(device);\n const modules = (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({platformInfo, ...this.props, modules});\n\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer');\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n // eslint-disable-next-line no-console\n console.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()');\n this.updateModuleSettings(props.moduleSettings);\n }\n if (props.transformFeedback) {\n this.transformFeedback = props.transformFeedback;\n }\n\n // WebGL1?\n // this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n this._uniformStore.destroy();\n }\n\n // Draw call\n\n predraw() {\n // Update uniform buffers if needed\n this.updateShaderInputs();\n }\n\n draw(renderPass: RenderPass): void {\n this.predraw();\n\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount,\n transformFeedback: this.transformFeedback\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n\n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n setShaderInputs(shaderInputs: ShaderInputs): void {\n this.shaderInputs = shaderInputs;\n this._uniformStore = new UniformStore(this.shaderInputs.modules);\n // Create uniform buffer bindings for all modules\n for (const moduleName of Object.keys(this.shaderInputs.modules)) {\n const uniformBuffer = this._uniformStore.getManagedUniformBuffer(\n this.device,\n moduleName\n );\n this.bindings[`${moduleName}Uniforms`] = uniformBuffer;\n }\n }\n\n updateShaderInputs(): void {\n this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n // eslint-disable-next-line no-console\n console.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()');\n const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));\n Object.assign(this.bindings, bindings);\n Object.assign(this.uniforms, uniforms);\n }\n \n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Updates optional transform feedback. WebGL 2 only.\n */\n setTransformFeedback(transformFeedback: TransformFeedback | null): void {\n this.transformFeedback = transformFeedback;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n log.warn(`Model(${this.id}): Missing layout for buffer \"${bufferName}\".`)();\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(\n `Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`\n )();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(\n 1,\n `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`\n )();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs\n ? this.device.createShader({\n id: '{$this.id}-fragment',\n stage: 'fragment',\n source: this.fs\n })\n : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\n\n// HELPERS\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n\n/** Create a shadertools platform info from the Device */\nexport function getPlatformInfo(device: Device): PlatformInfo {\n return {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguage,\n shaderLanguageVersion: device.info.shadingLanguageVersion as 100 | 300,\n gpu: device.info.gpu,\n features: device.features\n };\n}\n"],"mappings":"AAMA,SAAwBA,cAAc,EAAcC,YAAY,QAAO,eAAe;AACtF,SAAQC,GAAG,EAAEC,GAAG,EAAEC,SAAS,EAAEC,wBAAwB,QAAO,eAAe;AAC3E,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAC7CC,YAAY;AAAA,SAECC,eAAe;AAAA,SAC5BC,eAAe;AAqDvB,OAAO,MAAMC,KAAK,CAAC;EAkFjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,IAAAC,mBAAA,EAAAC,oBAAA,EAAAC,kBAAA;IAAA,KA3DtCJ,MAAM;IAAA,KACNK,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,WAAW,GAAkB,IAAI;IAAA,KAEjCC,gBAAgB,GAA2B,CAAC,CAAC;IAAA,KAE7CC,kBAAkB,GAA+B,CAAC,CAAC;IAAA,KAEnDC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAO3CC,WAAW;IAAA,KAGXC,iBAAiB,GAA6B,IAAI;IAAA,KAGlDC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ACjF,IAAI+E,KAAK,GAAG,CAAC,EAAE;MACbD,OAAO,CAACI,IAAI,CAACzB,SAAS,CAAC;IACzB,CAAC,MAAM;MACLqB,OAAO,CAACC,KAAK,CAAC,GAAGtB,SAAS;IAC5B;EACF;EACA,OAAOqB,OAAO;AAChB;AAGA,OAAO,SAAS3E,eAAeA,CAACxC,MAAc,EAAgB;EAC5D,OAAO;IACLwH,IAAI,EAAExH,MAAM,CAACyH,IAAI,CAACD,IAAI;IACtBE,cAAc,EAAE1H,MAAM,CAACyH,IAAI,CAACE,eAAe;IAC3CC,qBAAqB,EAAE5H,MAAM,CAACyH,IAAI,CAACI,sBAAmC;IACtEC,GAAG,EAAE9H,MAAM,CAACyH,IAAI,CAACK,GAAG;IACpBC,QAAQ,EAAE/H,MAAM,CAAC+H;EACnB,CAAC;AACH"}
@@ -0,0 +1,21 @@
1
+ import { Matrix4 } from '@math.gl/core';
2
+ import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
3
+ export type GroupNodeProps = ScenegraphNodeProps & {
4
+ children?: ScenegraphNode[];
5
+ };
6
+ export declare class GroupNode extends ScenegraphNode {
7
+ children: ScenegraphNode[];
8
+ constructor(children: ScenegraphNode[]);
9
+ constructor(props?: GroupNodeProps);
10
+ getBounds(): [number[], number[]] | null;
11
+ destroy(): void;
12
+ add(...children: (ScenegraphNode | ScenegraphNode[])[]): this;
13
+ remove(child: ScenegraphNode): this;
14
+ removeAll(): this;
15
+ traverse(visitor: (node: ScenegraphNode, context: {
16
+ worldMatrix: Matrix4;
17
+ }) => void, { worldMatrix }?: {
18
+ worldMatrix?: Matrix4;
19
+ }): void;
20
+ }
21
+ //# sourceMappingURL=group-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAA;AAED,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,EAAE,cAAc,EAAE,CAAC;gBAEf,QAAQ,EAAE,cAAc,EAAE;gBAC1B,KAAK,CAAC,EAAE,cAAc;IAazB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAkCxC,OAAO,IAAI,IAAI;IAOxB,GAAG,CAAC,GAAG,QAAQ,EAAE,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,IAAI;IAW7D,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IASnC,SAAS,IAAI,IAAI;IAKjB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,EAAE,EAAC,WAA2B,EAAC;;KAAK;CAWtH"}