@holoscript/core 6.0.3 → 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.
- package/README.md +40 -40
- package/dist/codebase/index.d.ts +25 -0
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +4 -0
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/index.d.ts +520 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/storage/index.d.ts +24 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +102 -19
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
- package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
- package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
- package/dist/USDZExporter-YA55ZS35.js +0 -707
- package/dist/chunk-26TLYBFD.js +0 -309
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2UX5LRAP.cjs +0 -833
- package/dist/chunk-32TWR3HE.js +0 -70
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-4FCZDTD5.js +0 -610
- package/dist/chunk-4KJ2R7VP.cjs +0 -507
- package/dist/chunk-4SMUJFHL.js +0 -1213
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-65RFOWZI.js +0 -765
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-74YCHHTE.js +0 -1872
- package/dist/chunk-7H5UNJZD.cjs +0 -1973
- package/dist/chunk-7KPI4EKH.cjs +0 -701
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-7N3JIJMT.js +0 -1395
- package/dist/chunk-7X2IEJIE.cjs +0 -2526
- package/dist/chunk-A6GO3DPZ.cjs +0 -1002
- package/dist/chunk-AC4BSHFV.js +0 -765
- package/dist/chunk-AIUXRS74.cjs +0 -3681
- package/dist/chunk-ARNKA274.cjs +0 -130
- package/dist/chunk-AW7WAELW.js +0 -975
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BO2OKHIY.js +0 -6055
- package/dist/chunk-BU5ZAFMC.js +0 -115
- package/dist/chunk-BY3B7ZYV.cjs +0 -457
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-C7BNX4XJ.js +0 -1043
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CMYAWUX3.js +0 -4455
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-CNVM7J3M.js +0 -883
- package/dist/chunk-CO2VM2DK.js +0 -1965
- package/dist/chunk-CQDOF3G7.cjs +0 -1404
- package/dist/chunk-DH5G2JUA.cjs +0 -614
- package/dist/chunk-DIEDKX5B.cjs +0 -660
- package/dist/chunk-DN7UFU63.cjs +0 -172
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-EGIZHYJP.cjs +0 -85
- package/dist/chunk-EJA7G2C4.cjs +0 -428
- package/dist/chunk-ELLQPFAF.js +0 -830
- package/dist/chunk-EMO7HAKJ.cjs +0 -1875
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-EPWRXL6S.js +0 -2522
- package/dist/chunk-EUFLX2PI.js +0 -56956
- package/dist/chunk-F5LVGHNT.js +0 -449
- package/dist/chunk-FEFHPUEM.cjs +0 -6122
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-GC3YU46J.js +0 -762
- package/dist/chunk-H6WMMLQK.cjs +0 -4492
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HBZYCASG.js +0 -4208
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-HHS6FMOU.cjs +0 -3813
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HKCVM6OK.cjs +0 -2237
- package/dist/chunk-HUFNKFA6.js +0 -698
- package/dist/chunk-I3XGTIHM.cjs +0 -1505
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-KDB6BUMB.js +0 -3666
- package/dist/chunk-KUJRR4FJ.js +0 -657
- package/dist/chunk-KYM4XRFG.js +0 -421
- package/dist/chunk-L3Z2HIWJ.cjs +0 -793
- package/dist/chunk-LBPEZQAF.js +0 -2232
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUHGRTZ.js +0 -752
- package/dist/chunk-NKRKT6V2.js +0 -69
- package/dist/chunk-NLPSZT4C.js +0 -630
- package/dist/chunk-NRUB55IT.cjs +0 -771
- package/dist/chunk-NTMZSDXM.cjs +0 -633
- package/dist/chunk-ODGMVILH.js +0 -9662
- package/dist/chunk-PBA6NXCT.cjs +0 -1216
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-PLMYCCA4.js +0 -504
- package/dist/chunk-PPULB4GG.cjs +0 -9728
- package/dist/chunk-PQLGZKMC.cjs +0 -755
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-RE3OKSYF.cjs +0 -424
- package/dist/chunk-RT7LJRSF.cjs +0 -57378
- package/dist/chunk-SPDELRRV.cjs +0 -319
- package/dist/chunk-SUCBB66F.js +0 -229
- package/dist/chunk-TSWTWZ42.cjs +0 -4214
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-V2ILLPHK.cjs +0 -237
- package/dist/chunk-V42NTCFH.js +0 -3645
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-VJVCD5T5.cjs +0 -769
- package/dist/chunk-VK5AXKO3.js +0 -746
- package/dist/chunk-VSXOIUCF.cjs +0 -473
- package/dist/chunk-VZNKJZTT.cjs +0 -749
- package/dist/chunk-W76ETJTI.js +0 -678
- package/dist/chunk-WFJIDI2N.cjs +0 -424
- package/dist/chunk-WN3YF33G.cjs +0 -118
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-WYH4GVZ5.js +0 -1488
- package/dist/chunk-X4YVN7H3.cjs +0 -888
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-XDXZM3ZP.cjs +0 -1046
- package/dist/chunk-XH7SE4HH.cjs +0 -72
- package/dist/chunk-XNMEH2BI.js +0 -126
- package/dist/chunk-XSF76QRU.js +0 -468
- package/dist/chunk-XSUZMPVQ.cjs +0 -682
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-Y5MUAYTO.js +0 -167
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-ZGTGVSTZ.js +0 -422
- package/dist/chunk-ZL6VJ6SN.js +0 -421
- package/dist/cli/holoscript-runner.cjs +0 -2258
- package/dist/cli/holoscript-runner.js +0 -2233
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -29
- package/dist/compiler/agent-inference.js +0 -6
- package/dist/compiler/android-xr.cjs +0 -20
- package/dist/compiler/android-xr.js +0 -10
- package/dist/compiler/android.cjs +0 -21
- package/dist/compiler/android.js +0 -11
- package/dist/compiler/ar.cjs +0 -21
- package/dist/compiler/ar.js +0 -9
- package/dist/compiler/babylon.cjs +0 -18
- package/dist/compiler/babylon.js +0 -12
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -595
- package/dist/compiler/domain-block-utils.js +0 -9
- package/dist/compiler/dtdl.cjs +0 -25
- package/dist/compiler/dtdl.js +0 -9
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -16
- package/dist/compiler/godot.js +0 -10
- package/dist/compiler/incremental.cjs +0 -30
- package/dist/compiler/incremental.js +0 -5
- package/dist/compiler/index.cjs +0 -1522
- package/dist/compiler/index.js +0 -1321
- package/dist/compiler/ios.cjs +0 -21
- package/dist/compiler/ios.js +0 -11
- package/dist/compiler/multi-layer.cjs +0 -27
- package/dist/compiler/multi-layer.js +0 -12
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -16
- package/dist/compiler/openxr.js +0 -10
- package/dist/compiler/playcanvas.cjs +0 -17
- package/dist/compiler/playcanvas.js +0 -11
- package/dist/compiler/r3f.cjs +0 -35
- package/dist/compiler/r3f.js +0 -13
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -22
- package/dist/compiler/sdf.js +0 -10
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -18
- package/dist/compiler/state.js +0 -8
- package/dist/compiler/trait-composition.cjs +0 -27
- package/dist/compiler/trait-composition.js +0 -6
- package/dist/compiler/unity.cjs +0 -16
- package/dist/compiler/unity.js +0 -10
- package/dist/compiler/unreal.cjs +0 -20
- package/dist/compiler/unreal.js +0 -10
- package/dist/compiler/urdf.cjs +0 -46
- package/dist/compiler/urdf.js +0 -10
- package/dist/compiler/usd-physics.cjs +0 -24
- package/dist/compiler/usd-physics.js +0 -7
- package/dist/compiler/visionos.cjs +0 -16
- package/dist/compiler/visionos.js +0 -10
- package/dist/compiler/vrchat.cjs +0 -20
- package/dist/compiler/vrchat.js +0 -10
- package/dist/compiler/vrr.cjs +0 -22
- package/dist/compiler/vrr.js +0 -10
- package/dist/compiler/wasm.cjs +0 -34
- package/dist/compiler/wasm.js +0 -10
- package/dist/compiler/webgpu.cjs +0 -16
- package/dist/compiler/webgpu.js +0 -10
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -67
- package/dist/entries/scripting.js +0 -10
- package/dist/index.cjs +0 -61703
- package/dist/index.js +0 -58652
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/parser.cjs +0 -26
- package/dist/parser.js +0 -9
- package/dist/playwright-7DTEQCBD.cjs +0 -98673
- package/dist/playwright-BIZXMLD2.js +0 -98660
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14331
- package/dist/traits/index.js +0 -12126
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
- package/dist/wot/index.cjs +0 -29
- package/dist/wot/index.js +0 -4
package/dist/chunk-I6XZ5DZF.cjs
DELETED
|
@@ -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
|