@luma.gl/engine 9.0.0-alpha.33 → 9.0.0-alpha.35
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 +93 -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 +83 -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.35",
|
|
4
4
|
"description": "WebGL2 Components for High Performance Rendering and Computation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
44
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
45
|
-
"@luma.gl/shadertools": "9.0.0-alpha.
|
|
46
|
-
"@luma.gl/webgl": "9.0.0-alpha.
|
|
43
|
+
"@luma.gl/constants": "9.0.0-alpha.35",
|
|
44
|
+
"@luma.gl/core": "9.0.0-alpha.35",
|
|
45
|
+
"@luma.gl/shadertools": "9.0.0-alpha.35",
|
|
46
|
+
"@luma.gl/webgl": "9.0.0-alpha.35",
|
|
47
47
|
"@math.gl/core": "4.0.0-alpha.4",
|
|
48
48
|
"@probe.gl/log": "^4.0.2",
|
|
49
49
|
"@probe.gl/stats": "^4.0.2"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5b93557731aaf1b9fd0fc1d84b5a3c7c0717298a"
|
|
52
52
|
}
|
|
@@ -17,14 +17,7 @@ export type GPUGeometryProps = {
|
|
|
17
17
|
vertexCount: number;
|
|
18
18
|
bufferLayout: BufferLayout[];
|
|
19
19
|
indices?: Buffer | null;
|
|
20
|
-
attributes:
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type GPUGeometryAttributes = {
|
|
24
|
-
positions: Buffer;
|
|
25
|
-
normals?: Buffer;
|
|
26
|
-
texCoords?: Buffer;
|
|
27
|
-
colors?: Buffer;
|
|
20
|
+
attributes: Record<string, Buffer>;
|
|
28
21
|
};
|
|
29
22
|
|
|
30
23
|
export class GPUGeometry {
|
|
@@ -37,12 +30,7 @@ export class GPUGeometry {
|
|
|
37
30
|
|
|
38
31
|
readonly vertexCount: number;
|
|
39
32
|
readonly indices?: Buffer | null;
|
|
40
|
-
readonly attributes:
|
|
41
|
-
positions: Buffer;
|
|
42
|
-
normals?: Buffer;
|
|
43
|
-
texCoords?: Buffer;
|
|
44
|
-
colors?: Buffer;
|
|
45
|
-
};
|
|
33
|
+
readonly attributes: Record<string, Buffer>;
|
|
46
34
|
|
|
47
35
|
constructor(props: GPUGeometryProps) {
|
|
48
36
|
this.id = props.id || uid('geometry');
|
|
@@ -50,23 +38,9 @@ export class GPUGeometry {
|
|
|
50
38
|
this.indices = props.indices || null;
|
|
51
39
|
this.attributes = props.attributes;
|
|
52
40
|
|
|
53
|
-
//
|
|
54
41
|
this.vertexCount = props.vertexCount;
|
|
55
42
|
|
|
56
|
-
// Populate default bufferLayout
|
|
57
43
|
this.bufferLayout = props.bufferLayout || [];
|
|
58
|
-
if (!this.bufferLayout.find(layout => layout.name === 'positions')) {
|
|
59
|
-
this.bufferLayout.push({name: 'positions', format: 'float32x3'});
|
|
60
|
-
}
|
|
61
|
-
if (this.attributes.normals && !this.bufferLayout.find(layout => layout.name === 'normals')) {
|
|
62
|
-
this.bufferLayout.push({name: 'normals', format: 'float32x3'});
|
|
63
|
-
}
|
|
64
|
-
if (this.attributes.texCoords && !this.bufferLayout.find(layout => layout.name === 'texCoords')) {
|
|
65
|
-
this.bufferLayout.push({name: 'texCoords', format: 'float32x2'});
|
|
66
|
-
}
|
|
67
|
-
if (this.attributes.colors && !this.bufferLayout.find(layout => layout.name === 'colors')) {
|
|
68
|
-
this.bufferLayout.push({name: 'colors', format: 'float32x3'});
|
|
69
|
-
}
|
|
70
44
|
|
|
71
45
|
if (this.indices) {
|
|
72
46
|
assert(this.indices.usage === Buffer.INDEX);
|
|
@@ -85,7 +59,7 @@ export class GPUGeometry {
|
|
|
85
59
|
return this.vertexCount;
|
|
86
60
|
}
|
|
87
61
|
|
|
88
|
-
getAttributes():
|
|
62
|
+
getAttributes(): Record<string, Buffer> {
|
|
89
63
|
return this.attributes;
|
|
90
64
|
}
|
|
91
65
|
|
|
@@ -120,36 +94,28 @@ export function getIndexBufferFromGeometry(device: Device, geometry: Geometry):
|
|
|
120
94
|
if (!geometry.indices) {
|
|
121
95
|
return undefined;
|
|
122
96
|
}
|
|
123
|
-
|
|
124
97
|
const data = geometry.indices.value;
|
|
125
|
-
assert(
|
|
126
|
-
data instanceof Uint16Array || data instanceof Uint32Array,
|
|
127
|
-
'attribute array for "indices" must be of integer type'
|
|
128
|
-
);
|
|
129
98
|
return device.createBuffer({usage: Buffer.INDEX, data});
|
|
130
99
|
}
|
|
131
100
|
|
|
132
101
|
export function getAttributeBuffersFromGeometry(
|
|
133
102
|
device: Device,
|
|
134
103
|
geometry: Geometry
|
|
135
|
-
): {attributes:
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (texCoords) {
|
|
151
|
-
attributes.texCoords = device.createBuffer({data: texCoords.value, id: 'texCoords-buffer'});
|
|
152
|
-
bufferLayout.push({name: 'texCoords', format: `float32x${texCoords.size as 2 | 3 | 4}`});
|
|
104
|
+
): {attributes: Record<string, Buffer>, bufferLayout: BufferLayout[], vertexCount: number} {
|
|
105
|
+
const bufferLayout: BufferLayout[] = [];
|
|
106
|
+
|
|
107
|
+
const attributes: Record<string, Buffer> = {};
|
|
108
|
+
for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
|
|
109
|
+
let name: string = attributeName;
|
|
110
|
+
// TODO Map some GLTF attribute names (is this still needed?)
|
|
111
|
+
switch (attributeName) {
|
|
112
|
+
case 'POSITION': name = 'positions'; break;
|
|
113
|
+
case 'NORMAL': name = 'normals'; break;
|
|
114
|
+
case 'TEXCOORD_0': name = 'texCoords'; break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
attributes[name] = device.createBuffer({data: attribute.value, id: `${attributeName}-buffer`});
|
|
118
|
+
bufferLayout.push({name, format: `float32x${attribute.size as 2 | 3 | 4}`});
|
|
153
119
|
}
|
|
154
120
|
|
|
155
121
|
const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
1
2
|
import type {RenderPipelineProps} from '@luma.gl/core';
|
|
2
3
|
import {Device, RenderPipeline} from '@luma.gl/core';
|
|
3
4
|
|
|
@@ -87,21 +88,23 @@ export class PipelineFactory {
|
|
|
87
88
|
const vsHash = this._getHash(props.vs);
|
|
88
89
|
const fsHash = props.fs ? this._getHash(props.fs) : 0;
|
|
89
90
|
|
|
90
|
-
// TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?
|
|
91
|
-
// create a deepHash() to deduplicate?
|
|
92
|
-
|
|
93
|
-
// hash parameters
|
|
94
|
-
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
95
|
-
|
|
96
|
-
// hash buffer layouts
|
|
97
|
-
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
98
|
-
|
|
99
91
|
// WebGL specific
|
|
100
92
|
// const {varyings = [], bufferMode = {}} = props;
|
|
101
93
|
// const varyingHashes = varyings.map((v) => this._getHash(v));
|
|
102
94
|
const varyingHash = '-'; // `${varyingHashes.join('/')}B${bufferMode}`
|
|
103
95
|
|
|
104
|
-
|
|
96
|
+
switch (this.device.info.type) {
|
|
97
|
+
case 'webgpu':
|
|
98
|
+
// On WebGPU we need to rebuild the pipeline if topology, parameters or bufferLayout change
|
|
99
|
+
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
100
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
101
|
+
// TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?
|
|
102
|
+
// create a deepHash() to deduplicate?
|
|
103
|
+
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
|
|
104
|
+
default:
|
|
105
|
+
// WebGL is more dynamic
|
|
106
|
+
return `${vsHash}/${fsHash}V${varyingHash}`;
|
|
107
|
+
}
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
_getHash(key: string): number {
|
package/src/model/model.ts
CHANGED
|
@@ -225,10 +225,7 @@ export class Model {
|
|
|
225
225
|
setTopology(topology: PrimitiveTopology): void {
|
|
226
226
|
if (topology !== this.topology) {
|
|
227
227
|
this.topology = topology;
|
|
228
|
-
|
|
229
|
-
if (this.device.info.type === 'webgpu') {
|
|
230
|
-
this._setPipelineNeedsUpdate('topology');
|
|
231
|
-
}
|
|
228
|
+
this._setPipelineNeedsUpdate('topology');
|
|
232
229
|
}
|
|
233
230
|
}
|
|
234
231
|
|
|
@@ -239,10 +236,7 @@ export class Model {
|
|
|
239
236
|
setBufferLayout(bufferLayout: BufferLayout[]): void {
|
|
240
237
|
if (bufferLayout !== this.bufferLayout) {
|
|
241
238
|
this.bufferLayout = bufferLayout;
|
|
242
|
-
|
|
243
|
-
if (this.device.info.type === 'webgpu') {
|
|
244
|
-
this._setPipelineNeedsUpdate('bufferLayout');
|
|
245
|
-
}
|
|
239
|
+
this._setPipelineNeedsUpdate('bufferLayout');
|
|
246
240
|
}
|
|
247
241
|
}
|
|
248
242
|
|
|
@@ -254,10 +248,7 @@ export class Model {
|
|
|
254
248
|
setParameters(parameters: RenderPipelineParameters) {
|
|
255
249
|
if (!deepEqual(parameters, this.parameters, 2)) {
|
|
256
250
|
this.parameters = parameters;
|
|
257
|
-
|
|
258
|
-
if (this.device.info.type === 'webgpu') {
|
|
259
|
-
this._setPipelineNeedsUpdate('parameters');
|
|
260
|
-
}
|
|
251
|
+
this._setPipelineNeedsUpdate('parameters');
|
|
261
252
|
}
|
|
262
253
|
}
|
|
263
254
|
|