@luma.gl/engine 9.0.0-beta.4 → 9.0.0-beta.6
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 +54 -54
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +95 -100
- package/dist/animation-loop/animation-loop-template.d.ts +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +19 -5
- package/dist/animation-loop/animation-loop.d.ts +2 -2
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +433 -356
- package/dist/animation-loop/animation-props.d.ts +2 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.d.ts +2 -2
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +28 -24
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
- package/dist/debug/copy-texture-to-image.js +41 -42
- package/dist/debug/debug-framebuffer.d.ts.map +1 -1
- package/dist/debug/debug-framebuffer.js +43 -40
- package/dist/debug/debug-shader-layout.js +24 -25
- package/dist/debug/pixel-data-utils.d.ts.map +1 -1
- package/dist/debug/pixel-data-utils.js +34 -36
- package/dist/dist.dev.js +3873 -8643
- 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 +11 -17
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +190 -61
- 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 +9 -14
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +141 -160
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +92 -110
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +76 -95
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +99 -117
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +3 -1
- package/dist/geometry/geometry-utils.js +35 -32
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +80 -71
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +80 -99
- package/dist/geometry/gpu-table.js +41 -1
- package/dist/index.cjs +241 -206
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +41 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/clip-space.d.ts +1 -1
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +23 -28
- package/dist/lib/pipeline-factory.d.ts +1 -5
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +64 -68
- package/dist/lib/shader-factory.d.ts +17 -0
- package/dist/lib/shader-factory.d.ts.map +1 -0
- package/dist/lib/shader-factory.js +44 -0
- package/dist/model/model.d.ts +22 -10
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +562 -410
- package/dist/scenegraph/group-node.d.ts +1 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +73 -83
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +31 -24
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +136 -124
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +99 -58
- package/dist/transform/buffer-transform.d.ts +1 -1
- package/dist/transform/buffer-transform.d.ts.map +1 -1
- package/dist/transform/buffer-transform.js +65 -57
- package/dist/transform/texture-transform.d.ts +1 -1
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +109 -114
- package/dist.min.js +2 -272
- package/package.json +10 -9
- package/src/animation/timeline.ts +20 -20
- package/src/animation-loop/animation-loop-template.ts +10 -8
- package/src/animation-loop/animation-loop.ts +20 -10
- package/src/animation-loop/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +17 -8
- package/src/debug/copy-texture-to-image.ts +8 -6
- package/src/debug/debug-framebuffer.ts +16 -3
- package/src/debug/debug-shader-layout.ts +1 -1
- package/src/debug/pixel-data-utils.ts +3 -6
- package/src/geometries/cube-geometry.ts +17 -13
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometries/plane-geometry.ts +1 -1
- package/src/geometries/sphere-geometry.ts +1 -1
- package/src/geometries/truncated-cone-geometry.ts +2 -1
- package/src/geometry/geometry-table.ts +9 -6
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +9 -6
- package/src/geometry/gpu-geometry.ts +14 -6
- package/src/index.ts +1 -0
- package/src/lib/clip-space.ts +14 -18
- package/src/lib/pipeline-factory.ts +12 -22
- package/src/lib/shader-factory.ts +55 -0
- package/src/model/model.ts +74 -42
- package/src/scenegraph/group-node.ts +14 -10
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +2 -2
- package/src/shader-inputs.ts +19 -12
- package/src/transform/buffer-transform.ts +16 -8
- package/src/transform/texture-transform.ts +14 -15
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop-template.js.map +0 -1
- package/dist/animation-loop/animation-loop.js.map +0 -1
- package/dist/animation-loop/animation-props.js.map +0 -1
- package/dist/animation-loop/make-animation-loop.js.map +0 -1
- package/dist/debug/copy-texture-to-image.js.map +0 -1
- package/dist/debug/debug-framebuffer.js.map +0 -1
- package/dist/debug/debug-shader-layout.js.map +0 -1
- package/dist/debug/pixel-data-utils.js.map +0 -1
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/geometry/geometry-table.js.map +0 -1
- package/dist/geometry/geometry-utils.js.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/geometry/gpu-geometry.js.map +0 -1
- package/dist/geometry/gpu-table.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
- package/dist/model/model.js.map +0 -1
- package/dist/scenegraph/group-node.js.map +0 -1
- package/dist/scenegraph/model-node.js.map +0 -1
- package/dist/scenegraph/scenegraph-node.js.map +0 -1
- package/dist/shader-inputs.js.map +0 -1
- package/dist/transform/buffer-transform.js.map +0 -1
- package/dist/transform/texture-transform.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Matrix4 } from '@math.gl/core';
|
|
2
|
-
import { ScenegraphNode, ScenegraphNodeProps } from
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
|
|
3
3
|
export type GroupNodeProps = ScenegraphNodeProps & {
|
|
4
4
|
children?: ScenegraphNode[];
|
|
5
5
|
};
|
|
@@ -1 +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,
|
|
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,6BAA0B;AAEtE,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAC;AAEF,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;IAmCxC,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,CACN,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,EACxE,EAAC,WAA2B,EAAC;;KAAK;CAYrC"}
|
|
@@ -2,93 +2,83 @@ import { Matrix4, Vector3 } from '@math.gl/core';
|
|
|
2
2
|
import { log } from '@luma.gl/core';
|
|
3
3
|
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
4
4
|
export class GroupNode extends ScenegraphNode {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
children;
|
|
6
|
+
constructor(props = {}) {
|
|
7
|
+
props = Array.isArray(props) ? { children: props } : props;
|
|
8
|
+
const { children = [] } = props;
|
|
9
|
+
log.assert(children.every(child => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
|
|
10
|
+
super(props);
|
|
11
|
+
this.children = children;
|
|
12
|
+
}
|
|
13
|
+
getBounds() {
|
|
14
|
+
const result = [
|
|
15
|
+
[Infinity, Infinity, Infinity],
|
|
16
|
+
[-Infinity, -Infinity, -Infinity]
|
|
17
|
+
];
|
|
18
|
+
this.traverse((node, { worldMatrix }) => {
|
|
19
|
+
const bounds = node.getBounds();
|
|
20
|
+
if (!bounds) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const [min, max] = bounds;
|
|
24
|
+
const center = new Vector3(min).add(max).divide([2, 2, 2]);
|
|
25
|
+
worldMatrix.transformAsPoint(center, center);
|
|
26
|
+
const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
27
|
+
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
28
|
+
for (let v = 0; v < 8; v++) {
|
|
29
|
+
// Test all 8 corners of the box
|
|
30
|
+
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1)
|
|
31
|
+
.multiply(halfSize)
|
|
32
|
+
.add(center);
|
|
33
|
+
for (let i = 0; i < 3; i++) {
|
|
34
|
+
result[0][i] = Math.min(result[0][i], position[i]);
|
|
35
|
+
result[1][i] = Math.max(result[1][i], position[i]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (!Number.isFinite(result[0][0])) {
|
|
40
|
+
return null;
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
if (!Number.isFinite(result[0][0])) {
|
|
42
|
-
return null;
|
|
42
|
+
return result;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
destroy() {
|
|
45
|
+
this.children.forEach(child => child.destroy());
|
|
46
|
+
this.removeAll();
|
|
47
|
+
super.destroy();
|
|
48
|
+
}
|
|
49
|
+
// Unpacks arrays and nested arrays of children
|
|
50
|
+
add(...children) {
|
|
51
|
+
for (const child of children) {
|
|
52
|
+
if (Array.isArray(child)) {
|
|
53
|
+
this.add(...child);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.children.push(child);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
remove(child) {
|
|
62
|
+
const children = this.children;
|
|
63
|
+
const indexOf = children.indexOf(child);
|
|
64
|
+
if (indexOf > -1) {
|
|
65
|
+
children.splice(indexOf, 1);
|
|
66
|
+
}
|
|
67
|
+
return this;
|
|
61
68
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const children = this.children;
|
|
66
|
-
const indexOf = children.indexOf(child);
|
|
67
|
-
if (indexOf > -1) {
|
|
68
|
-
children.splice(indexOf, 1);
|
|
69
|
+
removeAll() {
|
|
70
|
+
this.children = [];
|
|
71
|
+
return this;
|
|
69
72
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
}
|
|
73
|
+
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
74
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
75
|
+
for (const child of this.children) {
|
|
76
|
+
if (child instanceof GroupNode) {
|
|
77
|
+
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
visitor(child, { worldMatrix: modelMatrix });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
91
83
|
}
|
|
92
|
-
}
|
|
93
84
|
}
|
|
94
|
-
//# sourceMappingURL=group-node.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderPass } from '@luma.gl/core';
|
|
2
|
-
import { ScenegraphNode, ScenegraphNodeProps } from
|
|
3
|
-
import { Model } from
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
|
|
3
|
+
import { Model } from "../model/model.js";
|
|
4
4
|
export type ModelNodeProps = ScenegraphNodeProps & {
|
|
5
5
|
model: Model;
|
|
6
6
|
managedResources?: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,
|
|
1
|
+
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,6BAA0B;AACtE,OAAO,EAAC,KAAK,EAAC,0BAAuB;AAErC,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/B,CAAC;AAEF,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAQ;IAC3C,gBAAgB,EAAE,GAAG,EAAE,CAAC;gBAOZ,KAAK,EAAE,cAAc;IAUxB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAIxC,OAAO,IAAI,IAAI;IAWxB,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU;CAI7B"}
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
2
2
|
export class ModelNode extends ScenegraphNode {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
model;
|
|
4
|
+
bounds = null;
|
|
5
|
+
managedResources;
|
|
6
|
+
// TODO - is this used? override callbacks to make sure we call them with this
|
|
7
|
+
// onBeforeRender = null;
|
|
8
|
+
// onAfterRender = null;
|
|
9
|
+
// AfterRender = null;
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
// Create new Model or used supplied Model
|
|
13
|
+
this.model = props.model;
|
|
14
|
+
this.managedResources = props.managedResources || [];
|
|
15
|
+
this.bounds = props.bounds || null;
|
|
16
|
+
this.setProps(props);
|
|
17
|
+
}
|
|
18
|
+
getBounds() {
|
|
19
|
+
return this.bounds;
|
|
20
|
+
}
|
|
21
|
+
destroy() {
|
|
22
|
+
if (this.model) {
|
|
23
|
+
this.model.destroy();
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
this.model = null;
|
|
26
|
+
}
|
|
27
|
+
this.managedResources.forEach(resource => resource.destroy());
|
|
28
|
+
this.managedResources = [];
|
|
29
|
+
}
|
|
30
|
+
// Expose model methods
|
|
31
|
+
draw(renderPass) {
|
|
32
|
+
// Return value indicates if something was actually drawn
|
|
33
|
+
return this.model.draw(renderPass);
|
|
20
34
|
}
|
|
21
|
-
this.managedResources.forEach(resource => resource.destroy());
|
|
22
|
-
this.managedResources = [];
|
|
23
|
-
}
|
|
24
|
-
draw(renderPass) {
|
|
25
|
-
return this.model.draw(renderPass);
|
|
26
|
-
}
|
|
27
35
|
}
|
|
28
|
-
//# sourceMappingURL=model-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenegraph-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAA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QAAQ,EAAE,GAAG,GAAG,IAAI;IAMhC,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAMhC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAM1B,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,GAAE,OAAc,GAAG,IAAI;IAQxD,mBAAmB,CAAC,UAAU,EAAE;QAC9B,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,IAAI;IAiBR,YAAY,IAAI,IAAI;IAYpB,MAAM,CAAC,OAAO,GAAE;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAM,GAAG,IAAI;IAezE,qBAAqB,CACnB,UAAU,EAAE,GAAG,EACf,WAAW,CAAC,EAAE,GAAG,GAChB;QACD,UAAU,EAAE,GAAG,CAAC;QAChB,WAAW,EAAE,GAAG,CAAC;QACjB,YAAY,EAAE,GAAG,CAAC;QAClB,WAAW,EAAE,GAAG,CAAC;QACjB,kBAAkB,EAAE,GAAG,CAAC;QACxB,2BAA2B,EAAE,GAAG,CAAC;KAClC;IA0CD,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAsB1D"}
|
|
@@ -1,141 +1,153 @@
|
|
|
1
1
|
import { assert, uid } from '@luma.gl/core';
|
|
2
2
|
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
3
|
export class ScenegraphNode {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = props;
|
|
17
|
-
this.id = id || uid(this.constructor.name);
|
|
18
|
-
this._setScenegraphNodeProps(props);
|
|
19
|
-
}
|
|
20
|
-
getBounds() {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
destroy() {}
|
|
24
|
-
delete() {
|
|
25
|
-
this.destroy();
|
|
26
|
-
}
|
|
27
|
-
setProps(props) {
|
|
28
|
-
this._setScenegraphNodeProps(props);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
toString() {
|
|
32
|
-
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
33
|
-
}
|
|
34
|
-
setPosition(position) {
|
|
35
|
-
assert(position.length === 3, 'setPosition requires vector argument');
|
|
36
|
-
this.position = position;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
setRotation(rotation) {
|
|
40
|
-
assert(rotation.length === 3, 'setRotation requires vector argument');
|
|
41
|
-
this.rotation = rotation;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
setScale(scale) {
|
|
45
|
-
assert(scale.length === 3, 'setScale requires vector argument');
|
|
46
|
-
this.scale = scale;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
setMatrix(matrix) {
|
|
50
|
-
let copyMatrix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
51
|
-
if (copyMatrix) {
|
|
52
|
-
this.matrix.copy(matrix);
|
|
53
|
-
} else {
|
|
54
|
-
this.matrix = matrix;
|
|
4
|
+
id;
|
|
5
|
+
matrix = new Matrix4();
|
|
6
|
+
display = true;
|
|
7
|
+
position = new Vector3();
|
|
8
|
+
rotation = new Vector3();
|
|
9
|
+
scale = new Vector3(1, 1, 1);
|
|
10
|
+
userData = {};
|
|
11
|
+
props = {};
|
|
12
|
+
constructor(props = {}) {
|
|
13
|
+
const { id } = props;
|
|
14
|
+
this.id = id || uid(this.constructor.name);
|
|
15
|
+
this._setScenegraphNodeProps(props);
|
|
55
16
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
position,
|
|
60
|
-
rotation,
|
|
61
|
-
scale,
|
|
62
|
-
update = true
|
|
63
|
-
} = components;
|
|
64
|
-
if (position) {
|
|
65
|
-
this.setPosition(position);
|
|
17
|
+
getBounds() {
|
|
18
|
+
return null;
|
|
66
19
|
}
|
|
67
|
-
|
|
68
|
-
|
|
20
|
+
destroy() { }
|
|
21
|
+
/** @deprecated use .destroy() */
|
|
22
|
+
delete() {
|
|
23
|
+
this.destroy();
|
|
69
24
|
}
|
|
70
|
-
|
|
71
|
-
|
|
25
|
+
setProps(props) {
|
|
26
|
+
this._setScenegraphNodeProps(props);
|
|
27
|
+
return this;
|
|
72
28
|
}
|
|
73
|
-
|
|
74
|
-
|
|
29
|
+
toString() {
|
|
30
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
75
31
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const rot = this.rotation;
|
|
81
|
-
const scale = this.scale;
|
|
82
|
-
this.matrix.identity();
|
|
83
|
-
this.matrix.translate(pos);
|
|
84
|
-
this.matrix.rotateXYZ(rot);
|
|
85
|
-
this.matrix.scale(scale);
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
update() {
|
|
89
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
90
|
-
const {
|
|
91
|
-
position,
|
|
92
|
-
rotation,
|
|
93
|
-
scale
|
|
94
|
-
} = options;
|
|
95
|
-
if (position) {
|
|
96
|
-
this.setPosition(position);
|
|
32
|
+
setPosition(position) {
|
|
33
|
+
assert(position.length === 3, 'setPosition requires vector argument');
|
|
34
|
+
this.position = position;
|
|
35
|
+
return this;
|
|
97
36
|
}
|
|
98
|
-
|
|
99
|
-
|
|
37
|
+
setRotation(rotation) {
|
|
38
|
+
assert(rotation.length === 3, 'setRotation requires vector argument');
|
|
39
|
+
this.rotation = rotation;
|
|
40
|
+
return this;
|
|
100
41
|
}
|
|
101
|
-
|
|
102
|
-
|
|
42
|
+
setScale(scale) {
|
|
43
|
+
assert(scale.length === 3, 'setScale requires vector argument');
|
|
44
|
+
this.scale = scale;
|
|
45
|
+
return this;
|
|
103
46
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const worldInverse = worldMatrix.invert();
|
|
112
|
-
const worldInverseTranspose = worldInverse.transpose();
|
|
113
|
-
return {
|
|
114
|
-
viewMatrix,
|
|
115
|
-
modelMatrix,
|
|
116
|
-
objectMatrix: modelMatrix,
|
|
117
|
-
worldMatrix,
|
|
118
|
-
worldInverseMatrix: worldInverse,
|
|
119
|
-
worldInverseTransposeMatrix: worldInverseTranspose
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
_setScenegraphNodeProps(props) {
|
|
123
|
-
if ('display' in props) {
|
|
124
|
-
this.display = props.display;
|
|
47
|
+
setMatrix(matrix, copyMatrix = true) {
|
|
48
|
+
if (copyMatrix) {
|
|
49
|
+
this.matrix.copy(matrix);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.matrix = matrix;
|
|
53
|
+
}
|
|
125
54
|
}
|
|
126
|
-
|
|
127
|
-
|
|
55
|
+
setMatrixComponents(components) {
|
|
56
|
+
const { position, rotation, scale, update = true } = components;
|
|
57
|
+
if (position) {
|
|
58
|
+
this.setPosition(position);
|
|
59
|
+
}
|
|
60
|
+
if (rotation) {
|
|
61
|
+
this.setRotation(rotation);
|
|
62
|
+
}
|
|
63
|
+
if (scale) {
|
|
64
|
+
this.setScale(scale);
|
|
65
|
+
}
|
|
66
|
+
if (update) {
|
|
67
|
+
this.updateMatrix();
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
128
70
|
}
|
|
129
|
-
|
|
130
|
-
|
|
71
|
+
updateMatrix() {
|
|
72
|
+
const pos = this.position;
|
|
73
|
+
const rot = this.rotation;
|
|
74
|
+
const scale = this.scale;
|
|
75
|
+
this.matrix.identity();
|
|
76
|
+
this.matrix.translate(pos);
|
|
77
|
+
this.matrix.rotateXYZ(rot);
|
|
78
|
+
this.matrix.scale(scale);
|
|
79
|
+
return this;
|
|
131
80
|
}
|
|
132
|
-
|
|
133
|
-
|
|
81
|
+
update(options = {}) {
|
|
82
|
+
const { position, rotation, scale } = options;
|
|
83
|
+
if (position) {
|
|
84
|
+
this.setPosition(position);
|
|
85
|
+
}
|
|
86
|
+
if (rotation) {
|
|
87
|
+
this.setRotation(rotation);
|
|
88
|
+
}
|
|
89
|
+
if (scale) {
|
|
90
|
+
this.setScale(scale);
|
|
91
|
+
}
|
|
92
|
+
this.updateMatrix();
|
|
93
|
+
return this;
|
|
134
94
|
}
|
|
135
|
-
|
|
136
|
-
|
|
95
|
+
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
96
|
+
// TODO - solve multiple class problem
|
|
97
|
+
// assert(viewMatrix instanceof Matrix4);
|
|
98
|
+
assert(viewMatrix);
|
|
99
|
+
modelMatrix = modelMatrix || this.matrix;
|
|
100
|
+
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
101
|
+
const worldInverse = worldMatrix.invert();
|
|
102
|
+
const worldInverseTranspose = worldInverse.transpose();
|
|
103
|
+
return {
|
|
104
|
+
viewMatrix,
|
|
105
|
+
modelMatrix,
|
|
106
|
+
objectMatrix: modelMatrix,
|
|
107
|
+
worldMatrix,
|
|
108
|
+
worldInverseMatrix: worldInverse,
|
|
109
|
+
worldInverseTransposeMatrix: worldInverseTranspose
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// TODO - copied code, not yet vetted
|
|
113
|
+
/*
|
|
114
|
+
transform() {
|
|
115
|
+
if (!this.parent) {
|
|
116
|
+
this.endPosition.set(this.position);
|
|
117
|
+
this.endRotation.set(this.rotation);
|
|
118
|
+
this.endScale.set(this.scale);
|
|
119
|
+
} else {
|
|
120
|
+
const parent = this.parent;
|
|
121
|
+
this.endPosition.set(this.position.add(parent.endPosition));
|
|
122
|
+
this.endRotation.set(this.rotation.add(parent.endRotation));
|
|
123
|
+
this.endScale.set(this.scale.add(parent.endScale));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const ch = this.children;
|
|
127
|
+
for (let i = 0; i < ch.length; ++i) {
|
|
128
|
+
ch[i].transform();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
*/
|
|
134
|
+
_setScenegraphNodeProps(props) {
|
|
135
|
+
if ('display' in props) {
|
|
136
|
+
this.display = props.display;
|
|
137
|
+
}
|
|
138
|
+
if ('position' in props) {
|
|
139
|
+
this.setPosition(props.position);
|
|
140
|
+
}
|
|
141
|
+
if ('rotation' in props) {
|
|
142
|
+
this.setRotation(props.rotation);
|
|
143
|
+
}
|
|
144
|
+
if ('scale' in props) {
|
|
145
|
+
this.setScale(props.scale);
|
|
146
|
+
}
|
|
147
|
+
// Matrix overwrites other props
|
|
148
|
+
if ('matrix' in props) {
|
|
149
|
+
this.setMatrix(props.matrix);
|
|
150
|
+
}
|
|
151
|
+
Object.assign(this.props, props);
|
|
137
152
|
}
|
|
138
|
-
Object.assign(this.props, props);
|
|
139
|
-
}
|
|
140
153
|
}
|
|
141
|
-
//# sourceMappingURL=scenegraph-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-inputs.d.ts","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader-inputs.d.ts","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAkB,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE3E,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,CAC5B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,O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