Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents an image used for texturing Shape primitives.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Texture(fileName: string): Texture
  • new Texture(surface: Surface): Texture
  • new Texture(width: number, height: number, content?: Color | ArrayBuffer | ArrayBufferView): Texture
  • Construct a new texture from an image file.

    Parameters

    • fileName: string

      SphereFS path of the image file to load.

    Returns Texture

  • Construct a new texture from the contents of a Surface.

    Parameters

    • surface: Surface

      A surface whose contents will be used for the new texture.

    Returns Texture

  • Construct a new texture of a given size and initial contents.

    Parameters

    • width: number

      The width of the new texture, in pixels.

    • height: number

      The height of the new texture, in pixels.

    • Optional content: Color | ArrayBuffer | ArrayBufferView

      Either a Color to fill the texture with or a buffer of RGBA pixels.

    Returns Texture

Properties

fileName

fileName: string | null

The SphereFS path of the image file used to create the texture, or null for non-file-based textures.

height

height: number

Height of the texture image, in pixels.

width

width: number

Width of the texture image, in pixels.

Methods

download

  • download(): Uint8ClampedArray
  • Get the raw RGBA pixel data from this texture. May be slow!

    Returns Uint8ClampedArray

upload

  • upload(data: ArrayBuffer | ArrayBufferView): void
  • Upload new RGBA pixel data to this texture.

    Parameters

    • data: ArrayBuffer | ArrayBufferView

      A buffer with the new RGBA pixel values.

    Returns void

Static fromFile

  • fromFile(fileName: string): Promise<Texture>
  • Create a texture from an image file in the background. The promise resolves with a new Texture once it's ready to use.

    Parameters

    • fileName: string

      SphereFS path of the image file to load.

    Returns Promise<Texture>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc