@visactor/vrender-core 0.20.0-alpha.0 → 0.20.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/allocator/matrix-allocate.d.ts +1 -1
- package/cjs/allocator/matrix-allocate.js +2 -4
- package/cjs/allocator/matrix-allocate.js.map +1 -1
- package/cjs/animate/animate.js +4 -2
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.d.ts +5 -16
- package/cjs/animate/custom-animate.js +9 -62
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/group-fade.d.ts +16 -0
- package/cjs/animate/group-fade.js +66 -0
- package/cjs/animate/group-fade.js.map +1 -0
- package/cjs/animate/index.d.ts +1 -0
- package/cjs/animate/index.js +2 -1
- package/cjs/animate/index.js.map +1 -1
- package/cjs/canvas/util.d.ts +0 -1
- package/cjs/canvas/util.js +7 -17
- package/cjs/canvas/util.js.map +1 -1
- package/cjs/common/3d-interceptor.d.ts +3 -0
- package/cjs/common/3d-interceptor.js +51 -0
- package/cjs/common/3d-interceptor.js.map +1 -0
- package/cjs/common/bezier-utils.js +2 -1
- package/cjs/common/bounds-context.js +1 -2
- package/cjs/common/canvas-utils.d.ts +1 -1
- package/cjs/common/canvas-utils.js +15 -30
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/matrix.d.ts +11 -3
- package/cjs/common/matrix.js +97 -19
- package/cjs/common/matrix.js.map +1 -1
- package/cjs/common/morphing-utils.js +1 -1
- package/cjs/common/path-svg.js +1 -1
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +1 -1
- package/cjs/common/render-curve.js +23 -33
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/common/render-utils.js +2 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/common/simplify.js +1 -1
- package/cjs/common/sort.js +16 -13
- package/cjs/common/sort.js.map +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.d.ts +0 -2
- package/cjs/common/text.js +4 -11
- package/cjs/common/text.js.map +1 -1
- package/cjs/common/utils.js +1 -1
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/application.js +1 -2
- package/cjs/core/camera.js +4 -4
- package/cjs/core/camera.js.map +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +0 -2
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.js +15 -9
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/graphic/builtin-symbol/utils.js +1 -5
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.js +1 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-service.d.ts +2 -8
- package/cjs/graphic/graphic-service/graphic-service.js +17 -107
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/richtext/utils.js +12 -21
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +1 -1
- package/cjs/graphic/richtext.js +2 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/text.js +1 -1
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -3
- package/cjs/index.js.map +1 -1
- package/cjs/interface/graphic/group.d.ts +1 -1
- package/cjs/interface/graphic/group.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +1 -0
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/picker/pick-interceptor.d.ts +1 -1
- package/cjs/picker/pick-interceptor.js +2 -42
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/picker/picker-service.js +4 -5
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +22 -0
- package/cjs/plugins/builtin-plugin/edit-module.js +94 -0
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -0
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +76 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +338 -0
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
- package/cjs/render/contributions/render/arc-render.js +1 -4
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +1 -1
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/base-3d-render.d.ts +10 -0
- package/cjs/render/contributions/render/base-3d-render.js +63 -0
- package/cjs/render/contributions/render/base-3d-render.js.map +1 -0
- package/cjs/render/contributions/render/base-render.js +5 -5
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +7 -51
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +4 -5
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/pyramid3d-render.d.ts +3 -5
- package/cjs/render/contributions/render/pyramid3d-render.js +4 -54
- package/cjs/render/contributions/render/pyramid3d-render.js.map +1 -1
- package/cjs/render/contributions/render/rect3d-render.d.ts +3 -5
- package/cjs/render/contributions/render/rect3d-render.js +4 -53
- package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +9 -18
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.js +2 -5
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/dist/index.es.js +1288 -978
- package/es/allocator/matrix-allocate.d.ts +1 -1
- package/es/allocator/matrix-allocate.js +3 -3
- package/es/allocator/matrix-allocate.js.map +1 -1
- package/es/animate/animate.js +4 -2
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.d.ts +5 -16
- package/es/animate/custom-animate.js +9 -58
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/group-fade.d.ts +16 -0
- package/es/animate/group-fade.js +56 -0
- package/es/animate/group-fade.js.map +1 -0
- package/es/animate/index.d.ts +1 -0
- package/es/animate/index.js +2 -0
- package/es/animate/index.js.map +1 -1
- package/es/canvas/util.d.ts +0 -1
- package/es/canvas/util.js +7 -17
- package/es/canvas/util.js.map +1 -1
- package/es/common/3d-interceptor.d.ts +3 -0
- package/es/common/3d-interceptor.js +47 -0
- package/es/common/3d-interceptor.js.map +1 -0
- package/es/common/bezier-utils.js +2 -1
- package/es/common/bounds-context.js +1 -2
- package/es/common/canvas-utils.d.ts +1 -1
- package/es/common/canvas-utils.js +15 -30
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/matrix.d.ts +11 -3
- package/es/common/matrix.js +90 -17
- package/es/common/matrix.js.map +1 -1
- package/es/common/morphing-utils.js +1 -1
- package/es/common/path-svg.js +1 -1
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +1 -1
- package/es/common/render-curve.js +23 -33
- package/es/common/render-curve.js.map +1 -1
- package/es/common/render-utils.js +2 -1
- package/es/common/seg-context.js +1 -1
- package/es/common/simplify.js +1 -1
- package/es/common/sort.js +16 -13
- package/es/common/sort.js.map +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.d.ts +0 -2
- package/es/common/text.js +1 -7
- package/es/common/text.js.map +1 -1
- package/es/common/utils.js +1 -1
- package/es/common/utils.js.map +1 -1
- package/es/core/application.js +1 -2
- package/es/core/camera.js +6 -4
- package/es/core/camera.js.map +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +0 -2
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.js +15 -9
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +1 -1
- package/es/graphic/builtin-symbol/utils.js +1 -4
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.js +1 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic-service/graphic-service.d.ts +2 -8
- package/es/graphic/graphic-service/graphic-service.js +9 -97
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/richtext/utils.js +9 -20
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext.d.ts +1 -1
- package/es/graphic/richtext.js +2 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/text.js +2 -2
- package/es/graphic/text.js.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/interface/graphic/group.d.ts +1 -1
- package/es/interface/graphic/group.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +1 -0
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/picker/pick-interceptor.d.ts +1 -1
- package/es/picker/pick-interceptor.js +4 -44
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/picker/picker-service.js +1 -1
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.d.ts +22 -0
- package/es/plugins/builtin-plugin/edit-module.js +86 -0
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -0
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
- package/es/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +76 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +334 -0
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
- package/es/render/contributions/render/arc-render.js +1 -4
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/area-render.js +1 -1
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/base-3d-render.d.ts +10 -0
- package/es/render/contributions/render/base-3d-render.js +57 -0
- package/es/render/contributions/render/base-3d-render.js.map +1 -0
- package/es/render/contributions/render/base-render.js +3 -1
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +7 -51
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/group-render.js +3 -1
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/pyramid3d-render.d.ts +3 -5
- package/es/render/contributions/render/pyramid3d-render.js +4 -56
- package/es/render/contributions/render/pyramid3d-render.js.map +1 -1
- package/es/render/contributions/render/rect3d-render.d.ts +3 -5
- package/es/render/contributions/render/rect3d-render.js +4 -55
- package/es/render/contributions/render/rect3d-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +9 -18
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/utils.js +2 -5
- package/es/render/contributions/render/utils.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,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AErG,OAAO,CAAC,cAAc,EAAE,CAAC;gBACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACnB,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;oBACf,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,EAAE,CAAC;gBACjB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACnB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,gBAAgB,CAAC,WAAW,CAAC,OAAiB,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;aAChG;SACF;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds, pi2 } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../graphic/graphic-service/graphic-service';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IArc,\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { ARC3D_NUMBER_TYPE } from '../../../graphic/constants';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute.shadowRootIdx < 0) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n // hack逻辑,如果是饼图的话,需要依次绘制不同的边\n let isPie: boolean = false;\n let is3d: boolean = false;\n graphic.forEachChildren((c: IGraphic) => {\n isPie = c.numberType === ARC3D_NUMBER_TYPE;\n return !isPie;\n });\n graphic.forEachChildren((c: IGraphic) => {\n is3d = !!c.findFace;\n return !is3d;\n });\n if (isPie) {\n const children = graphic.getChildren() as IArc[];\n // 绘制内层\n // drawContext.hack_pieFace = 'inside';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制底部\n // drawContext.hack_pieFace = 'bottom';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制外部\n // 排序一下\n const sortedChildren = [...children];\n sortedChildren.sort((a, b) => {\n let angle1 = ((a.attribute.startAngle ?? 0) + (a.attribute.endAngle ?? 0)) / 2;\n let angle2 = ((b.attribute.startAngle ?? 0) + (b.attribute.endAngle ?? 0)) / 2;\n while (angle1 < 0) {\n angle1 += pi2;\n }\n while (angle2 < 0) {\n angle2 += pi2;\n }\n return angle2 - angle1;\n });\n sortedChildren.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n graphic.removeAllChild();\n graphic.update();\n sortedChildren.forEach(c => {\n graphic.appendChild(c);\n });\n const m = graphic.parent.globalTransMatrix;\n drawContext.hack_pieFace = 'outside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制内部\n drawContext.hack_pieFace = 'inside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制顶部\n drawContext.hack_pieFace = 'top';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n graphic.removeAllChild();\n children.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n children.forEach(c => {\n graphic.appendChild(c);\n });\n } else if (is3d) {\n // 排序这些图元\n const children = graphic.getChildren() as IGraphic[];\n const zChildren = children.map(g => {\n const face3d = g.findFace();\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2] + g.attribute.z ?? 0)[2];\n });\n const ave_z = viewdVerticesZ.reduce((a, b) => a + b, 0);\n return {\n ave_z,\n g\n };\n });\n zChildren.sort((a, b) => b.ave_z - a.ave_z);\n graphic.removeAllChild();\n zChildren.forEach(i => {\n i.g._next = null;\n i.g._prev = null;\n });\n graphic.update();\n zChildren.forEach(i => {\n graphic.add(i.g);\n });\n\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix, true);\n\n graphic.removeAllChild();\n children.forEach(g => {\n g._next = null;\n g._prev = null;\n });\n graphic.update();\n children.forEach(g => {\n graphic.add(g);\n });\n } else {\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix);\n }\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAYlE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;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AE,MAAM,CAAC,CAAC;aACpE;SACF;aAAM;YACL,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;SAC9B;QACD,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAG7C,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,UAAU,CACR,OAAO,EACP,OAAO,EACP,CAAC,KAAc,EAAE,IAAa,EAAE,EAAE;gBAChC,OAAO,gBAAgB,CAAC,WAAW,CACjC,OAAiB,EACjB,WAAW,EACX,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAChC,CAAC,KAAK,IAAI,IAAI,CACf,CAAC;YACJ,CAAC,EACD,WAAW,CACZ,CAAC;SACH;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
@@ -14,7 +14,7 @@ import { inject, injectable, named } from "../../../common/inversify-lite";
|
|
|
14
14
|
|
|
15
15
|
import { getTheme } from "../../../graphic/theme";
|
|
16
16
|
|
|
17
|
-
import { getModelMatrix
|
|
17
|
+
import { getModelMatrix } from "../../../graphic/graphic-service/graphic-service";
|
|
18
18
|
|
|
19
19
|
import { isArray } from "@visactor/vutils";
|
|
20
20
|
|
|
@@ -34,6 +34,8 @@ import { BaseRenderContributionTime } from "../../../common/enums";
|
|
|
34
34
|
|
|
35
35
|
import { defaultGroupBackgroundRenderContribution } from "./contributions";
|
|
36
36
|
|
|
37
|
+
import { multiplyMat4Mat4 } from "../../../common/matrix";
|
|
38
|
+
|
|
37
39
|
let DefaultCanvasGroupRender = class {
|
|
38
40
|
constructor(groupRenderContribitions) {
|
|
39
41
|
this.groupRenderContribitions = groupRenderContribitions, this.numberType = GROUP_NUMBER_TYPE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAc3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,wCAAwC,EAAE,MAAM,iBAAiB,CAAC;AAGpE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eA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S,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACrC;QACD,IAAI,CAAM,CAAC;QACX,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE;YAC9B,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;SACxB;QAED,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,eAAe,IAAI,WAAW,CAAC;QAEvC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YACf,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACV,IAAI,IAAI,EAAE;oBACR,OAAO,CAAC,OAAO,EAAE,CAAC;iBACnB;qBAAM;oBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,IAAI,EAAE;gBACR,OAAO,CAAC,OAAO,EAAE,CAAC;aACnB;iBAAM;gBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;aAClC;SACF;IACH,CAAC;CACF,CAAA;AAnRY,wBAAwB;IADpC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAmRpC;SAnRY,wBAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix, multiplyMat4Mat4 } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const groupAttribute = graphicService.themeService.getCurrentTheme().groupAttribute;\n const groupAttribute = getTheme(group, params?.theme).group;\n const {\n fill = groupAttribute.fill,\n background,\n stroke = groupAttribute.stroke,\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n clip = groupAttribute.clip,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius);\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n context.fill();\n }\n }\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, x, y, groupAttribute);\n context.stroke();\n }\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // debugger;\n const { clip, baseOpacity = 1 } = group.attribute;\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n context.baseGlobalAlpha *= baseOpacity;\n\n const groupAttribute = getTheme(group, params?.theme).group;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.drawingCb) {\n p = params.drawingCb();\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha /= baseOpacity;\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAc3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS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pC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAmRpC;SAnRY,wBAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const groupAttribute = graphicService.themeService.getCurrentTheme().groupAttribute;\n const groupAttribute = getTheme(group, params?.theme).group;\n const {\n fill = groupAttribute.fill,\n background,\n stroke = groupAttribute.stroke,\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n clip = groupAttribute.clip,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius);\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n context.fill();\n }\n }\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, x, y, groupAttribute);\n context.stroke();\n }\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // debugger;\n const { clip, baseOpacity = 1 } = group.attribute;\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n context.baseGlobalAlpha *= baseOpacity;\n\n const groupAttribute = getTheme(group, params?.theme).group;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.drawingCb) {\n p = params.drawingCb();\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha /= baseOpacity;\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d,
|
|
2
|
-
import {
|
|
3
|
-
export declare class DefaultCanvasPyramid3dRender extends
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IMarkAttribute, IPyramid3d, IThemeAttribute, IGraphicRender, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
|
|
2
|
+
import { Base3dRender } from './base-3d-render';
|
|
3
|
+
export declare class DefaultCanvasPyramid3dRender extends Base3dRender<IPyramid3d> implements IGraphicRender {
|
|
4
4
|
type: string;
|
|
5
5
|
numberType: number;
|
|
6
6
|
z: number;
|
|
7
7
|
drawShape(pyramid3d: IPyramid3d, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
-
stroke(x: number, y: number, z: number, face3d: IFace3d, context: IContext2d): void;
|
|
9
|
-
fill(x: number, y: number, z: number, face3d: IFace3d, faces: [boolean, boolean, boolean, boolean, boolean, boolean], fillColor: string, context: IContext2d, light: IDirectionLight, camera: ICamera, pyramid3d: IPyramid3d, pyramid3dAttribute: Partial<IMarkAttribute & IGraphicAttribute>, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
10
8
|
draw(pyramid3d: IPyramid3d, renderService: IRenderService, drawContext: IDrawContext): void;
|
|
11
9
|
}
|
|
@@ -10,11 +10,9 @@ import { getTheme } from "../../../graphic/theme";
|
|
|
10
10
|
|
|
11
11
|
import { PYRAMID3D_NUMBER_TYPE } from "../../../graphic/constants";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { Base3dRender } from "./base-3d-render";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let DefaultCanvasPyramid3dRender = class extends BaseRender {
|
|
15
|
+
let DefaultCanvasPyramid3dRender = class extends Base3dRender {
|
|
18
16
|
constructor() {
|
|
19
17
|
super(...arguments), this.type = "pyramid3d", this.numberType = PYRAMID3D_NUMBER_TYPE;
|
|
20
18
|
}
|
|
@@ -22,65 +20,15 @@ let DefaultCanvasPyramid3dRender = class extends BaseRender {
|
|
|
22
20
|
var _a;
|
|
23
21
|
const pyramidAttribute = getTheme(pyramid3d, null == params ? void 0 : params.theme).polygon, {fill: fill = pyramidAttribute.fill, stroke: stroke = pyramidAttribute.stroke, face: face = [ !0, !0, !0, !0, !0, !0 ]} = pyramid3d.attribute, z = null !== (_a = this.z) && void 0 !== _a ? _a : 0;
|
|
24
22
|
if (!this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb)) return;
|
|
25
|
-
const {light: light
|
|
23
|
+
const {light: light} = drawContext.stage || {}, face3d = pyramid3d.findFace();
|
|
26
24
|
if (!1 !== fill) {
|
|
27
25
|
context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
|
|
28
26
|
let fc = fill;
|
|
29
|
-
"string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, face, fc, context, light,
|
|
27
|
+
"string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, face, fc, context, light, pyramid3d, pyramidAttribute, fillCb);
|
|
30
28
|
}
|
|
31
29
|
!1 !== stroke && (context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute),
|
|
32
30
|
this.stroke(x, y, z, face3d, context));
|
|
33
31
|
}
|
|
34
|
-
stroke(x, y, z, face3d, context) {
|
|
35
|
-
const vertices = face3d.vertices;
|
|
36
|
-
face3d.edges.forEach((p => {
|
|
37
|
-
const p1 = vertices[p[0]], p2 = vertices[p[1]], v1 = {
|
|
38
|
-
x: x + p1[0],
|
|
39
|
-
y: y + p1[1],
|
|
40
|
-
z: z + p1[2]
|
|
41
|
-
}, v2 = {
|
|
42
|
-
x: x + p2[0],
|
|
43
|
-
y: y + p2[1],
|
|
44
|
-
z: z + p2[2]
|
|
45
|
-
};
|
|
46
|
-
context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
|
|
47
|
-
context.stroke();
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
fill(x, y, z, face3d, faces, fillColor, context, light, camera, pyramid3d, pyramid3dAttribute, fillCb) {
|
|
51
|
-
const rgbArray = ColorStore.Get(fillColor, ColorType.Color255), vertices = face3d.vertices, viewdVerticesZ = vertices.map((v => context.view(v[0], v[1], v[2])[2])), sortFace = [];
|
|
52
|
-
face3d.polygons.forEach(((p, i) => {
|
|
53
|
-
if (!faces[i]) return;
|
|
54
|
-
sortFace.push({
|
|
55
|
-
faceIdx: i,
|
|
56
|
-
polygon: p
|
|
57
|
-
});
|
|
58
|
-
const {polygon: polygon, normal: normal} = p, z1 = viewdVerticesZ[polygon[0]], z2 = viewdVerticesZ[polygon[1]], z3 = viewdVerticesZ[polygon[2]], z4 = viewdVerticesZ[polygon[3]];
|
|
59
|
-
p.ave_z = z1 + z2 + z3 + z4;
|
|
60
|
-
})), sortFace.sort(((a, b) => b.polygon.ave_z - a.polygon.ave_z)), sortFace.forEach((item => {
|
|
61
|
-
const {polygon: polygon, normal: normal} = item.polygon, p1 = vertices[polygon[0]], p2 = vertices[polygon[1]], p3 = vertices[polygon[2]], p4 = vertices[polygon[3]], v1 = {
|
|
62
|
-
x: x + p1[0],
|
|
63
|
-
y: y + p1[1],
|
|
64
|
-
z: z + p1[2]
|
|
65
|
-
}, v2 = {
|
|
66
|
-
x: x + p2[0],
|
|
67
|
-
y: y + p2[1],
|
|
68
|
-
z: z + p2[2]
|
|
69
|
-
}, v3 = {
|
|
70
|
-
x: x + p3[0],
|
|
71
|
-
y: y + p3[1],
|
|
72
|
-
z: z + p3[2]
|
|
73
|
-
}, v4 = {
|
|
74
|
-
x: x + p4[0],
|
|
75
|
-
y: y + p4[1],
|
|
76
|
-
z: z + p4[2]
|
|
77
|
-
};
|
|
78
|
-
context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
|
|
79
|
-
context.lineTo(v3.x, v3.y, v3.z), context.lineTo(v4.x, v4.y, v4.z), context.closePath(),
|
|
80
|
-
fillCb ? fillCb(context, pyramid3d.attribute, pyramid3dAttribute) : (context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor,
|
|
81
|
-
context.fill());
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
32
|
draw(pyramid3d, renderService, drawContext) {
|
|
85
33
|
const pyramid3dAttribute = getTheme(pyramid3d).polygon;
|
|
86
34
|
this._draw(pyramid3d, pyramid3dAttribute, !1, drawContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/pyramid3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAkBnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,UAAsB;IAAjE;;QACL,SAAI,GAAG,WAAW,CAAC;QACnB,eAAU,GAAW,qBAAqB,CAAC;IA2K7C,CAAC;IAxKC,SAAS,CACP,SAAqB,EACrB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAGZ,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,aAAN,MAAM,uBAAN,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4BAA4B","file":"pyramid3d-render.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { PYRAMID3D_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IDirectionLight,\n IMarkAttribute,\n IPyramid3d,\n IFace3d,\n IThemeAttribute,\n ICamera,\n IPolygonItem,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { BaseRender } from './base-render';\nimport { ColorStore, ColorType } from '../../../color-string';\n\n@injectable()\nexport class DefaultCanvasPyramid3dRender extends BaseRender<IPyramid3d> implements IGraphicRender {\n type = 'pyramid3d';\n numberType: number = PYRAMID3D_NUMBER_TYPE;\n declare z: number;\n\n drawShape(\n pyramid3d: IPyramid3d,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const pyramidAttribute = getTheme(pyramid3d, params?.theme).polygon;\n const {\n fill = pyramidAttribute.fill,\n stroke = pyramidAttribute.stroke,\n face = [true, true, true, true, true, true]\n } = pyramid3d.attribute;\n\n const z = this.z ?? 0;\n\n const data = this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n // const { fVisible, sVisible, doFill, doStroke } = data;\n\n const { light, camera } = drawContext.stage || {};\n\n const face3d = pyramid3d.findFace();\n\n if (fill !== false) {\n context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);\n let fc = fill;\n if (typeof fc !== 'string') {\n fc = 'black';\n }\n this.fill(x, y, z, face3d, face, fc, context, light, camera, pyramid3d, pyramidAttribute, fillCb);\n }\n if (stroke !== false) {\n context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);\n this.stroke(x, y, z, face3d, context);\n }\n }\n\n stroke(x: number, y: number, z: number, face3d: IFace3d, context: IContext2d) {\n const vertices = face3d.vertices;\n face3d.edges.forEach(p => {\n const p1 = vertices[p[0]];\n const p2 = vertices[p[1]];\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.stroke();\n });\n }\n fill(\n x: number,\n y: number,\n z: number,\n face3d: IFace3d,\n faces: [boolean, boolean, boolean, boolean, boolean, boolean],\n fillColor: string,\n context: IContext2d,\n light: IDirectionLight,\n camera: ICamera,\n pyramid3d: IPyramid3d,\n pyramid3dAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const rgbArray = ColorStore.Get(fillColor as string, ColorType.Color255);\n\n // 上下左右前后\n // 0,1,2,3,4,5\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2])[2];\n });\n // 排序\n const sortFace: { faceIdx: number; polygon: IPolygonItem }[] = [];\n face3d.polygons.forEach((p, i) => {\n if (!faces[i]) {\n return;\n }\n sortFace.push({\n faceIdx: i,\n polygon: p\n });\n // 设置ave_z进行排序\n const { polygon, normal } = p;\n\n const z1 = viewdVerticesZ[polygon[0]];\n const z2 = viewdVerticesZ[polygon[1]];\n const z3 = viewdVerticesZ[polygon[2]];\n const z4 = viewdVerticesZ[polygon[3]];\n\n p.ave_z = z1 + z2 + z3 + z4;\n });\n sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);\n sortFace.forEach(item => {\n const { polygon, normal } = item.polygon;\n\n const p1 = vertices[polygon[0]];\n const p2 = vertices[polygon[1]];\n const p3 = vertices[polygon[2]];\n const p4 = vertices[polygon[3]];\n\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n const v3 = {\n x: x + p3[0],\n y: y + p3[1],\n z: z + p3[2]\n };\n const v4 = {\n x: x + p4[0],\n y: y + p4[1],\n z: z + p4[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.lineTo(v3.x, v3.y, v3.z);\n context.lineTo(v4.x, v4.y, v4.z);\n context.closePath();\n if (fillCb) {\n fillCb(context, pyramid3d.attribute, pyramid3dAttribute);\n } else {\n context.fillStyle = light ? light.computeColor(normal, rgbArray as any) : fillColor;\n context.fill();\n }\n });\n }\n\n draw(pyramid3d: IPyramid3d, renderService: IRenderService, drawContext: IDrawContext) {\n const pyramid3dAttribute = getTheme(pyramid3d).polygon;\n this._draw(pyramid3d, pyramid3dAttribute, false, drawContext);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/pyramid3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAYnE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGzC,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,YAAwB;IAAnE;;QACL,SAAI,GAA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OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;SAC3F;QACD,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAC/E,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;SACvC;IACH,CAAC;IAED,IAAI,CAAC,SAAqB,EAAE,aAA6B,EAAE,WAAyB;QAClF,MAAM,kBAAkB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AA7DY,4BAA4B;IADxC,UAAU,EAAE;GACA,4BAA4B,CA6DxC;SA7DY,4BAA4B","file":"pyramid3d-render.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { PYRAMID3D_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IPyramid3d,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { Base3dRender } from './base-3d-render';\n\n@injectable()\nexport class DefaultCanvasPyramid3dRender extends Base3dRender<IPyramid3d> implements IGraphicRender {\n type = 'pyramid3d';\n numberType: number = PYRAMID3D_NUMBER_TYPE;\n declare z: number;\n\n drawShape(\n pyramid3d: IPyramid3d,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const pyramidAttribute = getTheme(pyramid3d, params?.theme).polygon;\n const {\n fill = pyramidAttribute.fill,\n stroke = pyramidAttribute.stroke,\n face = [true, true, true, true, true, true]\n } = pyramid3d.attribute;\n\n const z = this.z ?? 0;\n\n const data = this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n // const { fVisible, sVisible, doFill, doStroke } = data;\n\n const { light } = drawContext.stage || {};\n\n const face3d = pyramid3d.findFace();\n\n if (fill !== false) {\n context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);\n let fc = fill;\n if (typeof fc !== 'string') {\n fc = 'black';\n }\n this.fill(x, y, z, face3d, face, fc, context, light, pyramid3d, pyramidAttribute, fillCb);\n }\n if (stroke !== false) {\n context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);\n this.stroke(x, y, z, face3d, context);\n }\n }\n\n draw(pyramid3d: IPyramid3d, renderService: IRenderService, drawContext: IDrawContext) {\n const pyramid3dAttribute = getTheme(pyramid3d).polygon;\n this._draw(pyramid3d, pyramid3dAttribute, false, drawContext);\n }\n}\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d,
|
|
2
|
-
import {
|
|
3
|
-
export declare class DefaultCanvasRect3dRender extends
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IMarkAttribute, IRect3d, IThemeAttribute, IGraphicRender, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
|
|
2
|
+
import { Base3dRender } from './base-3d-render';
|
|
3
|
+
export declare class DefaultCanvasRect3dRender extends Base3dRender<IRect3d> implements IGraphicRender {
|
|
4
4
|
type: string;
|
|
5
5
|
numberType: number;
|
|
6
6
|
z: number;
|
|
7
7
|
drawShape(rect: IRect3d, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
-
stroke(x: number, y: number, z: number, face3d: IFace3d, context: IContext2d): void;
|
|
9
|
-
fill(x: number, y: number, z: number, face3d: IFace3d, fillColor: string, context: IContext2d, light: IDirectionLight, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
10
8
|
draw(rect: IRect3d, renderService: IRenderService, drawContext: IDrawContext): void;
|
|
11
9
|
}
|
|
@@ -10,13 +10,11 @@ import { getTheme } from "../../../graphic/theme";
|
|
|
10
10
|
|
|
11
11
|
import { rectFillVisible, rectStrokeVisible, runFill, runStroke } from "./utils";
|
|
12
12
|
|
|
13
|
-
import { BaseRender } from "./base-render";
|
|
14
|
-
|
|
15
13
|
import { RECT3D_NUMBER_TYPE } from "../../../graphic/constants";
|
|
16
14
|
|
|
17
|
-
import {
|
|
15
|
+
import { Base3dRender } from "./base-3d-render";
|
|
18
16
|
|
|
19
|
-
let DefaultCanvasRect3dRender = class extends
|
|
17
|
+
let DefaultCanvasRect3dRender = class extends Base3dRender {
|
|
20
18
|
constructor() {
|
|
21
19
|
super(...arguments), this.type = "rect3d", this.numberType = RECT3D_NUMBER_TYPE;
|
|
22
20
|
}
|
|
@@ -29,64 +27,15 @@ let DefaultCanvasRect3dRender = class extends BaseRender {
|
|
|
29
27
|
if (!rect.valid || !visible) return;
|
|
30
28
|
if (!doFill && !doStroke) return;
|
|
31
29
|
if (!(fVisible || sVisible || fillCb || strokeCb)) return;
|
|
32
|
-
const {light: light
|
|
30
|
+
const {light: light} = drawContext.stage || {}, face3d = rect.findFace();
|
|
33
31
|
if (!1 !== fill) {
|
|
34
32
|
context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);
|
|
35
33
|
let fc = fill;
|
|
36
|
-
"string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, fc, context, light, fillCb);
|
|
34
|
+
"string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, null, fc, context, light, null, null, fillCb);
|
|
37
35
|
}
|
|
38
36
|
!1 !== stroke && (context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute),
|
|
39
37
|
this.stroke(x, y, z, face3d, context));
|
|
40
38
|
}
|
|
41
|
-
stroke(x, y, z, face3d, context) {
|
|
42
|
-
const vertices = face3d.vertices;
|
|
43
|
-
face3d.edges.forEach((edge => {
|
|
44
|
-
const p1 = vertices[edge[0]], v1 = {
|
|
45
|
-
x: x + p1[0],
|
|
46
|
-
y: y + p1[1],
|
|
47
|
-
z: z + p1[2]
|
|
48
|
-
}, p2 = vertices[edge[1]], v2 = {
|
|
49
|
-
x: x + p2[0],
|
|
50
|
-
y: y + p2[1],
|
|
51
|
-
z: z + p2[2]
|
|
52
|
-
};
|
|
53
|
-
context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
|
|
54
|
-
context.stroke();
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
fill(x, y, z, face3d, fillColor, context, light, fillCb) {
|
|
58
|
-
const rgbArray = ColorStore.Get(fillColor, ColorType.Color255), vertices = face3d.vertices, viewdVerticesZ = vertices.map((v => context.view(v[0], v[1], v[2])[2])), sortFace = [];
|
|
59
|
-
face3d.polygons.forEach(((p, i) => {
|
|
60
|
-
sortFace.push({
|
|
61
|
-
faceIdx: i,
|
|
62
|
-
polygon: p
|
|
63
|
-
});
|
|
64
|
-
const {polygon: polygon, normal: normal} = p, z1 = viewdVerticesZ[polygon[0]], z2 = viewdVerticesZ[polygon[1]], z3 = viewdVerticesZ[polygon[2]], z4 = viewdVerticesZ[polygon[3]];
|
|
65
|
-
p.ave_z = z1 + z2 + z3 + z4;
|
|
66
|
-
})), sortFace.sort(((a, b) => b.polygon.ave_z - a.polygon.ave_z)), sortFace.forEach((item => {
|
|
67
|
-
const {polygon: polygon, normal: normal} = item.polygon, p1 = vertices[polygon[0]], p2 = vertices[polygon[1]], p3 = vertices[polygon[2]], p4 = vertices[polygon[3]], v1 = {
|
|
68
|
-
x: x + p1[0],
|
|
69
|
-
y: y + p1[1],
|
|
70
|
-
z: z + p1[2]
|
|
71
|
-
}, v2 = {
|
|
72
|
-
x: x + p2[0],
|
|
73
|
-
y: y + p2[1],
|
|
74
|
-
z: z + p2[2]
|
|
75
|
-
}, v3 = {
|
|
76
|
-
x: x + p3[0],
|
|
77
|
-
y: y + p3[1],
|
|
78
|
-
z: z + p3[2]
|
|
79
|
-
}, v4 = {
|
|
80
|
-
x: x + p4[0],
|
|
81
|
-
y: y + p4[1],
|
|
82
|
-
z: z + p4[2]
|
|
83
|
-
};
|
|
84
|
-
context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
|
|
85
|
-
context.lineTo(v3.x, v3.y, v3.z), context.lineTo(v4.x, v4.y, v4.z), context.closePath(),
|
|
86
|
-
fillCb ? fillCb(context, null, null) : (context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor,
|
|
87
|
-
context.fill());
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
39
|
draw(rect, renderService, drawContext) {
|
|
91
40
|
const rectAttribute = getTheme(rect).rect;
|
|
92
41
|
this._draw(rect, rectAttribute, !1, drawContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/rect3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAelD,OAAO,EAAE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":"rect3d-render.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IDirectionLight,\n IFace3d,\n IMarkAttribute,\n IPolygonItem,\n IRect3d,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { BaseRender } from './base-render';\nimport { RECT3D_NUMBER_TYPE } from '../../../graphic/constants';\nimport { ColorStore, ColorType } from '../../../color-string';\n@injectable()\nexport class DefaultCanvasRect3dRender extends BaseRender<IRect3d> implements IGraphicRender {\n type = 'rect3d';\n numberType: number = RECT3D_NUMBER_TYPE;\n declare z: number;\n\n drawShape(\n rect: IRect3d,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const rectAttribute = getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n stroke = rectAttribute.stroke,\n x1,\n y1,\n x: originX,\n y: originY,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible\n } = rect.attribute;\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n const z = this.z ?? 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb)) {\n return;\n }\n\n const { light, camera } = drawContext.stage || {};\n const face3d = rect.findFace();\n\n if (fill !== false) {\n context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);\n let fc = fill;\n if (typeof fc !== 'string') {\n fc = 'black';\n }\n this.fill(x, y, z, face3d, fc, context, light, fillCb);\n }\n if (stroke !== false) {\n context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);\n this.stroke(x, y, z, face3d, context);\n }\n }\n\n stroke(x: number, y: number, z: number, face3d: IFace3d, context: IContext2d) {\n const vertices = face3d.vertices;\n face3d.edges.forEach(edge => {\n const p1 = vertices[edge[0]];\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const p2 = vertices[edge[1]];\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.stroke();\n });\n }\n fill(\n x: number,\n y: number,\n z: number,\n face3d: IFace3d,\n fillColor: string,\n context: IContext2d,\n light: IDirectionLight,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const rgbArray = ColorStore.Get(fillColor as string, ColorType.Color255);\n // 上下左右前后\n // 0,1,2,3,4,5\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2])[2];\n });\n // 排序\n const sortFace: { faceIdx: number; polygon: IPolygonItem }[] = [];\n face3d.polygons.forEach((p, i) => {\n sortFace.push({\n faceIdx: i,\n polygon: p\n });\n // 设置ave_z进行排序\n const { polygon, normal } = p;\n\n const z1 = viewdVerticesZ[polygon[0]];\n const z2 = viewdVerticesZ[polygon[1]];\n const z3 = viewdVerticesZ[polygon[2]];\n const z4 = viewdVerticesZ[polygon[3]];\n\n p.ave_z = z1 + z2 + z3 + z4;\n });\n sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);\n\n sortFace.forEach(item => {\n const { polygon, normal } = item.polygon;\n\n const p1 = vertices[polygon[0]];\n const p2 = vertices[polygon[1]];\n const p3 = vertices[polygon[2]];\n const p4 = vertices[polygon[3]];\n\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n const v3 = {\n x: x + p3[0],\n y: y + p3[1],\n z: z + p3[2]\n };\n const v4 = {\n x: x + p4[0],\n y: y + p4[1],\n z: z + p4[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.lineTo(v3.x, v3.y, v3.z);\n context.lineTo(v4.x, v4.y, v4.z);\n context.closePath();\n if (fillCb) {\n fillCb(context, null, null);\n } else {\n context.fillStyle = light ? light.computeColor(normal, rgbArray as any) : fillColor;\n context.fill();\n }\n });\n }\n\n draw(rect: IRect3d, renderService: IRenderService, drawContext: IDrawContext) {\n const rectAttribute = getTheme(rect).rect;\n this._draw(rect, rectAttribute, false, drawContext);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/rect3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAalD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CA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EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;SACvC;IACH,CAAC;IAED,IAAI,CAAC,IAAa,EAAE,aAA6B,EAAE,WAAyB;QAC1E,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AArFY,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAqFrC;SArFY,yBAAyB","file":"rect3d-render.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IFace3d,\n IMarkAttribute,\n IRect3d,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { RECT3D_NUMBER_TYPE } from '../../../graphic/constants';\nimport { Base3dRender } from './base-3d-render';\n@injectable()\nexport class DefaultCanvasRect3dRender extends Base3dRender<IRect3d> implements IGraphicRender {\n type = 'rect3d';\n numberType: number = RECT3D_NUMBER_TYPE;\n declare z: number;\n\n drawShape(\n rect: IRect3d,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const rectAttribute = getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n stroke = rectAttribute.stroke,\n x1,\n y1,\n x: originX,\n y: originY,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible\n } = rect.attribute;\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n const z = this.z ?? 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb)) {\n return;\n }\n\n const { light } = drawContext.stage || {};\n const face3d = rect.findFace();\n\n if (fill !== false) {\n context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);\n let fc = fill;\n if (typeof fc !== 'string') {\n fc = 'black';\n }\n this.fill(x, y, z, face3d, null, fc, context, light, null, null, fillCb);\n }\n if (stroke !== false) {\n context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);\n this.stroke(x, y, z, face3d, context);\n }\n }\n\n draw(rect: IRect3d, renderService: IRenderService, drawContext: IDrawContext) {\n const rectAttribute = getTheme(rect).rect;\n this._draw(rect, rectAttribute, false, drawContext);\n }\n}\n"]}
|
|
@@ -39,34 +39,25 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
|
|
|
39
39
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, parsedPath = symbol.getParsedPath();
|
|
40
40
|
if (!parsedPath) return;
|
|
41
41
|
const {keepDirIn3d: keepDirIn3d = symbolAttribute.keepDirIn3d} = symbol.attribute, z = null !== (_a = this.z) && void 0 !== _a ? _a : 0;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
context.camera = null, !1 === parsedPath.draw(context, isArray(size) ? [ size[0] * scaleX, size[1] * scaleY ] : size * scaleX, p.x, p.y, void 0, ((p, a) => {
|
|
45
|
-
var _a, _b, _c;
|
|
46
|
-
if (symbol._parsedPath.svgCache) {
|
|
47
|
-
const obj = Object.assign({}, a);
|
|
48
|
-
obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
|
|
49
|
-
obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
|
|
50
|
-
obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
|
|
51
|
-
a = obj;
|
|
52
|
-
}
|
|
53
|
-
a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute),
|
|
54
|
-
context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
|
|
55
|
-
context.stroke()));
|
|
56
|
-
})) && context.closePath(), context.camera = camera;
|
|
57
|
-
} else !1 === parsedPath.draw(context, size, x, y, z, ((p, a) => {
|
|
42
|
+
context.beginPath();
|
|
43
|
+
const callback = (p, a) => {
|
|
58
44
|
var _a, _b, _c;
|
|
59
45
|
if (symbol._parsedPath.svgCache) {
|
|
60
46
|
const obj = Object.assign({}, a);
|
|
61
47
|
obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
|
|
62
|
-
obj.opacity = null !== (_b = a.
|
|
48
|
+
obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
|
|
63
49
|
obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
|
|
64
50
|
a = obj;
|
|
65
51
|
}
|
|
66
52
|
a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute),
|
|
67
53
|
context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
|
|
68
54
|
context.stroke()));
|
|
69
|
-
}
|
|
55
|
+
};
|
|
56
|
+
if (keepDirIn3d && context.camera && context.project) {
|
|
57
|
+
const p = context.project(x, y, z), camera = context.camera;
|
|
58
|
+
context.camera = null, !1 === parsedPath.draw(context, isArray(size) ? [ size[0] * scaleX, size[1] * scaleY ] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(),
|
|
59
|
+
context.camera = camera;
|
|
60
|
+
} else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
|
|
70
61
|
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute),
|
|
71
62
|
this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb),
|
|
72
63
|
doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
|