简体   繁体   English

从Three.js场景将具有偏移量的纹理导出到GLTF

[英]Exporting Textures with Offsets to GLTF from Three.js Scene

EDIT: 编辑:

I had a question about exporting to obj and mtl but discovered that I could export from three.js using GLTFExporter.js and had success getting the geometry and texture out of three.js from that. 我有一个关于导出到obj和mtl的问题,但是发现我可以使用GLTFExporter.js从three.js导出,并成功地从three.js中删除了几何图形和纹理。

The issue I'm having with the GLTF Exporter is that I have textures that have offset and repeat settings that seem to not be exported from three.js when I open the file in Blender. GLTF Exporter遇到的问题是,我的纹理具有偏移量,并且在Blender中打开文件时似乎无法从three.js导出重复设置。 In Blender the whole texture takes up the MeshPlane that used to only have a small part of the texture showing in Three.js scene. 在Blender中,整个纹理占据了MeshPlane,该网格平面过去只在Three.js场景中显示一小部分纹理。

Might anyone know what I could add to the GLTF Exporter to be able to record and keep the repeat and offset texture settings? 也许有人知道我可以添加到GLTF Exporter中以记录并保留重复和偏移纹理设置的内容吗?

Many Thanks :) 非常感谢 :)

I've hit this myself.. and as far as I know, the answer is No. 我自己打过这个。.据我所知,答案是否定的。

Offset and Repeat are THREE.js specific features. 偏移和重复是THREE.js的特定功能。 Some other libraries have equivalents.. some engines use direct texture matrix manipulation to achieve the same effect. 其他一些库具有等效项。一些引擎使用直接纹理矩阵操纵来达到相同的效果。

One workaround is to modify your models UV coordinates before exporting to reflect the settings of texture.offset and texture.repeat. 一种解决方法是在导出之前修改模型的UV坐标以反映texture.offset和texture.repeat的设置。 You would basically multiply each vertex UV by the texture.repeat, and then add texture.offset. 您基本上可以将每个顶点UV乘以texture.repeat,然后添加texture.offset。 That would effectively "bake" those parameters into the model UV's, but then would require you to reset .repeat and .offset back to 1,1 and 0,0 respectively, in order to render the model correctly again in THREE.js. 这将有效地将那些参数“烘焙”到模型UV中,但随后需要您将.repeat和.offset分别重置为1,1和0,0,以便再次在THREE.js中正确呈现模型。

Here's a slightly relevant thread from the GLTF working group: 这是GLTF工作组的一个相关主题:

https://github.com/KhronosGroup/glTF/issues/107 https://github.com/KhronosGroup/glTF/issues/107

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM