使用 ObjectLoader 加载时添加纹理(图像) [英] Adding texture (an image) when loading with ObjectLoader

查看:24
本文介绍了使用 ObjectLoader 加载时添加纹理(图像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ObjectLoader 加载我的场景(使用 ObjectExporter 导出).如何在加载时将纹理应用于我的对象?

I'm using ObjectLoader to load my scene (exported using ObjectExporter). How can I apply textures to my objects while loading?

推荐答案

使用 ObjectLoader 加载对象,然后使用它的几何体创建一个带有加载纹理的网格:

Use ObjectLoader to load the object, and then use it's geometry to create a mesh with a loaded texture:

var loader = new THREE.ObjectLoader();
    loader.load("models/ship.json",
        function (obj) {
            var material = new THREE.MeshLambertMaterial({
                      map: THREE.ImageUtils.loadTexture('models/textures/ship.jpg')});
            var mesh = new THREE.Mesh(obj.geometry, material);
            scene.add(mesh);
        }
    );

这篇关于使用 ObjectLoader 加载时添加纹理(图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆