Jump to content

Change texture on glTF model


djeustice
 Share

Recommended Posts

Hello.  I have this Seat.gltf model in my scene that I exported it from 3ds Max.  Anyways, how do I change the diffuse texture on it?  The seat imports with a black texture (SeatBlack_baseColorTexture.png).  I'd like to change it to this (SeatLime_baseColorTexture.png).   My goal eventually is to let the user pick from a variety of seat colors.  Any pointers in the right direction would be appreciated.  Thanks.

    var mySeat = BABYLON.SceneLoader.Append("./models/", "Seat.gltf", scene, function (scene) {
    }, null, function (scene) {
        
        var LimeTexture = new BABYLON.PBRMaterial("", scene);
        LimeTexture.baseColorTexture = new BABYLON.Texture("models/SeatLime_baseColorTexture.png", scene);
        mySeat.material = LimeTexture;
    });

Link to comment
Share on other sites

This seems to be working for changing just the diffuse texture.  I'll take a look at exporting PBRMetallicRoughness from 3ds Max. Thank you kindly.

 

    var myKayak2;
    BABYLON.SceneLoader.ImportMesh("", "models/", "Kayak.gltf", scene, function (newMeshes)  {
        myKayak2 = newMeshes[0];
        
        var BWTexture = new BABYLON.StandardMaterial("BlueWave", scene);
        BWTexture.diffuseTexture = new BABYLON.Texture("models/BlueWave.png", scene);
        BWTexture.diffuseTexture.hasAlpha = false;
        BWTexture.backFaceCulling = false;
        myKayak2.material._subMaterials[2] = BWTexture;    
    }); 

Link to comment
Share on other sites

  • RaananW changed the title to Change texture on glTF model
  • 3 months later...

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...