Giter VIP home page Giter VIP logo

starling-imagebatch's Introduction

An optimized Image batch class for Starling.

Note: Beta code and API

The ImageBatch can efficiently (in terms of CPU and memory) render a large number of images sharing the same texture. This class is designed as an object pool: items are recycled and vectors are never modified.

Try the demo: 8k particles with position/alpha/rotation animation and different textures from a shared spritesheet.

If you're unimpressed, that's ok - just notice that Starling rendering model adds an important overhead compared to heavily optimized demos or pure GPU particles (like ND2D offers). But here you can animate each element independently, and this is a big difference compared to animating a few high-polys models.

Features:

  • low memory footprint, items pooling
  • animate: x, y, scale, alpha, color, rotation, texture
  • (shared) spritesheet support
  • store custom data in items' "tag" property

Warning:

Starling TextureAtlas always returns new Texture instances - you must cache them if you manage animations yourself.

Important implementation detail:

The batch has a vector of items (the pool) and a 'count' index indicating how many items from the pool to render. When removing an item, it isn't actually removed:

  • the item to remove, say at index 'i', is swapped with the last item, at index 'count-1',
  • count is decreased because now the last item should not be rendered,
  • if you were iterating the items vector, the item at index 'i' should be processed again (if 'i' is still < count).

Credits:

This class is inspired by Starling's Particle System extension but with geometry building inlined.

starling-imagebatch's People

Contributors

elsassph avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.