我从 turbosquid 购买了 3d 场景格式的 3d 人类牙齿模型。我要做的就是从文件中提取个体牙齿并在threejs脚本中使用它们以在网页上显示它们。我所做的是从 3ds Max 中以 .obj 格式导出一颗牙齿,然后使用 threejs 提供的转换器将其转换为 json。虽然图像出现在页面上,但没有应用纹理。我是 3ds Max 和 Threejs 的新手,不知道我错过了什么。你能指导我吗?
编辑: 这是 Json 元数据
"metadata" :
{
"formatVersion" : 3.1,
"sourceFile" : "toothz.obj",
"generatedBy" : "OBJConverter",
"vertices" : 1636,
"faces" : 1634,
"normals" : 1636,
"colors" : 0,
"uvs" : 1636,
"materials" : 1
},
"scale" : 1.000000,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Teeth",
"colorAmbient" : [0.584314, 0.584314, 0.584314],
"colorDiffuse" : [0.584314, 0.584314, 0.584314],
"colorSpecular" : [0.538824, 0.538824, 0.538824],
"illumination" : 2,
"opticalDensity" : 1.5,
"specularCoef" : 70.0,
"transparency" : 1.0
}],
编辑: 这是完整的代码
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 2000);
loader = new THREE.JSONLoader();
loader.load( "js/JsonModels/toothz.js", function( geometry, materials ) {
materials[0].shading = THREE.SmoothShading;
var material = new THREE.MeshFaceMaterial( materials );
mesh = new THREE.Mesh( geometry, material );
mesh.scale.set( 3, 3, 3 );
mesh.position.y = 0;
mesh.position.x = 0;
scene.add( mesh );
} );
camera.position.z = 340;
//var ambient = new THREE.AmbientLight( 0x101030 );
//scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.set( 0, 0, 1 ).normalize();
scene.add( directionalLight );
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
}
render();