Curved rectangles (cubes)

Hello everybody! I would be glad if someone tells me how to draw such a map. Suppose I don’t know how to draw such curved rectangles.

Have you considered to design such a map in a DCC tool like Blender? This is probably the most easiest/flexibel approach since no coding is required.

2 Likes

You could also use two half cylinders (a big and a small) and subtract the small one from the big using a library like https://github.com/Hi-Level/three-csg.

This is how I do it

1 Like

thanks! And you do not tell me how to tie physics to these figures? At the moment, I use omio.js, but as far as I know, it has only primitive figures

Another option is to use THREE.ExtrudeBufferGeometry(), based on SVG or shapes you define.

2 Likes

I do not know oimo.js, I use ammo.js.

I’m actually about to create a library which does not only this but more. For now it only works in combination with Phaser. If you take a look at the source code, you will find how I did it.

I will create a stand alone version soon.

Here is an example:
https://enable3d.io/examples/constructive-solid-geometry-physics.html

And somewhere here I add physics to the new mesh:

Hope this helps :slight_smile:

2 Likes

Sorry, can I operate with three figures? Well, that is, there are three figures, I subtracted the other from one and want to subtract the third from the result. But for some reason it didn’t work out for me ((

Yes, you can subtract a three mesh from another.

Maybe this helps:

I built an example which uses the same shapes as you need. It uses Phaser.io and enable3d.io (which uses three.js and ammo.js)

https://enable3d.io/examples/dash-and-blast-prototype.html

1 Like

Thank :hugs:. Cool game:)

1 Like

@11121 I found a simpler way to do it the same shape!

https://jsfiddle.net/yandeu/83sdw5m2/

1 Like

Physics engines like Oimo.js and Cannon.js have heightmaps built into the library. Easiest approach is to create an image heightmap and rendering it. Black being the low level and white being the elevated level.

Example:
https://jsfiddle.net/Screwhead28/4ovmru0d/

1 Like