0

In Three.js, Calling action.play() makes objects just vanish, without any error or warning on the console.

I use THREE.ObjectLoader to load a JSON file created in blender. The srt (position/scale/quaternion) animation is in the generated file. As are the morphtargets. To optimise filesize I animated the srt as a series of null objects. The morphtargets tracks are in the main object, which I clone 5 times to build the characters (balloons to be exact).

I previously did extensive testing to introduce shape/morph animation. After being succesfull I finalised all the animations. Only to be trumped by the disappearing models. The srt (position/scale/quaternion) animation was working fine before. But after refactoring the code, to be less spagettied, upon calling action.play(). The objects just vanish, exactly then. Echoeing the mixers and the array containing the clips, everything looks correct (ie I see the tracks, the names are right etc). Also examining the newly generated JSON, it seems the same and correct (also I have not changed the SRT animations, only introduced shapeanimation)

So I am lost, and think this looks more and more like a bug. From previous experience I do know it works (or has worked).

I created a jsfiddle: https://jsfiddle.net/oompol/3ya6sqed/

[edit] I turned on the action.play and call the function from the link in the div [/edit] please note I commented out calling action.play(). So you see the load and init work. See the function listed below

function playScene(scene) {
  for (parentName in srtMixers) {
    var clpName = "balloon1_fly";
    var clp = THREE.AnimationClip.findByName(animLib, clpName);
    var action = srtMixers[parentName].clipAction(clp);
    action.clampWhenFinished = true;
    console.log("playScene:", clpName, clp, parentName, srtMixers);
    //this is when the problem happens
    action.play();
  }
}

This is the JSON I am loading: https://rawgit.com/bakajin/2e3d2f6a722103ed4aefd76f6250ec08/raw/28cad35c20060d478499c0cd40a2753611993720/oomp-scene_balloons-oomp-6.9.4.json

bakajin
  • 21
  • 2
  • If you export the scene as `window.fgScene = fgScene`, then inspect it in Dev Tools, you can see the position/rotation/scale and there are scales upward of `1000872413286`... that seems suspect? – Don McCurdy Oct 12 '17 at 03:59
  • Are they?! Not sure what you mean by window.fgScene = fGscene and when you set that. But I do know the scales are not animated. And if anything happens to them it would be reducing them lower that 1. – bakajin Oct 13 '17 at 18:23
  • See [Inspecting javascript on jsfiddle.net in Google Chrome](https://stackoverflow.com/questions/5655058/inspecting-javascript-on-jsfiddle-net-in-google-chrome). You can use a debugger to inspect `scene.children` and see the positions and scales of everything in the scene. – Don McCurdy Oct 13 '17 at 21:11
  • I really fail to see how or where to set this (I use FF more, tried in chrome now, to no avail). But console logging the scene I don't see any overly large values. Scales at 1 for ex. But it is a very interesting suggestion, 'cause I do see the objects still in the scene, looping the animation (I just dont see them). I have simplyfied my fiddle and reformatted the json a little. To write the animations part correctly – bakajin Oct 16 '17 at 13:13
  • @DonMcCurdy Right, I see what you mean now. Though I took a different approach to see it, logging the mixer objects position data. This is so weird, the values in scale are exponential numbers like 1.00005623625e-9 and such. Glad to see that, but where this comes from I have no clue. I don't do any animation on the scale, all the values are just 1, everywhere & always. – bakajin Oct 16 '17 at 15:41
  • Putting `window.fgScene = fgScene` in your script after `fgScreen` is defined makes it a global. Then you can open the JS Console, [select the fiddle.jshell.net](https://stackoverflow.com/a/5655166/1314762) dropdown, and type `fgScene` or `fgScene.children` in the console to print its value. – Don McCurdy Oct 16 '17 at 17:26
  • @DonMcCurdy Thanks a bundle for the clarification, as I use firefox for this mostly I didn't get it at all. So it is working in my new fiddle now. But all the scaling values show 1,1,1 now sadly. – bakajin Oct 16 '17 at 21:28

1 Answers1

0

Ok,

there was something very wrong with the scaling indeed. The io_three JSON exporter for Blender (r87 dev) writes incorrect matrix transformation data in the geometry object (really tiny scaling values). The animation track with the scaling keys were correctly written as 1,1,1. So all the objects just scaled out of view immediately.

Hard to see because the geometry has no separate scaling value but a matrix. Seems to happen when you set "Scene" to true on export.

Worked around the problem by entering the scaling value in the keyframe tracks. But this will only work if you have no scaling animation (so the keys are all one).

Meanwhile I have extensively edited the JSON by hand. Because this is not the only incorrect data. The formatting of the animation object is also wrong. The durations for the morphTargetInfluence Keys is also incorrect. The formatting of these keys is also not always correct.

Hope this helps some other ppl

bakajin
  • 21
  • 2