Jump to content

new mesh type : Lathe


jerome
 Share

Recommended Posts

Hi people,

 

Here's a new mesh type that I would like to propose : Lathe.

 

Lathe is a simple mesh type which combines cylinder and extrusion properties in an easy way to build more complex meshes.

 

Let's define a shape to be "lathed", the model, in the xOy plane, considering that the world Y axis will be the lathe rotation axis then :

 

http://www.babylonjs-playground.com/#1KN1LB

 

Now let's create the Lathe from this model : http://www.babylonjs-playground.com/#1KN1LB#1

Lathe will have two parameters in addition to the model shape :

a radius : http://www.babylonjs-playground.com/#1KN1LB#2

a tessellation : http://www.babylonjs-playground.com/#1KN1LB#3

 

which both will have default values

 

So this will be something as simple as :

var lathe = BABYLON.Mesh.CreateLathe("lathe", shape, radius, tessellation, scene);

Want it ?

(only 20 LOC)

Link to comment
Share on other sites

When talking about "more complex meshes"... well, just set a more complex model : http://www.babylonjs-playground.com/#1KN1LB#4

lathe : http://www.babylonjs-playground.com/#1KN1LB#5

 

 

What about caps ?

you could them by yourselves with the adequate shape : http://www.babylonjs-playground.com/#1KN1LB#6

lathe : http://www.babylonjs-playground.com/#1KN1LB#7

Link to comment
Share on other sites

  • 2 months later...

This looks awesome Jerome.  I'm planning on using the lathe in my current project, but there seems to be an issue with it.

 

You can see some shading issues and artifacts in the capped version:

http://www.babylonjs...d.com/#1KN1LB#7

 

I lowered the tesselation so that you can better see the geometry:

http://www.babylonjs-playground.com/#1KN1LB#8

 

Here I use the BABYLON.Mesh.createLathe function:

http://www.babylonjs-playground.com/#1KN1LB#9

 

Here I reduced the shape to a simple line:

http://www.babylonjs-playground.com/#1KN1LB#10

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...

I was able to improve the lathe by adding some code to Mesh._ExtrudeShapeGeneric.  I check to see if the first element in Path3D is the same as the last element.  If it is, I don't modify the shape using the tangents, normals, binormals.

 

without fix:

http://www.babylonjs-playground.com/#1KN1LB#9

 

with fix:

http://www.babylonjs-playground.com/#1KN1LB#18

 

without fix:

http://www.babylonjs-playground.com/#1KN1LB#10

 

with fix:

http://www.babylonjs-playground.com/#1KN1LB#21

 

I'm not sure how good of a fix this is.  Hopefully it is something you can use.

Link to comment
Share on other sites

well : http://www.babylonjs-playground.com/#1KN1LB#33

 

Normally, if we want no artifact on the caps, we should duplicate second and the n-1 vertices (if capped on bottom and on top) in the shape array.

As we can see the light reflection is (almost) correct.

 

It remains an artifact which is related to the (wrong) geometry of the lathe. I guess this happen on the way the lathe is closed, I need to check

Link to comment
Share on other sites

  • 1 month 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...