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

useGLTF在安卓环境下报错 #1924

Open
bieao411327 opened this issue Apr 15, 2024 · 1 comment
Open

useGLTF在安卓环境下报错 #1924

bieao411327 opened this issue Apr 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bieao411327
Copy link

Uncaught (in promise) {"name": "TypeError", "message": "Cannot read property 'length' of undefined", "stack": "TypeError: Cannot read property 'length' of undefined\n at http://localhost:13000/clientDist_1.6.5.69/925.4a9527e1.async.js:910:1197"},使用useGLTF加载glb文件时,在ios环境下是可以运行的,但是在安卓环境下就报错无法使用,是什么原因?

@bieao411327 bieao411327 added the bug Something isn't working label Apr 15, 2024
@bieao411327
Copy link
Author

原因:
useGLTF方法加载glb模型时需要返回二进制数据,也就是ArrayBuffer,在浏览器和IOS环境中使用本地路径加载glb文件是没问题的,但是在安卓系统中,加载本地的glb文件返回的是base64字符串,所以会报以上错误
解决方案:
1、将本地的glb文件放到远程服务器上,使用域名加载,安卓就可以读出二进制文件
2、修改useGLTF方法,判断在安卓环境下将base64改为ArrayBuffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant