wgs-player
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

wgs-player

npm version

wgs-player helps you to run wgs file on Web.

It's built on top of wgs-runtime-wgpu.

Installation

npm install wgs-player

Usage

import { createPlayer } from 'wgs-player'

async function main() {
  const canvas = document.getElementById('canvas')

  const player = await createPlayer({ canvas })
}

main()

API

createPlayer

function createPlayer(options: PlayerOptions): Promise<WgsPlayer>

Create a new WgsPlayer instance.

PlayerOptions

interface PlayerOptions {
  // Whether to automatically render the wgs once the instance is created.
  // Default is true.
  // If set to `false`, you can always manually invoke `play()` to trigger the rendering.
  autoPLay?: boolean

  // The HTMLCanvasElement where the player will render wgs.
  canvas: HTMLCanvasElement
}

WgsPlayer

The WgsPlayer instance.

runtime

property Expose the WebRuntime from wgs-runtime-wgpu.

destroy

destroy(): void

method Destroy the instance manually. Will remove listeners associated with the HTMLCanvasElement.

loadFromBlob

loadFromBlob(blob: Blob): Promise<void>

method Load wgs data from a Blob.

loadFromFile

loadFromFile(file: File): Promise<void>

method Load wgs data from a File.

loadFromUrl

loadFromUrl(url: string, fetchOptions?: RequestInit): Promise<void>

method Load wgs data from a url. fetchOptions will be passed down to Fetch API.

pause

pause(): void

method Pause the runtime.

play

play(): void

method Start the runtime manually. Used when autoPlay is set to false.

restart

restart(): void

method Restart the runtime.

resume

resume(): void

method Resume the runtime.

Package Sidebar

Install

npm i wgs-player

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

14.1 kB

Total Files

9

Last publish

Collaborators

  • zoron