Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SpriteManager

Class used to manage multiple sprites on the same spritesheet

see

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

Hierarchy

Implements

Index

Constructors

constructor

  • 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 sampling 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

isPickableSearch playground for isPickable

isPickable: boolean

Gets or sets a boolean indicating if the sprites are pickable

layerMaskSearch playground for layerMask

layerMask: number

Gets or sets camera layer mask

nameSearch playground for name

name: string

defines the manager's name

onDisposeObservableSearch playground for onDisposeObservable

onDisposeObservable: Observable<SpriteManager>

An event triggered when the manager is disposed.

renderingGroupIdSearch playground for renderingGroupId

renderingGroupId: number

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

snippetIdSearch playground for snippetId

snippetId: string

Snippet ID if the manager was created from the snippet server

spritesSearch playground for sprites

sprites: Sprite[]

Gets the list of sprites

uniqueIdSearch playground for uniqueId

uniqueId: number

Gets or sets the unique id of the sprite

Static SnippetUrlSearch playground for SnippetUrl

SnippetUrl: string

Define the Url to load snippets

Accessors

blendMode

  • 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

  • get capacity(): number
  • Gets the capacity of the manager

    Returns number

cellHeight

  • get cellHeight(): number
  • set cellHeight(value: number): any
  • Defines the default height of a cell in the spritesheet

    Returns number

  • Defines the default height of a cell in the spritesheet

    Parameters

    • value: number

    Returns any

cellWidth

  • get cellWidth(): number
  • set cellWidth(value: number): any
  • Defines the default width of a cell in the spritesheet

    Returns number

  • Defines the default width of a cell in the spritesheet

    Parameters

    • value: number

    Returns any

children

  • Gets the array of sprites

    Returns Sprite[]

disableDepthWrite

  • get disableDepthWrite(): boolean
  • set disableDepthWrite(value: boolean): any
  • 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.

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

    Parameters

    • value: boolean

    Returns any

fogEnabled

  • get fogEnabled(): boolean
  • set fogEnabled(value: boolean): any
  • Gets or sets a boolean indicating if the manager must consider scene fog when rendering

    Returns boolean

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

    Parameters

    • value: boolean

    Returns any

onDispose

  • set onDispose(callback: () => void): any
  • Callback called when the manager is disposed

    Parameters

    • callback: () => void
        • (): void
        • Returns void

    Returns any

scene

  • Gets the hosting scene

    Returns Scene

texture

  • Gets or sets the spritesheet texture

    Returns Texture

  • Gets or sets the spritesheet texture

    Parameters

    Returns any

Methods

disposeSearch playground for dispose

  • dispose(): void
  • Release associated resources

    Returns void

getClassNameSearch playground for getClassName

  • getClassName(): string
  • Returns the string "SpriteManager"

    Returns string

    "SpriteManager"

intersectsSearch playground for intersects

  • Intersects the sprites with a ray

    Parameters

    • ray: Ray

      defines the ray to intersect with

    • camera: Camera

      defines the current active camera

    • Optional predicate: (sprite: Sprite) => boolean

      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

multiIntersectsSearch playground for multiIntersects

  • Intersects the sprites with a ray

    Parameters

    • ray: Ray

      defines the ray to intersect with

    • camera: Camera

      defines the current active camera

    • Optional predicate: (sprite: Sprite) => boolean

      defines a predicate used to select candidate sprites

        • Parameters

          Returns boolean

    Returns Nullable<PickingInfo[]>

    null if no hit or a PickingInfo array

rebuildSearch playground for rebuild

  • rebuild(): void
  • Rebuilds the manager (after a context lost, for eg)

    Returns void

renderSearch playground for render

  • render(): void
  • Render all child sprites

    Returns void

serializeSearch playground for serialize

  • 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 CreateFromSnippetAsyncSearch playground for CreateFromSnippetAsync

  • 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 ParseSearch playground for Parse

  • 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 manager

    • rootUrl: string

      The root url to use to load external dependencies like texture

    Returns SpriteManager

    the new sprite manager

Static ParseFromFileAsyncSearch playground for ParseFromFileAsync

  • 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

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method