@visactor/vrender-core 0.19.11 → 0.19.13-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/graphic/richtext.d.ts +1 -1
- package/cjs/graphic/richtext.js +2 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +2 -3
- package/cjs/index.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +21 -0
- package/cjs/plugins/builtin-plugin/edit-module.js +81 -0
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +52 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +279 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
- package/cjs/render/contributions/render/draw-interceptor.js +2 -2
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/dist/index.es.js +479 -5
- package/es/graphic/richtext.d.ts +1 -1
- package/es/graphic/richtext.js +2 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/index.d.ts +1 -2
- package/es/index.js +2 -4
- package/es/index.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.d.ts +21 -0
- package/es/plugins/builtin-plugin/edit-module.js +73 -0
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +52 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +276 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
- package/es/render/contributions/render/draw-interceptor.js +2 -2
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { isString } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { Generator } from "../../common/generator";
|
|
4
|
+
|
|
5
|
+
import { createGroup, createLine, createRect } from "../../graphic";
|
|
6
|
+
|
|
7
|
+
import { EditModule } from "./edit-module";
|
|
8
|
+
|
|
9
|
+
export class RichTextEditPlugin {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.name = "RichTextEditPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
|
|
12
|
+
this.key = this.name + this._uid, this.editing = !1, this.pointerDown = !1, this.handleInput = (text, isComposing, cursorIdx, rt) => {
|
|
13
|
+
const p = this.getPointByColumnIdx(cursorIdx, rt);
|
|
14
|
+
this.hideSelection(), this.setCursor(p.x, p.y1, p.y2);
|
|
15
|
+
}, this.handleChange = (text, isComposing, cursorIdx, rt) => {
|
|
16
|
+
const p = this.getPointByColumnIdx(cursorIdx, rt);
|
|
17
|
+
this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx, this.setCursorAndTextArea(p.x, p.y1, p.y2, rt),
|
|
18
|
+
this.hideSelection();
|
|
19
|
+
}, this.handleMove = e => {
|
|
20
|
+
this.isRichtext(e) && (this.handleEnter(e), e.target.once("pointerleave", this.handleLeave),
|
|
21
|
+
this.showSelection(e));
|
|
22
|
+
}, this.handlePointerDown = e => {
|
|
23
|
+
this.editing ? this.onFocus(e) : this.deFocus(e), this.applyUpdate(), this.pointerDown = !0;
|
|
24
|
+
}, this.handlePointerUp = e => {
|
|
25
|
+
this.pointerDown = !1;
|
|
26
|
+
}, this.handleEnter = e => {
|
|
27
|
+
this.editing = !0, this.pluginService.stage.setCursor("text");
|
|
28
|
+
}, this.handleLeave = e => {
|
|
29
|
+
this.editing = !1, this.pluginService.stage.setCursor("default");
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
activate(context) {
|
|
33
|
+
this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove),
|
|
34
|
+
context.stage.on("pointerdown", this.handlePointerDown), context.stage.on("pointerup", this.handlePointerUp),
|
|
35
|
+
context.stage.on("pointerleave", this.handlePointerUp), this.editModule.onInput(this.handleInput),
|
|
36
|
+
this.editModule.onChange(this.handleChange);
|
|
37
|
+
}
|
|
38
|
+
showSelection(e) {
|
|
39
|
+
const cache = e.target.getFrameCache();
|
|
40
|
+
if (cache && this.editBg) {
|
|
41
|
+
if (this.pointerDown) {
|
|
42
|
+
let p0 = this.lastPoint, p1 = this.getEventPosition(e), line1Info = this.getLineByPoint(cache, p1);
|
|
43
|
+
const column1 = this.getColumnByLinePoint(line1Info, p1), y1 = line1Info.top, y2 = line1Info.top + line1Info.height;
|
|
44
|
+
let x = column1.left + column1.width, cursorIndex = this.getColumnIndex(cache, column1);
|
|
45
|
+
p1.x < column1.left + column1.width / 2 && (x = column1.left, cursorIndex -= 1),
|
|
46
|
+
p1.x = x, p1.y = (y1 + y2) / 2;
|
|
47
|
+
let line0Info = this.getLineByPoint(cache, p0);
|
|
48
|
+
if ((p0.y > p1.y || p0.y === p1.y && p0.x > p1.x) && ([p0, p1] = [ p1, p0 ], [line1Info, line0Info] = [ line0Info, line1Info ]),
|
|
49
|
+
this.editBg.removeAllChild(), line0Info === line1Info) {
|
|
50
|
+
const column0 = this.getColumnByLinePoint(line0Info, p0);
|
|
51
|
+
this.editBg.setAttributes({
|
|
52
|
+
x: p0.x,
|
|
53
|
+
y: line0Info.top,
|
|
54
|
+
width: p1.x - p0.x,
|
|
55
|
+
height: column0.height,
|
|
56
|
+
fill: "#336df4",
|
|
57
|
+
fillOpacity: .2
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
this.editBg.setAttributes({
|
|
61
|
+
x: 0,
|
|
62
|
+
y: line0Info.top,
|
|
63
|
+
width: 0,
|
|
64
|
+
height: 0
|
|
65
|
+
});
|
|
66
|
+
const startIdx = cache.lines.findIndex((item => item === line0Info)), endIdx = cache.lines.findIndex((item => item === line1Info));
|
|
67
|
+
let y = 0;
|
|
68
|
+
for (let i = startIdx; i <= endIdx; i++) {
|
|
69
|
+
const line = cache.lines[i];
|
|
70
|
+
if (i === startIdx) {
|
|
71
|
+
const p = line.paragraphs[line.paragraphs.length - 1];
|
|
72
|
+
this.editBg.add(createRect({
|
|
73
|
+
x: p0.x,
|
|
74
|
+
y: y,
|
|
75
|
+
width: p.left + p.width - p0.x,
|
|
76
|
+
height: line.height,
|
|
77
|
+
fill: "#336df4",
|
|
78
|
+
fillOpacity: .2
|
|
79
|
+
}));
|
|
80
|
+
} else if (i === endIdx) {
|
|
81
|
+
const p = line.paragraphs[0];
|
|
82
|
+
this.editBg.add(createRect({
|
|
83
|
+
x: p.left,
|
|
84
|
+
y: y,
|
|
85
|
+
width: p1.x - p.left,
|
|
86
|
+
height: line.height,
|
|
87
|
+
fill: "#336df4",
|
|
88
|
+
fillOpacity: .2
|
|
89
|
+
}));
|
|
90
|
+
} else {
|
|
91
|
+
const p0 = line.paragraphs[0], p1 = line.paragraphs[line.paragraphs.length - 1];
|
|
92
|
+
this.editBg.add(createRect({
|
|
93
|
+
x: p0.left,
|
|
94
|
+
y: y,
|
|
95
|
+
width: p1.left + p1.width - p0.left,
|
|
96
|
+
height: line.height,
|
|
97
|
+
fill: "#336df4",
|
|
98
|
+
fillOpacity: .2
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
y += line.height;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.curCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1 + 2, y2 - 2, e.target);
|
|
105
|
+
}
|
|
106
|
+
this.applyUpdate();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
hideSelection() {
|
|
110
|
+
this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
|
|
111
|
+
fill: "transparent"
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
isRichtext(e) {
|
|
115
|
+
return !(!e.target || "richtext" !== e.target.type);
|
|
116
|
+
}
|
|
117
|
+
getEventPosition(e) {
|
|
118
|
+
const p = this.pluginService.stage.eventPointTransform(e), p1 = {
|
|
119
|
+
x: 0,
|
|
120
|
+
y: 0
|
|
121
|
+
};
|
|
122
|
+
return e.target.globalTransMatrix.transformPoint(p, p1), p1;
|
|
123
|
+
}
|
|
124
|
+
getLineByPoint(cache, p1) {
|
|
125
|
+
let lineInfo = cache.lines[0];
|
|
126
|
+
for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
|
|
127
|
+
return lineInfo;
|
|
128
|
+
}
|
|
129
|
+
getColumnByLinePoint(lineInfo, p1) {
|
|
130
|
+
let columnInfo = lineInfo.paragraphs[0];
|
|
131
|
+
for (let i = 0; i < lineInfo.paragraphs.length && !(columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x); i++) columnInfo = lineInfo.paragraphs[i];
|
|
132
|
+
return columnInfo;
|
|
133
|
+
}
|
|
134
|
+
onFocus(e) {
|
|
135
|
+
this.deFocus(e);
|
|
136
|
+
const target = e.target;
|
|
137
|
+
this.tryUpdateRichtext(target);
|
|
138
|
+
const shadowRoot = target.attachShadow();
|
|
139
|
+
shadowRoot.setAttributes({
|
|
140
|
+
shadowRootIdx: -1
|
|
141
|
+
});
|
|
142
|
+
const cache = target.getFrameCache();
|
|
143
|
+
if (!cache) return;
|
|
144
|
+
if (!this.editLine) {
|
|
145
|
+
const line = createLine({
|
|
146
|
+
x: 0,
|
|
147
|
+
y: 0,
|
|
148
|
+
lineWidth: 1,
|
|
149
|
+
stroke: "black"
|
|
150
|
+
});
|
|
151
|
+
line.animate().to({
|
|
152
|
+
opacity: 1
|
|
153
|
+
}, 10, "linear").wait(700).to({
|
|
154
|
+
opacity: 0
|
|
155
|
+
}, 10, "linear").wait(700).loop(1 / 0), this.editLine = line;
|
|
156
|
+
const g = createGroup({
|
|
157
|
+
x: 0,
|
|
158
|
+
y: 0,
|
|
159
|
+
width: 0,
|
|
160
|
+
height: 0
|
|
161
|
+
});
|
|
162
|
+
this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
|
|
163
|
+
}
|
|
164
|
+
const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
|
|
165
|
+
if (lineInfo) {
|
|
166
|
+
const columnInfo = this.getColumnByLinePoint(lineInfo, p1);
|
|
167
|
+
if (!columnInfo) return;
|
|
168
|
+
let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height, x = columnInfo.left + columnInfo.width;
|
|
169
|
+
y1 += 2, y2 -= 2;
|
|
170
|
+
let cursorIndex = this.getColumnIndex(cache, columnInfo);
|
|
171
|
+
p1.x < columnInfo.left + columnInfo.width / 2 && (x = columnInfo.left, cursorIndex -= 1),
|
|
172
|
+
this.lastPoint = {
|
|
173
|
+
x: x,
|
|
174
|
+
y: (y1 + y2) / 2
|
|
175
|
+
}, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
|
|
176
|
+
this.setCursorAndTextArea(x, y1, y2, target);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
getPointByColumnIdx(idx, rt) {
|
|
180
|
+
const cache = rt.getFrameCache(), {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, idx);
|
|
181
|
+
let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
|
|
182
|
+
return y1 += 2, y2 -= 2, {
|
|
183
|
+
x: columnInfo.left + columnInfo.width,
|
|
184
|
+
y1: y1,
|
|
185
|
+
y2: y2
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
getColumnIndex(cache, cInfo) {
|
|
189
|
+
let inputIndex = -1;
|
|
190
|
+
for (let i = 0; i < cache.lines.length; i++) {
|
|
191
|
+
const line = cache.lines[i];
|
|
192
|
+
for (let j = 0; j < line.paragraphs.length; j++) if (inputIndex++, cInfo === line.paragraphs[j]) return inputIndex;
|
|
193
|
+
}
|
|
194
|
+
return -1;
|
|
195
|
+
}
|
|
196
|
+
getColumnByIndex(cache, index) {
|
|
197
|
+
let inputIndex = -1;
|
|
198
|
+
for (let i = 0; i < cache.lines.length; i++) {
|
|
199
|
+
const lineInfo = cache.lines[i];
|
|
200
|
+
for (let j = 0; j < lineInfo.paragraphs.length; j++) {
|
|
201
|
+
const columnInfo = lineInfo.paragraphs[j];
|
|
202
|
+
if (inputIndex++, inputIndex === index) return {
|
|
203
|
+
lineInfo: lineInfo,
|
|
204
|
+
columnInfo: columnInfo
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
setCursorAndTextArea(x, y1, y2, rt) {
|
|
211
|
+
this.editLine.setAttributes({
|
|
212
|
+
points: [ {
|
|
213
|
+
x: x,
|
|
214
|
+
y: y1
|
|
215
|
+
}, {
|
|
216
|
+
x: x,
|
|
217
|
+
y: y2
|
|
218
|
+
} ]
|
|
219
|
+
});
|
|
220
|
+
const out = {
|
|
221
|
+
x: 0,
|
|
222
|
+
y: 0
|
|
223
|
+
};
|
|
224
|
+
rt.globalTransMatrix.getInverse().transformPoint({
|
|
225
|
+
x: x,
|
|
226
|
+
y: y1
|
|
227
|
+
}, out);
|
|
228
|
+
const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
|
|
229
|
+
out.x += left, out.y += top, this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
|
|
230
|
+
}
|
|
231
|
+
setCursor(x, y1, y2) {
|
|
232
|
+
this.editLine.setAttributes({
|
|
233
|
+
points: [ {
|
|
234
|
+
x: x,
|
|
235
|
+
y: y1
|
|
236
|
+
}, {
|
|
237
|
+
x: x,
|
|
238
|
+
y: y2
|
|
239
|
+
} ]
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
applyUpdate() {
|
|
243
|
+
this.pluginService.stage.renderNextFrame();
|
|
244
|
+
}
|
|
245
|
+
deFocus(e) {
|
|
246
|
+
e.target.detachShadow(), this.editLine && (this.editLine.parent.removeChild(this.editLine),
|
|
247
|
+
this.editLine.release(), this.editLine = null, this.editBg.parent.removeChild(this.editBg),
|
|
248
|
+
this.editBg.release(), this.editBg = null);
|
|
249
|
+
}
|
|
250
|
+
splitText(text) {
|
|
251
|
+
return Array.from(text);
|
|
252
|
+
}
|
|
253
|
+
tryUpdateRichtext(richtext) {
|
|
254
|
+
if (!richtext.getFrameCache().lines.every((line => line.paragraphs.every((item => !(item.text && isString(item.text) && this.splitText(item.text).length > 1)))))) {
|
|
255
|
+
const tc = [];
|
|
256
|
+
richtext.attribute.textConfig.forEach((item => {
|
|
257
|
+
const textList = this.splitText(item.text.toString());
|
|
258
|
+
if (isString(item.text) && textList.length > 1) for (let i = 0; i < textList.length; i++) {
|
|
259
|
+
const t = textList[i];
|
|
260
|
+
tc.push(Object.assign(Object.assign({}, item), {
|
|
261
|
+
text: t
|
|
262
|
+
}));
|
|
263
|
+
} else tc.push(item);
|
|
264
|
+
})), richtext.doUpdateFrameCache(tc);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
onSelect() {}
|
|
268
|
+
deactivate(context) {
|
|
269
|
+
context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown),
|
|
270
|
+
context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp);
|
|
271
|
+
}
|
|
272
|
+
release() {
|
|
273
|
+
this.editModule.release();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=richtext-edit-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/richtext-edit-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAepE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,OAAO,kBAAkB;IAA/B;QACE,SAAI,G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AC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACtD,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;wBACtB,EAAE,CAAC,IAAI,iCAAM,IAAI,KAAE,IAAI,EAAE,CAAC,IAAG,CAAC;qBAC/B;iBACF;qBAAM;oBACL,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACf;YACH,CAAC,CAAC,CAAC;YACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;SACjC;IACH,CAAC;IAED,QAAQ;QACN,OAAO;IACT,CAAC;IAED,UAAU,CAAC,OAAuB;QAEhC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACrD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;CACF","file":"richtext-edit-plugin.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { isString } from '@visactor/vutils';\nimport { Generator } from '../../common/generator';\nimport { createGroup, createLine, createRect } from '../../graphic';\nimport type {\n IGroup,\n ILine,\n IPlugin,\n IPluginService,\n IRect,\n IRichText,\n IRichTextCharacter,\n IRichTextFrame,\n IRichTextIcon,\n IRichTextLine,\n IRichTextParagraph,\n IRichTextParagraphCharacter\n} from '../../interface';\nimport { EditModule } from './edit-module';\n\nexport class RichTextEditPlugin implements IPlugin {\n name: 'RichTextEditPlugin' = 'RichTextEditPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n editing: boolean = false;\n editLine: ILine;\n editBg: IGroup;\n pointerDown: boolean = false;\n // 用于selection中保存上一次click时候的位置\n lastPoint?: IPointLike;\n editModule: EditModule;\n\n // 当前的cursor信息\n curCursorIdx: number;\n selectionStartCursorIdx: number;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n this.editModule = new EditModule();\n // context.stage.on('click', this.handleClick);\n context.stage.on('pointermove', this.handleMove);\n context.stage.on('pointerdown', this.handlePointerDown);\n context.stage.on('pointerup', this.handlePointerUp);\n context.stage.on('pointerleave', this.handlePointerUp);\n\n this.editModule.onInput(this.handleInput);\n this.editModule.onChange(this.handleChange);\n }\n\n handleInput = (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => {\n // 修改cursor的位置,但并不同步,因为这可能是临时的\n const p = this.getPointByColumnIdx(cursorIdx, rt);\n this.hideSelection();\n this.setCursor(p.x, p.y1, p.y2);\n };\n handleChange = (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => {\n // 修改cursor的位置,并同步到editModule\n const p = this.getPointByColumnIdx(cursorIdx, rt);\n this.curCursorIdx = cursorIdx;\n this.selectionStartCursorIdx = cursorIdx;\n this.setCursorAndTextArea(p.x, p.y1, p.y2, rt);\n this.hideSelection();\n };\n\n handleMove = (e: PointerEvent) => {\n if (!this.isRichtext(e)) {\n return;\n }\n this.handleEnter(e);\n (e.target as any).once('pointerleave', this.handleLeave);\n\n this.showSelection(e);\n };\n\n showSelection(e: PointerEvent) {\n const cache = (e.target as IRichText).getFrameCache();\n if (!(cache && this.editBg)) {\n return;\n }\n if (this.pointerDown) {\n let p0 = this.lastPoint;\n // 计算p1在字符中的位置\n let p1 = this.getEventPosition(e);\n let line1Info = this.getLineByPoint(cache, p1);\n const column1 = this.getColumnByLinePoint(line1Info, p1);\n const y1 = line1Info.top;\n const y2 = line1Info.top + line1Info.height;\n let x = column1.left + column1.width;\n let cursorIndex = this.getColumnIndex(cache, column1);\n if (p1.x < column1.left + column1.width / 2) {\n x = column1.left;\n cursorIndex -= 1;\n }\n p1.x = x;\n p1.y = (y1 + y2) / 2;\n let line0Info = this.getLineByPoint(cache, p0);\n if (p0.y > p1.y || (p0.y === p1.y && p0.x > p1.x)) {\n [p0, p1] = [p1, p0];\n [line1Info, line0Info] = [line0Info, line1Info];\n }\n\n this.editBg.removeAllChild();\n if (line0Info === line1Info) {\n const column0 = this.getColumnByLinePoint(line0Info, p0);\n this.editBg.setAttributes({\n x: p0.x,\n y: line0Info.top,\n width: p1.x - p0.x,\n height: column0.height,\n fill: '#336df4',\n fillOpacity: 0.2\n });\n } else {\n this.editBg.setAttributes({ x: 0, y: line0Info.top, width: 0, height: 0 });\n const startIdx = cache.lines.findIndex(item => item === line0Info);\n const endIdx = cache.lines.findIndex(item => item === line1Info);\n let y = 0;\n for (let i = startIdx; i <= endIdx; i++) {\n const line = cache.lines[i];\n if (i === startIdx) {\n const p = line.paragraphs[line.paragraphs.length - 1];\n this.editBg.add(\n createRect({\n x: p0.x,\n y,\n width: p.left + p.width - p0.x,\n height: line.height,\n fill: '#336df4',\n fillOpacity: 0.2\n })\n );\n } else if (i === endIdx) {\n const p = line.paragraphs[0];\n this.editBg.add(\n createRect({\n x: p.left,\n y,\n width: p1.x - p.left,\n height: line.height,\n fill: '#336df4',\n fillOpacity: 0.2\n })\n );\n } else {\n const p0 = line.paragraphs[0];\n const p1 = line.paragraphs[line.paragraphs.length - 1];\n this.editBg.add(\n createRect({\n x: p0.left,\n y,\n width: p1.left + p1.width - p0.left,\n height: line.height,\n fill: '#336df4',\n fillOpacity: 0.2\n })\n );\n }\n y += line.height;\n }\n }\n\n this.curCursorIdx = cursorIndex;\n this.setCursorAndTextArea(x, y1 + 2, y2 - 2, e.target as IRichText);\n }\n this.applyUpdate();\n }\n\n hideSelection() {\n if (this.editBg) {\n this.editBg.removeAllChild();\n this.editBg.setAttributes({ fill: 'transparent' });\n }\n }\n\n handlePointerDown = (e: PointerEvent) => {\n if (this.editing) {\n this.onFocus(e);\n } else {\n this.deFocus(e);\n }\n this.applyUpdate();\n this.pointerDown = true;\n };\n handlePointerUp = (e: PointerEvent) => {\n this.pointerDown = false;\n };\n\n handleEnter = (e: PointerEvent) => {\n this.editing = true;\n this.pluginService.stage.setCursor('text');\n };\n\n handleLeave = (e: PointerEvent) => {\n this.editing = false;\n this.pluginService.stage.setCursor('default');\n };\n\n isRichtext(e: PointerEvent) {\n return !!(e.target && (e.target as any).type === 'richtext');\n }\n\n protected getEventPosition(e: PointerEvent): IPointLike {\n const p = this.pluginService.stage.eventPointTransform(e);\n\n const p1 = { x: 0, y: 0 };\n (e.target as IRichText).globalTransMatrix.transformPoint(p, p1);\n return p1;\n }\n\n protected getLineByPoint(cache: IRichTextFrame, p1: IPointLike): IRichTextLine {\n let lineInfo = cache.lines[0];\n for (let i = 0; i < cache.lines.length; i++) {\n if (lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y) {\n break;\n }\n lineInfo = cache.lines[i + 1];\n }\n\n return lineInfo;\n }\n protected getColumnByLinePoint(lineInfo: IRichTextLine, p1: IPointLike): IRichTextParagraph | IRichTextIcon {\n let columnInfo = lineInfo.paragraphs[0];\n for (let i = 0; i < lineInfo.paragraphs.length; i++) {\n if (columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x) {\n break;\n }\n columnInfo = lineInfo.paragraphs[i];\n }\n\n return columnInfo;\n }\n\n onFocus(e: PointerEvent) {\n this.deFocus(e);\n\n // 添加shadowGraphic\n const target = e.target as IRichText;\n this.tryUpdateRichtext(target);\n const shadowRoot = target.attachShadow();\n shadowRoot.setAttributes({ shadowRootIdx: -1 });\n const cache = target.getFrameCache();\n if (!cache) {\n return;\n }\n if (!this.editLine) {\n const line = createLine({ x: 0, y: 0, lineWidth: 1, stroke: 'black' });\n line\n .animate()\n .to({ opacity: 1 }, 10, 'linear')\n .wait(700)\n .to({ opacity: 0 }, 10, 'linear')\n .wait(700)\n .loop(Infinity);\n this.editLine = line;\n\n const g = createGroup({ x: 0, y: 0, width: 0, height: 0 });\n this.editBg = g;\n shadowRoot.add(this.editLine);\n shadowRoot.add(this.editBg);\n }\n\n const p1 = this.getEventPosition(e);\n\n const lineInfo = this.getLineByPoint(cache, p1);\n\n if (lineInfo) {\n const columnInfo = this.getColumnByLinePoint(lineInfo, p1);\n if (!columnInfo) {\n return;\n }\n\n let y1 = lineInfo.top;\n let y2 = lineInfo.top + lineInfo.height;\n let x = columnInfo.left + columnInfo.width;\n y1 += 2;\n y2 -= 2;\n let cursorIndex = this.getColumnIndex(cache, columnInfo);\n if (p1.x < columnInfo.left + columnInfo.width / 2) {\n x = columnInfo.left;\n cursorIndex -= 1;\n }\n\n this.lastPoint = { x, y: (y1 + y2) / 2 };\n\n this.curCursorIdx = cursorIndex;\n this.selectionStartCursorIdx = cursorIndex;\n this.setCursorAndTextArea(x, y1, y2, target);\n }\n }\n\n protected getPointByColumnIdx(idx: number, rt: IRichText) {\n const cache = rt.getFrameCache();\n const { lineInfo, columnInfo } = this.getColumnByIndex(cache, idx);\n let y1 = lineInfo.top;\n let y2 = lineInfo.top + lineInfo.height;\n const x = columnInfo.left + columnInfo.width;\n y1 += 2;\n y2 -= 2;\n\n return { x, y1, y2 };\n }\n\n protected getColumnIndex(cache: IRichTextFrame, cInfo: IRichTextParagraph | IRichTextIcon) {\n // TODO 认为都是单个字符拆分的\n let inputIndex = -1;\n for (let i = 0; i < cache.lines.length; i++) {\n const line = cache.lines[i];\n for (let j = 0; j < line.paragraphs.length; j++) {\n inputIndex++;\n if (cInfo === line.paragraphs[j]) {\n return inputIndex;\n }\n }\n }\n return -1;\n }\n protected getColumnByIndex(\n cache: IRichTextFrame,\n index: number\n ): {\n lineInfo: IRichTextLine;\n columnInfo: IRichTextParagraph | IRichTextIcon;\n } | null {\n // TODO 认为都是单个字符拆分的\n let inputIndex = -1;\n for (let i = 0; i < cache.lines.length; i++) {\n const lineInfo = cache.lines[i];\n for (let j = 0; j < lineInfo.paragraphs.length; j++) {\n const columnInfo = lineInfo.paragraphs[j];\n inputIndex++;\n if (inputIndex === index) {\n return {\n lineInfo,\n columnInfo\n };\n }\n }\n }\n return null;\n }\n\n protected setCursorAndTextArea(x: number, y1: number, y2: number, rt: IRichText) {\n this.editLine.setAttributes({\n points: [\n { x, y: y1 },\n { x, y: y2 }\n ]\n });\n const out = { x: 0, y: 0 };\n rt.globalTransMatrix.getInverse().transformPoint({ x, y: y1 }, out);\n // TODO 考虑stage变换\n const { left, top } = this.pluginService.stage.window.getBoundingClientRect();\n out.x += left;\n out.y += top;\n\n this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);\n }\n protected setCursor(x: number, y1: number, y2: number) {\n this.editLine.setAttributes({\n points: [\n { x, y: y1 },\n { x, y: y2 }\n ]\n });\n }\n\n applyUpdate() {\n this.pluginService.stage.renderNextFrame();\n }\n deFocus(e: PointerEvent) {\n const target = e.target as IRichText;\n target.detachShadow();\n if (this.editLine) {\n this.editLine.parent.removeChild(this.editLine);\n this.editLine.release();\n this.editLine = null;\n\n this.editBg.parent.removeChild(this.editBg);\n this.editBg.release();\n this.editBg = null;\n }\n }\n\n splitText(text: string) {\n // 😁这种emoji长度算两个,所以得处理一下\n return Array.from(text);\n }\n\n tryUpdateRichtext(richtext: IRichText) {\n const cache = richtext.getFrameCache();\n if (\n !cache.lines.every(line =>\n line.paragraphs.every(item => !(item.text && isString(item.text) && this.splitText(item.text).length > 1))\n )\n ) {\n const tc: IRichTextCharacter[] = [];\n richtext.attribute.textConfig.forEach((item: IRichTextParagraphCharacter) => {\n const textList = this.splitText(item.text.toString());\n if (isString(item.text) && textList.length > 1) {\n // 拆分\n for (let i = 0; i < textList.length; i++) {\n const t = textList[i];\n tc.push({ ...item, text: t });\n }\n } else {\n tc.push(item);\n }\n });\n richtext.doUpdateFrameCache(tc);\n }\n }\n\n onSelect() {\n return;\n }\n\n deactivate(context: IPluginService): void {\n // context.stage.off('pointerdown', this.handleClick);\n context.stage.off('pointermove', this.handleMove);\n context.stage.off('pointerdown', this.handlePointerDown);\n context.stage.off('pointerup', this.handlePointerUp);\n context.stage.off('pointerleave', this.handlePointerUp);\n }\n\n release() {\n this.editModule.release();\n }\n}\n"]}
|
|
@@ -25,11 +25,11 @@ export class ShadowRootDrawItemInterceptorContribution {
|
|
|
25
25
|
this.order = 1;
|
|
26
26
|
}
|
|
27
27
|
afterDrawItem(graphic, renderService, drawContext, drawContribution, params) {
|
|
28
|
-
return (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) && this.drawItem(graphic, renderService, drawContext, drawContribution, params),
|
|
28
|
+
return null == graphic.attribute.shadowRootIdx && graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0 || (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx || graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0) && this.drawItem(graphic, renderService, drawContext, drawContribution, params),
|
|
29
29
|
!1;
|
|
30
30
|
}
|
|
31
31
|
beforeDrawItem(graphic, renderService, drawContext, drawContribution, params) {
|
|
32
|
-
return graphic.attribute.shadowRootIdx < 0 && this.drawItem(graphic, renderService, drawContext, drawContribution, params),
|
|
32
|
+
return null == graphic.attribute.shadowRootIdx && graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0 || (graphic.attribute.shadowRootIdx < 0 || graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0) && this.drawItem(graphic, renderService, drawContext, drawContribution, params),
|
|
33
33
|
!1;
|
|
34
34
|
}
|
|
35
35
|
drawItem(graphic, renderService, drawContext, drawContribution, params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAchF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,UAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,UAAU,EAAE,CAAC;AAK/C,MAAM,OAAO,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAgEpB,CAAC;IA/DC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAEjC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,EAAE;YAC3E,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;SAC9E;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,cAAc,CACZ,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAEjC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,EAAE;YACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB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EH,gBAAgB,CAAC,WAAW,CAAC,OAAiB,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;gBAErG,OAAO,CAAC,cAAc,EAAE,CAAC;gBACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACnB,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;oBACf,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,EAAE,CAAC;gBACjB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACnB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,gBAAgB,CAAC,WAAW,CAAC,OAAiB,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;aAChG;SACF;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds, pi2 } from '@visactor/vutils';\nimport { graphicCreator, mat3Tomat4, multiplyMat4Mat4 } from '../../../graphic';\nimport type {\n IArc,\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicAttribute,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { ARC3D_NUMBER_TYPE } from '../../../graphic/constants';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute.shadowRootIdx < 0) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n // hack逻辑,如果是饼图的话,需要依次绘制不同的边\n let isPie: boolean = false;\n let is3d: boolean = false;\n graphic.forEachChildren((c: IGraphic) => {\n isPie = c.numberType === ARC3D_NUMBER_TYPE;\n return !isPie;\n });\n graphic.forEachChildren((c: IGraphic) => {\n is3d = !!c.findFace;\n return !is3d;\n });\n if (isPie) {\n const children = graphic.getChildren() as IArc[];\n // 绘制内层\n // drawContext.hack_pieFace = 'inside';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制底部\n // drawContext.hack_pieFace = 'bottom';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制外部\n // 排序一下\n const sortedChildren = [...children];\n sortedChildren.sort((a, b) => {\n let angle1 = ((a.attribute.startAngle ?? 0) + (a.attribute.endAngle ?? 0)) / 2;\n let angle2 = ((b.attribute.startAngle ?? 0) + (b.attribute.endAngle ?? 0)) / 2;\n while (angle1 < 0) {\n angle1 += pi2;\n }\n while (angle2 < 0) {\n angle2 += pi2;\n }\n return angle2 - angle1;\n });\n sortedChildren.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n graphic.removeAllChild();\n graphic.update();\n sortedChildren.forEach(c => {\n graphic.appendChild(c);\n });\n const m = graphic.parent.globalTransMatrix;\n drawContext.hack_pieFace = 'outside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制内部\n drawContext.hack_pieFace = 'inside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制顶部\n drawContext.hack_pieFace = 'top';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n graphic.removeAllChild();\n children.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n children.forEach(c => {\n graphic.appendChild(c);\n });\n } else if (is3d) {\n // 排序这些图元\n const children = graphic.getChildren() as IGraphic[];\n const zChildren = children.map(g => {\n const face3d = g.findFace();\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2] + g.attribute.z ?? 0)[2];\n });\n const ave_z = viewdVerticesZ.reduce((a, b) => a + b, 0);\n return {\n ave_z,\n g\n };\n });\n zChildren.sort((a, b) => b.ave_z - a.ave_z);\n graphic.removeAllChild();\n zChildren.forEach(i => {\n i.g._next = null;\n i.g._prev = null;\n });\n graphic.update();\n zChildren.forEach(i => {\n graphic.add(i.g);\n });\n\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix, true);\n\n graphic.removeAllChild();\n children.forEach(g => {\n g._next = null;\n g._prev = null;\n });\n graphic.update();\n children.forEach(g => {\n graphic.add(g);\n });\n } else {\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix);\n }\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAA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O,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds, pi2 } from '@visactor/vutils';\nimport { graphicCreator, mat3Tomat4, multiplyMat4Mat4 } from '../../../graphic';\nimport type {\n IArc,\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicAttribute,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { ARC3D_NUMBER_TYPE } from '../../../graphic/constants';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n // hack逻辑,如果是饼图的话,需要依次绘制不同的边\n let isPie: boolean = false;\n let is3d: boolean = false;\n graphic.forEachChildren((c: IGraphic) => {\n isPie = c.numberType === ARC3D_NUMBER_TYPE;\n return !isPie;\n });\n graphic.forEachChildren((c: IGraphic) => {\n is3d = !!c.findFace;\n return !is3d;\n });\n if (isPie) {\n const children = graphic.getChildren() as IArc[];\n // 绘制内层\n // drawContext.hack_pieFace = 'inside';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制底部\n // drawContext.hack_pieFace = 'bottom';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制外部\n // 排序一下\n const sortedChildren = [...children];\n sortedChildren.sort((a, b) => {\n let angle1 = ((a.attribute.startAngle ?? 0) + (a.attribute.endAngle ?? 0)) / 2;\n let angle2 = ((b.attribute.startAngle ?? 0) + (b.attribute.endAngle ?? 0)) / 2;\n while (angle1 < 0) {\n angle1 += pi2;\n }\n while (angle2 < 0) {\n angle2 += pi2;\n }\n return angle2 - angle1;\n });\n sortedChildren.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n graphic.removeAllChild();\n graphic.update();\n sortedChildren.forEach(c => {\n graphic.appendChild(c);\n });\n const m = graphic.parent.globalTransMatrix;\n drawContext.hack_pieFace = 'outside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制内部\n drawContext.hack_pieFace = 'inside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制顶部\n drawContext.hack_pieFace = 'top';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n graphic.removeAllChild();\n children.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n children.forEach(c => {\n graphic.appendChild(c);\n });\n } else if (is3d) {\n // 排序这些图元\n const children = graphic.getChildren() as IGraphic[];\n const zChildren = children.map(g => {\n const face3d = g.findFace();\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2] + g.attribute.z ?? 0)[2];\n });\n const ave_z = viewdVerticesZ.reduce((a, b) => a + b, 0);\n return {\n ave_z,\n g\n };\n });\n zChildren.sort((a, b) => b.ave_z - a.ave_z);\n graphic.removeAllChild();\n zChildren.forEach(i => {\n i.g._next = null;\n i.g._prev = null;\n });\n graphic.update();\n zChildren.forEach(i => {\n graphic.add(i.g);\n });\n\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix, true);\n\n graphic.removeAllChild();\n children.forEach(g => {\n g._next = null;\n g._prev = null;\n });\n graphic.update();\n children.forEach(g => {\n graphic.add(g);\n });\n } else {\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix);\n }\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|