SketchUp 导出带有纹理的 obj - 如何 [英] SketchUp export obj with textures - how
问题描述
Windows 7(64 位),SketchUp Make 13.0.4812.
Windows 7 (64bit), SketchUp Make 13.0.4812.
目标:将 SketchUp .skp 模型转换为 .obj
并使用 Three.js 加载到 WebGL.
Goal: convert SketchUp .skp model to .obj
and load to WebGL using three.js.
问题: Sketchup 导出模型到.obj
带有外部纹理,这些纹理没有被three.js 加载.
Problem: sketchup exports model to .obj
with external textures, and these textures are not loaded by three.js.
问题:是否可以将 SketchUp 模型保存为一个带有纹理的 .obj
文件?
Question: is it possible to save SketchUp model as one .obj
file with textures?
推荐答案
不,.obj 是一种简单的文本格式.您不能在 .obj 中存储纹理.这是一个示例,说明如何从单独的 .jpg 文件加载纹理.
No, .obj is a simple text format. You can't store textures in .obj. Here is an example on how to load the texture from a separate .jpg file.
我复制了重要的部分:
// texture
var manager = new THREE.LoadingManager();
manager.onProgress = function ( item, loaded, total ) {
console.log( item, loaded, total );
};
var texture = new THREE.Texture();
var loader = new THREE.ImageLoader( manager );
loader.load( 'textures/ash_uvgrid01.jpg', function ( image ) {
texture.image = image;
texture.needsUpdate = true;
} );
// model
var loader = new THREE.OBJLoader( manager );
loader.load( 'obj/male02/male02.obj', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.material.map = texture;
}
scene.add( object );
});
});
这篇关于SketchUp 导出带有纹理的 obj - 如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!