Skip to content

Commit da7b96e

Browse files
authored
[FIX] GLB assets not loading when part of asset bundles (playcanvas#2055)
1 parent 418d5dc commit da7b96e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/resources/animation.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ Object.assign(pc, function () {
2626
};
2727

2828
if (url.load.startsWith('blob:')) {
29-
options.responseType = pc.Http.ResponseType.JSON;
29+
if (pc.path.getExtension(url.original).toLowerCase() === '.glb') {
30+
options.responseType = pc.Http.ResponseType.ARRAY_BUFFER;
31+
} else {
32+
options.responseType = pc.Http.ResponseType.JSON;
33+
}
3034
}
3135

3236
pc.http.get(url.load, options, function (err, response) {
@@ -39,7 +43,7 @@ Object.assign(pc, function () {
3943
},
4044

4145
open: function (url, data) {
42-
if (pc.path.getExtension(url) === '.glb') {
46+
if (pc.path.getExtension(url).toLowerCase() === '.glb') {
4347
var glb = pc.GlbParser.parse("filename.glb", data, null);
4448
if (!glb) {
4549
return null;

src/resources/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ Object.assign(pc, function () {
4646
};
4747

4848
if (url.load.startsWith('blob:')) {
49-
options.responseType = pc.Http.ResponseType.JSON;
49+
if (pc.path.getExtension(url.original).toLowerCase() === '.glb') {
50+
options.responseType = pc.Http.ResponseType.ARRAY_BUFFER;
51+
} else {
52+
options.responseType = pc.Http.ResponseType.JSON;
53+
}
5054
}
5155

5256
pc.http.get(url.load, options, function (err, response) {

0 commit comments

Comments
 (0)