@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.10
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 +51 -72
- package/dist/animation/timeline.d.ts +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +95 -131
- package/dist/animation-loop/animation-loop-template.d.ts +23 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop-template.js +21 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +31 -23
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop.js +442 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +4 -5
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js +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 +32 -0
- package/dist/computation.d.ts +95 -0
- package/dist/computation.d.ts.map +1 -0
- package/dist/computation.js +248 -0
- package/dist/debug/copy-texture-to-image.d.ts +26 -0
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
- package/dist/debug/copy-texture-to-image.js +43 -0
- package/dist/debug/debug-framebuffer.d.ts +11 -0
- package/dist/debug/debug-framebuffer.d.ts.map +1 -0
- package/dist/debug/debug-framebuffer.js +46 -0
- package/dist/debug/debug-shader-layout.d.ts +9 -0
- package/dist/debug/debug-shader-layout.d.ts.map +1 -0
- package/dist/debug/debug-shader-layout.js +27 -0
- package/dist/debug/pixel-data-utils.d.ts +24 -0
- package/dist/debug/pixel-data-utils.d.ts.map +1 -0
- package/dist/debug/pixel-data-utils.js +39 -0
- package/dist/dist.dev.js +9592 -0
- package/dist/dist.min.js +102 -0
- package/dist/geometries/cone-geometry.d.ts +2 -2
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +13 -18
- 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 +192 -57
- package/dist/geometries/cylinder-geometry.d.ts +2 -2
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +11 -15
- 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 +143 -171
- 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 +95 -122
- 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 +78 -101
- 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 +100 -134
- 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 +3 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +35 -41
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +82 -139
- 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 +90 -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 +42 -0
- package/dist/index.cjs +3444 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +43 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -15
- 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 +43 -2
- package/dist/lib/pipeline-factory.d.ts +17 -51
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +84 -209
- 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 +46 -0
- package/dist/model/model.d.ts +219 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +659 -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 +84 -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 +35 -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 +153 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +107 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +70 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +117 -0
- package/dist.min.js +25 -0
- package/package.json +24 -14
- package/src/animation/timeline.ts +35 -34
- package/src/animation-loop/animation-loop-template.ts +25 -0
- package/src/{lib → animation-loop}/animation-loop.ts +114 -93
- package/src/{lib → animation-loop}/animation-props.ts +2 -2
- package/src/animation-loop/make-animation-loop.ts +53 -0
- package/src/computation.ts +346 -0
- package/src/debug/copy-texture-to-image.ts +70 -0
- package/src/debug/debug-framebuffer.ts +70 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +54 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +62 -56
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +6 -5
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +6 -14
- package/src/geometry/geometry-table.ts +10 -7
- package/src/geometry/geometry-utils.ts +19 -3
- package/src/geometry/geometry.ts +68 -110
- package/src/geometry/gpu-geometry.ts +132 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +37 -10
- package/src/lib/clip-space.ts +32 -34
- package/src/lib/pipeline-factory.ts +83 -193
- package/src/lib/shader-factory.ts +57 -0
- package/src/model/model.ts +835 -0
- package/src/scenegraph/group-node.ts +107 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +157 -0
- package/src/transform/buffer-transform.ts +102 -0
- package/src/transform/texture-transform.ts +168 -0
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- 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/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/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/index.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js +0 -480
- 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 +0 -2
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/clip-space.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 -182
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/pipeline-factory.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 -183
- package/src/lib/render-loop.ts +0 -58
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
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;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
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;
|
|
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;
|
|
68
|
+
}
|
|
69
|
+
removeAll() {
|
|
70
|
+
this.children = [];
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
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
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
|
|
3
|
+
import { Model } from "../model/model.js";
|
|
4
|
+
export type ModelNodeProps = ScenegraphNodeProps & {
|
|
5
|
+
model: Model;
|
|
6
|
+
managedResources?: any[];
|
|
7
|
+
bounds?: [number[], number[]];
|
|
8
|
+
};
|
|
9
|
+
export declare class ModelNode extends ScenegraphNode {
|
|
10
|
+
readonly model: Model;
|
|
11
|
+
bounds: [number[], number[]] | null;
|
|
12
|
+
managedResources: any[];
|
|
13
|
+
constructor(props: ModelNodeProps);
|
|
14
|
+
getBounds(): [number[], number[]] | null;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
draw(renderPass?: RenderPass): boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=model-node.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
2
|
+
export class ModelNode extends ScenegraphNode {
|
|
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);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NumberArray } from '@luma.gl/core';
|
|
2
|
+
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
|
+
/** Properties for creating a new Scenegraph */
|
|
4
|
+
export type ScenegraphNodeProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
/** whether to display the object at all */
|
|
7
|
+
display?: boolean;
|
|
8
|
+
matrix?: NumberArray;
|
|
9
|
+
position?: NumberArray;
|
|
10
|
+
rotation?: NumberArray;
|
|
11
|
+
scale?: NumberArray;
|
|
12
|
+
update?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class ScenegraphNode {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
matrix: Matrix4;
|
|
17
|
+
display: boolean;
|
|
18
|
+
position: Vector3;
|
|
19
|
+
rotation: Vector3;
|
|
20
|
+
scale: Vector3;
|
|
21
|
+
userData: Record<string, unknown>;
|
|
22
|
+
props: ScenegraphNodeProps;
|
|
23
|
+
constructor(props?: ScenegraphNodeProps);
|
|
24
|
+
getBounds(): [number[], number[]] | null;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
/** @deprecated use .destroy() */
|
|
27
|
+
delete(): void;
|
|
28
|
+
setProps(props: ScenegraphNodeProps): this;
|
|
29
|
+
toString(): string;
|
|
30
|
+
setPosition(position: any): this;
|
|
31
|
+
setRotation(rotation: any): this;
|
|
32
|
+
setScale(scale: any): this;
|
|
33
|
+
setMatrix(matrix: any, copyMatrix?: boolean): void;
|
|
34
|
+
setMatrixComponents(components: {
|
|
35
|
+
position?: any;
|
|
36
|
+
rotation?: any;
|
|
37
|
+
scale?: any;
|
|
38
|
+
update?: boolean;
|
|
39
|
+
}): this;
|
|
40
|
+
updateMatrix(): this;
|
|
41
|
+
update(options?: {
|
|
42
|
+
position?: any;
|
|
43
|
+
rotation?: any;
|
|
44
|
+
scale?: any;
|
|
45
|
+
}): this;
|
|
46
|
+
getCoordinateUniforms(viewMatrix: any, modelMatrix?: any): {
|
|
47
|
+
viewMatrix: any;
|
|
48
|
+
modelMatrix: any;
|
|
49
|
+
objectMatrix: any;
|
|
50
|
+
worldMatrix: any;
|
|
51
|
+
worldInverseMatrix: any;
|
|
52
|
+
worldInverseTransposeMatrix: any;
|
|
53
|
+
};
|
|
54
|
+
_setScenegraphNodeProps(props: ScenegraphNodeProps): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=scenegraph-node.d.ts.map
|
|
@@ -0,0 +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,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,qBAAa,cAAc;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAiB;IAEhC,OAAO,UAAQ;IACf,QAAQ,UAAiB;IACzB,QAAQ,UAAiB;IACzB,KAAK,UAAwB;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAEvC,KAAK,EAAE,mBAAmB,CAAM;gBAEpB,KAAK,GAAE,mBAAwB;IAQ3C,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAIxC,OAAO,IAAI,IAAI;IAEf,iCAAiC;IACjC,MAAM,IAAI,IAAI;IAGd,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAK1C,QAAQ,IAAI,MAAM;IAIlB,WAAW,CAAC,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"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { assert, uid } from '@luma.gl/core';
|
|
2
|
+
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
|
+
export class ScenegraphNode {
|
|
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);
|
|
16
|
+
}
|
|
17
|
+
getBounds() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
destroy() { }
|
|
21
|
+
/** @deprecated use .destroy() */
|
|
22
|
+
delete() {
|
|
23
|
+
this.destroy();
|
|
24
|
+
}
|
|
25
|
+
setProps(props) {
|
|
26
|
+
this._setScenegraphNodeProps(props);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
toString() {
|
|
30
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
31
|
+
}
|
|
32
|
+
setPosition(position) {
|
|
33
|
+
assert(position.length === 3, 'setPosition requires vector argument');
|
|
34
|
+
this.position = position;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
setRotation(rotation) {
|
|
38
|
+
assert(rotation.length === 3, 'setRotation requires vector argument');
|
|
39
|
+
this.rotation = rotation;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
setScale(scale) {
|
|
43
|
+
assert(scale.length === 3, 'setScale requires vector argument');
|
|
44
|
+
this.scale = scale;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
setMatrix(matrix, copyMatrix = true) {
|
|
48
|
+
if (copyMatrix) {
|
|
49
|
+
this.matrix.copy(matrix);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.matrix = matrix;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
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;
|
|
70
|
+
}
|
|
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;
|
|
80
|
+
}
|
|
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;
|
|
94
|
+
}
|
|
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);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { UniformValue, Texture, Sampler } from '@luma.gl/core';
|
|
2
|
+
import { ShaderModuleInstance } from '@luma.gl/shadertools';
|
|
3
|
+
/** Minimal ShaderModule subset, we don't need shader code etc */
|
|
4
|
+
export type ShaderModuleInputs<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string, Texture | Sampler> = Record<string, Texture | Sampler>> = {
|
|
5
|
+
defaultUniforms?: UniformsT;
|
|
6
|
+
getUniforms?: (settings: Partial<PropsT>, prevUniforms?: UniformsT) => UniformsT;
|
|
7
|
+
/** Not used. Used to access props type */
|
|
8
|
+
props?: PropsT;
|
|
9
|
+
bindings?: Record<keyof BindingsT, {
|
|
10
|
+
location: number;
|
|
11
|
+
type: 'texture' | 'sampler' | 'uniforms';
|
|
12
|
+
}>;
|
|
13
|
+
uniformTypes?: any;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* ShaderInputs holds uniform and binding values for one or more shader modules,
|
|
17
|
+
* - It can generate binary data for any uniform buffer
|
|
18
|
+
* - It can manage a uniform buffer for each block
|
|
19
|
+
* - It can update managed uniform buffers with a single call
|
|
20
|
+
* - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ShaderInputs<ShaderPropsT extends Partial<Record<string, Record<string, unknown>>> = Partial<Record<string, Record<string, unknown>>>> {
|
|
23
|
+
/**
|
|
24
|
+
* The map of modules
|
|
25
|
+
* @todo should should this include the resolved dependencies?
|
|
26
|
+
*/
|
|
27
|
+
modules: Readonly<{
|
|
28
|
+
[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>;
|
|
29
|
+
}>;
|
|
30
|
+
/** Stores the uniform values for each module */
|
|
31
|
+
moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;
|
|
32
|
+
/** Stores the uniform bindings for each module */
|
|
33
|
+
moduleBindings: Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;
|
|
34
|
+
/** Tracks if uniforms have changed */
|
|
35
|
+
moduleUniformsChanged: Record<keyof ShaderPropsT, false | string>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new UniformStore instance
|
|
38
|
+
* @param modules
|
|
39
|
+
*/
|
|
40
|
+
constructor(modules: {
|
|
41
|
+
[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>;
|
|
42
|
+
});
|
|
43
|
+
/** Destroy */
|
|
44
|
+
destroy(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Set module props
|
|
47
|
+
*/
|
|
48
|
+
setProps(props: Partial<{
|
|
49
|
+
[P in keyof ShaderPropsT]?: Partial<ShaderPropsT[P]>;
|
|
50
|
+
}>): void;
|
|
51
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
52
|
+
/**
|
|
53
|
+
* Return the map of modules
|
|
54
|
+
* @todo should should this include the resolved dependencies?
|
|
55
|
+
*/
|
|
56
|
+
getModules(): ShaderModuleInstance[];
|
|
57
|
+
/** Get all uniform values for all modules */
|
|
58
|
+
getUniformValues(): Record<keyof ShaderPropsT, Record<string, UniformValue>>;
|
|
59
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
60
|
+
getBindings(): Record<string, Texture | Sampler>;
|
|
61
|
+
getDebugTable(): Record<string, Record<string, unknown>>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=shader-inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7E,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IACrF;IACF,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,EAAE,SAAS,KAAK,SAAS,CAAC;IAEjF,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CACf,MAAM,SAAS,EACf;QACE,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;KAC1C,CACF,CAAC;IAEF,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,YAAY,CACvB,YAAY,SAAS,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAC7E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CACxC;IAED;;;OAGG;IACH,OAAO,EAAE,QAAQ,CAAC;SAAE,CAAC,IAAI,MAAM,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KAAC,CAAC,CAAC;IAEpF,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACzE,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAC9E,sCAAsC;IACtC,qBAAqB,EAAE,MAAM,CAAC,MAAM,YAAY,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;IAElE;;;OAGG;gBACS,OAAO,EAAE;SAAE,CAAC,IAAI,MAAM,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KAAC;IAwBrF,cAAc;IACd,OAAO,IAAI,IAAI;IAEf;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;SAAE,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KAAC,CAAC,GAAG,IAAI;IA0BtF,oEAAoE;IAKpE;;;OAGG;IACH,UAAU,IAAI,oBAAoB,EAAE;IAIpC,6CAA6C;IAC7C,gBAAgB,IAAI,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAI5E,oEAAoE;IACpE,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IAQhD,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAYzD"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { log } from '@luma.gl/core';
|
|
5
|
+
// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';
|
|
6
|
+
import { _resolveModules } from '@luma.gl/shadertools';
|
|
7
|
+
/**
|
|
8
|
+
* ShaderInputs holds uniform and binding values for one or more shader modules,
|
|
9
|
+
* - It can generate binary data for any uniform buffer
|
|
10
|
+
* - It can manage a uniform buffer for each block
|
|
11
|
+
* - It can update managed uniform buffers with a single call
|
|
12
|
+
* - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.
|
|
13
|
+
*/
|
|
14
|
+
export class ShaderInputs {
|
|
15
|
+
/**
|
|
16
|
+
* The map of modules
|
|
17
|
+
* @todo should should this include the resolved dependencies?
|
|
18
|
+
*/
|
|
19
|
+
modules;
|
|
20
|
+
/** Stores the uniform values for each module */
|
|
21
|
+
moduleUniforms;
|
|
22
|
+
/** Stores the uniform bindings for each module */
|
|
23
|
+
moduleBindings;
|
|
24
|
+
/** Tracks if uniforms have changed */
|
|
25
|
+
moduleUniformsChanged;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new UniformStore instance
|
|
28
|
+
* @param modules
|
|
29
|
+
*/
|
|
30
|
+
constructor(modules) {
|
|
31
|
+
// TODO - get all dependencies from modules
|
|
32
|
+
const allModules = _resolveModules(Object.values(modules));
|
|
33
|
+
log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();
|
|
34
|
+
// Store the module definitions and create storage for uniform values and binding values, per module
|
|
35
|
+
this.modules = modules;
|
|
36
|
+
this.moduleUniforms = {};
|
|
37
|
+
this.moduleBindings = {};
|
|
38
|
+
// Initialize the modules
|
|
39
|
+
for (const [name, module] of Object.entries(modules)) {
|
|
40
|
+
const moduleName = name;
|
|
41
|
+
// Get default uniforms from module
|
|
42
|
+
this.moduleUniforms[moduleName] = module.defaultUniforms || {};
|
|
43
|
+
this.moduleBindings[moduleName] = {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Destroy */
|
|
47
|
+
destroy() { }
|
|
48
|
+
/**
|
|
49
|
+
* Set module props
|
|
50
|
+
*/
|
|
51
|
+
setProps(props) {
|
|
52
|
+
for (const name of Object.keys(props)) {
|
|
53
|
+
const moduleName = name;
|
|
54
|
+
const moduleProps = props[moduleName];
|
|
55
|
+
const module = this.modules[moduleName];
|
|
56
|
+
if (!module) {
|
|
57
|
+
// Ignore props for unregistered modules
|
|
58
|
+
log.warn(`Module ${name} not found`)();
|
|
59
|
+
continue; // eslint-disable-line no-continue
|
|
60
|
+
}
|
|
61
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
62
|
+
const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps;
|
|
63
|
+
// console.error(uniforms)
|
|
64
|
+
this.moduleUniforms[moduleName] = { ...oldUniforms, ...uniforms };
|
|
65
|
+
// this.moduleUniformsChanged ||= moduleName;
|
|
66
|
+
// console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])
|
|
67
|
+
// TODO - Get Module bindings
|
|
68
|
+
// const bindings = module.getBindings?.(moduleProps);
|
|
69
|
+
// this.moduleUniforms[moduleName] = bindings;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
73
|
+
// getUniformBlocks(): Record<string, Texture | Sampler> {
|
|
74
|
+
// return this.moduleUniforms;
|
|
75
|
+
// }
|
|
76
|
+
/**
|
|
77
|
+
* Return the map of modules
|
|
78
|
+
* @todo should should this include the resolved dependencies?
|
|
79
|
+
*/
|
|
80
|
+
getModules() {
|
|
81
|
+
return Object.values(this.modules);
|
|
82
|
+
}
|
|
83
|
+
/** Get all uniform values for all modules */
|
|
84
|
+
getUniformValues() {
|
|
85
|
+
return this.moduleUniforms;
|
|
86
|
+
}
|
|
87
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
88
|
+
getBindings() {
|
|
89
|
+
const bindings = {};
|
|
90
|
+
for (const moduleBindings of Object.values(this.moduleBindings)) {
|
|
91
|
+
Object.assign(bindings, moduleBindings);
|
|
92
|
+
}
|
|
93
|
+
return bindings;
|
|
94
|
+
}
|
|
95
|
+
getDebugTable() {
|
|
96
|
+
const table = {};
|
|
97
|
+
for (const [moduleName, module] of Object.entries(this.moduleUniforms)) {
|
|
98
|
+
for (const [key, value] of Object.entries(module)) {
|
|
99
|
+
table[`${moduleName}.${key}`] = {
|
|
100
|
+
type: this.modules[moduleName].uniformTypes?.[key],
|
|
101
|
+
value: String(value)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return table;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Device, Buffer, BufferRange, TransformFeedback, RenderPassProps } from '@luma.gl/core';
|
|
2
|
+
import { Model } from "../model/model.js";
|
|
3
|
+
import type { ModelProps } from '..';
|
|
4
|
+
/**
|
|
5
|
+
* Properties for creating a {@link BufferTransform}
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
export type BufferTransformProps = Omit<ModelProps, 'fs'> & {
|
|
9
|
+
fs?: ModelProps['fs'];
|
|
10
|
+
feedbackBuffers?: Record<string, Buffer | BufferRange>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a pipeline for buffer→buffer transforms.
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
16
|
+
export declare class BufferTransform {
|
|
17
|
+
readonly device: Device;
|
|
18
|
+
readonly model: Model;
|
|
19
|
+
readonly transformFeedback: TransformFeedback;
|
|
20
|
+
/** @deprecated Use device feature test. */
|
|
21
|
+
static isSupported(device: Device): boolean;
|
|
22
|
+
constructor(device: Device, props?: BufferTransformProps);
|
|
23
|
+
/** Destroy owned resources. */
|
|
24
|
+
destroy(): void;
|
|
25
|
+
/** @deprecated Use {@link destroy}. */
|
|
26
|
+
delete(): void;
|
|
27
|
+
/** Run one transform loop. */
|
|
28
|
+
run(options?: RenderPassProps): void;
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
update(...args: any[]): void;
|
|
31
|
+
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
32
|
+
getBuffer(varyingName: string): Buffer | BufferRange | null;
|
|
33
|
+
readAsync(varyingName: string): Promise<Uint8Array>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=buffer-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-transform.d.ts","sourceRoot":"","sources":["../../src/transform/buffer-transform.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,iBAAiB,EAEjB,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,KAAK,EAAC,0BAAuB;AACrC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAC1D,EAAE,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC;CACxD,CAAC;AAEF;;;GAGG;AACH,qBAAa,eAAe;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAE9C,2CAA2C;IAC3C,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAI/B,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,oBAAyC;IAsB5E,+BAA+B;IAC/B,OAAO,IAAI,IAAI;IAMf,uCAAuC;IACvC,MAAM,IAAI,IAAI;IAId,8BAA8B;IAC9B,GAAG,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI;IAMpC,kBAAkB;IAClB,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAO5B,gFAAgF;IAChF,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI;IAI3D,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAQpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Buffer, assert } from '@luma.gl/core';
|
|
5
|
+
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
6
|
+
import { Model } from "../model/model.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a pipeline for buffer→buffer transforms.
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
11
|
+
export class BufferTransform {
|
|
12
|
+
device;
|
|
13
|
+
model;
|
|
14
|
+
transformFeedback;
|
|
15
|
+
/** @deprecated Use device feature test. */
|
|
16
|
+
static isSupported(device) {
|
|
17
|
+
return device?.info?.type === 'webgl';
|
|
18
|
+
}
|
|
19
|
+
constructor(device, props = Model.defaultProps) {
|
|
20
|
+
assert(BufferTransform.isSupported(device), 'BufferTransform not yet implemented on WebGPU');
|
|
21
|
+
this.device = device;
|
|
22
|
+
this.model = new Model(this.device, {
|
|
23
|
+
id: props.id || 'buffer-transform-model',
|
|
24
|
+
fs: props.fs || getPassthroughFS(),
|
|
25
|
+
topology: props.topology || 'point-list',
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
this.transformFeedback = this.device.createTransformFeedback({
|
|
29
|
+
layout: this.model.pipeline.shaderLayout,
|
|
30
|
+
buffers: props.feedbackBuffers
|
|
31
|
+
});
|
|
32
|
+
this.model.setTransformFeedback(this.transformFeedback);
|
|
33
|
+
Object.seal(this);
|
|
34
|
+
}
|
|
35
|
+
/** Destroy owned resources. */
|
|
36
|
+
destroy() {
|
|
37
|
+
if (this.model) {
|
|
38
|
+
this.model.destroy();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** @deprecated Use {@link destroy}. */
|
|
42
|
+
delete() {
|
|
43
|
+
this.destroy();
|
|
44
|
+
}
|
|
45
|
+
/** Run one transform loop. */
|
|
46
|
+
run(options) {
|
|
47
|
+
const renderPass = this.device.beginRenderPass(options);
|
|
48
|
+
this.model.draw(renderPass);
|
|
49
|
+
renderPass.end();
|
|
50
|
+
}
|
|
51
|
+
/** @deprecated */
|
|
52
|
+
update(...args) {
|
|
53
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
54
|
+
// to assist with migrating DeckGL usage.
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.warn('TextureTransform#update() not implemented');
|
|
57
|
+
}
|
|
58
|
+
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
59
|
+
getBuffer(varyingName) {
|
|
60
|
+
return this.transformFeedback.getBuffer(varyingName);
|
|
61
|
+
}
|
|
62
|
+
readAsync(varyingName) {
|
|
63
|
+
const result = this.getBuffer(varyingName);
|
|
64
|
+
if (result instanceof Buffer) {
|
|
65
|
+
return result.readAsync();
|
|
66
|
+
}
|
|
67
|
+
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
68
|
+
return buffer.readAsync(byteOffset, byteLength);
|
|
69
|
+
}
|
|
70
|
+
}
|