@kitware/vtk.js 33.0.0-beta.4 → 33.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +4 -1
- package/Rendering/Core/RenderWindowInteractor.d.ts +6 -0
- package/Rendering/Core/RenderWindowInteractor.js +7 -5
- package/Rendering/OpenGL/Framebuffer.js +7 -1
- package/Rendering/OpenGL/ImageCPRMapper.js +42 -6
- package/Rendering/OpenGL/ImageMapper.js +44 -6
- package/Rendering/OpenGL/ImageResliceMapper.js +41 -6
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +20 -3
- package/Rendering/OpenGL/PolyDataMapper.js +7 -1
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +7 -1
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +20 -3
- package/Rendering/OpenGL/Texture.d.ts +110 -62
- package/Rendering/OpenGL/Texture.js +145 -37
- package/Rendering/OpenGL/VolumeMapper.js +49 -7
- package/macros.js +1 -1
- package/macros2.js +7 -2
- package/package.json +1 -1
package/BREAKING_CHANGES.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
## From
|
|
1
|
+
## From 33.x to 34
|
|
2
2
|
|
|
3
3
|
- **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
|
|
4
|
+
- **vtkRenderWindowInteractor**: KeyPress, KeyDown and KeyUp events are now observed on the container and no longer on the document. "tabIndex=0" is now automatically added on RWI containers to give focus on your render windows and catch key events. Check the KeyPressEvents example for usage.
|
|
5
|
+
- **vtkOpenGLTexture**: The public `create2D*` and `create3D*` methods used to have positional parameters. These methods now use named parameters via passing in an object record.
|
|
6
|
+
|
|
4
7
|
## From 31.x to 32
|
|
5
8
|
|
|
6
9
|
- **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.
|
|
@@ -974,6 +974,12 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
974
974
|
/**
|
|
975
975
|
* Add an HTMLElement as the new container for the interactor.
|
|
976
976
|
* All events will be bound to this new container.
|
|
977
|
+
*
|
|
978
|
+
* container will gain the tabIndex=0 attribute to catch keyboard events.
|
|
979
|
+
* container must have focus (manually via click or tab, or programmatically
|
|
980
|
+
* via `.focus()`) to receive keypress events
|
|
981
|
+
* Outline on focus can be customized with CSS :focus pseudo-class.
|
|
982
|
+
*
|
|
977
983
|
* Any old container will be removed along with its listeners.
|
|
978
984
|
*/
|
|
979
985
|
setContainer(container: Nullable<HTMLElement>): boolean;
|
|
@@ -186,11 +186,13 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
186
186
|
});
|
|
187
187
|
container.addEventListener('pointerup', publicAPI.handlePointerUp);
|
|
188
188
|
container.addEventListener('pointercancel', publicAPI.handlePointerCancel);
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
container.addEventListener('keypress', publicAPI.handleKeyPress);
|
|
190
|
+
container.addEventListener('keydown', publicAPI.handleKeyDown);
|
|
191
|
+
// Observe keyup on document in case the focus changes
|
|
192
|
+
// between keydown and keyup.
|
|
191
193
|
document.addEventListener('keyup', publicAPI.handleKeyUp);
|
|
192
194
|
document.addEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
|
|
193
|
-
|
|
195
|
+
container.tabIndex = 0; // to receive key events
|
|
194
196
|
// using touchAction is more performant than preventDefault
|
|
195
197
|
// in a touchstart handler.
|
|
196
198
|
container.style.touchAction = 'none';
|
|
@@ -235,8 +237,8 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
235
237
|
container.removeEventListener('pointerup', publicAPI.handlePointerUp);
|
|
236
238
|
container.removeEventListener('pointercancel', publicAPI.handlePointerCancel);
|
|
237
239
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
container.removeEventListener('keypress', publicAPI.handleKeyPress);
|
|
241
|
+
container.removeEventListener('keydown', publicAPI.handleKeyDown);
|
|
240
242
|
document.removeEventListener('keyup', publicAPI.handleKeyUp);
|
|
241
243
|
document.removeEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
|
|
242
244
|
pointerCache.clear();
|
|
@@ -162,7 +162,13 @@ function vtkFramebuffer(publicAPI, model) {
|
|
|
162
162
|
texture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
163
163
|
texture.setMinificationFilter(Filter.LINEAR);
|
|
164
164
|
texture.setMagnificationFilter(Filter.LINEAR);
|
|
165
|
-
texture.create2DFromRaw(
|
|
165
|
+
texture.create2DFromRaw({
|
|
166
|
+
width: model.glFramebuffer.width,
|
|
167
|
+
height: model.glFramebuffer.height,
|
|
168
|
+
numComps: 4,
|
|
169
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
170
|
+
data: null
|
|
171
|
+
});
|
|
166
172
|
publicAPI.setColorBuffer(texture);
|
|
167
173
|
|
|
168
174
|
// for now do not count on having a depth buffer texture
|
|
@@ -167,7 +167,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
167
167
|
// Use norm16 for scalar texture if the extension is available
|
|
168
168
|
model.volumeTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
169
169
|
model.volumeTexture.resetFormatAndType();
|
|
170
|
-
model.volumeTexture.create3DFilterableFromDataArray(
|
|
170
|
+
model.volumeTexture.create3DFilterableFromDataArray({
|
|
171
|
+
width: dims[0],
|
|
172
|
+
height: dims[1],
|
|
173
|
+
depth: dims[2],
|
|
174
|
+
dataArray: scalars,
|
|
175
|
+
preferSizeOverAccuracy: model.renderable.getPreferSizeOverAccuracy()
|
|
176
|
+
});
|
|
171
177
|
model._openGLRenderWindow.setGraphicsResourceForObject(scalars, model.volumeTexture, volumeTextureHash);
|
|
172
178
|
if (scalars !== model._scalars) {
|
|
173
179
|
model._openGLRenderWindow.registerGraphicsResourceUser(scalars, publicAPI);
|
|
@@ -182,7 +188,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
182
188
|
// clear the array to acknowledge the update.
|
|
183
189
|
property.setUpdatedExtents([]);
|
|
184
190
|
const dims = image.getDimensions();
|
|
185
|
-
model.volumeTexture.create3DFilterableFromDataArray(
|
|
191
|
+
model.volumeTexture.create3DFilterableFromDataArray({
|
|
192
|
+
width: dims[0],
|
|
193
|
+
height: dims[1],
|
|
194
|
+
depth: dims[2],
|
|
195
|
+
dataArray: scalars,
|
|
196
|
+
updatedExtents
|
|
197
|
+
});
|
|
186
198
|
}
|
|
187
199
|
|
|
188
200
|
// Rebuild the color texture if needed
|
|
@@ -226,7 +238,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
226
238
|
}
|
|
227
239
|
}
|
|
228
240
|
model.colorTexture.resetFormatAndType();
|
|
229
|
-
model.colorTexture.create2DFromRaw(
|
|
241
|
+
model.colorTexture.create2DFromRaw({
|
|
242
|
+
width: cWidth,
|
|
243
|
+
height: textureHeight,
|
|
244
|
+
numComps: 3,
|
|
245
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
246
|
+
data: cTable
|
|
247
|
+
});
|
|
230
248
|
} else {
|
|
231
249
|
for (let i = 0; i < cWidth * 3; ++i) {
|
|
232
250
|
cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
|
|
@@ -234,7 +252,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
234
252
|
cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
|
|
235
253
|
}
|
|
236
254
|
model.colorTexture.resetFormatAndType();
|
|
237
|
-
model.colorTexture.create2DFromRaw(
|
|
255
|
+
model.colorTexture.create2DFromRaw({
|
|
256
|
+
width: cWidth,
|
|
257
|
+
height: 1,
|
|
258
|
+
numComps: 3,
|
|
259
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
260
|
+
data: cTable
|
|
261
|
+
});
|
|
238
262
|
}
|
|
239
263
|
if (firstColorTransferFunc) {
|
|
240
264
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, colorTextureHash);
|
|
@@ -293,12 +317,24 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
293
317
|
}
|
|
294
318
|
}
|
|
295
319
|
model.pwfTexture.resetFormatAndType();
|
|
296
|
-
model.pwfTexture.create2DFromRaw(
|
|
320
|
+
model.pwfTexture.create2DFromRaw({
|
|
321
|
+
width: pwfWidth,
|
|
322
|
+
height: textureHeight,
|
|
323
|
+
numComps: 1,
|
|
324
|
+
dataType: VtkDataTypes.FLOAT,
|
|
325
|
+
data: pwfFloatTable
|
|
326
|
+
});
|
|
297
327
|
} else {
|
|
298
328
|
// default is opaque
|
|
299
329
|
pwfTable.fill(255.0);
|
|
300
330
|
model.pwfTexture.resetFormatAndType();
|
|
301
|
-
model.pwfTexture.create2DFromRaw(
|
|
331
|
+
model.pwfTexture.create2DFromRaw({
|
|
332
|
+
width: pwfWidth,
|
|
333
|
+
height: 1,
|
|
334
|
+
numComps: 1,
|
|
335
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
336
|
+
data: pwfTable
|
|
337
|
+
});
|
|
302
338
|
}
|
|
303
339
|
if (firstPwFunc) {
|
|
304
340
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfTextureHash);
|
|
@@ -622,14 +622,26 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
model.colorTexture.resetFormatAndType();
|
|
625
|
-
model.colorTexture.create2DFromRaw(
|
|
625
|
+
model.colorTexture.create2DFromRaw({
|
|
626
|
+
width: cWidth,
|
|
627
|
+
height: textureHeight,
|
|
628
|
+
numComps: 3,
|
|
629
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
630
|
+
data: cTable
|
|
631
|
+
});
|
|
626
632
|
} else {
|
|
627
633
|
for (let i = 0; i < cWidth * 3; ++i) {
|
|
628
634
|
cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
|
|
629
635
|
cTable[i + 1] = 255.0 * i / ((cWidth - 1) * 3);
|
|
630
636
|
cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
|
|
631
637
|
}
|
|
632
|
-
model.colorTexture.create2DFromRaw(
|
|
638
|
+
model.colorTexture.create2DFromRaw({
|
|
639
|
+
width: cWidth,
|
|
640
|
+
height: 1,
|
|
641
|
+
numComps: 3,
|
|
642
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
643
|
+
data: cTable
|
|
644
|
+
});
|
|
633
645
|
}
|
|
634
646
|
if (firstColorTransferFunc) {
|
|
635
647
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, cfunToString);
|
|
@@ -699,11 +711,23 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
699
711
|
}
|
|
700
712
|
}
|
|
701
713
|
model.pwfTexture.resetFormatAndType();
|
|
702
|
-
model.pwfTexture.create2DFromRaw(
|
|
714
|
+
model.pwfTexture.create2DFromRaw({
|
|
715
|
+
width: pwfWidth,
|
|
716
|
+
height: textureHeight,
|
|
717
|
+
numComps: 1,
|
|
718
|
+
dataType: VtkDataTypes.FLOAT,
|
|
719
|
+
data: pwfFloatTable
|
|
720
|
+
});
|
|
703
721
|
} else {
|
|
704
722
|
// default is opaque
|
|
705
723
|
pwfTable.fill(255.0);
|
|
706
|
-
model.pwfTexture.create2DFromRaw(
|
|
724
|
+
model.pwfTexture.create2DFromRaw({
|
|
725
|
+
width: pwfWidth,
|
|
726
|
+
height: 1,
|
|
727
|
+
numComps: 1,
|
|
728
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
729
|
+
data: pwfTable
|
|
730
|
+
});
|
|
707
731
|
}
|
|
708
732
|
if (firstPwFunc) {
|
|
709
733
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfunToString);
|
|
@@ -887,7 +911,15 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
887
911
|
// Don't share this resource as `scalars` is created in this function
|
|
888
912
|
// so it is impossible to share
|
|
889
913
|
model.openGLTexture.resetFormatAndType();
|
|
890
|
-
model.openGLTexture.create2DFilterableFromRaw(
|
|
914
|
+
model.openGLTexture.create2DFilterableFromRaw({
|
|
915
|
+
width: dims[0],
|
|
916
|
+
height: dims[1],
|
|
917
|
+
numComps: numComp,
|
|
918
|
+
dataType: imgScalars.getDataType(),
|
|
919
|
+
data: scalars,
|
|
920
|
+
preferSizeOverAccuracy: !!model.renderable.getPreferSizeOverAccuracy?.(),
|
|
921
|
+
ranges
|
|
922
|
+
});
|
|
891
923
|
model.openGLTexture.activate();
|
|
892
924
|
model.openGLTexture.sendParameters();
|
|
893
925
|
model.openGLTexture.deactivate();
|
|
@@ -957,7 +989,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
957
989
|
model.labelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
|
|
958
990
|
|
|
959
991
|
// Create a 2D texture (acting as 1D) from the raw data
|
|
960
|
-
model.labelOutlineThicknessTexture.create2DFromRaw(
|
|
992
|
+
model.labelOutlineThicknessTexture.create2DFromRaw({
|
|
993
|
+
width: lWidth,
|
|
994
|
+
height: lHeight,
|
|
995
|
+
numComps: 1,
|
|
996
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
997
|
+
data: lTable
|
|
998
|
+
});
|
|
961
999
|
if (labelOutlineThicknessArray) {
|
|
962
1000
|
model._openGLRenderWindow.setGraphicsResourceForObject(labelOutlineThicknessArray, model.labelOutlineThicknessTexture, toString);
|
|
963
1001
|
if (labelOutlineThicknessArray !== model._labelOutlineThicknessArray) {
|
|
@@ -266,7 +266,12 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
266
266
|
// Use norm16 for scalar texture if the extension is available
|
|
267
267
|
newScalarTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
268
268
|
newScalarTexture.resetFormatAndType();
|
|
269
|
-
newScalarTexture.create3DFilterableFromDataArray(
|
|
269
|
+
newScalarTexture.create3DFilterableFromDataArray({
|
|
270
|
+
width: dims[0],
|
|
271
|
+
height: dims[1],
|
|
272
|
+
depth: dims[2],
|
|
273
|
+
dataArray: scalars
|
|
274
|
+
});
|
|
270
275
|
model._openGLRenderWindow.setGraphicsResourceForObject(scalars, newScalarTexture, scalarsHash);
|
|
271
276
|
model.scalarTextures[component] = newScalarTexture;
|
|
272
277
|
} else {
|
|
@@ -277,7 +282,13 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
277
282
|
// clear the array to acknowledge the update.
|
|
278
283
|
actorProperty.setUpdatedExtents([]);
|
|
279
284
|
const dims = imageData.getDimensions();
|
|
280
|
-
model.scalarTextures[component].create3DFilterableFromDataArray(
|
|
285
|
+
model.scalarTextures[component].create3DFilterableFromDataArray({
|
|
286
|
+
width: dims[0],
|
|
287
|
+
height: dims[1],
|
|
288
|
+
depth: dims[2],
|
|
289
|
+
dataArray: scalars,
|
|
290
|
+
updatedExtents
|
|
291
|
+
});
|
|
281
292
|
}
|
|
282
293
|
replaceGraphicsResource(model._openGLRenderWindow, model._scalarTexturesCore[component], scalars);
|
|
283
294
|
model._scalarTexturesCore[component] = scalars;
|
|
@@ -322,7 +333,13 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
322
333
|
}
|
|
323
334
|
}
|
|
324
335
|
newColorTexture.resetFormatAndType();
|
|
325
|
-
newColorTexture.create2DFromRaw(
|
|
336
|
+
newColorTexture.create2DFromRaw({
|
|
337
|
+
width: cWidth,
|
|
338
|
+
height: textureHeight,
|
|
339
|
+
numComps: 3,
|
|
340
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
341
|
+
data: cTable
|
|
342
|
+
});
|
|
326
343
|
} else {
|
|
327
344
|
for (let column = 0; column < cWidth * 3; ++column) {
|
|
328
345
|
const opacity = 255.0 * column / ((cWidth - 1) * 3);
|
|
@@ -334,7 +351,13 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
334
351
|
}
|
|
335
352
|
}
|
|
336
353
|
newColorTexture.resetFormatAndType();
|
|
337
|
-
newColorTexture.create2DFromRaw(
|
|
354
|
+
newColorTexture.create2DFromRaw({
|
|
355
|
+
width: cWidth,
|
|
356
|
+
height: 1,
|
|
357
|
+
numComps: 3,
|
|
358
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
359
|
+
data: cTable
|
|
360
|
+
});
|
|
338
361
|
}
|
|
339
362
|
if (firstColorTransferFunc) {
|
|
340
363
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, newColorTexture, colorFuncHash);
|
|
@@ -391,12 +414,24 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
391
414
|
}
|
|
392
415
|
}
|
|
393
416
|
newOpacityTexture.resetFormatAndType();
|
|
394
|
-
newOpacityTexture.create2DFromRaw(
|
|
417
|
+
newOpacityTexture.create2DFromRaw({
|
|
418
|
+
width: pwfWidth,
|
|
419
|
+
height: textureHeight,
|
|
420
|
+
numComps: 1,
|
|
421
|
+
dataType: VtkDataTypes.FLOAT,
|
|
422
|
+
data: pwfFloatTable
|
|
423
|
+
});
|
|
395
424
|
} else {
|
|
396
425
|
// default is opaque
|
|
397
426
|
pwfTable.fill(255.0);
|
|
398
427
|
newOpacityTexture.resetFormatAndType();
|
|
399
|
-
newOpacityTexture.create2DFromRaw(
|
|
428
|
+
newOpacityTexture.create2DFromRaw({
|
|
429
|
+
width: pwfWidth,
|
|
430
|
+
height: textureHeight,
|
|
431
|
+
numComps: 1,
|
|
432
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
433
|
+
data: pwfTable
|
|
434
|
+
});
|
|
400
435
|
}
|
|
401
436
|
if (firstPwFunc) {
|
|
402
437
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, newOpacityTexture, opacityFuncHash);
|
|
@@ -91,16 +91,33 @@ function vtkOpenGLOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
91
91
|
model.translucentRGBATexture.setFormat(gl.RGBA);
|
|
92
92
|
model.translucentRGBATexture.setOpenGLDataType(gl.HALF_FLOAT);
|
|
93
93
|
model.translucentRGBATexture.setOpenGLRenderWindow(viewNode);
|
|
94
|
-
model.translucentRGBATexture.create2DFromRaw(
|
|
94
|
+
model.translucentRGBATexture.create2DFromRaw({
|
|
95
|
+
width: size[0],
|
|
96
|
+
height: size[1],
|
|
97
|
+
numComps: 4,
|
|
98
|
+
dataType: 'Float32Array',
|
|
99
|
+
data: null
|
|
100
|
+
});
|
|
95
101
|
model.translucentRTexture = vtkOpenGLTexture.newInstance();
|
|
96
102
|
model.translucentRTexture.setInternalFormat(gl.R16F);
|
|
97
103
|
model.translucentRTexture.setFormat(gl.RED);
|
|
98
104
|
model.translucentRTexture.setOpenGLDataType(gl.HALF_FLOAT);
|
|
99
105
|
model.translucentRTexture.setOpenGLRenderWindow(viewNode);
|
|
100
|
-
model.translucentRTexture.create2DFromRaw(
|
|
106
|
+
model.translucentRTexture.create2DFromRaw({
|
|
107
|
+
width: size[0],
|
|
108
|
+
height: size[1],
|
|
109
|
+
numComps: 1,
|
|
110
|
+
dataType: 'Float32Array',
|
|
111
|
+
data: null
|
|
112
|
+
});
|
|
101
113
|
model.translucentZTexture = vtkOpenGLTexture.newInstance();
|
|
102
114
|
model.translucentZTexture.setOpenGLRenderWindow(viewNode);
|
|
103
|
-
model.translucentZTexture.createDepthFromRaw(
|
|
115
|
+
model.translucentZTexture.createDepthFromRaw({
|
|
116
|
+
width: size[0],
|
|
117
|
+
height: size[1],
|
|
118
|
+
dataType: 'Float32Array',
|
|
119
|
+
data: null
|
|
120
|
+
});
|
|
104
121
|
model.framebuffer.setColorBuffer(model.translucentRGBATexture, 0);
|
|
105
122
|
model.framebuffer.setColorBuffer(model.translucentRTexture, 1);
|
|
106
123
|
model.framebuffer.setDepthBuffer(model.translucentZTexture);
|
|
@@ -1014,7 +1014,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
1014
1014
|
const input = model.renderable.getColorTextureMap();
|
|
1015
1015
|
const ext = input.getExtent();
|
|
1016
1016
|
const inScalars = input.getPointData().getScalars();
|
|
1017
|
-
tex.create2DFromRaw(
|
|
1017
|
+
tex.create2DFromRaw({
|
|
1018
|
+
width: ext[1] - ext[0] + 1,
|
|
1019
|
+
height: ext[3] - ext[2] + 1,
|
|
1020
|
+
numComps: inScalars.getNumberOfComponents(),
|
|
1021
|
+
dataType: inScalars.getDataType(),
|
|
1022
|
+
data: inScalars.getData()
|
|
1023
|
+
});
|
|
1018
1024
|
tex.activate();
|
|
1019
1025
|
tex.sendParameters();
|
|
1020
1026
|
tex.deactivate();
|
|
@@ -64,7 +64,13 @@ function allocateBuffer(openGLRenderWindow, _ref, filter, wrapping) {
|
|
|
64
64
|
});
|
|
65
65
|
texture.setOpenGLRenderWindow(openGLRenderWindow);
|
|
66
66
|
texture.setInternalFormat(gl.RGBA32F);
|
|
67
|
-
texture.create2DFromRaw(
|
|
67
|
+
texture.create2DFromRaw({
|
|
68
|
+
width,
|
|
69
|
+
height,
|
|
70
|
+
numComps: 4,
|
|
71
|
+
dataType: 'Float32Array',
|
|
72
|
+
data: null
|
|
73
|
+
});
|
|
68
74
|
texture.activate();
|
|
69
75
|
texture.sendParameters();
|
|
70
76
|
texture.deactivate();
|
|
@@ -206,7 +206,13 @@ function vtkOpenGLSurfaceLICInterface(publicAPI, model) {
|
|
|
206
206
|
autoParameters: false
|
|
207
207
|
});
|
|
208
208
|
texture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
209
|
-
texture.create2DFromRaw(
|
|
209
|
+
texture.create2DFromRaw({
|
|
210
|
+
width: length,
|
|
211
|
+
height: length,
|
|
212
|
+
numComps: 4,
|
|
213
|
+
dataType: 'Float32Array',
|
|
214
|
+
data: values
|
|
215
|
+
});
|
|
210
216
|
texture.activate();
|
|
211
217
|
texture.sendParameters();
|
|
212
218
|
texture.deactivate();
|
|
@@ -255,7 +261,13 @@ function vtkOpenGLSurfaceLICInterface(publicAPI, model) {
|
|
|
255
261
|
});
|
|
256
262
|
texture.setOpenGLRenderWindow(openGLRenderWindow);
|
|
257
263
|
texture.setInternalFormat(gl.RGBA32F);
|
|
258
|
-
texture.create2DFromRaw(
|
|
264
|
+
texture.create2DFromRaw({
|
|
265
|
+
width: model.size[0],
|
|
266
|
+
height: model.size[1],
|
|
267
|
+
numComps: 4,
|
|
268
|
+
dataType: 'Float32Array',
|
|
269
|
+
data: null
|
|
270
|
+
});
|
|
259
271
|
texture.activate();
|
|
260
272
|
texture.sendParameters();
|
|
261
273
|
texture.deactivate();
|
|
@@ -269,7 +281,12 @@ function vtkOpenGLSurfaceLICInterface(publicAPI, model) {
|
|
|
269
281
|
autoParameters: false
|
|
270
282
|
});
|
|
271
283
|
texture.setOpenGLRenderWindow(openGLRenderWindow);
|
|
272
|
-
texture.createDepthFromRaw(
|
|
284
|
+
texture.createDepthFromRaw({
|
|
285
|
+
width: model.size[0],
|
|
286
|
+
height: model.size[1],
|
|
287
|
+
dataType: 'Float32Array',
|
|
288
|
+
data: null
|
|
289
|
+
});
|
|
273
290
|
texture.activate();
|
|
274
291
|
texture.sendParameters();
|
|
275
292
|
texture.deactivate();
|
|
@@ -199,17 +199,24 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
199
199
|
* @param numComps The number of components in the texture.
|
|
200
200
|
* @param dataType The data type of the texture.
|
|
201
201
|
* @param data The raw data for the texture.
|
|
202
|
-
* @param flip Whether to flip the texture vertically.
|
|
202
|
+
* @param flip Whether to flip the texture vertically. Defaults to false.
|
|
203
203
|
* @returns {boolean} True if the texture was successfully created, false otherwise.
|
|
204
204
|
*/
|
|
205
|
-
create2DFromRaw(
|
|
206
|
-
width
|
|
207
|
-
height
|
|
208
|
-
numComps
|
|
209
|
-
dataType
|
|
210
|
-
data
|
|
211
|
-
flip
|
|
212
|
-
|
|
205
|
+
create2DFromRaw({
|
|
206
|
+
width,
|
|
207
|
+
height,
|
|
208
|
+
numComps,
|
|
209
|
+
dataType,
|
|
210
|
+
data,
|
|
211
|
+
flip,
|
|
212
|
+
}: {
|
|
213
|
+
width: number;
|
|
214
|
+
height: number;
|
|
215
|
+
numComps: number;
|
|
216
|
+
dataType: VtkDataTypes;
|
|
217
|
+
data: any;
|
|
218
|
+
flip?: boolean;
|
|
219
|
+
}): boolean;
|
|
213
220
|
|
|
214
221
|
/**
|
|
215
222
|
* Creates a cube texture from raw data.
|
|
@@ -218,17 +225,21 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
218
225
|
* @param numComps The number of components in the texture.
|
|
219
226
|
* @param dataType The data type of the texture.
|
|
220
227
|
* @param data The raw data for the texture.
|
|
221
|
-
* @param flip Whether to flip the texture vertically.
|
|
222
228
|
* @returns {boolean} True if the cube texture was successfully created, false otherwise.
|
|
223
229
|
*/
|
|
224
|
-
createCubeFromRaw(
|
|
225
|
-
width
|
|
226
|
-
height
|
|
227
|
-
numComps
|
|
228
|
-
dataType
|
|
229
|
-
data
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
createCubeFromRaw({
|
|
231
|
+
width,
|
|
232
|
+
height,
|
|
233
|
+
numComps,
|
|
234
|
+
dataType,
|
|
235
|
+
data,
|
|
236
|
+
}: {
|
|
237
|
+
width: number;
|
|
238
|
+
height: number;
|
|
239
|
+
numComps: number;
|
|
240
|
+
dataType: VtkDataTypes;
|
|
241
|
+
data: any;
|
|
242
|
+
}): boolean;
|
|
232
243
|
|
|
233
244
|
/**
|
|
234
245
|
* Creates a 2D texture from an image.
|
|
@@ -248,15 +259,23 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
248
259
|
* @param [ranges] The precomputed ranges of the data (optional). Provided to prevent computation of the data ranges.
|
|
249
260
|
* @returns {boolean} True if the texture was successfully created, false otherwise.
|
|
250
261
|
*/
|
|
251
|
-
create2DFilterableFromRaw(
|
|
252
|
-
width
|
|
253
|
-
height
|
|
254
|
-
numComps
|
|
255
|
-
dataType
|
|
256
|
-
data
|
|
257
|
-
preferSizeOverAccuracy
|
|
258
|
-
ranges
|
|
259
|
-
|
|
262
|
+
create2DFilterableFromRaw({
|
|
263
|
+
width,
|
|
264
|
+
height,
|
|
265
|
+
numComps,
|
|
266
|
+
dataType,
|
|
267
|
+
data,
|
|
268
|
+
preferSizeOverAccuracy,
|
|
269
|
+
ranges,
|
|
270
|
+
}: {
|
|
271
|
+
width: number;
|
|
272
|
+
height: number;
|
|
273
|
+
numComps: number;
|
|
274
|
+
dataType: VtkDataTypes;
|
|
275
|
+
data: any;
|
|
276
|
+
preferSizeOverAccuracy?: boolean;
|
|
277
|
+
ranges?: vtkRange[];
|
|
278
|
+
}): boolean;
|
|
260
279
|
|
|
261
280
|
/**
|
|
262
281
|
* Creates a 2D filterable texture from a data array, with a preference for size over accuracy if necessary.
|
|
@@ -266,12 +285,17 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
266
285
|
* @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
|
|
267
286
|
* @returns {boolean} True if the texture was successfully created, false otherwise.
|
|
268
287
|
*/
|
|
269
|
-
create2DFilterableFromDataArray(
|
|
270
|
-
width
|
|
271
|
-
height
|
|
272
|
-
dataArray
|
|
273
|
-
preferSizeOverAccuracy
|
|
274
|
-
|
|
288
|
+
create2DFilterableFromDataArray({
|
|
289
|
+
width,
|
|
290
|
+
height,
|
|
291
|
+
dataArray,
|
|
292
|
+
preferSizeOverAccuracy,
|
|
293
|
+
}: {
|
|
294
|
+
width: number;
|
|
295
|
+
height: number;
|
|
296
|
+
dataArray: any;
|
|
297
|
+
preferSizeOverAccuracy?: boolean;
|
|
298
|
+
}): boolean;
|
|
275
299
|
|
|
276
300
|
/**
|
|
277
301
|
* Creates a 3D texture from raw data.
|
|
@@ -287,15 +311,23 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
287
311
|
* @param updatedExtents Only update the specified extents (default: [])
|
|
288
312
|
* @returns {boolean} True if the texture was successfully created, false otherwise.
|
|
289
313
|
*/
|
|
290
|
-
create3DFromRaw(
|
|
291
|
-
width
|
|
292
|
-
height
|
|
293
|
-
depth
|
|
294
|
-
numComps
|
|
295
|
-
dataType
|
|
296
|
-
data
|
|
297
|
-
updatedExtents
|
|
298
|
-
|
|
314
|
+
create3DFromRaw({
|
|
315
|
+
width,
|
|
316
|
+
height,
|
|
317
|
+
depth,
|
|
318
|
+
numComps,
|
|
319
|
+
dataType,
|
|
320
|
+
data,
|
|
321
|
+
updatedExtents,
|
|
322
|
+
}: {
|
|
323
|
+
width: number;
|
|
324
|
+
height: number;
|
|
325
|
+
depth: number;
|
|
326
|
+
numComps: number;
|
|
327
|
+
dataType: VtkDataTypes;
|
|
328
|
+
data: any;
|
|
329
|
+
updatedExtents?: Extent[];
|
|
330
|
+
}): boolean;
|
|
299
331
|
|
|
300
332
|
/**
|
|
301
333
|
* Creates a 3D filterable texture from raw data, with a preference for size over accuracy if necessary.
|
|
@@ -307,7 +339,7 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
307
339
|
* @param depth The depth of the texture.
|
|
308
340
|
* @param numComps The number of components in the texture.
|
|
309
341
|
* @param dataType The data type of the texture.
|
|
310
|
-
* @param
|
|
342
|
+
* @param data The raw data for the texture.
|
|
311
343
|
* @param preferSizeOverAccuracy Whether to prefer texture size over accuracy.
|
|
312
344
|
* @param [ranges] The precomputed ranges of the data (optional). Provided to
|
|
313
345
|
* @param updatedExtents Only update the specified extents (default: [])
|
|
@@ -315,17 +347,27 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
315
347
|
* @returns {boolean} True if the texture was successfully created, false
|
|
316
348
|
* otherwise.
|
|
317
349
|
*/
|
|
318
|
-
create3DFilterableFromRaw(
|
|
319
|
-
width
|
|
320
|
-
height
|
|
321
|
-
depth
|
|
322
|
-
numComps
|
|
323
|
-
dataType
|
|
324
|
-
|
|
325
|
-
preferSizeOverAccuracy
|
|
326
|
-
ranges
|
|
327
|
-
updatedExtents
|
|
328
|
-
|
|
350
|
+
create3DFilterableFromRaw({
|
|
351
|
+
width,
|
|
352
|
+
height,
|
|
353
|
+
depth,
|
|
354
|
+
numComps,
|
|
355
|
+
dataType,
|
|
356
|
+
data,
|
|
357
|
+
preferSizeOverAccuracy,
|
|
358
|
+
ranges,
|
|
359
|
+
updatedExtents,
|
|
360
|
+
}: {
|
|
361
|
+
width: number;
|
|
362
|
+
height: number;
|
|
363
|
+
depth: number;
|
|
364
|
+
numComps: number;
|
|
365
|
+
dataType: VtkDataTypes;
|
|
366
|
+
data: any;
|
|
367
|
+
preferSizeOverAccuracy?: boolean;
|
|
368
|
+
ranges?: vtkRange[];
|
|
369
|
+
updatedExtents?: Extent[];
|
|
370
|
+
}): boolean;
|
|
329
371
|
|
|
330
372
|
/**
|
|
331
373
|
* Creates a 3D filterable texture from a data array, with a preference for size over accuracy if necessary.
|
|
@@ -340,14 +382,20 @@ export interface vtkOpenGLTexture extends vtkViewNode {
|
|
|
340
382
|
* @param updatedExtents Only update the specified extents (default: [])
|
|
341
383
|
* @returns {boolean} True if the texture was successfully created, false otherwise.
|
|
342
384
|
*/
|
|
343
|
-
create3DFilterableFromDataArray(
|
|
344
|
-
width
|
|
345
|
-
height
|
|
346
|
-
depth
|
|
347
|
-
dataArray
|
|
348
|
-
preferSizeOverAccuracy
|
|
349
|
-
|
|
350
|
-
|
|
385
|
+
create3DFilterableFromDataArray({
|
|
386
|
+
width,
|
|
387
|
+
height,
|
|
388
|
+
depth,
|
|
389
|
+
dataArray,
|
|
390
|
+
preferSizeOverAccuracy,
|
|
391
|
+
}: {
|
|
392
|
+
width: number;
|
|
393
|
+
height: number;
|
|
394
|
+
depth: number;
|
|
395
|
+
dataArray: any;
|
|
396
|
+
preferSizeOverAccuracy?: boolean;
|
|
397
|
+
updatedExtents?: Extent[];
|
|
398
|
+
}): boolean;
|
|
351
399
|
|
|
352
400
|
/**
|
|
353
401
|
* Sets the OpenGL render window in which the texture will be used.
|
|
@@ -18,7 +18,8 @@ const {
|
|
|
18
18
|
const {
|
|
19
19
|
vtkDebugMacro,
|
|
20
20
|
vtkErrorMacro,
|
|
21
|
-
vtkWarningMacro
|
|
21
|
+
vtkWarningMacro,
|
|
22
|
+
requiredParam
|
|
22
23
|
} = macro;
|
|
23
24
|
const {
|
|
24
25
|
toHalf
|
|
@@ -95,7 +96,14 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
95
96
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
96
97
|
}
|
|
97
98
|
const canvas = model.renderable.getCanvas();
|
|
98
|
-
publicAPI.create2DFromRaw(
|
|
99
|
+
publicAPI.create2DFromRaw({
|
|
100
|
+
width: canvas.width,
|
|
101
|
+
height: canvas.height,
|
|
102
|
+
numComps: 4,
|
|
103
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
104
|
+
data: canvas,
|
|
105
|
+
flip: true
|
|
106
|
+
});
|
|
99
107
|
publicAPI.activate();
|
|
100
108
|
publicAPI.sendParameters();
|
|
101
109
|
model.textureBuildTime.modified();
|
|
@@ -107,7 +115,14 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
107
115
|
model.generateMipmap = true;
|
|
108
116
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
109
117
|
}
|
|
110
|
-
publicAPI.create2DFromRaw(
|
|
118
|
+
publicAPI.create2DFromRaw({
|
|
119
|
+
width: jsid.width,
|
|
120
|
+
height: jsid.height,
|
|
121
|
+
numComps: 4,
|
|
122
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
123
|
+
data: jsid.data,
|
|
124
|
+
flip: true
|
|
125
|
+
});
|
|
111
126
|
publicAPI.activate();
|
|
112
127
|
publicAPI.sendParameters();
|
|
113
128
|
model.textureBuildTime.modified();
|
|
@@ -132,9 +147,21 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
132
147
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
133
148
|
}
|
|
134
149
|
if (data.length % 6 === 0) {
|
|
135
|
-
publicAPI.createCubeFromRaw(
|
|
150
|
+
publicAPI.createCubeFromRaw({
|
|
151
|
+
width: ext[1] - ext[0] + 1,
|
|
152
|
+
height: ext[3] - ext[2] + 1,
|
|
153
|
+
numComps: inScalars.getNumberOfComponents(),
|
|
154
|
+
dataType: inScalars.getDataType(),
|
|
155
|
+
data
|
|
156
|
+
});
|
|
136
157
|
} else {
|
|
137
|
-
publicAPI.create2DFromRaw(
|
|
158
|
+
publicAPI.create2DFromRaw({
|
|
159
|
+
width: ext[1] - ext[0] + 1,
|
|
160
|
+
height: ext[3] - ext[2] + 1,
|
|
161
|
+
numComps: inScalars.getNumberOfComponents(),
|
|
162
|
+
dataType: inScalars.getDataType(),
|
|
163
|
+
data: inScalars.getData()
|
|
164
|
+
});
|
|
138
165
|
}
|
|
139
166
|
publicAPI.activate();
|
|
140
167
|
publicAPI.sendParameters();
|
|
@@ -786,8 +813,16 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
786
813
|
}
|
|
787
814
|
|
|
788
815
|
//----------------------------------------------------------------------------
|
|
789
|
-
|
|
790
|
-
|
|
816
|
+
|
|
817
|
+
publicAPI.create2DFromRaw = function () {
|
|
818
|
+
let {
|
|
819
|
+
width = requiredParam('width'),
|
|
820
|
+
height = requiredParam('height'),
|
|
821
|
+
numComps = requiredParam('numComps'),
|
|
822
|
+
dataType = requiredParam('dataType'),
|
|
823
|
+
data = requiredParam('data'),
|
|
824
|
+
flip = false
|
|
825
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
791
826
|
// Now determine the texture parameters using the arguments.
|
|
792
827
|
publicAPI.getOpenGLDataType(dataType, true);
|
|
793
828
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
@@ -836,7 +871,14 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
836
871
|
};
|
|
837
872
|
|
|
838
873
|
//----------------------------------------------------------------------------
|
|
839
|
-
publicAPI.createCubeFromRaw = (
|
|
874
|
+
publicAPI.createCubeFromRaw = function () {
|
|
875
|
+
let {
|
|
876
|
+
width = requiredParam('width'),
|
|
877
|
+
height = requiredParam('height'),
|
|
878
|
+
numComps = requiredParam('numComps'),
|
|
879
|
+
dataType = requiredParam('dataType'),
|
|
880
|
+
data = requiredParam('data')
|
|
881
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
840
882
|
// Now determine the texture parameters using the arguments.
|
|
841
883
|
publicAPI.getOpenGLDataType(dataType);
|
|
842
884
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
@@ -917,7 +959,13 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
917
959
|
};
|
|
918
960
|
|
|
919
961
|
//----------------------------------------------------------------------------
|
|
920
|
-
publicAPI.createDepthFromRaw = (
|
|
962
|
+
publicAPI.createDepthFromRaw = function () {
|
|
963
|
+
let {
|
|
964
|
+
width = requiredParam('width'),
|
|
965
|
+
height = requiredParam('height'),
|
|
966
|
+
dataType = requiredParam('dataType'),
|
|
967
|
+
data = requiredParam('data')
|
|
968
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
921
969
|
// Now determine the texture parameters using the arguments.
|
|
922
970
|
publicAPI.getOpenGLDataType(dataType);
|
|
923
971
|
model.format = model.context.DEPTH_COMPONENT;
|
|
@@ -1090,24 +1138,47 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1090
1138
|
scaleOffsets
|
|
1091
1139
|
};
|
|
1092
1140
|
}
|
|
1093
|
-
publicAPI.create2DFilterableFromRaw = function (
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
dataType,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1141
|
+
publicAPI.create2DFilterableFromRaw = function () {
|
|
1142
|
+
let {
|
|
1143
|
+
width = requiredParam('width'),
|
|
1144
|
+
height = requiredParam('height'),
|
|
1145
|
+
numComps = requiredParam('numComps'),
|
|
1146
|
+
dataType = requiredParam('dataType'),
|
|
1147
|
+
data = requiredParam('data'),
|
|
1148
|
+
preferSizeOverAccuracy = false,
|
|
1149
|
+
ranges = undefined
|
|
1150
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1151
|
+
return publicAPI.create2DFilterableFromDataArray({
|
|
1152
|
+
width,
|
|
1153
|
+
height,
|
|
1154
|
+
dataArray: vtkDataArray.newInstance({
|
|
1155
|
+
numComps,
|
|
1156
|
+
dataType,
|
|
1157
|
+
values: data,
|
|
1158
|
+
ranges
|
|
1159
|
+
}),
|
|
1160
|
+
preferSizeOverAccuracy
|
|
1161
|
+
});
|
|
1102
1162
|
};
|
|
1103
|
-
publicAPI.create2DFilterableFromDataArray = function (
|
|
1104
|
-
let
|
|
1163
|
+
publicAPI.create2DFilterableFromDataArray = function () {
|
|
1164
|
+
let {
|
|
1165
|
+
width = requiredParam('width'),
|
|
1166
|
+
height = requiredParam('height'),
|
|
1167
|
+
dataArray = requiredParam('dataArray'),
|
|
1168
|
+
preferSizeOverAccuracy = false
|
|
1169
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1105
1170
|
const {
|
|
1106
1171
|
numComps,
|
|
1107
1172
|
dataType,
|
|
1108
1173
|
data
|
|
1109
1174
|
} = processDataArray(dataArray, preferSizeOverAccuracy);
|
|
1110
|
-
publicAPI.create2DFromRaw(
|
|
1175
|
+
publicAPI.create2DFromRaw({
|
|
1176
|
+
width,
|
|
1177
|
+
height,
|
|
1178
|
+
numComps,
|
|
1179
|
+
dataType,
|
|
1180
|
+
data
|
|
1181
|
+
});
|
|
1111
1182
|
};
|
|
1112
1183
|
publicAPI.updateVolumeInfoForGL = (dataType, numComps) => {
|
|
1113
1184
|
let isScalingApplied = false;
|
|
@@ -1162,8 +1233,16 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1162
1233
|
};
|
|
1163
1234
|
|
|
1164
1235
|
//----------------------------------------------------------------------------
|
|
1165
|
-
publicAPI.create3DFromRaw = function (
|
|
1166
|
-
let
|
|
1236
|
+
publicAPI.create3DFromRaw = function () {
|
|
1237
|
+
let {
|
|
1238
|
+
width = requiredParam('width'),
|
|
1239
|
+
height = requiredParam('height'),
|
|
1240
|
+
depth = requiredParam('depth'),
|
|
1241
|
+
numComps = requiredParam('numComps'),
|
|
1242
|
+
dataType = requiredParam('dataType'),
|
|
1243
|
+
data = requiredParam('data'),
|
|
1244
|
+
updatedExtents = []
|
|
1245
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1167
1246
|
let dataTypeToUse = dataType;
|
|
1168
1247
|
let dataToUse = data;
|
|
1169
1248
|
if (!publicAPI.updateVolumeInfoForGL(dataTypeToUse, numComps) && dataToUse) {
|
|
@@ -1253,23 +1332,44 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1253
1332
|
//----------------------------------------------------------------------------
|
|
1254
1333
|
// This method simulates a 3D texture using 2D
|
|
1255
1334
|
// Prefer create3DFilterableFromDataArray to enable caching of min and max values
|
|
1256
|
-
publicAPI.create3DFilterableFromRaw = function (
|
|
1257
|
-
let
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
dataType,
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1335
|
+
publicAPI.create3DFilterableFromRaw = function () {
|
|
1336
|
+
let {
|
|
1337
|
+
width = requiredParam('width'),
|
|
1338
|
+
height = requiredParam('height'),
|
|
1339
|
+
depth = requiredParam('depth'),
|
|
1340
|
+
numComps = requiredParam('numComps'),
|
|
1341
|
+
dataType = requiredParam('dataType'),
|
|
1342
|
+
data = requiredParam('data'),
|
|
1343
|
+
preferSizeOverAccuracy = false,
|
|
1344
|
+
ranges = undefined,
|
|
1345
|
+
updatedExtents = []
|
|
1346
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1347
|
+
return publicAPI.create3DFilterableFromDataArray({
|
|
1348
|
+
width,
|
|
1349
|
+
height,
|
|
1350
|
+
depth,
|
|
1351
|
+
dataArray: vtkDataArray.newInstance({
|
|
1352
|
+
numComps,
|
|
1353
|
+
dataType,
|
|
1354
|
+
values: data,
|
|
1355
|
+
ranges
|
|
1356
|
+
}),
|
|
1357
|
+
preferSizeOverAccuracy,
|
|
1358
|
+
updatedExtents
|
|
1359
|
+
});
|
|
1266
1360
|
};
|
|
1267
1361
|
|
|
1268
1362
|
//----------------------------------------------------------------------------
|
|
1269
1363
|
// This method create a 3D texture from dimensions and a DataArray
|
|
1270
|
-
publicAPI.create3DFilterableFromDataArray = function (
|
|
1271
|
-
let
|
|
1272
|
-
|
|
1364
|
+
publicAPI.create3DFilterableFromDataArray = function () {
|
|
1365
|
+
let {
|
|
1366
|
+
width = requiredParam('width'),
|
|
1367
|
+
height = requiredParam('height'),
|
|
1368
|
+
depth = requiredParam('depth'),
|
|
1369
|
+
dataArray = requiredParam('dataArray'),
|
|
1370
|
+
preferSizeOverAccuracy = false,
|
|
1371
|
+
updatedExtents = []
|
|
1372
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1273
1373
|
const {
|
|
1274
1374
|
numComps,
|
|
1275
1375
|
dataType,
|
|
@@ -1304,7 +1404,15 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1304
1404
|
|
|
1305
1405
|
// WebGL2 path, we have 3d textures etc
|
|
1306
1406
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
1307
|
-
return publicAPI.create3DFromRaw(
|
|
1407
|
+
return publicAPI.create3DFromRaw({
|
|
1408
|
+
width,
|
|
1409
|
+
height,
|
|
1410
|
+
depth,
|
|
1411
|
+
numComps,
|
|
1412
|
+
dataType,
|
|
1413
|
+
data,
|
|
1414
|
+
updatedExtents
|
|
1415
|
+
});
|
|
1308
1416
|
}
|
|
1309
1417
|
const numPixelsIn = width * height * depth;
|
|
1310
1418
|
const scaleOffsetsCopy = structuredClone(scaleOffsets);
|
|
@@ -1013,7 +1013,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
model.jitterTexture.setMinificationFilter(Filter.NEAREST);
|
|
1015
1015
|
model.jitterTexture.setMagnificationFilter(Filter.NEAREST);
|
|
1016
|
-
model.jitterTexture.create2DFromRaw(
|
|
1016
|
+
model.jitterTexture.create2DFromRaw({
|
|
1017
|
+
width: 32,
|
|
1018
|
+
height: 32,
|
|
1019
|
+
numComps: 1,
|
|
1020
|
+
dataType: VtkDataTypes.FLOAT,
|
|
1021
|
+
data: jitterArray
|
|
1022
|
+
});
|
|
1017
1023
|
}
|
|
1018
1024
|
const volumeProperties = actor.getProperties();
|
|
1019
1025
|
const firstValidInput = model.currentValidInputs[0];
|
|
@@ -1061,13 +1067,25 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1061
1067
|
// visible artifacts. High values of opacity quickly terminate without
|
|
1062
1068
|
// artifacts.
|
|
1063
1069
|
if (model._openGLRenderWindow.getWebgl2() || model.context.getExtension('OES_texture_float') && model.context.getExtension('OES_texture_float_linear')) {
|
|
1064
|
-
newOpacityTexture.create2DFromRaw(
|
|
1070
|
+
newOpacityTexture.create2DFromRaw({
|
|
1071
|
+
width: oWidth,
|
|
1072
|
+
height: 2 * numIComps,
|
|
1073
|
+
numComps: 1,
|
|
1074
|
+
dataType: VtkDataTypes.FLOAT,
|
|
1075
|
+
data: ofTable
|
|
1076
|
+
});
|
|
1065
1077
|
} else {
|
|
1066
1078
|
const oTable = new Uint8ClampedArray(oSize);
|
|
1067
1079
|
for (let i = 0; i < oSize; ++i) {
|
|
1068
1080
|
oTable[i] = 255.0 * ofTable[i];
|
|
1069
1081
|
}
|
|
1070
|
-
newOpacityTexture.create2DFromRaw(
|
|
1082
|
+
newOpacityTexture.create2DFromRaw({
|
|
1083
|
+
width: oWidth,
|
|
1084
|
+
height: 2 * numIComps,
|
|
1085
|
+
numComps: 1,
|
|
1086
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
1087
|
+
data: oTable
|
|
1088
|
+
});
|
|
1071
1089
|
}
|
|
1072
1090
|
if (firstScalarOpacityFunc) {
|
|
1073
1091
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstScalarOpacityFunc, newOpacityTexture, opacityFuncHash);
|
|
@@ -1110,7 +1128,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1110
1128
|
newColorTexture.resetFormatAndType();
|
|
1111
1129
|
newColorTexture.setMinificationFilter(Filter.LINEAR);
|
|
1112
1130
|
newColorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
1113
|
-
newColorTexture.create2DFromRaw(
|
|
1131
|
+
newColorTexture.create2DFromRaw({
|
|
1132
|
+
width: cWidth,
|
|
1133
|
+
height: 2 * numIComps,
|
|
1134
|
+
numComps: 3,
|
|
1135
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
1136
|
+
data: cTable
|
|
1137
|
+
});
|
|
1114
1138
|
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, newColorTexture, colorFuncHash);
|
|
1115
1139
|
model.colorTexture = newColorTexture;
|
|
1116
1140
|
} else {
|
|
@@ -1141,7 +1165,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1141
1165
|
// Use norm16 for scalar texture if the extension is available
|
|
1142
1166
|
newScalarTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
1143
1167
|
newScalarTexture.resetFormatAndType();
|
|
1144
|
-
newScalarTexture.create3DFilterableFromDataArray(
|
|
1168
|
+
newScalarTexture.create3DFilterableFromDataArray({
|
|
1169
|
+
width: dims[0],
|
|
1170
|
+
height: dims[1],
|
|
1171
|
+
depth: dims[2],
|
|
1172
|
+
dataArray: scalars,
|
|
1173
|
+
preferSizeOverAccuracy: volumeProperty.getPreferSizeOverAccuracy()
|
|
1174
|
+
});
|
|
1145
1175
|
model._openGLRenderWindow.setGraphicsResourceForObject(scalars, newScalarTexture, scalarsHash);
|
|
1146
1176
|
model.scalarTextures[component] = newScalarTexture;
|
|
1147
1177
|
} else {
|
|
@@ -1152,7 +1182,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1152
1182
|
// clear the array to acknowledge the update.
|
|
1153
1183
|
volumeProperty.setUpdatedExtents([]);
|
|
1154
1184
|
const dims = imageData.getDimensions();
|
|
1155
|
-
model.scalarTextures[component].create3DFilterableFromDataArray(
|
|
1185
|
+
model.scalarTextures[component].create3DFilterableFromDataArray({
|
|
1186
|
+
width: dims[0],
|
|
1187
|
+
height: dims[1],
|
|
1188
|
+
depth: dims[2],
|
|
1189
|
+
dataArray: scalars,
|
|
1190
|
+
updatedExtents
|
|
1191
|
+
});
|
|
1156
1192
|
}
|
|
1157
1193
|
replaceGraphicsResource(model._openGLRenderWindow, model._scalarTexturesCore[component], scalars);
|
|
1158
1194
|
model._scalarTexturesCore[component] = scalars;
|
|
@@ -1186,7 +1222,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1186
1222
|
newLabelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
|
|
1187
1223
|
|
|
1188
1224
|
// Create a 2D texture (acting as 1D) from the raw data
|
|
1189
|
-
newLabelOutlineThicknessTexture.create2DFromRaw(
|
|
1225
|
+
newLabelOutlineThicknessTexture.create2DFromRaw({
|
|
1226
|
+
width: lWidth,
|
|
1227
|
+
height: lHeight,
|
|
1228
|
+
numComps: 1,
|
|
1229
|
+
dataType: VtkDataTypes.UNSIGNED_CHAR,
|
|
1230
|
+
data: lTable
|
|
1231
|
+
});
|
|
1190
1232
|
if (labelOutlineThicknessArray) {
|
|
1191
1233
|
model._openGLRenderWindow.setGraphicsResourceForObject(labelOutlineThicknessArray, newLabelOutlineThicknessTexture, labelOutlineThicknessHash);
|
|
1192
1234
|
}
|
package/macros.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'fast-deep-equal';
|
|
2
2
|
import './vtk.js';
|
|
3
3
|
import './Common/Core/ClassHierarchy.js';
|
|
4
|
-
export {
|
|
4
|
+
export { H as EVENT_ABORT, T as TYPED_ARRAYS, V as VOID, _ as _capitalize, d as algo, q as capitalize, h as chain, J as debounce, m as default, f as event, C as formatBytesToProperUnit, D as formatNumbersWithThousandSeparator, g as get, k as getArray, I as isVtkObject, L as keystore, F as measurePromiseExecution, i as moveToProtected, n as newInstance, a as newTypedArray, b as newTypedArrayFrom, N as normalizeWheel, o as obj, p as proxy, j as proxyPropertyMapping, M as proxyPropertyState, u as requiredParam, s as set, G as setArray, e as setGet, l as setGetArray, E as setImmediateVTK, w as setLoggerFunction, K as throttle, t as traverseInstanceTree, B as uncapitalize, z as vtkDebugMacro, r as vtkErrorMacro, y as vtkInfoMacro, x as vtkLogMacro, A as vtkOnceErrorMacro, v as vtkWarningMacro } from './macros2.js';
|
package/macros2.js
CHANGED
|
@@ -7,6 +7,9 @@ import ClassHierarchy from './Common/Core/ClassHierarchy.js';
|
|
|
7
7
|
* The name change is so we do not get eaten by babel-plugin-macros.
|
|
8
8
|
*/
|
|
9
9
|
let globalMTime = 0;
|
|
10
|
+
const requiredParam = name => {
|
|
11
|
+
throw new Error(`Named parameter '${name}' is missing`);
|
|
12
|
+
};
|
|
10
13
|
const VOID = Symbol('void');
|
|
11
14
|
function getCurrentGlobalMTime() {
|
|
12
15
|
return globalMTime;
|
|
@@ -1654,11 +1657,13 @@ var macro = {
|
|
|
1654
1657
|
vtkOnceErrorMacro,
|
|
1655
1658
|
vtkWarningMacro,
|
|
1656
1659
|
// vtk.js internal use
|
|
1657
|
-
objectSetterMap
|
|
1660
|
+
objectSetterMap,
|
|
1661
|
+
requiredParam
|
|
1658
1662
|
};
|
|
1659
1663
|
|
|
1660
1664
|
var macro$1 = /*#__PURE__*/Object.freeze({
|
|
1661
1665
|
__proto__: null,
|
|
1666
|
+
requiredParam: requiredParam,
|
|
1662
1667
|
VOID: VOID,
|
|
1663
1668
|
setLoggerFunction: setLoggerFunction,
|
|
1664
1669
|
vtkLogMacro: vtkLogMacro,
|
|
@@ -1702,4 +1707,4 @@ var macro$1 = /*#__PURE__*/Object.freeze({
|
|
|
1702
1707
|
'default': macro
|
|
1703
1708
|
});
|
|
1704
1709
|
|
|
1705
|
-
export {
|
|
1710
|
+
export { vtkOnceErrorMacro as A, uncapitalize as B, formatBytesToProperUnit as C, formatNumbersWithThousandSeparator as D, setImmediateVTK as E, measurePromiseExecution as F, setArray as G, EVENT_ABORT as H, isVtkObject as I, debounce as J, throttle as K, keystore as L, proxyPropertyState as M, normalizeWheel as N, TYPED_ARRAYS as T, VOID as V, _capitalize as _, newTypedArray as a, newTypedArrayFrom as b, macro$1 as c, algo as d, setGet as e, event as f, get as g, chain as h, moveToProtected as i, proxyPropertyMapping as j, getArray as k, setGetArray as l, macro as m, newInstance as n, obj as o, proxy as p, capitalize as q, vtkErrorMacro as r, set as s, traverseInstanceTree as t, requiredParam as u, vtkWarningMacro as v, setLoggerFunction as w, vtkLogMacro as x, vtkInfoMacro as y, vtkDebugMacro as z };
|