three.js 加载 obj模型

Posted chenyi4

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了three.js 加载 obj模型相关的知识,希望对你有一定的参考价值。

mtl文件  模型的材质信息,比如模型颜色、透明度等信息,还有纹理贴图的路径,比如颜色贴图、法线贴图、高光贴图等等。

obj 模型 2进制模型文件

 

 https://threejs.org/

js 文件去官网下载就行了

其他代码普通的一样就省略了

官方文档: https://threejs.org/docs/index.html#examples/en/loaders/OBJLoader


import * as THREE from \'./js/three.module.js\';

import Stats from \'./js/stats.module.js\';
import { OBJLoader } from \'./js/OBJLoader.js\';

function
loadObj(){ var loader = new OBJLoader(); loader.load( \'./3d/banana.obj\', function ( obj ) { let object = obj; object.scale.set(3,3,3); object.children[0].material.color.set(0xe8b73b); object.rotation.x = 1; object.rotation.y = 0.3; scene.add(object); }); var light = new THREE.DirectionalLight(0xffffff);//光源颜色 light.position.set(20, 10, 1305);//光源位置 scene.add(light);//光源添加到场景中 }

 

以上是关于three.js 加载 obj模型的主要内容,如果未能解决你的问题,请参考以下文章