Skip to content

lele394/threejs_shenannigans

Repository files navigation


stars issues watchers

Like what you see? drop me a star!


See it in video 📺

Little red riding hood


Controls 🎮

Controls AZERTY QWERTY
Forward Z W
Left Q A
Backward S S
Right D D
Turn Left A Q
Turn Right E E
Up R R
Down F F
Open settings Space Space
Soft Chunk Check C C
Toggle Wireframe X X
Reset Chunks V V

A few words ✍️

Introduction

Hi, I'ml Léo, I like creating a bunch of stuff by smashing my keyboard. This project is part of my journey in 3D graphics. I've wanted to implement by myself the Marching Cube algorithm. I cannot state how much this video helped me in debugging my code, I'm also using Deadlock's triangulation table.

Why do that

I've wanted to implement that algorithm due to a few games based on voxels that I always really liked :

Current features

Currently, the demo has a working camera that you can control using the listed keybinds below. You can toggle the wireframe by pressing X and reset chunks with V. Note that doing so will regenerate all the active chunks.
If your computer allows it, you can enable the auto chunk check to always generate and load chunks in a radius around you. I have implemented Web Workers to generate each chunk. However the generation is done on the CPU. An active web worker counter is displayed in the info panel.
Web workers are terminated if they are currently working on chunks that are no longer used, in order to avoid computations on chunks that won't be used.
If the auto chunk check is not enabled (disabled by default), you can press C to refresh the active chunk list to chunks around you.

Precautions with chunk radius

Please be careful when upping the chunk radius. It is generally better to increase the size of a chunk instead of teh radius, as each chunk will spawn a worker. A high radius leads to sometimes absurd amounts of workers; I do not recommend going past 5, which already spawns 515 of them.

Issues in Chrome and Opera

I'm aware of very bad performance in Chrome and Opera, however I do not think I have much control on that, though I'll look into it. No issues spotted running the demo on Firefox with a beefy machine. My setup runs an hexacore i5-10400 and a GTX-1660S and loads it pretty fast.


Screenshots 🖼️

Fully generated Mandelbulb sphere.

1


random blob from appearing when surrounding chunks are not generated.

2


Partially generated Mandelbulb.

3