DragonBones improvments

Hmm.
We have a nice property “panZ”
this is really strange, but when i inizialise this one as
this._renderDisplay.panZ(-this._renderDisplay.height / (2 * Math.tan(Math.PI / 16))+100);
then it’s works with normal dragonbones animatoin as espected, but, when animation cycle has some manipulations like SwordsMan in animation #6 has, then we become this behavior with body scaling and something with some special elements (like blue fires on his back).

On this momments i can fix it with a crunch, applying viewPosition object directly on mesh inizialisation step. Something like
this._renderDisplay.viewPosition.z = -this._renderDisplay.height / (2 * Math.tan(Math.PI / 16))+100;
I don’t sure its correct, and maby i need to come up with another way, but on this moment it’s looks good…

And so, I’ll play a little more with this thing, but it looks like the phaser is getting pretty good support for dragonbones in the face of this plugin.

And this is good my friends :slight_smile:

UPD
Found a different :slight_smile: left: plugin, right: original.
Безымянный

1 Like

OK, i found all i need, and it’s seems to be i will fix it all. This time mesh and textures has been fixed, i only need to rebuild bones inversion logic and that’s it. :slight_smile:

If bone has negative X or Y properties, then we need to recalculate frame. Hmm… it’s can be in animation or just in a basis armature. Or in in all of it in diffirent combinations :slight_smile:

1 Like

OK, problematic…
If you change some bone parametr in animation (for example you trying change scale property to mirroring something), then we need detect it in each frame… this is a problem. I can’t see any event or something like this in the code.

And you have to detect all parents too, becuse when we change some parent, all chain going to change it’s self…

If you using mirror scaling on bones, in static poses or in animation, then Bone.prototype._updateGlobalTransformMatrix = function (isCache) {
have to be redesigned :frowning:
So, this is a bad practic using bone scaling for mirroring your graphical elements at all. But this is a part of DragonBones functionality and it’s have to be implemented. This time i’m not sure i have time for that maby later.

First things is to change this part of this function

global.x = origin.x + offset.x + animationPose.x;
global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX;
global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY;

we can catch this.origin.scaleX<0 for bonesX or Y and then find the right scaling parameters but this is only theory and it’s possible that we have a better way.


As u can see scaleX parameter has negative state (-0.71) and have to be special recalculation for each frame.

OK, we have to fix this function

* - A transform relative to the armature coordinate system.
* @see #updateGlobalTransform()

What for problem over there. When we have a bone with negative scaling
Безымянный
then we become a wrong calculation in armature coordinate system space.
Безымянный

OK, i make a CRUNCH again, and it’s seems to be it’s working. CRUNCH trying to catch negative scaled bones and then does nagative calculation for scaling
Безымянный
but we need a super hero to implement it correctly :slight_smile: Maby i take a look on this problem later with a fresh eyes.

Fix for X negative scaled bones

if(this.parent.global.scaleX<0){
                            this._renderDisplay.setScale(transform.scaleX * this._textureScale, -transform.scaleY * this._textureScale);
                            return;
                        }

But how about parent’s tree… don’t sure it’s a right way
UPD
And animation poses… So, let’s wait.

UPD :slight_smile:


I think i no wanna go to the next stages :slight_smile:

Phaser3DragonBonesFixMesh.zip (7.2 MB)
It’s have to be FIXED, i just found whats wrong, and installed a crunches to get Scale. Maby later i will found a solutions for some parts but not sure.

Anyway, you can only using this for MESH and normal animation with out negative scaling in animation.

3.55.2
parentContainer.displayList = null… hmm, seems to be something was changed in this version.
Hmm, in 3.55.2 mesh it’s just a image
For example - Dragon
First object is container and scene bellow…


Безымянный
And this is a 3.5.0beta9

So, 5 Mesh’s transformed to images in 3.55.2 on the scene and meshes hidden from scene.

Files for @rich (not for use)
Phaser3DragonBonesFixMesh.zip (7.2 MB)

1 Like

Hey man, thank you for all your fixes! Your latest vesrion ( Phaser3DragonBonesFixMesh.zip) still seems to be working in Phaser 3.80.1, except for one thing, which is, unfortunately, crucial for my current project:

When I restart a scene (or switch to another one and then come back to the previous one), my armature/mesh disappears completely. It’s actually still there, just invisible. When I call armature.animation.reset(), it actually displays, but once I play my animation, it’s gone again.

I have created a CodePen example here showing the issue.

It seems to be an issue with caching animation frames. I tried everything I could think of, but I couldn’t make it work.

I’d be extremely thankful for any kind of help!

So, I managed to find a workaround for this. The animation doesn’t stop working on scene restart if I remove line 16463:

ee.once('shutdown', this.shutdown, this);

This probably means that DragonBones will never shutdown, but it doesn’t seem to matter for my use.

If anyone stumbles upon this issue, here’s my “fixed” version.