@omnimedia/omnitool 1.1.0-74 → 1.1.0-76
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/package.json +1 -1
- package/s/demo/routines/timeline-setup.ts +12 -1
- package/s/driver/fns/schematic.ts +3 -0
- package/s/driver/parts/compositor.ts +45 -4
- package/s/timeline/parts/item.ts +3 -0
- package/s/timeline/renderers/parts/samplers/visual/parts/sample.ts +5 -2
- package/s/timeline/sugar/helpers.ts +3 -3
- package/s/timeline/sugar/o.ts +4 -3
- package/x/{browserAll-6TVTCHHE.js → browserAll-LRGVU2GN.js} +2 -2
- package/x/{demo/chunk-YJQWVIHX.js → chunk-D5CIWPNS.js} +2 -2
- package/x/{chunk-W33LM336.js → chunk-MWCIWPRL.js} +2 -2
- package/x/demo/{browserAll-5AZHDDG6.js → browserAll-QEV2P3ED.js} +2 -2
- package/x/{chunk-63NSCXPX.js → demo/chunk-IRDQEA6B.js} +2 -2
- package/x/demo/{chunk-5ZZYIILO.js → chunk-RWJ2UHV4.js} +2 -2
- package/x/demo/demo.bundle.min.js +7 -7
- package/x/demo/demo.bundle.min.js.map +3 -3
- package/x/demo/routines/timeline-setup.js +8 -1
- package/x/demo/routines/timeline-setup.js.map +1 -1
- package/x/demo/webworkerAll-ELLD4M57.js +2 -0
- package/x/driver/fns/schematic.d.ts +3 -0
- package/x/driver/parts/compositor.d.ts +5 -0
- package/x/driver/parts/compositor.js +40 -3
- package/x/driver/parts/compositor.js.map +1 -1
- package/x/index.html +2 -2
- package/x/tests.bundle.min.js +12 -12
- package/x/tests.bundle.min.js.map +3 -3
- package/x/tests.html +1 -1
- package/x/timeline/parts/item.d.ts +2 -0
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.js +5 -2
- package/x/timeline/renderers/parts/samplers/visual/parts/sample.js.map +1 -1
- package/x/timeline/sugar/helpers.d.ts +2 -2
- package/x/timeline/sugar/helpers.js +2 -2
- package/x/timeline/sugar/helpers.js.map +1 -1
- package/x/timeline/sugar/o.d.ts +2 -2
- package/x/timeline/sugar/o.js +3 -2
- package/x/timeline/sugar/o.js.map +1 -1
- package/x/webworkerAll-KR5SWEBU.js +2 -0
- package/x/demo/webworkerAll-QKIC5O27.js +0 -2
- package/x/webworkerAll-VVIU3M54.js +0 -2
- /package/x/{browserAll-6TVTCHHE.js.map → browserAll-LRGVU2GN.js.map} +0 -0
- /package/x/{chunk-63NSCXPX.js.map → chunk-D5CIWPNS.js.map} +0 -0
- /package/x/{chunk-W33LM336.js.map → chunk-MWCIWPRL.js.map} +0 -0
- /package/x/demo/{browserAll-5AZHDDG6.js.map → browserAll-QEV2P3ED.js.map} +0 -0
- /package/x/demo/{chunk-YJQWVIHX.js.map → chunk-IRDQEA6B.js.map} +0 -0
- /package/x/demo/{chunk-5ZZYIILO.js.map → chunk-RWJ2UHV4.js.map} +0 -0
- /package/x/demo/{webworkerAll-QKIC5O27.js.map → webworkerAll-ELLD4M57.js.map} +0 -0
- /package/x/{webworkerAll-VVIU3M54.js.map → webworkerAll-KR5SWEBU.js.map} +0 -0
package/package.json
CHANGED
|
@@ -8,12 +8,23 @@ export async function TimelineSchemaTest(driver: Driver, file: File) {
|
|
|
8
8
|
const timeline = omni.timeline(o => {
|
|
9
9
|
const text = o.text("content", {duration: 1000})
|
|
10
10
|
const style = o.textStyle({fill: "green", fontSize: 100})
|
|
11
|
+
const spatial = o.spatial(
|
|
12
|
+
o.transform({
|
|
13
|
+
position: [240, 160],
|
|
14
|
+
scale: [1.4, 1.4],
|
|
15
|
+
rotation: 0.08,
|
|
16
|
+
}),
|
|
17
|
+
[0.15, 0.1, 0.05, 0.2],
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const video = o.video(videoA, {duration: 3000, start: 1000})
|
|
11
21
|
o.set<Item.Text>(text.id, {styleId: style.id})
|
|
22
|
+
o.set<Item.Video>(video.id, {spatialId: spatial.id})
|
|
12
23
|
|
|
13
24
|
return o.sequence(
|
|
14
25
|
o.stack(
|
|
15
26
|
text,
|
|
16
|
-
|
|
27
|
+
video,
|
|
17
28
|
o.audio(videoA, {duration: 1000})
|
|
18
29
|
),
|
|
19
30
|
o.gap(500),
|
|
@@ -5,6 +5,7 @@ import type {AudioEncodingConfig, StreamTargetChunk, VideoEncodingConfig} from "
|
|
|
5
5
|
|
|
6
6
|
import {Mat6} from "../../timeline/utils/matrix.js"
|
|
7
7
|
import {Id} from "../../timeline/index.js"
|
|
8
|
+
import {Crop} from "../../timeline/parts/item.js"
|
|
8
9
|
|
|
9
10
|
export type DriverSchematic = AsSchematic<{
|
|
10
11
|
|
|
@@ -79,6 +80,7 @@ export type TextLayer = {
|
|
|
79
80
|
content: string
|
|
80
81
|
style?: TextStyleOptions
|
|
81
82
|
matrix?: Mat6
|
|
83
|
+
crop?: Crop
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
export type ImageLayer = {
|
|
@@ -86,6 +88,7 @@ export type ImageLayer = {
|
|
|
86
88
|
kind: 'image'
|
|
87
89
|
frame: VideoFrame
|
|
88
90
|
matrix?: Mat6
|
|
91
|
+
crop?: Crop
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
export type TransitionLayer = {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import {pub} from "@e280/stz"
|
|
3
|
-
import {autoDetectRenderer, Container, FederatedPointerEvent, Renderer, Sprite, Text, Texture} from "pixi.js"
|
|
3
|
+
import {autoDetectRenderer, Container, FederatedPointerEvent, Graphics, Renderer, Sprite, Text, Texture} from "pixi.js"
|
|
4
4
|
|
|
5
5
|
import {Id} from "../../timeline/index.js"
|
|
6
|
+
import {Crop} from "../../timeline/parts/item.js"
|
|
6
7
|
import {Composition, Layer} from "../fns/schematic.js"
|
|
7
8
|
import {Mat6, mat6ToMatrix} from "../../timeline/utils/matrix.js"
|
|
8
9
|
import {makeTransition} from "../../features/transition/transition.js"
|
|
9
10
|
|
|
10
11
|
export class Compositor {
|
|
11
12
|
onPointerDown = pub<[{event: FederatedPointerEvent, id: Id, object: Container}]>()
|
|
13
|
+
onPointerMove = pub<[{event: FederatedPointerEvent, id: Id, object: Container}]>()
|
|
12
14
|
onPointerUp = pub<[{event: FederatedPointerEvent, id: Id, object: Container}]>()
|
|
13
15
|
onDispose = pub<[{id: Id, object: Container}]>()
|
|
14
16
|
|
|
@@ -30,6 +32,7 @@ export class Compositor {
|
|
|
30
32
|
#transitions: Map<string, ReturnType<typeof makeTransition>> = new Map()
|
|
31
33
|
// objects rendered for current Composition
|
|
32
34
|
#activeObjects = new Map<number, {sprite: Container, dispose: () => void}>()
|
|
35
|
+
#cropMasks = new WeakMap<Container, Graphics>()
|
|
33
36
|
|
|
34
37
|
async composite(
|
|
35
38
|
composition: Composition,
|
|
@@ -64,9 +67,8 @@ export class Compositor {
|
|
|
64
67
|
parent: Container,
|
|
65
68
|
) {
|
|
66
69
|
if (Array.isArray(layer)) {
|
|
67
|
-
layer.reverse()
|
|
68
70
|
const disposers: (() => void)[] = []
|
|
69
|
-
for (const child of layer) {
|
|
71
|
+
for (const child of [...layer].reverse()) {
|
|
70
72
|
const result = await this.#renderLayer(child, parent)
|
|
71
73
|
disposers.push(result.dispose)
|
|
72
74
|
}
|
|
@@ -96,6 +98,7 @@ export class Compositor {
|
|
|
96
98
|
) {
|
|
97
99
|
const sprite = this.#findOrCreate<Text>(layer)!
|
|
98
100
|
this.#applyTransform(sprite, layer.matrix)
|
|
101
|
+
this.#applyCrop(sprite, layer.crop)
|
|
99
102
|
parent.addChild(sprite)
|
|
100
103
|
return {
|
|
101
104
|
dispose: () => {}
|
|
@@ -115,6 +118,7 @@ export class Compositor {
|
|
|
115
118
|
const texture = Texture.from(layer.frame)
|
|
116
119
|
sprite.texture = texture
|
|
117
120
|
this.#applyTransform(sprite, layer.matrix)
|
|
121
|
+
this.#applyCrop(sprite, layer.crop)
|
|
118
122
|
parent.addChild(sprite)
|
|
119
123
|
|
|
120
124
|
return {
|
|
@@ -147,6 +151,38 @@ export class Compositor {
|
|
|
147
151
|
target.setFromMatrix(mx)
|
|
148
152
|
}
|
|
149
153
|
|
|
154
|
+
#applyCrop(target: Container, crop?: Crop) {
|
|
155
|
+
const existing = this.#cropMasks.get(target)
|
|
156
|
+
if (existing) {
|
|
157
|
+
if (target.mask === existing)
|
|
158
|
+
target.mask = null
|
|
159
|
+
existing.removeFromParent()
|
|
160
|
+
existing.clear()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!crop || crop.every(value => value === 0))
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
const [top, right, bottom, left] = crop
|
|
167
|
+
const activeMask = target.mask
|
|
168
|
+
target.mask = null
|
|
169
|
+
const bounds = target.getLocalBounds()
|
|
170
|
+
target.mask = activeMask
|
|
171
|
+
const x = bounds.x + bounds.width * left
|
|
172
|
+
const y = bounds.y + bounds.height * top
|
|
173
|
+
const width = bounds.width * Math.max(0, 1 - left - right)
|
|
174
|
+
const height = bounds.height * Math.max(0, 1 - top - bottom)
|
|
175
|
+
|
|
176
|
+
const mask = existing ?? new Graphics()
|
|
177
|
+
mask.clear()
|
|
178
|
+
mask.beginFill(0xffffff)
|
|
179
|
+
mask.drawRect(x, y, width, height)
|
|
180
|
+
mask.endFill()
|
|
181
|
+
target.addChild(mask)
|
|
182
|
+
target.mask = mask
|
|
183
|
+
this.#cropMasks.set(target, mask)
|
|
184
|
+
}
|
|
185
|
+
|
|
150
186
|
#findOrCreate<T = Container>(layer: Layer) {
|
|
151
187
|
const object = this.#activeObjects.get(layer.id)
|
|
152
188
|
if(!object) {
|
|
@@ -159,15 +195,18 @@ export class Compositor {
|
|
|
159
195
|
text.eventMode = "static"
|
|
160
196
|
const down = (event: FederatedPointerEvent) => this.onPointerDown.publish({event, id: layer.id, object: text})
|
|
161
197
|
const up = (event: FederatedPointerEvent) => this.onPointerUp.publish({event, id: layer.id, object: text})
|
|
198
|
+
const move = (event: FederatedPointerEvent) => this.onPointerUp.publish({event, id: layer.id, object: text})
|
|
162
199
|
|
|
163
200
|
text.on("pointerdown", down)
|
|
164
201
|
text.on("pointerup", up)
|
|
202
|
+
text.on("pointermove", move)
|
|
165
203
|
|
|
166
204
|
return this.#activeObjects
|
|
167
205
|
.set(layer.id, {
|
|
168
206
|
sprite: text,
|
|
169
207
|
dispose: () => {
|
|
170
208
|
this.onDispose.publish({id: layer.id, object: text})
|
|
209
|
+
text.off("pointermove", move)
|
|
171
210
|
text.off("pointerdown", down)
|
|
172
211
|
text.off("pointerup", up)
|
|
173
212
|
}
|
|
@@ -179,8 +218,10 @@ export class Compositor {
|
|
|
179
218
|
sprite.eventMode = "static"
|
|
180
219
|
const down = (event: FederatedPointerEvent) => this.onPointerDown.publish({event, id: layer.id, object: sprite})
|
|
181
220
|
const up = (event: FederatedPointerEvent) => this.onPointerUp.publish({event, id: layer.id, object: sprite})
|
|
221
|
+
const move = (event: FederatedPointerEvent) => this.onPointerUp.publish({event, id: layer.id, object: sprite})
|
|
182
222
|
|
|
183
223
|
sprite.on("pointerdown", down)
|
|
224
|
+
sprite.on("pointermove", move)
|
|
184
225
|
sprite.on("pointerup", up)
|
|
185
226
|
|
|
186
227
|
return this.#activeObjects
|
|
@@ -189,6 +230,7 @@ export class Compositor {
|
|
|
189
230
|
dispose: () => {
|
|
190
231
|
this.onDispose.publish({id: layer.id, object: sprite})
|
|
191
232
|
sprite.off("pointerdown", down)
|
|
233
|
+
sprite.off("pointermove", move)
|
|
192
234
|
sprite.off("pointerup", up)
|
|
193
235
|
}
|
|
194
236
|
})
|
|
@@ -222,4 +264,3 @@ export class Compositor {
|
|
|
222
264
|
}
|
|
223
265
|
}
|
|
224
266
|
}
|
|
225
|
-
|
package/s/timeline/parts/item.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {Id, Hash} from "./basics.js"
|
|
|
5
5
|
import {Transform} from "../types.js"
|
|
6
6
|
import {Ms} from "../../units/ms.js"
|
|
7
7
|
|
|
8
|
+
export type Crop = [top: number, right: number, bottom: number, left: number]
|
|
9
|
+
|
|
8
10
|
export enum Kind {
|
|
9
11
|
Sequence,
|
|
10
12
|
Stack,
|
|
@@ -32,6 +34,7 @@ export namespace Item {
|
|
|
32
34
|
id: Id
|
|
33
35
|
kind: Kind.Spatial
|
|
34
36
|
transform: Transform
|
|
37
|
+
crop?: Crop
|
|
35
38
|
enabled: boolean
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -13,6 +13,9 @@ export async function sampleVisual(
|
|
|
13
13
|
ancestors: ContainerItem[]
|
|
14
14
|
): Promise<Layer[]> {
|
|
15
15
|
const matrix = computeWorldMatrix(ctx.items, ancestors, item)
|
|
16
|
+
const crop = "spatialId" in item && item.spatialId
|
|
17
|
+
? (ctx.items.get(item.spatialId) as Item.Spatial | undefined)?.crop
|
|
18
|
+
: undefined
|
|
16
19
|
|
|
17
20
|
switch (item.kind) {
|
|
18
21
|
case Kind.Stack: {
|
|
@@ -35,7 +38,7 @@ export async function sampleVisual(
|
|
|
35
38
|
if (time < 0 || time >= item.duration) return []
|
|
36
39
|
|
|
37
40
|
const frame = await ctx.videoSampler(item, time)
|
|
38
|
-
return frame ? [{kind: "image", frame, matrix, id: item.id}] : []
|
|
41
|
+
return frame ? [{kind: "image", frame, matrix, crop, id: item.id}] : []
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
case Kind.Text: {
|
|
@@ -45,7 +48,7 @@ export async function sampleVisual(
|
|
|
45
48
|
? (ctx.items.get(item.styleId) as Item.TextStyle)?.style
|
|
46
49
|
: undefined
|
|
47
50
|
|
|
48
|
-
return [{id: item.id, kind: "text", content: item.content, style, matrix}]
|
|
51
|
+
return [{id: item.id, kind: "text", content: item.content, style, matrix, crop}]
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
case Kind.Gap: {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {TextStyleOptions} from "pixi.js"
|
|
3
3
|
|
|
4
4
|
import {O} from "./o.js"
|
|
5
|
-
import {Item} from "../parts/item.js"
|
|
6
5
|
import {Transform} from "../types.js"
|
|
7
6
|
import {Media} from "../parts/media.js"
|
|
7
|
+
import {Crop, Item} from "../parts/item.js"
|
|
8
8
|
import {TimelineFile} from "../parts/basics.js"
|
|
9
9
|
|
|
10
10
|
type Build<T extends Item.Any = Item.Any> = (o: O) => T
|
|
@@ -69,8 +69,8 @@ export function gap(duration: number): Build<Item.Gap> {
|
|
|
69
69
|
return o => o.gap(duration)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function spatial(transform
|
|
73
|
-
return o => o.spatial(transform)
|
|
72
|
+
export function spatial(transform?: Transform, crop?: Crop): Build<Item.Spatial> {
|
|
73
|
+
return o => o.spatial(transform, crop)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export function textStyle(style: TextStyleOptions): Build<Item.TextStyle> {
|
package/s/timeline/sugar/o.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {TextStyleOptions} from "pixi.js"
|
|
|
3
3
|
|
|
4
4
|
import {Media} from "../parts/media.js"
|
|
5
5
|
import {Id, TimelineFile} from "../parts/basics.js"
|
|
6
|
-
import {Effect, Item, Kind} from "../parts/item.js"
|
|
6
|
+
import {Crop, Effect, Item, Kind} from "../parts/item.js"
|
|
7
7
|
import {Transform, TransformOptions, Vec2} from "../types.js"
|
|
8
8
|
|
|
9
9
|
export class O {
|
|
@@ -45,11 +45,12 @@ export class O {
|
|
|
45
45
|
return item
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
spatial = (transform
|
|
48
|
+
spatial = (transform?: Transform, crop?: Crop): Item.Spatial => {
|
|
49
49
|
const item: Item.Spatial = {
|
|
50
50
|
id: this.getId(),
|
|
51
51
|
kind: Kind.Spatial,
|
|
52
|
-
transform,
|
|
52
|
+
transform: transform ?? this.transform(),
|
|
53
|
+
crop,
|
|
53
54
|
enabled: true
|
|
54
55
|
}
|
|
55
56
|
this.register(item)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,b as o,c as m,d as p,e}from"./chunk-OTQK6FAJ.js";import"./chunk-
|
|
2
|
-
//# sourceMappingURL=browserAll-
|
|
1
|
+
import{a as i,b as o,c as m,d as p,e}from"./chunk-OTQK6FAJ.js";import"./chunk-D5CIWPNS.js";import"./chunk-MWCIWPRL.js";import"./chunk-A45M2HJC.js";import{O as t,e as r}from"./chunk-WFT3KTZG.js";r.add(i);r.mixin(t,o);r.add(m);r.mixin(t,p);r.add(e);
|
|
2
|
+
//# sourceMappingURL=browserAll-LRGVU2GN.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,b as r,d as o,e,f as m,g as s,h as p,i as d,m as n,
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i,b as r,d as o,e,f as m,g as s,h as p,i as d,m as n,o as a,p as f,q as c,r as x,s as P,t as u,u as l}from"./chunk-MWCIWPRL.js";import{e as t}from"./chunk-WFT3KTZG.js";t.add(i);t.add(r);t.add(e);t.add(o);t.add(m);t.add(s);t.add(p);t.add(n);t.add(d);t.add(a);t.add(c);t.add(f);t.add(x);t.add(P);t.add(l);t.add(u);
|
|
2
|
+
//# sourceMappingURL=chunk-D5CIWPNS.js.map
|
|
@@ -378,7 +378,7 @@ fn mainFragment(
|
|
|
378
378
|
) -> @location(0) vec4<f32> {
|
|
379
379
|
return textureSample(uTexture, uSampler, uv);
|
|
380
380
|
}
|
|
381
|
-
`;var Ze=class extends Es{constructor(){let t=pe.from({vertex:{source:ns,entryPoint:"mainVertex"},fragment:{source:ns,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=fe.from({vertex:Pn,fragment:vn,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}};var Cn=new G;function Mn(n,t){t.clear();let e=t.matrix;for(let r=0;r<n.length;r++){let s=n[r];if(s.globalDisplayStatus<7)continue;let i=s.renderGroup??s.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Cn.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Cn.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=e,t}var Bo=new Gt({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),os=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},as=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new J({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new de({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let i=e.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(r.every(d=>!d.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;let h=this._getPreviousFilterData(),c=this._findFilterResolution(o),u=0,f=0;h&&(u=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(s,u,f,c,i.width,i.height),this._setupFilterTextures(s,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let s=t.source,i=s.resolution,o=s.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,i,0),r.skip)return t;let l=i;this._calculateGlobalFrame(r,0,0,l,s.width,s.height),r.outputRenderSurface=q.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&q.returnTexture(e.backTexture),q.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,i=q.getOptimalTexture(e.width,e.height,s,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:o,y:a},{width:l,height:h},{x:0,y:0}),i}applyFilter(t,e,r,s){let i=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h),u=0,f=0;if(l){let p=this._findPreviousFilterOffset();u=p.x,f=p.y}this._updateFilterUniforms(e,r,o,u,f,c,l,s);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,i)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Ze),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Bo,shader:t,state:t._state,topology:"triangle-list"}),r.type===It.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=E.EMPTY,t.inputTexture=q.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,o){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(t,e,r,s,i,o,a,l){let h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,p=h.uGlobalFrame,m=h.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let x=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=x.source.width*o,p[3]=x.source.height*o,e instanceof E&&(e.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof E?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Mn(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,i=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)i[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=q.getOptimalTexture(s.width,s.height,l.source._resolution,!1),c=h;for(let u=o;u<a;u++){let f=i[u];if(!f.enabled)continue;f.apply(this,l,c,!0);let d=l;l=c,c=d}i[a].apply(this,l,t.outputRenderSurface,e),q.returnTexture(h)}}_calculateFilterBounds(t,e,r,s,i){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,c=0,u=!0,f=!1,d=!1,p=!0,m=-1,x=-1;for(let g=0;g<l.length;g++){let _=l[g];if(!_.enabled)continue;if(m===-1&&(m=g),x=g,h=Math.min(h,_.resolution==="inherit"?s:_.resolution),c+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=r),_.clipToViewport||(p=!1),!!!(_.compatibleRenderers&o.type)){d=!1;break}if(_.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=_.blendRequired)}if(!d){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(h).ceil().scale(1/h).pad((c|0)*i),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=m,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new os),this._filterStackIndex++,t}};as.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"filter"};export{ur as a,dr as b,ot as c,ve as d,Sr as e,Tr as f,vr as g,Cr as h,Mr as i,dt as j,Y as k,Oe as l,Or as m,
|
|
381
|
+
`;var Ze=class extends Es{constructor(){let t=pe.from({vertex:{source:ns,entryPoint:"mainVertex"},fragment:{source:ns,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=fe.from({vertex:Pn,fragment:vn,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}};var Cn=new G;function Mn(n,t){t.clear();let e=t.matrix;for(let r=0;r<n.length;r++){let s=n[r];if(s.globalDisplayStatus<7)continue;let i=s.renderGroup??s.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Cn.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Cn.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=e,t}var Bo=new Gt({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),os=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},as=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new J({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new de({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let i=e.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(r.every(d=>!d.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;let h=this._getPreviousFilterData(),c=this._findFilterResolution(o),u=0,f=0;h&&(u=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(s,u,f,c,i.width,i.height),this._setupFilterTextures(s,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let s=t.source,i=s.resolution,o=s.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,i,0),r.skip)return t;let l=i;this._calculateGlobalFrame(r,0,0,l,s.width,s.height),r.outputRenderSurface=q.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&q.returnTexture(e.backTexture),q.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,i=q.getOptimalTexture(e.width,e.height,s,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:o,y:a},{width:l,height:h},{x:0,y:0}),i}applyFilter(t,e,r,s){let i=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h),u=0,f=0;if(l){let p=this._findPreviousFilterOffset();u=p.x,f=p.y}this._updateFilterUniforms(e,r,o,u,f,c,l,s);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,i)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Ze),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Bo,shader:t,state:t._state,topology:"triangle-list"}),r.type===It.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=E.EMPTY,t.inputTexture=q.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,o){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(t,e,r,s,i,o,a,l){let h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,p=h.uGlobalFrame,m=h.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let x=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=x.source.width*o,p[3]=x.source.height*o,e instanceof E&&(e.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof E?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Mn(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,i=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)i[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=q.getOptimalTexture(s.width,s.height,l.source._resolution,!1),c=h;for(let u=o;u<a;u++){let f=i[u];if(!f.enabled)continue;f.apply(this,l,c,!0);let d=l;l=c,c=d}i[a].apply(this,l,t.outputRenderSurface,e),q.returnTexture(h)}}_calculateFilterBounds(t,e,r,s,i){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,c=0,u=!0,f=!1,d=!1,p=!0,m=-1,x=-1;for(let g=0;g<l.length;g++){let _=l[g];if(!_.enabled)continue;if(m===-1&&(m=g),x=g,h=Math.min(h,_.resolution==="inherit"?s:_.resolution),c+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=r),_.clipToViewport||(p=!1),!!!(_.compatibleRenderers&o.type)){d=!1;break}if(_.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=_.blendRequired)}if(!d){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(h).ceil().scale(1/h).pad((c|0)*i),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=m,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new os),this._filterStackIndex++,t}};as.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"filter"};export{ur as a,dr as b,ot as c,ve as d,Sr as e,Tr as f,vr as g,Cr as h,Mr as i,dt as j,Y as k,Oe as l,Or as m,Ve as n,Yr as o,Xr as p,Qr as q,es as r,ss as s,is as t,as as u};
|
|
382
382
|
/*! Bundled license information:
|
|
383
383
|
|
|
384
384
|
tiny-lru/dist/tiny-lru.js:
|
|
@@ -390,4 +390,4 @@ tiny-lru/dist/tiny-lru.js:
|
|
|
390
390
|
* @version 11.4.5
|
|
391
391
|
*)
|
|
392
392
|
*/
|
|
393
|
-
//# sourceMappingURL=chunk-
|
|
393
|
+
//# sourceMappingURL=chunk-MWCIWPRL.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,b as o,c as m,d as p,e}from"./chunk-T3METYEY.js";import"./chunk-
|
|
2
|
-
//# sourceMappingURL=browserAll-
|
|
1
|
+
import{a as i,b as o,c as m,d as p,e}from"./chunk-T3METYEY.js";import"./chunk-IRDQEA6B.js";import"./chunk-RWJ2UHV4.js";import"./chunk-USLRKDKD.js";import{N as t,d as r}from"./chunk-PYG4RZZ2.js";r.add(i);r.mixin(t,o);r.add(m);r.mixin(t,p);r.add(e);
|
|
2
|
+
//# sourceMappingURL=browserAll-QEV2P3ED.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i,b as r,d as o,e,f as m,g as s,h as p,i as d,m as n,
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i,b as r,d as o,e,f as m,g as s,h as p,i as d,m as n,o as a,p as f,q as c,r as x,s as P,t as u,u as l}from"./chunk-RWJ2UHV4.js";import{d as t}from"./chunk-PYG4RZZ2.js";t.add(i);t.add(r);t.add(e);t.add(o);t.add(m);t.add(s);t.add(p);t.add(n);t.add(d);t.add(a);t.add(c);t.add(f);t.add(x);t.add(P);t.add(l);t.add(u);
|
|
2
|
+
//# sourceMappingURL=chunk-IRDQEA6B.js.map
|
|
@@ -378,7 +378,7 @@ fn mainFragment(
|
|
|
378
378
|
) -> @location(0) vec4<f32> {
|
|
379
379
|
return textureSample(uTexture, uSampler, uv);
|
|
380
380
|
}
|
|
381
|
-
`;var Ze=class extends Es{constructor(){let t=pe.from({vertex:{source:ns,entryPoint:"mainVertex"},fragment:{source:ns,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=fe.from({vertex:Pn,fragment:vn,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}};var Cn=new G;function Mn(n,t){t.clear();let e=t.matrix;for(let r=0;r<n.length;r++){let s=n[r];if(s.globalDisplayStatus<7)continue;let i=s.renderGroup??s.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Cn.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Cn.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=e,t}var Bo=new Gt({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),os=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},as=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new J({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new de({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let i=e.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(r.every(d=>!d.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;let h=this._getPreviousFilterData(),c=this._findFilterResolution(o),u=0,f=0;h&&(u=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(s,u,f,c,i.width,i.height),this._setupFilterTextures(s,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let s=t.source,i=s.resolution,o=s.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,i,0),r.skip)return t;let l=i;this._calculateGlobalFrame(r,0,0,l,s.width,s.height),r.outputRenderSurface=q.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&q.returnTexture(e.backTexture),q.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,i=q.getOptimalTexture(e.width,e.height,s,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:o,y:a},{width:l,height:h},{x:0,y:0}),i}applyFilter(t,e,r,s){let i=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h),u=0,f=0;if(l){let p=this._findPreviousFilterOffset();u=p.x,f=p.y}this._updateFilterUniforms(e,r,o,u,f,c,l,s);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,i)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Ze),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Bo,shader:t,state:t._state,topology:"triangle-list"}),r.type===It.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=E.EMPTY,t.inputTexture=q.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,o){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(t,e,r,s,i,o,a,l){let h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,p=h.uGlobalFrame,m=h.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let x=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=x.source.width*o,p[3]=x.source.height*o,e instanceof E&&(e.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof E?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Mn(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,i=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)i[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=q.getOptimalTexture(s.width,s.height,l.source._resolution,!1),c=h;for(let u=o;u<a;u++){let f=i[u];if(!f.enabled)continue;f.apply(this,l,c,!0);let d=l;l=c,c=d}i[a].apply(this,l,t.outputRenderSurface,e),q.returnTexture(h)}}_calculateFilterBounds(t,e,r,s,i){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,c=0,u=!0,f=!1,d=!1,p=!0,m=-1,x=-1;for(let g=0;g<l.length;g++){let _=l[g];if(!_.enabled)continue;if(m===-1&&(m=g),x=g,h=Math.min(h,_.resolution==="inherit"?s:_.resolution),c+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=r),_.clipToViewport||(p=!1),!!!(_.compatibleRenderers&o.type)){d=!1;break}if(_.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=_.blendRequired)}if(!d){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(h).ceil().scale(1/h).pad((c|0)*i),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=m,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new os),this._filterStackIndex++,t}};as.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"filter"};export{ur as a,dr as b,ot as c,ve as d,Sr as e,Tr as f,vr as g,Cr as h,Mr as i,dt as j,Y as k,Oe as l,Or as m,
|
|
381
|
+
`;var Ze=class extends Es{constructor(){let t=pe.from({vertex:{source:ns,entryPoint:"mainVertex"},fragment:{source:ns,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=fe.from({vertex:Pn,fragment:vn,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}};var Cn=new G;function Mn(n,t){t.clear();let e=t.matrix;for(let r=0;r<n.length;r++){let s=n[r];if(s.globalDisplayStatus<7)continue;let i=s.renderGroup??s.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Cn.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Cn.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=e,t}var Bo=new Gt({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),os=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},as=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new J({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new de({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let i=e.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(r.every(d=>!d.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;let h=this._getPreviousFilterData(),c=this._findFilterResolution(o),u=0,f=0;h&&(u=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(s,u,f,c,i.width,i.height),this._setupFilterTextures(s,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let s=t.source,i=s.resolution,o=s.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,i,0),r.skip)return t;let l=i;this._calculateGlobalFrame(r,0,0,l,s.width,s.height),r.outputRenderSurface=q.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&q.returnTexture(e.backTexture),q.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,i=q.getOptimalTexture(e.width,e.height,s,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:o,y:a},{width:l,height:h},{x:0,y:0}),i}applyFilter(t,e,r,s){let i=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h),u=0,f=0;if(l){let p=this._findPreviousFilterOffset();u=p.x,f=p.y}this._updateFilterUniforms(e,r,o,u,f,c,l,s);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,i)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Ze),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Bo,shader:t,state:t._state,topology:"triangle-list"}),r.type===It.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=E.EMPTY,t.inputTexture=q.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,o){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(t,e,r,s,i,o,a,l){let h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,p=h.uGlobalFrame,m=h.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let x=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=x.source.width*o,p[3]=x.source.height*o,e instanceof E&&(e.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof E?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Mn(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,i=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)i[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=q.getOptimalTexture(s.width,s.height,l.source._resolution,!1),c=h;for(let u=o;u<a;u++){let f=i[u];if(!f.enabled)continue;f.apply(this,l,c,!0);let d=l;l=c,c=d}i[a].apply(this,l,t.outputRenderSurface,e),q.returnTexture(h)}}_calculateFilterBounds(t,e,r,s,i){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,c=0,u=!0,f=!1,d=!1,p=!0,m=-1,x=-1;for(let g=0;g<l.length;g++){let _=l[g];if(!_.enabled)continue;if(m===-1&&(m=g),x=g,h=Math.min(h,_.resolution==="inherit"?s:_.resolution),c+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=r),_.clipToViewport||(p=!1),!!!(_.compatibleRenderers&o.type)){d=!1;break}if(_.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=_.blendRequired)}if(!d){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(h).ceil().scale(1/h).pad((c|0)*i),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=m,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new os),this._filterStackIndex++,t}};as.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"filter"};export{ur as a,dr as b,ot as c,ve as d,Sr as e,Tr as f,vr as g,Cr as h,Mr as i,dt as j,Y as k,Oe as l,Or as m,Ve as n,Yr as o,Xr as p,Qr as q,es as r,ss as s,is as t,as as u};
|
|
382
382
|
/*! Bundled license information:
|
|
383
383
|
|
|
384
384
|
tiny-lru/dist/tiny-lru.js:
|
|
@@ -390,4 +390,4 @@ tiny-lru/dist/tiny-lru.js:
|
|
|
390
390
|
* @version 11.4.5
|
|
391
391
|
*)
|
|
392
392
|
*/
|
|
393
|
-
//# sourceMappingURL=chunk-
|
|
393
|
+
//# sourceMappingURL=chunk-RWJ2UHV4.js.map
|