@kitware/vtk.js 25.2.0 → 25.2.3
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/Rendering/Core/Actor.d.ts +5 -4
- package/Rendering/Core/ImageSlice.d.ts +25 -1
- package/Rendering/Core/RenderWindowInteractor.js +4 -1
- package/Rendering/Core/Volume.d.ts +6 -5
- package/Rendering/Core/VolumeMapper.d.ts +1 -1
- package/Rendering/Core/VolumeProperty.d.ts +32 -30
- package/Rendering/OpenGL/ImageMapper.js +4 -4
- package/Rendering/OpenGL/ShaderCache.js +1 -3
- package/Rendering/OpenGL/ShaderProgram.js +2 -4
- package/Rendering/WebGPU/CellArrayMapper.js +18 -14
- package/Rendering/WebGPU/ImageMapper.js +11 -8
- package/Rendering/WebGPU/Pipeline.js +0 -12
- package/Rendering/WebGPU/RenderEncoder.js +0 -1
- package/Rendering/WebGPU/SimpleMapper.js +6 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bounds } from './../../types';
|
|
1
|
+
import { Bounds, Nullable } from './../../types';
|
|
2
2
|
import vtkMapper from './Mapper';
|
|
3
3
|
import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
|
|
4
|
-
import vtkProperty from './Property';
|
|
4
|
+
import vtkProperty, { IPropertyInitialValues } from './Property';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -62,7 +62,7 @@ export interface vtkActor extends vtkProp3D {
|
|
|
62
62
|
/**
|
|
63
63
|
* Get the Mapper that this actor is getting its data from.
|
|
64
64
|
*/
|
|
65
|
-
getMapper():
|
|
65
|
+
getMapper(): Nullable<vtkMapper>;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Get the property object that controls this actors surface
|
|
@@ -82,8 +82,9 @@ export interface vtkActor extends vtkProp3D {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Create a new property suitable for use with this type of Actor.
|
|
85
|
+
* @param {IPropertyInitialValues} [initialValues] (default: {})
|
|
85
86
|
*/
|
|
86
|
-
makeProperty(): vtkProperty;
|
|
87
|
+
makeProperty(initialValues?: IPropertyInitialValues): vtkProperty;
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
90
|
* Set the property object that controls this actors backface surface
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bounds } from './../../types';
|
|
2
|
-
import vtkImageProperty from './ImageProperty';
|
|
2
|
+
import vtkImageProperty, { IImagePropertyInitialValues } from './ImageProperty';
|
|
3
3
|
import vtkImageMapper from './ImageMapper';
|
|
4
4
|
import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
|
|
5
5
|
|
|
@@ -23,6 +23,12 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
23
23
|
*/
|
|
24
24
|
getBounds(): Bounds;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Get the bounds for this mapper as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
28
|
+
* @return {Bounds} The bounds for the mapper.
|
|
29
|
+
*/
|
|
30
|
+
getBoundsByReference(): Bounds;
|
|
31
|
+
|
|
26
32
|
/**
|
|
27
33
|
* Get the bounds for a given slice as [xmin, xmax, ymin, ymax,zmin, zmax].
|
|
28
34
|
* @param {Number} slice The slice index.
|
|
@@ -111,6 +117,24 @@ export interface vtkImageSlice extends vtkProp3D {
|
|
|
111
117
|
* and the Renderer will do the images in their own pass.
|
|
112
118
|
*/
|
|
113
119
|
hasTranslucentPolygonalGeometry(): boolean;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Create a new property suitable for use with this type of Actor.
|
|
123
|
+
* @param {IImageSliceInitialValues} [initialValues] (default: {})
|
|
124
|
+
*/
|
|
125
|
+
makeProperty(initialValues?: IImagePropertyInitialValues): vtkImageProperty;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param {vtkImageMapper} mapper The vtkImageMapper instance.
|
|
130
|
+
*/
|
|
131
|
+
setMapper(mapper: vtkImageMapper): boolean;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
* @param {vtkImageProperty} property The vtkImageProperty instance.
|
|
136
|
+
*/
|
|
137
|
+
setProperty(property: vtkImageProperty): boolean;
|
|
114
138
|
}
|
|
115
139
|
|
|
116
140
|
/**
|
|
@@ -518,6 +518,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
518
518
|
},
|
|
519
519
|
right: {
|
|
520
520
|
buttons: {}
|
|
521
|
+
},
|
|
522
|
+
none: {
|
|
523
|
+
buttons: {}
|
|
521
524
|
}
|
|
522
525
|
};
|
|
523
526
|
}
|
|
@@ -712,7 +715,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
712
715
|
// No more fingers down
|
|
713
716
|
if (pointers.length === 0) {
|
|
714
717
|
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
715
|
-
position:
|
|
718
|
+
position: getScreenEventPositionFor(event),
|
|
716
719
|
deviceType: getDeviceTypeFor(event)
|
|
717
720
|
});
|
|
718
721
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bounds } from './../../types';
|
|
1
|
+
import { Bounds, Nullable } from './../../types';
|
|
2
2
|
import vtkProp3D, { IProp3DInitialValues } from './Prop3D';
|
|
3
3
|
import vtkVolumeMapper from './VolumeMapper';
|
|
4
|
-
import vtkVolumeProperty from './VolumeProperty';
|
|
4
|
+
import vtkVolumeProperty, { IVolumePropertyInitialValues } from './VolumeProperty';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -20,7 +20,7 @@ export interface vtkVolume extends vtkProp3D {
|
|
|
20
20
|
/**
|
|
21
21
|
* Get the volume mapper
|
|
22
22
|
*/
|
|
23
|
-
getMapper(): vtkVolumeMapper
|
|
23
|
+
getMapper(): Nullable<vtkVolumeMapper>;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* For some exporters and other other operations we must be able to collect
|
|
@@ -63,9 +63,10 @@ export interface vtkVolume extends vtkProp3D {
|
|
|
63
63
|
getRedrawMTime(): number;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Create a new property suitable for use with this type of Actor.
|
|
67
|
+
* @param {IVolumePropertyInitialValues} [initialValues] (default: {})
|
|
67
68
|
*/
|
|
68
|
-
makeProperty():
|
|
69
|
+
makeProperty(initialValues?: IVolumePropertyInitialValues): vtkVolumeProperty;
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* Set the volume mapper
|
|
@@ -5,7 +5,7 @@ import { BlendMode, FilterMode } from './VolumeMapper/Constants';
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
interface IVolumeMapperInitialValues extends IAbstractMapperInitialValues {
|
|
8
|
+
export interface IVolumeMapperInitialValues extends IAbstractMapperInitialValues {
|
|
9
9
|
bounds?: Bounds;
|
|
10
10
|
blendMode?: BlendMode;
|
|
11
11
|
sampleDistance?: number;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
|
|
1
2
|
import { vtkObject } from './../../interfaces';
|
|
3
|
+
import vtkColorTransferFunction from './ColorTransferFunction';
|
|
2
4
|
import { InterpolationType, OpacityMode } from './VolumeProperty/Constants';
|
|
3
5
|
|
|
4
|
-
interface IVolumePropertyInitialValues {
|
|
6
|
+
export interface IVolumePropertyInitialValues {
|
|
5
7
|
independentComponents?: boolean;
|
|
6
8
|
shade?: number;
|
|
7
9
|
ambient?: number;
|
|
@@ -33,7 +35,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
*
|
|
36
|
-
* @param {Number} index
|
|
38
|
+
* @param {Number} index
|
|
37
39
|
*/
|
|
38
40
|
getColorChannels(index: number): number;
|
|
39
41
|
|
|
@@ -44,25 +46,25 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
*
|
|
47
|
-
* @param {Number} index
|
|
49
|
+
* @param {Number} index
|
|
48
50
|
*/
|
|
49
51
|
getGradientOpacityMaximumOpacity(index: number): number;
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
54
|
*
|
|
53
|
-
* @param {Number} index
|
|
55
|
+
* @param {Number} index
|
|
54
56
|
*/
|
|
55
57
|
getGradientOpacityMaximumValue(index: number): number;
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
*
|
|
59
|
-
* @param {Number} index
|
|
61
|
+
* @param {Number} index
|
|
60
62
|
*/
|
|
61
63
|
getGradientOpacityMinimumOpacity(index: number): number;
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
*
|
|
65
|
-
* @param {Number} index
|
|
67
|
+
* @param {Number} index
|
|
66
68
|
*/
|
|
67
69
|
getGradientOpacityMinimumValue(index: number): number;
|
|
68
70
|
|
|
@@ -73,15 +75,15 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
* Get the unit distance on which the scalar opacity transfer function is defined.
|
|
76
|
-
* @param {Number} index
|
|
78
|
+
* @param {Number} index
|
|
77
79
|
*/
|
|
78
80
|
getScalarOpacityUnitDistance(index: number): number;
|
|
79
81
|
|
|
80
82
|
/**
|
|
81
83
|
* Get the currently set gray transfer function. Create one if none set.
|
|
82
|
-
* @param {Number} index
|
|
84
|
+
* @param {Number} index
|
|
83
85
|
*/
|
|
84
|
-
getGrayTransferFunction(index: number):
|
|
86
|
+
getGrayTransferFunction(index: number): vtkPiecewiseFunction;
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
89
|
*
|
|
@@ -98,13 +100,13 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
98
100
|
* Get the currently set RGB transfer function. Create one if none set.
|
|
99
101
|
* @param {Number} index
|
|
100
102
|
*/
|
|
101
|
-
getRGBTransferFunction(index: number):
|
|
103
|
+
getRGBTransferFunction(index: number): vtkColorTransferFunction;
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* Get the scalar opacity transfer function. Create one if none set.
|
|
105
107
|
* @param {Number} index
|
|
106
108
|
*/
|
|
107
|
-
getScalarOpacity(index: number):
|
|
109
|
+
getScalarOpacity(index: number): vtkPiecewiseFunction;
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
112
|
* Get the shading of a volume.
|
|
@@ -147,37 +149,37 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
147
149
|
/**
|
|
148
150
|
*
|
|
149
151
|
* @param {Number} index
|
|
150
|
-
* @param {Number} value
|
|
152
|
+
* @param {Number} value
|
|
151
153
|
*/
|
|
152
154
|
setGradientOpacityMaximumOpacity(index: number, value: number): boolean;
|
|
153
155
|
|
|
154
156
|
/**
|
|
155
157
|
*
|
|
156
158
|
* @param {Number} index
|
|
157
|
-
* @param {Number} value
|
|
159
|
+
* @param {Number} value
|
|
158
160
|
*/
|
|
159
161
|
setGradientOpacityMaximumValue(index: number, value: number): boolean;
|
|
160
162
|
|
|
161
163
|
/**
|
|
162
164
|
*
|
|
163
165
|
* @param {Number} index
|
|
164
|
-
* @param {Number} value
|
|
166
|
+
* @param {Number} value
|
|
165
167
|
*/
|
|
166
168
|
setGradientOpacityMinimumOpacity(index: number, value: number): boolean;
|
|
167
169
|
|
|
168
170
|
/**
|
|
169
171
|
*
|
|
170
172
|
* @param {Number} index
|
|
171
|
-
* @param {Number} value
|
|
173
|
+
* @param {Number} value
|
|
172
174
|
*/
|
|
173
175
|
setGradientOpacityMinimumValue(index: number, value: number): boolean;
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
* Set the color of a volume to a gray transfer function
|
|
177
179
|
* @param {Number} index
|
|
178
|
-
* @param func
|
|
180
|
+
* @param {vtkPiecewiseFunction} func
|
|
179
181
|
*/
|
|
180
|
-
setGrayTransferFunction(index: number, func:
|
|
182
|
+
setGrayTransferFunction(index: number, func: vtkPiecewiseFunction): boolean;
|
|
181
183
|
|
|
182
184
|
/**
|
|
183
185
|
* Does the data have independent components, or do some define color only?
|
|
@@ -204,14 +206,14 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
204
206
|
|
|
205
207
|
/**
|
|
206
208
|
*
|
|
207
|
-
* @param {Number} labelOutlineThickness
|
|
209
|
+
* @param {Number} labelOutlineThickness
|
|
208
210
|
*/
|
|
209
211
|
setLabelOutlineThickness(labelOutlineThickness: number): boolean;
|
|
210
212
|
|
|
211
213
|
/**
|
|
212
214
|
*
|
|
213
215
|
* @param {Number} index
|
|
214
|
-
* @param {Number} value
|
|
216
|
+
* @param {Number} value
|
|
215
217
|
*/
|
|
216
218
|
setOpacityMode(index: number, value: number): boolean;
|
|
217
219
|
|
|
@@ -219,7 +221,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
219
221
|
* Set the unit distance on which the scalar opacity transfer function is
|
|
220
222
|
* defined.
|
|
221
223
|
* @param {Number} index
|
|
222
|
-
* @param {Number} value
|
|
224
|
+
* @param {Number} value
|
|
223
225
|
*/
|
|
224
226
|
setScalarOpacityUnitDistance(index: number, value: number): boolean;
|
|
225
227
|
|
|
@@ -234,7 +236,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
234
236
|
* turning shading off is generally the same as setting ambient=1,
|
|
235
237
|
* diffuse=0, specular=0. Shading can be independently turned on/off per
|
|
236
238
|
* component.
|
|
237
|
-
* @param {Number} shade
|
|
239
|
+
* @param {Number} shade
|
|
238
240
|
*/
|
|
239
241
|
setShade(shade: number): boolean;
|
|
240
242
|
|
|
@@ -252,35 +254,35 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
252
254
|
|
|
253
255
|
/**
|
|
254
256
|
*
|
|
255
|
-
* @param {
|
|
256
|
-
* @param {
|
|
257
|
+
* @param {Number} index
|
|
258
|
+
* @param {Boolean} value
|
|
257
259
|
*/
|
|
258
260
|
setUseGradientOpacity(index: number, value: boolean): boolean;
|
|
259
261
|
|
|
260
262
|
/**
|
|
261
263
|
*
|
|
262
|
-
* @param {Boolean} useLabelOutline
|
|
264
|
+
* @param {Boolean} useLabelOutline
|
|
263
265
|
*/
|
|
264
266
|
setUseLabelOutline(useLabelOutline: boolean): boolean;
|
|
265
267
|
|
|
266
268
|
/**
|
|
267
269
|
* Set the color of a volume to an RGB transfer function
|
|
268
270
|
* @param {Number} index
|
|
269
|
-
* @param func
|
|
271
|
+
* @param {vtkColorTransferFunction} func
|
|
270
272
|
*/
|
|
271
|
-
setRGBTransferFunction(index: number, func:
|
|
273
|
+
setRGBTransferFunction(index: number, func: vtkColorTransferFunction): boolean;
|
|
272
274
|
|
|
273
275
|
/**
|
|
274
276
|
* Set the scalar opacity of a volume to a transfer function
|
|
275
277
|
* @param {Number} index
|
|
276
|
-
* @param func
|
|
278
|
+
* @param {vtkPiecewiseFunction} func
|
|
277
279
|
*/
|
|
278
|
-
setScalarOpacity(index: number, func:
|
|
280
|
+
setScalarOpacity(index: number, func: vtkPiecewiseFunction): boolean;
|
|
279
281
|
|
|
280
282
|
/**
|
|
281
283
|
* Set the scalar component weights.
|
|
282
284
|
* @param {Number} index
|
|
283
|
-
* @param {Number} value
|
|
285
|
+
* @param {Number} value
|
|
284
286
|
*/
|
|
285
287
|
setComponentWeight(index: number, value: number): boolean;
|
|
286
288
|
|
|
@@ -292,7 +294,7 @@ export interface vtkVolumeProperty extends vtkObject {
|
|
|
292
294
|
|
|
293
295
|
/**
|
|
294
296
|
* Set the interpolation type for sampling a volume.
|
|
295
|
-
* @param {InterpolationType} interpolationType
|
|
297
|
+
* @param {InterpolationType} interpolationType
|
|
296
298
|
*/
|
|
297
299
|
setInterpolationType(interpolationType: InterpolationType): boolean;
|
|
298
300
|
|
|
@@ -405,8 +405,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
405
405
|
numClipPlanes = 6;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
var image = model.currentInput;
|
|
409
|
-
var w2imat4 = image.getWorldToIndex();
|
|
410
408
|
var shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
|
|
411
409
|
var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
|
|
412
410
|
var mat = inverseShiftScaleMatrix ? mat4.copy(model.imagematinv, actor.getMatrix()) : actor.getMatrix();
|
|
@@ -415,9 +413,11 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
415
413
|
mat4.transpose(mat, mat);
|
|
416
414
|
mat4.multiply(mat, mat, inverseShiftScaleMatrix);
|
|
417
415
|
mat4.transpose(mat, mat);
|
|
418
|
-
}
|
|
416
|
+
} // transform crop plane normal with transpose(inverse(worldToIndex))
|
|
417
|
+
|
|
419
418
|
|
|
420
|
-
mat4.
|
|
419
|
+
mat4.transpose(model.imagemat, model.currentInput.getIndexToWorld());
|
|
420
|
+
mat4.multiply(model.imagematinv, mat, model.imagemat);
|
|
421
421
|
var planeEquations = [];
|
|
422
422
|
|
|
423
423
|
for (var _i3 = 0; _i3 < numClipPlanes; _i3++) {
|
|
@@ -99,9 +99,7 @@ function vtkShaderCache(publicAPI, model) {
|
|
|
99
99
|
var hashInput = "".concat(vertexCode).concat(fragmentCode).concat(geometryCode);
|
|
100
100
|
var result = Md5.hash(hashInput); // does it already exist?
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (loc === -1) {
|
|
102
|
+
if (!(result in model.shaderPrograms)) {
|
|
105
103
|
// create one
|
|
106
104
|
var sps = vtkShaderProgram.newInstance();
|
|
107
105
|
sps.setContext(model.context);
|
|
@@ -478,9 +478,7 @@ function vtkShaderProgram(publicAPI, model) {
|
|
|
478
478
|
} // see if we have cached the result
|
|
479
479
|
|
|
480
480
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
if (loc !== -1) {
|
|
481
|
+
if (name in model.attributeLocs) {
|
|
484
482
|
return true;
|
|
485
483
|
}
|
|
486
484
|
|
|
@@ -489,7 +487,7 @@ function vtkShaderProgram(publicAPI, model) {
|
|
|
489
487
|
return false;
|
|
490
488
|
}
|
|
491
489
|
|
|
492
|
-
loc = model.context.getAttribLocation(model.handle, name);
|
|
490
|
+
var loc = model.context.getAttribLocation(model.handle, name);
|
|
493
491
|
|
|
494
492
|
if (loc === -1) {
|
|
495
493
|
return false;
|
|
@@ -239,7 +239,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
239
239
|
' var fresnel: f32 = schlickFresnelIOR(V, normal, ior, k); // Fresnel', ' fresnel = min(1, fresnel);', ' // This could be controlled with its own variable (that isnt base color) for better artistic control', ' var fresnelMetallic: vec3<f32> = schlickFresnelRGB(V, normal, baseColor); // Fresnel for metal, takes color into account', ' var kS: vec3<f32> = mix(vec3<f32>(fresnel), fresnelMetallic, metallic);', ' kS = min(vec3<f32>(1), kS);', ' var kD: vec3<f32> = (1.0 - kS) * (1.0 - metallic);', ' var PBR: vec3<f32> = mapperUBO.DiffuseIntensity*kD*diffuse + kS*specular;', ' PBR += emission;', ' computedColor = vec4<f32>(PBR, mapperUBO.Opacity);']).result;
|
|
240
240
|
fDesc.setCode(code); // If theres no normals, just set the specular color to be flat
|
|
241
241
|
} else {
|
|
242
|
-
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Light::Impl', [' var diffuse: vec3<f32> = diffuseColor.rgb;', ' var specular: vec3<f32> = mapperUBO.SpecularColor.rgb * mapperUBO.SpecularColor.a;', ' computedColor = vec4<f32>(diffuse, mapperUBO.Opacity);']).result;
|
|
242
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Light::Impl', [' var diffuse: vec3<f32> = diffuseColor.rgb;', ' var specular: vec3<f32> = mapperUBO.SpecularColor.rgb * mapperUBO.SpecularColor.a;', ' computedColor = vec4<f32>(diffuse * _diffuseMap.rgb, mapperUBO.Opacity);']).result;
|
|
243
243
|
fDesc.setCode(code);
|
|
244
244
|
}
|
|
245
245
|
};
|
|
@@ -290,7 +290,6 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
290
290
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::TCoord::Impl', [' output.tcoordVS = tcoord;' // Ensure that UV coordinates are always between 0-1
|
|
291
291
|
]).result;
|
|
292
292
|
vDesc.setCode(code);
|
|
293
|
-
if (model.is2D) return;
|
|
294
293
|
var fDesc = pipeline.getShaderDescription('fragment');
|
|
295
294
|
code = fDesc.getCode();
|
|
296
295
|
var actor = model.WebGPUActor.getRenderable();
|
|
@@ -605,36 +604,41 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
605
604
|
textures.push(_pair);
|
|
606
605
|
}
|
|
607
606
|
|
|
608
|
-
if (
|
|
609
|
-
var _pair2 = ['
|
|
607
|
+
if (model.colorTexture) {
|
|
608
|
+
var _pair2 = ['Diffuse', model.colorTexture];
|
|
610
609
|
textures.push(_pair2);
|
|
611
610
|
}
|
|
612
611
|
|
|
613
|
-
if ((_actor$getProperty$
|
|
614
|
-
var _pair3 = ['
|
|
612
|
+
if ((_actor$getProperty$ge15 = (_actor$getProperty9 = actor.getProperty()).getRoughnessTexture) !== null && _actor$getProperty$ge15 !== void 0 && _actor$getProperty$ge15.call(_actor$getProperty9)) {
|
|
613
|
+
var _pair3 = ['Roughness', actor.getProperty().getRoughnessTexture()];
|
|
615
614
|
textures.push(_pair3);
|
|
616
615
|
}
|
|
617
616
|
|
|
618
|
-
if ((_actor$getProperty$
|
|
619
|
-
var _pair4 = ['
|
|
617
|
+
if ((_actor$getProperty$ge16 = (_actor$getProperty10 = actor.getProperty()).getMetallicTexture) !== null && _actor$getProperty$ge16 !== void 0 && _actor$getProperty$ge16.call(_actor$getProperty10)) {
|
|
618
|
+
var _pair4 = ['Metallic', actor.getProperty().getMetallicTexture()];
|
|
620
619
|
textures.push(_pair4);
|
|
621
620
|
}
|
|
622
621
|
|
|
623
|
-
if ((_actor$getProperty$
|
|
624
|
-
var _pair5 = ['
|
|
622
|
+
if ((_actor$getProperty$ge17 = (_actor$getProperty11 = actor.getProperty()).getNormalTexture) !== null && _actor$getProperty$ge17 !== void 0 && _actor$getProperty$ge17.call(_actor$getProperty11)) {
|
|
623
|
+
var _pair5 = ['Normal', actor.getProperty().getNormalTexture()];
|
|
625
624
|
textures.push(_pair5);
|
|
626
625
|
}
|
|
627
626
|
|
|
628
|
-
if ((_actor$getProperty$
|
|
629
|
-
var _pair6 = ['
|
|
627
|
+
if ((_actor$getProperty$ge18 = (_actor$getProperty12 = actor.getProperty()).getAmbientOcclusionTexture) !== null && _actor$getProperty$ge18 !== void 0 && _actor$getProperty$ge18.call(_actor$getProperty12)) {
|
|
628
|
+
var _pair6 = ['AmbientOcclusion', actor.getProperty().getAmbientOcclusionTexture()];
|
|
630
629
|
textures.push(_pair6);
|
|
631
630
|
}
|
|
632
631
|
|
|
633
|
-
if ((
|
|
634
|
-
var _pair7 = ['
|
|
632
|
+
if ((_actor$getProperty$ge19 = (_actor$getProperty13 = actor.getProperty()).getEmissionTexture) !== null && _actor$getProperty$ge19 !== void 0 && _actor$getProperty$ge19.call(_actor$getProperty13)) {
|
|
633
|
+
var _pair7 = ['Emission', actor.getProperty().getEmissionTexture()];
|
|
635
634
|
textures.push(_pair7);
|
|
636
635
|
}
|
|
637
636
|
|
|
637
|
+
if ((_renderer$getBackgrou = renderer.getBackgroundTexture) !== null && _renderer$getBackgrou !== void 0 && _renderer$getBackgrou.call(renderer)) {
|
|
638
|
+
var _pair8 = ['Background', renderer.getBackgroundTexture()];
|
|
639
|
+
textures.push(_pair8);
|
|
640
|
+
}
|
|
641
|
+
|
|
638
642
|
for (var i = 0; i < textures.length; i++) {
|
|
639
643
|
if (textures[i][1].getInputData() || textures[i][1].getJsImageData() || textures[i][1].getCanvas()) {
|
|
640
644
|
newTextures.push(textures[i]);
|
|
@@ -106,7 +106,10 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
106
106
|
var modelToIndex = image.getWorldToIndex();
|
|
107
107
|
mat4.multiply(tmpMat4, modelToIndex, tmpMat4); // tmpMat4 is now SC -> Index, save this as we need it later
|
|
108
108
|
|
|
109
|
-
mat4.invert(tmp3Mat4, tmpMat4);
|
|
109
|
+
mat4.invert(tmp3Mat4, tmpMat4); // need translation and scale
|
|
110
|
+
|
|
111
|
+
mat4.fromTranslation(tmp2Mat4, [0.5, 0.5, 0.5]);
|
|
112
|
+
mat4.multiply(tmpMat4, tmp2Mat4, tmpMat4);
|
|
110
113
|
var dims = image.getDimensions();
|
|
111
114
|
mat4.identity(tmp2Mat4);
|
|
112
115
|
mat4.scale(tmp2Mat4, tmp2Mat4, [1.0 / dims[0], 1.0 / dims[1], 1.0 / dims[2]]);
|
|
@@ -143,22 +146,22 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
ptsArray1[axis0] = nSlice;
|
|
146
|
-
ptsArray1[axis1] = ext[axis1 * 2];
|
|
147
|
-
ptsArray1[axis2] = ext[axis2 * 2];
|
|
149
|
+
ptsArray1[axis1] = ext[axis1 * 2] - 0.5;
|
|
150
|
+
ptsArray1[axis2] = ext[axis2 * 2] - 0.5;
|
|
148
151
|
ptsArray1[3] = 1.0;
|
|
149
152
|
vec4.transformMat4(ptsArray1, ptsArray1, tmp3Mat4);
|
|
150
153
|
model.UBO.setArray('Origin', ptsArray1);
|
|
151
154
|
ptsArray2[axis0] = nSlice;
|
|
152
|
-
ptsArray2[axis1] = ext[axis1 * 2 + 1];
|
|
153
|
-
ptsArray2[axis2] = ext[axis2 * 2];
|
|
155
|
+
ptsArray2[axis1] = ext[axis1 * 2 + 1] + 0.5;
|
|
156
|
+
ptsArray2[axis2] = ext[axis2 * 2] - 0.5;
|
|
154
157
|
ptsArray2[3] = 1.0;
|
|
155
158
|
vec4.transformMat4(ptsArray2, ptsArray2, tmp3Mat4);
|
|
156
159
|
vec4.subtract(ptsArray2, ptsArray2, ptsArray1);
|
|
157
160
|
ptsArray2[3] = 1.0;
|
|
158
161
|
model.UBO.setArray('Axis1', ptsArray2);
|
|
159
162
|
ptsArray2[axis0] = nSlice;
|
|
160
|
-
ptsArray2[axis1] = ext[axis1 * 2];
|
|
161
|
-
ptsArray2[axis2] = ext[axis2 * 2 + 1];
|
|
163
|
+
ptsArray2[axis1] = ext[axis1 * 2] - 0.5;
|
|
164
|
+
ptsArray2[axis2] = ext[axis2 * 2 + 1] + 0.5;
|
|
162
165
|
ptsArray2[3] = 1.0;
|
|
163
166
|
vec4.transformMat4(ptsArray2, ptsArray2, tmp3Mat4);
|
|
164
167
|
vec4.subtract(ptsArray2, ptsArray2, ptsArray1);
|
|
@@ -179,7 +182,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
179
182
|
var target = iComps ? i : 0;
|
|
180
183
|
var cfun = actor.getProperty().getRGBTransferFunction(target);
|
|
181
184
|
|
|
182
|
-
if (cfun
|
|
185
|
+
if (cfun) {
|
|
183
186
|
var cRange = cfun.getRange();
|
|
184
187
|
cw = cRange[1] - cRange[0];
|
|
185
188
|
cl = 0.5 * (cRange[1] + cRange[0]);
|
|
@@ -83,17 +83,6 @@ function vtkWebGPUPipeline(publicAPI, model) {
|
|
|
83
83
|
publicAPI.bindVertexInput = function (renderEncoder, vInput) {
|
|
84
84
|
vInput.bindBuffers(renderEncoder);
|
|
85
85
|
};
|
|
86
|
-
|
|
87
|
-
publicAPI.addDrawCallback = function (cb) {
|
|
88
|
-
model._drawCallbacks.push(cb);
|
|
89
|
-
}; // handle anything that needs to be done when drawing
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
publicAPI.draw = function (encoder) {
|
|
93
|
-
for (var cb = 0; cb < model._drawCallbacks.length; cb++) {
|
|
94
|
-
model._drawCallbacks[cb](encoder, publicAPI);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
86
|
} // ----------------------------------------------------------------------------
|
|
98
87
|
// Object factory
|
|
99
88
|
// ----------------------------------------------------------------------------
|
|
@@ -116,7 +105,6 @@ function extend(publicAPI, model) {
|
|
|
116
105
|
obj(publicAPI, model);
|
|
117
106
|
model.layouts = [];
|
|
118
107
|
model.shaderDescriptions = [];
|
|
119
|
-
model._drawCallbacks = [];
|
|
120
108
|
get(publicAPI, model, ['handle', 'pipelineDescription']);
|
|
121
109
|
setGet(publicAPI, model, ['device', 'renderEncoder', 'topology', 'vertexState']); // For more macro methods, see "Sources/macros.js"
|
|
122
110
|
// Object specific methods
|
|
@@ -176,7 +176,12 @@ function vtkWebGPUSimpleMapper(publicAPI, model) {
|
|
|
176
176
|
publicAPI.draw = function (renderEncoder) {
|
|
177
177
|
var pipeline = renderEncoder.getBoundPipeline(); // bind the mapper bind group
|
|
178
178
|
|
|
179
|
-
renderEncoder.activateBindGroup(model.bindGroup);
|
|
179
|
+
renderEncoder.activateBindGroup(model.bindGroup);
|
|
180
|
+
|
|
181
|
+
if (model.WebGPURenderer) {
|
|
182
|
+
model.WebGPURenderer.bindUBO(renderEncoder);
|
|
183
|
+
} // bind the vertex input
|
|
184
|
+
|
|
180
185
|
|
|
181
186
|
pipeline.bindVertexInput(renderEncoder, model.vertexInput);
|
|
182
187
|
var indexBuffer = model.vertexInput.getIndexBuffer();
|
|
@@ -222,7 +227,6 @@ function vtkWebGPUSimpleMapper(publicAPI, model) {
|
|
|
222
227
|
|
|
223
228
|
if (model.WebGPURenderer) {
|
|
224
229
|
model.pipeline.addBindGroupLayout(model.WebGPURenderer.getBindGroup());
|
|
225
|
-
model.pipeline.addDrawCallback(model.WebGPURenderer.bindUBO);
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
model.pipeline.addBindGroupLayout(model.bindGroup);
|