@kitware/vtk.js 22.1.8 → 22.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/IO/Core/ImageStream/DefaultProtocol.d.ts +8 -8
- package/IO/Core/ImageStream.d.ts +17 -15
- package/Rendering/Core/ScalarBarActor.d.ts +39 -3
- package/Rendering/Core/ScalarBarActor.js +28 -8
- package/Rendering/Misc/SynchronizableRenderWindow.d.ts +73 -0
- package/Rendering/OpenGL/RenderWindow.d.ts +107 -106
- package/Rendering/OpenGL/RenderWindow.js +6 -0
- package/Rendering/SceneGraph/RenderWindowViewNode.js +5 -0
- package/Rendering/WebGPU/FullScreenQuad.js +1 -1
- package/Rendering/WebGPU/Glyph3DMapper.js +2 -2
- package/Rendering/WebGPU/HardwareSelector.js +1 -0
- package/Rendering/WebGPU/ImageMapper.js +2 -2
- package/Rendering/WebGPU/MapperHelper.js +4 -4
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +3 -3
- package/Rendering/WebGPU/PolyDataMapper.js +4 -4
- package/Rendering/WebGPU/RenderWindow.js +10 -1
- package/Rendering/WebGPU/Renderer.js +1 -1
- package/Rendering/WebGPU/Sampler.js +1 -1
- package/Rendering/WebGPU/ShaderDescription.js +4 -4
- package/Rendering/WebGPU/SphereMapper.js +3 -3
- package/Rendering/WebGPU/StickMapper.js +4 -4
- package/Rendering/WebGPU/StorageBuffer.js +1 -1
- package/Rendering/WebGPU/TextureView.js +2 -2
- package/Rendering/WebGPU/UniformBuffer.js +1 -1
- package/Rendering/WebGPU/VertexInput.js +1 -1
- package/Rendering/WebGPU/VolumePass.js +3 -3
- package/Rendering/WebGPU/VolumePassFSQ.js +3 -3
- package/Widgets/Core/WidgetManager.js +211 -71
- package/Widgets/Widgets3D/SplineWidget/behavior.js +9 -6
- package/package.json +4 -4
|
@@ -3,6 +3,7 @@ import { Size, Vector2, Vector3 } from '@kitware/vtk.js/types';
|
|
|
3
3
|
import { vtkRenderer } from '@kitware/vtk.js/Rendering/Core/Renderer';
|
|
4
4
|
import { VtkDataTypes } from '@kitware/vtk.js/Common/Core/DataArray';
|
|
5
5
|
import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
|
|
6
|
+
import vtkViewStream from '@kitware/vtk.js/IO/Core/ImageStream/ViewStream';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -18,7 +19,7 @@ export interface IOptions {
|
|
|
18
19
|
resetCamera: boolean,
|
|
19
20
|
size: Size,
|
|
20
21
|
scale: number
|
|
21
|
-
}
|
|
22
|
+
}
|
|
22
23
|
|
|
23
24
|
type vtkOpenGLRenderWindowBase = vtkObject & Omit<vtkAlgorithm,
|
|
24
25
|
| 'getInputData'
|
|
@@ -32,7 +33,7 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Builds myself.
|
|
35
|
-
* @param {Boolean} prepass
|
|
36
|
+
* @param {Boolean} prepass
|
|
36
37
|
*/
|
|
37
38
|
buildPass(prepass: boolean): void;
|
|
38
39
|
|
|
@@ -45,12 +46,12 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
45
46
|
initialize(): void;
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
*
|
|
49
50
|
*/
|
|
50
51
|
makeCurrent(): void;
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
+
*
|
|
54
55
|
* @param {HTMLElement} el The container element.
|
|
55
56
|
*/
|
|
56
57
|
setContainer(el: HTMLElement): void;
|
|
@@ -91,170 +92,170 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
91
92
|
getViewportCenter(viewport: vtkRenderer): Vector2;
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {Number} x
|
|
96
|
-
* @param {Number} y
|
|
97
|
-
* @param {Number} z
|
|
95
|
+
*
|
|
96
|
+
* @param {Number} x
|
|
97
|
+
* @param {Number} y
|
|
98
|
+
* @param {Number} z
|
|
98
99
|
*/
|
|
99
100
|
displayToNormalizedDisplay(x: number, y: number, z: number): Vector3;
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @param {Number} x
|
|
104
|
-
* @param {Number} y
|
|
105
|
-
* @param {Number} z
|
|
103
|
+
*
|
|
104
|
+
* @param {Number} x
|
|
105
|
+
* @param {Number} y
|
|
106
|
+
* @param {Number} z
|
|
106
107
|
*/
|
|
107
108
|
normalizedDisplayToDisplay(x: number, y: number, z: number): Vector3;
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {Number} x
|
|
112
|
-
* @param {Number} y
|
|
113
|
-
* @param {Number} z
|
|
114
|
-
* @param {vtkRenderer} renderer
|
|
111
|
+
*
|
|
112
|
+
* @param {Number} x
|
|
113
|
+
* @param {Number} y
|
|
114
|
+
* @param {Number} z
|
|
115
|
+
* @param {vtkRenderer} renderer
|
|
115
116
|
*/
|
|
116
117
|
worldToView(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @param {Number} x
|
|
121
|
-
* @param {Number} y
|
|
122
|
-
* @param {Number} z
|
|
123
|
-
* @param {vtkRenderer} renderer
|
|
120
|
+
*
|
|
121
|
+
* @param {Number} x
|
|
122
|
+
* @param {Number} y
|
|
123
|
+
* @param {Number} z
|
|
124
|
+
* @param {vtkRenderer} renderer
|
|
124
125
|
*/
|
|
125
126
|
viewToWorld(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
126
127
|
|
|
127
128
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @param {Number} x
|
|
130
|
-
* @param {Number} y
|
|
131
|
-
* @param {Number} z
|
|
132
|
-
* @param {vtkRenderer} renderer
|
|
129
|
+
*
|
|
130
|
+
* @param {Number} x
|
|
131
|
+
* @param {Number} y
|
|
132
|
+
* @param {Number} z
|
|
133
|
+
* @param {vtkRenderer} renderer
|
|
133
134
|
*/
|
|
134
135
|
worldToDisplay(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
|
-
*
|
|
138
|
-
* @param {Number} x
|
|
139
|
-
* @param {Number} y
|
|
140
|
-
* @param {Number} z
|
|
141
|
-
* @param {vtkRenderer} renderer
|
|
138
|
+
*
|
|
139
|
+
* @param {Number} x
|
|
140
|
+
* @param {Number} y
|
|
141
|
+
* @param {Number} z
|
|
142
|
+
* @param {vtkRenderer} renderer
|
|
142
143
|
*/
|
|
143
144
|
displayToWorld(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {Number} x
|
|
148
|
-
* @param {Number} y
|
|
149
|
-
* @param {Number} z
|
|
150
|
-
* @param {vtkRenderer} renderer
|
|
147
|
+
*
|
|
148
|
+
* @param {Number} x
|
|
149
|
+
* @param {Number} y
|
|
150
|
+
* @param {Number} z
|
|
151
|
+
* @param {vtkRenderer} renderer
|
|
151
152
|
*/
|
|
152
153
|
normalizedDisplayToViewport(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
153
154
|
|
|
154
155
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {Number} x
|
|
157
|
-
* @param {Number} y
|
|
158
|
-
* @param {Number} z
|
|
159
|
-
* @param {vtkRenderer} renderer
|
|
156
|
+
*
|
|
157
|
+
* @param {Number} x
|
|
158
|
+
* @param {Number} y
|
|
159
|
+
* @param {Number} z
|
|
160
|
+
* @param {vtkRenderer} renderer
|
|
160
161
|
*/
|
|
161
162
|
viewportToNormalizedViewport(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
162
163
|
|
|
163
164
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @param {Number} x
|
|
166
|
-
* @param {Number} y
|
|
167
|
-
* @param {Number} z
|
|
165
|
+
*
|
|
166
|
+
* @param {Number} x
|
|
167
|
+
* @param {Number} y
|
|
168
|
+
* @param {Number} z
|
|
168
169
|
*/
|
|
169
170
|
normalizedViewportToViewport(x: number, y: number, z: number): Vector3;
|
|
170
171
|
|
|
171
172
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @param {Number} x
|
|
174
|
-
* @param {Number} y
|
|
175
|
-
* @param {Number} z
|
|
173
|
+
*
|
|
174
|
+
* @param {Number} x
|
|
175
|
+
* @param {Number} y
|
|
176
|
+
* @param {Number} z
|
|
176
177
|
*/
|
|
177
178
|
displayToLocalDisplay(x: number, y: number, z: number): Vector3;
|
|
178
179
|
|
|
179
180
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @param {Number} x
|
|
182
|
-
* @param {Number} y
|
|
183
|
-
* @param {Number} z
|
|
184
|
-
* @param {vtkRenderer} renderer
|
|
181
|
+
*
|
|
182
|
+
* @param {Number} x
|
|
183
|
+
* @param {Number} y
|
|
184
|
+
* @param {Number} z
|
|
185
|
+
* @param {vtkRenderer} renderer
|
|
185
186
|
*/
|
|
186
187
|
viewportToNormalizedDisplay(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
187
188
|
|
|
188
189
|
/**
|
|
189
|
-
*
|
|
190
|
-
* @param {Number} x1
|
|
191
|
-
* @param {Number} y1
|
|
192
|
-
* @param {Number} x2
|
|
193
|
-
* @param {Number} y2
|
|
190
|
+
*
|
|
191
|
+
* @param {Number} x1
|
|
192
|
+
* @param {Number} y1
|
|
193
|
+
* @param {Number} x2
|
|
194
|
+
* @param {Number} y2
|
|
194
195
|
*/
|
|
195
196
|
getPixelData(x1: number, y1: number, x2: number, y2: number): Uint8Array;
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
*
|
|
199
|
-
* @param options
|
|
199
|
+
*
|
|
200
|
+
* @param options
|
|
200
201
|
*/
|
|
201
202
|
get3DContext(options: object): WebGLRenderingContext | null;
|
|
202
203
|
|
|
203
204
|
/**
|
|
204
|
-
*
|
|
205
|
+
*
|
|
205
206
|
*/
|
|
206
207
|
startVR(): void;
|
|
207
208
|
|
|
208
209
|
/**
|
|
209
|
-
*
|
|
210
|
+
*
|
|
210
211
|
*/
|
|
211
212
|
stopVR(): void;
|
|
212
213
|
|
|
213
214
|
/**
|
|
214
|
-
*
|
|
215
|
+
*
|
|
215
216
|
*/
|
|
216
217
|
vrRender(): void;
|
|
217
218
|
|
|
218
219
|
/**
|
|
219
|
-
*
|
|
220
|
+
*
|
|
220
221
|
*/
|
|
221
222
|
restoreContext(): void;
|
|
222
223
|
|
|
223
224
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param {vtkTexture} texture
|
|
225
|
+
*
|
|
226
|
+
* @param {vtkTexture} texture
|
|
226
227
|
*/
|
|
227
228
|
activateTexture(texture: vtkTexture): void;
|
|
228
229
|
|
|
229
230
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param {vtkTexture} texture
|
|
231
|
+
*
|
|
232
|
+
* @param {vtkTexture} texture
|
|
232
233
|
*/
|
|
233
234
|
deactivateTexture(texture: vtkTexture): void;
|
|
234
235
|
|
|
235
236
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {vtkTexture} texture
|
|
237
|
+
*
|
|
238
|
+
* @param {vtkTexture} texture
|
|
238
239
|
*/
|
|
239
240
|
getTextureUnitForTexture(texture: vtkTexture): number;
|
|
240
241
|
|
|
241
242
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @param vtktype
|
|
244
|
-
* @param numComps
|
|
245
|
-
* @param useFloat
|
|
243
|
+
*
|
|
244
|
+
* @param vtktype
|
|
245
|
+
* @param numComps
|
|
246
|
+
* @param useFloat
|
|
246
247
|
*/
|
|
247
248
|
getDefaultTextureInternalFormat(vtktype: VtkDataTypes, numComps: number, useFloat: boolean): void;
|
|
248
249
|
|
|
249
250
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @param {HTMLImageElement} img
|
|
251
|
+
*
|
|
252
|
+
* @param {HTMLImageElement} img
|
|
252
253
|
*/
|
|
253
254
|
setBackgroundImage(img: HTMLImageElement): void;
|
|
254
255
|
|
|
255
256
|
/**
|
|
256
|
-
*
|
|
257
|
-
* @param {Boolean} value
|
|
257
|
+
*
|
|
258
|
+
* @param {Boolean} value
|
|
258
259
|
*/
|
|
259
260
|
setUseBackgroundImage(value: boolean): void;
|
|
260
261
|
|
|
@@ -269,70 +270,70 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
269
270
|
* size. If no `size` or `scale` are provided, the current renderwindow
|
|
270
271
|
* size is assumed. The default format is "image/png". Returns a promise
|
|
271
272
|
* that resolves to the captured screenshot.
|
|
272
|
-
* @param {String} format
|
|
273
|
-
* @param {IOptions} options
|
|
273
|
+
* @param {String} format
|
|
274
|
+
* @param {IOptions} options
|
|
274
275
|
*/
|
|
275
276
|
captureNextImage(format: string, options: IOptions): Promise<string> | null;
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
|
-
*
|
|
279
|
+
*
|
|
279
280
|
*/
|
|
280
281
|
getGLInformations(): object;
|
|
281
282
|
|
|
282
283
|
/**
|
|
283
|
-
*
|
|
284
|
+
*
|
|
284
285
|
*/
|
|
285
286
|
traverseAllPasses(): void;
|
|
286
287
|
|
|
287
288
|
/**
|
|
288
|
-
*
|
|
289
|
+
*
|
|
289
290
|
*/
|
|
290
291
|
disableCullFace(): void;
|
|
291
292
|
|
|
292
293
|
/**
|
|
293
|
-
*
|
|
294
|
+
*
|
|
294
295
|
*/
|
|
295
296
|
enableCullFace(): void;
|
|
296
297
|
|
|
297
298
|
/**
|
|
298
|
-
*
|
|
299
|
-
* @param stream
|
|
299
|
+
*
|
|
300
|
+
* @param stream
|
|
300
301
|
*/
|
|
301
|
-
setViewStream(stream:
|
|
302
|
+
setViewStream(stream: vtkViewStream): boolean;
|
|
302
303
|
|
|
303
304
|
/**
|
|
304
|
-
*
|
|
305
|
-
* @param {Vector2} size
|
|
305
|
+
*
|
|
306
|
+
* @param {Vector2} size
|
|
306
307
|
*/
|
|
307
308
|
setSize(size: Vector2): void;
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
|
-
*
|
|
311
|
-
* @param {Number} x
|
|
312
|
-
* @param {Number} y
|
|
311
|
+
*
|
|
312
|
+
* @param {Number} x
|
|
313
|
+
* @param {Number} y
|
|
313
314
|
*/
|
|
314
315
|
setSize(x: number, y: number): void;
|
|
315
316
|
|
|
316
317
|
/**
|
|
317
|
-
*
|
|
318
|
+
*
|
|
318
319
|
*/
|
|
319
320
|
getSize(): Vector2;
|
|
320
321
|
|
|
321
322
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @param {Vector2} size
|
|
323
|
+
*
|
|
324
|
+
* @param {Vector2} size
|
|
324
325
|
*/
|
|
325
326
|
setVrResolution(size: Vector2): void;
|
|
326
327
|
|
|
327
328
|
/**
|
|
328
|
-
*
|
|
329
|
-
* @param {Number} x
|
|
330
|
-
* @param {Number} y
|
|
329
|
+
*
|
|
330
|
+
* @param {Number} x
|
|
331
|
+
* @param {Number} y
|
|
331
332
|
*/
|
|
332
333
|
setVrResolution(x: number, y: number): void;
|
|
333
334
|
|
|
334
335
|
/**
|
|
335
|
-
*
|
|
336
|
+
*
|
|
336
337
|
*/
|
|
337
338
|
getVrResolution(): Vector2;
|
|
338
339
|
}
|
|
@@ -353,20 +354,20 @@ export function extend(publicAPI: object, model: object, initialValues?: IOpenGL
|
|
|
353
354
|
export function newInstance(initialValues?: IOpenGLRenderWindowInitialValues): vtkOpenGLRenderWindow;
|
|
354
355
|
|
|
355
356
|
/**
|
|
356
|
-
*
|
|
357
|
-
* @param cb
|
|
357
|
+
*
|
|
358
|
+
* @param cb
|
|
358
359
|
*/
|
|
359
360
|
export function pushMonitorGLContextCount(cb: any): void;
|
|
360
361
|
|
|
361
362
|
/**
|
|
362
|
-
*
|
|
363
|
-
* @param cb
|
|
363
|
+
*
|
|
364
|
+
* @param cb
|
|
364
365
|
*/
|
|
365
366
|
export function popMonitorGLContextCount(cb: any): void;
|
|
366
367
|
|
|
367
368
|
/**
|
|
368
369
|
* WebGL rendering window
|
|
369
|
-
*
|
|
370
|
+
*
|
|
370
371
|
* vtkOpenGLRenderWindow is designed to view/render a vtkRenderWindow.
|
|
371
372
|
*/
|
|
372
373
|
export declare const vtkOpenGLRenderWindow: {
|
|
@@ -816,6 +816,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
816
816
|
return true;
|
|
817
817
|
};
|
|
818
818
|
|
|
819
|
+
publicAPI.createSelector = function () {
|
|
820
|
+
var ret = vtkHardwareSelector.newInstance();
|
|
821
|
+
ret.setOpenGLRenderWindow(publicAPI);
|
|
822
|
+
return ret;
|
|
823
|
+
};
|
|
824
|
+
|
|
819
825
|
publicAPI.delete = macro.chain(publicAPI.delete, publicAPI.setViewStream, deleteGLContext);
|
|
820
826
|
} // ----------------------------------------------------------------------------
|
|
821
827
|
// Object factory
|
|
@@ -123,6 +123,11 @@ function vtkRenderWindowViewNode(publicAPI, model) {
|
|
|
123
123
|
macro.vtkErrorMacro('not implemented');
|
|
124
124
|
return undefined;
|
|
125
125
|
};
|
|
126
|
+
|
|
127
|
+
publicAPI.createSelector = function () {
|
|
128
|
+
macro.vtkErrorMacro('not implemented');
|
|
129
|
+
return undefined;
|
|
130
|
+
};
|
|
126
131
|
} // ----------------------------------------------------------------------------
|
|
127
132
|
// Object factory
|
|
128
133
|
// ----------------------------------------------------------------------------
|
|
@@ -11,7 +11,7 @@ function vtkWebGPUFullScreenQuad(publicAPI, model) {
|
|
|
11
11
|
|
|
12
12
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
13
13
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
14
|
-
vDesc.addBuiltinOutput('vec4<f32>', '
|
|
14
|
+
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
15
15
|
var code = vDesc.getCode();
|
|
16
16
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', ['output.tcoordVS = vec2<f32>(vertexBC.x * 0.5 + 0.5, 1.0 - vertexBC.y * 0.5 - 0.5);', 'output.Position = vec4<f32>(vertexBC, 1.0);']).result;
|
|
17
17
|
vDesc.setCode(code);
|
|
@@ -21,8 +21,8 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
21
21
|
|
|
22
22
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
23
23
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
24
|
-
vDesc.addBuiltinInput('u32', '
|
|
25
|
-
vDesc.addBuiltinOutput('vec4<f32>', '
|
|
24
|
+
vDesc.addBuiltinInput('u32', '@builtin(instance_index) instanceIndex');
|
|
25
|
+
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
26
26
|
var code = vDesc.getCode();
|
|
27
27
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' output.Position = rendererUBO.SCPCMatrix*mapperUBO.BCSCMatrix', ' *glyphSSBO.values[input.instanceIndex].matrix', ' *vertexBC;']).result;
|
|
28
28
|
vDesc.setCode(code);
|
|
@@ -278,6 +278,7 @@ function vtkWebGPUHardwareSelector(publicAPI, model) {
|
|
|
278
278
|
// result object (by value in most cases)
|
|
279
279
|
|
|
280
280
|
result = {
|
|
281
|
+
area: [0, 0, texture.getWidth() - 1, texture.getHeight() - 1],
|
|
281
282
|
captureZValues: model.captureZValues,
|
|
282
283
|
fieldAssociation: model.fieldAssociation,
|
|
283
284
|
renderer: renderer,
|
|
@@ -11,7 +11,7 @@ import { InterpolationType } from '../Core/ImageProperty/Constants.js';
|
|
|
11
11
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
12
12
|
|
|
13
13
|
var SlicingMode = Constants.SlicingMode;
|
|
14
|
-
var imgFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Image::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
14
|
+
var imgFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Image::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(fragment)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n //VTK::Image::Sample\n\n // var computedColor: vec4<f32> = vec4<f32>(1.0,0.7, 0.5, 1.0);\n\n//VTK::RenderEncoder::Impl\n\n return output;\n}\n"; // ----------------------------------------------------------------------------
|
|
15
15
|
// helper methods
|
|
16
16
|
// ----------------------------------------------------------------------------
|
|
17
17
|
|
|
@@ -318,7 +318,7 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
318
318
|
|
|
319
319
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
320
320
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
321
|
-
vDesc.addBuiltinOutput('vec4<f32>', '
|
|
321
|
+
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
322
322
|
var code = vDesc.getCode();
|
|
323
323
|
var lines = ['var pos: vec4<f32> = mapperUBO.Origin +', ' (vertexBC.x * 0.5 + 0.5) * mapperUBO.Axis1 + (vertexBC.y * 0.5 + 0.5) * mapperUBO.Axis2;', 'pos.w = 1.0;'];
|
|
324
324
|
|
|
@@ -6,8 +6,8 @@ import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
|
6
6
|
import vtkWebGPUShaderDescription from './ShaderDescription.js';
|
|
7
7
|
import vtkWebGPUVertexInput from './VertexInput.js';
|
|
8
8
|
|
|
9
|
-
var vtkWebGPUMapperHelperVS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
10
|
-
var vtkWebGPUMapperHelperFS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
9
|
+
var vtkWebGPUMapperHelperVS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(vertex)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : vertexOutput;\n\n // var vertex: vec4<f32> = vertexBC;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n //VTK::Position::Impl\n\n return output;\n}\n";
|
|
10
|
+
var vtkWebGPUMapperHelperFS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(fragment)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : fragmentOutput;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::Light::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n // var computedColor:vec4<f32> = vec4<f32>(1.0,0.5,0.5,1.0);\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n"; // ----------------------------------------------------------------------------
|
|
11
11
|
// vtkWebGPUMapperHelper methods
|
|
12
12
|
// ----------------------------------------------------------------------------
|
|
13
13
|
|
|
@@ -94,7 +94,7 @@ function vtkWebGPUMapperHelper(publicAPI, model) {
|
|
|
94
94
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Mapper::Dec', [ubocode]).result;
|
|
95
95
|
vDesc.setCode(code);
|
|
96
96
|
var fDesc = pipeline.getShaderDescription('fragment');
|
|
97
|
-
fDesc.addBuiltinInput('bool', '
|
|
97
|
+
fDesc.addBuiltinInput('bool', '@builtin(front_facing) frontFacing');
|
|
98
98
|
code = fDesc.getCode();
|
|
99
99
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Mapper::Dec', [ubocode]).result;
|
|
100
100
|
fDesc.setCode(code);
|
|
@@ -104,7 +104,7 @@ function vtkWebGPUMapperHelper(publicAPI, model) {
|
|
|
104
104
|
|
|
105
105
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
106
106
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
107
|
-
vDesc.addBuiltinOutput('vec4<f32>', '
|
|
107
|
+
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
108
108
|
var code = vDesc.getCode();
|
|
109
109
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' output.Position = rendererUBO.SCPCMatrix*vertexBC;']).result;
|
|
110
110
|
vDesc.setCode(code);
|
|
@@ -5,7 +5,7 @@ import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
|
5
5
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
6
6
|
import vtkWebGPUFullScreenQuad from './FullScreenQuad.js';
|
|
7
7
|
|
|
8
|
-
var oitpFragTemplate = "\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
8
|
+
var oitpFragTemplate = "\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(fragment)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n var tcoord: vec2<i32> = vec2<i32>(i32(input.fragPos.x), i32(input.fragPos.y));\n var reveal: f32 = textureLoad(oitpAccumTexture, tcoord, 0).r;\n if (reveal == 1.0) { discard; }\n var tcolor: vec4<f32> = textureLoad(oitpColorTexture, tcoord, 0);\n var total: f32 = max(tcolor.a, 0.01);\n var computedColor: vec4<f32> = vec4<f32>(tcolor.r/total, tcolor.g/total, tcolor.b/total, 1.0 - reveal);\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n";
|
|
9
9
|
|
|
10
10
|
function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
11
11
|
// Set our className
|
|
@@ -110,7 +110,7 @@ function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
110
110
|
var fDesc = pipeline.getShaderDescription('fragment');
|
|
111
111
|
fDesc.addOutput('vec4<f32>', 'outColor');
|
|
112
112
|
fDesc.addOutput('f32', 'outAccum');
|
|
113
|
-
fDesc.addBuiltinInput('vec4<f32>', '
|
|
113
|
+
fDesc.addBuiltinInput('vec4<f32>', '@builtin(position) fragPos');
|
|
114
114
|
var code = fDesc.getCode();
|
|
115
115
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', [// very simple depth weighting in w
|
|
116
116
|
'var w: f32 = 1.0 - input.fragPos.z * 0.9;', 'output.outColor = vec4<f32>(computedColor.rgb*computedColor.a, computedColor.a) * w;', 'output.outAccum = computedColor.a;']).result;
|
|
@@ -168,7 +168,7 @@ function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
168
168
|
model.translucentFinalEncoder.setReplaceShaderCodeFunction(function (pipeline) {
|
|
169
169
|
var fDesc = pipeline.getShaderDescription('fragment');
|
|
170
170
|
fDesc.addOutput('vec4<f32>', 'outColor');
|
|
171
|
-
fDesc.addBuiltinInput('vec4<f32>', '
|
|
171
|
+
fDesc.addBuiltinInput('vec4<f32>', '@builtin(position) fragPos');
|
|
172
172
|
var code = fDesc.getCode();
|
|
173
173
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', ['output.outColor = vec4<f32>(computedColor.rgb*computedColor.a, computedColor.a);']).result;
|
|
174
174
|
fDesc.setCode(code);
|
|
@@ -20,8 +20,8 @@ var StartEvent = {
|
|
|
20
20
|
var EndEvent = {
|
|
21
21
|
type: 'EndEvent'
|
|
22
22
|
};
|
|
23
|
-
var vtkWebGPUPolyDataVS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
24
|
-
var vtkWebGPUPolyDataFS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
23
|
+
var vtkWebGPUPolyDataVS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(vertex)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : vertexOutput;\n\n var vertex: vec4<f32> = vertexBC;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n //VTK::Position::Impl\n\n return output;\n}\n";
|
|
24
|
+
var vtkWebGPUPolyDataFS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(fragment)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : fragmentOutput;\n\n var ambientColor: vec4<f32> = mapperUBO.AmbientColor;\n var diffuseColor: vec4<f32> = mapperUBO.DiffuseColor;\n var opacity: f32 = mapperUBO.Opacity;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::Light::Impl\n\n var computedColor: vec4<f32> = vec4<f32>(ambientColor.rgb * mapperUBO.AmbientIntensity\n + diffuse * mapperUBO.DiffuseIntensity\n + specular * mapperUBO.SpecularIntensity,\n opacity);\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n if (computedColor.a == 0.0) { discard; };\n\n //VTK::Position::Impl\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n";
|
|
25
25
|
|
|
26
26
|
function isEdges(hash) {
|
|
27
27
|
// edge pipelines have "edge" in them
|
|
@@ -104,11 +104,11 @@ function vtkWebGPUPolyDataMapper(publicAPI, model) {
|
|
|
104
104
|
|
|
105
105
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
106
106
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
107
|
-
vDesc.addBuiltinOutput('vec4<f32>', '
|
|
107
|
+
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
108
108
|
var code = vDesc.getCode();
|
|
109
109
|
|
|
110
110
|
if (isEdges(hash)) {
|
|
111
|
-
vDesc.addBuiltinInput('u32', '
|
|
111
|
+
vDesc.addBuiltinInput('u32', '@builtin(instance_index) instanceIndex'); // widen the edge
|
|
112
112
|
|
|
113
113
|
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' var tmpPos: vec4<f32> = rendererUBO.SCPCMatrix*mapperUBO.BCSCMatrix*vertexBC;', ' var tmpPos2: vec3<f32> = tmpPos.xyz / tmpPos.w;', ' tmpPos2.x = tmpPos2.x + 1.4*(f32(input.instanceIndex % 2u) - 0.5)/rendererUBO.viewportSize.x;', ' tmpPos2.y = tmpPos2.y + 1.4*(f32(input.instanceIndex / 2u) - 0.5)/rendererUBO.viewportSize.y;', ' tmpPos2.z = tmpPos2.z + 0.00001;', // could become a setting
|
|
114
114
|
' output.Position = vec4<f32>(tmpPos2.xyz * tmpPos.w, tmpPos.w);']).result;
|
|
@@ -66,6 +66,7 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
66
66
|
|
|
67
67
|
publicAPI.recreateSwapChain = function () {
|
|
68
68
|
if (model.context) {
|
|
69
|
+
model.context.unconfigure();
|
|
69
70
|
var presentationFormat = model.context.getPreferredFormat(model.adapter);
|
|
70
71
|
/* eslint-disable no-undef */
|
|
71
72
|
|
|
@@ -77,6 +78,7 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
77
78
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST,
|
|
78
79
|
size: model.size
|
|
79
80
|
});
|
|
81
|
+
model._configured = true;
|
|
80
82
|
}
|
|
81
83
|
};
|
|
82
84
|
|
|
@@ -96,7 +98,7 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
96
98
|
publicAPI.removeUnusedNodes();
|
|
97
99
|
publicAPI.initialize();
|
|
98
100
|
} else if (model.initialized) {
|
|
99
|
-
if (!model.
|
|
101
|
+
if (!model._configured) {
|
|
100
102
|
publicAPI.recreateSwapChain();
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -596,6 +598,13 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
596
598
|
}
|
|
597
599
|
}, _callee2);
|
|
598
600
|
}));
|
|
601
|
+
|
|
602
|
+
publicAPI.createSelector = function () {
|
|
603
|
+
var ret = vtkWebGPUHardwareSelector.newInstance();
|
|
604
|
+
ret.setWebGPURenderWindow(publicAPI);
|
|
605
|
+
return ret;
|
|
606
|
+
};
|
|
607
|
+
|
|
599
608
|
publicAPI.delete = macro.chain(publicAPI.delete, publicAPI.setViewStream);
|
|
600
609
|
} // ----------------------------------------------------------------------------
|
|
601
610
|
// Object factory
|
|
@@ -7,7 +7,7 @@ import vtkWebGPUUniformBuffer from './UniformBuffer.js';
|
|
|
7
7
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
8
8
|
|
|
9
9
|
var vtkDebugMacro = vtkDebugMacro$1;
|
|
10
|
-
var clearFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n
|
|
10
|
+
var clearFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n@stage(fragment)\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n var computedColor: vec4<f32> = mapperUBO.BackgroundColor;\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n"; // ----------------------------------------------------------------------------
|
|
11
11
|
// vtkWebGPURenderer methods
|
|
12
12
|
// ----------------------------------------------------------------------------
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ function vtkWebGPUSampler(publicAPI, model) {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
publicAPI.getShaderCode = function (binding, group) {
|
|
22
|
-
var result = "
|
|
22
|
+
var result = "@binding(".concat(binding, ") @group(").concat(group, ") var ").concat(model.name, ": sampler;");
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -51,9 +51,9 @@ function vtkWebGPUShaderDescription(publicAPI, model) {
|
|
|
51
51
|
|
|
52
52
|
for (var i = 0; i < inputNames.length; i++) {
|
|
53
53
|
if (inputInterpolations[i] !== undefined) {
|
|
54
|
-
inputStruct.push("
|
|
54
|
+
inputStruct.push(" @location(".concat(i, ") @interpolate(").concat(inputInterpolations[i], ") ").concat(inputNames[i], " : ").concat(inputTypes[i], ";"));
|
|
55
55
|
} else {
|
|
56
|
-
inputStruct.push("
|
|
56
|
+
inputStruct.push(" @location(".concat(i, ") ").concat(inputNames[i], " : ").concat(inputTypes[i], ";"));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -79,9 +79,9 @@ function vtkWebGPUShaderDescription(publicAPI, model) {
|
|
|
79
79
|
|
|
80
80
|
for (var _i2 = 0; _i2 < model.outputNames.length; _i2++) {
|
|
81
81
|
if (model.outputInterpolations[_i2] !== undefined) {
|
|
82
|
-
outputStruct.push("
|
|
82
|
+
outputStruct.push(" @location(".concat(_i2, ") @interpolate(").concat(model.outputInterpolations[_i2], ") ").concat(model.outputNames[_i2], " : ").concat(model.outputTypes[_i2], ";"));
|
|
83
83
|
} else {
|
|
84
|
-
outputStruct.push("
|
|
84
|
+
outputStruct.push(" @location(".concat(_i2, ") ").concat(model.outputNames[_i2], " : ").concat(model.outputTypes[_i2], ";"));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|