Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
spearwolf committed Mar 23, 2024
1 parent 9af2a21 commit c79e48a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# @spearwolf/visual-fx-web-components

> _Generated by [scripts/makeTODO.mjs](scripts/makeTODO.mjs) at 2024-03-23T15:11:12.395Z_
> _Generated by [scripts/makeTODO.mjs](scripts/makeTODO.mjs) at 2024-03-23T15:46:34.496Z_
This file contains an overview of all TODO, FIXME or XXX comments extracted from the source files of the packages.

Expand All @@ -24,7 +24,6 @@ This file contains an overview of all TODO, FIXME or XXX comments extracted from
| [packages/vfx/src/elements/VfxCtxElement.js](packages/vfx/src/elements/VfxCtxElement.js#L299) | 299 | what should happen with the events ? |
| [packages/vfx/src/elements/VfxCtxElement.js](packages/vfx/src/elements/VfxCtxElement.js#L312) | 312 | find a more friendly way to destroy the worker before termination |
| [packages/vfx/src/shadow-objects/VfxDisplay.js](packages/vfx/src/shadow-objects/VfxDisplay.js#L26) | 26 | use shared vfx.canvas|multiViewRenderer -------- |
| [packages/vfx/src/shadow-objects/VfxDisplay.js](packages/vfx/src/shadow-objects/VfxDisplay.js#L119) | 119 | maybe we should create a `<shadow-entity traverse-events="onRenderFrame, onIdle">` attribute ? |
| [packages/vfx/src/worker/MessageRouter.js](packages/vfx/src/worker/MessageRouter.js#L16) | 16 | subscribe to kernel "message" events |
| [packages/vfx/src/worker/MessageRouter.js](packages/vfx/src/worker/MessageRouter.js#L73) | 73 | remember constructors from define() for later cleanup (src changed, maybe we should support hotswap here?) |

Expand Down
21 changes: 21 additions & 0 deletions packages/vfx/src/shadow-objects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

### VfxDisplay

the vfx-display represents an offscreen canvas. however, a canvas _context_ is not created.

these contexts are provided:

| context name | type | description |
|------|------|-------------|
| `canvas` | [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas) | the offscreen canvas connected to the canvas element in the main document |
| `canvasSize` | [**width**: _number_, **height**: _number_, **pixelRatio**: _number_] | the size of the canvas element in _device pixels_. i.e. the pixelRatio is already included in the width and height specification. if you want the _css pixels_, divide the width and height by the pxelRatio |

In addition, the `onRenderFrame` event is dispatched to the entity and its children.

The `onRenderFrame` event comes with a data object:

| property | type | description |
|----------|------|-------------|
| `canvas` | [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas) | the offscreen canvas object, which is also offered as context |
| `now` | _number_ | the current time in seconds. see [performance.now](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) |
| `frameNo` | _number_ | a frame counter. starts at 0.
8 changes: 0 additions & 8 deletions packages/vfx/src/shadow-objects/VfxDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ export class VfxDisplay {

if (isNaN(w) || isNaN(h) || isNaN(pixelRatio)) return;

// if (canvas.width !== w || canvas.height !== h) {
// canvas.width = w;
// canvas.height = h;
// }
//
// setCanvasSize([w, h, pixelRatio]);

const canvasWidth = Math.round(w * pixelRatio);
const canvasHeight = Math.round(h * pixelRatio);

Expand Down Expand Up @@ -116,6 +109,5 @@ export class VfxDisplay {

const data = {canvas: this.canvas, now: this.now, frameNo: this.frameNo};
this.entity.traverse((entity) => entity.emit('onRenderFrame', data));
// TODO maybe we should create a `<shadow-entity traverse-events="onRenderFrame, onIdle">` attribute ?
}
}

0 comments on commit c79e48a

Please sign in to comment.