Repository navigation
Conversation
VanityNie
force-pushed
the
fix/gltf-khr-texture-transform
branch
from
December 3, 2026 11:20
0680143 to
fcb7d75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
导入带有 KHR_texture_transform 扩展的 glTF / GLB 模型(论坛反馈 178201)时,GltfConverter 仅读取了 scale 与 offset 写入标准材质 tilingOffset(Vec4),忽略了 rotation(弧度旋转)与扩展内的 texCoord 通道覆写字段,导致带贴图旋转的模型 UV 方向错乱。
修改内容

Mesh 导入阶段(_applyPrimitiveTextureTransform):当 primitive 关联材质的 baseColorTexture 含有非零 KHR_texture_transform.rotation 时,在 _applySettings(法线/切线重算)前按 glTF 2.0 规范矩阵 T * R * S 将 scale、rotation、offset 原地烘焙进对应 TEXCOORD 顶点属性(兼容归一化整型 UV 转浮点);无 rotation 的模型保持原路径不变。
Material 导入阶段:
优先读取 KHR_texture_transform.texCoord 决定 ALBEDO_UV = 'v_uv1';
仅在 !baseColorTransform.rotation 时写入 props['tilingOffset'],避免已烘焙到顶点 UV 的缩放/偏移在 Shader 中被二次叠加。
单元测试:新增 src/core/assets/test/gltf-khr-texture-transform.test.ts,覆盖带 rotation 顶点 UV 烘焙、扩展 texCoord 覆写及无 rotation 模型 tilingOffset 回归校验。