@luma.gl/engine 9.0.0-alpha.33 → 9.0.0-alpha.34
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/animation/key-frames.js +6 -7
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.js +5 -6
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop.js +18 -19
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/dist.dev.js +88 -96
- package/dist/geometries/ico-sphere-geometry.js +1 -1
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.js +4 -4
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometry/geometry.js +8 -9
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +4 -15
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +27 -62
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +28 -44
- package/dist/lib/clip-space.js +16 -3
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +15 -11
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +27 -34
- package/dist/model/model.js.map +1 -1
- package/dist/scenegraph/group-node.js +1 -2
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.js +3 -4
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +9 -10
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/transform/transform.js +4 -5
- package/dist/transform/transform.js.map +1 -1
- package/dist.min.js +75 -75
- package/package.json +6 -6
- package/src/geometry/gpu-geometry.ts +18 -52
- package/src/lib/pipeline-factory.ts +13 -10
- package/src/model/model.ts +3 -12
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { RenderPipeline } from '@luma.gl/core';
|
|
3
2
|
export class PipelineFactory {
|
|
4
3
|
static getDefaultPipelineFactory(device) {
|
|
@@ -6,11 +5,11 @@ export class PipelineFactory {
|
|
|
6
5
|
return device._lumaData.defaultPipelineFactory;
|
|
7
6
|
}
|
|
8
7
|
constructor(device) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
this.device = void 0;
|
|
9
|
+
this._hashCounter = 0;
|
|
10
|
+
this._hashes = {};
|
|
11
|
+
this._useCounts = {};
|
|
12
|
+
this._pipelineCache = {};
|
|
14
13
|
this.device = device;
|
|
15
14
|
}
|
|
16
15
|
createRenderPipeline(options) {
|
|
@@ -69,10 +68,15 @@ export class PipelineFactory {
|
|
|
69
68
|
_hashRenderPipeline(props) {
|
|
70
69
|
const vsHash = this._getHash(props.vs);
|
|
71
70
|
const fsHash = props.fs ? this._getHash(props.fs) : 0;
|
|
72
|
-
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
73
|
-
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
74
71
|
const varyingHash = '-';
|
|
75
|
-
|
|
72
|
+
switch (this.device.info.type) {
|
|
73
|
+
case 'webgpu':
|
|
74
|
+
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
75
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
76
|
+
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
|
|
77
|
+
default:
|
|
78
|
+
return `${vsHash}/${fsHash}V${varyingHash}`;
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
_getHash(key) {
|
|
78
82
|
if (this._hashes[key] === undefined) {
|
|
@@ -81,9 +85,9 @@ export class PipelineFactory {
|
|
|
81
85
|
return this._hashes[key];
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
|
|
88
|
+
PipelineFactory.defaultProps = {
|
|
85
89
|
...RenderPipeline.defaultProps,
|
|
86
90
|
vs: undefined,
|
|
87
91
|
fs: undefined
|
|
88
|
-
}
|
|
92
|
+
};
|
|
89
93
|
//# sourceMappingURL=pipeline-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.js","names":["RenderPipeline","PipelineFactory","getDefaultPipelineFactory","device","_lumaData","defaultPipelineFactory","constructor","
|
|
1
|
+
{"version":3,"file":"pipeline-factory.js","names":["RenderPipeline","PipelineFactory","getDefaultPipelineFactory","device","_lumaData","defaultPipelineFactory","constructor","_hashCounter","_hashes","_useCounts","_pipelineCache","createRenderPipeline","options","props","defaultProps","hash","_hashRenderPipeline","pipeline","vs","createShader","stage","source","fs","release","destroy","_createRenderPipeline","Error","vsHash","_getHash","fsHash","varyingHash","info","type","parameterHash","JSON","stringify","parameters","bufferLayoutHash","bufferLayout","topology","key","undefined"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {RenderPipelineProps} from '@luma.gl/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\n\n/** Todo - should be same as RenderPipelineProps */\nexport type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Only accepts string shaders\n vs: string;\n fs: string;\n};\n\n/** \n * Efficiently creates / caches pipelines\n */\nexport class PipelineFactory {\n static defaultProps: Required<PipelineFactoryProps> = {\n ...RenderPipeline.defaultProps,\n vs: undefined!,\n fs: undefined!\n }\n\n readonly device: Device;\n\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);\n return device._lumaData.defaultPipelineFactory as PipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n createRenderPipeline(options: PipelineFactoryProps): RenderPipeline {\n const props: Required<PipelineFactoryProps> = {...PipelineFactory.defaultProps, ...options};\n\n const hash = this._hashRenderPipeline({...props});\n\n if (!this._pipelineCache[hash]) {\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._pipelineCache[hash];\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._useCounts[hash];\n }\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: PipelineFactoryProps): RenderPipeline {\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n return pipeline;\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: PipelineFactoryProps): string {\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n // WebGL specific\n // const {varyings = [], bufferMode = {}} = props;\n // const varyingHashes = varyings.map((v) => this._getHash(v));\n const varyingHash = '-'; // `${varyingHashes.join('/')}B${bufferMode}`\n\n switch (this.device.info.type) {\n case 'webgpu':\n // On WebGPU we need to rebuild the pipeline if topology, parameters or bufferLayout change\n const parameterHash = this._getHash(JSON.stringify(props.parameters));\n const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));\n // TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?\n // create a deepHash() to deduplicate?\n return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;\n default:\n // WebGL is more dynamic\n return `${vsHash}/${fsHash}V${varyingHash}`;\n }\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n}\n\n"],"mappings":"AAEA,SAAgBA,cAAc,QAAO,eAAe;AAYpD,OAAO,MAAMC,eAAe,CAAC;EAc3B,OAAOC,yBAAyBA,CAACC,MAAc,EAAmB;IAChEA,MAAM,CAACC,SAAS,CAACC,sBAAsB,GAAGF,MAAM,CAACC,SAAS,CAACC,sBAAsB,IAAI,IAAIJ,eAAe,CAACE,MAAM,CAAC;IAChH,OAAOA,MAAM,CAACC,SAAS,CAACC,sBAAsB;EAChD;EAEAC,WAAWA,CAACH,MAAc,EAAE;IAAA,KAZnBA,MAAM;IAAA,KAEPI,YAAY,GAAW,CAAC;IAAA,KACfC,OAAO,GAA2B,CAAC,CAAC;IAAA,KACpCC,UAAU,GAA2B,CAAC,CAAC;IAAA,KACvCC,cAAc,GAAmC,CAAC,CAAC;IAQlE,IAAI,CAACP,MAAM,GAAGA,MAAM;EACtB;EAEAQ,oBAAoBA,CAACC,OAA6B,EAAkB;IAClE,MAAMC,KAAqC,GAAG;MAAC,GAAGZ,eAAe,CAACa,YAAY;MAAE,GAAGF;IAAO,CAAC;IAE3F,MAAMG,IAAI,GAAG,IAAI,CAACC,mBAAmB,CAAC;MAAC,GAAGH;IAAK,CAAC,CAAC;IAEjD,IAAI,CAAC,IAAI,CAACH,cAAc,CAACK,IAAI,CAAC,EAAE;MAC9B,MAAME,QAAQ,GAAG,IAAI,CAACd,MAAM,CAACQ,oBAAoB,CAAC;QAChD,GAAGE,KAAK;QACRK,EAAE,EAAE,IAAI,CAACf,MAAM,CAACgB,YAAY,CAAC;UAACC,KAAK,EAAE,QAAQ;UAAEC,MAAM,EAAER,KAAK,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C,UAAU,EAAE,wBAAwB;IASlD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIzC;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,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,30 +1,29 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { RenderPipeline, log, uid, deepEqual } from '@luma.gl/core';
|
|
3
2
|
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
3
|
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
5
4
|
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
6
5
|
export class Model {
|
|
7
6
|
constructor(device, props) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
this.device = void 0;
|
|
8
|
+
this.id = void 0;
|
|
9
|
+
this.vs = void 0;
|
|
10
|
+
this.fs = void 0;
|
|
11
|
+
this.pipelineFactory = void 0;
|
|
12
|
+
this.userData = {};
|
|
13
|
+
this.parameters = void 0;
|
|
14
|
+
this.topology = void 0;
|
|
15
|
+
this.bufferLayout = void 0;
|
|
16
|
+
this.vertexCount = void 0;
|
|
17
|
+
this.instanceCount = 0;
|
|
18
|
+
this.indices = null;
|
|
19
|
+
this.bufferAttributes = {};
|
|
20
|
+
this.constantAttributes = {};
|
|
21
|
+
this.bindings = {};
|
|
22
|
+
this.uniforms = {};
|
|
23
|
+
this.pipeline = void 0;
|
|
24
|
+
this._pipelineNeedsUpdate = 'newly created';
|
|
25
|
+
this._getModuleUniforms = void 0;
|
|
26
|
+
this.props = void 0;
|
|
28
27
|
this.props = {
|
|
29
28
|
...Model.defaultProps,
|
|
30
29
|
...props
|
|
@@ -108,25 +107,19 @@ export class Model {
|
|
|
108
107
|
setTopology(topology) {
|
|
109
108
|
if (topology !== this.topology) {
|
|
110
109
|
this.topology = topology;
|
|
111
|
-
|
|
112
|
-
this._setPipelineNeedsUpdate('topology');
|
|
113
|
-
}
|
|
110
|
+
this._setPipelineNeedsUpdate('topology');
|
|
114
111
|
}
|
|
115
112
|
}
|
|
116
113
|
setBufferLayout(bufferLayout) {
|
|
117
114
|
if (bufferLayout !== this.bufferLayout) {
|
|
118
115
|
this.bufferLayout = bufferLayout;
|
|
119
|
-
|
|
120
|
-
this._setPipelineNeedsUpdate('bufferLayout');
|
|
121
|
-
}
|
|
116
|
+
this._setPipelineNeedsUpdate('bufferLayout');
|
|
122
117
|
}
|
|
123
118
|
}
|
|
124
119
|
setParameters(parameters) {
|
|
125
120
|
if (!deepEqual(parameters, this.parameters, 2)) {
|
|
126
121
|
this.parameters = parameters;
|
|
127
|
-
|
|
128
|
-
this._setPipelineNeedsUpdate('parameters');
|
|
129
|
-
}
|
|
122
|
+
this._setPipelineNeedsUpdate('parameters');
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
setVertexCount(vertexCount) {
|
|
@@ -147,7 +140,7 @@ export class Model {
|
|
|
147
140
|
}
|
|
148
141
|
setAttributes(bufferAttributes) {
|
|
149
142
|
if (bufferAttributes.indices) {
|
|
150
|
-
log.warn(
|
|
143
|
+
log.warn(`Model:${this.id} setAttributes() - indices should be set using setIndexBuffer()`);
|
|
151
144
|
}
|
|
152
145
|
Object.assign(this.bufferAttributes, bufferAttributes);
|
|
153
146
|
}
|
|
@@ -166,7 +159,7 @@ export class Model {
|
|
|
166
159
|
}
|
|
167
160
|
_updatePipeline() {
|
|
168
161
|
if (this._pipelineNeedsUpdate) {
|
|
169
|
-
log.log(1,
|
|
162
|
+
log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
170
163
|
this._pipelineNeedsUpdate = false;
|
|
171
164
|
this.pipeline = this.device.createRenderPipeline({
|
|
172
165
|
...this.props,
|
|
@@ -186,7 +179,7 @@ export class Model {
|
|
|
186
179
|
return this.pipeline;
|
|
187
180
|
}
|
|
188
181
|
}
|
|
189
|
-
|
|
182
|
+
Model.defaultProps = {
|
|
190
183
|
...RenderPipeline.defaultProps,
|
|
191
184
|
vs: null,
|
|
192
185
|
fs: null,
|
|
@@ -199,7 +192,7 @@ _defineProperty(Model, "defaultProps", {
|
|
|
199
192
|
geometry: null,
|
|
200
193
|
pipelineFactory: undefined,
|
|
201
194
|
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
|
|
202
|
-
}
|
|
195
|
+
};
|
|
203
196
|
function mergeBufferLayouts(layouts1, layouts2) {
|
|
204
197
|
const layouts = [...layouts1];
|
|
205
198
|
for (const attribute of layouts2) {
|
package/dist/model/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","_defineProperty","defaultProps","id","Object","assign","userData","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","vs","fs","getUniforms","shaderAssembler","assembleShaders","_getModuleUniforms","vertexCount","instanceCount","topology","bufferLayout","parameters","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","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","warn","concat","reason","_pipelineNeedsUpdate","createRenderPipeline","createShader","stage","source","handle","undefined","defines","modules","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, PlatformInfo} 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';\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 /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(platformInfo, 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 if (props.geometry) {\n 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 // 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 * Geometry, sets several attributes, indices, and also vertex count and topology\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): void {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n\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 // 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;AAAA,SAC5BC,eAAe;AAsCvB,OAAO,MAAMC,KAAK,CAAC;EA0DjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAA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AGF,OAAO,CAACG,SAAS,CAC5BC,UAAU,IAAKA,UAAU,CAACC,IAAI,KAAKJ,SAAS,CAACI,IAChD,CAAC;IACD,IAAIH,KAAK,GAAG,CAAC,EAAE;MACbF,OAAO,CAACM,IAAI,CAACL,SAAS,CAAC;IACzB,CAAC,MAAM;MACLD,OAAO,CAACE,KAAK,CAAC,GAAGD,SAAS;IAC5B;EACF;EACA,OAAOD,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indices","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","_pipelineNeedsUpdate","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","setVertexCount","setInstanceCount","setIndexBuffer","attributes","setAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","setConstantAttributes","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","warn","reason","createRenderPipeline","createShader","stage","source","handle","undefined","defines","modules","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, PlatformInfo} 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';\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 /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(platformInfo, 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 if (props.geometry) {\n 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 // 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 * Geometry, sets several attributes, indices, and also vertex count and topology\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): void {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n\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 if (bufferLayout !== this.bufferLayout) {\n this.bufferLayout = bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\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 /**\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;AAAA,SAC5BC,eAAe;AAsCvB,OAAO,MAAMC,KAAK,CAAC;EA0DjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAzCtCD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,EAAE;IAAA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AIH,KAAK,GAAG,CAAC,EAAE;MACbF,OAAO,CAACM,IAAI,CAACL,SAAS,CAAC;IACzB,CAAC,MAAM;MACLD,OAAO,CAACE,KAAK,CAAC,GAAGD,SAAS;IAC5B;EACF;EACA,OAAOD,OAAO;AAChB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
3
2
|
import { log } from '@luma.gl/core';
|
|
4
3
|
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
@@ -13,7 +12,7 @@ export class GroupNode extends ScenegraphNode {
|
|
|
13
12
|
} = props;
|
|
14
13
|
log.assert(children.every(child => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
|
|
15
14
|
super(props);
|
|
16
|
-
|
|
15
|
+
this.children = void 0;
|
|
17
16
|
this.children = children;
|
|
18
17
|
}
|
|
19
18
|
getBounds() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-node.js","names":["Matrix4","Vector3","log","ScenegraphNode","GroupNode","constructor","props","arguments","length","undefined","Array","isArray","children","assert","every","child","
|
|
1
|
+
{"version":3,"file":"group-node.js","names":["Matrix4","Vector3","log","ScenegraphNode","GroupNode","constructor","props","arguments","length","undefined","Array","isArray","children","assert","every","child","getBounds","result","Infinity","traverse","node","_ref","worldMatrix","bounds","min","max","center","add","divide","transformAsPoint","halfSize","subtract","transformAsVector","v","position","multiply","i","Math","Number","isFinite","destroy","forEach","removeAll","_len","_key","push","remove","indexOf","splice","visitor","modelMatrix","multiplyRight","matrix"],"sources":["../../src/scenegraph/group-node.ts"],"sourcesContent":["import {Matrix4, Vector3} from '@math.gl/core';\nimport {log} from '@luma.gl/core';\nimport {ScenegraphNode, ScenegraphNodeProps} from './scenegraph-node';\n\nexport type GroupNodeProps = ScenegraphNodeProps & {\n children?: ScenegraphNode[];\n}\n\nexport class GroupNode extends ScenegraphNode {\n children: ScenegraphNode[];\n\n constructor(children: ScenegraphNode[]);\n constructor(props?: GroupNodeProps);\n\n constructor(props: ScenegraphNode[] | GroupNodeProps = {}) {\n props = Array.isArray(props) ? {children: props} : props;\n const {children = []} = props;\n log.assert(\n children.every((child) => child instanceof ScenegraphNode),\n 'every child must an instance of ScenegraphNode'\n );\n super(props);\n this.children = children;\n }\n\n override getBounds(): [number[], number[]] | null {\n const result: [number[], number[]] = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];\n\n this.traverse((node, {worldMatrix}) => {\n const bounds = node.getBounds();\n if (!bounds) {\n return;\n }\n const [min, max] = bounds;\n const center = new Vector3(min).add(max).divide([2, 2, 2]);\n worldMatrix.transformAsPoint(center, center);\n const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);\n worldMatrix.transformAsVector(halfSize, halfSize);\n\n for (let v = 0; v < 8; v++) {\n // Test all 8 corners of the box\n const position = new Vector3(\n v & 0b001 ? -1 : 1,\n v & 0b010 ? -1 : 1,\n v & 0b100 ? -1 : 1\n ).multiply(halfSize).add(center);\n\n for (let i = 0; i < 3; i++) {\n result[0][i] = Math.min(result[0][i], position[i]);\n result[1][i] = Math.max(result[1][i], position[i]);\n }\n }\n });\n if (!Number.isFinite(result[0][0])) {\n return null;\n }\n return result;\n }\n\n override destroy(): void {\n this.children.forEach((child) => child.destroy());\n this.removeAll();\n super.destroy();\n }\n\n // Unpacks arrays and nested arrays of children\n add(...children: (ScenegraphNode | ScenegraphNode[])[]): this {\n for (const child of children) {\n if (Array.isArray(child)) {\n this.add(...child);\n } else {\n this.children.push(child);\n }\n }\n return this;\n }\n\n remove(child: ScenegraphNode): this {\n const children = this.children;\n const indexOf = children.indexOf(child);\n if (indexOf > -1) {\n children.splice(indexOf, 1);\n }\n return this;\n }\n\n removeAll(): this {\n this.children = [];\n return this;\n }\n\n traverse(visitor: (node: ScenegraphNode, context: {worldMatrix: Matrix4}) => void, {worldMatrix = new Matrix4()} = {}) {\n const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);\n\n for (const child of this.children) {\n if (child instanceof GroupNode) {\n child.traverse(visitor, {worldMatrix: modelMatrix});\n } else {\n visitor(child, {worldMatrix: modelMatrix});\n }\n }\n }\n}\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,GAAG,QAAO,eAAe;AAAC,SAC1BC,cAAc;AAMtB,OAAO,MAAMC,SAAS,SAASD,cAAc,CAAC;EAM5CE,WAAWA,CAAA,EAAgD;IAAA,IAA/CC,KAAwC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACvDD,KAAK,GAAGI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,GAAG;MAACM,QAAQ,EAAEN;IAAK,CAAC,GAAGA,KAAK;IACxD,MAAM;MAACM,QAAQ,GAAG;IAAE,CAAC,GAAGN,KAAK;IAC7BJ,GAAG,CAACW,MAAM,CACRD,QAAQ,CAACE,KAAK,CAAEC,KAAK,IAAKA,KAAK,YAAYZ,cAAc,CAAC,EAC1D,gDACF,CAAC;IACD,KAAK,CAACG,KAAK,CAAC;IAAC,KAZfM,QAAQ;IAaN,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;EAESI,SAASA,CAAA,EAAgC;IAChD,MAAMC,MAA4B,GAAG,CAAC,CAACC,QAAQ,EAAEA,QAAQ,EAAEA,QAAQ,CAAC,EAAE,CAAC,CAACA,QAAQ,EAAE,CAACA,QAAQ,EAAE,CAACA,QAAQ,CAAC,CAAC;IAExG,IAAI,CAACC,QAAQ,CAAC,CAACC,IAAI,EAAAC,IAAA,KAAoB;MAAA,IAAlB;QAACC;MAAW,CAAC,GAAAD,IAAA;MAChC,MAAME,MAAM,GAAGH,IAAI,CAACJ,SAAS,CAAC,CAAC;MAC/B,IAAI,CAACO,MAAM,EAAE;QACX;MACF;MACA,MAAM,CAACC,GAAG,E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Q,GAAG,EAAE;IAClB,OAAO,IAAI;EACb;EAEAO,QAAQA,CAAC8B,OAAwE,EAAsC;IAAA,IAApC;MAAC3B,WAAW,GAAG,IAAItB,OAAO,CAAC;IAAC,CAAC,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACnH,MAAM2C,WAAW,GAAG,IAAIlD,OAAO,CAACsB,WAAW,CAAC,CAAC6B,aAAa,CAAC,IAAI,CAACC,MAAM,CAAC;IAEvE,KAAK,MAAMrC,KAAK,IAAI,IAAI,CAACH,QAAQ,EAAE;MACjC,IAAIG,KAAK,YAAYX,SAAS,EAAE;QAC9BW,KAAK,CAACI,QAAQ,CAAC8B,OAAO,EAAE;UAAC3B,WAAW,EAAE4B;QAAW,CAAC,CAAC;MACrD,CAAC,MAAM;QACLD,OAAO,CAAClC,KAAK,EAAE;UAACO,WAAW,EAAE4B;QAAW,CAAC,CAAC;MAC5C;IACF;EACF;AACF"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
3
2
|
export class ModelNode extends ScenegraphNode {
|
|
4
3
|
constructor(props) {
|
|
5
4
|
super(props);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
this.model = void 0;
|
|
6
|
+
this.bounds = null;
|
|
7
|
+
this.managedResources = void 0;
|
|
9
8
|
this.model = props.model;
|
|
10
9
|
this.managedResources = props.managedResources || [];
|
|
11
10
|
this.bounds = props.bounds || null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-node.js","names":["ScenegraphNode","ModelNode","constructor","props","
|
|
1
|
+
{"version":3,"file":"model-node.js","names":["ScenegraphNode","ModelNode","constructor","props","model","bounds","managedResources","setProps","getBounds","destroy","forEach","resource","draw","renderPass"],"sources":["../../src/scenegraph/model-node.ts"],"sourcesContent":["import {RenderPass} from '@luma.gl/core';\nimport {ScenegraphNode, ScenegraphNodeProps} from './scenegraph-node';\nimport {Model} from '../model/model';\n\nexport type ModelNodeProps = ScenegraphNodeProps & {\n model: Model;\n managedResources?: any[];\n bounds?: [number[], number[]];\n}\n\nexport class ModelNode extends ScenegraphNode {\n readonly model: Model;\n bounds: [number[], number[]] | null = null;\n managedResources: any[];\n\n // TODO - is this used? override callbacks to make sure we call them with this\n // onBeforeRender = null;\n // onAfterRender = null;\n // AfterRender = null;\n\n constructor(props: ModelNodeProps) {\n super(props);\n\n // Create new Model or used supplied Model\n this.model = props.model;\n this.managedResources = props.managedResources || [];\n this.bounds = props.bounds || null;\n this.setProps(props);\n }\n\n override getBounds(): [number[], number[]] | null {\n return this.bounds;\n }\n\n override destroy(): void {\n if (this.model) {\n this.model.destroy();\n // @ts-expect-error\n this.model = null;\n }\n this.managedResources.forEach((resource) => resource.destroy());\n this.managedResources = [];\n }\n\n // Expose model methods\n draw(renderPass?: RenderPass) {\n // Return value indicates if something was actually drawn\n return this.model.draw(renderPass);\n }\n}\n"],"mappings":"SACQA,cAAc;AAStB,OAAO,MAAMC,SAAS,SAASD,cAAc,CAAC;EAU5CE,WAAWA,CAACC,KAAqB,EAAE;IACjC,KAAK,CAACA,KAAK,CAAC;IAAC,KAVNC,KAAK;IAAA,KACdC,MAAM,GAAgC,IAAI;IAAA,KAC1CC,gBAAgB;IAWd,IAAI,CAACF,KAAK,GAAGD,KAAK,CAACC,KAAK;IACxB,IAAI,CAACE,gBAAgB,GAAGH,KAAK,CAACG,gBAAgB,IAAI,EAAE;IACpD,IAAI,CAACD,MAAM,GAAGF,KAAK,CAACE,MAAM,IAAI,IAAI;IAClC,IAAI,CAACE,QAAQ,CAACJ,KAAK,CAAC;EACtB;EAESK,SAASA,CAAA,EAAgC;IAChD,OAAO,IAAI,CAACH,MAAM;EACpB;EAESI,OAAOA,CAAA,EAAS;IACvB,IAAI,IAAI,CAACL,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACK,OAAO,CAAC,CAAC;MAEpB,IAAI,CAACL,KAAK,GAAG,IAAI;IACnB;IACA,IAAI,CAACE,gBAAgB,CAACI,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAACF,OAAO,CAAC,CAAC,CAAC;IAC/D,IAAI,CAACH,gBAAgB,GAAG,EAAE;EAC5B;EAGAM,IAAIA,CAACC,UAAuB,EAAE;IAE5B,OAAO,IAAI,CAACT,KAAK,CAACQ,IAAI,CAACC,UAAU,CAAC;EACpC;AACF"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { assert, uid } from '@luma.gl/core';
|
|
3
2
|
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
4
3
|
export class ScenegraphNode {
|
|
5
4
|
constructor() {
|
|
6
5
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
this.id = void 0;
|
|
7
|
+
this.matrix = new Matrix4();
|
|
8
|
+
this.display = true;
|
|
9
|
+
this.position = new Vector3();
|
|
10
|
+
this.rotation = new Vector3();
|
|
11
|
+
this.scale = new Vector3(1, 1, 1);
|
|
12
|
+
this.userData = {};
|
|
13
|
+
this.props = {};
|
|
15
14
|
const {
|
|
16
15
|
id
|
|
17
16
|
} = props;
|
|
@@ -30,7 +29,7 @@ export class ScenegraphNode {
|
|
|
30
29
|
return this;
|
|
31
30
|
}
|
|
32
31
|
toString() {
|
|
33
|
-
return
|
|
32
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
34
33
|
}
|
|
35
34
|
setPosition(position) {
|
|
36
35
|
assert(position.length === 3, 'setPosition requires vector argument');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenegraph-node.js","names":["assert","uid","Vector3","Matrix4","ScenegraphNode","constructor","props","arguments","length","undefined","
|
|
1
|
+
{"version":3,"file":"scenegraph-node.js","names":["assert","uid","Vector3","Matrix4","ScenegraphNode","constructor","props","arguments","length","undefined","id","matrix","display","position","rotation","scale","userData","name","_setScenegraphNodeProps","getBounds","destroy","delete","setProps","toString","setPosition","setRotation","setScale","setMatrix","copyMatrix","copy","setMatrixComponents","components","update","updateMatrix","pos","rot","identity","translate","rotateXYZ","options","getCoordinateUniforms","viewMatrix","modelMatrix","worldMatrix","multiplyRight","worldInverse","invert","worldInverseTranspose","transpose","objectMatrix","worldInverseMatrix","worldInverseTransposeMatrix","Object","assign"],"sources":["../../src/scenegraph/scenegraph-node.ts"],"sourcesContent":["import {assert, uid, NumericArray} from '@luma.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\n\n/** Properties for creating a new Scenegraph */\nexport type ScenegraphNodeProps = {\n id?: string;\n /** whether to display the object at all */\n display?: boolean;\n matrix?: NumericArray;\n position?: NumericArray;\n rotation?: NumericArray;\n scale?: NumericArray;\n update?: boolean\n};\n\nexport class ScenegraphNode {\n readonly id: string;\n matrix: Matrix4 = new Matrix4();\n\n display = true; \n position = new Vector3();\n rotation = new Vector3();\n scale = new Vector3(1, 1, 1);\n userData: Record<string, unknown> = {};\n\n props: ScenegraphNodeProps = {};\n\n constructor(props: ScenegraphNodeProps = {}) {\n const {id} = props;\n\n this.id = id || uid(this.constructor.name);\n\n this._setScenegraphNodeProps(props);\n }\n\n getBounds(): [number[], number[]] | null {\n return null;\n }\n\n destroy(): void {}\n\n /** @deprecated use .destroy() */\n delete(): void {\n this.destroy();\n }\n setProps(props: ScenegraphNodeProps): this {\n this._setScenegraphNodeProps(props);\n return this;\n }\n\n toString(): string {\n return `{type: ScenegraphNode, id: ${this.id})}`;\n }\n\n setPosition(position: any): this {\n assert(position.length === 3, 'setPosition requires vector argument');\n this.position = position;\n return this;\n }\n\n setRotation(rotation: any): this {\n assert(rotation.length === 3, 'setRotation requires vector argument');\n this.rotation = rotation;\n return this;\n }\n\n setScale(scale: any): this {\n assert(scale.length === 3, 'setScale requires vector argument');\n this.scale = scale;\n return this;\n }\n\n setMatrix(matrix: any, copyMatrix: boolean = true): void {\n if (copyMatrix) {\n this.matrix.copy(matrix);\n } else {\n this.matrix = matrix;\n }\n }\n\n setMatrixComponents(components: {\n position?: any;\n rotation?: any;\n scale?: any;\n update?: boolean;\n }): this {\n const {position, rotation, scale, update = true} = components;\n if (position) {\n this.setPosition(position);\n }\n if (rotation) {\n this.setRotation(rotation);\n }\n if (scale) {\n this.setScale(scale);\n }\n if (update) {\n this.updateMatrix();\n }\n return this;\n }\n\n updateMatrix(): this {\n const pos = this.position;\n const rot = this.rotation;\n const scale = this.scale;\n\n this.matrix.identity();\n this.matrix.translate(pos);\n this.matrix.rotateXYZ(rot);\n this.matrix.scale(scale);\n return this;\n }\n\n update(options: {position?: any; rotation?: any; scale?: any} = {}): this {\n const {position, rotation, scale} = options;\n if (position) {\n this.setPosition(position);\n }\n if (rotation) {\n this.setRotation(rotation);\n }\n if (scale) {\n this.setScale(scale);\n }\n this.updateMatrix();\n return this;\n }\n\n getCoordinateUniforms(\n viewMatrix: any,\n modelMatrix?: any\n ): {\n viewMatrix: any;\n modelMatrix: any;\n objectMatrix: any;\n worldMatrix: any;\n worldInverseMatrix: any;\n worldInverseTransposeMatrix: any;\n } {\n // TODO - solve multiple class problem\n // assert(viewMatrix instanceof Matrix4);\n assert(viewMatrix);\n modelMatrix = modelMatrix || this.matrix;\n const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);\n const worldInverse = worldMatrix.invert();\n const worldInverseTranspose = worldInverse.transpose();\n\n return {\n viewMatrix,\n modelMatrix,\n objectMatrix: modelMatrix,\n worldMatrix,\n worldInverseMatrix: worldInverse,\n worldInverseTransposeMatrix: worldInverseTranspose\n };\n }\n\n // TODO - copied code, not yet vetted\n /*\n transform() {\n if (!this.parent) {\n this.endPosition.set(this.position);\n this.endRotation.set(this.rotation);\n this.endScale.set(this.scale);\n } else {\n const parent = this.parent;\n this.endPosition.set(this.position.add(parent.endPosition));\n this.endRotation.set(this.rotation.add(parent.endRotation));\n this.endScale.set(this.scale.add(parent.endScale));\n }\n\n const ch = this.children;\n for (let i = 0; i < ch.length; ++i) {\n ch[i].transform();\n }\n\n return this;\n }\n */\n\n _setScenegraphNodeProps(props: ScenegraphNodeProps): void {\n if ('display' in props) {\n this.display = props.display;\n }\n\n if ('position' in props) {\n this.setPosition(props.position);\n }\n if ('rotation' in props) {\n this.setRotation(props.rotation);\n }\n if ('scale' in props) {\n this.setScale(props.scale);\n }\n\n // Matrix overwrites other props\n if ('matrix' in props) {\n this.setMatrix(props.matrix);\n }\n\n Object.assign(this.props, props);\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,EAAEC,GAAG,QAAqB,eAAe;AACvD,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAc9C,OAAO,MAAMC,cAAc,CAAC;EAY1BC,WAAWA,CAAA,EAAkC;IAAA,IAAjCC,KAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAXlCG,EAAE;IAAA,KACXC,MAAM,GAAY,IAAIR,OAAO,CAAC,CAAC;IAAA,KAE/BS,OAAO,GAAG,IAAI;IAAA,KACdC,QAAQ,GAAG,IAAIX,OAAO,CAAC,CAAC;IAAA,KACxBY,QAAQ,GAAG,IAAIZ,OAAO,CAAC,CAAC;IAAA,KACxBa,KAAK,GAAG,IAAIb,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAAA,KAC5Bc,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCV,KAAK,GAAwB,CAAC,CAAC;IAG7B,MAAM;MAACI;IAAE,CAAC,GAAGJ,KAAK;IAElB,IAAI,CAACI,EAAE,GAAGA,EAAE,IAAIT,GAAG,CAAC,IAAI,CAACI,WAA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
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { getShaderInfo, getPassthroughFS } from '@luma.gl/shadertools';
|
|
3
2
|
import { GL } from '@luma.gl/constants';
|
|
4
3
|
import { WebGLDevice } from '@luma.gl/webgl';
|
|
@@ -9,10 +8,10 @@ export class Transform {
|
|
|
9
8
|
}
|
|
10
9
|
constructor(device) {
|
|
11
10
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
this.device = void 0;
|
|
12
|
+
this.gl = void 0;
|
|
13
|
+
this.elementCount = 0;
|
|
14
|
+
this.elementIDBuffer = null;
|
|
16
15
|
this.device = WebGLDevice.attach(device);
|
|
17
16
|
this.gl = this.device.gl2;
|
|
18
17
|
this._buildResourceTransforms(props);
|