@mlightcad/cad-simple-viewer 1.2.2 → 1.2.3

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 (202) hide show
  1. package/dist/__vite-browser-external-l0sNRNKZ-l0sNRNKZ.js +1 -0
  2. package/dist/index.js +40205 -0
  3. package/dist/index.umd.cjs +333 -0
  4. package/dist/libredwg-parser-worker.js +15458 -0
  5. package/dist/mtext-renderer-worker.js +29930 -0
  6. package/lib/app/AcApContext.d.ts +57 -0
  7. package/lib/app/AcApContext.d.ts.map +1 -0
  8. package/lib/app/AcApContext.js +106 -0
  9. package/lib/app/AcApContext.js.map +1 -0
  10. package/lib/app/AcApDocManager.d.ts +291 -0
  11. package/lib/app/AcApDocManager.d.ts.map +1 -0
  12. package/lib/app/AcApDocManager.js +498 -0
  13. package/lib/app/AcApDocManager.js.map +1 -0
  14. package/lib/app/AcApDocument.d.ts +101 -0
  15. package/lib/app/AcApDocument.d.ts.map +1 -0
  16. package/lib/app/AcApDocument.js +237 -0
  17. package/lib/app/AcApDocument.js.map +1 -0
  18. package/lib/app/AcApFontLoader.d.ts +54 -0
  19. package/lib/app/AcApFontLoader.d.ts.map +1 -0
  20. package/lib/app/AcApFontLoader.js +151 -0
  21. package/lib/app/AcApFontLoader.js.map +1 -0
  22. package/lib/app/AcApGlobalFunc.d.ts +26 -0
  23. package/lib/app/AcApGlobalFunc.d.ts.map +1 -0
  24. package/lib/app/AcApGlobalFunc.js +66 -0
  25. package/lib/app/AcApGlobalFunc.js.map +1 -0
  26. package/lib/app/AcApSettingManager.d.ts +232 -0
  27. package/lib/app/AcApSettingManager.d.ts.map +1 -0
  28. package/lib/app/AcApSettingManager.js +283 -0
  29. package/lib/app/AcApSettingManager.js.map +1 -0
  30. package/lib/app/index.d.ts +6 -0
  31. package/lib/app/index.d.ts.map +1 -0
  32. package/lib/app/index.js +6 -0
  33. package/lib/app/index.js.map +1 -0
  34. package/lib/command/AcApConvertToSvgCmd.d.ts +32 -0
  35. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -0
  36. package/lib/command/AcApConvertToSvgCmd.js +56 -0
  37. package/lib/command/AcApConvertToSvgCmd.js.map +1 -0
  38. package/lib/command/AcApOpenCmd.d.ts +37 -0
  39. package/lib/command/AcApOpenCmd.d.ts.map +1 -0
  40. package/lib/command/AcApOpenCmd.js +60 -0
  41. package/lib/command/AcApOpenCmd.js.map +1 -0
  42. package/lib/command/AcApPanCmd.d.ts +31 -0
  43. package/lib/command/AcApPanCmd.d.ts.map +1 -0
  44. package/lib/command/AcApPanCmd.js +55 -0
  45. package/lib/command/AcApPanCmd.js.map +1 -0
  46. package/lib/command/AcApQNewCmd.d.ts +32 -0
  47. package/lib/command/AcApQNewCmd.d.ts.map +1 -0
  48. package/lib/command/AcApQNewCmd.js +56 -0
  49. package/lib/command/AcApQNewCmd.js.map +1 -0
  50. package/lib/command/AcApRegenCmd.d.ts +21 -0
  51. package/lib/command/AcApRegenCmd.d.ts.map +1 -0
  52. package/lib/command/AcApRegenCmd.js +45 -0
  53. package/lib/command/AcApRegenCmd.js.map +1 -0
  54. package/lib/command/AcApSelectCmd.d.ts +32 -0
  55. package/lib/command/AcApSelectCmd.d.ts.map +1 -0
  56. package/lib/command/AcApSelectCmd.js +56 -0
  57. package/lib/command/AcApSelectCmd.js.map +1 -0
  58. package/lib/command/AcApSvgConvertor.d.ts +53 -0
  59. package/lib/command/AcApSvgConvertor.d.ts.map +1 -0
  60. package/lib/command/AcApSvgConvertor.js +103 -0
  61. package/lib/command/AcApSvgConvertor.js.map +1 -0
  62. package/lib/command/AcApZoomCmd.d.ts +35 -0
  63. package/lib/command/AcApZoomCmd.d.ts.map +1 -0
  64. package/lib/command/AcApZoomCmd.js +57 -0
  65. package/lib/command/AcApZoomCmd.js.map +1 -0
  66. package/lib/command/AcApZoomToBoxCmd.d.ts +68 -0
  67. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -0
  68. package/lib/command/AcApZoomToBoxCmd.js +158 -0
  69. package/lib/command/AcApZoomToBoxCmd.js.map +1 -0
  70. package/lib/command/index.d.ts +11 -0
  71. package/lib/command/index.d.ts.map +1 -0
  72. package/lib/command/index.js +11 -0
  73. package/lib/command/index.js.map +1 -0
  74. package/lib/editor/command/AcEdCommand.d.ts +151 -0
  75. package/lib/editor/command/AcEdCommand.d.ts.map +1 -0
  76. package/lib/editor/command/AcEdCommand.js +164 -0
  77. package/lib/editor/command/AcEdCommand.js.map +1 -0
  78. package/lib/editor/command/AcEdCommandIterator.d.ts +36 -0
  79. package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -0
  80. package/lib/editor/command/AcEdCommandIterator.js +65 -0
  81. package/lib/editor/command/AcEdCommandIterator.js.map +1 -0
  82. package/lib/editor/command/AcEdCommandStack.d.ts +120 -0
  83. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -0
  84. package/lib/editor/command/AcEdCommandStack.js +235 -0
  85. package/lib/editor/command/AcEdCommandStack.js.map +1 -0
  86. package/lib/editor/command/index.d.ts +3 -0
  87. package/lib/editor/command/index.d.ts.map +1 -0
  88. package/lib/editor/command/index.js +3 -0
  89. package/lib/editor/command/index.js.map +1 -0
  90. package/lib/editor/global/AcEdConditionWaiter.d.ts +51 -0
  91. package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -0
  92. package/lib/editor/global/AcEdConditionWaiter.js +87 -0
  93. package/lib/editor/global/AcEdConditionWaiter.js.map +1 -0
  94. package/lib/editor/global/AcEdGlobalFunc.d.ts +8 -0
  95. package/lib/editor/global/AcEdGlobalFunc.d.ts.map +1 -0
  96. package/lib/editor/global/AcEdGlobalFunc.js +14 -0
  97. package/lib/editor/global/AcEdGlobalFunc.js.map +1 -0
  98. package/lib/editor/global/AcEdMessage.d.ts +5 -0
  99. package/lib/editor/global/AcEdMessage.d.ts.map +1 -0
  100. package/lib/editor/global/AcEdMessage.js +6 -0
  101. package/lib/editor/global/AcEdMessage.js.map +1 -0
  102. package/lib/editor/global/eventBus.d.ts +103 -0
  103. package/lib/editor/global/eventBus.d.ts.map +1 -0
  104. package/lib/editor/global/eventBus.js +41 -0
  105. package/lib/editor/global/eventBus.js.map +1 -0
  106. package/lib/editor/global/index.d.ts +4 -0
  107. package/lib/editor/global/index.d.ts.map +1 -0
  108. package/lib/editor/global/index.js +4 -0
  109. package/lib/editor/global/index.js.map +1 -0
  110. package/lib/editor/index.d.ts +5 -0
  111. package/lib/editor/index.d.ts.map +1 -0
  112. package/lib/editor/index.js +5 -0
  113. package/lib/editor/index.js.map +1 -0
  114. package/lib/editor/input/AcEdBaseInput.d.ts +89 -0
  115. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -0
  116. package/lib/editor/input/AcEdBaseInput.js +166 -0
  117. package/lib/editor/input/AcEdBaseInput.js.map +1 -0
  118. package/lib/editor/input/AcEdBoxSelector.d.ts +108 -0
  119. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -0
  120. package/lib/editor/input/AcEdBoxSelector.js +220 -0
  121. package/lib/editor/input/AcEdBoxSelector.js.map +1 -0
  122. package/lib/editor/input/AcEdCursorManager.d.ts +130 -0
  123. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -0
  124. package/lib/editor/input/AcEdCursorManager.js +155 -0
  125. package/lib/editor/input/AcEdCursorManager.js.map +1 -0
  126. package/lib/editor/input/AcEdInputPoint.d.ts +51 -0
  127. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -0
  128. package/lib/editor/input/AcEdInputPoint.js +78 -0
  129. package/lib/editor/input/AcEdInputPoint.js.map +1 -0
  130. package/lib/editor/input/AcEdJig.d.ts +180 -0
  131. package/lib/editor/input/AcEdJig.d.ts.map +1 -0
  132. package/lib/editor/input/AcEdJig.js +256 -0
  133. package/lib/editor/input/AcEdJig.js.map +1 -0
  134. package/lib/editor/input/AcEdJigLoop.d.ts +63 -0
  135. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -0
  136. package/lib/editor/input/AcEdJigLoop.js +91 -0
  137. package/lib/editor/input/AcEdJigLoop.js.map +1 -0
  138. package/lib/editor/input/AcEdSelectionSet.d.ts +146 -0
  139. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -0
  140. package/lib/editor/input/AcEdSelectionSet.js +179 -0
  141. package/lib/editor/input/AcEdSelectionSet.js.map +1 -0
  142. package/lib/editor/input/AcEditor.d.ts +111 -0
  143. package/lib/editor/input/AcEditor.d.ts.map +1 -0
  144. package/lib/editor/input/AcEditor.js +183 -0
  145. package/lib/editor/input/AcEditor.js.map +1 -0
  146. package/lib/editor/input/index.d.ts +5 -0
  147. package/lib/editor/input/index.d.ts.map +1 -0
  148. package/lib/editor/input/index.js +5 -0
  149. package/lib/editor/input/index.js.map +1 -0
  150. package/lib/editor/view/AcEdBaseView.d.ts +457 -0
  151. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -0
  152. package/lib/editor/view/AcEdBaseView.js +349 -0
  153. package/lib/editor/view/AcEdBaseView.js.map +1 -0
  154. package/lib/editor/view/AcEdLayerInfo.d.ts +21 -0
  155. package/lib/editor/view/AcEdLayerInfo.d.ts.map +1 -0
  156. package/lib/editor/view/AcEdLayerInfo.js +2 -0
  157. package/lib/editor/view/AcEdLayerInfo.js.map +1 -0
  158. package/lib/editor/view/index.d.ts +3 -0
  159. package/lib/editor/view/index.d.ts.map +1 -0
  160. package/lib/editor/view/index.js +3 -0
  161. package/lib/editor/view/index.js.map +1 -0
  162. package/lib/index.d.ts +5 -0
  163. package/lib/index.d.ts.map +1 -0
  164. package/lib/index.js +5 -0
  165. package/lib/index.js.map +1 -0
  166. package/lib/util/AcTrGeometryUtil.d.ts +92 -0
  167. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -0
  168. package/lib/util/AcTrGeometryUtil.js +109 -0
  169. package/lib/util/AcTrGeometryUtil.js.map +1 -0
  170. package/lib/util/index.d.ts +2 -0
  171. package/lib/util/index.d.ts.map +1 -0
  172. package/lib/util/index.js +2 -0
  173. package/lib/util/index.js.map +1 -0
  174. package/lib/view/AcTrLayer.d.ts +132 -0
  175. package/lib/view/AcTrLayer.d.ts.map +1 -0
  176. package/lib/view/AcTrLayer.js +199 -0
  177. package/lib/view/AcTrLayer.js.map +1 -0
  178. package/lib/view/AcTrLayout.d.ts +218 -0
  179. package/lib/view/AcTrLayout.d.ts.map +1 -0
  180. package/lib/view/AcTrLayout.js +437 -0
  181. package/lib/view/AcTrLayout.js.map +1 -0
  182. package/lib/view/AcTrLayoutView.d.ts +115 -0
  183. package/lib/view/AcTrLayoutView.d.ts.map +1 -0
  184. package/lib/view/AcTrLayoutView.js +200 -0
  185. package/lib/view/AcTrLayoutView.js.map +1 -0
  186. package/lib/view/AcTrLayoutViewManager.d.ts +89 -0
  187. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -0
  188. package/lib/view/AcTrLayoutViewManager.js +118 -0
  189. package/lib/view/AcTrLayoutViewManager.js.map +1 -0
  190. package/lib/view/AcTrScene.d.ts +162 -0
  191. package/lib/view/AcTrScene.d.ts.map +1 -0
  192. package/lib/view/AcTrScene.js +370 -0
  193. package/lib/view/AcTrScene.js.map +1 -0
  194. package/lib/view/AcTrView2d.d.ts +262 -0
  195. package/lib/view/AcTrView2d.d.ts.map +1 -0
  196. package/lib/view/AcTrView2d.js +772 -0
  197. package/lib/view/AcTrView2d.js.map +1 -0
  198. package/lib/view/index.d.ts +2 -0
  199. package/lib/view/index.d.ts.map +1 -0
  200. package/lib/view/index.js +2 -0
  201. package/lib/view/index.js.map +1 -0
  202. package/package.json +3 -3
@@ -0,0 +1,132 @@
1
+ import { AcDbObjectId } from '@mlightcad/data-model';
2
+ import { AcTrBatchedGroup, AcTrBatchedGroupStats, AcTrEntity } from '@mlightcad/three-renderer';
3
+ import * as THREE from 'three';
4
+ /**
5
+ * Statistics for a CAD layer including name and batched rendering metrics.
6
+ *
7
+ * Extends the standard batched group statistics with layer-specific information.
8
+ */
9
+ export type AcTrLayerStats = AcTrBatchedGroupStats & {
10
+ /** The name of the layer */
11
+ name: string;
12
+ };
13
+ /**
14
+ * Represents a CAD layer for organizing and rendering entities in Three.js.
15
+ *
16
+ * This class manages a collection of CAD entities that belong to the same logical layer.
17
+ * It provides:
18
+ * - Entity organization and grouping
19
+ * - Layer visibility control
20
+ * - Efficient batched rendering through Three.js groups
21
+ * - Performance monitoring and statistics
22
+ *
23
+ * ## Technical Notes
24
+ * Unlike Three.js built-in layers (which only support 32 layers), this implementation
25
+ * uses Three.js groups to represent AutoCAD layers, allowing unlimited layer support.
26
+ * Each AutoCAD layer corresponds to one Three.js group containing all entities.
27
+ *
28
+ * ## Performance Benefits
29
+ * - Batched rendering reduces draw calls
30
+ * - Efficient visibility toggling for entire layers
31
+ * - Optimized entity grouping for better GPU performance
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a new layer
36
+ * const layer = new AcTrLayer('Dimensions');
37
+ *
38
+ * // Add entities to the layer
39
+ * const line = new AcTrLine(startPoint, endPoint);
40
+ * layer.add(line);
41
+ *
42
+ * // Control layer visibility
43
+ * layer.visible = false; // Hide all entities in this layer
44
+ *
45
+ * // Get layer statistics
46
+ * const stats = layer.stats;
47
+ * console.log(`Layer ${stats.name} has ${stats.entityCount} entities`);
48
+ * ```
49
+ */
50
+ export declare class AcTrLayer {
51
+ /**
52
+ * Layer name
53
+ */
54
+ private _name;
55
+ /**
56
+ * This group contains all entities in this layer
57
+ */
58
+ private _group;
59
+ /**
60
+ * Construct one instance of this class
61
+ * @param name Input layer name
62
+ */
63
+ constructor(name: string);
64
+ /**
65
+ * Layer name
66
+ */
67
+ get name(): string;
68
+ set name(value: string);
69
+ get visible(): boolean;
70
+ set visible(value: boolean);
71
+ get internalObject(): AcTrBatchedGroup;
72
+ /**
73
+ * The statistics of this layer
74
+ */
75
+ get stats(): AcTrLayerStats;
76
+ /**
77
+ * The number of entities stored in this layer
78
+ */
79
+ get entityCount(): number;
80
+ /**
81
+ * Re-render points with latest point style settings
82
+ * @param displayMode Input display mode of points
83
+ */
84
+ rerenderPoints(displayMode: number): void;
85
+ /**
86
+ * Return true if this layer contains the entity with the specified object id. Otherwise, return false.
87
+ * @param objectId Input the object id of one entity
88
+ * @returns Return true if this layer contains the entity with the specified object id. Otherwise,
89
+ * return false.
90
+ */
91
+ hasEntity(objectId: AcDbObjectId): boolean;
92
+ /**
93
+ * Add one AutoCAD entity into this layer.
94
+ * @param entity Input AutoCAD entity to be added into this layer.
95
+ */
96
+ addEntity(entity: AcTrEntity): void;
97
+ /**
98
+ * Return true if the object with the specified object id is intersected with the ray by using raycast.
99
+ * @param objectId Input object id of object to check for intersection with the ray.
100
+ * @param raycaster Input raycaster to check intersection
101
+ */
102
+ isIntersectWith(objectId: string, raycaster: THREE.Raycaster): boolean;
103
+ /**
104
+ * Remove the specified entity from this layer.
105
+ * @param objectId Input the object id of the entity to remove
106
+ * @returns Return true if remove the specified entity successfully. Otherwise, return false.
107
+ */
108
+ remove(_objectId: AcDbObjectId): boolean;
109
+ /**
110
+ * Update the specified entity in this layer.
111
+ * @param entity Input the entity to update
112
+ * @returns Return true if update the specified entity successfully. Otherwise, return false.
113
+ */
114
+ update(entity: AcTrEntity): boolean;
115
+ /**
116
+ * Hover the specified entities
117
+ */
118
+ hover(ids: AcDbObjectId[]): void;
119
+ /**
120
+ * Unhover the specified entities
121
+ */
122
+ unhover(ids: AcDbObjectId[]): void;
123
+ /**
124
+ * Select the specified entities
125
+ */
126
+ select(ids: AcDbObjectId[]): void;
127
+ /**
128
+ * Unselect the specified entities
129
+ */
130
+ unselect(ids: AcDbObjectId[]): void;
131
+ }
132
+ //# sourceMappingURL=AcTrLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcTrLayer.d.ts","sourceRoot":"","sources":["../../src/view/AcTrLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACX,MAAM,2BAA2B,CAA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Y,EAAE;CAK7B"}
@@ -0,0 +1,199 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { AcTrBatchedGroup } from '@mlightcad/three-renderer';
13
+ /**
14
+ * Represents a CAD layer for organizing and rendering entities in Three.js.
15
+ *
16
+ * This class manages a collection of CAD entities that belong to the same logical layer.
17
+ * It provides:
18
+ * - Entity organization and grouping
19
+ * - Layer visibility control
20
+ * - Efficient batched rendering through Three.js groups
21
+ * - Performance monitoring and statistics
22
+ *
23
+ * ## Technical Notes
24
+ * Unlike Three.js built-in layers (which only support 32 layers), this implementation
25
+ * uses Three.js groups to represent AutoCAD layers, allowing unlimited layer support.
26
+ * Each AutoCAD layer corresponds to one Three.js group containing all entities.
27
+ *
28
+ * ## Performance Benefits
29
+ * - Batched rendering reduces draw calls
30
+ * - Efficient visibility toggling for entire layers
31
+ * - Optimized entity grouping for better GPU performance
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Create a new layer
36
+ * const layer = new AcTrLayer('Dimensions');
37
+ *
38
+ * // Add entities to the layer
39
+ * const line = new AcTrLine(startPoint, endPoint);
40
+ * layer.add(line);
41
+ *
42
+ * // Control layer visibility
43
+ * layer.visible = false; // Hide all entities in this layer
44
+ *
45
+ * // Get layer statistics
46
+ * const stats = layer.stats;
47
+ * console.log(`Layer ${stats.name} has ${stats.entityCount} entities`);
48
+ * ```
49
+ */
50
+ var AcTrLayer = /** @class */ (function () {
51
+ /**
52
+ * Construct one instance of this class
53
+ * @param name Input layer name
54
+ */
55
+ function AcTrLayer(name) {
56
+ this._group = new AcTrBatchedGroup();
57
+ this._name = name;
58
+ }
59
+ Object.defineProperty(AcTrLayer.prototype, "name", {
60
+ /**
61
+ * Layer name
62
+ */
63
+ get: function () {
64
+ return this._name;
65
+ },
66
+ set: function (value) {
67
+ this._name = value;
68
+ },
69
+ enumerable: false,
70
+ configurable: true
71
+ });
72
+ Object.defineProperty(AcTrLayer.prototype, "visible", {
73
+ get: function () {
74
+ return this._group.visible;
75
+ },
76
+ set: function (value) {
77
+ this._group.visible = value;
78
+ },
79
+ enumerable: false,
80
+ configurable: true
81
+ });
82
+ Object.defineProperty(AcTrLayer.prototype, "internalObject", {
83
+ get: function () {
84
+ return this._group;
85
+ },
86
+ enumerable: false,
87
+ configurable: true
88
+ });
89
+ Object.defineProperty(AcTrLayer.prototype, "stats", {
90
+ /**
91
+ * The statistics of this layer
92
+ */
93
+ get: function () {
94
+ var batchedGroupStats = this._group.stats;
95
+ return __assign({ name: this._name }, batchedGroupStats);
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ Object.defineProperty(AcTrLayer.prototype, "entityCount", {
101
+ /**
102
+ * The number of entities stored in this layer
103
+ */
104
+ get: function () {
105
+ return this._group.entityCount;
106
+ },
107
+ enumerable: false,
108
+ configurable: true
109
+ });
110
+ /**
111
+ * Re-render points with latest point style settings
112
+ * @param displayMode Input display mode of points
113
+ */
114
+ AcTrLayer.prototype.rerenderPoints = function (displayMode) {
115
+ this._group.rerenderPoints(displayMode);
116
+ };
117
+ /**
118
+ * Return true if this layer contains the entity with the specified object id. Otherwise, return false.
119
+ * @param objectId Input the object id of one entity
120
+ * @returns Return true if this layer contains the entity with the specified object id. Otherwise,
121
+ * return false.
122
+ */
123
+ AcTrLayer.prototype.hasEntity = function (objectId) {
124
+ return this._group.hasEntity(objectId);
125
+ };
126
+ /**
127
+ * Add one AutoCAD entity into this layer.
128
+ * @param entity Input AutoCAD entity to be added into this layer.
129
+ */
130
+ AcTrLayer.prototype.addEntity = function (entity) {
131
+ this._group.addEntity(entity);
132
+ };
133
+ /**
134
+ * Return true if the object with the specified object id is intersected with the ray by using raycast.
135
+ * @param objectId Input object id of object to check for intersection with the ray.
136
+ * @param raycaster Input raycaster to check intersection
137
+ */
138
+ AcTrLayer.prototype.isIntersectWith = function (objectId, raycaster) {
139
+ return this._group.isIntersectWith(objectId, raycaster);
140
+ };
141
+ /**
142
+ * Remove the specified entity from this layer.
143
+ * @param objectId Input the object id of the entity to remove
144
+ * @returns Return true if remove the specified entity successfully. Otherwise, return false.
145
+ */
146
+ AcTrLayer.prototype.remove = function (_objectId) {
147
+ // TODO: Finish it
148
+ throw new Error('Not implemented yet!');
149
+ };
150
+ /**
151
+ * Update the specified entity in this layer.
152
+ * @param entity Input the entity to update
153
+ * @returns Return true if update the specified entity successfully. Otherwise, return false.
154
+ */
155
+ AcTrLayer.prototype.update = function (entity) {
156
+ // TODO: Finish it
157
+ this._group.add(entity);
158
+ return true;
159
+ };
160
+ /**
161
+ * Hover the specified entities
162
+ */
163
+ AcTrLayer.prototype.hover = function (ids) {
164
+ var _this = this;
165
+ ids.forEach(function (id) {
166
+ _this._group.hover(id);
167
+ });
168
+ };
169
+ /**
170
+ * Unhover the specified entities
171
+ */
172
+ AcTrLayer.prototype.unhover = function (ids) {
173
+ var _this = this;
174
+ ids.forEach(function (id) {
175
+ _this._group.unhover(id);
176
+ });
177
+ };
178
+ /**
179
+ * Select the specified entities
180
+ */
181
+ AcTrLayer.prototype.select = function (ids) {
182
+ var _this = this;
183
+ ids.forEach(function (id) {
184
+ _this._group.select(id);
185
+ });
186
+ };
187
+ /**
188
+ * Unselect the specified entities
189
+ */
190
+ AcTrLayer.prototype.unselect = function (ids) {
191
+ var _this = this;
192
+ ids.forEach(function (id) {
193
+ _this._group.unselect(id);
194
+ });
195
+ };
196
+ return AcTrLayer;
197
+ }());
198
+ export { AcTrLayer };
199
+ //# sourceMappingURL=AcTrLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcTrLayer.js","sourceRoot":"","sources":["../../src/view/AcTrLayer.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EACL,gBAAgB,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M,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,gBAAC;AAAD,CAAC,AArJD,IAqJC"}
@@ -0,0 +1,218 @@
1
+ import { AcDbObjectId, AcGeBox2d, AcGeBox3d } from '@mlightcad/data-model';
2
+ import { AcTrEntity, AcTrObject } from '@mlightcad/three-renderer';
3
+ import * as THREE from 'three';
4
+ import { AcEdLayerInfo, AcEdSpatialQueryResultItem } from '../editor';
5
+ import { AcTrLayer, AcTrLayerStats } from './AcTrLayer';
6
+ /**
7
+ * Interface representing statistics for a layout.
8
+ * Provides detailed information about the layout's content including
9
+ * layer statistics and memory usage breakdown.
10
+ */
11
+ export interface AcTrLayoutStats {
12
+ /** Statistics for each layer in the layout */
13
+ layers: AcTrLayerStats[];
14
+ /** Summary statistics for the entire layout */
15
+ summary: {
16
+ /** Total number of entities across all layers */
17
+ entityCount: number;
18
+ /** Memory usage breakdown by object type */
19
+ totalSize: {
20
+ /** Memory used by line geometries (bytes) */
21
+ line: number;
22
+ /** Memory used by mesh geometries (bytes) */
23
+ mesh: number;
24
+ /** Memory used by point geometries (bytes) */
25
+ point: number;
26
+ /** Total geometry memory usage (bytes) */
27
+ geometry: number;
28
+ /** Memory used by entity mappings (bytes) */
29
+ mapping: number;
30
+ };
31
+ };
32
+ }
33
+ /**
34
+ * This class represents objects contained in one AutoCAD layout (model space or paper space).
35
+ *
36
+ * A layout manages the organization and rendering of CAD entities within a specific coordinate space.
37
+ * It provides functionality for:
38
+ * - Managing entities organized by layers
39
+ * - Spatial indexing for efficient entity queries
40
+ * - Bounding box management for view operations
41
+ * - Entity selection and highlighting
42
+ * - Memory usage tracking and statistics
43
+ *
44
+ * Layouts use a spatial index (R-tree) for fast entity lookup operations and maintain
45
+ * a hierarchical structure where entities are grouped by layers for efficient rendering
46
+ * and visibility management.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const layout = new AcTrLayout();
51
+ * layout.addEntity(entity);
52
+ * const entities = layout.search(boundingBox);
53
+ * layout.select(['entity1', 'entity2']);
54
+ * ```
55
+ */
56
+ export declare class AcTrLayout {
57
+ /** The group that contains all entities in this layout */
58
+ private _group;
59
+ /** Spatial index tree for efficient entity queries */
60
+ private _indexTree;
61
+ /** Bounding box containing all entities in this layout */
62
+ private _box;
63
+ /** Map of layers indexed by layer name */
64
+ private _layers;
65
+ /** Optional object for displaying snap points */
66
+ private _snapPointsObject?;
67
+ /**
68
+ * Creates a new layout instance.
69
+ * Initializes the layout with empty collections and a spatial index.
70
+ */
71
+ constructor();
72
+ /**
73
+ * The internal THREE.js object to use by scene. This is internally used only. Try to avoid using it.
74
+ * @internal
75
+ */
76
+ get internalObject(): THREE.Group<THREE.Object3DEventMap>;
77
+ /**
78
+ * Gets the map of layers in this layout.
79
+ *
80
+ * @returns Map of layer names to layer objects
81
+ */
82
+ get layers(): Map<string, AcTrLayer>;
83
+ /**
84
+ * Gets the bounding box that contains all entities in this layout.
85
+ *
86
+ * @returns The layout's bounding box
87
+ */
88
+ get box(): THREE.Box3;
89
+ /**
90
+ * The visibility of this layout.
91
+ * When set to false, the entire layout and all its contents are hidden.
92
+ */
93
+ get visible(): boolean;
94
+ set visible(value: boolean);
95
+ /**
96
+ * The number of entities stored in this layout.
97
+ * Calculates the total by summing entities across all layers.
98
+ */
99
+ get entityCount(): number;
100
+ /**
101
+ * The statistics of this layout.
102
+ * Provides detailed information about memory usage and entity counts.
103
+ */
104
+ get stats(): AcTrLayoutStats;
105
+ /**
106
+ * Clears all entities from the layout.
107
+ * Removes all layers, resets the bounding box, and clears the spatial index.
108
+ *
109
+ * @returns This layout instance for method chaining
110
+ */
111
+ clear(): this;
112
+ /**
113
+ * Re-render points with latest point style settings.
114
+ * Updates the visual representation of all point entities across all layers.
115
+ *
116
+ * @param displayMode - Input display mode of points
117
+ */
118
+ rerenderPoints(displayMode: number): void;
119
+ /**
120
+ * Return true if the object with the specified object id is intersected with the ray by using raycast.
121
+ *
122
+ * @param objectId - Input object id of object to check for intersection with the ray.
123
+ * @param raycaster - Input raycaster to check intersection
124
+ * @returns True if the object intersects with the ray, false otherwise
125
+ */
126
+ isIntersectWith(objectId: string, raycaster: THREE.Raycaster): boolean | undefined;
127
+ /**
128
+ * Add one AutoCAD entity into this layout. If layer group referenced by the entity doesn't exist, create one
129
+ * layer group and add this entity this group.
130
+ *
131
+ * @param entity - Input AutoCAD entity to be added into this layout.
132
+ * @param extendBbox - Input the flag whether to extend the bounding box of the scene by union the bounding box
133
+ * of the specified entity. Defaults to true.
134
+ * @returns This layout instance for method chaining
135
+ *
136
+ * @throws {Error} When entity is missing required objectId or layerName
137
+ */
138
+ addEntity(entity: AcTrEntity, extendBbox?: boolean): this;
139
+ /**
140
+ * Remove the specified entity from this layout.
141
+ *
142
+ * @param objectId - Input the object id of the entity to remove
143
+ * @returns Return true if remove the specified entity successfully. Otherwise, return false.
144
+ */
145
+ remove(objectId: AcDbObjectId): boolean;
146
+ /**
147
+ * Update the specified entity in this layout.
148
+ *
149
+ * @param entity - Input the entity to update
150
+ * @returns Return true if update the specified entity successfully. Otherwise, return false.
151
+ */
152
+ updateEntity(entity: AcTrEntity): boolean;
153
+ /**
154
+ * Adds layer group into this layout. If the layer already exist, do nothing.
155
+ *
156
+ * @param name - Input layer name
157
+ * @returns Return added layer group or the existing layer group in this layout if one layer
158
+ * group already exists in this layout.
159
+ */
160
+ addLayer(layer: AcEdLayerInfo): AcEdLayerInfo;
161
+ /**
162
+ * Updates layer group information (such as visibility). If the layer doesn't exist, do nothing.
163
+ * @param layerName Input layer information
164
+ * @returns Returns the updated layer group.
165
+ */
166
+ updateLayer(layer: AcEdLayerInfo): AcTrLayer | undefined;
167
+ /**
168
+ * Hover the specified entities.
169
+ * Applies hover highlighting to the entities with the given IDs.
170
+ *
171
+ * @param ids - Array of entity object IDs to hover
172
+ */
173
+ hover(ids: AcDbObjectId[]): void;
174
+ /**
175
+ * Unhover the specified entities.
176
+ * Removes hover highlighting from the entities with the given IDs.
177
+ *
178
+ * @param ids - Array of entity object IDs to unhover
179
+ */
180
+ unhover(ids: AcDbObjectId[]): void;
181
+ /**
182
+ * Select the specified entities.
183
+ * Applies selection highlighting to the entities with the given IDs.
184
+ *
185
+ * @param ids - Array of entity object IDs to select
186
+ */
187
+ select(ids: AcDbObjectId[]): void;
188
+ /**
189
+ * Unselect the specified entities.
190
+ * Removes selection highlighting from the entities with the given IDs.
191
+ *
192
+ * @param ids - Array of entity object IDs to unselect
193
+ */
194
+ unselect(ids: AcDbObjectId[]): void;
195
+ /**
196
+ * Sets the snap points object for this layout.
197
+ * Replaces any existing snap points object with the new one.
198
+ *
199
+ * @param object - The snap points object to display
200
+ */
201
+ setSnapObject(object: AcTrObject): void;
202
+ /**
203
+ * Search entities intersected or contained in the specified bounding box.
204
+ * Uses the spatial index for efficient querying of entities within the given bounds.
205
+ *
206
+ * @param box - Input the query bounding box (2D or 3D)
207
+ * @returns Return query results containing entity IDs and their bounds
208
+ */
209
+ search(box: AcGeBox2d | AcGeBox3d): AcEdSpatialQueryResultItem[];
210
+ /**
211
+ * Finds the layer containing the entity with the specified object ID.
212
+ *
213
+ * @param objectId - The object ID to search for
214
+ * @returns The layer containing the entity, or undefined if not found
215
+ */
216
+ private getLayerByObjectId;
217
+ }
218
+ //# sourceMappingURL=AcTrLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcTrLayout.d.ts","sourceRoot":"","sources":["../../src/view/AcTrLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AA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