@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.
- package/Common/Core/CellArray.js +14 -3
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/Triangle.js +1 -1
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/Core/PolyDataNormals.js +1 -1
- package/Filters/General/OBBTree.js +1 -1
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/Sources/CircleSource.js +1 -1
- package/Filters/Sources/PointSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleTrackballCamera.js +1 -1
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/Mapper.js +2 -2
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +1 -1
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +5 -3
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Rendering/WebGPU/BindGroup.js +1 -1
- package/Rendering/WebGPU/BufferManager/Constants.js +1 -1
- package/Rendering/WebGPU/BufferManager.js +149 -263
- package/Rendering/WebGPU/CellArrayMapper.js +46 -73
- package/Rendering/WebGPU/Device.js +97 -57
- package/Rendering/WebGPU/Glyph3DMapper.js +2 -0
- package/Rendering/WebGPU/ImageMapper.js +1 -5
- package/Rendering/WebGPU/IndexBuffer.js +397 -0
- package/Rendering/WebGPU/RenderEncoder.js +1 -1
- package/Rendering/WebGPU/SimpleMapper.js +7 -1
- package/Rendering/WebGPU/SphereMapper.js +29 -31
- package/Rendering/WebGPU/StickMapper.js +38 -42
- package/Rendering/WebGPU/StorageBuffer.js +0 -1
- package/Rendering/WebGPU/Texture.js +0 -2
- package/Rendering/WebGPU/TextureManager.js +37 -7
- package/Rendering/WebGPU/UniformBuffer.js +0 -1
- package/Rendering/WebGPU/VertexInput.js +7 -2
- package/Rendering/WebGPU/VolumePass.js +16 -8
- package/Rendering/WebGPU/VolumePassFSQ.js +1 -5
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/index.d.ts +2 -2
- 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,
|
|
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
|
-
|
|
14
|
-
var
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return numPoints * 4 - 6;
|
|
45
|
-
}
|
|
27
|
+
switch (dataArray.getDataType()) {
|
|
28
|
+
case VtkDataTypes.UNSIGNED_CHAR:
|
|
29
|
+
format = 'uint8';
|
|
30
|
+
break;
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (npts > 2) {
|
|
51
|
-
return (npts - 2) * 3;
|
|
52
|
-
}
|
|
32
|
+
case VtkDataTypes.FLOAT:
|
|
33
|
+
format = 'float32';
|
|
34
|
+
break;
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (numPoints > 2) {
|
|
58
|
-
return (npts - 2) * 3;
|
|
59
|
-
}
|
|
36
|
+
case VtkDataTypes.UNSIGNED_INT:
|
|
37
|
+
format = 'uint32';
|
|
38
|
+
break;
|
|
60
39
|
|
|
61
|
-
|
|
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
|
|
71
|
-
|
|
44
|
+
case VtkDataTypes.DOUBLE:
|
|
45
|
+
format = 'float32';
|
|
46
|
+
break;
|
|
72
47
|
|
|
73
|
-
case
|
|
74
|
-
|
|
75
|
-
|
|
48
|
+
case VtkDataTypes.UNSIGNED_SHORT:
|
|
49
|
+
format = 'uint16';
|
|
50
|
+
break;
|
|
76
51
|
|
|
77
|
-
case
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
case VtkDataTypes.SHORT:
|
|
53
|
+
format = 'sin16';
|
|
54
|
+
break;
|
|
80
55
|
|
|
81
56
|
default:
|
|
82
|
-
|
|
57
|
+
format = 'float32';
|
|
58
|
+
break;
|
|
83
59
|
}
|
|
84
|
-
}
|
|
85
60
|
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
switch (dataArray.getNumberOfComponents()) {
|
|
62
|
+
case 2:
|
|
63
|
+
format += 'x2';
|
|
64
|
+
break;
|
|
88
65
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
var caboCount = 0;
|
|
72
|
+
format += 'x3';
|
|
73
|
+
break;
|
|
100
74
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
75
|
+
case 4:
|
|
76
|
+
format += 'x4';
|
|
77
|
+
break;
|
|
104
78
|
}
|
|
105
79
|
|
|
106
|
-
return
|
|
80
|
+
return format;
|
|
107
81
|
}
|
|
108
82
|
|
|
109
|
-
function packArray(
|
|
110
|
-
var result = {
|
|
111
|
-
|
|
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 (!
|
|
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
|
|
212
|
-
var packedVBO = newTypedArray(outputType,
|
|
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
|
|
215
|
-
return pointData[ptId];
|
|
216
|
-
};
|
|
118
|
+
var flatIdMap = indexBuffer.getFlatIdToPointId();
|
|
217
119
|
|
|
218
120
|
if (options.cellData) {
|
|
219
|
-
|
|
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
|
|
227
|
-
packedVBO[vboidx++] = scale[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
|
|
231
|
-
packedVBO[vboidx++] = scale[0] *
|
|
232
|
-
packedVBO[vboidx++] = scale[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
|
|
236
|
-
packedVBO[vboidx++] = scale[0] *
|
|
237
|
-
packedVBO[vboidx++] = scale[1] *
|
|
238
|
-
packedVBO[vboidx++] = scale[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
|
|
242
|
-
packedVBO[vboidx++] = scale[0] *
|
|
243
|
-
packedVBO[vboidx++] = scale[1] *
|
|
244
|
-
packedVBO[vboidx++] = scale[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
|
|
249
|
-
packedVBO[vboidx++] = scale[0] *
|
|
250
|
-
packedVBO[vboidx++] = scale[1] *
|
|
251
|
-
packedVBO[vboidx++] = scale[2] *
|
|
252
|
-
packedVBO[vboidx++] = scale[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 <
|
|
259
|
-
|
|
260
|
-
|
|
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,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
175
|
+
function generateNormals(cellArray, pointArray) {
|
|
176
|
+
var pointData = pointArray.getData();
|
|
177
|
+
var cellArrayData = cellArray.getData();
|
|
282
178
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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.
|
|
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
|
-
|
|
423
|
-
|
|
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 (
|
|
447
|
-
|
|
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.
|
|
459
|
-
|
|
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;
|