【发布时间】:2019-06-09 23:47:30
【问题描述】:
我目前正在学习three.js。我想在我的场景中显示一张 16x9 的照片。
这是将images 数组添加到我的场景的代码:
const material = new MeshBasicMaterial({
map: loader.load(images[i]),
transparent: true,
opacity: 1,
});
const plane = new Mesh(new PlaneGeometry(imageWidth, 45), material);
plane.overdraw = true;
plane.position.x = i * (imageWidth + imageOffset);
plane.position.y = 0;
this.introImages.push({
obj: plane,
round: 1,
});
this.introImagesGroup.add(this.introImages[i].obj);
现在我收到控制台警告:
THREE.WebGLRenderer:图像不是二的幂 (1600x900)。调整为 1024x512
我已经读到纹理尺寸应该是 2 的幂次,因此它可以以优化的方式放入内存中,这让我想如果我将图像放入场景中的方式是正确的方式,或者是否有另一种方式将不遵循此的图像放入three.js?
【问题讨论】:
-
@UberMario 我不认为这是重复的,因为我理解为什么会出现警告并且我也不想禁用警告,我更想知道是否有其他方法可以将照片添加到场景中,而不是将其添加为纹理
标签: javascript three.js