SpriteManager

Class used to manage multiple sprites on the same spritesheet

see

https://doc.babylonjs.com/babylon101/sprites

Hierarchy

Implements

Index

Constructors

constructor

Find examples in Playground
  • new SpriteManager(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null): SpriteManager
  • Creates a new sprite manager

    Parameters

    • name: string

      defines the manager's name

    • imgUrl: string

      defines the sprite sheet url

    • capacity: number

      defines the maximum allowed number of sprites

    • cellSize: any

      defines the size of a sprite cell

    • scene: Scene

      defines the hosting scene

    • Optional epsilon: number

      defines the epsilon value to align texture (0.01 by default)

    • Optional samplingMode: number

      defines the smapling mode to use with spritesheet

    • Optional fromPacked: boolean

      set to false; do not alter

    • Optional spriteJSON: any | null

      null otherwise a JSON object defining sprite sheet data; do not alter

    Returns SpriteManager

Properties

cellHeight

Find examples in Playground
cellHeight: number

Defines the default height of a cell in the spritesheet

cellWidth

Find examples in Playground
cellWidth: number

Defines the default width of a cell in the spritesheet

disableDepthWrite

Find examples in Playground
disableDepthWrite: boolean

Disables writing to the depth buffer when rendering the sprites. It can be handy to disable depth writing when using textures without alpha channel and setting some specific blend modes.

fogEnabled

Find examples in Playground
fogEnabled: boolean

Gets or sets a boolean indicating if the manager must consider scene fog when rendering

isPickable

Find examples in Playground
isPickable: boolean

Gets or sets a boolean indicating if the sprites are pickable

layerMask

Find examples in Playground
layerMask: number

Gets or sets camera layer mask

name

Find examples in Playground
name: string

defines the manager's name

onDisposeObservable

Find examples in Playground
onDisposeObservable: Observable<SpriteManager>

An event triggered when the manager is disposed.

renderingGroupId

Find examples in Playground
renderingGroupId: number

Gets or sets the rendering group id (0 by default)

snippetId

Find examples in Playground
snippetId: string

Snippet ID if the manager was created from the snippet server

sprites

Find examples in Playground
sprites: Sprite[]

Gets the list of sprites

uniqueId

Find examples in Playground
uniqueId: number

Gets or sets the unique id of the sprite

Static SnippetUrl

Find examples in Playground
SnippetUrl: string

Define the Url to load snippets

Accessors

blendMode

Find examples in Playground
  • get blendMode(): number
  • set blendMode(blendMode: number): any
  • Blend mode use to render the particle, it can be any of the static Constants.ALPHA_x properties provided in this class. Default value is Constants.ALPHA_COMBINE

    Returns number

  • Blend mode use to render the particle, it can be any of the static Constants.ALPHA_x properties provided in this class. Default value is Constants.ALPHA_COMBINE

    Parameters

    • blendMode: number

    Returns any

capacity

Find examples in Playground
  • get capacity(): number
  • Gets the capacity of the manager

    Returns number

children

Find examples in Playground
  • Gets the array of sprites

    Returns Sprite[]

onDispose

Find examples in Playground
  • set onDispose(callback: function): any
  • Callback called when the manager is disposed

    Parameters

    • callback: function
        • (): void
        • Returns void

    Returns any

scene

Find examples in Playground
  • Gets the hosting scene

    Returns Scene

texture

Find examples in Playground
  • Gets or sets the spritesheet texture

    Returns Texture

  • Gets or sets the spritesheet texture

    Parameters

    Returns any

Methods

dispose

Find examples in Playground
  • dispose(): void

getClassName

Find examples in Playground
  • getClassName(): string
  • Returns the string "SpriteManager"

    Returns string

    "SpriteManager"

intersects

Find examples in Playground
  • Intersects the sprites with a ray

    Parameters

    • ray: Ray

      defines the ray to intersect with

    • camera: Camera

      defines the current active camera

    • Optional predicate: function

      defines a predicate used to select candidate sprites

        • Parameters

          Returns boolean

    • Optional fastCheck: boolean

      defines if a fast check only must be done (the first potential sprite is will be used and not the closer)

    Returns Nullable<PickingInfo>

    null if no hit or a PickingInfo

multiIntersects

Find examples in Playground
  • Intersects the sprites with a ray

    Parameters

    • ray: Ray

      defines the ray to intersect with

    • camera: Camera

      defines the current active camera

    • Optional predicate: function

      defines a predicate used to select candidate sprites

        • Parameters

          Returns boolean

    Returns Nullable<PickingInfo[]>

    null if no hit or a PickingInfo array

render

Find examples in Playground
  • render(): void

serialize

Find examples in Playground
  • serialize(serializeTexture?: boolean): any
  • Serializes the sprite manager to a JSON object

    Parameters

    • Optional serializeTexture: boolean

      defines if the texture must be serialized as well

    Returns any

    the JSON object

Static CreateFromSnippetAsync

Find examples in Playground
  • CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>
  • Creates a sprite manager from a snippet saved by the sprite editor

    Parameters

    • snippetId: string

      defines the snippet to load (can be set to _BLANK to create a default one)

    • scene: Scene

      defines the hosting scene

    • Optional rootUrl: string

      defines the root URL to use to load textures and relative dependencies

    Returns Promise<SpriteManager>

    a promise that will resolve to the new sprite manager

Static Parse

Find examples in Playground
  • Parses a JSON object to create a new sprite manager.

    Parameters

    • parsedManager: any

      The JSON object to parse

    • scene: Scene

      The scene to create the sprite managerin

    • rootUrl: string

      The root url to use to load external dependencies like texture

    Returns SpriteManager

    the new sprite manager

Static ParseFromFileAsync

Find examples in Playground
  • Creates a sprite manager from a snippet saved in a remote file

    Parameters

    • name: Nullable<string>

      defines the name of the sprite manager to create (can be null or empty to use the one from the json data)

    • url: string

      defines the url to load from

    • scene: Scene

      defines the hosting scene

    • Optional rootUrl: string

      defines the root URL to use to load textures and relative dependencies

    Returns Promise<SpriteManager>

    a promise that will resolve to the new sprite manager

Generated using TypeDoc