SketchUp export obj with textures - how

孤者浪人 提交于 2019-12-22 14:16:43

问题


Windows 7 (64bit), SketchUp Make 13.0.4812.

Goal: convert SketchUp .skp model to .obj and load to WebGL using three.js.

Problem: sketchup exports model to .obj with external textures, and these textures are not loaded by three.js.

Question: is it possible to save SketchUp model as one .obj file with textures?


回答1:


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.

I copied the important bits:

// 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 );
  });
});


来源:https://stackoverflow.com/questions/18694501/sketchup-export-obj-with-textures-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!