@gedit/editor-2d 0.3.4 → 0.3.6
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/LICENSE +21 -0
- package/lib/browser/editor2d-anim-path-selection-service.d.ts +24 -0
- package/lib/browser/editor2d-anim-path-selection-service.d.ts.map +1 -0
- package/lib/browser/editor2d-anim-path-selection-service.js +52 -0
- package/lib/browser/editor2d-anim-path-selection-service.js.map +1 -0
- package/lib/browser/editor2d-context-key-service.js +7 -10
- package/lib/browser/editor2d-context-key-service.js.map +1 -1
- package/lib/browser/editor2d-contribution.js +25 -28
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/editor2d-frontend-module.d.ts.map +1 -1
- package/lib/browser/editor2d-frontend-module.js +38 -38
- package/lib/browser/editor2d-frontend-module.js.map +1 -1
- package/lib/browser/editor2d-label-provider.js +18 -21
- package/lib/browser/editor2d-label-provider.js.map +1 -1
- package/lib/browser/editor2d-model-provider.js +16 -19
- package/lib/browser/editor2d-model-provider.js.map +1 -1
- package/lib/browser/editor2d-ref-provider-contribution.js +13 -16
- package/lib/browser/editor2d-ref-provider-contribution.js.map +1 -1
- package/lib/browser/editor2d-service.d.ts +2 -0
- package/lib/browser/editor2d-service.d.ts.map +1 -1
- package/lib/browser/editor2d-service.js +28 -27
- package/lib/browser/editor2d-service.js.map +1 -1
- package/lib/browser/index.d.ts +2 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +6 -20
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/model/editor2d-document.d.ts +22 -9
- package/lib/browser/model/editor2d-document.d.ts.map +1 -1
- package/lib/browser/model/editor2d-document.js +248 -133
- package/lib/browser/model/editor2d-document.js.map +1 -1
- package/lib/browser/model/editor2d-iterator.js +1 -5
- package/lib/browser/model/editor2d-iterator.js.map +1 -1
- package/lib/browser/model/editor2d-model-container.js +22 -26
- package/lib/browser/model/editor2d-model-container.js.map +1 -1
- package/lib/browser/model/editor2d-model.js +21 -24
- package/lib/browser/model/editor2d-model.js.map +1 -1
- package/lib/browser/model/editor2d-selection.js +7 -10
- package/lib/browser/model/editor2d-selection.js.map +1 -1
- package/lib/browser/model/editor2d-widget.js +17 -20
- package/lib/browser/model/editor2d-widget.js.map +1 -1
- package/lib/browser/model/editor2d.d.ts.map +1 -1
- package/lib/browser/model/editor2d.js +37 -35
- package/lib/browser/model/editor2d.js.map +1 -1
- package/lib/browser/model/index.js +7 -23
- package/lib/browser/model/index.js.map +1 -1
- package/lib/browser/model/utils/anim.utils.d.ts +2 -1
- package/lib/browser/model/utils/anim.utils.d.ts.map +1 -1
- package/lib/browser/model/utils/anim.utils.js +14 -16
- package/lib/browser/model/utils/anim.utils.js.map +1 -1
- package/lib/browser/model/utils/index.js +1 -17
- package/lib/browser/model/utils/index.js.map +1 -1
- package/lib/browser/playground/anim-path-edit-layer.d.ts +33 -0
- package/lib/browser/playground/anim-path-edit-layer.d.ts.map +1 -0
- package/lib/browser/playground/anim-path-edit-layer.js +352 -0
- package/lib/browser/playground/anim-path-edit-layer.js.map +1 -0
- package/lib/browser/playground/canvas-draw.d.ts +3 -0
- package/lib/browser/playground/canvas-draw.d.ts.map +1 -1
- package/lib/browser/playground/canvas-draw.js +57 -39
- package/lib/browser/playground/canvas-draw.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +29 -32
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/entities/document-entity.js +2 -6
- package/lib/browser/playground/entities/document-entity.js.map +1 -1
- package/lib/browser/playground/entities/editor2d-entity.js +3 -7
- package/lib/browser/playground/entities/editor2d-entity.js.map +1 -1
- package/lib/browser/playground/entities/extend-entity.js +2 -6
- package/lib/browser/playground/entities/extend-entity.js.map +1 -1
- package/lib/browser/playground/entities/index.js +3 -19
- package/lib/browser/playground/entities/index.js.map +1 -1
- package/lib/browser/playground/extend-edit/gradient-conic-node.d.ts +4 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.js +69 -0
- package/lib/browser/playground/extend-edit/gradient-conic-node.js.map +1 -0
- package/lib/browser/playground/{extend-edit-layer-point-event.d.ts → extend-edit/gradient-edit-layer-point-event.d.ts} +1 -1
- package/lib/browser/playground/extend-edit/gradient-edit-layer-point-event.d.ts.map +1 -0
- package/lib/browser/playground/{extend-edit-layer-point-event.js → extend-edit/gradient-edit-layer-point-event.js} +3 -28
- package/lib/browser/playground/extend-edit/gradient-edit-layer-point-event.js.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-node.d.ts +13 -0
- package/lib/browser/playground/extend-edit/gradient-node.d.ts.map +1 -0
- package/lib/browser/playground/extend-edit/gradient-node.js +154 -0
- package/lib/browser/playground/extend-edit/gradient-node.js.map +1 -0
- package/lib/browser/playground/extend-edit-layer.d.ts +0 -8
- package/lib/browser/playground/extend-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/extend-edit-layer.js +30 -249
- package/lib/browser/playground/extend-edit-layer.js.map +1 -1
- package/lib/browser/playground/index.js +11 -30
- package/lib/browser/playground/index.js.map +1 -1
- package/lib/browser/playground/path-edit/anim-path-edit-svg.d.ts +17 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.d.ts.map +1 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.js +58 -0
- package/lib/browser/playground/path-edit/anim-path-edit-svg.js.map +1 -0
- package/lib/browser/playground/path-edit/index.js +3 -19
- package/lib/browser/playground/path-edit/index.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +9 -39
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +2 -6
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +20 -50
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -1
- package/lib/browser/playground/path-edit/utils.js +64 -100
- package/lib/browser/playground/path-edit/utils.js.map +1 -1
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +67 -95
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-context.d.ts +3 -3
- package/lib/browser/playground/playground-context.d.ts.map +1 -1
- package/lib/browser/playground/playground-context.js +48 -54
- package/lib/browser/playground/playground-context.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +41 -42
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/playground/selection-entity-manager.d.ts.map +1 -1
- package/lib/browser/playground/selection-entity-manager.js +26 -54
- package/lib/browser/playground/selection-entity-manager.js.map +1 -1
- package/lib/browser/playground/selector-extend-icons.js +12 -39
- package/lib/browser/playground/selector-extend-icons.js.map +1 -1
- package/lib/browser/playground/selector-extend-renderer.js +22 -52
- package/lib/browser/playground/selector-extend-renderer.js.map +1 -1
- package/lib/browser/utils/bezier.path.utils.d.ts +23 -0
- package/lib/browser/utils/bezier.path.utils.d.ts.map +1 -0
- package/lib/browser/utils/bezier.path.utils.js +64 -0
- package/lib/browser/utils/bezier.path.utils.js.map +1 -0
- package/lib/browser/utils/bounds.d.ts.map +1 -1
- package/lib/browser/utils/bounds.js +17 -22
- package/lib/browser/utils/bounds.js.map +1 -1
- package/lib/browser/utils/snapshot.js +17 -20
- package/lib/browser/utils/snapshot.js.map +1 -1
- package/lib/i18n/zh-CN.js +1 -3
- package/lib/i18n/zh-CN.js.map +1 -1
- package/package.json +11 -10
- package/src/browser/editor2d-anim-path-selection-service.ts +48 -0
- package/src/browser/editor2d-frontend-module.ts +2 -0
- package/src/browser/editor2d-service.ts +2 -0
- package/src/browser/index.ts +2 -1
- package/src/browser/model/editor2d-document.ts +198 -20
- package/src/browser/model/editor2d.ts +13 -2
- package/src/browser/model/utils/anim.utils.ts +10 -6
- package/src/browser/playground/anim-path-edit-layer.tsx +435 -0
- package/src/browser/playground/canvas-draw.ts +37 -2
- package/src/browser/playground/canvas-layer.ts +1 -0
- package/src/browser/playground/extend-edit/gradient-conic-node.tsx +106 -0
- package/src/browser/playground/extend-edit/gradient-node.tsx +232 -0
- package/src/browser/playground/extend-edit-layer.tsx +32 -312
- package/src/browser/playground/path-edit/anim-path-edit-svg.tsx +168 -0
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +1 -1
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +3 -7
- package/src/browser/playground/path-edit/utils.tsx +1 -1
- package/src/browser/playground/path-edit-layer.tsx +4 -4
- package/src/browser/playground/playground-context.ts +2 -6
- package/src/browser/playground/playground-contribution.ts +2 -0
- package/src/browser/playground/selection-entity-manager.tsx +7 -7
- package/src/browser/style/path-edit-layer.less +13 -5
- package/src/browser/utils/bezier.path.utils.ts +89 -0
- package/src/browser/utils/bounds.ts +0 -1
- package/lib/browser/playground/extend-edit-layer-point-event.d.ts.map +0 -1
- package/lib/browser/playground/extend-edit-layer-point-event.js.map +0 -1
- /package/src/browser/playground/{extend-edit-layer-point-event.tsx → extend-edit/gradient-edit-layer-point-event.tsx} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
exports.SnapshotOptsDefault = {
|
|
1
|
+
import { CanvasDraw } from '../playground/canvas-draw';
|
|
2
|
+
import {
|
|
3
|
+
// debounce,
|
|
4
|
+
deepClone, Disposable, DisposableCollection, DisposableImpl, Emitter, PromiseDeferred, SizeSchema, URI } from '@gedit/utils';
|
|
5
|
+
import { Editor2dNode } from '../model';
|
|
6
|
+
export const SnapshotOptsDefault = {
|
|
8
7
|
quility: 0.8,
|
|
9
8
|
imageType: 'image/webp',
|
|
10
9
|
};
|
|
@@ -12,27 +11,26 @@ function fixDrawerScale(drawer, limitSize) {
|
|
|
12
11
|
// const appConfig = drawer.getData()?.appConfig;
|
|
13
12
|
// if (!appConfig) return;
|
|
14
13
|
const currentSize = drawer.getSceneSize();
|
|
15
|
-
const scale =
|
|
14
|
+
const scale = SizeSchema.fixSize(currentSize, {
|
|
16
15
|
width: limitSize.width,
|
|
17
16
|
height: limitSize.height,
|
|
18
17
|
});
|
|
19
18
|
drawer.refreshScale(false, scale);
|
|
20
19
|
}
|
|
21
|
-
async function createSnapshots(opts, sceneDatas) {
|
|
20
|
+
export async function createSnapshots(opts, sceneDatas) {
|
|
22
21
|
const creator = new SnapshotCreator(opts);
|
|
23
22
|
const result = await creator.draw(sceneDatas);
|
|
24
23
|
creator.dispose();
|
|
25
24
|
return result;
|
|
26
25
|
}
|
|
27
|
-
exports.createSnapshots = createSnapshots;
|
|
28
26
|
let host;
|
|
29
|
-
class SnapshotCreator extends
|
|
27
|
+
export class SnapshotCreator extends DisposableImpl {
|
|
30
28
|
constructor(opts) {
|
|
31
29
|
super();
|
|
32
30
|
this.opts = opts;
|
|
33
31
|
this.result = {};
|
|
34
32
|
this.processingData = [];
|
|
35
|
-
this.onUpdateEmitter = new
|
|
33
|
+
this.onUpdateEmitter = new Emitter();
|
|
36
34
|
this.onUpdate = this.onUpdateEmitter.event;
|
|
37
35
|
if (!host) {
|
|
38
36
|
host = document.createElement('div');
|
|
@@ -40,7 +38,7 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
40
38
|
// host.style.display = 'none';
|
|
41
39
|
document.body.appendChild(host);
|
|
42
40
|
}
|
|
43
|
-
this.drawer = new
|
|
41
|
+
this.drawer = new CanvasDraw(Object.assign({ host, isSnapshot: true }, opts));
|
|
44
42
|
this.toDispose.pushAll([
|
|
45
43
|
this.drawer,
|
|
46
44
|
this.onUpdateEmitter,
|
|
@@ -81,10 +79,10 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
81
79
|
if (this.processing) {
|
|
82
80
|
return this.processing.promise;
|
|
83
81
|
}
|
|
84
|
-
const deferred = this.processing = new
|
|
82
|
+
const deferred = this.processing = new PromiseDeferred();
|
|
85
83
|
const { drawer } = this;
|
|
86
|
-
const dispose = new
|
|
87
|
-
dispose.push(
|
|
84
|
+
const dispose = new DisposableCollection();
|
|
85
|
+
dispose.push(Disposable.create(() => {
|
|
88
86
|
deferred.resolve();
|
|
89
87
|
this.current = undefined;
|
|
90
88
|
this.processing = undefined;
|
|
@@ -115,7 +113,7 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
115
113
|
}
|
|
116
114
|
this.next(() => dispose.dispose());
|
|
117
115
|
};
|
|
118
|
-
widget.createSnapShot(this.opts.imageType ||
|
|
116
|
+
widget.createSnapShot(this.opts.imageType || SnapshotOptsDefault.imageType, this.opts.quility || SnapshotOptsDefault.quility, this.opts.fontBool || false, callback).then(callback);
|
|
119
117
|
}
|
|
120
118
|
}));
|
|
121
119
|
this.next(() => dispose.dispose());
|
|
@@ -140,12 +138,12 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
140
138
|
let content = next.content;
|
|
141
139
|
// Empty
|
|
142
140
|
if (!content || !content.children || Object.keys(content).length === 0) {
|
|
143
|
-
content =
|
|
141
|
+
content = Editor2dNode.createRootNode(new URI(next.uri));
|
|
144
142
|
const attrs = this.opts.renderEngine.getDisplayDefaultData(this.opts.engineName, content.displayType);
|
|
145
143
|
Object.assign(content, Object.assign({}, attrs));
|
|
146
144
|
}
|
|
147
145
|
// 设置 parent, 保持 id 一致; mask 里用的是 path id;
|
|
148
|
-
content = this.setParent(
|
|
146
|
+
content = this.setParent(deepClone(content));
|
|
149
147
|
this.drawer.update({
|
|
150
148
|
visible: true,
|
|
151
149
|
uri: next.uri,
|
|
@@ -181,5 +179,4 @@ class SnapshotCreator extends utils_1.DisposableImpl {
|
|
|
181
179
|
});
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
|
-
exports.SnapshotCreator = SnapshotCreator;
|
|
185
182
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/browser/utils/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AACvE,OAAO;AACL,YAAY;AACZ,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,eAAe,EACf,UAAU,EACV,GAAG,EACJ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAYxC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,YAAY;CACxB,CAAC;AAkBF,SAAS,cAAc,CAAC,MAAkB,EAAE,SAAqB;IAC/D,iDAAiD;IACjD,0BAA0B;IAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,WAAY,EAAE;QAC7C,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;KACzB,CAAC,CAAC;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAkB,EAAE,UAA2B;IACnF,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,OAAO,CAAC,OA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C,MAAc,EAAE,EAAE;4BAClC,IAAI,MAAM,EAAE;gCACV,EAAE,CAAC,MAAM,CAAC,CAAC;6BACZ;wBACH,CAAC,CAAC;wBACF,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;qBAEzF;iBACF;YACH,CAAC,EAAE,KAAK,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/lib/i18n/zh-CN.js
CHANGED
package/lib/i18n/zh-CN.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zh-CN.js","sourceRoot":"","sources":["../../src/i18n/zh-CN.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zh-CN.js","sourceRoot":"","sources":["../../src/i18n/zh-CN.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,eAAe;IACb,UAAU,EAAE,OAAO;IACnB,YAAY,EAAE,SAAS;IACvB,qBAAqB,EAAE,QAAQ;IAC/B,QAAQ,EAAE,EACT;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gedit/editor-2d",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/browser/index",
|
|
6
6
|
"typings": "lib/browser/index.d.ts",
|
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@gedit/app-config": "^0.3.
|
|
13
|
-
"@gedit/canvas-draw": "^0.3.
|
|
14
|
-
"@gedit/editor": "^0.3.
|
|
15
|
-
"@gedit/playground": "^0.3.
|
|
16
|
-
"@gedit/render-engine-ide": "^0.3.
|
|
17
|
-
"@gedit/theme": "^0.2.
|
|
18
|
-
"@gedit/workspace-2d": "^0.3.
|
|
12
|
+
"@gedit/app-config": "^0.3.7",
|
|
13
|
+
"@gedit/canvas-draw": "^0.3.5",
|
|
14
|
+
"@gedit/editor": "^0.3.3",
|
|
15
|
+
"@gedit/playground": "^0.3.5",
|
|
16
|
+
"@gedit/render-engine-ide": "^0.3.5",
|
|
17
|
+
"@gedit/theme": "^0.2.14",
|
|
18
|
+
"@gedit/workspace-2d": "^0.3.5",
|
|
19
19
|
"@types/bezier-js": "^4.1.3",
|
|
20
20
|
"bezier-js": "^6.1.4",
|
|
21
21
|
"clsx": "^1.1.1",
|
|
22
22
|
"json-stringify-pretty-compact": "^2.0.0",
|
|
23
|
-
"nanoid": "^3.3.2"
|
|
23
|
+
"nanoid": "^3.3.2",
|
|
24
|
+
"tween-one": "^1.2.0"
|
|
24
25
|
},
|
|
25
26
|
"geditExtensions": [
|
|
26
27
|
{
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"nyc": {
|
|
41
42
|
"extends": "../../configs/nyc.json"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "811242741b9942050f7e5aa872b57911de937e11"
|
|
44
45
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { injectable } from 'inversify';
|
|
2
|
+
import { Emitter, Event } from '@gedit/utils';
|
|
3
|
+
import { PathPointSelection } from '@gedit/playground';
|
|
4
|
+
|
|
5
|
+
interface AnimPathEvent {
|
|
6
|
+
changBool: boolean;
|
|
7
|
+
selection: PathPointSelection<number>[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 独立动画路程选择服务
|
|
11
|
+
* 用于处理动画路程的选择
|
|
12
|
+
* 通过设置selection属性来设置选择对象
|
|
13
|
+
* anim-path-edit-layer 与 timeline 互通使用;
|
|
14
|
+
* 注入到 PlaygroundContext;
|
|
15
|
+
*/
|
|
16
|
+
@injectable()
|
|
17
|
+
export class Editor2dAnimPathSelectionService {
|
|
18
|
+
protected readonly onSelectionChangedEmitter = new Emitter<AnimPathEvent>();
|
|
19
|
+
readonly onSelectionChanged: Event<AnimPathEvent> = this
|
|
20
|
+
.onSelectionChangedEmitter.event;
|
|
21
|
+
private currentSelection: PathPointSelection<number>[] = [];
|
|
22
|
+
|
|
23
|
+
get selection(): PathPointSelection<number>[] {
|
|
24
|
+
return this.currentSelection;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
set selection(selection: PathPointSelection<number>[]) {
|
|
28
|
+
if (this.currentSelection !== selection) {
|
|
29
|
+
this.currentSelection = selection;
|
|
30
|
+
this.onSelectionChangedEmitter.fire({
|
|
31
|
+
changBool: true,
|
|
32
|
+
selection,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
setSelection(selection: PathPointSelection<number>[], change: boolean = true): void {
|
|
37
|
+
if (this.currentSelection !== selection) {
|
|
38
|
+
this.currentSelection = selection;
|
|
39
|
+
this.onSelectionChangedEmitter.fire({
|
|
40
|
+
changBool: change,
|
|
41
|
+
selection,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
clearSelection(): void {
|
|
46
|
+
this.currentSelection = [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -15,9 +15,11 @@ import { Editor2dContextKeyService } from './editor2d-context-key-service';
|
|
|
15
15
|
import { EditorProviderContribution } from '@gedit/editor/lib/browser/editor-provider';
|
|
16
16
|
import { Editor2dRefProviderContribution } from './editor2d-ref-provider-contribution';
|
|
17
17
|
import { ResourceRefProviderContribution } from '@gedit/resource';
|
|
18
|
+
import { Editor2dAnimPathSelectionService } from './editor2d-anim-path-selection-service';
|
|
18
19
|
|
|
19
20
|
export default new ContainerModule(bind => {
|
|
20
21
|
bindInSingletonScope(bind, [
|
|
22
|
+
Editor2dAnimPathSelectionService,
|
|
21
23
|
Editor2dService,
|
|
22
24
|
Editor2dModelProvider,
|
|
23
25
|
Editor2dLabelProvider,
|
|
@@ -10,6 +10,7 @@ import { Editor2dNode } from './model/editor2d';
|
|
|
10
10
|
import { Editor2dDocument } from './model/editor2d-document';
|
|
11
11
|
import { SelectableTreeNode, TreeSelection } from '@gedit/tree';
|
|
12
12
|
import SelectionType = TreeSelection.SelectionType;
|
|
13
|
+
import { Editor2dAnimPathSelectionService } from './';
|
|
13
14
|
|
|
14
15
|
export interface Editor2dSelectedNodesChangedEvent {
|
|
15
16
|
selectedNodes: Editor2dNode[];
|
|
@@ -26,6 +27,7 @@ export class Editor2dService {
|
|
|
26
27
|
@inject(SelectionService) protected readonly selectionService: SelectionService;
|
|
27
28
|
@inject(EditorAccess) @named(EditorAccess.CURRENT) protected readonly editorAccess: EditorAccess;
|
|
28
29
|
@inject(EditorManager) protected readonly editorManager: EditorManager;
|
|
30
|
+
@inject(Editor2dAnimPathSelectionService) public readonly animPathSelection: Editor2dAnimPathSelectionService;
|
|
29
31
|
|
|
30
32
|
getCurrentModel(): Editor2dModel | undefined {
|
|
31
33
|
const model = this.editorAccess.editor as Editor2dModel;
|
package/src/browser/index.ts
CHANGED
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
PromiseDeferred,
|
|
13
13
|
URI,
|
|
14
14
|
FileStat,
|
|
15
|
+
getByKey,
|
|
16
|
+
coverData,
|
|
17
|
+
setByKey,
|
|
15
18
|
} from '@gedit/utils';
|
|
16
19
|
import {
|
|
17
20
|
checkDuplicateNodes,
|
|
@@ -21,7 +24,18 @@ import {
|
|
|
21
24
|
Editor2dNode,
|
|
22
25
|
// Editor2dNodeCache,
|
|
23
26
|
} from './editor2d';
|
|
24
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ComponentGameObjectData,
|
|
29
|
+
FrameChild,
|
|
30
|
+
GameConfig,
|
|
31
|
+
GameObject,
|
|
32
|
+
GameObjectBaseType,
|
|
33
|
+
GameObjectData,
|
|
34
|
+
GameObjectType,
|
|
35
|
+
LayerData,
|
|
36
|
+
TimelineData,
|
|
37
|
+
TimelineFrame,
|
|
38
|
+
} from '@gedit/render-engine';
|
|
25
39
|
import { GameObjectDecoration, RenderEngineIDEService } from '@gedit/render-engine-ide';
|
|
26
40
|
import { CompositeTreeNode, ExpandableTreeNode, Tree, TreeImpl, TreeNode } from '@gedit/tree';
|
|
27
41
|
import { ResourceAutoSaveService } from '@gedit/resource/lib/browser';
|
|
@@ -34,9 +48,9 @@ import { Editor2dIterator } from './editor2d-iterator';
|
|
|
34
48
|
import { ThemeService } from '@gedit/theme';
|
|
35
49
|
import { followKeyType, getFollowValue } from '@gedit/render-engine-pixi';
|
|
36
50
|
import { ConfirmDialog } from '@gedit/layout';
|
|
37
|
-
import { AssetsMetaData } from '@gedit/assets-2d';
|
|
38
51
|
import { toFixedValue } from '@gedit/canvas-draw';
|
|
39
52
|
import { getPIXILocalBoundsByNode } from '../utils/bounds';
|
|
53
|
+
import { sortFrame } from './utils';
|
|
40
54
|
// import { getAnimationKeys, getChangeAnimationData } from './utils';
|
|
41
55
|
|
|
42
56
|
export const maskShowArray: GameObjectType[] = [
|
|
@@ -70,6 +84,30 @@ export const Editor2dComponentProvider = Symbol('Editor2dComponentProvider');
|
|
|
70
84
|
|
|
71
85
|
const replaceReg = (s: string) => s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
72
86
|
|
|
87
|
+
export interface TimelineService {
|
|
88
|
+
getAnimationIds: () => string[]
|
|
89
|
+
changeTimelineData: (e: Editor2dNode) => void;
|
|
90
|
+
saveTimelineData: (
|
|
91
|
+
data: LayerData,
|
|
92
|
+
timeObj: {
|
|
93
|
+
totalTime: number;
|
|
94
|
+
regionStartTime: number;
|
|
95
|
+
regionEndTime: number;
|
|
96
|
+
},
|
|
97
|
+
forceUpdate?: boolean,
|
|
98
|
+
noSave?: boolean
|
|
99
|
+
) => void;
|
|
100
|
+
getNodeCurrentFrame: (
|
|
101
|
+
frame: TimelineFrame
|
|
102
|
+
) => {
|
|
103
|
+
[key: string]: number;
|
|
104
|
+
};
|
|
105
|
+
currentTimelineData?: TimelineData;
|
|
106
|
+
animationNode?: GameObject;
|
|
107
|
+
currentTime?: number;
|
|
108
|
+
playTime?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
73
111
|
/**
|
|
74
112
|
* 组件内容修改后触发
|
|
75
113
|
*/
|
|
@@ -107,7 +145,8 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
107
145
|
readonly onContentChanged = this.onContentChangedEmitter.event;
|
|
108
146
|
readonly onSaved = this.onSavedEmitter.event;
|
|
109
147
|
public animationStarted: boolean = false;
|
|
110
|
-
|
|
148
|
+
public animationIds: string[] = []; // 当前正在录制的动画节点
|
|
149
|
+
public timelineService?: TimelineService;
|
|
111
150
|
private _localVersion: number = 0;
|
|
112
151
|
private _saveVersion: number = 0;
|
|
113
152
|
protected errors: ResourceRefError[] = [];
|
|
@@ -517,6 +556,116 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
517
556
|
}
|
|
518
557
|
}
|
|
519
558
|
|
|
559
|
+
updateAnimationNode(node: Editor2dNode, data: Partial<Editor2dNode>): void {
|
|
560
|
+
if (!this.timelineService) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const frames: TimelineFrame[] = deepClone(this.timelineService.currentTimelineData?.frames) || [];
|
|
564
|
+
// 获取当前图层在动画中的数据;
|
|
565
|
+
const animItem = frames.find(c => c.id === node.id);
|
|
566
|
+
if (!animItem) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// 取出全部帧里的 key
|
|
571
|
+
const keys = Array.from(
|
|
572
|
+
new Set(animItem.frame.value.map((item: FrameChild) => item.key)),
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
Object.keys(animItem.frame.current).forEach(key => {
|
|
576
|
+
if (!keys.includes(key)) {
|
|
577
|
+
const currentValue = getByKey(data, key);
|
|
578
|
+
// 更新当前帧的数据
|
|
579
|
+
animItem.frame.current[key] = currentValue ?? animItem.frame.current[key];
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* 如果是动画节点,更新数据到动画节点上
|
|
585
|
+
* 不是动画节点,更新到当前节点上
|
|
586
|
+
*/
|
|
587
|
+
keys.forEach(key => {
|
|
588
|
+
const currentValue = getByKey(data, key);
|
|
589
|
+
if (typeof currentValue === 'undefined') {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (toFixedValue(currentValue, 2) !== toFixedValue(animItem.frame.current[key], 2)) {
|
|
593
|
+
animItem.frame.current[key] = currentValue ?? animItem.frame.current[key];
|
|
594
|
+
// 判断是否有帧
|
|
595
|
+
const frame = animItem.frame.value.find(
|
|
596
|
+
(item: FrameChild) =>
|
|
597
|
+
item.key === key && item.time === this.timelineService!.currentTime
|
|
598
|
+
);
|
|
599
|
+
if (frame) {
|
|
600
|
+
frame.value = currentValue;
|
|
601
|
+
} else {
|
|
602
|
+
animItem.frame.value.push({
|
|
603
|
+
key,
|
|
604
|
+
time: this.timelineService!.currentTime!,
|
|
605
|
+
value: currentValue,
|
|
606
|
+
});
|
|
607
|
+
animItem.frame.value = sortFrame(animItem.frame.value);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// 删除data里的当前帧的数据
|
|
612
|
+
const keyArr = key.split('.');
|
|
613
|
+
keyArr.reduce((v: any, k: string, i) => {
|
|
614
|
+
if (typeof v !== 'object') {
|
|
615
|
+
return undefined;
|
|
616
|
+
}
|
|
617
|
+
if (i >= keyArr.length - 1) {
|
|
618
|
+
delete v[k];
|
|
619
|
+
}
|
|
620
|
+
return v[k];
|
|
621
|
+
}, data);
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// 属性栏更新数据会传回来 Editor2dNode; 清除不需要的数据
|
|
625
|
+
const newData = omit(data, ['nextSibling', 'previousSibling', 'parent']);
|
|
626
|
+
const nodeData = coverData(node, newData);
|
|
627
|
+
const gameObject = this.getGameObjectById(node.id);
|
|
628
|
+
if (gameObject) {
|
|
629
|
+
gameObject.data = {
|
|
630
|
+
...gameObject.data,
|
|
631
|
+
...nodeData,
|
|
632
|
+
id: gameObject.data.id
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
Object.assign(node, nodeData);
|
|
637
|
+
// 通过 animation 保存;
|
|
638
|
+
// node.version = (node.version || 0) + 1;
|
|
639
|
+
// this.fireContentChanged([node], 'update', false, true);
|
|
640
|
+
const animNode = this.getNodeById(this.timelineService.currentTimelineData!.id) as Editor2dNode & {animation: any};
|
|
641
|
+
if (!animNode) {
|
|
642
|
+
console.error('动画节点不存在');
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// 告知 node 变更,时间轴里数据更新;
|
|
647
|
+
// 使用 changeTimelineData 变更数据;
|
|
648
|
+
// const nodes = frames
|
|
649
|
+
// .map(c => this.getNodeById(c.id))
|
|
650
|
+
// .filter(c => c) as Editor2dNode[];
|
|
651
|
+
// const contents = nodes.map(n => ({ text: 'treeNode' }));
|
|
652
|
+
// this.onContentChangedEmitter.fire({
|
|
653
|
+
// document: this,
|
|
654
|
+
// contentChanges: contents,
|
|
655
|
+
// nodes,
|
|
656
|
+
// type: 'update',
|
|
657
|
+
// });
|
|
658
|
+
// 更新保存 animation 数据
|
|
659
|
+
this.updateNode(animNode, {
|
|
660
|
+
animation: {
|
|
661
|
+
...animNode.animation,
|
|
662
|
+
frames,
|
|
663
|
+
}
|
|
664
|
+
}, true);
|
|
665
|
+
// 更新时间轴数据;
|
|
666
|
+
this.timelineService?.changeTimelineData(animNode);
|
|
667
|
+
}
|
|
668
|
+
|
|
520
669
|
updateNode(node: Editor2dNode | string, data: Partial<Editor2dNode> = {}, forceUpdate: boolean = false, noSave?: boolean, noFiredChanged?: boolean): void {
|
|
521
670
|
const treeNode = typeof node === 'string' ? this.nodes[node] : this.nodes[node.id];
|
|
522
671
|
if (!treeNode) return;
|
|
@@ -526,6 +675,16 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
526
675
|
// data = { ...data, name: treeNode.name };
|
|
527
676
|
// }
|
|
528
677
|
// }
|
|
678
|
+
// 动画面板更新属性,直接更新到动画节点上, 不保存;
|
|
679
|
+
if (
|
|
680
|
+
treeNode.useAnimationId &&
|
|
681
|
+
this.timelineService?.currentTimelineData &&
|
|
682
|
+
this.timelineService.currentTimelineData.id === treeNode.useAnimationId
|
|
683
|
+
) {
|
|
684
|
+
this.updateAnimationNode(treeNode, data);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
|
|
529
688
|
// 这里采用深度比较, 因为数据层次定义不会太多
|
|
530
689
|
if (data && data.id && data.id !== treeNode.id) {
|
|
531
690
|
alert('节点更新出错,不同节点无法互相覆盖');
|
|
@@ -600,6 +759,12 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
600
759
|
this.refresh();
|
|
601
760
|
// this.loadRefInfos();
|
|
602
761
|
this.fireContentChanged([], 'add', true);
|
|
762
|
+
if (this.timelineService?.currentTimelineData) {
|
|
763
|
+
const animNode = this.getNodeById(this.timelineService.currentTimelineData.id);
|
|
764
|
+
if (animNode) {
|
|
765
|
+
this.timelineService?.changeTimelineData(animNode);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
603
768
|
}
|
|
604
769
|
|
|
605
770
|
reloadEnd(): void {
|
|
@@ -1068,8 +1233,31 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
1068
1233
|
return nodes;
|
|
1069
1234
|
}
|
|
1070
1235
|
|
|
1071
|
-
getNodeById(nodeId: string): Editor2dNode | Editor2dContainerNode | undefined {
|
|
1072
|
-
|
|
1236
|
+
getNodeById(nodeId: string, noMerge?: boolean): Editor2dNode | Editor2dContainerNode | undefined {
|
|
1237
|
+
const node = this.nodes[nodeId];
|
|
1238
|
+
// 动画编辑,这里的 node 数据不会改变,还是没打开的数据;需要合并数据;
|
|
1239
|
+
// 动画数据在 animation 里变更附值;不会改前 document 的 node 数据;
|
|
1240
|
+
if (
|
|
1241
|
+
!noMerge && node?.useAnimationId &&
|
|
1242
|
+
this.timelineService?.currentTimelineData?.id === node.useAnimationId
|
|
1243
|
+
) {
|
|
1244
|
+
const animNode = this.nodes[
|
|
1245
|
+
this.timelineService.currentTimelineData.id
|
|
1246
|
+
] as Editor2dNode & { animation: any };
|
|
1247
|
+
if (animNode) {
|
|
1248
|
+
const current = animNode.animation.frames.find(
|
|
1249
|
+
(c: any) => c.id === node.id
|
|
1250
|
+
);
|
|
1251
|
+
if (current) {
|
|
1252
|
+
const newNode = this.cloneNodeData(node);
|
|
1253
|
+
Object.keys(current.frame.current || {}).forEach(key => {
|
|
1254
|
+
setByKey(newNode, key, current.frame.current[key]);
|
|
1255
|
+
});
|
|
1256
|
+
return newNode;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return node;
|
|
1073
1261
|
}
|
|
1074
1262
|
|
|
1075
1263
|
getNodeIcon(node: Editor2dNode | Editor2dContainerNode): string {
|
|
@@ -1195,21 +1383,22 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
1195
1383
|
}
|
|
1196
1384
|
|
|
1197
1385
|
startRecordAnimation(
|
|
1198
|
-
|
|
1199
|
-
onNodeChange: (nodes: Editor2dNode[], type: EditorDocumentChangeEvent['type']) => void
|
|
1386
|
+
timelineService: TimelineService,
|
|
1387
|
+
onNodeChange: (nodes: Editor2dNode[], type: EditorDocumentChangeEvent['type']) => void,
|
|
1200
1388
|
): Disposable {
|
|
1201
1389
|
// this.animationStarted = true;
|
|
1202
1390
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1203
1391
|
const getNodesToChildrenById: any = (n: Editor2dContainerNode, id: string) =>
|
|
1204
1392
|
n.children && n.children.some((c: Editor2dContainerNode) => c.id === id || getNodesToChildrenById(c, id));
|
|
1205
1393
|
|
|
1206
|
-
this.
|
|
1394
|
+
this.timelineService = timelineService;
|
|
1395
|
+
this.animationIds = timelineService.getAnimationIds();
|
|
1207
1396
|
// 缓存移到 timeline 里处理
|
|
1208
1397
|
/* const cache: Editor2dNode[] = this.animationIds
|
|
1209
1398
|
.map(id => this.getNodeById(id)).filter(n => !!n)
|
|
1210
1399
|
.map(node => this.cloneNodeData(node as Editor2dNode)); */
|
|
1211
1400
|
const toDispose = this.onContentChanged(e => {
|
|
1212
|
-
this.animationIds =
|
|
1401
|
+
this.animationIds = timelineService.getAnimationIds();
|
|
1213
1402
|
// TODO 删除动画元件后,动画面板清空数据
|
|
1214
1403
|
if (e.nodes) {
|
|
1215
1404
|
const nodes = e.nodes.filter((n: any) =>
|
|
@@ -1497,15 +1686,4 @@ export class Editor2dDocument extends TreeImpl<Editor2dNode, Editor2dContainerNo
|
|
|
1497
1686
|
});
|
|
1498
1687
|
|
|
1499
1688
|
}
|
|
1500
|
-
/**
|
|
1501
|
-
* 资源重新加载
|
|
1502
|
-
*/
|
|
1503
|
-
async reloadAssets(assets: AssetsMetaData[]): Promise<void> {
|
|
1504
|
-
if (!assets.length) {
|
|
1505
|
-
return;
|
|
1506
|
-
}
|
|
1507
|
-
const game = this.engineService.getGameWidgetByUri(this.uri);
|
|
1508
|
-
const scene = game?.getCurrentScene();
|
|
1509
|
-
await scene?.refresh(assets);
|
|
1510
|
-
}
|
|
1511
1689
|
}
|
|
@@ -56,13 +56,24 @@ export namespace Editor2dContent {
|
|
|
56
56
|
node.selected = false;
|
|
57
57
|
// console.log('>>>>>>>>>>>>>>cache', node.cache);
|
|
58
58
|
// 不保存动画数据,,如果有 cache 直接用 cache 的,cache 为 timeline 专属
|
|
59
|
-
|
|
59
|
+
// 不保存 useAnimationId, useAnimationId 打开 timeline 输入;
|
|
60
|
+
const { cache, useAnimationId, animationTime, ...n } = node;
|
|
61
|
+
// 清除 animation 里的 current;
|
|
62
|
+
if (n.animation) {
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
n.animation.frames = n.animation.frames.map(a => {
|
|
65
|
+
const frame = a.frame;
|
|
66
|
+
if (frame) {
|
|
67
|
+
const { current, ...f } = frame;
|
|
68
|
+
return { ...a, frame: f };
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
60
72
|
if (cache) {
|
|
61
73
|
return { ...n, ...cache };
|
|
62
74
|
}
|
|
63
75
|
return n;
|
|
64
76
|
});
|
|
65
|
-
// console.log(content);
|
|
66
77
|
return {
|
|
67
78
|
version: contentData.version,
|
|
68
79
|
content,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GameObjectData } from '@gedit/render-engine';
|
|
1
|
+
import { GameObjectData, FrameValue } from '@gedit/render-engine';
|
|
2
2
|
import { GameObjectIDERegister } from '@gedit/render-engine-ide';
|
|
3
3
|
import { RenderEngineIDEService as RenderEngineService } from '@gedit/render-engine-ide';
|
|
4
4
|
import { SchemaDecoration, SchemaType } from '@gedit/playground';
|
|
@@ -12,14 +12,14 @@ interface KeysValue {
|
|
|
12
12
|
// 添加进时间轴动画的条件;
|
|
13
13
|
const supportKeys: SchemaType[] = ['integer', 'float', 'color'];
|
|
14
14
|
// 三个数组 key 写死
|
|
15
|
-
export const animArrayKeys: {[key: string]: string} = {
|
|
15
|
+
export const animArrayKeys: { [key: string]: string } = {
|
|
16
16
|
'style.color': 'FillArray',
|
|
17
17
|
'style.line': 'LineArray',
|
|
18
18
|
'style.lineDash': 'LineDashArray',
|
|
19
19
|
};
|
|
20
20
|
function readAnimationKeys(
|
|
21
21
|
deco: SchemaDecoration,
|
|
22
|
-
keyList: { key: string; name: string
|
|
22
|
+
keyList: { key: string; name: string }[],
|
|
23
23
|
engineName: string,
|
|
24
24
|
currentKey?: string,
|
|
25
25
|
parentName?: string,
|
|
@@ -48,9 +48,8 @@ function readAnimationKeys(
|
|
|
48
48
|
} else if (
|
|
49
49
|
currentLabel &&
|
|
50
50
|
currentKey &&
|
|
51
|
-
(supportKeys.includes(deco.type) &&
|
|
52
|
-
|
|
53
|
-
|| animArrayKeys[currentKey])
|
|
51
|
+
((supportKeys.includes(deco.type) && !currentKey.match(/^(origin)/)) || // 干掉原点
|
|
52
|
+
animArrayKeys[currentKey])
|
|
54
53
|
) {
|
|
55
54
|
keyList.push({
|
|
56
55
|
key: currentKey,
|
|
@@ -93,3 +92,8 @@ export const getChangeAnimationData = (
|
|
|
93
92
|
});
|
|
94
93
|
return data;
|
|
95
94
|
};
|
|
95
|
+
|
|
96
|
+
export const sortFrame = (v: FrameValue) => {
|
|
97
|
+
v.sort((a, b) => a.time - b.time);
|
|
98
|
+
return v;
|
|
99
|
+
};
|