@mlightcad/cad-simple-viewer 1.5.5 → 1.5.6

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 (275) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -0
  3. package/dist/{index.js → cad-simple-viewer.js} +16583 -14248
  4. package/dist/cad-simple-viewer.umd.cjs +921 -0
  5. package/dist/dxf-parser-worker.js +2002 -0
  6. package/dist/libredwg-parser-worker.js +5388 -5122
  7. package/dist/mtext-renderer-worker.js +3061 -2858
  8. package/lib/app/AcApContext.d.ts.map +1 -1
  9. package/lib/app/AcApContext.js +3 -0
  10. package/lib/app/AcApContext.js.map +1 -1
  11. package/lib/app/AcApDocManager.d.ts +7 -0
  12. package/lib/app/AcApDocManager.d.ts.map +1 -1
  13. package/lib/app/AcApDocManager.js +84 -10
  14. package/lib/app/AcApDocManager.js.map +1 -1
  15. package/lib/app/AcDbOpenDatabaseOptions.d.ts +29 -0
  16. package/lib/app/AcDbOpenDatabaseOptions.d.ts.map +1 -1
  17. package/lib/app/AcDbOpenDatabaseOptions.js +10 -1
  18. package/lib/app/AcDbOpenDatabaseOptions.js.map +1 -1
  19. package/lib/app/index.d.ts +1 -0
  20. package/lib/app/index.d.ts.map +1 -1
  21. package/lib/app/index.js +1 -0
  22. package/lib/app/index.js.map +1 -1
  23. package/lib/command/AcApCacheFontCmd.d.ts +25 -0
  24. package/lib/command/AcApCacheFontCmd.d.ts.map +1 -0
  25. package/lib/command/AcApCacheFontCmd.js +142 -0
  26. package/lib/command/AcApCacheFontCmd.js.map +1 -0
  27. package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
  28. package/lib/command/AcApSysVarCmd.js +5 -11
  29. package/lib/command/AcApSysVarCmd.js.map +1 -1
  30. package/lib/command/convert/AcApPngConvertor.d.ts +1 -1
  31. package/lib/command/convert/AcApPngConvertor.d.ts.map +1 -1
  32. package/lib/command/convert/AcApPngConvertor.js +5 -2
  33. package/lib/command/convert/AcApPngConvertor.js.map +1 -1
  34. package/lib/command/draw/AcApArcCmd.d.ts.map +1 -1
  35. package/lib/command/draw/AcApArcCmd.js +2 -5
  36. package/lib/command/draw/AcApArcCmd.js.map +1 -1
  37. package/lib/command/draw/AcApEllipseCmd.d.ts.map +1 -1
  38. package/lib/command/draw/AcApEllipseCmd.js +2 -5
  39. package/lib/command/draw/AcApEllipseCmd.js.map +1 -1
  40. package/lib/command/draw/AcApHatchCmd.d.ts +1 -1
  41. package/lib/command/draw/AcApMLineCmd.d.ts.map +1 -1
  42. package/lib/command/draw/AcApMLineCmd.js +2 -2
  43. package/lib/command/draw/AcApMLineCmd.js.map +1 -1
  44. package/lib/command/draw/AcApPolygonCmd.d.ts.map +1 -1
  45. package/lib/command/draw/AcApPolygonCmd.js +2 -5
  46. package/lib/command/draw/AcApPolygonCmd.js.map +1 -1
  47. package/lib/command/draw/AcApRectCmd.d.ts +6 -0
  48. package/lib/command/draw/AcApRectCmd.d.ts.map +1 -1
  49. package/lib/command/draw/AcApRectCmd.js +12 -10
  50. package/lib/command/draw/AcApRectCmd.js.map +1 -1
  51. package/lib/command/draw/AcApXLineCmd.d.ts.map +1 -1
  52. package/lib/command/draw/AcApXLineCmd.js +1 -1
  53. package/lib/command/draw/AcApXLineCmd.js.map +1 -1
  54. package/lib/command/index.d.ts +1 -0
  55. package/lib/command/index.d.ts.map +1 -1
  56. package/lib/command/index.js +1 -0
  57. package/lib/command/index.js.map +1 -1
  58. package/lib/command/layer/AcApLayerCmd.d.ts +0 -7
  59. package/lib/command/layer/AcApLayerCmd.d.ts.map +1 -1
  60. package/lib/command/layer/AcApLayerCmd.js +13 -23
  61. package/lib/command/layer/AcApLayerCmd.js.map +1 -1
  62. package/lib/command/layer/AcApLayerCurCmd.d.ts +0 -7
  63. package/lib/command/layer/AcApLayerCurCmd.d.ts.map +1 -1
  64. package/lib/command/layer/AcApLayerCurCmd.js +3 -13
  65. package/lib/command/layer/AcApLayerCurCmd.js.map +1 -1
  66. package/lib/command/layer/AcApLayerDelCmd.d.ts +0 -7
  67. package/lib/command/layer/AcApLayerDelCmd.d.ts.map +1 -1
  68. package/lib/command/layer/AcApLayerDelCmd.js +8 -18
  69. package/lib/command/layer/AcApLayerDelCmd.js.map +1 -1
  70. package/lib/command/layer/AcApLayerFreezeCmd.d.ts +0 -7
  71. package/lib/command/layer/AcApLayerFreezeCmd.d.ts.map +1 -1
  72. package/lib/command/layer/AcApLayerFreezeCmd.js +11 -21
  73. package/lib/command/layer/AcApLayerFreezeCmd.js.map +1 -1
  74. package/lib/command/layer/AcApLayerIsoCmd.d.ts +0 -7
  75. package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
  76. package/lib/command/layer/AcApLayerIsoCmd.js +7 -17
  77. package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
  78. package/lib/command/layer/AcApLayerLockCmd.d.ts +0 -7
  79. package/lib/command/layer/AcApLayerLockCmd.d.ts.map +1 -1
  80. package/lib/command/layer/AcApLayerLockCmd.js +4 -14
  81. package/lib/command/layer/AcApLayerLockCmd.js.map +1 -1
  82. package/lib/command/layer/AcApLayerOffCmd.d.ts +0 -7
  83. package/lib/command/layer/AcApLayerOffCmd.d.ts.map +1 -1
  84. package/lib/command/layer/AcApLayerOffCmd.js +11 -21
  85. package/lib/command/layer/AcApLayerOffCmd.js.map +1 -1
  86. package/lib/command/layer/AcApLayerOnCmd.d.ts +0 -7
  87. package/lib/command/layer/AcApLayerOnCmd.d.ts.map +1 -1
  88. package/lib/command/layer/AcApLayerOnCmd.js +2 -13
  89. package/lib/command/layer/AcApLayerOnCmd.js.map +1 -1
  90. package/lib/command/layer/AcApLayerPCmd.d.ts +0 -7
  91. package/lib/command/layer/AcApLayerPCmd.d.ts.map +1 -1
  92. package/lib/command/layer/AcApLayerPCmd.js +2 -13
  93. package/lib/command/layer/AcApLayerPCmd.js.map +1 -1
  94. package/lib/command/layer/AcApLayerThawCmd.d.ts +0 -7
  95. package/lib/command/layer/AcApLayerThawCmd.d.ts.map +1 -1
  96. package/lib/command/layer/AcApLayerThawCmd.js +2 -13
  97. package/lib/command/layer/AcApLayerThawCmd.js.map +1 -1
  98. package/lib/command/layer/AcApLayerUnisoCmd.d.ts +0 -7
  99. package/lib/command/layer/AcApLayerUnisoCmd.d.ts.map +1 -1
  100. package/lib/command/layer/AcApLayerUnisoCmd.js +4 -15
  101. package/lib/command/layer/AcApLayerUnisoCmd.js.map +1 -1
  102. package/lib/command/layer/AcApLayerUnlockCmd.d.ts +0 -7
  103. package/lib/command/layer/AcApLayerUnlockCmd.d.ts.map +1 -1
  104. package/lib/command/layer/AcApLayerUnlockCmd.js +4 -14
  105. package/lib/command/layer/AcApLayerUnlockCmd.js.map +1 -1
  106. package/lib/command/modify/AcApHideObjectsCmd.js +1 -1
  107. package/lib/command/modify/AcApHideObjectsCmd.js.map +1 -1
  108. package/lib/command/modify/AcApOffsetCmd.d.ts.map +1 -1
  109. package/lib/command/modify/AcApOffsetCmd.js +9 -4
  110. package/lib/command/modify/AcApOffsetCmd.js.map +1 -1
  111. package/lib/command/modify/AcApRotateCmd.d.ts.map +1 -1
  112. package/lib/command/modify/AcApRotateCmd.js +2 -5
  113. package/lib/command/modify/AcApRotateCmd.js.map +1 -1
  114. package/lib/command/modify/AcApUnisolateObjectsCmd.d.ts.map +1 -1
  115. package/lib/command/modify/AcApUnisolateObjectsCmd.js +3 -3
  116. package/lib/command/modify/AcApUnisolateObjectsCmd.js.map +1 -1
  117. package/lib/editor/command/AcEdCommand.d.ts +16 -0
  118. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  119. package/lib/editor/command/AcEdCommand.js +23 -0
  120. package/lib/editor/command/AcEdCommand.js.map +1 -1
  121. package/lib/editor/global/AcEdUiColor.d.ts +13 -13
  122. package/lib/editor/global/AcEdUiColor.d.ts.map +1 -1
  123. package/lib/editor/global/AcEdUiColor.js +21 -20
  124. package/lib/editor/global/AcEdUiColor.js.map +1 -1
  125. package/lib/editor/global/eventBus.d.ts +7 -1
  126. package/lib/editor/global/eventBus.d.ts.map +1 -1
  127. package/lib/editor/global/eventBus.js.map +1 -1
  128. package/lib/editor/grip/AcEdGripEditSession.d.ts +29 -0
  129. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -0
  130. package/lib/editor/grip/AcEdGripEditSession.js +76 -0
  131. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -0
  132. package/lib/editor/grip/AcEdGripHandle.d.ts +20 -0
  133. package/lib/editor/grip/AcEdGripHandle.d.ts.map +1 -0
  134. package/lib/editor/grip/AcEdGripHandle.js +59 -0
  135. package/lib/editor/grip/AcEdGripHandle.js.map +1 -0
  136. package/lib/editor/grip/AcEdGripManager.d.ts +159 -0
  137. package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -0
  138. package/lib/editor/grip/AcEdGripManager.js +336 -0
  139. package/lib/editor/grip/AcEdGripManager.js.map +1 -0
  140. package/lib/editor/grip/AcEdGripPolicy.d.ts +6 -0
  141. package/lib/editor/grip/AcEdGripPolicy.d.ts.map +1 -0
  142. package/lib/editor/grip/AcEdGripPolicy.js +30 -0
  143. package/lib/editor/grip/AcEdGripPolicy.js.map +1 -0
  144. package/lib/editor/grip/AcEdGripPreviewJig.d.ts +21 -0
  145. package/lib/editor/grip/AcEdGripPreviewJig.d.ts.map +1 -0
  146. package/lib/editor/grip/AcEdGripPreviewJig.js +73 -0
  147. package/lib/editor/grip/AcEdGripPreviewJig.js.map +1 -0
  148. package/lib/editor/grip/index.d.ts +5 -0
  149. package/lib/editor/grip/index.d.ts.map +1 -0
  150. package/lib/editor/grip/index.js +5 -0
  151. package/lib/editor/grip/index.js.map +1 -0
  152. package/lib/editor/index.d.ts +1 -0
  153. package/lib/editor/index.d.ts.map +1 -1
  154. package/lib/editor/index.js +1 -0
  155. package/lib/editor/index.js.map +1 -1
  156. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
  157. package/lib/editor/input/AcEdCursorManager.js +2 -2
  158. package/lib/editor/input/AcEdCursorManager.js.map +1 -1
  159. package/lib/editor/input/AcEdOsnapResolver.d.ts +34 -0
  160. package/lib/editor/input/AcEdOsnapResolver.d.ts.map +1 -0
  161. package/lib/editor/input/AcEdOsnapResolver.js +117 -0
  162. package/lib/editor/input/AcEdOsnapResolver.js.map +1 -0
  163. package/lib/editor/input/handler/AcEdAngleHandler.d.ts +2 -1
  164. package/lib/editor/input/handler/AcEdAngleHandler.d.ts.map +1 -1
  165. package/lib/editor/input/handler/AcEdAngleHandler.js +6 -0
  166. package/lib/editor/input/handler/AcEdAngleHandler.js.map +1 -1
  167. package/lib/editor/input/handler/AcEdInputHandler.d.ts +20 -1
  168. package/lib/editor/input/handler/AcEdInputHandler.d.ts.map +1 -1
  169. package/lib/editor/input/handler/AcEdKeywordHandler.d.ts +2 -1
  170. package/lib/editor/input/handler/AcEdKeywordHandler.d.ts.map +1 -1
  171. package/lib/editor/input/handler/AcEdKeywordHandler.js +3 -0
  172. package/lib/editor/input/handler/AcEdKeywordHandler.js.map +1 -1
  173. package/lib/editor/input/handler/AcEdNumericalHandler.d.ts +2 -1
  174. package/lib/editor/input/handler/AcEdNumericalHandler.d.ts.map +1 -1
  175. package/lib/editor/input/handler/AcEdNumericalHandler.js +6 -0
  176. package/lib/editor/input/handler/AcEdNumericalHandler.js.map +1 -1
  177. package/lib/editor/input/handler/AcEdPointHandler.d.ts +17 -1
  178. package/lib/editor/input/handler/AcEdPointHandler.d.ts.map +1 -1
  179. package/lib/editor/input/handler/AcEdPointHandler.js +89 -0
  180. package/lib/editor/input/handler/AcEdPointHandler.js.map +1 -1
  181. package/lib/editor/input/handler/AcEdStringHandler.d.ts +2 -1
  182. package/lib/editor/input/handler/AcEdStringHandler.d.ts.map +1 -1
  183. package/lib/editor/input/handler/AcEdStringHandler.js +3 -0
  184. package/lib/editor/input/handler/AcEdStringHandler.js.map +1 -1
  185. package/lib/editor/input/index.d.ts +1 -0
  186. package/lib/editor/input/index.d.ts.map +1 -1
  187. package/lib/editor/input/index.js +1 -0
  188. package/lib/editor/input/index.js.map +1 -1
  189. package/lib/editor/input/session/AcEdInputSession.d.ts +11 -1
  190. package/lib/editor/input/session/AcEdInputSession.d.ts.map +1 -1
  191. package/lib/editor/input/session/AcEdInputSession.js.map +1 -1
  192. package/lib/editor/input/session/AcEdPromptInputSession.d.ts +51 -0
  193. package/lib/editor/input/session/AcEdPromptInputSession.d.ts.map +1 -0
  194. package/lib/editor/input/session/AcEdPromptInputSession.js +109 -0
  195. package/lib/editor/input/session/AcEdPromptInputSession.js.map +1 -0
  196. package/lib/editor/input/session/index.d.ts +1 -0
  197. package/lib/editor/input/session/index.d.ts.map +1 -1
  198. package/lib/editor/input/session/index.js +1 -0
  199. package/lib/editor/input/session/index.js.map +1 -1
  200. package/lib/editor/input/ui/AcEdCommandLine.d.ts +10 -0
  201. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  202. package/lib/editor/input/ui/AcEdCommandLine.js +67 -35
  203. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  204. package/lib/editor/input/ui/AcEdFloatingInput.d.ts +0 -11
  205. package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
  206. package/lib/editor/input/ui/AcEdFloatingInput.js +9 -119
  207. package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
  208. package/lib/editor/input/ui/AcEdInputManager.d.ts +26 -23
  209. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  210. package/lib/editor/input/ui/AcEdInputManager.js +135 -83
  211. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  212. package/lib/editor/input/ui/AcEdMTextEditor.js +2 -2
  213. package/lib/editor/input/ui/AcEdMTextEditor.js.map +1 -1
  214. package/lib/editor/view/AcEdBaseView.d.ts +7 -0
  215. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  216. package/lib/editor/view/AcEdBaseView.js +12 -0
  217. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  218. package/lib/i18n/en/command.d.ts +3 -0
  219. package/lib/i18n/en/command.d.ts.map +1 -1
  220. package/lib/i18n/en/command.js +3 -0
  221. package/lib/i18n/en/command.js.map +1 -1
  222. package/lib/i18n/en/jig.d.ts +26 -0
  223. package/lib/i18n/en/jig.d.ts.map +1 -1
  224. package/lib/i18n/en/jig.js +134 -108
  225. package/lib/i18n/en/jig.js.map +1 -1
  226. package/lib/i18n/en/main.d.ts +3 -0
  227. package/lib/i18n/en/main.d.ts.map +1 -1
  228. package/lib/i18n/en/main.js +4 -1
  229. package/lib/i18n/en/main.js.map +1 -1
  230. package/lib/i18n/zh/command.d.ts +3 -0
  231. package/lib/i18n/zh/command.d.ts.map +1 -1
  232. package/lib/i18n/zh/command.js +3 -0
  233. package/lib/i18n/zh/command.js.map +1 -1
  234. package/lib/i18n/zh/jig.d.ts +26 -0
  235. package/lib/i18n/zh/jig.d.ts.map +1 -1
  236. package/lib/i18n/zh/jig.js +134 -108
  237. package/lib/i18n/zh/jig.js.map +1 -1
  238. package/lib/i18n/zh/main.d.ts +3 -0
  239. package/lib/i18n/zh/main.d.ts.map +1 -1
  240. package/lib/i18n/zh/main.js +4 -1
  241. package/lib/i18n/zh/main.js.map +1 -1
  242. package/lib/plugin/AcApLazyPluginRegistration.d.ts +3 -8
  243. package/lib/plugin/AcApLazyPluginRegistration.d.ts.map +1 -1
  244. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +1 -1
  245. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +2 -2
  246. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
  247. package/lib/util/AcApFontUtil.d.ts +14 -2
  248. package/lib/util/AcApFontUtil.d.ts.map +1 -1
  249. package/lib/util/AcApFontUtil.js +18 -0
  250. package/lib/util/AcApFontUtil.js.map +1 -1
  251. package/lib/view/AcTrEntityDisplayController.d.ts +46 -0
  252. package/lib/view/AcTrEntityDisplayController.d.ts.map +1 -0
  253. package/lib/view/AcTrEntityDisplayController.js +114 -0
  254. package/lib/view/AcTrEntityDisplayController.js.map +1 -0
  255. package/lib/view/AcTrGroupWcsBboxAssert.d.ts +27 -0
  256. package/lib/view/AcTrGroupWcsBboxAssert.d.ts.map +1 -0
  257. package/lib/view/AcTrGroupWcsBboxAssert.js +65 -0
  258. package/lib/view/AcTrGroupWcsBboxAssert.js.map +1 -0
  259. package/lib/view/AcTrLayer.d.ts +7 -0
  260. package/lib/view/AcTrLayer.d.ts.map +1 -1
  261. package/lib/view/AcTrLayer.js +11 -2
  262. package/lib/view/AcTrLayer.js.map +1 -1
  263. package/lib/view/AcTrLayout.d.ts +1 -1
  264. package/lib/view/AcTrLayout.js +2 -2
  265. package/lib/view/AcTrLayout.js.map +1 -1
  266. package/lib/view/AcTrProgressiveOpenFitController.d.ts +64 -0
  267. package/lib/view/AcTrProgressiveOpenFitController.d.ts.map +1 -0
  268. package/lib/view/AcTrProgressiveOpenFitController.js +209 -0
  269. package/lib/view/AcTrProgressiveOpenFitController.js.map +1 -0
  270. package/lib/view/AcTrView2d.d.ts +95 -1
  271. package/lib/view/AcTrView2d.d.ts.map +1 -1
  272. package/lib/view/AcTrView2d.js +539 -200
  273. package/lib/view/AcTrView2d.js.map +1 -1
  274. package/package.json +13 -11
  275. package/dist/index.umd.cjs +0 -897
@@ -71,6 +71,31 @@ var __values = (this && this.__values) || function(o) {
71
71
  };
72
72
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
73
73
  };
74
+ var __read = (this && this.__read) || function (o, n) {
75
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
76
+ if (!m) return o;
77
+ var i = m.call(o), r, ar = [], e;
78
+ try {
79
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
80
+ }
81
+ catch (error) { e = { error: error }; }
82
+ finally {
83
+ try {
84
+ if (r && !r.done && (m = i["return"])) m.call(i);
85
+ }
86
+ finally { if (e) throw e.error; }
87
+ }
88
+ return ar;
89
+ };
90
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
91
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
92
+ if (ar || !(i in from)) {
93
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
94
+ ar[i] = from[i];
95
+ }
96
+ }
97
+ return to.concat(ar || Array.prototype.slice.call(from));
98
+ };
74
99
  import { acdbHostApplicationServices, AcDbMText, AcDbRasterImage, AcDbRay, AcDbSysVarManager, AcDbViewport, AcDbXline, AcGeBox2d, AcGePoint2d, log } from '@mlightcad/data-model';
75
100
  import { AcDbSystemVariables } from '@mlightcad/data-model';
76
101
  import { AcTrEntity, AcTrGroup, AcTrRenderer, AcTrViewportView, getMaterialMetadata, hasByLayerBinding, setMaterialMetadata } from '@mlightcad/three-renderer';
@@ -78,18 +103,22 @@ import * as THREE from 'three';
78
103
  import Stats from 'three/examples/jsm/libs/stats.module';
79
104
  import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
80
105
  import { AcApDocManager, AcApSettingManager } from '../app';
81
- import { AcEdBaseView, AcEdConditionWaiter, AcEdCorsorType, AcEdMTextEditor, AcEdOpenMode, AcEdViewMode, eventBus, resolvePointerSelectionAction } from '../editor';
82
- import { isModelSpaceDatabase, MODEL_SPACE_BACKGROUND, readLayoutBackgroundColor } from '../editor/global/AcEdUiColor';
106
+ import { AcEdBaseView, AcEdConditionWaiter, AcEdCorsorType, AcEdGripManager, AcEdMTextEditor, AcEdOpenMode, AcEdViewMode, eventBus, resolvePointerSelectionAction } from '../editor';
107
+ import { ACGI_MODEL_SPACE_BACKGROUND, isModelSpaceDatabase, readLayoutBackgroundColor } from '../editor/global/AcEdUiColor';
83
108
  import { AcTrGeometryUtil } from '../util';
109
+ import { AcTrEntityDisplayController } from './AcTrEntityDisplayController';
110
+ import { assertAcTrGroupWcsBboxesConsistent } from './AcTrGroupWcsBboxAssert';
111
+ import { AcTrLayer } from './AcTrLayer';
84
112
  import { AcTrLayoutView } from './AcTrLayoutView';
85
113
  import { AcTrLayoutViewManager } from './AcTrLayoutViewManager';
86
114
  import { sortPickResults } from './AcTrPickResultUtil';
115
+ import { AcTrProgressiveOpenFitController } from './AcTrProgressiveOpenFitController';
87
116
  import { AcTrScene } from './AcTrScene';
88
117
  /**
89
118
  * Default view option values
90
119
  */
91
120
  export var DEFAULT_VIEW_2D_OPTIONS = {
92
- background: MODEL_SPACE_BACKGROUND
121
+ background: ACGI_MODEL_SPACE_BACKGROUND
93
122
  };
94
123
  /**
95
124
  * A 2D CAD viewer component that renders CAD drawings using Three.js.
@@ -185,6 +214,21 @@ var AcTrView2d = /** @class */ (function (_super) {
185
214
  * race during document open.
186
215
  */
187
216
  _this._externallyFramedLayouts = new Set();
217
+ /**
218
+ * Layer names with an in-flight {@link convertMissingEntitiesOnLayer} pass.
219
+ *
220
+ * {@link updateLayer} triggers that conversion fire-and-forget when a layer
221
+ * becomes visible again. Rapid or repeated layer-on events for the same name
222
+ * would otherwise start parallel {@link batchConvert} runs over the same
223
+ * pending entities. `hasEntity` prevents duplicate scene entries, but not the
224
+ * wasted conversion work — this set skips re-entry until the current pass ends.
225
+ */
226
+ _this._convertingLayers = new Set();
227
+ /**
228
+ * When true, entity conversion during document open is deferred across
229
+ * event-loop turns so geometry appears incrementally.
230
+ */
231
+ _this._progressiveRendering = false;
188
232
  _this.animate = function () {
189
233
  var _a;
190
234
  _this._rafId = requestAnimationFrame(_this.animate);
@@ -193,15 +237,19 @@ var AcTrView2d = /** @class */ (function (_super) {
193
237
  camera: _this.internalCamera
194
238
  });
195
239
  var stillLoading = _this._numOfEntitiesToProcess > 0;
240
+ var deferRenderWhileLoading = stillLoading && !_this._progressiveRendering;
196
241
  if (!_this._isDirty && !stillLoading)
197
242
  return;
243
+ if (deferRenderWhileLoading)
244
+ return;
198
245
  var needsRedraw = _this._layoutViewManager.render(_this._scene);
199
246
  if (_this.internalCamera) {
200
247
  _this._css2dRenderer.render(_this._scene.internalScene, _this.internalCamera);
201
248
  }
202
249
  (_a = _this._stats) === null || _a === void 0 ? void 0 : _a.update();
203
- _this._isDirty = stillLoading || needsRedraw;
250
+ _this._isDirty = (_this._progressiveRendering && stillLoading) || needsRedraw;
204
251
  };
252
+ _this._gripManager = new AcEdGripManager(_this);
205
253
  if (options.calculateSizeCallback) {
206
254
  _this.setCalculateSizeCallback(options.calculateSizeCallback);
207
255
  }
@@ -219,7 +267,7 @@ var AcTrView2d = /** @class */ (function (_super) {
219
267
  });
220
268
  _this._scene = _this.createScene();
221
269
  // Initialize background color through setter to keep renderer/cursor in sync.
222
- _this.backgroundColor = (_b = mergedOptions.background) !== null && _b !== void 0 ? _b : MODEL_SPACE_BACKGROUND;
270
+ _this.backgroundColor = (_b = mergedOptions.background) !== null && _b !== void 0 ? _b : ACGI_MODEL_SPACE_BACKGROUND;
223
271
  _this._stats = _this.createStats(AcApSettingManager.instance.isShowStats);
224
272
  // Layout background sysvars drive the canvas clear colour and ACI-7
225
273
  // inversion (`MODELBKCOLOR` for model space, `PAPERBKCOLOR` for the
@@ -251,7 +299,8 @@ var AcTrView2d = /** @class */ (function (_super) {
251
299
  var canHandleSelectionGesture = function () {
252
300
  return (_this.mode === AcEdViewMode.SELECTION &&
253
301
  !_this.editor.isActive &&
254
- !AcEdMTextEditor.getActiveInputBox());
302
+ !AcEdMTextEditor.getActiveInputBox() &&
303
+ !_this._gripManager.isDragging);
255
304
  };
256
305
  var clearSelectionPreview = function () {
257
306
  selectionPreviewEl === null || selectionPreviewEl === void 0 ? void 0 : selectionPreviewEl.remove();
@@ -422,6 +471,13 @@ var AcTrView2d = /** @class */ (function (_super) {
422
471
  container.appendChild(_this._css2dRenderer.domElement);
423
472
  _this._missedImages = new Map();
424
473
  _this._layoutViewManager = new AcTrLayoutViewManager();
474
+ _this._progressiveOpenFit = new AcTrProgressiveOpenFitController(function (box, margin) {
475
+ _this.activeLayoutView.zoomTo(box, margin !== null && margin !== void 0 ? margin : 1.1);
476
+ _this._isDirty = true;
477
+ });
478
+ _this._entityDisplay = new AcTrEntityDisplayController(function (layerName) {
479
+ return _this.resolveLayerInfo(layerName);
480
+ });
425
481
  _this.initialize();
426
482
  _this.onWindowResize();
427
483
  _this._isDirty = true;
@@ -479,6 +535,14 @@ var AcTrView2d = /** @class */ (function (_super) {
479
535
  enumerable: false,
480
536
  configurable: true
481
537
  });
538
+ Object.defineProperty(AcTrView2d.prototype, "gripManager", {
539
+ /** Grip point manager for the view (Write mode only). */
540
+ get: function () {
541
+ return this._gripManager;
542
+ },
543
+ enumerable: false,
544
+ configurable: true
545
+ });
482
546
  Object.defineProperty(AcTrView2d.prototype, "isDirty", {
483
547
  /**
484
548
  * Gets whether the view needs to be re-rendered.
@@ -499,6 +563,46 @@ var AcTrView2d = /** @class */ (function (_super) {
499
563
  enumerable: false,
500
564
  configurable: true
501
565
  });
566
+ Object.defineProperty(AcTrView2d.prototype, "isProcessingEntities", {
567
+ /**
568
+ * True while {@link addEntity} batch-conversion callbacks are still running.
569
+ *
570
+ * Parsing can report 100% before this reaches zero; callers opening files
571
+ * should wait on this (as {@link zoomToFitDrawing} does) before hiding
572
+ * progress UI or assuming the canvas is ready.
573
+ */
574
+ get: function () {
575
+ return this._numOfEntitiesToProcess > 0;
576
+ },
577
+ enumerable: false,
578
+ configurable: true
579
+ });
580
+ Object.defineProperty(AcTrView2d.prototype, "progressiveRendering", {
581
+ /**
582
+ * Whether entity conversion during document open is deferred for progressive display.
583
+ */
584
+ get: function () {
585
+ return this._progressiveRendering;
586
+ },
587
+ set: function (value) {
588
+ this._progressiveRendering = value;
589
+ },
590
+ enumerable: false,
591
+ configurable: true
592
+ });
593
+ /**
594
+ * Enables progressive camera framing while entities are batch-converted at
595
+ * document open. Pair with {@link zoomToFitDrawing} for the final accurate fit.
596
+ */
597
+ AcTrView2d.prototype.beginProgressiveOpenFit = function () {
598
+ this._progressiveOpenFit.begin(this._numOfEntitiesToProcess);
599
+ };
600
+ /**
601
+ * Disables progressive open framing after the final zoom-to-fit runs.
602
+ */
603
+ AcTrView2d.prototype.endProgressiveOpenFit = function () {
604
+ this._progressiveOpenFit.end();
605
+ };
502
606
  Object.defineProperty(AcTrView2d.prototype, "missedData", {
503
607
  /**
504
608
  * Gets information about missing data during rendering (fonts and images).
@@ -552,8 +656,9 @@ var AcTrView2d = /** @class */ (function (_super) {
552
656
  */
553
657
  AcTrView2d.prototype.applyCanvasBackground = function (value) {
554
658
  this._renderer.setClearColor(value);
659
+ // Updates style-manager background, repaints ACI-7 / bg-follow materials.
555
660
  this._renderer.currentBackgroundColor = value;
556
- this._renderer.changeBackground(value);
661
+ this.refreshTextMaterialsInObjectTree(this._scene.internalScene);
557
662
  this.editor.syncCursorBackground(value);
558
663
  this._isDirty = true;
559
664
  };
@@ -641,6 +746,55 @@ var AcTrView2d = /** @class */ (function (_super) {
641
746
  enumerable: false,
642
747
  configurable: true
643
748
  });
749
+ /**
750
+ * Converts every drawable entity into the scene before offline export.
751
+ *
752
+ * Interactive viewing skips off/frozen layers for performance; HTML snapshots
753
+ * store layer visibility separately and need full geometry so the exported
754
+ * layer panel can toggle layers on later.
755
+ *
756
+ * Converted geometry remains in the live scene after this call completes.
757
+ */
758
+ AcTrView2d.prototype.ensureEntitiesConvertedForExport = function (options) {
759
+ return __awaiter(this, void 0, void 0, function () {
760
+ var includeInvisibleLayers, db, pending, _a, _b, _c, layoutBtrId, blockTableRecord;
761
+ var e_1, _d;
762
+ var _this = this;
763
+ return __generator(this, function (_e) {
764
+ switch (_e.label) {
765
+ case 0:
766
+ includeInvisibleLayers = (options === null || options === void 0 ? void 0 : options.includeInvisibleLayers) !== false;
767
+ db = AcApDocManager.instance.curDocument.database;
768
+ pending = [];
769
+ try {
770
+ for (_a = __values(this._scene.layouts), _b = _a.next(); !_b.done; _b = _a.next()) {
771
+ _c = __read(_b.value, 1), layoutBtrId = _c[0];
772
+ blockTableRecord = db.tables.blockTable.getIdAt(layoutBtrId);
773
+ if (!blockTableRecord) {
774
+ continue;
775
+ }
776
+ pending.push.apply(pending, __spreadArray([], __read(this._entityDisplay.collectMissingEntitiesForExport(blockTableRecord, function (objectId) { return _this.hasEntity(objectId); }, includeInvisibleLayers)), false));
777
+ }
778
+ }
779
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
780
+ finally {
781
+ try {
782
+ if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
783
+ }
784
+ finally { if (e_1) throw e_1.error; }
785
+ }
786
+ if (pending.length === 0) {
787
+ return [2 /*return*/];
788
+ }
789
+ this._numOfEntitiesToProcess += pending.length;
790
+ return [4 /*yield*/, this.batchConvert(pending, { forExport: true })];
791
+ case 1:
792
+ _e.sent();
793
+ return [2 /*return*/];
794
+ }
795
+ });
796
+ });
797
+ };
644
798
  Object.defineProperty(AcTrView2d.prototype, "internalScene", {
645
799
  /**
646
800
  * The internal THREE scene used by this view.
@@ -736,15 +890,12 @@ var AcTrView2d = /** @class */ (function (_super) {
736
890
  var _this = this;
737
891
  if (timeout === void 0) { timeout = 0; }
738
892
  var waiter = new AcEdConditionWaiter(function () { return _this._numOfEntitiesToProcess <= 0; }, function () {
739
- if (layoutBtrId &&
740
- _this._externallyFramedLayouts.delete(layoutBtrId)) {
893
+ if (layoutBtrId && _this._externallyFramedLayouts.delete(layoutBtrId)) {
894
+ _this.endProgressiveOpenFit();
741
895
  return;
742
896
  }
743
- var box = _this.resolveLayoutFitBox();
744
- if (box) {
745
- _this.zoomTo(box);
746
- _this._isDirty = true;
747
- }
897
+ _this._progressiveOpenFit.applyFinalFit(function () { return _this.resolveLayoutFitBox(); });
898
+ _this.endProgressiveOpenFit();
748
899
  }, 300, // check every 300 ms
749
900
  timeout);
750
901
  waiter.start();
@@ -897,7 +1048,7 @@ var AcTrView2d = /** @class */ (function (_super) {
897
1048
  * don't have to land pixel-perfect on the viewport line to grab it.
898
1049
  */
899
1050
  AcTrView2d.prototype.pick = function (point, hitRadius, pickOneOnly) {
900
- var e_1, _a;
1051
+ var e_2, _a;
901
1052
  if (point == null)
902
1053
  point = this.curPos;
903
1054
  var results = [];
@@ -928,12 +1079,12 @@ var AcTrView2d = /** @class */ (function (_super) {
928
1079
  }
929
1080
  }
930
1081
  }
931
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1082
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
932
1083
  finally {
933
1084
  try {
934
1085
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
935
1086
  }
936
- finally { if (e_1) throw e_1.error; }
1087
+ finally { if (e_2) throw e_2.error; }
937
1088
  }
938
1089
  }
939
1090
  // 1) Resolve hits in the active layout. Skip the `AcDbViewport`
@@ -974,7 +1125,7 @@ var AcTrView2d = /** @class */ (function (_super) {
974
1125
  * paper-space pick.
975
1126
  */
976
1127
  AcTrView2d.prototype.pickThroughViewports = function (paperPoint, paperBox, viewports, results) {
977
- var e_2, _a;
1128
+ var e_3, _a;
978
1129
  var modelLayout = this._scene.modelSpaceLayout;
979
1130
  if (!modelLayout)
980
1131
  return;
@@ -1007,12 +1158,12 @@ var AcTrView2d = /** @class */ (function (_super) {
1007
1158
  _loop_1(vpView);
1008
1159
  }
1009
1160
  }
1010
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1161
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1011
1162
  finally {
1012
1163
  try {
1013
1164
  if (viewports_1_1 && !viewports_1_1.done && (_a = viewports_1.return)) _a.call(viewports_1);
1014
1165
  }
1015
- finally { if (e_2) throw e_2.error; }
1166
+ finally { if (e_3) throw e_3.error; }
1016
1167
  }
1017
1168
  };
1018
1169
  /**
@@ -1041,16 +1192,10 @@ var AcTrView2d = /** @class */ (function (_super) {
1041
1192
  * @inheritdoc
1042
1193
  */
1043
1194
  AcTrView2d.prototype.addLayer = function (layer) {
1044
- var updatedLayers = this._scene.addLayer({
1045
- name: layer.name,
1046
- isFrozen: layer.isFrozen,
1047
- isOff: layer.isOff,
1048
- color: layer.color
1049
- });
1195
+ var updatedLayers = this._scene.addLayer(this.toLayerInfo(layer));
1050
1196
  var traits = {
1051
1197
  layer: layer.name,
1052
1198
  color: layer.color.clone(),
1053
- rgbColor: layer.color.RGB,
1054
1199
  lineType: layer.lineStyle,
1055
1200
  lineWeight: layer.lineWeight,
1056
1201
  transparency: layer.transparency
@@ -1068,16 +1213,10 @@ var AcTrView2d = /** @class */ (function (_super) {
1068
1213
  * @inheritdoc
1069
1214
  */
1070
1215
  AcTrView2d.prototype.updateLayer = function (layer, changes) {
1071
- var updatedLayers = this._scene.updateLayer({
1072
- name: layer.name,
1073
- isFrozen: layer.isFrozen,
1074
- isOff: layer.isOff,
1075
- color: layer.color
1076
- });
1216
+ var updatedLayers = this._scene.updateLayer(this.toLayerInfo(layer));
1077
1217
  var traits = {};
1078
1218
  if (changes.color) {
1079
1219
  traits.color = changes.color.clone();
1080
- traits.rgbColor = changes.color.RGB;
1081
1220
  }
1082
1221
  if (changes.lineStyle) {
1083
1222
  traits.lineType = layer.lineStyle;
@@ -1096,6 +1235,10 @@ var AcTrView2d = /** @class */ (function (_super) {
1096
1235
  layer.updateMaterial(Number(id), material);
1097
1236
  }
1098
1237
  });
1238
+ if (this._entityDisplay.layerVisibilityMayHaveChanged(changes) &&
1239
+ AcTrLayer.isLayerVisible(this.toLayerInfo(layer))) {
1240
+ void this.convertMissingEntitiesOnLayer(layer.name);
1241
+ }
1099
1242
  this._isDirty = true;
1100
1243
  };
1101
1244
  /**
@@ -1129,7 +1272,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1129
1272
  var _this = this;
1130
1273
  var entities = Array.isArray(entity) ? entity : [entity];
1131
1274
  this._numOfEntitiesToProcess += entities.length;
1132
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
1275
+ var convert = function () { return __awaiter(_this, void 0, void 0, function () {
1133
1276
  return __generator(this, function (_a) {
1134
1277
  switch (_a.label) {
1135
1278
  case 0: return [4 /*yield*/, this.batchConvert(entities)];
@@ -1138,8 +1281,14 @@ var AcTrView2d = /** @class */ (function (_super) {
1138
1281
  return [2 /*return*/];
1139
1282
  }
1140
1283
  });
1141
- }); });
1142
- this._isDirty = true;
1284
+ }); };
1285
+ if (this._progressiveRendering) {
1286
+ setTimeout(convert);
1287
+ this._isDirty = true;
1288
+ }
1289
+ else {
1290
+ void convert();
1291
+ }
1143
1292
  };
1144
1293
  /**
1145
1294
  * @inheritdoc
@@ -1210,7 +1359,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1210
1359
  threeEntity.objectId = entity_2.objectId;
1211
1360
  threeEntity.ownerId = entity_2.ownerId;
1212
1361
  threeEntity.layerName = entity_2.layer;
1213
- threeEntity.visible = entity_2.visibility;
1362
+ threeEntity.visible = entity_2.visibility !== false;
1214
1363
  this._scene.updateEntity(threeEntity);
1215
1364
  }
1216
1365
  }
@@ -1408,6 +1557,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1408
1557
  if (layoutView == null) {
1409
1558
  layoutView = new AcTrLayoutView(this._renderer, layoutBtrId, this.width, this.height);
1410
1559
  layoutView.events.viewChanged.addEventListener(function () {
1560
+ _this._progressiveOpenFit.onLayoutViewChanged();
1411
1561
  _this._isDirty = true;
1412
1562
  _this.events.viewChanged.dispatch();
1413
1563
  _this.clearHover();
@@ -1438,7 +1588,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1438
1588
  * @param layoutBtrId Input the block table record id of the layout
1439
1589
  */
1440
1590
  AcTrView2d.prototype.loadLayoutEntitiesIfNeeded = function (layoutBtrId) {
1441
- var e_3, _a;
1591
+ var e_4, _a;
1442
1592
  var _this = this;
1443
1593
  try {
1444
1594
  var db = AcApDocManager.instance.curDocument.database;
@@ -1509,12 +1659,12 @@ var AcTrView2d = /** @class */ (function (_super) {
1509
1659
  entities_1.push(entity);
1510
1660
  }
1511
1661
  }
1512
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1662
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1513
1663
  finally {
1514
1664
  try {
1515
1665
  if (iterator_1_1 && !iterator_1_1.done && (_a = iterator_1.return)) _a.call(iterator_1);
1516
1666
  }
1517
- finally { if (e_3) throw e_3.error; }
1667
+ finally { if (e_4) throw e_4.error; }
1518
1668
  }
1519
1669
  if (entities_1.length === 0) {
1520
1670
  // Empty layout (e.g. a freshly-created paper space tab). Mark as
@@ -1525,10 +1675,10 @@ var AcTrView2d = /** @class */ (function (_super) {
1525
1675
  }
1526
1676
  return;
1527
1677
  }
1528
- // Load entities asynchronously
1678
+ // Load entities asynchronously when progressive rendering is enabled.
1529
1679
  this._loadingLayouts.add(layoutBtrId);
1530
1680
  this._numOfEntitiesToProcess += entities_1.length;
1531
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
1681
+ var convert = function () { return __awaiter(_this, void 0, void 0, function () {
1532
1682
  var layout;
1533
1683
  return __generator(this, function (_a) {
1534
1684
  switch (_a.label) {
@@ -1548,7 +1698,13 @@ var AcTrView2d = /** @class */ (function (_super) {
1548
1698
  case 3: return [2 /*return*/];
1549
1699
  }
1550
1700
  });
1551
- }); });
1701
+ }); };
1702
+ if (this._progressiveRendering) {
1703
+ setTimeout(convert);
1704
+ }
1705
+ else {
1706
+ void convert();
1707
+ }
1552
1708
  }
1553
1709
  catch (error) {
1554
1710
  log.error('[AcTrView2d] Error loading layout entities:', error);
@@ -1567,9 +1723,137 @@ var AcTrView2d = /** @class */ (function (_super) {
1567
1723
  stats.dom.style.display = 'none'; // Hide the stats
1568
1724
  }
1569
1725
  };
1726
+ AcTrView2d.prototype.toLayerInfo = function (layer) {
1727
+ return {
1728
+ name: layer.name,
1729
+ isFrozen: layer.isFrozen,
1730
+ isOff: layer.isOff,
1731
+ color: layer.color
1732
+ };
1733
+ };
1734
+ AcTrView2d.prototype.resolveLayerInfo = function (layerName) {
1735
+ var layer = AcApDocManager.instance.curDocument.database.tables.layerTable.getAt(layerName);
1736
+ return layer ? this.toLayerInfo(layer) : undefined;
1737
+ };
1738
+ /**
1739
+ * Converts entities on the given layer that were skipped while the layer was
1740
+ * off/frozen and therefore are not yet present in the scene.
1741
+ */
1742
+ AcTrView2d.prototype.convertMissingEntitiesOnLayer = function (layerName) {
1743
+ return __awaiter(this, void 0, void 0, function () {
1744
+ var db, blockTableRecord, pending_1;
1745
+ var _this = this;
1746
+ return __generator(this, function (_a) {
1747
+ switch (_a.label) {
1748
+ case 0:
1749
+ if (this._convertingLayers.has(layerName)) {
1750
+ return [2 /*return*/];
1751
+ }
1752
+ this._convertingLayers.add(layerName);
1753
+ _a.label = 1;
1754
+ case 1:
1755
+ _a.trys.push([1, , 3, 4]);
1756
+ db = AcApDocManager.instance.curDocument.database;
1757
+ blockTableRecord = db.tables.blockTable.getIdAt(this.activeLayoutBtrId);
1758
+ if (!blockTableRecord) {
1759
+ return [2 /*return*/];
1760
+ }
1761
+ pending_1 = this._entityDisplay.collectMissingEntitiesOnLayer(layerName, blockTableRecord, function (objectId) { return _this.hasEntity(objectId); });
1762
+ if (pending_1.length === 0) {
1763
+ return [2 /*return*/];
1764
+ }
1765
+ this._numOfEntitiesToProcess += pending_1.length;
1766
+ return [4 /*yield*/, this.batchConvert(pending_1)];
1767
+ case 2:
1768
+ _a.sent();
1769
+ return [3 /*break*/, 4];
1770
+ case 3:
1771
+ this._convertingLayers.delete(layerName);
1772
+ return [7 /*endfinally*/];
1773
+ case 4: return [2 /*return*/];
1774
+ }
1775
+ });
1776
+ });
1777
+ };
1570
1778
  AcTrView2d.prototype.drawEntity = function (entity, delay) {
1571
1779
  return entity.worldDraw(this._renderer, delay);
1572
1780
  };
1781
+ /**
1782
+ * Finishes geometry for a converted entity. Progressive mode defers MTEXT/SHAPE
1783
+ * to async workers; non-progressive mode uses synchronous drawing from
1784
+ * {@link drawEntity}(..., false).
1785
+ */
1786
+ AcTrView2d.prototype.finishEntityGeometry = function (threeEntity, progressive) {
1787
+ return __awaiter(this, void 0, void 0, function () {
1788
+ return __generator(this, function (_a) {
1789
+ switch (_a.label) {
1790
+ case 0:
1791
+ if (!progressive) return [3 /*break*/, 2];
1792
+ return [4 /*yield*/, threeEntity.draw()];
1793
+ case 1:
1794
+ _a.sent();
1795
+ return [2 /*return*/];
1796
+ case 2:
1797
+ if (this.entityUsedSyncDraw(threeEntity)) {
1798
+ return [2 /*return*/];
1799
+ }
1800
+ return [4 /*yield*/, threeEntity.draw()];
1801
+ case 3:
1802
+ _a.sent();
1803
+ return [2 /*return*/];
1804
+ }
1805
+ });
1806
+ });
1807
+ };
1808
+ /**
1809
+ * Returns true when an entity already produced drawable geometry via syncDraw.
1810
+ * MText/Shape expose syncDraw even when delay=true left the entity empty.
1811
+ */
1812
+ AcTrView2d.prototype.entityUsedSyncDraw = function (threeEntity) {
1813
+ return (typeof threeEntity.syncDraw ===
1814
+ 'function' && threeEntity.children.length > 0);
1815
+ };
1816
+ /**
1817
+ * Finishes deferred MText/Shape geometry inside a block group before it is
1818
+ * split by layer. Block-reference attributes are created during INSERT
1819
+ * worldDraw and can be left empty when progressive open passes delay=true.
1820
+ */
1821
+ AcTrView2d.prototype.ensureGroupDrawableGeometry = function (group) {
1822
+ return __awaiter(this, void 0, void 0, function () {
1823
+ var pending, finalizeDeferredEntity;
1824
+ var _this = this;
1825
+ return __generator(this, function (_a) {
1826
+ switch (_a.label) {
1827
+ case 0:
1828
+ pending = [];
1829
+ finalizeDeferredEntity = function (child) {
1830
+ if (_this.entityUsedSyncDraw(child)) {
1831
+ return;
1832
+ }
1833
+ var drawable = child;
1834
+ if (typeof drawable.syncDraw !== 'function') {
1835
+ return;
1836
+ }
1837
+ pending.push(Promise.resolve(drawable.syncDraw()));
1838
+ };
1839
+ group.getSourceEntities().forEach(finalizeDeferredEntity);
1840
+ group.traverse(function (child) {
1841
+ if (!(child instanceof AcTrEntity)) {
1842
+ return;
1843
+ }
1844
+ if (group.getSourceEntities().includes(child)) {
1845
+ return;
1846
+ }
1847
+ finalizeDeferredEntity(child);
1848
+ });
1849
+ return [4 /*yield*/, Promise.all(pending)];
1850
+ case 1:
1851
+ _a.sent();
1852
+ return [2 /*return*/];
1853
+ }
1854
+ });
1855
+ });
1856
+ };
1573
1857
  /**
1574
1858
  * Walks the given block table record once and creates one
1575
1859
  * `AcTrViewportView` for every real `AcDbViewport` entity it finds
@@ -1589,7 +1873,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1589
1873
  * paper layouts.
1590
1874
  */
1591
1875
  AcTrView2d.prototype.ensureViewportViews = function (blockTableRecord, layoutView) {
1592
- var e_4, _a;
1876
+ var e_5, _a;
1593
1877
  var iterator = blockTableRecord.newIterator();
1594
1878
  try {
1595
1879
  for (var iterator_2 = __values(iterator), iterator_2_1 = iterator_2.next(); !iterator_2_1.done; iterator_2_1 = iterator_2.next()) {
@@ -1602,12 +1886,12 @@ var AcTrView2d = /** @class */ (function (_super) {
1602
1886
  layoutView.addViewport(viewportView);
1603
1887
  }
1604
1888
  }
1605
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1889
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1606
1890
  finally {
1607
1891
  try {
1608
1892
  if (iterator_2_1 && !iterator_2_1.done && (_a = iterator_2.return)) _a.call(iterator_2);
1609
1893
  }
1610
- finally { if (e_4) throw e_4.error; }
1894
+ finally { if (e_5) throw e_5.error; }
1611
1895
  }
1612
1896
  };
1613
1897
  /**
@@ -1615,20 +1899,23 @@ var AcTrView2d = /** @class */ (function (_super) {
1615
1899
  * @param entities - The database entities
1616
1900
  * @returns The converted three entities
1617
1901
  */
1618
- AcTrView2d.prototype.batchConvert = function (entities) {
1619
- return __awaiter(this, void 0, void 0, function () {
1620
- var i, entity, threeEntity, isExtendBbox, layoutView, viewportView, fileName, error_1;
1902
+ AcTrView2d.prototype.batchConvert = function (entities_2) {
1903
+ return __awaiter(this, arguments, void 0, function (entities, options) {
1904
+ var progressive, i, entity, shouldConvert, threeEntity, isExtendBbox, layoutView, viewportView, fileName, error_1;
1905
+ var _this = this;
1906
+ if (options === void 0) { options = {}; }
1621
1907
  return __generator(this, function (_a) {
1622
1908
  switch (_a.label) {
1623
1909
  case 0:
1910
+ progressive = this._progressiveRendering && !options.forExport;
1624
1911
  i = 0;
1625
1912
  _a.label = 1;
1626
1913
  case 1:
1627
- if (!(i < entities.length)) return [3 /*break*/, 9];
1914
+ if (!(i < entities.length)) return [3 /*break*/, 13];
1628
1915
  entity = entities[i];
1629
1916
  _a.label = 2;
1630
1917
  case 2:
1631
- _a.trys.push([2, 6, 7, 8]);
1918
+ _a.trys.push([2, 10, 11, 12]);
1632
1919
  // Skip the default paper-space viewport (`*Paper_Space`) entirely:
1633
1920
  // it is an AutoCAD-internal viewport that exists in every paper
1634
1921
  // layout and must not be drawn (would render a giant rectangle in
@@ -1642,18 +1929,24 @@ var AcTrView2d = /** @class */ (function (_super) {
1642
1929
  // parsers).
1643
1930
  if (entity instanceof AcDbViewport &&
1644
1931
  AcTrViewportView.isDefaultPaperSpaceViewport(entity)) {
1645
- return [3 /*break*/, 8];
1932
+ return [3 /*break*/, 12];
1646
1933
  }
1647
- if (!entity.visibility) {
1648
- return [3 /*break*/, 8];
1934
+ shouldConvert = options.forExport
1935
+ ? this._entityDisplay.shouldConvertForExport(entity)
1936
+ : this._entityDisplay.shouldConvert(entity);
1937
+ if (!shouldConvert) {
1938
+ return [3 /*break*/, 12];
1649
1939
  }
1650
- threeEntity = this.drawEntity(entity, true);
1651
- if (!threeEntity)
1652
- return [3 /*break*/, 8];
1940
+ threeEntity = this.drawEntity(entity, progressive);
1941
+ // Viewports may produce no border geometry (e.g. on a no-plot layer) while
1942
+ // still needing an AcTrViewportView for model content below.
1943
+ if (!threeEntity && !(entity instanceof AcDbViewport))
1944
+ return [3 /*break*/, 12];
1945
+ if (!threeEntity) return [3 /*break*/, 9];
1653
1946
  threeEntity.objectId = entity.objectId;
1654
1947
  threeEntity.ownerId = entity.ownerId;
1655
1948
  threeEntity.layerName = entity.layer;
1656
- threeEntity.visible = entity.visibility;
1949
+ threeEntity.visible = entity.visibility !== false;
1657
1950
  if (threeEntity instanceof AcTrGroup &&
1658
1951
  threeEntity.isOnTheSameLayer) {
1659
1952
  // Even when a block expands to a single layer bucket, children authored on
@@ -1661,21 +1954,36 @@ var AcTrView2d = /** @class */ (function (_super) {
1661
1954
  this.remapInheritedLayerObjects(threeEntity.children, '0', threeEntity.layerName);
1662
1955
  }
1663
1956
  if (!(threeEntity instanceof AcTrGroup &&
1664
- !threeEntity.isOnTheSameLayer)) return [3 /*break*/, 3];
1665
- this.handleGroup(threeEntity);
1666
- return [3 /*break*/, 5];
1957
+ !threeEntity.isOnTheSameLayer)) return [3 /*break*/, 4];
1958
+ return [4 /*yield*/, this.handleGroup(threeEntity)];
1667
1959
  case 3:
1668
- isExtendBbox = !(entity instanceof AcDbRay || entity instanceof AcDbXline);
1669
- return [4 /*yield*/, threeEntity.draw()];
1960
+ _a.sent();
1961
+ return [3 /*break*/, 9];
1670
1962
  case 4:
1963
+ isExtendBbox = !(entity instanceof AcDbRay || entity instanceof AcDbXline);
1964
+ if (!(threeEntity instanceof AcTrGroup)) return [3 /*break*/, 6];
1965
+ return [4 /*yield*/, this.ensureGroupDrawableGeometry(threeEntity)];
1966
+ case 5:
1967
+ _a.sent();
1968
+ _a.label = 6;
1969
+ case 6: return [4 /*yield*/, this.finishEntityGeometry(threeEntity, progressive)];
1970
+ case 7:
1671
1971
  _a.sent();
1972
+ if (threeEntity instanceof AcTrGroup) {
1973
+ ;
1974
+ threeEntity.refreshWcsChildBoxesFromChildren();
1975
+ }
1672
1976
  this._scene.addEntity(threeEntity, isExtendBbox);
1673
1977
  this.applySessionHiddenObjectState(entity.objectId);
1674
1978
  // Release memory occupied by this entity
1675
1979
  threeEntity.dispose();
1980
+ if (!progressive) return [3 /*break*/, 9];
1676
1981
  this._isDirty = true;
1677
- _a.label = 5;
1678
- case 5:
1982
+ return [4 /*yield*/, this._progressiveOpenFit.afterGeometryBatch(function () { return _this.resolveLayoutFitBox(); }, i)];
1983
+ case 8:
1984
+ _a.sent();
1985
+ _a.label = 9;
1986
+ case 9:
1679
1987
  if (entity instanceof AcDbViewport) {
1680
1988
  // Default paper-space viewport was already filtered out at the
1681
1989
  // top of the loop, so anything that reaches here is a real
@@ -1695,149 +2003,143 @@ var AcTrView2d = /** @class */ (function (_super) {
1695
2003
  if (fileName)
1696
2004
  this._missedImages.set(entity.objectId, fileName);
1697
2005
  }
1698
- return [3 /*break*/, 8];
1699
- case 6:
2006
+ return [3 /*break*/, 12];
2007
+ case 10:
1700
2008
  error_1 = _a.sent();
1701
2009
  log.error("[AcTrView2d] Failed to convert entity ".concat(entity.objectId, " (").concat(entity.type, "):"), error_1);
1702
- return [3 /*break*/, 8];
1703
- case 7:
2010
+ return [3 /*break*/, 12];
2011
+ case 11:
1704
2012
  this.decreaseNumOfEntitiesToProcess();
1705
2013
  return [7 /*endfinally*/];
1706
- case 8:
2014
+ case 12:
1707
2015
  ++i;
1708
2016
  return [3 /*break*/, 1];
1709
- case 9: return [2 /*return*/];
2017
+ case 13: return [2 /*return*/];
1710
2018
  }
1711
2019
  });
1712
2020
  });
1713
2021
  };
1714
2022
  AcTrView2d.prototype.handleGroup = function (group) {
1715
- var e_5, _a;
1716
- var _this = this;
1717
- var children = group.children;
1718
- var objectsGroupByLayer = new Map();
1719
- children.forEach(function (child) {
1720
- var _a;
1721
- if (!child.visible) {
1722
- return;
1723
- }
1724
- var layerName = child.userData.layerName;
1725
- if (!objectsGroupByLayer.has(layerName)) {
1726
- objectsGroupByLayer.set(layerName, []);
1727
- }
1728
- (_a = objectsGroupByLayer.get(layerName)) === null || _a === void 0 ? void 0 : _a.push(child);
1729
- });
1730
- // Important:
1731
- // Sometimes one group may contain huge amount of objects (> 100,000). So it is important
1732
- // to re-parent object with the fast approach. Calling add/remove method in THREE.Object3D
1733
- // is very slow because it do lots of things
1734
- // - Remove children from old group
1735
- // - Insert them into new group
1736
- // - Reset parent pointer
1737
- // - Do one updateMatrixWorld() at the end (optional)
1738
- // So we operate its children directly.
1739
- group.children = [];
1740
- try {
1741
- for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
1742
- var child = children_1_1.value;
1743
- child.parent = null;
1744
- }
1745
- }
1746
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1747
- finally {
1748
- try {
1749
- if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
1750
- }
1751
- finally { if (e_5) throw e_5.error; }
1752
- }
1753
- var styleManager = group.styleManager;
1754
- var groupObjectId = group.objectId;
1755
- var groupLayerName = group.layerName;
1756
- var worldGroupBox = group.box.clone();
1757
- worldGroupBox.applyMatrix4(group.matrix);
1758
- var groupChildBoxes = group.boxes.map(function (box) {
1759
- var e_6, _a, e_7, _b;
1760
- var points = [
1761
- new THREE.Vector3(box.minX, box.minY, 0),
1762
- new THREE.Vector3(box.maxX, box.minY, 0),
1763
- new THREE.Vector3(box.maxX, box.maxY, 0),
1764
- new THREE.Vector3(box.minX, box.maxY, 0)
1765
- ];
1766
- try {
1767
- for (var points_1 = __values(points), points_1_1 = points_1.next(); !points_1_1.done; points_1_1 = points_1.next()) {
1768
- var point = points_1_1.value;
1769
- point.applyMatrix4(group.matrix);
1770
- }
1771
- }
1772
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1773
- finally {
1774
- try {
1775
- if (points_1_1 && !points_1_1.done && (_a = points_1.return)) _a.call(points_1);
1776
- }
1777
- finally { if (e_6) throw e_6.error; }
1778
- }
1779
- var minX = Infinity;
1780
- var minY = Infinity;
1781
- var maxX = -Infinity;
1782
- var maxY = -Infinity;
1783
- try {
1784
- for (var points_2 = __values(points), points_2_1 = points_2.next(); !points_2_1.done; points_2_1 = points_2.next()) {
1785
- var point = points_2_1.value;
1786
- minX = Math.min(minX, point.x);
1787
- minY = Math.min(minY, point.y);
1788
- maxX = Math.max(maxX, point.x);
1789
- maxY = Math.max(maxY, point.y);
1790
- }
1791
- }
1792
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1793
- finally {
1794
- try {
1795
- if (points_2_1 && !points_2_1.done && (_b = points_2.return)) _b.call(points_2);
2023
+ return __awaiter(this, void 0, void 0, function () {
2024
+ var children, objectsGroupByLayer, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, groupChildBoxes;
2025
+ var e_6, _a;
2026
+ var _this = this;
2027
+ return __generator(this, function (_b) {
2028
+ switch (_b.label) {
2029
+ case 0: return [4 /*yield*/, this.ensureGroupDrawableGeometry(group)];
2030
+ case 1:
2031
+ _b.sent();
2032
+ group.refreshWcsChildBoxesFromChildren();
2033
+ children = group.children;
2034
+ objectsGroupByLayer = new Map();
2035
+ children.forEach(function (child) {
2036
+ var _a;
2037
+ if (child.visible === false) {
2038
+ return;
2039
+ }
2040
+ var layerName = child.userData.layerName;
2041
+ if (!objectsGroupByLayer.has(layerName)) {
2042
+ objectsGroupByLayer.set(layerName, []);
2043
+ }
2044
+ (_a = objectsGroupByLayer.get(layerName)) === null || _a === void 0 ? void 0 : _a.push(child);
2045
+ });
2046
+ // Important:
2047
+ // Sometimes one group may contain huge amount of objects (> 100,000). So it is important
2048
+ // to re-parent object with the fast approach. Calling add/remove method in THREE.Object3D
2049
+ // is very slow because it do lots of things
2050
+ // - Remove children from old group
2051
+ // - Insert them into new group
2052
+ // - Reset parent pointer
2053
+ // - Do one updateMatrixWorld() at the end (optional)
2054
+ // So we operate its children directly.
2055
+ group.children = [];
2056
+ try {
2057
+ for (children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
2058
+ child = children_1_1.value;
2059
+ child.parent = null;
2060
+ }
2061
+ }
2062
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
2063
+ finally {
2064
+ try {
2065
+ if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
2066
+ }
2067
+ finally { if (e_6) throw e_6.error; }
2068
+ }
2069
+ renderContext = group.renderContext;
2070
+ groupObjectId = group.objectId;
2071
+ groupLayerName = group.layerName;
2072
+ // AcDbRenderingCache.draw (and similar paths such as AcDbTable) already call
2073
+ // applyMatrix on the group, which updates wcsBbbox and wcsChildBoxes to WCS.
2074
+ // Do not multiply group.matrix here — that would double-transform spatial bounds.
2075
+ if (process.env.NODE_ENV !== 'production') {
2076
+ assertAcTrGroupWcsBboxesConsistent(group);
2077
+ }
2078
+ groupChildBoxes = group.wcsChildBoxes.map(function (box) { return ({
2079
+ minX: box.minX,
2080
+ minY: box.minY,
2081
+ maxX: box.maxX,
2082
+ maxY: box.maxY,
2083
+ id: box.id
2084
+ }); });
2085
+ objectsGroupByLayer.forEach(function (objects, layerName) {
2086
+ // AutoCAD block rule: entities authored on layer "0" inherit the INSERT's layer.
2087
+ // Non-zero layers keep their original layer name.
2088
+ var effectiveLayerName = layerName === '0' ? groupLayerName : layerName;
2089
+ // Keep runtime layer metadata/material cache aligned with the inherited layer so
2090
+ // later layer style edits (color, linetype, lineweight, transparency) target this
2091
+ // object set correctly.
2092
+ _this.remapInheritedLayerObjects(objects, layerName, effectiveLayerName);
2093
+ // One INSERT can expand to children from multiple layers. Here we create one
2094
+ // render entity per layer bucket but preserve the INSERT object id for all
2095
+ // buckets, so selection/highlight still maps back to the same database object.
2096
+ // Within each layer bucket, the object id remains unique in scene indexing.
2097
+ var entity = new AcTrEntity(renderContext);
2098
+ entity.applyMatrix4(group.matrix);
2099
+ entity.objectId = groupObjectId;
2100
+ entity.ownerId = group.ownerId;
2101
+ // If block-definition entities are on layer "0", this bucket now uses the layer
2102
+ // of the block reference itself (effectiveLayerName).
2103
+ entity.layerName = effectiveLayerName;
2104
+ entity.wcsBbox = group.wcsBbox.clone();
2105
+ var entityUserData = entity.userData;
2106
+ entityUserData.spatialIndexChildBoxes = groupChildBoxes;
2107
+ // Important:
2108
+ // DO NOT USE spread operator when adding objects because it may be one very large array
2109
+ // and can result in maximum call stack size exceeded
2110
+ for (var i = 0; i < objects.length; i++) {
2111
+ entity.add(objects[i]);
2112
+ }
2113
+ _this.refreshTextMaterialsInObjectTree(entity);
2114
+ _this._scene.addEntity(entity, true);
2115
+ _this.applySessionHiddenObjectState(groupObjectId);
2116
+ entity.dispose();
2117
+ });
2118
+ group.dispose();
2119
+ if (this._progressiveRendering) {
2120
+ this._isDirty = true;
2121
+ void this._progressiveOpenFit.afterGeometryBatch(function () {
2122
+ return _this.resolveLayoutFitBox();
2123
+ });
2124
+ }
2125
+ return [2 /*return*/];
1796
2126
  }
1797
- finally { if (e_7) throw e_7.error; }
1798
- }
1799
- return {
1800
- minX: minX,
1801
- minY: minY,
1802
- maxX: maxX,
1803
- maxY: maxY,
1804
- id: box.id
1805
- };
2127
+ });
1806
2128
  });
1807
- objectsGroupByLayer.forEach(function (objects, layerName) {
1808
- // AutoCAD block rule: entities authored on layer "0" inherit the INSERT's layer.
1809
- // Non-zero layers keep their original layer name.
1810
- var effectiveLayerName = layerName === '0' ? groupLayerName : layerName;
1811
- // Keep runtime layer metadata/material cache aligned with the inherited layer so
1812
- // later layer style edits (color, linetype, lineweight, transparency) target this
1813
- // object set correctly.
1814
- _this.remapInheritedLayerObjects(objects, layerName, effectiveLayerName);
1815
- // One INSERT can expand to children from multiple layers. Here we create one
1816
- // render entity per layer bucket but preserve the INSERT object id for all
1817
- // buckets, so selection/highlight still maps back to the same database object.
1818
- // Within each layer bucket, the object id remains unique in scene indexing.
1819
- var entity = new AcTrEntity(styleManager);
1820
- entity.applyMatrix4(group.matrix);
1821
- entity.objectId = groupObjectId;
1822
- entity.ownerId = group.ownerId;
1823
- // If block-definition entities are on layer "0", this bucket now uses the layer
1824
- // of the block reference itself (effectiveLayerName).
1825
- entity.layerName = effectiveLayerName;
1826
- entity.box = worldGroupBox;
1827
- var entityUserData = entity.userData;
1828
- entityUserData.spatialIndexChildBoxes = groupChildBoxes;
1829
- // Important:
1830
- // DO NOT USE spread operator when adding objects because it may be one very large array
1831
- // and can result in maximum call stack size exceeded
1832
- for (var i = 0; i < objects.length; i++) {
1833
- entity.add(objects[i]);
2129
+ };
2130
+ /**
2131
+ * Rebinds text materials after INSERT groups are split/reparented by layer.
2132
+ *
2133
+ * Layer remapping can replace mesh materials; text must keep entity-trait
2134
+ * colours (especially ACI-7 foreground on paper layouts).
2135
+ */
2136
+ AcTrView2d.prototype.refreshTextMaterialsInObjectTree = function (root) {
2137
+ root.traverse(function (child) {
2138
+ var refresh = child.refreshTextMaterials;
2139
+ if (typeof refresh === 'function') {
2140
+ refresh.call(child);
1834
2141
  }
1835
- _this._scene.addEntity(entity, true);
1836
- _this.applySessionHiddenObjectState(groupObjectId);
1837
- entity.dispose();
1838
2142
  });
1839
- group.dispose();
1840
- this._isDirty = true;
1841
2143
  };
1842
2144
  /**
1843
2145
  * Remaps layer metadata/material bindings from a source layer to the effective render layer.
@@ -1853,7 +2155,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1853
2155
  * @param effectiveLayerName - Final layer name used by rendering and style updates.
1854
2156
  */
1855
2157
  AcTrView2d.prototype.remapInheritedLayerObjects = function (objects, sourceLayerName, effectiveLayerName) {
1856
- var e_8, _a;
2158
+ var e_7, _a;
1857
2159
  var _this = this;
1858
2160
  if (sourceLayerName === effectiveLayerName)
1859
2161
  return;
@@ -1863,33 +2165,67 @@ var AcTrView2d = /** @class */ (function (_super) {
1863
2165
  for (var objects_1 = __values(objects), objects_1_1 = objects_1.next(); !objects_1_1.done; objects_1_1 = objects_1.next()) {
1864
2166
  var object = objects_1_1.value;
1865
2167
  object.traverse(function (child) {
1866
- if (child.userData.layerName === sourceLayerName) {
2168
+ var inheritsInsertLayer = child.userData.layerName === sourceLayerName;
2169
+ if (inheritsInsertLayer) {
1867
2170
  child.userData.layerName = effectiveLayerName;
1868
2171
  }
1869
2172
  if (!('material' in child))
1870
2173
  return;
2174
+ // Only layer-"0" (or the current source bucket) inherits INSERT traits.
2175
+ // Attributes/text on other layers must keep their own layer materials.
2176
+ if (!inheritsInsertLayer)
2177
+ return;
1871
2178
  var material = child.material;
1872
2179
  if (Array.isArray(material)) {
1873
2180
  var materials = material;
1874
2181
  child.material = materials.map(function (entry) {
1875
- return renderer.getLayerBoundMaterial(_this.promoteLayerZeroByLayerColor(entry, sourceLayerName), effectiveLayerName, layerTraits);
2182
+ var _a;
2183
+ if (!_this.shouldRemapInheritedLayerMaterial(entry, sourceLayerName)) {
2184
+ return entry;
2185
+ }
2186
+ return ((_a = renderer.getLayerBoundMaterial(_this.promoteLayerZeroByLayerColor(entry, sourceLayerName), effectiveLayerName, layerTraits)) !== null && _a !== void 0 ? _a : entry);
1876
2187
  });
1877
2188
  return;
1878
2189
  }
2190
+ if (!_this.shouldRemapInheritedLayerMaterial(material, sourceLayerName)) {
2191
+ return;
2192
+ }
1879
2193
  var remappedMaterial = renderer.getLayerBoundMaterial(_this.promoteLayerZeroByLayerColor(material, sourceLayerName), effectiveLayerName, layerTraits);
2194
+ if (!remappedMaterial) {
2195
+ return;
2196
+ }
1880
2197
  child.material = remappedMaterial;
1881
2198
  child.userData.styleMaterialId = remappedMaterial.id;
1882
2199
  });
1883
2200
  }
1884
2201
  }
1885
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
2202
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1886
2203
  finally {
1887
2204
  try {
1888
2205
  if (objects_1_1 && !objects_1_1.done && (_a = objects_1.return)) _a.call(objects_1);
1889
2206
  }
1890
- finally { if (e_8) throw e_8.error; }
2207
+ finally { if (e_7) throw e_7.error; }
1891
2208
  }
1892
2209
  };
2210
+ /**
2211
+ * Layer-0 block contents with ByLayer color resolve to ACI-7 foreground materials before
2212
+ * INSERT remapping. Those materials must still inherit the INSERT layer when their colour
2213
+ * is layer-bound, while explicit ACI-7 entities on layer 0 stay untouched.
2214
+ */
2215
+ AcTrView2d.prototype.shouldRemapInheritedLayerMaterial = function (material, sourceLayerName) {
2216
+ var metadata = getMaterialMetadata(material);
2217
+ if (metadata.isForeground !== true) {
2218
+ return true;
2219
+ }
2220
+ if (sourceLayerName !== '0') {
2221
+ return false;
2222
+ }
2223
+ if (metadata.isByLayerColor === true) {
2224
+ return true;
2225
+ }
2226
+ var promoted = this.promoteLayerZeroByLayerColor(material, sourceLayerName);
2227
+ return getMaterialMetadata(promoted).isByLayerColor === true;
2228
+ };
1893
2229
  /**
1894
2230
  * Some DXF conversion paths lose `isByLayerColor` on layer-0 block contents while still
1895
2231
  * retaining other ByLayer markers (lineType/lineWeight/transparency). For AutoCAD-compatible
@@ -1913,7 +2249,6 @@ var AcTrView2d = /** @class */ (function (_super) {
1913
2249
  return {
1914
2250
  layer: layer.name,
1915
2251
  color: layer.color.clone(),
1916
- rgbColor: layer.color.RGB,
1917
2252
  lineType: layer.lineStyle,
1918
2253
  lineWeight: layer.lineWeight,
1919
2254
  transparency: layer.transparency
@@ -1925,6 +2260,10 @@ var AcTrView2d = /** @class */ (function (_super) {
1925
2260
  this._numOfEntitiesToProcess = 0;
1926
2261
  log.warn('Something wrong! The number of entities to process should not be less than 0.');
1927
2262
  }
2263
+ else if (this._numOfEntitiesToProcess === 0 &&
2264
+ !this._progressiveRendering) {
2265
+ this._isDirty = true;
2266
+ }
1928
2267
  };
1929
2268
  return AcTrView2d;
1930
2269
  }(AcEdBaseView));