@mlightcad/cad-simple-viewer 1.5.6 → 1.5.7

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 (321) hide show
  1. package/README.md +66 -1
  2. package/dist/cad-simple-viewer.js +30394 -28405
  3. package/dist/cad-simple-viewer.umd.cjs +150 -158
  4. package/dist/dxf-parser-worker.js +796 -707
  5. package/lib/app/AcApContext.d.ts.map +1 -1
  6. package/lib/app/AcApContext.js +15 -5
  7. package/lib/app/AcApContext.js.map +1 -1
  8. package/lib/app/AcApDocManager.d.ts +56 -0
  9. package/lib/app/AcApDocManager.d.ts.map +1 -1
  10. package/lib/app/AcApDocManager.js +112 -14
  11. package/lib/app/AcApDocManager.js.map +1 -1
  12. package/lib/app/AcApDocument.d.ts +81 -0
  13. package/lib/app/AcApDocument.d.ts.map +1 -1
  14. package/lib/app/AcApDocument.js +154 -0
  15. package/lib/app/AcApDocument.js.map +1 -1
  16. package/lib/app/AcApLayerSessionState.d.ts +15 -0
  17. package/lib/app/AcApLayerSessionState.d.ts.map +1 -0
  18. package/lib/app/AcApLayerSessionState.js +2 -0
  19. package/lib/app/AcApLayerSessionState.js.map +1 -0
  20. package/lib/app/AcApOpenFileDialog.d.ts +35 -0
  21. package/lib/app/AcApOpenFileDialog.d.ts.map +1 -0
  22. package/lib/app/AcApOpenFileDialog.js +192 -0
  23. package/lib/app/AcApOpenFileDialog.js.map +1 -0
  24. package/lib/app/AcApWebworkerReadiness.d.ts +18 -0
  25. package/lib/app/AcApWebworkerReadiness.d.ts.map +1 -0
  26. package/lib/app/AcApWebworkerReadiness.js +126 -0
  27. package/lib/app/AcApWebworkerReadiness.js.map +1 -0
  28. package/lib/app/index.d.ts +3 -0
  29. package/lib/app/index.d.ts.map +1 -1
  30. package/lib/app/index.js +2 -0
  31. package/lib/app/index.js.map +1 -1
  32. package/lib/command/AcApOpenCmd.d.ts +3 -22
  33. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  34. package/lib/command/AcApOpenCmd.js +3 -22
  35. package/lib/command/AcApOpenCmd.js.map +1 -1
  36. package/lib/command/AcApRedoCmd.d.ts +10 -0
  37. package/lib/command/AcApRedoCmd.d.ts.map +1 -0
  38. package/lib/command/AcApRedoCmd.js +85 -0
  39. package/lib/command/AcApRedoCmd.js.map +1 -0
  40. package/lib/command/AcApUndoCmd.d.ts +10 -0
  41. package/lib/command/AcApUndoCmd.d.ts.map +1 -0
  42. package/lib/command/AcApUndoCmd.js +85 -0
  43. package/lib/command/AcApUndoCmd.js.map +1 -0
  44. package/lib/command/draw/AcApEllipseCmd.d.ts.map +1 -1
  45. package/lib/command/draw/AcApEllipseCmd.js +12 -4
  46. package/lib/command/draw/AcApEllipseCmd.js.map +1 -1
  47. package/lib/command/draw/AcApLineCmd.d.ts.map +1 -1
  48. package/lib/command/draw/AcApLineCmd.js +8 -2
  49. package/lib/command/draw/AcApLineCmd.js.map +1 -1
  50. package/lib/command/draw/AcApMLineCmd.d.ts.map +1 -1
  51. package/lib/command/draw/AcApMLineCmd.js +2 -0
  52. package/lib/command/draw/AcApMLineCmd.js.map +1 -1
  53. package/lib/command/draw/AcApPolylineCmd.d.ts.map +1 -1
  54. package/lib/command/draw/AcApPolylineCmd.js +3 -0
  55. package/lib/command/draw/AcApPolylineCmd.js.map +1 -1
  56. package/lib/command/draw/AcApSplineCmd.d.ts.map +1 -1
  57. package/lib/command/draw/AcApSplineCmd.js +2 -0
  58. package/lib/command/draw/AcApSplineCmd.js.map +1 -1
  59. package/lib/command/index.d.ts +2 -0
  60. package/lib/command/index.d.ts.map +1 -1
  61. package/lib/command/index.js +2 -0
  62. package/lib/command/index.js.map +1 -1
  63. package/lib/command/layer/AcApLayerCmd.d.ts +3 -187
  64. package/lib/command/layer/AcApLayerCmd.d.ts.map +1 -1
  65. package/lib/command/layer/AcApLayerCmd.js +52 -376
  66. package/lib/command/layer/AcApLayerCmd.js.map +1 -1
  67. package/lib/command/layer/AcApLayerCurCmd.d.ts +2 -27
  68. package/lib/command/layer/AcApLayerCurCmd.d.ts.map +1 -1
  69. package/lib/command/layer/AcApLayerCurCmd.js +18 -67
  70. package/lib/command/layer/AcApLayerCurCmd.js.map +1 -1
  71. package/lib/command/layer/AcApLayerDelCmd.d.ts +2 -25
  72. package/lib/command/layer/AcApLayerDelCmd.d.ts.map +1 -1
  73. package/lib/command/layer/AcApLayerDelCmd.js +22 -155
  74. package/lib/command/layer/AcApLayerDelCmd.js.map +1 -1
  75. package/lib/command/layer/AcApLayerFreezeCmd.d.ts +2 -9
  76. package/lib/command/layer/AcApLayerFreezeCmd.d.ts.map +1 -1
  77. package/lib/command/layer/AcApLayerFreezeCmd.js +27 -39
  78. package/lib/command/layer/AcApLayerFreezeCmd.js.map +1 -1
  79. package/lib/command/layer/AcApLayerIsoCmd.d.ts +2 -24
  80. package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
  81. package/lib/command/layer/AcApLayerIsoCmd.js +14 -183
  82. package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
  83. package/lib/command/layer/AcApLayerLockCmd.d.ts +2 -33
  84. package/lib/command/layer/AcApLayerLockCmd.d.ts.map +1 -1
  85. package/lib/command/layer/AcApLayerLockCmd.js +18 -55
  86. package/lib/command/layer/AcApLayerLockCmd.js.map +1 -1
  87. package/lib/command/layer/AcApLayerMutationCmd.d.ts +13 -0
  88. package/lib/command/layer/AcApLayerMutationCmd.d.ts.map +1 -0
  89. package/lib/command/layer/AcApLayerMutationCmd.js +42 -0
  90. package/lib/command/layer/AcApLayerMutationCmd.js.map +1 -0
  91. package/lib/command/layer/AcApLayerOffCmd.d.ts +2 -2
  92. package/lib/command/layer/AcApLayerOffCmd.d.ts.map +1 -1
  93. package/lib/command/layer/AcApLayerOffCmd.js +27 -28
  94. package/lib/command/layer/AcApLayerOffCmd.js.map +1 -1
  95. package/lib/command/layer/AcApLayerOnCmd.d.ts +2 -15
  96. package/lib/command/layer/AcApLayerOnCmd.d.ts.map +1 -1
  97. package/lib/command/layer/AcApLayerOnCmd.js +6 -49
  98. package/lib/command/layer/AcApLayerOnCmd.js.map +1 -1
  99. package/lib/command/layer/AcApLayerPCmd.d.ts +2 -68
  100. package/lib/command/layer/AcApLayerPCmd.d.ts.map +1 -1
  101. package/lib/command/layer/AcApLayerPCmd.js +4 -152
  102. package/lib/command/layer/AcApLayerPCmd.js.map +1 -1
  103. package/lib/command/layer/AcApLayerThawCmd.d.ts +2 -22
  104. package/lib/command/layer/AcApLayerThawCmd.d.ts.map +1 -1
  105. package/lib/command/layer/AcApLayerThawCmd.js +6 -61
  106. package/lib/command/layer/AcApLayerThawCmd.js.map +1 -1
  107. package/lib/command/layer/AcApLayerUnisoCmd.d.ts +2 -37
  108. package/lib/command/layer/AcApLayerUnisoCmd.d.ts.map +1 -1
  109. package/lib/command/layer/AcApLayerUnisoCmd.js +7 -108
  110. package/lib/command/layer/AcApLayerUnisoCmd.js.map +1 -1
  111. package/lib/command/layer/AcApLayerUnlockCmd.d.ts +2 -33
  112. package/lib/command/layer/AcApLayerUnlockCmd.d.ts.map +1 -1
  113. package/lib/command/layer/AcApLayerUnlockCmd.js +18 -55
  114. package/lib/command/layer/AcApLayerUnlockCmd.js.map +1 -1
  115. package/lib/command/modify/AcApCopyCmd.d.ts +12 -0
  116. package/lib/command/modify/AcApCopyCmd.d.ts.map +1 -1
  117. package/lib/command/modify/AcApCopyCmd.js +67 -177
  118. package/lib/command/modify/AcApCopyCmd.js.map +1 -1
  119. package/lib/command/modify/AcApCopyPreviewJig.d.ts +21 -0
  120. package/lib/command/modify/AcApCopyPreviewJig.d.ts.map +1 -0
  121. package/lib/command/modify/AcApCopyPreviewJig.js +61 -0
  122. package/lib/command/modify/AcApCopyPreviewJig.js.map +1 -0
  123. package/lib/command/modify/AcApEraseCmd.d.ts +0 -6
  124. package/lib/command/modify/AcApEraseCmd.d.ts.map +1 -1
  125. package/lib/command/modify/AcApEraseCmd.js +11 -38
  126. package/lib/command/modify/AcApEraseCmd.js.map +1 -1
  127. package/lib/command/modify/AcApHideObjectsCmd.d.ts +0 -7
  128. package/lib/command/modify/AcApHideObjectsCmd.d.ts.map +1 -1
  129. package/lib/command/modify/AcApHideObjectsCmd.js +0 -7
  130. package/lib/command/modify/AcApHideObjectsCmd.js.map +1 -1
  131. package/lib/command/modify/AcApMoveCmd.d.ts +0 -6
  132. package/lib/command/modify/AcApMoveCmd.d.ts.map +1 -1
  133. package/lib/command/modify/AcApMoveCmd.js +26 -105
  134. package/lib/command/modify/AcApMoveCmd.js.map +1 -1
  135. package/lib/command/modify/AcApMovePreviewJig.d.ts +18 -0
  136. package/lib/command/modify/AcApMovePreviewJig.d.ts.map +1 -0
  137. package/lib/command/modify/AcApMovePreviewJig.js +45 -0
  138. package/lib/command/modify/AcApMovePreviewJig.js.map +1 -0
  139. package/lib/command/modify/AcApOffsetCmd.d.ts.map +1 -1
  140. package/lib/command/modify/AcApOffsetCmd.js +5 -33
  141. package/lib/command/modify/AcApOffsetCmd.js.map +1 -1
  142. package/lib/command/modify/AcApRotateCmd.d.ts +2 -2
  143. package/lib/command/modify/AcApRotateCmd.d.ts.map +1 -1
  144. package/lib/command/modify/AcApRotateCmd.js +37 -200
  145. package/lib/command/modify/AcApRotateCmd.js.map +1 -1
  146. package/lib/command/modify/AcApRotatePreviewJig.d.ts +47 -0
  147. package/lib/command/modify/AcApRotatePreviewJig.d.ts.map +1 -0
  148. package/lib/command/modify/AcApRotatePreviewJig.js +97 -0
  149. package/lib/command/modify/AcApRotatePreviewJig.js.map +1 -0
  150. package/lib/editor/command/AcEdCommand.d.ts +8 -0
  151. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  152. package/lib/editor/command/AcEdCommand.js +48 -5
  153. package/lib/editor/command/AcEdCommand.js.map +1 -1
  154. package/lib/editor/global/eventBus.d.ts +10 -2
  155. package/lib/editor/global/eventBus.d.ts.map +1 -1
  156. package/lib/editor/global/eventBus.js.map +1 -1
  157. package/lib/editor/grip/AcEdGripAppearance.d.ts +18 -0
  158. package/lib/editor/grip/AcEdGripAppearance.d.ts.map +1 -0
  159. package/lib/editor/grip/AcEdGripAppearance.js +30 -0
  160. package/lib/editor/grip/AcEdGripAppearance.js.map +1 -0
  161. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
  162. package/lib/editor/grip/AcEdGripEditSession.js +9 -2
  163. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
  164. package/lib/editor/grip/AcEdGripHandle.d.ts +3 -2
  165. package/lib/editor/grip/AcEdGripHandle.d.ts.map +1 -1
  166. package/lib/editor/grip/AcEdGripHandle.js +9 -6
  167. package/lib/editor/grip/AcEdGripHandle.js.map +1 -1
  168. package/lib/editor/grip/AcEdGripManager.d.ts +13 -1
  169. package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -1
  170. package/lib/editor/grip/AcEdGripManager.js +54 -14
  171. package/lib/editor/grip/AcEdGripManager.js.map +1 -1
  172. package/lib/editor/input/AcEdBatchPreview.d.ts +96 -0
  173. package/lib/editor/input/AcEdBatchPreview.d.ts.map +1 -0
  174. package/lib/editor/input/AcEdBatchPreview.js +125 -0
  175. package/lib/editor/input/AcEdBatchPreview.js.map +1 -0
  176. package/lib/editor/input/AcEdPreviewJig.d.ts +1 -1
  177. package/lib/editor/input/AcEdPreviewJig.d.ts.map +1 -1
  178. package/lib/editor/input/AcEdPreviewJig.js +14 -0
  179. package/lib/editor/input/AcEdPreviewJig.js.map +1 -1
  180. package/lib/editor/input/AcEdSelectionPreviewJig.d.ts +109 -0
  181. package/lib/editor/input/AcEdSelectionPreviewJig.d.ts.map +1 -0
  182. package/lib/editor/input/AcEdSelectionPreviewJig.js +185 -0
  183. package/lib/editor/input/AcEdSelectionPreviewJig.js.map +1 -0
  184. package/lib/editor/input/index.d.ts +2 -0
  185. package/lib/editor/input/index.d.ts.map +1 -1
  186. package/lib/editor/input/index.js +2 -0
  187. package/lib/editor/input/index.js.map +1 -1
  188. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +7 -0
  189. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
  190. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +17 -0
  191. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
  192. package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts.map +1 -1
  193. package/lib/editor/input/ui/AcEdFloatingInputBox.js +10 -2
  194. package/lib/editor/input/ui/AcEdFloatingInputBox.js.map +1 -1
  195. package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
  196. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +9 -4
  197. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
  198. package/lib/editor/view/AcEdBaseView.d.ts +37 -2
  199. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  200. package/lib/editor/view/AcEdBaseView.js +14 -12
  201. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  202. package/lib/editor/view/AcEdSpatialQueryResult.d.ts +28 -0
  203. package/lib/editor/view/AcEdSpatialQueryResult.d.ts.map +1 -1
  204. package/lib/editor/view/AcEdSpatialQueryResult.js +65 -1
  205. package/lib/editor/view/AcEdSpatialQueryResult.js.map +1 -1
  206. package/lib/i18n/AcApI18n.d.ts +42 -0
  207. package/lib/i18n/AcApI18n.d.ts.map +1 -1
  208. package/lib/i18n/AcApI18n.js +56 -4
  209. package/lib/i18n/AcApI18n.js.map +1 -1
  210. package/lib/i18n/en/command.d.ts +23 -0
  211. package/lib/i18n/en/command.d.ts.map +1 -1
  212. package/lib/i18n/en/command.js +23 -0
  213. package/lib/i18n/en/command.js.map +1 -1
  214. package/lib/i18n/zh/command.d.ts +23 -0
  215. package/lib/i18n/zh/command.d.ts.map +1 -1
  216. package/lib/i18n/zh/command.js +23 -0
  217. package/lib/i18n/zh/command.js.map +1 -1
  218. package/lib/index.d.ts +1 -0
  219. package/lib/index.d.ts.map +1 -1
  220. package/lib/index.js +1 -0
  221. package/lib/index.js.map +1 -1
  222. package/lib/service/AcApEntitySelection.d.ts +42 -0
  223. package/lib/service/AcApEntitySelection.d.ts.map +1 -0
  224. package/lib/service/AcApEntitySelection.js +156 -0
  225. package/lib/service/AcApEntitySelection.js.map +1 -0
  226. package/lib/service/AcApEntityService.d.ts +115 -0
  227. package/lib/service/AcApEntityService.d.ts.map +1 -0
  228. package/lib/service/AcApEntityService.js +194 -0
  229. package/lib/service/AcApEntityService.js.map +1 -0
  230. package/lib/{command/layer → service}/AcApLayerIsoState.d.ts +6 -24
  231. package/lib/service/AcApLayerIsoState.d.ts.map +1 -0
  232. package/lib/service/AcApLayerIsoState.js +28 -0
  233. package/lib/service/AcApLayerIsoState.js.map +1 -0
  234. package/lib/service/AcApLayerService.d.ts +400 -0
  235. package/lib/service/AcApLayerService.d.ts.map +1 -0
  236. package/lib/service/AcApLayerService.js +1240 -0
  237. package/lib/service/AcApLayerService.js.map +1 -0
  238. package/lib/service/AcApLayerStore.d.ts +198 -0
  239. package/lib/service/AcApLayerStore.d.ts.map +1 -0
  240. package/lib/service/AcApLayerStore.js +335 -0
  241. package/lib/service/AcApLayerStore.js.map +1 -0
  242. package/lib/service/AcApServiceEdit.d.ts +18 -0
  243. package/lib/service/AcApServiceEdit.d.ts.map +1 -0
  244. package/lib/service/AcApServiceEdit.js +34 -0
  245. package/lib/service/AcApServiceEdit.js.map +1 -0
  246. package/lib/service/index.d.ts +16 -0
  247. package/lib/service/index.d.ts.map +1 -0
  248. package/lib/service/index.js +16 -0
  249. package/lib/service/index.js.map +1 -0
  250. package/lib/service/types.d.ts +116 -0
  251. package/lib/service/types.d.ts.map +1 -0
  252. package/lib/service/types.js +5 -0
  253. package/lib/service/types.js.map +1 -0
  254. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +21 -6
  255. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -1
  256. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +56 -10
  257. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
  258. package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts +2 -2
  259. package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts.map +1 -1
  260. package/lib/spatialIndex/AcTrLinearSpatialIndex.js +9 -3
  261. package/lib/spatialIndex/AcTrLinearSpatialIndex.js.map +1 -1
  262. package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts +2 -2
  263. package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts.map +1 -1
  264. package/lib/spatialIndex/AcTrRBushSpatialIndex.js +19 -5
  265. package/lib/spatialIndex/AcTrRBushSpatialIndex.js.map +1 -1
  266. package/lib/spatialIndex/AcTrSpatialIndex.d.ts +10 -1
  267. package/lib/spatialIndex/AcTrSpatialIndex.d.ts.map +1 -1
  268. package/lib/spatialIndex/AcTrSpatialIndex.js +7 -1
  269. package/lib/spatialIndex/AcTrSpatialIndex.js.map +1 -1
  270. package/lib/util/AcApDatabaseEdit.d.ts +11 -0
  271. package/lib/util/AcApDatabaseEdit.d.ts.map +1 -0
  272. package/lib/util/AcApDatabaseEdit.js +20 -0
  273. package/lib/util/AcApDatabaseEdit.js.map +1 -0
  274. package/lib/util/AcApGeTransform.d.ts +10 -0
  275. package/lib/util/AcApGeTransform.d.ts.map +1 -0
  276. package/lib/util/AcApGeTransform.js +15 -0
  277. package/lib/util/AcApGeTransform.js.map +1 -0
  278. package/lib/util/index.d.ts +2 -0
  279. package/lib/util/index.d.ts.map +1 -1
  280. package/lib/util/index.js +2 -0
  281. package/lib/util/index.js.map +1 -1
  282. package/lib/view/AcEdViewKeyHandler.d.ts +32 -0
  283. package/lib/view/AcEdViewKeyHandler.d.ts.map +1 -0
  284. package/lib/view/AcEdViewKeyHandler.js +101 -0
  285. package/lib/view/AcEdViewKeyHandler.js.map +1 -0
  286. package/lib/view/AcTrGroupWcsBboxAssert.d.ts +16 -0
  287. package/lib/view/AcTrGroupWcsBboxAssert.d.ts.map +1 -1
  288. package/lib/view/AcTrGroupWcsBboxAssert.js +19 -0
  289. package/lib/view/AcTrGroupWcsBboxAssert.js.map +1 -1
  290. package/lib/view/AcTrInheritedLayerMaterialMapper.d.ts +49 -0
  291. package/lib/view/AcTrInheritedLayerMaterialMapper.d.ts.map +1 -0
  292. package/lib/view/AcTrInheritedLayerMaterialMapper.js +138 -0
  293. package/lib/view/AcTrInheritedLayerMaterialMapper.js.map +1 -0
  294. package/lib/view/AcTrLayer.d.ts +26 -2
  295. package/lib/view/AcTrLayer.d.ts.map +1 -1
  296. package/lib/view/AcTrLayer.js +64 -0
  297. package/lib/view/AcTrLayer.js.map +1 -1
  298. package/lib/view/AcTrLayerAppearanceController.d.ts +55 -0
  299. package/lib/view/AcTrLayerAppearanceController.d.ts.map +1 -0
  300. package/lib/view/AcTrLayerAppearanceController.js +86 -0
  301. package/lib/view/AcTrLayerAppearanceController.js.map +1 -0
  302. package/lib/view/AcTrLayout.d.ts +36 -1
  303. package/lib/view/AcTrLayout.d.ts.map +1 -1
  304. package/lib/view/AcTrLayout.js +160 -14
  305. package/lib/view/AcTrLayout.js.map +1 -1
  306. package/lib/view/AcTrScene.d.ts +47 -1
  307. package/lib/view/AcTrScene.d.ts.map +1 -1
  308. package/lib/view/AcTrScene.js +78 -3
  309. package/lib/view/AcTrScene.js.map +1 -1
  310. package/lib/view/AcTrView2d.d.ts +50 -53
  311. package/lib/view/AcTrView2d.d.ts.map +1 -1
  312. package/lib/view/AcTrView2d.js +195 -312
  313. package/lib/view/AcTrView2d.js.map +1 -1
  314. package/lib/view/index.d.ts +3 -0
  315. package/lib/view/index.d.ts.map +1 -1
  316. package/lib/view/index.js +3 -0
  317. package/lib/view/index.js.map +1 -1
  318. package/package.json +7 -7
  319. package/lib/command/layer/AcApLayerIsoState.d.ts.map +0 -1
  320. package/lib/command/layer/AcApLayerIsoState.js +0 -53
  321. package/lib/command/layer/AcApLayerIsoState.js.map +0 -1
@@ -98,17 +98,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
98
98
  };
99
99
  import { acdbHostApplicationServices, AcDbMText, AcDbRasterImage, AcDbRay, AcDbSysVarManager, AcDbViewport, AcDbXline, AcGeBox2d, AcGePoint2d, log } from '@mlightcad/data-model';
100
100
  import { AcDbSystemVariables } from '@mlightcad/data-model';
101
- import { AcTrEntity, AcTrGroup, AcTrRenderer, AcTrViewportView, getMaterialMetadata, hasByLayerBinding, setMaterialMetadata } from '@mlightcad/three-renderer';
101
+ import { AcTrEntity, AcTrGroup, AcTrRenderer, AcTrViewportView } from '@mlightcad/three-renderer';
102
+ import { AcTrMatrixUtil } from '@mlightcad/three-renderer';
102
103
  import * as THREE from 'three';
103
104
  import Stats from 'three/examples/jsm/libs/stats.module';
104
105
  import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
105
106
  import { AcApDocManager, AcApSettingManager } from '../app';
106
107
  import { AcEdBaseView, AcEdConditionWaiter, AcEdCorsorType, AcEdGripManager, AcEdMTextEditor, AcEdOpenMode, AcEdViewMode, eventBus, resolvePointerSelectionAction } from '../editor';
107
108
  import { ACGI_MODEL_SPACE_BACKGROUND, isModelSpaceDatabase, readLayoutBackgroundColor } from '../editor/global/AcEdUiColor';
109
+ import { isEffectiveSpatialQueryHit } from '../editor/view/AcEdSpatialQueryResult';
108
110
  import { AcTrGeometryUtil } from '../util';
111
+ import { acapRunDatabaseEdit } from '../util/AcApDatabaseEdit';
112
+ import { AcEdViewKeyHandler } from './AcEdViewKeyHandler';
109
113
  import { AcTrEntityDisplayController } from './AcTrEntityDisplayController';
110
- import { assertAcTrGroupWcsBboxesConsistent } from './AcTrGroupWcsBboxAssert';
114
+ import { assertAcTrGroupWcsBboxesConsistent, unionGroupWcsChildBoxes } from './AcTrGroupWcsBboxAssert';
115
+ import { AcTrInheritedLayerMaterialMapper } from './AcTrInheritedLayerMaterialMapper';
111
116
  import { AcTrLayer } from './AcTrLayer';
117
+ import { AcTrLayerAppearanceController } from './AcTrLayerAppearanceController';
112
118
  import { AcTrLayoutView } from './AcTrLayoutView';
113
119
  import { AcTrLayoutViewManager } from './AcTrLayoutViewManager';
114
120
  import { sortPickResults } from './AcTrPickResultUtil';
@@ -158,11 +164,15 @@ var AcTrView2d = /** @class */ (function (_super) {
158
164
  var mergedOptions = __assign(__assign({}, DEFAULT_VIEW_2D_OPTIONS), options);
159
165
  var container = (_a = mergedOptions.container) !== null && _a !== void 0 ? _a : document.createElement('div');
160
166
  mergedOptions.container = container;
167
+ container.style.overflow = 'hidden';
161
168
  var renderer = new THREE.WebGLRenderer({
162
169
  antialias: true,
163
170
  alpha: true
164
171
  });
165
172
  container.appendChild(renderer.domElement);
173
+ renderer.domElement.style.display = 'block';
174
+ renderer.domElement.style.maxWidth = '100%';
175
+ renderer.domElement.style.maxHeight = '100%';
166
176
  _this = _super.call(this, renderer.domElement, container) || this;
167
177
  /**
168
178
  * ID of the currently scheduled requestAnimationFrame callback.
@@ -250,6 +260,7 @@ var AcTrView2d = /** @class */ (function (_super) {
250
260
  _this._isDirty = (_this._progressiveRendering && stillLoading) || needsRedraw;
251
261
  };
252
262
  _this._gripManager = new AcEdGripManager(_this);
263
+ _this._keyHandler = new AcEdViewKeyHandler(_this);
253
264
  if (options.calculateSizeCallback) {
254
265
  _this.setCalculateSizeCallback(options.calculateSizeCallback);
255
266
  }
@@ -266,8 +277,11 @@ var AcTrView2d = /** @class */ (function (_super) {
266
277
  });
267
278
  });
268
279
  _this._scene = _this.createScene();
280
+ _this._layerAppearance = new AcTrLayerAppearanceController(_this._scene, _this._renderer);
281
+ _this._inheritedLayerMaterialMapper = new AcTrInheritedLayerMaterialMapper(function (layerName) { return _this._layerAppearance.getEffectiveLayerTraits(layerName); }, _this._renderer);
269
282
  // Initialize background color through setter to keep renderer/cursor in sync.
270
- _this.backgroundColor = (_b = mergedOptions.background) !== null && _b !== void 0 ? _b : ACGI_MODEL_SPACE_BACKGROUND;
283
+ _this.backgroundColor =
284
+ (_b = mergedOptions.background) !== null && _b !== void 0 ? _b : ACGI_MODEL_SPACE_BACKGROUND;
271
285
  _this._stats = _this.createStats(AcApSettingManager.instance.isShowStats);
272
286
  // Layout background sysvars drive the canvas clear colour and ACI-7
273
287
  // inversion (`MODELBKCOLOR` for model space, `PAPERBKCOLOR` for the
@@ -346,6 +360,12 @@ var AcTrView2d = /** @class */ (function (_super) {
346
360
  selectionPreviewEl.style.setProperty('--line-color', style.lineColor);
347
361
  });
348
362
  _this.canvas.addEventListener('mouseup', function (e) {
363
+ if (_this._gripManager.isDragging) {
364
+ selectionStartWcs = null;
365
+ selectionStartCanvas = null;
366
+ clearSelectionPreview();
367
+ return;
368
+ }
349
369
  if (!selectionStartWcs || !selectionStartCanvas)
350
370
  return;
351
371
  var endCanvas = _this.viewportToCanvas({
@@ -388,31 +408,7 @@ var AcTrView2d = /** @class */ (function (_super) {
388
408
  // such as the canvas or the entire document. This can interfere with other event listeners you
389
409
  // add, including the keydown event.
390
410
  document.addEventListener('keydown', function (e) {
391
- // Ignore global shortcuts while typing or during IME composition.
392
- var target = e.target;
393
- var isEditableTarget = target instanceof HTMLInputElement ||
394
- target instanceof HTMLTextAreaElement ||
395
- (target === null || target === void 0 ? void 0 : target.isContentEditable) === true;
396
- // keyCode 229 is commonly reported by IME composing key events.
397
- var isImeComposing = e.isComposing || e.keyCode === 229;
398
- if (isEditableTarget || isImeComposing) {
399
- return;
400
- }
401
- switch (e.code) {
402
- case 'Escape':
403
- _this.selectionSet.clear();
404
- break;
405
- case 'Delete':
406
- case 'Backspace':
407
- // Only dispatch erase when no command is currently active.
408
- // Dispatching erase mid-command (e.g. while LINE awaits the next
409
- // point) corrupts the active command's input pipeline because
410
- // sendStringToExecute clears scripted inputs unconditionally.
411
- if (!_this.editor.isActive) {
412
- AcApDocManager.instance.sendStringToExecute('erase');
413
- }
414
- break;
415
- }
411
+ _this._keyHandler.handleKeyDown(e);
416
412
  });
417
413
  acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(function (args) {
418
414
  var btrId = args.layout.blockTableRecordId;
@@ -468,6 +464,8 @@ var AcTrView2d = /** @class */ (function (_super) {
468
464
  _this._css2dRenderer.domElement.style.left = '0px';
469
465
  _this._css2dRenderer.domElement.style.pointerEvents = 'none';
470
466
  _this._css2dRenderer.domElement.style.zIndex = '99998';
467
+ _this._css2dRenderer.domElement.style.maxWidth = '100%';
468
+ _this._css2dRenderer.domElement.style.maxHeight = '100%';
471
469
  container.appendChild(_this._css2dRenderer.domElement);
472
470
  _this._missedImages = new Map();
473
471
  _this._layoutViewManager = new AcTrLayoutViewManager();
@@ -658,7 +656,7 @@ var AcTrView2d = /** @class */ (function (_super) {
658
656
  this._renderer.setClearColor(value);
659
657
  // Updates style-manager background, repaints ACI-7 / bg-follow materials.
660
658
  this._renderer.currentBackgroundColor = value;
661
- this.refreshTextMaterialsInObjectTree(this._scene.internalScene);
659
+ this._layerAppearance.refreshTextMaterialsInObjectTree(this._scene.internalScene);
662
660
  this.editor.syncCursorBackground(value);
663
661
  this._isDirty = true;
664
662
  };
@@ -668,11 +666,21 @@ var AcTrView2d = /** @class */ (function (_super) {
668
666
  }
669
667
  return isModelSpaceDatabase(database);
670
668
  };
669
+ /**
670
+ * Binds the active drawing database on the renderer draw context.
671
+ *
672
+ * Called before document read so layer-table traits are available while layers
673
+ * are appended during open, and again after open to refresh display sysvars.
674
+ */
675
+ AcTrView2d.prototype.bindDrawDatabase = function (database) {
676
+ this._renderer.context.database = database;
677
+ };
671
678
  /**
672
679
  * Re-reads layout background sysvars from the active database. Called after
673
680
  * a document is opened so DWG-stored values take effect.
674
681
  */
675
682
  AcTrView2d.prototype.syncDisplaySysVars = function (database) {
683
+ this.bindDrawDatabase(database);
676
684
  this.applyCanvasBackground(readLayoutBackgroundColor(database, this.isModelSpaceLayout(database)));
677
685
  };
678
686
  /**
@@ -951,13 +959,18 @@ var AcTrView2d = /** @class */ (function (_super) {
951
959
  };
952
960
  AcTrView2d.prototype.editMTextEntity = function (mtext) {
953
961
  return __awaiter(this, void 0, void 0, function () {
954
- var editor, applied, result;
962
+ var db, editor, applied, result_1;
955
963
  return __generator(this, function (_a) {
956
964
  switch (_a.label) {
957
965
  case 0:
966
+ db = mtext.database;
958
967
  if (mtext.lineSpacingFactor !== AcEdMTextEditor.defaultLineSpacingFactor) {
959
- mtext.lineSpacingFactor = AcEdMTextEditor.defaultLineSpacingFactor;
960
- mtext.triggerModifiedEvent();
968
+ acapRunDatabaseEdit(db, 'Edit MText', function () {
969
+ var opened = db.openEntityForWrite(mtext);
970
+ if (!(opened instanceof AcDbMText))
971
+ return;
972
+ opened.lineSpacingFactor = AcEdMTextEditor.defaultLineSpacingFactor;
973
+ });
961
974
  }
962
975
  // Hide the in-scene MTEXT while the inline editor renders its own copy; otherwise
963
976
  // both draw at once (double text) when the user double-clicks to edit.
@@ -978,16 +991,20 @@ var AcTrView2d = /** @class */ (function (_super) {
978
991
  toolbarFontFamilies: this.getMTextToolbarFontFamilies()
979
992
  })];
980
993
  case 2:
981
- result = _a.sent();
982
- if (!result)
994
+ result_1 = _a.sent();
995
+ if (!result_1)
983
996
  return [2 /*return*/];
984
- mtext.location = result.location;
985
- mtext.contents = result.contents;
986
- mtext.width = result.width;
987
- mtext.height = result.height;
988
- mtext.lineSpacingFactor = result.lineSpacingFactor;
989
- mtext.attachmentPoint = result.attachmentPoint;
990
- mtext.triggerModifiedEvent();
997
+ acapRunDatabaseEdit(db, 'Edit MText', function () {
998
+ var opened = db.openEntityForWrite(mtext);
999
+ if (!(opened instanceof AcDbMText))
1000
+ return;
1001
+ opened.location = result_1.location;
1002
+ opened.contents = result_1.contents;
1003
+ opened.width = result_1.width;
1004
+ opened.height = result_1.height;
1005
+ opened.lineSpacingFactor = result_1.lineSpacingFactor;
1006
+ opened.attachmentPoint = result_1.attachmentPoint;
1007
+ });
991
1008
  applied = true;
992
1009
  return [3 /*break*/, 4];
993
1010
  case 3:
@@ -1096,6 +1113,8 @@ var AcTrView2d = /** @class */ (function (_super) {
1096
1113
  firstQueryResults.forEach(function (item) {
1097
1114
  if (drillThroughViewportIds.has(item.id))
1098
1115
  return;
1116
+ if (!isEffectiveSpatialQueryHit(item))
1117
+ return;
1099
1118
  if (activeLayout.isIntersectWith(item.id, raycaster)) {
1100
1119
  results.push(item);
1101
1120
  }
@@ -1147,6 +1166,8 @@ var AcTrView2d = /** @class */ (function (_super) {
1147
1166
  var vpRaycaster = vpView.resetRaycaster(modelPt, modelRadius);
1148
1167
  var modelHits = modelLayout.search(modelBox);
1149
1168
  modelHits.forEach(function (item) {
1169
+ if (!isEffectiveSpatialQueryHit(item))
1170
+ return;
1150
1171
  if (modelLayout.isIntersectWith(item.id, vpRaycaster)) {
1151
1172
  results.push(item);
1152
1173
  }
@@ -1169,8 +1190,8 @@ var AcTrView2d = /** @class */ (function (_super) {
1169
1190
  /**
1170
1191
  * @inheritdoc
1171
1192
  */
1172
- AcTrView2d.prototype.search = function (box) {
1173
- return this._scene.search(box);
1193
+ AcTrView2d.prototype.search = function (box, options) {
1194
+ return this._scene.search(box, options);
1174
1195
  };
1175
1196
  /**
1176
1197
  * @inheritdoc
@@ -1192,49 +1213,18 @@ var AcTrView2d = /** @class */ (function (_super) {
1192
1213
  * @inheritdoc
1193
1214
  */
1194
1215
  AcTrView2d.prototype.addLayer = function (layer) {
1195
- var updatedLayers = this._scene.addLayer(this.toLayerInfo(layer));
1196
- var traits = {
1197
- layer: layer.name,
1198
- color: layer.color.clone(),
1199
- lineType: layer.lineStyle,
1200
- lineWeight: layer.lineWeight,
1201
- transparency: layer.transparency
1202
- };
1203
- var materials = this._renderer.updateLayerMaterial(layer.name, traits);
1204
- updatedLayers.forEach(function (updatedLayer) {
1205
- for (var id in materials) {
1206
- var material = materials[id];
1207
- updatedLayer.updateMaterial(Number(id), material);
1208
- }
1209
- });
1216
+ this._scene.addLayer(this.toLayerInfo(layer));
1217
+ this._layerAppearance.syncFromLiveRecord(layer);
1210
1218
  this._isDirty = true;
1211
1219
  };
1212
1220
  /**
1213
1221
  * @inheritdoc
1214
1222
  */
1215
1223
  AcTrView2d.prototype.updateLayer = function (layer, changes) {
1216
- var updatedLayers = this._scene.updateLayer(this.toLayerInfo(layer));
1217
- var traits = {};
1218
- if (changes.color) {
1219
- traits.color = changes.color.clone();
1224
+ this._scene.updateLayer(this.toLayerInfo(layer));
1225
+ if (this._layerAppearance.layerStyleMayHaveChanged(changes)) {
1226
+ this._layerAppearance.syncFromLiveRecord(layer);
1220
1227
  }
1221
- if (changes.lineStyle) {
1222
- traits.lineType = layer.lineStyle;
1223
- }
1224
- if (changes.lineWeight !== undefined) {
1225
- traits.lineWeight = changes.lineWeight;
1226
- }
1227
- if (changes.transparency !== undefined) {
1228
- traits.transparency = changes.transparency;
1229
- }
1230
- traits.layer = layer.name; // always present
1231
- var materials = this._renderer.updateLayerMaterial(layer.name, traits);
1232
- updatedLayers.forEach(function (layer) {
1233
- for (var id in materials) {
1234
- var material = materials[id];
1235
- layer.updateMaterial(Number(id), material);
1236
- }
1237
- });
1238
1228
  if (this._entityDisplay.layerVisibilityMayHaveChanged(changes) &&
1239
1229
  AcTrLayer.isLayerVisible(this.toLayerInfo(layer))) {
1240
1230
  void this.convertMissingEntitiesOnLayer(layer.name);
@@ -1252,6 +1242,7 @@ var AcTrView2d = /** @class */ (function (_super) {
1252
1242
  var threeEntity = this.drawEntity(entity_1, true);
1253
1243
  if (threeEntity) {
1254
1244
  threeEntity.objectId = entity_1.objectId;
1245
+ threeEntity.syncDraw();
1255
1246
  this._scene.addTransientEntity(threeEntity);
1256
1247
  this._isDirty = true;
1257
1248
  }
@@ -1265,6 +1256,49 @@ var AcTrView2d = /** @class */ (function (_super) {
1265
1256
  this._scene.removeTransientEntity(objectId);
1266
1257
  this._isDirty = true;
1267
1258
  };
1259
+ /**
1260
+ * @inheritdoc
1261
+ */
1262
+ AcTrView2d.prototype.canCreateEntityPreview = function (entityIds) {
1263
+ return this._scene.canCreatePreview(entityIds);
1264
+ };
1265
+ /**
1266
+ * @inheritdoc
1267
+ */
1268
+ AcTrView2d.prototype.createEntityPreview = function (entityIds) {
1269
+ var handleId = this._scene.createPreview(entityIds);
1270
+ if (handleId) {
1271
+ this._isDirty = true;
1272
+ }
1273
+ return handleId;
1274
+ };
1275
+ /**
1276
+ * @inheritdoc
1277
+ */
1278
+ AcTrView2d.prototype.updateEntityPreview = function (handleId, matrix) {
1279
+ if (this._scene.updatePreview(handleId, AcTrMatrixUtil.createMatrix4(matrix))) {
1280
+ this._isDirty = true;
1281
+ }
1282
+ };
1283
+ /**
1284
+ * @inheritdoc
1285
+ */
1286
+ AcTrView2d.prototype.removeEntityPreview = function (handleId) {
1287
+ if (this._scene.removePreview(handleId)) {
1288
+ this._isDirty = true;
1289
+ }
1290
+ };
1291
+ /**
1292
+ * @inheritdoc
1293
+ */
1294
+ AcTrView2d.prototype.updateTransientPreviewTransforms = function (transforms) {
1295
+ if (this._scene.updateTransientPreviewTransforms(transforms.map(function (entry) { return ({
1296
+ objectId: entry.objectId,
1297
+ matrix: AcTrMatrixUtil.createMatrix4(entry.matrix)
1298
+ }); }))) {
1299
+ this._isDirty = true;
1300
+ }
1301
+ };
1268
1302
  /**
1269
1303
  * @inheritdoc
1270
1304
  */
@@ -1341,28 +1375,30 @@ var AcTrView2d = /** @class */ (function (_super) {
1341
1375
  this._scene.setEntityVisible(objectId, false);
1342
1376
  };
1343
1377
  /**
1344
- * @inheritdoc
1378
+ * Rebuilds scene geometry for entities whose shape or styling changed.
1379
+ *
1380
+ * Pure translations should use {@link translateEntity} instead.
1345
1381
  */
1346
1382
  AcTrView2d.prototype.updateEntity = function (entity) {
1347
1383
  var _this = this;
1348
- var entities = [];
1349
- if (Array.isArray(entity)) {
1350
- entities = entity;
1351
- }
1352
- else {
1353
- entities.push(entity);
1354
- }
1384
+ var entities = Array.isArray(entity) ? entity : [entity];
1385
+ var selectedIds = entities
1386
+ .map(function (item) { return item.objectId; })
1387
+ .filter(function (objectId) { return _this.selectionSet.has(objectId); });
1355
1388
  for (var i = 0; i < entities.length; ++i) {
1356
1389
  var entity_2 = entities[i];
1357
- var threeEntity = entity_2.worldDraw(this._renderer);
1358
- if (threeEntity) {
1359
- threeEntity.objectId = entity_2.objectId;
1360
- threeEntity.ownerId = entity_2.ownerId;
1361
- threeEntity.layerName = entity_2.layer;
1362
- threeEntity.visible = entity_2.visibility !== false;
1363
- this._scene.updateEntity(threeEntity);
1390
+ if (this._scene.hasEntity(entity_2.objectId)) {
1391
+ this._scene.removeEntity(entity_2.objectId);
1364
1392
  }
1365
1393
  }
1394
+ // Reconvert through the same path as initial load so block references are
1395
+ // split by layer correctly and deferred MTEXT/SHAPE geometry is drawn.
1396
+ void this.batchConvert(entities).then(function () {
1397
+ if (selectedIds.length > 0) {
1398
+ _this.highlight(selectedIds);
1399
+ }
1400
+ _this._gripManager.refresh();
1401
+ });
1366
1402
  this._isDirty = true;
1367
1403
  // Not sure why texture for image entity isn't updated even if 'isDirty' flag is already set to true.
1368
1404
  // So add one timeout event to set 'isDirty' flag to true again to make it work
@@ -1779,76 +1815,30 @@ var AcTrView2d = /** @class */ (function (_super) {
1779
1815
  return entity.worldDraw(this._renderer, delay);
1780
1816
  };
1781
1817
  /**
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).
1818
+ * Finishes geometry for a converted entity. Block groups always use
1819
+ * {@link AcTrGroup.syncDraw} to finalize deferred children. Progressive mode
1820
+ * defers MTEXT/SHAPE to async workers; non-progressive mode uses
1821
+ * {@link AcTrEntity.syncDraw}.
1785
1822
  */
1786
1823
  AcTrView2d.prototype.finishEntityGeometry = function (threeEntity, progressive) {
1787
1824
  return __awaiter(this, void 0, void 0, function () {
1788
1825
  return __generator(this, function (_a) {
1789
1826
  switch (_a.label) {
1790
1827
  case 0:
1828
+ if (threeEntity instanceof AcTrGroup) {
1829
+ threeEntity.syncDraw();
1830
+ return [2 /*return*/];
1831
+ }
1791
1832
  if (!progressive) return [3 /*break*/, 2];
1792
- return [4 /*yield*/, threeEntity.draw()];
1833
+ return [4 /*yield*/, threeEntity.asyncDraw()];
1793
1834
  case 1:
1794
1835
  _a.sent();
1795
1836
  return [2 /*return*/];
1796
1837
  case 2:
1797
- if (this.entityUsedSyncDraw(threeEntity)) {
1838
+ if (threeEntity.hasDrawableGeometry()) {
1798
1839
  return [2 /*return*/];
1799
1840
  }
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();
1841
+ threeEntity.syncDraw();
1852
1842
  return [2 /*return*/];
1853
1843
  }
1854
1844
  });
@@ -1911,11 +1901,11 @@ var AcTrView2d = /** @class */ (function (_super) {
1911
1901
  i = 0;
1912
1902
  _a.label = 1;
1913
1903
  case 1:
1914
- if (!(i < entities.length)) return [3 /*break*/, 13];
1904
+ if (!(i < entities.length)) return [3 /*break*/, 11];
1915
1905
  entity = entities[i];
1916
1906
  _a.label = 2;
1917
1907
  case 2:
1918
- _a.trys.push([2, 10, 11, 12]);
1908
+ _a.trys.push([2, 8, 9, 10]);
1919
1909
  // Skip the default paper-space viewport (`*Paper_Space`) entirely:
1920
1910
  // it is an AutoCAD-internal viewport that exists in every paper
1921
1911
  // layout and must not be drawn (would render a giant rectangle in
@@ -1929,20 +1919,20 @@ var AcTrView2d = /** @class */ (function (_super) {
1929
1919
  // parsers).
1930
1920
  if (entity instanceof AcDbViewport &&
1931
1921
  AcTrViewportView.isDefaultPaperSpaceViewport(entity)) {
1932
- return [3 /*break*/, 12];
1922
+ return [3 /*break*/, 10];
1933
1923
  }
1934
1924
  shouldConvert = options.forExport
1935
1925
  ? this._entityDisplay.shouldConvertForExport(entity)
1936
1926
  : this._entityDisplay.shouldConvert(entity);
1937
1927
  if (!shouldConvert) {
1938
- return [3 /*break*/, 12];
1928
+ return [3 /*break*/, 10];
1939
1929
  }
1940
1930
  threeEntity = this.drawEntity(entity, progressive);
1941
1931
  // Viewports may produce no border geometry (e.g. on a no-plot layer) while
1942
1932
  // still needing an AcTrViewportView for model content below.
1943
1933
  if (!threeEntity && !(entity instanceof AcDbViewport))
1944
- return [3 /*break*/, 12];
1945
- if (!threeEntity) return [3 /*break*/, 9];
1934
+ return [3 /*break*/, 10];
1935
+ if (!threeEntity) return [3 /*break*/, 7];
1946
1936
  threeEntity.objectId = entity.objectId;
1947
1937
  threeEntity.ownerId = entity.ownerId;
1948
1938
  threeEntity.layerName = entity.layer;
@@ -1951,39 +1941,33 @@ var AcTrView2d = /** @class */ (function (_super) {
1951
1941
  threeEntity.isOnTheSameLayer) {
1952
1942
  // Even when a block expands to a single layer bucket, children authored on
1953
1943
  // layer "0" still inherit the INSERT layer for ByLayer traits (color, etc.).
1954
- this.remapInheritedLayerObjects(threeEntity.children, '0', threeEntity.layerName);
1944
+ this._inheritedLayerMaterialMapper.remap(threeEntity.children, '0', threeEntity.layerName);
1955
1945
  }
1956
1946
  if (!(threeEntity instanceof AcTrGroup &&
1957
1947
  !threeEntity.isOnTheSameLayer)) return [3 /*break*/, 4];
1958
- return [4 /*yield*/, this.handleGroup(threeEntity)];
1948
+ return [4 /*yield*/, this.handleGroup(threeEntity, progressive)];
1959
1949
  case 3:
1960
1950
  _a.sent();
1961
- return [3 /*break*/, 9];
1951
+ return [3 /*break*/, 7];
1962
1952
  case 4:
1963
1953
  isExtendBbox = !(entity instanceof AcDbRay || entity instanceof AcDbXline);
1964
- if (!(threeEntity instanceof AcTrGroup)) return [3 /*break*/, 6];
1965
- return [4 /*yield*/, this.ensureGroupDrawableGeometry(threeEntity)];
1954
+ return [4 /*yield*/, this.finishEntityGeometry(threeEntity, progressive)];
1966
1955
  case 5:
1967
- _a.sent();
1968
- _a.label = 6;
1969
- case 6: return [4 /*yield*/, this.finishEntityGeometry(threeEntity, progressive)];
1970
- case 7:
1971
1956
  _a.sent();
1972
1957
  if (threeEntity instanceof AcTrGroup) {
1973
- ;
1974
- threeEntity.refreshWcsChildBoxesFromChildren();
1958
+ this.syncGroupSpatialBoundsForIndexing(threeEntity);
1975
1959
  }
1976
1960
  this._scene.addEntity(threeEntity, isExtendBbox);
1977
1961
  this.applySessionHiddenObjectState(entity.objectId);
1978
1962
  // Release memory occupied by this entity
1979
1963
  threeEntity.dispose();
1980
- if (!progressive) return [3 /*break*/, 9];
1964
+ if (!progressive) return [3 /*break*/, 7];
1981
1965
  this._isDirty = true;
1982
1966
  return [4 /*yield*/, this._progressiveOpenFit.afterGeometryBatch(function () { return _this.resolveLayoutFitBox(); }, i)];
1983
- case 8:
1967
+ case 6:
1984
1968
  _a.sent();
1985
- _a.label = 9;
1986
- case 9:
1969
+ _a.label = 7;
1970
+ case 7:
1987
1971
  if (entity instanceof AcDbViewport) {
1988
1972
  // Default paper-space viewport was already filtered out at the
1989
1973
  // top of the loop, so anything that reaches here is a real
@@ -2003,33 +1987,53 @@ var AcTrView2d = /** @class */ (function (_super) {
2003
1987
  if (fileName)
2004
1988
  this._missedImages.set(entity.objectId, fileName);
2005
1989
  }
2006
- return [3 /*break*/, 12];
2007
- case 10:
1990
+ return [3 /*break*/, 10];
1991
+ case 8:
2008
1992
  error_1 = _a.sent();
2009
1993
  log.error("[AcTrView2d] Failed to convert entity ".concat(entity.objectId, " (").concat(entity.type, "):"), error_1);
2010
- return [3 /*break*/, 12];
2011
- case 11:
1994
+ return [3 /*break*/, 10];
1995
+ case 9:
2012
1996
  this.decreaseNumOfEntitiesToProcess();
2013
1997
  return [7 /*endfinally*/];
2014
- case 12:
1998
+ case 10:
2015
1999
  ++i;
2016
2000
  return [3 /*break*/, 1];
2017
- case 13: return [2 /*return*/];
2001
+ case 11: return [2 /*return*/];
2018
2002
  }
2019
2003
  });
2020
2004
  });
2021
2005
  };
2022
- AcTrView2d.prototype.handleGroup = function (group) {
2006
+ /**
2007
+ * Rebuilds block-reference child boxes and aligns aggregate {@link AcTrGroup.wcsBbox}
2008
+ * with their union before spatial-index registration.
2009
+ */
2010
+ AcTrView2d.prototype.syncGroupSpatialBoundsForIndexing = function (group) {
2011
+ group.refreshWcsChildBoxesFromChildren();
2012
+ if (group.wcsChildBoxes.length === 0) {
2013
+ return;
2014
+ }
2015
+ var childBoxes = group.wcsChildBoxes.map(function (box) { return ({
2016
+ minX: box.minX,
2017
+ minY: box.minY,
2018
+ maxX: box.maxX,
2019
+ maxY: box.maxY,
2020
+ id: box.id
2021
+ }); });
2022
+ group.wcsBbox = unionGroupWcsChildBoxes(group);
2023
+ var userData = group.userData;
2024
+ userData.spatialIndexChildBoxes = childBoxes;
2025
+ };
2026
+ AcTrView2d.prototype.handleGroup = function (group, progressive) {
2023
2027
  return __awaiter(this, void 0, void 0, function () {
2024
- var children, objectsGroupByLayer, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, groupChildBoxes;
2028
+ var children, objectsGroupByLayer, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, groupChildBoxes, aggregateSpatialBbox;
2025
2029
  var e_6, _a;
2026
2030
  var _this = this;
2027
2031
  return __generator(this, function (_b) {
2028
2032
  switch (_b.label) {
2029
- case 0: return [4 /*yield*/, this.ensureGroupDrawableGeometry(group)];
2033
+ case 0: return [4 /*yield*/, this.finishEntityGeometry(group, progressive)];
2030
2034
  case 1:
2031
2035
  _b.sent();
2032
- group.refreshWcsChildBoxesFromChildren();
2036
+ this.syncGroupSpatialBoundsForIndexing(group);
2033
2037
  children = group.children;
2034
2038
  objectsGroupByLayer = new Map();
2035
2039
  children.forEach(function (child) {
@@ -2082,6 +2086,12 @@ var AcTrView2d = /** @class */ (function (_super) {
2082
2086
  maxY: box.maxY,
2083
2087
  id: box.id
2084
2088
  }); });
2089
+ aggregateSpatialBbox = groupChildBoxes.length > 0
2090
+ ? unionGroupWcsChildBoxes(group)
2091
+ : group.wcsBbox.clone();
2092
+ if (groupChildBoxes.length > 0) {
2093
+ group.wcsBbox = aggregateSpatialBbox.clone();
2094
+ }
2085
2095
  objectsGroupByLayer.forEach(function (objects, layerName) {
2086
2096
  // AutoCAD block rule: entities authored on layer "0" inherit the INSERT's layer.
2087
2097
  // Non-zero layers keep their original layer name.
@@ -2089,7 +2099,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2089
2099
  // Keep runtime layer metadata/material cache aligned with the inherited layer so
2090
2100
  // later layer style edits (color, linetype, lineweight, transparency) target this
2091
2101
  // object set correctly.
2092
- _this.remapInheritedLayerObjects(objects, layerName, effectiveLayerName);
2102
+ _this._inheritedLayerMaterialMapper.remap(objects, layerName, effectiveLayerName);
2093
2103
  // One INSERT can expand to children from multiple layers. Here we create one
2094
2104
  // render entity per layer bucket but preserve the INSERT object id for all
2095
2105
  // buckets, so selection/highlight still maps back to the same database object.
@@ -2101,7 +2111,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2101
2111
  // If block-definition entities are on layer "0", this bucket now uses the layer
2102
2112
  // of the block reference itself (effectiveLayerName).
2103
2113
  entity.layerName = effectiveLayerName;
2104
- entity.wcsBbox = group.wcsBbox.clone();
2114
+ entity.wcsBbox = aggregateSpatialBbox.clone();
2105
2115
  var entityUserData = entity.userData;
2106
2116
  entityUserData.spatialIndexChildBoxes = groupChildBoxes;
2107
2117
  // Important:
@@ -2110,7 +2120,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2110
2120
  for (var i = 0; i < objects.length; i++) {
2111
2121
  entity.add(objects[i]);
2112
2122
  }
2113
- _this.refreshTextMaterialsInObjectTree(entity);
2123
+ _this._layerAppearance.refreshTextMaterialsInObjectTree(entity);
2114
2124
  _this._scene.addEntity(entity, true);
2115
2125
  _this.applySessionHiddenObjectState(groupObjectId);
2116
2126
  entity.dispose();
@@ -2127,133 +2137,6 @@ var AcTrView2d = /** @class */ (function (_super) {
2127
2137
  });
2128
2138
  });
2129
2139
  };
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);
2141
- }
2142
- });
2143
- };
2144
- /**
2145
- * Remaps layer metadata/material bindings from a source layer to the effective render layer.
2146
- *
2147
- * During block decomposition, one INSERT may be split into multiple layer buckets. For
2148
- * children authored on layer "0", AutoCAD requires inheriting the INSERT's own layer.
2149
- * This method applies that inheritance by mutating each child's `userData.layerName` and
2150
- * re-binding materials via renderer cache, so subsequent layer-level style changes still
2151
- * hit the correct material instances.
2152
- *
2153
- * @param objects - Root objects in the current layer bucket to traverse and remap.
2154
- * @param sourceLayerName - Layer name found in block definition before inheritance.
2155
- * @param effectiveLayerName - Final layer name used by rendering and style updates.
2156
- */
2157
- AcTrView2d.prototype.remapInheritedLayerObjects = function (objects, sourceLayerName, effectiveLayerName) {
2158
- var e_7, _a;
2159
- var _this = this;
2160
- if (sourceLayerName === effectiveLayerName)
2161
- return;
2162
- var renderer = this._renderer;
2163
- var layerTraits = this.getEffectiveLayerTraits(effectiveLayerName);
2164
- try {
2165
- for (var objects_1 = __values(objects), objects_1_1 = objects_1.next(); !objects_1_1.done; objects_1_1 = objects_1.next()) {
2166
- var object = objects_1_1.value;
2167
- object.traverse(function (child) {
2168
- var inheritsInsertLayer = child.userData.layerName === sourceLayerName;
2169
- if (inheritsInsertLayer) {
2170
- child.userData.layerName = effectiveLayerName;
2171
- }
2172
- if (!('material' in child))
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;
2178
- var material = child.material;
2179
- if (Array.isArray(material)) {
2180
- var materials = material;
2181
- child.material = materials.map(function (entry) {
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);
2187
- });
2188
- return;
2189
- }
2190
- if (!_this.shouldRemapInheritedLayerMaterial(material, sourceLayerName)) {
2191
- return;
2192
- }
2193
- var remappedMaterial = renderer.getLayerBoundMaterial(_this.promoteLayerZeroByLayerColor(material, sourceLayerName), effectiveLayerName, layerTraits);
2194
- if (!remappedMaterial) {
2195
- return;
2196
- }
2197
- child.material = remappedMaterial;
2198
- child.userData.styleMaterialId = remappedMaterial.id;
2199
- });
2200
- }
2201
- }
2202
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
2203
- finally {
2204
- try {
2205
- if (objects_1_1 && !objects_1_1.done && (_a = objects_1.return)) _a.call(objects_1);
2206
- }
2207
- finally { if (e_7) throw e_7.error; }
2208
- }
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
- };
2229
- /**
2230
- * Some DXF conversion paths lose `isByLayerColor` on layer-0 block contents while still
2231
- * retaining other ByLayer markers (lineType/lineWeight/transparency). For AutoCAD-compatible
2232
- * INSERT inheritance, treat such colors as inheritable when remapping from layer "0".
2233
- */
2234
- AcTrView2d.prototype.promoteLayerZeroByLayerColor = function (material, sourceLayerName) {
2235
- var metadata = getMaterialMetadata(material);
2236
- var hasAnyOtherByLayerBinding = hasByLayerBinding(metadata) && metadata.isByLayerColor !== true;
2237
- if (sourceLayerName === '0' && hasAnyOtherByLayerBinding) {
2238
- setMaterialMetadata(material, { isByLayerColor: true });
2239
- }
2240
- return material;
2241
- };
2242
- /**
2243
- * Builds the resolved layer traits used when layer-0 block content inherits an INSERT layer.
2244
- */
2245
- AcTrView2d.prototype.getEffectiveLayerTraits = function (layerName) {
2246
- var layer = AcApDocManager.instance.curDocument.database.tables.layerTable.getAt(layerName);
2247
- if (!layer)
2248
- return undefined;
2249
- return {
2250
- layer: layer.name,
2251
- color: layer.color.clone(),
2252
- lineType: layer.lineStyle,
2253
- lineWeight: layer.lineWeight,
2254
- transparency: layer.transparency
2255
- };
2256
- };
2257
2140
  AcTrView2d.prototype.decreaseNumOfEntitiesToProcess = function () {
2258
2141
  this._numOfEntitiesToProcess--;
2259
2142
  if (this._numOfEntitiesToProcess < 0) {