@holoscript/core 6.0.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,755 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkVSXOIUCF_cjs = require('./chunk-VSXOIUCF.cjs');
4
- var chunkHHS6FMOU_cjs = require('./chunk-HHS6FMOU.cjs');
5
- var chunkQHVVVN47_cjs = require('./chunk-QHVVVN47.cjs');
6
- var chunkEGIZHYJP_cjs = require('./chunk-EGIZHYJP.cjs');
7
-
8
- // src/compiler/PlayCanvasCompiler.ts
9
- var PlayCanvasCompiler_exports = {};
10
- chunkEGIZHYJP_cjs.__export(PlayCanvasCompiler_exports, {
11
- PlayCanvasCompiler: () => exports.PlayCanvasCompiler
12
- });
13
- var SHAPE_TO_PRIMITIVE; exports.PlayCanvasCompiler = void 0;
14
- var init_PlayCanvasCompiler = chunkEGIZHYJP_cjs.__esm({
15
- "src/compiler/PlayCanvasCompiler.ts"() {
16
- chunkVSXOIUCF_cjs.init_TraitCompositor();
17
- chunkQHVVVN47_cjs.init_CompilerBase();
18
- chunkQHVVVN47_cjs.init_ANSNamespace();
19
- chunkHHS6FMOU_cjs.init_DomainBlockCompilerMixin();
20
- SHAPE_TO_PRIMITIVE = {
21
- sphere: "sphere",
22
- orb: "sphere",
23
- cube: "box",
24
- box: "box",
25
- cylinder: "cylinder",
26
- cone: "cone",
27
- pyramid: "cone",
28
- plane: "plane",
29
- ground: "plane",
30
- torus: "torus",
31
- ring: "torus",
32
- capsule: "capsule",
33
- disc: "plane"
34
- };
35
- exports.PlayCanvasCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
36
- constructor(options = {}) {
37
- super();
38
- this.compilerName = "PlayCanvasCompiler";
39
- this.lines = [];
40
- this.indentLevel = 0;
41
- this.options = {
42
- className: options.className || "GeneratedScene",
43
- enablePhysics: options.enablePhysics ?? true,
44
- enableXR: options.enableXR ?? false,
45
- indent: options.indent || " "
46
- };
47
- }
48
- getRequiredCapability() {
49
- return chunkQHVVVN47_cjs.ANSCapabilityPath.PLAYCANVAS;
50
- }
51
- compile(composition, agentToken, outputPath) {
52
- this.validateCompilerAccess(agentToken, outputPath);
53
- this.lines = [];
54
- this.indentLevel = 0;
55
- this.emit("// Auto-generated by HoloScript PlayCanvasCompiler");
56
- this.emit(
57
- `// Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}"`
58
- );
59
- this.emit("");
60
- this.emitImports(composition);
61
- this.emit("");
62
- this.emit(`export class ${this.options.className} {`);
63
- this.indent();
64
- this.emit("private app: pc.Application;");
65
- this.emit("private canvas: HTMLCanvasElement;");
66
- this.emit("");
67
- this.emit("constructor(canvas: HTMLCanvasElement) {");
68
- this.indent();
69
- this.emit("this.canvas = canvas;");
70
- this.emit("this.app = new pc.Application(canvas, {");
71
- this.indent();
72
- this.emit("mouse: new pc.Mouse(canvas),");
73
- this.emit("touch: new pc.TouchDevice(canvas),");
74
- this.emit("keyboard: new pc.Keyboard(window),");
75
- this.dedent();
76
- this.emit("});");
77
- this.emit("this.app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);");
78
- this.emit("this.app.setCanvasResolution(pc.RESOLUTION_AUTO);");
79
- this.dedent();
80
- this.emit("}");
81
- this.emit("");
82
- this.emit("async build(): Promise<void> {");
83
- this.indent();
84
- this.emitSceneSetup(composition);
85
- if (composition.environment) this.emitEnvironment(composition.environment);
86
- if (composition.lights?.length) {
87
- for (const light of composition.lights) this.emitLight(light);
88
- } else {
89
- this.emit("// Default light");
90
- this.emit('const defaultLight = new pc.Entity("defaultLight");');
91
- this.emit('defaultLight.addComponent("light", {');
92
- this.indent();
93
- this.emit('type: "directional",');
94
- this.emit("color: new pc.Color(1, 1, 1),");
95
- this.emit("intensity: 0.7,");
96
- this.emit("castShadows: true,");
97
- this.dedent();
98
- this.emit("});");
99
- this.emit("defaultLight.setEulerAngles(45, 30, 0);");
100
- this.emit("this.app.root.addChild(defaultLight);");
101
- this.emit("");
102
- }
103
- if (composition.camera) this.emitCamera(composition.camera);
104
- else {
105
- this.emit("// Default camera");
106
- this.emit('const camera = new pc.Entity("defaultCamera");');
107
- this.emit('camera.addComponent("camera", {');
108
- this.indent();
109
- this.emit("clearColor: new pc.Color(0.05, 0.05, 0.1),");
110
- this.dedent();
111
- this.emit("});");
112
- this.emit("camera.setPosition(0, 5, 10);");
113
- this.emit("camera.lookAt(0, 0, 0);");
114
- this.emit("this.app.root.addChild(camera);");
115
- this.emit("");
116
- }
117
- if (composition.objects?.length) for (const obj of composition.objects) this.emitObject(obj);
118
- if (composition.spatialGroups?.length)
119
- for (const g of composition.spatialGroups) this.emitGroup(g);
120
- if (composition.timelines?.length)
121
- for (const tl of composition.timelines) this.emitTimeline(tl);
122
- if (composition.audio?.length) for (const a of composition.audio) this.emitAudio(a);
123
- if (composition.zones?.length) for (const z of composition.zones) this.emitZone(z);
124
- if (composition.ui) this.emitUI(composition.ui);
125
- if (composition.effects) this.emitEffects(composition.effects);
126
- if (composition.transitions?.length)
127
- for (const t of composition.transitions) this.emitTransition(t);
128
- if (this.options.enableXR) this.emitXRSetup();
129
- this.compilePlayCanvasDomainBlocks(composition);
130
- this.emitStartApp();
131
- this.dedent();
132
- this.emit("}");
133
- this.emit("");
134
- this.emit("dispose(): void { this.app.destroy(); }");
135
- this.dedent();
136
- this.emit("}");
137
- return this.lines.join("\n");
138
- }
139
- compilePlayCanvasDomainBlocks(composition) {
140
- const domainBlocks = composition.domainBlocks ?? [];
141
- if (domainBlocks.length === 0) return;
142
- this.emit("");
143
- this.emit("// === v4.2 Domain Blocks ===");
144
- let blockIdx = 0;
145
- const compiled = chunkHHS6FMOU_cjs.compileDomainBlocks(
146
- // @ts-expect-error During migration
147
- domainBlocks,
148
- {
149
- material: (block) => {
150
- const mat = chunkHHS6FMOU_cjs.compileMaterialBlock(block);
151
- return chunkHHS6FMOU_cjs.materialToPlayCanvas(mat, `db${blockIdx++}`);
152
- },
153
- physics: (block) => {
154
- const phys = chunkHHS6FMOU_cjs.compilePhysicsBlock(block);
155
- return chunkHHS6FMOU_cjs.physicsToPlayCanvas(phys, `db${blockIdx++}`);
156
- },
157
- vfx: (block) => {
158
- const ps = chunkHHS6FMOU_cjs.compileParticleBlock(block);
159
- return chunkHHS6FMOU_cjs.particlesToPlayCanvas(ps, `db${blockIdx++}`);
160
- },
161
- postfx: (block) => {
162
- const pp = chunkHHS6FMOU_cjs.compilePostProcessingBlock(block);
163
- return `// Post-Processing: ${pp.keyword} \u2014 configure via PlayCanvas PostEffects
164
- ` + pp.effects.map((e) => `// Effect: ${e.type} \u2014 ${JSON.stringify(e.properties)}`).join("\n");
165
- },
166
- audio: (block) => {
167
- const audio = chunkHHS6FMOU_cjs.compileAudioSourceBlock(block);
168
- return chunkHHS6FMOU_cjs.audioSourceToPlayCanvas(audio, `db${blockIdx++}`);
169
- },
170
- weather: (block) => {
171
- const weather = chunkHHS6FMOU_cjs.compileWeatherBlock(block);
172
- return `// Weather: ${weather.keyword} "${weather.name || ""}" \u2014 implement via PlayCanvas particle system
173
- ` + weather.layers.map((l) => `// Layer: ${l.type} \u2014 ${JSON.stringify(l.properties)}`).join("\n");
174
- }
175
- },
176
- (block) => `// Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}"`
177
- );
178
- for (const line of compiled) {
179
- for (const l of line.split("\n")) {
180
- this.emit(l);
181
- }
182
- }
183
- }
184
- // --- Imports ---
185
- emitImports(_composition) {
186
- this.emit('import * as pc from "playcanvas";');
187
- }
188
- // --- Scene Setup ---
189
- emitSceneSetup(_composition) {
190
- if (this.options.enablePhysics) {
191
- this.emit("this.app.systems.rigidbody?.setGravity(0, -9.81, 0);");
192
- }
193
- this.emit("");
194
- }
195
- // --- Environment ---
196
- emitEnvironment(env) {
197
- for (const prop of env.properties) {
198
- if (prop.key === "skybox" || prop.key === "preset") {
199
- this.emit(`this.app.scene.setSkybox(null); // Skybox: "${prop.value}"`);
200
- this.emit(`this.app.scene.skyboxIntensity = 1.0;`);
201
- } else if (prop.key === "fog" && typeof prop.value === "object") {
202
- const fog = prop.value;
203
- this.emit(`this.app.scene.fog = pc.FOG_LINEAR;`);
204
- if (fog.color) this.emit(`this.app.scene.fogColor = ${this.toPlayCanvasColor(fog.color)};`);
205
- if (fog.near !== void 0) this.emit(`this.app.scene.fogStart = ${fog.near};`);
206
- if (fog.far !== void 0) this.emit(`this.app.scene.fogEnd = ${fog.far};`);
207
- } else if (prop.key === "ambient_light") {
208
- this.emit(
209
- `this.app.scene.ambientLight = new pc.Color(${prop.value}, ${prop.value}, ${prop.value});`
210
- );
211
- } else if (prop.key === "ground") {
212
- this.emit('const ground = new pc.Entity("ground");');
213
- this.emit('ground.addComponent("render", { type: "plane" });');
214
- this.emit("ground.setLocalScale(100, 1, 100);");
215
- if (typeof prop.value === "object" && prop.value !== null) {
216
- const g = prop.value;
217
- if (g.color) {
218
- this.emit("const groundMat = new pc.StandardMaterial();");
219
- this.emit(`groundMat.diffuse = ${this.toPlayCanvasColor(g.color)};`);
220
- this.emit("groundMat.update();");
221
- this.emit("ground.render!.meshInstances[0].material = groundMat;");
222
- }
223
- }
224
- this.emit("this.app.root.addChild(ground);");
225
- }
226
- }
227
- this.emit("");
228
- }
229
- // --- Objects ---
230
- emitObject(obj, parentVar) {
231
- const v = this.sanitizeName(obj.name);
232
- let geom = "cube", modelSrc, textContent;
233
- let position, rotation, scale, size;
234
- const mat = {};
235
- for (const p of obj.properties) {
236
- switch (p.key) {
237
- case "geometry":
238
- case "mesh":
239
- case "type":
240
- if (typeof p.value === "string") geom = p.value;
241
- break;
242
- case "position":
243
- if (Array.isArray(p.value)) position = p.value;
244
- break;
245
- case "rotation":
246
- if (Array.isArray(p.value)) rotation = p.value;
247
- break;
248
- case "scale":
249
- scale = p.value;
250
- break;
251
- case "size":
252
- size = p.value;
253
- break;
254
- case "color":
255
- mat.color = p.value;
256
- break;
257
- case "roughness":
258
- mat.roughness = p.value;
259
- break;
260
- case "metalness":
261
- case "metallic":
262
- mat.metalness = p.value;
263
- break;
264
- case "opacity":
265
- mat.opacity = p.value;
266
- break;
267
- case "emissive":
268
- mat.emissive = p.value;
269
- break;
270
- case "emissive_intensity":
271
- case "emissiveIntensity":
272
- mat.emissiveIntensity = p.value;
273
- break;
274
- case "material":
275
- if (typeof p.value === "object" && p.value !== null)
276
- Object.assign(mat, p.value);
277
- break;
278
- case "model":
279
- case "src":
280
- if (typeof p.value === "string") modelSrc = p.value;
281
- break;
282
- case "text":
283
- if (typeof p.value === "string") textContent = p.value;
284
- break;
285
- }
286
- }
287
- this.emit(`// Object: ${this.escapeStringValue(obj.name, "TypeScript")}`);
288
- this.emit(
289
- `const ${v} = new pc.Entity("${this.escapeStringValue(obj.name, "TypeScript")}");`
290
- );
291
- if (modelSrc) {
292
- this.emit(`// Model: ${modelSrc} \u2014 load via asset registry`);
293
- this.emit(`${v}.addComponent("render", { type: "asset" });`);
294
- } else if (geom === "text" || textContent) {
295
- this.emit(`${v}.addComponent("element", {`);
296
- this.indent();
297
- this.emit(`type: "text",`);
298
- this.emit(`text: "${textContent || ""}",`);
299
- this.emit(`fontSize: 48,`);
300
- this.emit(`color: new pc.Color(1, 1, 1),`);
301
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
302
- this.dedent();
303
- this.emit("});");
304
- } else {
305
- const prim = this.mapShapeToPrimitive(geom);
306
- this.emit(`${v}.addComponent("render", { type: "${prim}" });`);
307
- if (Object.keys(mat).length > 0) {
308
- this.emit(`const ${v}Mat = new pc.StandardMaterial();`);
309
- if (mat.color) this.emit(`${v}Mat.diffuse = ${this.toPlayCanvasColor(mat.color)};`);
310
- if (mat.roughness !== void 0)
311
- this.emit(`${v}Mat.shininess = ${(1 - mat.roughness) * 100};`);
312
- if (mat.metalness !== void 0) this.emit(`${v}Mat.metalness = ${mat.metalness};`);
313
- if (mat.opacity !== void 0 && mat.opacity < 1) {
314
- this.emit(`${v}Mat.opacity = ${mat.opacity};`);
315
- this.emit(`${v}Mat.blendType = pc.BLEND_NORMAL;`);
316
- }
317
- if (mat.emissive) this.emit(`${v}Mat.emissive = ${this.toPlayCanvasColor(mat.emissive)};`);
318
- if (mat.emissiveIntensity !== void 0)
319
- this.emit(`${v}Mat.emissiveIntensity = ${mat.emissiveIntensity};`);
320
- this.emit(`${v}Mat.update();`);
321
- this.emit(`${v}.render!.meshInstances[0].material = ${v}Mat;`);
322
- }
323
- }
324
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
325
- if (rotation) this.emit(`${v}.setEulerAngles(${rotation[0]}, ${rotation[1]}, ${rotation[2]});`);
326
- if (scale) {
327
- if (Array.isArray(scale))
328
- this.emit(`${v}.setLocalScale(${scale[0]}, ${scale[1]}, ${scale[2]});`);
329
- else this.emit(`${v}.setLocalScale(${scale}, ${scale}, ${scale});`);
330
- }
331
- if (size) {
332
- const s = typeof size === "number" ? size : 1;
333
- this.emit(`${v}.setLocalScale(${s}, ${s}, ${s});`);
334
- }
335
- for (const trait of obj.traits || []) {
336
- if (trait.name === "grabbable") {
337
- this.emit(`${v}.addComponent("button", { active: true });`);
338
- this.emit(
339
- `${v}.button!.on("click", () => { console.log("Picked: ${this.escapeStringValue(obj.name, "TypeScript")}"); });`
340
- );
341
- } else if (trait.name === "physics" || trait.name === "collidable") {
342
- const mt = (trait.config?.type || "dynamic") === "static" ? "static" : "dynamic";
343
- this.emit(`${v}.addComponent("rigidbody", {`);
344
- this.indent();
345
- this.emit(`type: "${mt}",`);
346
- this.emit(`mass: ${trait.config?.mass ?? 1},`);
347
- if (trait.config?.restitution !== void 0)
348
- this.emit(`restitution: ${trait.config.restitution},`);
349
- if (trait.config?.friction !== void 0) this.emit(`friction: ${trait.config.friction},`);
350
- this.dedent();
351
- this.emit("});");
352
- this.emit(`${v}.addComponent("collision", { type: "${this.mapShapeToPrimitive(geom)}" });`);
353
- } else if (trait.name === "hoverable") {
354
- this.emit(`${v}.addComponent("button", { active: true });`);
355
- this.emit(`${v}.button!.on("mouseenter", () => { /* hover enter */ });`);
356
- this.emit(`${v}.button!.on("mouseleave", () => { /* hover exit */ });`);
357
- } else if (trait.name === "accessible") {
358
- this.emit(
359
- `// @accessible: role="${trait.config?.role || "generic"}" for "${this.escapeStringValue(obj.name, "TypeScript")}"`
360
- );
361
- } else if (trait.name === "shadow") {
362
- this.emit(`${v}.render!.castShadows = true;`);
363
- this.emit(`${v}.render!.receiveShadows = true;`);
364
- } else {
365
- this.emit(
366
- `// @${this.escapeStringValue(trait.name, "TypeScript")}: ${JSON.stringify(trait.config || {})}`
367
- );
368
- }
369
- }
370
- if (obj.traits && Array.isArray(obj.traits) && obj.traits.length > 0) {
371
- const traitNames = obj.traits.map((t) => t.name);
372
- const compositor = new chunkVSXOIUCF_cjs.TraitCompositor();
373
- const composed = compositor.compose(traitNames);
374
- if (Object.keys(composed).length > 0) {
375
- const matVar = `${v}ComposedMat`;
376
- this.emit(`// TraitCompositor: composed ${traitNames.join(" + ")}`);
377
- this.emit(`const ${matVar} = new pc.StandardMaterial();`);
378
- if (composed.color)
379
- this.emit(`${matVar}.diffuse = ${this.toPlayCanvasColor(composed.color)};`);
380
- if (composed.roughness !== void 0)
381
- this.emit(`${matVar}.shininess = ${(1 - composed.roughness) * 100};`);
382
- if (composed.metalness !== void 0)
383
- this.emit(`${matVar}.metalness = ${composed.metalness};`);
384
- if (composed.opacity !== void 0 && composed.opacity < 1) {
385
- this.emit(`${matVar}.opacity = ${composed.opacity};`);
386
- this.emit(`${matVar}.blendType = pc.BLEND_NORMAL;`);
387
- }
388
- if (composed.emissive)
389
- this.emit(`${matVar}.emissive = ${this.toPlayCanvasColor(composed.emissive)};`);
390
- if (composed.emissiveIntensity !== void 0)
391
- this.emit(`${matVar}.emissiveIntensity = ${composed.emissiveIntensity};`);
392
- this.emit(`${matVar}.update();`);
393
- this.emit(`${v}.render!.meshInstances[0].material = ${matVar};`);
394
- }
395
- }
396
- const parent = parentVar || "this.app.root";
397
- this.emit(`${parent}.addChild(${v});`);
398
- if (obj.children?.length) for (const child of obj.children) this.emitObject(child, v);
399
- this.emit("");
400
- }
401
- // --- Groups ---
402
- emitGroup(group, parentVar) {
403
- const v = this.sanitizeName(group.name);
404
- this.emit(
405
- `const ${v} = new pc.Entity("${this.escapeStringValue(group.name, "TypeScript")}");`
406
- );
407
- for (const p of group.properties) {
408
- if (p.key === "position" && Array.isArray(p.value))
409
- this.emit(`${v}.setPosition(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
410
- else if (p.key === "rotation" && Array.isArray(p.value))
411
- this.emit(`${v}.setEulerAngles(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
412
- else if (p.key === "scale") {
413
- if (Array.isArray(p.value))
414
- this.emit(`${v}.setLocalScale(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
415
- else this.emit(`${v}.setLocalScale(${p.value}, ${p.value}, ${p.value});`);
416
- }
417
- }
418
- const parent = parentVar || "this.app.root";
419
- this.emit(`${parent}.addChild(${v});`);
420
- for (const obj of group.objects) this.emitObject(obj, v);
421
- if (group.groups) for (const sub of group.groups) this.emitGroup(sub, v);
422
- this.emit("");
423
- }
424
- // --- Lights ---
425
- emitLight(light) {
426
- const v = this.sanitizeName(light.name);
427
- let pos, color, intensity;
428
- let dir, castShadow = false, angle, dist;
429
- for (const p of light.properties) {
430
- if (p.key === "position" && Array.isArray(p.value)) pos = p.value;
431
- else if (p.key === "color") color = p.value;
432
- else if (p.key === "intensity") intensity = p.value;
433
- else if (p.key === "direction" && Array.isArray(p.value)) dir = p.value;
434
- else if (p.key === "cast_shadow" || p.key === "castShadow") castShadow = !!p.value;
435
- else if (p.key === "angle") angle = p.value;
436
- else if (p.key === "distance") dist = p.value;
437
- }
438
- const pcType = this.mapLightType(light.lightType);
439
- this.emit(
440
- `const ${v} = new pc.Entity("${this.escapeStringValue(light.name, "TypeScript")}");`
441
- );
442
- this.emit(`${v}.addComponent("light", {`);
443
- this.indent();
444
- this.emit(`type: "${pcType}",`);
445
- if (color) this.emit(`color: ${this.toPlayCanvasColor(color)},`);
446
- if (intensity !== void 0) this.emit(`intensity: ${intensity},`);
447
- if (castShadow) this.emit("castShadows: true,");
448
- if (dist !== void 0) this.emit(`range: ${dist},`);
449
- if (angle !== void 0 && pcType === "spot")
450
- this.emit(`outerConeAngle: ${angle * (180 / Math.PI)},`);
451
- this.dedent();
452
- this.emit("});");
453
- if (pos) this.emit(`${v}.setPosition(${pos[0]}, ${pos[1]}, ${pos[2]});`);
454
- if (dir) this.emit(`${v}.setEulerAngles(${this.directionToEuler(dir)});`);
455
- this.emit("this.app.root.addChild(" + v + ");");
456
- this.emit("");
457
- }
458
- // --- Camera ---
459
- emitCamera(cam) {
460
- let fov, pos, lookAt;
461
- let near, far;
462
- for (const p of cam.properties) {
463
- if (p.key === "fov" || p.key === "field_of_view") fov = p.value;
464
- else if (p.key === "position" && Array.isArray(p.value)) pos = p.value;
465
- else if ((p.key === "look_at" || p.key === "lookAt") && Array.isArray(p.value))
466
- lookAt = p.value;
467
- else if (p.key === "near") near = p.value;
468
- else if (p.key === "far") far = p.value;
469
- }
470
- this.emit('const camera = new pc.Entity("camera");');
471
- this.emit('camera.addComponent("camera", {');
472
- this.indent();
473
- this.emit("clearColor: new pc.Color(0.05, 0.05, 0.1),");
474
- if (cam.cameraType === "orthographic") {
475
- this.emit("projection: pc.PROJECTION_ORTHOGRAPHIC,");
476
- }
477
- if (fov !== void 0) this.emit(`fov: ${fov},`);
478
- if (near !== void 0) this.emit(`nearClip: ${near},`);
479
- if (far !== void 0) this.emit(`farClip: ${far},`);
480
- this.dedent();
481
- this.emit("});");
482
- if (pos) this.emit(`camera.setPosition(${pos[0]}, ${pos[1]}, ${pos[2]});`);
483
- else this.emit("camera.setPosition(0, 5, 10);");
484
- if (lookAt) this.emit(`camera.lookAt(${lookAt[0]}, ${lookAt[1]}, ${lookAt[2]});`);
485
- else this.emit("camera.lookAt(0, 0, 0);");
486
- this.emit("this.app.root.addChild(camera);");
487
- this.emit("");
488
- }
489
- // --- Timeline ---
490
- emitTimeline(timeline) {
491
- this.sanitizeName(timeline.name);
492
- this.emit(`// Timeline: "${this.escapeStringValue(timeline.name, "TypeScript")}"`);
493
- for (const entry of timeline.entries) {
494
- const a = entry.action;
495
- if (a.kind === "animate") {
496
- this.emit(`// @${entry.time}s: animate ${a.target} ${JSON.stringify(a.properties)}`);
497
- } else if (a.kind === "emit") {
498
- this.emit(
499
- `// @${entry.time}s: emit "${this.escapeStringValue(a.event, "TypeScript")}"`
500
- );
501
- } else if (a.kind === "call") {
502
- this.emit(
503
- `// @${entry.time}s: call ${this.escapeStringValue(a.method, "TypeScript")}()`
504
- );
505
- }
506
- }
507
- if (timeline.autoplay) this.emit(`// autoplay: ${timeline.loop ? "loop" : "once"}`);
508
- this.emit("");
509
- }
510
- // --- Audio ---
511
- emitAudio(audio) {
512
- const v = this.sanitizeName(audio.name);
513
- let src = "", volume = 1, loop = false, spatial = false;
514
- let position, dist;
515
- for (const p of audio.properties) {
516
- if (p.key === "src" || p.key === "source") src = String(p.value);
517
- else if (p.key === "volume") volume = p.value;
518
- else if (p.key === "loop") loop = !!p.value;
519
- else if (p.key === "spatial") spatial = !!p.value;
520
- else if (p.key === "position" && Array.isArray(p.value)) position = p.value;
521
- else if (p.key === "distance") dist = p.value;
522
- }
523
- this.emit(
524
- `const ${v} = new pc.Entity("${this.escapeStringValue(audio.name, "TypeScript")}");`
525
- );
526
- this.emit(`${v}.addComponent("sound");`);
527
- this.emit(`${v}.sound!.addSlot("default", {`);
528
- this.indent();
529
- this.emit(`asset: null, // Load "${src}" via asset registry`);
530
- this.emit(`loop: ${loop},`);
531
- this.emit(`volume: ${volume},`);
532
- this.emit(`autoPlay: true,`);
533
- if (dist !== void 0) this.emit(`maxDistance: ${dist},`);
534
- if (spatial) this.emit("positional: true,");
535
- this.dedent();
536
- this.emit("});");
537
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
538
- this.emit(`this.app.root.addChild(${v});`);
539
- this.emit("");
540
- }
541
- // --- Zone ---
542
- emitZone(zone) {
543
- const v = this.sanitizeName(zone.name);
544
- let shape = "box", position, size, radius;
545
- for (const p of zone.properties) {
546
- if (p.key === "shape") shape = String(p.value);
547
- else if (p.key === "position" && Array.isArray(p.value)) position = p.value;
548
- else if (p.key === "size") size = p.value;
549
- else if (p.key === "radius") radius = p.value;
550
- }
551
- this.emit(
552
- `const ${v} = new pc.Entity("${this.escapeStringValue(zone.name, "TypeScript")}");`
553
- );
554
- if (shape === "sphere") {
555
- this.emit(`${v}.addComponent("collision", { type: "sphere", radius: ${radius || 5} });`);
556
- } else {
557
- const s = Array.isArray(size) ? size : [size || 5, size || 5, size || 5];
558
- this.emit(
559
- `${v}.addComponent("collision", { type: "box", halfExtents: new pc.Vec3(${s[0] / 2}, ${s[1] / 2}, ${s[2] / 2}) });`
560
- );
561
- }
562
- this.emit(`${v}.addComponent("rigidbody", { type: "static" });`);
563
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
564
- if (zone.handlers?.length) {
565
- for (const h of zone.handlers) {
566
- const event = h.event === "on_enter" ? "triggerenter" : h.event === "on_exit" ? "triggerleave" : h.event;
567
- this.emit(
568
- `${v}.collision!.on("${event}", (result: unknown) => { /* ${this.escapeStringValue(h.event, "TypeScript")} */ });`
569
- );
570
- }
571
- }
572
- this.emit(`this.app.root.addChild(${v});`);
573
- this.emit("");
574
- }
575
- // --- UI ---
576
- emitUI(ui) {
577
- this.emit('const screenEntity = new pc.Entity("screen");');
578
- this.emit(
579
- 'screenEntity.addComponent("screen", { screenSpace: true, referenceResolution: new pc.Vec2(1280, 720) });'
580
- );
581
- this.emit("this.app.root.addChild(screenEntity);");
582
- for (const el of ui.elements) {
583
- const v = this.sanitizeName(el.name);
584
- let elType = "text", text = "", fontSize = 24, color = "#ffffff";
585
- for (const p of el.properties) {
586
- if (p.key === "type") elType = String(p.value);
587
- else if (p.key === "text") text = String(p.value);
588
- else if (p.key === "font_size" || p.key === "fontSize") fontSize = p.value;
589
- else if (p.key === "color") color = String(p.value);
590
- else if (p.key === "background") String(p.value);
591
- }
592
- this.emit(
593
- `const ${v} = new pc.Entity("${this.escapeStringValue(el.name, "TypeScript")}");`
594
- );
595
- if (elType === "button") {
596
- this.emit(`${v}.addComponent("element", {`);
597
- this.indent();
598
- this.emit(`type: "text",`);
599
- this.emit(`text: "${text}",`);
600
- this.emit(`fontSize: ${fontSize},`);
601
- this.emit(`color: ${this.toPlayCanvasColor(color)},`);
602
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
603
- this.emit(`pivot: new pc.Vec2(0.5, 0.5),`);
604
- this.emit(`width: 150,`);
605
- this.emit(`height: 40,`);
606
- this.dedent();
607
- this.emit("});");
608
- this.emit(`${v}.addComponent("button", { active: true });`);
609
- } else if (elType === "progress") {
610
- this.emit(`${v}.addComponent("element", {`);
611
- this.indent();
612
- this.emit('type: "image",');
613
- this.emit("anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),");
614
- this.emit("width: 200,");
615
- this.emit("height: 20,");
616
- this.dedent();
617
- this.emit("});");
618
- } else {
619
- this.emit(`${v}.addComponent("element", {`);
620
- this.indent();
621
- this.emit(`type: "text",`);
622
- this.emit(`text: "${text}",`);
623
- this.emit(`fontSize: ${fontSize},`);
624
- this.emit(`color: ${this.toPlayCanvasColor(color)},`);
625
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
626
- this.dedent();
627
- this.emit("});");
628
- }
629
- this.emit(`screenEntity.addChild(${v});`);
630
- }
631
- this.emit("");
632
- }
633
- // --- Effects ---
634
- emitEffects(effects) {
635
- for (const fx of effects.effects) {
636
- const p = fx.properties;
637
- switch (fx.effectType) {
638
- case "bloom":
639
- this.emit("// Post-processing: Bloom");
640
- this.emit("this.app.scene.rendering.toneMapping = pc.TONEMAP_ACES;");
641
- if (p.intensity !== void 0) this.emit(`// bloom intensity: ${p.intensity}`);
642
- break;
643
- case "ssao":
644
- this.emit("// Post-processing: SSAO");
645
- if (p.radius !== void 0) this.emit(`// ssao radius: ${p.radius}`);
646
- break;
647
- case "vignette":
648
- this.emit("// Post-processing: Vignette");
649
- if (p.weight !== void 0) this.emit(`// vignette weight: ${p.weight}`);
650
- break;
651
- case "tone_mapping":
652
- this.emit("this.app.scene.rendering.toneMapping = pc.TONEMAP_ACES;");
653
- break;
654
- default:
655
- this.emit(`// Effect "${fx.effectType}": ${JSON.stringify(p)}`);
656
- }
657
- }
658
- this.emit("");
659
- }
660
- // --- Transition ---
661
- emitTransition(tr) {
662
- let target, effect, duration;
663
- for (const p of tr.properties) {
664
- if (p.key === "target") target = String(p.value);
665
- else if (p.key === "effect") effect = String(p.value);
666
- else if (p.key === "duration") duration = p.value;
667
- }
668
- this.emit(
669
- `// Transition "${this.escapeStringValue(tr.name, "TypeScript")}": navigate to "${target || "?"}" with ${effect || "fade"} over ${duration || 1}s`
670
- );
671
- }
672
- // --- XR ---
673
- emitXRSetup() {
674
- this.emit("if (this.app.xr.supported) {");
675
- this.indent();
676
- this.emit(
677
- 'this.app.xr.start(this.app.root.findByName("camera")?.camera!, pc.XRTYPE_VR, pc.XRSPACE_LOCAL);'
678
- );
679
- this.dedent();
680
- this.emit("}");
681
- this.emit("");
682
- }
683
- // --- Start App ---
684
- emitStartApp() {
685
- this.emit("this.app.start();");
686
- this.emit('window.addEventListener("resize", () => { this.app.resizeCanvas(); });');
687
- }
688
- // --- Value Conversion Helpers ---
689
- toPlayCanvasColor(value) {
690
- if (typeof value === "string" && value.startsWith("#")) {
691
- const h = value.slice(1);
692
- const r = parseInt(h.substring(0, 2), 16) / 255;
693
- const g = parseInt(h.substring(2, 4), 16) / 255;
694
- const b = parseInt(h.substring(4, 6), 16) / 255;
695
- return `new pc.Color(${r.toFixed(3)}, ${g.toFixed(3)}, ${b.toFixed(3)})`;
696
- }
697
- if (typeof value === "object" && value !== null && "r" in value) {
698
- const c = value;
699
- const rVal = Number(c.r);
700
- const gVal = Number(c.g);
701
- const bVal = Number(c.b);
702
- const r = rVal > 1 ? rVal / 255 : rVal;
703
- const g = gVal > 1 ? gVal / 255 : gVal;
704
- const b = bVal > 1 ? bVal / 255 : bVal;
705
- return `new pc.Color(${r.toFixed(3)}, ${g.toFixed(3)}, ${b.toFixed(3)})`;
706
- }
707
- return "new pc.Color(1, 1, 1)";
708
- }
709
- mapShapeToPrimitive(type) {
710
- return SHAPE_TO_PRIMITIVE[type] || "box";
711
- }
712
- mapLightType(type) {
713
- switch (type) {
714
- case "hemisphere":
715
- case "ambient":
716
- return "directional";
717
- case "directional":
718
- return "directional";
719
- case "point":
720
- return "point";
721
- case "spot":
722
- return "spot";
723
- case "area":
724
- return "point";
725
- default:
726
- return "directional";
727
- }
728
- }
729
- directionToEuler(dir) {
730
- const x = Number(dir[0]) || 0, y = Number(dir[1]) || 0, z = Number(dir[2]) || 0;
731
- const pitch = Math.atan2(-y, Math.sqrt(x * x + z * z)) * (180 / Math.PI);
732
- const yaw = Math.atan2(x, z) * (180 / Math.PI);
733
- return `${pitch.toFixed(1)}, ${yaw.toFixed(1)}, 0`;
734
- }
735
- // --- Emit Helpers ---
736
- emit(line) {
737
- this.lines.push(this.options.indent.repeat(this.indentLevel) + line);
738
- }
739
- indent() {
740
- this.indentLevel++;
741
- }
742
- dedent() {
743
- this.indentLevel = Math.max(0, this.indentLevel - 1);
744
- }
745
- sanitizeName(name) {
746
- return name.replace(/[^a-zA-Z0-9_]/g, "_");
747
- }
748
- };
749
- }
750
- });
751
-
752
- exports.PlayCanvasCompiler_exports = PlayCanvasCompiler_exports;
753
- exports.init_PlayCanvasCompiler = init_PlayCanvasCompiler;
754
- //# sourceMappingURL=chunk-PQLGZKMC.cjs.map
755
- //# sourceMappingURL=chunk-PQLGZKMC.cjs.map