@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.
Files changed (149) hide show
  1. package/dist/animation/key-frames.js +54 -54
  2. package/dist/animation/timeline.d.ts.map +1 -1
  3. package/dist/animation/timeline.js +95 -100
  4. package/dist/animation-loop/animation-loop-template.d.ts +1 -1
  5. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
  6. package/dist/animation-loop/animation-loop-template.js +19 -5
  7. package/dist/animation-loop/animation-loop.d.ts +2 -2
  8. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  9. package/dist/animation-loop/animation-loop.js +433 -356
  10. package/dist/animation-loop/animation-props.d.ts +2 -2
  11. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  12. package/dist/animation-loop/animation-props.js +0 -1
  13. package/dist/animation-loop/make-animation-loop.d.ts +2 -2
  14. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  15. package/dist/animation-loop/make-animation-loop.js +28 -24
  16. package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
  17. package/dist/debug/copy-texture-to-image.js +41 -42
  18. package/dist/debug/debug-framebuffer.d.ts.map +1 -1
  19. package/dist/debug/debug-framebuffer.js +43 -40
  20. package/dist/debug/debug-shader-layout.js +24 -25
  21. package/dist/debug/pixel-data-utils.d.ts.map +1 -1
  22. package/dist/debug/pixel-data-utils.js +34 -36
  23. package/dist/dist.dev.js +3873 -8643
  24. package/dist/geometries/cone-geometry.d.ts +1 -1
  25. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  26. package/dist/geometries/cone-geometry.js +11 -17
  27. package/dist/geometries/cube-geometry.d.ts +1 -1
  28. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  29. package/dist/geometries/cube-geometry.js +190 -61
  30. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  31. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cylinder-geometry.js +9 -14
  33. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  34. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  35. package/dist/geometries/ico-sphere-geometry.js +141 -160
  36. package/dist/geometries/plane-geometry.d.ts +1 -1
  37. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  38. package/dist/geometries/plane-geometry.js +92 -110
  39. package/dist/geometries/sphere-geometry.d.ts +1 -1
  40. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  41. package/dist/geometries/sphere-geometry.js +76 -95
  42. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  43. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/truncated-cone-geometry.js +99 -117
  45. package/dist/geometry/geometry-table.d.ts.map +1 -1
  46. package/dist/geometry/geometry-table.js +3 -1
  47. package/dist/geometry/geometry-utils.js +35 -32
  48. package/dist/geometry/geometry.d.ts.map +1 -1
  49. package/dist/geometry/geometry.js +80 -71
  50. package/dist/geometry/gpu-geometry.d.ts +1 -1
  51. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  52. package/dist/geometry/gpu-geometry.js +80 -99
  53. package/dist/geometry/gpu-table.js +41 -1
  54. package/dist/index.cjs +241 -206
  55. package/dist/index.cjs.map +7 -0
  56. package/dist/index.d.ts +41 -40
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +5 -1
  59. package/dist/lib/clip-space.d.ts +1 -1
  60. package/dist/lib/clip-space.d.ts.map +1 -1
  61. package/dist/lib/clip-space.js +23 -28
  62. package/dist/lib/pipeline-factory.d.ts +1 -5
  63. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  64. package/dist/lib/pipeline-factory.js +64 -68
  65. package/dist/lib/shader-factory.d.ts +17 -0
  66. package/dist/lib/shader-factory.d.ts.map +1 -0
  67. package/dist/lib/shader-factory.js +44 -0
  68. package/dist/model/model.d.ts +22 -10
  69. package/dist/model/model.d.ts.map +1 -1
  70. package/dist/model/model.js +562 -410
  71. package/dist/scenegraph/group-node.d.ts +1 -1
  72. package/dist/scenegraph/group-node.d.ts.map +1 -1
  73. package/dist/scenegraph/group-node.js +73 -83
  74. package/dist/scenegraph/model-node.d.ts +2 -2
  75. package/dist/scenegraph/model-node.d.ts.map +1 -1
  76. package/dist/scenegraph/model-node.js +31 -24
  77. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  78. package/dist/scenegraph/scenegraph-node.js +136 -124
  79. package/dist/shader-inputs.d.ts.map +1 -1
  80. package/dist/shader-inputs.js +99 -58
  81. package/dist/transform/buffer-transform.d.ts +1 -1
  82. package/dist/transform/buffer-transform.d.ts.map +1 -1
  83. package/dist/transform/buffer-transform.js +65 -57
  84. package/dist/transform/texture-transform.d.ts +1 -1
  85. package/dist/transform/texture-transform.d.ts.map +1 -1
  86. package/dist/transform/texture-transform.js +109 -114
  87. package/dist.min.js +2 -272
  88. package/package.json +10 -9
  89. package/src/animation/timeline.ts +20 -20
  90. package/src/animation-loop/animation-loop-template.ts +10 -8
  91. package/src/animation-loop/animation-loop.ts +20 -10
  92. package/src/animation-loop/animation-props.ts +1 -1
  93. package/src/animation-loop/make-animation-loop.ts +17 -8
  94. package/src/debug/copy-texture-to-image.ts +8 -6
  95. package/src/debug/debug-framebuffer.ts +16 -3
  96. package/src/debug/debug-shader-layout.ts +1 -1
  97. package/src/debug/pixel-data-utils.ts +3 -6
  98. package/src/geometries/cube-geometry.ts +17 -13
  99. package/src/geometries/ico-sphere-geometry.ts +1 -1
  100. package/src/geometries/plane-geometry.ts +1 -1
  101. package/src/geometries/sphere-geometry.ts +1 -1
  102. package/src/geometries/truncated-cone-geometry.ts +2 -1
  103. package/src/geometry/geometry-table.ts +9 -6
  104. package/src/geometry/geometry-utils.ts +1 -1
  105. package/src/geometry/geometry.ts +9 -6
  106. package/src/geometry/gpu-geometry.ts +14 -6
  107. package/src/index.ts +1 -0
  108. package/src/lib/clip-space.ts +14 -18
  109. package/src/lib/pipeline-factory.ts +12 -22
  110. package/src/lib/shader-factory.ts +55 -0
  111. package/src/model/model.ts +74 -42
  112. package/src/scenegraph/group-node.ts +14 -10
  113. package/src/scenegraph/model-node.ts +2 -2
  114. package/src/scenegraph/scenegraph-node.ts +2 -2
  115. package/src/shader-inputs.ts +19 -12
  116. package/src/transform/buffer-transform.ts +16 -8
  117. package/src/transform/texture-transform.ts +14 -15
  118. package/dist/animation/key-frames.js.map +0 -1
  119. package/dist/animation/timeline.js.map +0 -1
  120. package/dist/animation-loop/animation-loop-template.js.map +0 -1
  121. package/dist/animation-loop/animation-loop.js.map +0 -1
  122. package/dist/animation-loop/animation-props.js.map +0 -1
  123. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  124. package/dist/debug/copy-texture-to-image.js.map +0 -1
  125. package/dist/debug/debug-framebuffer.js.map +0 -1
  126. package/dist/debug/debug-shader-layout.js.map +0 -1
  127. package/dist/debug/pixel-data-utils.js.map +0 -1
  128. package/dist/geometries/cone-geometry.js.map +0 -1
  129. package/dist/geometries/cube-geometry.js.map +0 -1
  130. package/dist/geometries/cylinder-geometry.js.map +0 -1
  131. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  132. package/dist/geometries/plane-geometry.js.map +0 -1
  133. package/dist/geometries/sphere-geometry.js.map +0 -1
  134. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  135. package/dist/geometry/geometry-table.js.map +0 -1
  136. package/dist/geometry/geometry-utils.js.map +0 -1
  137. package/dist/geometry/geometry.js.map +0 -1
  138. package/dist/geometry/gpu-geometry.js.map +0 -1
  139. package/dist/geometry/gpu-table.js.map +0 -1
  140. package/dist/index.js.map +0 -1
  141. package/dist/lib/clip-space.js.map +0 -1
  142. package/dist/lib/pipeline-factory.js.map +0 -1
  143. package/dist/model/model.js.map +0 -1
  144. package/dist/scenegraph/group-node.js.map +0 -1
  145. package/dist/scenegraph/model-node.js.map +0 -1
  146. package/dist/scenegraph/scenegraph-node.js.map +0 -1
  147. package/dist/shader-inputs.js.map +0 -1
  148. package/dist/transform/buffer-transform.js.map +0 -1
  149. package/dist/transform/texture-transform.js.map +0 -1
@@ -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
- constructor(modules) {
5
- this.modules = void 0;
6
- this.moduleUniforms = void 0;
7
- this.moduleBindings = void 0;
8
- this.moduleUniformsChanged = void 0;
9
- const allModules = _resolveModules(Object.values(modules));
10
- log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();
11
- this.modules = modules;
12
- this.moduleUniforms = {};
13
- this.moduleBindings = {};
14
- for (const [name, module] of Object.entries(modules)) {
15
- const moduleName = name;
16
- this.moduleUniforms[moduleName] = module.defaultUniforms || {};
17
- this.moduleBindings[moduleName] = {};
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
- destroy() {}
21
- setProps(props) {
22
- for (const name of Object.keys(props)) {
23
- var _module$getUniforms;
24
- const moduleName = name;
25
- const moduleProps = props[moduleName];
26
- const module = this.modules[moduleName];
27
- if (!module) {
28
- log.warn(`Module ${name} not found`)();
29
- continue;
30
- }
31
- const oldUniforms = this.moduleUniforms[moduleName];
32
- const uniforms = ((_module$getUniforms = module.getUniforms) === null || _module$getUniforms === void 0 ? void 0 : _module$getUniforms.call(module, moduleProps, this.moduleUniforms[moduleName])) || moduleProps;
33
- this.moduleUniforms[moduleName] = {
34
- ...oldUniforms,
35
- ...uniforms
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
- getModules() {
40
- return Object.values(this.modules);
41
- }
42
- getUniformValues() {
43
- return this.moduleUniforms;
44
- }
45
- getBindings() {
46
- const bindings = {};
47
- for (const moduleBindings of Object.values(this.moduleBindings)) {
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
- return bindings;
51
- }
52
- getDebugTable() {
53
- const table = {};
54
- for (const [moduleName, module] of Object.entries(this.moduleUniforms)) {
55
- for (const [key, value] of Object.entries(module)) {
56
- var _this$modules$moduleN;
57
- table[`${moduleName}.${key}`] = {
58
- type: (_this$modules$moduleN = this.modules[moduleName].uniformTypes) === null || _this$modules$moduleN === void 0 ? void 0 : _this$modules$moduleN[key],
59
- value: String(value)
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 '../model/model';
2
+ import { Model } from "../model/model.js";
3
3
  import type { ModelProps } from '..';
4
4
  /**
5
5
  * Properties for creating a {@link BufferTransform}
@@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: 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
- static isSupported(device) {
6
- return device.features.has('transform-feedback-webgl2');
7
- }
8
- constructor(device) {
9
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Model.defaultProps;
10
- this.device = void 0;
11
- this.model = void 0;
12
- this.transformFeedback = void 0;
13
- assert(device.features.has('transform-feedback-webgl2'), 'Device must support transform feedback');
14
- this.device = device;
15
- this.model = new Model(this.device, {
16
- id: props.id || 'buffer-transform-model',
17
- fs: props.fs || getPassthroughFS({
18
- version: 300
19
- }),
20
- topology: props.topology || 'point-list',
21
- ...props
22
- });
23
- this.transformFeedback = this.device.createTransformFeedback({
24
- layout: this.model.pipeline.shaderLayout,
25
- buffers: props.feedbackBuffers
26
- });
27
- this.model.setTransformFeedback(this.transformFeedback);
28
- Object.seal(this);
29
- }
30
- destroy() {
31
- if (this.model) {
32
- this.model.destroy();
33
- }
34
- }
35
- delete() {
36
- this.destroy();
37
- }
38
- run(options) {
39
- const renderPass = this.device.beginRenderPass(options);
40
- this.model.draw(renderPass);
41
- renderPass.end();
42
- }
43
- update() {
44
- console.warn('TextureTransform#update() not implemented');
45
- }
46
- getBuffer(varyingName) {
47
- return this.transformFeedback.getBuffer(varyingName);
48
- }
49
- readAsync(varyingName) {
50
- const result = this.getBuffer(varyingName);
51
- if (result instanceof Buffer) {
52
- return result.readAsync();
53
- }
54
- const {
55
- buffer,
56
- byteOffset = 0,
57
- byteLength = buffer.byteLength
58
- } = result;
59
- return buffer.readAsync(byteOffset, byteLength);
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 '../model/model';
2
+ import { Model, ModelProps } from "../model/model.js";
3
3
  /**
4
4
  * Properties for creating a {@link TextureTransform}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O,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
- constructor(device, props) {
6
- this.device = void 0;
7
- this.model = void 0;
8
- this.sampler = void 0;
9
- this.currentIndex = 0;
10
- this.samplerTextureMap = null;
11
- this.bindings = [];
12
- this.resources = {};
13
- this.device = device;
14
- this.sampler = device.createSampler({
15
- addressModeU: 'clamp-to-edge',
16
- addressModeV: 'clamp-to-edge',
17
- minFilter: 'nearest',
18
- magFilter: 'nearest',
19
- mipmapFilter: 'nearest'
20
- });
21
- this.model = new Model(this.device, {
22
- id: props.id || 'texture-transform-model',
23
- fs: props.fs || getPassthroughFS({
24
- version: 300,
25
- input: props.targetTextureVarying,
26
- inputChannels: props.targetTextureChannels,
27
- output: FS_OUTPUT_VARIABLE
28
- }),
29
- vertexCount: props.vertexCount,
30
- ...props
31
- });
32
- this._initialize(props);
33
- Object.seal(this);
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
- Object.assign(binding.sourceTextures, sourceTextures);
89
- Object.assign(binding.sourceBuffers, sourceBuffers);
90
- if (targetTexture) {
91
- binding.targetTexture = targetTexture;
92
- const {
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
- return binding;
111
- }
112
- _setSourceTextureParameters() {
113
- const index = this.currentIndex;
114
- const {
115
- sourceTextures
116
- } = this.bindings[index];
117
- for (const name in sourceTextures) {
118
- sourceTextures[name].sampler = this.sampler;
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