@kitware/vtk.js 22.5.3 → 22.5.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/Rendering/Core/ScalarBarActor.js +3 -28
- package/Rendering/Core/Texture.js +44 -4
- package/Rendering/Misc/SynchronizableRenderWindow.d.ts +109 -17
- package/Rendering/OpenGL/HardwareSelector.js +2 -2
- package/Rendering/OpenGL/ShaderCache.js +2 -2
- package/Rendering/OpenGL/Texture.js +38 -11
- package/Rendering/WebGPU/PolyDataMapper.js +10 -2
- package/Rendering/WebGPU/Texture.js +23 -2
- package/Rendering/WebGPU/TextureManager.js +29 -3
- package/package.json +2 -2
|
@@ -221,22 +221,6 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
221
221
|
model.lastRedrawTime.modified();
|
|
222
222
|
model.forceViewUpdate = false;
|
|
223
223
|
}
|
|
224
|
-
}; // The text atlas is an image and as loading images is async we call this when
|
|
225
|
-
// the promise resolves. The old texture is used until then
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
publicAPI.completedImage = function (doUpdate) {
|
|
229
|
-
if (model.nextImage && model.nextImage.complete) {
|
|
230
|
-
model.tmTexture.setImage(model.nextImage);
|
|
231
|
-
model.nextImage = null;
|
|
232
|
-
model._tmAtlas = model._nextAtlas;
|
|
233
|
-
model._nextAtlas = null;
|
|
234
|
-
|
|
235
|
-
if (doUpdate) {
|
|
236
|
-
model.forceViewUpdate = true;
|
|
237
|
-
model.renderWindow.render();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
224
|
}; // create the texture map atlas that contains the rendering of
|
|
241
225
|
// all the text strings. Only needs to be called when the text strings
|
|
242
226
|
// have changed (labels and ticks)
|
|
@@ -317,19 +301,10 @@ function vtkScalarBarActorHelper(publicAPI, model) {
|
|
|
317
301
|
applyTextStyle(model.tmContext, value.textStyle);
|
|
318
302
|
model.tmContext.fillText(key, 1, value.startingHeight + value.height - 1);
|
|
319
303
|
});
|
|
320
|
-
|
|
321
|
-
image.src = model.tmCanvas.toDataURL('image/png');
|
|
322
|
-
model.nextImage = image;
|
|
323
|
-
model._nextAtlas = newTmAtlas;
|
|
324
|
-
|
|
325
|
-
if (image.complete) {
|
|
326
|
-
publicAPI.completedImage(false);
|
|
327
|
-
} else {
|
|
328
|
-
image.addEventListener('load', function () {
|
|
329
|
-
publicAPI.completedImage(true);
|
|
330
|
-
});
|
|
331
|
-
}
|
|
304
|
+
model.tmTexture.setCanvas(model.tmCanvas); // mark as modified since the canvas typically doesn't change
|
|
332
305
|
|
|
306
|
+
model.tmTexture.modified();
|
|
307
|
+
model._tmAtlas = newTmAtlas;
|
|
333
308
|
return results;
|
|
334
309
|
};
|
|
335
310
|
|
|
@@ -13,14 +13,52 @@ function vtkTexture(publicAPI, model) {
|
|
|
13
13
|
publicAPI.modified();
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
publicAPI.setJsImageData = function (imageData) {
|
|
17
|
+
if (model.jsImageData === imageData) {
|
|
18
|
+
return;
|
|
19
|
+
} // clear other entries
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if (imageData !== null) {
|
|
23
|
+
publicAPI.setInputData(null);
|
|
24
|
+
publicAPI.setInputConnection(null);
|
|
25
|
+
model.image = null;
|
|
26
|
+
model.canvas = null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
model.jsImageData = imageData;
|
|
30
|
+
model.imageLoaded = true;
|
|
31
|
+
publicAPI.modified();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
publicAPI.setCanvas = function (canvas) {
|
|
35
|
+
if (model.canvas === canvas) {
|
|
36
|
+
return;
|
|
37
|
+
} // clear other entries
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (canvas !== null) {
|
|
41
|
+
publicAPI.setInputData(null);
|
|
42
|
+
publicAPI.setInputConnection(null);
|
|
43
|
+
model.image = null;
|
|
44
|
+
model.jsImageData = null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
model.canvas = canvas;
|
|
48
|
+
publicAPI.modified();
|
|
49
|
+
};
|
|
50
|
+
|
|
16
51
|
publicAPI.setImage = function (image) {
|
|
17
52
|
if (model.image === image) {
|
|
18
53
|
return;
|
|
19
|
-
}
|
|
54
|
+
} // clear other entries
|
|
55
|
+
|
|
20
56
|
|
|
21
57
|
if (image !== null) {
|
|
22
58
|
publicAPI.setInputData(null);
|
|
23
59
|
publicAPI.setInputConnection(null);
|
|
60
|
+
model.canvas = null;
|
|
61
|
+
model.jsImageData = null;
|
|
24
62
|
}
|
|
25
63
|
|
|
26
64
|
model.image = image;
|
|
@@ -44,7 +82,9 @@ var DEFAULT_VALUES = {
|
|
|
44
82
|
interpolate: false,
|
|
45
83
|
edgeClamp: false,
|
|
46
84
|
image: null,
|
|
47
|
-
|
|
85
|
+
canvas: null,
|
|
86
|
+
imageLoaded: false,
|
|
87
|
+
jsImageData: null
|
|
48
88
|
}; // ----------------------------------------------------------------------------
|
|
49
89
|
|
|
50
90
|
function extend(publicAPI, model) {
|
|
@@ -53,8 +93,8 @@ function extend(publicAPI, model) {
|
|
|
53
93
|
|
|
54
94
|
macro.obj(publicAPI, model);
|
|
55
95
|
macro.algo(publicAPI, model, 6, 0);
|
|
56
|
-
macro.get(publicAPI, model, ['imageLoaded']);
|
|
57
|
-
macro.setGet(publicAPI, model, ['repeat', 'edgeClamp', 'interpolate'
|
|
96
|
+
macro.get(publicAPI, model, ['canvas', 'image', 'jsImageData', 'imageLoaded']);
|
|
97
|
+
macro.setGet(publicAPI, model, ['repeat', 'edgeClamp', 'interpolate']);
|
|
58
98
|
vtkTexture(publicAPI, model);
|
|
59
99
|
} // ----------------------------------------------------------------------------
|
|
60
100
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import vtkRenderWindow, { IRenderWindowInitialValues } from '@kitware/vtk.js/Rendering/Core/RenderWindow';
|
|
2
2
|
|
|
3
3
|
// Keeps state for client / server scene synchronization.
|
|
4
|
-
export interface
|
|
4
|
+
export interface ISynchronizerContext {
|
|
5
5
|
// Set a function that fetches the data array for the given object.
|
|
6
6
|
setFetchArrayFunction(fetcher: (hash: string, dataType: any) => Promise<ArrayBuffer>): void;
|
|
7
7
|
// Invokes the fetcher registered by setFetchArrayFunction.
|
|
8
|
-
getArray(sha: string, dataType: any, context:
|
|
8
|
+
getArray(sha: string, dataType: any, context: ISynchronizerContext): Promise<ArrayBuffer>;
|
|
9
9
|
emptyCachedArrays(): void;
|
|
10
|
-
freeOldArrays(threshold: number, context:
|
|
10
|
+
freeOldArrays(threshold: number, context: ISynchronizerContext): void;
|
|
11
11
|
|
|
12
12
|
// instanceMap
|
|
13
13
|
getInstance(id: any): any;
|
|
@@ -25,15 +25,15 @@ export interface SynchContext {
|
|
|
25
25
|
// TODO: fill progresshandler
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export interface
|
|
28
|
+
export interface ISynchronizableRenderWindowInitialValues extends IRenderWindowInitialValues {
|
|
29
29
|
synchronizerContextName?: string; // default: 'default':
|
|
30
|
-
synchronizerContext?:
|
|
30
|
+
synchronizerContext?: ISynchronizerContext | null;
|
|
31
31
|
synchronizedViewId?: string | null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Server-side view state.
|
|
35
|
-
export interface
|
|
36
|
-
id:
|
|
35
|
+
export interface IViewState {
|
|
36
|
+
id: string;
|
|
37
37
|
// vtk object type.
|
|
38
38
|
type: string;
|
|
39
39
|
// vtk object mtime.
|
|
@@ -42,7 +42,7 @@ export interface ViewState {
|
|
|
42
42
|
parent?: string | null;
|
|
43
43
|
properties?: {[key: string]: any};
|
|
44
44
|
// Child objects.
|
|
45
|
-
dependencies?:
|
|
45
|
+
dependencies?: IViewState[];
|
|
46
46
|
extra?: any;
|
|
47
47
|
// List of [methodName, args] to be invoked on the object.
|
|
48
48
|
calls?: [string, string[]][];
|
|
@@ -50,24 +50,116 @@ export interface ViewState {
|
|
|
50
50
|
[key: string]: any;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export interface
|
|
54
|
-
|
|
53
|
+
export interface vtkSynchronizableRenderWindow extends vtkRenderWindow {
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
getSynchronizerContext(): ISynchronizerContext;
|
|
55
59
|
|
|
56
60
|
// methods added by createSyncFunction
|
|
57
|
-
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {IViewState} state
|
|
65
|
+
*/
|
|
66
|
+
synchronize(state: IViewState): Promise<boolean>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {String} viewId
|
|
71
|
+
*/
|
|
58
72
|
setSynchronizedViewId(viewId: string): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
59
77
|
getSynchronizedViewId(): string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {Number} v
|
|
82
|
+
*/
|
|
60
83
|
updateGarbageCollectorThreshold(v: number): void;
|
|
61
|
-
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
getManagedInstanceIds(): string[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
62
93
|
clearOneTimeUpdaters(): void;
|
|
63
94
|
}
|
|
64
95
|
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Method used to decorate a given object (publicAPI+model) with vtkCellArray characteristics.
|
|
98
|
+
*
|
|
99
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
100
|
+
* @param model object on which data structure will be bounds (protected)
|
|
101
|
+
* @param {ISynchronizableRenderWindowInitialValues} [initialValues] (default: {})
|
|
102
|
+
*/
|
|
103
|
+
export function extend(publicAPI: object, model: object, initialValues?: ISynchronizableRenderWindowInitialValues): void;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Method used to create a new instance of vtkSynchronizableRenderWindow
|
|
107
|
+
* @param {ISynchronizableRenderWindowInitialValues} [initialValues] for pre-setting some of its content
|
|
108
|
+
*/
|
|
109
|
+
export function newInstance(initialValues?: ISynchronizableRenderWindowInitialValues): vtkSynchronizableRenderWindow;
|
|
67
110
|
|
|
68
|
-
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @param {String} [name]
|
|
114
|
+
*/
|
|
115
|
+
export function getSynchronizerContext(name?: string): ISynchronizerContext;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @param {String} name
|
|
120
|
+
* @param {ISynchronizerContext} ctx
|
|
121
|
+
*/
|
|
122
|
+
export function setSynchronizerContext(name: string, ctx: ISynchronizerContext): ISynchronizerContext;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @param {vtkRenderWindow} renderWindow
|
|
127
|
+
* @param {String} [name]
|
|
128
|
+
*/
|
|
129
|
+
export function decorate(renderWindow: vtkRenderWindow, name?: string): object;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
export function createInstanceMap(): object;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
export function createArrayHandler(): object;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
export function createProgressHandler(): object;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
export function createSceneMtimeHandler(): object;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
export declare const vtkSynchronizableRenderWindow: {
|
|
69
155
|
newInstance: typeof newInstance;
|
|
70
156
|
getSynchronizerContext: typeof getSynchronizerContext;
|
|
157
|
+
setSynchronizerContext: typeof setSynchronizerContext;
|
|
158
|
+
decorate: typeof decorate,
|
|
159
|
+
createInstanceMap: typeof createInstanceMap,
|
|
160
|
+
createArrayHandler: typeof createArrayHandler,
|
|
161
|
+
createProgressHandler: typeof createProgressHandler,
|
|
162
|
+
createSceneMtimeHandler: typeof createSceneMtimeHandler,
|
|
163
|
+
vtkObjectManager: object
|
|
71
164
|
};
|
|
72
|
-
|
|
73
165
|
export default vtkSynchronizableRenderWindow;
|
|
@@ -57,7 +57,7 @@ function getPixelInformationWithData(buffdata, inDisplayPosition, maxDistance, o
|
|
|
57
57
|
var displayPosition = [inDisplayPosition[0] - buffdata.area[0], inDisplayPosition[1] - buffdata.area[1]];
|
|
58
58
|
var actorid = convert(displayPosition[0], displayPosition[1], buffdata.pixBuffer[PassTypes.ACTOR_PASS], buffdata.area);
|
|
59
59
|
|
|
60
|
-
if (actorid <= 0) {
|
|
60
|
+
if (actorid <= 0 || actorid - idOffset >= buffdata.props.length) {
|
|
61
61
|
// the pixel did not hit any actor.
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
@@ -520,7 +520,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
520
520
|
var displayPosition = [inDisplayPosition[0] - model.area[0], inDisplayPosition[1] - model.area[1]];
|
|
521
521
|
var actorid = convert(displayPosition[0], displayPosition[1], model.pixBuffer[PassTypes.ACTOR_PASS], model.area);
|
|
522
522
|
|
|
523
|
-
if (actorid <= 0) {
|
|
523
|
+
if (actorid <= 0 || actorid - idOffset >= model.props.length) {
|
|
524
524
|
// the pixel did not hit any actor.
|
|
525
525
|
return null;
|
|
526
526
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Md5 from 'spark-md5';
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkShaderProgram from './ShaderProgram.js';
|
|
4
4
|
|
|
@@ -88,7 +88,7 @@ function vtkShaderCache(publicAPI, model) {
|
|
|
88
88
|
publicAPI.getShaderProgram = function (vertexCode, fragmentCode, geometryCode) {
|
|
89
89
|
// compute the MD5 and the check the map
|
|
90
90
|
var hashInput = "".concat(vertexCode).concat(fragmentCode).concat(geometryCode);
|
|
91
|
-
var result =
|
|
91
|
+
var result = Md5.hash(hashInput); // does it already exist?
|
|
92
92
|
|
|
93
93
|
var loc = Object.keys(model.shaderPrograms).indexOf(result);
|
|
94
94
|
|
|
@@ -78,7 +78,36 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
78
78
|
publicAPI.sendParameters();
|
|
79
79
|
model.textureBuildTime.modified();
|
|
80
80
|
}
|
|
81
|
-
} // if we have
|
|
81
|
+
} // if we have a canvas
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if (model.renderable.getCanvas() !== null) {
|
|
85
|
+
if (model.renderable.getInterpolate()) {
|
|
86
|
+
model.generateMipmap = true;
|
|
87
|
+
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var canvas = model.renderable.getCanvas();
|
|
91
|
+
publicAPI.create2DFromRaw(canvas.width, canvas.height, 4, VtkDataTypes.UNSIGNED_CHAR, canvas, true);
|
|
92
|
+
publicAPI.activate();
|
|
93
|
+
publicAPI.sendParameters();
|
|
94
|
+
model.textureBuildTime.modified();
|
|
95
|
+
} // if we have jsImageData
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if (model.renderable.getJsImageData() !== null) {
|
|
99
|
+
var jsid = model.renderable.getJsImageData();
|
|
100
|
+
|
|
101
|
+
if (model.renderable.getInterpolate()) {
|
|
102
|
+
model.generateMipmap = true;
|
|
103
|
+
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
publicAPI.create2DFromRaw(jsid.width, jsid.height, 4, VtkDataTypes.UNSIGNED_CHAR, jsid.data, true);
|
|
107
|
+
publicAPI.activate();
|
|
108
|
+
publicAPI.sendParameters();
|
|
109
|
+
model.textureBuildTime.modified();
|
|
110
|
+
} // if we have InputData
|
|
82
111
|
|
|
83
112
|
|
|
84
113
|
var input = model.renderable.getInputData(0);
|
|
@@ -678,6 +707,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
678
707
|
|
|
679
708
|
|
|
680
709
|
publicAPI.create2DFromRaw = function (width, height, numComps, dataType, data) {
|
|
710
|
+
var flip = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
681
711
|
// Now determine the texture parameters using the arguments.
|
|
682
712
|
publicAPI.getOpenGLDataType(dataType);
|
|
683
713
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
@@ -701,13 +731,18 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
701
731
|
var dataArray = [data];
|
|
702
732
|
var pixData = updateArrayDataType(dataType, dataArray);
|
|
703
733
|
var scaledData = scaleTextureToHighestPowerOfTwo(pixData); // Source texture data from the PBO.
|
|
704
|
-
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
705
734
|
|
|
735
|
+
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, flip);
|
|
706
736
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
707
737
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, scaledData[0]);
|
|
708
738
|
|
|
709
739
|
if (model.generateMipmap) {
|
|
710
740
|
model.context.generateMipmap(model.target);
|
|
741
|
+
} // always reset the flip
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
if (flip) {
|
|
745
|
+
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, false);
|
|
711
746
|
}
|
|
712
747
|
|
|
713
748
|
publicAPI.deactivate();
|
|
@@ -867,15 +902,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
867
902
|
var ctx = canvas.getContext('2d');
|
|
868
903
|
ctx.translate(0, canvas.height);
|
|
869
904
|
ctx.scale(1, -1);
|
|
870
|
-
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
871
|
-
// canvases from working properly with webGL textures. By getting any
|
|
872
|
-
// image data from the canvas, this works around the bug. See
|
|
873
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=896307
|
|
874
|
-
|
|
875
|
-
if (navigator.userAgent.indexOf('Chrome/69') >= 0) {
|
|
876
|
-
ctx.getImageData(0, 0, 1, 1);
|
|
877
|
-
}
|
|
878
|
-
|
|
905
|
+
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
879
906
|
var safeImage = canvas;
|
|
880
907
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.format, model.openGLDataType, safeImage);
|
|
881
908
|
|
|
@@ -432,7 +432,7 @@ function vtkWebGPUPolyDataMapper(publicAPI, model) {
|
|
|
432
432
|
var textures = actor.getTextures();
|
|
433
433
|
|
|
434
434
|
for (var i = 0; i < textures.length; i++) {
|
|
435
|
-
if (textures[i].getInputData()) {
|
|
435
|
+
if (textures[i].getInputData() || textures[i].getJsImageData() || textures[i].getCanvas()) {
|
|
436
436
|
newTextures.push(textures[i]);
|
|
437
437
|
}
|
|
438
438
|
|
|
@@ -445,7 +445,9 @@ function vtkWebGPUPolyDataMapper(publicAPI, model) {
|
|
|
445
445
|
|
|
446
446
|
for (var _i = 0; _i < newTextures.length; _i++) {
|
|
447
447
|
var srcTexture = newTextures[_i];
|
|
448
|
-
var treq = {
|
|
448
|
+
var treq = {
|
|
449
|
+
time: srcTexture.getMTime()
|
|
450
|
+
};
|
|
449
451
|
|
|
450
452
|
if (srcTexture.getInputData()) {
|
|
451
453
|
treq.imageData = srcTexture.getInputData();
|
|
@@ -453,6 +455,12 @@ function vtkWebGPUPolyDataMapper(publicAPI, model) {
|
|
|
453
455
|
} else if (srcTexture.getImage()) {
|
|
454
456
|
treq.image = srcTexture.getImage();
|
|
455
457
|
treq.owner = treq.image;
|
|
458
|
+
} else if (srcTexture.getJsImageData()) {
|
|
459
|
+
treq.jsImageData = srcTexture.getJsImageData();
|
|
460
|
+
treq.owner = treq.jsImageData;
|
|
461
|
+
} else if (srcTexture.getCanvas()) {
|
|
462
|
+
treq.canvas = srcTexture.getCanvas();
|
|
463
|
+
treq.owner = treq.canvas;
|
|
456
464
|
}
|
|
457
465
|
|
|
458
466
|
var newTex = model.device.getTextureManager().getTexture(treq);
|
|
@@ -21,7 +21,7 @@ function vtkWebGPUTexture(publicAPI, model) {
|
|
|
21
21
|
model.height = options.height;
|
|
22
22
|
model.depth = options.depth ? options.depth : 1;
|
|
23
23
|
var dimension = model.depth === 1 ? '2d' : '3d';
|
|
24
|
-
model.format = options.format ? options.format : '
|
|
24
|
+
model.format = options.format ? options.format : 'rgba8unorm';
|
|
25
25
|
/* eslint-disable no-undef */
|
|
26
26
|
|
|
27
27
|
/* eslint-disable no-bitwise */
|
|
@@ -47,7 +47,7 @@ function vtkWebGPUTexture(publicAPI, model) {
|
|
|
47
47
|
model.width = options.width;
|
|
48
48
|
model.height = options.height;
|
|
49
49
|
model.depth = options.depth ? options.depth : 1;
|
|
50
|
-
model.format = options.format ? options.format : '
|
|
50
|
+
model.format = options.format ? options.format : 'rgba8unorm';
|
|
51
51
|
/* eslint-disable no-undef */
|
|
52
52
|
|
|
53
53
|
/* eslint-disable no-bitwise */
|
|
@@ -60,6 +60,27 @@ function vtkWebGPUTexture(publicAPI, model) {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
publicAPI.writeImageData = function (req) {
|
|
63
|
+
if (req.canvas) {
|
|
64
|
+
model.device.getHandle().queue.copyExternalImageToTexture({
|
|
65
|
+
source: req.canvas,
|
|
66
|
+
flipY: req.flip
|
|
67
|
+
}, {
|
|
68
|
+
texture: model.handle,
|
|
69
|
+
premultipliedAlpha: true
|
|
70
|
+
}, [model.width, model.height, model.depth]);
|
|
71
|
+
model.ready = true;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (req.jsImageData && !req.nativeArray) {
|
|
76
|
+
req.width = req.jsImageData.width;
|
|
77
|
+
req.height = req.jsImageData.height;
|
|
78
|
+
req.depth = 1;
|
|
79
|
+
req.format = 'rgba8unorm';
|
|
80
|
+
req.flip = true;
|
|
81
|
+
req.nativeArray = req.jsImageData.data;
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
var tDetails = vtkWebGPUTypes.getDetailsFromTextureFormat(model.format);
|
|
64
85
|
var bufferBytesPerRow = model.width * tDetails.stride;
|
|
65
86
|
|
|
@@ -64,11 +64,36 @@ function vtkWebGPUTextureManager(publicAPI, model) {
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
if (req.image) {
|
|
67
|
-
req.time = 0;
|
|
68
67
|
req.width = req.image.width;
|
|
69
68
|
req.height = req.image.height;
|
|
70
69
|
req.depth = 1;
|
|
71
70
|
req.format = 'rgba8unorm';
|
|
71
|
+
} // fill in based on js imageData
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if (req.jsImageData) {
|
|
75
|
+
req.width = req.jsImageData.width;
|
|
76
|
+
req.height = req.jsImageData.height;
|
|
77
|
+
req.depth = 1;
|
|
78
|
+
req.format = 'rgba8unorm';
|
|
79
|
+
req.flip = true;
|
|
80
|
+
req.nativeArray = req.jsImageData.data;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (req.canvas) {
|
|
84
|
+
req.width = req.canvas.width;
|
|
85
|
+
req.height = req.canvas.height;
|
|
86
|
+
req.depth = 1;
|
|
87
|
+
req.format = 'rgba8unorm';
|
|
88
|
+
req.flip = true;
|
|
89
|
+
/* eslint-disable no-undef */
|
|
90
|
+
|
|
91
|
+
/* eslint-disable no-bitwise */
|
|
92
|
+
|
|
93
|
+
req.usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT;
|
|
94
|
+
/* eslint-enable no-undef */
|
|
95
|
+
|
|
96
|
+
/* eslint-enable no-bitwise */
|
|
72
97
|
}
|
|
73
98
|
} // create a texture (used by getTexture)
|
|
74
99
|
|
|
@@ -79,10 +104,11 @@ function vtkWebGPUTextureManager(publicAPI, model) {
|
|
|
79
104
|
width: req.width,
|
|
80
105
|
height: req.height,
|
|
81
106
|
depth: req.depth,
|
|
82
|
-
format: req.format
|
|
107
|
+
format: req.format,
|
|
108
|
+
usage: req.usage
|
|
83
109
|
}); // fill the texture if we have data
|
|
84
110
|
|
|
85
|
-
if (req.nativeArray || req.image) {
|
|
111
|
+
if (req.nativeArray || req.image || req.canvas) {
|
|
86
112
|
newTex.writeImageData(req);
|
|
87
113
|
}
|
|
88
114
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitware/vtk.js",
|
|
3
|
-
"version": "22.5.
|
|
3
|
+
"version": "22.5.6",
|
|
4
4
|
"description": "Visualization Toolkit for the Web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"module": "./index.js",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "7.16.7",
|
|
34
|
-
"blueimp-md5": "2.19.0",
|
|
35
34
|
"commander": "8.3.0",
|
|
36
35
|
"d3-scale": "4.0.2",
|
|
37
36
|
"gl-matrix": "3.4.3",
|
|
@@ -41,6 +40,7 @@
|
|
|
41
40
|
"seedrandom": "3.0.5",
|
|
42
41
|
"shader-loader": "1.3.1",
|
|
43
42
|
"shelljs": "0.8.5",
|
|
43
|
+
"spark-md5": "^3.0.2",
|
|
44
44
|
"stream-browserify": "3.0.0",
|
|
45
45
|
"webworker-promise": "0.4.4",
|
|
46
46
|
"worker-loader": "3.0.8",
|