@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
|
@@ -2181,17 +2181,24 @@ function isCompositeEffect(e) {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
|
|
2183
2183
|
// src/videoEffects/PixiRenderer.ts
|
|
2184
|
-
import {
|
|
2185
|
-
Application,
|
|
2186
|
-
Container,
|
|
2187
|
-
Sprite
|
|
2188
|
-
} from "pixi.js";
|
|
2184
|
+
import { Application, Container, Sprite, Texture, Filter, RenderTexture } from "pixi.js";
|
|
2189
2185
|
var PixiRenderer = class {
|
|
2190
2186
|
app = null;
|
|
2191
2187
|
videoSprite = null;
|
|
2188
|
+
transitionSprite = null;
|
|
2189
|
+
_activeTransition = null;
|
|
2190
|
+
fromRenderTexture = null;
|
|
2191
|
+
toRenderTexture = null;
|
|
2192
|
+
blitSprite = null;
|
|
2193
|
+
_transitionFromTex = null;
|
|
2194
|
+
_transitionToTex = null;
|
|
2192
2195
|
overlayContainer = null;
|
|
2196
|
+
baseMediaContainer = null;
|
|
2193
2197
|
mounted = /* @__PURE__ */ new Map();
|
|
2194
2198
|
initialized = false;
|
|
2199
|
+
initializing = false;
|
|
2200
|
+
_activeSource = null;
|
|
2201
|
+
_fitMode = "fit";
|
|
2195
2202
|
/**
|
|
2196
2203
|
* Initialize the PixiJS Application.
|
|
2197
2204
|
* Call once, reuse across effect changes.
|
|
@@ -2201,47 +2208,77 @@ var PixiRenderer = class {
|
|
|
2201
2208
|
* @param height Canvas height in pixels
|
|
2202
2209
|
*/
|
|
2203
2210
|
async init(canvas, width, height) {
|
|
2204
|
-
if (this.initialized) return;
|
|
2205
|
-
this.
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
antialias: true,
|
|
2213
|
-
preference: "webgl",
|
|
2214
|
-
// WebGL for production stability; swap to 'webgpu' later
|
|
2215
|
-
resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
2216
|
-
autoDensity: true,
|
|
2217
|
-
preserveDrawingBuffer: true
|
|
2211
|
+
if (this.initialized || this.initializing) return;
|
|
2212
|
+
this.initializing = true;
|
|
2213
|
+
canvas.addEventListener("webglcontextlost", (event) => {
|
|
2214
|
+
event.preventDefault();
|
|
2215
|
+
console.warn("[PixiRenderer] WebGL context lost \u2014 attempting recovery");
|
|
2216
|
+
});
|
|
2217
|
+
canvas.addEventListener("webglcontextrestored", () => {
|
|
2218
|
+
console.log("[PixiRenderer] WebGL context restored");
|
|
2218
2219
|
});
|
|
2220
|
+
const app = new Application();
|
|
2221
|
+
try {
|
|
2222
|
+
await app.init({
|
|
2223
|
+
canvas,
|
|
2224
|
+
width,
|
|
2225
|
+
height,
|
|
2226
|
+
backgroundAlpha: 0,
|
|
2227
|
+
// transparent — composited over video below
|
|
2228
|
+
antialias: true,
|
|
2229
|
+
preference: "webgl",
|
|
2230
|
+
// WebGL for production stability; swap to 'webgpu' later
|
|
2231
|
+
resolution: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
2232
|
+
autoDensity: true,
|
|
2233
|
+
preserveDrawingBuffer: true
|
|
2234
|
+
});
|
|
2235
|
+
} catch (e) {
|
|
2236
|
+
this.initializing = false;
|
|
2237
|
+
throw e;
|
|
2238
|
+
}
|
|
2239
|
+
if (!this.initializing) {
|
|
2240
|
+
app.destroy(true);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
this.app = app;
|
|
2219
2244
|
this.videoSprite = new Sprite();
|
|
2220
2245
|
this.videoSprite.width = width;
|
|
2221
2246
|
this.videoSprite.height = height;
|
|
2247
|
+
this.transitionSprite = new Sprite();
|
|
2248
|
+
this.transitionSprite.width = width;
|
|
2249
|
+
this.transitionSprite.height = height;
|
|
2250
|
+
this.transitionSprite.visible = false;
|
|
2222
2251
|
this.overlayContainer = new Container();
|
|
2252
|
+
this.baseMediaContainer = new Container();
|
|
2253
|
+
this.baseMediaContainer.sortableChildren = true;
|
|
2254
|
+
this.app.stage.addChildAt(this.baseMediaContainer, 0);
|
|
2223
2255
|
this.app.stage.addChild(this.videoSprite);
|
|
2256
|
+
this.app.stage.addChild(this.transitionSprite);
|
|
2224
2257
|
this.app.stage.addChild(this.overlayContainer);
|
|
2225
2258
|
this.initialized = true;
|
|
2259
|
+
this.initializing = false;
|
|
2226
2260
|
}
|
|
2227
|
-
/**
|
|
2228
|
-
* Point the video sprite at a live HTMLVideoElement.
|
|
2229
|
-
* PixiJS polls the video element each frame automatically.
|
|
2230
|
-
*/
|
|
2231
2261
|
setVideoSource(video) {
|
|
2262
|
+
if (this._activeSource === video) {
|
|
2263
|
+
this.resizeSprites();
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
this._activeSource = video;
|
|
2232
2267
|
if (!this.videoSprite || !this.app) return;
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
this.videoSprite.texture = texture;
|
|
2237
|
-
});
|
|
2268
|
+
const texture = Texture.from(video);
|
|
2269
|
+
this.videoSprite.texture = texture;
|
|
2270
|
+
this.resizeSprites();
|
|
2238
2271
|
}
|
|
2239
2272
|
setImageSource(image) {
|
|
2273
|
+
if (this._activeSource === image) {
|
|
2274
|
+
this.resizeSprites();
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
this._activeSource = image;
|
|
2240
2278
|
if (!this.videoSprite || !this.app) return;
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
});
|
|
2279
|
+
const texture = Texture.from(image);
|
|
2280
|
+
this.videoSprite.texture = texture;
|
|
2281
|
+
this.resizeSprites();
|
|
2245
2282
|
}
|
|
2246
2283
|
// -------------------------------------------------------------------------
|
|
2247
2284
|
// Effect lifecycle
|
|
@@ -2272,11 +2309,7 @@ var PixiRenderer = class {
|
|
|
2272
2309
|
Object.assign(m.params, params);
|
|
2273
2310
|
Object.assign(m.ctx.params, params);
|
|
2274
2311
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2275
|
-
m.definition.filterSpec.updateUniforms(
|
|
2276
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2277
|
-
m.params,
|
|
2278
|
-
0
|
|
2279
|
-
);
|
|
2312
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2280
2313
|
}
|
|
2281
2314
|
if (m.filters) filterChain.push(...m.filters);
|
|
2282
2315
|
continue;
|
|
@@ -2301,11 +2334,7 @@ var PixiRenderer = class {
|
|
|
2301
2334
|
tickerFn = (ticker) => {
|
|
2302
2335
|
elapsed.value += ticker.deltaMS;
|
|
2303
2336
|
if (filters) {
|
|
2304
|
-
spec.updateUniforms(
|
|
2305
|
-
filters.length === 1 ? filters[0] : filters,
|
|
2306
|
-
params,
|
|
2307
|
-
elapsed.value
|
|
2308
|
-
);
|
|
2337
|
+
spec.updateUniforms(filters.length === 1 ? filters[0] : filters, params, elapsed.value);
|
|
2309
2338
|
}
|
|
2310
2339
|
};
|
|
2311
2340
|
this.app.ticker.add(tickerFn);
|
|
@@ -2327,11 +2356,7 @@ var PixiRenderer = class {
|
|
|
2327
2356
|
Object.assign(m.params, params);
|
|
2328
2357
|
Object.assign(m.ctx.params, params);
|
|
2329
2358
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2330
|
-
m.definition.filterSpec.updateUniforms(
|
|
2331
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2332
|
-
m.params,
|
|
2333
|
-
0
|
|
2334
|
-
);
|
|
2359
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2335
2360
|
}
|
|
2336
2361
|
}
|
|
2337
2362
|
/**
|
|
@@ -2351,11 +2376,7 @@ var PixiRenderer = class {
|
|
|
2351
2376
|
m.params[key] = value;
|
|
2352
2377
|
m.ctx.params[key] = value;
|
|
2353
2378
|
if (m.filters && m.definition.filterSpec?.updateUniforms) {
|
|
2354
|
-
m.definition.filterSpec.updateUniforms(
|
|
2355
|
-
m.filters.length === 1 ? m.filters[0] : m.filters,
|
|
2356
|
-
m.params,
|
|
2357
|
-
0
|
|
2358
|
-
);
|
|
2379
|
+
m.definition.filterSpec.updateUniforms(m.filters.length === 1 ? m.filters[0] : m.filters, m.params, 0);
|
|
2359
2380
|
}
|
|
2360
2381
|
m.definition.onParamChange?.(m.ctx, key, value);
|
|
2361
2382
|
}
|
|
@@ -2376,9 +2397,75 @@ var PixiRenderer = class {
|
|
|
2376
2397
|
resize(width, height) {
|
|
2377
2398
|
if (!this.app) return;
|
|
2378
2399
|
this.app.renderer.resize(width, height);
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2400
|
+
this.resizeSprites();
|
|
2401
|
+
}
|
|
2402
|
+
setFitMode(mode) {
|
|
2403
|
+
if (this._fitMode === mode) return;
|
|
2404
|
+
this._fitMode = mode;
|
|
2405
|
+
this.resizeSprites();
|
|
2406
|
+
}
|
|
2407
|
+
resizeSprites() {
|
|
2408
|
+
if (this.videoSprite && this.videoSprite.texture) {
|
|
2409
|
+
this._resizeSprite(this.videoSprite, this.videoSprite.texture, this._fitMode);
|
|
2410
|
+
}
|
|
2411
|
+
if (this.transitionSprite) {
|
|
2412
|
+
if (this._activeTransition) {
|
|
2413
|
+
this.transitionSprite.width = this.app?.screen.width ?? 1280;
|
|
2414
|
+
this.transitionSprite.height = this.app?.screen.height ?? 720;
|
|
2415
|
+
this.transitionSprite.position.set(0, 0);
|
|
2416
|
+
} else if (this.transitionSprite.texture) {
|
|
2417
|
+
this._resizeSprite(this.transitionSprite, this.transitionSprite.texture, this._fitMode);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
_getElementDimensions(texture) {
|
|
2422
|
+
const sourceEl = this._activeSource;
|
|
2423
|
+
if (sourceEl) {
|
|
2424
|
+
const tagName = sourceEl.tagName;
|
|
2425
|
+
if ((tagName === "VIDEO" || sourceEl.videoWidth !== void 0) && sourceEl.videoWidth > 0) {
|
|
2426
|
+
return { width: sourceEl.videoWidth, height: sourceEl.videoHeight };
|
|
2427
|
+
}
|
|
2428
|
+
if ((tagName === "IMG" || sourceEl.naturalWidth !== void 0) && sourceEl.naturalWidth > 0) {
|
|
2429
|
+
return { width: sourceEl.naturalWidth, height: sourceEl.naturalHeight };
|
|
2430
|
+
}
|
|
2431
|
+
if ((tagName === "CANVAS" || sourceEl.getContext !== void 0) && sourceEl.width > 0) {
|
|
2432
|
+
return { width: sourceEl.width, height: sourceEl.height };
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
const resource = texture.source?.resource || texture.source?.source;
|
|
2436
|
+
if (resource) {
|
|
2437
|
+
const tagName = resource.tagName;
|
|
2438
|
+
if ((tagName === "VIDEO" || resource.videoWidth !== void 0) && resource.videoWidth > 0) {
|
|
2439
|
+
return { width: resource.videoWidth, height: resource.videoHeight };
|
|
2440
|
+
}
|
|
2441
|
+
if ((tagName === "IMG" || resource.naturalWidth !== void 0) && resource.naturalWidth > 0) {
|
|
2442
|
+
return { width: resource.naturalWidth, height: resource.naturalHeight };
|
|
2443
|
+
}
|
|
2444
|
+
if ((tagName === "CANVAS" || resource.getContext !== void 0) && resource.width > 0) {
|
|
2445
|
+
return { width: resource.width, height: resource.height };
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if (texture.width > 0) {
|
|
2449
|
+
return { width: texture.width, height: texture.height };
|
|
2450
|
+
}
|
|
2451
|
+
return { width: 1280, height: 720 };
|
|
2452
|
+
}
|
|
2453
|
+
_resizeSprite(sprite, texture, fitMode) {
|
|
2454
|
+
if (!this.app) return;
|
|
2455
|
+
const canvasWidth = this.app.screen.width;
|
|
2456
|
+
const canvasHeight = this.app.screen.height;
|
|
2457
|
+
const { width: texWidth, height: texHeight } = this._getElementDimensions(texture);
|
|
2458
|
+
if (fitMode === "stretch") {
|
|
2459
|
+
sprite.width = canvasWidth;
|
|
2460
|
+
sprite.height = canvasHeight;
|
|
2461
|
+
sprite.position.set(0, 0);
|
|
2462
|
+
} else {
|
|
2463
|
+
const scaleX = canvasWidth / texWidth;
|
|
2464
|
+
const scaleY = canvasHeight / texHeight;
|
|
2465
|
+
const scale = fitMode === "fit" ? Math.min(scaleX, scaleY) : Math.max(scaleX, scaleY);
|
|
2466
|
+
sprite.width = texWidth * scale;
|
|
2467
|
+
sprite.height = texHeight * scale;
|
|
2468
|
+
sprite.position.set((canvasWidth - sprite.width) / 2, (canvasHeight - sprite.height) / 2);
|
|
2382
2469
|
}
|
|
2383
2470
|
}
|
|
2384
2471
|
/**
|
|
@@ -2386,15 +2473,40 @@ var PixiRenderer = class {
|
|
|
2386
2473
|
* Call when the editor session ends or the Studio workspace unmounts.
|
|
2387
2474
|
*/
|
|
2388
2475
|
destroy() {
|
|
2476
|
+
this.initializing = false;
|
|
2389
2477
|
for (const mounted of this.mounted.values()) {
|
|
2390
2478
|
this._unmount(mounted);
|
|
2391
2479
|
}
|
|
2392
2480
|
this.mounted.clear();
|
|
2393
|
-
this.app
|
|
2394
|
-
|
|
2481
|
+
if (this.app) {
|
|
2482
|
+
try {
|
|
2483
|
+
const gl = this.app.renderer.gl;
|
|
2484
|
+
this.app.destroy(true, { children: true, texture: true });
|
|
2485
|
+
gl?.getExtension("WEBGL_lose_context")?.loseContext();
|
|
2486
|
+
} catch (e) {
|
|
2487
|
+
console.warn("Error destroying Pixi application:", e);
|
|
2488
|
+
}
|
|
2489
|
+
this.app = null;
|
|
2490
|
+
}
|
|
2395
2491
|
this.videoSprite = null;
|
|
2492
|
+
this.transitionSprite = null;
|
|
2396
2493
|
this.overlayContainer = null;
|
|
2494
|
+
this.baseMediaContainer = null;
|
|
2397
2495
|
this.initialized = false;
|
|
2496
|
+
this._activeTransition = null;
|
|
2497
|
+
this._activeSource = null;
|
|
2498
|
+
if (this.fromRenderTexture) {
|
|
2499
|
+
this.fromRenderTexture.destroy(true);
|
|
2500
|
+
this.fromRenderTexture = null;
|
|
2501
|
+
}
|
|
2502
|
+
if (this.toRenderTexture) {
|
|
2503
|
+
this.toRenderTexture.destroy(true);
|
|
2504
|
+
this.toRenderTexture = null;
|
|
2505
|
+
}
|
|
2506
|
+
if (this.blitSprite) {
|
|
2507
|
+
this.blitSprite.destroy();
|
|
2508
|
+
this.blitSprite = null;
|
|
2509
|
+
}
|
|
2398
2510
|
}
|
|
2399
2511
|
// -------------------------------------------------------------------------
|
|
2400
2512
|
// Private helpers
|
|
@@ -2419,9 +2531,125 @@ var PixiRenderer = class {
|
|
|
2419
2531
|
getVideoSprite() {
|
|
2420
2532
|
return this.videoSprite;
|
|
2421
2533
|
}
|
|
2534
|
+
getTransitionSprite() {
|
|
2535
|
+
return this.transitionSprite;
|
|
2536
|
+
}
|
|
2537
|
+
getBaseMediaContainer() {
|
|
2538
|
+
return this.baseMediaContainer;
|
|
2539
|
+
}
|
|
2540
|
+
getOverlayContainer() {
|
|
2541
|
+
return this.overlayContainer;
|
|
2542
|
+
}
|
|
2422
2543
|
get isReady() {
|
|
2423
2544
|
return this.initialized;
|
|
2424
2545
|
}
|
|
2546
|
+
_ensureRenderTextures(width, height) {
|
|
2547
|
+
if (!this.fromRenderTexture || this.fromRenderTexture.width !== width || this.fromRenderTexture.height !== height) {
|
|
2548
|
+
if (this.fromRenderTexture) this.fromRenderTexture.destroy(true);
|
|
2549
|
+
this.fromRenderTexture = RenderTexture.create({ width, height });
|
|
2550
|
+
}
|
|
2551
|
+
if (!this.toRenderTexture || this.toRenderTexture.width !== width || this.toRenderTexture.height !== height) {
|
|
2552
|
+
if (this.toRenderTexture) this.toRenderTexture.destroy(true);
|
|
2553
|
+
this.toRenderTexture = RenderTexture.create({ width, height });
|
|
2554
|
+
}
|
|
2555
|
+
if (!this.blitSprite) {
|
|
2556
|
+
this.blitSprite = new Sprite();
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
_blitTransitionFrames() {
|
|
2560
|
+
if (!this.app || !this._transitionFromTex || !this._transitionToTex || !this.fromRenderTexture || !this.toRenderTexture || !this.blitSprite) {
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
const currentFitMode = this._fitMode;
|
|
2564
|
+
this.blitSprite.texture = this._transitionFromTex;
|
|
2565
|
+
this._resizeSprite(this.blitSprite, this._transitionFromTex, currentFitMode);
|
|
2566
|
+
this.app.renderer.render({
|
|
2567
|
+
container: this.blitSprite,
|
|
2568
|
+
target: this.fromRenderTexture,
|
|
2569
|
+
clear: true
|
|
2570
|
+
});
|
|
2571
|
+
this.blitSprite.texture = this._transitionToTex;
|
|
2572
|
+
this._resizeSprite(this.blitSprite, this._transitionToTex, currentFitMode);
|
|
2573
|
+
this.app.renderer.render({
|
|
2574
|
+
container: this.blitSprite,
|
|
2575
|
+
target: this.toRenderTexture,
|
|
2576
|
+
clear: true
|
|
2577
|
+
});
|
|
2578
|
+
this.blitSprite.texture = Texture.EMPTY;
|
|
2579
|
+
}
|
|
2580
|
+
mountTransition(definition, fromTexture, toTexture, params) {
|
|
2581
|
+
if (!this.transitionSprite || !this.videoSprite || !this.app) return;
|
|
2582
|
+
this._activeSource = null;
|
|
2583
|
+
if (this._activeTransition?.filter) {
|
|
2584
|
+
this._activeTransition.filter.destroy();
|
|
2585
|
+
}
|
|
2586
|
+
this._transitionFromTex = fromTexture;
|
|
2587
|
+
this._transitionToTex = toTexture;
|
|
2588
|
+
const canvasWidth = this.app.screen.width;
|
|
2589
|
+
const canvasHeight = this.app.screen.height;
|
|
2590
|
+
this._ensureRenderTextures(canvasWidth, canvasHeight);
|
|
2591
|
+
this._blitTransitionFrames();
|
|
2592
|
+
const fromRT = this.fromRenderTexture;
|
|
2593
|
+
const toRT = this.toRenderTexture;
|
|
2594
|
+
const originalFilterFrom = Filter.from;
|
|
2595
|
+
Filter.from = function(options) {
|
|
2596
|
+
if (options && options.resources) {
|
|
2597
|
+
if (!options.resources.uFrom) {
|
|
2598
|
+
options.resources.uFrom = fromRT.source;
|
|
2599
|
+
}
|
|
2600
|
+
if (!options.resources.uTo) {
|
|
2601
|
+
options.resources.uTo = toRT.source;
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
return originalFilterFrom.call(this, options);
|
|
2605
|
+
};
|
|
2606
|
+
let filter;
|
|
2607
|
+
try {
|
|
2608
|
+
filter = definition.create(params);
|
|
2609
|
+
} finally {
|
|
2610
|
+
Filter.from = originalFilterFrom;
|
|
2611
|
+
}
|
|
2612
|
+
filter.resources.uFrom = fromRT.source;
|
|
2613
|
+
filter.resources.uTo = toRT.source;
|
|
2614
|
+
this.transitionSprite.texture = fromRT;
|
|
2615
|
+
this.transitionSprite.filters = [filter];
|
|
2616
|
+
this.transitionSprite.visible = true;
|
|
2617
|
+
this.videoSprite.visible = false;
|
|
2618
|
+
if (this.baseMediaContainer) {
|
|
2619
|
+
this.baseMediaContainer.visible = false;
|
|
2620
|
+
}
|
|
2621
|
+
this._activeTransition = { definition, filter, params };
|
|
2622
|
+
this.resizeSprites();
|
|
2623
|
+
}
|
|
2624
|
+
getActiveTransitionId() {
|
|
2625
|
+
return this._activeTransition?.definition.id || null;
|
|
2626
|
+
}
|
|
2627
|
+
updateTransitionProgress(id, progress, params) {
|
|
2628
|
+
if (!this._activeTransition) return;
|
|
2629
|
+
if (params) {
|
|
2630
|
+
this._activeTransition.params = params;
|
|
2631
|
+
}
|
|
2632
|
+
this._blitTransitionFrames();
|
|
2633
|
+
this._activeTransition.definition.updateProgress(this._activeTransition.filter, progress, this._activeTransition.params);
|
|
2634
|
+
}
|
|
2635
|
+
unmountTransition() {
|
|
2636
|
+
if (this.transitionSprite) {
|
|
2637
|
+
this.transitionSprite.visible = false;
|
|
2638
|
+
this.transitionSprite.filters = null;
|
|
2639
|
+
}
|
|
2640
|
+
if (this.videoSprite) {
|
|
2641
|
+
this.videoSprite.visible = true;
|
|
2642
|
+
}
|
|
2643
|
+
if (this.baseMediaContainer) {
|
|
2644
|
+
this.baseMediaContainer.visible = true;
|
|
2645
|
+
}
|
|
2646
|
+
if (this._activeTransition?.filter) {
|
|
2647
|
+
this._activeTransition.filter.destroy();
|
|
2648
|
+
}
|
|
2649
|
+
this._activeTransition = null;
|
|
2650
|
+
this._transitionFromTex = null;
|
|
2651
|
+
this._transitionToTex = null;
|
|
2652
|
+
}
|
|
2425
2653
|
};
|
|
2426
2654
|
|
|
2427
2655
|
// src/videoEffects/example.ts
|
|
@@ -2431,7 +2659,7 @@ __export(example_exports, {
|
|
|
2431
2659
|
ParticleBurstEffect: () => ParticleBurstEffect,
|
|
2432
2660
|
VHSCompositeEffect: () => VHSCompositeEffect
|
|
2433
2661
|
});
|
|
2434
|
-
import { Filter, Container as Container2, Graphics } from "pixi.js";
|
|
2662
|
+
import { Filter as Filter2, Container as Container2, Graphics } from "pixi.js";
|
|
2435
2663
|
var hexToRgb = (hex) => {
|
|
2436
2664
|
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
2437
2665
|
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
@@ -2518,7 +2746,7 @@ var NeonGlowEffect = {
|
|
|
2518
2746
|
}
|
|
2519
2747
|
`;
|
|
2520
2748
|
const rgb = hexToRgb(params.color);
|
|
2521
|
-
return
|
|
2749
|
+
return Filter2.from({
|
|
2522
2750
|
gl: { vertex: DEFAULT_VERTEX_SHADER, fragment },
|
|
2523
2751
|
resources: {
|
|
2524
2752
|
uniforms: {
|
|
@@ -2562,7 +2790,6 @@ var ParticleBurstEffect = {
|
|
|
2562
2790
|
{ key: "fade", label: "Fade out", type: "toggle", value: true }
|
|
2563
2791
|
],
|
|
2564
2792
|
mount(ctx) {
|
|
2565
|
-
;
|
|
2566
2793
|
ctx._particleContainer = new Container2();
|
|
2567
2794
|
ctx.container.addChild(ctx._particleContainer);
|
|
2568
2795
|
const particles = [];
|
|
@@ -2683,7 +2910,7 @@ var VHSCompositeEffect = {
|
|
|
2683
2910
|
finalColor = color;
|
|
2684
2911
|
}
|
|
2685
2912
|
`;
|
|
2686
|
-
return
|
|
2913
|
+
return Filter2.from({
|
|
2687
2914
|
gl: { vertex: DEFAULT_VERTEX_SHADER, fragment },
|
|
2688
2915
|
resources: {
|
|
2689
2916
|
uniforms: {
|
|
@@ -2719,7 +2946,6 @@ var VHSCompositeEffect = {
|
|
|
2719
2946
|
draw();
|
|
2720
2947
|
ctx.container.addChild(band);
|
|
2721
2948
|
ctx._tickerFn = (ticker) => {
|
|
2722
|
-
;
|
|
2723
2949
|
ctx._bandY += ctx.params.bandSpeed * ticker.deltaTime;
|
|
2724
2950
|
if (ctx._bandY > ctx.height + 20) ctx._bandY = -20;
|
|
2725
2951
|
draw();
|
|
@@ -2823,4 +3049,4 @@ export {
|
|
|
2823
3049
|
example_exports,
|
|
2824
3050
|
camera_exports
|
|
2825
3051
|
};
|
|
2826
|
-
//# sourceMappingURL=chunk-
|
|
3052
|
+
//# sourceMappingURL=chunk-2VGI6ZB7.js.map
|