@luma.gl/engine 9.0.0-alpha.48 → 9.0.0-alpha.50
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-loop/animation-loop.js +1 -1
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/dist.dev.js +161 -54
- package/dist/index.cjs +125 -65
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js.map +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +8 -7
- package/dist/shader-inputs.js.map +1 -1
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/{transform.js → buffer-transform.js} +13 -41
- package/dist/transform/buffer-transform.js.map +1 -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 +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +67 -67
- package/package.json +5 -5
- package/src/animation-loop/animation-loop.ts +1 -1
- package/src/index.ts +5 -1
- package/src/model/model.ts +2 -0
- package/src/shader-inputs.ts +6 -5
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/transform/transform.d.ts +0 -65
- package/dist/transform/transform.d.ts.map +0 -1
- package/dist/transform/transform.js.map +0 -1
- package/src/transform/transform.ts +0 -261
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.50",
|
|
4
4
|
"description": "WebGL2 Components for High Performance Rendering and Computation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
44
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
45
|
-
"@luma.gl/shadertools": "9.0.0-alpha.
|
|
43
|
+
"@luma.gl/constants": "9.0.0-alpha.50",
|
|
44
|
+
"@luma.gl/core": "9.0.0-alpha.50",
|
|
45
|
+
"@luma.gl/shadertools": "9.0.0-alpha.50",
|
|
46
46
|
"@math.gl/core": "^4.0.0",
|
|
47
47
|
"@probe.gl/log": "^4.0.2",
|
|
48
48
|
"@probe.gl/stats": "^4.0.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "83899806fcfab67f97cc8b308f81e4844a05ca05"
|
|
51
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,11 @@ export {makeAnimationLoop} from './animation-loop/make-animation-loop';
|
|
|
16
16
|
export type {ModelProps} from './model/model';
|
|
17
17
|
export {Model} from './model/model';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Transforms
|
|
20
|
+
export type {BufferTransformProps} from './transform/buffer-transform';
|
|
21
|
+
export {BufferTransform} from './transform/buffer-transform';
|
|
22
|
+
export type {TextureTransformProps} from './transform/texture-transform';
|
|
23
|
+
export {TextureTransform} from './transform/texture-transform';
|
|
20
24
|
|
|
21
25
|
export {PipelineFactory} from './lib/pipeline-factory';
|
|
22
26
|
|
package/src/model/model.ts
CHANGED
|
@@ -223,6 +223,7 @@ export class Model {
|
|
|
223
223
|
this.setUniforms(props.uniforms);
|
|
224
224
|
}
|
|
225
225
|
if (props.moduleSettings) {
|
|
226
|
+
// eslint-disable-next-line no-console
|
|
226
227
|
console.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()');
|
|
227
228
|
this.updateModuleSettings(props.moduleSettings);
|
|
228
229
|
}
|
|
@@ -386,6 +387,7 @@ export class Model {
|
|
|
386
387
|
* @deprecated Updates shader module settings (which results in uniforms being set)
|
|
387
388
|
*/
|
|
388
389
|
updateModuleSettings(props: Record<string, any>): void {
|
|
390
|
+
// eslint-disable-next-line no-console
|
|
389
391
|
console.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()');
|
|
390
392
|
const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));
|
|
391
393
|
Object.assign(this.bindings, bindings);
|
package/src/shader-inputs.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class ShaderInputs<
|
|
|
72
72
|
const moduleName = name as keyof ShaderPropsT;
|
|
73
73
|
|
|
74
74
|
// Get default uniforms from module
|
|
75
|
-
this.moduleUniforms[moduleName] = module.
|
|
75
|
+
this.moduleUniforms[moduleName] = module.defaultUniforms || {};
|
|
76
76
|
this.moduleBindings[moduleName] = {};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -89,12 +89,13 @@ export class ShaderInputs<
|
|
|
89
89
|
const moduleProps = props[moduleName];
|
|
90
90
|
const module = this.modules[moduleName];
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
93
|
+
const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps as any;
|
|
94
|
+
// console.error(uniforms)
|
|
95
|
+
this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};
|
|
95
96
|
// this.moduleUniformsChanged ||= moduleName;
|
|
96
97
|
|
|
97
|
-
console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])
|
|
98
|
+
// console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])
|
|
98
99
|
|
|
99
100
|
// TODO - Get Module bindings
|
|
100
101
|
// const bindings = module.getBindings?.(moduleProps);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {Device, Buffer, BufferRange, TransformFeedback, assert, RenderPassProps} from '@luma.gl/core';
|
|
5
|
+
import {getPassthroughFS} from '@luma.gl/shadertools';
|
|
6
|
+
import {Model} from '../model/model';
|
|
7
|
+
import type { ModelProps } from '..';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Properties for creating a {@link BufferTransform}
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
export type BufferTransformProps = Omit<ModelProps, 'fs'> & {
|
|
14
|
+
fs?: ModelProps['fs']; // override as optional
|
|
15
|
+
feedbackBuffers?: Record<string, Buffer | BufferRange>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a pipeline for buffer→buffer transforms.
|
|
20
|
+
* @deprecated
|
|
21
|
+
*/
|
|
22
|
+
export class BufferTransform {
|
|
23
|
+
readonly device: Device;
|
|
24
|
+
readonly model: Model;
|
|
25
|
+
readonly transformFeedback: TransformFeedback;
|
|
26
|
+
|
|
27
|
+
/** @deprecated Use device feature test. */
|
|
28
|
+
static isSupported(device: Device): boolean {
|
|
29
|
+
return device.features.has('transform-feedback-webgl2');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor(device: Device, props: BufferTransformProps = Model.defaultProps) {
|
|
33
|
+
assert(device.features.has('transform-feedback-webgl2'), 'Device must support transform feedback');
|
|
34
|
+
|
|
35
|
+
this.device = device;
|
|
36
|
+
|
|
37
|
+
this.model = new Model(this.device, {
|
|
38
|
+
id: props.id || 'buffer-transform-model',
|
|
39
|
+
fs: props.fs || getPassthroughFS({version: 300}),
|
|
40
|
+
topology: props.topology || 'point-list',
|
|
41
|
+
...props,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.transformFeedback = this.device.createTransformFeedback({
|
|
45
|
+
layout: this.model.pipeline.shaderLayout,
|
|
46
|
+
buffers: props.feedbackBuffers,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.model.setTransformFeedback(this.transformFeedback);
|
|
50
|
+
|
|
51
|
+
Object.seal(this);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Destroy owned resources. */
|
|
55
|
+
destroy(): void {
|
|
56
|
+
if (this.model) {
|
|
57
|
+
this.model.destroy();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @deprecated Use {@link destroy}. */
|
|
62
|
+
delete(): void {
|
|
63
|
+
this.destroy();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Run one transform loop. */
|
|
67
|
+
run(options?: RenderPassProps): void {
|
|
68
|
+
const renderPass = this.device.beginRenderPass(options);
|
|
69
|
+
this.model.draw(renderPass);
|
|
70
|
+
renderPass.end();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @deprecated */
|
|
74
|
+
update(...args: any[]): void {
|
|
75
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
76
|
+
// to assist with migrating DeckGL usage.
|
|
77
|
+
// eslint-disable-next-line no-console
|
|
78
|
+
console.warn('TextureTransform#update() not implemented');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
82
|
+
getBuffer(varyingName: string): Buffer | BufferRange | null {
|
|
83
|
+
return this.transformFeedback.getBuffer(varyingName);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
readAsync(varyingName: string): Promise<Uint8Array> {
|
|
87
|
+
const result = this.getBuffer(varyingName);
|
|
88
|
+
if (result instanceof Buffer) {
|
|
89
|
+
return result.readAsync();
|
|
90
|
+
}
|
|
91
|
+
const {buffer, byteOffset = 0, byteLength = buffer.byteLength} = result;
|
|
92
|
+
return buffer.readAsync(byteOffset, byteLength);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import { Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture } from '@luma.gl/core';
|
|
5
|
+
import { Model, ModelProps } from '../model/model';
|
|
6
|
+
import { getPassthroughFS } from '@luma.gl/shadertools';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Properties for creating a {@link TextureTransform}
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export type TextureTransformProps = Omit<ModelProps, 'fs'> & {
|
|
13
|
+
fs?: ModelProps['fs']; // override as optional
|
|
14
|
+
/** @deprecated TODO(donmccurdy): Needed? */
|
|
15
|
+
inject?: Record<string, string>;
|
|
16
|
+
/** @deprecated TODO(donmccurdy): Needed? */
|
|
17
|
+
framebuffer?: Framebuffer;
|
|
18
|
+
/** @deprecated TODO(donmccurdy): Model already handles this? */
|
|
19
|
+
sourceBuffers?: Record<string, Buffer>;
|
|
20
|
+
/** @deprecated TODO(donmccurdy): Model already handles this? */
|
|
21
|
+
sourceTextures?: Record<string, Texture>;
|
|
22
|
+
targetTexture: Texture;
|
|
23
|
+
targetTextureChannels: 1 | 2 | 3 | 4;
|
|
24
|
+
targetTextureVarying: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
type TextureBinding = {
|
|
29
|
+
sourceBuffers: Record<string, Buffer>;
|
|
30
|
+
sourceTextures: Record<string, Texture>;
|
|
31
|
+
targetTexture: Texture;
|
|
32
|
+
framebuffer?: Framebuffer;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const FS_OUTPUT_VARIABLE = 'transform_output';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a pipeline for texture→texture transforms.
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
41
|
+
export class TextureTransform {
|
|
42
|
+
readonly device: Device;
|
|
43
|
+
readonly model: Model;
|
|
44
|
+
readonly sampler: Sampler;
|
|
45
|
+
|
|
46
|
+
currentIndex = 0;
|
|
47
|
+
samplerTextureMap: Record<string, any> | null = null;
|
|
48
|
+
bindings: TextureBinding[] = []; // each element is an object : {sourceTextures, targetTexture, framebuffer}
|
|
49
|
+
resources: Record<string, any> = {}; // resources to be deleted
|
|
50
|
+
|
|
51
|
+
constructor(device: Device, props: TextureTransformProps) {
|
|
52
|
+
this.device = device;
|
|
53
|
+
|
|
54
|
+
// For precise picking of element IDs.
|
|
55
|
+
this.sampler = device.createSampler({
|
|
56
|
+
addressModeU: 'clamp-to-edge',
|
|
57
|
+
addressModeV: 'clamp-to-edge',
|
|
58
|
+
minFilter: 'nearest',
|
|
59
|
+
magFilter: 'nearest',
|
|
60
|
+
mipmapFilter: 'nearest',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.model = new Model(this.device, {
|
|
64
|
+
id: props.id || 'texture-transform-model',
|
|
65
|
+
fs: props.fs || getPassthroughFS({
|
|
66
|
+
version: 300,
|
|
67
|
+
input: props.targetTextureVarying,
|
|
68
|
+
inputChannels: props.targetTextureChannels,
|
|
69
|
+
output: FS_OUTPUT_VARIABLE
|
|
70
|
+
}),
|
|
71
|
+
vertexCount: props.vertexCount, // TODO(donmccurdy): Naming?
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
this._initialize(props);
|
|
76
|
+
Object.seal(this);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Delete owned resources.
|
|
80
|
+
destroy(): void {}
|
|
81
|
+
|
|
82
|
+
/** @deprecated Use {@link destroy}. */
|
|
83
|
+
delete(): void {
|
|
84
|
+
this.destroy();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
run(options?: RenderPassProps): void {
|
|
88
|
+
const {framebuffer} = this.bindings[this.currentIndex];
|
|
89
|
+
const renderPass = this.device.beginRenderPass({framebuffer, ...options});
|
|
90
|
+
this.model.draw(renderPass);
|
|
91
|
+
renderPass.end();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @deprecated */
|
|
95
|
+
update(...args: any[]): void {
|
|
96
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
97
|
+
// to assist with migrating DeckGL usage.
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.warn('TextureTransform#update() not implemented');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
getData({packed = false} = {}) {
|
|
104
|
+
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
105
|
+
// to assist with migrating DeckGL usage.
|
|
106
|
+
throw new Error('getData() not implemented');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getTargetTexture(): Texture {
|
|
110
|
+
const {targetTexture} = this.bindings[this.currentIndex];
|
|
111
|
+
return targetTexture;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
getFramebuffer(): Framebuffer {
|
|
116
|
+
const currentResources = this.bindings[this.currentIndex];
|
|
117
|
+
return currentResources.framebuffer;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Private
|
|
121
|
+
|
|
122
|
+
_initialize(props: TextureTransformProps): void {
|
|
123
|
+
this._updateBindings(props);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_updateBindings(props: TextureTransformProps) {
|
|
127
|
+
this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], props);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_updateBinding(
|
|
131
|
+
binding: TextureBinding,
|
|
132
|
+
{sourceBuffers, sourceTextures, targetTexture}: TextureTransformProps
|
|
133
|
+
): TextureBinding {
|
|
134
|
+
if (!binding) {
|
|
135
|
+
binding = {
|
|
136
|
+
sourceBuffers: {},
|
|
137
|
+
sourceTextures: {},
|
|
138
|
+
targetTexture: null
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
Object.assign(binding.sourceTextures, sourceTextures);
|
|
142
|
+
Object.assign(binding.sourceBuffers, sourceBuffers);
|
|
143
|
+
if (targetTexture) {
|
|
144
|
+
binding.targetTexture = targetTexture;
|
|
145
|
+
const {width, height} = targetTexture;
|
|
146
|
+
// TODO(donmccurdy): When is this called, and is this expected?
|
|
147
|
+
if (binding.framebuffer) {
|
|
148
|
+
binding.framebuffer.destroy();
|
|
149
|
+
}
|
|
150
|
+
binding.framebuffer = this.device.createFramebuffer({
|
|
151
|
+
id: 'transform-framebuffer',
|
|
152
|
+
width,
|
|
153
|
+
height,
|
|
154
|
+
colorAttachments: [targetTexture]
|
|
155
|
+
});
|
|
156
|
+
binding.framebuffer.resize({width, height});
|
|
157
|
+
}
|
|
158
|
+
return binding;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// set texture filtering parameters on source textures.
|
|
162
|
+
_setSourceTextureParameters(): void {
|
|
163
|
+
const index = this.currentIndex;
|
|
164
|
+
const {sourceTextures} = this.bindings[index];
|
|
165
|
+
for (const name in sourceTextures) {
|
|
166
|
+
sourceTextures[name].sampler = this.sampler;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Device, Buffer, BufferRange, Framebuffer, TransformFeedback, PrimitiveTopology, RenderPassParameters, BufferLayout } from '@luma.gl/core';
|
|
2
|
-
import { ShaderModule } from '@luma.gl/shadertools';
|
|
3
|
-
import { Model } from '../model/model';
|
|
4
|
-
/** Properties for creating Transforms */
|
|
5
|
-
export type TransformProps = {
|
|
6
|
-
id?: string;
|
|
7
|
-
vs?: string;
|
|
8
|
-
fs?: string;
|
|
9
|
-
vertexCount?: number;
|
|
10
|
-
sourceBuffers?: Record<string, Buffer>;
|
|
11
|
-
feedbackBuffers?: Record<string, Buffer | BufferRange>;
|
|
12
|
-
varyings?: string[];
|
|
13
|
-
feedbackMap?: Record<string, string>;
|
|
14
|
-
modules?: ShaderModule[];
|
|
15
|
-
attributes?: Record<string, any>;
|
|
16
|
-
bufferLayout?: BufferLayout[];
|
|
17
|
-
uniforms?: Record<string, any>;
|
|
18
|
-
defines?: Record<string, any>;
|
|
19
|
-
discard?: boolean;
|
|
20
|
-
topology?: PrimitiveTopology;
|
|
21
|
-
};
|
|
22
|
-
/** Options that can be provided when running a Transform */
|
|
23
|
-
export type TransformRunOptions = {
|
|
24
|
-
framebuffer?: Framebuffer;
|
|
25
|
-
/** @deprecated Use uniform buffers for portability. */
|
|
26
|
-
uniforms?: Record<string, any>;
|
|
27
|
-
parameters?: RenderPassParameters;
|
|
28
|
-
discard?: boolean;
|
|
29
|
-
};
|
|
30
|
-
/** Options that control drawing a Transform. Used by subclasses to return draw parameters */
|
|
31
|
-
/**
|
|
32
|
-
* Takes source and target buffers/textures and sets up the pipeline
|
|
33
|
-
*/
|
|
34
|
-
export declare class Transform {
|
|
35
|
-
readonly device: Device;
|
|
36
|
-
readonly model: Model;
|
|
37
|
-
readonly transformFeedback: TransformFeedback;
|
|
38
|
-
/** @deprecated Use device feature test. */
|
|
39
|
-
static isSupported(device: Device): boolean;
|
|
40
|
-
elementIDBuffer: Buffer | null;
|
|
41
|
-
constructor(device: Device, props?: TransformProps);
|
|
42
|
-
/** Destroy owned resources. */
|
|
43
|
-
destroy(): void;
|
|
44
|
-
/** Run one transform loop. */
|
|
45
|
-
run(options?: TransformRunOptions): void;
|
|
46
|
-
/** swap resources if a map is provided */
|
|
47
|
-
swap(): void;
|
|
48
|
-
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
49
|
-
getBuffer(varyingName: string): Buffer | BufferRange | null;
|
|
50
|
-
readAsync(varyingName: string): Promise<Uint8Array>;
|
|
51
|
-
/**
|
|
52
|
-
* Return data either from Buffer or from Texture.
|
|
53
|
-
* @deprecated Prefer {@link readAsync}.
|
|
54
|
-
*/
|
|
55
|
-
getData(options?: {
|
|
56
|
-
packed?: boolean;
|
|
57
|
-
varyingName?: string;
|
|
58
|
-
}): void;
|
|
59
|
-
/** Return framebuffer object if rendering to textures */
|
|
60
|
-
getFramebuffer(): Framebuffer | null;
|
|
61
|
-
/** Update some or all buffer/texture bindings. */
|
|
62
|
-
update(props: TransformProps): void;
|
|
63
|
-
_updateModelProps(props: TransformProps): TransformProps;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/transform/transform.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAU,iBAAiB,EAAE,oBAAoB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACzJ,OAAO,EAAkC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAKrC,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE7B,OAAO,CA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AI;IAanC,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc;CA+BzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","names":["Buffer","assert","getShaderInfo","getPassthroughFS","Model","Transform","isSupported","device","features","has","constructor","props","arguments","length","undefined","model","transformFeedback","elementIDBuffer","vs","fs","version","id","varyings","attributes","bufferLayout","topology","vertexCount","defines","modules","createTransformFeedback","layout","pipeline","shaderLayout","buffers","feedbackBuffers","setTransformFeedback","Object","seal","destroy","run","options","framebuffer","parameters","discard","uniforms","renderPass","beginRenderPass","setUniforms","draw","end","swap","Error","getBuffer","varyingName","readAsync","result","buffer","byteOffset","byteLength","getData","getFramebuffer","update","_updateModelProps"],"sources":["../../src/transform/transform.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Device, Buffer, BufferRange, Framebuffer, TransformFeedback, assert, PrimitiveTopology, RenderPassParameters, BufferLayout} from '@luma.gl/core';\nimport {getShaderInfo, getPassthroughFS, ShaderModule} from '@luma.gl/shadertools';\nimport {Model} from '../model/model';\n\n// import BufferTransform from './buffer-transform';\n// import TextureTransform from './texture-transform';\n\n/** Properties for creating Transforms */\nexport type TransformProps = {\n id?: string;\n vs?: string;\n fs?: string;\n vertexCount?: number;\n sourceBuffers?: Record<string, Buffer>;\n feedbackBuffers?: Record<string, Buffer | BufferRange>;\n varyings?: string[];\n feedbackMap?: Record<string, string>;\n modules?: ShaderModule[];\n attributes?: Record<string, any>;\n bufferLayout?: BufferLayout[];\n uniforms?: Record<string, any>;\n defines?: Record<string, any>\n // parameters?: GLParameters;\n discard?: boolean;\n // isIndexed?: boolean;\n // inject?: Record<string, string>;\n topology?: PrimitiveTopology;\n // framebuffer?: Framebuffer;\n // _sourceTextures?: Record<string, Texture>;\n // _targetTexture?: string | Texture;\n // _targetTextureVarying?: string;\n // _swapTexture?: string | null;\n // _fs?: string;\n};\n\n/** Options that can be provided when running a Transform */\nexport type TransformRunOptions = {\n framebuffer?: Framebuffer;\n // clearRenderTarget?: boolean;\n /** @deprecated Use uniform buffers for portability. */\n uniforms?: Record<string, any>;\n parameters?: RenderPassParameters;\n discard?: boolean;\n};\n\n/** Options that control drawing a Transform. Used by subclasses to return draw parameters */\n// export type TransformDrawOptions = {\n// attributes?: Record<string, any>;\n// framebuffer?: any;\n// uniforms?: object;\n// discard?: boolean;\n// parameters?: object;\n// transformFeedback?: TransformFeedback;\n// };\n\n// export type TransformBinding = {\n// sourceBuffers: Record<string, Buffer>;\n// sourceTextures: Record<string, Texture>;\n// feedbackBuffers?: Record<string, Buffer | BufferRange>;\n// transformFeedback?: TransformFeedback;\n// framebuffer?: Framebuffer;\n// targetTexture?: Texture;\n// };\n\n/**\n * Takes source and target buffers/textures and sets up the pipeline\n */\nexport class Transform {\n readonly device: Device;\n readonly model: Model;\n readonly transformFeedback: TransformFeedback;\n\n /** @deprecated Use device feature test. */\n static isSupported(device: Device): boolean {\n return device.features.has('transform-feedback-webgl2');\n }\n\n // bufferTransform: BufferTransform | null = null;\n // textureTransform: TextureTransform | null = null;\n elementIDBuffer: Buffer | null = null;\n\n constructor(device: Device, props: TransformProps = {}) {\n assert(device.features.has('transform-feedback-webgl2'), 'Device must support transform feedback');\n\n this.device = device;\n\n // this._buildResourceTransforms(props);\n\n // props = this._updateModelProps(props);\n\n this.model = new Model(this.device, {\n vs: props.vs,\n fs: props.fs || getPassthroughFS({version: getShaderInfo(props.vs).version}),\n id: props.id || 'transform-model',\n varyings: props.varyings,\n attributes: props.attributes,\n bufferLayout: props.bufferLayout,\n topology: props.topology || 'point-list',\n vertexCount: props.vertexCount,\n defines: props.defines,\n modules: props.modules,\n });\n\n this.transformFeedback = this.device.createTransformFeedback({\n layout: this.model.pipeline.shaderLayout,\n buffers: props.feedbackBuffers,\n });\n\n this.model.setTransformFeedback(this.transformFeedback);\n\n // if (this.bufferTransform) {\n // this.bufferTransform.setupResources({model: this.model});\n // }\n\n Object.seal(this);\n }\n\n /** Destroy owned resources. */\n destroy(): void {\n if (this.model) {\n this.model.destroy();\n }\n // if (this.bufferTransform) {\n // this.bufferTransform.destroy();\n // }\n // if (this.textureTransform) {\n // this.textureTransform.destroy();\n // }\n }\n\n /** Run one transform loop. */\n run(options?: TransformRunOptions): void {\n const {framebuffer, parameters, discard, uniforms} = options || {};\n // const {clearRenderTarget = true} = options || {};\n\n // const updatedOpts = this._updateDrawOptions(options);\n\n // if (clearRenderTarget && updatedOpts.framebuffer) {\n // clear(this.device, {framebuffer: updatedOpts.framebuffer, color: true});\n // }\n\n const renderPass = this.device.beginRenderPass({framebuffer, parameters, discard});\n if (uniforms) this.model.setUniforms(uniforms);\n this.model.draw(renderPass);\n renderPass.end();\n }\n\n /** swap resources if a map is provided */\n swap(): void {\n // let swapped = false;\n // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean);\n // for (const resourceTransform of resourceTransforms) {\n // swapped = swapped || Boolean(resourceTransform?.swap());\n // }\n // assert(swapped, 'Nothing to swap');\n throw new Error('Not implemented');\n }\n\n /** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */\n getBuffer(varyingName: string): Buffer | BufferRange | null {\n return this.transformFeedback.getBuffer(varyingName);\n }\n\n readAsync(varyingName: string): Promise<Uint8Array> {\n const result = this.getBuffer(varyingName);\n if (result instanceof Buffer) {\n return result.readAsync();\n }\n const {buffer, byteOffset = 0, byteLength = buffer.byteLength} = result;\n return buffer.readAsync(byteOffset, byteLength);\n }\n\n /**\n * Return data either from Buffer or from Texture.\n * @deprecated Prefer {@link readAsync}.\n */\n getData(options: {packed?: boolean; varyingName?: string} = {}) {\n // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean);\n // for (const resourceTransform of resourceTransforms) {\n // const data = resourceTransform?.getData(options);\n // if (data) {\n // return data;\n // }\n // }\n // return null;\n throw new Error('Not implemented');\n }\n\n /** Return framebuffer object if rendering to textures */\n getFramebuffer(): Framebuffer | null {\n // return this.textureTransform?.getFramebuffer() || null;\n throw new Error('Not implemented');\n }\n\n /** Update some or all buffer/texture bindings. */\n update(props: TransformProps): void {\n // if (props.elementCount !== undefined) {\n // this.model.setVertexCount(props.elementCount);\n // }\n // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean);\n // for (const resourceTransform of resourceTransforms) {\n // resourceTransform?.update(props);\n // }\n throw new Error('Not implemented');\n }\n\n // Private\n\n _updateModelProps(props: TransformProps): TransformProps {\n // const updatedProps: TransformProps = {...props};\n // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean) ;\n // for (const resourceTransform of resourceTransforms) {\n // updatedProps = resourceTransform.updateModelProps(updatedProps);\n // }\n // return updatedProps;\n throw new Error('Not implemented');\n }\n\n // _buildResourceTransforms(props: TransformProps) {\n // if (canCreateBufferTransform(props)) {\n // this.bufferTransform = new BufferTransform(this.device, props);\n // }\n // if (canCreateTextureTransform(props)) {\n // this.textureTransform = new TextureTransform(this.device, props);\n // }\n // assert(\n // this.bufferTransform || this.textureTransform,\n // 'must provide source/feedback buffers or source/target textures'\n // );\n // }\n\n // _updateDrawOptions(options: TransformRunOptions): TransformDrawOptions {\n // const updatedOpts = {...options};\n // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean) ;\n // for (const resourceTransform of resourceTransforms) {\n // updatedOpts = Object.assign(updatedOpts, resourceTransform.getDrawOptions(updatedOpts));\n // }\n // return updatedOpts;\n // }\n}\n\n// Helper Methods\n\n// function canCreateBufferTransform(props: TransformProps): boolean {\n// const canCreate =\n// (props.feedbackBuffers && !isObjectEmpty(props.feedbackBuffers)) ||\n// (props.feedbackMap && !isObjectEmpty(props.feedbackMap)) ||\n// (props.varyings && props.varyings.length > 0);\n// return Boolean(canCreate);\n// }\n\n// function canCreateTextureTransform(props: TransformProps): boolean {\n// const canCreate =\n// (props._sourceTextures && !isObjectEmpty(props._sourceTextures)) ||\n// props._targetTexture ||\n// props._targetTextureVarying;\n// return Boolean(canCreate);\n// }\n"],"mappings":"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