Jump to content

SVG No Texture Dimensions Until Next RAF


megmut
 Share

Recommended Posts

Hey guys.. I'm hoping this is something I'm doing wrong, but basically.. when I'm creating a new SVG, it's having width, and height of 1 until 1 frame has passed and then it has actual dimensions. 

My guess is that the onTextureChange event is being triggered, however the new local transformation isn't happening until the next loop takes place. Here is an example of my code:

var texture = PIXI.Texture.fromImage('mySVGPath.svg');
var sprite = new PIXI.Sprite(texture);
console.log(sprite.width, sprite.height) // 1, 1

setTimeout(() => {
    console.log(sprite.width, sprite.height) // 500, 465
}, 0);

Is there a way of solving this? Thanks!

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