Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions example/loaders/gltf-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ export function registerGLTFLoader(THREE) {
var options = this.options;
var textureLoader = this.textureLoader;

var URL = window.URL || window.webkitURL;
// var URL = window.URL || window.webkitURL;

var textureDef = json.textures[textureIndex];

Expand Down Expand Up @@ -1998,9 +1998,14 @@ export function registerGLTFLoader(THREE) {
sourceURI = parser.getDependency('bufferView', source.bufferView).then(function (bufferView) {

isObjectURL = true;
var blob = new Blob([bufferView], { type: source.mimeType });
sourceURI = URL.createObjectURL(blob);
return sourceURI;
// var blob = new Blob([bufferView], { type: source.mimeType });
// sourceURI = URL.createObjectURL(blob);
// return sourceURI;

// 微信小程序不支持 Blob 对象,则使用 base64 编码的字符串来创建 data URI
const base64Str = wx.arrayBufferToBase64(bufferView);
sourceURI = `data:${source.mimeType};base64,${base64Str}`;
return sourceURI

});

Expand Down Expand Up @@ -2032,7 +2037,7 @@ export function registerGLTFLoader(THREE) {

if (isObjectURL === true) {

URL.revokeObjectURL(sourceURI);
// URL.revokeObjectURL(sourceURI);

}

Expand Down