@holoscript/core 6.0.4 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +3 -2
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/index.d.ts +501 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/tools/index.d.ts +22 -1
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +105 -57
- package/dist/GLTFPipeline-DEN36VNK.js +0 -12
- package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
- package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
- package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
- package/dist/USDZExporter-NTMBNTDB.js +0 -707
- package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2CWOLHTE.js +0 -69
- package/dist/chunk-33LSUQDD.cjs +0 -835
- package/dist/chunk-3FJCK5XA.js +0 -2232
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3SAK5KFL.cjs +0 -83
- package/dist/chunk-4XSNJCLC.cjs +0 -1859
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5BGSECRJ.cjs +0 -2237
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5O6TQC6M.cjs +0 -1871
- package/dist/chunk-5OEOHAAW.cjs +0 -682
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-5WUNN6ZN.cjs +0 -428
- package/dist/chunk-6TZPZCOJ.cjs +0 -1404
- package/dist/chunk-6UEHYZ7V.cjs +0 -773
- package/dist/chunk-6XSERL6L.js +0 -5678
- package/dist/chunk-72EQECGT.cjs +0 -908
- package/dist/chunk-7AGYRWKW.cjs +0 -507
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-A7PIMZGU.js +0 -263
- package/dist/chunk-ATSKSYVE.cjs +0 -51683
- package/dist/chunk-B5TCIAPQ.cjs +0 -117
- package/dist/chunk-BF2235SI.cjs +0 -5714
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BND3ST2K.cjs +0 -662
- package/dist/chunk-BU7VWW2K.js +0 -2522
- package/dist/chunk-BWFJEM5A.js +0 -5419
- package/dist/chunk-CAUCGUEA.cjs +0 -130
- package/dist/chunk-CBJSLA2E.cjs +0 -5423
- package/dist/chunk-CDPGV4DN.js +0 -114
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CS2EMTGF.js +0 -1966
- package/dist/chunk-DMG7C4H2.js +0 -975
- package/dist/chunk-DXJQDCFL.js +0 -468
- package/dist/chunk-E3FWRT3Z.js +0 -608
- package/dist/chunk-E3UALNFA.js +0 -421
- package/dist/chunk-EONILVMF.js +0 -762
- package/dist/chunk-EQV4R3EV.cjs +0 -769
- package/dist/chunk-F3HH56EB.cjs +0 -5538
- package/dist/chunk-F4IULT7N.js +0 -1488
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-FFKU7BTK.cjs +0 -1046
- package/dist/chunk-FHQVYCH2.js +0 -70
- package/dist/chunk-FSF7EQVA.cjs +0 -1974
- package/dist/chunk-G4VZTCIB.js +0 -659
- package/dist/chunk-G7CT3EMP.cjs +0 -1002
- package/dist/chunk-GGHSW2NN.js +0 -51334
- package/dist/chunk-GVUR45UF.cjs +0 -777
- package/dist/chunk-H5Z7NASB.js +0 -9662
- package/dist/chunk-HE7ULERA.cjs +0 -697
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HPS76H7Q.js +0 -309
- package/dist/chunk-HQUEA5R6.cjs +0 -424
- package/dist/chunk-HYNTS5CP.js +0 -422
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IBDG74G2.cjs +0 -1219
- package/dist/chunk-IFNQFCTM.js +0 -3098
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-IWI6J7FX.js +0 -421
- package/dist/chunk-K3JDKWGI.cjs +0 -270
- package/dist/chunk-K6EKD26I.js +0 -630
- package/dist/chunk-KCQ5NDYC.cjs +0 -3172
- package/dist/chunk-KED34ILP.js +0 -832
- package/dist/chunk-KSGXLT74.cjs +0 -457
- package/dist/chunk-L4G4RLXX.js +0 -767
- package/dist/chunk-LDP5OK6G.js +0 -1216
- package/dist/chunk-LGGRPKTV.cjs +0 -735
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-LSW7P7ML.js +0 -3675
- package/dist/chunk-LXJ4667L.cjs +0 -3874
- package/dist/chunk-LZ266PCM.cjs +0 -4499
- package/dist/chunk-MD6KDHVE.cjs +0 -237
- package/dist/chunk-MEASWI2Y.js +0 -126
- package/dist/chunk-MPXBVFHQ.js +0 -768
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUKG4SK.cjs +0 -3075
- package/dist/chunk-NDQNIJEH.js +0 -1715
- package/dist/chunk-NOZZ46QU.js +0 -168
- package/dist/chunk-OFKWH2IP.js +0 -449
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PMGODDJA.cjs +0 -319
- package/dist/chunk-Q4QX3AET.cjs +0 -1505
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-Q5JT3YML.cjs +0 -129
- package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
- package/dist/chunk-QGKNANZ3.js +0 -3071
- package/dist/chunk-QLEAOI3Q.cjs +0 -424
- package/dist/chunk-R7MA7QWV.js +0 -732
- package/dist/chunk-RVYPEYPX.js +0 -678
- package/dist/chunk-S2N5TNMA.js +0 -1855
- package/dist/chunk-S565K7NK.js +0 -752
- package/dist/chunk-SDAMZIRE.js +0 -765
- package/dist/chunk-T36DDXSF.js +0 -4250
- package/dist/chunk-T4NKMBDL.js +0 -5474
- package/dist/chunk-T7LEXZUZ.cjs +0 -2526
- package/dist/chunk-TEWCN33Y.js +0 -694
- package/dist/chunk-TQSZUOW5.cjs +0 -793
- package/dist/chunk-TSH3MSQU.cjs +0 -129
- package/dist/chunk-UERJ3YJV.js +0 -504
- package/dist/chunk-UPJBDCVF.js +0 -1395
- package/dist/chunk-V3NN3HPP.js +0 -4462
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-WB4Z63GG.js +0 -229
- package/dist/chunk-WDW67DZB.cjs +0 -9728
- package/dist/chunk-WGMEAYBG.js +0 -126
- package/dist/chunk-X4ZF6CNE.cjs +0 -473
- package/dist/chunk-X6SEAXAX.cjs +0 -3681
- package/dist/chunk-XCWFGZAA.js +0 -1043
- package/dist/chunk-XD6IYDUX.js +0 -903
- package/dist/chunk-XG23EUQX.cjs +0 -1717
- package/dist/chunk-XRKWN5PL.cjs +0 -173
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-XUTX5CBW.js +0 -126
- package/dist/chunk-XWPNTWDN.cjs +0 -755
- package/dist/chunk-XXINBTZK.cjs +0 -633
- package/dist/chunk-YCXFCXDS.js +0 -1868
- package/dist/chunk-YQK5JNFK.js +0 -3725
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-Z34RLXRA.cjs +0 -612
- package/dist/chunk-ZP4D3CSX.cjs +0 -72
- package/dist/cli/holoscript-runner.cjs +0 -2259
- package/dist/cli/holoscript-runner.js +0 -2234
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -28
- package/dist/compiler/agent-inference.js +0 -5
- package/dist/compiler/android-xr.cjs +0 -19
- package/dist/compiler/android-xr.js +0 -9
- package/dist/compiler/android.cjs +0 -20
- package/dist/compiler/android.js +0 -10
- package/dist/compiler/ar.cjs +0 -20
- package/dist/compiler/ar.js +0 -8
- package/dist/compiler/babylon.cjs +0 -17
- package/dist/compiler/babylon.js +0 -11
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -602
- package/dist/compiler/domain-block-utils.js +0 -8
- package/dist/compiler/dtdl.cjs +0 -24
- package/dist/compiler/dtdl.js +0 -8
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -15
- package/dist/compiler/godot.js +0 -9
- package/dist/compiler/incremental.cjs +0 -29
- package/dist/compiler/incremental.js +0 -4
- package/dist/compiler/index.cjs +0 -2578
- package/dist/compiler/index.js +0 -2383
- package/dist/compiler/ios.cjs +0 -20
- package/dist/compiler/ios.js +0 -10
- package/dist/compiler/multi-layer.cjs +0 -20
- package/dist/compiler/multi-layer.js +0 -11
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -15
- package/dist/compiler/openxr.js +0 -9
- package/dist/compiler/playcanvas.cjs +0 -16
- package/dist/compiler/playcanvas.js +0 -10
- package/dist/compiler/r3f.cjs +0 -34
- package/dist/compiler/r3f.js +0 -12
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -21
- package/dist/compiler/sdf.js +0 -9
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -17
- package/dist/compiler/state.js +0 -7
- package/dist/compiler/trait-composition.cjs +0 -26
- package/dist/compiler/trait-composition.js +0 -5
- package/dist/compiler/unity.cjs +0 -15
- package/dist/compiler/unity.js +0 -9
- package/dist/compiler/unreal.cjs +0 -19
- package/dist/compiler/unreal.js +0 -9
- package/dist/compiler/urdf.cjs +0 -45
- package/dist/compiler/urdf.js +0 -9
- package/dist/compiler/usd-physics.cjs +0 -23
- package/dist/compiler/usd-physics.js +0 -6
- package/dist/compiler/visionos.cjs +0 -15
- package/dist/compiler/visionos.js +0 -9
- package/dist/compiler/vrchat.cjs +0 -19
- package/dist/compiler/vrchat.js +0 -9
- package/dist/compiler/vrr.cjs +0 -21
- package/dist/compiler/vrr.js +0 -9
- package/dist/compiler/wasm.cjs +0 -33
- package/dist/compiler/wasm.js +0 -9
- package/dist/compiler/webgpu.cjs +0 -15
- package/dist/compiler/webgpu.js +0 -9
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -68
- package/dist/entries/scripting.js +0 -11
- package/dist/index.cjs +0 -40921
- package/dist/index.js +0 -37763
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
- package/dist/ml-dsa-WYLJHJO6.js +0 -1178
- package/dist/parser.cjs +0 -27
- package/dist/parser.js +0 -10
- package/dist/playwright-5OSAPTNH.js +0 -98660
- package/dist/playwright-RL6GY4F7.cjs +0 -98673
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14649
- package/dist/traits/index.js +0 -12243
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
package/dist/chunk-TEWCN33Y.js
DELETED
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
import { init_DomainBlockCompilerMixin, compileDomainBlocks, inputToUnity, compileInputBlock, navigationToUnity, compileNavigationBlock, renderingToUnity, compileRenderingBlock, proceduralToUnity, compileProceduralBlock, web3ToUnity, compileWeb3Block, architectureToUnity, compileArchitectureBlock, musicToUnity, compileMusicBlock, educationToUnity, compileEducationBlock, datavizToUnity, compileDataVizBlock, iotToUnity, compileIoTBlock, compileRoboticsBlock, roboticsToUnity, compileHealthcareBlock, healthcareToUnity, compilePaymentBlock, paymentToUnity, compileNarrativeBlock, narrativeToUnity, compileWeatherBlock, weatherToUnity, compileAudioSourceBlock, audioSourceToUnity, compilePostProcessingBlock, postProcessingToUnity, compileParticleBlock, particlesToUnity, compilePhysicsBlock, physicsToUnity, compileMaterialBlock, materialToUnity } from './chunk-YQK5JNFK.js';
|
|
2
|
-
import { init_CompilerBase, CompilerBase } from './chunk-6XSERL6L.js';
|
|
3
|
-
import { __export, __esm } from './chunk-2CWOLHTE.js';
|
|
4
|
-
import { ANSCapabilityPath } from '@holoscript/platform';
|
|
5
|
-
|
|
6
|
-
// src/compiler/UnityCompiler.ts
|
|
7
|
-
var UnityCompiler_exports = {};
|
|
8
|
-
__export(UnityCompiler_exports, {
|
|
9
|
-
UnityCompiler: () => UnityCompiler
|
|
10
|
-
});
|
|
11
|
-
var UnityCompiler;
|
|
12
|
-
var init_UnityCompiler = __esm({
|
|
13
|
-
"src/compiler/UnityCompiler.ts"() {
|
|
14
|
-
init_CompilerBase();
|
|
15
|
-
init_DomainBlockCompilerMixin();
|
|
16
|
-
UnityCompiler = class extends CompilerBase {
|
|
17
|
-
constructor(options = {}) {
|
|
18
|
-
super();
|
|
19
|
-
this.compilerName = "UnityCompiler";
|
|
20
|
-
this.lines = [];
|
|
21
|
-
this.indentLevel = 0;
|
|
22
|
-
this.options = {
|
|
23
|
-
namespace: options.namespace || "HoloScene",
|
|
24
|
-
className: options.className || "GeneratedScene",
|
|
25
|
-
useURP: options.useURP ?? true,
|
|
26
|
-
indent: options.indent || " "
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
getRequiredCapability() {
|
|
30
|
-
return ANSCapabilityPath.UNITY;
|
|
31
|
-
}
|
|
32
|
-
compile(composition, agentToken, outputPath) {
|
|
33
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
34
|
-
this.lines = [];
|
|
35
|
-
this.indentLevel = 0;
|
|
36
|
-
this.emit("// Auto-generated by HoloScript UnityCompiler");
|
|
37
|
-
this.emit(
|
|
38
|
-
`// Source: composition "${this.escapeStringValue(composition.name, "CSharp")}"`
|
|
39
|
-
);
|
|
40
|
-
this.emit("// Do not edit manually \u2014 regenerate from .holo source");
|
|
41
|
-
this.emit("");
|
|
42
|
-
this.emit("using UnityEngine;");
|
|
43
|
-
this.emit("using UnityEngine.UI;");
|
|
44
|
-
if (composition.timelines?.length) this.emit("using System.Collections;");
|
|
45
|
-
this.emit("");
|
|
46
|
-
this.emit(`namespace ${this.options.namespace}`);
|
|
47
|
-
this.emit("{");
|
|
48
|
-
this.indentLevel++;
|
|
49
|
-
this.emit(`public class ${this.options.className} : MonoBehaviour`);
|
|
50
|
-
this.emit("{");
|
|
51
|
-
this.indentLevel++;
|
|
52
|
-
if (composition.state) {
|
|
53
|
-
this.emit("// === State ===");
|
|
54
|
-
for (const prop of composition.state.properties) {
|
|
55
|
-
const csType = this.toCSharpType(prop.value);
|
|
56
|
-
const csVal = this.toCSharpValue(prop.value);
|
|
57
|
-
this.emit(
|
|
58
|
-
`private ${csType} ${this.escapeStringValue(prop.key, "CSharp")} = ${csVal};`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
this.emit("");
|
|
62
|
-
}
|
|
63
|
-
this.emit("private void Awake()");
|
|
64
|
-
this.emit("{");
|
|
65
|
-
this.indentLevel++;
|
|
66
|
-
if (composition.environment) {
|
|
67
|
-
this.compileEnvironment(composition.environment);
|
|
68
|
-
}
|
|
69
|
-
if (composition.lights) {
|
|
70
|
-
for (const light of composition.lights) {
|
|
71
|
-
this.compileLight(light);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (composition.camera) {
|
|
75
|
-
this.compileCamera(composition.camera);
|
|
76
|
-
}
|
|
77
|
-
if (composition.objects) {
|
|
78
|
-
for (const obj of composition.objects) {
|
|
79
|
-
this.compileObject(obj, "transform");
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (composition.spatialGroups) {
|
|
83
|
-
for (const group of composition.spatialGroups) {
|
|
84
|
-
this.compileSpatialGroup(group, "transform");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (composition.audio) {
|
|
88
|
-
for (const audio of composition.audio) {
|
|
89
|
-
this.compileAudio(audio);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (composition.zones) {
|
|
93
|
-
for (const zone of composition.zones) {
|
|
94
|
-
this.compileZone(zone);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (composition.timelines) {
|
|
98
|
-
for (const tl of composition.timelines) {
|
|
99
|
-
if (tl.autoplay) {
|
|
100
|
-
this.emit(`StartCoroutine(${this.sanitizeName(tl.name)}Routine());`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
this.indentLevel--;
|
|
105
|
-
this.emit("}");
|
|
106
|
-
this.emit("");
|
|
107
|
-
if (composition.timelines) {
|
|
108
|
-
for (const tl of composition.timelines) {
|
|
109
|
-
this.compileTimeline(tl);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (composition.effects) {
|
|
113
|
-
this.compileEffects(composition.effects);
|
|
114
|
-
}
|
|
115
|
-
if (composition.transitions) {
|
|
116
|
-
for (const tr of composition.transitions) {
|
|
117
|
-
this.compileTransition(tr);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (composition.ui) {
|
|
121
|
-
this.compileUI(composition.ui);
|
|
122
|
-
}
|
|
123
|
-
this.compileDomainBlocks(composition);
|
|
124
|
-
this.indentLevel--;
|
|
125
|
-
this.emit("}");
|
|
126
|
-
this.indentLevel--;
|
|
127
|
-
this.emit("}");
|
|
128
|
-
return this.lines.join("\n");
|
|
129
|
-
}
|
|
130
|
-
compileDomainBlocks(composition) {
|
|
131
|
-
const domainBlocks = composition.domainBlocks ?? [];
|
|
132
|
-
if (domainBlocks.length === 0) return;
|
|
133
|
-
this.emit("");
|
|
134
|
-
this.emit("// === v4.2 Domain Blocks ===");
|
|
135
|
-
let blockIdx = 0;
|
|
136
|
-
const compiled = compileDomainBlocks(
|
|
137
|
-
domainBlocks,
|
|
138
|
-
{
|
|
139
|
-
material: (block) => {
|
|
140
|
-
const mat = compileMaterialBlock(block);
|
|
141
|
-
const prefix = `db${blockIdx++}`;
|
|
142
|
-
return materialToUnity(mat, prefix);
|
|
143
|
-
},
|
|
144
|
-
physics: (block) => {
|
|
145
|
-
const phys = compilePhysicsBlock(block);
|
|
146
|
-
const prefix = `db${blockIdx++}`;
|
|
147
|
-
return physicsToUnity(phys, prefix);
|
|
148
|
-
},
|
|
149
|
-
vfx: (block) => {
|
|
150
|
-
const ps = compileParticleBlock(block);
|
|
151
|
-
const prefix = `db${blockIdx++}`;
|
|
152
|
-
return particlesToUnity(ps, prefix);
|
|
153
|
-
},
|
|
154
|
-
postfx: (block) => {
|
|
155
|
-
const pp = compilePostProcessingBlock(block);
|
|
156
|
-
return postProcessingToUnity(pp);
|
|
157
|
-
},
|
|
158
|
-
audio: (block) => {
|
|
159
|
-
const audio = compileAudioSourceBlock(block);
|
|
160
|
-
const prefix = `db${blockIdx++}`;
|
|
161
|
-
return audioSourceToUnity(audio, prefix);
|
|
162
|
-
},
|
|
163
|
-
weather: (block) => {
|
|
164
|
-
const weather = compileWeatherBlock(block);
|
|
165
|
-
return weatherToUnity(weather);
|
|
166
|
-
},
|
|
167
|
-
narrative: (block) => {
|
|
168
|
-
const narr = compileNarrativeBlock(block);
|
|
169
|
-
return narrativeToUnity(narr);
|
|
170
|
-
},
|
|
171
|
-
payment: (block) => {
|
|
172
|
-
const pay = compilePaymentBlock(block);
|
|
173
|
-
return paymentToUnity(pay);
|
|
174
|
-
},
|
|
175
|
-
healthcare: (block) => {
|
|
176
|
-
const h = compileHealthcareBlock(block);
|
|
177
|
-
return healthcareToUnity(h);
|
|
178
|
-
},
|
|
179
|
-
robotics: (block) => {
|
|
180
|
-
const r = compileRoboticsBlock(block);
|
|
181
|
-
return roboticsToUnity(r);
|
|
182
|
-
},
|
|
183
|
-
iot: (block) => iotToUnity(compileIoTBlock(block)),
|
|
184
|
-
dataviz: (block) => datavizToUnity(compileDataVizBlock(block)),
|
|
185
|
-
education: (block) => educationToUnity(compileEducationBlock(block)),
|
|
186
|
-
music: (block) => musicToUnity(compileMusicBlock(block)),
|
|
187
|
-
architecture: (block) => architectureToUnity(compileArchitectureBlock(block)),
|
|
188
|
-
web3: (block) => web3ToUnity(compileWeb3Block(block)),
|
|
189
|
-
procedural: (block) => proceduralToUnity(compileProceduralBlock(block)),
|
|
190
|
-
rendering: (block) => renderingToUnity(compileRenderingBlock(block)),
|
|
191
|
-
navigation: (block) => navigationToUnity(compileNavigationBlock(block)),
|
|
192
|
-
input: (block) => inputToUnity(compileInputBlock(block))
|
|
193
|
-
},
|
|
194
|
-
(block) => `// Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "CSharp")}"`
|
|
195
|
-
);
|
|
196
|
-
for (const line of compiled) {
|
|
197
|
-
for (const l of line.split("\n")) {
|
|
198
|
-
this.emit(l);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
compileEnvironment(env) {
|
|
203
|
-
this.emit("// === Environment ===");
|
|
204
|
-
for (const prop of env.properties) {
|
|
205
|
-
if (prop.key === "preset" || prop.key === "skybox") {
|
|
206
|
-
this.emit(`RenderSettings.skybox = Resources.Load<Material>("Skybox/${prop.value}");`);
|
|
207
|
-
} else if (prop.key === "fog" && typeof prop.value === "object") {
|
|
208
|
-
const fog = prop.value;
|
|
209
|
-
this.emit("RenderSettings.fog = true;");
|
|
210
|
-
if (fog.color) this.emit(`RenderSettings.fogColor = ${this.toColor(fog.color)};`);
|
|
211
|
-
if (fog.near !== void 0) this.emit(`RenderSettings.fogStartDistance = ${fog.near}f;`);
|
|
212
|
-
if (fog.far !== void 0) this.emit(`RenderSettings.fogEndDistance = ${fog.far}f;`);
|
|
213
|
-
} else if (prop.key === "ambient_light") {
|
|
214
|
-
this.emit(`RenderSettings.ambientIntensity = ${prop.value}f;`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this.emit("");
|
|
218
|
-
}
|
|
219
|
-
compileLight(light) {
|
|
220
|
-
const varName = this.sanitizeName(light.name);
|
|
221
|
-
this.emit(`// Light: ${this.escapeStringValue(light.name, "CSharp")}`);
|
|
222
|
-
this.emit(
|
|
223
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(light.name, "CSharp")}");`
|
|
224
|
-
);
|
|
225
|
-
this.emit(`${varName}GO.transform.SetParent(transform);`);
|
|
226
|
-
this.emit(`var ${varName} = ${varName}GO.AddComponent<Light>();`);
|
|
227
|
-
const typeMap = {
|
|
228
|
-
directional: "LightType.Directional",
|
|
229
|
-
point: "LightType.Point",
|
|
230
|
-
spot: "LightType.Spot",
|
|
231
|
-
area: "LightType.Area"
|
|
232
|
-
};
|
|
233
|
-
this.emit(`${varName}.type = ${typeMap[light.lightType] || "LightType.Directional"};`);
|
|
234
|
-
for (const prop of light.properties) {
|
|
235
|
-
if (prop.key === "color") {
|
|
236
|
-
this.emit(`${varName}.color = ${this.toColor(prop.value)};`);
|
|
237
|
-
} else if (prop.key === "intensity") {
|
|
238
|
-
this.emit(`${varName}.intensity = ${prop.value}f;`);
|
|
239
|
-
} else if (prop.key === "position" && Array.isArray(prop.value)) {
|
|
240
|
-
this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
|
|
241
|
-
} else if (prop.key === "cast_shadow" || prop.key === "castShadow") {
|
|
242
|
-
this.emit(
|
|
243
|
-
`${varName}.shadows = ${prop.value ? "LightShadows.Soft" : "LightShadows.None"};`
|
|
244
|
-
);
|
|
245
|
-
} else if (prop.key === "angle") {
|
|
246
|
-
this.emit(`${varName}.spotAngle = ${prop.value * (180 / Math.PI)}f;`);
|
|
247
|
-
} else if (prop.key === "distance") {
|
|
248
|
-
this.emit(`${varName}.range = ${prop.value}f;`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
this.emit("");
|
|
252
|
-
}
|
|
253
|
-
compileCamera(camera) {
|
|
254
|
-
this.emit("// === Camera ===");
|
|
255
|
-
this.emit("var cam = Camera.main;");
|
|
256
|
-
this.emit(`cam.fieldOfView = ${this.findProp(camera.properties, "fov") || 60}f;`);
|
|
257
|
-
const pos = this.findProp(camera.properties, "position");
|
|
258
|
-
if (pos) this.emit(`cam.transform.position = ${this.toVector3(pos)};`);
|
|
259
|
-
const lookAt = this.findProp(camera.properties, "look_at") || this.findProp(camera.properties, "lookAt");
|
|
260
|
-
if (lookAt) this.emit(`cam.transform.LookAt(${this.toVector3(lookAt)});`);
|
|
261
|
-
const near = this.findProp(camera.properties, "near");
|
|
262
|
-
if (near) this.emit(`cam.nearClipPlane = ${near}f;`);
|
|
263
|
-
const far = this.findProp(camera.properties, "far");
|
|
264
|
-
if (far) this.emit(`cam.farClipPlane = ${far}f;`);
|
|
265
|
-
this.emit("");
|
|
266
|
-
}
|
|
267
|
-
compileObject(obj, parentVar) {
|
|
268
|
-
const varName = this.sanitizeName(obj.name);
|
|
269
|
-
const meshType = this.findObjProp(obj, "geometry") || this.findObjProp(obj, "mesh") || this.findObjProp(obj, "type") || "cube";
|
|
270
|
-
const isText = meshType === "text";
|
|
271
|
-
const isSparkles = meshType === "sparkles";
|
|
272
|
-
const isModel = meshType === "model" || !!this.findObjProp(obj, "model") || !!this.findObjProp(obj, "src") || !!this.findObjProp(obj, "source");
|
|
273
|
-
this.emit(`// Object: ${this.escapeStringValue(obj.name, "CSharp")}`);
|
|
274
|
-
if (isText) {
|
|
275
|
-
this.emit(
|
|
276
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(obj.name, "CSharp")}");`
|
|
277
|
-
);
|
|
278
|
-
this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
|
|
279
|
-
this.emit(`var ${varName}TM = ${varName}GO.AddComponent<TextMesh>();`);
|
|
280
|
-
const text = this.findObjProp(obj, "text");
|
|
281
|
-
if (text) this.emit(`${varName}TM.text = "${text}";`);
|
|
282
|
-
const fontSize = this.findObjProp(obj, "font_size");
|
|
283
|
-
if (fontSize) this.emit(`${varName}TM.fontSize = ${Math.round(fontSize * 100)};`);
|
|
284
|
-
const color = this.findObjProp(obj, "color");
|
|
285
|
-
if (color) this.emit(`${varName}TM.color = ${this.toColor(color)};`);
|
|
286
|
-
} else if (isModel) {
|
|
287
|
-
const src = this.findObjProp(obj, "model") || this.findObjProp(obj, "src") || this.findObjProp(obj, "source");
|
|
288
|
-
if (src) {
|
|
289
|
-
this.emit(`var ${varName}GO = Instantiate(Resources.Load<GameObject>("Models/${src}"));`);
|
|
290
|
-
} else {
|
|
291
|
-
this.emit(`// WARNING: geometry "model" without source \u2014 placeholder cube`);
|
|
292
|
-
this.emit(`var ${varName}GO = GameObject.CreatePrimitive(PrimitiveType.Cube);`);
|
|
293
|
-
}
|
|
294
|
-
this.emit(`${varName}GO.name = "${this.escapeStringValue(obj.name, "CSharp")}";`);
|
|
295
|
-
this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
|
|
296
|
-
} else if (isSparkles) {
|
|
297
|
-
this.emit(
|
|
298
|
-
`// Sparkles: use ParticleSystem for "${this.escapeStringValue(obj.name, "CSharp")}"`
|
|
299
|
-
);
|
|
300
|
-
this.emit(
|
|
301
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(obj.name, "CSharp")}");`
|
|
302
|
-
);
|
|
303
|
-
this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
|
|
304
|
-
this.emit(`${varName}GO.AddComponent<ParticleSystem>();`);
|
|
305
|
-
} else {
|
|
306
|
-
const primitiveMap = {
|
|
307
|
-
cube: "PrimitiveType.Cube",
|
|
308
|
-
box: "PrimitiveType.Cube",
|
|
309
|
-
sphere: "PrimitiveType.Sphere",
|
|
310
|
-
cylinder: "PrimitiveType.Cylinder",
|
|
311
|
-
plane: "PrimitiveType.Plane",
|
|
312
|
-
capsule: "PrimitiveType.Capsule"
|
|
313
|
-
};
|
|
314
|
-
const primitive = primitiveMap[meshType] || "PrimitiveType.Cube";
|
|
315
|
-
this.emit(`var ${varName}GO = GameObject.CreatePrimitive(${primitive});`);
|
|
316
|
-
this.emit(`${varName}GO.name = "${this.escapeStringValue(obj.name, "CSharp")}";`);
|
|
317
|
-
this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
|
|
318
|
-
}
|
|
319
|
-
const pos = this.findObjProp(obj, "position");
|
|
320
|
-
if (pos) this.emit(`${varName}GO.transform.localPosition = ${this.toVector3(pos)};`);
|
|
321
|
-
const rot = this.findObjProp(obj, "rotation");
|
|
322
|
-
if (rot) this.emit(`${varName}GO.transform.localEulerAngles = ${this.toVector3(rot)};`);
|
|
323
|
-
const scale = this.findObjProp(obj, "scale");
|
|
324
|
-
if (scale) this.emit(`${varName}GO.transform.localScale = ${this.toVector3(scale)};`);
|
|
325
|
-
const size = this.findObjProp(obj, "size");
|
|
326
|
-
if (size && !isText) {
|
|
327
|
-
if (Array.isArray(size)) {
|
|
328
|
-
this.emit(`${varName}GO.transform.localScale = ${this.toVector3(size)};`);
|
|
329
|
-
} else {
|
|
330
|
-
this.emit(`${varName}GO.transform.localScale = Vector3.one * ${size}f;`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
const material = this.findObjProp(obj, "material");
|
|
334
|
-
if (material && typeof material === "object" && !isText && !isModel) {
|
|
335
|
-
this.emit(`var ${varName}Mat = ${varName}GO.GetComponent<Renderer>().material;`);
|
|
336
|
-
const mat = material;
|
|
337
|
-
if (mat.color) this.emit(`${varName}Mat.color = ${this.toColor(mat.color)};`);
|
|
338
|
-
if (mat.roughness !== void 0)
|
|
339
|
-
this.emit(`${varName}Mat.SetFloat("_Smoothness", ${1 - mat.roughness}f);`);
|
|
340
|
-
if (mat.metalness !== void 0)
|
|
341
|
-
this.emit(`${varName}Mat.SetFloat("_Metallic", ${mat.metalness}f);`);
|
|
342
|
-
if (mat.emissive) {
|
|
343
|
-
this.emit(`${varName}Mat.EnableKeyword("_EMISSION");`);
|
|
344
|
-
this.emit(`${varName}Mat.SetColor("_EmissionColor", ${this.toColor(mat.emissive)});`);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (obj.traits) {
|
|
348
|
-
for (const trait of obj.traits) {
|
|
349
|
-
if (trait.name === "collidable") {
|
|
350
|
-
this.emit(`// Collider already present from primitive`);
|
|
351
|
-
} else if (trait.name === "physics" || trait.name === "grabbable") {
|
|
352
|
-
this.emit(`var ${varName}RB = ${varName}GO.AddComponent<Rigidbody>();`);
|
|
353
|
-
if (trait.config?.mass) this.emit(`${varName}RB.mass = ${trait.config.mass}f;`);
|
|
354
|
-
} else if (trait.name === "portal") {
|
|
355
|
-
this.emit(
|
|
356
|
-
`// Portal: "${trait.config?.destination}" \u2014 implement via SceneManager.LoadScene()`
|
|
357
|
-
);
|
|
358
|
-
} else if (trait.name === "plane_detection") {
|
|
359
|
-
this.emit(`// @plane_detection \u2014 AR Foundation: ARPlaneManager`);
|
|
360
|
-
this.emit(`// ${varName}GO.AddComponent<UnityEngine.XR.ARFoundation.ARPlaneManager>();`);
|
|
361
|
-
} else if (trait.name === "mesh_detection") {
|
|
362
|
-
this.emit(`// @mesh_detection \u2014 AR Foundation: ARMeshManager`);
|
|
363
|
-
} else if (trait.name === "anchor") {
|
|
364
|
-
this.emit(`// @anchor \u2014 AR Foundation: ARAnchorManager`);
|
|
365
|
-
} else if (trait.name === "persistent_anchor" || trait.name === "shared_anchor") {
|
|
366
|
-
this.emit(
|
|
367
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 Azure Spatial Anchors or AR Foundation`
|
|
368
|
-
);
|
|
369
|
-
} else if (trait.name === "occlusion") {
|
|
370
|
-
this.emit(`// @occlusion \u2014 AR Foundation: AROcclusionManager`);
|
|
371
|
-
} else if (trait.name === "light_estimation") {
|
|
372
|
-
this.emit(
|
|
373
|
-
`// @light_estimation \u2014 AR Foundation: ARCameraManager.requestedLightEstimation`
|
|
374
|
-
);
|
|
375
|
-
} else if (trait.name === "geospatial" || trait.name === "geospatial_anchor" || trait.name === "terrain_anchor" || trait.name === "rooftop_anchor") {
|
|
376
|
-
this.emit(
|
|
377
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 ARCore Geospatial API`
|
|
378
|
-
);
|
|
379
|
-
} else if (trait.name === "cloth") {
|
|
380
|
-
this.emit(`var ${varName}Cloth = ${varName}GO.AddComponent<Cloth>();`);
|
|
381
|
-
if (trait.config?.stiffness)
|
|
382
|
-
this.emit(`${varName}Cloth.stretchingStiffness = ${trait.config.stiffness}f;`);
|
|
383
|
-
if (trait.config?.damping)
|
|
384
|
-
this.emit(`${varName}Cloth.damping = ${trait.config.damping}f;`);
|
|
385
|
-
} else if (trait.name === "wind") {
|
|
386
|
-
this.emit(`var ${varName}Wind = ${varName}GO.AddComponent<WindZone>();`);
|
|
387
|
-
if (trait.config?.strength)
|
|
388
|
-
this.emit(`${varName}Wind.windMain = ${trait.config.strength}f;`);
|
|
389
|
-
if (trait.config?.turbulence)
|
|
390
|
-
this.emit(`${varName}Wind.windTurbulence = ${trait.config.turbulence}f;`);
|
|
391
|
-
} else if (trait.name === "fluid" || trait.name === "soft_body" || trait.name === "rope" || trait.name === "chain" || trait.name === "buoyancy" || trait.name === "destruction") {
|
|
392
|
-
this.emit(
|
|
393
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 custom physics: ${JSON.stringify(trait.config || {})}`
|
|
394
|
-
);
|
|
395
|
-
} else if (trait.name === "reverb_zone") {
|
|
396
|
-
this.emit(`var ${varName}Reverb = ${varName}GO.AddComponent<AudioReverbZone>();`);
|
|
397
|
-
if (trait.config?.decay_time)
|
|
398
|
-
this.emit(`${varName}Reverb.decayTime = ${trait.config.decay_time}f;`);
|
|
399
|
-
} else if (trait.name === "audio_occlusion") {
|
|
400
|
-
this.emit(`${varName}GO.AddComponent<AudioLowPassFilter>();`);
|
|
401
|
-
this.emit(`// @audio_occlusion \u2014 raycast-based low-pass filter`);
|
|
402
|
-
} else if (trait.name === "ambisonics" || trait.name === "hrtf" || trait.name === "audio_portal" || trait.name === "audio_material" || trait.name === "head_tracked_audio") {
|
|
403
|
-
this.emit(
|
|
404
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 spatial audio: ${JSON.stringify(trait.config || {})}`
|
|
405
|
-
);
|
|
406
|
-
} else if (trait.name === "gaussian_splat" || trait.name === "nerf" || trait.name === "volumetric_video" || trait.name === "point_cloud" || trait.name === "photogrammetry") {
|
|
407
|
-
this.emit(
|
|
408
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 volumetric renderer: ${JSON.stringify(trait.config || {})}`
|
|
409
|
-
);
|
|
410
|
-
} else if (trait.name === "eye_tracking") {
|
|
411
|
-
this.emit(`// @eye_tracking \u2014 XR Interaction Toolkit: XREyeInteractor`);
|
|
412
|
-
} else if (trait.name === "hand_tracking") {
|
|
413
|
-
this.emit(`// @hand_tracking \u2014 XR Hands: XRHandTrackingSubsystem`);
|
|
414
|
-
} else if (trait.name === "body_tracking") {
|
|
415
|
-
this.emit(`// @body_tracking \u2014 XR Body Tracking subsystem`);
|
|
416
|
-
} else if (trait.name === "face_tracking") {
|
|
417
|
-
this.emit(`// @face_tracking \u2014 AR Foundation: ARFaceManager`);
|
|
418
|
-
} else if (trait.name === "accessible") {
|
|
419
|
-
this.emit(
|
|
420
|
-
`// @accessible(role: "${trait.config?.role || "generic"}") \u2014 Unity Accessibility`
|
|
421
|
-
);
|
|
422
|
-
} else if (trait.name === "spatial_persona" || trait.name === "shareplay") {
|
|
423
|
-
this.emit(
|
|
424
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 visionOS-specific; use Mirror/Photon for Unity multiplayer`
|
|
425
|
-
);
|
|
426
|
-
} else if (trait.name === "object_tracking") {
|
|
427
|
-
this.emit(`// @object_tracking \u2014 AR Foundation: ARTrackedObjectManager`);
|
|
428
|
-
} else if (trait.name === "scene_reconstruction") {
|
|
429
|
-
this.emit(`// @scene_reconstruction \u2014 AR Foundation: ARMeshManager`);
|
|
430
|
-
} else if (trait.name === "eye_tracked") {
|
|
431
|
-
this.emit(`// @eye_tracked \u2014 XR Interaction Toolkit: XREyeInteractor`);
|
|
432
|
-
} else if (trait.name === "eye_hand_fusion") {
|
|
433
|
-
this.emit(`// @eye_hand_fusion \u2014 combine XREyeInteractor + XRHandInteractorController`);
|
|
434
|
-
} else if (trait.name === "controlnet") {
|
|
435
|
-
const model = trait.config?.model || "canny";
|
|
436
|
-
this.emit(`// @controlnet(model: "${model}") \u2014 route to inference API or Unity Sentis`);
|
|
437
|
-
} else if (trait.name === "ai_texture_gen") {
|
|
438
|
-
const style = trait.config?.style || "photorealistic";
|
|
439
|
-
this.emit(`// @ai_texture_gen(style: "${style}") \u2014 Unity Sentis or external API`);
|
|
440
|
-
} else if (trait.name === "diffusion_realtime") {
|
|
441
|
-
this.emit(`// @diffusion_realtime \u2014 Unity Sentis real-time diffusion pipeline`);
|
|
442
|
-
} else if (trait.name === "ai_upscaling") {
|
|
443
|
-
const factor = trait.config?.factor || 2;
|
|
444
|
-
this.emit(`// @ai_upscaling(${factor}x) \u2014 Unity Sentis super-resolution model`);
|
|
445
|
-
} else if (trait.name === "ai_inpainting") {
|
|
446
|
-
this.emit(`// @ai_inpainting \u2014 Unity Sentis or API-based inpainting`);
|
|
447
|
-
} else if (trait.name === "neural_link" || trait.name === "neural_forge") {
|
|
448
|
-
this.emit(
|
|
449
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 ${JSON.stringify(trait.config || {})}`
|
|
450
|
-
);
|
|
451
|
-
} else if (trait.name === "embedding_search" || trait.name === "ai_npc_brain" || trait.name === "vector_db") {
|
|
452
|
-
this.emit(
|
|
453
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 AI knowledge: use external service or on-device model`
|
|
454
|
-
);
|
|
455
|
-
} else if (trait.name === "vision" || trait.name === "ai_vision") {
|
|
456
|
-
this.emit(
|
|
457
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 Unity Barracuda / Sentis vision model`
|
|
458
|
-
);
|
|
459
|
-
} else if (trait.name === "spatial_awareness") {
|
|
460
|
-
this.emit(`// @spatial_awareness \u2014 AR Foundation scene understanding`);
|
|
461
|
-
} else if (trait.name === "neural_animation") {
|
|
462
|
-
this.emit(`// @neural_animation \u2014 Motion Matching (com.unity.animation.rigging)`);
|
|
463
|
-
} else {
|
|
464
|
-
this.emit(
|
|
465
|
-
`// @${this.escapeStringValue(trait.name, "CSharp")}: ${JSON.stringify(trait.config || {})}`
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
if (obj.children) {
|
|
471
|
-
for (const child of obj.children) {
|
|
472
|
-
this.compileObject(child, `${varName}GO.transform`);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
this.emit("");
|
|
476
|
-
}
|
|
477
|
-
compileSpatialGroup(group, parentVar) {
|
|
478
|
-
const varName = this.sanitizeName(group.name);
|
|
479
|
-
this.emit(`// Spatial Group: ${this.escapeStringValue(group.name, "CSharp")}`);
|
|
480
|
-
this.emit(
|
|
481
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(group.name, "CSharp")}");`
|
|
482
|
-
);
|
|
483
|
-
this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
|
|
484
|
-
for (const prop of group.properties) {
|
|
485
|
-
if (prop.key === "position" && Array.isArray(prop.value)) {
|
|
486
|
-
this.emit(`${varName}GO.transform.localPosition = ${this.toVector3(prop.value)};`);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
for (const obj of group.objects) {
|
|
490
|
-
this.compileObject(obj, `${varName}GO.transform`);
|
|
491
|
-
}
|
|
492
|
-
if (group.groups) {
|
|
493
|
-
for (const sub of group.groups) {
|
|
494
|
-
this.compileSpatialGroup(sub, `${varName}GO.transform`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
this.emit("");
|
|
498
|
-
}
|
|
499
|
-
compileAudio(audio) {
|
|
500
|
-
const varName = this.sanitizeName(audio.name);
|
|
501
|
-
this.emit(`// Audio: ${this.escapeStringValue(audio.name, "CSharp")}`);
|
|
502
|
-
this.emit(
|
|
503
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(audio.name, "CSharp")}");`
|
|
504
|
-
);
|
|
505
|
-
this.emit(`${varName}GO.transform.SetParent(transform);`);
|
|
506
|
-
this.emit(`var ${varName}AS = ${varName}GO.AddComponent<AudioSource>();`);
|
|
507
|
-
for (const prop of audio.properties) {
|
|
508
|
-
if (prop.key === "src" || prop.key === "source") {
|
|
509
|
-
this.emit(`${varName}AS.clip = Resources.Load<AudioClip>("Audio/${prop.value}");`);
|
|
510
|
-
} else if (prop.key === "volume") {
|
|
511
|
-
this.emit(`${varName}AS.volume = ${prop.value}f;`);
|
|
512
|
-
} else if (prop.key === "loop") {
|
|
513
|
-
this.emit(`${varName}AS.loop = ${prop.value};`);
|
|
514
|
-
} else if (prop.key === "spatial") {
|
|
515
|
-
this.emit(`${varName}AS.spatialBlend = ${prop.value ? "1.0f" : "0.0f"};`);
|
|
516
|
-
} else if (prop.key === "position" && Array.isArray(prop.value)) {
|
|
517
|
-
this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
|
|
518
|
-
} else if (prop.key === "distance") {
|
|
519
|
-
this.emit(`${varName}AS.maxDistance = ${prop.value}f;`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
this.emit(`${varName}AS.Play();`);
|
|
523
|
-
this.emit("");
|
|
524
|
-
}
|
|
525
|
-
compileZone(zone) {
|
|
526
|
-
const varName = this.sanitizeName(zone.name);
|
|
527
|
-
this.emit(`// Zone: ${this.escapeStringValue(zone.name, "CSharp")}`);
|
|
528
|
-
this.emit(
|
|
529
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(zone.name, "CSharp")}");`
|
|
530
|
-
);
|
|
531
|
-
this.emit(`${varName}GO.transform.SetParent(transform);`);
|
|
532
|
-
for (const prop of zone.properties) {
|
|
533
|
-
if (prop.key === "position" && Array.isArray(prop.value)) {
|
|
534
|
-
this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
|
|
535
|
-
} else if (prop.key === "shape" && prop.value === "box") {
|
|
536
|
-
this.emit(`var ${varName}Col = ${varName}GO.AddComponent<BoxCollider>();`);
|
|
537
|
-
this.emit(`${varName}Col.isTrigger = true;`);
|
|
538
|
-
} else if (prop.key === "shape" && prop.value === "sphere") {
|
|
539
|
-
this.emit(`var ${varName}Col = ${varName}GO.AddComponent<SphereCollider>();`);
|
|
540
|
-
this.emit(`${varName}Col.isTrigger = true;`);
|
|
541
|
-
} else if (prop.key === "size" && Array.isArray(prop.value)) {
|
|
542
|
-
this.emit(
|
|
543
|
-
`${varName}GO.GetComponent<Collider>().bounds.size == ${this.toVector3(prop.value)}; // Set via scale`
|
|
544
|
-
);
|
|
545
|
-
} else if (prop.key === "radius") {
|
|
546
|
-
this.emit(`${varName}GO.GetComponent<SphereCollider>().radius = ${prop.value}f;`);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
if (zone.handlers?.length) {
|
|
550
|
-
this.emit(
|
|
551
|
-
`// Zone handlers: ${zone.handlers.map((h) => h.event).join(", ")} \u2014 implement via OnTriggerEnter/Exit`
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
this.emit("");
|
|
555
|
-
}
|
|
556
|
-
compileTimeline(timeline) {
|
|
557
|
-
const varName = this.sanitizeName(timeline.name);
|
|
558
|
-
this.emit(`private IEnumerator ${varName}Routine()`);
|
|
559
|
-
this.emit("{");
|
|
560
|
-
this.indentLevel++;
|
|
561
|
-
let lastTime = 0;
|
|
562
|
-
for (const entry of timeline.entries) {
|
|
563
|
-
const delay = entry.time - lastTime;
|
|
564
|
-
if (delay > 0) {
|
|
565
|
-
this.emit(`yield return new WaitForSeconds(${delay}f);`);
|
|
566
|
-
}
|
|
567
|
-
if (entry.action.kind === "animate") {
|
|
568
|
-
this.emit(`// Animate "${entry.action.target}" \u2014 use DOTween or AnimationCurve`);
|
|
569
|
-
const props = entry.action.properties;
|
|
570
|
-
for (const [key, value] of Object.entries(props)) {
|
|
571
|
-
this.emit(`// ${key}: ${JSON.stringify(value)}`);
|
|
572
|
-
}
|
|
573
|
-
} else if (entry.action.kind === "emit") {
|
|
574
|
-
this.emit(`// Emit event: "${entry.action.event}"`);
|
|
575
|
-
} else if (entry.action.kind === "call") {
|
|
576
|
-
this.emit(`// Call: ${entry.action.method}(${entry.action.args?.join(", ") || ""})`);
|
|
577
|
-
}
|
|
578
|
-
lastTime = entry.time;
|
|
579
|
-
}
|
|
580
|
-
if (timeline.loop) {
|
|
581
|
-
this.emit(`StartCoroutine(${varName}Routine()); // loop`);
|
|
582
|
-
}
|
|
583
|
-
this.indentLevel--;
|
|
584
|
-
this.emit("}");
|
|
585
|
-
this.emit("");
|
|
586
|
-
}
|
|
587
|
-
compileEffects(effects) {
|
|
588
|
-
this.emit("// === Post-Processing (configure via URP Volume) ===");
|
|
589
|
-
for (const effect of effects.effects) {
|
|
590
|
-
this.emit(`// Effect: ${effect.effectType} \u2014 ${JSON.stringify(effect.properties)}`);
|
|
591
|
-
}
|
|
592
|
-
this.emit("");
|
|
593
|
-
}
|
|
594
|
-
compileTransition(tr) {
|
|
595
|
-
const varName = this.sanitizeName(tr.name);
|
|
596
|
-
this.emit(`public void ${varName}()`);
|
|
597
|
-
this.emit("{");
|
|
598
|
-
this.indentLevel++;
|
|
599
|
-
for (const prop of tr.properties) {
|
|
600
|
-
if (prop.key === "target") {
|
|
601
|
-
this.emit(`// Load scene: "${prop.value}"`);
|
|
602
|
-
this.emit(`UnityEngine.SceneManagement.SceneManager.LoadScene("${prop.value}");`);
|
|
603
|
-
} else if (prop.key === "effect") {
|
|
604
|
-
this.emit(`// Transition effect: ${prop.value}`);
|
|
605
|
-
} else if (prop.key === "duration") {
|
|
606
|
-
this.emit(`// Duration: ${prop.value}s`);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
this.indentLevel--;
|
|
610
|
-
this.emit("}");
|
|
611
|
-
this.emit("");
|
|
612
|
-
}
|
|
613
|
-
compileUI(ui) {
|
|
614
|
-
this.emit("// === UI Setup ===");
|
|
615
|
-
this.emit("// Create Canvas for HUD overlay");
|
|
616
|
-
this.emit('var canvasGO = new GameObject("HoloUI");');
|
|
617
|
-
this.emit("canvasGO.transform.SetParent(transform);");
|
|
618
|
-
this.emit("var canvas = canvasGO.AddComponent<Canvas>();");
|
|
619
|
-
this.emit("canvas.renderMode = RenderMode.ScreenSpaceOverlay;");
|
|
620
|
-
this.emit("canvasGO.AddComponent<CanvasScaler>();");
|
|
621
|
-
this.emit("");
|
|
622
|
-
for (const el of ui.elements) {
|
|
623
|
-
const varName = this.sanitizeName(el.name);
|
|
624
|
-
const elType = el.properties.find((p) => p.key === "type")?.value;
|
|
625
|
-
this.emit(
|
|
626
|
-
`// UI Element: ${this.escapeStringValue(el.name, "CSharp")} (${elType})`
|
|
627
|
-
);
|
|
628
|
-
this.emit(
|
|
629
|
-
`var ${varName}GO = new GameObject("${this.escapeStringValue(el.name, "CSharp")}");`
|
|
630
|
-
);
|
|
631
|
-
this.emit(`${varName}GO.transform.SetParent(canvasGO.transform);`);
|
|
632
|
-
if (elType === "text") {
|
|
633
|
-
this.emit(`var ${varName}Text = ${varName}GO.AddComponent<Text>();`);
|
|
634
|
-
const text = el.properties.find((p) => p.key === "text")?.value;
|
|
635
|
-
if (text) this.emit(`${varName}Text.text = "${text}";`);
|
|
636
|
-
} else if (elType === "progress") {
|
|
637
|
-
this.emit(`var ${varName}Slider = ${varName}GO.AddComponent<Slider>();`);
|
|
638
|
-
}
|
|
639
|
-
this.emit("");
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
// ─── Helpers ───────────────────────────────────────────────────────────
|
|
643
|
-
emit(line) {
|
|
644
|
-
this.lines.push(this.options.indent.repeat(this.indentLevel) + line);
|
|
645
|
-
}
|
|
646
|
-
sanitizeName(name) {
|
|
647
|
-
return name.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
648
|
-
}
|
|
649
|
-
toVector3(arr) {
|
|
650
|
-
if (Array.isArray(arr) && arr.length >= 3) {
|
|
651
|
-
return `new Vector3(${arr[0]}f, ${arr[1]}f, ${arr[2]}f)`;
|
|
652
|
-
}
|
|
653
|
-
if (Array.isArray(arr) && arr.length === 2) {
|
|
654
|
-
return `new Vector2(${arr[0]}f, ${arr[1]}f)`;
|
|
655
|
-
}
|
|
656
|
-
return `new Vector3(${arr}f, ${arr}f, ${arr}f)`;
|
|
657
|
-
}
|
|
658
|
-
toColor(value) {
|
|
659
|
-
if (typeof value === "string" && value.startsWith("#")) {
|
|
660
|
-
const hex = value.slice(1);
|
|
661
|
-
const r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
662
|
-
const g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
663
|
-
const b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
664
|
-
return `new Color(${r.toFixed(3)}f, ${g.toFixed(3)}f, ${b.toFixed(3)}f)`;
|
|
665
|
-
}
|
|
666
|
-
return `Color.white`;
|
|
667
|
-
}
|
|
668
|
-
toCSharpType(value) {
|
|
669
|
-
if (typeof value === "number") return Number.isInteger(value) ? "int" : "float";
|
|
670
|
-
if (typeof value === "boolean") return "bool";
|
|
671
|
-
if (typeof value === "string") return "string";
|
|
672
|
-
if (Array.isArray(value)) return "object[]";
|
|
673
|
-
return "object";
|
|
674
|
-
}
|
|
675
|
-
toCSharpValue(value) {
|
|
676
|
-
if (typeof value === "number") return Number.isInteger(value) ? `${value}` : `${value}f`;
|
|
677
|
-
if (typeof value === "boolean") return value ? "true" : "false";
|
|
678
|
-
if (typeof value === "string") return `"${this.escapeStringValue(value, "CSharp")}"`;
|
|
679
|
-
if (value === null) return "null";
|
|
680
|
-
return "null";
|
|
681
|
-
}
|
|
682
|
-
findProp(props, key) {
|
|
683
|
-
return props?.find((p) => p.key === key)?.value;
|
|
684
|
-
}
|
|
685
|
-
findObjProp(obj, key) {
|
|
686
|
-
return obj.properties?.find((p) => p.key === key)?.value;
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
export { UnityCompiler, UnityCompiler_exports, init_UnityCompiler };
|
|
693
|
-
//# sourceMappingURL=chunk-TEWCN33Y.js.map
|
|
694
|
-
//# sourceMappingURL=chunk-TEWCN33Y.js.map
|