Three.js 有没有办法让几何体适应纹理

Three.js is there a way to adapt the geometry to the texture

我在 Three.js 的一个项目中工作,我需要将多个图像浮动到 3D space 中。所以我开始简单地使用这些图像作为平面上的纹理。但是,图像具有不同的高度和宽度,所以我想知道是否有办法让平面适应纹理的大小。或者与之成正比。

也许有一种简单的方法可以做到这一点,但我没有找到任何东西。你们中的一个可以帮助我,或者告诉我停止寻找它吗?

加载纹理时,您可以检查其大小,然后创建平面以正确的 width/height 比例承载它:

var loader = new THREE.TextureLoader();
var texture = loader.load( "./img.png", function ( tex ) {
    console.log( tex.image.width, tex.image.height );
    // here you can create a plane based on width/height image linear proportion

} );