@woosh/meep-engine 2.100.2 → 2.100.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/build/meep.cjs +109 -97
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +109 -97
- package/package.json +1 -1
- package/src/core/binary/downloadUrlAsFile.d.ts.map +1 -1
- package/src/core/binary/downloadUrlAsFile.js +3 -1
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/asset/AssetManager.js +6 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts +2 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.js +107 -99
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.d.ts +1 -1
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js +4 -4
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts +1 -2
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +1 -2
- package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_uint8_RGBA.js +8 -0
package/build/meep.cjs
CHANGED
|
@@ -67748,6 +67748,83 @@ class AssetLoader {
|
|
|
67748
67748
|
}
|
|
67749
67749
|
}
|
|
67750
67750
|
|
|
67751
|
+
/**
|
|
67752
|
+
*
|
|
67753
|
+
* @param {Response} input
|
|
67754
|
+
* @param {function} progress
|
|
67755
|
+
* @return {Response}
|
|
67756
|
+
*/
|
|
67757
|
+
function observeResponseProgress(input, progress) {
|
|
67758
|
+
let response = input;
|
|
67759
|
+
|
|
67760
|
+
|
|
67761
|
+
if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
|
|
67762
|
+
|
|
67763
|
+
return response;
|
|
67764
|
+
|
|
67765
|
+
}
|
|
67766
|
+
|
|
67767
|
+
/**
|
|
67768
|
+
* @type {ReadableStreamDefaultReader<Uint8Array>}
|
|
67769
|
+
*/
|
|
67770
|
+
const reader = response.body.getReader();
|
|
67771
|
+
|
|
67772
|
+
const contentLength = response.headers.get('Content-Length');
|
|
67773
|
+
const total = contentLength ? parseInt(contentLength) : 0;
|
|
67774
|
+
let loaded = 0;
|
|
67775
|
+
|
|
67776
|
+
// periodically read data into the new stream tracking while download progress
|
|
67777
|
+
const stream_prototype = {
|
|
67778
|
+
type: "bytes",
|
|
67779
|
+
start(controller) {
|
|
67780
|
+
|
|
67781
|
+
pump();
|
|
67782
|
+
|
|
67783
|
+
function pump() {
|
|
67784
|
+
|
|
67785
|
+
reader.read().then(({ done, value }) => {
|
|
67786
|
+
|
|
67787
|
+
if (done) {
|
|
67788
|
+
// no more data, we're done
|
|
67789
|
+
controller.close();
|
|
67790
|
+
return;
|
|
67791
|
+
}
|
|
67792
|
+
|
|
67793
|
+
loaded += value.byteLength;
|
|
67794
|
+
|
|
67795
|
+
progress(loaded, total);
|
|
67796
|
+
|
|
67797
|
+
controller.enqueue(value);
|
|
67798
|
+
pump();
|
|
67799
|
+
|
|
67800
|
+
});
|
|
67801
|
+
|
|
67802
|
+
}
|
|
67803
|
+
|
|
67804
|
+
}
|
|
67805
|
+
|
|
67806
|
+
};
|
|
67807
|
+
|
|
67808
|
+
/**
|
|
67809
|
+
* @type {ReadableStream}
|
|
67810
|
+
*/
|
|
67811
|
+
let stream;
|
|
67812
|
+
|
|
67813
|
+
try {
|
|
67814
|
+
stream = new ReadableStream(stream_prototype);
|
|
67815
|
+
|
|
67816
|
+
response = new Response(stream);
|
|
67817
|
+
} catch (e) {
|
|
67818
|
+
/*
|
|
67819
|
+
Workaround for Safari bug: "TypeError: ReadableByteStreamController is not implemented"
|
|
67820
|
+
By not wrapping the response we lose the ability to track progress, but that's not a critical issue in most cases
|
|
67821
|
+
*/
|
|
67822
|
+
}
|
|
67823
|
+
|
|
67824
|
+
return response;
|
|
67825
|
+
|
|
67826
|
+
}
|
|
67827
|
+
|
|
67751
67828
|
class ArrayBufferLoader extends AssetLoader {
|
|
67752
67829
|
/**
|
|
67753
67830
|
*
|
|
@@ -67766,7 +67843,13 @@ class ArrayBufferLoader extends AssetLoader {
|
|
|
67766
67843
|
this.__fetch_priority = fetch_priority;
|
|
67767
67844
|
}
|
|
67768
67845
|
|
|
67769
|
-
load(
|
|
67846
|
+
async load(
|
|
67847
|
+
scope,
|
|
67848
|
+
path,
|
|
67849
|
+
success,
|
|
67850
|
+
failure = console.error,
|
|
67851
|
+
progress = noop
|
|
67852
|
+
) {
|
|
67770
67853
|
const coc = this.assetManager !== null ? this.assetManager.crossOriginConfig : CrossOriginConfig.default;
|
|
67771
67854
|
|
|
67772
67855
|
const headers = new Headers();
|
|
@@ -67781,112 +67864,36 @@ class ArrayBufferLoader extends AssetLoader {
|
|
|
67781
67864
|
request.priority = this.__fetch_priority;
|
|
67782
67865
|
}
|
|
67783
67866
|
|
|
67784
|
-
fetch(request)
|
|
67785
|
-
.then(handle_response)
|
|
67786
|
-
.then(response_to_asset)
|
|
67787
|
-
.catch(failure);
|
|
67867
|
+
let response = await fetch(request);
|
|
67788
67868
|
|
|
67789
|
-
|
|
67790
|
-
*
|
|
67791
|
-
* @param {Response} response
|
|
67792
|
-
* @return {Promise<void>}
|
|
67793
|
-
*/
|
|
67794
|
-
async function response_to_asset(response) {
|
|
67795
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
67869
|
+
if (!(response.status === 200 || response.status === 0)) {
|
|
67796
67870
|
|
|
67797
|
-
|
|
67798
|
-
function () {
|
|
67799
|
-
return arrayBuffer;
|
|
67800
|
-
},
|
|
67801
|
-
arrayBuffer.byteSize
|
|
67802
|
-
);
|
|
67871
|
+
throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
|
|
67803
67872
|
|
|
67804
|
-
success(asset);
|
|
67805
67873
|
}
|
|
67806
67874
|
|
|
67807
|
-
|
|
67808
|
-
|
|
67809
|
-
* @param {Response} response
|
|
67810
|
-
* @return {Response}
|
|
67811
|
-
*/
|
|
67812
|
-
function handle_response(response) {
|
|
67813
|
-
if (!(response.status === 200 || response.status === 0)) {
|
|
67814
|
-
|
|
67815
|
-
throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
|
|
67816
|
-
|
|
67817
|
-
}
|
|
67818
|
-
|
|
67819
|
-
// Some browsers return HTTP Status 0 when using non-http protocol
|
|
67820
|
-
// e.g. 'file://' or 'data://'. Handle as success.
|
|
67821
|
-
|
|
67822
|
-
if (response.status === 0) ;
|
|
67823
|
-
|
|
67824
|
-
if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
|
|
67825
|
-
|
|
67826
|
-
return response;
|
|
67827
|
-
|
|
67828
|
-
}
|
|
67829
|
-
|
|
67830
|
-
/**
|
|
67831
|
-
* @type {ReadableStreamDefaultReader<Uint8Array>}
|
|
67832
|
-
*/
|
|
67833
|
-
const reader = response.body.getReader();
|
|
67834
|
-
|
|
67835
|
-
const contentLength = response.headers.get('Content-Length');
|
|
67836
|
-
const total = contentLength ? parseInt(contentLength) : 0;
|
|
67837
|
-
let loaded = 0;
|
|
67838
|
-
|
|
67839
|
-
// periodically read data into the new stream tracking while download progress
|
|
67840
|
-
const stream_prototype = {
|
|
67841
|
-
type: "bytes",
|
|
67842
|
-
start(controller) {
|
|
67843
|
-
|
|
67844
|
-
pump();
|
|
67845
|
-
|
|
67846
|
-
function pump() {
|
|
67847
|
-
|
|
67848
|
-
reader.read().then(({ done, value }) => {
|
|
67849
|
-
|
|
67850
|
-
if (done) {
|
|
67851
|
-
// no more data, we're done
|
|
67852
|
-
controller.close();
|
|
67853
|
-
return;
|
|
67854
|
-
}
|
|
67855
|
-
|
|
67856
|
-
loaded += value.byteLength;
|
|
67875
|
+
// Some browsers return HTTP Status 0 when using non-http protocol
|
|
67876
|
+
// e.g. 'file://' or 'data://'. Handle as success.
|
|
67857
67877
|
|
|
67858
|
-
|
|
67878
|
+
if (response.status === 0) ;
|
|
67859
67879
|
|
|
67860
|
-
|
|
67861
|
-
|
|
67862
|
-
|
|
67863
|
-
|
|
67864
|
-
|
|
67865
|
-
}
|
|
67866
|
-
|
|
67867
|
-
}
|
|
67868
|
-
|
|
67869
|
-
};
|
|
67870
|
-
|
|
67871
|
-
/**
|
|
67872
|
-
* @type {ReadableStream}
|
|
67873
|
-
*/
|
|
67874
|
-
let stream;
|
|
67880
|
+
try {
|
|
67881
|
+
response = observeResponseProgress(response, progress);
|
|
67882
|
+
} catch (e) {
|
|
67883
|
+
}
|
|
67875
67884
|
|
|
67876
|
-
|
|
67877
|
-
stream = new ReadableStream(stream_prototype);
|
|
67878
|
-
} catch (e) {
|
|
67879
|
-
/*
|
|
67880
|
-
Workaround for Safari bug: "TypeError: ReadableByteStreamController is not implemented"
|
|
67881
|
-
By not wrapping the response we lose the ability to track progress, but that's not a critical issue in most cases
|
|
67882
|
-
*/
|
|
67883
|
-
return response;
|
|
67884
|
-
}
|
|
67885
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
67885
67886
|
|
|
67886
|
-
|
|
67887
|
-
|
|
67887
|
+
const asset = new Asset(
|
|
67888
|
+
function () {
|
|
67889
|
+
return arrayBuffer;
|
|
67890
|
+
},
|
|
67891
|
+
arrayBuffer.byteSize
|
|
67892
|
+
);
|
|
67888
67893
|
|
|
67894
|
+
success(asset);
|
|
67889
67895
|
|
|
67896
|
+
return asset;
|
|
67890
67897
|
}
|
|
67891
67898
|
}
|
|
67892
67899
|
|
|
@@ -86244,7 +86251,12 @@ class AssetManager {
|
|
|
86244
86251
|
try {
|
|
86245
86252
|
|
|
86246
86253
|
|
|
86247
|
-
loader.load(scope, full_path, success, failure, progress);
|
|
86254
|
+
const result = loader.load(scope, full_path, success, failure, progress);
|
|
86255
|
+
|
|
86256
|
+
if (result instanceof Promise) {
|
|
86257
|
+
// allow promise responses
|
|
86258
|
+
result.catch(failure);
|
|
86259
|
+
}
|
|
86248
86260
|
|
|
86249
86261
|
} catch (e) {
|
|
86250
86262
|
failure(e);
|