标题已经解释得很清楚了。我有一个以 Base 64 编码的法线贴图,我想在模型上使用它。我一直在尝试一些在网上找到的例子,但没有成功。
var curObj = mesh.getObjectByName(object + "_low")
var image = new Image()
var texture = new THREE.Texture(image)
image.src = reader.result
curObj.material.normalMap = image
image.onload = function() { texture.needsUpdate = true }
Object 是一个字符串,它是我想要应用法线贴图的部分的名称。 64进制字符串是reader.result
最佳答案
您想要将纹理
指定为法线贴图,而不是图像
。此外,我会在图像加载完成后创建纹理,而不是之前:
var image = new Image();
image.onload = function() {
var curObj = mesh.getObjectByName(object + "_low");
var texture = new THREE.Texture(image);
curObj.material.normalMap = texture; // Make sure this is the texture.
}
// I believe .src needs to be assigned after .onload has been declared
image.src = reader.result;
关于three.js - 如何使用 Base 64 字符串作为法线贴图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70843396/