zincjs 1.10.2 → 1.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zincjs",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -18,7 +18,6 @@ const mergeGeometries = (geometries) => {
18
18
  }
19
19
 
20
20
  const IndexedSourcesHandler = function(urlIn, crossOrigin, onDownloadedCallback) {
21
- const allData = [];
22
21
  const loader = new FileLoader();
23
22
  const jsonLoader = new JSONLoader();
24
23
  loader.crossOrigin = crossOrigin;
@@ -130,7 +129,6 @@ const MultiSourcesHandler = function(numberIn, onLoadCallback) {
130
129
  onLoad(geometry, materials);
131
130
  }
132
131
  }
133
-
134
132
  }
135
133
 
136
134
  exports.PrimitivesLoader = function () {
@@ -161,35 +159,47 @@ exports.PrimitivesLoader = function () {
161
159
  const newOptions = options ? {...options} : {};
162
160
  let indexedLoader = indexedLoaders[url];
163
161
  if (!indexedLoader) {
164
- const onLoadCallback = new onFinally(undefined, this, newOptions);
165
- ++concurrentDownloads;
166
- indexedLoader = new IndexedSourcesHandler(url, this.crossOrigin, onLoadCallback);
167
- indexedLoaders[url] = indexedLoader;
162
+ if (MAX_DOWNLOAD > concurrentDownloads) {
163
+ const onLoadCallback = new onFinally(undefined, this, newOptions);
164
+ ++concurrentDownloads;
165
+ indexedLoader = new IndexedSourcesHandler(url, this.crossOrigin, onLoadCallback);
166
+ indexedLoaders[url] = indexedLoader;
167
+ } else {
168
+ waitingList.push({
169
+ url,
170
+ onLoad,
171
+ onProgress,
172
+ onError,
173
+ options,
174
+ });
175
+ }
176
+ }
177
+ if (indexedLoader) {
178
+ newOptions.isHandler = indexedLoader;
179
+ indexedLoader.load(options.index, onLoad, onProgress, onError);
168
180
  }
169
- newOptions.isHandler = indexedLoader;
170
- indexedLoader.load(options.index, onLoad, onProgress, onError);
171
181
  }
172
182
 
173
183
  const loadFromSingleSource = (url, onLoad, onProgress, onError, options) => {
174
- if (MAX_DOWNLOAD > concurrentDownloads) {
175
- if (options && (options.index !== undefined) ) {
176
- handleIndexedSource(url, onLoad, onProgress, onError, options);
177
- } else {
178
- //Standard loading
184
+ if (options && (options.index !== undefined) ) {
185
+ handleIndexedSource(url, onLoad, onProgress, onError, options);
186
+ } else {
187
+ //Standard loading
188
+ if (MAX_DOWNLOAD > concurrentDownloads) {
179
189
  ++concurrentDownloads;
180
190
  const onLoadCallback = new onFinally(onLoad, this, options);
181
191
  const onErrorCallback = new onFinally(onError, this, options);
182
192
  loader.crossOrigin = this.crossOrigin;
183
193
  loader.load(url, onLoadCallback, onProgress, onErrorCallback);
194
+ } else {
195
+ waitingList.push({
196
+ url,
197
+ onLoad,
198
+ onProgress,
199
+ onError,
200
+ options,
201
+ });
184
202
  }
185
- } else {
186
- waitingList.push({
187
- url,
188
- onLoad,
189
- onProgress,
190
- onError,
191
- options,
192
- });
193
203
  }
194
204
  }
195
205
 
@@ -202,10 +212,18 @@ exports.PrimitivesLoader = function () {
202
212
  }
203
213
 
204
214
  this.loadFromWaitingList = () => {
205
- const item = waitingList.shift();
206
- if (item) {
207
- this.load(item.url, item.onLoad, item.onProgress, item.onError, item.options);
208
- } else {
215
+ while (MAX_DOWNLOAD > concurrentDownloads) {
216
+ const item = waitingList.shift();
217
+ if (item) {
218
+ this.load(item.url, item.onLoad, item.onProgress, item.onError, item.options);
219
+ } else {
220
+ return;
221
+ }
222
+ }
223
+ }
224
+
225
+ this.itemRemainingCheck = () => {
226
+ if (waitingList.length === 0 && concurrentDownloads === 0) {
209
227
  for (let key in indexedLoaders) {
210
228
  if (indexedLoaders.hasOwnProperty(key)) {
211
229
  delete indexedLoaders[key];
@@ -227,6 +245,7 @@ exports.PrimitivesLoader = function () {
227
245
  }
228
246
  }
229
247
  loader.loadFromWaitingList();
248
+ loader.itemRemainingCheck();
230
249
  }
231
250
  }
232
251