@luma.gl/engine 9.0.0-alpha.4 → 9.0.0-alpha.40
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/LICENSE +3 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +9 -9
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -31
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +114 -195
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +6 -7
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/animation-loop/render-loop.d.ts +23 -0
- package/dist/animation-loop/render-loop.d.ts.map +1 -0
- package/dist/animation-loop/render-loop.js +7 -0
- package/dist/animation-loop/render-loop.js.map +1 -0
- package/dist/dist.dev.js +7149 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +15 -8
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +50 -59
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +32 -97
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +102 -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 +2802 -0
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -40
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +50 -148
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +175 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +273 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shadertools/shader-module-uniforms.d.ts +36 -0
- package/dist/shadertools/shader-module-uniforms.d.ts.map +1 -0
- package/dist/shadertools/shader-module-uniforms.js +87 -0
- package/dist/shadertools/shader-module-uniforms.js.map +1 -0
- package/dist/transform/transform.d.ts +98 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/transform/transform.js +48 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist.min.js +264 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +16 -15
- package/src/{lib → animation-loop}/animation-loop.ts +119 -102
- package/src/{lib → animation-loop}/animation-props.ts +5 -5
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/animation-loop/render-loop.ts +23 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +6 -3
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +7 -6
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +79 -119
- package/src/geometry/gpu-geometry.ts +124 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +31 -12
- package/src/lib/clip-space.ts +16 -15
- package/src/lib/pipeline-factory.ts +60 -168
- package/src/model/model.ts +489 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shadertools/shader-module-uniforms.ts +178 -0
- package/src/transform/transform.ts +249 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- 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/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -176
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -179
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout, VertexArray, AttributeInfo } from '@luma.gl/core';
|
|
2
|
+
import type { Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';
|
|
3
|
+
import { Device, Buffer, RenderPipeline, RenderPass } from '@luma.gl/core';
|
|
4
|
+
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
5
|
+
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
6
|
+
import type { Geometry } from '../geometry/geometry';
|
|
7
|
+
import { GPUGeometry } from '../geometry/gpu-geometry';
|
|
8
|
+
import { PipelineFactory } from '../lib/pipeline-factory';
|
|
9
|
+
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
10
|
+
vs: {
|
|
11
|
+
glsl?: string;
|
|
12
|
+
wgsl?: string;
|
|
13
|
+
} | string | null;
|
|
14
|
+
fs: {
|
|
15
|
+
glsl?: string;
|
|
16
|
+
wgsl?: string;
|
|
17
|
+
} | string | null;
|
|
18
|
+
/** shadertool shader modules (added to shader code) */
|
|
19
|
+
modules?: ShaderModule[];
|
|
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
|
+
pipelineFactory?: PipelineFactory;
|
|
24
|
+
/** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
|
|
25
|
+
shaderAssembler?: ShaderAssembler;
|
|
26
|
+
/** Parameters that are built into the pipeline */
|
|
27
|
+
parameters?: RenderPipelineParameters;
|
|
28
|
+
/** Geometry */
|
|
29
|
+
geometry?: GPUGeometry | Geometry | null;
|
|
30
|
+
/** Vertex count */
|
|
31
|
+
vertexCount?: number;
|
|
32
|
+
/** instance count */
|
|
33
|
+
instanceCount?: number;
|
|
34
|
+
indexBuffer?: Buffer | null;
|
|
35
|
+
/** @note this is really a map of buffers, not a map of attributes */
|
|
36
|
+
attributes?: Record<string, Buffer>;
|
|
37
|
+
/** */
|
|
38
|
+
constantAttributes?: Record<string, TypedArray>;
|
|
39
|
+
/** Mapped uniforms for shadertool modules */
|
|
40
|
+
moduleSettings?: Record<string, Record<string, any>>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* v9 Model API
|
|
44
|
+
* A model
|
|
45
|
+
* - automatically reuses pipelines (programs) when possible
|
|
46
|
+
* - automatically rebuilds pipelines if necessary to accommodate changed settings
|
|
47
|
+
* shadertools integration
|
|
48
|
+
* - accepts modules and performs shader transpilation
|
|
49
|
+
*/
|
|
50
|
+
export declare class Model {
|
|
51
|
+
static defaultProps: Required<ModelProps>;
|
|
52
|
+
readonly device: Device;
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly vs: string;
|
|
55
|
+
readonly fs: string;
|
|
56
|
+
readonly pipelineFactory: PipelineFactory;
|
|
57
|
+
userData: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
/** The render pipeline GPU parameters, depth testing etc */
|
|
61
|
+
parameters: RenderPipelineParameters;
|
|
62
|
+
/** The primitive topology */
|
|
63
|
+
topology: PrimitiveTopology;
|
|
64
|
+
/** Buffer layout */
|
|
65
|
+
bufferLayout: BufferLayout[];
|
|
66
|
+
/** Vertex count */
|
|
67
|
+
vertexCount: number;
|
|
68
|
+
/** instance count */
|
|
69
|
+
instanceCount: number;
|
|
70
|
+
/** Index buffer */
|
|
71
|
+
indexBuffer: Buffer | null;
|
|
72
|
+
/** Buffer-valued attributes */
|
|
73
|
+
bufferAttributes: Record<string, Buffer>;
|
|
74
|
+
/** Constant-valued attributes */
|
|
75
|
+
constantAttributes: Record<string, TypedArray>;
|
|
76
|
+
/** Bindings (textures, samplers, uniform buffers) */
|
|
77
|
+
bindings: Record<string, Binding>;
|
|
78
|
+
/** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/
|
|
79
|
+
uniforms: Record<string, UniformValue>;
|
|
80
|
+
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
81
|
+
pipeline: RenderPipeline;
|
|
82
|
+
/**
|
|
83
|
+
* VertexArray
|
|
84
|
+
* @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
|
|
85
|
+
* @todo - allow application to define multiple vertex arrays?
|
|
86
|
+
* */
|
|
87
|
+
vertexArray: VertexArray;
|
|
88
|
+
_pipelineNeedsUpdate: string | false;
|
|
89
|
+
_attributeInfos: Record<string, AttributeInfo>;
|
|
90
|
+
_gpuGeometry: GPUGeometry | null;
|
|
91
|
+
private _getModuleUniforms;
|
|
92
|
+
private props;
|
|
93
|
+
constructor(device: Device, props: ModelProps);
|
|
94
|
+
destroy(): void;
|
|
95
|
+
draw(renderPass: RenderPass): void;
|
|
96
|
+
/**
|
|
97
|
+
* Updates the optional geometry
|
|
98
|
+
* Geometry, set topology and bufferLayout
|
|
99
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
100
|
+
*/
|
|
101
|
+
setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry;
|
|
102
|
+
/**
|
|
103
|
+
* Updates the optional geometry attributes
|
|
104
|
+
* Geometry, sets several attributes, indexBuffer, and also vertex count
|
|
105
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
106
|
+
*/
|
|
107
|
+
_setGeometryAttributes(gpuGeometry: GPUGeometry): void;
|
|
108
|
+
/**
|
|
109
|
+
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
110
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
111
|
+
*/
|
|
112
|
+
setTopology(topology: PrimitiveTopology): void;
|
|
113
|
+
/**
|
|
114
|
+
* Updates the buffer layout.
|
|
115
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
116
|
+
*/
|
|
117
|
+
setBufferLayout(bufferLayout: BufferLayout[]): void;
|
|
118
|
+
/**
|
|
119
|
+
* Set GPU parameters.
|
|
120
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch.
|
|
121
|
+
* @param parameters
|
|
122
|
+
*/
|
|
123
|
+
setParameters(parameters: RenderPipelineParameters): void;
|
|
124
|
+
/**
|
|
125
|
+
* Updates the vertex count (used in draw calls)
|
|
126
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
127
|
+
*/
|
|
128
|
+
setVertexCount(vertexCount: number): void;
|
|
129
|
+
/**
|
|
130
|
+
* Updates the instance count (used in draw calls)
|
|
131
|
+
* @note Any attributes with stepMode=instance need to be at least this big
|
|
132
|
+
*/
|
|
133
|
+
setInstanceCount(instanceCount: number): void;
|
|
134
|
+
/**
|
|
135
|
+
* Updates shader module settings (which results in uniforms being set)
|
|
136
|
+
*/
|
|
137
|
+
setShaderModuleProps(props: Record<string, any>): void;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Updates shader module settings (which results in uniforms being set)
|
|
140
|
+
*/
|
|
141
|
+
updateModuleSettings(props: Record<string, any>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Sets bindings (textures, samplers, uniform buffers)
|
|
144
|
+
*/
|
|
145
|
+
setBindings(bindings: Record<string, Binding>): void;
|
|
146
|
+
/**
|
|
147
|
+
* Sets individual uniforms
|
|
148
|
+
* @deprecated WebGL only, use uniform buffers for portability
|
|
149
|
+
* @param uniforms
|
|
150
|
+
* @returns self for chaining
|
|
151
|
+
*/
|
|
152
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
153
|
+
/**
|
|
154
|
+
* Sets the index buffer
|
|
155
|
+
* @todo - how to unset it if we change geometry?
|
|
156
|
+
*/
|
|
157
|
+
setIndexBuffer(indexBuffer: Buffer | null): void;
|
|
158
|
+
/**
|
|
159
|
+
* Sets attributes (buffers)
|
|
160
|
+
* @note Overrides any attributes previously set with the same name
|
|
161
|
+
*/
|
|
162
|
+
setAttributes(buffers: Record<string, Buffer>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Sets constant attributes
|
|
165
|
+
* @note Overrides any attributes previously set with the same name
|
|
166
|
+
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
167
|
+
* Any attribute that is disabled in the current vertex array object
|
|
168
|
+
* is read from the context's global constant value for that attribute location.
|
|
169
|
+
* @param constantAttributes
|
|
170
|
+
*/
|
|
171
|
+
setConstantAttributes(attributes: Record<string, TypedArray>): void;
|
|
172
|
+
_setPipelineNeedsUpdate(reason: string): void;
|
|
173
|
+
_updatePipeline(): RenderPipeline;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,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;AAE9F,OAAO,KAAK,EAAC,YAAY,EAAe,MAAM,sBAAsB,CAAC;AACrE,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;AAExD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAm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EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;CAqBlC"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { RenderPipeline, log, uid, deepEqual } from '@luma.gl/core';
|
|
2
|
+
import { getAttributeInfosFromLayouts } from '@luma.gl/core';
|
|
3
|
+
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
|
+
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
5
|
+
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
6
|
+
export class Model {
|
|
7
|
+
constructor(device, props) {
|
|
8
|
+
this.device = void 0;
|
|
9
|
+
this.id = void 0;
|
|
10
|
+
this.vs = void 0;
|
|
11
|
+
this.fs = void 0;
|
|
12
|
+
this.pipelineFactory = void 0;
|
|
13
|
+
this.userData = {};
|
|
14
|
+
this.parameters = void 0;
|
|
15
|
+
this.topology = void 0;
|
|
16
|
+
this.bufferLayout = void 0;
|
|
17
|
+
this.vertexCount = void 0;
|
|
18
|
+
this.instanceCount = 0;
|
|
19
|
+
this.indexBuffer = null;
|
|
20
|
+
this.bufferAttributes = {};
|
|
21
|
+
this.constantAttributes = {};
|
|
22
|
+
this.bindings = {};
|
|
23
|
+
this.uniforms = {};
|
|
24
|
+
this.pipeline = void 0;
|
|
25
|
+
this.vertexArray = void 0;
|
|
26
|
+
this._pipelineNeedsUpdate = 'newly created';
|
|
27
|
+
this._attributeInfos = {};
|
|
28
|
+
this._gpuGeometry = null;
|
|
29
|
+
this._getModuleUniforms = void 0;
|
|
30
|
+
this.props = void 0;
|
|
31
|
+
this.props = {
|
|
32
|
+
...Model.defaultProps,
|
|
33
|
+
...props
|
|
34
|
+
};
|
|
35
|
+
props = this.props;
|
|
36
|
+
this.id = props.id || uid('model');
|
|
37
|
+
this.device = device;
|
|
38
|
+
Object.assign(this.userData, props.userData);
|
|
39
|
+
const platformInfo = {
|
|
40
|
+
type: device.info.type,
|
|
41
|
+
shaderLanguage: device.info.shadingLanguages[0],
|
|
42
|
+
gpu: device.info.gpu,
|
|
43
|
+
features: device.features
|
|
44
|
+
};
|
|
45
|
+
const {
|
|
46
|
+
vs,
|
|
47
|
+
fs,
|
|
48
|
+
getUniforms
|
|
49
|
+
} = this.props.shaderAssembler.assembleShaders(platformInfo, this.props);
|
|
50
|
+
this.vs = vs;
|
|
51
|
+
this.fs = fs;
|
|
52
|
+
this._getModuleUniforms = getUniforms;
|
|
53
|
+
this.vertexCount = this.props.vertexCount;
|
|
54
|
+
this.instanceCount = this.props.instanceCount;
|
|
55
|
+
this.topology = this.props.topology;
|
|
56
|
+
this.bufferLayout = this.props.bufferLayout;
|
|
57
|
+
this.parameters = this.props.parameters;
|
|
58
|
+
if (props.geometry) {
|
|
59
|
+
this._gpuGeometry = this.setGeometry(props.geometry);
|
|
60
|
+
}
|
|
61
|
+
this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
62
|
+
this.pipeline = this._updatePipeline();
|
|
63
|
+
this.vertexArray = device.createVertexArray({
|
|
64
|
+
renderPipeline: this.pipeline
|
|
65
|
+
});
|
|
66
|
+
if (this._gpuGeometry) {
|
|
67
|
+
this._setGeometryAttributes(this._gpuGeometry);
|
|
68
|
+
}
|
|
69
|
+
if (props.vertexCount) {
|
|
70
|
+
this.setVertexCount(props.vertexCount);
|
|
71
|
+
}
|
|
72
|
+
if (props.instanceCount) {
|
|
73
|
+
this.setInstanceCount(props.instanceCount);
|
|
74
|
+
}
|
|
75
|
+
if (props.indices) {
|
|
76
|
+
throw new Error('Model.props.indices removed. Use props.indexBuffer');
|
|
77
|
+
}
|
|
78
|
+
if (props.indexBuffer) {
|
|
79
|
+
this.setIndexBuffer(props.indexBuffer);
|
|
80
|
+
}
|
|
81
|
+
if (props.attributes) {
|
|
82
|
+
this.setAttributes(props.attributes);
|
|
83
|
+
}
|
|
84
|
+
if (props.constantAttributes) {
|
|
85
|
+
this.setConstantAttributes(props.constantAttributes);
|
|
86
|
+
}
|
|
87
|
+
if (props.bindings) {
|
|
88
|
+
this.setBindings(props.bindings);
|
|
89
|
+
}
|
|
90
|
+
if (props.uniforms) {
|
|
91
|
+
this.setUniforms(props.uniforms);
|
|
92
|
+
}
|
|
93
|
+
if (props.moduleSettings) {
|
|
94
|
+
this.updateModuleSettings(props.moduleSettings);
|
|
95
|
+
}
|
|
96
|
+
this.setUniforms(this._getModuleUniforms());
|
|
97
|
+
Object.seal(this);
|
|
98
|
+
}
|
|
99
|
+
destroy() {
|
|
100
|
+
this.pipelineFactory.release(this.pipeline);
|
|
101
|
+
}
|
|
102
|
+
draw(renderPass) {
|
|
103
|
+
this.pipeline = this._updatePipeline();
|
|
104
|
+
this.pipeline.setBindings(this.bindings);
|
|
105
|
+
this.pipeline.setUniforms(this.uniforms);
|
|
106
|
+
this.pipeline.draw({
|
|
107
|
+
renderPass,
|
|
108
|
+
vertexArray: this.vertexArray,
|
|
109
|
+
vertexCount: this.vertexCount,
|
|
110
|
+
instanceCount: this.instanceCount
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
setGeometry(geometry) {
|
|
114
|
+
const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
|
|
115
|
+
this.setTopology(gpuGeometry.topology || 'triangle-list');
|
|
116
|
+
this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
|
|
117
|
+
if (this.vertexArray) {
|
|
118
|
+
this._setGeometryAttributes(gpuGeometry);
|
|
119
|
+
}
|
|
120
|
+
return gpuGeometry;
|
|
121
|
+
}
|
|
122
|
+
_setGeometryAttributes(gpuGeometry) {
|
|
123
|
+
this.vertexCount = gpuGeometry.vertexCount;
|
|
124
|
+
this.setAttributes(gpuGeometry.attributes);
|
|
125
|
+
this.setIndexBuffer(gpuGeometry.indices);
|
|
126
|
+
}
|
|
127
|
+
setTopology(topology) {
|
|
128
|
+
if (topology !== this.topology) {
|
|
129
|
+
this.topology = topology;
|
|
130
|
+
this._setPipelineNeedsUpdate('topology');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
setBufferLayout(bufferLayout) {
|
|
134
|
+
this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
|
|
135
|
+
this._setPipelineNeedsUpdate('bufferLayout');
|
|
136
|
+
this.pipeline = this._updatePipeline();
|
|
137
|
+
this.vertexArray = this.device.createVertexArray({
|
|
138
|
+
renderPipeline: this.pipeline
|
|
139
|
+
});
|
|
140
|
+
if (this._gpuGeometry) {
|
|
141
|
+
this._setGeometryAttributes(this._gpuGeometry);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
setParameters(parameters) {
|
|
145
|
+
if (!deepEqual(parameters, this.parameters, 2)) {
|
|
146
|
+
this.parameters = parameters;
|
|
147
|
+
this._setPipelineNeedsUpdate('parameters');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
setVertexCount(vertexCount) {
|
|
151
|
+
this.vertexCount = vertexCount;
|
|
152
|
+
}
|
|
153
|
+
setInstanceCount(instanceCount) {
|
|
154
|
+
this.instanceCount = instanceCount;
|
|
155
|
+
}
|
|
156
|
+
setShaderModuleProps(props) {
|
|
157
|
+
const uniforms = this._getModuleUniforms(props);
|
|
158
|
+
const keys = Object.keys(uniforms).filter(k => uniforms[k].constructor.name.includes('WEBGL'));
|
|
159
|
+
const bindings = {};
|
|
160
|
+
for (const k of keys) {
|
|
161
|
+
bindings[k] = uniforms[k];
|
|
162
|
+
delete uniforms[k];
|
|
163
|
+
}
|
|
164
|
+
Object.assign(this.uniforms, uniforms);
|
|
165
|
+
Object.assign(this.bindings, bindings);
|
|
166
|
+
}
|
|
167
|
+
updateModuleSettings(props) {
|
|
168
|
+
this.setShaderModuleProps(props);
|
|
169
|
+
}
|
|
170
|
+
setBindings(bindings) {
|
|
171
|
+
Object.assign(this.bindings, bindings);
|
|
172
|
+
}
|
|
173
|
+
setUniforms(uniforms) {
|
|
174
|
+
this.pipeline.setUniforms(uniforms);
|
|
175
|
+
Object.assign(this.uniforms, uniforms);
|
|
176
|
+
}
|
|
177
|
+
setIndexBuffer(indexBuffer) {
|
|
178
|
+
this.vertexArray.setIndexBuffer(indexBuffer);
|
|
179
|
+
}
|
|
180
|
+
setAttributes(buffers) {
|
|
181
|
+
if (buffers.indices) {
|
|
182
|
+
log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
|
|
183
|
+
}
|
|
184
|
+
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
185
|
+
var _bufferLayout$attribu;
|
|
186
|
+
const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);
|
|
187
|
+
if (!bufferLayout) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map(layout => layout.attribute) : [bufferLayout.name];
|
|
191
|
+
let set = false;
|
|
192
|
+
for (const attributeName of attributeNames) {
|
|
193
|
+
const attributeInfo = this._attributeInfos[attributeName];
|
|
194
|
+
if (attributeInfo) {
|
|
195
|
+
this.vertexArray.setBuffer(attributeInfo.location, buffer);
|
|
196
|
+
set = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!set) {
|
|
200
|
+
log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
setConstantAttributes(attributes) {
|
|
205
|
+
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
206
|
+
const attributeInfo = this._attributeInfos[attributeName];
|
|
207
|
+
if (attributeInfo) {
|
|
208
|
+
this.vertexArray.setConstant(attributeInfo.location, value);
|
|
209
|
+
} else {
|
|
210
|
+
log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
_setPipelineNeedsUpdate(reason) {
|
|
215
|
+
this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
|
|
216
|
+
}
|
|
217
|
+
_updatePipeline() {
|
|
218
|
+
if (this._pipelineNeedsUpdate) {
|
|
219
|
+
if (this.pipeline) {
|
|
220
|
+
log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
221
|
+
}
|
|
222
|
+
this._pipelineNeedsUpdate = false;
|
|
223
|
+
this.pipeline = this.device.createRenderPipeline({
|
|
224
|
+
...this.props,
|
|
225
|
+
bufferLayout: this.bufferLayout,
|
|
226
|
+
topology: this.topology,
|
|
227
|
+
parameters: this.parameters,
|
|
228
|
+
vs: this.device.createShader({
|
|
229
|
+
id: '{$this.id}-vertex',
|
|
230
|
+
stage: 'vertex',
|
|
231
|
+
source: this.vs
|
|
232
|
+
}),
|
|
233
|
+
fs: this.fs ? this.device.createShader({
|
|
234
|
+
id: '{$this.id}-fragment',
|
|
235
|
+
stage: 'fragment',
|
|
236
|
+
source: this.fs
|
|
237
|
+
}) : null
|
|
238
|
+
});
|
|
239
|
+
this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
|
|
240
|
+
}
|
|
241
|
+
return this.pipeline;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
Model.defaultProps = {
|
|
245
|
+
...RenderPipeline.defaultProps,
|
|
246
|
+
vs: null,
|
|
247
|
+
fs: null,
|
|
248
|
+
id: 'unnamed',
|
|
249
|
+
handle: undefined,
|
|
250
|
+
userData: {},
|
|
251
|
+
defines: {},
|
|
252
|
+
modules: [],
|
|
253
|
+
moduleSettings: {},
|
|
254
|
+
geometry: null,
|
|
255
|
+
indexBuffer: null,
|
|
256
|
+
attributes: {},
|
|
257
|
+
constantAttributes: {},
|
|
258
|
+
pipelineFactory: undefined,
|
|
259
|
+
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
|
|
260
|
+
};
|
|
261
|
+
function mergeBufferLayouts(layouts1, layouts2) {
|
|
262
|
+
const layouts = [...layouts1];
|
|
263
|
+
for (const attribute of layouts2) {
|
|
264
|
+
const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);
|
|
265
|
+
if (index < 0) {
|
|
266
|
+
layouts.push(attribute);
|
|
267
|
+
} else {
|
|
268
|
+
layouts[index] = attribute;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return layouts;
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","getAttributeInfosFromLayouts","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","vertexArray","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","keys","filter","k","name","includes","buffers","warn","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","attributeNames","map","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n TypedArray,\n RenderPipelineProps,\n RenderPipelineParameters,\n BufferLayout,\n VertexArray,\n AttributeInfo\n} 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 {getAttributeInfosFromLayouts} 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 /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: {},\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\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 indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n /** 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(\n platformInfo,\n this.props\n );\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer')\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n 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.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n \n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n /**\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\n // Extract textures & framebuffers set by the modules\n // TODO better way to extract bindings\n const keys = Object.keys(uniforms).filter(k => uniforms[k].constructor.name.includes('WEBGL'));\n const bindings: Record<string, Binding> = {};\n for (const k of keys) {\n bindings[k] = uniforms[k];\n delete uniforms[k];\n }\n\n Object.assign(this.uniforms, uniforms);\n Object.assign(this.bindings, bindings);\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 bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(`Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`)();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs ? this.device.createShader({id: '{$this.id}-fragment', stage: 'fragment', source: this.fs}) : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\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(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n"],"mappings":"AAYA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAC7F,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AA8CvB,OAAO,MAAMC,KAAK,CAAC;EAuEjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAnDtCD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,WAAW,GAAkB,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oB,QAAQ,EAAE;IAChC,MAAME,KAAK,GAAGD,OAAO,CAACE,SAAS,CAACC,UAAU,IAAIA,UAAU,CAACpC,IAAI,KAAKY,SAAS,CAACZ,IAAI,CAAC;IACjF,IAAIkC,KAAK,GAAG,CAAC,EAAE;MACbD,OAAO,CAACI,IAAI,CAACzB,SAAS,CAAC;IACzB,CAAC,MAAM;MACLqB,OAAO,CAACC,KAAK,CAAC,GAAGtB,SAAS;IAC5B;EACF;EACA,OAAOqB,OAAO;AAChB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Matrix4 } from '@math.gl/core';
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
|
|
3
|
+
export type GroupNodeProps = ScenegraphNodeProps & {
|
|
4
|
+
children?: ScenegraphNode[];
|
|
5
|
+
};
|
|
6
|
+
export declare class GroupNode extends ScenegraphNode {
|
|
7
|
+
children: ScenegraphNode[];
|
|
8
|
+
constructor(children: ScenegraphNode[]);
|
|
9
|
+
constructor(props?: GroupNodeProps);
|
|
10
|
+
getBounds(): [number[], number[]] | null;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
add(...children: (ScenegraphNode | ScenegraphNode[])[]): this;
|
|
13
|
+
remove(child: ScenegraphNode): this;
|
|
14
|
+
removeAll(): this;
|
|
15
|
+
traverse(visitor: (node: ScenegraphNode, context: {
|
|
16
|
+
worldMatrix: Matrix4;
|
|
17
|
+
}) => void, { worldMatrix }?: {
|
|
18
|
+
worldMatrix?: Matrix4;
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=group-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAA;AAED,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,EAAE,cAAc,EAAE,CAAC;gBAEf,QAAQ,EAAE,cAAc,EAAE;gBAC1B,KAAK,CAAC,EAAE,cAAc;IAazB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAkCxC,OAAO,IAAI,IAAI;IAOxB,GAAG,CAAC,GAAG,QAAQ,EAAE,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,IAAI;IAW7D,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IASnC,SAAS,IAAI,IAAI;IAKjB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,EAAE,EAAC,WAA2B,EAAC;;KAAK;CAWtH"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
2
|
+
import { log } from '@luma.gl/core';
|
|
3
|
+
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
4
|
+
export class GroupNode extends ScenegraphNode {
|
|
5
|
+
constructor() {
|
|
6
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
props = Array.isArray(props) ? {
|
|
8
|
+
children: props
|
|
9
|
+
} : props;
|
|
10
|
+
const {
|
|
11
|
+
children = []
|
|
12
|
+
} = props;
|
|
13
|
+
log.assert(children.every(child => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
|
|
14
|
+
super(props);
|
|
15
|
+
this.children = void 0;
|
|
16
|
+
this.children = children;
|
|
17
|
+
}
|
|
18
|
+
getBounds() {
|
|
19
|
+
const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
|
|
20
|
+
this.traverse((node, _ref) => {
|
|
21
|
+
let {
|
|
22
|
+
worldMatrix
|
|
23
|
+
} = _ref;
|
|
24
|
+
const bounds = node.getBounds();
|
|
25
|
+
if (!bounds) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const [min, max] = bounds;
|
|
29
|
+
const center = new Vector3(min).add(max).divide([2, 2, 2]);
|
|
30
|
+
worldMatrix.transformAsPoint(center, center);
|
|
31
|
+
const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
32
|
+
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
33
|
+
for (let v = 0; v < 8; v++) {
|
|
34
|
+
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1).multiply(halfSize).add(center);
|
|
35
|
+
for (let i = 0; i < 3; i++) {
|
|
36
|
+
result[0][i] = Math.min(result[0][i], position[i]);
|
|
37
|
+
result[1][i] = Math.max(result[1][i], position[i]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!Number.isFinite(result[0][0])) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.children.forEach(child => child.destroy());
|
|
48
|
+
this.removeAll();
|
|
49
|
+
super.destroy();
|
|
50
|
+
}
|
|
51
|
+
add() {
|
|
52
|
+
for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
children[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
for (const child of children) {
|
|
56
|
+
if (Array.isArray(child)) {
|
|
57
|
+
this.add(...child);
|
|
58
|
+
} else {
|
|
59
|
+
this.children.push(child);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
remove(child) {
|
|
65
|
+
const children = this.children;
|
|
66
|
+
const indexOf = children.indexOf(child);
|
|
67
|
+
if (indexOf > -1) {
|
|
68
|
+
children.splice(indexOf, 1);
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
removeAll() {
|
|
73
|
+
this.children = [];
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
traverse(visitor) {
|
|
77
|
+
let {
|
|
78
|
+
worldMatrix = new Matrix4()
|
|
79
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
80
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
81
|
+
for (const child of this.children) {
|
|
82
|
+
if (child instanceof GroupNode) {
|
|
83
|
+
child.traverse(visitor, {
|
|
84
|
+
worldMatrix: modelMatrix
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
visitor(child, {
|
|
88
|
+
worldMatrix: modelMatrix
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=group-node.js.map
|
|
@@ -0,0 +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","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,EAAEC,GAAG,CAAC,GAAGF,MAA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