@visactor/vrender-core 1.0.0-alpha.12 → 1.0.0-alpha.13
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.js +2 -3
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -0
- package/cjs/graphic/graphic.js +9 -8
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +8 -15
- package/cjs/graphic/group.js.map +1 -1
- package/dist/index.es.js +18 -23
- package/es/graphic/graphic-service/graphic-service.js +1 -4
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -0
- package/es/graphic/graphic.js +9 -8
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +8 -15
- package/es/graphic/group.js.map +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -10919,6 +10919,10 @@ class Graphic extends Node {
|
|
|
10919
10919
|
this.setShadowGraphic(params.shadowGraphic);
|
|
10920
10920
|
}
|
|
10921
10921
|
}
|
|
10922
|
+
getGraphicService() {
|
|
10923
|
+
var _a, _b;
|
|
10924
|
+
return (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService) !== null && _b !== void 0 ? _b : application.graphicService;
|
|
10925
|
+
}
|
|
10922
10926
|
getAttributes() {
|
|
10923
10927
|
return this.attribute;
|
|
10924
10928
|
}
|
|
@@ -10949,7 +10953,6 @@ class Graphic extends Node {
|
|
|
10949
10953
|
this._emitCustomEvent('animate-bind', animate);
|
|
10950
10954
|
}
|
|
10951
10955
|
tryUpdateAABBBounds() {
|
|
10952
|
-
var _a, _b;
|
|
10953
10956
|
const full = this.attribute.boundsMode === 'imprecise';
|
|
10954
10957
|
if (!this.shouldUpdateAABBBounds()) {
|
|
10955
10958
|
return this._AABBBounds;
|
|
@@ -10958,9 +10961,9 @@ class Graphic extends Node {
|
|
|
10958
10961
|
this._AABBBounds.clear();
|
|
10959
10962
|
return this._AABBBounds;
|
|
10960
10963
|
}
|
|
10961
|
-
|
|
10964
|
+
this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
|
|
10962
10965
|
const bounds = this.doUpdateAABBBounds(full);
|
|
10963
|
-
|
|
10966
|
+
this.getGraphicService().afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, true);
|
|
10964
10967
|
if (this.attribute.boundsMode === 'empty') {
|
|
10965
10968
|
bounds.clear();
|
|
10966
10969
|
}
|
|
@@ -11137,10 +11140,10 @@ class Graphic extends Node {
|
|
|
11137
11140
|
shouldUpdateAABBBounds() {
|
|
11138
11141
|
if (this.shadowRoot) {
|
|
11139
11142
|
return ((!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) &&
|
|
11140
|
-
|
|
11143
|
+
this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
|
|
11141
11144
|
}
|
|
11142
11145
|
return (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) &&
|
|
11143
|
-
|
|
11146
|
+
this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
|
|
11144
11147
|
}
|
|
11145
11148
|
shouldSelfChangeUpdateAABBBounds() {
|
|
11146
11149
|
if (this.shadowRoot) {
|
|
@@ -11451,11 +11454,10 @@ class Graphic extends Node {
|
|
|
11451
11454
|
return this;
|
|
11452
11455
|
}
|
|
11453
11456
|
onAttributeUpdate(context) {
|
|
11454
|
-
var _a;
|
|
11455
11457
|
if (context && context.skipUpdateCallback) {
|
|
11456
11458
|
return;
|
|
11457
11459
|
}
|
|
11458
|
-
|
|
11460
|
+
this.getGraphicService().onAttributeUpdate(this);
|
|
11459
11461
|
this._emitCustomEvent('afterAttributeUpdate', context);
|
|
11460
11462
|
}
|
|
11461
11463
|
update(d) {
|
|
@@ -11748,7 +11750,6 @@ class Graphic extends Node {
|
|
|
11748
11750
|
}
|
|
11749
11751
|
}
|
|
11750
11752
|
setStage(stage, layer) {
|
|
11751
|
-
var _a;
|
|
11752
11753
|
if (this.stage !== stage) {
|
|
11753
11754
|
this.stage = stage;
|
|
11754
11755
|
this.layer = layer;
|
|
@@ -11763,7 +11764,7 @@ class Graphic extends Node {
|
|
|
11763
11764
|
});
|
|
11764
11765
|
}
|
|
11765
11766
|
this._onSetStage && this._onSetStage(this, stage, layer);
|
|
11766
|
-
|
|
11767
|
+
this.getGraphicService().onSetStage(this, stage);
|
|
11767
11768
|
}
|
|
11768
11769
|
}
|
|
11769
11770
|
setStageToShadowRoot(stage, layer) {
|
|
@@ -12015,15 +12016,14 @@ class Group extends Graphic {
|
|
|
12015
12016
|
return false;
|
|
12016
12017
|
}
|
|
12017
12018
|
tryUpdateAABBBounds() {
|
|
12018
|
-
var _a, _b;
|
|
12019
12019
|
if (!this.shouldUpdateAABBBounds()) {
|
|
12020
12020
|
return this._AABBBounds;
|
|
12021
12021
|
}
|
|
12022
|
-
|
|
12022
|
+
this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
|
|
12023
12023
|
const selfChange = this.shouldSelfChangeUpdateAABBBounds();
|
|
12024
12024
|
const bounds = this.doUpdateAABBBounds();
|
|
12025
12025
|
this.addUpdateLayoutTag();
|
|
12026
|
-
|
|
12026
|
+
this.getGraphicService().afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange);
|
|
12027
12027
|
if (this.attribute.boundsMode === 'empty') {
|
|
12028
12028
|
bounds.clear();
|
|
12029
12029
|
}
|
|
@@ -12092,21 +12092,19 @@ class Group extends Graphic {
|
|
|
12092
12092
|
return this.theme.getTheme(this);
|
|
12093
12093
|
}
|
|
12094
12094
|
incrementalAppendChild(node) {
|
|
12095
|
-
var _a;
|
|
12096
12095
|
const data = super.appendChild(node);
|
|
12097
12096
|
if (this.stage && data) {
|
|
12098
12097
|
data.stage = this.stage;
|
|
12099
12098
|
data.layer = this.layer;
|
|
12100
12099
|
}
|
|
12101
12100
|
this.addUpdateBoundTag();
|
|
12102
|
-
|
|
12101
|
+
this.getGraphicService().onAddIncremental(node, this, this.stage);
|
|
12103
12102
|
return data;
|
|
12104
12103
|
}
|
|
12105
12104
|
incrementalClearChild() {
|
|
12106
|
-
var _a;
|
|
12107
12105
|
super.removeAllChild();
|
|
12108
12106
|
this.addUpdateBoundTag();
|
|
12109
|
-
|
|
12107
|
+
this.getGraphicService().onClearIncremental(this, this.stage);
|
|
12110
12108
|
return;
|
|
12111
12109
|
}
|
|
12112
12110
|
_updateChildToStage(child) {
|
|
@@ -12134,17 +12132,15 @@ class Group extends Graphic {
|
|
|
12134
12132
|
return this._updateChildToStage(super.insertInto(newNode, idx));
|
|
12135
12133
|
}
|
|
12136
12134
|
removeChild(child) {
|
|
12137
|
-
var _a;
|
|
12138
12135
|
const data = super.removeChild(child);
|
|
12139
12136
|
child.stage = null;
|
|
12140
|
-
|
|
12137
|
+
this.getGraphicService().onRemove(child);
|
|
12141
12138
|
this.addUpdateBoundTag();
|
|
12142
12139
|
return data;
|
|
12143
12140
|
}
|
|
12144
12141
|
removeAllChild(deep = false) {
|
|
12145
12142
|
this.forEachChildren((child) => {
|
|
12146
|
-
|
|
12147
|
-
(_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onRemove(child);
|
|
12143
|
+
this.getGraphicService().onRemove(child);
|
|
12148
12144
|
if (deep && child.isContainer) {
|
|
12149
12145
|
child.removeAllChild(deep);
|
|
12150
12146
|
}
|
|
@@ -12153,13 +12149,12 @@ class Group extends Graphic {
|
|
|
12153
12149
|
this.addUpdateBoundTag();
|
|
12154
12150
|
}
|
|
12155
12151
|
setStage(stage, layer) {
|
|
12156
|
-
var _a;
|
|
12157
12152
|
if (this.stage !== stage) {
|
|
12158
12153
|
this.stage = stage;
|
|
12159
12154
|
this.layer = layer;
|
|
12160
12155
|
this.setStageToShadowRoot(stage, layer);
|
|
12161
12156
|
this._onSetStage && this._onSetStage(this, stage, layer);
|
|
12162
|
-
|
|
12157
|
+
this.getGraphicService().onSetStage(this, stage);
|
|
12163
12158
|
this.forEachChildren(item => {
|
|
12164
12159
|
item.setStage(stage, this.layer);
|
|
12165
12160
|
});
|
|
@@ -13109,7 +13104,7 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
13109
13104
|
if (!(graphic.valid && visible)) {
|
|
13110
13105
|
if (!aabbBounds.empty()) {
|
|
13111
13106
|
graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix);
|
|
13112
|
-
|
|
13107
|
+
this.clearAABBBounds(graphic, graphic.stage, aabbBounds);
|
|
13113
13108
|
aabbBounds.clear();
|
|
13114
13109
|
}
|
|
13115
13110
|
return false;
|
|
@@ -30,8 +30,6 @@ 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
|
-
|
|
35
33
|
export function getExtraModelMatrix(dx, dy, graphic) {
|
|
36
34
|
const {alpha: alpha, beta: beta} = graphic.attribute;
|
|
37
35
|
if (!alpha && !beta) return null;
|
|
@@ -185,8 +183,7 @@ let DefaultGraphicService = class {
|
|
|
185
183
|
if (graphic.shadowRoot || graphic.isContainer) return !0;
|
|
186
184
|
const {visible: visible = theme.visible} = attribute;
|
|
187
185
|
return !(!graphic.valid || !visible) || (aabbBounds.empty() || (graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix),
|
|
188
|
-
|
|
189
|
-
aabbBounds.clear()), !1);
|
|
186
|
+
this.clearAABBBounds(graphic, graphic.stage, aabbBounds), aabbBounds.clear()), !1);
|
|
190
187
|
}
|
|
191
188
|
updateTempAABBBounds(aabbBounds) {
|
|
192
189
|
const tb1 = this.tempAABBBounds1, tb2 = this.tempAABBBounds2;
|
|
@@ -1 +1 @@
|
|
|
1
|
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CAAA;;GAhBxB,qBAAqB,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/graphic-service/graphic-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,yBAAyB,EA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AAC,OAAO,EAAE,GAAG,SAAS,CAAC;QAE9C,IAAI,CAAC,CAAC,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,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBACzD,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,UAAU,EAAE;IAiBE,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;;GAhBxB,qBAAqB,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';\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 this.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"]}
|
package/es/graphic/graphic.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
|
|
|
93
93
|
protected updateOBBBoundsStamp?: number;
|
|
94
94
|
clipPathMap?: Map<string, ISymbolClass>;
|
|
95
95
|
constructor(params?: T);
|
|
96
|
+
getGraphicService(): import("../interface").IGraphicService;
|
|
96
97
|
getAttributes(): T;
|
|
97
98
|
setMode(mode: '2d' | '3d'): void;
|
|
98
99
|
set3dMode(): void;
|
package/es/graphic/graphic.js
CHANGED
|
@@ -99,6 +99,10 @@ export class Graphic extends Node {
|
|
|
99
99
|
super(), this._AABBBounds = new AABBBounds, this._updateTag = UpdateTag.INIT, this.attribute = params,
|
|
100
100
|
this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
|
|
101
101
|
}
|
|
102
|
+
getGraphicService() {
|
|
103
|
+
var _a, _b;
|
|
104
|
+
return null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.graphicService) && void 0 !== _b ? _b : application.graphicService;
|
|
105
|
+
}
|
|
102
106
|
getAttributes() {
|
|
103
107
|
return this.attribute;
|
|
104
108
|
}
|
|
@@ -124,13 +128,12 @@ export class Graphic extends Node {
|
|
|
124
128
|
this._emitCustomEvent("animate-bind", animate);
|
|
125
129
|
}
|
|
126
130
|
tryUpdateAABBBounds() {
|
|
127
|
-
var _a, _b;
|
|
128
131
|
const full = "imprecise" === this.attribute.boundsMode;
|
|
129
132
|
if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
|
|
130
133
|
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
131
|
-
|
|
134
|
+
this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
132
135
|
const bounds = this.doUpdateAABBBounds(full);
|
|
133
|
-
return
|
|
136
|
+
return this.getGraphicService().afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0),
|
|
134
137
|
"empty" === this.attribute.boundsMode && bounds.clear(), bounds;
|
|
135
138
|
}
|
|
136
139
|
tryUpdateOBBBounds() {
|
|
@@ -226,7 +229,7 @@ export class Graphic extends Node {
|
|
|
226
229
|
clearTag && this.clearUpdateLocalPositionTag()), this._transMatrix;
|
|
227
230
|
}
|
|
228
231
|
shouldUpdateAABBBounds() {
|
|
229
|
-
return this.shadowRoot ? (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) &&
|
|
232
|
+
return this.shadowRoot ? (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) && this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this) : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) && this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this);
|
|
230
233
|
}
|
|
231
234
|
shouldSelfChangeUpdateAABBBounds() {
|
|
232
235
|
return this.shadowRoot ? !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds() : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS);
|
|
@@ -409,8 +412,7 @@ export class Graphic extends Node {
|
|
|
409
412
|
return this;
|
|
410
413
|
}
|
|
411
414
|
onAttributeUpdate(context) {
|
|
412
|
-
|
|
413
|
-
context && context.skipUpdateCallback || (null === (_a = this.stage) || void 0 === _a || _a.graphicService.onAttributeUpdate(this),
|
|
415
|
+
context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
|
|
414
416
|
this._emitCustomEvent("afterAttributeUpdate", context));
|
|
415
417
|
}
|
|
416
418
|
update(d) {
|
|
@@ -587,7 +589,6 @@ export class Graphic extends Node {
|
|
|
587
589
|
}
|
|
588
590
|
}
|
|
589
591
|
setStage(stage, layer) {
|
|
590
|
-
var _a;
|
|
591
592
|
if (this.stage !== stage) {
|
|
592
593
|
if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer),
|
|
593
594
|
this.animates && this.animates.size) {
|
|
@@ -596,7 +597,7 @@ export class Graphic extends Node {
|
|
|
596
597
|
a.timeline.isGlobal && (a.setTimeline(timeline), timeline.addAnimate(a));
|
|
597
598
|
}));
|
|
598
599
|
}
|
|
599
|
-
this._onSetStage && this._onSetStage(this, stage, layer),
|
|
600
|
+
this._onSetStage && this._onSetStage(this, stage, layer), this.getGraphicService().onSetStage(this, stage);
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
603
|
setStageToShadowRoot(stage, layer) {
|