Closed cx20 closed 5 years ago
Perhaps, if you check in the following places if the uri
format is a Data URI
and set uri
or root + uri
, I think that it will be displayed.
https://github.com/but0n/Ashes/blob/master/src/asset.ts#L137-L146
The following is a suggestion of a fix code.
static adjustDataUri(root, uri) {
return uri.substr(0, 5) == "data:" ? uri : root + uri;
}
//gltf.buffers = await Promise.all(gltf.buffers.map(({ uri }) => this.loadBuffer(root + uri)));
gltf.buffers = await Promise.all(gltf.buffers.map(({ uri }) => this.loadBuffer(adjustDataUri(root, uri))));
//gltf.images = await Promise.all(gltf.images.map(({ uri }) => this.loadImage(root + uri)));
gltf.images = await Promise.all(gltf.images.map(({ uri }) => this.loadImage(adjustDataUri(root, uri))));
Thanks for your suggestion! I'm already add the fix code you provide, it will support data url in the next version.
I tried v0.0.48
. However, it seems that there is another error.
ashes.main.js:5711
Uncaught TypeError: meshChunk.entities(...) is not a function or its return value is not iterable
at gltfScene.createEntity (ashes.main.js:5711)
at setTimeout (ashes.main.js:5623)
Oh, that was a typo. 😅 It already been fixed in the newest version.
I tried to display several glTF models using Ashes. However, it seems that you can not display models in
glTF Embedded
format. The following is a sample that could not be displayed because of a format problem.Ashes + glTF Additonal Test Case No.3 http://jsdo.it/cx20/kSsC
Ashes + glTF Additonal Test Case No.5 http://jsdo.it/cx20/YY6E
Ashes + glTF Additonal Test Case No.10 http://jsdo.it/cx20/c2TU
The
glTF Embedded format
is a format used when incorporating resources into JSON usingData URI
. I hope that you can support if possible.