Options
All
  • Public
  • Public/Protected
  • All
Menu

SDF-2D - v0.4.1

Index

Enumerations

Drawable Classes

Drawable Providing a noise texture is required for this drawable. Classes

Other Classes

Interfaces

Type aliases

Drawable Functions

Other Functions

Object literals

Type aliases

TextureWithOptions

TextureWithOptions: { overrides: Partial<TextureOptions>; source: TexImageSource }

Type declaration

Drawable Functions

Const PolygonFactory

  • PolygonFactory(vertexCount: number): { constructor: any; descriptor: DrawableDescriptor }

Other Functions

compile

  • Compiles a new renderer instance. There can multiple renderers on a single page.

    Asynchronous behaviour is required for parallel shader compiling. Trying to draw before the returned promise resolves, results in no action taken. Settings can be set before promise resolution and they will be applied later.

    The descriptors of every to-be-drawn objects are required before creating the renderer, allowing the compiler to only create the shaders that will actually be used.

    Example usage:

     import { compile, Circle, CircleLight } from 'sdf-2d';
    
     const canvas = document.querySelector('canvas');
     const renderer = await compile(canvas, [Circle.descriptor, CircleLight.descriptor]);

    Parameters

    • canvas: HTMLCanvasElement

      The returned renderer will only be able to draw to this canvas.

    • descriptors: Array<DrawableDescriptor>

      The descriptor of every single object (and light) that ever needs to be drawn by this renderer has to be given before compiling.

    • Default value settingsOverrides: Partial<StartupSettings> = {}

      Sensible defaults are provided, but these can be overridden.

    Returns Promise<Renderer>

Const renderNoise

  • renderNoise(textureSize: vec2, scale: number, amplitude: number, ignoreWebGL2?: boolean): Promise<HTMLCanvasElement>
  • Create a renderer, draw a (1D) noise texture with it, then destroy the used resources, while returning the generated texture in the form of a canvas.

    Parameters

    • textureSize: vec2

      The resolution of the end result.

    • scale: number

      A starting value can be 60

    • amplitude: number

      A starting value can be 0.125

    • Default value ignoreWebGL2: boolean = false

      Ignore WebGL2, even when its available.

    Returns Promise<HTMLCanvasElement>

Object literals

Const defaultRuntimeSettings

defaultRuntimeSettings: object

Contains the default values used for RuntimeSettings.

ambientLight

ambientLight: vec3 = vec3.fromValues(0.25, 0.15, 0.25)

backgroundColor

backgroundColor: vec4 = vec4.fromValues(1, 1, 1, 1)

colorPalette

colorPalette: never[] = []

enableHighDpiRendering

enableHighDpiRendering: false = false

isWorldInverted

isWorldInverted: false = false

lightCutoffDistance

lightCutoffDistance: number = 400

textures

textures: {}

Type declaration

tileMultiplier

tileMultiplier: number = 8

Const defaultStartupSettings

defaultStartupSettings: object

Contains the default values used for StartupSettings.

enableStopwatch

enableStopwatch: false = false

ignoreWebGL2

ignoreWebGL2: false = false

paletteSize

paletteSize: number = 256

shadowTraceCount

shadowTraceCount: number = 16