Сообщения, созданные пользователем mikejamesbelanger
07 декабря 2016 18:39
Hi guys,
So progress is still happening, I can even get some audio-reactive stuff (with the help of tonejs).
Here's a simple test : http://clojurescript-experiments.neocities.org/ (you'll need a microphone). You can even 'live-code' some of the functions changing, if you compile it un-optimized!
I'm also trying to set up the clojurescript externs for blend4web. Because blend4web is already Google Closure enabled, I found that using your own externs actually works with clojurescript as well.
That said, in order to get advanced compilation, I had to include the files in:
https://github.com/TriumphLLC/Blend4Web/tree/master/src/ext
in addition to those prefixed with 'externs_' - which leads me to believe these are externs too? Or are they for extensions? Sorry for my silly questions.
-Mike
So progress is still happening, I can even get some audio-reactive stuff (with the help of tonejs).
Here's a simple test : http://clojurescript-experiments.neocities.org/ (you'll need a microphone). You can even 'live-code' some of the functions changing, if you compile it un-optimized!
I'm also trying to set up the clojurescript externs for blend4web. Because blend4web is already Google Closure enabled, I found that using your own externs actually works with clojurescript as well.
That said, in order to get advanced compilation, I had to include the files in:
https://github.com/TriumphLLC/Blend4Web/tree/master/src/ext
in addition to those prefixed with 'externs_' - which leads me to believe these are externs too? Or are they for extensions? Sorry for my silly questions.
-Mike
16 ноября 2016 20:02
Hi guys,
I'm getting to grips with a clojurescript-controlled blend4web scene. I still don't know what I'm doing, but it looks like this isn't as crazy as it sounds.
Here's a video showing me fooling around with it. Note how I trigger a B4W engine panic whenever I save the clojurescript file (on the left). I don't fault blend4web for this, as I'm using blend4web for a very unorthodox purpose.
That said, I think it's interesting that blend4web's engine doesn't fully restart every time I save – and I don't know why :P The JS get's re-compiled every time it saves - including the JS that starts the engine. My guess is that because blend4web uses a separate web-worker for asset loading, and because clojurescript only targets the main thread whenever I load, the separate worker thread keeps going as I save the file. This is actually kind of neat, but probably something I should resolve.
I'm getting to grips with a clojurescript-controlled blend4web scene. I still don't know what I'm doing, but it looks like this isn't as crazy as it sounds.
Here's a video showing me fooling around with it. Note how I trigger a B4W engine panic whenever I save the clojurescript file (on the left). I don't fault blend4web for this, as I'm using blend4web for a very unorthodox purpose.
That said, I think it's interesting that blend4web's engine doesn't fully restart every time I save – and I don't know why :P The JS get's re-compiled every time it saves - including the JS that starts the engine. My guess is that because blend4web uses a separate web-worker for asset loading, and because clojurescript only targets the main thread whenever I load, the separate worker thread keeps going as I save the file. This is actually kind of neat, but probably something I should resolve.
08 октября 2016 21:39
Sweet – thanks Ivan it works just as you said. I put it up here, in case anyone wants to check it out. The corrresponding clojurescript is here.
And thanks for pointing out the victory day code – this will probably answer a lot my other questions.
And thanks for pointing out the victory day code – this will probably answer a lot my other questions.
05 октября 2016 15:08
Oh yeah, I'm definitely planning on making more complex scenes – I just want to ensure I understand simple scenes first. Speaking of which, yes – I'm not a fan of my update loop right now, its just that elapsed sensor was the only one I could figure out. So time.animate sounds like a more reliable (sane) way of animating values. But I'm confused on how to use it – would I invoke this in my elapsed sensor callback? Or do I invoke it somewhere else?
I re-opened it today in latest FF, and….it's now the same as in Chrome :P Mind you, I think there was a small update that FF downloaded before I re-opened..maybe it was that fix. Either that, or I'm hallucinating.
At any rate, b4w is working pretty good on both now!
Hmm… I don't see the difference. Can you show a screenshot?
I re-opened it today in latest FF, and….it's now the same as in Chrome :P Mind you, I think there was a small update that FF downloaded before I re-opened..maybe it was that fix. Either that, or I'm hallucinating.
At any rate, b4w is working pretty good on both now!
01 октября 2016 16:49
Cheers Ivan!
I've managed to cobble together a basic scene – some animation, manipulating a simple cube via clojurescript. Check it out here
Here's that same project's source code – you can find the 'meat' of the logic in ../src/cube_test/core.cljs.
Note that it seems to work better on Chrome – FF doesn't seem to load shadows the same way.
I've managed to cobble together a basic scene – some animation, manipulating a simple cube via clojurescript. Check it out here
Here's that same project's source code – you can find the 'meat' of the logic in ../src/cube_test/core.cljs.
Note that it seems to work better on Chrome – FF doesn't seem to load shadows the same way.
30 сентября 2016 16:40
Hi Ivan,
Ok good to hear. It turns out I'm a goddamn fool – I was trying to create the manifold from the elapsed sensor object, *not* from the controls module :P Of course that elapsed sensor doesn't have that method! Once I realized my idiocy, I was able to create the manifold callback with the sensor.
Thank-you. That's similar to what I've been using – only I used everything in your google closure directory. I really shouldn't have said 'declaring externs' because it was more like 'taking your externs, putting them in the right clojurescript extern directory and see what happens'. From your link, it looks like I've included a few too many :P cljs externs
Cheers!
Hi, Mike!
This is normal, it looks the same as in compiled b4w.min.js. I don't see a problem here.
Ok good to hear. It turns out I'm a goddamn fool – I was trying to create the manifold from the elapsed sensor object, *not* from the controls module :P Of course that elapsed sensor doesn't have that method! Once I realized my idiocy, I was able to create the manifold callback with the sensor.
Yes, you should declare b4w-specific externs to avoid possible bugs. Firstly, here you can find the list of the externs that we use for compilation: source.
Thank-you. That's similar to what I've been using – only I used everything in your google closure directory. I really shouldn't have said 'declaring externs' because it was more like 'taking your externs, putting them in the right clojurescript extern directory and see what happens'. From your link, it looks like I've included a few too many :P cljs externs
Besides them, we also generate a special temporary file during the compilation, which contains some data gathered from the source files: source. We find API functions/variables declared as "exports.IDENTIFIER" and also indetifiers under the @cc_externs token. You can see it here: source.Thanks – this is good to know. I should familiarize myself with this part of the compilation process, as I've been ignoring it until now.
Cheers!
28 сентября 2016 23:06
Hi guys,
In my ongoing quest to integrate Clojurescript with blend4web, I've run into another issue. I can't seem to create a sensor type. I've tried the elapsed sensor, and the callback sensor.
In both of those cases, I start by invoking the control module's create_elapsed_sensor function, and what it returns is an object with all its attributes munged.
Now, Clojurescript uses Google Closure (like b4w) to compile into Javascript. So I suspect the problem is how I declared Clojurescript's b4w externs. But before I start altering the externs, I want to make sure I'm not doing some other blend4web-specific mistake. Here's a screencap of what is supposed to be the elapsed sensor object:
Thanks
In my ongoing quest to integrate Clojurescript with blend4web, I've run into another issue. I can't seem to create a sensor type. I've tried the elapsed sensor, and the callback sensor.
In both of those cases, I start by invoking the control module's create_elapsed_sensor function, and what it returns is an object with all its attributes munged.
Now, Clojurescript uses Google Closure (like b4w) to compile into Javascript. So I suspect the problem is how I declared Clojurescript's b4w externs. But before I start altering the externs, I want to make sure I'm not doing some other blend4web-specific mistake. Here's a screencap of what is supposed to be the elapsed sensor object:
Thanks
26 сентября 2016 19:45
Hi Yuri - and thank-you! No worries about responding to this, blend4web development itself is an understandably higher priority. Making it work with Clojure is understandably lower. I wasn't sure if anyone else would be interested anyways. But it's cool if anyone else is interested.
I should post an update – I can now grab the active scene. I just had to activate it in the second callback – just like the link in my last post :P I got mixed up because the previous post uses different modules, and so I thought it would be different kinds of callbacks.
I also think my problem (but correct me if I'm wrong) is that I had to have that callback invoked within another function call, much like the tutorials all say. I believe this is important for any CommonJS-based library, so its good I learn for most modern JS dev work.
For what it's worth, here is the clojurescript way of invoking it.
I should post an update – I can now grab the active scene. I just had to activate it in the second callback – just like the link in my last post :P I got mixed up because the previous post uses different modules, and so I thought it would be different kinds of callbacks.
I also think my problem (but correct me if I'm wrong) is that I had to have that callback invoked within another function call, much like the tutorials all say. I believe this is important for any CommonJS-based library, so its good I learn for most modern JS dev work.
For what it's worth, here is the clojurescript way of invoking it.
(ns cube-test.core
(:require blend4web))
(defn check-version []
(let [m-version (.require js/b4w "version")]
(.log js/console "Using Blend4Web Version" (.version m-version))))
(check-version)
(defn ^:export start
[json]
(let [m-main (.require js/b4w "main")
m-data (.require js/b4w "data")
m-scene (.require js/b4w "scenes")
m-config (.require js/b4w "config")
m-trans (.require js/b4w "transform")
m-camera (.require js/b4w "camera")
canvas (.getElementById js/document "container")]
(defn loaded-cb [data-id success]
(.log js/console
"Main scene loaded on thread number: " data-id
"with a success value of: " success))
(defn stageload-cb [data-id success]
"Use camera, translation and other b4w modules in this fn's scope."
(when (.is-primary-loaded m-data)
(let [current-camera (.get-active-camera m-scene)
cube (.get-object-by-name m-scene "Cube")]
(.translate-view m-camera current-camera 0 0.5 0.25)
(.set-rotation m-trans cube 1.2 0 0 0)
(.set-scale m-trans cube 0.25 0.25 0.25))))
(.set m-config "console_verbose" true)
(.load m-data (str json) loaded-cb stageload-cb true false)
(.init m-main canvas)))
23 сентября 2016 22:31
I should also mention I found this thread relating to scenes not getting active. In that case, it looked like changing the callback declarations did the trick. In my case, there are no callbacks to be declared (I'm not using the "app" module).
But that makes me wonder, do I need an "app" module instance in order to use a "scenes" instance?
But that makes me wonder, do I need an "app" module instance in order to use a "scenes" instance?
23 сентября 2016 22:07
Alright, so I'm trying to get camera navigation in my example. From the documentation, it looks like I need to first use the "scenes" module, and use that to get the active camera.
But the scene instance needs to be active first, and this is where I'm stumped. Right now, I'm just invoking the scenes module like:
as per the documentation.. 0 is the name of the scene in my .blend. I've also tried just invoking set_active without arguments. Either way, I get this error:
I'm not sure what I need for an active scene. Here's the entire compiled JS.
But the scene instance needs to be active first, and this is where I'm stumped. Right now, I'm just invoking the scenes module like:
m_scene.set_active("0");
B4W ERROR: No active scene
I'm not sure what I need for an active scene. Here's the entire compiled JS.
cube_test.core.check_version = (function cube_test$core$check_version(){
var m_version = b4w.require("version");
return console.log(m_version.version());
});
cube_test.core.check_version.call(null);
cube_test.core.start = (function cube_test$core$start(){
var m_main = b4w.require("main");
var m_data = b4w.require("data");
var m_scene = b4w.require("scenes");
var canvas = document.getElementById("container");
m_main.init(canvas);
m_data.load("cube_test.json");
m_scene.set_active("0");
cube_test.core.m_camera = m_scene.get_active_camera("scene");
return console.log(m_scene);