@visactor/vrender-core 0.18.14 → 0.18.16

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 (39) hide show
  1. package/cjs/graphic/config.js +3 -0
  2. package/cjs/graphic/config.js.map +1 -1
  3. package/cjs/graphic/graphic-service/graphic-service.d.ts +1 -0
  4. package/cjs/graphic/graphic-service/graphic-service.js +18 -3
  5. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  6. package/cjs/graphic/rect3d.js +1 -1
  7. package/cjs/graphic/rect3d.js.map +1 -1
  8. package/cjs/graphic/theme.js +0 -2
  9. package/cjs/graphic/theme.js.map +1 -1
  10. package/cjs/interface/graphic/theme.d.ts +0 -3
  11. package/cjs/interface/graphic/theme.js.map +1 -1
  12. package/cjs/interface/graphic.d.ts +3 -0
  13. package/cjs/interface/graphic.js.map +1 -1
  14. package/cjs/render/contributions/render/base-render.js +2 -0
  15. package/cjs/render/contributions/render/base-render.js.map +1 -1
  16. package/cjs/render/contributions/render/rect3d-render.js +1 -1
  17. package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
  18. package/cjs/render/contributions/render/utils.js +1 -1
  19. package/cjs/render/contributions/render/utils.js.map +1 -1
  20. package/es/graphic/config.js +3 -0
  21. package/es/graphic/config.js.map +1 -1
  22. package/es/graphic/graphic-service/graphic-service.d.ts +1 -0
  23. package/es/graphic/graphic-service/graphic-service.js +18 -6
  24. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  25. package/es/graphic/rect3d.js +1 -1
  26. package/es/graphic/rect3d.js.map +1 -1
  27. package/es/graphic/theme.js +1 -3
  28. package/es/graphic/theme.js.map +1 -1
  29. package/es/interface/graphic/theme.d.ts +0 -3
  30. package/es/interface/graphic/theme.js.map +1 -1
  31. package/es/interface/graphic.d.ts +3 -0
  32. package/es/interface/graphic.js.map +1 -1
  33. package/es/render/contributions/render/base-render.js +2 -0
  34. package/es/render/contributions/render/base-render.js.map +1 -1
  35. package/es/render/contributions/render/rect3d-render.js +1 -1
  36. package/es/render/contributions/render/rect3d-render.js.map +1 -1
  37. package/es/render/contributions/render/utils.js +1 -1
  38. package/es/render/contributions/render/utils.js.map +1 -1
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,uBAAuB;IAChC,QAAQ,EAAE,wBAAwB;IAClC,YAAY,EAAE,4BAA4B;IAC1C,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;CAC7B,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE/C,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC;QAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC;QAC7C,MA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;aACP;YACD,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACd;QACD,IAAI,CAAC,CAAC,EAAE;YACN,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;YACZ,CAAC,CAAC,WAAW,EAAE,CAAC;SACjB;QACD,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAW,CAAC,CAAC;KACtC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","file":"theme.js","sourcesContent":["import { Logger, clone } from '@visactor/vutils';\nimport type { IGraphicAttribute, IFullThemeSpec, IGraphic, IGroup, ITheme, IThemeSpec } from '../interface';\nimport {\n DefaultArcAttribute,\n DefaultAreaAttribute,\n DefaultCircleAttribute,\n DefaultGlyphAttribute,\n DefaultGroupAttribute,\n DefaultImageAttribute,\n DefaultLineAttribute,\n DefaultPathAttribute,\n DefaultPolygonAttribute,\n DefaultRect3dAttribute,\n DefaultRectAttribute,\n DefaultSymbolAttribute,\n DefaultTextAttribute,\n DefaultRichTextAttribute,\n DefaultRichTextIconAttribute\n} from './config';\n\nconst defaultThemeObj = {\n arc: DefaultArcAttribute,\n area: DefaultAreaAttribute,\n circle: DefaultCircleAttribute,\n line: DefaultLineAttribute,\n path: DefaultPathAttribute,\n symbol: DefaultSymbolAttribute,\n text: DefaultTextAttribute,\n rect: DefaultRectAttribute,\n rect3d: DefaultRect3dAttribute,\n polygon: DefaultPolygonAttribute,\n richtext: DefaultRichTextAttribute,\n richtextIcon: DefaultRichTextIconAttribute,\n image: DefaultImageAttribute,\n group: DefaultGroupAttribute,\n glyph: DefaultGlyphAttribute\n};\n\nconst themeKeys = Object.keys(defaultThemeObj);\n\nexport function newThemeObj(): IFullThemeSpec {\n return {\n arc: Object.assign({}, defaultThemeObj.arc),\n area: Object.assign({}, defaultThemeObj.area),\n circle: Object.assign({}, defaultThemeObj.circle),\n line: Object.assign({}, defaultThemeObj.line),\n path: Object.assign({}, defaultThemeObj.path),\n symbol: Object.assign({}, defaultThemeObj.symbol),\n text: Object.assign({}, defaultThemeObj.text),\n rect: Object.assign({}, defaultThemeObj.rect),\n rect3d: Object.assign({}, defaultThemeObj.rect3d),\n polygon: Object.assign({}, defaultThemeObj.polygon),\n richtext: Object.assign({}, defaultThemeObj.richtext),\n richtextIcon: Object.assign({}, defaultThemeObj.richtextIcon),\n image: Object.assign({}, defaultThemeObj.image),\n group: Object.assign({}, defaultThemeObj.group),\n glyph: Object.assign({}, defaultThemeObj.glyph)\n };\n}\n\n// /**\n// * 将t合并到out中\n// * @param out\n// * @param t\n// * @param rewrite 是否重写out的属性\n// * @returns\n// */\n// function combineTheme(out: IThemeSpec, t: IThemeSpec, rewrite: boolean = true) {\n// if (!t) {\n// return;\n// }\n// if (rewrite) {\n// Object.keys(t).forEach(k => {\n// if (out[k]) {\n// Object.assign(out[k], t[k]);\n// } else {\n// out[k] = t[k];\n// }\n// });\n// } else {\n// Object.keys(t).forEach(k => {\n// if (out[k]) {\n// // Object.assign(out[k], t[k]);\n// const outItem = out[k];\n// const tItem = t[k];\n// Object.keys(t[k]).forEach(kItem => {\n// if (outItem[kItem] === undefined) {\n// outItem[kItem] = tItem[kItem];\n// }\n// });\n// } else {\n// out[k] = t[k];\n// }\n// });\n// }\n// }\n\nfunction combine(out: Record<string, any>, t: Record<string, any>) {\n Object.keys(t).forEach(k => {\n out[k] = t[k];\n });\n}\n\nconst globalThemeObj = newThemeObj();\n\n// // 性能优化,没有修改的theme都使用这个\n// const defaultCommontTheme = newThemeObj();\n\n// function combineTheme(out: IThemeSpec, userTheme: IThemeSpec, defaultTheme: IFullThemeSpec) {\n\n// }\n\n// 优先级:\n// 1. userTheme\n// 2. commonTheme\n// 3. parentTheme\n// 4. defaultTheme\n\n// 使用原型链来保存主题,避免大量的merge操作\nexport class Theme implements ITheme {\n // 当前的总theme,最终合并后的theme\n combinedTheme: IFullThemeSpec;\n // 记录累计应用的所有用户设置上的theme\n userTheme?: IThemeSpec;\n\n protected _defaultTheme: IFullThemeSpec;\n\n dirty: boolean;\n\n constructor() {\n this.initTheme();\n this.dirty = false;\n }\n\n initTheme() {\n this._defaultTheme = {} as any;\n themeKeys.forEach(key => {\n this._defaultTheme[key] = Object.create(globalThemeObj[key]);\n });\n this.combinedTheme = this._defaultTheme;\n }\n\n /**\n * 获取group上应该有的主题配置\n * @param group\n * @returns\n */\n getTheme(group?: IGroup) {\n if (!group) {\n return this.combinedTheme;\n }\n if (!this.dirty) {\n return this.combinedTheme;\n }\n let parentTheme = {};\n const parentGroup = this.getParentWithTheme(group);\n if (parentGroup) {\n parentTheme = parentGroup.theme;\n }\n this.applyTheme(group, parentTheme);\n return this.combinedTheme;\n }\n\n // 获取具有主题的parent\n getParentWithTheme(group: IGroup) {\n while (group.parent) {\n group = group.parent;\n if (group.theme) {\n return group;\n }\n }\n return null;\n }\n\n // 应用主题,从根节点一直触发到当前节点(如果上层节点需要的话)\n applyTheme(group: IGroup, pt: IThemeSpec, force: boolean = false): IThemeSpec {\n if (this.dirty) {\n const parentGroup = this.getParentWithTheme(group);\n if (parentGroup) {\n const parentTheme = parentGroup.theme;\n if (parentTheme.dirty || force) {\n // 强制apply所有的上层\n parentTheme.applyTheme(parentGroup, pt, true);\n }\n }\n // 如果当前节点没有userTheme的话,直接复用上层的combinedTheme\n // 或者直接用默认的theme\n if (!this.userTheme) {\n if (parentGroup) {\n this.combinedTheme = parentGroup.theme.combinedTheme;\n } else {\n this.combinedTheme = this._defaultTheme;\n Logger.getInstance().warn('未知错误,走到不应该走的区域里');\n }\n this.dirty = false;\n } else {\n this.doCombine(parentGroup && parentGroup.theme.combinedTheme);\n }\n }\n\n return this.combinedTheme;\n }\n\n // 合并userTheme到combinedTheme\n protected doCombine(parentCombinedTheme?: IThemeSpec) {\n const userTheme = this.userTheme;\n const combinedTheme = this.combinedTheme;\n\n // 1. userTheme\n // 2. combinedTheme\n // 3. parentCombinedTheme\n // 4. defaultTheme\n themeKeys.forEach(k => {\n // init defaultTheme\n const obj = Object.create(globalThemeObj[k]);\n // merge parentCombinedTheme\n if (parentCombinedTheme && parentCombinedTheme[k]) {\n combine(obj, parentCombinedTheme[k]);\n }\n // merge combinedTheme\n if (combinedTheme[k]) {\n combine(obj, combinedTheme[k]);\n }\n // merge userTheme\n if (userTheme[k]) {\n combine(obj, userTheme[k]);\n }\n this.combinedTheme[k] = obj;\n });\n if (userTheme.common) {\n themeKeys.forEach(k => {\n combine(this.combinedTheme[k], userTheme.common);\n });\n }\n this.dirty = false;\n }\n\n setTheme(t: IThemeSpec, g: IGroup) {\n // 设置自己的nextTheme\n let userTheme = this.userTheme;\n if (userTheme) {\n Object.keys(t).forEach(k => {\n if (userTheme[k]) {\n Object.assign(userTheme[k], t[k]);\n } else {\n // todo,这里调用次数不多,应该问题不大\n userTheme[k] = Object.assign({}, t[k]);\n }\n });\n } else {\n userTheme = t;\n }\n this.userTheme = userTheme;\n // 设置自己和子节点的theme都为dirty\n this.dirty = true;\n this.dirtyChildren(g);\n }\n\n resetTheme(t: IThemeSpec, g: IGroup) {\n this.userTheme = t;\n // 设置自己和子节点的theme都为dirty\n this.dirty = true;\n this.dirtyChildren(g);\n }\n\n dirtyChildren(g: IGroup) {\n g.forEachChildren(item => {\n if ((item as IGroup).isContainer) {\n if ((item as IGroup).theme) {\n (item as IGroup).theme.dirty = true;\n }\n this.dirtyChildren(item as IGroup);\n }\n });\n }\n}\n\nexport const globalTheme = new Theme();\n\nexport function getTheme(graphic: IGraphic, theme?: IFullThemeSpec): IFullThemeSpec {\n if (graphic.glyphHost) {\n return getTheme(graphic.glyphHost);\n }\n if (theme) {\n if (graphic.isContainer) {\n // 暂时不支持Group\n return theme;\n }\n return theme;\n }\n\n return (\n getThemeFromGroup(graphic) ||\n (graphic.attachedThemeGraphic && getTheme(graphic.attachedThemeGraphic)) ||\n globalTheme.getTheme()\n );\n}\n\nexport function getThemeFromGroup(graphic: IGraphic): IFullThemeSpec | null {\n let g: IGroup;\n if (graphic.isContainer) {\n // 找到存在theme的group\n g = graphic as IGroup;\n } else {\n g = graphic.parent;\n }\n\n if (g) {\n while (g) {\n if (g.theme) {\n break;\n }\n g = g.parent;\n }\n if (!g) {\n return globalTheme.getTheme();\n }\n if (!g.theme) {\n g.createTheme();\n }\n return g.theme.getTheme(g as IGroup);\n }\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,UAAU,CAAC;AAElB,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;IAC9B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,OAAO,EAAE,uBAAuB;IAChC,QAAQ,EAAE,wBAAwB;IAClC,YAAY,EAAE,4BAA4B;IAC1C,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;CAC7B,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE/C,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC;QAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CA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AC,CAAC,EAAE;YACN,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;SAC/B;QACD,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;YACZ,CAAC,CAAC,WAAW,EAAE,CAAC;SACjB;QACD,OAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAW,CAAC,CAAC;KACtC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","file":"theme.js","sourcesContent":["import { Logger } from '@visactor/vutils';\nimport type { IFullThemeSpec, IGraphic, IGroup, ITheme, IThemeSpec } from '../interface';\nimport {\n DefaultArcAttribute,\n DefaultAreaAttribute,\n DefaultCircleAttribute,\n DefaultGlyphAttribute,\n DefaultGroupAttribute,\n DefaultImageAttribute,\n DefaultLineAttribute,\n DefaultPathAttribute,\n DefaultPolygonAttribute,\n DefaultRectAttribute,\n DefaultSymbolAttribute,\n DefaultTextAttribute,\n DefaultRichTextAttribute,\n DefaultRichTextIconAttribute\n} from './config';\n\nconst defaultThemeObj = {\n arc: DefaultArcAttribute,\n area: DefaultAreaAttribute,\n circle: DefaultCircleAttribute,\n line: DefaultLineAttribute,\n path: DefaultPathAttribute,\n symbol: DefaultSymbolAttribute,\n text: DefaultTextAttribute,\n rect: DefaultRectAttribute,\n polygon: DefaultPolygonAttribute,\n richtext: DefaultRichTextAttribute,\n richtextIcon: DefaultRichTextIconAttribute,\n image: DefaultImageAttribute,\n group: DefaultGroupAttribute,\n glyph: DefaultGlyphAttribute\n};\n\nconst themeKeys = Object.keys(defaultThemeObj);\n\nexport function newThemeObj(): IFullThemeSpec {\n return {\n arc: Object.assign({}, defaultThemeObj.arc),\n area: Object.assign({}, defaultThemeObj.area),\n circle: Object.assign({}, defaultThemeObj.circle),\n line: Object.assign({}, defaultThemeObj.line),\n path: Object.assign({}, defaultThemeObj.path),\n symbol: Object.assign({}, defaultThemeObj.symbol),\n text: Object.assign({}, defaultThemeObj.text),\n rect: Object.assign({}, defaultThemeObj.rect),\n polygon: Object.assign({}, defaultThemeObj.polygon),\n richtext: Object.assign({}, defaultThemeObj.richtext),\n richtextIcon: Object.assign({}, defaultThemeObj.richtextIcon),\n image: Object.assign({}, defaultThemeObj.image),\n group: Object.assign({}, defaultThemeObj.group),\n glyph: Object.assign({}, defaultThemeObj.glyph)\n };\n}\n\n// /**\n// * 将t合并到out中\n// * @param out\n// * @param t\n// * @param rewrite 是否重写out的属性\n// * @returns\n// */\n// function combineTheme(out: IThemeSpec, t: IThemeSpec, rewrite: boolean = true) {\n// if (!t) {\n// return;\n// }\n// if (rewrite) {\n// Object.keys(t).forEach(k => {\n// if (out[k]) {\n// Object.assign(out[k], t[k]);\n// } else {\n// out[k] = t[k];\n// }\n// });\n// } else {\n// Object.keys(t).forEach(k => {\n// if (out[k]) {\n// // Object.assign(out[k], t[k]);\n// const outItem = out[k];\n// const tItem = t[k];\n// Object.keys(t[k]).forEach(kItem => {\n// if (outItem[kItem] === undefined) {\n// outItem[kItem] = tItem[kItem];\n// }\n// });\n// } else {\n// out[k] = t[k];\n// }\n// });\n// }\n// }\n\nfunction combine(out: Record<string, any>, t: Record<string, any>) {\n Object.keys(t).forEach(k => {\n out[k] = t[k];\n });\n}\n\nconst globalThemeObj = newThemeObj();\n\n// // 性能优化,没有修改的theme都使用这个\n// const defaultCommontTheme = newThemeObj();\n\n// function combineTheme(out: IThemeSpec, userTheme: IThemeSpec, defaultTheme: IFullThemeSpec) {\n\n// }\n\n// 优先级:\n// 1. userTheme\n// 2. commonTheme\n// 3. parentTheme\n// 4. defaultTheme\n\n// 使用原型链来保存主题,避免大量的merge操作\nexport class Theme implements ITheme {\n // 当前的总theme,最终合并后的theme\n combinedTheme: IFullThemeSpec;\n // 记录累计应用的所有用户设置上的theme\n userTheme?: IThemeSpec;\n\n protected _defaultTheme: IFullThemeSpec;\n\n dirty: boolean;\n\n constructor() {\n this.initTheme();\n this.dirty = false;\n }\n\n initTheme() {\n this._defaultTheme = {} as any;\n themeKeys.forEach(key => {\n this._defaultTheme[key] = Object.create(globalThemeObj[key]);\n });\n this.combinedTheme = this._defaultTheme;\n }\n\n /**\n * 获取group上应该有的主题配置\n * @param group\n * @returns\n */\n getTheme(group?: IGroup) {\n if (!group) {\n return this.combinedTheme;\n }\n if (!this.dirty) {\n return this.combinedTheme;\n }\n let parentTheme = {};\n const parentGroup = this.getParentWithTheme(group);\n if (parentGroup) {\n parentTheme = parentGroup.theme;\n }\n this.applyTheme(group, parentTheme);\n return this.combinedTheme;\n }\n\n // 获取具有主题的parent\n getParentWithTheme(group: IGroup) {\n while (group.parent) {\n group = group.parent;\n if (group.theme) {\n return group;\n }\n }\n return null;\n }\n\n // 应用主题,从根节点一直触发到当前节点(如果上层节点需要的话)\n applyTheme(group: IGroup, pt: IThemeSpec, force: boolean = false): IThemeSpec {\n if (this.dirty) {\n const parentGroup = this.getParentWithTheme(group);\n if (parentGroup) {\n const parentTheme = parentGroup.theme;\n if (parentTheme.dirty || force) {\n // 强制apply所有的上层\n parentTheme.applyTheme(parentGroup, pt, true);\n }\n }\n // 如果当前节点没有userTheme的话,直接复用上层的combinedTheme\n // 或者直接用默认的theme\n if (!this.userTheme) {\n if (parentGroup) {\n this.combinedTheme = parentGroup.theme.combinedTheme;\n } else {\n this.combinedTheme = this._defaultTheme;\n Logger.getInstance().warn('未知错误,走到不应该走的区域里');\n }\n this.dirty = false;\n } else {\n this.doCombine(parentGroup && parentGroup.theme.combinedTheme);\n }\n }\n\n return this.combinedTheme;\n }\n\n // 合并userTheme到combinedTheme\n protected doCombine(parentCombinedTheme?: IThemeSpec) {\n const userTheme = this.userTheme;\n const combinedTheme = this.combinedTheme;\n\n // 1. userTheme\n // 2. combinedTheme\n // 3. parentCombinedTheme\n // 4. defaultTheme\n themeKeys.forEach(k => {\n // init defaultTheme\n const obj = Object.create(globalThemeObj[k]);\n // merge parentCombinedTheme\n if (parentCombinedTheme && parentCombinedTheme[k]) {\n combine(obj, parentCombinedTheme[k]);\n }\n // merge combinedTheme\n if (combinedTheme[k]) {\n combine(obj, combinedTheme[k]);\n }\n // merge userTheme\n if (userTheme[k]) {\n combine(obj, userTheme[k]);\n }\n this.combinedTheme[k] = obj;\n });\n if (userTheme.common) {\n themeKeys.forEach(k => {\n combine(this.combinedTheme[k], userTheme.common);\n });\n }\n this.dirty = false;\n }\n\n setTheme(t: IThemeSpec, g: IGroup) {\n // 设置自己的nextTheme\n let userTheme = this.userTheme;\n if (userTheme) {\n Object.keys(t).forEach(k => {\n if (userTheme[k]) {\n Object.assign(userTheme[k], t[k]);\n } else {\n // todo,这里调用次数不多,应该问题不大\n userTheme[k] = Object.assign({}, t[k]);\n }\n });\n } else {\n userTheme = t;\n }\n this.userTheme = userTheme;\n // 设置自己和子节点的theme都为dirty\n this.dirty = true;\n this.dirtyChildren(g);\n }\n\n resetTheme(t: IThemeSpec, g: IGroup) {\n this.userTheme = t;\n // 设置自己和子节点的theme都为dirty\n this.dirty = true;\n this.dirtyChildren(g);\n }\n\n dirtyChildren(g: IGroup) {\n g.forEachChildren(item => {\n if ((item as IGroup).isContainer) {\n if ((item as IGroup).theme) {\n (item as IGroup).theme.dirty = true;\n }\n this.dirtyChildren(item as IGroup);\n }\n });\n }\n}\n\nexport const globalTheme = new Theme();\n\nexport function getTheme(graphic: IGraphic, theme?: IFullThemeSpec): IFullThemeSpec {\n if (graphic.glyphHost) {\n return getTheme(graphic.glyphHost);\n }\n if (theme) {\n if (graphic.isContainer) {\n // 暂时不支持Group\n return theme;\n }\n return theme;\n }\n\n return (\n getThemeFromGroup(graphic) ||\n (graphic.attachedThemeGraphic && getTheme(graphic.attachedThemeGraphic)) ||\n globalTheme.getTheme()\n );\n}\n\nexport function getThemeFromGroup(graphic: IGraphic): IFullThemeSpec | null {\n let g: IGroup;\n if (graphic.isContainer) {\n // 找到存在theme的group\n g = graphic as IGroup;\n } else {\n g = graphic.parent;\n }\n\n if (g) {\n while (g) {\n if (g.theme) {\n break;\n }\n g = g.parent;\n }\n if (!g) {\n return globalTheme.getTheme();\n }\n if (!g.theme) {\n g.createTheme();\n }\n return g.theme.getTheme(g as IGroup);\n }\n return null;\n}\n"]}
@@ -9,14 +9,12 @@ import type { ILineGraphicAttribute } from './line';
9
9
  import type { IPathGraphicAttribute } from './path';
10
10
  import type { IPolygonGraphicAttribute } from './polygon';
11
11
  import type { IRectGraphicAttribute } from './rect';
12
- import type { IRect3dGraphicAttribute } from './rect3d';
13
12
  import type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';
14
13
  import type { ISymbolGraphicAttribute } from './symbol';
15
14
  import type { ITextGraphicAttribute } from './text';
16
15
  export interface IThemeSpec {
17
16
  text?: Partial<ITextGraphicAttribute>;
18
17
  rect?: Partial<IRectGraphicAttribute>;
19
- rect3d?: Partial<IRect3dGraphicAttribute>;
20
18
  arc?: Partial<IArcGraphicAttribute>;
21
19
  area?: Partial<IAreaGraphicAttribute>;
22
20
  circle?: Partial<ICircleGraphicAttribute>;
@@ -37,7 +35,6 @@ export interface IFullThemeSpec {
37
35
  symbol: Required<ISymbolGraphicAttribute>;
38
36
  text: Required<ITextGraphicAttribute>;
39
37
  rect: Required<IRectGraphicAttribute>;
40
- rect3d: Required<IRect3dGraphicAttribute>;
41
38
  glyph: Required<IGlyphGraphicAttribute>;
42
39
  group: Required<IGroupGraphicAttribute>;
43
40
  polygon: Required<IPolygonGraphicAttribute>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRect3dGraphicAttribute } from './rect3d';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n rect3d?: Partial<IRect3dGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n rect3d: Required<IRect3dGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
@@ -95,6 +95,8 @@ export type IBackgroundConfig = {
95
95
  };
96
96
  type IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;
97
97
  export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
98
+ forceBoundsWidth: number | (() => number) | undefined;
99
+ forceBoundsHeight: number | (() => number) | undefined;
98
100
  opacity: number;
99
101
  backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
100
102
  backgroundFit: boolean;
@@ -156,6 +158,7 @@ export type IGraphicAttribute = IDebugType & IGraphicStyle & ITransform & {
156
158
  visible: boolean;
157
159
  zIndex: number;
158
160
  layout: any;
161
+ renderable: boolean;
159
162
  keepDirIn3d?: boolean;
160
163
  shadowRootIdx: number;
161
164
  globalZIndex: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\nimport { ITheme } from './graphic/theme';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n opacity: number;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html: {\n dom: string | HTMLElement; // dom字符串或者dom\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n react: {\n element: any; // react场景节点\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IOBBBounds, IMatrix, IPointLike, IPoint } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\nimport { ITheme } from './graphic/theme';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n forceBoundsWidth: number | (() => number) | undefined;\n forceBoundsHeight: number | (() => number) | undefined;\n opacity: number;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html: {\n dom: string | HTMLElement; // dom字符串或者dom\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n react: {\n element: any; // react场景节点\n container: string | HTMLElement | null; // id或者dom\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?: string | Record<string, any>; // 容器的样式\n visible?: boolean;\n pointerEvents?: boolean;\n anchorType?: 'position' | 'boundsLeftTop';\n } | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
@@ -89,6 +89,8 @@ export class BaseRender {
89
89
  _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
90
90
  const {context: context} = drawContext;
91
91
  if (!context) return;
92
+ const {renderable: renderable} = graphic.attribute;
93
+ if (!1 === renderable) return;
92
94
  context.highPerformanceSave();
93
95
  const data = this.transform(graphic, defaultAttr, context, computed3dMatrix), {x: x, y: y, z: z, lastModelMatrix: lastModelMatrix} = data;
94
96
  this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/base-render.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAsD,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAE9G,MAAM,OAAgB,UAAU;IAY9B,IAAI,CAAC,aAAiF;QACpF,IAAI,aAAa,EAAE;YAEjB,IAAI,CAAC,oBAAoB,GAAG,aAAa,CAAC,gBAA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B,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;IAED,KAAK,CACH,OAAU,EACV,WAA8B,EAC9B,gBAAyB,EACzB,WAAyB,EACzB,MAAiC;QAEjC,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAE9B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC7E,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;QAE1C,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;YAC9D,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO;SACR;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CAsHF","file":"base-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n ICamera,\n IContext2d,\n IGraphic,\n mat4,\n IRenderService,\n IDrawContext,\n IGraphicRenderDrawParams,\n IMarkAttribute,\n IThemeAttribute,\n IContributionProvider,\n ICircleRenderContribution,\n IBaseRenderContribution\n} from '../../../interface';\nimport { getModelMatrix, multiplyMat4Mat4, shouldUseMat4 } from '../../../graphic';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRenderContributionTime } from '../../../common/enums';\n\nconst result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x: 0, y: 0, z: 0, lastModelMatrix: null };\n\nexport abstract class BaseRender<T extends IGraphic> {\n camera: ICamera;\n declare z: number;\n\n builtinContributions: IBaseRenderContribution<T, T['attribute']>[];\n\n // declare renderContribitions: IContributionProvider<IBaseRenderContribution<T, T['attribute']>> | null;\n\n protected _beforeRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _afterRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _renderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n\n init(contributions?: IContributionProvider<IBaseRenderContribution<T, T['attribute']>>) {\n if (contributions) {\n // this.renderContribitions = contributions;\n this._renderContribitions = contributions.getContributions();\n }\n if (!this._renderContribitions) {\n this._renderContribitions = [];\n }\n this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item));\n if (this._renderContribitions.length) {\n this._renderContribitions.sort((a, b) => b.order - a.order);\n this._beforeRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.beforeFillStroke\n );\n this._afterRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.afterFillStroke\n );\n }\n }\n\n beforeRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\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 params?: any\n ) {\n this._beforeRenderContribitions &&\n this._beforeRenderContribitions.forEach(c => {\n c.drawShape(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n params\n );\n });\n }\n\n afterRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\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 params?: any\n ) {\n this._afterRenderContribitions &&\n this._afterRenderContribitions.forEach(c => {\n c.drawShape(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n params\n );\n });\n }\n\n valid(graphic: IGraphic, defaultAttribute: IGraphicAttribute, fillCb?: any, strokeCb?: any) {\n const {\n fill = defaultAttribute.fill,\n background,\n stroke = defaultAttribute.stroke,\n opacity = defaultAttribute.opacity,\n fillOpacity = defaultAttribute.fillOpacity,\n lineWidth = defaultAttribute.lineWidth,\n strokeOpacity = defaultAttribute.strokeOpacity,\n visible = defaultAttribute.visible\n } = graphic.attribute;\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(graphic.valid && visible)) {\n return false;\n }\n\n if (!(doFill || doStroke)) {\n return false;\n }\n\n // 如果存在fillCb和strokeCb,以及background那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return false;\n }\n return {\n fVisible,\n sVisible,\n doFill,\n doStroke\n };\n }\n\n /**\n * 进行2d或3d变换\n * @param graphic\n * @param graphicAttribute\n * @param context\n * @param use3dMatrixIn3dMode 是否在3d模式使用3d矩阵\n * @returns\n */\n transform(\n graphic: IGraphic,\n graphicAttribute: IGraphicAttribute,\n context: IContext2d,\n use3dMatrixIn3dMode: boolean = false\n ): IPointLike & { z: number; lastModelMatrix: mat4 } {\n // const transMatrix = graphic.transMatrix;\n const {\n x = graphicAttribute.x,\n y = graphicAttribute.y,\n z = graphicAttribute.z,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY,\n angle = graphicAttribute.angle,\n postMatrix\n } = graphic.attribute;\n // const onlyTranslate = transMatrix.onlyTranslate() && !postMatrix;\n\n // 存在3d变换的时候,需要计算3d矩阵\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n // const result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x, y, z, lastModelMatrix };\n result.x = x;\n result.y = y;\n result.z = z;\n result.lastModelMatrix = lastModelMatrix;\n\n // 是否应该进行3d变换\n const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic));\n\n // 是否仅有translate\n const onlyTranslate = shouldTransform3d\n ? graphic.transMatrix.onlyTranslate() && !postMatrix\n : scaleX === 1 && scaleY === 1 && angle === 0 && !postMatrix;\n\n if (shouldTransform3d) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, graphic, graphicAttribute);\n // 合并模型矩阵\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.modelMatrix = nextModelMatrix;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n mat4Allocate.free(modelMatrix);\n // 有旋转的情况下需要手动计算模型矩阵\n // TODO: 这里暂时都使用模型矩阵,因为视角旋转的时候如果当不固定角度那也需要用到模型矩阵\n }\n\n // 如果只有位移,且没计算3d变换矩阵,那么不设置context的2d矩阵\n if (onlyTranslate && !lastModelMatrix) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n result.z = z;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n } else if (shouldTransform3d) {\n // 如果计算了3d矩阵,那么就不需要2d矩阵计算了\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n if (camera && context.project) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n // result.x = 0;\n // result.y = 0;\n // 位置直接通过project设置,而2d变换通过变换矩阵完成\n this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);\n } else {\n // 如果是纯2d的情况,那么直接设置context的2d矩阵\n // 性能较差\n context.transformFromMatrix(graphic.transMatrix, true);\n result.x = 0;\n result.y = 0;\n result.z = 0;\n }\n }\n\n return result;\n }\n\n /**\n * 将3d的transform转成context2d的transform\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n transformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n const camera = context.camera;\n this.camera = camera;\n if (camera) {\n const bounds = graphic.AABBBounds;\n const width = bounds.x2 - bounds.x1;\n const height = bounds.y2 - bounds.y1;\n const p1 = context.project(0, 0, z);\n const p2 = context.project(width, 0, z);\n const p3 = context.project(width, height, z);\n const _p1 = { x: 0, y: 0 };\n const _p2 = { x: width, y: 0 };\n const _p3 = { x: width, y: height };\n\n context.camera = null;\n\n // 生成3维矩阵\n /* Adapted from phoria.js by ecomfe\n * https://github.com/kevinroast/phoria.js\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/kevinroast/phoria.js/blob/736c6b854a679df180f8a6e689aeb218efa6dc01/scripts/phoria-renderer.js\n * License: https://github.com/kevinroast/phoria.js/blob/master/LICENSE\n * @license\n */\n const denom = 1.0 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y);\n // calculate context transformation matrix\n const m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom;\n const m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom;\n const m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom;\n const m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom;\n const dx =\n (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) +\n _p1.y * (_p2.x * p3.x - _p3.x * p2.x) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) *\n denom;\n const dy =\n (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) +\n _p1.y * (_p2.x * p3.y - _p3.x * p2.y) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) *\n denom;\n\n context.setTransform(m11, m12, m21, m22, dx, dy, true);\n }\n }\n\n /**\n * transformUseContext2d的后处理\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n restoreTransformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n if (this.camera) {\n context.camera = this.camera;\n }\n }\n\n protected transformWithoutTranslate(\n context: IContext2d,\n x: number,\n y: number,\n z: number,\n scaleX: number,\n scaleY: number,\n angle: number\n ) {\n const p = context.project(x, y, z);\n context.translate(p.x, p.y, false);\n context.scale(scaleX, scaleY, false);\n context.rotate(angle, false);\n context.translate(-p.x, -p.y, false);\n context.setTransformForCurrent();\n }\n\n _draw(\n graphic: T,\n defaultAttr: IGraphicAttribute,\n computed3dMatrix: boolean,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n context.highPerformanceSave();\n\n const data = this.transform(graphic, defaultAttr, context, computed3dMatrix);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(graphic, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(graphic, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n\n drawShape?(\n path: T,\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 ): void;\n\n // abstract drawShape(\n // graphic: T,\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 // ): void;\n\n // drawPathProxy(\n // graphic: T,\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 // if (!graphic.pathProxy) {\n // return false;\n // }\n\n // const themeAttributes = getTheme(graphic)[graphic.type];\n\n // const {\n // fill = themeAttributes.fill == null ? !!graphic.attribute.fillColor : themeAttributes.fill,\n // stroke = themeAttributes.stroke == null ? !!graphic.attribute.strokeColor : themeAttributes.stroke,\n // opacity = themeAttributes.opacity,\n // fillOpacity = themeAttributes.fillOpacity,\n // lineWidth = themeAttributes.lineWidth,\n // strokeOpacity = themeAttributes.strokeOpacity,\n // visible = themeAttributes.visible\n // } = graphic.attribute;\n // // 不绘制或者透明\n // const fVisible = fillVisible(opacity, fillOpacity);\n // const sVisible = strokeVisible(opacity, strokeOpacity);\n // const doFill = runFill(fill);\n // const doStroke = runStroke(stroke, lineWidth);\n\n // if (!visible) {\n // return true;\n // }\n\n // if (!(doFill || doStroke)) {\n // return true;\n // }\n\n // // 如果存在fillCb和strokeCb,那就不直接跳过\n // if (!(fVisible || sVisible || fillCb || strokeCb)) {\n // return true;\n // }\n\n // context.beginPath();\n\n // const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n // renderCommandList(path.commandList, context, x, y);\n\n // // shadow\n // context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes);\n\n // if (doStroke) {\n // if (strokeCb) {\n // strokeCb(context, graphic.attribute, themeAttributes);\n // } else if (sVisible) {\n // context.setStrokeStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.stroke();\n // }\n // }\n // if (doFill) {\n // if (fillCb) {\n // fillCb(context, graphic.attribute, themeAttributes);\n // } else if (fVisible) {\n // context.setCommonStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.fill();\n // }\n // }\n // return true;\n // }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/base-render.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAsD,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAE9G,MAAM,OAAgB,UAAU;IAY9B,IAAI,CAAC,aAAiF;QACpF,IAAI,aAAa,EAAE;YAEjB,IAAI,CAAC,oBAAoB,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;SAC9D;QACD,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7G,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE;YACpC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;YAC5D,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAChE,CAAC,CAAC,EAAE,CAA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,gBAAgB,CAAC,CAAC;QAC7E,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;QAE1C,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;YAC9D,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO;SACR;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CAsHF","file":"base-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n ICamera,\n IContext2d,\n IGraphic,\n mat4,\n IRenderService,\n IDrawContext,\n IGraphicRenderDrawParams,\n IMarkAttribute,\n IThemeAttribute,\n IContributionProvider,\n ICircleRenderContribution,\n IBaseRenderContribution\n} from '../../../interface';\nimport { getModelMatrix, multiplyMat4Mat4, shouldUseMat4 } from '../../../graphic';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRenderContributionTime } from '../../../common/enums';\n\nconst result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x: 0, y: 0, z: 0, lastModelMatrix: null };\n\nexport abstract class BaseRender<T extends IGraphic> {\n camera: ICamera;\n declare z: number;\n\n builtinContributions: IBaseRenderContribution<T, T['attribute']>[];\n\n // declare renderContribitions: IContributionProvider<IBaseRenderContribution<T, T['attribute']>> | null;\n\n protected _beforeRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _afterRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _renderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n\n init(contributions?: IContributionProvider<IBaseRenderContribution<T, T['attribute']>>) {\n if (contributions) {\n // this.renderContribitions = contributions;\n this._renderContribitions = contributions.getContributions();\n }\n if (!this._renderContribitions) {\n this._renderContribitions = [];\n }\n this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item));\n if (this._renderContribitions.length) {\n this._renderContribitions.sort((a, b) => b.order - a.order);\n this._beforeRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.beforeFillStroke\n );\n this._afterRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.afterFillStroke\n );\n }\n }\n\n beforeRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\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 params?: any\n ) {\n this._beforeRenderContribitions &&\n this._beforeRenderContribitions.forEach(c => {\n c.drawShape(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n params\n );\n });\n }\n\n afterRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\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 params?: any\n ) {\n this._afterRenderContribitions &&\n this._afterRenderContribitions.forEach(c => {\n c.drawShape(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n params\n );\n });\n }\n\n valid(graphic: IGraphic, defaultAttribute: IGraphicAttribute, fillCb?: any, strokeCb?: any) {\n const {\n fill = defaultAttribute.fill,\n background,\n stroke = defaultAttribute.stroke,\n opacity = defaultAttribute.opacity,\n fillOpacity = defaultAttribute.fillOpacity,\n lineWidth = defaultAttribute.lineWidth,\n strokeOpacity = defaultAttribute.strokeOpacity,\n visible = defaultAttribute.visible\n } = graphic.attribute;\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(graphic.valid && visible)) {\n return false;\n }\n\n if (!(doFill || doStroke)) {\n return false;\n }\n\n // 如果存在fillCb和strokeCb,以及background那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return false;\n }\n return {\n fVisible,\n sVisible,\n doFill,\n doStroke\n };\n }\n\n /**\n * 进行2d或3d变换\n * @param graphic\n * @param graphicAttribute\n * @param context\n * @param use3dMatrixIn3dMode 是否在3d模式使用3d矩阵\n * @returns\n */\n transform(\n graphic: IGraphic,\n graphicAttribute: IGraphicAttribute,\n context: IContext2d,\n use3dMatrixIn3dMode: boolean = false\n ): IPointLike & { z: number; lastModelMatrix: mat4 } {\n // const transMatrix = graphic.transMatrix;\n const {\n x = graphicAttribute.x,\n y = graphicAttribute.y,\n z = graphicAttribute.z,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY,\n angle = graphicAttribute.angle,\n postMatrix\n } = graphic.attribute;\n // const onlyTranslate = transMatrix.onlyTranslate() && !postMatrix;\n\n // 存在3d变换的时候,需要计算3d矩阵\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n // const result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x, y, z, lastModelMatrix };\n result.x = x;\n result.y = y;\n result.z = z;\n result.lastModelMatrix = lastModelMatrix;\n\n // 是否应该进行3d变换\n const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic));\n\n // 是否仅有translate\n const onlyTranslate = shouldTransform3d\n ? graphic.transMatrix.onlyTranslate() && !postMatrix\n : scaleX === 1 && scaleY === 1 && angle === 0 && !postMatrix;\n\n if (shouldTransform3d) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, graphic, graphicAttribute);\n // 合并模型矩阵\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.modelMatrix = nextModelMatrix;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n mat4Allocate.free(modelMatrix);\n // 有旋转的情况下需要手动计算模型矩阵\n // TODO: 这里暂时都使用模型矩阵,因为视角旋转的时候如果当不固定角度那也需要用到模型矩阵\n }\n\n // 如果只有位移,且没计算3d变换矩阵,那么不设置context的2d矩阵\n if (onlyTranslate && !lastModelMatrix) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n result.z = z;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n } else if (shouldTransform3d) {\n // 如果计算了3d矩阵,那么就不需要2d矩阵计算了\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n if (camera && context.project) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n // result.x = 0;\n // result.y = 0;\n // 位置直接通过project设置,而2d变换通过变换矩阵完成\n this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);\n } else {\n // 如果是纯2d的情况,那么直接设置context的2d矩阵\n // 性能较差\n context.transformFromMatrix(graphic.transMatrix, true);\n result.x = 0;\n result.y = 0;\n result.z = 0;\n }\n }\n\n return result;\n }\n\n /**\n * 将3d的transform转成context2d的transform\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n transformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n const camera = context.camera;\n this.camera = camera;\n if (camera) {\n const bounds = graphic.AABBBounds;\n const width = bounds.x2 - bounds.x1;\n const height = bounds.y2 - bounds.y1;\n const p1 = context.project(0, 0, z);\n const p2 = context.project(width, 0, z);\n const p3 = context.project(width, height, z);\n const _p1 = { x: 0, y: 0 };\n const _p2 = { x: width, y: 0 };\n const _p3 = { x: width, y: height };\n\n context.camera = null;\n\n // 生成3维矩阵\n /* Adapted from phoria.js by ecomfe\n * https://github.com/kevinroast/phoria.js\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/kevinroast/phoria.js/blob/736c6b854a679df180f8a6e689aeb218efa6dc01/scripts/phoria-renderer.js\n * License: https://github.com/kevinroast/phoria.js/blob/master/LICENSE\n * @license\n */\n const denom = 1.0 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y);\n // calculate context transformation matrix\n const m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom;\n const m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom;\n const m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom;\n const m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom;\n const dx =\n (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) +\n _p1.y * (_p2.x * p3.x - _p3.x * p2.x) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) *\n denom;\n const dy =\n (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) +\n _p1.y * (_p2.x * p3.y - _p3.x * p2.y) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) *\n denom;\n\n context.setTransform(m11, m12, m21, m22, dx, dy, true);\n }\n }\n\n /**\n * transformUseContext2d的后处理\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n restoreTransformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n if (this.camera) {\n context.camera = this.camera;\n }\n }\n\n protected transformWithoutTranslate(\n context: IContext2d,\n x: number,\n y: number,\n z: number,\n scaleX: number,\n scaleY: number,\n angle: number\n ) {\n const p = context.project(x, y, z);\n context.translate(p.x, p.y, false);\n context.scale(scaleX, scaleY, false);\n context.rotate(angle, false);\n context.translate(-p.x, -p.y, false);\n context.setTransformForCurrent();\n }\n\n _draw(\n graphic: T,\n defaultAttr: IGraphicAttribute,\n computed3dMatrix: boolean,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // 如果hide,直接跳过后续绘制\n const { renderable } = graphic.attribute;\n if (renderable === false) {\n return;\n }\n\n context.highPerformanceSave();\n\n const data = this.transform(graphic, defaultAttr, context, computed3dMatrix);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(graphic, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(graphic, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n\n drawShape?(\n path: T,\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 ): void;\n\n // abstract drawShape(\n // graphic: T,\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 // ): void;\n\n // drawPathProxy(\n // graphic: T,\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 // if (!graphic.pathProxy) {\n // return false;\n // }\n\n // const themeAttributes = getTheme(graphic)[graphic.type];\n\n // const {\n // fill = themeAttributes.fill == null ? !!graphic.attribute.fillColor : themeAttributes.fill,\n // stroke = themeAttributes.stroke == null ? !!graphic.attribute.strokeColor : themeAttributes.stroke,\n // opacity = themeAttributes.opacity,\n // fillOpacity = themeAttributes.fillOpacity,\n // lineWidth = themeAttributes.lineWidth,\n // strokeOpacity = themeAttributes.strokeOpacity,\n // visible = themeAttributes.visible\n // } = graphic.attribute;\n // // 不绘制或者透明\n // const fVisible = fillVisible(opacity, fillOpacity);\n // const sVisible = strokeVisible(opacity, strokeOpacity);\n // const doFill = runFill(fill);\n // const doStroke = runStroke(stroke, lineWidth);\n\n // if (!visible) {\n // return true;\n // }\n\n // if (!(doFill || doStroke)) {\n // return true;\n // }\n\n // // 如果存在fillCb和strokeCb,那就不直接跳过\n // if (!(fVisible || sVisible || fillCb || strokeCb)) {\n // return true;\n // }\n\n // context.beginPath();\n\n // const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n // renderCommandList(path.commandList, context, x, y);\n\n // // shadow\n // context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes);\n\n // if (doStroke) {\n // if (strokeCb) {\n // strokeCb(context, graphic.attribute, themeAttributes);\n // } else if (sVisible) {\n // context.setStrokeStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.stroke();\n // }\n // }\n // if (doFill) {\n // if (fillCb) {\n // fillCb(context, graphic.attribute, themeAttributes);\n // } else if (fVisible) {\n // context.setCommonStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.fill();\n // }\n // }\n // return true;\n // }\n}\n"]}
@@ -22,7 +22,7 @@ let DefaultCanvasRect3dRender = class extends BaseRender {
22
22
  }
23
23
  drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
24
24
  var _a;
25
- const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect3d, {fill: fill = rectAttribute.fill, stroke: stroke = rectAttribute.stroke, x1: x1, y1: y1, x: originX, y: originY, opacity: opacity = rectAttribute.opacity, fillOpacity: fillOpacity = rectAttribute.fillOpacity, lineWidth: lineWidth = rectAttribute.lineWidth, strokeOpacity: strokeOpacity = rectAttribute.strokeOpacity, visible: visible = rectAttribute.visible} = rect.attribute;
25
+ const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect, {fill: fill = rectAttribute.fill, stroke: stroke = rectAttribute.stroke, x1: x1, y1: y1, x: originX, y: originY, opacity: opacity = rectAttribute.opacity, fillOpacity: fillOpacity = rectAttribute.fillOpacity, lineWidth: lineWidth = rectAttribute.lineWidth, strokeOpacity: strokeOpacity = rectAttribute.strokeOpacity, visible: visible = rectAttribute.visible} = rect.attribute;
26
26
  let {width: width, height: height} = rect.attribute;
27
27
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
28
28
  const z = null !== (_a = this.z) && void 0 !== _a ? _a : 0, fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill), sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height), doFill = runFill(fill), doStroke = runStroke(stroke, lineWidth);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/rect3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAelD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAmB;IAA3D;;QACL,SAAI,GAAG,QAAQ,CAAC;QAChB,eAAU,GAAW,kBAAkB,CAAC;IA4L1C,CAAC;IAzLC,SAAS,CACP,IAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EAC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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACjC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACjC,OAAO,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;aAC7B;iBAAM;gBACL,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,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,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AA9LY,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CA8LrC;SA9LY,yBAAyB","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 { mat4Allocate } from '../../../allocator/matrix-allocate';\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).rect3d;\n const {\n fill = rectAttribute.fill,\n stroke = rectAttribute.stroke,\n x1,\n y1,\n x: originX,\n y: originY,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible\n } = rect.attribute;\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n const z = this.z ?? 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb)) {\n return;\n }\n\n const { light, camera } = drawContext.stage || {};\n const face3d = rect.findFace();\n\n if (fill !== false) {\n context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);\n let fc = fill;\n if (typeof fc !== 'string') {\n fc = 'black';\n }\n this.fill(x, y, z, face3d, fc, context, light, fillCb);\n }\n if (stroke !== false) {\n context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);\n this.stroke(x, y, z, face3d, context);\n }\n }\n\n stroke(x: number, y: number, z: number, face3d: IFace3d, context: IContext2d) {\n const vertices = face3d.vertices;\n face3d.edges.forEach(edge => {\n const p1 = vertices[edge[0]];\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const p2 = vertices[edge[1]];\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.stroke();\n });\n }\n fill(\n x: number,\n y: number,\n z: number,\n face3d: IFace3d,\n fillColor: string,\n context: IContext2d,\n light: IDirectionLight,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const rgbArray = ColorStore.Get(fillColor as string, ColorType.Color255);\n // 上下左右前后\n // 0,1,2,3,4,5\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2])[2];\n });\n // 排序\n const sortFace: { faceIdx: number; polygon: IPolygonItem }[] = [];\n face3d.polygons.forEach((p, i) => {\n sortFace.push({\n faceIdx: i,\n polygon: p\n });\n // 设置ave_z进行排序\n const { polygon, normal } = p;\n\n const z1 = viewdVerticesZ[polygon[0]];\n const z2 = viewdVerticesZ[polygon[1]];\n const z3 = viewdVerticesZ[polygon[2]];\n const z4 = viewdVerticesZ[polygon[3]];\n\n p.ave_z = z1 + z2 + z3 + z4;\n });\n sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);\n\n sortFace.forEach(item => {\n const { polygon, normal } = item.polygon;\n\n const p1 = vertices[polygon[0]];\n const p2 = vertices[polygon[1]];\n const p3 = vertices[polygon[2]];\n const p4 = vertices[polygon[3]];\n\n const v1 = {\n x: x + p1[0],\n y: y + p1[1],\n z: z + p1[2]\n };\n const v2 = {\n x: x + p2[0],\n y: y + p2[1],\n z: z + p2[2]\n };\n const v3 = {\n x: x + p3[0],\n y: y + p3[1],\n z: z + p3[2]\n };\n const v4 = {\n x: x + p4[0],\n y: y + p4[1],\n z: z + p4[2]\n };\n context.beginPath();\n context.moveTo(v1.x, v1.y, v1.z);\n context.lineTo(v2.x, v2.y, v2.z);\n context.lineTo(v3.x, v3.y, v3.z);\n context.lineTo(v4.x, v4.y, v4.z);\n context.closePath();\n if (fillCb) {\n fillCb(context, null, null);\n } else {\n context.fillStyle = light ? light.computeColor(normal, rgbArray as any) : fillColor;\n context.fill();\n }\n });\n }\n\n draw(rect: IRect3d, renderService: IRenderService, drawContext: IDrawContext) {\n const rectAttribute = getTheme(rect).rect;\n this._draw(rect, rectAttribute, false, drawContext);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/rect3d-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAelD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAmB;IAA3D;;QACL,SAAI,GAAG,QAAQ,CAAC;QAChB,eAAU,GAAW,kBAAkB,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,QAAQ,CAAC,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AC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACjC,OAAO,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;aAC7B;iBAAM;gBACL,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,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,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AA9LY,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CA8LrC;SA9LY,yBAAyB","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"]}
@@ -32,7 +32,7 @@ export function rectStrokeVisible(opacity, strokeOpacity, width, height) {
32
32
 
33
33
  export function drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
34
34
  if (!graphic.pathProxy) return !1;
35
- const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type], {fill: fill = themeAttributes.fill, stroke: stroke = themeAttributes.stroke, opacity: opacity = themeAttributes.opacity, fillOpacity: fillOpacity = themeAttributes.fillOpacity, lineWidth: lineWidth = themeAttributes.lineWidth, strokeOpacity: strokeOpacity = themeAttributes.strokeOpacity, visible: visible = themeAttributes.visible, x: originX = themeAttributes.x, y: originY = themeAttributes.y} = graphic.attribute, fVisible = fillVisible(opacity, fillOpacity, fill), sVisible = strokeVisible(opacity, strokeOpacity), doFill = runFill(fill), doStroke = runStroke(stroke, lineWidth);
35
+ const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")], {fill: fill = themeAttributes.fill, stroke: stroke = themeAttributes.stroke, opacity: opacity = themeAttributes.opacity, fillOpacity: fillOpacity = themeAttributes.fillOpacity, lineWidth: lineWidth = themeAttributes.lineWidth, strokeOpacity: strokeOpacity = themeAttributes.strokeOpacity, visible: visible = themeAttributes.visible, x: originX = themeAttributes.x, y: originY = themeAttributes.y} = graphic.attribute, fVisible = fillVisible(opacity, fillOpacity, fill), sVisible = strokeVisible(opacity, strokeOpacity), doFill = runFill(fill), doStroke = runStroke(stroke, lineWidth);
36
36
  if (!visible) return !0;
37
37
  if (!doFill && !doStroke) return !0;
38
38
  if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;