←back to thread

287 points imadr | 5 comments | | HN request time: 0.333s | source
1. jupitr ◴[] No.45109823[source]
How was the interactivity achieved? Could you maybe link to the source so I can learn? I have been trying to get something like this working with quarto, but it is getting way too complicated.
replies(1): >>45109937 #
2. imadr ◴[] No.45109937[source]
I wrote everything from scratch in javascript and webgl. You can check the entire source code of the article here: https://imadr.me/pbr/main.js

Beaware though, it's a 8000+ lines of code js file that is very badly organized, it's by no mean a reference for good quality code. However I find writing everything by hand easier in the long term than using already existing libraries for example.

The code includes all the math functions, mesh primitive generation, shaders and even a sketchy text renderer using sdf fonts.

If I had to make it again I would use typescript, type errors were the biggest source of bugs.

replies(2): >>45113662 #>>45116740 #
3. Cthulhu_ ◴[] No.45113662[source]
How long did it take you to write that code / this article?

I'm a big fan of zero-dependency code (or at the very least with any dependency vendored/hosted locally), it means this page will still work and look as it does today in 25 years time.

I don't know if TS runs natively in browsers yet, but v8 / NodeJS does support it (just strips off Typescript specific tokens).

replies(1): >>45119902 #
4. amitp ◴[] No.45116740[source]
Love it! For typescript, esbuild has been my favorite tool for turning typescript into browser-readable js, and then I check type errors separately using the ide plugin.
5. imadr ◴[] No.45119902{3}[source]
I took me about 3 months working on it on and off, it amounts to about 3 weeks of full time work. For my other projects I'm just writing everything to a single typescript file and compiling it with tsc, works like a charm and zero dependencies!