@holoscript/core 6.0.4 → 7.0.0

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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,488 +0,0 @@
1
- 'use strict';
2
-
3
- // src/compiler/COCOExporter.ts
4
- var DEFAULT_SHAPE_SIZES = {
5
- box: [1, 1, 1],
6
- cube: [1, 1, 1],
7
- sphere: [1, 1, 1],
8
- orb: [1, 1, 1],
9
- cylinder: [1, 2, 1],
10
- cone: [1, 2, 1],
11
- pyramid: [1, 1, 1],
12
- plane: [2, 0.01, 2],
13
- ground: [10, 0.01, 10],
14
- model: [1, 1, 1],
15
- mesh: [1, 1, 1],
16
- splat: [1, 1, 1],
17
- nerf: [1, 1, 1]
18
- };
19
- var NPC_KEYPOINT_NAMES = [
20
- "nose",
21
- "left_eye",
22
- "right_eye",
23
- "left_ear",
24
- "right_ear",
25
- "left_shoulder",
26
- "right_shoulder",
27
- "left_elbow",
28
- "right_elbow",
29
- "left_wrist",
30
- "right_wrist",
31
- "left_hip",
32
- "right_hip",
33
- "left_knee",
34
- "right_knee",
35
- "left_ankle",
36
- "right_ankle"
37
- ];
38
- var NPC_SKELETON = [
39
- [0, 1],
40
- [0, 2],
41
- [1, 3],
42
- [2, 4],
43
- // head
44
- [5, 6],
45
- [5, 7],
46
- [7, 9],
47
- [6, 8],
48
- [8, 10],
49
- // arms
50
- [5, 11],
51
- [6, 12],
52
- [11, 12],
53
- // torso
54
- [11, 13],
55
- [13, 15],
56
- [12, 14],
57
- [14, 16]
58
- // legs
59
- ];
60
- function exportCOCO(composition, options = {}) {
61
- const exporter = new COCOExporterImpl(options);
62
- return exporter.export(composition);
63
- }
64
- function exportCOCOString(composition, options = {}) {
65
- return JSON.stringify(exportCOCO(composition, options), null, 2);
66
- }
67
- var COCOExporterImpl = class {
68
- constructor(options = {}) {
69
- this.categoryMap = /* @__PURE__ */ new Map();
70
- this.categories = [];
71
- this.nextCategoryId = 1;
72
- this.nextAnnotationId = 1;
73
- this.imageWidth = options.imageWidth ?? 1920;
74
- this.imageHeight = options.imageHeight ?? 1080;
75
- this.fov = options.fov ?? 60;
76
- this.cameraPosition = options.cameraPosition ?? [0, 1.6, 5];
77
- this.cameraTarget = options.cameraTarget ?? [0, 0, 0];
78
- this.description = options.description ?? "HoloScript COCO Export";
79
- this.contributor = options.contributor ?? "HoloScript";
80
- this.filenameTemplate = options.filenameTemplate ?? "frame_{index}.png";
81
- this.viewCount = options.viewCount ?? 1;
82
- this.includeKeypoints = options.includeKeypoints ?? true;
83
- this.categoryOverrides = options.categoryOverrides ?? {};
84
- }
85
- export(composition) {
86
- this.categoryMap.clear();
87
- this.categories = [];
88
- this.nextCategoryId = 1;
89
- this.nextAnnotationId = 1;
90
- this.scanCategories(composition);
91
- if (this.includeKeypoints && composition.npcs?.length > 0) {
92
- this.ensureCategory("npc", "character");
93
- const npcCat = this.categories.find((c) => c.name === "npc");
94
- if (npcCat) {
95
- npcCat.keypoints = NPC_KEYPOINT_NAMES;
96
- npcCat.skeleton = NPC_SKELETON;
97
- }
98
- }
99
- const images = [];
100
- const annotations = [];
101
- for (let viewIdx = 0; viewIdx < this.viewCount; viewIdx++) {
102
- const imageId = viewIdx + 1;
103
- const filename = this.filenameTemplate.replace("{index}", String(viewIdx).padStart(6, "0"));
104
- images.push({
105
- id: imageId,
106
- width: this.imageWidth,
107
- height: this.imageHeight,
108
- file_name: filename,
109
- date_captured: (/* @__PURE__ */ new Date()).toISOString(),
110
- holoscript_meta: {
111
- composition: composition.name,
112
- view_index: viewIdx,
113
- camera_position: this.cameraPosition,
114
- camera_fov: this.fov
115
- }
116
- });
117
- const sceneAnnotations = this.annotateComposition(composition, imageId);
118
- annotations.push(...sceneAnnotations);
119
- }
120
- const now = /* @__PURE__ */ new Date();
121
- return {
122
- info: {
123
- year: now.getFullYear(),
124
- version: "1.0",
125
- description: this.description,
126
- contributor: this.contributor,
127
- url: "https://holoscript.dev",
128
- date_created: now.toISOString()
129
- },
130
- licenses: [
131
- {
132
- id: 1,
133
- name: "HoloScript Synthetic Data License",
134
- url: "https://holoscript.dev/license"
135
- }
136
- ],
137
- images,
138
- annotations,
139
- categories: this.categories
140
- };
141
- }
142
- // ---------------------------------------------------------------------------
143
- // Category scanning
144
- // ---------------------------------------------------------------------------
145
- scanCategories(composition) {
146
- for (const obj of composition.objects ?? []) {
147
- this.scanObjectCategories(obj);
148
- }
149
- for (const group of composition.spatialGroups ?? []) {
150
- this.scanGroupCategories(group);
151
- }
152
- for (const shape of composition.shapes ?? []) {
153
- this.ensureCategory(shape.shapeType, "geometry");
154
- }
155
- for (const block of composition.domainBlocks ?? []) {
156
- this.ensureCategory(block.keyword, block.domain);
157
- }
158
- }
159
- scanObjectCategories(obj) {
160
- const categoryName = this.inferCategory(obj);
161
- const supercategory = this.inferSupercategory(obj);
162
- this.ensureCategory(categoryName, supercategory);
163
- for (const child of obj.children ?? []) {
164
- this.scanObjectCategories(child);
165
- }
166
- }
167
- scanGroupCategories(group) {
168
- for (const obj of group.objects ?? []) {
169
- this.scanObjectCategories(obj);
170
- }
171
- for (const child of group.groups ?? []) {
172
- this.scanGroupCategories(child);
173
- }
174
- }
175
- ensureCategory(name, supercategory) {
176
- if (this.categoryOverrides[name]) {
177
- name = this.categoryOverrides[name].name;
178
- supercategory = this.categoryOverrides[name]?.supercategory ?? supercategory;
179
- }
180
- if (!this.categoryMap.has(name)) {
181
- const id = this.nextCategoryId++;
182
- this.categoryMap.set(name, id);
183
- this.categories.push({ id, name, supercategory });
184
- }
185
- return this.categoryMap.get(name);
186
- }
187
- // ---------------------------------------------------------------------------
188
- // Annotation generation
189
- // ---------------------------------------------------------------------------
190
- annotateComposition(composition, imageId) {
191
- const annotations = [];
192
- for (const obj of composition.objects ?? []) {
193
- annotations.push(...this.annotateObject(obj, imageId, [0, 0, 0]));
194
- }
195
- for (const group of composition.spatialGroups ?? []) {
196
- annotations.push(...this.annotateGroup(group, imageId, [0, 0, 0]));
197
- }
198
- for (const npc of composition.npcs ?? []) {
199
- annotations.push(...this.annotateNPC(npc, imageId));
200
- }
201
- for (const shape of composition.shapes ?? []) {
202
- annotations.push(...this.annotateShape(shape, imageId));
203
- }
204
- return annotations;
205
- }
206
- annotateObject(obj, imageId, parentOffset) {
207
- const annotations = [];
208
- const position = this.extractPosition(obj.properties, parentOffset);
209
- const scale = this.extractScale(obj.properties);
210
- const geometry = this.inferGeometry(obj);
211
- const size = [
212
- (DEFAULT_SHAPE_SIZES[geometry]?.[0] ?? 1) * scale[0],
213
- (DEFAULT_SHAPE_SIZES[geometry]?.[1] ?? 1) * scale[1],
214
- (DEFAULT_SHAPE_SIZES[geometry]?.[2] ?? 1) * scale[2]
215
- ];
216
- const bbox = this.projectBoundingBox(position, size);
217
- if (bbox) {
218
- const categoryName = this.inferCategory(obj);
219
- const categoryId = this.categoryMap.get(categoryName) ?? 1;
220
- const annotation = {
221
- id: this.nextAnnotationId++,
222
- image_id: imageId,
223
- category_id: categoryId,
224
- bbox,
225
- area: bbox[2] * bbox[3],
226
- segmentation: [this.bboxToPolygon(bbox)],
227
- iscrowd: 0
228
- };
229
- if (obj.traits?.length > 0) {
230
- annotation.attributes = {};
231
- for (const trait of obj.traits) {
232
- annotation.attributes[trait.name] = trait.config;
233
- }
234
- }
235
- annotations.push(annotation);
236
- }
237
- for (const child of obj.children ?? []) {
238
- annotations.push(...this.annotateObject(child, imageId, position));
239
- }
240
- return annotations;
241
- }
242
- annotateGroup(group, imageId, parentOffset) {
243
- const annotations = [];
244
- const groupOffset = this.extractGroupPosition(group, parentOffset);
245
- for (const obj of group.objects ?? []) {
246
- annotations.push(...this.annotateObject(obj, imageId, groupOffset));
247
- }
248
- for (const child of group.groups ?? []) {
249
- annotations.push(...this.annotateGroup(child, imageId, groupOffset));
250
- }
251
- return annotations;
252
- }
253
- annotateNPC(npc, imageId) {
254
- const annotations = [];
255
- const position = this.extractNPCPosition(npc);
256
- const size = [0.6, 1.8, 0.4];
257
- const bbox = this.projectBoundingBox(position, size);
258
- if (!bbox) return annotations;
259
- const categoryId = this.categoryMap.get("npc") ?? 1;
260
- const annotation = {
261
- id: this.nextAnnotationId++,
262
- image_id: imageId,
263
- category_id: categoryId,
264
- bbox,
265
- area: bbox[2] * bbox[3],
266
- segmentation: [this.bboxToPolygon(bbox)],
267
- iscrowd: 0
268
- };
269
- if (this.includeKeypoints) {
270
- const keypoints = this.generateNPCKeypoints(position, bbox);
271
- annotation.keypoints = keypoints;
272
- annotation.num_keypoints = NPC_KEYPOINT_NAMES.length;
273
- }
274
- annotations.push(annotation);
275
- return annotations;
276
- }
277
- annotateShape(shape, imageId) {
278
- const annotations = [];
279
- const position = [0, 0, 0];
280
- const size = DEFAULT_SHAPE_SIZES[shape.shapeType] ?? [1, 1, 1];
281
- for (const prop of shape.properties) {
282
- if (prop.key === "position" && Array.isArray(prop.value)) {
283
- const arr = prop.value;
284
- position[0] = arr[0] ?? 0;
285
- position[1] = arr[1] ?? 0;
286
- position[2] = arr[2] ?? 0;
287
- }
288
- }
289
- const bbox = this.projectBoundingBox(position, size);
290
- if (!bbox) return annotations;
291
- const categoryId = this.categoryMap.get(shape.shapeType) ?? 1;
292
- annotations.push({
293
- id: this.nextAnnotationId++,
294
- image_id: imageId,
295
- category_id: categoryId,
296
- bbox,
297
- area: bbox[2] * bbox[3],
298
- segmentation: [this.bboxToPolygon(bbox)],
299
- iscrowd: 0
300
- });
301
- return annotations;
302
- }
303
- // ---------------------------------------------------------------------------
304
- // Projection (simplified pinhole camera model)
305
- // ---------------------------------------------------------------------------
306
- /**
307
- * Project a 3D bounding box to 2D image coordinates using a pinhole camera model.
308
- * Returns [x, y, width, height] in COCO format or null if behind camera.
309
- */
310
- projectBoundingBox(position, size) {
311
- const focalLength = this.imageWidth / 2 / Math.tan(this.fov * Math.PI / 360);
312
- const cx = position[0] - this.cameraPosition[0];
313
- const cy = position[1] - this.cameraPosition[1];
314
- const cz = this.cameraPosition[2] - position[2];
315
- if (cz <= 0.01) return null;
316
- const px = cx * focalLength / cz + this.imageWidth / 2;
317
- const py = -(cy * focalLength) / cz + this.imageHeight / 2;
318
- const projW = size[0] * focalLength / cz;
319
- const projH = size[1] * focalLength / cz;
320
- const x = Math.max(0, Math.round(px - projW / 2));
321
- const y = Math.max(0, Math.round(py - projH / 2));
322
- const w = Math.min(this.imageWidth - x, Math.round(projW));
323
- const h = Math.min(this.imageHeight - y, Math.round(projH));
324
- if (w <= 0 || h <= 0) return null;
325
- return [x, y, w, h];
326
- }
327
- /** Convert bounding box to polygon format for segmentation */
328
- bboxToPolygon(bbox) {
329
- const [x, y, w, h] = bbox;
330
- return [x, y, x + w, y, x + w, y + h, x, y + h];
331
- }
332
- // ---------------------------------------------------------------------------
333
- // Property extraction helpers
334
- // ---------------------------------------------------------------------------
335
- extractPosition(properties, parentOffset) {
336
- const pos = [...parentOffset];
337
- for (const prop of properties) {
338
- if (prop.key === "position" && Array.isArray(prop.value)) {
339
- const arr = prop.value;
340
- pos[0] += arr[0] ?? 0;
341
- pos[1] += arr[1] ?? 0;
342
- pos[2] += arr[2] ?? 0;
343
- }
344
- }
345
- return pos;
346
- }
347
- extractScale(properties) {
348
- for (const prop of properties) {
349
- if (prop.key === "scale") {
350
- if (typeof prop.value === "number") {
351
- return [prop.value, prop.value, prop.value];
352
- }
353
- if (Array.isArray(prop.value)) {
354
- const arr = prop.value;
355
- return [arr[0] ?? 1, arr[1] ?? 1, arr[2] ?? 1];
356
- }
357
- }
358
- }
359
- return [1, 1, 1];
360
- }
361
- extractGroupPosition(group, parentOffset) {
362
- const pos = [...parentOffset];
363
- for (const prop of group.properties) {
364
- if (prop.key === "position" && Array.isArray(prop.value)) {
365
- const arr = prop.value;
366
- pos[0] += arr[0] ?? 0;
367
- pos[1] += arr[1] ?? 0;
368
- pos[2] += arr[2] ?? 0;
369
- }
370
- }
371
- return pos;
372
- }
373
- extractNPCPosition(npc) {
374
- for (const prop of npc.properties) {
375
- if (prop.key === "position" && Array.isArray(prop.value)) {
376
- const arr = prop.value;
377
- return [arr[0] ?? 0, arr[1] ?? 0, arr[2] ?? 0];
378
- }
379
- }
380
- return [0, 0, 0];
381
- }
382
- // ---------------------------------------------------------------------------
383
- // Category/geometry inference
384
- // ---------------------------------------------------------------------------
385
- inferCategory(obj) {
386
- for (const trait of obj.traits ?? []) {
387
- if (this.categoryOverrides[trait.name]) {
388
- return this.categoryOverrides[trait.name].name;
389
- }
390
- }
391
- if (obj.template) return obj.template.toLowerCase();
392
- const geometryTrait = obj.traits?.find(
393
- (t) => ["geometry", "mesh", "model", "shape"].includes(t.name.toLowerCase())
394
- );
395
- if (geometryTrait) {
396
- const shapeType = geometryTrait.config["type"] ?? geometryTrait.config["shape"];
397
- if (typeof shapeType === "string") return shapeType;
398
- }
399
- return obj.name.toLowerCase().replace(/[^a-z0-9]+/g, "_");
400
- }
401
- inferSupercategory(obj) {
402
- for (const trait of obj.traits ?? []) {
403
- const name = trait.name.toLowerCase();
404
- if (["interactive", "clickable", "draggable"].includes(name)) return "interactive";
405
- if (["animated", "moving"].includes(name)) return "dynamic";
406
- if (["physics", "rigidbody", "collider"].includes(name)) return "physics";
407
- if (["light", "emissive", "glow"].includes(name)) return "lighting";
408
- }
409
- return "object";
410
- }
411
- inferGeometry(obj) {
412
- for (const prop of obj.properties) {
413
- if (prop.key === "geometry" || prop.key === "shape") {
414
- if (typeof prop.value === "string") return prop.value;
415
- }
416
- }
417
- const geoTrait = obj.traits?.find(
418
- (t) => t.name.toLowerCase() === "geometry" || t.name.toLowerCase() === "mesh"
419
- );
420
- if (geoTrait) {
421
- const shape = geoTrait.config["type"] ?? geoTrait.config["shape"];
422
- if (typeof shape === "string") return shape;
423
- }
424
- return "cube";
425
- }
426
- // ---------------------------------------------------------------------------
427
- // NPC keypoint generation
428
- // ---------------------------------------------------------------------------
429
- /**
430
- * Generate approximate COCO-format keypoints for an NPC within its bounding box.
431
- * Format: [x1, y1, v1, x2, y2, v2, ...] where v=2 means visible.
432
- */
433
- generateNPCKeypoints(position, bbox) {
434
- const [bx, by, bw, bh] = bbox;
435
- const keypointRatios = [
436
- [0.5, 0.05],
437
- // nose
438
- [0.45, 0.04],
439
- // left_eye
440
- [0.55, 0.04],
441
- // right_eye
442
- [0.4, 0.06],
443
- // left_ear
444
- [0.6, 0.06],
445
- // right_ear
446
- [0.35, 0.22],
447
- // left_shoulder
448
- [0.65, 0.22],
449
- // right_shoulder
450
- [0.28, 0.4],
451
- // left_elbow
452
- [0.72, 0.4],
453
- // right_elbow
454
- [0.25, 0.55],
455
- // left_wrist
456
- [0.75, 0.55],
457
- // right_wrist
458
- [0.38, 0.55],
459
- // left_hip
460
- [0.62, 0.55],
461
- // right_hip
462
- [0.36, 0.75],
463
- // left_knee
464
- [0.64, 0.75],
465
- // right_knee
466
- [0.34, 0.95],
467
- // left_ankle
468
- [0.66, 0.95]
469
- // right_ankle
470
- ];
471
- const keypoints = [];
472
- for (const [rx, ry] of keypointRatios) {
473
- const kx = Math.round(bx + bw * rx);
474
- const ky = Math.round(by + bh * ry);
475
- const visible = 2;
476
- keypoints.push(kx, ky, visible);
477
- }
478
- return keypoints;
479
- }
480
- };
481
- var COCOExporter_default = exportCOCO;
482
-
483
- exports.COCOExporterImpl = COCOExporterImpl;
484
- exports.COCOExporter_default = COCOExporter_default;
485
- exports.exportCOCO = exportCOCO;
486
- exports.exportCOCOString = exportCOCOString;
487
- //# sourceMappingURL=chunk-I6XZ5DZF.cjs.map
488
- //# sourceMappingURL=chunk-I6XZ5DZF.cjs.map