@kitware/vtk.js 24.5.4 → 24.6.0

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 (61) hide show
  1. package/Common/Core/CellArray.js +14 -3
  2. package/Common/Core/Math/index.js +1 -1
  3. package/Common/Core/Math.js +1 -1
  4. package/Common/DataModel/Triangle.js +1 -1
  5. package/Common/Transform/LandmarkTransform.js +1 -1
  6. package/Filters/Core/PolyDataNormals.js +1 -1
  7. package/Filters/General/OBBTree.js +1 -1
  8. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  9. package/Filters/Sources/CircleSource.js +1 -1
  10. package/Filters/Sources/PointSource.js +1 -1
  11. package/Filters/Texture/TextureMapToPlane.js +1 -1
  12. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  13. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  14. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  15. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  16. package/Interaction/Style/InteractorStyleTrackballCamera.js +1 -1
  17. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  18. package/Proxy/Core/View2DProxy.js +1 -1
  19. package/Rendering/Core/ColorTransferFunction.js +1 -1
  20. package/Rendering/Core/Coordinate.js +1 -1
  21. package/Rendering/Core/CubeAxesActor.js +1 -1
  22. package/Rendering/Core/Glyph3DMapper.js +1 -1
  23. package/Rendering/Core/ImageMapper.js +1 -1
  24. package/Rendering/Core/Mapper.js +2 -2
  25. package/Rendering/Core/Prop3D.js +1 -1
  26. package/Rendering/Core/RenderWindowInteractor.js +1 -1
  27. package/Rendering/Core/Renderer.js +1 -1
  28. package/Rendering/Core/ScalarBarActor.js +1 -1
  29. package/Rendering/Core/VolumeMapper.js +1 -1
  30. package/Rendering/OpenGL/PolyDataMapper2D.js +5 -3
  31. package/Rendering/OpenGL/Texture.js +1 -1
  32. package/Rendering/WebGPU/BindGroup.js +1 -1
  33. package/Rendering/WebGPU/BufferManager/Constants.js +1 -1
  34. package/Rendering/WebGPU/BufferManager.js +149 -263
  35. package/Rendering/WebGPU/CellArrayMapper.js +46 -73
  36. package/Rendering/WebGPU/Device.js +97 -57
  37. package/Rendering/WebGPU/Glyph3DMapper.js +2 -0
  38. package/Rendering/WebGPU/ImageMapper.js +1 -5
  39. package/Rendering/WebGPU/IndexBuffer.js +397 -0
  40. package/Rendering/WebGPU/RenderEncoder.js +1 -1
  41. package/Rendering/WebGPU/SimpleMapper.js +7 -1
  42. package/Rendering/WebGPU/SphereMapper.js +29 -31
  43. package/Rendering/WebGPU/StickMapper.js +38 -42
  44. package/Rendering/WebGPU/StorageBuffer.js +0 -1
  45. package/Rendering/WebGPU/Texture.js +0 -2
  46. package/Rendering/WebGPU/TextureManager.js +37 -7
  47. package/Rendering/WebGPU/UniformBuffer.js +0 -1
  48. package/Rendering/WebGPU/VertexInput.js +7 -2
  49. package/Rendering/WebGPU/VolumePass.js +16 -8
  50. package/Rendering/WebGPU/VolumePassFSQ.js +1 -5
  51. package/Widgets/Manipulators/LineManipulator.js +1 -1
  52. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  53. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  54. package/Widgets/Widgets3D/AngleWidget.js +1 -1
  55. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  56. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  57. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  58. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  59. package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
  60. package/index.d.ts +2 -2
  61. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import { newInstance as newInstance$1, obj, setGet, newTypedArray, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
2
+ import { newInstance as newInstance$1, obj, setGet, vtkErrorMacro as vtkErrorMacro$1, newTypedArray } from '../../macros.js';
3
3
  import { j as cross, l as normalize } from '../../Common/Core/Math/index.js';
4
+ import vtkDataArray from '../../Common/Core/DataArray.js';
4
5
  import vtkWebGPUBuffer from './Buffer.js';
6
+ import vtkWebGPUIndexBuffer from './IndexBuffer.js';
5
7
  import vtkWebGPUTypes from './Types.js';
6
- import vtkProperty from '../Core/Property.js';
7
8
  import Constants from './BufferManager/Constants.js';
8
9
 
9
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
11
 
11
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
- var BufferUsage = Constants.BufferUsage,
13
- PrimitiveTypes = Constants.PrimitiveTypes;
14
- var Representation = vtkProperty.Representation;
15
- var vtkDebugMacro = vtkDebugMacro$1; // the webgpu constants all show up as undefined
13
+ var BufferUsage = Constants.BufferUsage;
14
+ var vtkErrorMacro = vtkErrorMacro$1;
15
+ var VtkDataTypes = vtkDataArray.VtkDataTypes; // the webgpu constants all show up as undefined
16
16
 
17
17
  /* eslint-disable no-undef */
18
18
  // ----------------------------------------------------------------------------
@@ -20,100 +20,71 @@ var vtkDebugMacro = vtkDebugMacro$1; // the webgpu constants all show up as unde
20
20
  // ----------------------------------------------------------------------------
21
21
 
22
22
  var STATIC = {};
23
- var cellCounters = {
24
- // easy, every input point becomes an output point
25
- anythingToPoints: function anythingToPoints(numPoints, cellPts) {
26
- return numPoints;
27
- },
28
- linesToWireframe: function linesToWireframe(numPoints, cellPts) {
29
- if (numPoints > 1) {
30
- return (numPoints - 1) * 2;
31
- }
32
23
 
33
- return 0;
34
- },
35
- polysToWireframe: function polysToWireframe(numPoints, cellPts) {
36
- if (numPoints > 2) {
37
- return numPoints * 2;
38
- }
24
+ function _getFormatForDataArray(dataArray) {
25
+ var format;
39
26
 
40
- return 0;
41
- },
42
- stripsToWireframe: function stripsToWireframe(numPoints, cellPts) {
43
- if (numPoints > 2) {
44
- return numPoints * 4 - 6;
45
- }
27
+ switch (dataArray.getDataType()) {
28
+ case VtkDataTypes.UNSIGNED_CHAR:
29
+ format = 'uint8';
30
+ break;
46
31
 
47
- return 0;
48
- },
49
- polysToSurface: function polysToSurface(npts, cellPts) {
50
- if (npts > 2) {
51
- return (npts - 2) * 3;
52
- }
32
+ case VtkDataTypes.FLOAT:
33
+ format = 'float32';
34
+ break;
53
35
 
54
- return 0;
55
- },
56
- stripsToSurface: function stripsToSurface(npts, cellPts, offset) {
57
- if (numPoints > 2) {
58
- return (npts - 2) * 3;
59
- }
36
+ case VtkDataTypes.UNSIGNED_INT:
37
+ format = 'uint32';
38
+ break;
60
39
 
61
- return 0;
62
- }
63
- };
64
-
65
- function getPrimitiveName(primType) {
66
- switch (primType) {
67
- case PrimitiveTypes.Points:
68
- return 'points';
40
+ case VtkDataTypes.INT:
41
+ format = 'sint32';
42
+ break;
69
43
 
70
- case PrimitiveTypes.Lines:
71
- return 'lines';
44
+ case VtkDataTypes.DOUBLE:
45
+ format = 'float32';
46
+ break;
72
47
 
73
- case PrimitiveTypes.Triangles:
74
- case PrimitiveTypes.TriangleEdges:
75
- return 'polys';
48
+ case VtkDataTypes.UNSIGNED_SHORT:
49
+ format = 'uint16';
50
+ break;
76
51
 
77
- case PrimitiveTypes.TriangleStripEdges:
78
- case PrimitiveTypes.TriangleStrips:
79
- return 'strips';
52
+ case VtkDataTypes.SHORT:
53
+ format = 'sin16';
54
+ break;
80
55
 
81
56
  default:
82
- return '';
57
+ format = 'float32';
58
+ break;
83
59
  }
84
- }
85
60
 
86
- function getOutputSize(cellArray, representation, inRepName) {
87
- var countFunc = null;
61
+ switch (dataArray.getNumberOfComponents()) {
62
+ case 2:
63
+ format += 'x2';
64
+ break;
88
65
 
89
- if (representation === Representation.POINTS || inRepName === 'points') {
90
- countFunc = cellCounters.anythingToPoints;
91
- } else if (representation === Representation.WIREFRAME || inRepName === 'lines') {
92
- countFunc = cellCounters["".concat(inRepName, "ToWireframe")];
93
- } else {
94
- countFunc = cellCounters["".concat(inRepName, "ToSurface")];
95
- }
66
+ case 3:
67
+ // only 32bit types support x3
68
+ if (!format.contains('32')) {
69
+ vtkErrorMacro("unsupported x3 type for ".concat(format));
70
+ }
96
71
 
97
- var array = cellArray.getData();
98
- var size = array.length;
99
- var caboCount = 0;
72
+ format += 'x3';
73
+ break;
100
74
 
101
- for (var index = 0; index < size;) {
102
- caboCount += countFunc(array[index], array);
103
- index += array[index] + 1;
75
+ case 4:
76
+ format += 'x4';
77
+ break;
104
78
  }
105
79
 
106
- return caboCount;
80
+ return format;
107
81
  }
108
82
 
109
- function packArray(cellArray, primType, representation, inArray, outputType, options) {
110
- var result = {
111
- elementCount: 0,
112
- blockSize: 0,
113
- stride: 0
114
- };
83
+ function packArray(indexBuffer, inArrayData, numComp, outputType, options) {
84
+ var result = {};
85
+ var flatSize = indexBuffer.getFlatSize();
115
86
 
116
- if (!cellArray.getData() || !cellArray.getData().length) {
87
+ if (!flatSize) {
117
88
  return result;
118
89
  } // setup shift and scale
119
90
 
@@ -139,130 +110,56 @@ function packArray(cellArray, primType, representation, inArray, outputType, opt
139
110
  }
140
111
 
141
112
  var packExtra = Object.prototype.hasOwnProperty.call(options, 'packExtra') ? options.packExtra : false;
142
- var pointData = inArray.getData();
143
113
  var addAPoint;
144
- var cellBuilders = {
145
- // easy, every input point becomes an output point
146
- anythingToPoints: function anythingToPoints(numPoints, cellPts, offset, cellId) {
147
- for (var i = 0; i < numPoints; ++i) {
148
- addAPoint(cellPts[offset + i], cellId);
149
- }
150
- },
151
- linesToWireframe: function linesToWireframe(numPoints, cellPts, offset, cellId) {
152
- // for lines we add a bunch of segments
153
- for (var i = 0; i < numPoints - 1; ++i) {
154
- addAPoint(cellPts[offset + i], cellId);
155
- addAPoint(cellPts[offset + i + 1], cellId);
156
- }
157
- },
158
- polysToWireframe: function polysToWireframe(numPoints, cellPts, offset, cellId) {
159
- // for polys we add a bunch of segments and close it
160
- if (numPoints > 2) {
161
- for (var i = 0; i < numPoints; ++i) {
162
- addAPoint(cellPts[offset + i], cellId);
163
- addAPoint(cellPts[offset + (i + 1) % numPoints], cellId);
164
- }
165
- }
166
- },
167
- stripsToWireframe: function stripsToWireframe(numPoints, cellPts, offset, cellId) {
168
- if (numPoints > 2) {
169
- // for strips we add a bunch of segments and close it
170
- for (var i = 0; i < numPoints - 1; ++i) {
171
- addAPoint(cellPts[offset + i], cellId);
172
- addAPoint(cellPts[offset + i + 1], cellId);
173
- }
174
-
175
- for (var _i = 0; _i < numPoints - 2; _i++) {
176
- addAPoint(cellPts[offset + _i], cellId);
177
- addAPoint(cellPts[offset + _i + 2], cellId);
178
- }
179
- }
180
- },
181
- polysToSurface: function polysToSurface(npts, cellPts, offset, cellId) {
182
- for (var i = 0; i < npts - 2; i++) {
183
- addAPoint(cellPts[offset + 0], cellId);
184
- addAPoint(cellPts[offset + i + 1], cellId);
185
- addAPoint(cellPts[offset + i + 2], cellId);
186
- }
187
- },
188
- stripsToSurface: function stripsToSurface(npts, cellPts, offset, cellId) {
189
- for (var i = 0; i < npts - 2; i++) {
190
- addAPoint(cellPts[offset + i], cellId);
191
- addAPoint(cellPts[offset + i + 1 + i % 2], cellId);
192
- addAPoint(cellPts[offset + i + 1 + (i + 1) % 2], cellId);
193
- }
194
- }
195
- };
196
- var inRepName = getPrimitiveName(primType);
197
- var func = null;
198
-
199
- if (representation === Representation.POINTS || primType === PrimitiveTypes.Points) {
200
- func = cellBuilders.anythingToPoints;
201
- } else if (representation === Representation.WIREFRAME || primType === PrimitiveTypes.Lines) {
202
- func = cellBuilders["".concat(inRepName, "ToWireframe")];
203
- } else {
204
- func = cellBuilders["".concat(inRepName, "ToSurface")];
205
- }
206
-
207
- var array = cellArray.getData();
208
- var size = array.length;
209
- var caboCount = getOutputSize(cellArray, representation, inRepName);
210
114
  var vboidx = 0;
211
- var numComp = inArray.getNumberOfComponents();
212
- var packedVBO = newTypedArray(outputType, caboCount * (numComp + (packExtra ? 1 : 0))); // pick the right function based on point versus cell data
115
+ var stride = numComp + (packExtra ? 1 : 0);
116
+ var packedVBO = newTypedArray(outputType, flatSize * stride); // pick the right function based on point versus cell data
213
117
 
214
- var getData = function getData(ptId, cellId) {
215
- return pointData[ptId];
216
- };
118
+ var flatIdMap = indexBuffer.getFlatIdToPointId();
217
119
 
218
120
  if (options.cellData) {
219
- getData = function getData(ptId, cellId) {
220
- return pointData[cellId];
221
- };
121
+ flatIdMap = indexBuffer.getFlatIdToCellId();
222
122
  } // add data based on number of components
223
123
 
224
124
 
225
125
  if (numComp === 1) {
226
- addAPoint = function addAPointFunc(i, cellid) {
227
- packedVBO[vboidx++] = scale[0] * getData(i, cellid) + shift[0];
126
+ addAPoint = function addAPointFunc(i) {
127
+ packedVBO[vboidx++] = scale[0] * inArrayData[i] + shift[0];
228
128
  };
229
129
  } else if (numComp === 2) {
230
- addAPoint = function addAPointFunc(i, cellid) {
231
- packedVBO[vboidx++] = scale[0] * getData(i * 2, cellid * 2) + shift[0];
232
- packedVBO[vboidx++] = scale[1] * getData(i * 2 + 1, cellid * 2 + 1) + shift[1];
130
+ addAPoint = function addAPointFunc(i) {
131
+ packedVBO[vboidx++] = scale[0] * inArrayData[i] + shift[0];
132
+ packedVBO[vboidx++] = scale[1] * inArrayData[i + 1] + shift[1];
233
133
  };
234
134
  } else if (numComp === 3 && !packExtra) {
235
- addAPoint = function addAPointFunc(i, cellid) {
236
- packedVBO[vboidx++] = scale[0] * getData(i * 3, cellid * 3) + shift[0];
237
- packedVBO[vboidx++] = scale[1] * getData(i * 3 + 1, cellid * 3 + 1) + shift[1];
238
- packedVBO[vboidx++] = scale[2] * getData(i * 3 + 2, cellid * 3 + 2) + shift[2];
135
+ addAPoint = function addAPointFunc(i) {
136
+ packedVBO[vboidx++] = scale[0] * inArrayData[i] + shift[0];
137
+ packedVBO[vboidx++] = scale[1] * inArrayData[i + 1] + shift[1];
138
+ packedVBO[vboidx++] = scale[2] * inArrayData[i + 2] + shift[2];
239
139
  };
240
140
  } else if (numComp === 3 && packExtra) {
241
- addAPoint = function addAPointFunc(i, cellid) {
242
- packedVBO[vboidx++] = scale[0] * getData(i * 3, cellid * 3) + shift[0];
243
- packedVBO[vboidx++] = scale[1] * getData(i * 3 + 1, cellid * 3 + 1) + shift[1];
244
- packedVBO[vboidx++] = scale[2] * getData(i * 3 + 2, cellid * 3 + 2) + shift[2];
141
+ addAPoint = function addAPointFunc(i) {
142
+ packedVBO[vboidx++] = scale[0] * inArrayData[i] + shift[0];
143
+ packedVBO[vboidx++] = scale[1] * inArrayData[i + 1] + shift[1];
144
+ packedVBO[vboidx++] = scale[2] * inArrayData[i + 2] + shift[2];
245
145
  packedVBO[vboidx++] = scale[3] * 1.0 + shift[3];
246
146
  };
247
147
  } else if (numComp === 4) {
248
- addAPoint = function addAPointFunc(i, cellid) {
249
- packedVBO[vboidx++] = scale[0] * getData(i * 4, cellid * 4) + shift[0];
250
- packedVBO[vboidx++] = scale[1] * getData(i * 4 + 1, cellid * 4 + 1) + shift[1];
251
- packedVBO[vboidx++] = scale[2] * getData(i * 4 + 2, cellid * 4 + 2) + shift[2];
252
- packedVBO[vboidx++] = scale[3] * getData(i * 4 + 3, cellid * 4 + 3) + shift[3];
148
+ addAPoint = function addAPointFunc(i) {
149
+ packedVBO[vboidx++] = scale[0] * inArrayData[i] + shift[0];
150
+ packedVBO[vboidx++] = scale[1] * inArrayData[i + 1] + shift[1];
151
+ packedVBO[vboidx++] = scale[2] * inArrayData[i + 2] + shift[2];
152
+ packedVBO[vboidx++] = scale[3] * inArrayData[i + 3] + shift[3];
253
153
  };
254
- }
154
+ } // for each entry in the flat array process it
255
155
 
256
- var cellId = options.cellOffset;
257
156
 
258
- for (var index = 0; index < size;) {
259
- func(array[index], array, index + 1, cellId);
260
- index += array[index] + 1;
261
- cellId++;
157
+ for (var index = 0; index < flatSize; index++) {
158
+ var inArrayId = numComp * flatIdMap[index];
159
+ addAPoint(inArrayId);
262
160
  }
263
161
 
264
162
  result.nativeArray = packedVBO;
265
- result.elementCount = caboCount;
266
163
  return result;
267
164
  }
268
165
 
@@ -275,75 +172,26 @@ function getNormal(pointData, i0, i1, i2) {
275
172
  return result;
276
173
  }
277
174
 
278
- function generateNormals(cellArray, primType, representation, inArray) {
279
- if (!cellArray.getData() || !cellArray.getData().length) {
280
- return null;
281
- }
175
+ function generateNormals(cellArray, pointArray) {
176
+ var pointData = pointArray.getData();
177
+ var cellArrayData = cellArray.getData();
282
178
 
283
- var pointData = inArray.getData();
284
- var addAPoint;
285
- var cellBuilders = {
286
- polysToPoints: function polysToPoints(numPoints, cellPts, offset) {
287
- var normal = getNormal(pointData, cellPts[offset], cellPts[offset + 1], cellPts[offset + 2]);
179
+ if (!cellArrayData || !pointData) {
180
+ return null;
181
+ } // return a cellArray of normals
288
182
 
289
- for (var i = 0; i < numPoints; ++i) {
290
- addAPoint(normal);
291
- }
292
- },
293
- polysToWireframe: function polysToWireframe(numPoints, cellPts, offset) {
294
- // for polys we add a bunch of segments and close it
295
- // compute the normal
296
- var normal = getNormal(pointData, cellPts[offset], cellPts[offset + 1], cellPts[offset + 2]);
297
-
298
- for (var i = 0; i < numPoints; ++i) {
299
- addAPoint(normal);
300
- addAPoint(normal);
301
- }
302
- },
303
- polysToSurface: function polysToSurface(npts, cellPts, offset) {
304
- if (npts < 3) {
305
- // ignore degenerate triangles
306
- vtkDebugMacro('skipping degenerate triangle');
307
- } else {
308
- // compute the normal
309
- var normal = getNormal(pointData, cellPts[offset], cellPts[offset + 1], cellPts[offset + 2]);
310
-
311
- for (var i = 0; i < npts - 2; i++) {
312
- addAPoint(normal);
313
- addAPoint(normal);
314
- addAPoint(normal);
315
- }
316
- }
317
- }
318
- };
319
- var primName = getPrimitiveName(primType);
320
- var func = null;
321
-
322
- if (representation === Representation.POINTS) {
323
- func = cellBuilders["".concat(primName, "ToPoints")];
324
- } else if (representation === Representation.WIREFRAME) {
325
- func = cellBuilders["".concat(primName, "ToWireframe")];
326
- } else {
327
- func = cellBuilders["".concat(primName, "ToSurface")];
328
- }
329
183
 
330
- var caboCount = getOutputSize(cellArray, representation, primName);
184
+ var packedVBO = new Int8Array(cellArray.getNumberOfCells() * 4);
185
+ var size = cellArrayData.length;
331
186
  var vboidx = 0;
332
- var packedVBO = new Int8Array(caboCount * 4);
333
187
 
334
- addAPoint = function addAPointFunc(normal) {
188
+ for (var index = 0; index < size;) {
189
+ var normal = getNormal(pointData, cellArrayData[index + 1], cellArrayData[index + 2], cellArrayData[index + 3]);
335
190
  packedVBO[vboidx++] = 127 * normal[0];
336
191
  packedVBO[vboidx++] = 127 * normal[1];
337
192
  packedVBO[vboidx++] = 127 * normal[2];
338
193
  packedVBO[vboidx++] = 127;
339
- };
340
-
341
- var array = cellArray.getData();
342
- var size = array.length;
343
-
344
- for (var index = 0; index < size;) {
345
- func(array[index], array, index + 1);
346
- index += array[index] + 1;
194
+ index += cellArrayData[index] + 1;
347
195
  }
348
196
 
349
197
  return packedVBO;
@@ -360,14 +208,37 @@ function vtkWebGPUBufferManager(publicAPI, model) {
360
208
  // if a dataArray is provided set the nativeArray
361
209
  if (req.dataArray && !req.nativeArray) {
362
210
  req.nativeArray = req.dataArray.getData();
363
- } // create one
211
+ }
212
+
213
+ var buffer;
214
+ var gpuUsage; // handle index buffers
215
+
216
+ if (req.usage === BufferUsage.Index) {
217
+ // todo change to FlattenedIndex to be more clear
218
+ buffer = vtkWebGPUIndexBuffer.newInstance({
219
+ label: req.label
220
+ });
221
+ buffer.setDevice(model.device);
222
+ /* eslint-disable no-bitwise */
223
+
224
+ gpuUsage = GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST;
225
+ /* eslint-enable no-bitwise */
226
+
227
+ buffer.buildIndexBuffer(req);
228
+ buffer.createAndWrite(req.nativeArray, gpuUsage);
229
+ buffer.setArrayInformation([{
230
+ format: req.format
231
+ }]);
232
+ } // create one if not done already
364
233
 
365
234
 
366
- var buffer = vtkWebGPUBuffer.newInstance({
367
- label: req.label
368
- });
369
- buffer.setDevice(model.device);
370
- var gpuUsage = null; // handle uniform buffers
235
+ if (!buffer) {
236
+ buffer = vtkWebGPUBuffer.newInstance({
237
+ label: req.label
238
+ });
239
+ buffer.setDevice(model.device);
240
+ } // handle uniform buffers
241
+
371
242
 
372
243
  if (req.usage === BufferUsage.UniformArray) {
373
244
  /* eslint-disable no-bitwise */
@@ -401,7 +272,7 @@ function vtkWebGPUBufferManager(publicAPI, model) {
401
272
  if (req.usage === BufferUsage.PointArray) {
402
273
  gpuUsage = GPUBufferUsage.VERTEX;
403
274
  var arrayType = vtkWebGPUTypes.getNativeTypeFromBufferFormat(req.format);
404
- var result = packArray(req.cells, req.primitiveType, req.representation, req.dataArray, arrayType, {
275
+ var result = packArray(req.indexBuffer, req.dataArray.getData(), req.dataArray.getNumberOfComponents(), arrayType, {
405
276
  packExtra: req.packExtra,
406
277
  shift: req.shift,
407
278
  scale: req.scale,
@@ -412,19 +283,29 @@ function vtkWebGPUBufferManager(publicAPI, model) {
412
283
  buffer.setStrideInBytes(vtkWebGPUTypes.getByteStrideFromBufferFormat(req.format));
413
284
  buffer.setArrayInformation([{
414
285
  offset: 0,
415
- format: req.format
286
+ format: req.format,
287
+ interpolation: req.cellData ? 'flat' : 'perspective'
416
288
  }]);
417
289
  } // handle normals from points, snorm8x4
418
290
 
419
291
 
420
292
  if (req.usage === BufferUsage.NormalsFromPoints) {
421
293
  gpuUsage = GPUBufferUsage.VERTEX;
422
- var normals = generateNormals(req.cells, req.primitiveType, req.representation, req.dataArray);
423
- buffer.createAndWrite(normals, gpuUsage);
294
+
295
+ var _arrayType = vtkWebGPUTypes.getNativeTypeFromBufferFormat(req.format);
296
+
297
+ var normals = generateNormals(req.cells, req.dataArray);
298
+
299
+ var _result = packArray(req.indexBuffer, normals, 4, _arrayType, {
300
+ cellData: true
301
+ });
302
+
303
+ buffer.createAndWrite(_result.nativeArray, gpuUsage);
424
304
  buffer.setStrideInBytes(vtkWebGPUTypes.getByteStrideFromBufferFormat(req.format));
425
305
  buffer.setArrayInformation([{
426
306
  offset: 0,
427
- format: req.format
307
+ format: req.format,
308
+ interpolation: 'flat'
428
309
  }]);
429
310
  }
430
311
 
@@ -443,27 +324,32 @@ function vtkWebGPUBufferManager(publicAPI, model) {
443
324
  } // is the buffer already present?
444
325
 
445
326
 
446
- publicAPI.hasBuffer = function (req) {
447
- if (req.owner) {
448
- // if a matching buffer already exists then return true
449
- var hash = req.time + req.format + req.usage + req.hash;
450
- return model.device.hasCachedObject(req.owner, hash);
451
- }
452
-
453
- return false;
327
+ publicAPI.hasBuffer = function (hash) {
328
+ return model.device.hasCachedObject(hash);
454
329
  };
455
330
 
456
331
  publicAPI.getBuffer = function (req) {
457
332
  // if we have a source the get/create/cache the buffer
458
- if (req.owner) {
459
- // if a matching buffer already exists then return it
460
- var hash = req.time + req.format + req.usage + req.hash;
461
- return model.device.getCachedObject(req.owner, hash, _createBuffer, req);
333
+ if (req.hash) {
334
+ return model.device.getCachedObject(req.hash, _createBuffer, req);
462
335
  }
463
336
 
464
337
  return _createBuffer(req);
465
338
  };
466
339
 
340
+ publicAPI.getBufferForPointArray = function (dataArray, indexBuffer) {
341
+ var format = _getFormatForDataArray(dataArray);
342
+
343
+ var buffRequest = {
344
+ hash: "".concat(dataArray.getMTime(), "I").concat(indexBuffer.getMTime()).concat(format),
345
+ usage: BufferUsage.PointArray,
346
+ format: format,
347
+ dataArray: dataArray,
348
+ indexBuffer: indexBuffer
349
+ };
350
+ return publicAPI.getBuffer(buffRequest);
351
+ };
352
+
467
353
  publicAPI.getFullScreenQuadBuffer = function () {
468
354
  if (model.fullScreenQuadBuffer) {
469
355
  return model.fullScreenQuadBuffer;