@kitware/vtk.js 25.3.0 → 25.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +4 -8
  2. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +6 -14
  3. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +60 -57
  4. package/IO/Core/ZipMultiDataSetReader.js +19 -29
  5. package/IO/Core/ZipMultiDataSetWriter.js +7 -23
  6. package/IO/Misc/SkyboxReader.js +67 -75
  7. package/IO/XML/XMLReader.js +2 -2
  8. package/IO/XML/XMLWriter.js +2 -2
  9. package/Interaction/Style/InteractorStyleTrackballCamera.js +16 -0
  10. package/README.md +2 -2
  11. package/Rendering/Core/Actor2D.d.ts +12 -6
  12. package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
  13. package/Rendering/Core/Property2D.d.ts +1 -1
  14. package/Rendering/Core/Renderer.d.ts +43 -3
  15. package/Rendering/Core/Renderer.js +5 -1
  16. package/Rendering/Core/Texture.d.ts +22 -0
  17. package/Rendering/Core/Texture.js +159 -10
  18. package/Rendering/Core/VolumeProperty.d.ts +4 -4
  19. package/Rendering/Core/VolumeProperty.js +1 -1
  20. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +65 -0
  21. package/Rendering/OpenGL/RenderWindow.js +3 -1
  22. package/Rendering/WebGPU/CellArrayMapper.js +43 -13
  23. package/Rendering/WebGPU/ForwardPass.js +93 -15
  24. package/Rendering/WebGPU/FullScreenQuad.js +2 -1
  25. package/Rendering/WebGPU/OpaquePass.js +1 -1
  26. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  27. package/Rendering/WebGPU/RenderEncoder.js +9 -5
  28. package/Rendering/WebGPU/RenderWindow.js +15 -13
  29. package/Rendering/WebGPU/Renderer.js +77 -5
  30. package/Rendering/WebGPU/Sampler.js +4 -0
  31. package/Rendering/WebGPU/Texture.js +78 -46
  32. package/Rendering/WebGPU/TextureManager.js +5 -3
  33. package/Rendering/WebGPU/TextureView.js +15 -2
  34. package/Rendering/WebGPU/VolumePass.js +1 -1
  35. package/index.d.ts +1 -0
  36. package/index.js +0 -2
  37. package/package.json +4 -5
  38. package/ThirdParty/index.js +0 -9
@@ -1,4 +1,4 @@
1
- import pako from 'pako';
1
+ import { strFromU8, decompressSync } from 'fflate';
2
2
  import macro from '../../../macros.js';
3
3
  import Base64 from '../../../Common/Core/Base64.js';
4
4
  import Endian from '../../../Common/Core/Endian.js';
@@ -59,9 +59,7 @@ function fetchArray(instance, baseURL, array) {
59
59
  var bText = atob(txt);
60
60
 
61
61
  if (options.compression) {
62
- bText = pako.inflate(bText, {
63
- to: 'string'
64
- });
62
+ bText = strFromU8(decompressSync(bText));
65
63
  }
66
64
 
67
65
  array.values = JSON.parse(bText);
@@ -74,11 +72,9 @@ function fetchArray(instance, baseURL, array) {
74
72
 
75
73
  if (options.compression) {
76
74
  if (array.dataType === 'string' || array.dataType === 'JSON') {
77
- array.buffer = pako.inflate(new Uint8Array(array.buffer), {
78
- to: 'string'
79
- });
75
+ array.buffer = strFromU8(decompressSync(new Uint8Array(array.buffer)));
80
76
  } else {
81
- array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer;
77
+ array.buffer = decompressSync(new Uint8Array(array.buffer)).buffer;
82
78
  }
83
79
  }
84
80
 
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import pako from 'pako';
2
+ import { decompressSync, strFromU8 } from 'fflate';
3
3
  import macro from '../../../macros.js';
4
4
  import Endian from '../../../Common/Core/Endian.js';
5
5
  import { DataTypeByteSize } from '../../../Common/Core/DataArray/Constants.js';
@@ -48,9 +48,7 @@ function fetchBinary(url) {
48
48
  if (xhr.readyState === 4) {
49
49
  if (xhr.status === 200 || xhr.status === 0) {
50
50
  if (options.compression) {
51
- resolve(pako.inflate(new Uint8Array(xhr.response), {
52
- to: 'arraybuffer'
53
- }).buffer);
51
+ resolve(decompressSync(new Uint8Array(xhr.response)).buffer);
54
52
  } else {
55
53
  resolve(xhr.response);
56
54
  }
@@ -101,11 +99,9 @@ function fetchArray(instance, baseURL, array) {
101
99
 
102
100
  if (options.compression) {
103
101
  if (array.dataType === 'string' || array.dataType === 'JSON') {
104
- array.buffer = pako.inflate(new Uint8Array(array.buffer), {
105
- to: 'string'
106
- });
102
+ array.buffer = strFromU8(decompressSync(new Uint8Array(array.buffer)));
107
103
  } else {
108
- array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer;
104
+ array.buffer = decompressSync(new Uint8Array(array.buffer)).buffer;
109
105
  }
110
106
  }
111
107
 
@@ -175,9 +171,7 @@ function fetchJSON(instance, url) {
175
171
 
176
172
  if (xhr.status === 200 || xhr.status === 0) {
177
173
  if (options.compression) {
178
- resolve(JSON.parse(pako.inflate(new Uint8Array(xhr.response), {
179
- to: 'string'
180
- })));
174
+ resolve(JSON.parse(strFromU8(decompressSync(new Uint8Array(xhr.response)))));
181
175
  } else {
182
176
  resolve(JSON.parse(xhr.responseText));
183
177
  }
@@ -222,9 +216,7 @@ function fetchText(instance, url) {
222
216
 
223
217
  if (xhr.status === 200 || xhr.status === 0) {
224
218
  if (options.compression) {
225
- resolve(pako.inflate(new Uint8Array(xhr.response), {
226
- to: 'string'
227
- }));
219
+ resolve(strFromU8(decompressSync(new Uint8Array(xhr.response))));
228
220
  } else {
229
221
  resolve(xhr.responseText);
230
222
  }
@@ -1,9 +1,9 @@
1
- import JSZip from 'jszip';
2
- import pako from 'pako';
1
+ import { strToU8, unzipSync, strFromU8, decompressSync } from 'fflate';
3
2
  import macro from '../../../macros.js';
4
3
  import Endian from '../../../Common/Core/Endian.js';
5
4
  import { DataTypeByteSize } from '../../../Common/Core/DataArray/Constants.js';
6
5
  import { registerType } from '../DataAccessHelper.js';
6
+ import { fromArrayBuffer } from '../../../Common/Core/Base64.js';
7
7
 
8
8
  var vtkErrorMacro = macro.vtkErrorMacro,
9
9
  vtkDebugMacro = macro.vtkDebugMacro;
@@ -27,11 +27,9 @@ function handleUint8Array(array, compression, done) {
27
27
 
28
28
  if (compression) {
29
29
  if (array.dataType === 'string' || array.dataType === 'JSON') {
30
- array.buffer = pako.inflate(new Uint8Array(array.buffer), {
31
- to: 'string'
32
- });
30
+ array.buffer = strFromU8(decompressSync(new Uint8Array(array.buffer)));
33
31
  } else {
34
- array.buffer = pako.inflate(new Uint8Array(array.buffer)).buffer;
32
+ array.buffer = decompressSync(new Uint8Array(array.buffer)).buffer;
35
33
  }
36
34
  }
37
35
 
@@ -58,9 +56,7 @@ function handleUint8Array(array, compression, done) {
58
56
  function handleString(array, compression, done) {
59
57
  return function (string) {
60
58
  if (compression) {
61
- array.values = JSON.parse(pako.inflate(string, {
62
- to: 'string'
63
- }));
59
+ array.values = JSON.parse(strFromU8(decompressSync(string)));
64
60
  } else {
65
61
  array.values = JSON.parse(string);
66
62
  }
@@ -69,11 +65,6 @@ function handleString(array, compression, done) {
69
65
  };
70
66
  }
71
67
 
72
- var handlers = {
73
- uint8array: handleUint8Array,
74
- string: handleString
75
- };
76
-
77
68
  function removeLeadingSlash(str) {
78
69
  return str[0] === '/' ? str.substr(1) : str;
79
70
  }
@@ -86,32 +77,47 @@ function cleanUpPath(str) {
86
77
  return removeLeadingSlash(normalizePath(str));
87
78
  }
88
79
 
80
+ function unpack(zipContent) {
81
+ return new Promise(function (resolve, reject) {
82
+ if (typeof zipContent === 'string') {
83
+ resolve(strToU8(zipContent));
84
+ } else if (zipContent instanceof Blob) {
85
+ resolve(zipContent.arrayBuffer().then(function (ab) {
86
+ return new Uint8Array(ab);
87
+ }));
88
+ } else if (zipContent instanceof ArrayBuffer) {
89
+ resolve(new Uint8Array(zipContent));
90
+ } else if ((zipContent === null || zipContent === void 0 ? void 0 : zipContent.buffer) instanceof ArrayBuffer) {
91
+ resolve(new Uint8Array(zipContent.buffer));
92
+ } else {
93
+ reject(new Error('Invalid datatype to unpack.'));
94
+ }
95
+ });
96
+ }
97
+
89
98
  function create(createOptions) {
90
99
  var ready = false;
91
100
  var requestCount = 0;
92
- var zip = new JSZip();
93
- var zipRoot = zip;
94
- zip.loadAsync(createOptions.zipContent).then(function () {
101
+ var decompressedFiles = null;
102
+ var fullRootPath = '';
103
+ unpack(createOptions.zipContent).then(function (zipFileData) {
104
+ decompressedFiles = unzipSync(zipFileData);
95
105
  ready = true; // Find root index.json
96
106
 
97
107
  var metaFiles = [];
98
- zip.forEach(function (relativePath, zipEntry) {
99
- if (relativePath.indexOf('index.json') !== -1) {
108
+ Object.keys(decompressedFiles).forEach(function (relativePath) {
109
+ if (relativePath.endsWith('index.json')) {
100
110
  metaFiles.push(relativePath);
101
111
  }
102
112
  });
103
113
  metaFiles.sort(function (a, b) {
104
114
  return a.length - b.length;
105
- });
106
- var fullRootPath = metaFiles[0].split('/');
115
+ }); // if not empty, then fullRootPath will have a forward slash suffix
107
116
 
108
- while (fullRootPath.length > 1) {
109
- var dirName = fullRootPath.shift();
110
- zipRoot = zipRoot.folder(dirName);
111
- }
117
+ fullRootPath = metaFiles[0].replace(/index\.json$/, '');
112
118
 
113
119
  if (createOptions.callback) {
114
- createOptions.callback(zip);
120
+ createOptions.callback(decompressedFiles);
115
121
  }
116
122
  });
117
123
  return {
@@ -143,9 +149,18 @@ function create(createOptions) {
143
149
  resolve(array);
144
150
  }
145
151
 
146
- var asyncType = array.dataType === 'string' && !options.compression ? 'string' : 'uint8array';
147
- var asyncCallback = handlers[asyncType](array, options.compression, doneCleanUp);
148
- zipRoot.file(url).async(asyncType).then(asyncCallback);
152
+ var fileData = decompressedFiles["".concat(fullRootPath).concat(url)];
153
+
154
+ if (array.dataType === 'string' && !options.compression) {
155
+ // string
156
+ var handler = handleString(array, options.compression, doneCleanUp);
157
+ handler(strFromU8(fileData));
158
+ } else {
159
+ // uint8array
160
+ var _handler = handleUint8Array(array, options.compression, doneCleanUp);
161
+
162
+ _handler(fileData);
163
+ }
149
164
  });
150
165
  },
151
166
  fetchJSON: function fetchJSON(instance, url) {
@@ -156,22 +171,18 @@ function create(createOptions) {
156
171
  vtkErrorMacro('ERROR!!! zip not ready...');
157
172
  }
158
173
 
174
+ var fileData = decompressedFiles["".concat(fullRootPath).concat(path)];
175
+
159
176
  if (options.compression) {
160
177
  if (options.compression === 'gz') {
161
- return zipRoot.file(path).async('uint8array').then(function (uint8array) {
162
- var str = pako.inflate(uint8array, {
163
- to: 'string'
164
- });
165
- return Promise.resolve(JSON.parse(str));
166
- });
178
+ var str = strFromU8(decompressSync(fileData));
179
+ return Promise.resolve(JSON.parse(str));
167
180
  }
168
181
 
169
182
  return Promise.reject(new Error('Invalid compression'));
170
183
  }
171
184
 
172
- return zipRoot.file(path).async('string').then(function (str) {
173
- return Promise.resolve(JSON.parse(str));
174
- });
185
+ return Promise.resolve(JSON.parse(strFromU8(fileData)));
175
186
  },
176
187
  fetchText: function fetchText(instance, url) {
177
188
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -181,22 +192,17 @@ function create(createOptions) {
181
192
  vtkErrorMacro('ERROR!!! zip not ready...');
182
193
  }
183
194
 
195
+ var fileData = decompressedFiles["".concat(fullRootPath).concat(path)];
196
+
184
197
  if (options.compression) {
185
198
  if (options.compression === 'gz') {
186
- return zipRoot.file(path).async('uint8array').then(function (uint8array) {
187
- var str = pako.inflate(uint8array, {
188
- to: 'string'
189
- });
190
- return Promise.resolve(str);
191
- });
199
+ return Promise.resolve(strFromU8(unzipSync(fileData)));
192
200
  }
193
201
 
194
202
  return Promise.reject(new Error('Invalid compression'));
195
203
  }
196
204
 
197
- return zipRoot.file(path).async('string').then(function (str) {
198
- return Promise.resolve(str);
199
- });
205
+ return Promise.resolve(strFromU8(fileData));
200
206
  },
201
207
  fetchImage: function fetchImage(instance, url) {
202
208
  var path = cleanUpPath(url);
@@ -205,6 +211,7 @@ function create(createOptions) {
205
211
  vtkErrorMacro('ERROR!!! zip not ready...');
206
212
  }
207
213
 
214
+ var fileData = decompressedFiles["".concat(fullRootPath).concat(path)];
208
215
  return new Promise(function (resolve, reject) {
209
216
  var img = new Image();
210
217
 
@@ -213,9 +220,8 @@ function create(createOptions) {
213
220
  };
214
221
 
215
222
  img.onerror = reject;
216
- zipRoot.file(path).async('base64').then(function (str) {
217
- img.src = "data:image/".concat(toMimeType(path), ";base64,").concat(str);
218
- });
223
+ var str = fromArrayBuffer(fileData.buffer);
224
+ img.src = "data:image/".concat(toMimeType(path), ";base64,").concat(str);
219
225
  });
220
226
  },
221
227
  fetchBinary: function fetchBinary(instance, url) {
@@ -226,20 +232,17 @@ function create(createOptions) {
226
232
  vtkErrorMacro('ERROR!!! zip not ready...');
227
233
  }
228
234
 
235
+ var fileData = decompressedFiles["".concat(fullRootPath).concat(path)];
236
+
229
237
  if (options.compression) {
230
238
  if (options.compression === 'gz') {
231
- return zipRoot.file(path).then(function (data) {
232
- var array = pako.inflate(data).buffer;
233
- return Promise.resolve(array);
234
- });
239
+ return Promise.resolve(decompressSync(fileData).buffer);
235
240
  }
236
241
 
237
242
  return Promise.reject(new Error('Invalid compression'));
238
243
  }
239
244
 
240
- return zipRoot.file(path).async('arraybuffer').then(function (data) {
241
- return Promise.resolve(data);
242
- });
245
+ return Promise.resolve(fileData.buffer);
243
246
  }
244
247
  };
245
248
  }
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import JSZip from 'jszip';
2
+ import { unzipSync, strFromU8 } from 'fflate';
3
3
  import DataAccessHelper from './DataAccessHelper.js';
4
4
  import macro from '../../macros.js';
5
5
  import './DataAccessHelper/HttpDataAccessHelper.js';
@@ -49,41 +49,31 @@ function vtkZipMultiDataSetReader(publicAPI, model) {
49
49
 
50
50
  return new Promise(function (resolve, reject) {
51
51
  model.arrays = [];
52
- var zip = new JSZip();
53
- zip.loadAsync(arrayBuffer).then(function () {
54
- var processing = 0;
55
- zip.forEach(function (relativePath, zipEntry) {
52
+ var decompressedFiles = unzipSync(new Uint8Array(arrayBuffer));
53
+
54
+ try {
55
+ Object.entries(decompressedFiles).forEach(function (_ref) {
56
+ var _ref2 = _slicedToArray(_ref, 2),
57
+ relativePath = _ref2[0],
58
+ fileData = _ref2[1];
59
+
56
60
  if (relativePath.match(/datasets\.json$/i)) {
57
- processing++;
58
- zipEntry.async('string').then(function (txt) {
59
- model.datasets = JSON.parse(txt);
60
- processing--;
61
-
62
- if (!processing) {
63
- resolve();
64
- }
65
- }).catch(reject);
61
+ model.datasets = JSON.parse(strFromU8(fileData));
66
62
  }
67
63
 
68
64
  if (relativePath.match(/array_[a-zA-Z]+_[0-9]+/)) {
69
- processing++;
70
- zipEntry.async('arraybuffer').then(function (arraybuffer) {
71
- processing--;
72
-
73
- var _relativePath$split$s = relativePath.split('_').slice(-2),
74
- _relativePath$split$s2 = _slicedToArray(_relativePath$split$s, 2),
75
- type = _relativePath$split$s2[0],
76
- id = _relativePath$split$s2[1];
77
-
78
- model.arrays[id] = macro.newTypedArray(type, arraybuffer);
65
+ var _relativePath$split$s = relativePath.split('_').slice(-2),
66
+ _relativePath$split$s2 = _slicedToArray(_relativePath$split$s, 2),
67
+ type = _relativePath$split$s2[0],
68
+ id = _relativePath$split$s2[1];
79
69
 
80
- if (!processing) {
81
- resolve();
82
- }
83
- });
70
+ model.arrays[id] = macro.newTypedArray(type, fileData.buffer);
84
71
  }
85
72
  });
86
- }).catch(reject);
73
+ resolve();
74
+ } catch (err) {
75
+ reject(err);
76
+ }
87
77
  });
88
78
  };
89
79
 
@@ -1,4 +1,4 @@
1
- import JSZip from 'jszip';
1
+ import { zipSync } from 'fflate';
2
2
  import macro from '../../macros.js';
3
3
  import vtkSerializer from './Serializer.js';
4
4
  import vtkDataArray from '../../Common/Core/DataArray.js';
@@ -39,31 +39,16 @@ function vtkZipMultiDataSetWriter(publicAPI, model) {
39
39
  };
40
40
 
41
41
  publicAPI.write = function () {
42
- publicAPI.update(); // Write to zip
42
+ publicAPI.update();
43
+ var zipInfo = Object.create(null); // Write metadata
43
44
 
44
- if (model.zipFile) {
45
- model.zipFile = new JSZip();
46
- } // Write metadata
47
-
48
-
49
- model.zipFile.file('datasets.json', JSON.stringify(model.datasets)); // Write Arrays
45
+ zipInfo['datasets.json'] = JSON.stringify(model.datasets); // Write Arrays
50
46
 
51
47
  for (var i = 0; i < model.arrays.length; i++) {
52
- model.zipFile.file("array_".concat(vtkDataArray.getDataType(model.arrays[i]), "_").concat(i), model.arrays[i], {
53
- binary: true
54
- });
48
+ zipInfo["array_".concat(vtkDataArray.getDataType(model.arrays[i]), "_").concat(i)] = model.arrays[i];
55
49
  }
56
50
 
57
- model.zipFile.generateAsync({
58
- type: 'blob',
59
- compression: 'DEFLATE',
60
- compressionOptions: {
61
- level: model.compressionLevel
62
- }
63
- }).then(function (blob) {
64
- model.blob = blob;
65
- return blob;
66
- });
51
+ model.blob = new Blob([zipSync(zipInfo)]);
67
52
  };
68
53
  } // ----------------------------------------------------------------------------
69
54
  // Object factory
@@ -71,7 +56,6 @@ function vtkZipMultiDataSetWriter(publicAPI, model) {
71
56
 
72
57
 
73
58
  var DEFAULT_VALUES = {
74
- zipFile: null,
75
59
  compressionLevel: 6,
76
60
  blob: null
77
61
  }; // ----------------------------------------------------------------------------
@@ -83,7 +67,7 @@ function extend(publicAPI, model) {
83
67
  macro.obj(publicAPI, model); // Also make it an algorithm with one input and one output
84
68
 
85
69
  macro.algo(publicAPI, model, 1, 0);
86
- macro.setGet(publicAPI, model, ['zipFile', 'compressionLevel']);
70
+ macro.setGet(publicAPI, model, ['compressionLevel']);
87
71
  macro.get(publicAPI, model, ['blob']); // Object specific methods
88
72
 
89
73
  vtkZipMultiDataSetWriter(publicAPI, model);
@@ -1,7 +1,8 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
1
2
  import macro from '../../macros.js';
2
3
  import ImageHelper from '../../Common/Core/ImageHelper.js';
3
4
  import vtkTexture from '../../Rendering/Core/Texture.js';
4
- import JSZip from 'jszip';
5
+ import { unzipSync, strFromU8 } from 'fflate';
5
6
 
6
7
  // vtkSkyboxReader methods
7
8
  // ----------------------------------------------------------------------------
@@ -41,101 +42,92 @@ function vtkSkyboxReader(publicAPI, model) {
41
42
  model.busy = true;
42
43
  publicAPI.invokeBusy(model.busy);
43
44
  model.dataMapping = {};
44
- var workCount = 0;
45
- var canStartProcessing = false;
46
- var imageReady = [];
45
+ var imageReady = []; // Finish data processing
47
46
 
48
47
  function workDone() {
49
- workCount--; // Finish data processing
48
+ for (var i = 0; i < model.positions.length; i++) {
49
+ var key = model.positions[i];
50
+ var images = model.dataMapping[key];
50
51
 
51
- if (workCount === 0 || canStartProcessing) {
52
- for (var i = 0; i < model.positions.length; i++) {
53
- var key = model.positions[i];
54
- var images = model.dataMapping[key];
55
-
56
- if (!model.textures[key]) {
57
- model.textures[key] = vtkTexture.newInstance({
58
- interpolate: true
59
- });
60
- }
52
+ if (!model.textures[key]) {
53
+ model.textures[key] = vtkTexture.newInstance({
54
+ interpolate: true
55
+ });
56
+ }
61
57
 
62
- if (images) {
63
- var texture = model.textures[key];
58
+ if (images) {
59
+ var texture = model.textures[key];
64
60
 
65
- for (var idx = 0; idx < 6; idx++) {
66
- var _model$faceMapping$id = model.faceMapping[idx],
67
- fileName = _model$faceMapping$id.fileName,
68
- transform = _model$faceMapping$id.transform;
69
- var readyIndex = imageReady.indexOf("".concat(key, "/").concat(fileName));
61
+ for (var idx = 0; idx < 6; idx++) {
62
+ var _model$faceMapping$id = model.faceMapping[idx],
63
+ fileName = _model$faceMapping$id.fileName,
64
+ transform = _model$faceMapping$id.transform;
65
+ var readyIndex = imageReady.indexOf("".concat(key, "/").concat(fileName));
70
66
 
71
- if (readyIndex !== -1) {
72
- texture.setInputData(ImageHelper.imageToImageData(images[fileName], transform), idx); // Free image
67
+ if (readyIndex !== -1) {
68
+ texture.setInputData(ImageHelper.imageToImageData(images[fileName], transform), idx); // Free image
73
69
 
74
- URL.revokeObjectURL(images[fileName].src);
75
- delete images[fileName]; // Don't process again
70
+ URL.revokeObjectURL(images[fileName].src);
71
+ delete images[fileName]; // Don't process again
76
72
 
77
- imageReady.splice(readyIndex, 1);
78
- }
73
+ imageReady.splice(readyIndex, 1);
79
74
  }
80
75
  }
81
76
  }
82
-
83
- if (workCount === 0) {
84
- model.busy = false;
85
- publicAPI.modified();
86
- publicAPI.invokeBusy(model.busy);
87
- }
88
77
  }
89
- }
90
78
 
91
- var zip = new JSZip();
92
- zip.loadAsync(content).then(function () {
93
- // Find root index.json
94
- zip.forEach(function (relativePath, zipEntry) {
95
- if (relativePath.match(/index.json$/)) {
96
- workCount++;
97
- zipEntry.async('text').then(function (txt) {
98
- var config = JSON.parse(txt);
99
-
100
- if (config.skybox && config.skybox.faceMapping) {
101
- model.faceMapping = config.skybox.faceMapping;
102
- }
79
+ model.busy = false;
80
+ publicAPI.modified();
81
+ publicAPI.invokeBusy(model.busy);
82
+ }
103
83
 
104
- if (config.metadata && config.metadata.skybox && config.metadata.skybox.faceMapping) {
105
- model.faceMapping = config.metadata.skybox.faceMapping;
106
- }
84
+ var decompressedFiles = unzipSync(new Uint8Array(content));
85
+ var pending = []; // Find root index.json
107
86
 
108
- canStartProcessing = true;
109
- workDone();
110
- });
111
- }
87
+ Object.entries(decompressedFiles).forEach(function (_ref) {
88
+ var _ref2 = _slicedToArray(_ref, 2),
89
+ relativePath = _ref2[0],
90
+ fileData = _ref2[1];
112
91
 
113
- if (relativePath.match(/\.jpg$/)) {
114
- workCount++;
115
- var pathTokens = relativePath.split('/');
116
- var fileName = pathTokens.pop();
117
- var key = pathTokens.pop();
92
+ if (relativePath.match(/index.json$/)) {
93
+ var txt = strFromU8(fileData);
94
+ var config = JSON.parse(txt);
118
95
 
119
- if (!model.dataMapping[key]) {
120
- model.dataMapping[key] = {};
121
- }
96
+ if (config.skybox && config.skybox.faceMapping) {
97
+ model.faceMapping = config.skybox.faceMapping;
98
+ }
122
99
 
123
- zipEntry.async('blob').then(function (blob) {
124
- var img = new Image();
125
- var readyKey = "".concat(key, "/").concat(fileName);
126
- model.dataMapping[key][fileName] = img;
100
+ if (config.metadata && config.metadata.skybox && config.metadata.skybox.faceMapping) {
101
+ model.faceMapping = config.metadata.skybox.faceMapping;
102
+ }
103
+ }
127
104
 
128
- img.onload = function () {
129
- imageReady.push(readyKey);
130
- workDone();
131
- };
105
+ if (relativePath.match(/\.jpg$/)) {
106
+ var pathTokens = relativePath.split('/');
107
+ var fileName = pathTokens.pop();
108
+ var key = pathTokens.pop();
132
109
 
133
- img.src = URL.createObjectURL(blob);
134
- });
110
+ if (!model.dataMapping[key]) {
111
+ model.dataMapping[key] = {};
135
112
  }
136
- });
137
- model.positions = Object.keys(model.dataMapping);
138
- model.position = model.positions[0];
113
+
114
+ var blob = new Blob([fileData.buffer]);
115
+ var img = new Image();
116
+ var readyKey = "".concat(key, "/").concat(fileName);
117
+ model.dataMapping[key][fileName] = img;
118
+ pending.push(new Promise(function (resolve) {
119
+ img.onload = function () {
120
+ imageReady.push(readyKey);
121
+ resolve();
122
+ };
123
+ }));
124
+ img.src = URL.createObjectURL(blob);
125
+ }
126
+ });
127
+ model.positions = Object.keys(model.dataMapping);
128
+ model.position = model.positions[0];
129
+ Promise.all(pending).then(function () {
130
+ workDone();
139
131
  });
140
132
  return publicAPI.getReadyPromise();
141
133
  };
@@ -1,6 +1,6 @@
1
1
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
2
  import { create } from 'xmlbuilder2';
3
- import pako from 'pako';
3
+ import { decompressSync } from 'fflate';
4
4
  import DataAccessHelper from '../Core/DataAccessHelper.js';
5
5
  import Base64 from '../../Common/Core/Base64.js';
6
6
  import macro from '../../macros.js';
@@ -112,7 +112,7 @@ function readerHeader(uint8, headerType) {
112
112
 
113
113
 
114
114
  function uncompressBlock(compressedUint8, output) {
115
- var uncompressedBlock = pako.inflate(compressedUint8);
115
+ var uncompressedBlock = decompressSync(compressedUint8);
116
116
  output.uint8.set(uncompressedBlock, output.offset);
117
117
  output.offset += uncompressedBlock.length;
118
118
  } // ----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
  import { create } from 'xmlbuilder2';
2
- import pako from 'pako';
2
+ import { zlibSync } from 'fflate';
3
3
  import macro from '../../macros.js';
4
4
  import { fromArrayBuffer } from '../../Common/Core/Base64.js';
5
5
  import { FormatTypes, TYPED_ARRAY } from './XMLWriter/Constants.js';
@@ -8,7 +8,7 @@ import { FormatTypes, TYPED_ARRAY } from './XMLWriter/Constants.js';
8
8
  // ----------------------------------------------------------------------------
9
9
 
10
10
  function compressBlock(uncompressed) {
11
- return pako.deflate(uncompressed);
11
+ return zlibSync(uncompressed);
12
12
  }
13
13
 
14
14
  function processDataArray(dataArray, format, blockSize) {