@luma.gl/engine 9.0.0-alpha.30 → 9.0.0-alpha.32
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 +1028 -685
- package/dist/geometries/truncated-cone-geometry.d.ts +0 -2
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +0 -11
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry.d.ts +6 -7
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +45 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +123 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +311 -209
- package/dist/lib/pipeline-factory.d.ts +11 -44
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +28 -119
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model-shaders.d.ts +35 -0
- package/dist/model/model-shaders.d.ts.map +1 -0
- package/dist/model/model-shaders.js +38 -0
- package/dist/model/model-shaders.js.map +1 -0
- package/dist/model/model-utils.d.ts +1 -1
- package/dist/model/model-utils.d.ts.map +1 -1
- package/dist/model/model-utils.js +1 -1
- package/dist/model/model-utils.js.map +1 -1
- package/dist/model/model.d.ts +110 -23
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +144 -91
- package/dist/model/model.js.map +1 -1
- package/dist.min.js +71 -71
- package/package.json +6 -6
- package/src/geometries/truncated-cone-geometry.ts +0 -10
- package/src/geometry/geometry.ts +7 -7
- package/src/geometry/gpu-geometry.ts +159 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/lib/pipeline-factory.ts +43 -163
- package/src/model/model-shaders.ts +76 -0
- package/src/model/model-utils.ts +2 -2
- package/src/model/model.ts +271 -125
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/src/geometry/primitive-utils.ts +0 -30
package/dist/model/model.d.ts
CHANGED
|
@@ -1,65 +1,152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout } from '@luma.gl/core';
|
|
2
|
+
import type { Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';
|
|
3
|
+
import { Device, Buffer, RenderPipeline, RenderPass } from '@luma.gl/core';
|
|
3
4
|
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
5
|
+
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
6
|
import type { Geometry } from '../geometry/geometry';
|
|
7
|
+
import { GPUGeometry } from '../geometry/gpu-geometry';
|
|
5
8
|
import { PipelineFactory } from '../lib/pipeline-factory';
|
|
6
|
-
import { TypedArray } from '@math.gl/core';
|
|
7
|
-
/** @todo import type */
|
|
8
|
-
type UniformValue = unknown;
|
|
9
9
|
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
10
|
-
vs
|
|
10
|
+
vs: {
|
|
11
11
|
glsl?: string;
|
|
12
12
|
wgsl?: string;
|
|
13
13
|
} | string | null;
|
|
14
|
-
fs
|
|
14
|
+
fs: {
|
|
15
15
|
glsl?: string;
|
|
16
16
|
wgsl?: string;
|
|
17
17
|
} | string | null;
|
|
18
|
-
|
|
18
|
+
/** shadertool shader modules (added to shader code) */
|
|
19
19
|
modules?: ShaderModule[];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
20
|
+
/** Shadertool module defines (configures shader code)*/
|
|
21
|
+
defines?: Record<string, string | number | boolean>;
|
|
22
|
+
/** pipeline factory to use to create render pipelines. Defaults to default factory for the device */
|
|
23
23
|
pipelineFactory?: PipelineFactory;
|
|
24
|
+
/** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
|
|
25
|
+
shaderAssembler?: ShaderAssembler;
|
|
26
|
+
/** Geometry */
|
|
27
|
+
geometry?: GPUGeometry | Geometry | null;
|
|
28
|
+
/** Parameters that are built into the pipeline */
|
|
29
|
+
parameters?: RenderPipelineParameters;
|
|
30
|
+
/** shadertool modules */
|
|
31
|
+
moduleSettings?: Record<string, Record<string, any>>;
|
|
32
|
+
/** Vertex count */
|
|
33
|
+
vertexCount?: number;
|
|
34
|
+
/** instance count */
|
|
35
|
+
instanceCount?: number;
|
|
24
36
|
};
|
|
25
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* v9 Model API
|
|
39
|
+
* A model
|
|
40
|
+
* - automatically reuses pipelines (programs) when possible
|
|
41
|
+
* - automatically rebuilds pipelines if necessary to accommodate changed settings
|
|
42
|
+
* shadertools integration
|
|
43
|
+
* - accepts modules and performs shader transpilation
|
|
44
|
+
*/
|
|
26
45
|
export declare class Model {
|
|
46
|
+
static defaultProps: Required<ModelProps>;
|
|
27
47
|
readonly device: Device;
|
|
28
48
|
readonly id: string;
|
|
29
49
|
readonly vs: string;
|
|
30
|
-
readonly fs: string
|
|
31
|
-
readonly topology: PrimitiveTopology;
|
|
50
|
+
readonly fs: string;
|
|
32
51
|
readonly pipelineFactory: PipelineFactory;
|
|
33
|
-
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
34
|
-
pipeline: RenderPipeline;
|
|
35
52
|
userData: {
|
|
36
53
|
[key: string]: any;
|
|
37
54
|
};
|
|
55
|
+
/** The render pipeline GPU parameters, depth testing etc */
|
|
56
|
+
parameters: RenderPipelineParameters;
|
|
57
|
+
/** The primitive topology */
|
|
58
|
+
topology: PrimitiveTopology;
|
|
59
|
+
/** Buffer layout */
|
|
60
|
+
bufferLayout: BufferLayout[];
|
|
38
61
|
/** Vertex count */
|
|
39
62
|
vertexCount: number;
|
|
40
63
|
/** instance count */
|
|
41
64
|
instanceCount: number;
|
|
65
|
+
/** Index buffer */
|
|
66
|
+
indices: Buffer | null;
|
|
42
67
|
/** Buffer-valued attributes */
|
|
43
68
|
bufferAttributes: Record<string, Buffer>;
|
|
44
69
|
/** Constant-valued attributes */
|
|
45
70
|
constantAttributes: Record<string, TypedArray>;
|
|
46
71
|
/** Bindings (textures, samplers, uniform buffers) */
|
|
47
72
|
bindings: Record<string, Binding>;
|
|
48
|
-
/**
|
|
73
|
+
/** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/
|
|
49
74
|
uniforms: Record<string, UniformValue>;
|
|
75
|
+
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
76
|
+
pipeline: RenderPipeline;
|
|
77
|
+
_pipelineNeedsUpdate: string | false;
|
|
50
78
|
private _getModuleUniforms;
|
|
79
|
+
private props;
|
|
51
80
|
constructor(device: Device, props: ModelProps);
|
|
52
81
|
destroy(): void;
|
|
53
82
|
draw(renderPass: RenderPass): void;
|
|
54
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Updates the optional geometry
|
|
85
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
86
|
+
*/
|
|
87
|
+
setGeometry(geometry: GPUGeometry): void;
|
|
88
|
+
/**
|
|
89
|
+
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
90
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
91
|
+
*/
|
|
92
|
+
setTopology(topology: PrimitiveTopology): void;
|
|
93
|
+
/**
|
|
94
|
+
* Updates the buffer layout.
|
|
95
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
96
|
+
*/
|
|
97
|
+
setBufferLayout(bufferLayout: BufferLayout[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Set GPU parameters.
|
|
100
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch.
|
|
101
|
+
* @param parameters
|
|
102
|
+
*/
|
|
103
|
+
setParameters(parameters: RenderPipelineParameters): void;
|
|
104
|
+
/**
|
|
105
|
+
* Updates the vertex count (used in draw calls)
|
|
106
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
107
|
+
*/
|
|
108
|
+
setVertexCount(vertexCount: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Updates the instance count (used in draw calls)
|
|
111
|
+
* @note Any attributes with stepMode=instance need to be at least this big
|
|
112
|
+
*/
|
|
113
|
+
setInstanceCount(instanceCount: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* Updates shader module settings (which results in uniforms being set)
|
|
116
|
+
*/
|
|
117
|
+
setShaderModuleProps(props: Record<string, any>): void;
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Updates shader module settings (which results in uniforms being set)
|
|
120
|
+
*/
|
|
55
121
|
updateModuleSettings(props: Record<string, any>): void;
|
|
56
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Sets the index buffer
|
|
124
|
+
* @todo - how to unset it if we change geometry?
|
|
125
|
+
*/
|
|
126
|
+
setIndexBuffer(indices: Buffer | null): void;
|
|
127
|
+
/**
|
|
128
|
+
* Sets attributes (buffers)
|
|
129
|
+
* @note Overrides any attributes previously set with the same name
|
|
130
|
+
*/
|
|
57
131
|
setAttributes(bufferAttributes: Record<string, Buffer>): void;
|
|
132
|
+
/**
|
|
133
|
+
* Sets constant attributes
|
|
134
|
+
* @note Overrides any attributes previously set with the same name
|
|
135
|
+
* @param constantAttributes
|
|
136
|
+
*/
|
|
58
137
|
setConstantAttributes(constantAttributes: Record<string, TypedArray>): void;
|
|
59
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Sets bindings (textures, samplers, uniform buffers)
|
|
140
|
+
*/
|
|
60
141
|
setBindings(bindings: Record<string, Binding>): void;
|
|
61
|
-
|
|
62
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Sets individual uniforms
|
|
144
|
+
* @deprecated WebGL only, use uniform buffers for portability
|
|
145
|
+
* @param uniforms
|
|
146
|
+
* @returns self for chaining
|
|
147
|
+
*/
|
|
148
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
149
|
+
_setPipelineNeedsUpdate(reason: string): void;
|
|
150
|
+
_updatePipeline(): RenderPipeline;
|
|
63
151
|
}
|
|
64
|
-
export {};
|
|
65
152
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,KAAK,EAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAC9F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAkB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAGxD,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;KAAC,GAAG,MAAM,GAAG,I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E,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAKtD;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAItD;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI5C;;;OAGG;IACH,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAQ7D;;;;OAIG;IACH,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAK3E;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpD;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAKzD,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;CAelC"}
|
package/dist/model/model.js
CHANGED
|
@@ -1,91 +1,64 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { log } from '@luma.gl/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { RenderPipeline, log, uid, deepEqual } from '@luma.gl/core';
|
|
3
|
+
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
|
+
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
5
5
|
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
6
|
-
|
|
7
|
-
...RenderPipeline._DEFAULT_PROPS,
|
|
8
|
-
vs: null,
|
|
9
|
-
fs: null,
|
|
10
|
-
id: 'unnamed',
|
|
11
|
-
handle: undefined,
|
|
12
|
-
userData: {},
|
|
13
|
-
defines: {},
|
|
14
|
-
modules: [],
|
|
15
|
-
moduleSettings: {},
|
|
16
|
-
geometry: null,
|
|
17
|
-
pipelineFactory: undefined
|
|
18
|
-
};
|
|
6
|
+
import { buildShaders } from "./model-shaders.js";
|
|
19
7
|
export class Model {
|
|
20
8
|
constructor(device, props) {
|
|
21
9
|
_defineProperty(this, "device", void 0);
|
|
22
10
|
_defineProperty(this, "id", void 0);
|
|
23
11
|
_defineProperty(this, "vs", void 0);
|
|
24
|
-
_defineProperty(this, "fs",
|
|
25
|
-
_defineProperty(this, "topology", void 0);
|
|
12
|
+
_defineProperty(this, "fs", void 0);
|
|
26
13
|
_defineProperty(this, "pipelineFactory", void 0);
|
|
27
|
-
_defineProperty(this, "pipeline", void 0);
|
|
28
14
|
_defineProperty(this, "userData", {});
|
|
15
|
+
_defineProperty(this, "parameters", void 0);
|
|
16
|
+
_defineProperty(this, "topology", void 0);
|
|
17
|
+
_defineProperty(this, "bufferLayout", void 0);
|
|
29
18
|
_defineProperty(this, "vertexCount", void 0);
|
|
30
19
|
_defineProperty(this, "instanceCount", 0);
|
|
20
|
+
_defineProperty(this, "indices", null);
|
|
31
21
|
_defineProperty(this, "bufferAttributes", {});
|
|
32
22
|
_defineProperty(this, "constantAttributes", {});
|
|
33
23
|
_defineProperty(this, "bindings", {});
|
|
34
24
|
_defineProperty(this, "uniforms", {});
|
|
25
|
+
_defineProperty(this, "pipeline", void 0);
|
|
26
|
+
_defineProperty(this, "_pipelineNeedsUpdate", 'newly created');
|
|
35
27
|
_defineProperty(this, "_getModuleUniforms", void 0);
|
|
36
|
-
props
|
|
37
|
-
|
|
28
|
+
_defineProperty(this, "props", void 0);
|
|
29
|
+
this.props = {
|
|
30
|
+
...Model.defaultProps,
|
|
38
31
|
...props
|
|
39
32
|
};
|
|
40
|
-
|
|
33
|
+
props = this.props;
|
|
34
|
+
this.id = props.id || uid('model');
|
|
41
35
|
this.device = device;
|
|
42
36
|
Object.assign(this.userData, props.userData);
|
|
43
|
-
if (!props.vs) {
|
|
44
|
-
throw new Error('no vertex shader');
|
|
45
|
-
}
|
|
46
|
-
this.vs = getShaderSource(this.device, props.vs);
|
|
47
|
-
if (props.fs) {
|
|
48
|
-
this.fs = getShaderSource(this.device, props.fs);
|
|
49
|
-
}
|
|
50
|
-
this.vertexCount = props.vertexCount;
|
|
51
|
-
this.instanceCount = props.instanceCount;
|
|
52
|
-
this.topology = props.topology;
|
|
53
|
-
if (props.geometry) {
|
|
54
|
-
this.vertexCount = props.geometry.vertexCount;
|
|
55
|
-
this.topology = props.geometry.topology || 'triangle-list';
|
|
56
|
-
}
|
|
57
|
-
this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
58
37
|
const {
|
|
59
|
-
|
|
38
|
+
vs,
|
|
39
|
+
fs,
|
|
60
40
|
getUniforms
|
|
61
|
-
} = this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
fs: this.fs,
|
|
65
|
-
topology: this.topology,
|
|
66
|
-
defines: props.defines,
|
|
67
|
-
parameters: props.parameters,
|
|
68
|
-
layout: props.layout
|
|
69
|
-
});
|
|
70
|
-
this.pipeline = pipeline;
|
|
41
|
+
} = buildShaders(device, this.props);
|
|
42
|
+
this.vs = vs;
|
|
43
|
+
this.fs = fs;
|
|
71
44
|
this._getModuleUniforms = getUniforms;
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
this.vertexCount = this.props.vertexCount;
|
|
46
|
+
this.instanceCount = this.props.instanceCount;
|
|
47
|
+
this.topology = this.props.topology;
|
|
48
|
+
this.bufferLayout = this.props.bufferLayout;
|
|
49
|
+
this.parameters = this.props.parameters;
|
|
50
|
+
const gpuGeometry = props.geometry && makeGPUGeometry(device, props.geometry);
|
|
51
|
+
if (gpuGeometry) {
|
|
52
|
+
this.setGeometry(gpuGeometry);
|
|
53
|
+
}
|
|
54
|
+
this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
55
|
+
this.pipeline = this._updatePipeline();
|
|
56
|
+
if (props.vertexCount) {
|
|
57
|
+
this.setVertexCount(props.vertexCount);
|
|
58
|
+
}
|
|
59
|
+
if (props.instanceCount) {
|
|
60
|
+
this.setInstanceCount(props.instanceCount);
|
|
74
61
|
}
|
|
75
|
-
this.setUniforms(this._getModuleUniforms());
|
|
76
|
-
this.setProps(props);
|
|
77
|
-
}
|
|
78
|
-
destroy() {
|
|
79
|
-
this.pipelineFactory.release(this.pipeline);
|
|
80
|
-
}
|
|
81
|
-
draw(renderPass) {
|
|
82
|
-
this.pipeline.draw({
|
|
83
|
-
renderPass,
|
|
84
|
-
vertexCount: this.vertexCount,
|
|
85
|
-
instanceCount: this.instanceCount
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setProps(props) {
|
|
89
62
|
if (props.indices) {
|
|
90
63
|
this.setIndexBuffer(props.indices);
|
|
91
64
|
}
|
|
@@ -101,57 +74,137 @@ export class Model {
|
|
|
101
74
|
if (props.moduleSettings) {
|
|
102
75
|
this.updateModuleSettings(props.moduleSettings);
|
|
103
76
|
}
|
|
77
|
+
this.setUniforms(this._getModuleUniforms());
|
|
78
|
+
Object.seal(this);
|
|
104
79
|
}
|
|
105
|
-
|
|
80
|
+
destroy() {
|
|
81
|
+
this.pipelineFactory.release(this.pipeline);
|
|
82
|
+
}
|
|
83
|
+
draw(renderPass) {
|
|
84
|
+
this.pipeline = this._updatePipeline();
|
|
85
|
+
this.pipeline.setIndexBuffer(this.indices);
|
|
86
|
+
this.pipeline.setAttributes(this.bufferAttributes);
|
|
87
|
+
this.pipeline.setConstantAttributes(this.constantAttributes);
|
|
88
|
+
this.pipeline.setBindings(this.bindings);
|
|
89
|
+
this.pipeline.setUniforms(this.uniforms);
|
|
90
|
+
this.pipeline.draw({
|
|
91
|
+
renderPass,
|
|
92
|
+
vertexCount: this.vertexCount,
|
|
93
|
+
instanceCount: this.instanceCount
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
setGeometry(geometry) {
|
|
97
|
+
this.setTopology(geometry.topology || 'triangle-list');
|
|
98
|
+
this.bufferLayout = mergeBufferLayouts(this.bufferLayout, geometry.bufferLayout);
|
|
99
|
+
this.vertexCount = geometry.vertexCount;
|
|
100
|
+
this.setAttributes(geometry.attributes);
|
|
101
|
+
this.setIndexBuffer(geometry.indices);
|
|
102
|
+
}
|
|
103
|
+
setTopology(topology) {
|
|
104
|
+
if (topology !== this.topology) {
|
|
105
|
+
this.topology = topology;
|
|
106
|
+
if (this.device.info.type === 'webgpu') {
|
|
107
|
+
this._setPipelineNeedsUpdate('topology');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
setBufferLayout(bufferLayout) {
|
|
112
|
+
if (bufferLayout !== this.bufferLayout) {
|
|
113
|
+
this.bufferLayout = bufferLayout;
|
|
114
|
+
if (this.device.info.type === 'webgpu') {
|
|
115
|
+
this._setPipelineNeedsUpdate('bufferLayout');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
setParameters(parameters) {
|
|
120
|
+
if (!deepEqual(parameters, this.parameters, 2)) {
|
|
121
|
+
this.parameters = parameters;
|
|
122
|
+
if (this.device.info.type === 'webgpu') {
|
|
123
|
+
this._setPipelineNeedsUpdate('parameters');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
setVertexCount(vertexCount) {
|
|
128
|
+
this.vertexCount = vertexCount;
|
|
129
|
+
}
|
|
130
|
+
setInstanceCount(instanceCount) {
|
|
131
|
+
this.instanceCount = instanceCount;
|
|
132
|
+
}
|
|
133
|
+
setShaderModuleProps(props) {
|
|
106
134
|
const uniforms = this._getModuleUniforms(props);
|
|
107
|
-
this.
|
|
135
|
+
Object.assign(this.uniforms, uniforms);
|
|
136
|
+
}
|
|
137
|
+
updateModuleSettings(props) {
|
|
138
|
+
this.setShaderModuleProps(props);
|
|
108
139
|
}
|
|
109
140
|
setIndexBuffer(indices) {
|
|
110
|
-
this.
|
|
141
|
+
this.indices = indices;
|
|
111
142
|
}
|
|
112
143
|
setAttributes(bufferAttributes) {
|
|
113
144
|
if (bufferAttributes.indices) {
|
|
114
145
|
log.warn("Model:".concat(this.id, " setAttributes() - indices should be set using setIndexBuffer()"));
|
|
115
146
|
}
|
|
116
|
-
this.pipeline.setAttributes(bufferAttributes);
|
|
117
147
|
Object.assign(this.bufferAttributes, bufferAttributes);
|
|
118
148
|
}
|
|
119
149
|
setConstantAttributes(constantAttributes) {
|
|
120
|
-
this.pipeline.setConstantAttributes(constantAttributes);
|
|
121
150
|
Object.assign(this.constantAttributes, constantAttributes);
|
|
122
151
|
}
|
|
123
152
|
setBindings(bindings) {
|
|
124
|
-
this.pipeline.setBindings(bindings);
|
|
125
153
|
Object.assign(this.bindings, bindings);
|
|
126
154
|
}
|
|
127
155
|
setUniforms(uniforms) {
|
|
128
156
|
this.pipeline.setUniforms(uniforms);
|
|
129
157
|
Object.assign(this.uniforms, uniforms);
|
|
130
158
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
this.
|
|
159
|
+
_setPipelineNeedsUpdate(reason) {
|
|
160
|
+
this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
|
|
161
|
+
}
|
|
162
|
+
_updatePipeline() {
|
|
163
|
+
if (this._pipelineNeedsUpdate) {
|
|
164
|
+
log.log(1, "Model ".concat(this.id, ": Recreating pipeline because \"").concat(this._pipelineNeedsUpdate, "\"."))();
|
|
165
|
+
this._pipelineNeedsUpdate = false;
|
|
166
|
+
this.pipeline = this.device.createRenderPipeline({
|
|
167
|
+
...this.props,
|
|
168
|
+
bufferLayout: this.bufferLayout,
|
|
169
|
+
topology: this.topology,
|
|
170
|
+
parameters: this.parameters,
|
|
171
|
+
vs: this.device.createShader({
|
|
172
|
+
stage: 'vertex',
|
|
173
|
+
source: this.vs
|
|
174
|
+
}),
|
|
175
|
+
fs: this.fs ? this.device.createShader({
|
|
176
|
+
stage: 'fragment',
|
|
177
|
+
source: this.fs
|
|
178
|
+
}) : null
|
|
179
|
+
});
|
|
137
180
|
}
|
|
181
|
+
return this.pipeline;
|
|
138
182
|
}
|
|
139
183
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
_defineProperty(Model, "defaultProps", {
|
|
185
|
+
...RenderPipeline.defaultProps,
|
|
186
|
+
vs: null,
|
|
187
|
+
fs: null,
|
|
188
|
+
id: 'unnamed',
|
|
189
|
+
handle: undefined,
|
|
190
|
+
userData: {},
|
|
191
|
+
defines: {},
|
|
192
|
+
modules: [],
|
|
193
|
+
moduleSettings: {},
|
|
194
|
+
geometry: null,
|
|
195
|
+
pipelineFactory: undefined,
|
|
196
|
+
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
|
|
197
|
+
});
|
|
198
|
+
function mergeBufferLayouts(layouts1, layouts2) {
|
|
199
|
+
const layouts = [...layouts1];
|
|
200
|
+
for (const attribute of layouts2) {
|
|
201
|
+
const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);
|
|
202
|
+
if (index < 0) {
|
|
203
|
+
layouts.push(attribute);
|
|
204
|
+
} else {
|
|
205
|
+
layouts[index] = attribute;
|
|
206
|
+
}
|
|
155
207
|
}
|
|
208
|
+
return layouts;
|
|
156
209
|
}
|
|
157
210
|
//# sourceMappingURL=model.js.map
|
package/dist/model/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","names":["log","RenderPipeline","getAttributeBuffersFromGeometry","getIndexBufferFromGeometry","PipelineFactory","DEFAULT_MODEL_PROPS","_DEFAULT_PROPS","vs","fs","id","handle","undefined","userData","defines","modules","moduleSettings","geometry","pipelineFactory","Model","constructor","device","props","_defineProperty","Object","assign","Error","getShaderSource","vertexCount","instanceCount","topology","getDefaultPipelineFactory","pipeline","getUniforms","createRenderPipeline","parameters","layout","_getModuleUniforms","_setGeometry","setUniforms","setProps","destroy","release","draw","renderPass","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","bufferAttributes","warn","concat","setConstantAttributes","constantAttributes","geometryBuffers","indexBuffer","shader","info","type","wgsl","glsl"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {\n Device,\n Buffer,\n RenderPipelineProps,\n RenderPass,\n Binding,\n PrimitiveTopology,\n log\n} from '@luma.gl/core';\nimport {RenderPipeline} from '@luma.gl/core';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport type {Geometry} from '../geometry/geometry';\nimport {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';\nimport {PipelineFactory} from '../lib/pipeline-factory';\nimport {TypedArray} from '@math.gl/core';\n\n/** @todo import type */\ntype UniformValue = unknown;\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string\n vs?: {glsl?: string; wgsl?: string} | string | null;\n fs?: {glsl?: string; wgsl?: string} | string | null;\n defines?: Record<string, string | number | boolean>;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry | null;\n /** deprecated pipeline factory to use to create renderpipelines */\n pipelineFactory?: PipelineFactory;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: {},\n geometry: null,\n pipelineFactory: undefined\n};\n\n/** v9 API */\nexport class Model {\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | null = null;\n readonly topology: PrimitiveTopology;\n readonly pipelineFactory: PipelineFactory;\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n userData: {[key: string]: any} = {};\n\n // readonly props: Required<ModelProps>;\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\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 /** Uniforms */\n uniforms: Record<string, UniformValue> = {};\n\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n\n constructor(device: Device, props: ModelProps) {\n props = {...DEFAULT_MODEL_PROPS, ...props};\n this.id = props.id;\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n // Create the pipeline\n if (!props.vs) {\n throw new Error('no vertex shader');\n }\n this.vs = getShaderSource(this.device, props.vs);\n if (props.fs) {\n this.fs = getShaderSource(this.device, props.fs);\n }\n\n this.vertexCount = props.vertexCount;\n this.instanceCount = props.instanceCount;\n this.topology = props.topology;\n\n if (props.geometry) {\n this.vertexCount = props.geometry.vertexCount;\n this.topology = props.geometry.topology || 'triangle-list';\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n const {pipeline, getUniforms} = this.pipelineFactory.createRenderPipeline({\n ...props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n defines: props.defines,\n parameters: props.parameters,\n layout: props.layout\n });\n\n this.pipeline = pipeline;\n this._getModuleUniforms = getUniforms;\n\n if (props.geometry) {\n this._setGeometry(props.geometry);\n }\n\n this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Props can update any of the above, so call setProps last.\n this.setProps(props);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n }\n\n draw(renderPass: RenderPass): void {\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount\n });\n }\n\n setProps(props: ModelProps): void {\n if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\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 this.updateModuleSettings(props.moduleSettings);\n }\n }\n\n updateModuleSettings(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n this.setUniforms(uniforms);\n }\n\n setIndexBuffer(indices: Buffer): void {\n this.pipeline.setIndexBuffer(indices);\n // this._indices = indices;\n }\n\n setAttributes(bufferAttributes: Record<string, Buffer>): void {\n if (bufferAttributes.indices) {\n log.warn(`Model:${this.id} setAttributes() - indices should be set using setIndexBuffer()`);\n }\n\n this.pipeline.setAttributes(bufferAttributes);\n Object.assign(this.bufferAttributes, bufferAttributes);\n }\n\n setConstantAttributes(constantAttributes: Record<string, TypedArray>): void {\n // TODO - this doesn't work under WebGPU, we'll need to create buffers or inject uniforms\n this.pipeline.setConstantAttributes(constantAttributes);\n Object.assign(this.constantAttributes, constantAttributes);\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline.setBindings(bindings);\n Object.assign(this.bindings, bindings);\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n _setGeometry(geometry: Geometry): void {\n // this._deleteGeometryBuffers();\n\n const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);\n this.setAttributes(geometryBuffers);\n\n const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);\n if (indexBuffer) {\n this.setIndexBuffer(indexBuffer);\n }\n }\n}\n\n/** Create a shader from the different overloads */\nfunction getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {\n // TODO - detect WGSL/GLSL and throw an error if not supported\n if (typeof shader === 'string') {\n return shader;\n }\n\n switch (device.info.type) {\n case 'webgpu':\n if (shader?.wgsl) {\n return shader.wgsl;\n }\n throw new Error('WebGPU does not support GLSL shaders');\n\n default:\n if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ACN,MAAc,EAAEuC,MAA+C,EAAU;EAEhG,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EAEA,QAAQvC,MAAM,CAACwC,IAAI,CAACC,IAAI;IACtB,KAAK,QAAQ;MACX,IAAIF,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEG,IAAI,EAAE;QAChB,OAAOH,MAAM,CAACG,IAAI;MACpB;MACA,MAAM,IAAIrC,KAAK,CAAC,sCAAsC,CAAC;IAEzD;MACE,IAAIkC,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEI,IAAI,EAAE;QAChB,OAAOJ,MAAM,CAACI,IAAI;MACpB;MACA,MAAM,IAAItC,KAAK,CAAC,qCAAqC,CAAC;EAC1D;AACF"}
|
|
1
|
+
{"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","ShaderAssembler","makeGPUGeometry","PipelineFactory","buildShaders","Model","constructor","device","props","_defineProperty","defaultProps","id","Object","assign","userData","vs","fs","getUniforms","_getModuleUniforms","vertexCount","instanceCount","topology","bufferLayout","parameters","gpuGeometry","geometry","setGeometry","pipelineFactory","getDefaultPipelineFactory","pipeline","_updatePipeline","setVertexCount","setInstanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","bufferAttributes","setConstantAttributes","constantAttributes","setTopology","mergeBufferLayouts","info","type","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","warn","concat","reason","_pipelineNeedsUpdate","createRenderPipeline","createShader","stage","source","handle","undefined","defines","modules","shaderAssembler","getDefaultShaderAssembler","layouts1","layouts2","layouts","attribute","index","findIndex","attribute2","name","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout} from '@luma.gl/core';\nimport type {Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, log, uid, deepEqual} from '@luma.gl/core';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\nimport {buildShaders} from './model-shaders';\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\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 /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n /** shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\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: {},\n geometry: null,\n\n pipelineFactory: 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 indices: 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 /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n _pipelineNeedsUpdate: string | false = 'newly created';\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 const {vs, fs, getUniforms} = buildShaders(device, this.props);\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 several attributes, indices, and also vertex count and topology\n const gpuGeometry = props.geometry && makeGPUGeometry(device, props.geometry);\n if (gpuGeometry) {\n this.setGeometry(gpuGeometry);\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 // Now we can apply geometry attributes\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 if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\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 this.updateModuleSettings(props.moduleSettings);\n }\n\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 }\n\n // Draw call\n\n draw(renderPass: RenderPass): void {\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.setIndexBuffer(this.indices);\n this.pipeline.setAttributes(this.bufferAttributes);\n this.pipeline.setConstantAttributes(this.constantAttributes);\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /** \n * Updates the optional geometry\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry): void {\n this.setTopology(geometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, geometry.bufferLayout);\n\n // TODO - delete previous geometry?\n this.vertexCount = geometry.vertexCount;\n this.setAttributes(geometry.attributes);\n this.setIndexBuffer(geometry.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 // On WebGPU we need to rebuild the pipeline\n if (this.device.info.type === 'webgpu') {\n this._setPipelineNeedsUpdate('topology');\n }\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 if (bufferLayout !== this.bufferLayout) {\n this.bufferLayout = bufferLayout;\n // On WebGPU we need to rebuild the pipeline\n if (this.device.info.type === 'webgpu') {\n this._setPipelineNeedsUpdate('bufferLayout');\n }\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 // On WebGPU we need to rebuild the pipeline\n if (this.device.info.type === 'webgpu') {\n this._setPipelineNeedsUpdate('parameters');\n }\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 /**\n * Updates shader module settings (which results in uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n this.setShaderModuleProps(props);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indices: Buffer | null): void {\n this.indices = indices;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(bufferAttributes: Record<string, Buffer>): void {\n if (bufferAttributes.indices) {\n log.warn(`Model:${this.id} setAttributes() - indices should be set using setIndexBuffer()`);\n }\n\n Object.assign(this.bufferAttributes, bufferAttributes);\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * @param constantAttributes\n */\n setConstantAttributes(constantAttributes: Record<string, TypedArray>): void {\n // TODO - this doesn't work under WebGPU, we'll need to create buffers or inject uniforms\n Object.assign(this.constantAttributes, constantAttributes);\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 _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n log.log(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\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({stage: 'vertex', source: this.vs}),\n fs: this.fs ? this.device.createShader({stage: 'fragment', source: this.fs}) : null\n });\n }\n return this.pipeline;\n }\n}\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(\n (attribute2) => attribute2.name === attribute.name\n );\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}"],"mappings":";AAIA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAE7F,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAA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