Three.js merge with different textures

折月煮酒 提交于 2019-12-25 09:09:49

问题


I have a scene with two individual meshes. It looks like this:

    this.loadFiles("gras", (gras) => {
        var particleMaterial = new THREE.MeshPhongMaterial();
        particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/gras.jpg");
        particleMaterial.side = THREE.DoubleSide;
        this.mesh = new THREE.Mesh(gras,particleMaterial);
        this.loadFiles("rocks", (rocks) => {
            var particleMaterial = new THREE.MeshPhongMaterial();
            particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/rocks.jpg");
            particleMaterial.side = THREE.DoubleSide;
            this.rocks = new THREE.Mesh(rocks,particleMaterial);
            callback(this);
        });
    });

Now I want to merge the meshes together. But how can i combine the textures?

   this.loadFiles("gras", (gras) => {
        this.loadFiles("rocks", (rocks) => {
            var geometry = new THREE.Geometry;
            THREE.GeometryUtils.merge(geometry,gras);
            THREE.GeometryUtils.merge(geometry,rocks);
            var particleMaterial = new THREE.MeshPhongMaterial();
            particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/gras.jpg");
            particleMaterial.side = THREE.DoubleSide;
            this.mesh = new THREE.Mesh(geometry,particleMaterial);
            callback(this);
        });
    });

来源:https://stackoverflow.com/questions/41988213/three-js-merge-with-different-textures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!