@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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,755 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkX4ZF6CNE_cjs = require('./chunk-X4ZF6CNE.cjs');
4
- var chunkLXJ4667L_cjs = require('./chunk-LXJ4667L.cjs');
5
- var chunkBF2235SI_cjs = require('./chunk-BF2235SI.cjs');
6
- var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
7
- var platform = require('@holoscript/platform');
8
-
9
- // src/compiler/PlayCanvasCompiler.ts
10
- var PlayCanvasCompiler_exports = {};
11
- chunk3SAK5KFL_cjs.__export(PlayCanvasCompiler_exports, {
12
- PlayCanvasCompiler: () => exports.PlayCanvasCompiler
13
- });
14
- var SHAPE_TO_PRIMITIVE; exports.PlayCanvasCompiler = void 0;
15
- var init_PlayCanvasCompiler = chunk3SAK5KFL_cjs.__esm({
16
- "src/compiler/PlayCanvasCompiler.ts"() {
17
- chunkX4ZF6CNE_cjs.init_TraitCompositor();
18
- chunkBF2235SI_cjs.init_CompilerBase();
19
- chunkLXJ4667L_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 chunkBF2235SI_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 platform.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 = chunkLXJ4667L_cjs.compileDomainBlocks(
146
- // @ts-expect-error During migration
147
- domainBlocks,
148
- {
149
- material: (block) => {
150
- const mat = chunkLXJ4667L_cjs.compileMaterialBlock(block);
151
- return chunkLXJ4667L_cjs.materialToPlayCanvas(mat, `db${blockIdx++}`);
152
- },
153
- physics: (block) => {
154
- const phys = chunkLXJ4667L_cjs.compilePhysicsBlock(block);
155
- return chunkLXJ4667L_cjs.physicsToPlayCanvas(phys, `db${blockIdx++}`);
156
- },
157
- vfx: (block) => {
158
- const ps = chunkLXJ4667L_cjs.compileParticleBlock(block);
159
- return chunkLXJ4667L_cjs.particlesToPlayCanvas(ps, `db${blockIdx++}`);
160
- },
161
- postfx: (block) => {
162
- const pp = chunkLXJ4667L_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 = chunkLXJ4667L_cjs.compileAudioSourceBlock(block);
168
- return chunkLXJ4667L_cjs.audioSourceToPlayCanvas(audio, `db${blockIdx++}`);
169
- },
170
- weather: (block) => {
171
- const weather = chunkLXJ4667L_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 chunkX4ZF6CNE_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-XWPNTWDN.cjs.map
755
- //# sourceMappingURL=chunk-XWPNTWDN.cjs.map