u/ryjocodes

▲ 44 r/raylib+1 crossposts

I re-created the 3d split-screen example in CLIPS

This is my first 3d example in CLIPSraylib! It shows two different camera angles of the same 3d scene. It's available to run and edit live on the Tour of CLIPSraylib website. I based it on the existing C example from the raylib source code.

This one went surprisingly smoothly. I learned a lot about how to optimize CLIPSraylib programs when bringing them into Wasm, including the importance of ordering your input event checks around `raylib-window-should-close` which is when `emscripten_sleep` runs in raylib.

u/ryjocodes — 9 days ago
▲ 28 r/raylib

I converted another C-based raylib example into CLIPS using CLIPSraylib. The first implementation worked well when running natively on my OS, but it took me a bit longer to convert it to Wasm for two reasons.

Originally, I'd implemented a rules engine which activated a Defrule for each star Fact and then rendered it. However, Defrule activations are more costly in Wasm than they are in native compiled CLIPSraylib programs. After I converted the rules engine to activate only once and then iterate through all stars with `do-for-all-facts`, the performance was much better.

However, I still ran into some problems with detecting mouse scroll wheel movement and spacebar presses. This is because of the way Emscripten-built Async programs return control back to the browser in order to receive events. Once I re-arranged some function calls (ie moving `raylib-window-should-close` to come before mouse wheel and key pressed detection), things worked just like they did when compiled natively.

Now I can cruise through space using raylib and CLIPS from the comfort of my browser.

u/ryjocodes — 25 days ago