Jump to content

FPS Drop on setting object properties


clifftm
 Share

Recommended Posts

Hello again!

My stage contains 60000 sprites that i want to tween over it, so i wrote code to manipulate props of the objects and add update function to

PIXI.ticker.shared.add(this._update, this);

The final action on this._update is to update props of tweening object. In that way of updating i'v got 22 FPS

object['alpha'] = start + (end - start) * percent;
// OR
object.alpha = start + (end - start) * percent;

But i'v got about 5 - FPS drop if an update property name is located in other object

this.props = [ 'alpha','rotation','tint','something']

function _update(delta){
...
   for(let i = 0 ; i < this.props.length; i++)
     upd( object, this.props[i], start, end, percent)
...
}

function upd( object, key, start,end, percent){
   //15FPS
   object[key] = start + (end - start) * percent; 
}

And if I'll add 2 checks, than again got 22FPS

this.props = [ 'alpha','rotation','tint','something']

function _update(delta){
...
   for(let i = 0 ; i < this.props.length; i++)
     upd( object, this.props[i], start, end, percent)
...
}

function upd( object, key, start,end, percent){
   // 20 - 22FPS
   if(key == 'alpha') object.alpha = start + (end - start) * percent;           
   else
   if(key == 'rotation') object.rotation = start + (end - start) * percent;
}

Can someone help me, how to iterate through dynamical props names without getting fps drop?

Thanks.

Link to comment
Share on other sites

or make several functions that update one prop and call them in small cycle, like here: https://github.com/pixijs/pixi.js/blob/dev/src/particles/webgl/ParticleRenderer.js#L256 , we have updates for vertices, uvs, alpha. We call whatever functions we need. 
If you have many props, you have to generate those functions code and use "new Function"

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