@holoscript/core 6.0.3 → 6.1.1
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/bin/holoscript.cjs +3 -0
- package/dist/GLTFPipeline-SFIORFJU.js +16 -0
- package/dist/GLTFPipeline-VNNDPONV.cjs +37 -0
- package/dist/{HoloScriptPlusParser-BZR5DELQ.js → HoloScriptPlusParser-7FBIFUFC.js} +6 -5
- package/dist/{HoloScriptPlusParser-SBMYDNXO.cjs → HoloScriptPlusParser-A2W7OCN2.cjs} +17 -16
- package/dist/HoloScriptPlusParser-F2Z56FJR.js +10 -0
- package/dist/HoloScriptPlusParser-WKHRIH6T.cjs +27 -0
- package/dist/{USDZExporter-MHEHXZB4.cjs → USDZExporter-3FWJ25JI.cjs} +344 -16
- package/dist/{USDZExporter-YA55ZS35.js → USDZExporter-D2HQLQYK.js} +344 -16
- package/dist/agents/index.cjs +19 -0
- package/dist/agents/index.d.ts +100 -0
- package/dist/agents/index.js +17 -0
- package/dist/chunk-22W6NGYN.js +725 -0
- package/dist/{chunk-XSUZMPVQ.cjs → chunk-27MPVJVZ.cjs} +64 -28
- package/dist/{chunk-W76ETJTI.js → chunk-2A7FURVO.js} +44 -8
- package/dist/{chunk-C7BNX4XJ.js → chunk-2B7WVIDZ.js} +11 -8
- package/dist/chunk-2BSMSUCE.js +1941 -0
- package/dist/chunk-2HLIGOKU.cjs +5546 -0
- package/dist/{chunk-GC3YU46J.js → chunk-2M2DPHKB.js} +4 -4
- package/dist/{chunk-A6GO3DPZ.cjs → chunk-2YSNA2F2.cjs} +321 -49
- package/dist/{chunk-ZL6VJ6SN.js → chunk-33XCOVE3.js} +5 -5
- package/dist/chunk-3FOKASKO.cjs +348 -0
- package/dist/{chunk-XSF76QRU.js → chunk-4C57PR42.js} +3 -3
- package/dist/chunk-4N4SXXWF.js +769 -0
- package/dist/chunk-4PDEPEQW.cjs +41 -0
- package/dist/chunk-4R6SBXDB.js +45 -0
- package/dist/chunk-4SY77NA4.cjs +413 -0
- package/dist/{chunk-74YCHHTE.js → chunk-4UUKPCY4.js} +670 -116
- package/dist/{chunk-VZNKJZTT.cjs → chunk-52ULD552.cjs} +178 -113
- package/dist/{chunk-65RFOWZI.js → chunk-5CKA5SXU.js} +441 -23
- package/dist/chunk-5FSKKMR7.cjs +2092 -0
- package/dist/{chunk-FF3Q7ADR.js → chunk-5JEU52DW.js} +5 -3
- package/dist/chunk-5N54COB6.cjs +327 -0
- package/dist/chunk-5S7RKFGR.cjs +446 -0
- package/dist/{chunk-EJA7G2C4.cjs → chunk-5WUNN6ZN.cjs} +2 -2
- package/dist/{chunk-ELLQPFAF.js → chunk-6ASWLXXN.js} +24 -10
- package/dist/chunk-6CTRH7HT.cjs +1985 -0
- package/dist/{chunk-ARNKA274.cjs → chunk-6EX3I5P4.cjs} +6 -6
- package/dist/chunk-6FGQNDR4.js +5731 -0
- package/dist/{chunk-X4YVN7H3.cjs → chunk-6KMK2UXT.cjs} +152 -56
- package/dist/{chunk-KUJRR4FJ.js → chunk-6L4VE27M.js} +36 -24
- package/dist/{chunk-RT7LJRSF.cjs → chunk-6S6TKNEA.cjs} +7357 -8312
- package/dist/chunk-77V4GTCA.js +596 -0
- package/dist/{chunk-XH7SE4HH.cjs → chunk-7AD52FRS.cjs} +19 -19
- package/dist/chunk-7OPW2KO7.cjs +639 -0
- package/dist/chunk-A6KINLZJ.js +236 -0
- package/dist/chunk-AIA52I7T.cjs +543 -0
- package/dist/chunk-AIX25INK.cjs +602 -0
- package/dist/{chunk-WN3YF33G.cjs → chunk-AO4I2Z7M.cjs} +15 -17
- package/dist/{chunk-TSWTWZ42.cjs → chunk-BPICAGBV.cjs} +376 -209
- package/dist/chunk-BRQJKJGT.cjs +20 -0
- package/dist/{chunk-3FXV5S25.cjs → chunk-C37BHB7N.cjs} +6 -3
- package/dist/{chunk-XNMEH2BI.js → chunk-CBJY23VL.js} +3 -3
- package/dist/chunk-CIWWXYHZ.cjs +50 -0
- package/dist/{chunk-NTMZSDXM.cjs → chunk-DIL6DDDN.cjs} +101 -45
- package/dist/chunk-DMXC24WV.js +404 -0
- package/dist/{chunk-SPDELRRV.cjs → chunk-DTGBOSEM.cjs} +12 -12
- package/dist/chunk-E7JP3BS3.cjs +61 -0
- package/dist/{chunk-HJJLD366.js → chunk-EKBKLK7P.js} +3 -3
- package/dist/chunk-EKYL4PE3.cjs +404 -0
- package/dist/{chunk-7N3JIJMT.js → chunk-EMMC5CSQ.js} +12 -8
- package/dist/{chunk-EUFLX2PI.js → chunk-EOBB6A4B.js} +7263 -8214
- package/dist/chunk-EOFNVCM6.js +325 -0
- package/dist/{chunk-NKRKT6V2.js → chunk-ER4GATIU.js} +11 -10
- package/dist/{chunk-N5FTS757.cjs → chunk-EXKSFGSX.cjs} +7 -148
- package/dist/{chunk-LK5IAVH6.cjs → chunk-EXUP2BUM.cjs} +27 -27
- package/dist/chunk-FDSGHPAK.js +130 -0
- package/dist/chunk-FEWUHQNM.cjs +144 -0
- package/dist/{chunk-5TOFIR6L.js → chunk-FGGJQRLZ.js} +5 -142
- package/dist/chunk-FHP6LXJS.js +415 -0
- package/dist/{chunk-7LCYLPW2.cjs → chunk-FJPADH77.cjs} +7 -4
- package/dist/{chunk-HBZYCASG.js → chunk-FXKTYFYA.js} +203 -36
- package/dist/chunk-GCMWDSBZ.cjs +729 -0
- package/dist/chunk-GJNCFRJU.cjs +125 -0
- package/dist/{chunk-I3XGTIHM.cjs → chunk-GMP623FG.cjs} +16 -13
- package/dist/{chunk-CNVM7J3M.js → chunk-GN3KDX4W.js} +149 -53
- package/dist/{chunk-WFJIDI2N.cjs → chunk-GQYKQSTC.cjs} +10 -10
- package/dist/chunk-GTU2Z2WW.cjs +262 -0
- package/dist/chunk-GZG4KA4E.js +529 -0
- package/dist/{chunk-DIEDKX5B.cjs → chunk-H3MGK7TX.cjs} +45 -33
- package/dist/{chunk-DN7UFU63.cjs → chunk-H5DZIHJP.cjs} +14 -17
- package/dist/{chunk-DH5G2JUA.cjs → chunk-HANL7K2Q.cjs} +66 -53
- package/dist/{chunk-EGIZHYJP.cjs → chunk-HCCQLAA4.cjs} +2 -13
- package/dist/{chunk-HHS6FMOU.cjs → chunk-HGVXZDSK.cjs} +178 -29
- package/dist/{chunk-LBPEZQAF.js → chunk-HRODTEEO.js} +30 -10
- package/dist/{chunk-ZGTGVSTZ.js → chunk-HYNTS5CP.js} +2 -2
- package/dist/{chunk-RE3OKSYF.cjs → chunk-HZCQO4JM.cjs} +6 -6
- package/dist/{chunk-NCUHGRTZ.js → chunk-I2O7TW6B.js} +12 -8
- package/dist/chunk-IHESJZSW.js +4490 -0
- package/dist/{chunk-7H5UNJZD.cjs → chunk-IRWWS72C.cjs} +64 -22
- package/dist/{chunk-EMO7HAKJ.cjs → chunk-IVIA7K75.cjs} +691 -133
- package/dist/chunk-IVY74O6C.js +247 -0
- package/dist/chunk-J32ZJZJH.js +554 -0
- package/dist/chunk-JD7CIZ33.js +1949 -0
- package/dist/{chunk-7X2IEJIE.cjs → chunk-JIYN45TV.cjs} +41 -42
- package/dist/{chunk-XDXZM3ZP.cjs → chunk-KHPCJRI3.cjs} +24 -21
- package/dist/chunk-KKFZ3B6J.cjs +557 -0
- package/dist/chunk-KPJL34Y7.cjs +186 -0
- package/dist/{chunk-7KPI4EKH.cjs → chunk-KQTPCYTG.cjs} +130 -50
- package/dist/{chunk-F5LVGHNT.js → chunk-KX76JUQY.js} +3 -3
- package/dist/chunk-L4LFINPO.js +623 -0
- package/dist/{chunk-2UX5LRAP.cjs → chunk-L63H3SQ4.cjs} +46 -32
- package/dist/{chunk-NLPSZT4C.js → chunk-LAOCQJ2M.js} +64 -8
- package/dist/chunk-LM2VU56C.cjs +37 -0
- package/dist/chunk-M56JSP4A.js +400 -0
- package/dist/chunk-MBOOR7X4.js +18 -0
- package/dist/{chunk-PQLGZKMC.cjs → chunk-MJVIRCUV.cjs} +31 -27
- package/dist/{chunk-AC4BSHFV.js → chunk-MSMIFMBL.js} +135 -18
- package/dist/{chunk-56IF4NTA.js → chunk-MXFUTKCO.js} +18 -18
- package/dist/{chunk-NRUB55IT.cjs → chunk-MXJ5SS53.cjs} +450 -32
- package/dist/chunk-MXWNGCRS.js +2176 -0
- package/dist/chunk-MYY4PMWX.cjs +264 -0
- package/dist/chunk-N75IH2HY.js +258 -0
- package/dist/chunk-NG77ATEW.cjs +778 -0
- package/dist/chunk-NW5G5FBQ.js +215 -0
- package/dist/{chunk-4FCZDTD5.js → chunk-OEFY723R.js} +29 -16
- package/dist/chunk-OEV5RMZO.cjs +3042 -0
- package/dist/{chunk-VSXOIUCF.cjs → chunk-OIQYIIO3.cjs} +7 -7
- package/dist/{chunk-32TWR3HE.js → chunk-OL46QLBJ.js} +3 -12
- package/dist/chunk-OPZ7XDDI.js +487 -0
- package/dist/chunk-OSYNRVOV.cjs +243 -0
- package/dist/{chunk-HUFNKFA6.js → chunk-P7YIA5LN.js} +93 -13
- package/dist/chunk-PGANYCAG.cjs +220 -0
- package/dist/{chunk-CO2VM2DK.js → chunk-QAVXL2IH.js} +62 -20
- package/dist/{chunk-BO2OKHIY.js → chunk-QCCBXSCE.js} +1640 -1311
- package/dist/{chunk-WYH4GVZ5.js → chunk-QPOQ7VPI.js} +16 -13
- package/dist/{chunk-V42NTCFH.js → chunk-QTPMJRGS.js} +2331 -17
- package/dist/{chunk-FEFHPUEM.cjs → chunk-QWNQ523V.cjs} +1705 -1382
- package/dist/{chunk-VK5AXKO3.js → chunk-R3IVNY6P.js} +166 -101
- package/dist/chunk-R75BSDH7.cjs +50 -0
- package/dist/{chunk-AIUXRS74.cjs → chunk-RMHC2VG7.cjs} +2358 -41
- package/dist/chunk-RUXGBKPS.cjs +4517 -0
- package/dist/{chunk-PLMYCCA4.js → chunk-S5IFXW6E.js} +113 -9
- package/dist/{chunk-27LWW5FU.cjs → chunk-S6YWHCKV.cjs} +5 -5
- package/dist/{chunk-SUCBB66F.js → chunk-SIEXCILW.js} +3 -3
- package/dist/{chunk-CLYEIWA5.cjs → chunk-SLU6UPJI.cjs} +5 -3
- package/dist/{chunk-H6WMMLQK.cjs → chunk-T5J7ZKP3.cjs} +454 -61
- package/dist/chunk-TDCNJHWO.js +341 -0
- package/dist/{chunk-IHOUYQIA.js → chunk-TG7O4WBC.js} +5 -5
- package/dist/chunk-THCK6ECW.js +2085 -0
- package/dist/chunk-TJHVSBP2.js +439 -0
- package/dist/chunk-TK74TR4H.js +5541 -0
- package/dist/{chunk-BU5ZAFMC.js → chunk-U4NBQJBY.js} +11 -13
- package/dist/{chunk-Y5MUAYTO.js → chunk-UD3DSHZM.js} +10 -13
- package/dist/chunk-UDMYRFDZ.js +3038 -0
- package/dist/{chunk-PPULB4GG.cjs → chunk-UOIGFQXC.cjs} +90 -68
- package/dist/{chunk-EPWRXL6S.js → chunk-URG2SJLK.js} +41 -42
- package/dist/{chunk-VJVCD5T5.cjs → chunk-V73NPPTM.cjs} +152 -35
- package/dist/chunk-VECQYRXL.js +474 -0
- package/dist/chunk-VEXPG4WN.js +1989 -0
- package/dist/{chunk-4SMUJFHL.js → chunk-VMLKSV26.js} +9 -6
- package/dist/{chunk-HKCVM6OK.cjs → chunk-VSK7W3O5.cjs} +47 -27
- package/dist/chunk-VVKVQZI6.js +55 -0
- package/dist/{chunk-KDB6BUMB.js → chunk-W55Z7QIX.js} +172 -25
- package/dist/{chunk-BY3B7ZYV.cjs → chunk-W6P2GBHH.cjs} +3 -3
- package/dist/{chunk-PBA6NXCT.cjs → chunk-W6RW64BB.cjs} +11 -8
- package/dist/chunk-WDT3JTGM.cjs +483 -0
- package/dist/{chunk-26TLYBFD.js → chunk-WKX5AMOY.js} +3 -3
- package/dist/chunk-WNNE3PO3.js +34 -0
- package/dist/chunk-WRLUBRKS.cjs +1943 -0
- package/dist/chunk-WRNEH5MO.js +3169 -0
- package/dist/{chunk-54FHG2MX.js → chunk-WRWEX5ZF.js} +7 -4
- package/dist/chunk-X3GJPRVK.cjs +3246 -0
- package/dist/{chunk-4KJ2R7VP.cjs → chunk-XFXGA5IW.cjs} +126 -22
- package/dist/{chunk-L3Z2HIWJ.cjs → chunk-XHIV6326.cjs} +4 -4
- package/dist/chunk-XJAN7CZG.cjs +432 -0
- package/dist/chunk-XL6INWKT.js +121 -0
- package/dist/{chunk-KYM4XRFG.js → chunk-XMWZG36H.js} +4 -4
- package/dist/{chunk-BKIGPPVM.js → chunk-XSFNHP2E.js} +6 -3
- package/dist/{chunk-ODGMVILH.js → chunk-XT6JY5W5.js} +25 -3
- package/dist/chunk-XXZJEFKW.cjs +490 -0
- package/dist/chunk-Y3MWXQSB.cjs +5737 -0
- package/dist/chunk-YF2I3MV3.js +46 -0
- package/dist/{chunk-CMYAWUX3.js → chunk-YIMN575O.js} +445 -53
- package/dist/chunk-YIVFJNYV.js +176 -0
- package/dist/{chunk-V2ILLPHK.cjs → chunk-YKGPCZEE.cjs} +10 -10
- package/dist/chunk-YQELFNJV.js +39 -0
- package/dist/chunk-YSCKYJOB.cjs +2196 -0
- package/dist/chunk-Z5XMPRNC.cjs +5390 -0
- package/dist/{chunk-3FYZOR7S.cjs → chunk-ZDSYWBIE.cjs} +18 -18
- package/dist/{chunk-CQDOF3G7.cjs → chunk-ZKSS47EV.cjs} +24 -19
- package/dist/chunk-ZUL5AVTX.cjs +1993 -0
- package/dist/chunk-ZXBZVXDW.js +5386 -0
- package/dist/{chunk-AW7WAELW.js → chunk-ZZ7RO2UQ.js} +314 -46
- package/dist/cli/holoscript-runner.cjs +203 -206
- package/dist/cli/holoscript-runner.js +147 -150
- package/dist/codebase/index.cjs +1 -1
- package/dist/codebase/index.d.ts +25 -0
- package/dist/codebase/index.js +1 -1
- package/dist/compiler/agent-inference.cjs +10 -8
- package/dist/compiler/agent-inference.js +6 -4
- package/dist/compiler/android-xr.cjs +12 -8
- package/dist/compiler/android-xr.js +10 -6
- package/dist/compiler/android.cjs +12 -9
- package/dist/compiler/android.js +10 -7
- package/dist/compiler/ar.cjs +9 -7
- package/dist/compiler/ar.js +7 -5
- package/dist/compiler/babylon.cjs +12 -9
- package/dist/compiler/babylon.js +11 -8
- package/dist/compiler/business-quest.cjs +43 -0
- package/dist/compiler/business-quest.js +4 -0
- package/dist/compiler/coco.cjs +1 -1
- package/dist/compiler/coco.js +1 -1
- package/dist/compiler/context.cjs +25 -0
- package/dist/compiler/context.d.ts +28 -0
- package/dist/compiler/context.js +8 -0
- package/dist/compiler/domain-block-utils.cjs +161 -151
- package/dist/compiler/domain-block-utils.js +7 -5
- package/dist/compiler/dtdl.cjs +10 -8
- package/dist/compiler/dtdl.js +7 -5
- package/dist/compiler/gltf-pipeline.cjs +9 -9
- package/dist/compiler/gltf-pipeline.js +2 -2
- package/dist/compiler/godot.cjs +9 -7
- package/dist/compiler/godot.js +8 -6
- package/dist/compiler/incremental.cjs +12 -8
- package/dist/compiler/incremental.js +7 -3
- package/dist/compiler/index.cjs +5152 -814
- package/dist/compiler/index.d.ts +404 -21
- package/dist/compiler/index.js +5063 -859
- package/dist/compiler/ios.cjs +11 -9
- package/dist/compiler/ios.js +9 -7
- package/dist/compiler/llm-provider-capabilities.cjs +25 -0
- package/dist/compiler/llm-provider-capabilities.d.ts +43 -0
- package/dist/compiler/llm-provider-capabilities.js +8 -0
- package/dist/compiler/multi-layer.cjs +14 -17
- package/dist/compiler/multi-layer.js +13 -10
- package/dist/compiler/nodetoy.cjs +5 -5
- package/dist/compiler/nodetoy.js +2 -2
- package/dist/compiler/openxr.cjs +10 -7
- package/dist/compiler/openxr.js +9 -6
- package/dist/compiler/playcanvas.cjs +10 -8
- package/dist/compiler/playcanvas.js +9 -7
- package/dist/compiler/r3f.cjs +17 -14
- package/dist/compiler/r3f.d.ts +22 -0
- package/dist/compiler/r3f.js +12 -9
- package/dist/compiler/remotion.cjs +1 -1
- package/dist/compiler/remotion.js +1 -1
- package/dist/compiler/reproducibility.cjs +1 -1
- package/dist/compiler/reproducibility.js +1 -1
- package/dist/compiler/sdf.cjs +10 -8
- package/dist/compiler/sdf.js +8 -6
- package/dist/compiler/semantic-scene.cjs +7 -7
- package/dist/compiler/semantic-scene.js +2 -2
- package/dist/compiler/state.cjs +9 -6
- package/dist/compiler/state.js +7 -4
- package/dist/compiler/trait-composition.cjs +11 -8
- package/dist/compiler/trait-composition.js +7 -4
- package/dist/compiler/unity.cjs +10 -7
- package/dist/compiler/unity.js +9 -6
- package/dist/compiler/unreal.cjs +11 -8
- package/dist/compiler/unreal.js +9 -6
- package/dist/compiler/urdf.cjs +20 -14
- package/dist/compiler/urdf.js +8 -6
- package/dist/compiler/usd-physics.cjs +10 -8
- package/dist/compiler/usd-physics.js +7 -5
- package/dist/compiler/visionos.cjs +10 -7
- package/dist/compiler/visionos.js +9 -6
- package/dist/compiler/vrchat.cjs +10 -8
- package/dist/compiler/vrchat.js +8 -6
- package/dist/compiler/vrr.cjs +10 -8
- package/dist/compiler/vrr.js +8 -6
- package/dist/compiler/wasm.cjs +13 -11
- package/dist/compiler/wasm.js +8 -6
- package/dist/compiler/webgpu.cjs +9 -7
- package/dist/compiler/webgpu.js +8 -6
- package/dist/constants.d.ts +4 -0
- package/dist/coordinators/index.cjs +1266 -0
- package/dist/coordinators/index.d.ts +260 -0
- package/dist/coordinators/index.js +1259 -0
- package/dist/debugger.cjs +9 -7
- package/dist/debugger.js +7 -5
- package/dist/entries/interop.cjs +23 -21
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/interop.js +5 -3
- package/dist/entries/scripting.cjs +18 -17
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/entries/scripting.js +8 -7
- package/dist/hololand/index.cjs +146 -0
- package/dist/hololand/index.d.ts +70 -0
- package/dist/hololand/index.js +5 -0
- package/dist/index.cjs +21396 -39967
- package/dist/index.d.ts +1496 -40
- package/dist/index.js +21066 -40142
- package/dist/math/tropical-spmv.cjs +45 -0
- package/dist/math/tropical-spmv.js +4 -0
- package/dist/math/vec3.cjs +14 -14
- package/dist/math/vec3.js +2 -2
- package/dist/ml-dsa-FSKBTE3W.cjs +1265 -0
- package/dist/ml-dsa-Z7JDKW4L.js +1265 -0
- package/dist/paper-0c-spike/index.cjs +150 -0
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/paper-0c-spike/index.js +141 -0
- package/dist/parser.cjs +45 -10
- package/dist/parser.d.ts +11 -0
- package/dist/parser.js +10 -7
- package/dist/{playwright-7DTEQCBD.cjs → playwright-3AT3AKTV.cjs} +1985 -1985
- package/dist/{playwright-BIZXMLD2.js → playwright-VZPDVUEQ.js} +3 -3
- package/dist/reconstruction/index.cjs +153 -0
- package/dist/reconstruction/index.d.ts +105 -0
- package/dist/reconstruction/index.js +8 -0
- package/dist/runtime.cjs +7 -5
- package/dist/runtime.js +6 -4
- package/dist/self-improvement/index.cjs +563 -0
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/self-improvement/index.js +545 -0
- package/dist/storage/index.cjs +10 -9
- package/dist/storage/index.d.ts +24 -0
- package/dist/storage/index.js +3 -2
- package/dist/testing.cjs +25 -0
- package/dist/testing.d.ts +70 -0
- package/dist/testing.js +4 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/traitDocs/traitDocs.cjs +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traitDocs/traitDocs.js +7 -0
- package/dist/traits/botanical-lotus.cjs +41 -0
- package/dist/traits/botanical-lotus.d.ts +172 -0
- package/dist/traits/botanical-lotus.js +4 -0
- package/dist/traits/engines/index.cjs +520 -0
- package/dist/traits/engines/index.d.ts +111 -0
- package/dist/traits/engines/index.js +380 -0
- package/dist/traits/index.cjs +14387 -4320
- package/dist/traits/index.d.ts +197 -0
- package/dist/traits/index.js +16455 -6958
- package/dist/traits/simulation-solver-factory.cjs +13 -0
- package/dist/traits/simulation-solver-factory.d.ts +23 -0
- package/dist/traits/simulation-solver-factory.js +4 -0
- package/dist/traits/webcam-gaze.cjs +35 -0
- package/dist/traits/webcam-gaze.d.ts +17 -0
- package/dist/traits/webcam-gaze.js +4 -0
- package/dist/type-checker.cjs +6 -5
- package/dist/type-checker.js +4 -3
- package/dist/world/index.cjs +947 -0
- package/dist/world/index.d.ts +147 -0
- package/dist/world/index.js +939 -0
- package/dist/world-model/index.cjs +1446 -0
- package/dist/world-model/index.d.ts +119 -0
- package/dist/world-model/index.js +1414 -0
- package/dist/wot/index.cjs +7 -7
- package/dist/wot/index.js +2 -2
- package/package.json +150 -23
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
|
@@ -1,471 +1,644 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkBPICAGBV_cjs = require('./chunk-BPICAGBV.cjs');
|
|
4
|
+
var chunk5S7RKFGR_cjs = require('./chunk-5S7RKFGR.cjs');
|
|
5
|
+
var chunkOIQYIIO3_cjs = require('./chunk-OIQYIIO3.cjs');
|
|
6
|
+
var chunkAIA52I7T_cjs = require('./chunk-AIA52I7T.cjs');
|
|
7
|
+
var chunkHGVXZDSK_cjs = require('./chunk-HGVXZDSK.cjs');
|
|
8
|
+
var chunkRMHC2VG7_cjs = require('./chunk-RMHC2VG7.cjs');
|
|
9
|
+
var chunkKKFZ3B6J_cjs = require('./chunk-KKFZ3B6J.cjs');
|
|
10
|
+
var chunkHCCQLAA4_cjs = require('./chunk-HCCQLAA4.cjs');
|
|
11
|
+
var ans = require('@holoscript/core-types/ans');
|
|
7
12
|
|
|
8
|
-
// src/compiler/
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
// src/compiler/ThreeJSCompiler.ts
|
|
14
|
+
var ThreeJSCompiler_exports = {};
|
|
15
|
+
chunkHCCQLAA4_cjs.__export(ThreeJSCompiler_exports, {
|
|
16
|
+
ThreeJSCompiler: () => exports.ThreeJSCompiler
|
|
12
17
|
});
|
|
13
|
-
exports.
|
|
14
|
-
var
|
|
15
|
-
"src/compiler/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
var SHAPE_TO_THREE_GEOMETRY; exports.ThreeJSCompiler = void 0;
|
|
19
|
+
var init_ThreeJSCompiler = chunkHCCQLAA4_cjs.__esm({
|
|
20
|
+
"src/compiler/ThreeJSCompiler.ts"() {
|
|
21
|
+
chunkOIQYIIO3_cjs.init_TraitCompositor();
|
|
22
|
+
chunk5S7RKFGR_cjs.init_ProvenanceSemiring();
|
|
23
|
+
chunkRMHC2VG7_cjs.init_CompilerBase();
|
|
24
|
+
SHAPE_TO_THREE_GEOMETRY = {
|
|
25
|
+
sphere: "SphereGeometry",
|
|
26
|
+
orb: "SphereGeometry",
|
|
27
|
+
cube: "BoxGeometry",
|
|
28
|
+
box: "BoxGeometry",
|
|
29
|
+
cylinder: "CylinderGeometry",
|
|
30
|
+
cone: "ConeGeometry",
|
|
31
|
+
pyramid: "ConeGeometry",
|
|
32
|
+
plane: "PlaneGeometry",
|
|
33
|
+
ground: "PlaneGeometry",
|
|
34
|
+
torus: "TorusGeometry",
|
|
35
|
+
ring: "TorusGeometry",
|
|
36
|
+
capsule: "CapsuleGeometry"
|
|
37
|
+
};
|
|
38
|
+
exports.ThreeJSCompiler = class extends chunkRMHC2VG7_cjs.CompilerBase {
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
super();
|
|
41
|
+
this.compilerName = "ThreeJSCompiler";
|
|
42
|
+
this.lines = [];
|
|
43
|
+
this.indentLevel = 0;
|
|
44
|
+
this.options = {
|
|
45
|
+
className: options.className ?? "GeneratedScene",
|
|
46
|
+
enableShadows: options.enableShadows ?? true,
|
|
47
|
+
enablePostProcessing: options.enablePostProcessing ?? false,
|
|
48
|
+
indent: options.indent ?? " ",
|
|
49
|
+
provenanceHash: options.provenanceHash ?? ""
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
getRequiredCapability() {
|
|
53
|
+
return ans.ANSCapabilityPath.R3F;
|
|
54
|
+
}
|
|
55
|
+
compile(composition, agentToken, outputPath) {
|
|
33
56
|
this.validateCompilerAccess(agentToken, outputPath);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return code;
|
|
45
|
-
} else {
|
|
46
|
-
const code = this.generateHTMLPage(composition.name, elements, composition);
|
|
47
|
-
if (options?.generateDocs) {
|
|
48
|
-
return {
|
|
49
|
-
output: code,
|
|
50
|
-
documentation: this.generateDocumentation(composition, code, options.docsOptions)
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return code;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
generateReactComponent(name, objects, composition, options) {
|
|
57
|
-
this._slotImports.clear();
|
|
58
|
-
this._uiImports.clear();
|
|
59
|
-
this._stateFields.clear();
|
|
60
|
-
this._fetchCalls = [];
|
|
61
|
-
this._options = options || {};
|
|
62
|
-
const safeName = name.replace(/[^a-zA-Z0-9]/g, "");
|
|
63
|
-
if (composition?.state?.properties) {
|
|
64
|
-
for (const prop of composition.state.properties) {
|
|
65
|
-
this._stateFields.set(prop.key, prop.value ?? null);
|
|
66
|
-
}
|
|
57
|
+
this.lines = [];
|
|
58
|
+
this.indentLevel = 0;
|
|
59
|
+
this.emit("// Auto-generated by HoloScript ThreeJSCompiler");
|
|
60
|
+
this.emit(
|
|
61
|
+
`// Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}"`
|
|
62
|
+
);
|
|
63
|
+
if (this.options.provenanceHash) {
|
|
64
|
+
this.emit(`// Provenance Hash: ${this.options.provenanceHash}`);
|
|
67
65
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
this.emit("");
|
|
67
|
+
this.emitImports(composition);
|
|
68
|
+
this.emit("");
|
|
69
|
+
this.emit(`export class ${this.options.className} {`);
|
|
70
|
+
this.indent();
|
|
71
|
+
this.emit("private scene: THREE.Scene;");
|
|
72
|
+
this.emit("private renderer: THREE.WebGLRenderer;");
|
|
73
|
+
this.emit("private camera: THREE.PerspectiveCamera;");
|
|
74
|
+
this.emit("private canvas: HTMLCanvasElement;");
|
|
75
|
+
this.emit("private frameId: number = 0;");
|
|
76
|
+
this.emit("");
|
|
77
|
+
this.emit("constructor(canvas: HTMLCanvasElement) {");
|
|
78
|
+
this.indent();
|
|
79
|
+
this.emit("this.canvas = canvas;");
|
|
80
|
+
this.emit("this.scene = new THREE.Scene();");
|
|
81
|
+
this.emit(
|
|
82
|
+
"this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: false });"
|
|
75
83
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
const stateHooks = [];
|
|
83
|
-
for (const [key, value] of this._stateFields) {
|
|
84
|
-
const capitalKey = key.charAt(0).toUpperCase() + key.slice(1);
|
|
85
|
-
const initValue = JSON.stringify(value);
|
|
86
|
-
stateHooks.push(` const [${key}, set${capitalKey}] = useState(${initValue === void 0 ? "null" : initValue});`);
|
|
87
|
-
}
|
|
88
|
-
const fetchEffects = [];
|
|
89
|
-
for (const f of this._fetchCalls) {
|
|
90
|
-
fetchEffects.push(` useEffect(() => {
|
|
91
|
-
fetch(\`${f.endpoint}\`${f.method !== "GET" ? `, { method: '${f.method}' }` : ""})
|
|
92
|
-
.then(r => r.json())
|
|
93
|
-
.then(set${f.name.charAt(0).toUpperCase() + f.name.slice(1)})
|
|
94
|
-
.catch(console.error);
|
|
95
|
-
}, []);`);
|
|
96
|
-
}
|
|
97
|
-
return `${imports.join("\n")}
|
|
98
|
-
|
|
99
|
-
// @generated by HoloScript Native2DCompiler \u2014 DO NOT EDIT
|
|
100
|
-
export function ${safeName}Component() {
|
|
101
|
-
${stateHooks.join("\n")}
|
|
102
|
-
${fetchEffects.join("\n")}
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<div className="holoscript-2d-root w-full h-full">
|
|
106
|
-
${jsx}
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export default ${safeName}Component;
|
|
112
|
-
`;
|
|
113
|
-
}
|
|
114
|
-
generateReactNode(obj) {
|
|
115
|
-
const traits = this.extractTraits(obj);
|
|
116
|
-
if (traits.slot) {
|
|
117
|
-
const slotName = traits.slot.name || obj.name || "Slot";
|
|
118
|
-
const configuredSlot = this._options.slots?.[String(slotName)];
|
|
119
|
-
const component = traits.slot.component || configuredSlot?.component || slotName;
|
|
120
|
-
const importPath = traits.slot.import || configuredSlot?.importPath || `@/components/${component}`;
|
|
121
|
-
this._slotImports.set(slotName, { component, importPath });
|
|
122
|
-
const propsStr = traits.slot.props ? ` {...${JSON.stringify(traits.slot.props)}}` : "";
|
|
123
|
-
return `<div data-holo-slot="${slotName}">
|
|
124
|
-
<${component}${propsStr} />
|
|
125
|
-
</div>`;
|
|
126
|
-
}
|
|
127
|
-
if (traits.fetch) {
|
|
128
|
-
const name = traits.fetch.into || "data";
|
|
129
|
-
const endpoint = traits.fetch.endpoint || "/api/data";
|
|
130
|
-
const method = traits.fetch.method || "GET";
|
|
131
|
-
this._fetchCalls.push({ name, endpoint, method });
|
|
132
|
-
if (!this._stateFields.has(name)) {
|
|
133
|
-
this._stateFields.set(name, null);
|
|
134
|
-
}
|
|
84
|
+
this.emit("this.renderer.setPixelRatio(window.devicePixelRatio);");
|
|
85
|
+
this.emit("this.renderer.setSize(canvas.clientWidth, canvas.clientHeight);");
|
|
86
|
+
if (this.options.enableShadows) {
|
|
87
|
+
this.emit("this.renderer.shadowMap.enabled = true;");
|
|
88
|
+
this.emit("this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;");
|
|
135
89
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"h3"
|
|
149
|
-
].includes(tag)) ; else if (tag === "container") {
|
|
150
|
-
tag = "div";
|
|
151
|
-
} else if (traits.link || tag === "link") {
|
|
152
|
-
tag = "a";
|
|
153
|
-
} else if (traits.button || tag === "button") {
|
|
154
|
-
tag = "button";
|
|
155
|
-
} else if (traits.image || tag === "image") {
|
|
156
|
-
tag = "img";
|
|
157
|
-
} else if (traits.input || tag === "input") {
|
|
158
|
-
tag = "input";
|
|
159
|
-
} else if (traits.text || tag === "text") {
|
|
160
|
-
tag = this.mapTextVariantToTag(traits.text?.variant || "body");
|
|
90
|
+
this.emit(
|
|
91
|
+
"this.camera = new THREE.PerspectiveCamera(75, canvas.clientWidth / canvas.clientHeight, 0.1, 1000);"
|
|
92
|
+
);
|
|
93
|
+
this.emit("this.camera.position.set(0, 2, 10);");
|
|
94
|
+
this.dedent();
|
|
95
|
+
this.emit("}");
|
|
96
|
+
this.emit("");
|
|
97
|
+
this.emit("async build(): Promise<void> {");
|
|
98
|
+
this.indent();
|
|
99
|
+
if (composition.environment) this.emitEnvironment(composition.environment);
|
|
100
|
+
if (composition.lights?.length) {
|
|
101
|
+
for (const light of composition.lights) this.emitLight(light);
|
|
161
102
|
} else {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const combinedStyles = { ...styles };
|
|
174
|
-
if (traits.theme?.style) {
|
|
175
|
-
traits.theme.style.split(";").forEach((rule) => {
|
|
176
|
-
const [key, ...valueParts] = rule.split(":");
|
|
177
|
-
const value = valueParts.join(":");
|
|
178
|
-
if (key && value) {
|
|
179
|
-
const camelKey = key.trim().replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
180
|
-
combinedStyles[camelKey] = value.trim();
|
|
181
|
-
}
|
|
182
|
-
});
|
|
103
|
+
this.emit("// Default lighting");
|
|
104
|
+
this.emit("const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);");
|
|
105
|
+
this.emit("this.scene.add(ambientLight);");
|
|
106
|
+
this.emit("const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);");
|
|
107
|
+
this.emit("dirLight.position.set(5, 10, 5);");
|
|
108
|
+
if (this.options.enableShadows) {
|
|
109
|
+
this.emit("dirLight.castShadow = true;");
|
|
110
|
+
this.emit("dirLight.shadow.mapSize.set(2048, 2048);");
|
|
111
|
+
}
|
|
112
|
+
this.emit("this.scene.add(dirLight);");
|
|
113
|
+
this.emit("");
|
|
183
114
|
}
|
|
184
|
-
if (
|
|
185
|
-
|
|
115
|
+
if (composition.camera) this.emitCamera(composition.camera);
|
|
116
|
+
if (composition.objects?.length) {
|
|
117
|
+
for (const obj of composition.objects) this.emitObject(obj);
|
|
186
118
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
119
|
+
if (composition.spatialGroups?.length) {
|
|
120
|
+
for (const g of composition.spatialGroups) this.emitGroup(g);
|
|
189
121
|
}
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
} catch (e) {
|
|
197
|
-
}
|
|
122
|
+
if (composition.zones?.length) {
|
|
123
|
+
for (const z of composition.zones) this.emitZone(z);
|
|
124
|
+
}
|
|
125
|
+
if (composition.audio?.length) {
|
|
126
|
+
for (const a of composition.audio) this.emitAudio(a);
|
|
198
127
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
128
|
+
this.emitRenderLoop();
|
|
129
|
+
this.dedent();
|
|
130
|
+
this.emit("}");
|
|
131
|
+
this.emit("");
|
|
132
|
+
this.emit("dispose(): void {");
|
|
133
|
+
this.indent();
|
|
134
|
+
this.emit("cancelAnimationFrame(this.frameId);");
|
|
135
|
+
this.emit("this.renderer.dispose();");
|
|
136
|
+
this.emit("this.scene.clear();");
|
|
137
|
+
this.dedent();
|
|
138
|
+
this.emit("}");
|
|
139
|
+
this.dedent();
|
|
140
|
+
this.emit("}");
|
|
141
|
+
return this.lines.join("\n");
|
|
142
|
+
}
|
|
143
|
+
// --- Imports ---
|
|
144
|
+
emitImports(_composition) {
|
|
145
|
+
this.emit('import * as THREE from "three";');
|
|
146
|
+
if (this.options.enablePostProcessing) {
|
|
147
|
+
this.emit('import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js";');
|
|
148
|
+
this.emit(
|
|
149
|
+
'import { RenderPass } from "three/addons/postprocessing/RenderPass.js";'
|
|
150
|
+
);
|
|
151
|
+
this.emit(
|
|
152
|
+
'import { UnrealBloomPass } from "three/addons/postprocessing/UnrealBloomPass.js";'
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// --- Environment ---
|
|
157
|
+
emitEnvironment(env) {
|
|
158
|
+
for (const prop of env.properties) {
|
|
159
|
+
if (prop.key === "background" || prop.key === "skybox" || prop.key === "preset") {
|
|
160
|
+
if (typeof prop.value === "string" && prop.value.startsWith("#")) {
|
|
161
|
+
this.emit(`this.scene.background = new THREE.Color(${this.toThreeColorHex(prop.value)});`);
|
|
209
162
|
} else {
|
|
210
|
-
|
|
163
|
+
this.emit(`// skybox: "${prop.value}" \u2014 load via THREE.CubeTextureLoader`);
|
|
211
164
|
}
|
|
165
|
+
} else if (prop.key === "fog" && typeof prop.value === "object") {
|
|
166
|
+
const fog = prop.value;
|
|
167
|
+
const near = fog.near ?? 10;
|
|
168
|
+
const far = fog.far ?? 100;
|
|
169
|
+
const color = this.toThreeColorHex(fog.color ?? "#cccccc");
|
|
170
|
+
this.emit(`this.scene.fog = new THREE.Fog(${color}, ${near}, ${far});`);
|
|
171
|
+
} else if (prop.key === "ambient_light") {
|
|
172
|
+
this.emit(
|
|
173
|
+
`this.scene.add(new THREE.AmbientLight(0xffffff, ${prop.value ?? 0.5}));`
|
|
174
|
+
);
|
|
175
|
+
} else if (prop.key === "ground") {
|
|
176
|
+
this.emit(
|
|
177
|
+
`const groundGeom = new THREE.PlaneGeometry(100, 100);`
|
|
178
|
+
);
|
|
179
|
+
this.emit(
|
|
180
|
+
`const groundMat = new THREE.MeshStandardMaterial({ color: 0x888888, roughness: 0.8 });`
|
|
181
|
+
);
|
|
182
|
+
this.emit(`const ground = new THREE.Mesh(groundGeom, groundMat);`);
|
|
183
|
+
this.emit(`ground.rotation.x = -Math.PI / 2;`);
|
|
184
|
+
if (this.options.enableShadows) {
|
|
185
|
+
this.emit(`ground.receiveShadow = true;`);
|
|
186
|
+
}
|
|
187
|
+
this.emit(`this.scene.add(ground);`);
|
|
212
188
|
}
|
|
213
189
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
190
|
+
this.emit("");
|
|
191
|
+
}
|
|
192
|
+
// --- Objects ---
|
|
193
|
+
emitObject(obj, parentVar) {
|
|
194
|
+
const v = this.sanitizeName(obj.name);
|
|
195
|
+
let geom = "cube";
|
|
196
|
+
let modelSrc;
|
|
197
|
+
let textContent;
|
|
198
|
+
let position;
|
|
199
|
+
let rotation;
|
|
200
|
+
let scale;
|
|
201
|
+
let size;
|
|
202
|
+
const mat = {};
|
|
203
|
+
for (const p of obj.properties) {
|
|
204
|
+
switch (p.key) {
|
|
205
|
+
case "geometry":
|
|
206
|
+
case "mesh":
|
|
207
|
+
case "type":
|
|
208
|
+
if (typeof p.value === "string") geom = p.value;
|
|
209
|
+
break;
|
|
210
|
+
case "position":
|
|
211
|
+
if (Array.isArray(p.value)) position = p.value;
|
|
212
|
+
break;
|
|
213
|
+
case "rotation":
|
|
214
|
+
if (Array.isArray(p.value)) rotation = p.value;
|
|
215
|
+
break;
|
|
216
|
+
case "scale":
|
|
217
|
+
scale = p.value;
|
|
218
|
+
break;
|
|
219
|
+
case "size":
|
|
220
|
+
size = p.value;
|
|
221
|
+
break;
|
|
222
|
+
case "color":
|
|
223
|
+
mat.color = p.value;
|
|
224
|
+
break;
|
|
225
|
+
case "roughness":
|
|
226
|
+
mat.roughness = p.value;
|
|
227
|
+
break;
|
|
228
|
+
case "metalness":
|
|
229
|
+
case "metallic":
|
|
230
|
+
mat.metalness = p.value;
|
|
231
|
+
break;
|
|
232
|
+
case "opacity":
|
|
233
|
+
mat.opacity = p.value;
|
|
234
|
+
break;
|
|
235
|
+
case "emissive":
|
|
236
|
+
mat.emissive = p.value;
|
|
237
|
+
break;
|
|
238
|
+
case "emissive_intensity":
|
|
239
|
+
case "emissiveIntensity":
|
|
240
|
+
mat.emissiveIntensity = p.value;
|
|
241
|
+
break;
|
|
242
|
+
case "material":
|
|
243
|
+
if (typeof p.value === "object" && p.value !== null)
|
|
244
|
+
Object.assign(mat, p.value);
|
|
245
|
+
break;
|
|
246
|
+
case "model":
|
|
247
|
+
case "src":
|
|
248
|
+
case "source":
|
|
249
|
+
if (typeof p.value === "string") modelSrc = p.value;
|
|
250
|
+
break;
|
|
251
|
+
case "text":
|
|
252
|
+
if (typeof p.value === "string") textContent = p.value;
|
|
253
|
+
break;
|
|
252
254
|
}
|
|
253
255
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
<script>
|
|
274
|
-
function navigate(path) { window.location.href = path; }
|
|
275
|
-
function submitNewsletter(e) { e.preventDefault(); alert('Subscribed!'); }
|
|
276
|
-
</script>
|
|
277
|
-
</body>
|
|
278
|
-
</html>`;
|
|
279
|
-
}
|
|
280
|
-
generateHTMLNode(obj) {
|
|
281
|
-
const node = obj;
|
|
282
|
-
const traits = this.extractTraits(obj);
|
|
283
|
-
const nodeType = typeof node.type === "string" ? node.type.toLowerCase() : void 0;
|
|
284
|
-
let tag = traits.theme?.tag || traits.panel?.tag || nodeType || "div";
|
|
285
|
-
if ([
|
|
286
|
-
"nav",
|
|
287
|
-
"section",
|
|
288
|
-
"main",
|
|
289
|
-
"footer",
|
|
290
|
-
"form",
|
|
291
|
-
"style",
|
|
292
|
-
"a",
|
|
293
|
-
"header",
|
|
294
|
-
"h1",
|
|
295
|
-
"h2",
|
|
296
|
-
"h3"
|
|
297
|
-
].includes(tag)) ; else if (tag === "container") {
|
|
298
|
-
tag = "div";
|
|
299
|
-
} else if (traits.link || tag === "link") {
|
|
300
|
-
tag = "a";
|
|
301
|
-
} else if (traits.button || tag === "button") {
|
|
302
|
-
tag = "button";
|
|
303
|
-
} else if (traits.image || tag === "image") {
|
|
304
|
-
tag = "img";
|
|
305
|
-
} else if (traits.input || tag === "input") {
|
|
306
|
-
tag = "input";
|
|
307
|
-
} else if (traits.text || tag === "text") {
|
|
308
|
-
tag = this.mapTextVariantToTag(traits.text?.variant || "body");
|
|
256
|
+
this.emit(`// Object: ${this.escapeStringValue(obj.name, "TypeScript")}`);
|
|
257
|
+
if (modelSrc) {
|
|
258
|
+
this.emit(`// GLTFLoader required for model: "${modelSrc}"`);
|
|
259
|
+
this.emit(`// import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";`);
|
|
260
|
+
this.emit(`const ${v}Loader = new GLTFLoader();`);
|
|
261
|
+
this.emit(
|
|
262
|
+
`const ${v}Gltf = await new Promise<THREE.Group>((resolve, reject) => { ${v}Loader.load("${modelSrc}", (g) => resolve(g.scene), undefined, reject); });`
|
|
263
|
+
);
|
|
264
|
+
this.emit(`const ${v} = ${v}Gltf;`);
|
|
265
|
+
this.emit(`this.scene.add(${v});`);
|
|
266
|
+
} else if (geom === "text" || textContent) {
|
|
267
|
+
this.emit(`// Text geometry requires THREE.FontLoader / troika-three-text`);
|
|
268
|
+
this.emit(`const ${v}Geom = new THREE.PlaneGeometry(2, 0.5);`);
|
|
269
|
+
this.emit(
|
|
270
|
+
`const ${v}Mat = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true });`
|
|
271
|
+
);
|
|
272
|
+
this.emit(`const ${v} = new THREE.Mesh(${v}Geom, ${v}Mat);`);
|
|
273
|
+
this.emit(`// Text content: "${textContent || ""}"`);
|
|
274
|
+
this.emit(`this.scene.add(${v});`);
|
|
309
275
|
} else {
|
|
310
|
-
|
|
276
|
+
const geomArgs = this.geometryArgs(geom, size);
|
|
277
|
+
const geomClass = SHAPE_TO_THREE_GEOMETRY[geom] ?? "BoxGeometry";
|
|
278
|
+
this.emit(`const ${v}Geom = new THREE.${geomClass}(${geomArgs});`);
|
|
279
|
+
const matProps = this.buildMaterialProps(mat);
|
|
280
|
+
this.emit(`const ${v}Mat = new THREE.MeshStandardMaterial({ ${matProps} });`);
|
|
281
|
+
this.emit(`const ${v} = new THREE.Mesh(${v}Geom, ${v}Mat);`);
|
|
282
|
+
this.emit(`this.scene.add(${v});`);
|
|
311
283
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
284
|
+
if (position)
|
|
285
|
+
this.emit(`${v}.position.set(${position[0]}, ${position[1]}, ${position[2]});`);
|
|
286
|
+
if (rotation)
|
|
287
|
+
this.emit(`${v}.rotation.set(${rotation[0]}, ${rotation[1]}, ${rotation[2]});`);
|
|
288
|
+
if (scale) {
|
|
289
|
+
if (Array.isArray(scale)) {
|
|
290
|
+
this.emit(`${v}.scale.set(${scale[0]}, ${scale[1]}, ${scale[2]});`);
|
|
291
|
+
} else {
|
|
292
|
+
this.emit(`${v}.scale.setScalar(${scale});`);
|
|
293
|
+
}
|
|
317
294
|
}
|
|
318
|
-
if (
|
|
319
|
-
|
|
295
|
+
if (parentVar) this.emit(`${parentVar}.add(${v});`);
|
|
296
|
+
const physicsTraits = (obj.traits || []).filter(
|
|
297
|
+
(t) => t.name === "physics" || t.name === "collidable"
|
|
298
|
+
);
|
|
299
|
+
if (physicsTraits.length > 0) {
|
|
300
|
+
const semiring = new chunk5S7RKFGR_cjs.ProvenanceSemiring();
|
|
301
|
+
const applications = physicsTraits.map((t) => ({
|
|
302
|
+
name: t.name,
|
|
303
|
+
config: t.config || {},
|
|
304
|
+
context: obj.provenance?.context
|
|
305
|
+
}));
|
|
306
|
+
const { config: physicsConfig } = semiring.add(applications);
|
|
307
|
+
const isStatic = (physicsConfig.type || "dynamic") === "static";
|
|
308
|
+
this.emit(
|
|
309
|
+
`// @physics \u2014 mass: ${physicsConfig.mass ?? 1}, type: ${isStatic ? "static" : "dynamic"}`
|
|
310
|
+
);
|
|
311
|
+
this.emit(
|
|
312
|
+
`// Use a physics library (cannon-es, rapier, ammo.js) to attach a rigid body to ${v}`
|
|
313
|
+
);
|
|
320
314
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
315
|
+
for (const trait of obj.traits || []) {
|
|
316
|
+
if (trait.name === "physics" || trait.name === "collidable") {
|
|
317
|
+
continue;
|
|
318
|
+
} else if (trait.name === "shadow") {
|
|
319
|
+
if (this.options.enableShadows) {
|
|
320
|
+
this.emit(`${v}.castShadow = true;`);
|
|
321
|
+
this.emit(`${v}.receiveShadow = true;`);
|
|
322
|
+
}
|
|
323
|
+
} else if (trait.name === "grabbable") {
|
|
324
|
+
this.emit(`// @grabbable \u2014 attach raycaster pointer-down handler to ${v}`);
|
|
325
|
+
} else if (trait.name === "hoverable") {
|
|
326
|
+
this.emit(`// @hoverable \u2014 attach raycaster pointer-move handler to ${v}`);
|
|
327
|
+
} else if (trait.name === "gaussian_splat") {
|
|
328
|
+
this.emit(
|
|
329
|
+
`// @gaussian_splat \u2014 use @mkkellogg/gaussian-splats-3d or three-splat for ${v}`
|
|
330
|
+
);
|
|
331
|
+
} else if (trait.name === "object_tracking") {
|
|
332
|
+
this.emit(`// @object_tracking \u2014 WebXR hit-test for ${v}`);
|
|
333
|
+
} else if (trait.name === "eye_tracked") {
|
|
334
|
+
this.emit(`// @eye_tracked \u2014 WebXR eye tracking for ${v}`);
|
|
335
|
+
} else if (trait.name === "controlnet") {
|
|
336
|
+
this.emit(
|
|
337
|
+
`// @controlnet(model: "${trait.config?.model || "canny"}") \u2014 route to inference API for ${v}`
|
|
338
|
+
);
|
|
339
|
+
} else {
|
|
340
|
+
this.emit(
|
|
341
|
+
`// @${this.escapeStringValue(trait.name, "TypeScript")}: ${JSON.stringify(trait.config || {})}`
|
|
342
|
+
);
|
|
325
343
|
}
|
|
326
|
-
props += ` style="${styleStr}"`;
|
|
327
344
|
}
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
345
|
+
if (obj.traits && obj.traits.length > 0) {
|
|
346
|
+
const traitNames = obj.traits.map((t) => t.name);
|
|
347
|
+
const compositor = new chunkOIQYIIO3_cjs.TraitCompositor();
|
|
348
|
+
const composed = compositor.compose(traitNames);
|
|
349
|
+
if (Object.keys(composed).length > 0) {
|
|
350
|
+
this.emit(`// TraitCompositor: composed ${traitNames.join(" + ")}`);
|
|
351
|
+
const composedProps = this.buildMaterialProps(composed);
|
|
352
|
+
if (composedProps) {
|
|
353
|
+
this.emit(
|
|
354
|
+
`Object.assign((${v}.material as THREE.MeshStandardMaterial), { ${composedProps} });`
|
|
355
|
+
);
|
|
336
356
|
}
|
|
337
|
-
} catch (e) {
|
|
338
357
|
}
|
|
339
358
|
}
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
extractTraits(obj) {
|
|
363
|
-
const map = {};
|
|
364
|
-
const node = obj;
|
|
365
|
-
if (!node.traits) return map;
|
|
366
|
-
for (const t of node.traits) {
|
|
367
|
-
map[t.name] = t.config || {};
|
|
368
|
-
if (t.name === "tailwind" && typeof t.config === "string") {
|
|
369
|
-
map[t.name] = { classes: t.config };
|
|
359
|
+
if (obj.children?.length) {
|
|
360
|
+
for (const child of obj.children) this.emitObject(child, v);
|
|
361
|
+
}
|
|
362
|
+
this.emit("");
|
|
363
|
+
}
|
|
364
|
+
// --- Groups ---
|
|
365
|
+
emitGroup(group, parentVar) {
|
|
366
|
+
const v = this.sanitizeName(group.name);
|
|
367
|
+
this.emit(
|
|
368
|
+
`const ${v} = new THREE.Group(); // "${this.escapeStringValue(group.name, "TypeScript")}"`
|
|
369
|
+
);
|
|
370
|
+
for (const p of group.properties) {
|
|
371
|
+
if (p.key === "position" && Array.isArray(p.value))
|
|
372
|
+
this.emit(`${v}.position.set(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
|
|
373
|
+
else if (p.key === "rotation" && Array.isArray(p.value))
|
|
374
|
+
this.emit(`${v}.rotation.set(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
|
|
375
|
+
else if (p.key === "scale") {
|
|
376
|
+
if (Array.isArray(p.value)) {
|
|
377
|
+
this.emit(`${v}.scale.set(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
|
|
378
|
+
} else {
|
|
379
|
+
this.emit(`${v}.scale.setScalar(${p.value});`);
|
|
380
|
+
}
|
|
370
381
|
}
|
|
371
382
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return "h1";
|
|
378
|
-
case "h2":
|
|
379
|
-
return "h2";
|
|
380
|
-
case "h3":
|
|
381
|
-
return "h3";
|
|
382
|
-
case "subtitle":
|
|
383
|
-
return "h4";
|
|
384
|
-
case "caption":
|
|
385
|
-
return "span";
|
|
386
|
-
case "emoji":
|
|
387
|
-
return "span";
|
|
388
|
-
default:
|
|
389
|
-
return "p";
|
|
383
|
+
const addTarget = parentVar ? parentVar : "this.scene";
|
|
384
|
+
this.emit(`${addTarget}.add(${v});`);
|
|
385
|
+
for (const obj of group.objects) this.emitObject(obj, v);
|
|
386
|
+
if (group.groups) {
|
|
387
|
+
for (const sub of group.groups) this.emitGroup(sub, v);
|
|
390
388
|
}
|
|
389
|
+
this.emit("");
|
|
391
390
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
391
|
+
// --- Lights ---
|
|
392
|
+
emitLight(light) {
|
|
393
|
+
const v = this.sanitizeName(light.name);
|
|
394
|
+
let position;
|
|
395
|
+
let color;
|
|
396
|
+
let intensity;
|
|
397
|
+
let direction;
|
|
398
|
+
let castShadow = false;
|
|
399
|
+
let angle;
|
|
400
|
+
let distance;
|
|
401
|
+
let penumbra;
|
|
402
|
+
for (const p of light.properties) {
|
|
403
|
+
if (p.key === "position" && Array.isArray(p.value)) position = p.value;
|
|
404
|
+
else if (p.key === "color") color = p.value;
|
|
405
|
+
else if (p.key === "intensity") intensity = p.value;
|
|
406
|
+
else if (p.key === "direction" && Array.isArray(p.value)) direction = p.value;
|
|
407
|
+
else if (p.key === "cast_shadow" || p.key === "castShadow") castShadow = !!p.value;
|
|
408
|
+
else if (p.key === "angle") angle = p.value;
|
|
409
|
+
else if (p.key === "distance") distance = p.value;
|
|
410
|
+
else if (p.key === "penumbra") penumbra = p.value;
|
|
411
|
+
}
|
|
412
|
+
const colorHex = this.toThreeColorHex(color ?? "#ffffff");
|
|
413
|
+
const intStr = intensity !== void 0 ? String(intensity) : "1.0";
|
|
414
|
+
switch (light.lightType) {
|
|
415
|
+
case "hemisphere":
|
|
416
|
+
case "ambient":
|
|
417
|
+
this.emit(`const ${v} = new THREE.AmbientLight(${colorHex}, ${intStr});`);
|
|
418
|
+
this.emit(`this.scene.add(${v});`);
|
|
419
|
+
break;
|
|
420
|
+
case "directional": {
|
|
421
|
+
this.emit(`const ${v} = new THREE.DirectionalLight(${colorHex}, ${intStr});`);
|
|
422
|
+
const pos = position ?? direction ?? [5, 10, 5];
|
|
423
|
+
this.emit(`${v}.position.set(${pos[0]}, ${pos[1]}, ${pos[2]});`);
|
|
424
|
+
if (castShadow && this.options.enableShadows) {
|
|
425
|
+
this.emit(`${v}.castShadow = true;`);
|
|
426
|
+
this.emit(`${v}.shadow.mapSize.set(2048, 2048);`);
|
|
427
|
+
this.emit(`${v}.shadow.camera.near = 0.1;`);
|
|
428
|
+
this.emit(`${v}.shadow.camera.far = 500;`);
|
|
429
|
+
}
|
|
430
|
+
this.emit(`this.scene.add(${v});`);
|
|
431
|
+
break;
|
|
400
432
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
433
|
+
case "point": {
|
|
434
|
+
const distStr = distance !== void 0 ? String(distance) : "0";
|
|
435
|
+
this.emit(
|
|
436
|
+
`const ${v} = new THREE.PointLight(${colorHex}, ${intStr}, ${distStr});`
|
|
437
|
+
);
|
|
438
|
+
if (position) this.emit(`${v}.position.set(${position[0]}, ${position[1]}, ${position[2]});`);
|
|
439
|
+
if (castShadow && this.options.enableShadows) this.emit(`${v}.castShadow = true;`);
|
|
440
|
+
this.emit(`this.scene.add(${v});`);
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
case "spot": {
|
|
444
|
+
const angleRad = angle !== void 0 ? `${angle} * Math.PI / 180` : "Math.PI / 6";
|
|
445
|
+
const pen = penumbra ?? 0.1;
|
|
446
|
+
this.emit(
|
|
447
|
+
`const ${v} = new THREE.SpotLight(${colorHex}, ${intStr}, ${distance ?? 0}, ${angleRad}, ${pen});`
|
|
448
|
+
);
|
|
449
|
+
if (position) this.emit(`${v}.position.set(${position[0]}, ${position[1]}, ${position[2]});`);
|
|
450
|
+
if (castShadow && this.options.enableShadows) this.emit(`${v}.castShadow = true;`);
|
|
451
|
+
this.emit(`this.scene.add(${v});`);
|
|
452
|
+
break;
|
|
404
453
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
if (
|
|
423
|
-
if (
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
default:
|
|
455
|
+
this.emit(`// Light "${light.lightType}" not mapped \u2014 using AmbientLight fallback`);
|
|
456
|
+
this.emit(`const ${v} = new THREE.AmbientLight(${colorHex}, ${intStr});`);
|
|
457
|
+
this.emit(`this.scene.add(${v});`);
|
|
458
|
+
}
|
|
459
|
+
this.emit("");
|
|
460
|
+
}
|
|
461
|
+
// --- Camera ---
|
|
462
|
+
emitCamera(camera) {
|
|
463
|
+
let position;
|
|
464
|
+
let target;
|
|
465
|
+
let fov;
|
|
466
|
+
let near;
|
|
467
|
+
let far;
|
|
468
|
+
for (const p of camera.properties) {
|
|
469
|
+
if (p.key === "position" && Array.isArray(p.value)) position = p.value;
|
|
470
|
+
else if (p.key === "target" && Array.isArray(p.value)) target = p.value;
|
|
471
|
+
else if (p.key === "fov") fov = p.value;
|
|
472
|
+
else if (p.key === "near") near = p.value;
|
|
473
|
+
else if (p.key === "far") far = p.value;
|
|
474
|
+
}
|
|
475
|
+
if (fov !== void 0) this.emit(`this.camera.fov = ${fov};`);
|
|
476
|
+
if (near !== void 0) this.emit(`this.camera.near = ${near};`);
|
|
477
|
+
if (far !== void 0) this.emit(`this.camera.far = ${far};`);
|
|
478
|
+
if (position)
|
|
479
|
+
this.emit(
|
|
480
|
+
`this.camera.position.set(${position[0]}, ${position[1]}, ${position[2]});`
|
|
481
|
+
);
|
|
482
|
+
if (target) {
|
|
483
|
+
this.emit(
|
|
484
|
+
`this.camera.lookAt(new THREE.Vector3(${target[0]}, ${target[1]}, ${target[2]}));`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
this.emit(`this.camera.updateProjectionMatrix();`);
|
|
488
|
+
this.emit("");
|
|
489
|
+
}
|
|
490
|
+
// --- Audio ---
|
|
491
|
+
emitAudio(audio) {
|
|
492
|
+
const v = this.sanitizeName(audio.name);
|
|
493
|
+
let src = "";
|
|
494
|
+
let loop = false;
|
|
495
|
+
let volume = 1;
|
|
496
|
+
let spatial = false;
|
|
497
|
+
for (const p of audio.properties) {
|
|
498
|
+
if (p.key === "src" || p.key === "source") src = String(p.value);
|
|
499
|
+
else if (p.key === "loop") loop = !!p.value;
|
|
500
|
+
else if (p.key === "volume") volume = p.value;
|
|
501
|
+
else if (p.key === "spatial") spatial = !!p.value;
|
|
502
|
+
}
|
|
503
|
+
if (spatial) {
|
|
504
|
+
this.emit(`const ${v}Listener = new THREE.AudioListener();`);
|
|
505
|
+
this.emit(`this.camera.add(${v}Listener);`);
|
|
506
|
+
this.emit(`const ${v} = new THREE.PositionalAudio(${v}Listener);`);
|
|
507
|
+
} else {
|
|
508
|
+
this.emit(`const ${v}Listener = new THREE.AudioListener();`);
|
|
509
|
+
this.emit(`this.camera.add(${v}Listener);`);
|
|
510
|
+
this.emit(`const ${v} = new THREE.Audio(${v}Listener);`);
|
|
511
|
+
}
|
|
512
|
+
this.emit(`const ${v}Loader = new THREE.AudioLoader();`);
|
|
513
|
+
this.emit(
|
|
514
|
+
`${v}Loader.load("${src}", (buffer) => { ${v}.setBuffer(buffer); ${v}.setLoop(${loop}); ${v}.setVolume(${volume}); ${v}.play(); });`
|
|
515
|
+
);
|
|
516
|
+
this.emit("");
|
|
517
|
+
}
|
|
518
|
+
// --- Zones ---
|
|
519
|
+
emitZone(zone) {
|
|
520
|
+
const v = this.sanitizeName(zone.name);
|
|
521
|
+
let shape = "box";
|
|
522
|
+
let position;
|
|
523
|
+
let size;
|
|
524
|
+
let radius;
|
|
525
|
+
for (const p of zone.properties) {
|
|
526
|
+
if (p.key === "shape") shape = String(p.value);
|
|
527
|
+
else if (p.key === "position" && Array.isArray(p.value)) position = p.value;
|
|
528
|
+
else if (p.key === "size") size = p.value;
|
|
529
|
+
else if (p.key === "radius") radius = p.value;
|
|
530
|
+
}
|
|
531
|
+
if (shape === "sphere") {
|
|
532
|
+
this.emit(
|
|
533
|
+
`const ${v}Geom = new THREE.SphereGeometry(${radius ?? 5}, 16, 16);`
|
|
460
534
|
);
|
|
535
|
+
} else {
|
|
536
|
+
const s = Array.isArray(size) ? size : [size ?? 5, size ?? 5, size ?? 5];
|
|
537
|
+
this.emit(`const ${v}Geom = new THREE.BoxGeometry(${s[0]}, ${s[1]}, ${s[2]});`);
|
|
538
|
+
}
|
|
539
|
+
this.emit(
|
|
540
|
+
`const ${v}Mat = new THREE.MeshBasicMaterial({ color: 0x00ff00, wireframe: true, visible: false });`
|
|
541
|
+
);
|
|
542
|
+
this.emit(`const ${v} = new THREE.Mesh(${v}Geom, ${v}Mat);`);
|
|
543
|
+
if (position) this.emit(`${v}.position.set(${position[0]}, ${position[1]}, ${position[2]});`);
|
|
544
|
+
this.emit(`this.scene.add(${v}); // trigger zone (invisible)`);
|
|
545
|
+
if (zone.handlers?.length) {
|
|
546
|
+
this.emit(
|
|
547
|
+
`// Zone handlers: attach raycaster intersection checks for ${v}`
|
|
548
|
+
);
|
|
549
|
+
for (const h of zone.handlers) {
|
|
550
|
+
this.emit(
|
|
551
|
+
`// on ${this.escapeStringValue(h.event, "TypeScript")}: implement via raycaster.intersectObject(${v})`
|
|
552
|
+
);
|
|
553
|
+
}
|
|
461
554
|
}
|
|
462
|
-
|
|
463
|
-
|
|
555
|
+
this.emit("");
|
|
556
|
+
}
|
|
557
|
+
// --- Render Loop ---
|
|
558
|
+
emitRenderLoop() {
|
|
559
|
+
this.emit("// Render loop");
|
|
560
|
+
this.emit("const animate = (): void => {");
|
|
561
|
+
this.indent();
|
|
562
|
+
this.emit("this.frameId = requestAnimationFrame(animate);");
|
|
563
|
+
this.emit("this.renderer.render(this.scene, this.camera);");
|
|
564
|
+
this.dedent();
|
|
565
|
+
this.emit("};");
|
|
566
|
+
this.emit("animate();");
|
|
567
|
+
this.emit("");
|
|
568
|
+
this.emit("// Resize handler");
|
|
569
|
+
this.emit('window.addEventListener("resize", () => {');
|
|
570
|
+
this.indent();
|
|
571
|
+
this.emit("const w = this.canvas.clientWidth, h = this.canvas.clientHeight;");
|
|
572
|
+
this.emit("this.renderer.setSize(w, h);");
|
|
573
|
+
this.emit("this.camera.aspect = w / h;");
|
|
574
|
+
this.emit("this.camera.updateProjectionMatrix();");
|
|
575
|
+
this.dedent();
|
|
576
|
+
this.emit("});");
|
|
577
|
+
}
|
|
578
|
+
// --- Value Helpers ---
|
|
579
|
+
toThreeColorHex(value) {
|
|
580
|
+
if (typeof value === "string" && value.startsWith("#")) {
|
|
581
|
+
return `0x${value.slice(1)}`;
|
|
464
582
|
}
|
|
465
|
-
return
|
|
583
|
+
if (typeof value === "number") return `0x${value.toString(16).padStart(6, "0")}`;
|
|
584
|
+
return "0xffffff";
|
|
466
585
|
}
|
|
467
|
-
|
|
468
|
-
|
|
586
|
+
buildMaterialProps(mat) {
|
|
587
|
+
const parts = [];
|
|
588
|
+
if (mat.color !== void 0) {
|
|
589
|
+
parts.push(`color: ${this.toThreeColorHex(mat.color)}`);
|
|
590
|
+
}
|
|
591
|
+
if (mat.roughness !== void 0) parts.push(`roughness: ${mat.roughness}`);
|
|
592
|
+
if (mat.metalness !== void 0) parts.push(`metalness: ${mat.metalness}`);
|
|
593
|
+
if (mat.opacity !== void 0 && mat.opacity < 1) {
|
|
594
|
+
parts.push(`opacity: ${mat.opacity}`, "transparent: true");
|
|
595
|
+
}
|
|
596
|
+
if (mat.emissive !== void 0) {
|
|
597
|
+
parts.push(`emissive: ${this.toThreeColorHex(mat.emissive)}`);
|
|
598
|
+
}
|
|
599
|
+
if (mat.emissiveIntensity !== void 0) {
|
|
600
|
+
parts.push(`emissiveIntensity: ${mat.emissiveIntensity}`);
|
|
601
|
+
}
|
|
602
|
+
return parts.join(", ");
|
|
603
|
+
}
|
|
604
|
+
geometryArgs(type, size) {
|
|
605
|
+
const s = typeof size === "number" ? size : 1;
|
|
606
|
+
switch (type) {
|
|
607
|
+
case "sphere":
|
|
608
|
+
case "orb":
|
|
609
|
+
return `${s * 0.5}, 32, 32`;
|
|
610
|
+
case "cube":
|
|
611
|
+
case "box":
|
|
612
|
+
return `${s}, ${s}, ${s}`;
|
|
613
|
+
case "cylinder":
|
|
614
|
+
return `${s * 0.5}, ${s * 0.5}, ${s * 2}, 32`;
|
|
615
|
+
case "cone":
|
|
616
|
+
case "pyramid":
|
|
617
|
+
return `${s * 0.5}, ${s * 2}, ${type === "pyramid" ? 4 : 32}`;
|
|
618
|
+
case "plane":
|
|
619
|
+
case "ground":
|
|
620
|
+
return `${s}, ${s}`;
|
|
621
|
+
case "torus":
|
|
622
|
+
case "ring":
|
|
623
|
+
return `${s * 0.5}, ${s * 0.15}, 16, 64`;
|
|
624
|
+
case "capsule":
|
|
625
|
+
return `${s * 0.3}, ${s * 0.6}, 4, 16`;
|
|
626
|
+
default:
|
|
627
|
+
return `${s}, ${s}, ${s}`;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
// --- Emit Helpers ---
|
|
631
|
+
emit(line) {
|
|
632
|
+
this.lines.push(this.options.indent.repeat(this.indentLevel) + line);
|
|
633
|
+
}
|
|
634
|
+
indent() {
|
|
635
|
+
this.indentLevel++;
|
|
636
|
+
}
|
|
637
|
+
dedent() {
|
|
638
|
+
this.indentLevel = Math.max(0, this.indentLevel - 1);
|
|
639
|
+
}
|
|
640
|
+
sanitizeName(name) {
|
|
641
|
+
return name.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
469
642
|
}
|
|
470
643
|
};
|
|
471
644
|
}
|
|
@@ -473,16 +646,15 @@ export default ${safeName}Component;
|
|
|
473
646
|
|
|
474
647
|
// src/compiler/A2AAgentCardCompiler.ts
|
|
475
648
|
var A2AAgentCardCompiler_exports = {};
|
|
476
|
-
|
|
649
|
+
chunkHCCQLAA4_cjs.__export(A2AAgentCardCompiler_exports, {
|
|
477
650
|
A2AAgentCardCompiler: () => exports.A2AAgentCardCompiler,
|
|
478
651
|
default: () => A2AAgentCardCompiler_default
|
|
479
652
|
});
|
|
480
653
|
exports.A2AAgentCardCompiler = void 0; var A2AAgentCardCompiler_default;
|
|
481
|
-
var init_A2AAgentCardCompiler =
|
|
654
|
+
var init_A2AAgentCardCompiler = chunkHCCQLAA4_cjs.__esm({
|
|
482
655
|
"src/compiler/A2AAgentCardCompiler.ts"() {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
exports.A2AAgentCardCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
|
|
656
|
+
chunkRMHC2VG7_cjs.init_CompilerBase();
|
|
657
|
+
exports.A2AAgentCardCompiler = class extends chunkRMHC2VG7_cjs.CompilerBase {
|
|
486
658
|
constructor(options = {}) {
|
|
487
659
|
super();
|
|
488
660
|
this.compilerName = "A2AAgentCardCompiler";
|
|
@@ -507,7 +679,7 @@ var init_A2AAgentCardCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
507
679
|
};
|
|
508
680
|
}
|
|
509
681
|
getRequiredCapability() {
|
|
510
|
-
return
|
|
682
|
+
return ans.ANSCapabilityPath.A2A_AGENT_CARD;
|
|
511
683
|
}
|
|
512
684
|
/**
|
|
513
685
|
* Compile a HoloComposition AST into an A2A Agent Card JSON string.
|
|
@@ -635,9 +807,7 @@ var init_A2AAgentCardCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
635
807
|
}
|
|
636
808
|
}
|
|
637
809
|
if (examples.length === 0) {
|
|
638
|
-
examples.push(
|
|
639
|
-
`Create a ${this.escapeStringValue(template.name, "JSON")} instance`
|
|
640
|
-
);
|
|
810
|
+
examples.push(`Create a ${this.escapeStringValue(template.name, "JSON")} instance`);
|
|
641
811
|
}
|
|
642
812
|
return {
|
|
643
813
|
id: this.sanitizeId(template.name),
|
|
@@ -665,9 +835,7 @@ var init_A2AAgentCardCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
665
835
|
}
|
|
666
836
|
const examples = [];
|
|
667
837
|
if (objTraitNames.includes("sensor")) {
|
|
668
|
-
examples.push(
|
|
669
|
-
`Read sensor data from ${this.escapeStringValue(obj.name, "JSON")}`
|
|
670
|
-
);
|
|
838
|
+
examples.push(`Read sensor data from ${this.escapeStringValue(obj.name, "JSON")}`);
|
|
671
839
|
}
|
|
672
840
|
if (objTraitNames.includes("networked")) {
|
|
673
841
|
examples.push(
|
|
@@ -758,26 +926,10 @@ var init_A2AAgentCardCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
758
926
|
* Compile a domain-specific block into a specialized skill.
|
|
759
927
|
*/
|
|
760
928
|
compileDomainBlockSkill(block) {
|
|
761
|
-
const domainTags = {
|
|
762
|
-
iot: ["iot", "sensor", "telemetry", "digital-twin"],
|
|
763
|
-
robotics: ["robotics", "control", "actuator", "simulation"],
|
|
764
|
-
dataviz: ["data-visualization", "analytics", "dashboard"],
|
|
765
|
-
education: ["education", "learning", "curriculum"],
|
|
766
|
-
healthcare: ["healthcare", "medical", "monitoring"],
|
|
767
|
-
music: ["music", "audio", "composition"],
|
|
768
|
-
architecture: ["architecture", "building", "design"],
|
|
769
|
-
web3: ["web3", "blockchain", "smart-contract"],
|
|
770
|
-
physics: ["physics", "simulation", "collision"],
|
|
771
|
-
material: ["material", "rendering", "pbr"],
|
|
772
|
-
vfx: ["vfx", "particles", "visual-effects"],
|
|
773
|
-
weather: ["weather", "atmosphere", "environmental"],
|
|
774
|
-
navigation: ["navigation", "pathfinding", "ai"],
|
|
775
|
-
procedural: ["procedural", "generation", "algorithms"]
|
|
776
|
-
};
|
|
777
929
|
const tags = [
|
|
778
930
|
block.domain,
|
|
779
931
|
block.keyword,
|
|
780
|
-
...domainTags
|
|
932
|
+
...block.domainTags?.length ? block.domainTags : [],
|
|
781
933
|
...block.traits
|
|
782
934
|
];
|
|
783
935
|
return {
|
|
@@ -945,9 +1097,7 @@ var init_A2AAgentCardCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
945
1097
|
*/
|
|
946
1098
|
generateDescription(composition) {
|
|
947
1099
|
const parts = [];
|
|
948
|
-
parts.push(
|
|
949
|
-
`HoloScript agent "${this.escapeStringValue(composition.name, "JSON")}"`
|
|
950
|
-
);
|
|
1100
|
+
parts.push(`HoloScript agent "${this.escapeStringValue(composition.name, "JSON")}"`);
|
|
951
1101
|
const features = [];
|
|
952
1102
|
if (composition.templates?.length) {
|
|
953
1103
|
features.push(`${composition.templates.length} template(s)`);
|
|
@@ -1044,7 +1194,7 @@ function validateNIRGraph(graph) {
|
|
|
1044
1194
|
return { valid: errors.length === 0, errors };
|
|
1045
1195
|
}
|
|
1046
1196
|
var NEURON_TRAIT_MAP, SYNAPSE_TRAIT_MAP, ENCODING_TRAIT_MAP, TOPOLOGY_TRAIT_MAP, NIR_TRAIT_MAP;
|
|
1047
|
-
var init_NIRTraitMap =
|
|
1197
|
+
var init_NIRTraitMap = chunkHCCQLAA4_cjs.__esm({
|
|
1048
1198
|
"src/compiler/NIRTraitMap.ts"() {
|
|
1049
1199
|
NEURON_TRAIT_MAP = {
|
|
1050
1200
|
lif_neuron: {
|
|
@@ -1558,17 +1708,16 @@ var init_NIRTraitMap = chunkEGIZHYJP_cjs.__esm({
|
|
|
1558
1708
|
|
|
1559
1709
|
// src/compiler/NIRCompiler.ts
|
|
1560
1710
|
var NIRCompiler_exports = {};
|
|
1561
|
-
|
|
1711
|
+
chunkHCCQLAA4_cjs.__export(NIRCompiler_exports, {
|
|
1562
1712
|
NIRCompiler: () => exports.NIRCompiler,
|
|
1563
1713
|
default: () => NIRCompiler_default
|
|
1564
1714
|
});
|
|
1565
1715
|
exports.NIRCompiler = void 0; var NIRCompiler_default;
|
|
1566
|
-
var init_NIRCompiler =
|
|
1716
|
+
var init_NIRCompiler = chunkHCCQLAA4_cjs.__esm({
|
|
1567
1717
|
"src/compiler/NIRCompiler.ts"() {
|
|
1568
|
-
|
|
1569
|
-
chunkQHVVVN47_cjs.init_ANSNamespace();
|
|
1718
|
+
chunkRMHC2VG7_cjs.init_CompilerBase();
|
|
1570
1719
|
init_NIRTraitMap();
|
|
1571
|
-
exports.NIRCompiler = class extends
|
|
1720
|
+
exports.NIRCompiler = class extends chunkRMHC2VG7_cjs.CompilerBase {
|
|
1572
1721
|
constructor(options = {}) {
|
|
1573
1722
|
super();
|
|
1574
1723
|
this.compilerName = "NIRCompiler";
|
|
@@ -1589,7 +1738,7 @@ var init_NIRCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
1589
1738
|
};
|
|
1590
1739
|
}
|
|
1591
1740
|
getRequiredCapability() {
|
|
1592
|
-
return
|
|
1741
|
+
return ans.ANSCapabilityPath.NIR;
|
|
1593
1742
|
}
|
|
1594
1743
|
/**
|
|
1595
1744
|
* Compile a HoloScript composition to NIR graph JSON.
|
|
@@ -1913,691 +2062,21 @@ var init_NIRCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
|
1913
2062
|
}
|
|
1914
2063
|
});
|
|
1915
2064
|
|
|
1916
|
-
// src/
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
const ch = line[i];
|
|
1923
|
-
if (inString) {
|
|
1924
|
-
if (ch === inString && line[i - 1] !== "\\") inString = null;
|
|
1925
|
-
} else if (ch === '"' || ch === "'") {
|
|
1926
|
-
inString = ch;
|
|
1927
|
-
} else if (ch === "/" && line[i + 1] === "/") {
|
|
1928
|
-
return line.substring(0, i);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
return line;
|
|
1932
|
-
}).join("\n");
|
|
1933
|
-
}
|
|
1934
|
-
function parseDuration(value) {
|
|
1935
|
-
const match = value.match(/^(\d+)(s|m|h|d)$/);
|
|
1936
|
-
if (!match) return void 0;
|
|
1937
|
-
return { value: parseInt(match[1], 10), unit: match[2] };
|
|
1938
|
-
}
|
|
1939
|
-
function extractBlock(source, keyword, name) {
|
|
1940
|
-
const results = [];
|
|
1941
|
-
const namePattern = "(\\w+)";
|
|
1942
|
-
const regex = new RegExp(`${keyword}\\s+${namePattern}\\s*\\{`, "g");
|
|
1943
|
-
let match;
|
|
1944
|
-
while ((match = regex.exec(source)) !== null) {
|
|
1945
|
-
const blockName = match[1];
|
|
1946
|
-
const startLine = source.substring(0, match.index).split("\n").length;
|
|
1947
|
-
const startIdx = source.indexOf("{", match.index);
|
|
1948
|
-
let depth = 1;
|
|
1949
|
-
let i = startIdx + 1;
|
|
1950
|
-
while (i < source.length && depth > 0) {
|
|
1951
|
-
if (source[i] === "{") depth++;
|
|
1952
|
-
if (source[i] === "}") depth--;
|
|
1953
|
-
i++;
|
|
1954
|
-
}
|
|
1955
|
-
results.push({
|
|
1956
|
-
content: source.substring(startIdx + 1, i - 1),
|
|
1957
|
-
name: blockName,
|
|
1958
|
-
startLine
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
return results;
|
|
1962
|
-
}
|
|
1963
|
-
function parseProperties(content) {
|
|
1964
|
-
const props = {};
|
|
1965
|
-
const lines = content.split("\n");
|
|
1966
|
-
for (const line of lines) {
|
|
1967
|
-
const trimmed = line.trim();
|
|
1968
|
-
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
1969
|
-
const kvMatch = trimmed.match(/^(\w+)\s*:\s+(.+)$/);
|
|
1970
|
-
if (kvMatch) {
|
|
1971
|
-
const key = kvMatch[1];
|
|
1972
|
-
let val = kvMatch[2].trim();
|
|
1973
|
-
if (typeof val === "string" && val.endsWith(",")) {
|
|
1974
|
-
val = val.slice(0, -1).trim();
|
|
1975
|
-
}
|
|
1976
|
-
if (typeof val === "string") {
|
|
1977
|
-
const strVal = val;
|
|
1978
|
-
if (strVal.startsWith('"') && strVal.endsWith('"')) {
|
|
1979
|
-
val = strVal.slice(1, -1);
|
|
1980
|
-
} else if (strVal.startsWith("'") && strVal.endsWith("'")) {
|
|
1981
|
-
val = strVal.slice(1, -1);
|
|
1982
|
-
} else if (strVal === "true") {
|
|
1983
|
-
val = true;
|
|
1984
|
-
} else if (strVal === "false") {
|
|
1985
|
-
val = false;
|
|
1986
|
-
} else if (/^\d+$/.test(strVal)) {
|
|
1987
|
-
val = parseInt(strVal, 10);
|
|
1988
|
-
} else if (/^\d+\.\d+$/.test(strVal)) {
|
|
1989
|
-
val = parseFloat(strVal);
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
props[key] = val;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
return props;
|
|
1996
|
-
}
|
|
1997
|
-
function parseNestedBlock(content, keyword) {
|
|
1998
|
-
const blocks = extractBlock(content, keyword);
|
|
1999
|
-
if (blocks.length === 0) return void 0;
|
|
2000
|
-
return parseProperties(blocks[0].content);
|
|
2001
|
-
}
|
|
2002
|
-
function parseFieldMappings(content) {
|
|
2003
|
-
const mappings = [];
|
|
2004
|
-
const lines = content.split("\n");
|
|
2005
|
-
for (const line of lines) {
|
|
2006
|
-
const trimmed = line.trim();
|
|
2007
|
-
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
2008
|
-
const mapMatch = trimmed.match(/^(\w+)\s*->\s*(\w+)(?:\s*:\s*(.+))?$/);
|
|
2009
|
-
if (mapMatch) {
|
|
2010
|
-
const transforms = mapMatch[3] ? mapMatch[3].split(":").map((t) => t.trim()).filter(Boolean) : [];
|
|
2011
|
-
mappings.push({
|
|
2012
|
-
from: mapMatch[1],
|
|
2013
|
-
to: mapMatch[2],
|
|
2014
|
-
transforms
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
return mappings;
|
|
2019
|
-
}
|
|
2020
|
-
function parseValidateFields(content) {
|
|
2021
|
-
const fields = [];
|
|
2022
|
-
const lines = content.split("\n");
|
|
2023
|
-
for (const line of lines) {
|
|
2024
|
-
const trimmed = line.trim();
|
|
2025
|
-
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
2026
|
-
const vMatch = trimmed.match(/^(\w+)\s*:\s*(.+)$/);
|
|
2027
|
-
if (vMatch) {
|
|
2028
|
-
const rules = vMatch[2].split(",").map((r) => r.trim()).filter(Boolean);
|
|
2029
|
-
fields.push({ field: vMatch[1], rules });
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
return fields;
|
|
2033
|
-
}
|
|
2034
|
-
function parseBranchRoutes(content) {
|
|
2035
|
-
const routes = [];
|
|
2036
|
-
const lines = content.split("\n");
|
|
2037
|
-
for (const line of lines) {
|
|
2038
|
-
const trimmed = line.trim();
|
|
2039
|
-
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
2040
|
-
const whenMatch = trimmed.match(/^when\s+(.+?)\s*->\s*sink\s+(\w+)$/);
|
|
2041
|
-
if (whenMatch) {
|
|
2042
|
-
routes.push({ condition: whenMatch[1], sinkName: whenMatch[2] });
|
|
2043
|
-
continue;
|
|
2044
|
-
}
|
|
2045
|
-
const defaultMatch = trimmed.match(/^default\s*->\s*sink\s+(\w+)$/);
|
|
2046
|
-
if (defaultMatch) {
|
|
2047
|
-
routes.push({ condition: "default", sinkName: defaultMatch[1] });
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
return routes;
|
|
2051
|
-
}
|
|
2052
|
-
function parseStringArray(content) {
|
|
2053
|
-
const match = content.match(/\[([\s\S]*?)\]/);
|
|
2054
|
-
if (!match) return [];
|
|
2055
|
-
return match[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
2056
|
-
}
|
|
2057
|
-
function parsePipeline(source) {
|
|
2058
|
-
const errors = [];
|
|
2059
|
-
const clean = stripComments(source);
|
|
2060
|
-
const pipelineBlocks = extractBlock(clean, "pipeline");
|
|
2061
|
-
if (pipelineBlocks.length === 0) {
|
|
2062
|
-
const quotedMatch = clean.match(/pipeline\s+["']([^"']+)["']\s*\{/);
|
|
2063
|
-
if (!quotedMatch) {
|
|
2064
|
-
return { success: false, errors: [{ message: "No pipeline block found" }] };
|
|
2065
|
-
}
|
|
2066
|
-
const startIdx = clean.indexOf("{", quotedMatch.index);
|
|
2067
|
-
let depth = 1;
|
|
2068
|
-
let i = startIdx + 1;
|
|
2069
|
-
while (i < clean.length && depth > 0) {
|
|
2070
|
-
if (clean[i] === "{") depth++;
|
|
2071
|
-
if (clean[i] === "}") depth--;
|
|
2072
|
-
i++;
|
|
2073
|
-
}
|
|
2074
|
-
const pipelineContent = clean.substring(startIdx + 1, i - 1);
|
|
2075
|
-
return parsePipelineContent(quotedMatch[1], pipelineContent, errors);
|
|
2076
|
-
}
|
|
2077
|
-
return parsePipelineContent(pipelineBlocks[0].name, pipelineBlocks[0].content, errors);
|
|
2078
|
-
}
|
|
2079
|
-
function parsePipelineContent(name, content, errors) {
|
|
2080
|
-
const invalidKeywords = [
|
|
2081
|
-
"environment",
|
|
2082
|
-
"spatial_group",
|
|
2083
|
-
"template",
|
|
2084
|
-
"object",
|
|
2085
|
-
"orb",
|
|
2086
|
-
"theme",
|
|
2087
|
-
"light",
|
|
2088
|
-
"camera",
|
|
2089
|
-
"audio",
|
|
2090
|
-
"zone",
|
|
2091
|
-
"timeline",
|
|
2092
|
-
"particle_system",
|
|
2093
|
-
"effects",
|
|
2094
|
-
"ui",
|
|
2095
|
-
"npc",
|
|
2096
|
-
"quest",
|
|
2097
|
-
"dialogue",
|
|
2098
|
-
"ability",
|
|
2099
|
-
"achievement",
|
|
2100
|
-
"talent_tree",
|
|
2101
|
-
"behavior",
|
|
2102
|
-
"state_machine",
|
|
2103
|
-
"shape",
|
|
2104
|
-
"terrain",
|
|
2105
|
-
"waypoints",
|
|
2106
|
-
"spawn_group",
|
|
2107
|
-
"composition",
|
|
2108
|
-
"constraint",
|
|
2109
|
-
"sub_orb",
|
|
2110
|
-
"norm",
|
|
2111
|
-
"metanorm"
|
|
2112
|
-
];
|
|
2113
|
-
for (const keyword of invalidKeywords) {
|
|
2114
|
-
if (new RegExp(`\\b${keyword}\\b`).test(content)) {
|
|
2115
|
-
errors.push({
|
|
2116
|
-
message: `SyntaxError: '${keyword}' is not valid in a pipeline context. Use .holo for spatial compositions or .hsplus for behaviors.`
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
const props = parseProperties(content);
|
|
2121
|
-
const schedule = typeof props.schedule === "string" ? props.schedule : void 0;
|
|
2122
|
-
const timeout = typeof props.timeout === "string" ? parseDuration(props.timeout) : void 0;
|
|
2123
|
-
let retry;
|
|
2124
|
-
const retryBlock = parseNestedBlock(content, "retry");
|
|
2125
|
-
if (retryBlock) {
|
|
2126
|
-
retry = {
|
|
2127
|
-
max: typeof retryBlock.max === "number" ? retryBlock.max : 3,
|
|
2128
|
-
backoff: retryBlock.backoff || "exponential"
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
2131
|
-
const sources = [];
|
|
2132
|
-
for (const block of extractBlock(content, "source")) {
|
|
2133
|
-
const p = parseProperties(block.content);
|
|
2134
|
-
sources.push({
|
|
2135
|
-
kind: "source",
|
|
2136
|
-
name: block.name,
|
|
2137
|
-
type: p.type || "rest",
|
|
2138
|
-
endpoint: p.endpoint,
|
|
2139
|
-
path: p.path,
|
|
2140
|
-
pattern: p.pattern,
|
|
2141
|
-
since: p.since,
|
|
2142
|
-
method: p.method,
|
|
2143
|
-
auth: parseNestedBlock(block.content, "auth"),
|
|
2144
|
-
pagination: parseNestedBlock(block.content, "pagination"),
|
|
2145
|
-
properties: p
|
|
2146
|
-
});
|
|
2147
|
-
}
|
|
2148
|
-
const transforms = [];
|
|
2149
|
-
for (const block of extractBlock(content, "transform")) {
|
|
2150
|
-
const p = parseProperties(block.content);
|
|
2151
|
-
const mappings = parseFieldMappings(block.content);
|
|
2152
|
-
const hasType = p.type !== void 0;
|
|
2153
|
-
transforms.push({
|
|
2154
|
-
kind: "transform",
|
|
2155
|
-
name: block.name,
|
|
2156
|
-
type: hasType ? p.type : mappings.length > 0 ? "field_mapping" : void 0,
|
|
2157
|
-
mappings: mappings.length > 0 ? mappings : void 0,
|
|
2158
|
-
model: p.model,
|
|
2159
|
-
prompt: p.prompt,
|
|
2160
|
-
input: p.input,
|
|
2161
|
-
output: p.output,
|
|
2162
|
-
server: p.server,
|
|
2163
|
-
tool: p.tool,
|
|
2164
|
-
method: p.method,
|
|
2165
|
-
url: p.url,
|
|
2166
|
-
timeout: typeof p.timeout === "string" ? parseDuration(p.timeout) : void 0,
|
|
2167
|
-
where: p.where,
|
|
2168
|
-
properties: p
|
|
2169
|
-
});
|
|
2170
|
-
}
|
|
2171
|
-
const filters = [];
|
|
2172
|
-
for (const block of extractBlock(content, "filter")) {
|
|
2173
|
-
const p = parseProperties(block.content);
|
|
2174
|
-
if (!p.where) {
|
|
2175
|
-
errors.push({ message: `Filter "${block.name}" missing 'where' clause`, line: block.startLine, block: block.name });
|
|
2176
|
-
}
|
|
2177
|
-
filters.push({
|
|
2178
|
-
kind: "filter",
|
|
2179
|
-
name: block.name,
|
|
2180
|
-
where: p.where || ""
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
|
-
const validates = [];
|
|
2184
|
-
for (const block of extractBlock(content, "validate")) {
|
|
2185
|
-
validates.push({
|
|
2186
|
-
kind: "validate",
|
|
2187
|
-
name: block.name,
|
|
2188
|
-
fields: parseValidateFields(block.content)
|
|
2189
|
-
});
|
|
2190
|
-
}
|
|
2191
|
-
const merges = [];
|
|
2192
|
-
for (const block of extractBlock(content, "merge")) {
|
|
2193
|
-
const p = parseProperties(block.content);
|
|
2194
|
-
const fromArr = typeof p.from === "string" ? parseStringArray(p.from) : [];
|
|
2195
|
-
merges.push({
|
|
2196
|
-
kind: "merge",
|
|
2197
|
-
name: block.name,
|
|
2198
|
-
from: fromArr,
|
|
2199
|
-
dedup: parseNestedBlock(block.content, "dedup"),
|
|
2200
|
-
strategy: p.strategy
|
|
2201
|
-
});
|
|
2202
|
-
}
|
|
2203
|
-
const branches = [];
|
|
2204
|
-
for (const block of extractBlock(content, "branch")) {
|
|
2205
|
-
branches.push({
|
|
2206
|
-
kind: "branch",
|
|
2207
|
-
name: block.name,
|
|
2208
|
-
routes: parseBranchRoutes(block.content)
|
|
2209
|
-
});
|
|
2210
|
-
}
|
|
2211
|
-
const sinks = [];
|
|
2212
|
-
for (const block of extractBlock(content, "sink")) {
|
|
2213
|
-
const p = parseProperties(block.content);
|
|
2214
|
-
sinks.push({
|
|
2215
|
-
kind: "sink",
|
|
2216
|
-
name: block.name,
|
|
2217
|
-
type: p.type || "rest",
|
|
2218
|
-
endpoint: p.endpoint,
|
|
2219
|
-
path: p.path,
|
|
2220
|
-
method: p.method,
|
|
2221
|
-
auth: parseNestedBlock(block.content, "auth"),
|
|
2222
|
-
batch: parseNestedBlock(block.content, "batch"),
|
|
2223
|
-
onError: parseNestedBlock(block.content, "on_error"),
|
|
2224
|
-
format: p.format,
|
|
2225
|
-
append: p.append,
|
|
2226
|
-
server: p.server,
|
|
2227
|
-
tool: p.tool,
|
|
2228
|
-
properties: p
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
const steps = [
|
|
2232
|
-
...sources,
|
|
2233
|
-
...merges,
|
|
2234
|
-
...transforms,
|
|
2235
|
-
...filters,
|
|
2236
|
-
...validates,
|
|
2237
|
-
...branches,
|
|
2238
|
-
...sinks
|
|
2239
|
-
];
|
|
2240
|
-
if (sources.length === 0) {
|
|
2241
|
-
errors.push({ message: "Pipeline has no sources" });
|
|
2242
|
-
}
|
|
2243
|
-
if (sinks.length === 0) {
|
|
2244
|
-
errors.push({ message: "Pipeline has no sinks" });
|
|
2245
|
-
}
|
|
2246
|
-
const pipeline = {
|
|
2247
|
-
name,
|
|
2248
|
-
schedule,
|
|
2249
|
-
timeout,
|
|
2250
|
-
retry,
|
|
2251
|
-
steps,
|
|
2252
|
-
sources,
|
|
2253
|
-
transforms,
|
|
2254
|
-
filters,
|
|
2255
|
-
validates,
|
|
2256
|
-
merges,
|
|
2257
|
-
branches,
|
|
2258
|
-
sinks
|
|
2259
|
-
};
|
|
2260
|
-
return { success: errors.length === 0, pipeline, errors };
|
|
2261
|
-
}
|
|
2262
|
-
function isPipelineSource(source) {
|
|
2263
|
-
return /pipeline\s+["']?\w/.test(source);
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
// src/compiler/platform/PlatformConditional.ts
|
|
2267
|
-
var PLATFORM_CATEGORIES = {
|
|
2268
|
-
vr: ["quest3", "pcvr", "visionos", "android-xr"],
|
|
2269
|
-
ar: ["visionos-ar", "android-xr-ar", "webxr"],
|
|
2270
|
-
mobile: ["ios", "android"],
|
|
2271
|
-
desktop: ["windows", "macos", "linux", "web"],
|
|
2272
|
-
automotive: ["android-auto", "carplay"],
|
|
2273
|
-
wearable: ["watchos", "wearos"]
|
|
2274
|
-
};
|
|
2275
|
-
var ALL_PLATFORMS = Object.values(
|
|
2276
|
-
PLATFORM_CATEGORIES
|
|
2277
|
-
).flat();
|
|
2278
|
-
function platformCategory(target) {
|
|
2279
|
-
for (const [cat, platforms] of Object.entries(PLATFORM_CATEGORIES)) {
|
|
2280
|
-
if (platforms.includes(target)) return cat;
|
|
2281
|
-
}
|
|
2282
|
-
return "desktop";
|
|
2283
|
-
}
|
|
2284
|
-
var PLATFORM_CAPABILITIES = {
|
|
2285
|
-
quest3: {
|
|
2286
|
-
spatialTracking: true,
|
|
2287
|
-
handTracking: true,
|
|
2288
|
-
eyeTracking: true,
|
|
2289
|
-
haptics: true,
|
|
2290
|
-
spatialAudio: true,
|
|
2291
|
-
gpu3D: true,
|
|
2292
|
-
arCamera: true,
|
|
2293
|
-
gps: false,
|
|
2294
|
-
npu: true,
|
|
2295
|
-
webxrSupport: true,
|
|
2296
|
-
frameBudgetMs: 11.1,
|
|
2297
|
-
agentBudgetMs: 5,
|
|
2298
|
-
computeModel: "edge-first"
|
|
2299
|
-
},
|
|
2300
|
-
pcvr: {
|
|
2301
|
-
spatialTracking: true,
|
|
2302
|
-
handTracking: true,
|
|
2303
|
-
eyeTracking: true,
|
|
2304
|
-
haptics: true,
|
|
2305
|
-
spatialAudio: true,
|
|
2306
|
-
gpu3D: true,
|
|
2307
|
-
arCamera: false,
|
|
2308
|
-
gps: false,
|
|
2309
|
-
npu: false,
|
|
2310
|
-
webxrSupport: true,
|
|
2311
|
-
frameBudgetMs: 11.1,
|
|
2312
|
-
agentBudgetMs: 5,
|
|
2313
|
-
computeModel: "edge-first"
|
|
2314
|
-
},
|
|
2315
|
-
visionos: {
|
|
2316
|
-
spatialTracking: true,
|
|
2317
|
-
handTracking: true,
|
|
2318
|
-
eyeTracking: true,
|
|
2319
|
-
haptics: false,
|
|
2320
|
-
spatialAudio: true,
|
|
2321
|
-
gpu3D: true,
|
|
2322
|
-
arCamera: true,
|
|
2323
|
-
gps: false,
|
|
2324
|
-
npu: true,
|
|
2325
|
-
webxrSupport: false,
|
|
2326
|
-
frameBudgetMs: 11.1,
|
|
2327
|
-
agentBudgetMs: 5,
|
|
2328
|
-
computeModel: "edge-first"
|
|
2329
|
-
},
|
|
2330
|
-
"android-xr": {
|
|
2331
|
-
spatialTracking: true,
|
|
2332
|
-
handTracking: true,
|
|
2333
|
-
eyeTracking: true,
|
|
2334
|
-
haptics: true,
|
|
2335
|
-
spatialAudio: true,
|
|
2336
|
-
gpu3D: true,
|
|
2337
|
-
arCamera: true,
|
|
2338
|
-
gps: true,
|
|
2339
|
-
npu: true,
|
|
2340
|
-
webxrSupport: true,
|
|
2341
|
-
frameBudgetMs: 11.1,
|
|
2342
|
-
agentBudgetMs: 5,
|
|
2343
|
-
computeModel: "edge-first"
|
|
2344
|
-
},
|
|
2345
|
-
"visionos-ar": {
|
|
2346
|
-
spatialTracking: true,
|
|
2347
|
-
handTracking: true,
|
|
2348
|
-
eyeTracking: true,
|
|
2349
|
-
haptics: false,
|
|
2350
|
-
spatialAudio: true,
|
|
2351
|
-
gpu3D: true,
|
|
2352
|
-
arCamera: true,
|
|
2353
|
-
gps: true,
|
|
2354
|
-
npu: true,
|
|
2355
|
-
webxrSupport: false,
|
|
2356
|
-
frameBudgetMs: 16.6,
|
|
2357
|
-
agentBudgetMs: 10,
|
|
2358
|
-
computeModel: "edge-first"
|
|
2359
|
-
},
|
|
2360
|
-
"android-xr-ar": {
|
|
2361
|
-
spatialTracking: true,
|
|
2362
|
-
handTracking: true,
|
|
2363
|
-
eyeTracking: false,
|
|
2364
|
-
haptics: true,
|
|
2365
|
-
spatialAudio: true,
|
|
2366
|
-
gpu3D: true,
|
|
2367
|
-
arCamera: true,
|
|
2368
|
-
gps: true,
|
|
2369
|
-
npu: true,
|
|
2370
|
-
webxrSupport: true,
|
|
2371
|
-
frameBudgetMs: 16.6,
|
|
2372
|
-
agentBudgetMs: 10,
|
|
2373
|
-
computeModel: "edge-first"
|
|
2374
|
-
},
|
|
2375
|
-
webxr: {
|
|
2376
|
-
spatialTracking: true,
|
|
2377
|
-
handTracking: false,
|
|
2378
|
-
eyeTracking: false,
|
|
2379
|
-
haptics: false,
|
|
2380
|
-
spatialAudio: false,
|
|
2381
|
-
gpu3D: true,
|
|
2382
|
-
arCamera: true,
|
|
2383
|
-
gps: false,
|
|
2384
|
-
npu: false,
|
|
2385
|
-
webxrSupport: true,
|
|
2386
|
-
frameBudgetMs: 16.6,
|
|
2387
|
-
agentBudgetMs: 15,
|
|
2388
|
-
computeModel: "cloud-first"
|
|
2389
|
-
},
|
|
2390
|
-
ios: {
|
|
2391
|
-
spatialTracking: false,
|
|
2392
|
-
handTracking: false,
|
|
2393
|
-
eyeTracking: false,
|
|
2394
|
-
haptics: true,
|
|
2395
|
-
spatialAudio: false,
|
|
2396
|
-
gpu3D: true,
|
|
2397
|
-
arCamera: true,
|
|
2398
|
-
gps: true,
|
|
2399
|
-
npu: true,
|
|
2400
|
-
webxrSupport: false,
|
|
2401
|
-
frameBudgetMs: 16.6,
|
|
2402
|
-
agentBudgetMs: 100,
|
|
2403
|
-
computeModel: "cloud-first"
|
|
2404
|
-
},
|
|
2405
|
-
android: {
|
|
2406
|
-
spatialTracking: false,
|
|
2407
|
-
handTracking: false,
|
|
2408
|
-
eyeTracking: false,
|
|
2409
|
-
haptics: true,
|
|
2410
|
-
spatialAudio: false,
|
|
2411
|
-
gpu3D: true,
|
|
2412
|
-
arCamera: true,
|
|
2413
|
-
gps: true,
|
|
2414
|
-
npu: true,
|
|
2415
|
-
webxrSupport: true,
|
|
2416
|
-
frameBudgetMs: 16.6,
|
|
2417
|
-
agentBudgetMs: 100,
|
|
2418
|
-
computeModel: "cloud-first"
|
|
2419
|
-
},
|
|
2420
|
-
windows: {
|
|
2421
|
-
spatialTracking: false,
|
|
2422
|
-
handTracking: false,
|
|
2423
|
-
eyeTracking: false,
|
|
2424
|
-
haptics: false,
|
|
2425
|
-
spatialAudio: false,
|
|
2426
|
-
gpu3D: true,
|
|
2427
|
-
arCamera: false,
|
|
2428
|
-
gps: false,
|
|
2429
|
-
npu: false,
|
|
2430
|
-
webxrSupport: true,
|
|
2431
|
-
frameBudgetMs: 16.6,
|
|
2432
|
-
agentBudgetMs: 200,
|
|
2433
|
-
computeModel: "cloud-first"
|
|
2434
|
-
},
|
|
2435
|
-
macos: {
|
|
2436
|
-
spatialTracking: false,
|
|
2437
|
-
handTracking: false,
|
|
2438
|
-
eyeTracking: false,
|
|
2439
|
-
haptics: false,
|
|
2440
|
-
spatialAudio: false,
|
|
2441
|
-
gpu3D: true,
|
|
2442
|
-
arCamera: false,
|
|
2443
|
-
gps: false,
|
|
2444
|
-
npu: true,
|
|
2445
|
-
webxrSupport: true,
|
|
2446
|
-
frameBudgetMs: 16.6,
|
|
2447
|
-
agentBudgetMs: 200,
|
|
2448
|
-
computeModel: "cloud-first"
|
|
2449
|
-
},
|
|
2450
|
-
linux: {
|
|
2451
|
-
spatialTracking: false,
|
|
2452
|
-
handTracking: false,
|
|
2453
|
-
eyeTracking: false,
|
|
2454
|
-
haptics: false,
|
|
2455
|
-
spatialAudio: false,
|
|
2456
|
-
gpu3D: true,
|
|
2457
|
-
arCamera: false,
|
|
2458
|
-
gps: false,
|
|
2459
|
-
npu: false,
|
|
2460
|
-
webxrSupport: true,
|
|
2461
|
-
frameBudgetMs: 16.6,
|
|
2462
|
-
agentBudgetMs: 200,
|
|
2463
|
-
computeModel: "cloud-first"
|
|
2464
|
-
},
|
|
2465
|
-
web: {
|
|
2466
|
-
spatialTracking: false,
|
|
2467
|
-
handTracking: false,
|
|
2468
|
-
eyeTracking: false,
|
|
2469
|
-
haptics: false,
|
|
2470
|
-
spatialAudio: false,
|
|
2471
|
-
gpu3D: true,
|
|
2472
|
-
arCamera: false,
|
|
2473
|
-
gps: false,
|
|
2474
|
-
npu: false,
|
|
2475
|
-
webxrSupport: true,
|
|
2476
|
-
frameBudgetMs: 16.6,
|
|
2477
|
-
agentBudgetMs: 200,
|
|
2478
|
-
computeModel: "cloud-first"
|
|
2479
|
-
},
|
|
2480
|
-
"android-auto": {
|
|
2481
|
-
spatialTracking: false,
|
|
2482
|
-
handTracking: false,
|
|
2483
|
-
eyeTracking: false,
|
|
2484
|
-
haptics: false,
|
|
2485
|
-
spatialAudio: true,
|
|
2486
|
-
gpu3D: false,
|
|
2487
|
-
arCamera: false,
|
|
2488
|
-
gps: true,
|
|
2489
|
-
npu: false,
|
|
2490
|
-
webxrSupport: false,
|
|
2491
|
-
frameBudgetMs: 30,
|
|
2492
|
-
agentBudgetMs: 15,
|
|
2493
|
-
computeModel: "safety-critical"
|
|
2494
|
-
},
|
|
2495
|
-
carplay: {
|
|
2496
|
-
spatialTracking: false,
|
|
2497
|
-
handTracking: false,
|
|
2498
|
-
eyeTracking: false,
|
|
2499
|
-
haptics: false,
|
|
2500
|
-
spatialAudio: true,
|
|
2501
|
-
gpu3D: false,
|
|
2502
|
-
arCamera: false,
|
|
2503
|
-
gps: true,
|
|
2504
|
-
npu: false,
|
|
2505
|
-
webxrSupport: false,
|
|
2506
|
-
frameBudgetMs: 30,
|
|
2507
|
-
agentBudgetMs: 15,
|
|
2508
|
-
computeModel: "safety-critical"
|
|
2509
|
-
},
|
|
2510
|
-
watchos: {
|
|
2511
|
-
spatialTracking: false,
|
|
2512
|
-
handTracking: false,
|
|
2513
|
-
eyeTracking: false,
|
|
2514
|
-
haptics: true,
|
|
2515
|
-
spatialAudio: false,
|
|
2516
|
-
gpu3D: false,
|
|
2517
|
-
arCamera: false,
|
|
2518
|
-
gps: true,
|
|
2519
|
-
npu: true,
|
|
2520
|
-
webxrSupport: false,
|
|
2521
|
-
frameBudgetMs: 33.3,
|
|
2522
|
-
agentBudgetMs: 50,
|
|
2523
|
-
computeModel: "cloud-first"
|
|
2524
|
-
},
|
|
2525
|
-
wearos: {
|
|
2526
|
-
spatialTracking: false,
|
|
2527
|
-
handTracking: false,
|
|
2528
|
-
eyeTracking: false,
|
|
2529
|
-
haptics: true,
|
|
2530
|
-
spatialAudio: false,
|
|
2531
|
-
gpu3D: false,
|
|
2532
|
-
arCamera: false,
|
|
2533
|
-
gps: true,
|
|
2534
|
-
npu: false,
|
|
2535
|
-
webxrSupport: false,
|
|
2536
|
-
frameBudgetMs: 33.3,
|
|
2537
|
-
agentBudgetMs: 50,
|
|
2538
|
-
computeModel: "cloud-first"
|
|
2539
|
-
}
|
|
2540
|
-
};
|
|
2541
|
-
var DEFAULT_EMBODIMENT = {
|
|
2542
|
-
vr: "Avatar3D",
|
|
2543
|
-
ar: "SpatialPersona",
|
|
2544
|
-
mobile: "UI2D",
|
|
2545
|
-
desktop: "FullGUI",
|
|
2546
|
-
automotive: "VoiceHUD",
|
|
2547
|
-
wearable: "UI2D"
|
|
2548
|
-
};
|
|
2549
|
-
function resolvePlatforms(condition) {
|
|
2550
|
-
let platforms = /* @__PURE__ */ new Set();
|
|
2551
|
-
if (condition.include) {
|
|
2552
|
-
for (const p of condition.include) platforms.add(p);
|
|
2553
|
-
}
|
|
2554
|
-
if (condition.includeCategories) {
|
|
2555
|
-
for (const cat of condition.includeCategories) {
|
|
2556
|
-
for (const p of PLATFORM_CATEGORIES[cat]) platforms.add(p);
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
if (!condition.include && !condition.includeCategories) {
|
|
2560
|
-
for (const p of ALL_PLATFORMS) platforms.add(p);
|
|
2561
|
-
}
|
|
2562
|
-
if (condition.exclude) {
|
|
2563
|
-
for (const p of condition.exclude) platforms.delete(p);
|
|
2564
|
-
}
|
|
2565
|
-
if (condition.requireCapabilities) {
|
|
2566
|
-
platforms = new Set(
|
|
2567
|
-
[...platforms].filter((p) => {
|
|
2568
|
-
const caps = PLATFORM_CAPABILITIES[p];
|
|
2569
|
-
return condition.requireCapabilities.every((cap) => {
|
|
2570
|
-
const val = caps[cap];
|
|
2571
|
-
return typeof val === "boolean" ? val : Number(val) > 0;
|
|
2572
|
-
});
|
|
2573
|
-
})
|
|
2574
|
-
);
|
|
2575
|
-
}
|
|
2576
|
-
return [...platforms];
|
|
2577
|
-
}
|
|
2578
|
-
function matchesPlatform(target, condition) {
|
|
2579
|
-
return resolvePlatforms(condition).includes(target);
|
|
2580
|
-
}
|
|
2581
|
-
function selectBlock(target, blocks) {
|
|
2582
|
-
for (const block of blocks) {
|
|
2583
|
-
if (matchesPlatform(target, block.condition)) return block.body;
|
|
2584
|
-
}
|
|
2585
|
-
return void 0;
|
|
2586
|
-
}
|
|
2587
|
-
function embodimentFor(target) {
|
|
2588
|
-
return DEFAULT_EMBODIMENT[platformCategory(target)];
|
|
2065
|
+
// src/compiler/USDZPipeline.ts
|
|
2066
|
+
chunkHGVXZDSK_cjs.init_DomainBlockCompilerMixin();
|
|
2067
|
+
chunkBPICAGBV_cjs.init_R3FCompiler();
|
|
2068
|
+
function presetString(p, k) {
|
|
2069
|
+
const v = p[k];
|
|
2070
|
+
return typeof v === "string" ? v : void 0;
|
|
2589
2071
|
}
|
|
2590
|
-
function
|
|
2591
|
-
|
|
2072
|
+
function presetNumber(p, k) {
|
|
2073
|
+
const v = p[k];
|
|
2074
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
2592
2075
|
}
|
|
2593
|
-
function
|
|
2594
|
-
const
|
|
2595
|
-
return typeof
|
|
2076
|
+
function presetBoolean(p, k) {
|
|
2077
|
+
const v = p[k];
|
|
2078
|
+
return typeof v === "boolean" ? v : void 0;
|
|
2596
2079
|
}
|
|
2597
|
-
|
|
2598
|
-
// src/compiler/USDZPipeline.ts
|
|
2599
|
-
chunkHHS6FMOU_cjs.init_DomainBlockCompilerMixin();
|
|
2600
|
-
chunkTSWTWZ42_cjs.init_R3FCompiler();
|
|
2601
2080
|
var _USDZPipeline = class _USDZPipeline {
|
|
2602
2081
|
constructor(options = {}) {
|
|
2603
2082
|
this.materials = /* @__PURE__ */ new Map();
|
|
@@ -2816,33 +2295,49 @@ ${domainBlocksOutput}` : materials,
|
|
|
2816
2295
|
const matName = `Material_${this.sanitizeName(obj.name)}`;
|
|
2817
2296
|
const mat = { name: matName };
|
|
2818
2297
|
const presetName = typeof material === "string" ? material : typeof materialPreset === "string" ? materialPreset : void 0;
|
|
2819
|
-
if (presetName &&
|
|
2820
|
-
const preset =
|
|
2821
|
-
|
|
2822
|
-
if (
|
|
2823
|
-
|
|
2824
|
-
if (
|
|
2825
|
-
|
|
2826
|
-
if (
|
|
2827
|
-
|
|
2828
|
-
if (
|
|
2829
|
-
|
|
2830
|
-
if (
|
|
2831
|
-
|
|
2832
|
-
if (
|
|
2833
|
-
|
|
2834
|
-
if (
|
|
2835
|
-
|
|
2836
|
-
if (
|
|
2837
|
-
|
|
2838
|
-
if (
|
|
2839
|
-
|
|
2840
|
-
if (
|
|
2841
|
-
|
|
2842
|
-
if (
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2298
|
+
if (presetName && chunkBPICAGBV_cjs.MATERIAL_PRESETS[presetName]) {
|
|
2299
|
+
const preset = chunkBPICAGBV_cjs.MATERIAL_PRESETS[presetName];
|
|
2300
|
+
const colorStr = presetString(preset, "color");
|
|
2301
|
+
if (colorStr) mat.baseColor = this.hexToRGB(colorStr);
|
|
2302
|
+
const metal = presetNumber(preset, "metalness");
|
|
2303
|
+
if (metal !== void 0) mat.metallic = metal;
|
|
2304
|
+
const rough = presetNumber(preset, "roughness");
|
|
2305
|
+
if (rough !== void 0) mat.roughness = rough;
|
|
2306
|
+
const op = presetNumber(preset, "opacity");
|
|
2307
|
+
if (op !== void 0) mat.opacity = op;
|
|
2308
|
+
const emissiveStr = presetString(preset, "emissive");
|
|
2309
|
+
if (emissiveStr) mat.emissiveColor = this.hexToRGB(emissiveStr);
|
|
2310
|
+
const emissiveInt = presetNumber(preset, "emissiveIntensity");
|
|
2311
|
+
if (emissiveInt !== void 0) mat.emissiveIntensity = emissiveInt;
|
|
2312
|
+
const trans = presetNumber(preset, "transmission");
|
|
2313
|
+
if (trans !== void 0) mat.transmission = trans;
|
|
2314
|
+
const ior = presetNumber(preset, "ior");
|
|
2315
|
+
if (ior !== void 0) mat.ior = ior;
|
|
2316
|
+
const thick = presetNumber(preset, "thickness");
|
|
2317
|
+
if (thick !== void 0) mat.thickness = thick;
|
|
2318
|
+
const cc = presetNumber(preset, "clearcoat");
|
|
2319
|
+
if (cc !== void 0) mat.clearcoat = cc;
|
|
2320
|
+
const ccr = presetNumber(preset, "clearcoatRoughness");
|
|
2321
|
+
if (ccr !== void 0) mat.clearcoatRoughness = ccr;
|
|
2322
|
+
const sheen = presetNumber(preset, "sheen");
|
|
2323
|
+
if (sheen !== void 0) mat.sheen = sheen;
|
|
2324
|
+
const sheenR = presetNumber(preset, "sheenRoughness");
|
|
2325
|
+
if (sheenR !== void 0) mat.sheenRoughness = sheenR;
|
|
2326
|
+
const sheenColorStr = presetString(preset, "sheenColor");
|
|
2327
|
+
if (sheenColorStr) mat.sheenColor = this.hexToRGB(sheenColorStr);
|
|
2328
|
+
const irid = presetNumber(preset, "iridescence");
|
|
2329
|
+
if (irid !== void 0) mat.iridescence = irid;
|
|
2330
|
+
const iridIor = presetNumber(preset, "iridescenceIOR");
|
|
2331
|
+
if (iridIor !== void 0) mat.iridescenceIOR = iridIor;
|
|
2332
|
+
const aniso = presetNumber(preset, "anisotropy");
|
|
2333
|
+
if (aniso !== void 0) mat.anisotropy = aniso;
|
|
2334
|
+
const anisoRot = presetNumber(preset, "anisotropyRotation");
|
|
2335
|
+
if (anisoRot !== void 0) mat.anisotropyRotation = anisoRot;
|
|
2336
|
+
const attColorStr = presetString(preset, "attenuationColor");
|
|
2337
|
+
if (attColorStr) mat.attenuationColor = this.hexToRGB(attColorStr);
|
|
2338
|
+
const attDist = presetNumber(preset, "attenuationDistance");
|
|
2339
|
+
if (attDist !== void 0) mat.attenuationDistance = attDist;
|
|
2340
|
+
if (presetBoolean(preset, "transparent") && mat.opacity === void 0) mat.opacity = 0.99;
|
|
2846
2341
|
}
|
|
2847
2342
|
if (typeof color === "string") {
|
|
2848
2343
|
mat.baseColor = this.hexToRGB(color);
|
|
@@ -3302,59 +2797,59 @@ ${domainBlocksOutput}` : materials,
|
|
|
3302
2797
|
generateDomainBlocks(composition) {
|
|
3303
2798
|
const domainBlocks = composition.domainBlocks ?? [];
|
|
3304
2799
|
if (domainBlocks.length === 0) return "";
|
|
3305
|
-
const compiled =
|
|
2800
|
+
const compiled = chunkHGVXZDSK_cjs.compileDomainBlocks(
|
|
3306
2801
|
domainBlocks,
|
|
3307
2802
|
{
|
|
3308
2803
|
material: (block) => {
|
|
3309
|
-
const mat =
|
|
3310
|
-
return
|
|
2804
|
+
const mat = chunkHGVXZDSK_cjs.compileMaterialBlock(block);
|
|
2805
|
+
return chunkHGVXZDSK_cjs.materialToUSD(mat);
|
|
3311
2806
|
},
|
|
3312
2807
|
physics: (block) => {
|
|
3313
|
-
const phys =
|
|
2808
|
+
const phys = chunkHGVXZDSK_cjs.compilePhysicsBlock(block);
|
|
3314
2809
|
return `# Physics: ${phys.keyword} "${phys.name || ""}" \u2014 ${JSON.stringify(phys.properties)}`;
|
|
3315
2810
|
},
|
|
3316
2811
|
vfx: (block) => {
|
|
3317
|
-
const ps =
|
|
3318
|
-
return
|
|
2812
|
+
const ps = chunkHGVXZDSK_cjs.compileParticleBlock(block);
|
|
2813
|
+
return chunkHGVXZDSK_cjs.particlesToUSD(ps);
|
|
3319
2814
|
},
|
|
3320
2815
|
postfx: (block) => {
|
|
3321
|
-
const pp =
|
|
3322
|
-
return
|
|
2816
|
+
const pp = chunkHGVXZDSK_cjs.compilePostProcessingBlock(block);
|
|
2817
|
+
return chunkHGVXZDSK_cjs.postProcessingToUSD(pp);
|
|
3323
2818
|
},
|
|
3324
2819
|
audio: (block) => {
|
|
3325
|
-
const audio =
|
|
3326
|
-
return
|
|
2820
|
+
const audio = chunkHGVXZDSK_cjs.compileAudioSourceBlock(block);
|
|
2821
|
+
return chunkHGVXZDSK_cjs.audioSourceToUSD(audio);
|
|
3327
2822
|
},
|
|
3328
2823
|
weather: (block) => {
|
|
3329
|
-
const weather =
|
|
3330
|
-
return
|
|
2824
|
+
const weather = chunkHGVXZDSK_cjs.compileWeatherBlock(block);
|
|
2825
|
+
return chunkHGVXZDSK_cjs.weatherToUSD(weather);
|
|
3331
2826
|
},
|
|
3332
2827
|
narrative: (block) => {
|
|
3333
|
-
const narr =
|
|
3334
|
-
return
|
|
2828
|
+
const narr = chunkHGVXZDSK_cjs.compileNarrativeBlock(block);
|
|
2829
|
+
return chunkHGVXZDSK_cjs.narrativeToUSDA(narr);
|
|
3335
2830
|
},
|
|
3336
2831
|
payment: (block) => {
|
|
3337
|
-
const pay =
|
|
3338
|
-
return
|
|
2832
|
+
const pay = chunkHGVXZDSK_cjs.compilePaymentBlock(block);
|
|
2833
|
+
return chunkHGVXZDSK_cjs.paymentToUSDA(pay);
|
|
3339
2834
|
},
|
|
3340
2835
|
healthcare: (block) => {
|
|
3341
|
-
const h =
|
|
3342
|
-
return
|
|
2836
|
+
const h = chunkHGVXZDSK_cjs.compileHealthcareBlock(block);
|
|
2837
|
+
return chunkHGVXZDSK_cjs.healthcareToUSDA(h);
|
|
3343
2838
|
},
|
|
3344
2839
|
robotics: (block) => {
|
|
3345
|
-
const r =
|
|
3346
|
-
return
|
|
2840
|
+
const r = chunkHGVXZDSK_cjs.compileRoboticsBlock(block);
|
|
2841
|
+
return chunkHGVXZDSK_cjs.roboticsToUSDA(r);
|
|
3347
2842
|
},
|
|
3348
|
-
iot: (block) =>
|
|
3349
|
-
dataviz: (block) =>
|
|
3350
|
-
education: (block) =>
|
|
3351
|
-
music: (block) =>
|
|
3352
|
-
architecture: (block) =>
|
|
3353
|
-
web3: (block) =>
|
|
3354
|
-
procedural: (block) =>
|
|
3355
|
-
rendering: (block) =>
|
|
3356
|
-
navigation: (block) =>
|
|
3357
|
-
input: (block) =>
|
|
2843
|
+
iot: (block) => chunkHGVXZDSK_cjs.iotToUSDA(chunkHGVXZDSK_cjs.compileIoTBlock(block)),
|
|
2844
|
+
dataviz: (block) => chunkHGVXZDSK_cjs.datavizToUSDA(chunkHGVXZDSK_cjs.compileDataVizBlock(block)),
|
|
2845
|
+
education: (block) => chunkHGVXZDSK_cjs.educationToUSDA(chunkHGVXZDSK_cjs.compileEducationBlock(block)),
|
|
2846
|
+
music: (block) => chunkHGVXZDSK_cjs.musicToUSDA(chunkHGVXZDSK_cjs.compileMusicBlock(block)),
|
|
2847
|
+
architecture: (block) => chunkHGVXZDSK_cjs.architectureToUSDA(chunkHGVXZDSK_cjs.compileArchitectureBlock(block)),
|
|
2848
|
+
web3: (block) => chunkHGVXZDSK_cjs.web3ToUSDA(chunkHGVXZDSK_cjs.compileWeb3Block(block)),
|
|
2849
|
+
procedural: (block) => chunkHGVXZDSK_cjs.proceduralToUSDA(chunkHGVXZDSK_cjs.compileProceduralBlock(block)),
|
|
2850
|
+
rendering: (block) => chunkHGVXZDSK_cjs.renderingToUSDA(chunkHGVXZDSK_cjs.compileRenderingBlock(block)),
|
|
2851
|
+
navigation: (block) => chunkHGVXZDSK_cjs.navigationToUSDA(chunkHGVXZDSK_cjs.compileNavigationBlock(block)),
|
|
2852
|
+
input: (block) => chunkHGVXZDSK_cjs.inputToUSDA(chunkHGVXZDSK_cjs.compileInputBlock(block))
|
|
3358
2853
|
},
|
|
3359
2854
|
(block) => `# Domain block: ${block.domain}/${block.keyword} "${block.name}"`
|
|
3360
2855
|
);
|
|
@@ -3384,6 +2879,864 @@ _USDZPipeline.TEXTURE_CHANNEL_MAP = {
|
|
|
3384
2879
|
};
|
|
3385
2880
|
var USDZPipeline = _USDZPipeline;
|
|
3386
2881
|
|
|
2882
|
+
// src/compiler/GaussianSplattingCompiler.ts
|
|
2883
|
+
chunkRMHC2VG7_cjs.init_CompilerBase();
|
|
2884
|
+
var GAUSSIAN_SPLAT_TRAIT_NAME = "gaussian_splat";
|
|
2885
|
+
var MULTIPLAYER_TRAIT_NAME = "multiplayer";
|
|
2886
|
+
function detectMultiUserSharedSort(composition) {
|
|
2887
|
+
const objects = composition.objects ?? [];
|
|
2888
|
+
for (const obj of objects) {
|
|
2889
|
+
if (objectHasBothTraits(obj)) return true;
|
|
2890
|
+
}
|
|
2891
|
+
return false;
|
|
2892
|
+
}
|
|
2893
|
+
function objectHasBothTraits(obj) {
|
|
2894
|
+
const traits = obj.traits ?? [];
|
|
2895
|
+
let hasSplat = false;
|
|
2896
|
+
let hasMultiplayer = false;
|
|
2897
|
+
for (const t of traits) {
|
|
2898
|
+
if (t.name === GAUSSIAN_SPLAT_TRAIT_NAME) hasSplat = true;
|
|
2899
|
+
else if (t.name === MULTIPLAYER_TRAIT_NAME) hasMultiplayer = true;
|
|
2900
|
+
if (hasSplat && hasMultiplayer) return true;
|
|
2901
|
+
}
|
|
2902
|
+
const childrenLike = obj.children ?? obj.objects ?? [];
|
|
2903
|
+
for (const child of childrenLike) {
|
|
2904
|
+
if (objectHasBothTraits(child)) return true;
|
|
2905
|
+
}
|
|
2906
|
+
return false;
|
|
2907
|
+
}
|
|
2908
|
+
var SHARED_SORT_SHADER_PATH = "packages/engine/src/gpu/shaders/splat-shared-sort.wgsl";
|
|
2909
|
+
var GaussianSplattingCompiler = class extends chunkRMHC2VG7_cjs.CompilerBase {
|
|
2910
|
+
constructor(options = {}) {
|
|
2911
|
+
super();
|
|
2912
|
+
this.compilerName = "GaussianSplattingCompiler";
|
|
2913
|
+
this.options = {
|
|
2914
|
+
format: options.format ?? "glb",
|
|
2915
|
+
colorSpace: options.colorSpace ?? "srgb_rec709_display",
|
|
2916
|
+
generator: options.generator ?? "HoloScript GaussianSplattingCompiler v1.0.0",
|
|
2917
|
+
copyright: options.copyright ?? "",
|
|
2918
|
+
shDegree: options.shDegree ?? 0
|
|
2919
|
+
};
|
|
2920
|
+
}
|
|
2921
|
+
getRequiredCapability() {
|
|
2922
|
+
return ans.ANSCapabilityPath.GLTF;
|
|
2923
|
+
}
|
|
2924
|
+
compile(composition, agentToken, outputPath) {
|
|
2925
|
+
this.validateCompilerAccess(agentToken, outputPath);
|
|
2926
|
+
const { data, warnings } = this.extractGaussianData(composition);
|
|
2927
|
+
const result = this.buildGLTF(data);
|
|
2928
|
+
if (warnings && warnings.length > 0) {
|
|
2929
|
+
result.warnings = warnings;
|
|
2930
|
+
}
|
|
2931
|
+
return result;
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Extended compile that runs the standard glTF export AND reports
|
|
2935
|
+
* compile-time WebGPU emit flags derived from trait co-occurrence.
|
|
2936
|
+
*
|
|
2937
|
+
* The standard `compile()` API is left unchanged so existing call sites
|
|
2938
|
+
* (MCP `compile_to_3dgs`, ExportManager) keep their contract. Callers that
|
|
2939
|
+
* need the shared-sort flag opt in via this method.
|
|
2940
|
+
*
|
|
2941
|
+
* @see detectMultiUserSharedSort (the detection rule)
|
|
2942
|
+
* @see SHARED_SORT_SHADER_PATH (the kernel artifact path)
|
|
2943
|
+
*/
|
|
2944
|
+
compileExtended(composition, agentToken, outputPath) {
|
|
2945
|
+
const gltf = this.compile(composition, agentToken, outputPath);
|
|
2946
|
+
const multiUserSharedSort = detectMultiUserSharedSort(composition);
|
|
2947
|
+
return {
|
|
2948
|
+
gltf,
|
|
2949
|
+
multiUserSharedSort,
|
|
2950
|
+
sharedSortShaderPath: multiUserSharedSort ? SHARED_SORT_SHADER_PATH : void 0
|
|
2951
|
+
};
|
|
2952
|
+
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Instance accessor for the multi-user shared-sort detector. Mirrors the
|
|
2955
|
+
* standalone `detectMultiUserSharedSort()` export — provided so callers
|
|
2956
|
+
* holding a compiler instance can run the check without a second import.
|
|
2957
|
+
*/
|
|
2958
|
+
detectMultiUserSharedSort(composition) {
|
|
2959
|
+
return detectMultiUserSharedSort(composition);
|
|
2960
|
+
}
|
|
2961
|
+
// ─── Data extraction ────────────────────────────────────────────────────────
|
|
2962
|
+
extractGaussianData(composition) {
|
|
2963
|
+
for (const obj of composition.objects ?? []) {
|
|
2964
|
+
const trait = obj.traits?.find((t) => t.name === "gaussian_splat");
|
|
2965
|
+
if (trait && trait.config) {
|
|
2966
|
+
const p = trait.config;
|
|
2967
|
+
const positions = this.parseFloatArray(p.positions);
|
|
2968
|
+
const scales = this.parseFloatArray(p.scales);
|
|
2969
|
+
const rotations = this.parseFloatArray(p.rotations);
|
|
2970
|
+
let colors = this.parseFloatArray(p.colors);
|
|
2971
|
+
const opacities = this.parseFloatArray(p.opacities);
|
|
2972
|
+
if (positions && scales && rotations && colors && opacities) {
|
|
2973
|
+
const count = positions.length / 3;
|
|
2974
|
+
if (scales.length === count * 3 && rotations.length === count * 4 && (colors.length === count * 4 || colors.length === count * 3) && opacities.length === count) {
|
|
2975
|
+
if (colors.length === count * 3) {
|
|
2976
|
+
colors = this.expandRgbToRgba(colors, count);
|
|
2977
|
+
}
|
|
2978
|
+
return {
|
|
2979
|
+
data: {
|
|
2980
|
+
positions,
|
|
2981
|
+
scales,
|
|
2982
|
+
rotations,
|
|
2983
|
+
colors,
|
|
2984
|
+
opacities,
|
|
2985
|
+
shCoefficients: this.parseFloatArray(p.shCoefficients),
|
|
2986
|
+
count
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
if (positions && colors) {
|
|
2992
|
+
const count = positions.length / 3;
|
|
2993
|
+
if (colors.length === count * 3 || colors.length === count * 4) {
|
|
2994
|
+
return { data: this.computeCovarianceFromPointCloud(positions, colors) };
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
return {
|
|
3000
|
+
data: this.generateDemoGrid(),
|
|
3001
|
+
warnings: ["No valid @gaussian_splat trait data found; falling back to demo grid"]
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
expandRgbToRgba(rgb, count) {
|
|
3005
|
+
const rgba = new Float32Array(count * 4);
|
|
3006
|
+
for (let i = 0; i < count; i++) {
|
|
3007
|
+
rgba[i * 4] = rgb[i * 3];
|
|
3008
|
+
rgba[i * 4 + 1] = rgb[i * 3 + 1];
|
|
3009
|
+
rgba[i * 4 + 2] = rgb[i * 3 + 2];
|
|
3010
|
+
rgba[i * 4 + 3] = 1;
|
|
3011
|
+
}
|
|
3012
|
+
return rgba;
|
|
3013
|
+
}
|
|
3014
|
+
parseFloatArray(value) {
|
|
3015
|
+
if (value instanceof Float32Array) return value;
|
|
3016
|
+
if (Array.isArray(value)) {
|
|
3017
|
+
const nums = value.map((v) => typeof v === "number" ? v : Number(v));
|
|
3018
|
+
return new Float32Array(nums);
|
|
3019
|
+
}
|
|
3020
|
+
return void 0;
|
|
3021
|
+
}
|
|
3022
|
+
// ─── Covariance from point cloud (HoloMap raw output) ───────────────────────
|
|
3023
|
+
/**
|
|
3024
|
+
* Compute per-point Gaussian parameters from a raw point cloud.
|
|
3025
|
+
*
|
|
3026
|
+
* For each point we find k nearest neighbours, compute the 3x3 covariance
|
|
3027
|
+
* matrix of that neighbourhood, eigen-decompose it via Jacobi rotations,
|
|
3028
|
+
* and derive:
|
|
3029
|
+
* - scales = sqrt(eigenvalues) (isotropic minimum clamp)
|
|
3030
|
+
* - rotation = quaternion from eigenvector basis
|
|
3031
|
+
* - opacity = 1.0 (uniform)
|
|
3032
|
+
* - colors = passed through (RGB expanded to RGBA if needed)
|
|
3033
|
+
*/
|
|
3034
|
+
computeCovarianceFromPointCloud(positions, colors) {
|
|
3035
|
+
const n = Math.floor(positions.length / 3);
|
|
3036
|
+
const k = Math.min(12, Math.max(4, n - 1));
|
|
3037
|
+
const scales = new Float32Array(n * 3);
|
|
3038
|
+
const rotations = new Float32Array(n * 4);
|
|
3039
|
+
const opacities = new Float32Array(n);
|
|
3040
|
+
let rgbaColors;
|
|
3041
|
+
if (colors.length === n * 3) {
|
|
3042
|
+
rgbaColors = this.expandRgbToRgba(colors, n);
|
|
3043
|
+
} else {
|
|
3044
|
+
rgbaColors = colors;
|
|
3045
|
+
}
|
|
3046
|
+
const grid = this.buildSpatialGrid(positions, n);
|
|
3047
|
+
for (let i = 0; i < n; i++) {
|
|
3048
|
+
const px = positions[i * 3];
|
|
3049
|
+
const py = positions[i * 3 + 1];
|
|
3050
|
+
const pz = positions[i * 3 + 2];
|
|
3051
|
+
const neighbours = this.findKNearestNeighbours(grid, positions, n, px, py, pz, k, i);
|
|
3052
|
+
let meanX = 0, meanY = 0, meanZ = 0;
|
|
3053
|
+
for (const idx of neighbours) {
|
|
3054
|
+
meanX += positions[idx * 3];
|
|
3055
|
+
meanY += positions[idx * 3 + 1];
|
|
3056
|
+
meanZ += positions[idx * 3 + 2];
|
|
3057
|
+
}
|
|
3058
|
+
const invM = 1 / neighbours.length;
|
|
3059
|
+
meanX *= invM;
|
|
3060
|
+
meanY *= invM;
|
|
3061
|
+
meanZ *= invM;
|
|
3062
|
+
let c00 = 0, c01 = 0, c02 = 0, c11 = 0, c12 = 0, c22 = 0;
|
|
3063
|
+
for (const idx of neighbours) {
|
|
3064
|
+
const dx = positions[idx * 3] - meanX;
|
|
3065
|
+
const dy = positions[idx * 3 + 1] - meanY;
|
|
3066
|
+
const dz = positions[idx * 3 + 2] - meanZ;
|
|
3067
|
+
c00 += dx * dx;
|
|
3068
|
+
c01 += dx * dy;
|
|
3069
|
+
c02 += dx * dz;
|
|
3070
|
+
c11 += dy * dy;
|
|
3071
|
+
c12 += dy * dz;
|
|
3072
|
+
c22 += dz * dz;
|
|
3073
|
+
}
|
|
3074
|
+
const invLen = 1 / (neighbours.length - 1 || 1);
|
|
3075
|
+
c00 *= invLen;
|
|
3076
|
+
c01 *= invLen;
|
|
3077
|
+
c02 *= invLen;
|
|
3078
|
+
c11 *= invLen;
|
|
3079
|
+
c12 *= invLen;
|
|
3080
|
+
c22 *= invLen;
|
|
3081
|
+
const ev = this.jacobiEigenvalues3([
|
|
3082
|
+
c00,
|
|
3083
|
+
c01,
|
|
3084
|
+
c02,
|
|
3085
|
+
c01,
|
|
3086
|
+
c11,
|
|
3087
|
+
c12,
|
|
3088
|
+
c02,
|
|
3089
|
+
c12,
|
|
3090
|
+
c22
|
|
3091
|
+
]);
|
|
3092
|
+
const minScale = 1e-3;
|
|
3093
|
+
scales[i * 3] = Math.max(minScale, Math.sqrt(Math.abs(ev.values[0])));
|
|
3094
|
+
scales[i * 3 + 1] = Math.max(minScale, Math.sqrt(Math.abs(ev.values[1])));
|
|
3095
|
+
scales[i * 3 + 2] = Math.max(minScale, Math.sqrt(Math.abs(ev.values[2])));
|
|
3096
|
+
const q = this.rotationMatrixToQuaternion(ev.vectors);
|
|
3097
|
+
rotations[i * 4] = q[0];
|
|
3098
|
+
rotations[i * 4 + 1] = q[1];
|
|
3099
|
+
rotations[i * 4 + 2] = q[2];
|
|
3100
|
+
rotations[i * 4 + 3] = q[3];
|
|
3101
|
+
opacities[i] = 1;
|
|
3102
|
+
}
|
|
3103
|
+
return {
|
|
3104
|
+
positions,
|
|
3105
|
+
scales,
|
|
3106
|
+
rotations,
|
|
3107
|
+
colors: rgbaColors,
|
|
3108
|
+
opacities,
|
|
3109
|
+
count: n
|
|
3110
|
+
};
|
|
3111
|
+
}
|
|
3112
|
+
/** Simple uniform-grid spatial hash for k-NN acceleration. */
|
|
3113
|
+
buildSpatialGrid(positions, n) {
|
|
3114
|
+
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
|
3115
|
+
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
3116
|
+
for (let i = 0; i < n; i++) {
|
|
3117
|
+
const x = positions[i * 3];
|
|
3118
|
+
const y = positions[i * 3 + 1];
|
|
3119
|
+
const z = positions[i * 3 + 2];
|
|
3120
|
+
if (x < minX) minX = x;
|
|
3121
|
+
if (y < minY) minY = y;
|
|
3122
|
+
if (z < minZ) minZ = z;
|
|
3123
|
+
if (x > maxX) maxX = x;
|
|
3124
|
+
if (y > maxY) maxY = y;
|
|
3125
|
+
if (z > maxZ) maxZ = z;
|
|
3126
|
+
}
|
|
3127
|
+
const extent = Math.max(maxX - minX, maxY - minY, maxZ - minZ, 1e-6);
|
|
3128
|
+
const cellsPerAxis = Math.max(1, Math.round(Math.pow(n / 8, 1 / 3)));
|
|
3129
|
+
const cellSize = extent / cellsPerAxis;
|
|
3130
|
+
const grid = /* @__PURE__ */ new Map();
|
|
3131
|
+
for (let i = 0; i < n; i++) {
|
|
3132
|
+
const cx = Math.floor((positions[i * 3] - minX) / cellSize);
|
|
3133
|
+
const cy = Math.floor((positions[i * 3 + 1] - minY) / cellSize);
|
|
3134
|
+
const cz = Math.floor((positions[i * 3 + 2] - minZ) / cellSize);
|
|
3135
|
+
const key = `${cx},${cy},${cz}`;
|
|
3136
|
+
const arr = grid.get(key);
|
|
3137
|
+
if (arr) {
|
|
3138
|
+
arr.push(i);
|
|
3139
|
+
} else {
|
|
3140
|
+
grid.set(key, [i]);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
return grid;
|
|
3144
|
+
}
|
|
3145
|
+
findKNearestNeighbours(grid, positions, n, px, py, pz, k, selfIdx) {
|
|
3146
|
+
if (n <= 2048) {
|
|
3147
|
+
const dists = [];
|
|
3148
|
+
for (let i = 0; i < n; i++) {
|
|
3149
|
+
const dx = positions[i * 3] - px;
|
|
3150
|
+
const dy = positions[i * 3 + 1] - py;
|
|
3151
|
+
const dz = positions[i * 3 + 2] - pz;
|
|
3152
|
+
dists.push({ idx: i, d2: dx * dx + dy * dy + dz * dz });
|
|
3153
|
+
}
|
|
3154
|
+
dists.sort((a, b) => a.d2 - b.d2);
|
|
3155
|
+
return dists.slice(0, k + 1).map((d) => d.idx);
|
|
3156
|
+
}
|
|
3157
|
+
const radius = this.estimateSearchRadius(positions, n);
|
|
3158
|
+
const radius2 = radius * radius;
|
|
3159
|
+
const candidates = [];
|
|
3160
|
+
for (let i = 0; i < n; i++) {
|
|
3161
|
+
const dx = positions[i * 3] - px;
|
|
3162
|
+
const dy = positions[i * 3 + 1] - py;
|
|
3163
|
+
const dz = positions[i * 3 + 2] - pz;
|
|
3164
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
3165
|
+
if (d2 <= radius2) {
|
|
3166
|
+
candidates.push({ idx: i, d2 });
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
candidates.sort((a, b) => a.d2 - b.d2);
|
|
3170
|
+
return candidates.slice(0, k + 1).map((c) => c.idx);
|
|
3171
|
+
}
|
|
3172
|
+
estimateSearchRadius(positions, n) {
|
|
3173
|
+
const sampleCount = Math.min(256, n);
|
|
3174
|
+
let totalDist = 0;
|
|
3175
|
+
let counted = 0;
|
|
3176
|
+
const step = Math.max(1, Math.floor(n / sampleCount));
|
|
3177
|
+
for (let i = 0; i < n; i += step) {
|
|
3178
|
+
let minD2 = Infinity;
|
|
3179
|
+
const px = positions[i * 3];
|
|
3180
|
+
const py = positions[i * 3 + 1];
|
|
3181
|
+
const pz = positions[i * 3 + 2];
|
|
3182
|
+
for (let j = 0; j < n; j++) {
|
|
3183
|
+
if (i === j) continue;
|
|
3184
|
+
const dx = positions[j * 3] - px;
|
|
3185
|
+
const dy = positions[j * 3 + 1] - py;
|
|
3186
|
+
const dz = positions[j * 3 + 2] - pz;
|
|
3187
|
+
const d2 = dx * dx + dy * dy + dz * dz;
|
|
3188
|
+
if (d2 < minD2) minD2 = d2;
|
|
3189
|
+
}
|
|
3190
|
+
if (minD2 < Infinity) {
|
|
3191
|
+
totalDist += Math.sqrt(minD2);
|
|
3192
|
+
counted++;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
const avg = counted > 0 ? totalDist / counted : 0.1;
|
|
3196
|
+
return avg * 3;
|
|
3197
|
+
}
|
|
3198
|
+
/** Jacobi eigenvalue decomposition for a 3x3 symmetric matrix.
|
|
3199
|
+
* Returns eigenvalues (descending) and eigenvectors as column-major 3x3.
|
|
3200
|
+
*/
|
|
3201
|
+
jacobiEigenvalues3(a) {
|
|
3202
|
+
let m = [
|
|
3203
|
+
[a[0], a[1], a[2]],
|
|
3204
|
+
[a[3], a[4], a[5]],
|
|
3205
|
+
[a[6], a[7], a[8]]
|
|
3206
|
+
];
|
|
3207
|
+
let v = [
|
|
3208
|
+
[1, 0, 0],
|
|
3209
|
+
[0, 1, 0],
|
|
3210
|
+
[0, 0, 1]
|
|
3211
|
+
];
|
|
3212
|
+
const eps = 1e-10;
|
|
3213
|
+
const maxSweeps = 50;
|
|
3214
|
+
for (let sweep = 0; sweep < maxSweeps; sweep++) {
|
|
3215
|
+
let offDiagSum = 0;
|
|
3216
|
+
for (let p = 0; p < 3; p++) {
|
|
3217
|
+
for (let q = p + 1; q < 3; q++) {
|
|
3218
|
+
offDiagSum += Math.abs(m[p][q]);
|
|
3219
|
+
if (Math.abs(m[p][q]) < eps) continue;
|
|
3220
|
+
const tau = (m[q][q] - m[p][p]) / (2 * m[p][q]);
|
|
3221
|
+
let t;
|
|
3222
|
+
if (tau >= 0) {
|
|
3223
|
+
t = 1 / (tau + Math.sqrt(1 + tau * tau));
|
|
3224
|
+
} else {
|
|
3225
|
+
t = 1 / (tau - Math.sqrt(1 + tau * tau));
|
|
3226
|
+
}
|
|
3227
|
+
const c = 1 / Math.sqrt(1 + t * t);
|
|
3228
|
+
const s = t * c;
|
|
3229
|
+
const mpp = m[p][p];
|
|
3230
|
+
const mqq = m[q][q];
|
|
3231
|
+
const mpq = m[p][q];
|
|
3232
|
+
m[p][p] = c * c * mpp - 2 * s * c * mpq + s * s * mqq;
|
|
3233
|
+
m[q][q] = s * s * mpp + 2 * s * c * mpq + c * c * mqq;
|
|
3234
|
+
m[p][q] = 0;
|
|
3235
|
+
m[q][p] = 0;
|
|
3236
|
+
for (let r = 0; r < 3; r++) {
|
|
3237
|
+
if (r !== p && r !== q) {
|
|
3238
|
+
const mr_p = m[r][p];
|
|
3239
|
+
const mr_q = m[r][q];
|
|
3240
|
+
m[r][p] = c * mr_p - s * mr_q;
|
|
3241
|
+
m[p][r] = m[r][p];
|
|
3242
|
+
m[r][q] = s * mr_p + c * mr_q;
|
|
3243
|
+
m[q][r] = m[r][q];
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
for (let r = 0; r < 3; r++) {
|
|
3247
|
+
const vr_p = v[r][p];
|
|
3248
|
+
const vr_q = v[r][q];
|
|
3249
|
+
v[r][p] = c * vr_p - s * vr_q;
|
|
3250
|
+
v[r][q] = s * vr_p + c * vr_q;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
if (offDiagSum < eps) break;
|
|
3255
|
+
}
|
|
3256
|
+
const vals = [m[0][0], m[1][1], m[2][2]];
|
|
3257
|
+
const cols = [
|
|
3258
|
+
[v[0][0], v[1][0], v[2][0]],
|
|
3259
|
+
[v[0][1], v[1][1], v[2][1]],
|
|
3260
|
+
[v[0][2], v[1][2], v[2][2]]
|
|
3261
|
+
];
|
|
3262
|
+
const order = [0, 1, 2].sort((i, j) => vals[j] - vals[i]);
|
|
3263
|
+
return {
|
|
3264
|
+
values: [vals[order[0]], vals[order[1]], vals[order[2]]],
|
|
3265
|
+
vectors: [
|
|
3266
|
+
cols[order[0]][0],
|
|
3267
|
+
cols[order[1]][0],
|
|
3268
|
+
cols[order[2]][0],
|
|
3269
|
+
cols[order[0]][1],
|
|
3270
|
+
cols[order[1]][1],
|
|
3271
|
+
cols[order[2]][1],
|
|
3272
|
+
cols[order[0]][2],
|
|
3273
|
+
cols[order[1]][2],
|
|
3274
|
+
cols[order[2]][2]
|
|
3275
|
+
]
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
rotationMatrixToQuaternion(m) {
|
|
3279
|
+
const trace = m[0] + m[4] + m[8];
|
|
3280
|
+
let qw, qx, qy, qz;
|
|
3281
|
+
if (trace > 0) {
|
|
3282
|
+
const s = 0.5 / Math.sqrt(trace + 1);
|
|
3283
|
+
qw = 0.25 / s;
|
|
3284
|
+
qx = (m[5] - m[7]) * s;
|
|
3285
|
+
qy = (m[6] - m[2]) * s;
|
|
3286
|
+
qz = (m[1] - m[3]) * s;
|
|
3287
|
+
} else if (m[0] > m[4] && m[0] > m[8]) {
|
|
3288
|
+
const s = 2 * Math.sqrt(1 + m[0] - m[4] - m[8]);
|
|
3289
|
+
qw = (m[5] - m[7]) / s;
|
|
3290
|
+
qx = 0.25 * s;
|
|
3291
|
+
qy = (m[3] + m[1]) / s;
|
|
3292
|
+
qz = (m[6] + m[2]) / s;
|
|
3293
|
+
} else if (m[4] > m[8]) {
|
|
3294
|
+
const s = 2 * Math.sqrt(1 + m[4] - m[0] - m[8]);
|
|
3295
|
+
qw = (m[6] - m[2]) / s;
|
|
3296
|
+
qx = (m[3] + m[1]) / s;
|
|
3297
|
+
qy = 0.25 * s;
|
|
3298
|
+
qz = (m[7] + m[5]) / s;
|
|
3299
|
+
} else {
|
|
3300
|
+
const s = 2 * Math.sqrt(1 + m[8] - m[0] - m[4]);
|
|
3301
|
+
qw = (m[1] - m[3]) / s;
|
|
3302
|
+
qx = (m[6] + m[2]) / s;
|
|
3303
|
+
qy = (m[7] + m[5]) / s;
|
|
3304
|
+
qz = 0.25 * s;
|
|
3305
|
+
}
|
|
3306
|
+
const norm = Math.sqrt(qx * qx + qy * qy + qz * qz + qw * qw) || 1;
|
|
3307
|
+
return [qx / norm, qy / norm, qz / norm, qw / norm];
|
|
3308
|
+
}
|
|
3309
|
+
generateDemoGrid() {
|
|
3310
|
+
const count = 8;
|
|
3311
|
+
const positions = new Float32Array(count * 3);
|
|
3312
|
+
const scales = new Float32Array(count * 3);
|
|
3313
|
+
const rotations = new Float32Array(count * 4);
|
|
3314
|
+
const colors = new Float32Array(count * 4);
|
|
3315
|
+
const opacities = new Float32Array(count);
|
|
3316
|
+
let i = 0;
|
|
3317
|
+
for (let x = 0; x < 2; x++) {
|
|
3318
|
+
for (let y = 0; y < 2; y++) {
|
|
3319
|
+
for (let z = 0; z < 2; z++) {
|
|
3320
|
+
positions[i * 3] = x * 0.5;
|
|
3321
|
+
positions[i * 3 + 1] = y * 0.5;
|
|
3322
|
+
positions[i * 3 + 2] = z * 0.5;
|
|
3323
|
+
scales[i * 3] = 0.1;
|
|
3324
|
+
scales[i * 3 + 1] = 0.1;
|
|
3325
|
+
scales[i * 3 + 2] = 0.1;
|
|
3326
|
+
rotations[i * 4] = 0;
|
|
3327
|
+
rotations[i * 4 + 1] = 0;
|
|
3328
|
+
rotations[i * 4 + 2] = 0;
|
|
3329
|
+
rotations[i * 4 + 3] = 1;
|
|
3330
|
+
colors[i * 4] = 0.8;
|
|
3331
|
+
colors[i * 4 + 1] = 0.3;
|
|
3332
|
+
colors[i * 4 + 2] = 0.3;
|
|
3333
|
+
colors[i * 4 + 3] = 1;
|
|
3334
|
+
opacities[i] = 1;
|
|
3335
|
+
i++;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
return { positions, scales, rotations, colors, opacities, count };
|
|
3340
|
+
}
|
|
3341
|
+
// ─── glTF builder ─────────────────────────────────────────────────────────
|
|
3342
|
+
buildGLTF(data) {
|
|
3343
|
+
const N = data.count;
|
|
3344
|
+
const bufferData = this.buildBuffer(data);
|
|
3345
|
+
const bufferViews = this.buildBufferViews(N);
|
|
3346
|
+
const accessors = this.buildAccessors(N);
|
|
3347
|
+
const primitive = {
|
|
3348
|
+
attributes: {
|
|
3349
|
+
POSITION: 0,
|
|
3350
|
+
_ROTATION: 1,
|
|
3351
|
+
_SCALE: 2,
|
|
3352
|
+
_OPACITY: 3,
|
|
3353
|
+
COLOR_0: 4
|
|
3354
|
+
},
|
|
3355
|
+
mode: 0,
|
|
3356
|
+
// POINTS
|
|
3357
|
+
extensions: {
|
|
3358
|
+
KHR_gaussian_splatting: {
|
|
3359
|
+
colorSpace: this.options.colorSpace
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
const mesh = {
|
|
3364
|
+
name: "GaussianSplatMesh",
|
|
3365
|
+
primitives: [primitive]
|
|
3366
|
+
};
|
|
3367
|
+
const node = {
|
|
3368
|
+
name: "GaussianSplatNode",
|
|
3369
|
+
mesh: 0
|
|
3370
|
+
};
|
|
3371
|
+
const gltf = {
|
|
3372
|
+
asset: {
|
|
3373
|
+
version: "2.0",
|
|
3374
|
+
generator: this.options.generator,
|
|
3375
|
+
...this.options.copyright ? { copyright: this.options.copyright } : {}
|
|
3376
|
+
},
|
|
3377
|
+
scene: 0,
|
|
3378
|
+
scenes: [{ name: "Scene", nodes: [0] }],
|
|
3379
|
+
nodes: [node],
|
|
3380
|
+
meshes: [mesh],
|
|
3381
|
+
accessors,
|
|
3382
|
+
bufferViews,
|
|
3383
|
+
buffers: [{ byteLength: bufferData.byteLength }],
|
|
3384
|
+
extensionsUsed: ["KHR_gaussian_splatting"]
|
|
3385
|
+
};
|
|
3386
|
+
const stats = {
|
|
3387
|
+
nodeCount: 1,
|
|
3388
|
+
meshCount: 1,
|
|
3389
|
+
materialCount: 0,
|
|
3390
|
+
textureCount: 0,
|
|
3391
|
+
animationCount: 0,
|
|
3392
|
+
totalVertices: N,
|
|
3393
|
+
totalTriangles: 0,
|
|
3394
|
+
fileSizeBytes: 0
|
|
3395
|
+
};
|
|
3396
|
+
if (this.options.format === "glb") {
|
|
3397
|
+
const binary = this.createGLB(gltf, bufferData);
|
|
3398
|
+
stats.fileSizeBytes = binary.byteLength;
|
|
3399
|
+
return { binary, stats };
|
|
3400
|
+
}
|
|
3401
|
+
stats.fileSizeBytes = JSON.stringify(gltf).length + bufferData.byteLength;
|
|
3402
|
+
return { json: gltf, buffer: bufferData, stats };
|
|
3403
|
+
}
|
|
3404
|
+
// ─── Binary layout ──────────────────────────────────────────────────────────
|
|
3405
|
+
buildBuffer(data) {
|
|
3406
|
+
const N = data.count;
|
|
3407
|
+
const logScales = new Float32Array(N * 3);
|
|
3408
|
+
for (let i = 0; i < N * 3; i++) {
|
|
3409
|
+
logScales[i] = Math.log(Math.max(data.scales[i], 1e-8));
|
|
3410
|
+
}
|
|
3411
|
+
const size = N * 3 * 4 + N * 4 * 4 + N * 3 * 4 + N * 4 + N * 4 * 4;
|
|
3412
|
+
const buf = new Uint8Array(size);
|
|
3413
|
+
let off = 0;
|
|
3414
|
+
const write = (arr) => {
|
|
3415
|
+
const view = new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
3416
|
+
buf.set(view, off);
|
|
3417
|
+
off += arr.byteLength;
|
|
3418
|
+
};
|
|
3419
|
+
write(data.positions);
|
|
3420
|
+
write(data.rotations);
|
|
3421
|
+
write(logScales);
|
|
3422
|
+
write(data.opacities);
|
|
3423
|
+
write(data.colors);
|
|
3424
|
+
return buf;
|
|
3425
|
+
}
|
|
3426
|
+
buildBufferViews(N) {
|
|
3427
|
+
let off = 0;
|
|
3428
|
+
const views = [];
|
|
3429
|
+
const add = (len) => {
|
|
3430
|
+
views.push({ buffer: 0, byteOffset: off, byteLength: len });
|
|
3431
|
+
off += len;
|
|
3432
|
+
return views.length - 1;
|
|
3433
|
+
};
|
|
3434
|
+
add(N * 3 * 4);
|
|
3435
|
+
add(N * 4 * 4);
|
|
3436
|
+
add(N * 3 * 4);
|
|
3437
|
+
add(N * 4);
|
|
3438
|
+
add(N * 4 * 4);
|
|
3439
|
+
return views;
|
|
3440
|
+
}
|
|
3441
|
+
buildAccessors(N) {
|
|
3442
|
+
let bv = 0;
|
|
3443
|
+
const accs = [];
|
|
3444
|
+
const add = (type, compType, count) => {
|
|
3445
|
+
accs.push({ bufferView: bv++, componentType: compType, count, type });
|
|
3446
|
+
};
|
|
3447
|
+
add("VEC3", 5126, N);
|
|
3448
|
+
add("VEC4", 5126, N);
|
|
3449
|
+
add("VEC3", 5126, N);
|
|
3450
|
+
add("SCALAR", 5126, N);
|
|
3451
|
+
add("VEC4", 5126, N);
|
|
3452
|
+
return accs;
|
|
3453
|
+
}
|
|
3454
|
+
// ─── GLB assembler (mirrors GLTFPipeline) ─────────────────────────────────
|
|
3455
|
+
createGLB(gltf, buffer) {
|
|
3456
|
+
const jsonString = JSON.stringify(gltf);
|
|
3457
|
+
const jsonBuffer = new TextEncoder().encode(jsonString);
|
|
3458
|
+
const jsonPadding = (4 - jsonBuffer.byteLength % 4) % 4;
|
|
3459
|
+
const paddedJsonLength = jsonBuffer.byteLength + jsonPadding;
|
|
3460
|
+
const binPadding = (4 - buffer.byteLength % 4) % 4;
|
|
3461
|
+
const paddedBinLength = buffer.byteLength + binPadding;
|
|
3462
|
+
const totalSize = 12 + 8 + paddedJsonLength + 8 + paddedBinLength;
|
|
3463
|
+
const output = new ArrayBuffer(totalSize);
|
|
3464
|
+
const view = new DataView(output);
|
|
3465
|
+
const bytes = new Uint8Array(output);
|
|
3466
|
+
let offset = 0;
|
|
3467
|
+
view.setUint32(offset, 1179937895, true);
|
|
3468
|
+
offset += 4;
|
|
3469
|
+
view.setUint32(offset, 2, true);
|
|
3470
|
+
offset += 4;
|
|
3471
|
+
view.setUint32(offset, totalSize, true);
|
|
3472
|
+
offset += 4;
|
|
3473
|
+
view.setUint32(offset, paddedJsonLength, true);
|
|
3474
|
+
offset += 4;
|
|
3475
|
+
view.setUint32(offset, 1313821514, true);
|
|
3476
|
+
offset += 4;
|
|
3477
|
+
bytes.set(jsonBuffer, offset);
|
|
3478
|
+
offset += jsonBuffer.byteLength;
|
|
3479
|
+
for (let i = 0; i < jsonPadding; i++) bytes[offset++] = 32;
|
|
3480
|
+
view.setUint32(offset, paddedBinLength, true);
|
|
3481
|
+
offset += 4;
|
|
3482
|
+
view.setUint32(offset, 5130562, true);
|
|
3483
|
+
offset += 4;
|
|
3484
|
+
bytes.set(buffer, offset);
|
|
3485
|
+
offset += buffer.byteLength;
|
|
3486
|
+
for (let i = 0; i < binPadding; i++) bytes[offset++] = 0;
|
|
3487
|
+
return new Uint8Array(output);
|
|
3488
|
+
}
|
|
3489
|
+
};
|
|
3490
|
+
function createGaussianSplattingCompiler(options) {
|
|
3491
|
+
return new GaussianSplattingCompiler(options);
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
// src/compiler/SpatialPartitionPass.ts
|
|
3495
|
+
var MAX_DEPTH = 8;
|
|
3496
|
+
var SCALE_PER_SPLAT_UNIT = 1e-6;
|
|
3497
|
+
var MIN_SCALE = 1e-9;
|
|
3498
|
+
var SpatialPartitionPass = class {
|
|
3499
|
+
constructor(options = {}) {
|
|
3500
|
+
this.maxDepth = options.maxDepth ?? MAX_DEPTH;
|
|
3501
|
+
this.scalePerSplatUnit = options.scalePerSplatUnit ?? SCALE_PER_SPLAT_UNIT;
|
|
3502
|
+
this.includeUnpositioned = options.includeUnpositioned ?? true;
|
|
3503
|
+
}
|
|
3504
|
+
/**
|
|
3505
|
+
* Run the pass over a HoloComposition and return the serializable result.
|
|
3506
|
+
*/
|
|
3507
|
+
run(composition) {
|
|
3508
|
+
const rawSources = [];
|
|
3509
|
+
this.collectFromComposition(composition, rawSources);
|
|
3510
|
+
if (rawSources.length === 0) {
|
|
3511
|
+
return this.emptyResult(composition.name);
|
|
3512
|
+
}
|
|
3513
|
+
const maxScaleInScene = Math.max(
|
|
3514
|
+
...rawSources.map((s) => Math.max(s.maxSplats * this.scalePerSplatUnit, MIN_SCALE))
|
|
3515
|
+
);
|
|
3516
|
+
const anchors = [];
|
|
3517
|
+
const lodDist = {};
|
|
3518
|
+
let objectsWalked = 0;
|
|
3519
|
+
for (const src of rawSources) {
|
|
3520
|
+
objectsWalked++;
|
|
3521
|
+
if (!this.includeUnpositioned && !src.hasPosition) continue;
|
|
3522
|
+
const scale = Math.max(src.maxSplats * this.scalePerSplatUnit, MIN_SCALE);
|
|
3523
|
+
const lodLevel = this.computeLODLevel(scale, maxScaleInScene);
|
|
3524
|
+
const provenanceHash = src.sourceFile ? deterministicHash(`file:${src.sourceFile}:${src.maxSplats}`) : deterministicHash(`${src.objectName}:${lodLevel}:${src.maxSplats}`);
|
|
3525
|
+
const anchor = {
|
|
3526
|
+
id: `spa_${sanitiseId(src.objectName)}_l${lodLevel}`,
|
|
3527
|
+
position: src.position,
|
|
3528
|
+
scale,
|
|
3529
|
+
lodLevel,
|
|
3530
|
+
gaussianCount: src.maxSplats,
|
|
3531
|
+
importance: src.importance,
|
|
3532
|
+
provenanceHash,
|
|
3533
|
+
...src.sourceFile ? { sourceFile: src.sourceFile } : {}
|
|
3534
|
+
};
|
|
3535
|
+
anchors.push(anchor);
|
|
3536
|
+
lodDist[lodLevel] = (lodDist[lodLevel] ?? 0) + 1;
|
|
3537
|
+
}
|
|
3538
|
+
anchors.sort((a, b) => a.lodLevel - b.lodLevel);
|
|
3539
|
+
const bounds = computeBounds(anchors);
|
|
3540
|
+
const merkleRoot = computeMerkleRoot(anchors);
|
|
3541
|
+
const totalGaussians = anchors.reduce((s, a) => s + a.gaussianCount, 0);
|
|
3542
|
+
const maxLodLevel = anchors.length > 0 ? Math.max(...anchors.map((a) => a.lodLevel)) : 0;
|
|
3543
|
+
return {
|
|
3544
|
+
schema: "spatial-partition/v1",
|
|
3545
|
+
compositionName: composition.name,
|
|
3546
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3547
|
+
anchors,
|
|
3548
|
+
bounds,
|
|
3549
|
+
merkleRoot,
|
|
3550
|
+
totalGaussians,
|
|
3551
|
+
stats: {
|
|
3552
|
+
objectsWalked,
|
|
3553
|
+
anchorsEmitted: anchors.length,
|
|
3554
|
+
lodLevelDistribution: lodDist,
|
|
3555
|
+
maxLodLevel,
|
|
3556
|
+
maxScaleInScene
|
|
3557
|
+
}
|
|
3558
|
+
};
|
|
3559
|
+
}
|
|
3560
|
+
// ── LOD level computation (same algorithm as OctreeLODSystem.computeLODLevelFromScale) ──
|
|
3561
|
+
computeLODLevel(scale, maxScaleInScene) {
|
|
3562
|
+
if (scale <= 0 || maxScaleInScene <= 0) return this.maxDepth - 1;
|
|
3563
|
+
if (scale >= maxScaleInScene) return 0;
|
|
3564
|
+
const ratio = maxScaleInScene / scale;
|
|
3565
|
+
const level = Math.floor(Math.log2(ratio));
|
|
3566
|
+
return Math.min(Math.max(0, level), this.maxDepth - 1);
|
|
3567
|
+
}
|
|
3568
|
+
// ── AST Walk (mirrors GaussianBudgetAnalyzer.collectGaussianSources) ─────────
|
|
3569
|
+
collectFromComposition(composition, out) {
|
|
3570
|
+
if (composition.objects) {
|
|
3571
|
+
for (const obj of composition.objects) {
|
|
3572
|
+
this.collectFromObject(obj, out);
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
if (composition.spatialGroups) {
|
|
3576
|
+
for (const group of composition.spatialGroups) {
|
|
3577
|
+
this.collectFromGroup(group, out);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
if (composition.conditionals) {
|
|
3581
|
+
for (const cond of composition.conditionals) {
|
|
3582
|
+
if (cond.objects) {
|
|
3583
|
+
for (const obj of cond.objects) this.collectFromObject(obj, out);
|
|
3584
|
+
}
|
|
3585
|
+
if (cond.elseObjects) {
|
|
3586
|
+
for (const obj of cond.elseObjects) this.collectFromObject(obj, out);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
if (composition.iterators) {
|
|
3591
|
+
for (const iter of composition.iterators) {
|
|
3592
|
+
if (iter.objects) {
|
|
3593
|
+
for (const obj of iter.objects) this.collectFromObject(obj, out);
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
collectFromObject(obj, out) {
|
|
3599
|
+
if (obj.traits) {
|
|
3600
|
+
for (const trait of obj.traits) {
|
|
3601
|
+
if (trait.name === "gaussian_splat") {
|
|
3602
|
+
const src = this.extractSource(obj, trait);
|
|
3603
|
+
if (src) out.push(src);
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
if (obj.children) {
|
|
3608
|
+
for (const child of obj.children) {
|
|
3609
|
+
this.collectFromObject(child, out);
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
collectFromGroup(group, out) {
|
|
3614
|
+
if (group.objects) {
|
|
3615
|
+
for (const obj of group.objects) this.collectFromObject(obj, out);
|
|
3616
|
+
}
|
|
3617
|
+
if (group.groups) {
|
|
3618
|
+
for (const sub of group.groups) this.collectFromGroup(sub, out);
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
extractSource(obj, trait) {
|
|
3622
|
+
const config = trait.config ?? {};
|
|
3623
|
+
const maxSplats = typeof config.max_splats === "number" ? config.max_splats : 5e4;
|
|
3624
|
+
const sourceFile = typeof config.src === "string" ? config.src : typeof config.source === "string" ? config.source : void 0;
|
|
3625
|
+
const importance = typeof config.importance === "number" ? Math.max(0, Math.min(1, config.importance)) : 0.5;
|
|
3626
|
+
let posArr = null;
|
|
3627
|
+
if (obj.position && typeof obj.position.x === "number") {
|
|
3628
|
+
posArr = [obj.position.x, obj.position.y, obj.position.z];
|
|
3629
|
+
} else {
|
|
3630
|
+
const posProp = obj.properties?.find((p) => p.key === "position")?.value;
|
|
3631
|
+
if (Array.isArray(posProp) && posProp.length >= 3) {
|
|
3632
|
+
posArr = [Number(posProp[0]), Number(posProp[1]), Number(posProp[2])];
|
|
3633
|
+
} else if (posProp !== null && typeof posProp === "object" && !Array.isArray(posProp) && typeof posProp["x"] === "number") {
|
|
3634
|
+
const pobj = posProp;
|
|
3635
|
+
posArr = [pobj.x, pobj.y, pobj.z];
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
return {
|
|
3639
|
+
objectName: obj.name ?? `unnamed_${Math.random().toString(36).slice(2, 7)}`,
|
|
3640
|
+
position: posArr ?? [0, 0, 0],
|
|
3641
|
+
hasPosition: posArr !== null,
|
|
3642
|
+
maxSplats,
|
|
3643
|
+
sourceFile,
|
|
3644
|
+
importance
|
|
3645
|
+
};
|
|
3646
|
+
}
|
|
3647
|
+
// ── Empty-composition fast path ─────────────────────────────────────────────
|
|
3648
|
+
emptyResult(compositionName) {
|
|
3649
|
+
return {
|
|
3650
|
+
schema: "spatial-partition/v1",
|
|
3651
|
+
compositionName,
|
|
3652
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3653
|
+
anchors: [],
|
|
3654
|
+
bounds: {
|
|
3655
|
+
min: { x: 0, y: 0, z: 0 },
|
|
3656
|
+
max: { x: 0, y: 0, z: 0 },
|
|
3657
|
+
center: { x: 0, y: 0, z: 0 },
|
|
3658
|
+
halfSize: 0
|
|
3659
|
+
},
|
|
3660
|
+
merkleRoot: "0".repeat(64),
|
|
3661
|
+
totalGaussians: 0,
|
|
3662
|
+
stats: {
|
|
3663
|
+
objectsWalked: 0,
|
|
3664
|
+
anchorsEmitted: 0,
|
|
3665
|
+
lodLevelDistribution: {},
|
|
3666
|
+
maxLodLevel: 0,
|
|
3667
|
+
maxScaleInScene: 0
|
|
3668
|
+
}
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
};
|
|
3672
|
+
function deterministicHash(input) {
|
|
3673
|
+
let h0 = 2166136261;
|
|
3674
|
+
let h1 = 3521423859;
|
|
3675
|
+
for (let i = 0; i < input.length; i++) {
|
|
3676
|
+
const c = input.charCodeAt(i);
|
|
3677
|
+
h0 = Math.imul(h0 ^ c, 16777619) >>> 0;
|
|
3678
|
+
h1 = Math.imul(h1 ^ c, 16777619) >>> 0;
|
|
3679
|
+
}
|
|
3680
|
+
const hex0 = h0.toString(16).padStart(8, "0");
|
|
3681
|
+
const hex1 = h1.toString(16).padStart(8, "0");
|
|
3682
|
+
const base = (hex0 + hex1).repeat(4).slice(0, 64);
|
|
3683
|
+
return base;
|
|
3684
|
+
}
|
|
3685
|
+
function computeMerkleRoot(anchors) {
|
|
3686
|
+
if (anchors.length === 0) return "0".repeat(64);
|
|
3687
|
+
const sorted = [...anchors].sort((a, b) => a.id.localeCompare(b.id));
|
|
3688
|
+
const bytes = new Uint8Array(32);
|
|
3689
|
+
for (const anchor of sorted) {
|
|
3690
|
+
const hash = anchor.provenanceHash.slice(0, 64).padEnd(64, "0");
|
|
3691
|
+
for (let i = 0; i < 32; i++) {
|
|
3692
|
+
const byteHex = hash.slice(i * 2, i * 2 + 2);
|
|
3693
|
+
bytes[i] ^= parseInt(byteHex, 16) || 0;
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3697
|
+
}
|
|
3698
|
+
function computeBounds(anchors) {
|
|
3699
|
+
if (anchors.length === 0) {
|
|
3700
|
+
return {
|
|
3701
|
+
min: { x: 0, y: 0, z: 0 },
|
|
3702
|
+
max: { x: 0, y: 0, z: 0 },
|
|
3703
|
+
center: { x: 0, y: 0, z: 0 },
|
|
3704
|
+
halfSize: 0
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
let minX = Infinity, minY = Infinity, minZ = Infinity;
|
|
3708
|
+
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
3709
|
+
for (const a of anchors) {
|
|
3710
|
+
const r = a.scale;
|
|
3711
|
+
minX = Math.min(minX, a.position[0] - r);
|
|
3712
|
+
minY = Math.min(minY, a.position[1] - r);
|
|
3713
|
+
minZ = Math.min(minZ, a.position[2] - r);
|
|
3714
|
+
maxX = Math.max(maxX, a.position[0] + r);
|
|
3715
|
+
maxY = Math.max(maxY, a.position[1] + r);
|
|
3716
|
+
maxZ = Math.max(maxZ, a.position[2] + r);
|
|
3717
|
+
}
|
|
3718
|
+
const cx = (minX + maxX) / 2;
|
|
3719
|
+
const cy = (minY + maxY) / 2;
|
|
3720
|
+
const cz = (minZ + maxZ) / 2;
|
|
3721
|
+
const halfSize = Math.max(
|
|
3722
|
+
(maxX - minX) / 2,
|
|
3723
|
+
(maxY - minY) / 2,
|
|
3724
|
+
(maxZ - minZ) / 2
|
|
3725
|
+
);
|
|
3726
|
+
return {
|
|
3727
|
+
min: { x: minX, y: minY, z: minZ },
|
|
3728
|
+
max: { x: maxX, y: maxY, z: maxZ },
|
|
3729
|
+
center: { x: cx, y: cy, z: cz },
|
|
3730
|
+
halfSize
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
function sanitiseId(s) {
|
|
3734
|
+
return s.replace(/[^a-zA-Z0-9_]/g, "_").slice(0, 32);
|
|
3735
|
+
}
|
|
3736
|
+
function spatialPartition(composition, options) {
|
|
3737
|
+
return new SpatialPartitionPass(options).run(composition);
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3387
3740
|
// src/types/effects.ts
|
|
3388
3741
|
function effectCategory(effect) {
|
|
3389
3742
|
return effect.split(":")[0];
|
|
@@ -3548,6 +3901,7 @@ var TRAIT_EFFECTS = {
|
|
|
3548
3901
|
// Audio traits
|
|
3549
3902
|
"@audio": ["audio:play"],
|
|
3550
3903
|
"@spatial_audio": ["audio:spatial"],
|
|
3904
|
+
"@gem_resonance": ["audio:spatial", "state:read"],
|
|
3551
3905
|
"@reverb": ["audio:reverb"],
|
|
3552
3906
|
"@music": ["audio:play", "audio:global"],
|
|
3553
3907
|
// State traits
|
|
@@ -3758,6 +4112,7 @@ var TRAIT_EFFECTS = {
|
|
|
3758
4112
|
"@mitosis": [],
|
|
3759
4113
|
"@mock": [],
|
|
3760
4114
|
"@model_load": [],
|
|
4115
|
+
"@modbus": ["io:network"],
|
|
3761
4116
|
"@motion_reduced": ["io:read", "io:write"],
|
|
3762
4117
|
"@mqtt_pub": ["io:network"],
|
|
3763
4118
|
"@mqtt_sink": ["io:network"],
|
|
@@ -3775,6 +4130,7 @@ var TRAIT_EFFECTS = {
|
|
|
3775
4130
|
"@object_tracking": ["state:read"],
|
|
3776
4131
|
"@occlusion": ["io:read", "io:write"],
|
|
3777
4132
|
"@openxr_hal": [],
|
|
4133
|
+
"@opc_ua": ["io:network"],
|
|
3778
4134
|
"@orbital": [],
|
|
3779
4135
|
"@package_signing": ["authority:own"],
|
|
3780
4136
|
"@pagerduty": [],
|
|
@@ -3967,7 +4323,9 @@ function inferFromTraits(traitNames) {
|
|
|
3967
4323
|
sources.set(e, existing);
|
|
3968
4324
|
}
|
|
3969
4325
|
} else {
|
|
3970
|
-
warnings.push(
|
|
4326
|
+
warnings.push(
|
|
4327
|
+
`Unknown trait '${normalized}': cannot infer effects, so the safety checker assumes pure. Register the trait in TRAIT_EFFECTS or add an explicit @effect declaration before relying on this inference.`
|
|
4328
|
+
);
|
|
3971
4329
|
}
|
|
3972
4330
|
}
|
|
3973
4331
|
return { row: new EffectRow(allEffects), sources, warnings };
|
|
@@ -4258,6 +4616,7 @@ var TRAIT_RESOURCE_COSTS = {
|
|
|
4258
4616
|
// ── Audio ──
|
|
4259
4617
|
"@audio": { audioSources: 1 },
|
|
4260
4618
|
"@spatial_audio": { audioSources: 1 },
|
|
4619
|
+
"@gem_resonance": { audioSources: 1 },
|
|
4261
4620
|
"@environmental_audio": { audioSources: 4, memoryMB: 2 },
|
|
4262
4621
|
"@voice_mesh": { audioSources: 1, networkMsgs: 10 },
|
|
4263
4622
|
"@voice_input": { audioSources: 1, memoryMB: 1 },
|
|
@@ -4270,6 +4629,8 @@ var TRAIT_RESOURCE_COSTS = {
|
|
|
4270
4629
|
"@lobby": { networkMsgs: 5, memoryMB: 2 },
|
|
4271
4630
|
"@mqtt_sink": { networkMsgs: 5 },
|
|
4272
4631
|
"@mqtt_source": { networkMsgs: 5 },
|
|
4632
|
+
"@modbus": { networkMsgs: 5 },
|
|
4633
|
+
"@opc_ua": { networkMsgs: 5 },
|
|
4273
4634
|
"@sync_tier": { networkMsgs: 2 },
|
|
4274
4635
|
"@crdt_room": { networkMsgs: 10, memoryMB: 4 },
|
|
4275
4636
|
"@shareplay": { networkMsgs: 5, memoryMB: 2 },
|
|
@@ -4983,6 +5344,7 @@ function quickSafetyCheck(traits, calls, options = {}) {
|
|
|
4983
5344
|
}
|
|
4984
5345
|
|
|
4985
5346
|
// src/compiler/platform/CrossRealityTraitRegistry.ts
|
|
5347
|
+
chunkAIA52I7T_cjs.init_PlatformConditional();
|
|
4986
5348
|
var CATEGORY_DEFAULT_EMBODIMENT = {
|
|
4987
5349
|
vr: "FullAvatar",
|
|
4988
5350
|
ar: "FloatingAgent",
|
|
@@ -5083,7 +5445,7 @@ var CrossRealityTraitRegistry = class {
|
|
|
5083
5445
|
if (trait.applicablePlatforms.length === 0 && trait.applicableCategories.length === 0)
|
|
5084
5446
|
return true;
|
|
5085
5447
|
if (trait.applicablePlatforms.includes(platform)) return true;
|
|
5086
|
-
const category = platformCategory(platform);
|
|
5448
|
+
const category = chunkAIA52I7T_cjs.platformCategory(platform);
|
|
5087
5449
|
return trait.applicableCategories.includes(category);
|
|
5088
5450
|
}
|
|
5089
5451
|
/** Resolve the default embodiment for a platform */
|
|
@@ -5091,13 +5453,13 @@ var CrossRealityTraitRegistry = class {
|
|
|
5091
5453
|
if (platform in PLATFORM_EMBODIMENT_OVERRIDES) {
|
|
5092
5454
|
return PLATFORM_EMBODIMENT_OVERRIDES[platform];
|
|
5093
5455
|
}
|
|
5094
|
-
const category = platformCategory(platform);
|
|
5456
|
+
const category = chunkAIA52I7T_cjs.platformCategory(platform);
|
|
5095
5457
|
return CATEGORY_DEFAULT_EMBODIMENT[category];
|
|
5096
5458
|
}
|
|
5097
5459
|
/** Validate a handoff path at compile time */
|
|
5098
5460
|
validateHandoffPath(from, to) {
|
|
5099
|
-
const fromCat = platformCategory(from);
|
|
5100
|
-
const toCat = platformCategory(to);
|
|
5461
|
+
const fromCat = chunkAIA52I7T_cjs.platformCategory(from);
|
|
5462
|
+
const toCat = chunkAIA52I7T_cjs.platformCategory(to);
|
|
5101
5463
|
if (fromCat === toCat) return { allowed: true, latencyBudgetMs: 100 };
|
|
5102
5464
|
const rule = HANDOFF_PATH_RULES.find((r) => r.from === fromCat && r.to === toCat);
|
|
5103
5465
|
if (!rule) return { allowed: true, latencyBudgetMs: 500 };
|
|
@@ -5110,7 +5472,7 @@ var CrossRealityTraitRegistry = class {
|
|
|
5110
5472
|
}
|
|
5111
5473
|
/** Get MVC budget for a target platform */
|
|
5112
5474
|
getMVCBudget(platform) {
|
|
5113
|
-
const category = platformCategory(platform);
|
|
5475
|
+
const category = chunkAIA52I7T_cjs.platformCategory(platform);
|
|
5114
5476
|
return MVC_BUDGET_CONSTRAINTS.find((b) => b.category === category) ?? MVC_BUDGET_CONSTRAINTS[0];
|
|
5115
5477
|
}
|
|
5116
5478
|
/** Get total registered trait count */
|
|
@@ -5270,6 +5632,7 @@ function createCrossRealityTraitRegistry() {
|
|
|
5270
5632
|
}
|
|
5271
5633
|
|
|
5272
5634
|
// src/compiler/platform/ModalitySelector.ts
|
|
5635
|
+
chunkAIA52I7T_cjs.init_PlatformConditional();
|
|
5273
5636
|
var EMBODIMENT_TO_TARGET = {
|
|
5274
5637
|
FullAvatar: { primary: "openxr", fallback: "r3f" },
|
|
5275
5638
|
FloatingAgent: { primary: "visionos", fallback: "r3f" },
|
|
@@ -5301,22 +5664,18 @@ var PLATFORM_TARGET_OVERRIDES = {
|
|
|
5301
5664
|
};
|
|
5302
5665
|
function selectModality(platform, options = {}) {
|
|
5303
5666
|
const reasoning = [];
|
|
5304
|
-
const capabilities = PLATFORM_CAPABILITIES[platform];
|
|
5305
|
-
const category = platformCategory(platform);
|
|
5667
|
+
const capabilities = chunkAIA52I7T_cjs.PLATFORM_CAPABILITIES[platform];
|
|
5668
|
+
const category = chunkAIA52I7T_cjs.platformCategory(platform);
|
|
5306
5669
|
let embodiment;
|
|
5307
5670
|
if (options.forceEmbodiment) {
|
|
5308
5671
|
embodiment = options.forceEmbodiment;
|
|
5309
5672
|
reasoning.push(`Embodiment forced to ${embodiment} by caller`);
|
|
5310
5673
|
} else if (platform in PLATFORM_EMBODIMENT_OVERRIDES) {
|
|
5311
5674
|
embodiment = PLATFORM_EMBODIMENT_OVERRIDES[platform];
|
|
5312
|
-
reasoning.push(
|
|
5313
|
-
`Embodiment ${embodiment} from platform-specific override for ${platform}`
|
|
5314
|
-
);
|
|
5675
|
+
reasoning.push(`Embodiment ${embodiment} from platform-specific override for ${platform}`);
|
|
5315
5676
|
} else {
|
|
5316
5677
|
embodiment = CATEGORY_DEFAULT_EMBODIMENT[category];
|
|
5317
|
-
reasoning.push(
|
|
5318
|
-
`Embodiment ${embodiment} from category default for ${category}`
|
|
5319
|
-
);
|
|
5678
|
+
reasoning.push(`Embodiment ${embodiment} from category default for ${category}`);
|
|
5320
5679
|
}
|
|
5321
5680
|
let exportTarget;
|
|
5322
5681
|
let fallbackTarget;
|
|
@@ -5327,16 +5686,12 @@ function selectModality(platform, options = {}) {
|
|
|
5327
5686
|
} else if (platform in PLATFORM_TARGET_OVERRIDES) {
|
|
5328
5687
|
exportTarget = PLATFORM_TARGET_OVERRIDES[platform];
|
|
5329
5688
|
fallbackTarget = EMBODIMENT_TO_TARGET[embodiment]?.fallback ?? null;
|
|
5330
|
-
reasoning.push(
|
|
5331
|
-
`ExportTarget ${exportTarget} from platform-specific override for ${platform}`
|
|
5332
|
-
);
|
|
5689
|
+
reasoning.push(`ExportTarget ${exportTarget} from platform-specific override for ${platform}`);
|
|
5333
5690
|
} else {
|
|
5334
5691
|
const mapping = EMBODIMENT_TO_TARGET[embodiment];
|
|
5335
5692
|
exportTarget = mapping.primary;
|
|
5336
5693
|
fallbackTarget = mapping.fallback;
|
|
5337
|
-
reasoning.push(
|
|
5338
|
-
`ExportTarget ${exportTarget} from embodiment mapping for ${embodiment}`
|
|
5339
|
-
);
|
|
5694
|
+
reasoning.push(`ExportTarget ${exportTarget} from embodiment mapping for ${embodiment}`);
|
|
5340
5695
|
}
|
|
5341
5696
|
const canRenderSpatial = capabilities.gpu3D && capabilities.frameBudgetMs <= 16.6;
|
|
5342
5697
|
reasoning.push(
|
|
@@ -5367,19 +5722,21 @@ function selectModality(platform, options = {}) {
|
|
|
5367
5722
|
}
|
|
5368
5723
|
function selectModalityForAll(options = {}) {
|
|
5369
5724
|
const results = /* @__PURE__ */ new Map();
|
|
5370
|
-
for (const platform of Object.keys(PLATFORM_CAPABILITIES)) {
|
|
5725
|
+
for (const platform of Object.keys(chunkAIA52I7T_cjs.PLATFORM_CAPABILITIES)) {
|
|
5371
5726
|
results.set(platform, selectModality(platform, options));
|
|
5372
5727
|
}
|
|
5373
5728
|
return results;
|
|
5374
5729
|
}
|
|
5375
5730
|
function bestCategoryForTraits(requiredCapabilities) {
|
|
5376
5731
|
const categories = [];
|
|
5377
|
-
for (const [cat, platforms] of Object.entries(PLATFORM_CATEGORIES)) {
|
|
5732
|
+
for (const [cat, platforms] of Object.entries(chunkAIA52I7T_cjs.PLATFORM_CATEGORIES)) {
|
|
5378
5733
|
const canSupport = platforms.some((platform) => {
|
|
5379
|
-
const caps = PLATFORM_CAPABILITIES[platform];
|
|
5734
|
+
const caps = chunkAIA52I7T_cjs.PLATFORM_CAPABILITIES[platform];
|
|
5380
5735
|
return Object.entries(requiredCapabilities).every(([key, required]) => {
|
|
5381
|
-
if (typeof required === "boolean")
|
|
5382
|
-
|
|
5736
|
+
if (typeof required === "boolean")
|
|
5737
|
+
return !required || caps[key] === true;
|
|
5738
|
+
if (typeof required === "number")
|
|
5739
|
+
return caps[key] <= required;
|
|
5383
5740
|
return true;
|
|
5384
5741
|
});
|
|
5385
5742
|
});
|
|
@@ -5401,7 +5758,7 @@ var CompilerBridge = class {
|
|
|
5401
5758
|
if (this.initialized) return;
|
|
5402
5759
|
try {
|
|
5403
5760
|
const [parserModule, compilerModule] = await Promise.all([
|
|
5404
|
-
import('./
|
|
5761
|
+
import('./HoloScriptPlusParser-WKHRIH6T.cjs'),
|
|
5405
5762
|
import('./compiler/r3f.cjs')
|
|
5406
5763
|
]);
|
|
5407
5764
|
this.modules = {
|
|
@@ -5530,6 +5887,16 @@ function getCompilerBridge() {
|
|
|
5530
5887
|
function json(value) {
|
|
5531
5888
|
return JSON.stringify(value, null, 2);
|
|
5532
5889
|
}
|
|
5890
|
+
function unsupportedPipelineStep(kind, type, name) {
|
|
5891
|
+
const typeLabel = type || "unknown";
|
|
5892
|
+
return `[PipelineNodeCompiler] Unsupported pipeline ${kind} type "${typeLabel}" (step: ${name}). PipelineNodeCompiler does not yet emit code for this type.`;
|
|
5893
|
+
}
|
|
5894
|
+
function unsupportedNodeThrow(kind, type, name) {
|
|
5895
|
+
return `(() => { throw new Error(${json(unsupportedPipelineStep(kind, type, name))}); })()`;
|
|
5896
|
+
}
|
|
5897
|
+
function unsupportedPythonRaise(kind, type, name) {
|
|
5898
|
+
return `raise NotImplementedError(${json(unsupportedPipelineStep(kind, type, name))})`;
|
|
5899
|
+
}
|
|
5533
5900
|
function emitSource(source) {
|
|
5534
5901
|
switch (source.type) {
|
|
5535
5902
|
case "rest":
|
|
@@ -5540,15 +5907,29 @@ function emitSource(source) {
|
|
|
5540
5907
|
case "list":
|
|
5541
5908
|
return json(source.items || []);
|
|
5542
5909
|
default:
|
|
5543
|
-
return "
|
|
5910
|
+
return unsupportedNodeThrow("source", source.type, source.name);
|
|
5544
5911
|
}
|
|
5545
5912
|
}
|
|
5546
5913
|
function emitFieldMappingTransform(t) {
|
|
5547
5914
|
const mappings = t.mappings || [];
|
|
5548
|
-
const
|
|
5549
|
-
|
|
5915
|
+
const unwrapMappings = mappings.filter((m) => m.from.endsWith("[]"));
|
|
5916
|
+
const valueMappings = mappings.filter((m) => !m.from.endsWith("[]"));
|
|
5917
|
+
const lines = [];
|
|
5918
|
+
for (const mapping of unwrapMappings) {
|
|
5919
|
+
lines.push(
|
|
5920
|
+
`data = data.flatMap((item) => unwrapPathValues(item, ${json(mapping.from)}).map((value) => ({ ...item, ${json(mapping.to)}: applyTransforms(value, ${json(mapping.transforms || [])}) })));`
|
|
5921
|
+
);
|
|
5922
|
+
}
|
|
5923
|
+
if (valueMappings.length === 0) {
|
|
5924
|
+
return lines.join("\n");
|
|
5925
|
+
}
|
|
5926
|
+
const mapExpr = valueMappings.map(
|
|
5927
|
+
(m) => `${json(m.to)}: applyTransforms(getPathValue(item, ${json(m.from)}), ${json(m.transforms || [])})`
|
|
5928
|
+
).join(",\n ");
|
|
5929
|
+
lines.push(`data = data.map((item) => ({
|
|
5550
5930
|
${mapExpr}
|
|
5551
|
-
}))
|
|
5931
|
+
}));`);
|
|
5932
|
+
return lines.join("\n");
|
|
5552
5933
|
}
|
|
5553
5934
|
function emitTransform(t) {
|
|
5554
5935
|
if ((t.type === "field_mapping" || !t.type) && t.mappings && t.mappings.length > 0) {
|
|
@@ -5580,11 +5961,11 @@ function emitSink(sink) {
|
|
|
5580
5961
|
return `await writeOutput(${json(sink.path || "./pipeline-output.jsonl")}, data, ${json(sink.format || "jsonl")}, ${json(Boolean(sink.append))});`;
|
|
5581
5962
|
case "rest":
|
|
5582
5963
|
case "webhook":
|
|
5583
|
-
return `await
|
|
5964
|
+
return `await postJSON(${json(sink.endpoint || "")}, data, { method: ${json(sink.method || "POST")} });`;
|
|
5584
5965
|
case "mcp":
|
|
5585
5966
|
return `console.warn(${json(`[${sink.name}] mcp sink requires host integration: ${sink.server || ""}/${sink.tool || ""}`)});`;
|
|
5586
5967
|
default:
|
|
5587
|
-
return
|
|
5968
|
+
return `${unsupportedNodeThrow("sink", sink.type, sink.name)};`;
|
|
5588
5969
|
}
|
|
5589
5970
|
}
|
|
5590
5971
|
function emitPythonSource(source) {
|
|
@@ -5597,12 +5978,14 @@ function emitPythonSource(source) {
|
|
|
5597
5978
|
case "list":
|
|
5598
5979
|
return `datasets[${json(source.name)}] = ${json(source.items || [])}`;
|
|
5599
5980
|
default:
|
|
5600
|
-
return
|
|
5981
|
+
return unsupportedPythonRaise("source", source.type, source.name);
|
|
5601
5982
|
}
|
|
5602
5983
|
}
|
|
5603
5984
|
function emitPythonFieldMappingTransform(t) {
|
|
5604
5985
|
const mappings = t.mappings || [];
|
|
5605
|
-
const mappingLines = mappings.map(
|
|
5986
|
+
const mappingLines = mappings.map(
|
|
5987
|
+
(m) => `${json(m.to)}: apply_transforms(item.get(${json(m.from)}), ${json(m.transforms || [])}),`
|
|
5988
|
+
).join("\n ");
|
|
5606
5989
|
return `data = [
|
|
5607
5990
|
{
|
|
5608
5991
|
${mappingLines}
|
|
@@ -5644,7 +6027,7 @@ function emitPythonSink(sink) {
|
|
|
5644
6027
|
case "mcp":
|
|
5645
6028
|
return `print(${json(`[${sink.name}] mcp sink requires host integration: ${sink.server || ""}/${sink.tool || ""}`)})`;
|
|
5646
6029
|
default:
|
|
5647
|
-
return
|
|
6030
|
+
return unsupportedPythonRaise("sink", sink.type, sink.name);
|
|
5648
6031
|
}
|
|
5649
6032
|
}
|
|
5650
6033
|
function compilePipelineToNode(pipeline, options = {}) {
|
|
@@ -5661,18 +6044,55 @@ function compilePipelineToNode(pipeline, options = {}) {
|
|
|
5661
6044
|
*/
|
|
5662
6045
|
|
|
5663
6046
|
import fs from 'node:fs/promises';
|
|
6047
|
+
import path from 'node:path';
|
|
6048
|
+
|
|
6049
|
+
const RUN_DATE = new Date().toISOString().slice(0, 10);
|
|
6050
|
+
|
|
6051
|
+
function resolveTemplate(value, context = {}) {
|
|
6052
|
+
if (typeof value !== 'string') return value;
|
|
6053
|
+
return value
|
|
6054
|
+
.replace(/\\$\\{date\\}/g, RUN_DATE)
|
|
6055
|
+
.replace(/\\$\\{env\\.([A-Za-z_][A-Za-z0-9_]*)\\}/g, (_match, name) => process.env[name] ?? '')
|
|
6056
|
+
.replace(/\\$\\{([A-Za-z_][A-Za-z0-9_.]*)\\}/g, (_match, key) => {
|
|
6057
|
+
const found = key.split('.').reduce((acc, part) => (acc && typeof acc === 'object' ? acc[part] : undefined), context);
|
|
6058
|
+
return found === undefined || found === null ? '' : String(found);
|
|
6059
|
+
});
|
|
6060
|
+
}
|
|
6061
|
+
|
|
6062
|
+
function normalizeOutputPath(rawPath, format) {
|
|
6063
|
+
const resolved = resolveTemplate(rawPath);
|
|
6064
|
+
if (!resolved) return format === 'json' ? './pipeline-output.json' : './pipeline-output.jsonl';
|
|
6065
|
+
if (path.extname(resolved)) return resolved;
|
|
6066
|
+
return path.join(resolved, format === 'json' ? 'pipeline-output.json' : 'pipeline-output.jsonl');
|
|
6067
|
+
}
|
|
5664
6068
|
|
|
5665
6069
|
async function fetchJSON(url, init) {
|
|
5666
|
-
|
|
5667
|
-
|
|
6070
|
+
const resolvedUrl = resolveTemplate(url);
|
|
6071
|
+
if (!resolvedUrl) return [];
|
|
6072
|
+
const res = await fetch(resolvedUrl, init);
|
|
5668
6073
|
if (!res.ok) throw new Error(\`Request failed: \${res.status} \${res.statusText}\`);
|
|
5669
6074
|
const body = await res.json();
|
|
5670
6075
|
return Array.isArray(body) ? body : [body];
|
|
5671
6076
|
}
|
|
5672
6077
|
|
|
6078
|
+
async function postJSON(url, data, init) {
|
|
6079
|
+
const resolvedUrl = resolveTemplate(url, { data });
|
|
6080
|
+
if (!resolvedUrl) {
|
|
6081
|
+
console.warn('[PipelineNodeCompiler] skipping empty webhook/rest sink endpoint');
|
|
6082
|
+
return;
|
|
6083
|
+
}
|
|
6084
|
+
const res = await fetch(resolvedUrl, {
|
|
6085
|
+
...init,
|
|
6086
|
+
headers: { 'content-type': 'application/json', ...(init?.headers || {}) },
|
|
6087
|
+
body: JSON.stringify(data),
|
|
6088
|
+
});
|
|
6089
|
+
if (!res.ok) throw new Error(\`Request failed: \${res.status} \${res.statusText}\`);
|
|
6090
|
+
}
|
|
6091
|
+
|
|
5673
6092
|
async function readJSONArray(filePath) {
|
|
5674
|
-
|
|
5675
|
-
|
|
6093
|
+
const resolvedPath = resolveTemplate(filePath);
|
|
6094
|
+
if (!resolvedPath) return [];
|
|
6095
|
+
const raw = await fs.readFile(resolvedPath, 'utf8');
|
|
5676
6096
|
const parsed = JSON.parse(raw);
|
|
5677
6097
|
return Array.isArray(parsed) ? parsed : [parsed];
|
|
5678
6098
|
}
|
|
@@ -5690,6 +6110,22 @@ function applyTransforms(value, transforms) {
|
|
|
5690
6110
|
return v;
|
|
5691
6111
|
}
|
|
5692
6112
|
|
|
6113
|
+
function getPathValue(item, pathExpr) {
|
|
6114
|
+
const cleanPath = String(pathExpr || '').replace(/\\[\\]$/, '');
|
|
6115
|
+
if (!cleanPath) return item;
|
|
6116
|
+
return cleanPath.split('.').reduce((acc, part) => {
|
|
6117
|
+
if (acc == null || typeof acc !== 'object') return undefined;
|
|
6118
|
+
return acc[part];
|
|
6119
|
+
}, item);
|
|
6120
|
+
}
|
|
6121
|
+
|
|
6122
|
+
function unwrapPathValues(item, pathExpr) {
|
|
6123
|
+
const value = getPathValue(item, pathExpr);
|
|
6124
|
+
if (Array.isArray(value)) return value;
|
|
6125
|
+
if (value == null) return [];
|
|
6126
|
+
return [value];
|
|
6127
|
+
}
|
|
6128
|
+
|
|
5693
6129
|
function evalCondition(item, condition) {
|
|
5694
6130
|
try {
|
|
5695
6131
|
const fn = new Function('item', \`with (item) { return (\${condition}); }\`);
|
|
@@ -5710,17 +6146,20 @@ function validateItem(item, fields) {
|
|
|
5710
6146
|
return true;
|
|
5711
6147
|
}
|
|
5712
6148
|
|
|
5713
|
-
async function writeOutput(
|
|
6149
|
+
async function writeOutput(rawPath, data, format, append) {
|
|
6150
|
+
const outputPath = normalizeOutputPath(rawPath, format);
|
|
6151
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
6152
|
+
|
|
5714
6153
|
if (format === 'json') {
|
|
5715
6154
|
const text = JSON.stringify(data, null, 2);
|
|
5716
|
-
if (append) await fs.appendFile(
|
|
5717
|
-
else await fs.writeFile(
|
|
6155
|
+
if (append) await fs.appendFile(outputPath, text + '\\n');
|
|
6156
|
+
else await fs.writeFile(outputPath, text);
|
|
5718
6157
|
return;
|
|
5719
6158
|
}
|
|
5720
6159
|
|
|
5721
6160
|
const lines = data.map((d) => JSON.stringify(d)).join('\\n') + '\\n';
|
|
5722
|
-
if (append) await fs.appendFile(
|
|
5723
|
-
else await fs.writeFile(
|
|
6161
|
+
if (append) await fs.appendFile(outputPath, lines);
|
|
6162
|
+
else await fs.writeFile(outputPath, lines);
|
|
5724
6163
|
}
|
|
5725
6164
|
|
|
5726
6165
|
export async function runPipeline() {
|
|
@@ -5909,7 +6348,7 @@ if __name__ == '__main__':
|
|
|
5909
6348
|
`;
|
|
5910
6349
|
}
|
|
5911
6350
|
function compilePipelineSourceToNode(source, options = {}) {
|
|
5912
|
-
const parsed = parsePipeline(source);
|
|
6351
|
+
const parsed = chunkKKFZ3B6J_cjs.parsePipeline(source);
|
|
5913
6352
|
if (!parsed.success || !parsed.pipeline) {
|
|
5914
6353
|
return {
|
|
5915
6354
|
success: false,
|
|
@@ -5922,7 +6361,7 @@ function compilePipelineSourceToNode(source, options = {}) {
|
|
|
5922
6361
|
};
|
|
5923
6362
|
}
|
|
5924
6363
|
function compilePipelineSourceToPython(source, options = {}) {
|
|
5925
|
-
const parsed = parsePipeline(source);
|
|
6364
|
+
const parsed = chunkKKFZ3B6J_cjs.parsePipeline(source);
|
|
5926
6365
|
if (!parsed.success || !parsed.pipeline) {
|
|
5927
6366
|
return {
|
|
5928
6367
|
success: false,
|
|
@@ -5942,144 +6381,32 @@ function compilePipelineSource(source, options = {}) {
|
|
|
5942
6381
|
return compilePipelineSourceToNode(source, options.node);
|
|
5943
6382
|
}
|
|
5944
6383
|
|
|
5945
|
-
// src/compiler/NextJSCompiler.ts
|
|
5946
|
-
chunkQHVVVN47_cjs.init_CompilerBase();
|
|
5947
|
-
init_Native2DCompiler();
|
|
5948
|
-
function findTrait(composition, traitName) {
|
|
5949
|
-
const traits = composition.traits;
|
|
5950
|
-
if (!traits) return null;
|
|
5951
|
-
const found = traits.find((t) => t.name === traitName);
|
|
5952
|
-
return found?.config || null;
|
|
5953
|
-
}
|
|
5954
|
-
var NextJSCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
|
|
5955
|
-
constructor(options = {}) {
|
|
5956
|
-
super();
|
|
5957
|
-
this.options = options;
|
|
5958
|
-
this.compilerName = "NextJSCompiler";
|
|
5959
|
-
}
|
|
5960
|
-
/**
|
|
5961
|
-
* Compile HoloComposition AST to Next.js App Router Code
|
|
5962
|
-
*
|
|
5963
|
-
* @param composition - HoloScript AST
|
|
5964
|
-
* @param agentToken - JWT or UCAN token proving agent identity
|
|
5965
|
-
* @param outputPath - Optional output file path for scope validation
|
|
5966
|
-
* @param sceneGraph - Optional pre-computed SSG
|
|
5967
|
-
*/
|
|
5968
|
-
async compile(composition, agentToken, outputPath, _sceneGraph) {
|
|
5969
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
5970
|
-
return this.buildNextRoute(composition);
|
|
5971
|
-
}
|
|
5972
|
-
validateCompilerAccess(agentToken, outputPath) {
|
|
5973
|
-
if (typeof agentToken === "object" && agentToken !== null) {
|
|
5974
|
-
this.validateCapabilityAccess(agentToken, outputPath);
|
|
5975
|
-
} else {
|
|
5976
|
-
this.validateASTAccess(agentToken);
|
|
5977
|
-
this.validateCodeGeneration(agentToken);
|
|
5978
|
-
if (outputPath) {
|
|
5979
|
-
this.validateOutputPath(agentToken, outputPath);
|
|
5980
|
-
}
|
|
5981
|
-
this.validateSpatialZoneAccess(agentToken);
|
|
5982
|
-
}
|
|
5983
|
-
}
|
|
5984
|
-
buildNextRoute(composition) {
|
|
5985
|
-
const compiler = new exports.Native2DCompiler();
|
|
5986
|
-
const pageTrait = findTrait(composition, "page");
|
|
5987
|
-
const metaTrait = findTrait(composition, "metadata");
|
|
5988
|
-
const route = pageTrait?.route || `/${composition.name.toLowerCase().replace(/\s+/g, "-")}`;
|
|
5989
|
-
const isClient = pageTrait?.client !== false;
|
|
5990
|
-
const slotMap = this.options.slots || {};
|
|
5991
|
-
if (pageTrait?.redirect) {
|
|
5992
|
-
const redirectUrl = pageTrait.redirect;
|
|
5993
|
-
const lines2 = [
|
|
5994
|
-
`// @generated by HoloScript NextJSCompiler \u2014 DO NOT EDIT`,
|
|
5995
|
-
`import { redirect } from 'next/navigation';`,
|
|
5996
|
-
``,
|
|
5997
|
-
`export default function RedirectPage() {`,
|
|
5998
|
-
` redirect(${JSON.stringify(redirectUrl)});`,
|
|
5999
|
-
`}`
|
|
6000
|
-
];
|
|
6001
|
-
if (metaTrait) {
|
|
6002
|
-
const metaEntries = [];
|
|
6003
|
-
if (metaTrait.title) metaEntries.push(` title: ${JSON.stringify(metaTrait.title)},`);
|
|
6004
|
-
if (metaTrait.description) metaEntries.push(` description: ${JSON.stringify(metaTrait.description)},`);
|
|
6005
|
-
lines2.push("");
|
|
6006
|
-
lines2.push(`export const metadata = {`);
|
|
6007
|
-
lines2.push(metaEntries.join("\n"));
|
|
6008
|
-
lines2.push(`};`);
|
|
6009
|
-
}
|
|
6010
|
-
const routePath2 = route.replace(/^\//, "") || "index";
|
|
6011
|
-
return {
|
|
6012
|
-
path: `${routePath2}/page.tsx`,
|
|
6013
|
-
code: lines2.join("\n")
|
|
6014
|
-
};
|
|
6015
|
-
}
|
|
6016
|
-
const compilerOptions = {
|
|
6017
|
-
format: "react",
|
|
6018
|
-
useUIComponents: true,
|
|
6019
|
-
slots: slotMap
|
|
6020
|
-
};
|
|
6021
|
-
const elements = composition.ui?.elements || composition.objects || [];
|
|
6022
|
-
const componentCode = compiler.generateReactComponent(
|
|
6023
|
-
composition.name,
|
|
6024
|
-
elements,
|
|
6025
|
-
composition,
|
|
6026
|
-
compilerOptions
|
|
6027
|
-
);
|
|
6028
|
-
const pageSafeComponentCode = componentCode.replace(
|
|
6029
|
-
/export\s+function\s+([A-Za-z0-9_]+)\s*\(/,
|
|
6030
|
-
"function $1("
|
|
6031
|
-
);
|
|
6032
|
-
const lines = [];
|
|
6033
|
-
if (isClient) {
|
|
6034
|
-
lines.push("'use client';");
|
|
6035
|
-
lines.push("");
|
|
6036
|
-
}
|
|
6037
|
-
lines.push(pageSafeComponentCode);
|
|
6038
|
-
if (metaTrait && !isClient) {
|
|
6039
|
-
const metaEntries = [];
|
|
6040
|
-
if (metaTrait.title) metaEntries.push(` title: ${JSON.stringify(metaTrait.title)},`);
|
|
6041
|
-
if (metaTrait.description) metaEntries.push(` description: ${JSON.stringify(metaTrait.description)},`);
|
|
6042
|
-
lines.push("");
|
|
6043
|
-
lines.push(`export const metadata = {`);
|
|
6044
|
-
lines.push(metaEntries.join("\n"));
|
|
6045
|
-
lines.push(`};`);
|
|
6046
|
-
}
|
|
6047
|
-
const routePath = route.replace(/^\//, "") || "index";
|
|
6048
|
-
return {
|
|
6049
|
-
path: `${routePath}/page.tsx`,
|
|
6050
|
-
code: lines.join("\n")
|
|
6051
|
-
};
|
|
6052
|
-
}
|
|
6053
|
-
};
|
|
6054
|
-
|
|
6055
6384
|
exports.A2AAgentCardCompiler_exports = A2AAgentCardCompiler_exports;
|
|
6056
|
-
exports.ALL_PLATFORMS = ALL_PLATFORMS;
|
|
6057
6385
|
exports.BUILTIN_RESOURCES = BUILTIN_RESOURCES;
|
|
6058
6386
|
exports.CAPABILITY_HIERARCHY = CAPABILITY_HIERARCHY;
|
|
6059
6387
|
exports.CATEGORY_DEFAULT_EMBODIMENT = CATEGORY_DEFAULT_EMBODIMENT;
|
|
6060
6388
|
exports.CompilerBridge = CompilerBridge;
|
|
6061
6389
|
exports.CrossRealityTraitRegistry = CrossRealityTraitRegistry;
|
|
6062
|
-
exports.
|
|
6390
|
+
exports.EFFECTS_BY_CATEGORY = EFFECTS_BY_CATEGORY;
|
|
6063
6391
|
exports.EFFECT_TO_CAPABILITY = EFFECT_TO_CAPABILITY;
|
|
6064
6392
|
exports.EffectChecker = EffectChecker;
|
|
6065
6393
|
exports.EffectRow = EffectRow;
|
|
6394
|
+
exports.GaussianSplattingCompiler = GaussianSplattingCompiler;
|
|
6066
6395
|
exports.HANDOFF_PATH_RULES = HANDOFF_PATH_RULES;
|
|
6067
6396
|
exports.LinearTypeChecker = LinearTypeChecker;
|
|
6068
6397
|
exports.MVC_BUDGET_CONSTRAINTS = MVC_BUDGET_CONSTRAINTS;
|
|
6069
6398
|
exports.NIRCompiler_exports = NIRCompiler_exports;
|
|
6070
|
-
exports.Native2DCompiler_exports = Native2DCompiler_exports;
|
|
6071
|
-
exports.NextJSCompiler = NextJSCompiler;
|
|
6072
6399
|
exports.PLATFORM_BUDGETS = PLATFORM_BUDGETS;
|
|
6073
|
-
exports.PLATFORM_CAPABILITIES = PLATFORM_CAPABILITIES;
|
|
6074
|
-
exports.PLATFORM_CATEGORIES = PLATFORM_CATEGORIES;
|
|
6075
6400
|
exports.PLATFORM_EMBODIMENT_OVERRIDES = PLATFORM_EMBODIMENT_OVERRIDES;
|
|
6076
6401
|
exports.ResourceBudgetAnalyzer = ResourceBudgetAnalyzer;
|
|
6402
|
+
exports.SHARED_SORT_SHADER_PATH = SHARED_SORT_SHADER_PATH;
|
|
6403
|
+
exports.SpatialPartitionPass = SpatialPartitionPass;
|
|
6077
6404
|
exports.TRAIT_EFFECTS = TRAIT_EFFECTS;
|
|
6078
6405
|
exports.TRAIT_RESOURCE_COSTS = TRAIT_RESOURCE_COSTS;
|
|
6079
6406
|
exports.TRAIT_RESOURCE_MAP = TRAIT_RESOURCE_MAP;
|
|
6080
6407
|
exports.TRUST_LEVEL_CAPABILITIES = TRUST_LEVEL_CAPABILITIES;
|
|
6408
|
+
exports.ThreeJSCompiler_exports = ThreeJSCompiler_exports;
|
|
6081
6409
|
exports.USDZPipeline = USDZPipeline;
|
|
6082
|
-
exports.agentBudgetFor = agentBudgetFor;
|
|
6083
6410
|
exports.bestCategoryForTraits = bestCategoryForTraits;
|
|
6084
6411
|
exports.buildSafetyReport = buildSafetyReport;
|
|
6085
6412
|
exports.checkCapabilities = checkCapabilities;
|
|
@@ -6090,33 +6417,29 @@ exports.compilePipelineToNode = compilePipelineToNode;
|
|
|
6090
6417
|
exports.compilePipelineToPython = compilePipelineToPython;
|
|
6091
6418
|
exports.createCrossRealityTraitRegistry = createCrossRealityTraitRegistry;
|
|
6092
6419
|
exports.createEffectChecker = createEffectChecker;
|
|
6420
|
+
exports.createGaussianSplattingCompiler = createGaussianSplattingCompiler;
|
|
6093
6421
|
exports.dangerLevel = dangerLevel;
|
|
6094
6422
|
exports.deriveRequirements = deriveRequirements;
|
|
6095
|
-
exports.
|
|
6423
|
+
exports.detectMultiUserSharedSort = detectMultiUserSharedSort;
|
|
6424
|
+
exports.effectCategory = effectCategory;
|
|
6096
6425
|
exports.expandCapabilities = expandCapabilities;
|
|
6097
6426
|
exports.formatReport = formatReport;
|
|
6098
6427
|
exports.generateCertificate = generateCertificate;
|
|
6099
6428
|
exports.getCompilerBridge = getCompilerBridge;
|
|
6100
6429
|
exports.getCrossRealityTraitRegistry = getCrossRealityTraitRegistry;
|
|
6101
|
-
exports.hasCapability = hasCapability;
|
|
6102
6430
|
exports.inferFromBuiltins = inferFromBuiltins;
|
|
6103
6431
|
exports.inferFromTraits = inferFromTraits;
|
|
6104
6432
|
exports.init_A2AAgentCardCompiler = init_A2AAgentCardCompiler;
|
|
6105
6433
|
exports.init_NIRCompiler = init_NIRCompiler;
|
|
6106
|
-
exports.
|
|
6107
|
-
exports.isPipelineSource = isPipelineSource;
|
|
6434
|
+
exports.init_ThreeJSCompiler = init_ThreeJSCompiler;
|
|
6108
6435
|
exports.isSafeTraitSet = isSafeTraitSet;
|
|
6109
6436
|
exports.knownBuiltins = knownBuiltins;
|
|
6110
6437
|
exports.knownTraits = knownTraits;
|
|
6111
|
-
exports.matchesPlatform = matchesPlatform;
|
|
6112
|
-
exports.parsePipeline = parsePipeline;
|
|
6113
|
-
exports.platformCategory = platformCategory;
|
|
6114
6438
|
exports.quickSafetyCheck = quickSafetyCheck;
|
|
6115
6439
|
exports.resetCrossRealityTraitRegistry = resetCrossRealityTraitRegistry;
|
|
6116
|
-
exports.resolvePlatforms = resolvePlatforms;
|
|
6117
6440
|
exports.runSafetyPass = runSafetyPass;
|
|
6118
|
-
exports.selectBlock = selectBlock;
|
|
6119
6441
|
exports.selectModality = selectModality;
|
|
6120
6442
|
exports.selectModalityForAll = selectModalityForAll;
|
|
6121
|
-
|
|
6122
|
-
//# sourceMappingURL=chunk-
|
|
6443
|
+
exports.spatialPartition = spatialPartition;
|
|
6444
|
+
//# sourceMappingURL=chunk-QWNQ523V.cjs.map
|
|
6445
|
+
//# sourceMappingURL=chunk-QWNQ523V.cjs.map
|