gpt4 book ai didi

javascript - 显示纹理 - Maya 到 Three.js

转载 作者:行者123 更新时间:2023-11-28 09:43:09 25 4
gpt4 key购买 nike

我需要将 Maya 转换为 JS,以获得带有纹理的简单模型工作正常但没有纹理显示我的代码:var loader = new THREE.JSONLoader();

loader.load( "models/t2.js", function(geometry) {
var part1 = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
mesh =new THREE.Object3D();
mesh.add( part1 );
//var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(0,0,0);
mesh.rotation.set(0,0,0);
mesh.scale.set(30,30,30);
scene.add( mesh );
});

在线演示:http://mika.ir/virtual-exhibition/下载码:http://mika.ir/virtual-exhibition/virtual-exhibition.rar

最佳答案

您必须将纹理传递给 Material 对象之一。使用 MeshLambertMaterial 或 MeshPhongMaterial 并传入 THREE.Texture。您首先必须加载纹理并传递回调。如果您要加载的纹理是“path/texture.png”,我会执行以下操作:

var modelTexture = THREE.ImageUtils.loadTexture('path/texture.png', false, loadModel);

function loadModel() {
loader.load( "models/t2.js", function(geometry) {
var part1 = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial({ map: modelTexture });
mesh =new THREE.Object3D();
mesh.add( part1 );
//var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(0,0,0);
mesh.rotation.set(0,0,0);
mesh.scale.set(30,30,30);
scene.add( mesh );
});
}

关于javascript - 显示纹理 - Maya 到 Three.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12132237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com