@luma.gl/webgl 9.0.0-alpha.44 → 9.0.0-alpha.46

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 (56) hide show
  1. package/dist/adapter/device-helpers/device-features.js +1 -0
  2. package/dist/adapter/device-helpers/device-features.js.map +1 -1
  3. package/dist/adapter/helpers/webgl-topology-utils.d.ts +6 -1
  4. package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
  5. package/dist/adapter/helpers/webgl-topology-utils.js +40 -0
  6. package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -1
  7. package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
  8. package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
  9. package/dist/adapter/resources/webgl-buffer.js +2 -0
  10. package/dist/adapter/resources/webgl-buffer.js.map +1 -1
  11. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  12. package/dist/adapter/resources/webgl-command-buffer.js +6 -4
  13. package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
  14. package/dist/adapter/resources/webgl-render-pipeline.d.ts +2 -0
  15. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  16. package/dist/adapter/resources/webgl-render-pipeline.js +4 -44
  17. package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
  18. package/dist/adapter/resources/webgl-transform-feedback.d.ts +53 -0
  19. package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -0
  20. package/dist/adapter/resources/webgl-transform-feedback.js +161 -0
  21. package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
  22. package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
  23. package/dist/adapter/resources/webgl-vertex-array.js +5 -3
  24. package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
  25. package/dist/adapter/webgl-device.d.ts +4 -2
  26. package/dist/adapter/webgl-device.d.ts.map +1 -1
  27. package/dist/adapter/webgl-device.js +7 -3
  28. package/dist/adapter/webgl-device.js.map +1 -1
  29. package/dist/classic/copy-and-blit.d.ts +3 -3
  30. package/dist/classic/copy-and-blit.d.ts.map +1 -1
  31. package/dist/classic/copy-and-blit.js +12 -20
  32. package/dist/classic/copy-and-blit.js.map +1 -1
  33. package/dist/dist.dev.js +2140 -2302
  34. package/dist/index.cjs +645 -806
  35. package/dist/index.d.ts +1 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist.min.js +23 -22
  40. package/package.json +5 -5
  41. package/src/adapter/device-helpers/device-features.ts +1 -0
  42. package/src/adapter/helpers/webgl-topology-utils.ts +40 -0
  43. package/src/adapter/resources/webgl-buffer.ts +12 -8
  44. package/src/adapter/resources/webgl-command-buffer.ts +7 -13
  45. package/src/adapter/resources/webgl-render-pipeline.ts +11 -47
  46. package/src/adapter/resources/webgl-transform-feedback.ts +205 -0
  47. package/src/adapter/resources/webgl-vertex-array.ts +11 -8
  48. package/src/adapter/webgl-device.ts +10 -5
  49. package/src/classic/copy-and-blit.ts +16 -19
  50. package/src/index.ts +5 -4
  51. package/LICENSE +0 -34
  52. package/dist/classic/buffer-with-accessor.d.ts +0 -82
  53. package/dist/classic/buffer-with-accessor.d.ts.map +0 -1
  54. package/dist/classic/buffer-with-accessor.js +0 -314
  55. package/dist/classic/buffer-with-accessor.js.map +0 -1
  56. package/src/classic/buffer-with-accessor.ts +0 -466
@@ -4,12 +4,11 @@
4
4
  import {assert, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';
5
5
  import {GL} from '@luma.gl/constants';
6
6
 
7
- import {BufferWithAccessor as Buffer} from './buffer-with-accessor';
8
7
  import {WEBGLTexture} from '../adapter/resources/webgl-texture';
9
8
  import {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';
10
- import {withGLParameters} from '../context/state-tracker/with-parameters';
11
9
  import {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';
12
10
  import {glFormatToComponents, glTypeToBytes} from './format-utils';
11
+ import {WEBGLBuffer} from '../adapter/resources/webgl-buffer';
13
12
 
14
13
  /**
15
14
  * Copies data from a type or a Texture object into ArrayBuffer object.
@@ -99,14 +98,14 @@ export function readPixelsToBuffer(
99
98
  sourceX?: number;
100
99
  sourceY?: number;
101
100
  sourceFormat?: number;
102
- target?: Buffer; // A new Buffer object is created when not provided.
101
+ target?: WEBGLBuffer; // A new Buffer object is created when not provided.
103
102
  targetByteOffset?: number; // byte offset in buffer object
104
103
  // following parameters are auto deduced if not provided
105
104
  sourceWidth?: number;
106
105
  sourceHeight?: number;
107
106
  sourceType?: number;
108
107
  }
109
- ): Buffer {
108
+ ): WEBGLBuffer {
110
109
  const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0} = options || {};
111
110
  // following parameters are auto deduced if not provided
112
111
  let {target, sourceWidth, sourceHeight, sourceType} = options || {};
@@ -117,32 +116,30 @@ export function readPixelsToBuffer(
117
116
 
118
117
  // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
119
118
  const webglFramebuffer = framebuffer as WEBGLFramebuffer;
120
- const gl2 = webglFramebuffer.device.assertWebGL2();
121
119
 
122
120
  // deduce type if not available.
123
- sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);
121
+ sourceType = sourceType || GL.UNSIGNED_BYTE;
124
122
 
125
123
  if (!target) {
126
124
  // Create new buffer with enough size
127
125
  const components = glFormatToComponents(sourceFormat);
128
126
  const byteCount = glTypeToBytes(sourceType);
129
127
  const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
130
- target = new Buffer(gl2, {byteLength, accessor: {type: sourceType, size: components}});
128
+ target = webglFramebuffer.device.createBuffer({byteLength});
131
129
  }
132
130
 
133
- target.bind({glTarget: GL.PIXEL_PACK_BUFFER});
134
- withGLParameters(gl2, {framebuffer}, () => {
135
- gl2.readPixels(
136
- sourceX,
137
- sourceY,
138
- sourceWidth,
139
- sourceHeight,
140
- sourceFormat,
141
- sourceType,
142
- targetByteOffset
143
- );
131
+ // TODO(donmccurdy): Do we have tests to confirm this is working?
132
+ const commandEncoder = source.device.createCommandEncoder();
133
+ commandEncoder.copyTextureToBuffer({
134
+ source: source as Texture,
135
+ width: sourceWidth,
136
+ height: sourceHeight,
137
+ origin: [sourceX, sourceY],
138
+ destination: target,
139
+ byteOffset: targetByteOffset
144
140
  });
145
- target.unbind({glTarget: GL.PIXEL_PACK_BUFFER});
141
+ commandEncoder.destroy();
142
+
146
143
  if (deleteFramebuffer) {
147
144
  framebuffer.destroy();
148
145
  }
package/src/index.ts CHANGED
@@ -32,15 +32,16 @@ export {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';
32
32
  // export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
33
33
  export {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';
34
34
 
35
- // non-api resources
35
+ // Internal WebGL classes
36
36
  export type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
37
37
  export {WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
38
38
 
39
- // WebGL adapter classes (Legacy will likely be removed)
39
+ // WebGL adapter classes
40
+ export {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';
41
+
42
+ // WebGL adapter classes
40
43
  export {Accessor} from './classic/accessor';
41
44
  export type {AccessorObject} from './types';
42
- export type {BufferWithAccessorProps} from './classic/buffer-with-accessor';
43
- export {BufferWithAccessor} from './classic/buffer-with-accessor';
44
45
 
45
46
  export {
46
47
  isWebGL,
package/LICENSE DELETED
@@ -1,34 +0,0 @@
1
- luma.gl is provided under the MIT license
2
-
3
- Copyright (c) 2020 vis.gl contributors
4
-
5
- This software includes parts initially developed by Uber and open sourced under MIT license.
6
- Copyright (c) 2015 Uber Technologies, Inc.
7
-
8
- This software includes parts of PhiloGL (https://github.com/philogb/philogl)
9
- under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
10
-
11
- This software includes adaptations of some postprocessing code from
12
- THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
- THREE.js parts Copyright © 2010-2018 three.js authors.
14
-
15
- Additional attribution given in specific source files.
16
-
17
- Permission is hereby granted, free of charge, to any person obtaining a copy
18
- of this software and associated documentation files (the "Software"), to deal
19
- in the Software without restriction, including without limitation the rights
20
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- copies of the Software, and to permit persons to whom the Software is
22
- furnished to do so, subject to the following conditions:
23
-
24
- The above copyright notice and this permission notice shall be included in
25
- all copies or substantial portions of the Software.
26
-
27
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33
- THE SOFTWARE.
34
-
@@ -1,82 +0,0 @@
1
- import type { Device, BufferProps, TypedArray } from '@luma.gl/core';
2
- import { GL } from '@luma.gl/constants';
3
- import { AccessorObject } from '../types';
4
- import { Accessor } from './accessor';
5
- import { WEBGLBuffer } from '../adapter/resources/webgl-buffer';
6
- /** WebGL Buffer interface */
7
- export type BufferWithAccessorProps = BufferProps & {
8
- handle?: WebGLBuffer;
9
- accessor?: AccessorObject;
10
- };
11
- /** WebGL Buffer interface */
12
- export declare class BufferWithAccessor extends WEBGLBuffer {
13
- accessor: Accessor;
14
- constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);
15
- constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);
16
- constructor(device: Device | WebGLRenderingContext, byteLength: number);
17
- getElementCount(accessor?: AccessorObject): number;
18
- getVertexCount(accessor?: AccessorObject): number;
19
- initialize(props?: BufferWithAccessorProps): this;
20
- setProps(props: BufferWithAccessorProps): this;
21
- setAccessor(accessor: AccessorObject | Accessor): this;
22
- reallocate(byteLength: number): boolean;
23
- setData(props: BufferWithAccessorProps): this;
24
- subData(options: TypedArray | {
25
- data: TypedArray;
26
- offset?: number;
27
- srcOffset?: number;
28
- byteLength?: number;
29
- length?: number;
30
- }): this;
31
- /**
32
- * Copies part of the data of another buffer into this buffer
33
- * @note WEBGL2 ONLY
34
- */
35
- copyData(options: {
36
- sourceBuffer: any;
37
- readOffset?: number;
38
- writeOffset?: number;
39
- size: any;
40
- }): this;
41
- /**
42
- * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.
43
- * @note WEBGL2 ONLY
44
- */
45
- getData(options?: {
46
- dstData?: any;
47
- srcByteOffset?: number;
48
- dstOffset?: number;
49
- length?: number;
50
- }): any;
51
- /**
52
- * Binds a buffer to a given binding point (target).
53
- * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.
54
- * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state
55
- * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.
56
- * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.
57
- */
58
- bind(options?: {
59
- glTarget?: number;
60
- index?: any;
61
- offset?: number;
62
- size?: any;
63
- }): this;
64
- unbind(options?: {
65
- glTarget?: any;
66
- index?: any;
67
- }): this;
68
- getDebugData(): {
69
- data: any;
70
- changed: boolean;
71
- };
72
- invalidateDebugData(): void;
73
- _setData(data: any, offset?: number, byteLength?: number): this;
74
- _setByteLength(byteLength: number): this;
75
- _getTarget(): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.COPY_WRITE_BUFFER | GL.UNIFORM_BUFFER;
76
- _getAvailableElementCount(srcByteOffset: number): number;
77
- _inferType(data: any): void;
78
- getParameter(pname: GL): any;
79
- /** @deprecated Use Buffer.accessor.type */
80
- get type(): number;
81
- }
82
- //# sourceMappingURL=buffer-with-accessor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer-with-accessor.d.ts","sourceRoot":"","sources":["../../src/classic/buffer-with-accessor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAIpC,OAAO,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AAoD9D,6BAA6B;AAC7B,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAY3B,CAAA;AAED,6BAA6B;AAC7B,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,QAAQ,EAAE,QAAQ,CAAC;gBAEP,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,KAAK,CAAC,EAAE,uBAAuB;gBACvE,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,EAAE;gBACxE,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,UAAU,EAAE,MAAM;IA0BtE,eAAe,CAAC,QAAQ,GAAE,cAA8B,GAAG,MAAM;IAKjE,cAAc,CAAC,QAAQ,GAAE,cAA8B,GAAG,MAAM;IAQhE,UAAU,CAAC,KAAK,GAAE,uBAA4B,GAAG,IAAI;IAgCrD,QAAQ,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI;IAY9C,WAAW,CAAC,QAA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,KAAA,EAAE,MAAM,GAAE,MAAU,EAAE,UAAU,GAAE,MAAiC,GAAG,IAAI;IAwBvF,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IA6BxC,UAAU;IAKV,yBAAyB,CAAC,aAAa,EAAE,MAAM;IAQ/C,UAAU,CAAC,IAAI,KAAA;IAQf,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,GAAG;IAQ5B,2CAA2C;IAC3C,IAAI,IAAI,WAEP;CACF"}
@@ -1,314 +0,0 @@
1
- import { assert, checkProps } from '@luma.gl/core';
2
- import { GL } from '@luma.gl/constants';
3
- import { assertWebGL2Context } from "../context/context/webgl-checks.js";
4
- import { Accessor } from "./accessor.js";
5
- import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
6
- import { WebGLDevice } from "../adapter/webgl-device.js";
7
- import { WEBGLBuffer } from "../adapter/resources/webgl-buffer.js";
8
- const DEBUG_DATA_LENGTH = 10;
9
- const DEPRECATED_PROPS = {
10
- offset: 'accessor.offset',
11
- stride: 'accessor.stride',
12
- type: 'accessor.type',
13
- size: 'accessor.size',
14
- divisor: 'accessor.divisor',
15
- normalized: 'accessor.normalized',
16
- integer: 'accessor.integer',
17
- instanced: 'accessor.divisor',
18
- isInstanced: 'accessor.divisor'
19
- };
20
- const PROP_CHECKS_INITIALIZE = {
21
- removedProps: {},
22
- replacedProps: {
23
- bytes: 'byteLength'
24
- },
25
- deprecatedProps: DEPRECATED_PROPS
26
- };
27
- const PROP_CHECKS_SET_PROPS = {
28
- removedProps: DEPRECATED_PROPS
29
- };
30
- function getWEBGLBufferProps(props) {
31
- if (ArrayBuffer.isView(props)) {
32
- return {
33
- data: props
34
- };
35
- } else if (typeof props === 'number') {
36
- return {
37
- byteLength: props
38
- };
39
- }
40
- props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);
41
- const bufferProps = {
42
- ...props
43
- };
44
- return bufferProps;
45
- }
46
- export class BufferWithAccessor extends WEBGLBuffer {
47
- constructor(device) {
48
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
49
- super(WebGLDevice.attach(device), getWEBGLBufferProps(props));
50
- this.accessor = void 0;
51
- this.setAccessor(Object.assign({}, props, props.accessor));
52
- if (this.props.data) {
53
- const type = getGLTypeFromTypedArray(this.props.data);
54
- assert(type);
55
- this.setAccessor(new Accessor(this.accessor, {
56
- type
57
- }));
58
- }
59
- Object.seal(this);
60
- }
61
- getElementCount() {
62
- let accessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.accessor;
63
- return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));
64
- }
65
- getVertexCount() {
66
- let accessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.accessor;
67
- return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));
68
- }
69
- initialize() {
70
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
71
- if (ArrayBuffer.isView(props)) {
72
- props = {
73
- data: props
74
- };
75
- }
76
- if (Number.isFinite(props)) {
77
- props = {
78
- byteLength: props
79
- };
80
- }
81
- props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);
82
- this.glUsage = props.glUsage || GL.STATIC_DRAW;
83
- this.debugData = null;
84
- this.setAccessor(Object.assign({}, props, props.accessor));
85
- if (props.data) {
86
- this._setData(props.data, props.byteOffset, props.byteLength);
87
- } else {
88
- this._setByteLength(props.byteLength || 0);
89
- }
90
- return this;
91
- }
92
- setProps(props) {
93
- props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);
94
- if ('accessor' in props) {
95
- this.setAccessor(props.accessor);
96
- }
97
- return this;
98
- }
99
- setAccessor(accessor) {
100
- accessor = Object.assign({}, accessor);
101
- delete accessor.buffer;
102
- this.accessor = new Accessor(accessor);
103
- return this;
104
- }
105
- reallocate(byteLength) {
106
- if (byteLength > this.byteLength) {
107
- this._setByteLength(byteLength);
108
- return true;
109
- }
110
- this.bytesUsed = byteLength;
111
- return false;
112
- }
113
- setData(props) {
114
- return this.initialize(props);
115
- }
116
- subData(options) {
117
- if (ArrayBuffer.isView(options)) {
118
- options = {
119
- data: options
120
- };
121
- }
122
- const {
123
- data,
124
- offset = 0,
125
- srcOffset = 0
126
- } = options;
127
- const byteLength = options.byteLength || options.length;
128
- assert(data);
129
- const glTarget = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
130
- this.gl.bindBuffer(glTarget, this.handle);
131
- if (srcOffset !== 0 || byteLength !== undefined) {
132
- assertWebGL2Context(this.gl);
133
- this.gl.bufferSubData(this.glTarget, offset, data, srcOffset, byteLength);
134
- } else {
135
- this.gl.bufferSubData(glTarget, offset, data);
136
- }
137
- this.gl.bindBuffer(glTarget, null);
138
- this.debugData = null;
139
- this._inferType(data);
140
- return this;
141
- }
142
- copyData(options) {
143
- const {
144
- sourceBuffer,
145
- readOffset = 0,
146
- writeOffset = 0,
147
- size
148
- } = options;
149
- const {
150
- gl,
151
- gl2
152
- } = this;
153
- assertWebGL2Context(gl);
154
- gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);
155
- gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);
156
- gl2 === null || gl2 === void 0 ? void 0 : gl2.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
157
- gl.bindBuffer(GL.COPY_READ_BUFFER, null);
158
- gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);
159
- this.debugData = null;
160
- return this;
161
- }
162
- getData(options) {
163
- var _this$gl;
164
- let {
165
- dstData = null,
166
- length = 0
167
- } = options || {};
168
- const {
169
- srcByteOffset = 0,
170
- dstOffset = 0
171
- } = options || {};
172
- assertWebGL2Context(this.gl);
173
- const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {
174
- clamped: false
175
- });
176
- const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);
177
- const dstElementOffset = dstOffset;
178
- let dstAvailableElementCount;
179
- let dstElementCount;
180
- if (dstData) {
181
- dstElementCount = dstData.length;
182
- dstAvailableElementCount = dstElementCount - dstElementOffset;
183
- } else {
184
- dstAvailableElementCount = Math.min(sourceAvailableElementCount, length || sourceAvailableElementCount);
185
- dstElementCount = dstElementOffset + dstAvailableElementCount;
186
- }
187
- const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);
188
- length = length || copyElementCount;
189
- assert(length <= copyElementCount);
190
- dstData = dstData || new ArrayType(dstElementCount);
191
- this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);
192
- (_this$gl = this.gl2) === null || _this$gl === void 0 ? void 0 : _this$gl.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
193
- this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);
194
- return dstData;
195
- }
196
- bind(options) {
197
- const {
198
- glTarget = this.glTarget,
199
- index = this.accessor && this.accessor.index,
200
- offset = 0,
201
- size
202
- } = options || {};
203
- if (glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER) {
204
- if (size !== undefined) {
205
- var _this$gl2;
206
- (_this$gl2 = this.gl2) === null || _this$gl2 === void 0 ? void 0 : _this$gl2.bindBufferRange(glTarget, index, this.handle, offset, size);
207
- } else {
208
- var _this$gl3;
209
- assert(offset === 0);
210
- (_this$gl3 = this.gl2) === null || _this$gl3 === void 0 ? void 0 : _this$gl3.bindBufferBase(glTarget, index, this.handle);
211
- }
212
- } else {
213
- this.gl.bindBuffer(glTarget, this.handle);
214
- }
215
- return this;
216
- }
217
- unbind(options) {
218
- const {
219
- glTarget = this.glTarget,
220
- index = this.accessor && this.accessor.index
221
- } = options || {};
222
- const isIndexedBuffer = glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER;
223
- if (isIndexedBuffer) {
224
- var _this$gl4;
225
- (_this$gl4 = this.gl2) === null || _this$gl4 === void 0 ? void 0 : _this$gl4.bindBufferBase(glTarget, index, null);
226
- } else {
227
- this.gl.bindBuffer(glTarget, null);
228
- }
229
- return this;
230
- }
231
- getDebugData() {
232
- if (!this.debugData) {
233
- this.debugData = this.getData({
234
- length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)
235
- });
236
- return {
237
- data: this.debugData,
238
- changed: true
239
- };
240
- }
241
- return {
242
- data: this.debugData,
243
- changed: false
244
- };
245
- }
246
- invalidateDebugData() {
247
- this.debugData = null;
248
- }
249
- _setData(data) {
250
- let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
251
- let byteLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : data.byteLength + offset;
252
- assert(ArrayBuffer.isView(data));
253
- this.trackDeallocatedMemory();
254
- const target = this._getTarget();
255
- this.gl.bindBuffer(target, this.handle);
256
- this.gl.bufferData(target, byteLength, this.glUsage);
257
- this.gl.bufferSubData(target, offset, data);
258
- this.gl.bindBuffer(target, null);
259
- this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
260
- this.bytesUsed = byteLength;
261
- this.byteLength = byteLength;
262
- this.trackAllocatedMemory(byteLength);
263
- const type = getGLTypeFromTypedArray(data);
264
- assert(type);
265
- this.setAccessor(new Accessor(this.accessor, {
266
- type
267
- }));
268
- return this;
269
- }
270
- _setByteLength(byteLength) {
271
- assert(byteLength >= 0);
272
- this.trackDeallocatedMemory();
273
- let data = byteLength;
274
- if (byteLength === 0) {
275
- data = new Float32Array(0);
276
- }
277
- const glTarget = this._getTarget();
278
- this.gl.bindBuffer(glTarget, this.handle);
279
- this.gl.bufferData(glTarget, data, this.glUsage);
280
- this.gl.bindBuffer(glTarget, null);
281
- this.debugData = null;
282
- this.bytesUsed = byteLength;
283
- this.byteLength = byteLength;
284
- this.trackAllocatedMemory(byteLength);
285
- return this;
286
- }
287
- _getTarget() {
288
- return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;
289
- }
290
- _getAvailableElementCount(srcByteOffset) {
291
- const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {
292
- clamped: false
293
- });
294
- const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;
295
- return this.getElementCount() - sourceElementOffset;
296
- }
297
- _inferType(data) {
298
- if (!this.accessor.type) {
299
- this.setAccessor(new Accessor(this.accessor, {
300
- type: getGLTypeFromTypedArray(data)
301
- }));
302
- }
303
- }
304
- getParameter(pname) {
305
- this.gl.bindBuffer(this.glTarget, this.handle);
306
- const value = this.gl.getBufferParameter(this.glTarget, pname);
307
- this.gl.bindBuffer(this.glTarget, null);
308
- return value;
309
- }
310
- get type() {
311
- return this.accessor.type;
312
- }
313
- }
314
- //# sourceMappingURL=buffer-with-accessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer-with-accessor.js","names":["assert","checkProps","GL","assertWebGL2Context","Accessor","getGLTypeFromTypedArray","getTypedArrayFromGLType","WebGLDevice","WEBGLBuffer","DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","BufferWithAccessor","constructor","device","arguments","length","undefined","attach","accessor","setAccessor","Object","assign","seal","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","glUsage","STATIC_DRAW","debugData","_setData","byteOffset","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","subData","options","srcOffset","glTarget","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","_this$gl","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","_this$gl2","bindBufferRange","_this$gl3","bindBufferBase","unbind","isIndexedBuffer","_this$gl4","getDebugData","changed","invalidateDebugData","trackDeallocatedMemory","target","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"sources":["../../src/classic/buffer-with-accessor.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/core';\nimport {assert, checkProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport {Accessor} from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport {WebGLDevice} from '../adapter/webgl-device';\nimport {WEBGLBuffer} from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: BufferWithAccessorProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props };\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props };\n // if (bufferProps.offset) {\n // bufferProps.byteOffset = bufferProps.offset;\n // }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type BufferWithAccessorProps = BufferProps & {\n handle?: WebGLBuffer;\n\n accessor?: AccessorObject;\n\n // target?: number;\n // glUsage?: number;\n // /** @deprecated */\n // index?: number;\n // /** @deprecated */\n // offset?: number;\n // /** @deprecated */\n // size?: number;\n // /** @deprecated */\n // type?: number\n}\n\n/** WebGL Buffer interface */\nexport class BufferWithAccessor extends WEBGLBuffer {\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as BufferWithAccessorProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n // override write(data: TypedArray, byteOffset: number = 0): void {\n // this.subData({data, offset: byteOffset});\n // }\n\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: BufferWithAccessorProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n // @ts-expect-error readonly field\n this.glUsage = props.glUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: BufferWithAccessorProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: BufferWithAccessorProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n // @ts-expect-error\n const glTarget = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.glTarget, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, offset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n override getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {glTarget?: number; index?: any; offset?: number; size?: any}): this {\n const {\n glTarget = this.glTarget, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(glTarget, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(glTarget, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(glTarget, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {glTarget?: any; index?: any}): this {\n const {glTarget = this.glTarget, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(glTarget, index, null);\n } else {\n this.gl.bindBuffer(glTarget, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.glUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const glTarget = this._getTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.glTarget, this.handle);\n const value = this.gl.getBufferParameter(this.glTarget, pname);\n this.gl.bindBuffer(this.glTarget, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"mappings":"AAIA,SAAQA,MAAM,EAAEC,UAAU,QAAO,eAAe;AAChD,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,mBAAmB;AAAA,SAEnBC,QAAQ;AAAA,SACRC,uBAAuB,EAAEC,uBAAuB;AAAA,SAEhDC,WAAW;AAAA,SACXC,WAAW;AAEnB,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,MAAMC,gBAAgB,GAAG;EACvBC,MAAM,EAAE,iBAAiB;EACzBC,MAAM,EAAE,iBAAiB;EACzBC,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAE,kBAAkB;EAC3BC,UAAU,EAAE,qBAAqB;EACjCC,OAAO,EAAE,kBAAkB;EAC3BC,SAAS,EAAE,kBAAkB;EAC7BC,WAAW,EAAE;AACf,CAAC;AAGD,MAAMC,sBAAsB,GAAG;EAC7BC,YAAY,EAAE,CAAC,CAAC;EAChBC,aAAa,EAAE;IACbC,KAAK,EAAE;EACT,CAAC;EAEDC,eAAe,EAAEd;AACnB,CAAC;AAGD,MAAMe,qBAAqB,GAAG;EAE5BJ,YAAY,EAAEX;AAChB,CAAC;AAED,SAASgB,mBAAmBA,CAACC,KAAyD,EAAe;EAEnG,IAAIC,WAAW,CAACC,MAAM,CAACF,KAAK,CAAC,EAAE;IAC7B,OAAO;MAACG,IAAI,EAAEH;IAAK,CAAC;EACtB,CAAC,MAGI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO;MAACI,UAAU,EAAEJ;IAAM,CAAC;EAC7B;EAEAA,KAAK,GAAG1B,UAAU,CAAC,QAAQ,EAAE0B,KAAK,EAAEP,sBAAsB,CAAC;EA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