如何只调用textureLoader.load一次,并为每个纹理指定一个贴图名称,以便在所有纹理都已加载时调用创建材质?
否则,我无法控制何时创建材质并正确指定纹理。
我在不加载mtl的情况下使用obj。
谢谢你的帮助
这是我要求替换为一个函数textureLoader.load的代码
var textureLoader = new THREE.TextureLoader(manager);
var albedoM = textureLoader.load( "vaseTextures/albedo.png", onLoad, onProgress, onError );
var normalMap = textureLoader.load( "vaseTextures/normal.png", onLoad, onProgress, onError );
var aoMap = textureLoader.load( "vaseTextures/cavity.png", onLoad, onProgress, onError );
Expected result: I call once function onLoad( texture) after the textures are loaded and saving a name for each texture, and so that I can then create one material that holds each texture and assign the textures to it.发布于 2019-03-30 04:24:21
在这种情况下,最好使用THREE.LoadingManager的onLoad()回调。它将在加载完所有资源后立即执行。因为你已经向你的纹理加载器传递了一个THREE.LoadingManager的实例,所以你只需要实现onLoad()。例如:
manager.onLoad = function ( ) {
const material = new THREE.MeshPhongMaterial();
material.map = albedoM;
material.normalMap = normalMap;
material.aoMap = aoMap;
// do something with your material
};three.js R103
https://stackoverflow.com/questions/55422336
复制相似问题