wechat-miniprogram / threejs-miniprogram

WeChat MiniProgram adapted version of Three.js
MIT License
713 stars 230 forks source link

加载有贴图的gltf文件会报错 #15

Open majie1202 opened 4 years ago

majie1202 commented 4 years ago

e = TypeError: Cannot read property 'URL' of undefined at GLTFParser.loadTexture (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1723:24) at GLTFParser.getDependency (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1489:31) at GLTFParser.assignTexture (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1812:19) at GLTFParser.loadMaterial (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:2001:31) at GLTFParser.getDependency (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1485:31) at GLTFParser.loadMesh (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:2218:94) at GLTFParser.getDependency (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1469:31) at http://127.0.0.1:22948/appservice/libs/gltf-loader.js:2550:31 at GLTFParser.loadNode (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:2603:8) at GLTFParser.getDependency (http://127.0.0.1:22948/appservice/libs/gltf-loader.js:1465:31)

ele828 commented 4 years ago

方便提供下模型文件看看吗

chenqincheng commented 4 years ago

gltf-loader.js 文件的大概1966 行 loadTexture方法; 1.有window对象,报错; 2.Blob对象,目前微信小程序还不支持;

chenqincheng commented 4 years ago

@ele828

Ivorzk commented 4 years ago

gltf-loader.js 文件的大概1966 行 loadTexture方法; 1.有window对象,报错; 2.Blob对象,目前微信小程序还不支持;

所以,现在还有办法解决此问题不?

iguoxing commented 3 years ago

gltf-loader.js 文件的大概1966 行 loadTexture方法; 1.有window对象,报错; 2.Blob对象,目前微信小程序还不支持;

看到你的仓库里有类似的解决方案,但不知道texture_loader.js如何用,求大神指点~

iguoxing commented 3 years ago

@chenqincheng

deepkolos commented 3 years ago

已支持小程序加载GLB polyfill https://github.com/deepkolos/three-platformize

sanyuered commented 3 years ago

《关于gltf模型加载贴图的问题》 https://github.com/wechat-miniprogram/threejs-miniprogram/issues/5

《带贴图的模型加载出问题》 https://github.com/wechat-miniprogram/threejs-miniprogram/issues/6

《TextureLoader真机加载图片失败》 https://github.com/wechat-miniprogram/threejs-miniprogram/issues/2

deepkolos commented 3 years ago

@sanyuered 可以尝试 https://github.com/deepkolos/three-platformize

已测试模块 Loader

GLTFLoader (支持带纹理的 GLB) && (EXT_meshopt_compression 安卓可用WASM,ios可用ASM版,见tools) && (KHR_mesh_quantization,小程序可用)
TextureLoader
RGBELoader & PMREMGenerator (小程序部分机型可能偶现生成 envMap 错误,可用HDRPrefilter避免 )
SVGLoader
OBJLoader
EXRLoader (需支持 OES_texture_float_linear 扩展,部分移动端 GPU 不支持)
MTLLoader (小程序使用 JPG 纹理即可)
DDSLoader (需支持 WEBGL_compressed_texture_s3tc 扩展,移动端 GPU 不支持)
LWOLoader (需支持 EXT_blend_minmax 扩展,小程序一半效果绘制出错)
FBXLoader
BVHLoader
ColladaLoader (TGALoader 尚未适配)
TTFLoader
STLLoader
PDBLoader

Controls

OrbitControls & MapControls
DeviceOrientationControls
SunXinFei commented 2 years ago

https://github.com/deepkolos/three-platformize 为什么不能参考这个解决一下呢

mydaoyuan commented 2 years ago

https://github.com/deepkolos/three-platformize 为什么不能参考这个解决一下呢 (悲伤)

mydaoyuan commented 2 years ago

模型用 blender 导出的时候选 gltf 分离,导出后就是一个 gltf文件,一个贴图,一个 bin 文件,于是就可以加载 gltf 文件了。 不过模型用在 VKSession 里面的时候,还是会展示错误,不知道是不是修改了 着色器相关的内容

SunXinFei commented 2 years ago

最后three用的threejs-miniprogram,gltf参考了https://github.com/deepkolos/three-platformize,搞的微信小程序AR

mydaoyuan commented 2 years ago

最后three用的threejs-miniprogram,gltf参考了https://github.com/deepkolos/three-platformize,搞的微信小程序AR

噢噢,老哥你是参考 three-platformize 项目,重写了 gltfloader 是吗?

SunXinFei commented 2 years ago

最后three用的threejs-miniprogram,gltf参考了https://github.com/deepkolos/three-platformize,搞的微信小程序AR

噢噢,老哥你是参考 three-platformize 项目,重写了 gltfloader 是吗?

是的,让threejs-miniprogram和three-platformize的gltfloader结合一起