@luma.gl/engine 9.0.9 → 9.0.10
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.
- package/dist/dist.dev.js +129 -263
- package/dist/dist.min.js +10 -10
- package/dist/index.cjs +26 -12
- package/dist/index.cjs.map +2 -2
- package/dist/model/model.d.ts +17 -9
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +28 -12
- package/package.json +3 -3
- package/src/model/model.ts +37 -16
package/dist/model/model.d.ts
CHANGED
|
@@ -20,14 +20,18 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
20
20
|
defines?: Record<string, string | number | boolean>;
|
|
21
21
|
/** Shader inputs, used to generated uniform buffers and bindings */
|
|
22
22
|
shaderInputs?: ShaderInputs;
|
|
23
|
+
/** Bindings */
|
|
24
|
+
bindings?: Record<string, Binding>;
|
|
23
25
|
/** Parameters that are built into the pipeline */
|
|
24
26
|
parameters?: RenderPipelineParameters;
|
|
25
27
|
/** Geometry */
|
|
26
28
|
geometry?: GPUGeometry | Geometry | null;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
+
/** @deprecated Use instanced rendering? Will be auto-detected in 9.1 */
|
|
30
|
+
isInstanced?: boolean;
|
|
29
31
|
/** instance count */
|
|
30
32
|
instanceCount?: number;
|
|
33
|
+
/** Vertex count */
|
|
34
|
+
vertexCount?: number;
|
|
31
35
|
indexBuffer?: Buffer | null;
|
|
32
36
|
/** @note this is really a map of buffers, not a map of attributes */
|
|
33
37
|
attributes?: Record<string, Buffer>;
|
|
@@ -75,10 +79,12 @@ export declare class Model {
|
|
|
75
79
|
topology: PrimitiveTopology;
|
|
76
80
|
/** Buffer layout */
|
|
77
81
|
bufferLayout: BufferLayout[];
|
|
82
|
+
/** Use instanced rendering */
|
|
83
|
+
isInstanced: boolean | undefined;
|
|
84
|
+
/** instance count. `undefined` means not instanced */
|
|
85
|
+
instanceCount: number;
|
|
78
86
|
/** Vertex count */
|
|
79
87
|
vertexCount: number;
|
|
80
|
-
/** instance count */
|
|
81
|
-
instanceCount: number;
|
|
82
88
|
/** Index buffer */
|
|
83
89
|
indexBuffer: Buffer | null;
|
|
84
90
|
/** Buffer-valued attributes */
|
|
@@ -141,17 +147,19 @@ export declare class Model {
|
|
|
141
147
|
* @param parameters
|
|
142
148
|
*/
|
|
143
149
|
setParameters(parameters: RenderPipelineParameters): void;
|
|
144
|
-
/**
|
|
145
|
-
* Updates the vertex count (used in draw calls)
|
|
146
|
-
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
147
|
-
*/
|
|
148
|
-
setVertexCount(vertexCount: number): void;
|
|
149
150
|
/**
|
|
150
151
|
* Updates the instance count (used in draw calls)
|
|
151
152
|
* @note Any attributes with stepMode=instance need to be at least this big
|
|
152
153
|
*/
|
|
153
154
|
setInstanceCount(instanceCount: number): void;
|
|
155
|
+
/**
|
|
156
|
+
* Updates the vertex count (used in draw calls)
|
|
157
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
158
|
+
*/
|
|
159
|
+
setVertexCount(vertexCount: number): void;
|
|
160
|
+
/** Set the shader inputs */
|
|
154
161
|
setShaderInputs(shaderInputs: ShaderInputs): void;
|
|
162
|
+
/** Update uniform buffers from the model's shader inputs */
|
|
155
163
|
updateShaderInputs(): void;
|
|
156
164
|
/**
|
|
157
165
|
* Sets bindings (textures, samplers, uniform buffers)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAC,YAAY,EAAU,WAAW,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAA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AAE,UAAU,CAAC,EACtC,OAAO,CAAC,EAAE;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAC,GACpC,IAAI;IAgBP;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAQzD;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAUtD,0FAA0F;IAC1F,2BAA2B,IAAI,MAAM;IAcrC;;;;OAIG;IACH,sBAAsB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBtD,sCAAsC;IACtC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK7C,gCAAgC;IAChC,eAAe,IAAI,cAAc;IAsDjC,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,CAS5D"}
|
package/dist/model/model.js
CHANGED
|
@@ -39,6 +39,9 @@ export class Model {
|
|
|
39
39
|
attributes: {},
|
|
40
40
|
constantAttributes: {},
|
|
41
41
|
varyings: [],
|
|
42
|
+
isInstanced: undefined,
|
|
43
|
+
instanceCount: 0,
|
|
44
|
+
vertexCount: 0,
|
|
42
45
|
shaderInputs: undefined,
|
|
43
46
|
pipelineFactory: undefined,
|
|
44
47
|
shaderFactory: undefined,
|
|
@@ -63,10 +66,12 @@ export class Model {
|
|
|
63
66
|
/** Buffer layout */
|
|
64
67
|
bufferLayout;
|
|
65
68
|
// Dynamic properties
|
|
69
|
+
/** Use instanced rendering */
|
|
70
|
+
isInstanced = undefined;
|
|
71
|
+
/** instance count. `undefined` means not instanced */
|
|
72
|
+
instanceCount = 0;
|
|
66
73
|
/** Vertex count */
|
|
67
74
|
vertexCount;
|
|
68
|
-
/** instance count */
|
|
69
|
-
instanceCount = 0;
|
|
70
75
|
/** Index buffer */
|
|
71
76
|
indexBuffer = null;
|
|
72
77
|
/** Buffer-valued attributes */
|
|
@@ -161,12 +166,15 @@ export class Model {
|
|
|
161
166
|
this._setGeometryAttributes(this._gpuGeometry);
|
|
162
167
|
}
|
|
163
168
|
// Apply any dynamic settings that will not trigger pipeline change
|
|
164
|
-
if (props.
|
|
165
|
-
this.
|
|
169
|
+
if (props.isInstanced) {
|
|
170
|
+
this.isInstanced = props.isInstanced;
|
|
166
171
|
}
|
|
167
172
|
if (props.instanceCount) {
|
|
168
173
|
this.setInstanceCount(props.instanceCount);
|
|
169
174
|
}
|
|
175
|
+
if (props.vertexCount) {
|
|
176
|
+
this.setVertexCount(props.vertexCount);
|
|
177
|
+
}
|
|
170
178
|
if (props.indexBuffer) {
|
|
171
179
|
this.setIndexBuffer(props.indexBuffer);
|
|
172
180
|
}
|
|
@@ -248,6 +256,7 @@ export class Model {
|
|
|
248
256
|
drawSuccess = this.pipeline.draw({
|
|
249
257
|
renderPass,
|
|
250
258
|
vertexArray: this.vertexArray,
|
|
259
|
+
isInstanced: this.isInstanced,
|
|
251
260
|
vertexCount: this.vertexCount,
|
|
252
261
|
instanceCount: this.instanceCount,
|
|
253
262
|
indexCount,
|
|
@@ -334,22 +343,28 @@ export class Model {
|
|
|
334
343
|
}
|
|
335
344
|
}
|
|
336
345
|
// Update dynamic fields
|
|
337
|
-
/**
|
|
338
|
-
* Updates the vertex count (used in draw calls)
|
|
339
|
-
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
340
|
-
*/
|
|
341
|
-
setVertexCount(vertexCount) {
|
|
342
|
-
this.vertexCount = vertexCount;
|
|
343
|
-
this.setNeedsRedraw('vertexCount');
|
|
344
|
-
}
|
|
345
346
|
/**
|
|
346
347
|
* Updates the instance count (used in draw calls)
|
|
347
348
|
* @note Any attributes with stepMode=instance need to be at least this big
|
|
348
349
|
*/
|
|
349
350
|
setInstanceCount(instanceCount) {
|
|
350
351
|
this.instanceCount = instanceCount;
|
|
352
|
+
// luma.gl examples don't set props.isInstanced and rely on auto-detection
|
|
353
|
+
// but deck.gl sets instanceCount even for models that are not instanced.
|
|
354
|
+
if (this.isInstanced === undefined && instanceCount > 0) {
|
|
355
|
+
this.isInstanced = true;
|
|
356
|
+
}
|
|
351
357
|
this.setNeedsRedraw('instanceCount');
|
|
352
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Updates the vertex count (used in draw calls)
|
|
361
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
362
|
+
*/
|
|
363
|
+
setVertexCount(vertexCount) {
|
|
364
|
+
this.vertexCount = vertexCount;
|
|
365
|
+
this.setNeedsRedraw('vertexCount');
|
|
366
|
+
}
|
|
367
|
+
/** Set the shader inputs */
|
|
353
368
|
setShaderInputs(shaderInputs) {
|
|
354
369
|
this.shaderInputs = shaderInputs;
|
|
355
370
|
this._uniformStore = new UniformStore(this.shaderInputs.modules);
|
|
@@ -360,6 +375,7 @@ export class Model {
|
|
|
360
375
|
}
|
|
361
376
|
this.setNeedsRedraw('shaderInputs');
|
|
362
377
|
}
|
|
378
|
+
/** Update uniform buffers from the model's shader inputs */
|
|
363
379
|
updateShaderInputs() {
|
|
364
380
|
this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
|
|
365
381
|
// TODO - this is already tracked through buffer/texture update times?
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.10",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@luma.gl/core": "^9.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/shadertools": "9.0.
|
|
46
|
+
"@luma.gl/shadertools": "9.0.10",
|
|
47
47
|
"@math.gl/core": "^4.0.0",
|
|
48
48
|
"@probe.gl/log": "^4.0.2",
|
|
49
49
|
"@probe.gl/stats": "^4.0.2"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "aa5e354fd9502a84e43c9e312ad33d9c155fed01"
|
|
52
52
|
}
|
package/src/model/model.ts
CHANGED
|
@@ -38,17 +38,20 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
38
38
|
|
|
39
39
|
/** Shader inputs, used to generated uniform buffers and bindings */
|
|
40
40
|
shaderInputs?: ShaderInputs;
|
|
41
|
-
|
|
41
|
+
/** Bindings */
|
|
42
|
+
bindings?: Record<string, Binding>;
|
|
42
43
|
/** Parameters that are built into the pipeline */
|
|
43
44
|
parameters?: RenderPipelineParameters;
|
|
44
45
|
|
|
45
46
|
/** Geometry */
|
|
46
47
|
geometry?: GPUGeometry | Geometry | null;
|
|
47
48
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
49
|
+
/** @deprecated Use instanced rendering? Will be auto-detected in 9.1 */
|
|
50
|
+
isInstanced?: boolean;
|
|
50
51
|
/** instance count */
|
|
51
52
|
instanceCount?: number;
|
|
53
|
+
/** Vertex count */
|
|
54
|
+
vertexCount?: number;
|
|
52
55
|
|
|
53
56
|
indexBuffer?: Buffer | null;
|
|
54
57
|
/** @note this is really a map of buffers, not a map of attributes */
|
|
@@ -104,6 +107,10 @@ export class Model {
|
|
|
104
107
|
constantAttributes: {},
|
|
105
108
|
varyings: [],
|
|
106
109
|
|
|
110
|
+
isInstanced: undefined!,
|
|
111
|
+
instanceCount: 0,
|
|
112
|
+
vertexCount: 0,
|
|
113
|
+
|
|
107
114
|
shaderInputs: undefined!,
|
|
108
115
|
pipelineFactory: undefined!,
|
|
109
116
|
shaderFactory: undefined!,
|
|
@@ -135,10 +142,12 @@ export class Model {
|
|
|
135
142
|
|
|
136
143
|
// Dynamic properties
|
|
137
144
|
|
|
145
|
+
/** Use instanced rendering */
|
|
146
|
+
isInstanced: boolean | undefined = undefined;
|
|
147
|
+
/** instance count. `undefined` means not instanced */
|
|
148
|
+
instanceCount: number = 0;
|
|
138
149
|
/** Vertex count */
|
|
139
150
|
vertexCount: number;
|
|
140
|
-
/** instance count */
|
|
141
|
-
instanceCount: number = 0;
|
|
142
151
|
|
|
143
152
|
/** Index buffer */
|
|
144
153
|
indexBuffer: Buffer | null = null;
|
|
@@ -260,12 +269,16 @@ export class Model {
|
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
// Apply any dynamic settings that will not trigger pipeline change
|
|
263
|
-
if (props.
|
|
264
|
-
this.
|
|
272
|
+
if (props.isInstanced) {
|
|
273
|
+
this.isInstanced = props.isInstanced;
|
|
265
274
|
}
|
|
275
|
+
|
|
266
276
|
if (props.instanceCount) {
|
|
267
277
|
this.setInstanceCount(props.instanceCount);
|
|
268
278
|
}
|
|
279
|
+
if (props.vertexCount) {
|
|
280
|
+
this.setVertexCount(props.vertexCount);
|
|
281
|
+
}
|
|
269
282
|
if (props.indexBuffer) {
|
|
270
283
|
this.setIndexBuffer(props.indexBuffer);
|
|
271
284
|
}
|
|
@@ -358,6 +371,7 @@ export class Model {
|
|
|
358
371
|
drawSuccess = this.pipeline.draw({
|
|
359
372
|
renderPass,
|
|
360
373
|
vertexArray: this.vertexArray,
|
|
374
|
+
isInstanced: this.isInstanced,
|
|
361
375
|
vertexCount: this.vertexCount,
|
|
362
376
|
instanceCount: this.instanceCount,
|
|
363
377
|
indexCount,
|
|
@@ -453,24 +467,30 @@ export class Model {
|
|
|
453
467
|
|
|
454
468
|
// Update dynamic fields
|
|
455
469
|
|
|
456
|
-
/**
|
|
457
|
-
* Updates the vertex count (used in draw calls)
|
|
458
|
-
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
459
|
-
*/
|
|
460
|
-
setVertexCount(vertexCount: number): void {
|
|
461
|
-
this.vertexCount = vertexCount;
|
|
462
|
-
this.setNeedsRedraw('vertexCount');
|
|
463
|
-
}
|
|
464
|
-
|
|
465
470
|
/**
|
|
466
471
|
* Updates the instance count (used in draw calls)
|
|
467
472
|
* @note Any attributes with stepMode=instance need to be at least this big
|
|
468
473
|
*/
|
|
469
474
|
setInstanceCount(instanceCount: number): void {
|
|
470
475
|
this.instanceCount = instanceCount;
|
|
476
|
+
// luma.gl examples don't set props.isInstanced and rely on auto-detection
|
|
477
|
+
// but deck.gl sets instanceCount even for models that are not instanced.
|
|
478
|
+
if (this.isInstanced === undefined && instanceCount > 0) {
|
|
479
|
+
this.isInstanced = true;
|
|
480
|
+
}
|
|
471
481
|
this.setNeedsRedraw('instanceCount');
|
|
472
482
|
}
|
|
473
483
|
|
|
484
|
+
/**
|
|
485
|
+
* Updates the vertex count (used in draw calls)
|
|
486
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
487
|
+
*/
|
|
488
|
+
setVertexCount(vertexCount: number): void {
|
|
489
|
+
this.vertexCount = vertexCount;
|
|
490
|
+
this.setNeedsRedraw('vertexCount');
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Set the shader inputs */
|
|
474
494
|
setShaderInputs(shaderInputs: ShaderInputs): void {
|
|
475
495
|
this.shaderInputs = shaderInputs;
|
|
476
496
|
this._uniformStore = new UniformStore(this.shaderInputs.modules);
|
|
@@ -482,6 +502,7 @@ export class Model {
|
|
|
482
502
|
this.setNeedsRedraw('shaderInputs');
|
|
483
503
|
}
|
|
484
504
|
|
|
505
|
+
/** Update uniform buffers from the model's shader inputs */
|
|
485
506
|
updateShaderInputs(): void {
|
|
486
507
|
this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
|
|
487
508
|
// TODO - this is already tracked through buffer/texture update times?
|