Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I read the stl file with base64 to get the string of base64, and then call your function. Why can't I display the 3D effect #22

Open
5 tasks done
linhuanfeng opened this issue Aug 30, 2023 · 0 comments
Labels

Comments

@linhuanfeng
Copy link

Describe the bug

testLoad();
var str =
'U2tldGNoVXAgU1RMIFVudGl0bGVkLTU2ZTNlMjU2ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAMAAAAAAAAAAAAAAAAAIC/AACgQAAAoEAAAKDAAACgwAAAoMAAAKDAAACgwAAAoEAAAKDAAAAAAAAAAAAAAAAAgL8AAKDAAACgwAAAoMAAAKBAAACgQAAAoMAAAKBAAACgwAAAoMAAAAAAAIAAAIC/AAAAgAAAoEAAAKDAAACgQAAAoMAAAKDAAACgwAAAoEAAAKDAAACgwAAAAAAAgAAAgL8AAACAAACgwAAAoMAAAKDAAACgQAAAoMAAAKBAAACgwAAAoMAAAKBAAAAAAIC/AAAAAAAAAAAAAKDAAACgQAAAoEAAAKDAAACgwAAAoMAAAKDAAACgwAAAoEAAAAAAgL8AAAAAAAAAAAAAoMAAAKDAAACgwAAAoMAAAKBAAACgQAAAoMAAAKBAAACgwAAAAAAAAAAAAAAAAIA/AACgQAAAoMAAAKBAAACgwAAAoEAAAKBAAACgwAAAoMAAAKBAAAAAAAAAAAAAAAAAgD8AAKDAAACgQAAAoEAAAKBAAACgwAAAoEAAAKBAAACgQAAAoEAAAAAAgD8AAAAAAAAAAAAAoEAAAKBAAACgwAAAoEAAAKDAAACgQAAAoEAAAKDAAACgwAAAAACAPwAAAAAAAAAAAACgQAAAoMAAAKBAAACgQAAAoEAAAKDAAACgQAAAoEAAAKBAAAAAAAAAAACAPwAAAAAAAKDAAACgQAAAoEAAAKBAAACgQAAAoMAAAKDAAACgQAAAoMAAAAAAAAAAAIA/AAAAAAAAoEAAAKBAAACgwAAAoMAAAKBAAACgQAAAoEAAAKBAAACgQAAA';

function testLoad() {
console.log('tesload');
// var f1 = base64toFile(str);
// var f2 = base64ToBlob(str, '.stl');

console.log('tesload1');
// loader.loadFile(f1);
// loader.loadString(f1);
// loader.loadBinaryData(f1);
// loader.loadFile(f1);

console.log('tesload2');

// loader.loadFile(f2);
// loader.loadString(f2);
// loader.loadBinaryData(f2);
// loader.loadFile(f2);

console.log('tesload3');

// loader.loadFile(str);
loader.loadString(str);
loader.loadBinaryData(str);
loader.loadFile(str);

// var to = base64ToBlob(str, 'zip');
// loader.loadFile(base64ToBlob(to));
// loader.loadString(to);
// loader.loadBinaryData(to);
// loader.loadFile(to);
}

function base64ToBlob(code, suffix) {
code = code.replace(/[\n\r]/g, '');
// atob() 方法用于解码使用 base-64 编码的字符串。
const raw = window.atob(code);
const rawLength = raw.length;
const uInt8Array = new Uint8Array(rawLength);
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
return new Blob([uInt8Array], {type: application/${suffix}});
}

Reproduction

thanks

System Info

tesload3
main.js:91 TypeError: Cannot read properties of undefined (reading 'getUint32')
    at STLLoader.loadBinaryData (stl.js:182:26)
    at testLoad (main.js:1169:10)
    at main.js:1143:1
errorHandler @ main.js:91
STLLoader.loadBinaryData @ stl.js:184
testLoad @ main.js:1169
(anonymous) @ main.js:1143
stl.js:128 Uncaught TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.
    at STLLoader.loadFile (stl.js:128:12)
    at testLoad (main.js:1170:10)
    at main.js:1143:1
STLLoader.loadFile @ stl.js:128
testLoad @ main.js:1170
(anonymous) @ main.js:1143
translate.google.com/gen204?nca=te_li&client=te_lib&logld=vTE_20230827:1     GET file://translate.google.com/gen204?nca=te_li&client=te_lib&logld=vTE_20230827 net::ERR_FILE_NOT_FOUND
Image (async)
dn @ VM677:241
eval @ VM677:503
eval @ VM677:507
xhr.onreadystatechange @ m=el_conf:430
XMLHttpRequest.send (async)
onLoadJavascript @ m=el_conf:432
(anonymous) @ m=el_conf:640
(anonymous) @ m=el_conf:641
(anonymous) @ m=el_conf:642
Show 5 more frames
Show less
translate.google.com/gen204?sl=en&tl=zh-CN&textlen=16&ttt=363&ttl=43&ttf=299&sr=1&nca=te_time&client=te_lib&logld=vTE_20230827:1     GET file://translate.google.com/gen204?sl=en&tl=zh-CN&textlen=16&ttt=363&ttl=43&ttf=299&sr=1&nca=te_time&client=te_lib&logld=vTE_20230827 net::ERR_FILE_NOT_FOUND

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant