@fps-games/editor 0.1.1-beta.0 → 0.1.1-beta.10

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 (162) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/local-editor-harness.d.ts +113 -6
  5. package/dist/local-editor-harness.d.ts.map +1 -1
  6. package/dist/local-editor-harness.js +1253 -55
  7. package/dist/local-editor-harness.js.map +1 -1
  8. package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts +33 -0
  9. package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts.map +1 -0
  10. package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js +231 -0
  11. package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js.map +1 -0
  12. package/node_modules/@fps-games/editor-babylon/dist/editor-world.d.ts +3 -0
  13. package/node_modules/@fps-games/editor-babylon/dist/editor-world.d.ts.map +1 -1
  14. package/node_modules/@fps-games/editor-babylon/dist/editor-world.js +8 -0
  15. package/node_modules/@fps-games/editor-babylon/dist/editor-world.js.map +1 -1
  16. package/node_modules/@fps-games/editor-babylon/dist/index.d.ts +5 -0
  17. package/node_modules/@fps-games/editor-babylon/dist/index.d.ts.map +1 -1
  18. package/node_modules/@fps-games/editor-babylon/dist/index.js +5 -0
  19. package/node_modules/@fps-games/editor-babylon/dist/index.js.map +1 -1
  20. package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts +40 -0
  21. package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts.map +1 -0
  22. package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js +237 -0
  23. package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js.map +1 -0
  24. package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.d.ts +1 -1
  25. package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.d.ts.map +1 -1
  26. package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.js +15 -50
  27. package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.js.map +1 -1
  28. package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts +27 -0
  29. package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts.map +1 -1
  30. package/node_modules/@fps-games/editor-babylon/dist/projection.js +368 -14
  31. package/node_modules/@fps-games/editor-babylon/dist/projection.js.map +1 -1
  32. package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.d.ts +25 -0
  33. package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.d.ts.map +1 -0
  34. package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.js +176 -0
  35. package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.js.map +1 -0
  36. package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.d.ts +18 -0
  37. package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.d.ts.map +1 -1
  38. package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.js +142 -0
  39. package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.js.map +1 -1
  40. package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.d.ts +2 -0
  41. package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.d.ts.map +1 -1
  42. package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.js +6 -0
  43. package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.js.map +1 -1
  44. package/node_modules/@fps-games/editor-babylon/dist/scene-view-measurement-controller.d.ts +20 -0
  45. package/node_modules/@fps-games/editor-babylon/dist/scene-view-measurement-controller.d.ts.map +1 -0
  46. package/node_modules/@fps-games/editor-babylon/dist/scene-view-measurement-controller.js +187 -0
  47. package/node_modules/@fps-games/editor-babylon/dist/scene-view-measurement-controller.js.map +1 -0
  48. package/node_modules/@fps-games/editor-babylon/dist/scene-view-spatial-overlay-controller.d.ts +20 -0
  49. package/node_modules/@fps-games/editor-babylon/dist/scene-view-spatial-overlay-controller.d.ts.map +1 -0
  50. package/node_modules/@fps-games/editor-babylon/dist/scene-view-spatial-overlay-controller.js +188 -0
  51. package/node_modules/@fps-games/editor-babylon/dist/scene-view-spatial-overlay-controller.js.map +1 -0
  52. package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts +22 -2
  53. package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts.map +1 -1
  54. package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js +469 -90
  55. package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js.map +1 -1
  56. package/node_modules/@fps-games/editor-babylon/dist/types.d.ts +20 -0
  57. package/node_modules/@fps-games/editor-babylon/dist/types.d.ts.map +1 -1
  58. package/node_modules/@fps-games/editor-babylon/package.json +4 -4
  59. package/node_modules/@fps-games/editor-browser/dist/index.d.ts +2 -0
  60. package/node_modules/@fps-games/editor-browser/dist/index.d.ts.map +1 -1
  61. package/node_modules/@fps-games/editor-browser/dist/index.js +1 -0
  62. package/node_modules/@fps-games/editor-browser/dist/index.js.map +1 -1
  63. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.d.ts +3 -1
  64. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.d.ts.map +1 -1
  65. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.js +103 -48
  66. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.js.map +1 -1
  67. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts +17 -1
  68. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts.map +1 -1
  69. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js +327 -33
  70. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js.map +1 -1
  71. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts +3 -1
  72. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts.map +1 -1
  73. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js +143 -17
  74. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js.map +1 -1
  75. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js +0 -2
  76. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js.map +1 -1
  77. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts.map +1 -1
  78. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js +27 -20
  79. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js.map +1 -1
  80. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts +10 -0
  81. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts.map +1 -0
  82. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js +253 -0
  83. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js.map +1 -0
  84. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts +8 -1
  85. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts.map +1 -1
  86. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js +403 -110
  87. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js.map +1 -1
  88. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-primitives.d.ts +13 -3
  89. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-primitives.d.ts.map +1 -1
  90. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-primitives.js +107 -14
  91. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-primitives.js.map +1 -1
  92. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.d.ts +20 -3
  93. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.d.ts.map +1 -1
  94. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js +127 -16
  95. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js.map +1 -1
  96. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.d.ts.map +1 -1
  97. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js +13 -4
  98. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js.map +1 -1
  99. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.d.ts +4 -0
  100. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.d.ts.map +1 -1
  101. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.js +114 -9
  102. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.js.map +1 -1
  103. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.d.ts +11 -0
  104. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.d.ts.map +1 -0
  105. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.js +148 -0
  106. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.js.map +1 -0
  107. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +141 -3
  108. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
  109. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.d.ts +35 -0
  110. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.d.ts.map +1 -1
  111. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.js +376 -2
  112. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.js.map +1 -1
  113. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +11 -6
  114. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
  115. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +1617 -110
  116. package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
  117. package/node_modules/@fps-games/editor-browser/package.json +4 -1
  118. package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts +4 -1
  119. package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts.map +1 -1
  120. package/node_modules/@fps-games/editor-core/dist/editor-session.js +13 -3
  121. package/node_modules/@fps-games/editor-core/dist/editor-session.js.map +1 -1
  122. package/node_modules/@fps-games/editor-core/dist/index.d.ts +3 -0
  123. package/node_modules/@fps-games/editor-core/dist/index.d.ts.map +1 -1
  124. package/node_modules/@fps-games/editor-core/dist/index.js +3 -0
  125. package/node_modules/@fps-games/editor-core/dist/index.js.map +1 -1
  126. package/node_modules/@fps-games/editor-core/dist/inspector.d.ts +6 -1
  127. package/node_modules/@fps-games/editor-core/dist/inspector.d.ts.map +1 -1
  128. package/node_modules/@fps-games/editor-core/dist/inspector.js +6 -1
  129. package/node_modules/@fps-games/editor-core/dist/inspector.js.map +1 -1
  130. package/node_modules/@fps-games/editor-core/dist/scene-graph.d.ts +7 -0
  131. package/node_modules/@fps-games/editor-core/dist/scene-graph.d.ts.map +1 -1
  132. package/node_modules/@fps-games/editor-core/dist/scene-graph.js.map +1 -1
  133. package/node_modules/@fps-games/editor-core/dist/scene-view-input.d.ts +1 -1
  134. package/node_modules/@fps-games/editor-core/dist/scene-view-input.d.ts.map +1 -1
  135. package/node_modules/@fps-games/editor-core/dist/selection-strategy.d.ts +12 -0
  136. package/node_modules/@fps-games/editor-core/dist/selection-strategy.d.ts.map +1 -0
  137. package/node_modules/@fps-games/editor-core/dist/selection-strategy.js +52 -0
  138. package/node_modules/@fps-games/editor-core/dist/selection-strategy.js.map +1 -0
  139. package/node_modules/@fps-games/editor-core/dist/transform-gizmo.d.ts +78 -2
  140. package/node_modules/@fps-games/editor-core/dist/transform-gizmo.d.ts.map +1 -1
  141. package/node_modules/@fps-games/editor-core/dist/transform-gizmo.js +81 -1
  142. package/node_modules/@fps-games/editor-core/dist/transform-gizmo.js.map +1 -1
  143. package/node_modules/@fps-games/editor-core/dist/transform-operations.d.ts +32 -0
  144. package/node_modules/@fps-games/editor-core/dist/transform-operations.d.ts.map +1 -0
  145. package/node_modules/@fps-games/editor-core/dist/transform-operations.js +125 -0
  146. package/node_modules/@fps-games/editor-core/dist/transform-operations.js.map +1 -0
  147. package/node_modules/@fps-games/editor-core/dist/viewport-tools.d.ts +94 -0
  148. package/node_modules/@fps-games/editor-core/dist/viewport-tools.d.ts.map +1 -0
  149. package/node_modules/@fps-games/editor-core/dist/viewport-tools.js +58 -0
  150. package/node_modules/@fps-games/editor-core/dist/viewport-tools.js.map +1 -0
  151. package/node_modules/@fps-games/editor-core/package.json +2 -2
  152. package/node_modules/@fps-games/editor-forge-play/dist/index.d.ts +1 -1
  153. package/node_modules/@fps-games/editor-forge-play/dist/index.d.ts.map +1 -1
  154. package/node_modules/@fps-games/editor-forge-play/dist/index.js +5 -1
  155. package/node_modules/@fps-games/editor-forge-play/dist/index.js.map +1 -1
  156. package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
  157. package/node_modules/@fps-games/editor-protocol/dist/index.d.ts +4 -0
  158. package/node_modules/@fps-games/editor-protocol/dist/index.d.ts.map +1 -1
  159. package/node_modules/@fps-games/editor-protocol/dist/index.js +4 -0
  160. package/node_modules/@fps-games/editor-protocol/dist/index.js.map +1 -1
  161. package/node_modules/@fps-games/editor-protocol/package.json +1 -1
  162. package/package.json +6 -6
@@ -0,0 +1,187 @@
1
+ export function createBabylonSceneViewMeasurementController(options) {
2
+ let disposed = false;
3
+ let state = createEmptyMeasurementState();
4
+ function beginAt(clientX, clientY) {
5
+ if (disposed)
6
+ return null;
7
+ const point = pickGroundPoint(options, clientX, clientY);
8
+ if (!point)
9
+ return null;
10
+ state = projectMeasurementState(options, {
11
+ active: true,
12
+ start: point,
13
+ end: null,
14
+ preview: point,
15
+ distance: null,
16
+ });
17
+ return cloneMeasurement(state);
18
+ }
19
+ function previewAt(clientX, clientY) {
20
+ if (disposed || !state.active || !state.start || state.end)
21
+ return null;
22
+ const point = pickGroundPoint(options, clientX, clientY);
23
+ if (!point)
24
+ return null;
25
+ state = projectMeasurementState(options, {
26
+ active: true,
27
+ start: state.start,
28
+ end: null,
29
+ preview: point,
30
+ distance: distanceXZ(state.start, point),
31
+ });
32
+ return cloneMeasurement(state);
33
+ }
34
+ function completeAt(clientX, clientY) {
35
+ if (disposed || !state.active || !state.start)
36
+ return null;
37
+ const point = pickGroundPoint(options, clientX, clientY);
38
+ if (!point)
39
+ return null;
40
+ state = projectMeasurementState(options, {
41
+ active: false,
42
+ start: state.start,
43
+ end: point,
44
+ preview: null,
45
+ distance: distanceXZ(state.start, point),
46
+ });
47
+ return cloneMeasurement(state);
48
+ }
49
+ function clear() {
50
+ state = createEmptyMeasurementState();
51
+ return cloneMeasurement(state);
52
+ }
53
+ return {
54
+ beginAt,
55
+ previewAt,
56
+ completeAt,
57
+ clear,
58
+ getState: () => {
59
+ state = projectMeasurementState(options, state);
60
+ return cloneMeasurement(state);
61
+ },
62
+ dispose() {
63
+ disposed = true;
64
+ state = createEmptyMeasurementState();
65
+ },
66
+ };
67
+ }
68
+ export function createEmptyMeasurementState() {
69
+ return {
70
+ active: false,
71
+ start: null,
72
+ end: null,
73
+ preview: null,
74
+ distance: null,
75
+ screenStart: null,
76
+ screenEnd: null,
77
+ screenPreview: null,
78
+ label: null,
79
+ };
80
+ }
81
+ export function pickGroundPoint(options, clientX, clientY) {
82
+ const scene = options.scene;
83
+ const Matrix = options.babylon.Matrix;
84
+ const camera = scene.activeCamera ?? scene.cameraToUseForPointers ?? null;
85
+ const canvas = scene.getEngine?.().getRenderingCanvas?.();
86
+ if (!canvas || !camera || !Matrix?.Identity || typeof scene.createPickingRay !== 'function')
87
+ return null;
88
+ const rect = canvas.getBoundingClientRect();
89
+ const renderWidth = Math.max(1, Number(scene.getEngine?.().getRenderWidth?.() ?? canvas.width ?? rect.width));
90
+ const renderHeight = Math.max(1, Number(scene.getEngine?.().getRenderHeight?.() ?? canvas.height ?? rect.height));
91
+ const renderX = (clientX - rect.left) * (renderWidth / Math.max(1, rect.width));
92
+ const renderY = (clientY - rect.top) * (renderHeight / Math.max(1, rect.height));
93
+ const ray = scene.createPickingRay(renderX, renderY, Matrix.Identity(), camera);
94
+ const origin = readVec3(ray?.origin);
95
+ const direction = readVec3(ray?.direction);
96
+ if (!origin || !direction || Math.abs(direction.y) < 0.000001)
97
+ return null;
98
+ const t = -origin.y / direction.y;
99
+ if (!Number.isFinite(t) || t < 0)
100
+ return null;
101
+ return addVec3(origin, scaleVec3(direction, t));
102
+ }
103
+ export function projectMeasurementState(options, measurement) {
104
+ const start = measurement.start ? { ...measurement.start } : null;
105
+ const end = measurement.end ? { ...measurement.end } : null;
106
+ const preview = measurement.preview ? { ...measurement.preview } : null;
107
+ const screenStart = start ? projectWorldPoint(options, start) : null;
108
+ const screenEnd = end ? projectWorldPoint(options, end) : null;
109
+ const screenPreview = preview ? projectWorldPoint(options, preview) : null;
110
+ const labelEnd = screenEnd ?? screenPreview;
111
+ const distance = measurement.distance ?? (start && (end ?? preview) ? distanceXZ(start, end ?? preview) : null);
112
+ return {
113
+ active: measurement.active,
114
+ start,
115
+ end,
116
+ preview,
117
+ distance,
118
+ screenStart,
119
+ screenEnd,
120
+ screenPreview,
121
+ label: screenStart && labelEnd && distance != null
122
+ ? {
123
+ text: `${formatMeasurementDistance(distance)} m`,
124
+ x: (screenStart.x + labelEnd.x) / 2,
125
+ y: (screenStart.y + labelEnd.y) / 2 - 14,
126
+ }
127
+ : null,
128
+ };
129
+ }
130
+ export function formatMeasurementDistance(value) {
131
+ if (!Number.isFinite(value))
132
+ return '0';
133
+ const rounded = Math.abs(value) < 0.005 ? 0 : value;
134
+ return rounded.toFixed(2).replace(/\.?0+$/, '');
135
+ }
136
+ function projectWorldPoint(options, point) {
137
+ const Vector3 = options.babylon.Vector3;
138
+ const Matrix = options.babylon.Matrix;
139
+ const scene = options.scene;
140
+ const camera = scene.activeCamera ?? scene.cameraToUseForPointers ?? null;
141
+ const canvas = scene.getEngine?.().getRenderingCanvas?.();
142
+ const viewport = camera?.viewport?.toGlobal?.(scene.getEngine?.().getRenderWidth?.() ?? canvas?.width ?? 0, scene.getEngine?.().getRenderHeight?.() ?? canvas?.height ?? 0);
143
+ const transformMatrix = scene.getTransformMatrix?.();
144
+ if (!Vector3?.Project || !Matrix?.Identity || !camera || !canvas || !viewport || !transformMatrix)
145
+ return null;
146
+ const rect = canvas.getBoundingClientRect();
147
+ const renderWidth = Math.max(1, Number(scene.getEngine?.().getRenderWidth?.() ?? canvas.width ?? rect.width));
148
+ const renderHeight = Math.max(1, Number(scene.getEngine?.().getRenderHeight?.() ?? canvas.height ?? rect.height));
149
+ const projected = Vector3.Project(new Vector3(point.x, point.y, point.z), Matrix.Identity(), transformMatrix, viewport);
150
+ const x = rect.left + Number(projected?.x) * (rect.width / renderWidth);
151
+ const y = rect.top + Number(projected?.y) * (rect.height / renderHeight);
152
+ const depth = Number(projected?.z);
153
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(depth))
154
+ return null;
155
+ return { x, y, depth };
156
+ }
157
+ function cloneMeasurement(measurement) {
158
+ return {
159
+ active: measurement.active,
160
+ start: measurement.start ? { ...measurement.start } : null,
161
+ end: measurement.end ? { ...measurement.end } : null,
162
+ preview: measurement.preview ? { ...measurement.preview } : null,
163
+ distance: measurement.distance,
164
+ screenStart: measurement.screenStart ? { ...measurement.screenStart } : null,
165
+ screenEnd: measurement.screenEnd ? { ...measurement.screenEnd } : null,
166
+ screenPreview: measurement.screenPreview ? { ...measurement.screenPreview } : null,
167
+ label: measurement.label ? { ...measurement.label } : null,
168
+ };
169
+ }
170
+ function readVec3(value) {
171
+ if (!value)
172
+ return null;
173
+ const x = Number(value.x);
174
+ const y = Number(value.y);
175
+ const z = Number(value.z);
176
+ return Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z) ? { x, y, z } : null;
177
+ }
178
+ function addVec3(left, right) {
179
+ return { x: left.x + right.x, y: left.y + right.y, z: left.z + right.z };
180
+ }
181
+ function scaleVec3(value, factor) {
182
+ return { x: value.x * factor, y: value.y * factor, z: value.z * factor };
183
+ }
184
+ function distanceXZ(left, right) {
185
+ return Math.hypot(right.x - left.x, right.z - left.z);
186
+ }
187
+ //# sourceMappingURL=scene-view-measurement-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-view-measurement-controller.js","sourceRoot":"","sources":["../src/scene-view-measurement-controller.ts"],"names":[],"mappings":"AAwBA,MAAM,UAAU,2CAA2C,CACzD,OAAqD;IAErD,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,KAAK,GAAG,2BAA2B,EAAE,CAAC;IAE1C,SAAS,OAAO,CAAC,OAAe,EAAE,OAAe;QAC/C,IAAI,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC1B,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,KAAK,GAAG,uBAAuB,CAAC,OAAO,EAAE;YACvC,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,SAAS,CAAC,OAAe,EAAE,OAAe;QACjD,IAAI,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACxE,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,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B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,SAAS,OAAO,CAAC,IAAyB,EAAE,KAA0B;IACpE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,SAAS,CAAC,KAA0B,EAAE,MAAc;IAC3D,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,UAAU,CAAC,IAAyB,EAAE,KAA0B;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { EditorTransformVec3, EditorViewportBounds, EditorViewportOverlaySettings, EditorViewportSpatialOverlayState } from '@fps-games/editor-core';
2
+ import type { BabylonRuntimeGlobal, RuntimeScene } from './types';
3
+ export interface BabylonSceneViewSpatialOverlayControllerOptions {
4
+ babylon: BabylonRuntimeGlobal;
5
+ scene: RuntimeScene;
6
+ }
7
+ export interface BabylonSceneViewSpatialOverlayInput {
8
+ nodeId: string | null;
9
+ bounds: EditorViewportBounds | null;
10
+ anchor: EditorTransformVec3 | null;
11
+ settings: EditorViewportOverlaySettings;
12
+ }
13
+ export interface BabylonSceneViewSpatialOverlayController {
14
+ compute(input: BabylonSceneViewSpatialOverlayInput): EditorViewportSpatialOverlayState;
15
+ dispose(): void;
16
+ }
17
+ export declare function createBabylonSceneViewSpatialOverlayController(options: BabylonSceneViewSpatialOverlayControllerOptions): BabylonSceneViewSpatialOverlayController;
18
+ export declare function createEditorViewportSpatialOverlayState(options: BabylonSceneViewSpatialOverlayControllerOptions, input: BabylonSceneViewSpatialOverlayInput): EditorViewportSpatialOverlayState;
19
+ export declare function formatEditorViewportOverlayNumber(value: number): string;
20
+ //# sourceMappingURL=scene-view-spatial-overlay-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-view-spatial-overlay-controller.d.ts","sourceRoot":"","sources":["../src/scene-view-spatial-overlay-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,EAI7B,iCAAiC,EAClC,MAAM,wBAAwB,CAAC;AAIhC,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,+CAA+C;IAC9D,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,mCAAmC;IAClD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,6BAA6B,CAAC;CACzC;AAED,MAAM,WAAW,wCAAwC;IACvD,OAAO,CAAC,KAAK,EAAE,mCAAmC,GAAG,iCAAiC,CAAC;IACvF,OAAO,IAAI,IAAI,CAAC;CACjB;AAsDD,wBAAgB,8CAA8C,CAC5D,OAAO,EAAE,+CAA+C,GACvD,wCAAwC,CAY1C;AAED,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,+CAA+C,EACxD,KAAK,EAAE,mCAAmC,GACzC,iCAAiC,CA2DnC;AAwGD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvE"}
@@ -0,0 +1,188 @@
1
+ import { createEmptyEditorViewportSpatialOverlayState, } from '@fps-games/editor-core';
2
+ const MIN_LABEL_EDGE_LENGTH_PX = 34;
3
+ const BOUNDS_EDGES = [
4
+ { id: 'x-y0-z0', axis: 'x', start: 'min-min-min', end: 'max-min-min' },
5
+ { id: 'x-y1-z0', axis: 'x', start: 'min-max-min', end: 'max-max-min' },
6
+ { id: 'x-y0-z1', axis: 'x', start: 'min-min-max', end: 'max-min-max' },
7
+ { id: 'x-y1-z1', axis: 'x', start: 'min-max-max', end: 'max-max-max' },
8
+ { id: 'y-x0-z0', axis: 'y', start: 'min-min-min', end: 'min-max-min' },
9
+ { id: 'y-x1-z0', axis: 'y', start: 'max-min-min', end: 'max-max-min' },
10
+ { id: 'y-x0-z1', axis: 'y', start: 'min-min-max', end: 'min-max-max' },
11
+ { id: 'y-x1-z1', axis: 'y', start: 'max-min-max', end: 'max-max-max' },
12
+ { id: 'z-x0-y0', axis: 'z', start: 'min-min-min', end: 'min-min-max' },
13
+ { id: 'z-x1-y0', axis: 'z', start: 'max-min-min', end: 'max-min-max' },
14
+ { id: 'z-x0-y1', axis: 'z', start: 'min-max-min', end: 'min-max-max' },
15
+ { id: 'z-x1-y1', axis: 'z', start: 'max-max-min', end: 'max-max-max' },
16
+ ];
17
+ const DIMENSION_EDGES = [
18
+ BOUNDS_EDGES[0],
19
+ BOUNDS_EDGES[4],
20
+ BOUNDS_EDGES[8],
21
+ ];
22
+ export function createBabylonSceneViewSpatialOverlayController(options) {
23
+ let disposed = false;
24
+ return {
25
+ compute(input) {
26
+ if (disposed)
27
+ return createEmptyEditorViewportSpatialOverlayState();
28
+ return createEditorViewportSpatialOverlayState(options, input);
29
+ },
30
+ dispose() {
31
+ disposed = true;
32
+ },
33
+ };
34
+ }
35
+ export function createEditorViewportSpatialOverlayState(options, input) {
36
+ if (!input.nodeId || !input.bounds)
37
+ return createEmptyEditorViewportSpatialOverlayState();
38
+ const projectedCorners = projectBoundsCorners(options, input.bounds);
39
+ if (!projectedCorners)
40
+ return createEmptyEditorViewportSpatialOverlayState();
41
+ const cornerMap = new Map(projectedCorners.map(corner => [corner.key, corner]));
42
+ const lines = [];
43
+ const labels = [];
44
+ if (input.settings.bounds) {
45
+ for (const edge of BOUNDS_EDGES) {
46
+ const line = createOverlayLine(edge, cornerMap);
47
+ if (line)
48
+ lines.push(line);
49
+ }
50
+ }
51
+ if (input.settings.dimensions) {
52
+ for (const edge of DIMENSION_EDGES) {
53
+ const label = createEdgeLabel(edge, cornerMap, input.bounds, 'dimension');
54
+ if (label)
55
+ labels.push(label);
56
+ }
57
+ }
58
+ if (input.settings.edgeLengths) {
59
+ for (const edge of BOUNDS_EDGES) {
60
+ const label = createEdgeLabel(edge, cornerMap, input.bounds, 'edge-length');
61
+ if (label)
62
+ labels.push(label);
63
+ }
64
+ }
65
+ const markers = [];
66
+ if (input.settings.anchor && input.anchor) {
67
+ const anchor = projectWorldPoint(options, input.anchor);
68
+ if (anchor) {
69
+ const label = `Anchor ${formatVec3(input.anchor)}`;
70
+ markers.push({
71
+ id: 'anchor',
72
+ kind: 'anchor',
73
+ position: anchor,
74
+ label,
75
+ });
76
+ labels.push({
77
+ id: 'anchor-label',
78
+ kind: 'anchor',
79
+ text: label,
80
+ x: anchor.x,
81
+ y: anchor.y - 18,
82
+ });
83
+ }
84
+ }
85
+ return {
86
+ active: lines.length > 0 || labels.length > 0 || markers.length > 0,
87
+ nodeId: input.nodeId,
88
+ bounds: cloneBounds(input.bounds),
89
+ anchor: input.anchor ? { ...input.anchor } : null,
90
+ lines,
91
+ labels,
92
+ markers,
93
+ };
94
+ }
95
+ function projectBoundsCorners(options, bounds) {
96
+ const corners = [
97
+ ['min-min-min', { x: bounds.min.x, y: bounds.min.y, z: bounds.min.z }],
98
+ ['max-min-min', { x: bounds.max.x, y: bounds.min.y, z: bounds.min.z }],
99
+ ['min-max-min', { x: bounds.min.x, y: bounds.max.y, z: bounds.min.z }],
100
+ ['max-max-min', { x: bounds.max.x, y: bounds.max.y, z: bounds.min.z }],
101
+ ['min-min-max', { x: bounds.min.x, y: bounds.min.y, z: bounds.max.z }],
102
+ ['max-min-max', { x: bounds.max.x, y: bounds.min.y, z: bounds.max.z }],
103
+ ['min-max-max', { x: bounds.min.x, y: bounds.max.y, z: bounds.max.z }],
104
+ ['max-max-max', { x: bounds.max.x, y: bounds.max.y, z: bounds.max.z }],
105
+ ];
106
+ const projected = [];
107
+ for (const [key, world] of corners) {
108
+ const screen = projectWorldPoint(options, world);
109
+ if (!screen)
110
+ return null;
111
+ projected.push({ key, world, screen });
112
+ }
113
+ return projected;
114
+ }
115
+ function projectWorldPoint(options, point) {
116
+ const Vector3 = options.babylon.Vector3;
117
+ const Matrix = options.babylon.Matrix;
118
+ const scene = options.scene;
119
+ const camera = scene.activeCamera ?? scene.cameraToUseForPointers ?? null;
120
+ const canvas = scene.getEngine?.().getRenderingCanvas?.();
121
+ const viewport = camera?.viewport?.toGlobal?.(scene.getEngine?.().getRenderWidth?.() ?? canvas?.width ?? 0, scene.getEngine?.().getRenderHeight?.() ?? canvas?.height ?? 0);
122
+ const transformMatrix = scene.getTransformMatrix?.();
123
+ if (!Vector3?.Project || !Matrix?.Identity || !camera || !canvas || !viewport || !transformMatrix)
124
+ return null;
125
+ const canvasRect = canvas.getBoundingClientRect();
126
+ const renderWidth = Math.max(1, Number(scene.getEngine?.().getRenderWidth?.() ?? canvas.width ?? canvasRect.width));
127
+ const renderHeight = Math.max(1, Number(scene.getEngine?.().getRenderHeight?.() ?? canvas.height ?? canvasRect.height));
128
+ const cssScaleX = canvasRect.width / renderWidth;
129
+ const cssScaleY = canvasRect.height / renderHeight;
130
+ const projected = Vector3.Project(new Vector3(point.x, point.y, point.z), Matrix.Identity(), transformMatrix, viewport);
131
+ const x = canvasRect.left + Number(projected?.x) * cssScaleX;
132
+ const y = canvasRect.top + Number(projected?.y) * cssScaleY;
133
+ const depth = Number(projected?.z);
134
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(depth))
135
+ return null;
136
+ return { x, y, depth };
137
+ }
138
+ function createOverlayLine(edge, corners) {
139
+ const start = corners.get(edge.start)?.screen;
140
+ const end = corners.get(edge.end)?.screen;
141
+ if (!start || !end)
142
+ return null;
143
+ return {
144
+ id: edge.id,
145
+ kind: 'bounds',
146
+ start: { ...start },
147
+ end: { ...end },
148
+ };
149
+ }
150
+ function createEdgeLabel(edge, corners, bounds, kind) {
151
+ const start = corners.get(edge.start)?.screen;
152
+ const end = corners.get(edge.end)?.screen;
153
+ if (!start || !end)
154
+ return null;
155
+ const screenLength = Math.hypot(end.x - start.x, end.y - start.y);
156
+ if (screenLength < MIN_LABEL_EDGE_LENGTH_PX)
157
+ return null;
158
+ return {
159
+ id: `${kind}-${edge.id}`,
160
+ kind,
161
+ text: kind === 'dimension'
162
+ ? `${edge.axis.toUpperCase()} ${formatNumber(bounds.size[edge.axis])}`
163
+ : formatNumber(bounds.size[edge.axis]),
164
+ x: (start.x + end.x) / 2,
165
+ y: (start.y + end.y) / 2,
166
+ };
167
+ }
168
+ function cloneBounds(bounds) {
169
+ return {
170
+ min: { ...bounds.min },
171
+ max: { ...bounds.max },
172
+ center: { ...bounds.center },
173
+ size: { ...bounds.size },
174
+ };
175
+ }
176
+ export function formatEditorViewportOverlayNumber(value) {
177
+ return formatNumber(value);
178
+ }
179
+ function formatVec3(value) {
180
+ return `(${formatNumber(value.x)}, ${formatNumber(value.y)}, ${formatNumber(value.z)})`;
181
+ }
182
+ function formatNumber(value) {
183
+ if (!Number.isFinite(value))
184
+ return '0';
185
+ const rounded = Math.abs(value) < 0.005 ? 0 : value;
186
+ return rounded.toFixed(2).replace(/\.?0+$/, '');
187
+ }
188
+ //# sourceMappingURL=scene-view-spatial-overlay-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-view-spatial-overlay-controller.js","sourceRoot":"","sources":["../src/scene-view-spatial-overlay-controller.ts"],"names":[],"mappings":"AASA,OAAO,EACL,4CAA4C,GAC7C,MAAM,wBAAwB,CAAC;AAoDhC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE;IACtE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,GA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C;AAClD,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { EditorSelectionState, EditorTransformBatchCommit, EditorTransformConstraint, EditorTransformGizmoCommit, EditorTransformGizmoState, EditorTransformPivot, EditorTransformSnapshot, EditorTransformSpace, EditorTransformTool } from '@fps-games/editor-core';
1
+ import type { EditorPlacementHit, EditorPlacementMode, EditorTransformOperationSettings, EditorTransformCanonicalConstraint, EditorSelectionState, EditorTransformBatchCommit, EditorTransformConstraint, EditorTransformGizmoCommit, EditorTransformGizmoState, EditorTransformPivot, EditorTransformSnapshot, EditorTransformSpace, EditorTransformTool } from '@fps-games/editor-core';
2
2
  import type { BabylonRuntimeGlobal, RuntimeScene } from './types';
3
3
  import type { BabylonEditorProjection } from './projection';
4
4
  export interface BabylonTransformGizmoDragEvent {
@@ -7,12 +7,27 @@ export interface BabylonTransformGizmoDragEvent {
7
7
  activeId: string | null;
8
8
  tool: Exclude<EditorTransformTool, 'select'>;
9
9
  space: EditorTransformSpace;
10
- constraint: EditorTransformConstraint;
10
+ constraint: EditorTransformCanonicalConstraint;
11
11
  pivot: EditorTransformPivot;
12
12
  before: EditorTransformSnapshot | null;
13
13
  beforeTransforms: Record<string, EditorTransformSnapshot>;
14
+ duplicate: boolean;
14
15
  }
15
16
  export type BabylonTransformGizmoCommit = EditorTransformGizmoCommit | EditorTransformBatchCommit;
17
+ export interface BabylonTransformGizmoDuplicateDragInput {
18
+ targetIds: string[];
19
+ activeId: string | null;
20
+ tool: Exclude<EditorTransformTool, 'select'>;
21
+ space: EditorTransformSpace;
22
+ constraint: EditorTransformCanonicalConstraint;
23
+ beforeTransforms: Record<string, EditorTransformSnapshot>;
24
+ }
25
+ export interface BabylonTransformGizmoDuplicateDragResult {
26
+ targetIds: string[];
27
+ activeId?: string | null;
28
+ }
29
+ export type BabylonTransformGizmoHandleKey = 'xGizmo' | 'yGizmo' | 'zGizmo' | 'xPlaneGizmo' | 'yPlaneGizmo' | 'zPlaneGizmo' | 'uniformScaleGizmo';
30
+ export declare function resolveBabylonTransformHandleConstraint(tool: Exclude<EditorTransformTool, 'select'>, handleKey: BabylonTransformGizmoHandleKey): EditorTransformCanonicalConstraint | null;
16
31
  export interface BabylonTransformGizmoControllerOptions {
17
32
  babylon: BabylonRuntimeGlobal;
18
33
  scene: RuntimeScene;
@@ -25,6 +40,7 @@ export interface BabylonTransformGizmoControllerOptions {
25
40
  }) => void;
26
41
  onDragEnd?: (event: BabylonTransformGizmoCommit) => void;
27
42
  onDragCancel?: (event: BabylonTransformGizmoDragEvent) => void;
43
+ onDuplicateDragStart?: (input: BabylonTransformGizmoDuplicateDragInput) => BabylonTransformGizmoDuplicateDragResult | null;
28
44
  logger?: Pick<Console, 'warn'>;
29
45
  }
30
46
  export interface BabylonTransformGizmoController {
@@ -32,6 +48,8 @@ export interface BabylonTransformGizmoController {
32
48
  setTool(tool: EditorTransformTool): void;
33
49
  setSpace(space: EditorTransformSpace): void;
34
50
  setConstraint(constraint: EditorTransformConstraint): void;
51
+ setOperationSettings(settings: EditorTransformOperationSettings): void;
52
+ preparePointerDrag(event: PointerEvent): void;
35
53
  setSelectedNode(nodeId: string | null): void;
36
54
  setSelection(selection: EditorSelectionState): void;
37
55
  refreshSelection(): void;
@@ -40,6 +58,8 @@ export interface BabylonTransformGizmoController {
40
58
  beginViewPlaneMove(event: PointerEvent): boolean;
41
59
  updateViewPlaneMove(event: PointerEvent): boolean;
42
60
  endViewPlaneMove(event: PointerEvent): boolean;
61
+ pickPlacementHit(clientX: number, clientY: number, mode: EditorPlacementMode): EditorPlacementHit | null;
62
+ setPlacementMarker(hit: EditorPlacementHit | null): void;
43
63
  cancelDrag(): void;
44
64
  dispose(): void;
45
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform-gizmo-controller.d.ts","sourceRoot":"","sources":["../src/transform-gizmo-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB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