@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
package/dist/shader-inputs.js
CHANGED
|
@@ -1,66 +1,107 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { log } from '@luma.gl/core';
|
|
5
|
+
// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';
|
|
2
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
|
+
*/
|
|
3
14
|
export class ShaderInputs {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
18
45
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
}
|
|
37
71
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Object.assign(bindings, moduleBindings);
|
|
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);
|
|
49
82
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
for (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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;
|
|
62
106
|
}
|
|
63
|
-
return table;
|
|
64
|
-
}
|
|
65
107
|
}
|
|
66
|
-
//# sourceMappingURL=shader-inputs.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Device, Buffer, BufferRange, TransformFeedback, RenderPassProps } from '@luma.gl/core';
|
|
2
|
-
import { Model } from
|
|
2
|
+
import { Model } from "../model/model.js";
|
|
3
3
|
import type { ModelProps } from '..';
|
|
4
4
|
/**
|
|
5
5
|
* Properties for creating a {@link BufferTransform}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-transform.d.ts","sourceRoot":"","sources":["../../src/transform/buffer-transform.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,62 +1,70 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { Buffer, assert } from '@luma.gl/core';
|
|
2
5
|
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
3
6
|
import { Model } from "../model/model.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a pipeline for buffer→buffer transforms.
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
4
11
|
export class BufferTransform {
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
}
|
|
61
70
|
}
|
|
62
|
-
//# sourceMappingURL=buffer-transform.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture } from '@luma.gl/core';
|
|
2
|
-
import { Model, ModelProps } from
|
|
2
|
+
import { Model, ModelProps } from "../model/model.js";
|
|
3
3
|
/**
|
|
4
4
|
* Properties for creating a {@link TextureTransform}
|
|
5
5
|
* @deprecated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture-transform.d.ts","sourceRoot":"","sources":["../../src/transform/texture-transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"texture-transform.d.ts","sourceRoot":"","sources":["../../src/transform/texture-transform.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,0BAAuB;AAGjD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAC3D,EAAE,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,4CAA4C;IAC5C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAIF;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,YAAY,SAAK;IACjB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAQ;IACrD,QAAQ,EAAE,cAAc,EAAE,CAAM;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAExB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;IA8BxD,OAAO,IAAI,IAAI;IAEf,uCAAuC;IACvC,MAAM,IAAI,IAAI;IAId,GAAG,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI;IAOpC,kBAAkB;IAClB,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAO5B,OAAO,CAAC,EAAC,MAAc,EAAC;;KAAK;IAM7B,gBAAgB,IAAI,OAAO;IAK3B,cAAc,IAAI,WAAW;IAO7B,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IAI/C,eAAe,CAAC,KAAK,EAAE,qBAAqB;IAI5C,cAAc,CACZ,OAAO,EAAE,cAAc,EACvB,EAAC,aAAa,EAAE,cAAc,EAAE,aAAa,EAAC,EAAE,qBAAqB,GACpE,cAAc;IA6BjB,2BAA2B,IAAI,IAAI;CAOpC"}
|
|
@@ -1,122 +1,117 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { Model } from "../model/model.js";
|
|
2
5
|
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
3
6
|
const FS_OUTPUT_VARIABLE = 'transform_output';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a pipeline for texture→texture transforms.
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
4
11
|
export class TextureTransform {
|
|
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
|
-
destroy() {}
|
|
36
|
-
delete() {
|
|
37
|
-
this.destroy();
|
|
38
|
-
}
|
|
39
|
-
run(options) {
|
|
40
|
-
const {
|
|
41
|
-
framebuffer
|
|
42
|
-
} = this.bindings[this.currentIndex];
|
|
43
|
-
const renderPass = this.device.beginRenderPass({
|
|
44
|
-
framebuffer,
|
|
45
|
-
...options
|
|
46
|
-
});
|
|
47
|
-
this.model.draw(renderPass);
|
|
48
|
-
renderPass.end();
|
|
49
|
-
}
|
|
50
|
-
update() {
|
|
51
|
-
console.warn('TextureTransform#update() not implemented');
|
|
52
|
-
}
|
|
53
|
-
getData() {
|
|
54
|
-
let {
|
|
55
|
-
packed = false
|
|
56
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
57
|
-
throw new Error('getData() not implemented');
|
|
58
|
-
}
|
|
59
|
-
getTargetTexture() {
|
|
60
|
-
const {
|
|
61
|
-
targetTexture
|
|
62
|
-
} = this.bindings[this.currentIndex];
|
|
63
|
-
return targetTexture;
|
|
64
|
-
}
|
|
65
|
-
getFramebuffer() {
|
|
66
|
-
const currentResources = this.bindings[this.currentIndex];
|
|
67
|
-
return currentResources.framebuffer;
|
|
68
|
-
}
|
|
69
|
-
_initialize(props) {
|
|
70
|
-
this._updateBindings(props);
|
|
71
|
-
}
|
|
72
|
-
_updateBindings(props) {
|
|
73
|
-
this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], props);
|
|
74
|
-
}
|
|
75
|
-
_updateBinding(binding, _ref) {
|
|
76
|
-
let {
|
|
77
|
-
sourceBuffers,
|
|
78
|
-
sourceTextures,
|
|
79
|
-
targetTexture
|
|
80
|
-
} = _ref;
|
|
81
|
-
if (!binding) {
|
|
82
|
-
binding = {
|
|
83
|
-
sourceBuffers: {},
|
|
84
|
-
sourceTextures: {},
|
|
85
|
-
targetTexture: null
|
|
86
|
-
};
|
|
12
|
+
device;
|
|
13
|
+
model;
|
|
14
|
+
sampler;
|
|
15
|
+
currentIndex = 0;
|
|
16
|
+
samplerTextureMap = null;
|
|
17
|
+
bindings = []; // each element is an object : {sourceTextures, targetTexture, framebuffer}
|
|
18
|
+
resources = {}; // resources to be deleted
|
|
19
|
+
constructor(device, props) {
|
|
20
|
+
this.device = device;
|
|
21
|
+
// For precise picking of element IDs.
|
|
22
|
+
this.sampler = device.createSampler({
|
|
23
|
+
addressModeU: 'clamp-to-edge',
|
|
24
|
+
addressModeV: 'clamp-to-edge',
|
|
25
|
+
minFilter: 'nearest',
|
|
26
|
+
magFilter: 'nearest',
|
|
27
|
+
mipmapFilter: 'nearest'
|
|
28
|
+
});
|
|
29
|
+
this.model = new Model(this.device, {
|
|
30
|
+
id: props.id || 'texture-transform-model',
|
|
31
|
+
fs: props.fs ||
|
|
32
|
+
getPassthroughFS({
|
|
33
|
+
input: props.targetTextureVarying,
|
|
34
|
+
inputChannels: props.targetTextureChannels,
|
|
35
|
+
output: FS_OUTPUT_VARIABLE
|
|
36
|
+
}),
|
|
37
|
+
vertexCount: props.vertexCount, // TODO(donmccurdy): Naming?
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
this._initialize(props);
|
|
41
|
+
Object.seal(this);
|
|
87
42
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
width,
|
|
94
|
-
height
|
|
95
|
-
} = targetTexture;
|
|
96
|
-
if (binding.framebuffer) {
|
|
97
|
-
binding.framebuffer.destroy();
|
|
98
|
-
}
|
|
99
|
-
binding.framebuffer = this.device.createFramebuffer({
|
|
100
|
-
id: 'transform-framebuffer',
|
|
101
|
-
width,
|
|
102
|
-
height,
|
|
103
|
-
colorAttachments: [targetTexture]
|
|
104
|
-
});
|
|
105
|
-
binding.framebuffer.resize({
|
|
106
|
-
width,
|
|
107
|
-
height
|
|
108
|
-
});
|
|
43
|
+
// Delete owned resources.
|
|
44
|
+
destroy() { }
|
|
45
|
+
/** @deprecated Use {@link destroy}. */
|
|
46
|
+
delete() {
|
|
47
|
+
this.destroy();
|
|
109
48
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
49
|
+
run(options) {
|
|
50
|
+
const { framebuffer } = this.bindings[this.currentIndex];
|
|
51
|
+
const renderPass = this.device.beginRenderPass({ framebuffer, ...options });
|
|
52
|
+
this.model.draw(renderPass);
|
|
53
|
+
renderPass.end();
|
|
54
|
+
}
|
|
55
|
+
/** @deprecated */
|
|
56
|
+
update(...args) {
|
|
57
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
58
|
+
// to assist with migrating DeckGL usage.
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.warn('TextureTransform#update() not implemented');
|
|
61
|
+
}
|
|
62
|
+
getData({ packed = false } = {}) {
|
|
63
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
64
|
+
// to assist with migrating DeckGL usage.
|
|
65
|
+
throw new Error('getData() not implemented');
|
|
66
|
+
}
|
|
67
|
+
getTargetTexture() {
|
|
68
|
+
const { targetTexture } = this.bindings[this.currentIndex];
|
|
69
|
+
return targetTexture;
|
|
70
|
+
}
|
|
71
|
+
getFramebuffer() {
|
|
72
|
+
const currentResources = this.bindings[this.currentIndex];
|
|
73
|
+
return currentResources.framebuffer;
|
|
74
|
+
}
|
|
75
|
+
// Private
|
|
76
|
+
_initialize(props) {
|
|
77
|
+
this._updateBindings(props);
|
|
78
|
+
}
|
|
79
|
+
_updateBindings(props) {
|
|
80
|
+
this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], props);
|
|
81
|
+
}
|
|
82
|
+
_updateBinding(binding, { sourceBuffers, sourceTextures, targetTexture }) {
|
|
83
|
+
if (!binding) {
|
|
84
|
+
binding = {
|
|
85
|
+
sourceBuffers: {},
|
|
86
|
+
sourceTextures: {},
|
|
87
|
+
targetTexture: null
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
Object.assign(binding.sourceTextures, sourceTextures);
|
|
91
|
+
Object.assign(binding.sourceBuffers, sourceBuffers);
|
|
92
|
+
if (targetTexture) {
|
|
93
|
+
binding.targetTexture = targetTexture;
|
|
94
|
+
const { width, height } = targetTexture;
|
|
95
|
+
// TODO(donmccurdy): When is this called, and is this expected?
|
|
96
|
+
if (binding.framebuffer) {
|
|
97
|
+
binding.framebuffer.destroy();
|
|
98
|
+
}
|
|
99
|
+
binding.framebuffer = this.device.createFramebuffer({
|
|
100
|
+
id: 'transform-framebuffer',
|
|
101
|
+
width,
|
|
102
|
+
height,
|
|
103
|
+
colorAttachments: [targetTexture]
|
|
104
|
+
});
|
|
105
|
+
binding.framebuffer.resize({ width, height });
|
|
106
|
+
}
|
|
107
|
+
return binding;
|
|
108
|
+
}
|
|
109
|
+
// set texture filtering parameters on source textures.
|
|
110
|
+
_setSourceTextureParameters() {
|
|
111
|
+
const index = this.currentIndex;
|
|
112
|
+
const { sourceTextures } = this.bindings[index];
|
|
113
|
+
for (const name in sourceTextures) {
|
|
114
|
+
sourceTextures[name].sampler = this.sampler;
|
|
115
|
+
}
|
|
119
116
|
}
|
|
120
|
-
}
|
|
121
117
|
}
|
|
122
|
-
//# sourceMappingURL=texture-transform.js.map
|