layershift 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -43
- package/dist/components/layershift.js +264 -1119
- package/dist/npm/layershift.es.js +2277 -3774
- package/dist/types/components/layershift/global.d.ts +2 -2
- package/dist/types/components/layershift/index.d.ts +5 -1
- package/dist/types/components/layershift/index.d.ts.map +1 -1
- package/dist/types/components/layershift/layershift-element.d.ts +39 -9
- package/dist/types/components/layershift/layershift-element.d.ts.map +1 -1
- package/dist/types/components/layershift/lifecycle.d.ts +6 -0
- package/dist/types/components/layershift/lifecycle.d.ts.map +1 -1
- package/dist/types/components/layershift/portal-element.d.ts +11 -3
- package/dist/types/components/layershift/portal-element.d.ts.map +1 -1
- package/dist/types/components/layershift/types.d.ts +22 -9
- package/dist/types/components/layershift/types.d.ts.map +1 -1
- package/dist/types/depth-analysis.d.ts +10 -6
- package/dist/types/depth-analysis.d.ts.map +1 -1
- package/dist/types/{parallax-renderer.d.ts → depth-effect-renderer.d.ts} +63 -15
- package/dist/types/depth-effect-renderer.d.ts.map +1 -0
- package/dist/types/depth-estimator.d.ts +96 -0
- package/dist/types/depth-estimator.d.ts.map +1 -0
- package/dist/types/input-handler.d.ts +8 -2
- package/dist/types/input-handler.d.ts.map +1 -1
- package/dist/types/media-source.d.ts +76 -0
- package/dist/types/media-source.d.ts.map +1 -0
- package/dist/types/portal-renderer.d.ts +2 -1
- package/dist/types/portal-renderer.d.ts.map +1 -1
- package/dist/types/precomputed-depth.d.ts +5 -0
- package/dist/types/precomputed-depth.d.ts.map +1 -1
- package/dist/types/renderer-base.d.ts +13 -8
- package/dist/types/renderer-base.d.ts.map +1 -1
- package/dist/types/shared/channel-to-renderer.d.ts +72 -0
- package/dist/types/shared/channel-to-renderer.d.ts.map +1 -0
- package/dist/types/shared/filter-config.d.ts +184 -0
- package/dist/types/shared/filter-config.d.ts.map +1 -0
- package/dist/types/video-source.d.ts +0 -1
- package/dist/types/video-source.d.ts.map +1 -1
- package/package.json +9 -3
- package/dist/types/gpu-backend.d.ts +0 -37
- package/dist/types/gpu-backend.d.ts.map +0 -1
- package/dist/types/parallax-renderer-webgpu.d.ts +0 -103
- package/dist/types/parallax-renderer-webgpu.d.ts.map +0 -1
- package/dist/types/parallax-renderer.d.ts.map +0 -1
- package/dist/types/portal-renderer-webgpu.d.ts +0 -199
- package/dist/types/portal-renderer-webgpu.d.ts.map +0 -1
- package/dist/types/render-pass-webgpu.d.ts +0 -76
- package/dist/types/render-pass-webgpu.d.ts.map +0 -1
- package/dist/types/webgpu-utils.d.ts +0 -42
- package/dist/types/webgpu-utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,30 +4,42 @@
|
|
|
4
4
|
|
|
5
5
|
Embeddable video effects as Web Components. One script tag, one custom element — works in plain HTML, React, Vue, Svelte, Angular, WordPress, and anywhere else.
|
|
6
6
|
|
|
7
|
-
Layershift is a growing collection of visual effects that turn flat video into something interactive.
|
|
7
|
+
Layershift is a growing collection of visual effects that turn flat video into something interactive. Effects are configured via a `filter-config.json` file authored in the [Layershift Editor](https://layershift.io/editor/).
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
### `<layershift-parallax>` — Depth-Aware Parallax Video
|
|
12
|
-
|
|
13
|
-
A precomputed depth map drives per-pixel UV displacement with Parallax Occlusion Mapping (POM), so near objects move more than far objects — creating a convincing 3D effect from a single 2D video.
|
|
9
|
+
## Quick Start
|
|
14
10
|
|
|
15
11
|
```html
|
|
16
|
-
<script src="https://
|
|
12
|
+
<script src="https://unpkg.com/layershift"></script>
|
|
17
13
|
|
|
18
|
-
<layershift-
|
|
14
|
+
<layershift-effect
|
|
19
15
|
src="video.mp4"
|
|
20
16
|
depth-src="depth-data.bin"
|
|
21
17
|
depth-meta="depth-meta.json"
|
|
22
|
-
|
|
18
|
+
config="filter-config.json"
|
|
19
|
+
></layershift-effect>
|
|
23
20
|
```
|
|
24
21
|
|
|
22
|
+
**[Live demo →](https://layershift.io)**
|
|
23
|
+
|
|
24
|
+
## Effects
|
|
25
|
+
|
|
26
|
+
The `<layershift-effect>` element supports multiple effect types, all driven by the same depth data:
|
|
27
|
+
|
|
28
|
+
- **Depth Parallax** — per-pixel UV displacement via Parallax Occlusion Mapping
|
|
29
|
+
- **Depth Glow** — depth-driven emissive glow
|
|
30
|
+
- **Color Grade** — depth-aware color grading
|
|
31
|
+
- **Fog / Atmosphere** — depth-based atmospheric haze
|
|
32
|
+
- **Tilt Shift** — miniature/diorama lens effect
|
|
33
|
+
- **Pop-Out** — foreground subjects break out of the frame
|
|
34
|
+
|
|
35
|
+
Effects are configured in the [Layershift Editor](https://layershift.io/editor/) and exported as a `filter-config.json` file.
|
|
36
|
+
|
|
25
37
|
### `<layershift-portal>` — Logo Depth Portal
|
|
26
38
|
|
|
27
39
|
Renders video through an SVG-shaped cutout with depth-aware parallax, emissive interior compositing, geometric chamfer lighting, and dimensional boundary effects. The canvas background is fully transparent, so the portal can be overlaid on any HTML content.
|
|
28
40
|
|
|
29
41
|
```html
|
|
30
|
-
<script src="https://
|
|
42
|
+
<script src="https://unpkg.com/layershift"></script>
|
|
31
43
|
|
|
32
44
|
<layershift-portal
|
|
33
45
|
src="video.mp4"
|
|
@@ -37,8 +49,6 @@ Renders video through an SVG-shaped cutout with depth-aware parallax, emissive i
|
|
|
37
49
|
></layershift-portal>
|
|
38
50
|
```
|
|
39
51
|
|
|
40
|
-
**[Live demo →](https://layershift.io)**
|
|
41
|
-
|
|
42
52
|
---
|
|
43
53
|
|
|
44
54
|
## Install
|
|
@@ -46,7 +56,7 @@ Renders video through an SVG-shaped cutout with depth-aware parallax, emissive i
|
|
|
46
56
|
### Script Tag (IIFE)
|
|
47
57
|
|
|
48
58
|
```html
|
|
49
|
-
<script src="https://
|
|
59
|
+
<script src="https://unpkg.com/layershift"></script>
|
|
50
60
|
```
|
|
51
61
|
|
|
52
62
|
### npm
|
|
@@ -57,7 +67,7 @@ npm install layershift
|
|
|
57
67
|
|
|
58
68
|
```js
|
|
59
69
|
import 'layershift';
|
|
60
|
-
//
|
|
70
|
+
// <layershift-effect> and <layershift-portal> are now registered
|
|
61
71
|
```
|
|
62
72
|
|
|
63
73
|
### TypeScript
|
|
@@ -71,31 +81,21 @@ Add JSX type support for the custom elements:
|
|
|
71
81
|
|
|
72
82
|
---
|
|
73
83
|
|
|
74
|
-
##
|
|
75
|
-
|
|
76
|
-
The `precompute` script needs **FFmpeg** to read video metadata and extract frames.
|
|
77
|
-
|
|
78
|
-
- **macOS:** `brew install ffmpeg`
|
|
79
|
-
- **Windows:** [FFmpeg downloads](https://ffmpeg.org/download.html) or `winget install FFmpeg`
|
|
80
|
-
- **Linux:** `apt install ffmpeg` / `dnf install ffmpeg`
|
|
84
|
+
## Prepare Your Video
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
Use the [Layershift Editor](https://layershift.io/editor/) to:
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
1. Import a video or image
|
|
89
|
+
2. Run browser-based depth estimation (no CLI needed)
|
|
90
|
+
3. Configure your effect with the visual editor
|
|
91
|
+
4. Export a consumer package with all assets + config
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
npm run precompute
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Generates `depth-data.bin` and `depth-meta.json` from a video using Depth Anything v2.
|
|
93
|
+
The editor produces `depth-data.bin`, `depth-meta.json`, and `filter-config.json` — everything `<layershift-effect>` needs.
|
|
95
94
|
|
|
96
95
|
## Development
|
|
97
96
|
|
|
98
97
|
```bash
|
|
98
|
+
npm install
|
|
99
99
|
npm run dev
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -126,19 +126,22 @@ Components follow atomic design (Atoms → Molecules → Organisms → Templates
|
|
|
126
126
|
|
|
127
127
|
---
|
|
128
128
|
|
|
129
|
-
## `<layershift-
|
|
129
|
+
## `<layershift-effect>` Reference
|
|
130
130
|
|
|
131
131
|
### Configuration
|
|
132
132
|
|
|
133
133
|
| Attribute | Type | Default | Description |
|
|
134
134
|
|-----------|------|---------|-------------|
|
|
135
|
-
| `src` | string | — | Video
|
|
135
|
+
| `src` | string | — | Video or image URL (required) |
|
|
136
136
|
| `depth-src` | string | — | Depth binary URL (required) |
|
|
137
137
|
| `depth-meta` | string | — | Depth metadata URL (required) |
|
|
138
|
+
| `config` | string | — | Filter config JSON URL |
|
|
138
139
|
| `parallax-x` | number | 0.4 | Horizontal parallax intensity |
|
|
139
140
|
| `parallax-y` | number | 1.0 | Vertical parallax intensity |
|
|
140
141
|
| `parallax-max` | number | 30 | Max pixel offset for nearest layer |
|
|
141
142
|
| `overscan` | number | 0.05 | Extra padding ratio |
|
|
143
|
+
| `quality` | string | auto | Quality tier: `auto`, `high`, `medium`, `low` |
|
|
144
|
+
| `source-type` | string | video | Source type: `video`, `image`, `camera` |
|
|
142
145
|
| `autoplay` | boolean | true | Auto-play on mount |
|
|
143
146
|
| `loop` | boolean | true | Loop playback |
|
|
144
147
|
| `muted` | boolean | true | Muted (required for autoplay) |
|
|
@@ -147,24 +150,24 @@ Components follow atomic design (Atoms → Molecules → Organisms → Templates
|
|
|
147
150
|
|
|
148
151
|
| Event | Detail | When |
|
|
149
152
|
|-------|--------|------|
|
|
150
|
-
| `layershift-
|
|
151
|
-
| `layershift-
|
|
152
|
-
| `layershift-
|
|
153
|
-
| `layershift-
|
|
154
|
-
| `layershift-
|
|
155
|
-
| `layershift-
|
|
153
|
+
| `layershift-effect:ready` | `{ videoWidth, videoHeight, duration }` | Initialization complete |
|
|
154
|
+
| `layershift-effect:play` | `{ currentTime }` | Video starts playing |
|
|
155
|
+
| `layershift-effect:pause` | `{ currentTime }` | Video pauses |
|
|
156
|
+
| `layershift-effect:loop` | `{ loopCount }` | Video loops back to start |
|
|
157
|
+
| `layershift-effect:frame` | `{ currentTime, frameNumber }` | New video frame presented |
|
|
158
|
+
| `layershift-effect:error` | `{ message }` | Initialization error |
|
|
156
159
|
|
|
157
160
|
```js
|
|
158
|
-
const el = document.querySelector('layershift-
|
|
161
|
+
const el = document.querySelector('layershift-effect');
|
|
159
162
|
|
|
160
|
-
el.addEventListener('layershift-
|
|
163
|
+
el.addEventListener('layershift-effect:ready', (e) => {
|
|
161
164
|
console.log(`Video: ${e.detail.videoWidth}x${e.detail.videoHeight}`);
|
|
162
165
|
});
|
|
163
166
|
```
|
|
164
167
|
|
|
165
168
|
### Performance
|
|
166
169
|
|
|
167
|
-
Each `<layershift-
|
|
170
|
+
Each `<layershift-effect>` instance creates 1 WebGL renderer, 1 Web Worker, 1 hidden `<video>` element, and 2 GPU textures (1 draw call per frame). The bilateral filter runs entirely off the main thread.
|
|
168
171
|
|
|
169
172
|
| Instances | Suitability |
|
|
170
173
|
|-----------|-------------|
|