clifftm Posted September 11, 2018 Share Posted September 11, 2018 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 11, 2018 Share Posted September 11, 2018 generate function code and use "new Function" Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 11, 2018 Share Posted September 11, 2018 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" Quote Link to comment Share on other sites More sharing options...
xerver Posted September 12, 2018 Share Posted September 12, 2018 Have you profiled it? Without profiling, you are just guessing as to what is taking your time. I seriously doubt that object property lookup is your bottleneck. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.