@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.
Files changed (248) hide show
  1. package/cjs/allocator/matrix-allocate.d.ts +1 -1
  2. package/cjs/allocator/matrix-allocate.js +2 -4
  3. package/cjs/allocator/matrix-allocate.js.map +1 -1
  4. package/cjs/animate/animate.js +4 -2
  5. package/cjs/animate/animate.js.map +1 -1
  6. package/cjs/animate/custom-animate.d.ts +5 -16
  7. package/cjs/animate/custom-animate.js +9 -62
  8. package/cjs/animate/custom-animate.js.map +1 -1
  9. package/cjs/animate/group-fade.d.ts +16 -0
  10. package/cjs/animate/group-fade.js +66 -0
  11. package/cjs/animate/group-fade.js.map +1 -0
  12. package/cjs/animate/index.d.ts +1 -0
  13. package/cjs/animate/index.js +2 -1
  14. package/cjs/animate/index.js.map +1 -1
  15. package/cjs/canvas/util.d.ts +0 -1
  16. package/cjs/canvas/util.js +7 -17
  17. package/cjs/canvas/util.js.map +1 -1
  18. package/cjs/common/3d-interceptor.d.ts +3 -0
  19. package/cjs/common/3d-interceptor.js +51 -0
  20. package/cjs/common/3d-interceptor.js.map +1 -0
  21. package/cjs/common/bezier-utils.js +2 -1
  22. package/cjs/common/bounds-context.js +1 -2
  23. package/cjs/common/canvas-utils.d.ts +1 -1
  24. package/cjs/common/canvas-utils.js +15 -30
  25. package/cjs/common/canvas-utils.js.map +1 -1
  26. package/cjs/common/matrix.d.ts +11 -3
  27. package/cjs/common/matrix.js +97 -19
  28. package/cjs/common/matrix.js.map +1 -1
  29. package/cjs/common/morphing-utils.js +1 -1
  30. package/cjs/common/path-svg.js +1 -1
  31. package/cjs/common/polygon.js +2 -2
  32. package/cjs/common/rect-utils.js +1 -1
  33. package/cjs/common/render-area.js +1 -1
  34. package/cjs/common/render-command-list.js +1 -1
  35. package/cjs/common/render-curve.js +23 -33
  36. package/cjs/common/render-curve.js.map +1 -1
  37. package/cjs/common/render-utils.js +2 -1
  38. package/cjs/common/seg-context.js +1 -1
  39. package/cjs/common/simplify.js +1 -1
  40. package/cjs/common/sort.js +16 -13
  41. package/cjs/common/sort.js.map +1 -1
  42. package/cjs/common/split-path.js +1 -1
  43. package/cjs/common/store.js +1 -1
  44. package/cjs/common/text.d.ts +0 -2
  45. package/cjs/common/text.js +4 -11
  46. package/cjs/common/text.js.map +1 -1
  47. package/cjs/common/utils.js +1 -1
  48. package/cjs/common/utils.js.map +1 -1
  49. package/cjs/core/application.js +1 -2
  50. package/cjs/core/camera.js +4 -4
  51. package/cjs/core/camera.js.map +1 -1
  52. package/cjs/core/constants.js +1 -1
  53. package/cjs/core/core-modules.js +1 -1
  54. package/cjs/core/global-module.js +0 -2
  55. package/cjs/core/global.js +1 -1
  56. package/cjs/core/graphic-utils.js +1 -1
  57. package/cjs/core/index.js +1 -1
  58. package/cjs/core/layer-service.js +1 -1
  59. package/cjs/core/layer.js +1 -1
  60. package/cjs/core/light.js +1 -1
  61. package/cjs/core/stage.js +15 -9
  62. package/cjs/core/stage.js.map +1 -1
  63. package/cjs/core/window.js +1 -1
  64. package/cjs/graphic/builtin-symbol/utils.js +1 -5
  65. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  66. package/cjs/graphic/config.js +1 -0
  67. package/cjs/graphic/config.js.map +1 -1
  68. package/cjs/graphic/graphic-service/graphic-service.d.ts +2 -8
  69. package/cjs/graphic/graphic-service/graphic-service.js +17 -107
  70. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  71. package/cjs/graphic/richtext/utils.js +12 -21
  72. package/cjs/graphic/richtext/utils.js.map +1 -1
  73. package/cjs/graphic/richtext.d.ts +1 -1
  74. package/cjs/graphic/richtext.js +2 -2
  75. package/cjs/graphic/richtext.js.map +1 -1
  76. package/cjs/graphic/text.js +1 -1
  77. package/cjs/graphic/text.js.map +1 -1
  78. package/cjs/index.d.ts +1 -0
  79. package/cjs/index.js +3 -3
  80. package/cjs/index.js.map +1 -1
  81. package/cjs/interface/graphic/group.d.ts +1 -1
  82. package/cjs/interface/graphic/group.js.map +1 -1
  83. package/cjs/interface/graphic/richText.d.ts +1 -0
  84. package/cjs/interface/graphic/richText.js.map +1 -1
  85. package/cjs/picker/pick-interceptor.d.ts +1 -1
  86. package/cjs/picker/pick-interceptor.js +2 -42
  87. package/cjs/picker/pick-interceptor.js.map +1 -1
  88. package/cjs/picker/picker-service.js +4 -5
  89. package/cjs/picker/picker-service.js.map +1 -1
  90. package/cjs/plugins/builtin-plugin/edit-module.d.ts +22 -0
  91. package/cjs/plugins/builtin-plugin/edit-module.js +94 -0
  92. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -0
  93. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
  94. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  95. package/cjs/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
  96. package/cjs/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
  97. package/cjs/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
  98. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +76 -0
  99. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +338 -0
  100. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
  101. package/cjs/render/contributions/render/arc-render.js +1 -4
  102. package/cjs/render/contributions/render/arc-render.js.map +1 -1
  103. package/cjs/render/contributions/render/area-render.js +1 -1
  104. package/cjs/render/contributions/render/area-render.js.map +1 -1
  105. package/cjs/render/contributions/render/base-3d-render.d.ts +10 -0
  106. package/cjs/render/contributions/render/base-3d-render.js +63 -0
  107. package/cjs/render/contributions/render/base-3d-render.js.map +1 -0
  108. package/cjs/render/contributions/render/base-render.js +5 -5
  109. package/cjs/render/contributions/render/base-render.js.map +1 -1
  110. package/cjs/render/contributions/render/draw-interceptor.js +7 -51
  111. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  112. package/cjs/render/contributions/render/group-render.js +4 -5
  113. package/cjs/render/contributions/render/group-render.js.map +1 -1
  114. package/cjs/render/contributions/render/pyramid3d-render.d.ts +3 -5
  115. package/cjs/render/contributions/render/pyramid3d-render.js +4 -54
  116. package/cjs/render/contributions/render/pyramid3d-render.js.map +1 -1
  117. package/cjs/render/contributions/render/rect3d-render.d.ts +3 -5
  118. package/cjs/render/contributions/render/rect3d-render.js +4 -53
  119. package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
  120. package/cjs/render/contributions/render/symbol-render.js +9 -18
  121. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  122. package/cjs/render/contributions/render/utils.js +2 -5
  123. package/cjs/render/contributions/render/utils.js.map +1 -1
  124. package/dist/index.es.js +1288 -978
  125. package/es/allocator/matrix-allocate.d.ts +1 -1
  126. package/es/allocator/matrix-allocate.js +3 -3
  127. package/es/allocator/matrix-allocate.js.map +1 -1
  128. package/es/animate/animate.js +4 -2
  129. package/es/animate/animate.js.map +1 -1
  130. package/es/animate/custom-animate.d.ts +5 -16
  131. package/es/animate/custom-animate.js +9 -58
  132. package/es/animate/custom-animate.js.map +1 -1
  133. package/es/animate/group-fade.d.ts +16 -0
  134. package/es/animate/group-fade.js +56 -0
  135. package/es/animate/group-fade.js.map +1 -0
  136. package/es/animate/index.d.ts +1 -0
  137. package/es/animate/index.js +2 -0
  138. package/es/animate/index.js.map +1 -1
  139. package/es/canvas/util.d.ts +0 -1
  140. package/es/canvas/util.js +7 -17
  141. package/es/canvas/util.js.map +1 -1
  142. package/es/common/3d-interceptor.d.ts +3 -0
  143. package/es/common/3d-interceptor.js +47 -0
  144. package/es/common/3d-interceptor.js.map +1 -0
  145. package/es/common/bezier-utils.js +2 -1
  146. package/es/common/bounds-context.js +1 -2
  147. package/es/common/canvas-utils.d.ts +1 -1
  148. package/es/common/canvas-utils.js +15 -30
  149. package/es/common/canvas-utils.js.map +1 -1
  150. package/es/common/matrix.d.ts +11 -3
  151. package/es/common/matrix.js +90 -17
  152. package/es/common/matrix.js.map +1 -1
  153. package/es/common/morphing-utils.js +1 -1
  154. package/es/common/path-svg.js +1 -1
  155. package/es/common/polygon.js +1 -1
  156. package/es/common/rect-utils.js +1 -1
  157. package/es/common/render-area.js +1 -1
  158. package/es/common/render-command-list.js +1 -1
  159. package/es/common/render-curve.js +23 -33
  160. package/es/common/render-curve.js.map +1 -1
  161. package/es/common/render-utils.js +2 -1
  162. package/es/common/seg-context.js +1 -1
  163. package/es/common/simplify.js +1 -1
  164. package/es/common/sort.js +16 -13
  165. package/es/common/sort.js.map +1 -1
  166. package/es/common/split-path.js +1 -1
  167. package/es/common/store.js +1 -1
  168. package/es/common/text.d.ts +0 -2
  169. package/es/common/text.js +1 -7
  170. package/es/common/text.js.map +1 -1
  171. package/es/common/utils.js +1 -1
  172. package/es/common/utils.js.map +1 -1
  173. package/es/core/application.js +1 -2
  174. package/es/core/camera.js +6 -4
  175. package/es/core/camera.js.map +1 -1
  176. package/es/core/constants.js +1 -1
  177. package/es/core/core-modules.js +1 -1
  178. package/es/core/global-module.js +0 -2
  179. package/es/core/global.js +1 -1
  180. package/es/core/graphic-utils.js +1 -1
  181. package/es/core/index.js +1 -1
  182. package/es/core/layer-service.js +1 -1
  183. package/es/core/layer.js +1 -1
  184. package/es/core/light.js +1 -1
  185. package/es/core/stage.js +15 -9
  186. package/es/core/stage.js.map +1 -1
  187. package/es/core/window.js +1 -1
  188. package/es/graphic/builtin-symbol/utils.js +1 -4
  189. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  190. package/es/graphic/config.js +1 -0
  191. package/es/graphic/config.js.map +1 -1
  192. package/es/graphic/graphic-service/graphic-service.d.ts +2 -8
  193. package/es/graphic/graphic-service/graphic-service.js +9 -97
  194. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  195. package/es/graphic/richtext/utils.js +9 -20
  196. package/es/graphic/richtext/utils.js.map +1 -1
  197. package/es/graphic/richtext.d.ts +1 -1
  198. package/es/graphic/richtext.js +2 -2
  199. package/es/graphic/richtext.js.map +1 -1
  200. package/es/graphic/text.js +2 -2
  201. package/es/graphic/text.js.map +1 -1
  202. package/es/index.d.ts +1 -0
  203. package/es/index.js +2 -0
  204. package/es/index.js.map +1 -1
  205. package/es/interface/graphic/group.d.ts +1 -1
  206. package/es/interface/graphic/group.js.map +1 -1
  207. package/es/interface/graphic/richText.d.ts +1 -0
  208. package/es/interface/graphic/richText.js.map +1 -1
  209. package/es/picker/pick-interceptor.d.ts +1 -1
  210. package/es/picker/pick-interceptor.js +4 -44
  211. package/es/picker/pick-interceptor.js.map +1 -1
  212. package/es/picker/picker-service.js +1 -1
  213. package/es/picker/picker-service.js.map +1 -1
  214. package/es/plugins/builtin-plugin/edit-module.d.ts +22 -0
  215. package/es/plugins/builtin-plugin/edit-module.js +86 -0
  216. package/es/plugins/builtin-plugin/edit-module.js.map +1 -0
  217. package/es/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
  218. package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  219. package/es/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
  220. package/es/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
  221. package/es/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
  222. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +76 -0
  223. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +334 -0
  224. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -0
  225. package/es/render/contributions/render/arc-render.js +1 -4
  226. package/es/render/contributions/render/arc-render.js.map +1 -1
  227. package/es/render/contributions/render/area-render.js +1 -1
  228. package/es/render/contributions/render/area-render.js.map +1 -1
  229. package/es/render/contributions/render/base-3d-render.d.ts +10 -0
  230. package/es/render/contributions/render/base-3d-render.js +57 -0
  231. package/es/render/contributions/render/base-3d-render.js.map +1 -0
  232. package/es/render/contributions/render/base-render.js +3 -1
  233. package/es/render/contributions/render/base-render.js.map +1 -1
  234. package/es/render/contributions/render/draw-interceptor.js +7 -51
  235. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  236. package/es/render/contributions/render/group-render.js +3 -1
  237. package/es/render/contributions/render/group-render.js.map +1 -1
  238. package/es/render/contributions/render/pyramid3d-render.d.ts +3 -5
  239. package/es/render/contributions/render/pyramid3d-render.js +4 -56
  240. package/es/render/contributions/render/pyramid3d-render.js.map +1 -1
  241. package/es/render/contributions/render/rect3d-render.d.ts +3 -5
  242. package/es/render/contributions/render/rect3d-render.js +4 -55
  243. package/es/render/contributions/render/rect3d-render.js.map +1 -1
  244. package/es/render/contributions/render/symbol-render.js +9 -18
  245. package/es/render/contributions/render/symbol-render.js.map +1 -1
  246. package/es/render/contributions/render/utils.js +2 -5
  247. package/es/render/contributions/render/utils.js.map +1 -1
  248. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAAmD;AACnD,sFAAgG;AAChG,sEAAkE;AAalE,wEAAkE;AAClE,0DAA+D;AAGlD,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,mBAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,mBAAU,EAAE,CAAC;AAK/C,MAAa,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAgEpB,CAAC;IA/DC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAEjC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,EAAE;YAC3E,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;SAC9E;QACD,OAAO,KAAK,CAAC;I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OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF;AArKD,kEAqKC","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,mEAA4D;AAC5D,6CAA8C;AAC9C,mDAAsE;AACtE,sEAAkE;AAYlE,wEAAkE;AAClE,oEAA4D;AAG/C,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,mBAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,mBAAU,EAAE,CAAC;AAK/C,MAAa,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAoFpB,CAAC;IAnFC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAGjC,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI;YACvC,OAAO,CAAC,UAAU;YAClB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,EAC9C;YACA,OAAO,KAAK,CAAC;SACd;QACD,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC;YACnC,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa;YAChC,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,EACtE;YACA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;SAC9E;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,cAAc,CACZ,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAGjC,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI;YACvC,OAAO,CAAC,UAAU;YAClB,OAAO,CAAC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/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"]}
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  value: !0
17
17
  }), exports.DefaultCanvasGroupRender = void 0;
18
18
 
19
- const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), graphic_service_1 = require("../../../graphic/graphic-service/graphic-service"), vutils_1 = require("@visactor/vutils"), contribution_provider_1 = require("../../../common/contribution-provider"), rect_1 = require("../../../common/shape/rect"), utils_1 = require("./utils"), constants_1 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), constants_2 = require("../../../graphic/constants"), enums_1 = require("../../../common/enums"), contributions_1 = require("./contributions");
19
+ const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), graphic_service_1 = require("../../../graphic/graphic-service/graphic-service"), vutils_1 = require("@visactor/vutils"), contribution_provider_1 = require("../../../common/contribution-provider"), rect_1 = require("../../../common/shape/rect"), utils_1 = require("./utils"), constants_1 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), constants_2 = require("../../../graphic/constants"), enums_1 = require("../../../common/enums"), contributions_1 = require("./contributions"), matrix_1 = require("../../../common/matrix");
20
20
 
21
21
  let DefaultCanvasGroupRender = class {
22
22
  constructor(groupRenderContribitions) {
@@ -64,10 +64,9 @@ let DefaultCanvasGroupRender = class {
64
64
  if (context.camera) {
65
65
  const nextModelMatrix = matrix_allocate_1.mat4Allocate.allocate(), modelMatrix = matrix_allocate_1.mat4Allocate.allocate();
66
66
  (0, graphic_service_1.getModelMatrix)(modelMatrix, group, groupAttribute), lastModelMatrix ? (0,
67
- graphic_service_1.multiplyMat4Mat4)(nextModelMatrix, lastModelMatrix, modelMatrix) : (0,
68
- graphic_service_1.multiplyMat4Mat4)(nextModelMatrix, nextModelMatrix, modelMatrix),
69
- context.modelMatrix = nextModelMatrix, matrix_allocate_1.mat4Allocate.free(modelMatrix),
70
- context.setTransform(1, 0, 0, 1, 0, 0, !0);
67
+ matrix_1.multiplyMat4Mat4)(nextModelMatrix, lastModelMatrix, modelMatrix) : (0,
68
+ matrix_1.multiplyMat4Mat4)(nextModelMatrix, nextModelMatrix, modelMatrix), context.modelMatrix = nextModelMatrix,
69
+ matrix_allocate_1.mat4Allocate.free(modelMatrix), context.setTransform(1, 0, 0, 1, 0, 0, !0);
71
70
  } else context.transformFromMatrix(group.transMatrix, !0);
72
71
  context.beginPath(), params.skipDraw ? this.drawShape(group, context, 0, 0, drawContext, params, (() => !1), (() => !1)) : this.drawShape(group, context, 0, 0, drawContext);
73
72
  const {scrollX: scrollX = groupAttribute.scrollX, scrollY: scrollY = groupAttribute.scrollY} = group.attribute;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAc3E,kDAAkD;AAClD,sFAAoG;AACpG,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAGpE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,EACJ,IAAI,GAAG,cAAc,CAAC,IAAI,EAC1B,UAAU,EACV,MAAM,GAAG,cAAc,CAAC,MAAM,EAC9B,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,KAAK,GAAG,cAAc,CAAC,KAAK,EAC5B,MAAM,GA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AI,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,IAAA,2BAAU,GAAE;IAQR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAmRpC;AAnRY,4DAAwB","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,mEAA2E;AAc3E,kDAAkD;AAClD,sFAAkF;AAClF,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAC3E,mDAA0D;AAGnD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,KAAK,CAAC;QAC5D,MAAM,EACJ,IAAI,GAAG,cAAc,CAAC,IAAI,EAC1B,UAAU,EACV,MAAM,GAAG,cAAc,CAAC,MAAM,EAC9B,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,KAAK,GAAG,cAAc,CAAC,KAAK,EAC5B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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,IAAA,2BAAU,GAAE;IAQR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAmRpC;AAnRY,4DAAwB","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, IDirectionLight, IMarkAttribute, IPyramid3d, IFace3d, IThemeAttribute, ICamera, IGraphicRender, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
2
- import { BaseRender } from './base-render';
3
- export declare class DefaultCanvasPyramid3dRender extends BaseRender<IPyramid3d> implements IGraphicRender {
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,9 +10,9 @@ Object.defineProperty(exports, "__esModule", {
10
10
  value: !0
11
11
  }), exports.DefaultCanvasPyramid3dRender = void 0;
12
12
 
13
- const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), constants_1 = require("../../../graphic/constants"), base_render_1 = require("./base-render"), color_string_1 = require("../../../color-string");
13
+ const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), constants_1 = require("../../../graphic/constants"), base_3d_render_1 = require("./base-3d-render");
14
14
 
15
- let DefaultCanvasPyramid3dRender = class extends base_render_1.BaseRender {
15
+ let DefaultCanvasPyramid3dRender = class extends base_3d_render_1.Base3dRender {
16
16
  constructor() {
17
17
  super(...arguments), this.type = "pyramid3d", this.numberType = constants_1.PYRAMID3D_NUMBER_TYPE;
18
18
  }
@@ -20,65 +20,15 @@ let DefaultCanvasPyramid3dRender = class extends base_render_1.BaseRender {
20
20
  var _a;
21
21
  const pyramidAttribute = (0, theme_1.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;
22
22
  if (!this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb)) return;
23
- const {light: light, camera: camera} = drawContext.stage || {}, face3d = pyramid3d.findFace();
23
+ const {light: light} = drawContext.stage || {}, face3d = pyramid3d.findFace();
24
24
  if (!1 !== fill) {
25
25
  context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
26
26
  let fc = fill;
27
- "string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, face, fc, context, light, camera, pyramid3d, pyramidAttribute, fillCb);
27
+ "string" != typeof fc && (fc = "black"), this.fill(x, y, z, face3d, face, fc, context, light, pyramid3d, pyramidAttribute, fillCb);
28
28
  }
29
29
  !1 !== stroke && (context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute),
30
30
  this.stroke(x, y, z, face3d, context));
31
31
  }
32
- stroke(x, y, z, face3d, context) {
33
- const vertices = face3d.vertices;
34
- face3d.edges.forEach((p => {
35
- const p1 = vertices[p[0]], p2 = vertices[p[1]], v1 = {
36
- x: x + p1[0],
37
- y: y + p1[1],
38
- z: z + p1[2]
39
- }, v2 = {
40
- x: x + p2[0],
41
- y: y + p2[1],
42
- z: z + p2[2]
43
- };
44
- context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
45
- context.stroke();
46
- }));
47
- }
48
- fill(x, y, z, face3d, faces, fillColor, context, light, camera, pyramid3d, pyramid3dAttribute, fillCb) {
49
- const rgbArray = color_string_1.ColorStore.Get(fillColor, color_string_1.ColorType.Color255), vertices = face3d.vertices, viewdVerticesZ = vertices.map((v => context.view(v[0], v[1], v[2])[2])), sortFace = [];
50
- face3d.polygons.forEach(((p, i) => {
51
- if (!faces[i]) return;
52
- sortFace.push({
53
- faceIdx: i,
54
- polygon: p
55
- });
56
- const {polygon: polygon, normal: normal} = p, z1 = viewdVerticesZ[polygon[0]], z2 = viewdVerticesZ[polygon[1]], z3 = viewdVerticesZ[polygon[2]], z4 = viewdVerticesZ[polygon[3]];
57
- p.ave_z = z1 + z2 + z3 + z4;
58
- })), sortFace.sort(((a, b) => b.polygon.ave_z - a.polygon.ave_z)), sortFace.forEach((item => {
59
- const {polygon: polygon, normal: normal} = item.polygon, p1 = vertices[polygon[0]], p2 = vertices[polygon[1]], p3 = vertices[polygon[2]], p4 = vertices[polygon[3]], v1 = {
60
- x: x + p1[0],
61
- y: y + p1[1],
62
- z: z + p1[2]
63
- }, v2 = {
64
- x: x + p2[0],
65
- y: y + p2[1],
66
- z: z + p2[2]
67
- }, v3 = {
68
- x: x + p3[0],
69
- y: y + p3[1],
70
- z: z + p3[2]
71
- }, v4 = {
72
- x: x + p4[0],
73
- y: y + p4[1],
74
- z: z + p4[2]
75
- };
76
- context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
77
- context.lineTo(v3.x, v3.y, v3.z), context.lineTo(v4.x, v4.y, v4.z), context.closePath(),
78
- fillCb ? fillCb(context, pyramid3d.attribute, pyramid3dAttribute) : (context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor,
79
- context.fill());
80
- }));
81
- }
82
32
  draw(pyramid3d, renderService, drawContext) {
83
33
  const pyramid3dAttribute = (0, theme_1.getTheme)(pyramid3d).polygon;
84
34
  this._draw(pyramid3d, pyramid3dAttribute, !1, drawContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/pyramid3d-render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mEAA4D;AAC5D,kDAAkD;AAClD,0DAAmE;AAkBnE,+CAA2C;AAC3C,wDAA8D;AAGvD,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,wBAAsB;IAAjE;;QACL,SAAI,GAAG,WAAW,CAAC;QACnB,eAAU,GAAW,iCAAqB,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,IAAA,gBAAQ,EAAC,SAAS,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,OAAO,CAAC;Q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ourcesContent":["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,mEAA4D;AAC5D,kDAAkD;AAClD,0DAAmE;AAYnE,qDAAgD;AAGzC,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,6BAAwB;IAAnE;;QACL,SAAI,GAAG,WAAW,CAAC;QACnB,eAAU,GAAW,iCAAqB,CAAC;IA2D7C,CAAC;IAxDC,SAAS,CACP,SAAqB,EACrB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAG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,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,IAAA,gBAAQ,EAAC,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,IAAA,2BAAU,GAAE;GACA,4BAA4B,CA6DxC;AA7DY,oEAA4B","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, IDirectionLight, IFace3d, IMarkAttribute, IRect3d, IThemeAttribute, IGraphicRender, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
2
- import { BaseRender } from './base-render';
3
- export declare class DefaultCanvasRect3dRender extends BaseRender<IRect3d> implements IGraphicRender {
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,9 +10,9 @@ Object.defineProperty(exports, "__esModule", {
10
10
  value: !0
11
11
  }), exports.DefaultCanvasRect3dRender = void 0;
12
12
 
13
- const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), utils_1 = require("./utils"), base_render_1 = require("./base-render"), constants_1 = require("../../../graphic/constants"), color_string_1 = require("../../../color-string");
13
+ const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), utils_1 = require("./utils"), constants_1 = require("../../../graphic/constants"), base_3d_render_1 = require("./base-3d-render");
14
14
 
15
- let DefaultCanvasRect3dRender = class extends base_render_1.BaseRender {
15
+ let DefaultCanvasRect3dRender = class extends base_3d_render_1.Base3dRender {
16
16
  constructor() {
17
17
  super(...arguments), this.type = "rect3d", this.numberType = constants_1.RECT3D_NUMBER_TYPE;
18
18
  }
@@ -27,64 +27,15 @@ let DefaultCanvasRect3dRender = class extends base_render_1.BaseRender {
27
27
  if (!rect.valid || !visible) return;
28
28
  if (!doFill && !doStroke) return;
29
29
  if (!(fVisible || sVisible || fillCb || strokeCb)) return;
30
- const {light: light, camera: camera} = drawContext.stage || {}, face3d = rect.findFace();
30
+ const {light: light} = drawContext.stage || {}, face3d = rect.findFace();
31
31
  if (!1 !== fill) {
32
32
  context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);
33
33
  let fc = fill;
34
- "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);
35
35
  }
36
36
  !1 !== stroke && (context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute),
37
37
  this.stroke(x, y, z, face3d, context));
38
38
  }
39
- stroke(x, y, z, face3d, context) {
40
- const vertices = face3d.vertices;
41
- face3d.edges.forEach((edge => {
42
- const p1 = vertices[edge[0]], v1 = {
43
- x: x + p1[0],
44
- y: y + p1[1],
45
- z: z + p1[2]
46
- }, p2 = vertices[edge[1]], v2 = {
47
- x: x + p2[0],
48
- y: y + p2[1],
49
- z: z + p2[2]
50
- };
51
- context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
52
- context.stroke();
53
- }));
54
- }
55
- fill(x, y, z, face3d, fillColor, context, light, fillCb) {
56
- const rgbArray = color_string_1.ColorStore.Get(fillColor, color_string_1.ColorType.Color255), vertices = face3d.vertices, viewdVerticesZ = vertices.map((v => context.view(v[0], v[1], v[2])[2])), sortFace = [];
57
- face3d.polygons.forEach(((p, i) => {
58
- sortFace.push({
59
- faceIdx: i,
60
- polygon: p
61
- });
62
- const {polygon: polygon, normal: normal} = p, z1 = viewdVerticesZ[polygon[0]], z2 = viewdVerticesZ[polygon[1]], z3 = viewdVerticesZ[polygon[2]], z4 = viewdVerticesZ[polygon[3]];
63
- p.ave_z = z1 + z2 + z3 + z4;
64
- })), sortFace.sort(((a, b) => b.polygon.ave_z - a.polygon.ave_z)), sortFace.forEach((item => {
65
- const {polygon: polygon, normal: normal} = item.polygon, p1 = vertices[polygon[0]], p2 = vertices[polygon[1]], p3 = vertices[polygon[2]], p4 = vertices[polygon[3]], v1 = {
66
- x: x + p1[0],
67
- y: y + p1[1],
68
- z: z + p1[2]
69
- }, v2 = {
70
- x: x + p2[0],
71
- y: y + p2[1],
72
- z: z + p2[2]
73
- }, v3 = {
74
- x: x + p3[0],
75
- y: y + p3[1],
76
- z: z + p3[2]
77
- }, v4 = {
78
- x: x + p4[0],
79
- y: y + p4[1],
80
- z: z + p4[2]
81
- };
82
- context.beginPath(), context.moveTo(v1.x, v1.y, v1.z), context.lineTo(v2.x, v2.y, v2.z),
83
- context.lineTo(v3.x, v3.y, v3.z), context.lineTo(v4.x, v4.y, v4.z), context.closePath(),
84
- fillCb ? fillCb(context, null, null) : (context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor,
85
- context.fill());
86
- }));
87
- }
88
39
  draw(rect, renderService, drawContext) {
89
40
  const rectAttribute = (0, theme_1.getTheme)(rect).rect;
90
41
  this._draw(rect, rectAttribute, !1, drawContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/rect3d-render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mEAA4D;AAC5D,kDAAkD;AAelD,mCAAiF;AACjF,+CAA2C;AAC3C,0DAAgE;AAChE,wDAA8D;AAEvD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,wBAAmB;IAA3D;;QACL,SAAI,GAAG,QAAQ,CAAC;QAChB,eAAU,GAAW,8BAAkB,CAAC;IA4L1C,CAAC;IAzLC,SAAS,CACP,IAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAGZ,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,EACJ,IAAI,GAAG,aAAa,CAAC,IAAI,EACzB,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,EAAE,EACF,EAAE,EACF,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,OAAO,GAAG,aAAa,CAAC,OAAO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C,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,QAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,OAAO,CAAC,IAAI,EAAE,CAAC;aAChB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,IAAa,EAAE,aAA6B,EAAE,WAAyB;QAC1E,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AA9LY,yBAAyB;IADrC,IAAA,2BAAU,GAAE;GACA,yBAAyB,CA8LrC;AA9LY,8DAAyB","file":"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,mEAA4D;AAC5D,kDAAkD;AAalD,mCAAiF;AACjF,0DAAgE;AAChE,qDAAgD;AAEzC,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,6BAAqB;IAA7D;;QACL,SAAI,GAAG,QAAQ,CAAC;QAChB,eAAU,GAAW,8BAAkB,CAAC;IAmF1C,CAAC;IAhFC,SAAS,CACP,IAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAGZ,MAAM,aAAa,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,EACJ,IAAI,GAAG,aAAa,CAAC,IAAI,EACzB,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,EAAE,EACF,EAAE,EACF,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,WAAW,GAAG,aAAa,CAAC,WAAW,EACvC,SAAS,GAAG,aAAa,CAAC,SAAS,EACnC,aAAa,GAAG,aAAa,CAAC,aAAa,EAC3C,OAAO,GAAG,aAAa,CAAC,OAAO,EAChC,GAAG,IAAI,CAAC,SAAS,CAAC;QACnB,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAEvC,KAAK,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC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AAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;SAC1E;QACD,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;YAClE,IAAI,CAAC,MAAM,CAAC,CAAC,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,IAAA,gBAAQ,EAAC,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,IAAA,2BAAU,GAAE;GACA,yBAAyB,CAqFrC;AArFY,8DAAyB","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"]}
@@ -31,34 +31,25 @@ let DefaultCanvasSymbolRender = class extends base_render_1.BaseRender {
31
31
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, parsedPath = symbol.getParsedPath();
32
32
  if (!parsedPath) return;
33
33
  const {keepDirIn3d: keepDirIn3d = symbolAttribute.keepDirIn3d} = symbol.attribute, z = null !== (_a = this.z) && void 0 !== _a ? _a : 0;
34
- if (context.beginPath(), keepDirIn3d && context.camera && context.project) {
35
- const p = context.project(x, y, z), camera = context.camera;
36
- context.camera = null, !1 === parsedPath.draw(context, (0, vutils_1.isArray)(size) ? [ size[0] * scaleX, size[1] * scaleY ] : size * scaleX, p.x, p.y, void 0, ((p, a) => {
37
- var _a, _b, _c;
38
- if (symbol._parsedPath.svgCache) {
39
- const obj = Object.assign({}, a);
40
- obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
41
- obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
42
- obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
43
- a = obj;
44
- }
45
- a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute),
46
- context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
47
- context.stroke()));
48
- })) && context.closePath(), context.camera = camera;
49
- } else !1 === parsedPath.draw(context, size, x, y, z, ((p, a) => {
34
+ context.beginPath();
35
+ const callback = (p, a) => {
50
36
  var _a, _b, _c;
51
37
  if (symbol._parsedPath.svgCache) {
52
38
  const obj = Object.assign({}, a);
53
39
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
54
- obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity,
40
+ obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
55
41
  obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
56
42
  a = obj;
57
43
  }
58
44
  a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute),
59
45
  context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
60
46
  context.stroke()));
61
- })) && context.closePath();
47
+ };
48
+ if (keepDirIn3d && context.camera && context.project) {
49
+ const p = context.project(x, y, z), camera = context.camera;
50
+ context.camera = null, !1 === parsedPath.draw(context, (0, vutils_1.isArray)(size) ? [ size[0] * scaleX, size[1] * scaleY ] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(),
51
+ context.camera = camera;
52
+ } else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
62
53
  context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute),
63
54
  this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb),
64
55
  doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),