wgs-player
v0.1.1
Published
Wgs file player for Web
Downloads
7
Maintainers
Readme
wgs-player
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.