Jump to content

scaleX change position


Ner
 Share

Recommended Posts

I tried to add a sprite2d(scaleX 0.5) to ScreenSpaceCanvas2D,,,if the texture didn't load, it will like this1.png,,position.x is correct.

but when the texture loaded,,it mostly like this 2.png ,,position.x still thinks scaleX is 1.

The first picture is suitable,,,,but I want to preload texture,,,

 

 

Link to comment
Share on other sites

Hello 

i think Nockawa will have a look at this problem soon.

I don't know, what's the problem is with texture task, maybe you have to  first change some default properties of the texture.


i load my images in binary and never face any problems,
I also like to have the ability to change properties of my textures like samplingmode easily

http://playground.babylonjs.com/#1ZRGGC#3

Best

Link to comment
Share on other sites

On 05/08/2016 at 3:30 PM, Ner said:

I tried to add a sprite2d(scaleX 0.5) to ScreenSpaceCanvas2D,,,if the texture didn't load, it will like this1.png,,position.x is correct.

but when the texture loaded,,it mostly like this 2.png ,,position.x still thinks scaleX is 1.

The first picture is suitable,,,,but I want to preload texture,,,

 

 

Hello @Ner I'm on holidays right now and have limited working time, but I'll try to find some time tonight to work on your issue. I told @MasterK that non uniform scale would cause issue, looks like I was right! ;) Anyway I'll fix it.

Here is the Trello Card corresponding to the bug.

Link to comment
Share on other sites

4 minutes ago, Nockawa said:

Hello @Ner I'm on holidays right now and have limited working time, but I'll try to find some time tonight to work on your issue. I told @MasterK that non uniform scale would cause issue, looks like I was right! ;) Anyway I'll fix it.

Here is the Trello Card corresponding to the bug.

I missed your words and understand just now...

Link to comment
Share on other sites

Hello @Ner

Sorry for answering such lately, I don't have much time to work right now, but I've found your issue and just fixed it.

Let me first say that what you think for right were in fact wrong. The correct result is where the texture is already loaded, like with this PG: http://playground.babylonjs.com/#1ZRGGC#1

What was not working was when the texture was not loaded the origin wasn't apply on the Sprite2d with the texture size then it looked like this: http://playground.babylonjs.com/#1WE7TW#0

Why you got it wrong? Because the default origin for a Sprite2d will be 0.5, 0.5 which means if you apply a scale of 0.5 your Sprite2d will be vertically shrink by half and centered. If you set an origin of 0, you will get the result you're looking for and this will work in both modes with the latest release I've just pushed (note that the latest preview of bjs doesn't include it, you have to get the code from the official repo and recompile it).

The origin will work for scale/rotation of a primitive, per default the 0.5 value means it's centered, you can set left/bottom by setting 0, right/top by setting 1.

Let me know if there's something not as clear as it should be.

Link to comment
Share on other sites

On 12/08/2016 at 5:22 AM, Ner said:

I just found another issue   http://www.babylonjs-playground.com/#BD8MQ

If a sprite's parent is a group, and the sprite's marginAlignment has been set, , ,even if the sprite is in the group, group's range will also be change.

Hello @Ner , I took a look at your PG, as I explained in another post (that I can't find again), when you're using the Positioning Engine (margin, alignment, padding) you must not set the x/y/position properties of your primitive, the result will be something unexpected... Is this the cause of your issue? If you remove the x/y properties and rely on margin instead, will it solve it?

Take a look at this doc (which I recently updated to make this clearer) for more info: http://doc.babylonjs.com/overviews/Canvas2D_Prim_Positioning

Tell me if something is still not clear enough.

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...