donmccurdy / three-gltf-viewer

Drag-and-drop preview for glTF 2.0 models in WebGL using three.js.
https://gltf-viewer.donmccurdy.com/
MIT License
2.06k stars 530 forks source link

"MESH_PRIMITIVE_TOO_FEW_TEXCOORDS" on GLB created with three.js r153 #341

Closed vis-prime closed 1 year ago

vis-prime commented 1 year ago

Getting this aoMap/uv related validator error

MESH_PRIMITIVE_TOO_FEW_TEXCOORDS | Material is incompatible with mesh primitive: Texture binding '/materials/0/occlusionTexture' needs 'TEXCOORD_1' attribute. | /meshes/0/primitives/0/material

from a glb created with r153 and the mesh with the occlusion texture is invisible in the viewer

the gltf is still valid right? it work's on https://github.khronos.org/glTF-Sample-Viewer-Release/

donmccurdy commented 1 year ago

The warning comes from https://github.com/KhronosGroup/glTF-Validator. The issue here is that the aoMap says it needs the second UV set, while the file only contains one UV set. Viewers might happen to handle that fine, but it's technically invalid, and could break elsewhere.

One fix might be to assign aoMap.channel = 0 before exporting from three.js. I'm surprised three.js works without that actually, now that three.js supports arbitrary UV set assignments.

Related fix in r152 –

vis-prime commented 1 year ago

aoMap.channel = 0 is the default value right?

donmccurdy commented 1 year ago

That's the default for a new texture, yes. If you're loading a new model from a file the loader might change it.