4 ms·
I'm finding Three.js with an idiomatic Clojure veneer to be quite enjoyable. I find one of the biggest "wins" of any Lisp is how natural it is to build a DSL fo
by adrianm 13y ago
I'm finding Three.js with an idiomatic Clojure veneer to be quite enjoyable. I find one of the biggest "wins" of any Lisp is how natural it is to build a DSL for whatever your problem domain happens to be.
For example, right now I'm toying around with a declarative syntax for specifying arbitrarily complex mesh animations in terms of partial functions. To illustrate, instead of having a render loop where conceptually you are modifying something globally in a once per frame, iterative fashion, instead you would feed your rendering context a hash-map that both specifies animatables to be animated, and applies these partial functions onto the specified properties of the animatable object.
Trivial example:
{:animatable some-planet
:animation {:rotation {:y (partial + rotation-speed) } } }
Anyway, I suppose my advice is to not give up on using ClojureScript here because the potential for making the development of your game a thoroughly enjoyable experience is, for one, a huge win. Aren't we supposed to be enjoying this stuff at the end of the day?
Take advantage of the language and be creative. I have never run into a situation where ClojureScript has somehow bottlenecked performance in any way, and I honestly can't really imagine that being a real concern. This is doubly true in a WebGL graphical context where most of the potentially awesome looking stuff (www.shadertoy.com) is being offloaded to the GPU and has absolutely nothing to do with Javascript or ClojureScript.
My last piece of advice: figure out how often you want to deal with native javascript objects instead of Clojure data structures early on, and stick to it as a convention. The little differences in how the language treats the two (in a collection/sequence sense) will drive you (or me) crazy. I personally prefer to take any JS object I'm going to make considerable use of and turn it into a full fledged Clojure object until I'm finished with it. Obviously this advice doesn't apply to short lived objects, or simple method calls.