Jump to content

sprite2D of canvas2D display not stable


MasterK
 Share

Recommended Posts

2 hours ago, MasterK said:

           this.scale = (settings.scale == null) ? 1 : settings.scale;

this.scaleX = (settings.scaleX == null) ? 1 : settings.scaleX;
            this.scaleY = (settings.scaleY == null) ? 1 : settings.scaleY;

Object.defineProperty(Prim2DBase.prototype, "scale", {

Object.defineProperty(Prim2DBase.prototype, "scaleX", {

 Object.defineProperty(Prim2DBase.prototype, "scaleY", {

 var tflags = Prim2DBase.actualPositionProperty.flagId | Prim2DBase.rotationProperty.flagId | Prim2DBase.scaleProperty.flagId | Prim2DBase.originProperty.flagId;
var tflags = Prim2DBase.actualPositionProperty.flagId | Prim2DBase.rotationProperty.flagId | Prim2DBase.originProperty.flagId
                    | Prim2DBase.scaleXProperty.flagId | Prim2DBase.scaleYProperty.flagId;

          local = BABYLON.Matrix.Compose(new BABYLON.Vector3(this._scale, this._scale, 1), rot, new BABYLON.Vector3(pos.x, pos.y, 0));

local = BABYLON.Matrix.Compose(new BABYLON.Vector3(this._scaleX, this._scaleY, 1), rot, new BABYLON.Vector3(pos.x, pos.y, 0));

BABYLON.Matrix.ScalingToRef(this._scale, this._scale, 1, Prim2DBase._t0);

BABYLON.Matrix.ScalingToRef(this._scaleX, this._scaleY, 1, Prim2DBase._t0);


            BABYLON.instanceLevelProperty(5, function (pi) { return Prim2DBase.scaleProperty = pi; }, false, true)
        ], Prim2DBase.prototype, "scale", null);
        __decorate([


        __decorate([
            BABYLON.instanceLevelProperty(14, function (pi) { return Prim2DBase.scaleXProperty = pi; }, false, true)
        ], Prim2DBase.prototype, "scaleX", null);
        __decorate([
            BABYLON.instanceLevelProperty(15, function (pi) { return Prim2DBase.scaleYProperty = pi; }, false, true)
        ], Prim2DBase.prototype, "scaleY", null);

Yes indeed, you did what should be done, but I'm still not convinced that it's a good idea to enable nonuniform scale, do you have a concrete use case to give me when you need it? Thanks!

Link to comment
Share on other sites

49 minutes ago, Nockawa said:

Yes indeed, you did what should be done, but I'm still not convinced that it's a good idea to enable nonuniform scale, do you have a concrete use case to give me when you need it? Thanks!

QQ图片20160728135755.pngQQ图片20160728135742.png

Animate sprite scaleY (1->2->1)

Link to comment
Share on other sites

3 minutes ago, MasterK said:

QQ图片20160728135755.pngQQ图片20160728135742.png

Animate sprite scaleY (1->2->1)

Ok, why not, non uniform scale is mostly a bad thing when it comes to compute the invert of a matrix, which is not something that happens a lot for a 2D Engine.

But I would keep the behavior of scale the same as before to ensure backward compatibility and add the two properties you mentioned. Ok, let's try that, you'll tell me if it's turning out ok of not.

Link to comment
Share on other sites

3 minutes ago, Nockawa said:

Ok @MasterK here's the dev: https://github.com/nockawa/Babylon.js/commit/1c0aba093844302162984429b620a9557e16b090

I'll submit a PR right away. Please review the commit and tell me it's you think everything is ok, I tend to always forget something... :)

nice. Looks perfect. better than i did, i was forced to remove scale, cause i didn't make this two things mix good. I'll try after github js update.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...