Skip to content
Mike edited this page Oct 7, 2016 · 2 revisions

Clojurescript -> Blend4Web Web-player

Experiment to see if I can control Blend4Web's outputted JS stuff with Clojurescript.

Workflow

You'd make a scene in Blender the usual way, use Blend4Web's exporter (JSON option) to make the un-manipulated 3d scene. You would then load a scene with the exported files, only with Clojurescript instead of JS.

...Why?

Blend4Web can output to a fairly performant WebGL-based scene, and its easily manipulated via the library's various own function calls. This means a more functional language like Clojurescript could easily translate into b4w function calls.

It also turns out that Blend4Web, like Clojurescript, uses Google Closure, and already has its own extern files. Surprisingly, b4w's externs appear to be enough for generating a functioning cljsjs package.

Why bother? There's already xyz.

My main goal is getting 3d graphics into a beat-driven (aka audio-reactive) context. While there's already some takes on this idea, I believe this setup will be the most optimal.

  • I've been using Blender for 10 years, and, despite it's eccentricities, is the devil I know.
  • I'm somewhat comfortable debugging JS, the language of blend4web's outputted webgl.
  • While I've only been using Clojurescript for about 4 months, it's lispyness make it conducive to live-coding, as evidenced by tools like Overtone, Afterglow and Quil. The language itself is also very expressive, and coerces me into better coding practices.

There's other software for this, but they'd force me to either learn a new 3d package, deal with 3d file format export issues, wrestle with JS, or all of the above. I could just set the bar lower, and make triangles and circles, but that's just boring!

What about outputting Clojurescript-driven stuff back into Blender?

It would be really cool if the live-coded scene be translated back into a Blender scene. Unfortunately, I can't figure this out, and I'm planning on Blender just outputting stuff. If you have any ideas, please let me know!