@vvfx/sdk 0.2.8 → 0.2.10
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/config.js +231 -0
- package/dist/exporter/config.js +18 -0
- package/dist/exporter/const.js +71 -0
- package/dist/exporter/export-media.js +878 -0
- package/dist/exporter/exporter.js +121 -0
- package/dist/exporter/index.js +1 -0
- package/dist/exporter/types.js +1 -0
- package/dist/exporter/utils.js +190 -0
- package/dist/exporter/wav-audio.js +50 -0
- package/dist/gesture-handler/gizmo/adsorption-gizmo.js +227 -0
- package/dist/gesture-handler/gizmo/control-gizmo.js +149 -0
- package/dist/gesture-handler/gizmo/gizmo.js +17 -0
- package/dist/gesture-handler/gizmo/icon-gizmo.js +189 -0
- package/dist/gesture-handler/gizmo/index.js +6 -0
- package/dist/gesture-handler/gizmo/item-create-gizmo.js +256 -0
- package/dist/gesture-handler/gizmo/loading-gizmo.js +320 -0
- package/dist/gesture-handler/gizmo/mask-gizmo.js +648 -0
- package/dist/gesture-handler/gizmo/picture-cut-gizmo.js +550 -0
- package/dist/gesture-handler/gizmo/picture-expand-gizmo.js +491 -0
- package/dist/gesture-handler/gizmo/preference-gizmo.js +148 -0
- package/dist/gesture-handler/gizmo/selector-gizmo.d.ts +1 -1
- package/dist/gesture-handler/gizmo/selector-gizmo.js +468 -0
- package/dist/gesture-handler/gizmo/sprite-text-edit-gizmo.js +247 -0
- package/dist/gesture-handler/gizmo/text-gizmo.js +1033 -0
- package/dist/gesture-handler/gizmo/transform-gizmo.js +1199 -0
- package/dist/gesture-handler/gizmo/type.js +18 -0
- package/dist/gesture-handler/index.js +3 -0
- package/dist/gesture-handler/src/gesture-handler.js +770 -0
- package/dist/gesture-handler/src/icons.js +24 -0
- package/dist/gesture-handler/utils.js +40 -0
- package/dist/html-overlay/anchor-navigation-runtime.js +27 -0
- package/dist/html-overlay/auto-height-layout.d.ts +6 -0
- package/dist/html-overlay/auto-height-layout.js +7 -0
- package/dist/html-overlay/auto-height-runtime.js +132 -0
- package/dist/html-overlay/document-runtime.js +71 -0
- package/dist/html-overlay/document-transform.js +96 -0
- package/dist/html-overlay/dom-order.js +8 -0
- package/dist/html-overlay/host-message-runtime.js +24 -0
- package/dist/html-overlay/html-capture-runtime.js +282 -0
- package/dist/html-overlay/html-viewport-style.js +10 -0
- package/dist/html-overlay/index.js +1 -0
- package/dist/html-overlay/manager.d.ts +1 -0
- package/dist/html-overlay/manager.js +1677 -0
- package/dist/html-overlay/mime-utils.js +21 -0
- package/dist/html-overlay/overlay-transform.js +57 -0
- package/dist/html-overlay/path-utils.js +35 -0
- package/dist/html-overlay/shell-runtime.js +12 -0
- package/dist/index.cjs +34 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -75311
- package/dist/index.mjs +75337 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layer-order.js +8 -0
- package/dist/math/box2.js +396 -0
- package/dist/math/circle.js +131 -0
- package/dist/math/euler.js +35 -0
- package/dist/math/index.js +13 -0
- package/dist/math/line2.js +153 -0
- package/dist/math/line3.js +36 -0
- package/dist/math/matrix4.js +207 -0
- package/dist/math/plane.js +52 -0
- package/dist/math/quaternion.js +3 -0
- package/dist/math/ray-caster.js +25 -0
- package/dist/math/ray.js +47 -0
- package/dist/math/type.js +1 -0
- package/dist/math/utils.js +77 -0
- package/dist/math/vector2.js +70 -0
- package/dist/math/vector3.js +60 -0
- package/dist/screen-shot/index.js +1 -0
- package/dist/screen-shot/screen-shot.js +113 -0
- package/dist/sdk-item/base-item.js +160 -0
- package/dist/sdk-item/card-item.js +131 -0
- package/dist/sdk-item/effects-item.js +144 -0
- package/dist/sdk-item/frame-item.js +217 -0
- package/dist/sdk-item/generator-item.js +188 -0
- package/dist/sdk-item/group-item.js +116 -0
- package/dist/sdk-item/index.js +39 -0
- package/dist/sdk-item/sprite-item.js +147 -0
- package/dist/sdk-item/text-item.js +223 -0
- package/dist/sdk-item/types.d.ts +1 -1
- package/dist/sdk-item/types.js +15 -0
- package/dist/sdk-item/video-item.js +174 -0
- package/dist/sdk.js +1908 -0
- package/dist/service/UndoRedo.js +79 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/player.d.ts +1 -1
- package/dist/shared/player.js +9 -0
- package/dist/shared/spec.d.ts +1 -0
- package/dist/shared/spec.js +1 -0
- package/dist/size-adapte/index.js +1 -0
- package/dist/size-adapte/size-adapt.js +395 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.js +17 -0
- package/dist/utils/background-manager.js +189 -0
- package/dist/utils/common-utils.js +183 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/interaction-utils.js +205 -0
- package/dist/utils/json-data-utils.js +1529 -0
- package/dist/utils/layout-utils.js +1217 -0
- package/dist/utils/page-data-utils.js +5397 -0
- package/dist/utils/player-data-utils.js +48 -0
- package/dist/utils/types.js +8 -0
- package/dist/wireframe/common/box.js +18 -0
- package/dist/wireframe/common/dashed-line.js +21 -0
- package/dist/wireframe/common/line.js +17 -0
- package/dist/wireframe/common/pixi-ext.js +1 -0
- package/dist/wireframe/common/pixi.js +31 -0
- package/dist/wireframe/index.js +4 -0
- package/package.json +10 -3
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { EffectComponent, Geometry, glContext, Material, spec } from '@galacean/effects';
|
|
2
|
+
import { getBoxByNormalizeBox, getNormalizeBoxByBoxes, Vector2 } from '../../math';
|
|
3
|
+
import { Graphics, Text } from '../../wireframe';
|
|
4
|
+
import { Gizmo } from './gizmo';
|
|
5
|
+
import { VFXItemFactory } from '../../utils';
|
|
6
|
+
import { SDK } from '../../sdk';
|
|
7
|
+
const DEFAULT_LOADING_FRAGMENT = `
|
|
8
|
+
// Shadertoy Fragment Shader
|
|
9
|
+
// Diagonal background gradient + wider colorful transparent shimmer
|
|
10
|
+
|
|
11
|
+
precision highp float;
|
|
12
|
+
|
|
13
|
+
varying vec2 vUV;
|
|
14
|
+
|
|
15
|
+
uniform vec4 _Time;
|
|
16
|
+
|
|
17
|
+
// ------------------------------------------------------------
|
|
18
|
+
// Background
|
|
19
|
+
// ------------------------------------------------------------
|
|
20
|
+
vec3 background(vec2 uv) {
|
|
21
|
+
vec3 topLeft = vec3(0.88, 0.85, 1.00);
|
|
22
|
+
vec3 bottomRight = vec3(0.98, 0.98, 0.98);
|
|
23
|
+
|
|
24
|
+
float d = (uv.x + (1.0 - uv.y)) * 0.5;
|
|
25
|
+
d = smoothstep(0.0, 1.0, d);
|
|
26
|
+
|
|
27
|
+
vec3 col = mix(topLeft, bottomRight, d);
|
|
28
|
+
|
|
29
|
+
vec2 p1 = uv - vec2(1.13, 1.40);
|
|
30
|
+
float r1 = length(p1 / vec2(0.85, 0.85));
|
|
31
|
+
float g1 = 1.0 - smoothstep(0.0, 0.96, r1);
|
|
32
|
+
col += vec3(172.0/255.0, 183.0/255.0, 1.0) * g1 * 0.28;
|
|
33
|
+
|
|
34
|
+
vec2 p2 = uv - vec2(0.25, 0.23);
|
|
35
|
+
float r2 = length(p2 / vec2(0.74, 0.64));
|
|
36
|
+
float g2 = 1.0 - smoothstep(0.0, 1.0, r2);
|
|
37
|
+
col += vec3(147.0/255.0, 108.0/255.0, 1.0) * g2 * 0.10;
|
|
38
|
+
|
|
39
|
+
return col;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ------------------------------------------------------------
|
|
43
|
+
// Easing: slow at start, fast at end
|
|
44
|
+
// ------------------------------------------------------------
|
|
45
|
+
float easeInQuad(float x) {
|
|
46
|
+
return x * x;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ------------------------------------------------------------
|
|
50
|
+
// Color palette helper
|
|
51
|
+
// ------------------------------------------------------------
|
|
52
|
+
vec3 palette(float t) {
|
|
53
|
+
// 柔和的彩色条:蓝 -> 青 -> 紫 -> 粉 -> 蓝
|
|
54
|
+
vec3 a = vec3(0.62, 0.82, 1.00);
|
|
55
|
+
vec3 b = vec3(0.72, 0.95, 1.00);
|
|
56
|
+
vec3 c = vec3(0.83, 0.76, 1.00);
|
|
57
|
+
vec3 d = vec3(1.00, 0.82, 0.95);
|
|
58
|
+
|
|
59
|
+
t = fract(t);
|
|
60
|
+
|
|
61
|
+
if (t < 0.33) {
|
|
62
|
+
float k = smoothstep(0.0, 0.33, t);
|
|
63
|
+
return mix(a, b, k);
|
|
64
|
+
} else if (t < 0.66) {
|
|
65
|
+
float k = smoothstep(0.33, 0.66, t);
|
|
66
|
+
return mix(b, c, k);
|
|
67
|
+
} else {
|
|
68
|
+
float k = smoothstep(0.66, 1.0, t);
|
|
69
|
+
return mix(c, d, k);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ------------------------------------------------------------
|
|
74
|
+
// Wider colorful transparent left-to-right shimmer
|
|
75
|
+
// ------------------------------------------------------------
|
|
76
|
+
vec4 shimmerBand(vec2 uv, float t) {
|
|
77
|
+
float cycle = fract(t * 0.70);
|
|
78
|
+
cycle = easeInQuad(cycle);
|
|
79
|
+
|
|
80
|
+
float x = cycle * 1.55 - 0.25; // sweep from left to right
|
|
81
|
+
|
|
82
|
+
float d = abs(uv.x - x);
|
|
83
|
+
float band = 1.0 - smoothstep(0.0, 0.30, d);
|
|
84
|
+
float core = 1.0 - smoothstep(0.0, 0.10, d);
|
|
85
|
+
|
|
86
|
+
float x2 = x + (uv.y - 0.5) * 0.18;
|
|
87
|
+
float d2 = abs(uv.x - x2);
|
|
88
|
+
float band2 = 1.0 - smoothstep(0.0, 0.20, d2);
|
|
89
|
+
|
|
90
|
+
float s = max(band * 0.85, band2 * 0.60);
|
|
91
|
+
s = max(s, core * 0.95);
|
|
92
|
+
s = clamp(s, 0.0, 1.0);
|
|
93
|
+
|
|
94
|
+
// 颜色沿条带变化,模拟彩色渐变
|
|
95
|
+
float hueT = uv.y * 0.25 + uv.x * 0.60 + t * 0.10;
|
|
96
|
+
vec3 color1 = palette(hueT);
|
|
97
|
+
|
|
98
|
+
// 中间更亮一点,边缘更淡
|
|
99
|
+
vec3 color2 = mix(color1, vec3(1.0), core * 0.35);
|
|
100
|
+
|
|
101
|
+
return vec4(color2, s);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ------------------------------------------------------------
|
|
105
|
+
// Main
|
|
106
|
+
// ------------------------------------------------------------
|
|
107
|
+
void main() {
|
|
108
|
+
vec2 uv = vUV;
|
|
109
|
+
|
|
110
|
+
vec3 col = background(uv);
|
|
111
|
+
|
|
112
|
+
vec4 sh = shimmerBand(uv, _Time.y);
|
|
113
|
+
|
|
114
|
+
// 可选:增加一点柔光感
|
|
115
|
+
col += sh.rgb * sh.a * 0.06;
|
|
116
|
+
|
|
117
|
+
gl_FragColor = vec4(col, 1.0);
|
|
118
|
+
}`;
|
|
119
|
+
export class LoadingGizmo extends Gizmo {
|
|
120
|
+
constructor(utils) {
|
|
121
|
+
super();
|
|
122
|
+
this._pageDataUtils = utils;
|
|
123
|
+
}
|
|
124
|
+
type = 'loading';
|
|
125
|
+
_pageDataUtils;
|
|
126
|
+
_idMap = new Map();
|
|
127
|
+
createLoadingVFXItem(loadingBox) {
|
|
128
|
+
const composition = this._pageDataUtils.player.getCompositions()[0];
|
|
129
|
+
const loadingVFXItem = VFXItemFactory.createVFXItem(composition, null, 'LoadingVFXItem', EffectComponent);
|
|
130
|
+
loadingVFXItem.type = spec.ItemType.effect;
|
|
131
|
+
const effects = loadingVFXItem.getComponent(EffectComponent);
|
|
132
|
+
const engine = this._pageDataUtils.player.engine;
|
|
133
|
+
const geometry = Geometry.create(engine, {
|
|
134
|
+
attributes: {
|
|
135
|
+
aPos: {
|
|
136
|
+
size: 3,
|
|
137
|
+
data: new Float32Array([
|
|
138
|
+
-0.5, -0.5, 0,
|
|
139
|
+
0.5, -0.5, 0,
|
|
140
|
+
0.5, 0.5, 0,
|
|
141
|
+
-0.5, 0.5, 0,
|
|
142
|
+
]),
|
|
143
|
+
},
|
|
144
|
+
aUV: {
|
|
145
|
+
size: 2,
|
|
146
|
+
data: new Float32Array([
|
|
147
|
+
0, 0,
|
|
148
|
+
1, 0,
|
|
149
|
+
1, 1,
|
|
150
|
+
0, 1,
|
|
151
|
+
]),
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
indices: { data: new Uint16Array([0, 1, 2, 0, 2, 3]) },
|
|
155
|
+
mode: glContext.TRIANGLES,
|
|
156
|
+
drawCount: 6,
|
|
157
|
+
});
|
|
158
|
+
const material = Material.create(engine, {
|
|
159
|
+
shader: {
|
|
160
|
+
vertex: `
|
|
161
|
+
precision highp float;
|
|
162
|
+
attribute vec3 aPos;
|
|
163
|
+
attribute vec2 aUV;
|
|
164
|
+
uniform mat4 effects_MatrixVP;
|
|
165
|
+
uniform mat4 effects_ObjectToWorld;
|
|
166
|
+
varying vec2 vUV;
|
|
167
|
+
void main() {
|
|
168
|
+
vUV = aUV;
|
|
169
|
+
gl_Position = effects_MatrixVP * effects_ObjectToWorld * vec4(aPos, 1.0);
|
|
170
|
+
}`,
|
|
171
|
+
fragment: SDK.config.gestureHandlerConfig.loadingGizmoConfig?.loadingFragment ?? DEFAULT_LOADING_FRAGMENT,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
// @ts-expect-error 强制设置元素geometry
|
|
175
|
+
effects.geometry = geometry;
|
|
176
|
+
effects.material = material;
|
|
177
|
+
// 坐标转换
|
|
178
|
+
const viewBox = this._pageDataUtils.getViewBoxByBox(loadingBox);
|
|
179
|
+
const viewPosition = new Vector2((viewBox.max.x + viewBox.min.x) / 2, (viewBox.max.y + viewBox.min.y) / 2);
|
|
180
|
+
const worldPosition = this._pageDataUtils.interactionUtils.getWorldPositionByViewPoint(viewPosition);
|
|
181
|
+
const viewSize = new Vector2(viewBox.max.x - viewBox.min.x, viewBox.max.y - viewBox.min.y);
|
|
182
|
+
const pixelSize = this._pageDataUtils.interactionUtils.getPixelSizeByViewSize(viewSize);
|
|
183
|
+
const worldSize = this._pageDataUtils.getWorldSizeByPixelSize([pixelSize.x, pixelSize.y]);
|
|
184
|
+
loadingVFXItem.transform.setPosition(worldPosition.x, worldPosition.y, 0);
|
|
185
|
+
loadingVFXItem.transform.setScale(worldSize[0], worldSize[1], 1);
|
|
186
|
+
return loadingVFXItem;
|
|
187
|
+
}
|
|
188
|
+
add(id, options) {
|
|
189
|
+
const itemBox = this._pageDataUtils.getItemBoxById(id);
|
|
190
|
+
const currentBox = (options?.loadingBox ?? itemBox);
|
|
191
|
+
const normalizeLoadingBox = getNormalizeBoxByBoxes(itemBox, currentBox);
|
|
192
|
+
if (typeof id === 'string') {
|
|
193
|
+
const { tip = { text: '' } } = options ?? {};
|
|
194
|
+
const _tip = {
|
|
195
|
+
text: tip.text ?? '',
|
|
196
|
+
fontFamily: tip.fontFamily ?? '',
|
|
197
|
+
color: tip.color ?? 0x000000,
|
|
198
|
+
fontSize: tip.fontSize ?? 16,
|
|
199
|
+
};
|
|
200
|
+
const text = new Text(_tip.text, {
|
|
201
|
+
fontSize: _tip.fontSize,
|
|
202
|
+
fontFamily: _tip.fontFamily,
|
|
203
|
+
fill: _tip.color,
|
|
204
|
+
align: 'center',
|
|
205
|
+
});
|
|
206
|
+
const graphics = new Graphics();
|
|
207
|
+
graphics.addChild(text);
|
|
208
|
+
this._idMap.set(id, {
|
|
209
|
+
status: 'init',
|
|
210
|
+
loadingBox: normalizeLoadingBox,
|
|
211
|
+
loadingVFXItem: this.createLoadingVFXItem(currentBox),
|
|
212
|
+
graphics,
|
|
213
|
+
tip: _tip,
|
|
214
|
+
});
|
|
215
|
+
this._pageDataUtils.addLoadingItems([id]);
|
|
216
|
+
if (options?.clearSelected) {
|
|
217
|
+
this._pageDataUtils.removeSelectedItems([id]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
delete(id) {
|
|
222
|
+
const loadingItem = this._idMap.get(id);
|
|
223
|
+
if (loadingItem) {
|
|
224
|
+
const { graphics, loadingVFXItem } = loadingItem;
|
|
225
|
+
graphics.destroy();
|
|
226
|
+
loadingVFXItem.dispose();
|
|
227
|
+
this._idMap.delete(id);
|
|
228
|
+
this._pageDataUtils.removeLoadingItems([id]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 更新指定 loading 元素的提示文案
|
|
233
|
+
*/
|
|
234
|
+
update(id, options) {
|
|
235
|
+
const loadingItem = this._idMap.get(id);
|
|
236
|
+
if (!loadingItem) {
|
|
237
|
+
console.warn(`Loading item ${id} not found.`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const text = loadingItem.graphics.children[0];
|
|
241
|
+
// 更新存储的 tip 配置
|
|
242
|
+
if (text) {
|
|
243
|
+
loadingItem.tip = {
|
|
244
|
+
...loadingItem.tip,
|
|
245
|
+
...options.tip,
|
|
246
|
+
};
|
|
247
|
+
text.text = loadingItem.tip.text;
|
|
248
|
+
if (loadingItem.tip.fontFamily) {
|
|
249
|
+
text.style.fontFamily = loadingItem.tip.fontFamily;
|
|
250
|
+
}
|
|
251
|
+
if (loadingItem.tip.color !== undefined) {
|
|
252
|
+
text.style.fill = loadingItem.tip.color;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// 鼠标状态绘制结果
|
|
257
|
+
cursorResult = {
|
|
258
|
+
type: 'normal',
|
|
259
|
+
angle: 0,
|
|
260
|
+
};
|
|
261
|
+
initialize() { }
|
|
262
|
+
preparationAction() {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
preAction() {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
action() { }
|
|
269
|
+
endAction() {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
interruption() {
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
actionKey() { }
|
|
276
|
+
endActionKey() { }
|
|
277
|
+
cancelPreparation() { }
|
|
278
|
+
refreshResults() { }
|
|
279
|
+
getRenderObjects() {
|
|
280
|
+
if (this._idMap.size === 0) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
return this.refreshRenderObjects();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
refreshRenderObjects() {
|
|
288
|
+
if (this._idMap.size === 0) {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
const renderList = [];
|
|
292
|
+
// 绘制 Loading 蒙版
|
|
293
|
+
for (const id of this._idMap.keys()) {
|
|
294
|
+
const loadingItem = this._idMap.get(id);
|
|
295
|
+
if (!loadingItem) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const itemBox = this._pageDataUtils.getViewBoxById(id);
|
|
299
|
+
const { min, max } = getBoxByNormalizeBox(itemBox, loadingItem.loadingBox);
|
|
300
|
+
const width = max.x - min.x;
|
|
301
|
+
const height = max.y - min.y;
|
|
302
|
+
// 更新提示文本位置(居中显示在 Loading 区域内)并跟随画布缩放
|
|
303
|
+
if (loadingItem.tip?.text) {
|
|
304
|
+
// 基础字体大小
|
|
305
|
+
const baseFontSize = loadingItem.tip.fontSize;
|
|
306
|
+
const text = loadingItem.graphics.children[0];
|
|
307
|
+
if (text) {
|
|
308
|
+
text.style.fontWeight = 'bold';
|
|
309
|
+
// 按图片尺寸缩放文本
|
|
310
|
+
text.style.fontSize = Math.min(width / loadingItem.tip.text.length * 0.5, baseFontSize);
|
|
311
|
+
// 计算居中位置
|
|
312
|
+
text.x = min.x + (width - text.width) / 2;
|
|
313
|
+
text.y = min.y + (height - text.height) / 2;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
renderList.push(loadingItem.graphics);
|
|
317
|
+
}
|
|
318
|
+
return renderList;
|
|
319
|
+
}
|
|
320
|
+
}
|