@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,247 @@
|
|
|
1
|
+
import { Graphics, Text } from '../../wireframe';
|
|
2
|
+
import { Gizmo } from './gizmo';
|
|
3
|
+
import { Box2, getBoxByNormalizeBox, getNormalizeBoxByBoxes, RAD2DEG, Vector2 } from '../../math';
|
|
4
|
+
import { SDK } from '../../sdk';
|
|
5
|
+
import { processText } from '../utils';
|
|
6
|
+
const defuleTextStyle = {
|
|
7
|
+
fontSize: 14,
|
|
8
|
+
fill: 0xFFFFFF,
|
|
9
|
+
align: 'center',
|
|
10
|
+
lineHeight: 16,
|
|
11
|
+
};
|
|
12
|
+
export class SpriteTextEditGizmo extends Gizmo {
|
|
13
|
+
type = 'sprite-text-edit';
|
|
14
|
+
_pageDataUtils;
|
|
15
|
+
_eventEmitter;
|
|
16
|
+
graphics = new Graphics();
|
|
17
|
+
editGraphics = new Graphics();
|
|
18
|
+
preSelectedText = new Text('', defuleTextStyle);
|
|
19
|
+
result = [];
|
|
20
|
+
interactionParam = { preSelected: -1, selected: -1 };
|
|
21
|
+
clearPreSelected = false;
|
|
22
|
+
constructor(pageDataUtils, emitter) {
|
|
23
|
+
super();
|
|
24
|
+
this._pageDataUtils = pageDataUtils;
|
|
25
|
+
this._eventEmitter = emitter;
|
|
26
|
+
this.preSelectedText.resolution = 3;
|
|
27
|
+
}
|
|
28
|
+
get interactive() {
|
|
29
|
+
return SDK.config.gestureHandlerConfig.spriteTextEditGizmoEnabled;
|
|
30
|
+
}
|
|
31
|
+
set interactive(state) {
|
|
32
|
+
if (state === SDK.config.gestureHandlerConfig.spriteTextEditGizmoEnabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
SDK.config.gestureHandlerConfig.spriteTextEditGizmoEnabled = state;
|
|
36
|
+
}
|
|
37
|
+
preparationAction(event) {
|
|
38
|
+
const mouse = new Vector2(event.offsetX, event.offsetY);
|
|
39
|
+
// const selected = this.result[this.interactionParam.selected]
|
|
40
|
+
this.interactionParam.preSelected = -1;
|
|
41
|
+
this.result.forEach((textInfo, i) => {
|
|
42
|
+
if (this.interactionParam.preSelected >= 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const originBox = this._pageDataUtils.getViewBoxById(textInfo.id);
|
|
46
|
+
const textInfoBox = getBoxByNormalizeBox(originBox, textInfo.box);
|
|
47
|
+
// if (selected?.id === textInfo.id) {
|
|
48
|
+
// const selectedBox = getBoxByNormalizeBox(originBox, selected.box)
|
|
49
|
+
// if ((!selectedBox.containsPoint(mouse) || textInfo.index < selected.index) && textInfoBox.containsPoint(mouse)) {
|
|
50
|
+
// this.interactionParam.preSelected = i
|
|
51
|
+
// }
|
|
52
|
+
// } else {
|
|
53
|
+
// if (textInfoBox.containsPoint(mouse)) {
|
|
54
|
+
// this.interactionParam.preSelected = i
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
if (textInfoBox.containsPoint(mouse)) {
|
|
58
|
+
this.interactionParam.preSelected = i;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return this.type;
|
|
62
|
+
}
|
|
63
|
+
preAction() {
|
|
64
|
+
const targetInfo = this.result[this.interactionParam.preSelected];
|
|
65
|
+
if (targetInfo) {
|
|
66
|
+
const emitInfo = targetInfo ? { id: targetInfo.id, index: targetInfo.index, text: targetInfo.text } : undefined;
|
|
67
|
+
this._eventEmitter.emit('spriteTextClick', emitInfo);
|
|
68
|
+
}
|
|
69
|
+
this.result.forEach(info => {
|
|
70
|
+
info.isEditing = info.id === targetInfo?.id && info.index === targetInfo.index;
|
|
71
|
+
});
|
|
72
|
+
this.interactionParam.preSelected = -1;
|
|
73
|
+
return this.type;
|
|
74
|
+
}
|
|
75
|
+
action(event) { }
|
|
76
|
+
endAction(event) {
|
|
77
|
+
return this.type;
|
|
78
|
+
}
|
|
79
|
+
interruption() {
|
|
80
|
+
return this.type;
|
|
81
|
+
}
|
|
82
|
+
actionKey(keyCode) { }
|
|
83
|
+
endActionKey(keyCode) { }
|
|
84
|
+
cancelPreparation() { }
|
|
85
|
+
initResult(initParams) {
|
|
86
|
+
initParams.forEach(param => {
|
|
87
|
+
const originBox = this._pageDataUtils.getItemBoxById(param.id);
|
|
88
|
+
param.info.forEach((initInfo, index) => {
|
|
89
|
+
const { text, box, hasChanged } = initInfo;
|
|
90
|
+
const corners = box.map(corner => new Vector2(...corner).add(originBox.min));
|
|
91
|
+
const targetBox = new Box2().setFromVec2Array(corners);
|
|
92
|
+
const normalizeBox = getNormalizeBoxByBoxes(originBox, targetBox);
|
|
93
|
+
this.result.push({
|
|
94
|
+
id: param.id,
|
|
95
|
+
index,
|
|
96
|
+
hasChanged,
|
|
97
|
+
text: text,
|
|
98
|
+
box: normalizeBox,
|
|
99
|
+
isEditing: false
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
clearResult() {
|
|
105
|
+
this.result = [];
|
|
106
|
+
}
|
|
107
|
+
setSelected(id, index) {
|
|
108
|
+
const selected = this.result.findIndex(info => info.id === id && info.index === index);
|
|
109
|
+
if (selected < 0) {
|
|
110
|
+
console.warn(`item ${id} does not have index ${index} text info.`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.interactionParam.selected = selected;
|
|
115
|
+
const targetInfo = this.result[this.interactionParam.selected];
|
|
116
|
+
const emitInfo = targetInfo ? { id: targetInfo.id, index: targetInfo.index, text: targetInfo.text } : undefined;
|
|
117
|
+
this._eventEmitter.emit('spriteTextClick', emitInfo);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
setText(id, index, text) {
|
|
121
|
+
const targetInfo = this.result.find(info => info.id === id && info.index === index);
|
|
122
|
+
if (!targetInfo) {
|
|
123
|
+
console.warn(`item ${id} does not have index ${index} text info.`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
targetInfo.text = text;
|
|
127
|
+
}
|
|
128
|
+
setChangedState(id, index, hasChanged) {
|
|
129
|
+
const targetInfo = this.result.find(info => info.id === id && info.index === index);
|
|
130
|
+
if (!targetInfo) {
|
|
131
|
+
console.warn(`item ${id} does not have index ${index} text info.`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
targetInfo.hasChanged = hasChanged;
|
|
135
|
+
}
|
|
136
|
+
setEditState(id, index, isEditing) {
|
|
137
|
+
const targetInfo = this.result.find(info => info.id === id && info.index === index);
|
|
138
|
+
if (!targetInfo) {
|
|
139
|
+
console.warn(`item ${id} does not have index ${index} text info.`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
targetInfo.isEditing = isEditing;
|
|
143
|
+
}
|
|
144
|
+
refreshResults() {
|
|
145
|
+
this.graphics.clear();
|
|
146
|
+
this.editGraphics.clear();
|
|
147
|
+
this.preSelectedText.text = '';
|
|
148
|
+
if (!this.interactive || this.result.length === 0) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const { scale } = this._pageDataUtils.interactionUtils.viewportParam;
|
|
152
|
+
const { editBoxColor, editBoxAlpha, editBoxPreSelectedColor, editBoxPreSelectedAlpha, hasChangedEditBoxColor, hasChangedEditBoxAlpha, hasChangedEditBoxPreSelectedColor, hasChangedEditBoxPreSelectedAlpha,
|
|
153
|
+
// boxLineWidth,
|
|
154
|
+
// dashLineDash,
|
|
155
|
+
// dashLineGap,
|
|
156
|
+
editBoxLineColor, editBoxLineAlpha, editBoxLinePreSelectedAlpha, editBoxLinePreSelectedColor, hasChangedEditBoxLineColor, hasChangedEditBoxLineAlpha, hasChangedEditBoxLinePreSelectedColor, hasChangedEditBoxLinePreSelectedAlpha, } = SDK.config.gestureHandlerConfig.spriteTextEditGizmoConfig;
|
|
157
|
+
this.result.forEach((value, index) => {
|
|
158
|
+
const isPreSelecetd = index === this.interactionParam.preSelected && !this.clearPreSelected;
|
|
159
|
+
const { box, id, hasChanged, isEditing } = value;
|
|
160
|
+
const originBox = this._pageDataUtils.getViewBoxById(id);
|
|
161
|
+
const viewBox = getBoxByNormalizeBox(originBox, box);
|
|
162
|
+
if (hasChanged) {
|
|
163
|
+
const boxColor = !hasChanged ? (!isPreSelecetd ? editBoxColor : editBoxPreSelectedColor) : (!isPreSelecetd ? hasChangedEditBoxColor : hasChangedEditBoxPreSelectedColor);
|
|
164
|
+
const boxAlpha = !hasChanged ? (!isPreSelecetd ? editBoxAlpha : editBoxPreSelectedAlpha) : (!isPreSelecetd ? hasChangedEditBoxAlpha : hasChangedEditBoxPreSelectedAlpha);
|
|
165
|
+
this.editGraphics.beginFill(boxColor, boxAlpha);
|
|
166
|
+
this.editGraphics.fillBox(viewBox);
|
|
167
|
+
this.editGraphics.endFill();
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const boxColor = !hasChanged ? (!isPreSelecetd ? editBoxColor : editBoxPreSelectedColor) : (!isPreSelecetd ? hasChangedEditBoxColor : hasChangedEditBoxPreSelectedColor);
|
|
171
|
+
const boxAlpha = !hasChanged ? (!isPreSelecetd ? editBoxAlpha : editBoxPreSelectedAlpha) : (!isPreSelecetd ? hasChangedEditBoxAlpha : hasChangedEditBoxPreSelectedAlpha);
|
|
172
|
+
this.graphics.beginFill(boxColor, boxAlpha);
|
|
173
|
+
this.graphics.fillBox(viewBox);
|
|
174
|
+
this.graphics.endFill();
|
|
175
|
+
}
|
|
176
|
+
const textPosition = viewBox.getCenter();
|
|
177
|
+
const textSize = viewBox.getSize();
|
|
178
|
+
if (isEditing) {
|
|
179
|
+
const text = processText(value.text, defuleTextStyle, textSize.x / scale, Math.floor(textSize.y / scale / 16));
|
|
180
|
+
this.preSelectedText.style.wordWrapWidth = textSize.x / scale;
|
|
181
|
+
this.preSelectedText.text = text;
|
|
182
|
+
this.preSelectedText.scale.x = scale;
|
|
183
|
+
this.preSelectedText.scale.y = scale;
|
|
184
|
+
this.preSelectedText.anchor.set(0.5, 0.5);
|
|
185
|
+
this.preSelectedText.x = textPosition.x;
|
|
186
|
+
this.preSelectedText.y = textPosition.y;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
// 绘制DashLine
|
|
190
|
+
this.result.forEach((value, index) => {
|
|
191
|
+
const isPreSelecetd = index === this.interactionParam.preSelected && !this.clearPreSelected;
|
|
192
|
+
const { box, id, hasChanged } = value;
|
|
193
|
+
const originBox = this._pageDataUtils.getViewBoxById(id);
|
|
194
|
+
const viewBox = getBoxByNormalizeBox(originBox, box);
|
|
195
|
+
if (hasChanged) {
|
|
196
|
+
const boxLineColor = !hasChanged ? (!isPreSelecetd ? editBoxLineColor : editBoxLinePreSelectedColor) : (!isPreSelecetd ? hasChangedEditBoxLineColor : hasChangedEditBoxLinePreSelectedColor);
|
|
197
|
+
const boxLineAlpha = !hasChanged ? (!isPreSelecetd ? editBoxLineAlpha : editBoxLinePreSelectedAlpha) : (!isPreSelecetd ? hasChangedEditBoxLineAlpha : hasChangedEditBoxLinePreSelectedAlpha);
|
|
198
|
+
viewBox.corners.forEach((corner, _i) => {
|
|
199
|
+
const start = corner.clone();
|
|
200
|
+
const end = viewBox.corners[(_i + 1) % 4].clone();
|
|
201
|
+
const angle = new Vector2().subtractVectors(end, start).angle() * RAD2DEG;
|
|
202
|
+
if ([180, 270].includes(angle)) {
|
|
203
|
+
const endClone = end.clone();
|
|
204
|
+
end.copyFrom(start);
|
|
205
|
+
start.copyFrom(endClone);
|
|
206
|
+
}
|
|
207
|
+
this.editGraphics.lineStyle(1, boxLineColor, boxLineAlpha);
|
|
208
|
+
this.editGraphics.moveTo(...start.toArray());
|
|
209
|
+
this.editGraphics.lineTo(...end.toArray());
|
|
210
|
+
// this.editGraphics.drawDashLine(...end.toArray(), dashLineDash, dashLineGap)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const boxLineColor = !hasChanged ? (!isPreSelecetd ? editBoxLineColor : editBoxLinePreSelectedColor) : (!isPreSelecetd ? hasChangedEditBoxLineColor : hasChangedEditBoxLinePreSelectedColor);
|
|
215
|
+
const boxLineAlpha = !hasChanged ? (!isPreSelecetd ? editBoxLineAlpha : editBoxLinePreSelectedAlpha) : (!isPreSelecetd ? hasChangedEditBoxLineAlpha : hasChangedEditBoxLinePreSelectedAlpha);
|
|
216
|
+
viewBox.corners.forEach((corner, _i) => {
|
|
217
|
+
const start = corner.clone();
|
|
218
|
+
const end = viewBox.corners[(_i + 1) % 4].clone();
|
|
219
|
+
const angle = new Vector2().subtractVectors(end, start).angle() * RAD2DEG;
|
|
220
|
+
if ([180, 270].includes(angle)) {
|
|
221
|
+
const endClone = end.clone();
|
|
222
|
+
end.copyFrom(start);
|
|
223
|
+
start.copyFrom(endClone);
|
|
224
|
+
}
|
|
225
|
+
this.graphics.lineStyle(1, boxLineColor, boxLineAlpha);
|
|
226
|
+
this.graphics.moveTo(...start.toArray());
|
|
227
|
+
this.graphics.lineTo(...end.toArray());
|
|
228
|
+
// this.graphics.drawDashLine(...end.toArray(), dashLineDash, dashLineGap)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
getRenderObjects() {
|
|
234
|
+
const hasEditingText = !!this.result.find(info => info.isEditing);
|
|
235
|
+
// const hasSelected = this.interactionParam.selected >= 0
|
|
236
|
+
this.clearPreSelected = false;
|
|
237
|
+
const result = [];
|
|
238
|
+
if (!this.interactive) {
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
result.push(this.graphics, this.editGraphics);
|
|
242
|
+
if (hasEditingText) {
|
|
243
|
+
result.push(this.preSelectedText);
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
}
|