Jump to content

Easy what to make hollow cylinder?


gaelbeltran
 Share

Recommended Posts

  • 5 months later...
  • 3 years later...

More Generic approach to create hollow Cylinder and Cones

https://www.babylonjs-playground.com/#1F1AHQ#10

 

for hollow tube set 

    var outerTopDiameter = 4
    var outerBottomDiameter = outerTopDiameter




    var height = 5;
    var thickness = .1
    
    //Outer Cylinder
    var outerTopDiameter = 4
    var outerBottomDiameter = 7

    //Inner Cylinder
    var innerTopDiameter = outerTopDiameter - thickness
    var innerBottomDiameter = outerBottomDiameter - thickness

    var tess = 20;

    var inner = BABYLON.MeshBuilder.CreateCylinder("cone", { diameterTop: innerTopDiameter, diameterBottom: innerBottomDiameter, height: height, tessellation: tess }, scene);
    //BABYLON.Mesh.CreateCylinder("inner", height, innerDiameter, innerDiameter, tess, 1, scene);
    var outer = BABYLON.MeshBuilder.CreateCylinder("cone", { diameterTop: outerTopDiameter, diameterBottom: outerBottomDiameter, height: height, tessellation: tess }, scene);
    //BABYLON.Mesh.CreateCylinder("outer", height, outerDiameter, outerDiameter, tess, 1, scene);

    var innerCSG = BABYLON.CSG.FromMesh(inner);
    var outerCSG = BABYLON.CSG.FromMesh(outer);

    var subCSG = outerCSG.subtract(innerCSG);

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

    var newMesh = subCSG.toMesh("csg2", mat0, scene);

    scene.removeMesh(inner);
    scene.removeMesh(outer);

 

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