Three.js: Extrude geometry bevel is sinusoidal not elliptical.

Created on 21 Jul 2016  路  7Comments  路  Source: mrdoob/three.js

Description of the problem

I needed the bevel to be eliptical to look nice for my project. I looked through the source code for the extrude geometry and noticed that of the two parameters, bs and z, z steps linearly while bs is a sine function.

So I changed: z = bevelThickness * ( 1 - t );
to: z = bevelThickness * Math.cos( t * Math.PI / 2 );
And that made it work like I expected. (And looks way better)

Is there a reason that it's sinusoidal? I think the default should be eliptical.

Three.js version
  • [x] Dev
  • [x] r78
  • [x] r72
  • [ ] ...

    Browser
  • [x] All of them

  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer

    OS
  • [x] All of them

  • [ ] Windows
  • [ ] Linux
  • [ ] Android
  • [ ] IOS

Most helpful comment

@bhouston This is actually only my second time even interacting with github so I am in no way familiar with the process of making a pull request.

@zz85 Here are some screen shots:
sinusoidal
sinusoidal box

As you can see it makes a very noticeable square outline at the end where it doesn't smoothly align.

eliptical bevel
beveled box

Where as the new function makes it look nicely rounded.

All 7 comments

/ping @zz85

Why not make this an option and PR it? :)

Hmm, interesting I've never given thought to this. Do you have an example or screenshots of what the difference would look with the different easing functions?

@bhouston This is actually only my second time even interacting with github so I am in no way familiar with the process of making a pull request.

@zz85 Here are some screen shots:
sinusoidal
sinusoidal box

As you can see it makes a very noticeable square outline at the end where it doesn't smoothly align.

eliptical bevel
beveled box

Where as the new function makes it look nicely rounded.

Thanks @flagstone78 for illustrating it nicely. From the looks of it I think it should be a function of cos function, and I guess should have give more attention to the details when I wrote that 馃槣

For making a Pull Request, you could either fork the repository to push your git commits, or use the online github editor to make a change.

Let me know if you would like to try that, otherwise I could help with a patch for this :)

@flagstone78 This wiki article may also help. Don't worry if you mess up, we will help you. : - )

@zz85 I used the online editor and referenced it above.

Was this page helpful?
0 / 5 - 0 ratings