简体   繁体   English

三.js 将纹理应用于 stl 网格

[英]three.js applying texture to stl mesh

I am loading a STL exported from Rhino.我正在加载从 Rhino 导出的 STL。 All works ok, however, when I try and apply a simple texture to the mesh, the STL objects are not rendered at all.一切正常,但是,当我尝试将简单的纹理应用于网格时,根本不会渲染 STL 对象。

What am I missing我错过了什么

Code is as follows:代码如下:

var diamondTexture = THREE.ImageUtils.loadTexture('images/diamond.jpg');
...
var loader = new THREE.STLLoader();
loader.addEventListener( 'load', function ( event ) {

    var geometry = event.content;
    stones = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial({color:0x99CC3B, ambient:0x99CC3B, map:diamondTexture}) );

    scene.add( stones );

} );
loader.load( 'models/jwl0020-stones.stl' );

You could try geometry.computeTangents().你可以试试 geometry.computeTangents()。 Once I added that my stl files were able to have a texture though... the texture does not not properly "fit" the model since there are no UVs.一旦我补充说我的 stl 文件能够有纹理……纹理不能正确“适合”模型,因为没有 UV。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM