@visactor/vrender-core 0.20.9 → 0.21.0-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/graphic-service/graphic-service.d.ts +2 -0
- package/cjs/graphic/graphic-service/graphic-service.js +10 -5
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/interface/graphic-service.d.ts +2 -0
- package/cjs/interface/graphic-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +3 -0
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/dist/index.es.js +26 -8
- package/es/graphic/graphic-service/graphic-service.d.ts +2 -0
- package/es/graphic/graphic-service/graphic-service.js +11 -4
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/interface/graphic-service.d.ts +2 -0
- package/es/interface/graphic-service.js.map +1 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +3 -0
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ export declare class DefaultGraphicService implements IGraphicService {
|
|
|
17
17
|
afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, {
|
|
18
18
|
globalAABBBounds: IAABBBounds;
|
|
19
19
|
}, boolean]>;
|
|
20
|
+
clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;
|
|
20
21
|
};
|
|
21
22
|
protected tempAABBBounds1: AABBBounds;
|
|
22
23
|
protected tempAABBBounds2: AABBBounds;
|
|
@@ -31,6 +32,7 @@ export declare class DefaultGraphicService implements IGraphicService {
|
|
|
31
32
|
afterUpdateAABBBounds(graphic: IGraphic, stage: IStage, bounds: IAABBBounds, params: {
|
|
32
33
|
globalAABBBounds: IAABBBounds;
|
|
33
34
|
}, selfChange: boolean): void;
|
|
35
|
+
clearAABBBounds(graphic: IGraphic, stage: IStage, b: IAABBBounds): void;
|
|
34
36
|
updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean;
|
|
35
37
|
updateHTMLTextAABBBounds(attribute: ITextGraphicAttribute, textTheme: Required<ITextGraphicAttribute>, aabbBounds: IAABBBounds, graphic?: IText): void;
|
|
36
38
|
combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic): void;
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
value: !0
|
|
17
17
|
}), exports.DefaultGraphicService = exports.shouldUseMat4 = exports.getModelMatrix = exports.getExtraModelMatrix = void 0;
|
|
18
18
|
|
|
19
|
-
const inversify_lite_1 = require("../../common/inversify-lite"), vutils_1 = require("@visactor/vutils"), tapable_1 = require("../../tapable"), text_1 = require("../../common/text"), tools_1 = require("../tools"), matrix_allocate_1 = require("../../allocator/matrix-allocate"), bounds_context_1 = require("../../common/bounds-context"), render_command_list_1 = require("../../common/render-command-list"), constants_1 = require("../constants"), matrix_1 = require("../../common/matrix");
|
|
19
|
+
const inversify_lite_1 = require("../../common/inversify-lite"), vutils_1 = require("@visactor/vutils"), tapable_1 = require("../../tapable"), text_1 = require("../../common/text"), tools_1 = require("../tools"), matrix_allocate_1 = require("../../allocator/matrix-allocate"), bounds_context_1 = require("../../common/bounds-context"), render_command_list_1 = require("../../common/render-command-list"), constants_1 = require("../constants"), matrix_1 = require("../../common/matrix"), application_1 = require("../../application");
|
|
20
20
|
|
|
21
21
|
function getExtraModelMatrix(dx, dy, graphic) {
|
|
22
22
|
const {alpha: alpha, beta: beta} = graphic.attribute;
|
|
@@ -96,7 +96,8 @@ let DefaultGraphicService = class {
|
|
|
96
96
|
onAddIncremental: new tapable_1.SyncHook([ "graphic", "group", "stage" ]),
|
|
97
97
|
onClearIncremental: new tapable_1.SyncHook([ "graphic", "group", "stage" ]),
|
|
98
98
|
beforeUpdateAABBBounds: new tapable_1.SyncHook([ "graphic", "stage", "willUpdate", "aabbBounds" ]),
|
|
99
|
-
afterUpdateAABBBounds: new tapable_1.SyncHook([ "graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange" ])
|
|
99
|
+
afterUpdateAABBBounds: new tapable_1.SyncHook([ "graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange" ]),
|
|
100
|
+
clearAABBBounds: new tapable_1.SyncHook([ "graphic", "stage", "aabbBounds" ])
|
|
100
101
|
}, this.tempAABBBounds1 = new vutils_1.AABBBounds, this.tempAABBBounds2 = new vutils_1.AABBBounds;
|
|
101
102
|
}
|
|
102
103
|
onAttributeUpdate(graphic) {
|
|
@@ -123,6 +124,9 @@ let DefaultGraphicService = class {
|
|
|
123
124
|
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
124
125
|
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
125
126
|
}
|
|
127
|
+
clearAABBBounds(graphic, stage, b) {
|
|
128
|
+
this.hooks.clearAABBBounds.taps.length && this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
129
|
+
}
|
|
126
130
|
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
127
131
|
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
128
132
|
if (!path) return !1;
|
|
@@ -172,10 +176,11 @@ let DefaultGraphicService = class {
|
|
|
172
176
|
validCheck(attribute, theme, aabbBounds, graphic) {
|
|
173
177
|
if (!graphic) return !0;
|
|
174
178
|
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
175
|
-
if (graphic.shadowRoot) return !0;
|
|
176
|
-
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
179
|
+
if (graphic.shadowRoot || graphic.isContainer) return !0;
|
|
177
180
|
const {visible: visible = theme.visible} = attribute;
|
|
178
|
-
return
|
|
181
|
+
return !(!graphic.valid || !visible) || (aabbBounds.empty() || (graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix),
|
|
182
|
+
application_1.application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds),
|
|
183
|
+
aabbBounds.clear()), !1);
|
|
179
184
|
}
|
|
180
185
|
updateTempAABBBounds(aabbBounds) {
|
|
181
186
|
const tb1 = this.tempAABBBounds1, tb2 = this.tempAABBBounds2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/graphic-service/graphic-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAAiE;AAEjE,6CAAmF;AACnF,2CAAyC;AAczC,4CAAuE;AACvE,oCAAuC;AACvC,qEAA+D;AAE/D,gEAA4D;AAC5D,0EAAqE;AACrE,4CAA8C;AAC9C,gDAAsH;AAEtH,SAAgB,mBAAmB,CAAC,EAAU,EAAE,EAAU,EAAE,OAAiB;IAC3E,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAElE,MAAM,OAAO,GAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,IAAI,QAAQ,EAAE;QACZ,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YACnC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAClC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;SAC1D;aAAM;YACL,OAAO,CAAC,CAA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AU,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,UAAuB;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QACzE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QAEzE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACtB,CAAC;CACF,CAAA;AA7NY,qBAAqB;IADjC,IAAA,2BAAU,GAAE;IAgBE,WAAA,IAAA,uBAAM,EAAC,0BAAc,CAAC,CAAA;;GAfxB,qBAAqB,CA6NjC;AA7NY,sDAAqB","file":"graphic-service.js","sourcesContent":["import { inject, injectable } from '../../common/inversify-lite';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isNumber, transformBoundsWithMatrix } from '@visactor/vutils';\nimport { SyncHook } from '../../tapable';\nimport type {\n mat4,\n IGraphicAttribute,\n IGraphic,\n IGroup,\n IStage,\n IText,\n ITextGraphicAttribute,\n ITransform,\n IGraphicService,\n IGraphicCreator,\n ISyncHook\n} from '../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../common/text';\nimport { boundStroke } from '../tools';\nimport { mat4Allocate } from '../../allocator/matrix-allocate';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { BoundsContext } from '../../common/bounds-context';\nimport { renderCommandList } from '../../common/render-command-list';\nimport { GraphicCreator } from '../constants';\nimport { identityMat4, multiplyMat4Mat4, rotateX, rotateY, rotateZ, scaleMat4, translate } from '../../common/matrix';\n\nexport function getExtraModelMatrix(dx: number, dy: number, graphic: IGraphic): mat4 | null {\n const { alpha, beta } = graphic.attribute;\n if (!alpha && !beta) {\n return null;\n }\n const { anchor3d = graphic.attribute.anchor } = graphic.attribute;\n\n const _anchor: [number, number] = [0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n if (graphic.type === 'text') {\n const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // 计算偏移\n _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n }\n\n // 应用偏移,计算全局的偏移\n _anchor[0] += dx;\n _anchor[1] += dy;\n // matrix.scale(dpr, dpr);\n\n const modelMatrix = mat4Allocate.allocate();\n translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]);\n if (beta) {\n rotateX(modelMatrix, modelMatrix, beta);\n }\n if (alpha) {\n rotateY(modelMatrix, modelMatrix, alpha);\n }\n translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]);\n\n return modelMatrix;\n}\n\n// 计算3d下的模型矩阵\nexport function getModelMatrix(out: mat4, graphic: IGraphic, theme: ITransform) {\n const {\n x = theme.x,\n y = theme.y,\n z = theme.z,\n dx = theme.dx,\n dy = theme.dy,\n dz = theme.dz,\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n scaleZ = theme.scaleZ,\n alpha = theme.alpha,\n beta = theme.beta,\n angle = theme.angle,\n anchor3d = graphic.attribute.anchor,\n anchor\n } = graphic.attribute;\n\n const _anchor: [number, number, number] = [0, 0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n _anchor[2] = anchor3d[2] ?? 0;\n }\n\n // if (graphic.type === 'text') {\n // const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // // 计算偏移\n // _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n // }\n\n identityMat4(out);\n // 平移\n translate(out, out, [x + dx, y + dy, z + dz]);\n translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]);\n rotateX(out, out, beta);\n rotateY(out, out, alpha);\n // 基于z轴的偏移基于anchor计算\n // rotateZ(out, out, angle);\n translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]);\n scaleMat4(out, out, [scaleX, scaleY, scaleZ]);\n\n // 计算基于z轴的偏移\n if (angle) {\n const m = mat4Allocate.allocate();\n const _anchor: [number, number] = [0, 0];\n if (anchor) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n translate(m, m, [_anchor[0], _anchor[1], 0]);\n // 基于z轴的偏移基于anchor计算\n rotateZ(m, m, angle);\n translate(m, m, [-_anchor[0], -_anchor[1], 0]);\n\n multiplyMat4Mat4(out, out, m);\n }\n}\n\nexport function shouldUseMat4(graphic: IGraphic) {\n const { alpha, beta } = graphic.attribute;\n return alpha || beta;\n}\n\n// 管理graphic\n@injectable()\nexport class DefaultGraphicService implements IGraphicService {\n declare hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n };\n\n // 临时bounds,用作缓存\n protected tempAABBBounds1: AABBBounds;\n protected tempAABBBounds2: AABBBounds;\n constructor(@inject(GraphicCreator) public readonly creator: IGraphicCreator) {\n this.hooks = {\n onAttributeUpdate: new SyncHook<[IGraphic]>(['graphic']),\n onSetStage: new SyncHook<[IGraphic, IStage]>(['graphic', 'stage']),\n onRemove: new SyncHook<[IGraphic]>(['graphic']),\n onRelease: new SyncHook<[IGraphic]>(['graphic']),\n onAddIncremental: new SyncHook<[IGraphic, IGroup, IStage]>(['graphic', 'group', 'stage']),\n onClearIncremental: new SyncHook<[IGroup, IStage]>(['graphic', 'group', 'stage']),\n beforeUpdateAABBBounds: new SyncHook<[IGraphic, IStage, boolean, IAABBBounds]>([\n 'graphic',\n 'stage',\n 'willUpdate',\n 'aabbBounds'\n ]),\n afterUpdateAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>([\n 'graphic',\n 'stage',\n 'aabbBounds',\n 'globalAABBBounds',\n 'selfChange'\n ])\n };\n this.tempAABBBounds1 = new AABBBounds();\n this.tempAABBBounds2 = new AABBBounds();\n }\n onAttributeUpdate(graphic: IGraphic) {\n if (this.hooks.onAttributeUpdate.taps.length) {\n this.hooks.onAttributeUpdate.call(graphic);\n }\n }\n onSetStage(graphic: IGraphic, stage: IStage): void {\n if (this.hooks.onSetStage.taps.length) {\n this.hooks.onSetStage.call(graphic, stage);\n }\n }\n onRemove(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRemove.taps.length) {\n this.hooks.onRemove.call(graphic);\n }\n }\n onRelease(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRelease.taps.length) {\n this.hooks.onRelease.call(graphic);\n }\n }\n onAddIncremental(graphic: IGraphic, group: IGroup, stage: IStage): void {\n if (this.hooks.onAddIncremental.taps.length) {\n this.hooks.onAddIncremental.call(graphic, group, stage);\n }\n }\n onClearIncremental(group: IGroup, stage: IStage): void {\n if (this.hooks.onClearIncremental.taps.length) {\n this.hooks.onClearIncremental.call(group, stage);\n }\n }\n beforeUpdateAABBBounds(graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) {\n if (this.hooks.beforeUpdateAABBBounds.taps.length) {\n this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);\n }\n }\n afterUpdateAABBBounds(\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) {\n if (this.hooks.afterUpdateAABBBounds.taps.length) {\n this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);\n }\n }\n // TODO delete\n updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean {\n const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n if (!path) {\n return false;\n }\n const boundsContext = new BoundsContext(aabbBounds);\n renderCommandList(path.commandList, boundsContext, 0, 0);\n return true;\n }\n\n updateHTMLTextAABBBounds(\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) {\n const { textAlign, textBaseline } = attribute;\n if (attribute.forceBoundsHeight != null) {\n const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();\n const dy = textLayoutOffsetY(textBaseline, h, h);\n aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);\n }\n if (attribute.forceBoundsWidth != null) {\n const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();\n const dx = textDrawOffsetX(textAlign, w);\n aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);\n }\n }\n\n combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic) {\n // 合并shadowRoot的Bounds\n if (graphic && graphic.shadowRoot) {\n const b = graphic.shadowRoot.AABBBounds;\n bounds.union(b);\n }\n }\n\n transformAABBBounds(\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) {\n if (!aabbBounds.empty()) {\n const {\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n stroke = theme.stroke,\n shadowBlur = theme.shadowBlur,\n lineWidth = theme.lineWidth,\n pickStrokeBuffer = theme.pickStrokeBuffer,\n strokeBoundsBuffer = theme.strokeBoundsBuffer\n } = attribute;\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n if (stroke && lineWidth) {\n const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);\n boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n if (shadowBlur) {\n const { shadowOffsetX = theme.shadowOffsetX, shadowOffsetY = theme.shadowOffsetY } = attribute;\n const shadowBlurWidth = (shadowBlur / Math.abs(scaleX + scaleY)) * 2;\n boundStroke(tb1, shadowBlurWidth, false, strokeBoundsBuffer + 1);\n tb1.translate(shadowOffsetX, shadowOffsetY);\n aabbBounds.union(tb1);\n // tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n }\n\n // 合并shadowRoot的bounds\n this.combindShadowAABBBounds(aabbBounds, graphic);\n if (aabbBounds.empty()) {\n return;\n }\n\n // 性能优化逻辑,group类型变换较少,不需要矩阵变换\n let updateMatrix = true;\n const m = graphic.transMatrix;\n if (graphic && graphic.isContainer) {\n updateMatrix = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0);\n }\n updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);\n\n // TODO 加上锚点\n // transformBounds(aabbBounds, x, y, scaleX, scaleY, angle);\n // if (graphic.attribute.postMatrix) {\n // console.log('aaa');\n // transformBoundsWithMatrix(aabbBounds, graphic.attribute.postMatrix);\n // }\n // aabbBounds.translate(dx, dy);\n }\n\n validCheck(\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ): boolean {\n if (!graphic) {\n return true;\n }\n\n // 设置了强制wh,那就直接认为是合法的\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n return true;\n }\n\n if (graphic.shadowRoot) {\n return true;\n }\n\n if (!graphic.valid) {\n aabbBounds.clear();\n return false;\n }\n const { visible = theme.visible } = attribute;\n if (!visible) {\n aabbBounds.clear();\n return false;\n }\n return true;\n }\n\n updateTempAABBBounds(aabbBounds: IAABBBounds) {\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n\n return { tb1, tb2 };\n }\n}\n"]}
|
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C,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,EAAE;YAE/B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE;gBACvB,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,mBAAmB,CAAE,OAAO,CAAC,MAAiB,CAAC,iBAAiB,CAAC,CAAC;gBAC/F,yBAAW,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBAC/E,UAAU,CAAC,KAAK,EAAE,CAAC;aACpB;YACD,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,UAAuB;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QACzE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QAEzE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACtB,CAAC;CACF,CAAA;AAvOY,qBAAqB;IADjC,IAAA,2BAAU,GAAE;IAiBE,WAAA,IAAA,uBAAM,EAAC,0BAAc,CAAC,CAAA;;GAhBxB,qBAAqB,CAuOjC;AAvOY,sDAAqB","file":"graphic-service.js","sourcesContent":["import { inject, injectable } from '../../common/inversify-lite';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isNumber, transformBoundsWithMatrix } from '@visactor/vutils';\nimport { SyncHook } from '../../tapable';\nimport type {\n mat4,\n IGraphicAttribute,\n IGraphic,\n IGroup,\n IStage,\n IText,\n ITextGraphicAttribute,\n ITransform,\n IGraphicService,\n IGraphicCreator,\n ISyncHook\n} from '../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../common/text';\nimport { boundStroke } from '../tools';\nimport { mat4Allocate } from '../../allocator/matrix-allocate';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { BoundsContext } from '../../common/bounds-context';\nimport { renderCommandList } from '../../common/render-command-list';\nimport { GraphicCreator } from '../constants';\nimport { identityMat4, multiplyMat4Mat4, rotateX, rotateY, rotateZ, scaleMat4, translate } from '../../common/matrix';\nimport { application } from '../../application';\n\nexport function getExtraModelMatrix(dx: number, dy: number, graphic: IGraphic): mat4 | null {\n const { alpha, beta } = graphic.attribute;\n if (!alpha && !beta) {\n return null;\n }\n const { anchor3d = graphic.attribute.anchor } = graphic.attribute;\n\n const _anchor: [number, number] = [0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n if (graphic.type === 'text') {\n const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // 计算偏移\n _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n }\n\n // 应用偏移,计算全局的偏移\n _anchor[0] += dx;\n _anchor[1] += dy;\n // matrix.scale(dpr, dpr);\n\n const modelMatrix = mat4Allocate.allocate();\n translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]);\n if (beta) {\n rotateX(modelMatrix, modelMatrix, beta);\n }\n if (alpha) {\n rotateY(modelMatrix, modelMatrix, alpha);\n }\n translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]);\n\n return modelMatrix;\n}\n\n// 计算3d下的模型矩阵\nexport function getModelMatrix(out: mat4, graphic: IGraphic, theme: ITransform) {\n const {\n x = theme.x,\n y = theme.y,\n z = theme.z,\n dx = theme.dx,\n dy = theme.dy,\n dz = theme.dz,\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n scaleZ = theme.scaleZ,\n alpha = theme.alpha,\n beta = theme.beta,\n angle = theme.angle,\n anchor3d = graphic.attribute.anchor,\n anchor\n } = graphic.attribute;\n\n const _anchor: [number, number, number] = [0, 0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n _anchor[2] = anchor3d[2] ?? 0;\n }\n\n // if (graphic.type === 'text') {\n // const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // // 计算偏移\n // _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n // }\n\n identityMat4(out);\n // 平移\n translate(out, out, [x + dx, y + dy, z + dz]);\n translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]);\n rotateX(out, out, beta);\n rotateY(out, out, alpha);\n // 基于z轴的偏移基于anchor计算\n // rotateZ(out, out, angle);\n translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]);\n scaleMat4(out, out, [scaleX, scaleY, scaleZ]);\n\n // 计算基于z轴的偏移\n if (angle) {\n const m = mat4Allocate.allocate();\n const _anchor: [number, number] = [0, 0];\n if (anchor) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n translate(m, m, [_anchor[0], _anchor[1], 0]);\n // 基于z轴的偏移基于anchor计算\n rotateZ(m, m, angle);\n translate(m, m, [-_anchor[0], -_anchor[1], 0]);\n\n multiplyMat4Mat4(out, out, m);\n }\n}\n\nexport function shouldUseMat4(graphic: IGraphic) {\n const { alpha, beta } = graphic.attribute;\n return alpha || beta;\n}\n\n// 管理graphic\n@injectable()\nexport class DefaultGraphicService implements IGraphicService {\n declare hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;\n };\n\n // 临时bounds,用作缓存\n protected tempAABBBounds1: AABBBounds;\n protected tempAABBBounds2: AABBBounds;\n constructor(@inject(GraphicCreator) public readonly creator: IGraphicCreator) {\n this.hooks = {\n onAttributeUpdate: new SyncHook<[IGraphic]>(['graphic']),\n onSetStage: new SyncHook<[IGraphic, IStage]>(['graphic', 'stage']),\n onRemove: new SyncHook<[IGraphic]>(['graphic']),\n onRelease: new SyncHook<[IGraphic]>(['graphic']),\n onAddIncremental: new SyncHook<[IGraphic, IGroup, IStage]>(['graphic', 'group', 'stage']),\n onClearIncremental: new SyncHook<[IGroup, IStage]>(['graphic', 'group', 'stage']),\n beforeUpdateAABBBounds: new SyncHook<[IGraphic, IStage, boolean, IAABBBounds]>([\n 'graphic',\n 'stage',\n 'willUpdate',\n 'aabbBounds'\n ]),\n afterUpdateAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>([\n 'graphic',\n 'stage',\n 'aabbBounds',\n 'globalAABBBounds',\n 'selfChange'\n ]),\n clearAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds]>(['graphic', 'stage', 'aabbBounds'])\n };\n this.tempAABBBounds1 = new AABBBounds();\n this.tempAABBBounds2 = new AABBBounds();\n }\n onAttributeUpdate(graphic: IGraphic) {\n if (this.hooks.onAttributeUpdate.taps.length) {\n this.hooks.onAttributeUpdate.call(graphic);\n }\n }\n onSetStage(graphic: IGraphic, stage: IStage): void {\n if (this.hooks.onSetStage.taps.length) {\n this.hooks.onSetStage.call(graphic, stage);\n }\n }\n onRemove(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRemove.taps.length) {\n this.hooks.onRemove.call(graphic);\n }\n }\n onRelease(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRelease.taps.length) {\n this.hooks.onRelease.call(graphic);\n }\n }\n onAddIncremental(graphic: IGraphic, group: IGroup, stage: IStage): void {\n if (this.hooks.onAddIncremental.taps.length) {\n this.hooks.onAddIncremental.call(graphic, group, stage);\n }\n }\n onClearIncremental(group: IGroup, stage: IStage): void {\n if (this.hooks.onClearIncremental.taps.length) {\n this.hooks.onClearIncremental.call(group, stage);\n }\n }\n beforeUpdateAABBBounds(graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) {\n if (this.hooks.beforeUpdateAABBBounds.taps.length) {\n this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);\n }\n }\n afterUpdateAABBBounds(\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) {\n if (this.hooks.afterUpdateAABBBounds.taps.length) {\n this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);\n }\n }\n clearAABBBounds(graphic: IGraphic, stage: IStage, b: IAABBBounds) {\n if (this.hooks.clearAABBBounds.taps.length) {\n this.hooks.clearAABBBounds.call(graphic, stage, b);\n }\n }\n // TODO delete\n updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean {\n const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n if (!path) {\n return false;\n }\n const boundsContext = new BoundsContext(aabbBounds);\n renderCommandList(path.commandList, boundsContext, 0, 0);\n return true;\n }\n\n updateHTMLTextAABBBounds(\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) {\n const { textAlign, textBaseline } = attribute;\n if (attribute.forceBoundsHeight != null) {\n const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();\n const dy = textLayoutOffsetY(textBaseline, h, h);\n aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);\n }\n if (attribute.forceBoundsWidth != null) {\n const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();\n const dx = textDrawOffsetX(textAlign, w);\n aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);\n }\n }\n\n combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic) {\n // 合并shadowRoot的Bounds\n if (graphic && graphic.shadowRoot) {\n const b = graphic.shadowRoot.AABBBounds;\n bounds.union(b);\n }\n }\n\n transformAABBBounds(\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) {\n if (!aabbBounds.empty()) {\n const {\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n stroke = theme.stroke,\n shadowBlur = theme.shadowBlur,\n lineWidth = theme.lineWidth,\n pickStrokeBuffer = theme.pickStrokeBuffer,\n strokeBoundsBuffer = theme.strokeBoundsBuffer\n } = attribute;\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n if (stroke && lineWidth) {\n const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);\n boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n if (shadowBlur) {\n const { shadowOffsetX = theme.shadowOffsetX, shadowOffsetY = theme.shadowOffsetY } = attribute;\n const shadowBlurWidth = (shadowBlur / Math.abs(scaleX + scaleY)) * 2;\n boundStroke(tb1, shadowBlurWidth, false, strokeBoundsBuffer + 1);\n tb1.translate(shadowOffsetX, shadowOffsetY);\n aabbBounds.union(tb1);\n // tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n }\n\n // 合并shadowRoot的bounds\n this.combindShadowAABBBounds(aabbBounds, graphic);\n if (aabbBounds.empty()) {\n return;\n }\n\n // 性能优化逻辑,group类型变换较少,不需要矩阵变换\n let updateMatrix = true;\n const m = graphic.transMatrix;\n if (graphic && graphic.isContainer) {\n updateMatrix = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0);\n }\n updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);\n\n // TODO 加上锚点\n // transformBounds(aabbBounds, x, y, scaleX, scaleY, angle);\n // if (graphic.attribute.postMatrix) {\n // console.log('aaa');\n // transformBoundsWithMatrix(aabbBounds, graphic.attribute.postMatrix);\n // }\n // aabbBounds.translate(dx, dy);\n }\n\n validCheck(\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ): boolean {\n if (!graphic) {\n return true;\n }\n\n // 设置了强制wh,那就直接认为是合法的\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n return true;\n }\n\n // 是Group或者有影子节点的话,就直接认为是合法的\n if (graphic.shadowRoot || graphic.isContainer) {\n return true;\n }\n\n const { visible = theme.visible } = attribute;\n\n if (!(graphic.valid && visible)) {\n // application.graphicService.beforeUpdateAABBBounds(graphic, graphic.stage, true, aabbBounds);\n if (!aabbBounds.empty()) {\n graphic.parent && aabbBounds.transformWithMatrix((graphic.parent as IGroup).globalTransMatrix);\n application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds);\n aabbBounds.clear();\n }\n return false;\n }\n return true;\n }\n\n updateTempAABBBounds(aabbBounds: IAABBBounds) {\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n\n return { tb1, tb2 };\n }\n}\n"]}
|
|
@@ -21,11 +21,13 @@ export interface IGraphicService {
|
|
|
21
21
|
afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, {
|
|
22
22
|
globalAABBBounds: IAABBBounds;
|
|
23
23
|
}, boolean]>;
|
|
24
|
+
clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;
|
|
24
25
|
};
|
|
25
26
|
beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;
|
|
26
27
|
afterUpdateAABBBounds: (graphic: IGraphic, stage: IStage, bounds: IAABBBounds, params: {
|
|
27
28
|
globalAABBBounds: IAABBBounds;
|
|
28
29
|
}, selfChange: boolean) => void;
|
|
30
|
+
clearAABBBounds: (graphic: IGraphic, stage: IStage, b: IAABBBounds) => void;
|
|
29
31
|
creator: IGraphicCreator;
|
|
30
32
|
validCheck: (attribute: Partial<IGraphicAttribute>, theme: Required<IGraphicAttribute>, aabbBounds: IAABBBounds, graphic?: IGraphic) => boolean;
|
|
31
33
|
transformAABBBounds: (attribute: Partial<IGraphicAttribute>, aabbBounds: IAABBBounds, theme: Required<IGraphicAttribute>, miter: boolean, graphic?: IGraphic) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic-service.ts"],"names":[],"mappings":"","file":"graphic-service.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\n\nimport type { ISyncHook } from './sync-hook';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IStage } from './stage';\nimport type {\n IRectGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n ISymbolGraphicAttribute,\n ICircleGraphicAttribute,\n ICircle,\n ISymbol,\n IArcGraphicAttribute,\n IArc,\n IAreaGraphicAttribute,\n IArea,\n ILineGraphicAttribute,\n IPathGraphicAttribute,\n ILine,\n IPath,\n IPolygonGraphicAttribute,\n IPolygon,\n ITextGraphicAttribute,\n IText,\n IRichTextGraphicAttribute,\n IRichText,\n IImageGraphicAttribute,\n IImage,\n IRect3dGraphicAttribute,\n IRect,\n IRect3d,\n IShadowRoot,\n IWrapTextGraphicAttribute\n} from './graphic/index';\n\nexport interface IGraphicService {\n // themeService: IThemeService;\n onAttributeUpdate: (graphic: IGraphic) => void;\n onSetStage: (graphic: IGraphic, stage: IStage) => void;\n onRemove: (graphic: IGraphic) => void;\n onRelease: (graphic: IGraphic) => void;\n onAddIncremental: (graphic: IGraphic, group: IGroup, stage: IStage) => void;\n onClearIncremental: (group: IGroup, stage: IStage) => void;\n hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n };\n beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;\n afterUpdateAABBBounds: (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => void;\n\n creator: IGraphicCreator;\n validCheck: (\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => boolean;\n\n transformAABBBounds: (\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) => void;\n\n updateHTMLTextAABBBounds: (\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) => void;\n\n combindShadowAABBBounds: (bounds: IAABBBounds, graphic?: IGraphic) => void;\n updateTempAABBBounds: (aabbBounds: IAABBBounds) => { tb1: IAABBBounds; tb2: IAABBBounds };\n}\n\nexport type IGraphicCreator = {\n arc: (attributes: IArcGraphicAttribute) => IArc;\n area: (attributes: IAreaGraphicAttribute) => IArea;\n circle: (attributes: ICircleGraphicAttribute) => ICircle;\n group: (attributes: IGroupGraphicAttribute) => IGroup;\n image: (attributes: IImageGraphicAttribute) => IImage;\n line: (attributes: ILineGraphicAttribute) => ILine;\n path: (attributes: IPathGraphicAttribute) => IPath;\n rect: (attributes: IRectGraphicAttribute) => IRect;\n rect3d: (attributes: IRect3dGraphicAttribute) => IRect3d;\n symbol: (attributes: ISymbolGraphicAttribute) => ISymbol;\n text: (attributes: ITextGraphicAttribute) => IText;\n richtext: (attributes: IRichTextGraphicAttribute) => IRichText;\n polygon: (attributes: IPolygonGraphicAttribute) => IPolygon;\n shadowRoot: (graphic?: IGraphic) => IShadowRoot;\n wrapText: (attributes: IWrapTextGraphicAttribute) => IText;\n};\n\nexport interface IArcBoundsContribution {\n updateBounds: (\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IAreaBoundsContribution {\n updateBounds: (\n attribute: IAreaGraphicAttribute,\n arcTheme: Required<IAreaGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ICircleBoundsContribution {\n updateBounds: (\n attribute: ICircleGraphicAttribute,\n circleTheme: Required<ICircleGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IPathBoundsContribution {\n updateBounds: (\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IRectBoundsContribution {\n updateBounds: (\n attribute: IRectGraphicAttribute,\n rectTheme: Required<IRectGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ISymbolBoundsContribution {\n updateBounds: (\n attribute: ISymbolGraphicAttribute,\n SymbolTheme: Required<ISymbolGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\nexport interface IImageBoundsContribution {\n updateBounds: (\n attribute: IImageGraphicAttribute,\n ImageTheme: Required<IImageGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic-service.ts"],"names":[],"mappings":"","file":"graphic-service.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\n\nimport type { ISyncHook } from './sync-hook';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IStage } from './stage';\nimport type {\n IRectGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n ISymbolGraphicAttribute,\n ICircleGraphicAttribute,\n ICircle,\n ISymbol,\n IArcGraphicAttribute,\n IArc,\n IAreaGraphicAttribute,\n IArea,\n ILineGraphicAttribute,\n IPathGraphicAttribute,\n ILine,\n IPath,\n IPolygonGraphicAttribute,\n IPolygon,\n ITextGraphicAttribute,\n IText,\n IRichTextGraphicAttribute,\n IRichText,\n IImageGraphicAttribute,\n IImage,\n IRect3dGraphicAttribute,\n IRect,\n IRect3d,\n IShadowRoot,\n IWrapTextGraphicAttribute\n} from './graphic/index';\n\nexport interface IGraphicService {\n // themeService: IThemeService;\n onAttributeUpdate: (graphic: IGraphic) => void;\n onSetStage: (graphic: IGraphic, stage: IStage) => void;\n onRemove: (graphic: IGraphic) => void;\n onRelease: (graphic: IGraphic) => void;\n onAddIncremental: (graphic: IGraphic, group: IGroup, stage: IStage) => void;\n onClearIncremental: (group: IGroup, stage: IStage) => void;\n hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;\n };\n beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;\n afterUpdateAABBBounds: (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => void;\n clearAABBBounds: (graphic: IGraphic, stage: IStage, b: IAABBBounds) => void;\n\n creator: IGraphicCreator;\n validCheck: (\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => boolean;\n\n transformAABBBounds: (\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) => void;\n\n updateHTMLTextAABBBounds: (\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) => void;\n\n combindShadowAABBBounds: (bounds: IAABBBounds, graphic?: IGraphic) => void;\n updateTempAABBBounds: (aabbBounds: IAABBBounds) => { tb1: IAABBBounds; tb2: IAABBBounds };\n}\n\nexport type IGraphicCreator = {\n arc: (attributes: IArcGraphicAttribute) => IArc;\n area: (attributes: IAreaGraphicAttribute) => IArea;\n circle: (attributes: ICircleGraphicAttribute) => ICircle;\n group: (attributes: IGroupGraphicAttribute) => IGroup;\n image: (attributes: IImageGraphicAttribute) => IImage;\n line: (attributes: ILineGraphicAttribute) => ILine;\n path: (attributes: IPathGraphicAttribute) => IPath;\n rect: (attributes: IRectGraphicAttribute) => IRect;\n rect3d: (attributes: IRect3dGraphicAttribute) => IRect3d;\n symbol: (attributes: ISymbolGraphicAttribute) => ISymbol;\n text: (attributes: ITextGraphicAttribute) => IText;\n richtext: (attributes: IRichTextGraphicAttribute) => IRichText;\n polygon: (attributes: IPolygonGraphicAttribute) => IPolygon;\n shadowRoot: (graphic?: IGraphic) => IShadowRoot;\n wrapText: (attributes: IWrapTextGraphicAttribute) => IText;\n};\n\nexport interface IArcBoundsContribution {\n updateBounds: (\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IAreaBoundsContribution {\n updateBounds: (\n attribute: IAreaGraphicAttribute,\n arcTheme: Required<IAreaGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ICircleBoundsContribution {\n updateBounds: (\n attribute: ICircleGraphicAttribute,\n circleTheme: Required<ICircleGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IPathBoundsContribution {\n updateBounds: (\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IRectBoundsContribution {\n updateBounds: (\n attribute: IRectGraphicAttribute,\n rectTheme: Required<IRectGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ISymbolBoundsContribution {\n updateBounds: (\n attribute: ISymbolGraphicAttribute,\n SymbolTheme: Required<ISymbolGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\nexport interface IImageBoundsContribution {\n updateBounds: (\n attribute: IImageGraphicAttribute,\n ImageTheme: Required<IImageGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n"]}
|
|
@@ -19,6 +19,8 @@ class DirtyBoundsPlugin {
|
|
|
19
19
|
stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
|
|
20
20
|
})), application_1.application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
21
21
|
stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
|
|
22
|
+
})), application_1.application.graphicService.hooks.clearAABBBounds.tap(this.key, ((graphic, stage, bounds) => {
|
|
23
|
+
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
|
|
22
24
|
})), application_1.application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
|
|
23
25
|
const stage = graphic.stage;
|
|
24
26
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
|
|
@@ -27,6 +29,7 @@ class DirtyBoundsPlugin {
|
|
|
27
29
|
deactivate(context) {
|
|
28
30
|
application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps = application_1.application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
29
31
|
application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps = application_1.application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
32
|
+
application_1.application.graphicService.hooks.clearAABBBounds.taps = application_1.application.graphicService.hooks.clearAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
30
33
|
context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter((item => item.name !== this.key)),
|
|
31
34
|
application_1.application.graphicService.hooks.onRemove.taps = application_1.application.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key));
|
|
32
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAC9C,sDAAmD;AAEnD,mDAAgD;AAEhD,MAAM,YAAY,GAAG,IAAI,mBAAU,EAAE,CAAC;AAEtC,MAAa,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-pl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CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5G,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9FD,8CA8FC","file":"dirty-bounds-plugin.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds } from '@visactor/vutils';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n application.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n application.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(graphic.globalAABBBounds);\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.clearAABBBounds.taps =\n application.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -14316,7 +14316,8 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
14316
14316
|
'aabbBounds',
|
|
14317
14317
|
'globalAABBBounds',
|
|
14318
14318
|
'selfChange'
|
|
14319
|
-
])
|
|
14319
|
+
]),
|
|
14320
|
+
clearAABBBounds: new SyncHook(['graphic', 'stage', 'aabbBounds'])
|
|
14320
14321
|
};
|
|
14321
14322
|
this.tempAABBBounds1 = new AABBBounds();
|
|
14322
14323
|
this.tempAABBBounds2 = new AABBBounds();
|
|
@@ -14361,6 +14362,11 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
14361
14362
|
this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
14362
14363
|
}
|
|
14363
14364
|
}
|
|
14365
|
+
clearAABBBounds(graphic, stage, b) {
|
|
14366
|
+
if (this.hooks.clearAABBBounds.taps.length) {
|
|
14367
|
+
this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
14368
|
+
}
|
|
14369
|
+
}
|
|
14364
14370
|
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
14365
14371
|
const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
14366
14372
|
if (!path) {
|
|
@@ -14426,16 +14432,16 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
14426
14432
|
if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {
|
|
14427
14433
|
return true;
|
|
14428
14434
|
}
|
|
14429
|
-
if (graphic.shadowRoot) {
|
|
14435
|
+
if (graphic.shadowRoot || graphic.isContainer) {
|
|
14430
14436
|
return true;
|
|
14431
14437
|
}
|
|
14432
|
-
if (!graphic.valid) {
|
|
14433
|
-
aabbBounds.clear();
|
|
14434
|
-
return false;
|
|
14435
|
-
}
|
|
14436
14438
|
const { visible = theme.visible } = attribute;
|
|
14437
|
-
if (!visible) {
|
|
14438
|
-
aabbBounds.
|
|
14439
|
+
if (!(graphic.valid && visible)) {
|
|
14440
|
+
if (!aabbBounds.empty()) {
|
|
14441
|
+
graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix);
|
|
14442
|
+
application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds);
|
|
14443
|
+
aabbBounds.clear();
|
|
14444
|
+
}
|
|
14439
14445
|
return false;
|
|
14440
14446
|
}
|
|
14441
14447
|
return true;
|
|
@@ -24323,6 +24329,14 @@ class DirtyBoundsPlugin {
|
|
|
24323
24329
|
}
|
|
24324
24330
|
stage.dirty(params.globalAABBBounds);
|
|
24325
24331
|
});
|
|
24332
|
+
application.graphicService.hooks.clearAABBBounds.tap(this.key, (graphic, stage, bounds) => {
|
|
24333
|
+
if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
|
|
24334
|
+
return;
|
|
24335
|
+
}
|
|
24336
|
+
if (stage) {
|
|
24337
|
+
stage.dirty(bounds);
|
|
24338
|
+
}
|
|
24339
|
+
});
|
|
24326
24340
|
application.graphicService.hooks.onRemove.tap(this.key, (graphic) => {
|
|
24327
24341
|
const stage = graphic.stage;
|
|
24328
24342
|
if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
|
|
@@ -24342,6 +24356,10 @@ class DirtyBoundsPlugin {
|
|
|
24342
24356
|
application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {
|
|
24343
24357
|
return item.name !== this.key;
|
|
24344
24358
|
});
|
|
24359
|
+
application.graphicService.hooks.clearAABBBounds.taps =
|
|
24360
|
+
application.graphicService.hooks.clearAABBBounds.taps.filter(item => {
|
|
24361
|
+
return item.name !== this.key;
|
|
24362
|
+
});
|
|
24345
24363
|
context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {
|
|
24346
24364
|
return item.name !== this.key;
|
|
24347
24365
|
});
|
|
@@ -17,6 +17,7 @@ export declare class DefaultGraphicService implements IGraphicService {
|
|
|
17
17
|
afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, {
|
|
18
18
|
globalAABBBounds: IAABBBounds;
|
|
19
19
|
}, boolean]>;
|
|
20
|
+
clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;
|
|
20
21
|
};
|
|
21
22
|
protected tempAABBBounds1: AABBBounds;
|
|
22
23
|
protected tempAABBBounds2: AABBBounds;
|
|
@@ -31,6 +32,7 @@ export declare class DefaultGraphicService implements IGraphicService {
|
|
|
31
32
|
afterUpdateAABBBounds(graphic: IGraphic, stage: IStage, bounds: IAABBBounds, params: {
|
|
32
33
|
globalAABBBounds: IAABBBounds;
|
|
33
34
|
}, selfChange: boolean): void;
|
|
35
|
+
clearAABBBounds(graphic: IGraphic, stage: IStage, b: IAABBBounds): void;
|
|
34
36
|
updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean;
|
|
35
37
|
updateHTMLTextAABBBounds(attribute: ITextGraphicAttribute, textTheme: Required<ITextGraphicAttribute>, aabbBounds: IAABBBounds, graphic?: IText): void;
|
|
36
38
|
combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic): void;
|
|
@@ -30,6 +30,8 @@ import { GraphicCreator } from "../constants";
|
|
|
30
30
|
|
|
31
31
|
import { identityMat4, multiplyMat4Mat4, rotateX, rotateY, rotateZ, scaleMat4, translate } from "../../common/matrix";
|
|
32
32
|
|
|
33
|
+
import { application } from "../../application";
|
|
34
|
+
|
|
33
35
|
export function getExtraModelMatrix(dx, dy, graphic) {
|
|
34
36
|
const {alpha: alpha, beta: beta} = graphic.attribute;
|
|
35
37
|
if (!alpha && !beta) return null;
|
|
@@ -103,7 +105,8 @@ let DefaultGraphicService = class {
|
|
|
103
105
|
onAddIncremental: new SyncHook([ "graphic", "group", "stage" ]),
|
|
104
106
|
onClearIncremental: new SyncHook([ "graphic", "group", "stage" ]),
|
|
105
107
|
beforeUpdateAABBBounds: new SyncHook([ "graphic", "stage", "willUpdate", "aabbBounds" ]),
|
|
106
|
-
afterUpdateAABBBounds: new SyncHook([ "graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange" ])
|
|
108
|
+
afterUpdateAABBBounds: new SyncHook([ "graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange" ]),
|
|
109
|
+
clearAABBBounds: new SyncHook([ "graphic", "stage", "aabbBounds" ])
|
|
107
110
|
}, this.tempAABBBounds1 = new AABBBounds, this.tempAABBBounds2 = new AABBBounds;
|
|
108
111
|
}
|
|
109
112
|
onAttributeUpdate(graphic) {
|
|
@@ -130,6 +133,9 @@ let DefaultGraphicService = class {
|
|
|
130
133
|
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
131
134
|
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
132
135
|
}
|
|
136
|
+
clearAABBBounds(graphic, stage, b) {
|
|
137
|
+
this.hooks.clearAABBBounds.taps.length && this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
138
|
+
}
|
|
133
139
|
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
134
140
|
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
135
141
|
if (!path) return !1;
|
|
@@ -176,10 +182,11 @@ let DefaultGraphicService = class {
|
|
|
176
182
|
validCheck(attribute, theme, aabbBounds, graphic) {
|
|
177
183
|
if (!graphic) return !0;
|
|
178
184
|
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
179
|
-
if (graphic.shadowRoot) return !0;
|
|
180
|
-
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
185
|
+
if (graphic.shadowRoot || graphic.isContainer) return !0;
|
|
181
186
|
const {visible: visible = theme.visible} = attribute;
|
|
182
|
-
return
|
|
187
|
+
return !(!graphic.valid || !visible) || (aabbBounds.empty() || (graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix),
|
|
188
|
+
application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds),
|
|
189
|
+
aabbBounds.clear()), !1);
|
|
183
190
|
}
|
|
184
191
|
updateTempAABBBounds(aabbBounds) {
|
|
185
192
|
const tb1 = this.tempAABBBounds1, tb2 = this.tempAABBBounds2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/graph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KAAK,EAAE,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,UAAuB;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QACzE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QAEzE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACtB,CAAC;CACF,CAAA;AA7NY,qBAAqB;IADjC,UAAU,EAAE;IAgBE,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;;GAfxB,qBAAqB,CA6NjC;SA7NY,qBAAqB","file":"graphic-service.js","sourcesContent":["import { inject, injectable } from '../../common/inversify-lite';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isNumber, transformBoundsWithMatrix } from '@visactor/vutils';\nimport { SyncHook } from '../../tapable';\nimport type {\n mat4,\n IGraphicAttribute,\n IGraphic,\n IGroup,\n IStage,\n IText,\n ITextGraphicAttribute,\n ITransform,\n IGraphicService,\n IGraphicCreator,\n ISyncHook\n} from '../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../common/text';\nimport { boundStroke } from '../tools';\nimport { mat4Allocate } from '../../allocator/matrix-allocate';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { BoundsContext } from '../../common/bounds-context';\nimport { renderCommandList } from '../../common/render-command-list';\nimport { GraphicCreator } from '../constants';\nimport { identityMat4, multiplyMat4Mat4, rotateX, rotateY, rotateZ, scaleMat4, translate } from '../../common/matrix';\n\nexport function getExtraModelMatrix(dx: number, dy: number, graphic: IGraphic): mat4 | null {\n const { alpha, beta } = graphic.attribute;\n if (!alpha && !beta) {\n return null;\n }\n const { anchor3d = graphic.attribute.anchor } = graphic.attribute;\n\n const _anchor: [number, number] = [0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n if (graphic.type === 'text') {\n const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // 计算偏移\n _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n }\n\n // 应用偏移,计算全局的偏移\n _anchor[0] += dx;\n _anchor[1] += dy;\n // matrix.scale(dpr, dpr);\n\n const modelMatrix = mat4Allocate.allocate();\n translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]);\n if (beta) {\n rotateX(modelMatrix, modelMatrix, beta);\n }\n if (alpha) {\n rotateY(modelMatrix, modelMatrix, alpha);\n }\n translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]);\n\n return modelMatrix;\n}\n\n// 计算3d下的模型矩阵\nexport function getModelMatrix(out: mat4, graphic: IGraphic, theme: ITransform) {\n const {\n x = theme.x,\n y = theme.y,\n z = theme.z,\n dx = theme.dx,\n dy = theme.dy,\n dz = theme.dz,\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n scaleZ = theme.scaleZ,\n alpha = theme.alpha,\n beta = theme.beta,\n angle = theme.angle,\n anchor3d = graphic.attribute.anchor,\n anchor\n } = graphic.attribute;\n\n const _anchor: [number, number, number] = [0, 0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n _anchor[2] = anchor3d[2] ?? 0;\n }\n\n // if (graphic.type === 'text') {\n // const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // // 计算偏移\n // _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n // }\n\n identityMat4(out);\n // 平移\n translate(out, out, [x + dx, y + dy, z + dz]);\n translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]);\n rotateX(out, out, beta);\n rotateY(out, out, alpha);\n // 基于z轴的偏移基于anchor计算\n // rotateZ(out, out, angle);\n translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]);\n scaleMat4(out, out, [scaleX, scaleY, scaleZ]);\n\n // 计算基于z轴的偏移\n if (angle) {\n const m = mat4Allocate.allocate();\n const _anchor: [number, number] = [0, 0];\n if (anchor) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n translate(m, m, [_anchor[0], _anchor[1], 0]);\n // 基于z轴的偏移基于anchor计算\n rotateZ(m, m, angle);\n translate(m, m, [-_anchor[0], -_anchor[1], 0]);\n\n multiplyMat4Mat4(out, out, m);\n }\n}\n\nexport function shouldUseMat4(graphic: IGraphic) {\n const { alpha, beta } = graphic.attribute;\n return alpha || beta;\n}\n\n// 管理graphic\n@injectable()\nexport class DefaultGraphicService implements IGraphicService {\n declare hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n };\n\n // 临时bounds,用作缓存\n protected tempAABBBounds1: AABBBounds;\n protected tempAABBBounds2: AABBBounds;\n constructor(@inject(GraphicCreator) public readonly creator: IGraphicCreator) {\n this.hooks = {\n onAttributeUpdate: new SyncHook<[IGraphic]>(['graphic']),\n onSetStage: new SyncHook<[IGraphic, IStage]>(['graphic', 'stage']),\n onRemove: new SyncHook<[IGraphic]>(['graphic']),\n onRelease: new SyncHook<[IGraphic]>(['graphic']),\n onAddIncremental: new SyncHook<[IGraphic, IGroup, IStage]>(['graphic', 'group', 'stage']),\n onClearIncremental: new SyncHook<[IGroup, IStage]>(['graphic', 'group', 'stage']),\n beforeUpdateAABBBounds: new SyncHook<[IGraphic, IStage, boolean, IAABBBounds]>([\n 'graphic',\n 'stage',\n 'willUpdate',\n 'aabbBounds'\n ]),\n afterUpdateAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>([\n 'graphic',\n 'stage',\n 'aabbBounds',\n 'globalAABBBounds',\n 'selfChange'\n ])\n };\n this.tempAABBBounds1 = new AABBBounds();\n this.tempAABBBounds2 = new AABBBounds();\n }\n onAttributeUpdate(graphic: IGraphic) {\n if (this.hooks.onAttributeUpdate.taps.length) {\n this.hooks.onAttributeUpdate.call(graphic);\n }\n }\n onSetStage(graphic: IGraphic, stage: IStage): void {\n if (this.hooks.onSetStage.taps.length) {\n this.hooks.onSetStage.call(graphic, stage);\n }\n }\n onRemove(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRemove.taps.length) {\n this.hooks.onRemove.call(graphic);\n }\n }\n onRelease(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRelease.taps.length) {\n this.hooks.onRelease.call(graphic);\n }\n }\n onAddIncremental(graphic: IGraphic, group: IGroup, stage: IStage): void {\n if (this.hooks.onAddIncremental.taps.length) {\n this.hooks.onAddIncremental.call(graphic, group, stage);\n }\n }\n onClearIncremental(group: IGroup, stage: IStage): void {\n if (this.hooks.onClearIncremental.taps.length) {\n this.hooks.onClearIncremental.call(group, stage);\n }\n }\n beforeUpdateAABBBounds(graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) {\n if (this.hooks.beforeUpdateAABBBounds.taps.length) {\n this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);\n }\n }\n afterUpdateAABBBounds(\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) {\n if (this.hooks.afterUpdateAABBBounds.taps.length) {\n this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);\n }\n }\n // TODO delete\n updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean {\n const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n if (!path) {\n return false;\n }\n const boundsContext = new BoundsContext(aabbBounds);\n renderCommandList(path.commandList, boundsContext, 0, 0);\n return true;\n }\n\n updateHTMLTextAABBBounds(\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) {\n const { textAlign, textBaseline } = attribute;\n if (attribute.forceBoundsHeight != null) {\n const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();\n const dy = textLayoutOffsetY(textBaseline, h, h);\n aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);\n }\n if (attribute.forceBoundsWidth != null) {\n const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();\n const dx = textDrawOffsetX(textAlign, w);\n aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);\n }\n }\n\n combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic) {\n // 合并shadowRoot的Bounds\n if (graphic && graphic.shadowRoot) {\n const b = graphic.shadowRoot.AABBBounds;\n bounds.union(b);\n }\n }\n\n transformAABBBounds(\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) {\n if (!aabbBounds.empty()) {\n const {\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n stroke = theme.stroke,\n shadowBlur = theme.shadowBlur,\n lineWidth = theme.lineWidth,\n pickStrokeBuffer = theme.pickStrokeBuffer,\n strokeBoundsBuffer = theme.strokeBoundsBuffer\n } = attribute;\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n if (stroke && lineWidth) {\n const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);\n boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n if (shadowBlur) {\n const { shadowOffsetX = theme.shadowOffsetX, shadowOffsetY = theme.shadowOffsetY } = attribute;\n const shadowBlurWidth = (shadowBlur / Math.abs(scaleX + scaleY)) * 2;\n boundStroke(tb1, shadowBlurWidth, false, strokeBoundsBuffer + 1);\n tb1.translate(shadowOffsetX, shadowOffsetY);\n aabbBounds.union(tb1);\n // tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n }\n\n // 合并shadowRoot的bounds\n this.combindShadowAABBBounds(aabbBounds, graphic);\n if (aabbBounds.empty()) {\n return;\n }\n\n // 性能优化逻辑,group类型变换较少,不需要矩阵变换\n let updateMatrix = true;\n const m = graphic.transMatrix;\n if (graphic && graphic.isContainer) {\n updateMatrix = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0);\n }\n updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);\n\n // TODO 加上锚点\n // transformBounds(aabbBounds, x, y, scaleX, scaleY, angle);\n // if (graphic.attribute.postMatrix) {\n // console.log('aaa');\n // transformBoundsWithMatrix(aabbBounds, graphic.attribute.postMatrix);\n // }\n // aabbBounds.translate(dx, dy);\n }\n\n validCheck(\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ): boolean {\n if (!graphic) {\n return true;\n }\n\n // 设置了强制wh,那就直接认为是合法的\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n return true;\n }\n\n if (graphic.shadowRoot) {\n return true;\n }\n\n if (!graphic.valid) {\n aabbBounds.clear();\n return false;\n }\n const { visible = theme.visible } = attribute;\n if (!visible) {\n aabbBounds.clear();\n return false;\n }\n return true;\n }\n\n updateTempAABBBounds(aabbBounds: IAABBBounds) {\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n\n return { tb1, tb2 };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src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AAqB,CAuOjC;SAvOY,qBAAqB","file":"graphic-service.js","sourcesContent":["import { inject, injectable } from '../../common/inversify-lite';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, isNumber, transformBoundsWithMatrix } from '@visactor/vutils';\nimport { SyncHook } from '../../tapable';\nimport type {\n mat4,\n IGraphicAttribute,\n IGraphic,\n IGroup,\n IStage,\n IText,\n ITextGraphicAttribute,\n ITransform,\n IGraphicService,\n IGraphicCreator,\n ISyncHook\n} from '../../interface';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../../common/text';\nimport { boundStroke } from '../tools';\nimport { mat4Allocate } from '../../allocator/matrix-allocate';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { BoundsContext } from '../../common/bounds-context';\nimport { renderCommandList } from '../../common/render-command-list';\nimport { GraphicCreator } from '../constants';\nimport { identityMat4, multiplyMat4Mat4, rotateX, rotateY, rotateZ, scaleMat4, translate } from '../../common/matrix';\nimport { application } from '../../application';\n\nexport function getExtraModelMatrix(dx: number, dy: number, graphic: IGraphic): mat4 | null {\n const { alpha, beta } = graphic.attribute;\n if (!alpha && !beta) {\n return null;\n }\n const { anchor3d = graphic.attribute.anchor } = graphic.attribute;\n\n const _anchor: [number, number] = [0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n if (graphic.type === 'text') {\n const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // 计算偏移\n _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n }\n\n // 应用偏移,计算全局的偏移\n _anchor[0] += dx;\n _anchor[1] += dy;\n // matrix.scale(dpr, dpr);\n\n const modelMatrix = mat4Allocate.allocate();\n translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]);\n if (beta) {\n rotateX(modelMatrix, modelMatrix, beta);\n }\n if (alpha) {\n rotateY(modelMatrix, modelMatrix, alpha);\n }\n translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]);\n\n return modelMatrix;\n}\n\n// 计算3d下的模型矩阵\nexport function getModelMatrix(out: mat4, graphic: IGraphic, theme: ITransform) {\n const {\n x = theme.x,\n y = theme.y,\n z = theme.z,\n dx = theme.dx,\n dy = theme.dy,\n dz = theme.dz,\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n scaleZ = theme.scaleZ,\n alpha = theme.alpha,\n beta = theme.beta,\n angle = theme.angle,\n anchor3d = graphic.attribute.anchor,\n anchor\n } = graphic.attribute;\n\n const _anchor: [number, number, number] = [0, 0, 0];\n if (anchor3d) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n _anchor[2] = anchor3d[2] ?? 0;\n }\n\n // if (graphic.type === 'text') {\n // const { textAlign } = graphic.attribute as ITextGraphicAttribute;\n // // 计算偏移\n // _anchor[0] += textDrawOffsetX(textAlign, (graphic as IText).clipedWidth);\n // }\n\n identityMat4(out);\n // 平移\n translate(out, out, [x + dx, y + dy, z + dz]);\n translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]);\n rotateX(out, out, beta);\n rotateY(out, out, alpha);\n // 基于z轴的偏移基于anchor计算\n // rotateZ(out, out, angle);\n translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]);\n scaleMat4(out, out, [scaleX, scaleY, scaleZ]);\n\n // 计算基于z轴的偏移\n if (angle) {\n const m = mat4Allocate.allocate();\n const _anchor: [number, number] = [0, 0];\n if (anchor) {\n if (typeof anchor3d[0] === 'string') {\n const ratio = parseFloat(anchor3d[0]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[0] = anchor3d[0];\n }\n if (typeof anchor3d[1] === 'string') {\n const ratio = parseFloat(anchor3d[1]) / 100;\n const bounds = graphic.AABBBounds;\n _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;\n } else {\n _anchor[1] = anchor3d[1];\n }\n }\n\n translate(m, m, [_anchor[0], _anchor[1], 0]);\n // 基于z轴的偏移基于anchor计算\n rotateZ(m, m, angle);\n translate(m, m, [-_anchor[0], -_anchor[1], 0]);\n\n multiplyMat4Mat4(out, out, m);\n }\n}\n\nexport function shouldUseMat4(graphic: IGraphic) {\n const { alpha, beta } = graphic.attribute;\n return alpha || beta;\n}\n\n// 管理graphic\n@injectable()\nexport class DefaultGraphicService implements IGraphicService {\n declare hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;\n };\n\n // 临时bounds,用作缓存\n protected tempAABBBounds1: AABBBounds;\n protected tempAABBBounds2: AABBBounds;\n constructor(@inject(GraphicCreator) public readonly creator: IGraphicCreator) {\n this.hooks = {\n onAttributeUpdate: new SyncHook<[IGraphic]>(['graphic']),\n onSetStage: new SyncHook<[IGraphic, IStage]>(['graphic', 'stage']),\n onRemove: new SyncHook<[IGraphic]>(['graphic']),\n onRelease: new SyncHook<[IGraphic]>(['graphic']),\n onAddIncremental: new SyncHook<[IGraphic, IGroup, IStage]>(['graphic', 'group', 'stage']),\n onClearIncremental: new SyncHook<[IGroup, IStage]>(['graphic', 'group', 'stage']),\n beforeUpdateAABBBounds: new SyncHook<[IGraphic, IStage, boolean, IAABBBounds]>([\n 'graphic',\n 'stage',\n 'willUpdate',\n 'aabbBounds'\n ]),\n afterUpdateAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>([\n 'graphic',\n 'stage',\n 'aabbBounds',\n 'globalAABBBounds',\n 'selfChange'\n ]),\n clearAABBBounds: new SyncHook<[IGraphic, IStage, IAABBBounds]>(['graphic', 'stage', 'aabbBounds'])\n };\n this.tempAABBBounds1 = new AABBBounds();\n this.tempAABBBounds2 = new AABBBounds();\n }\n onAttributeUpdate(graphic: IGraphic) {\n if (this.hooks.onAttributeUpdate.taps.length) {\n this.hooks.onAttributeUpdate.call(graphic);\n }\n }\n onSetStage(graphic: IGraphic, stage: IStage): void {\n if (this.hooks.onSetStage.taps.length) {\n this.hooks.onSetStage.call(graphic, stage);\n }\n }\n onRemove(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRemove.taps.length) {\n this.hooks.onRemove.call(graphic);\n }\n }\n onRelease(graphic: IGraphic<Partial<IGraphicAttribute>>): void {\n if (this.hooks.onRelease.taps.length) {\n this.hooks.onRelease.call(graphic);\n }\n }\n onAddIncremental(graphic: IGraphic, group: IGroup, stage: IStage): void {\n if (this.hooks.onAddIncremental.taps.length) {\n this.hooks.onAddIncremental.call(graphic, group, stage);\n }\n }\n onClearIncremental(group: IGroup, stage: IStage): void {\n if (this.hooks.onClearIncremental.taps.length) {\n this.hooks.onClearIncremental.call(group, stage);\n }\n }\n beforeUpdateAABBBounds(graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) {\n if (this.hooks.beforeUpdateAABBBounds.taps.length) {\n this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);\n }\n }\n afterUpdateAABBBounds(\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) {\n if (this.hooks.afterUpdateAABBBounds.taps.length) {\n this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);\n }\n }\n clearAABBBounds(graphic: IGraphic, stage: IStage, b: IAABBBounds) {\n if (this.hooks.clearAABBBounds.taps.length) {\n this.hooks.clearAABBBounds.call(graphic, stage, b);\n }\n }\n // TODO delete\n updatePathProxyAABBBounds(aabbBounds: IAABBBounds, graphic?: IGraphic): boolean {\n const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n if (!path) {\n return false;\n }\n const boundsContext = new BoundsContext(aabbBounds);\n renderCommandList(path.commandList, boundsContext, 0, 0);\n return true;\n }\n\n updateHTMLTextAABBBounds(\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) {\n const { textAlign, textBaseline } = attribute;\n if (attribute.forceBoundsHeight != null) {\n const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight();\n const dy = textLayoutOffsetY(textBaseline, h, h);\n aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);\n }\n if (attribute.forceBoundsWidth != null) {\n const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth();\n const dx = textDrawOffsetX(textAlign, w);\n aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);\n }\n }\n\n combindShadowAABBBounds(bounds: IAABBBounds, graphic?: IGraphic) {\n // 合并shadowRoot的Bounds\n if (graphic && graphic.shadowRoot) {\n const b = graphic.shadowRoot.AABBBounds;\n bounds.union(b);\n }\n }\n\n transformAABBBounds(\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) {\n if (!aabbBounds.empty()) {\n const {\n scaleX = theme.scaleX,\n scaleY = theme.scaleY,\n stroke = theme.stroke,\n shadowBlur = theme.shadowBlur,\n lineWidth = theme.lineWidth,\n pickStrokeBuffer = theme.pickStrokeBuffer,\n strokeBoundsBuffer = theme.strokeBoundsBuffer\n } = attribute;\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n if (stroke && lineWidth) {\n const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);\n boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n if (shadowBlur) {\n const { shadowOffsetX = theme.shadowOffsetX, shadowOffsetY = theme.shadowOffsetY } = attribute;\n const shadowBlurWidth = (shadowBlur / Math.abs(scaleX + scaleY)) * 2;\n boundStroke(tb1, shadowBlurWidth, false, strokeBoundsBuffer + 1);\n tb1.translate(shadowOffsetX, shadowOffsetY);\n aabbBounds.union(tb1);\n // tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n }\n }\n\n // 合并shadowRoot的bounds\n this.combindShadowAABBBounds(aabbBounds, graphic);\n if (aabbBounds.empty()) {\n return;\n }\n\n // 性能优化逻辑,group类型变换较少,不需要矩阵变换\n let updateMatrix = true;\n const m = graphic.transMatrix;\n if (graphic && graphic.isContainer) {\n updateMatrix = !(m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0);\n }\n updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);\n\n // TODO 加上锚点\n // transformBounds(aabbBounds, x, y, scaleX, scaleY, angle);\n // if (graphic.attribute.postMatrix) {\n // console.log('aaa');\n // transformBoundsWithMatrix(aabbBounds, graphic.attribute.postMatrix);\n // }\n // aabbBounds.translate(dx, dy);\n }\n\n validCheck(\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ): boolean {\n if (!graphic) {\n return true;\n }\n\n // 设置了强制wh,那就直接认为是合法的\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n return true;\n }\n\n // 是Group或者有影子节点的话,就直接认为是合法的\n if (graphic.shadowRoot || graphic.isContainer) {\n return true;\n }\n\n const { visible = theme.visible } = attribute;\n\n if (!(graphic.valid && visible)) {\n // application.graphicService.beforeUpdateAABBBounds(graphic, graphic.stage, true, aabbBounds);\n if (!aabbBounds.empty()) {\n graphic.parent && aabbBounds.transformWithMatrix((graphic.parent as IGroup).globalTransMatrix);\n application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds);\n aabbBounds.clear();\n }\n return false;\n }\n return true;\n }\n\n updateTempAABBBounds(aabbBounds: IAABBBounds) {\n const tb1 = this.tempAABBBounds1;\n const tb2 = this.tempAABBBounds2;\n tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2);\n\n return { tb1, tb2 };\n }\n}\n"]}
|
|
@@ -21,11 +21,13 @@ export interface IGraphicService {
|
|
|
21
21
|
afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, {
|
|
22
22
|
globalAABBBounds: IAABBBounds;
|
|
23
23
|
}, boolean]>;
|
|
24
|
+
clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;
|
|
24
25
|
};
|
|
25
26
|
beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;
|
|
26
27
|
afterUpdateAABBBounds: (graphic: IGraphic, stage: IStage, bounds: IAABBBounds, params: {
|
|
27
28
|
globalAABBBounds: IAABBBounds;
|
|
28
29
|
}, selfChange: boolean) => void;
|
|
30
|
+
clearAABBBounds: (graphic: IGraphic, stage: IStage, b: IAABBBounds) => void;
|
|
29
31
|
creator: IGraphicCreator;
|
|
30
32
|
validCheck: (attribute: Partial<IGraphicAttribute>, theme: Required<IGraphicAttribute>, aabbBounds: IAABBBounds, graphic?: IGraphic) => boolean;
|
|
31
33
|
transformAABBBounds: (attribute: Partial<IGraphicAttribute>, aabbBounds: IAABBBounds, theme: Required<IGraphicAttribute>, miter: boolean, graphic?: IGraphic) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic-service.ts"],"names":[],"mappings":"","file":"graphic-service.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\n\nimport type { ISyncHook } from './sync-hook';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IStage } from './stage';\nimport type {\n IRectGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n ISymbolGraphicAttribute,\n ICircleGraphicAttribute,\n ICircle,\n ISymbol,\n IArcGraphicAttribute,\n IArc,\n IAreaGraphicAttribute,\n IArea,\n ILineGraphicAttribute,\n IPathGraphicAttribute,\n ILine,\n IPath,\n IPolygonGraphicAttribute,\n IPolygon,\n ITextGraphicAttribute,\n IText,\n IRichTextGraphicAttribute,\n IRichText,\n IImageGraphicAttribute,\n IImage,\n IRect3dGraphicAttribute,\n IRect,\n IRect3d,\n IShadowRoot,\n IWrapTextGraphicAttribute\n} from './graphic/index';\n\nexport interface IGraphicService {\n // themeService: IThemeService;\n onAttributeUpdate: (graphic: IGraphic) => void;\n onSetStage: (graphic: IGraphic, stage: IStage) => void;\n onRemove: (graphic: IGraphic) => void;\n onRelease: (graphic: IGraphic) => void;\n onAddIncremental: (graphic: IGraphic, group: IGroup, stage: IStage) => void;\n onClearIncremental: (group: IGroup, stage: IStage) => void;\n hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n };\n beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;\n afterUpdateAABBBounds: (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => void;\n\n creator: IGraphicCreator;\n validCheck: (\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => boolean;\n\n transformAABBBounds: (\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) => void;\n\n updateHTMLTextAABBBounds: (\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) => void;\n\n combindShadowAABBBounds: (bounds: IAABBBounds, graphic?: IGraphic) => void;\n updateTempAABBBounds: (aabbBounds: IAABBBounds) => { tb1: IAABBBounds; tb2: IAABBBounds };\n}\n\nexport type IGraphicCreator = {\n arc: (attributes: IArcGraphicAttribute) => IArc;\n area: (attributes: IAreaGraphicAttribute) => IArea;\n circle: (attributes: ICircleGraphicAttribute) => ICircle;\n group: (attributes: IGroupGraphicAttribute) => IGroup;\n image: (attributes: IImageGraphicAttribute) => IImage;\n line: (attributes: ILineGraphicAttribute) => ILine;\n path: (attributes: IPathGraphicAttribute) => IPath;\n rect: (attributes: IRectGraphicAttribute) => IRect;\n rect3d: (attributes: IRect3dGraphicAttribute) => IRect3d;\n symbol: (attributes: ISymbolGraphicAttribute) => ISymbol;\n text: (attributes: ITextGraphicAttribute) => IText;\n richtext: (attributes: IRichTextGraphicAttribute) => IRichText;\n polygon: (attributes: IPolygonGraphicAttribute) => IPolygon;\n shadowRoot: (graphic?: IGraphic) => IShadowRoot;\n wrapText: (attributes: IWrapTextGraphicAttribute) => IText;\n};\n\nexport interface IArcBoundsContribution {\n updateBounds: (\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IAreaBoundsContribution {\n updateBounds: (\n attribute: IAreaGraphicAttribute,\n arcTheme: Required<IAreaGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ICircleBoundsContribution {\n updateBounds: (\n attribute: ICircleGraphicAttribute,\n circleTheme: Required<ICircleGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IPathBoundsContribution {\n updateBounds: (\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IRectBoundsContribution {\n updateBounds: (\n attribute: IRectGraphicAttribute,\n rectTheme: Required<IRectGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ISymbolBoundsContribution {\n updateBounds: (\n attribute: ISymbolGraphicAttribute,\n SymbolTheme: Required<ISymbolGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\nexport interface IImageBoundsContribution {\n updateBounds: (\n attribute: IImageGraphicAttribute,\n ImageTheme: Required<IImageGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic-service.ts"],"names":[],"mappings":"","file":"graphic-service.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\n\nimport type { ISyncHook } from './sync-hook';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IStage } from './stage';\nimport type {\n IRectGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n ISymbolGraphicAttribute,\n ICircleGraphicAttribute,\n ICircle,\n ISymbol,\n IArcGraphicAttribute,\n IArc,\n IAreaGraphicAttribute,\n IArea,\n ILineGraphicAttribute,\n IPathGraphicAttribute,\n ILine,\n IPath,\n IPolygonGraphicAttribute,\n IPolygon,\n ITextGraphicAttribute,\n IText,\n IRichTextGraphicAttribute,\n IRichText,\n IImageGraphicAttribute,\n IImage,\n IRect3dGraphicAttribute,\n IRect,\n IRect3d,\n IShadowRoot,\n IWrapTextGraphicAttribute\n} from './graphic/index';\n\nexport interface IGraphicService {\n // themeService: IThemeService;\n onAttributeUpdate: (graphic: IGraphic) => void;\n onSetStage: (graphic: IGraphic, stage: IStage) => void;\n onRemove: (graphic: IGraphic) => void;\n onRelease: (graphic: IGraphic) => void;\n onAddIncremental: (graphic: IGraphic, group: IGroup, stage: IStage) => void;\n onClearIncremental: (group: IGroup, stage: IStage) => void;\n hooks: {\n onAttributeUpdate: ISyncHook<[IGraphic]>;\n onSetStage: ISyncHook<[IGraphic, IStage]>;\n onRemove: ISyncHook<[IGraphic]>;\n onRelease: ISyncHook<[IGraphic]>;\n onAddIncremental: ISyncHook<[IGraphic, IGroup, IStage]>;\n onClearIncremental: ISyncHook<[IGroup, IStage]>;\n beforeUpdateAABBBounds: ISyncHook<[IGraphic, IStage, boolean, IAABBBounds]>;\n afterUpdateAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds, { globalAABBBounds: IAABBBounds }, boolean]>;\n clearAABBBounds: ISyncHook<[IGraphic, IStage, IAABBBounds]>;\n };\n beforeUpdateAABBBounds: (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => void;\n afterUpdateAABBBounds: (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => void;\n clearAABBBounds: (graphic: IGraphic, stage: IStage, b: IAABBBounds) => void;\n\n creator: IGraphicCreator;\n validCheck: (\n attribute: Partial<IGraphicAttribute>,\n theme: Required<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => boolean;\n\n transformAABBBounds: (\n attribute: Partial<IGraphicAttribute>,\n aabbBounds: IAABBBounds,\n theme: Required<IGraphicAttribute>,\n miter: boolean,\n graphic?: IGraphic\n ) => void;\n\n updateHTMLTextAABBBounds: (\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IText\n ) => void;\n\n combindShadowAABBBounds: (bounds: IAABBBounds, graphic?: IGraphic) => void;\n updateTempAABBBounds: (aabbBounds: IAABBBounds) => { tb1: IAABBBounds; tb2: IAABBBounds };\n}\n\nexport type IGraphicCreator = {\n arc: (attributes: IArcGraphicAttribute) => IArc;\n area: (attributes: IAreaGraphicAttribute) => IArea;\n circle: (attributes: ICircleGraphicAttribute) => ICircle;\n group: (attributes: IGroupGraphicAttribute) => IGroup;\n image: (attributes: IImageGraphicAttribute) => IImage;\n line: (attributes: ILineGraphicAttribute) => ILine;\n path: (attributes: IPathGraphicAttribute) => IPath;\n rect: (attributes: IRectGraphicAttribute) => IRect;\n rect3d: (attributes: IRect3dGraphicAttribute) => IRect3d;\n symbol: (attributes: ISymbolGraphicAttribute) => ISymbol;\n text: (attributes: ITextGraphicAttribute) => IText;\n richtext: (attributes: IRichTextGraphicAttribute) => IRichText;\n polygon: (attributes: IPolygonGraphicAttribute) => IPolygon;\n shadowRoot: (graphic?: IGraphic) => IShadowRoot;\n wrapText: (attributes: IWrapTextGraphicAttribute) => IText;\n};\n\nexport interface IArcBoundsContribution {\n updateBounds: (\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IAreaBoundsContribution {\n updateBounds: (\n attribute: IAreaGraphicAttribute,\n arcTheme: Required<IAreaGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ICircleBoundsContribution {\n updateBounds: (\n attribute: ICircleGraphicAttribute,\n circleTheme: Required<ICircleGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IPathBoundsContribution {\n updateBounds: (\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface IRectBoundsContribution {\n updateBounds: (\n attribute: IRectGraphicAttribute,\n rectTheme: Required<IRectGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n\nexport interface ISymbolBoundsContribution {\n updateBounds: (\n attribute: ISymbolGraphicAttribute,\n SymbolTheme: Required<ISymbolGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\nexport interface IImageBoundsContribution {\n updateBounds: (\n attribute: IImageGraphicAttribute,\n ImageTheme: Required<IImageGraphicAttribute>,\n aabbBounds: IAABBBounds,\n graphic?: IGraphic\n ) => IAABBBounds;\n}\n"]}
|
|
@@ -19,6 +19,8 @@ export class DirtyBoundsPlugin {
|
|
|
19
19
|
stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
|
|
20
20
|
})), application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => {
|
|
21
21
|
stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
|
|
22
|
+
})), application.graphicService.hooks.clearAABBBounds.tap(this.key, ((graphic, stage, bounds) => {
|
|
23
|
+
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
|
|
22
24
|
})), application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
|
|
23
25
|
const stage = graphic.stage;
|
|
24
26
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
|
|
@@ -27,6 +29,7 @@ export class DirtyBoundsPlugin {
|
|
|
27
29
|
deactivate(context) {
|
|
28
30
|
application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
29
31
|
application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
32
|
+
application.graphicService.hooks.clearAABBBounds.taps = application.graphicService.hooks.clearAABBBounds.taps.filter((item => item.name !== this.key)),
|
|
30
33
|
context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter((item => item.name !== this.key)),
|
|
31
34
|
application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key));
|
|
32
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/dirty-bounds-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBA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c,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI;YACnD,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBAClE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACxF,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5G,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","file":"dirty-bounds-plugin.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds } from '@visactor/vutils';\nimport { Generator } from '../../common/generator';\nimport type { IGraphic, IStage, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\n\nconst globalBounds = new AABBBounds();\n\nexport class DirtyBoundsPlugin implements IPlugin {\n name: 'DirtyBoundsPlugin' = 'DirtyBoundsPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n stage.dirtyBounds.clear();\n });\n application.graphicService.hooks.beforeUpdateAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, willUpdate: boolean, bounds: IAABBBounds) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {\n return;\n }\n if (willUpdate) {\n globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);\n stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);\n }\n }\n );\n application.graphicService.hooks.afterUpdateAABBBounds.tap(\n this.key,\n (\n graphic: IGraphic,\n stage: IStage,\n bounds: IAABBBounds,\n params: { globalAABBBounds: IAABBBounds },\n selfChange: boolean\n ) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n // group的子元素导致的bounds更新不用做dirtyBounds\n if (graphic.isContainer && !selfChange) {\n return;\n }\n stage.dirty(params.globalAABBBounds);\n }\n );\n application.graphicService.hooks.clearAABBBounds.tap(\n this.key,\n (graphic: IGraphic, stage: IStage, bounds: IAABBBounds) => {\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(bounds);\n }\n }\n );\n application.graphicService.hooks.onRemove.tap(this.key, (graphic: IGraphic) => {\n const stage = graphic.stage;\n if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {\n return;\n }\n if (stage) {\n stage.dirty(graphic.globalAABBBounds);\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.beforeUpdateAABBBounds.taps =\n application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.afterUpdateAABBBounds.taps =\n application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.clearAABBBounds.taps =\n application.graphicService.hooks.clearAABBBounds.taps.filter(item => {\n return item.name !== this.key;\n });\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
|