Package Exports
- @netless/white-snapshot
- @netless/white-snapshot/index.js
- @netless/white-snapshot/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@netless/white-snapshot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@netless/white-snapshot
Take a snapshot of a white-web-sdk scene.
Requires white-web-sdk ≥ 2.16.20.
Usage
import { snapshot } from "@netless/white-snapshot";
// room = await sdk.joinRoom(...)
snapshot(room).then(canvas => {
document.body.append(canvas);
});Options
snapshot(room, {
scenePath: "/init",
padding: 5,
background: 'transparent',
crop: null,
crossorigin: false,
src2dataurl: undefined,
}): Promise<HTMLCanvasElement | null>;Returns null if failed.
| Option | Type | Default | Description |
|---|---|---|---|
| scenePath | string | current scene | Default is displayer.state.sceneState.scenePath. |
| padding | number | 5 | Pixels to the border of canvas. |
| background | string | Background color. | |
| crop | Rectangle | null | Apply crop on the snapshot. Note that the snapshot includes padding. |
| crossorigin | boolean | false | Apply hack to document.createElement('img') to enable crossorigin images. |
| src2dataurl | (src: string) ⇒ Promise<string> | Due to a limitation in html2canvas, we must convert images to dataurl before feeding them to it. |
Develop
pnpm devChangelog
License
MIT @ netless