Jump to content

Imported mesh material color


Zahir Junejo
 Share

Recommended Posts

Hi fellow Babylonians,

 

I tried to import a mesh of a boat, but i want to change the color of its material. I cannot change it for some reason.

 

here is the part of code:

                let boat = new BABYLON.AbstractMesh("boat", scene);
                boatMaterial = new BABYLON.StandardMaterial("boatMat", scene);
                boatMaterial.diffuseColor = new BABYLON.Color3(1.0, 0.2, 0.5);


                BABYLON.SceneLoader.ImportMesh("", "assets/", "speedboat.babylon", scene,  (meshes, particleSystems) => { 
                meshes[0].material = boatMaterial;
                boat = meshes[0];
                });
                               
                let boatSpeed = 1;
                boat.position = new BABYLON.Vector3(-10, 0, 100);

 

But bright side, experience on babylon has been great so far. But just need help on this.

Link to comment
Share on other sites

Why not just use meshes[0].material.diffuseColor = new BABYLON.Color3(1.0, 0.2, 0.5); ? Unless, of course, the same material is used by other meshes. Also, why do you create an AbstractMesh variable and then reassign it to the loaded mesh?

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