I’m having an issue with what I call the cat flap - trying to animate it. Basically it is a set of two doors with one door built into another door that I want to work together. Here is a simple playground:
As it stands each door animates by clicking on it., but I want to move the red door, by clicking on it, and the blue door will move with it, then a click on the blue door and it rotates from its current position.
In the playground there is no link between the red and the blue door. However, when I add the blue door as a child of the red door, by activating ONE of the lines 22-24, clicking on the red door now rotates both the red and blue door as expected. But now click on the blue door, and it jumps out of place before animating.
If you activate line 24 to do the parenting, it jumps out of place BEFORE animating (From the Babylion docs, I thought all those lines of code accomplished the same thing?).
I’ve also tried parenting directly in Blender - same result.
Any thoughts about how I might get the doors to animate without that jump in the blue door?
@sebavan : Naw - probably my poor explanation about what I am trying to accomplish.
Basically, when I click on the red door - both doors rotate together, when I click on the blue door it rotates at its current position - does not jump half way up the red door
The pivot points for both doors are set on the right back edge of each door
It looks like the key values for the position animation are wrong. After calling setParent to keep the smaller door’s position the same, I copied the key values for its position animation from box2.position and it works. I’m guessing you’ll want to make the parent/child relationship in blender and try to make sure that the key values for the position animation are correct, but I haven’t used Blender much so am just guessing. https://playground.babylonjs.com/#LX32L2#1
Edit: or maybe you can try animating the world matrix all at once, instead of animating position, rotation, and scaling separately, to make sure that the parent position is factored in?
That accomplishes what I am trying to do. I knew that had to be a code solution of some kind. And yes, I will try it with the parenting in Blender. I just used the simple unparented file in the PG just so changes could be made easily in a single PG with a single line of code
I will continue developing it in Blender - with a much larger project file and hope there are no more issues.
I did get it to work by hacking into the .babylon file and doing a manual copy/paste but it gets tedious with a much larger project file. I wondered if it was some fault with @JCPalmer 's exporter.
The shifting would seem to be because parenting, right? The origin of the bigger door is probably in the middle of the right edge.
I think that both the positioning and scaling animations could be just deleted as a worst case, since all that is really being done is rotation. That is certainly a cleaner edit. But first try parenting in Blender applying all transforms, and compare the 2 exports.
Correction: A couple of experiments in Blender show that the location property of a mesh is always in world coordinates no matter how it is parented. In order for location / position to be animated in BJS, the values need to be in local coordinates. One or the other these need addressing for it to work out of the box.
@gryff, I have marked up changes to recording location animation of a mesh when it has a non-armature parent to subtract the parent’s. This should result in putting a local rather than global location into the frames.
My confidence in this is not high, so I have not put it on the server, but right here. Blender2Babylon-2.93x.zip (2.3 MB)
I do not really have a .blend that checks properly, but it does run with one with a camera animation. If I move forward, I would still need to make the same change for camera & light as was done to mesh. Also would have to determine if changes for rotation & scale properties also need to be done.
@JCPalmer : Well I tried that new version of the exporter and it failed. I got this :
animation processing begun
========= An error was encountered =========
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\json_exporter.py”, line 116, in execute
mesh = Mesh(object, scene, self)
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\mesh.py”, line 109, in init
self.define_animations(bpyMesh, True, True, True, self.parentId)
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\f_curve_animatable.py”, line 52, in define_animations
hasData = rotAnimation.append_range(object, animationRange, parent)
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\animation.py”, line 114, in append_range
self.values.append(self.get_attr(object, parent))
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\animation.py”, line 170, in get_attr
return scale_vector(value, self.mult, self.xOffset)
File “C:\Users\Peter\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\babylon_js\package_level.py”, line 222, in scale_vector
ret.x += xOffset
ERROR: unsupported operand type(s) for +=: ‘float’ and ‘str’
========= end of processing =========
elapsed time: 0 min, 0.039 secs
Sorry for the delay, I had a nasty fall last week when I was out walking the little dog you see in the icon I use. Unable to get down the stairs to my computers. The little dog was amazing. I could not get up and she came over and sat down beside me, raised her head and barked until neighbours came out to help me get home.,
Looks like I mixed up the order of the parameter I added and the calling of it. Probably be easier if you just post the .blend in a zip. No hurry, I would not get to it before Saturday.
Well, it took me a while but I got this fixed. After seeing your Welsh Happy New Year scene with the opening doors, I fear that it might be a little too late for your needs, though.
Sorry, a lot of things in addition to Holidays I had to deal with. Also, sometimes I do not know what to do, like in this case, and I generally work on something else till I get inspiration. Otherwise, huge amounts of time can get chewed through + getting nothing actually done.
Naw … It is for something more complicated than that. I know you will always deliver, and I work on a few projects at a time so I just move around a little bit