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