@clypra-studio/engine 0.1.2 → 1.0.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/dist/TransitionDefinition-CQoSb4ZB.d.cts +158 -0
- package/dist/TransitionDefinition-CQoSb4ZB.d.ts +158 -0
- package/dist/{chunk-CJRH4PAV.js → chunk-2VGI6ZB7.js} +289 -63
- package/dist/chunk-2VGI6ZB7.js.map +1 -0
- package/dist/chunk-4PKBLJ34.js +667 -0
- package/dist/chunk-4PKBLJ34.js.map +1 -0
- package/dist/chunk-FIJBB3MH.js +2990 -0
- package/dist/chunk-FIJBB3MH.js.map +1 -0
- package/dist/{chunk-EVQAI3P3.js → chunk-S24UVNPZ.js} +5 -1
- package/dist/{chunk-EVQAI3P3.js.map → chunk-S24UVNPZ.js.map} +1 -1
- package/dist/{index-BWo6qV_z.d.cts → index-Da47I6aX.d.cts} +5 -5
- package/dist/{index-BWo6qV_z.d.ts → index-Da47I6aX.d.ts} +5 -5
- package/dist/index.cjs +3906 -1371
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +437 -3807
- package/dist/index.d.ts +437 -3807
- package/dist/index.js +1310 -1411
- package/dist/index.js.map +1 -1
- package/dist/textEffects/index.cjs.map +1 -1
- package/dist/textEffects/index.js +1 -1
- package/dist/transitions/index.cjs +2207 -3
- package/dist/transitions/index.cjs.map +1 -1
- package/dist/transitions/index.d.cts +58 -9
- package/dist/transitions/index.d.ts +58 -9
- package/dist/transitions/index.js +53 -3
- package/dist/v2/backends/index.cjs +246 -33
- package/dist/v2/backends/index.cjs.map +1 -1
- package/dist/v2/backends/index.d.cts +1 -1
- package/dist/v2/backends/index.d.ts +1 -1
- package/dist/v2/backends/index.js +1 -1
- package/dist/v2/contract/index.d.cts +12 -12
- package/dist/v2/contract/index.d.ts +12 -12
- package/dist/videoEffects/index.cjs +284 -64
- package/dist/videoEffects/index.cjs.map +1 -1
- package/dist/videoEffects/index.d.cts +34 -138
- package/dist/videoEffects/index.d.ts +34 -138
- package/dist/videoEffects/index.js +1 -1
- package/package.json +12 -12
- package/LICENSE +0 -9
- package/dist/chunk-5JOAEDIQ.js +0 -446
- package/dist/chunk-5JOAEDIQ.js.map +0 -1
- package/dist/chunk-CJRH4PAV.js.map +0 -1
- package/dist/chunk-QMRMNH52.js +0 -811
- package/dist/chunk-QMRMNH52.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @clypra/engine — NLE Runtime & Pipeline Contract v2 (LEGACY DRAFT)
|
|
2
|
+
* @clypra-studio/engine — NLE Runtime & Pipeline Contract v2 (LEGACY DRAFT)
|
|
3
3
|
*
|
|
4
4
|
* @deprecated Prefer `v2/project`, `v2/graph`, `v2/planner`, and `v2/runtime`.
|
|
5
5
|
* Exported via `@clypra/engine/contract` for Rust/wgpu alignment only.
|
|
6
6
|
*/
|
|
7
|
-
type AssetType =
|
|
7
|
+
type AssetType = "video" | "audio" | "image" | "font" | "lut" | "model" | "generated";
|
|
8
8
|
interface AssetDescriptor {
|
|
9
9
|
id: string;
|
|
10
10
|
name: string;
|
|
@@ -29,7 +29,7 @@ interface MediaResolver {
|
|
|
29
29
|
prewarmAsset(assetId: string): Promise<void>;
|
|
30
30
|
releaseAsset(assetId: string): void;
|
|
31
31
|
}
|
|
32
|
-
type GraphDataType =
|
|
32
|
+
type GraphDataType = "Texture" | "Depth" | "MotionField" | "BoundingBoxes" | "Mask" | "Mesh" | "Particles" | "AudioSpectrum" | "Text" | "Markers";
|
|
33
33
|
interface GraphValue<T = any> {
|
|
34
34
|
type: GraphDataType;
|
|
35
35
|
payload: T;
|
|
@@ -65,23 +65,23 @@ interface GraphNode {
|
|
|
65
65
|
capabilities: EffectCapabilities;
|
|
66
66
|
profile: EffectProfile;
|
|
67
67
|
}
|
|
68
|
-
type ExecutionQuality =
|
|
69
|
-
type PlaybackMode =
|
|
70
|
-
type PlaybackDirection =
|
|
68
|
+
type ExecutionQuality = "draft" | "preview" | "export";
|
|
69
|
+
type PlaybackMode = "play" | "seek";
|
|
70
|
+
type PlaybackDirection = "forward" | "reverse";
|
|
71
71
|
interface ExecutionPolicy {
|
|
72
72
|
quality: ExecutionQuality;
|
|
73
73
|
playbackMode: PlaybackMode;
|
|
74
74
|
direction: PlaybackDirection;
|
|
75
75
|
targetFps: number;
|
|
76
76
|
}
|
|
77
|
-
type RenderIntent =
|
|
77
|
+
type RenderIntent = "thumbnail" | "preview" | "export" | "still" | "analysis";
|
|
78
78
|
interface ResourceRequest {
|
|
79
79
|
id: string;
|
|
80
|
-
type:
|
|
80
|
+
type: "texture" | "buffer";
|
|
81
81
|
width?: number;
|
|
82
82
|
height?: number;
|
|
83
|
-
format:
|
|
84
|
-
usage:
|
|
83
|
+
format: "rgba8" | "rgba16f" | "rgba32f" | "r8";
|
|
84
|
+
usage: "render_target" | "shader_read" | "compute_write";
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Single-frame resolved graph to run on the GPU queue.
|
|
@@ -101,7 +101,7 @@ interface FrameGraph {
|
|
|
101
101
|
resourceRequests: ResourceRequest[];
|
|
102
102
|
}
|
|
103
103
|
interface Command {
|
|
104
|
-
op:
|
|
104
|
+
op: "draw" | "compute" | "copy" | "clear" | "resolve";
|
|
105
105
|
shaderId: string;
|
|
106
106
|
inputs: string[];
|
|
107
107
|
outputs: string[];
|
|
@@ -141,7 +141,7 @@ interface ClipSegment {
|
|
|
141
141
|
interface TrackDefinition {
|
|
142
142
|
id: string;
|
|
143
143
|
name: string;
|
|
144
|
-
type:
|
|
144
|
+
type: "video" | "audio";
|
|
145
145
|
enabled: boolean;
|
|
146
146
|
clips: ClipSegment[];
|
|
147
147
|
effectGraph: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @clypra/engine — NLE Runtime & Pipeline Contract v2 (LEGACY DRAFT)
|
|
2
|
+
* @clypra-studio/engine — NLE Runtime & Pipeline Contract v2 (LEGACY DRAFT)
|
|
3
3
|
*
|
|
4
4
|
* @deprecated Prefer `v2/project`, `v2/graph`, `v2/planner`, and `v2/runtime`.
|
|
5
5
|
* Exported via `@clypra/engine/contract` for Rust/wgpu alignment only.
|
|
6
6
|
*/
|
|
7
|
-
type AssetType =
|
|
7
|
+
type AssetType = "video" | "audio" | "image" | "font" | "lut" | "model" | "generated";
|
|
8
8
|
interface AssetDescriptor {
|
|
9
9
|
id: string;
|
|
10
10
|
name: string;
|
|
@@ -29,7 +29,7 @@ interface MediaResolver {
|
|
|
29
29
|
prewarmAsset(assetId: string): Promise<void>;
|
|
30
30
|
releaseAsset(assetId: string): void;
|
|
31
31
|
}
|
|
32
|
-
type GraphDataType =
|
|
32
|
+
type GraphDataType = "Texture" | "Depth" | "MotionField" | "BoundingBoxes" | "Mask" | "Mesh" | "Particles" | "AudioSpectrum" | "Text" | "Markers";
|
|
33
33
|
interface GraphValue<T = any> {
|
|
34
34
|
type: GraphDataType;
|
|
35
35
|
payload: T;
|
|
@@ -65,23 +65,23 @@ interface GraphNode {
|
|
|
65
65
|
capabilities: EffectCapabilities;
|
|
66
66
|
profile: EffectProfile;
|
|
67
67
|
}
|
|
68
|
-
type ExecutionQuality =
|
|
69
|
-
type PlaybackMode =
|
|
70
|
-
type PlaybackDirection =
|
|
68
|
+
type ExecutionQuality = "draft" | "preview" | "export";
|
|
69
|
+
type PlaybackMode = "play" | "seek";
|
|
70
|
+
type PlaybackDirection = "forward" | "reverse";
|
|
71
71
|
interface ExecutionPolicy {
|
|
72
72
|
quality: ExecutionQuality;
|
|
73
73
|
playbackMode: PlaybackMode;
|
|
74
74
|
direction: PlaybackDirection;
|
|
75
75
|
targetFps: number;
|
|
76
76
|
}
|
|
77
|
-
type RenderIntent =
|
|
77
|
+
type RenderIntent = "thumbnail" | "preview" | "export" | "still" | "analysis";
|
|
78
78
|
interface ResourceRequest {
|
|
79
79
|
id: string;
|
|
80
|
-
type:
|
|
80
|
+
type: "texture" | "buffer";
|
|
81
81
|
width?: number;
|
|
82
82
|
height?: number;
|
|
83
|
-
format:
|
|
84
|
-
usage:
|
|
83
|
+
format: "rgba8" | "rgba16f" | "rgba32f" | "r8";
|
|
84
|
+
usage: "render_target" | "shader_read" | "compute_write";
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Single-frame resolved graph to run on the GPU queue.
|
|
@@ -101,7 +101,7 @@ interface FrameGraph {
|
|
|
101
101
|
resourceRequests: ResourceRequest[];
|
|
102
102
|
}
|
|
103
103
|
interface Command {
|
|
104
|
-
op:
|
|
104
|
+
op: "draw" | "compute" | "copy" | "clear" | "resolve";
|
|
105
105
|
shaderId: string;
|
|
106
106
|
inputs: string[];
|
|
107
107
|
outputs: string[];
|
|
@@ -141,7 +141,7 @@ interface ClipSegment {
|
|
|
141
141
|
interface TrackDefinition {
|
|
142
142
|
id: string;
|
|
143
143
|
name: string;
|
|
144
|
-
type:
|
|
144
|
+
type: "video" | "audio";
|
|
145
145
|
enabled: boolean;
|
|
146
146
|
clips: ClipSegment[];
|
|
147
147
|
effectGraph: {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/videoEffects/index.ts
|
|
@@ -2246,9 +2236,20 @@ var import_pixi = require("pixi.js");
|
|
|
2246
2236
|
var PixiRenderer = class {
|
|
2247
2237
|
app = null;
|
|
2248
2238
|
videoSprite = null;
|
|
2239
|
+
transitionSprite = null;
|
|
2240
|
+
_activeTransition = null;
|
|
2241
|
+
fromRenderTexture = null;
|
|
2242
|
+
toRenderTexture = null;
|
|
2243
|
+
blitSprite = null;
|
|
2244
|
+
_transitionFromTex = null;
|
|
2245
|
+
_transitionToTex = null;
|
|
2249
2246
|
overlayContainer = null;
|
|
2247
|
+
baseMediaContainer = null;
|
|
2250
2248
|
mounted = /* @__PURE__ */ new Map();
|
|
2251
2249
|
initialized = false;
|
|
2250
|
+
initializing = false;
|
|
2251
|
+
_activeSource = null;
|
|
2252
|
+
_fitMode = "fit";
|
|
2252
2253
|
/**
|
|
2253
2254
|
* Initialize the PixiJS Application.
|
|
2254
2255
|
* Call once, reuse across effect changes.
|
|
@@ -2258,47 +2259,77 @@ var PixiRenderer = class {
|
|
|
2258
2259
|
* @param height Canvas height in pixels
|
|
2259
2260
|
*/
|
|
2260
2261
|
async init(canvas, width, height) {
|
|
2261
|
-
if (this.initialized) return;
|
|
2262
|
-
this.
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
height,
|
|
2267
|
-
backgroundAlpha: 0,
|
|
2268
|
-
// transparent — composited over video below
|
|
2269
|
-
antialias: true,
|
|
2270
|
-
preference: "webgl",
|
|
2271
|
-
// WebGL for production stability; swap to 'webgpu' later
|
|
2272
|
-
resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
2273
|
-
autoDensity: true,
|
|
2274
|
-
preserveDrawingBuffer: true
|
|
2262
|
+
if (this.initialized || this.initializing) return;
|
|
2263
|
+
this.initializing = true;
|
|
2264
|
+
canvas.addEventListener("webglcontextlost", (event) => {
|
|
2265
|
+
event.preventDefault();
|
|
2266
|
+
console.warn("[PixiRenderer] WebGL context lost \u2014 attempting recovery");
|
|
2275
2267
|
});
|
|
2268
|
+
canvas.addEventListener("webglcontextrestored", () => {
|
|
2269
|
+
console.log("[PixiRenderer] WebGL context restored");
|
|
2270
|
+
});
|
|
2271
|
+
const app = new import_pixi.Application();
|
|
2272
|
+
try {
|
|
2273
|
+
await app.init({
|
|
2274
|
+
canvas,
|
|
2275
|
+
width,
|
|
2276
|
+
height,
|
|
2277
|
+
backgroundAlpha: 0,
|
|
2278
|
+
// transparent — composited over video below
|
|
2279
|
+
antialias: true,
|
|
2280
|
+
preference: "webgl",
|
|
2281
|
+
// WebGL for production stability; swap to 'webgpu' later
|
|
2282
|
+
resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
2283
|
+
autoDensity: true,
|
|
2284
|
+
preserveDrawingBuffer: true
|
|
2285
|
+
});
|
|
2286
|
+
} catch (e) {
|
|
2287
|
+
this.initializing = false;
|
|
2288
|
+
throw e;
|
|
2289
|
+
}
|
|
2290
|
+
if (!this.initializing) {
|
|
2291
|
+
app.destroy(true);
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
this.app = app;
|
|
2276
2295
|
this.videoSprite = new import_pixi.Sprite();
|
|
2277
2296
|
this.videoSprite.width = width;
|
|
2278
2297
|
this.videoSprite.height = height;
|
|
2298
|
+
this.transitionSprite = new import_pixi.Sprite();
|
|
2299
|
+
this.transitionSprite.width = width;
|
|
2300
|
+
this.transitionSprite.height = height;
|
|
2301
|
+
this.transitionSprite.visible = false;
|
|
2279
2302
|
this.overlayContainer = new import_pixi.Container();
|
|
2303
|
+
this.baseMediaContainer = new import_pixi.Container();
|
|
2304
|
+
this.baseMediaContainer.sortableChildren = true;
|
|
2305
|
+
this.app.stage.addChildAt(this.baseMediaContainer, 0);
|
|
2280
2306
|
this.app.stage.addChild(this.videoSprite);
|
|
2307
|
+
this.app.stage.addChild(this.transitionSprite);
|
|
2281
2308
|
this.app.stage.addChild(this.overlayContainer);
|
|
2282
2309
|
this.initialized = true;
|
|
2310
|
+
this.initializing = false;
|
|
2283
2311
|
}
|
|
2284
|
-
/**
|
|
2285
|
-
* Point the video sprite at a live HTMLVideoElement.
|
|
2286
|
-
* PixiJS polls the video element each frame automatically.
|
|
2287
|
-
*/
|
|
2288
2312
|
setVideoSource(video) {
|
|
2313
|
+
if (this._activeSource === video) {
|
|
2314
|
+
this.resizeSprites();
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
this._activeSource = video;
|
|
2289
2318
|
if (!this.videoSprite || !this.app) return;
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
this.videoSprite.texture = texture;
|
|
2294
|
-
});
|
|
2319
|
+
const texture = import_pixi.Texture.from(video);
|
|
2320
|
+
this.videoSprite.texture = texture;
|
|
2321
|
+
this.resizeSprites();
|
|
2295
2322
|
}
|
|
2296
2323
|
setImageSource(image) {
|
|
2324
|
+
if (this._activeSource === image) {
|
|
2325
|
+
this.resizeSprites();
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
this._activeSource = image;
|
|
2297
2329
|
if (!this.videoSprite || !this.app) return;
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
});
|
|
2330
|
+
const texture = import_pixi.Texture.from(image);
|
|
2331
|
+
this.videoSprite.texture = texture;
|
|
2332
|
+
this.resizeSprites();
|
|
2302
2333
|
}
|
|
2303
2334
|
// -------------------------------------------------------------------------
|
|
2304
2335
|
// Effect lifecycle
|
|
@@ -2329,11 +2360,7 @@ var PixiRenderer = class {
|
|
|
2329
2360
|
Object.assign(m.params, params);
|
|
2330
2361
|
Object.assign(m.ctx.params, params);
|
|
2331
2362
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2332
|
-
m.definition.filterSpec.updateUniforms(
|
|
2333
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2334
|
-
m.params,
|
|
2335
|
-
0
|
|
2336
|
-
);
|
|
2363
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2337
2364
|
}
|
|
2338
2365
|
if (m.filters) filterChain.push(...m.filters);
|
|
2339
2366
|
continue;
|
|
@@ -2358,11 +2385,7 @@ var PixiRenderer = class {
|
|
|
2358
2385
|
tickerFn = (ticker) => {
|
|
2359
2386
|
elapsed.value += ticker.deltaMS;
|
|
2360
2387
|
if (filters) {
|
|
2361
|
-
spec.updateUniforms(
|
|
2362
|
-
filters.length === 1 ? filters[0] : filters,
|
|
2363
|
-
params,
|
|
2364
|
-
elapsed.value
|
|
2365
|
-
);
|
|
2388
|
+
spec.updateUniforms(filters.length === 1 ? filters[0] : filters, params, elapsed.value);
|
|
2366
2389
|
}
|
|
2367
2390
|
};
|
|
2368
2391
|
this.app.ticker.add(tickerFn);
|
|
@@ -2384,11 +2407,7 @@ var PixiRenderer = class {
|
|
|
2384
2407
|
Object.assign(m.params, params);
|
|
2385
2408
|
Object.assign(m.ctx.params, params);
|
|
2386
2409
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2387
|
-
m.definition.filterSpec.updateUniforms(
|
|
2388
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2389
|
-
m.params,
|
|
2390
|
-
0
|
|
2391
|
-
);
|
|
2410
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2392
2411
|
}
|
|
2393
2412
|
}
|
|
2394
2413
|
/**
|
|
@@ -2408,11 +2427,7 @@ var PixiRenderer = class {
|
|
|
2408
2427
|
m.params[key] = value;
|
|
2409
2428
|
m.ctx.params[key] = value;
|
|
2410
2429
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2411
|
-
m.definition.filterSpec.updateUniforms(
|
|
2412
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2413
|
-
m.params,
|
|
2414
|
-
0
|
|
2415
|
-
);
|
|
2430
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2416
2431
|
}
|
|
2417
2432
|
m.definition.onParamChange?.(m.ctx, key, value);
|
|
2418
2433
|
}
|
|
@@ -2433,9 +2448,75 @@ var PixiRenderer = class {
|
|
|
2433
2448
|
resize(width, height) {
|
|
2434
2449
|
if (!this.app) return;
|
|
2435
2450
|
this.app.renderer.resize(width, height);
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2451
|
+
this.resizeSprites();
|
|
2452
|
+
}
|
|
2453
|
+
setFitMode(mode) {
|
|
2454
|
+
if (this._fitMode === mode) return;
|
|
2455
|
+
this._fitMode = mode;
|
|
2456
|
+
this.resizeSprites();
|
|
2457
|
+
}
|
|
2458
|
+
resizeSprites() {
|
|
2459
|
+
if (this.videoSprite && this.videoSprite.texture) {
|
|
2460
|
+
this._resizeSprite(this.videoSprite, this.videoSprite.texture, this._fitMode);
|
|
2461
|
+
}
|
|
2462
|
+
if (this.transitionSprite) {
|
|
2463
|
+
if (this._activeTransition) {
|
|
2464
|
+
this.transitionSprite.width = this.app?.screen.width ?? 1280;
|
|
2465
|
+
this.transitionSprite.height = this.app?.screen.height ?? 720;
|
|
2466
|
+
this.transitionSprite.position.set(0, 0);
|
|
2467
|
+
} else if (this.transitionSprite.texture) {
|
|
2468
|
+
this._resizeSprite(this.transitionSprite, this.transitionSprite.texture, this._fitMode);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
_getElementDimensions(texture) {
|
|
2473
|
+
const sourceEl = this._activeSource;
|
|
2474
|
+
if (sourceEl) {
|
|
2475
|
+
const tagName = sourceEl.tagName;
|
|
2476
|
+
if ((tagName === "VIDEO" || sourceEl.videoWidth !== void 0) && sourceEl.videoWidth > 0) {
|
|
2477
|
+
return { width: sourceEl.videoWidth, height: sourceEl.videoHeight };
|
|
2478
|
+
}
|
|
2479
|
+
if ((tagName === "IMG" || sourceEl.naturalWidth !== void 0) && sourceEl.naturalWidth > 0) {
|
|
2480
|
+
return { width: sourceEl.naturalWidth, height: sourceEl.naturalHeight };
|
|
2481
|
+
}
|
|
2482
|
+
if ((tagName === "CANVAS" || sourceEl.getContext !== void 0) && sourceEl.width > 0) {
|
|
2483
|
+
return { width: sourceEl.width, height: sourceEl.height };
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
const resource = texture.source?.resource || texture.source?.source;
|
|
2487
|
+
if (resource) {
|
|
2488
|
+
const tagName = resource.tagName;
|
|
2489
|
+
if ((tagName === "VIDEO" || resource.videoWidth !== void 0) && resource.videoWidth > 0) {
|
|
2490
|
+
return { width: resource.videoWidth, height: resource.videoHeight };
|
|
2491
|
+
}
|
|
2492
|
+
if ((tagName === "IMG" || resource.naturalWidth !== void 0) && resource.naturalWidth > 0) {
|
|
2493
|
+
return { width: resource.naturalWidth, height: resource.naturalHeight };
|
|
2494
|
+
}
|
|
2495
|
+
if ((tagName === "CANVAS" || resource.getContext !== void 0) && resource.width > 0) {
|
|
2496
|
+
return { width: resource.width, height: resource.height };
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
if (texture.width > 0) {
|
|
2500
|
+
return { width: texture.width, height: texture.height };
|
|
2501
|
+
}
|
|
2502
|
+
return { width: 1280, height: 720 };
|
|
2503
|
+
}
|
|
2504
|
+
_resizeSprite(sprite, texture, fitMode) {
|
|
2505
|
+
if (!this.app) return;
|
|
2506
|
+
const canvasWidth = this.app.screen.width;
|
|
2507
|
+
const canvasHeight = this.app.screen.height;
|
|
2508
|
+
const { width: texWidth, height: texHeight } = this._getElementDimensions(texture);
|
|
2509
|
+
if (fitMode === "stretch") {
|
|
2510
|
+
sprite.width = canvasWidth;
|
|
2511
|
+
sprite.height = canvasHeight;
|
|
2512
|
+
sprite.position.set(0, 0);
|
|
2513
|
+
} else {
|
|
2514
|
+
const scaleX = canvasWidth / texWidth;
|
|
2515
|
+
const scaleY = canvasHeight / texHeight;
|
|
2516
|
+
const scale = fitMode === "fit" ? Math.min(scaleX, scaleY) : Math.max(scaleX, scaleY);
|
|
2517
|
+
sprite.width = texWidth * scale;
|
|
2518
|
+
sprite.height = texHeight * scale;
|
|
2519
|
+
sprite.position.set((canvasWidth - sprite.width) / 2, (canvasHeight - sprite.height) / 2);
|
|
2439
2520
|
}
|
|
2440
2521
|
}
|
|
2441
2522
|
/**
|
|
@@ -2443,15 +2524,40 @@ var PixiRenderer = class {
|
|
|
2443
2524
|
* Call when the editor session ends or the Studio workspace unmounts.
|
|
2444
2525
|
*/
|
|
2445
2526
|
destroy() {
|
|
2527
|
+
this.initializing = false;
|
|
2446
2528
|
for (const mounted of this.mounted.values()) {
|
|
2447
2529
|
this._unmount(mounted);
|
|
2448
2530
|
}
|
|
2449
2531
|
this.mounted.clear();
|
|
2450
|
-
this.app
|
|
2451
|
-
|
|
2532
|
+
if (this.app) {
|
|
2533
|
+
try {
|
|
2534
|
+
const gl = this.app.renderer.gl;
|
|
2535
|
+
this.app.destroy(true, { children: true, texture: true });
|
|
2536
|
+
gl?.getExtension("WEBGL_lose_context")?.loseContext();
|
|
2537
|
+
} catch (e) {
|
|
2538
|
+
console.warn("Error destroying Pixi application:", e);
|
|
2539
|
+
}
|
|
2540
|
+
this.app = null;
|
|
2541
|
+
}
|
|
2452
2542
|
this.videoSprite = null;
|
|
2543
|
+
this.transitionSprite = null;
|
|
2453
2544
|
this.overlayContainer = null;
|
|
2545
|
+
this.baseMediaContainer = null;
|
|
2454
2546
|
this.initialized = false;
|
|
2547
|
+
this._activeTransition = null;
|
|
2548
|
+
this._activeSource = null;
|
|
2549
|
+
if (this.fromRenderTexture) {
|
|
2550
|
+
this.fromRenderTexture.destroy(true);
|
|
2551
|
+
this.fromRenderTexture = null;
|
|
2552
|
+
}
|
|
2553
|
+
if (this.toRenderTexture) {
|
|
2554
|
+
this.toRenderTexture.destroy(true);
|
|
2555
|
+
this.toRenderTexture = null;
|
|
2556
|
+
}
|
|
2557
|
+
if (this.blitSprite) {
|
|
2558
|
+
this.blitSprite.destroy();
|
|
2559
|
+
this.blitSprite = null;
|
|
2560
|
+
}
|
|
2455
2561
|
}
|
|
2456
2562
|
// -------------------------------------------------------------------------
|
|
2457
2563
|
// Private helpers
|
|
@@ -2476,9 +2582,125 @@ var PixiRenderer = class {
|
|
|
2476
2582
|
getVideoSprite() {
|
|
2477
2583
|
return this.videoSprite;
|
|
2478
2584
|
}
|
|
2585
|
+
getTransitionSprite() {
|
|
2586
|
+
return this.transitionSprite;
|
|
2587
|
+
}
|
|
2588
|
+
getBaseMediaContainer() {
|
|
2589
|
+
return this.baseMediaContainer;
|
|
2590
|
+
}
|
|
2591
|
+
getOverlayContainer() {
|
|
2592
|
+
return this.overlayContainer;
|
|
2593
|
+
}
|
|
2479
2594
|
get isReady() {
|
|
2480
2595
|
return this.initialized;
|
|
2481
2596
|
}
|
|
2597
|
+
_ensureRenderTextures(width, height) {
|
|
2598
|
+
if (!this.fromRenderTexture || this.fromRenderTexture.width !== width || this.fromRenderTexture.height !== height) {
|
|
2599
|
+
if (this.fromRenderTexture) this.fromRenderTexture.destroy(true);
|
|
2600
|
+
this.fromRenderTexture = import_pixi.RenderTexture.create({ width, height });
|
|
2601
|
+
}
|
|
2602
|
+
if (!this.toRenderTexture || this.toRenderTexture.width !== width || this.toRenderTexture.height !== height) {
|
|
2603
|
+
if (this.toRenderTexture) this.toRenderTexture.destroy(true);
|
|
2604
|
+
this.toRenderTexture = import_pixi.RenderTexture.create({ width, height });
|
|
2605
|
+
}
|
|
2606
|
+
if (!this.blitSprite) {
|
|
2607
|
+
this.blitSprite = new import_pixi.Sprite();
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
_blitTransitionFrames() {
|
|
2611
|
+
if (!this.app || !this._transitionFromTex || !this._transitionToTex || !this.fromRenderTexture || !this.toRenderTexture || !this.blitSprite) {
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
const currentFitMode = this._fitMode;
|
|
2615
|
+
this.blitSprite.texture = this._transitionFromTex;
|
|
2616
|
+
this._resizeSprite(this.blitSprite, this._transitionFromTex, currentFitMode);
|
|
2617
|
+
this.app.renderer.render({
|
|
2618
|
+
container: this.blitSprite,
|
|
2619
|
+
target: this.fromRenderTexture,
|
|
2620
|
+
clear: true
|
|
2621
|
+
});
|
|
2622
|
+
this.blitSprite.texture = this._transitionToTex;
|
|
2623
|
+
this._resizeSprite(this.blitSprite, this._transitionToTex, currentFitMode);
|
|
2624
|
+
this.app.renderer.render({
|
|
2625
|
+
container: this.blitSprite,
|
|
2626
|
+
target: this.toRenderTexture,
|
|
2627
|
+
clear: true
|
|
2628
|
+
});
|
|
2629
|
+
this.blitSprite.texture = import_pixi.Texture.EMPTY;
|
|
2630
|
+
}
|
|
2631
|
+
mountTransition(definition, fromTexture, toTexture, params) {
|
|
2632
|
+
if (!this.transitionSprite || !this.videoSprite || !this.app) return;
|
|
2633
|
+
this._activeSource = null;
|
|
2634
|
+
if (this._activeTransition?.filter) {
|
|
2635
|
+
this._activeTransition.filter.destroy();
|
|
2636
|
+
}
|
|
2637
|
+
this._transitionFromTex = fromTexture;
|
|
2638
|
+
this._transitionToTex = toTexture;
|
|
2639
|
+
const canvasWidth = this.app.screen.width;
|
|
2640
|
+
const canvasHeight = this.app.screen.height;
|
|
2641
|
+
this._ensureRenderTextures(canvasWidth, canvasHeight);
|
|
2642
|
+
this._blitTransitionFrames();
|
|
2643
|
+
const fromRT = this.fromRenderTexture;
|
|
2644
|
+
const toRT = this.toRenderTexture;
|
|
2645
|
+
const originalFilterFrom = import_pixi.Filter.from;
|
|
2646
|
+
import_pixi.Filter.from = function(options) {
|
|
2647
|
+
if (options && options.resources) {
|
|
2648
|
+
if (!options.resources.uFrom) {
|
|
2649
|
+
options.resources.uFrom = fromRT.source;
|
|
2650
|
+
}
|
|
2651
|
+
if (!options.resources.uTo) {
|
|
2652
|
+
options.resources.uTo = toRT.source;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
return originalFilterFrom.call(this, options);
|
|
2656
|
+
};
|
|
2657
|
+
let filter;
|
|
2658
|
+
try {
|
|
2659
|
+
filter = definition.create(params);
|
|
2660
|
+
} finally {
|
|
2661
|
+
import_pixi.Filter.from = originalFilterFrom;
|
|
2662
|
+
}
|
|
2663
|
+
filter.resources.uFrom = fromRT.source;
|
|
2664
|
+
filter.resources.uTo = toRT.source;
|
|
2665
|
+
this.transitionSprite.texture = fromRT;
|
|
2666
|
+
this.transitionSprite.filters = [filter];
|
|
2667
|
+
this.transitionSprite.visible = true;
|
|
2668
|
+
this.videoSprite.visible = false;
|
|
2669
|
+
if (this.baseMediaContainer) {
|
|
2670
|
+
this.baseMediaContainer.visible = false;
|
|
2671
|
+
}
|
|
2672
|
+
this._activeTransition = { definition, filter, params };
|
|
2673
|
+
this.resizeSprites();
|
|
2674
|
+
}
|
|
2675
|
+
getActiveTransitionId() {
|
|
2676
|
+
return this._activeTransition?.definition.id || null;
|
|
2677
|
+
}
|
|
2678
|
+
updateTransitionProgress(id, progress, params) {
|
|
2679
|
+
if (!this._activeTransition) return;
|
|
2680
|
+
if (params) {
|
|
2681
|
+
this._activeTransition.params = params;
|
|
2682
|
+
}
|
|
2683
|
+
this._blitTransitionFrames();
|
|
2684
|
+
this._activeTransition.definition.updateProgress(this._activeTransition.filter, progress, this._activeTransition.params);
|
|
2685
|
+
}
|
|
2686
|
+
unmountTransition() {
|
|
2687
|
+
if (this.transitionSprite) {
|
|
2688
|
+
this.transitionSprite.visible = false;
|
|
2689
|
+
this.transitionSprite.filters = null;
|
|
2690
|
+
}
|
|
2691
|
+
if (this.videoSprite) {
|
|
2692
|
+
this.videoSprite.visible = true;
|
|
2693
|
+
}
|
|
2694
|
+
if (this.baseMediaContainer) {
|
|
2695
|
+
this.baseMediaContainer.visible = true;
|
|
2696
|
+
}
|
|
2697
|
+
if (this._activeTransition?.filter) {
|
|
2698
|
+
this._activeTransition.filter.destroy();
|
|
2699
|
+
}
|
|
2700
|
+
this._activeTransition = null;
|
|
2701
|
+
this._transitionFromTex = null;
|
|
2702
|
+
this._transitionToTex = null;
|
|
2703
|
+
}
|
|
2482
2704
|
};
|
|
2483
2705
|
|
|
2484
2706
|
// src/videoEffects/example.ts
|
|
@@ -2619,7 +2841,6 @@ var ParticleBurstEffect = {
|
|
|
2619
2841
|
{ key: "fade", label: "Fade out", type: "toggle", value: true }
|
|
2620
2842
|
],
|
|
2621
2843
|
mount(ctx) {
|
|
2622
|
-
;
|
|
2623
2844
|
ctx._particleContainer = new import_pixi2.Container();
|
|
2624
2845
|
ctx.container.addChild(ctx._particleContainer);
|
|
2625
2846
|
const particles = [];
|
|
@@ -2776,7 +2997,6 @@ var VHSCompositeEffect = {
|
|
|
2776
2997
|
draw();
|
|
2777
2998
|
ctx.container.addChild(band);
|
|
2778
2999
|
ctx._tickerFn = (ticker) => {
|
|
2779
|
-
;
|
|
2780
3000
|
ctx._bandY += ctx.params.bandSpeed * ticker.deltaTime;
|
|
2781
3001
|
if (ctx._bandY > ctx.height + 20) ctx._bandY = -20;
|
|
2782
3002
|
draw();
|