Jump to content

Add material for meshes created by loop.


Quac_quac_92
 Share

Recommended Posts

Hello, i use this code for create 8 Cylinder in a cirlce.

var angle = 0;
        for (var index = 0; index < 8; index++) {
            var Cylinder  = BABYLON.Mesh.CreateCylinder("cylinder", 0.3, .5, .5, 20, 1, scene, false);
            Cylinder.position.y =  Math.sin(angle);;
            Cylinder.position.x =  Math.cos(angle);
            Cylinder.rotation.x = Math.PI/2;

            angle -= Math.PI / 4;
         }

Now i want to add material for each them  after an event (click ,...) , but i don't know how.  I only can add material for the first Cylinder.

one more thing, how to add URL image on http://www.babylonjs-playground.com

like BABYLON.Texture("textures/misc.jpg", scene);

demo.rar

Link to comment
Share on other sites

Hi guys!  QQ, how about I treat you to a PG (a playground demo) that should help? 

http://www.babylonjs-playground.com/#11XV5X#1

That should get you rolling.  ActionManager picks are active on most mesh. 

Clicking makes changes to material colors.  Code lightly commented.

And... a little cosine animating... which is always fun.  :)

Hope this helps.  Be well.

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