Jump to content

Problem with babylon.csg, dispose method and material property


Anonymous
 Share

Recommended Posts

var b1=new BABYLON.Mesh.CreateBox("box1",3.0,scene);

var b11=new BABYLON.StandardMaterial("b11",scene);

b11.diffuseColor=new BABYLON.Color3(1,1,0);
b1.material=b11;

i have created one box and applied material property and i have also subtracted another box from b1 box using babylon.csg like

var b2=new BABYLON.Mesh.CreateBox("box2",1.0,scene);

var b1CSG=BABYLON.CSG.FromMesh(b1);
    var b2CSG=BABYLON.CSG.FromMesh(b2);
    
    subCSG=b1CSG.subtract(b2CSG);
    
    b1.dispose();
    b2.dispose();
    
    subCSG.toMesh("csg",new BABYLON.StandardMaterial("mat",scene),scene);

After this, hole is created inside box1 but the material property i have given is not applied to the box1.

How can i apply this material property to box1 after dispose method?

Thanks...!!

Link to comment
Share on other sites

Hi Anonymous (who is that masked stranger) and welcome to the forum. Do you know about the playground ? Putting your code into the playground is the best way to get help from the many responsive people on this forum.

NOTE do not use new when creating a box mesh. In your line  subCSG.toMesh("csg",new BABYLON.StandardMaterial("mat",scene),scene);  the new standard material you created has not been given any properties use a material you have previously set see PG below.

Here is a working playground http://www.babylonjs-playground.com/#GSRTH#1

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