Jump to content

Three.js merge geometries with different textures


sambP
 Share

Recommended Posts

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

aWdTG.png.84f642da7e4f87de3250fe3f15b64564.png

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?

Rvi8O.png.98dfc702b73df1b558147b6b9b261ed5.png

 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);
        });
    });

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...