@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,752 +0,0 @@
1
- import { init_TraitCompositor, TraitCompositor } from './chunk-DXJQDCFL.js';
2
- import { init_DomainBlockCompilerMixin, compileDomainBlocks, compileWeatherBlock, compileAudioSourceBlock, audioSourceToPlayCanvas, compilePostProcessingBlock, compileParticleBlock, particlesToPlayCanvas, compilePhysicsBlock, physicsToPlayCanvas, compileMaterialBlock, materialToPlayCanvas } from './chunk-YQK5JNFK.js';
3
- import { init_CompilerBase, CompilerBase } from './chunk-6XSERL6L.js';
4
- import { __export, __esm } from './chunk-2CWOLHTE.js';
5
- import { ANSCapabilityPath } from '@holoscript/platform';
6
-
7
- // src/compiler/PlayCanvasCompiler.ts
8
- var PlayCanvasCompiler_exports = {};
9
- __export(PlayCanvasCompiler_exports, {
10
- PlayCanvasCompiler: () => PlayCanvasCompiler
11
- });
12
- var SHAPE_TO_PRIMITIVE, PlayCanvasCompiler;
13
- var init_PlayCanvasCompiler = __esm({
14
- "src/compiler/PlayCanvasCompiler.ts"() {
15
- init_TraitCompositor();
16
- init_CompilerBase();
17
- init_DomainBlockCompilerMixin();
18
- SHAPE_TO_PRIMITIVE = {
19
- sphere: "sphere",
20
- orb: "sphere",
21
- cube: "box",
22
- box: "box",
23
- cylinder: "cylinder",
24
- cone: "cone",
25
- pyramid: "cone",
26
- plane: "plane",
27
- ground: "plane",
28
- torus: "torus",
29
- ring: "torus",
30
- capsule: "capsule",
31
- disc: "plane"
32
- };
33
- PlayCanvasCompiler = class extends CompilerBase {
34
- constructor(options = {}) {
35
- super();
36
- this.compilerName = "PlayCanvasCompiler";
37
- this.lines = [];
38
- this.indentLevel = 0;
39
- this.options = {
40
- className: options.className || "GeneratedScene",
41
- enablePhysics: options.enablePhysics ?? true,
42
- enableXR: options.enableXR ?? false,
43
- indent: options.indent || " "
44
- };
45
- }
46
- getRequiredCapability() {
47
- return ANSCapabilityPath.PLAYCANVAS;
48
- }
49
- compile(composition, agentToken, outputPath) {
50
- this.validateCompilerAccess(agentToken, outputPath);
51
- this.lines = [];
52
- this.indentLevel = 0;
53
- this.emit("// Auto-generated by HoloScript PlayCanvasCompiler");
54
- this.emit(
55
- `// Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}"`
56
- );
57
- this.emit("");
58
- this.emitImports(composition);
59
- this.emit("");
60
- this.emit(`export class ${this.options.className} {`);
61
- this.indent();
62
- this.emit("private app: pc.Application;");
63
- this.emit("private canvas: HTMLCanvasElement;");
64
- this.emit("");
65
- this.emit("constructor(canvas: HTMLCanvasElement) {");
66
- this.indent();
67
- this.emit("this.canvas = canvas;");
68
- this.emit("this.app = new pc.Application(canvas, {");
69
- this.indent();
70
- this.emit("mouse: new pc.Mouse(canvas),");
71
- this.emit("touch: new pc.TouchDevice(canvas),");
72
- this.emit("keyboard: new pc.Keyboard(window),");
73
- this.dedent();
74
- this.emit("});");
75
- this.emit("this.app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);");
76
- this.emit("this.app.setCanvasResolution(pc.RESOLUTION_AUTO);");
77
- this.dedent();
78
- this.emit("}");
79
- this.emit("");
80
- this.emit("async build(): Promise<void> {");
81
- this.indent();
82
- this.emitSceneSetup(composition);
83
- if (composition.environment) this.emitEnvironment(composition.environment);
84
- if (composition.lights?.length) {
85
- for (const light of composition.lights) this.emitLight(light);
86
- } else {
87
- this.emit("// Default light");
88
- this.emit('const defaultLight = new pc.Entity("defaultLight");');
89
- this.emit('defaultLight.addComponent("light", {');
90
- this.indent();
91
- this.emit('type: "directional",');
92
- this.emit("color: new pc.Color(1, 1, 1),");
93
- this.emit("intensity: 0.7,");
94
- this.emit("castShadows: true,");
95
- this.dedent();
96
- this.emit("});");
97
- this.emit("defaultLight.setEulerAngles(45, 30, 0);");
98
- this.emit("this.app.root.addChild(defaultLight);");
99
- this.emit("");
100
- }
101
- if (composition.camera) this.emitCamera(composition.camera);
102
- else {
103
- this.emit("// Default camera");
104
- this.emit('const camera = new pc.Entity("defaultCamera");');
105
- this.emit('camera.addComponent("camera", {');
106
- this.indent();
107
- this.emit("clearColor: new pc.Color(0.05, 0.05, 0.1),");
108
- this.dedent();
109
- this.emit("});");
110
- this.emit("camera.setPosition(0, 5, 10);");
111
- this.emit("camera.lookAt(0, 0, 0);");
112
- this.emit("this.app.root.addChild(camera);");
113
- this.emit("");
114
- }
115
- if (composition.objects?.length) for (const obj of composition.objects) this.emitObject(obj);
116
- if (composition.spatialGroups?.length)
117
- for (const g of composition.spatialGroups) this.emitGroup(g);
118
- if (composition.timelines?.length)
119
- for (const tl of composition.timelines) this.emitTimeline(tl);
120
- if (composition.audio?.length) for (const a of composition.audio) this.emitAudio(a);
121
- if (composition.zones?.length) for (const z of composition.zones) this.emitZone(z);
122
- if (composition.ui) this.emitUI(composition.ui);
123
- if (composition.effects) this.emitEffects(composition.effects);
124
- if (composition.transitions?.length)
125
- for (const t of composition.transitions) this.emitTransition(t);
126
- if (this.options.enableXR) this.emitXRSetup();
127
- this.compilePlayCanvasDomainBlocks(composition);
128
- this.emitStartApp();
129
- this.dedent();
130
- this.emit("}");
131
- this.emit("");
132
- this.emit("dispose(): void { this.app.destroy(); }");
133
- this.dedent();
134
- this.emit("}");
135
- return this.lines.join("\n");
136
- }
137
- compilePlayCanvasDomainBlocks(composition) {
138
- const domainBlocks = composition.domainBlocks ?? [];
139
- if (domainBlocks.length === 0) return;
140
- this.emit("");
141
- this.emit("// === v4.2 Domain Blocks ===");
142
- let blockIdx = 0;
143
- const compiled = compileDomainBlocks(
144
- // @ts-expect-error During migration
145
- domainBlocks,
146
- {
147
- material: (block) => {
148
- const mat = compileMaterialBlock(block);
149
- return materialToPlayCanvas(mat, `db${blockIdx++}`);
150
- },
151
- physics: (block) => {
152
- const phys = compilePhysicsBlock(block);
153
- return physicsToPlayCanvas(phys, `db${blockIdx++}`);
154
- },
155
- vfx: (block) => {
156
- const ps = compileParticleBlock(block);
157
- return particlesToPlayCanvas(ps, `db${blockIdx++}`);
158
- },
159
- postfx: (block) => {
160
- const pp = compilePostProcessingBlock(block);
161
- return `// Post-Processing: ${pp.keyword} \u2014 configure via PlayCanvas PostEffects
162
- ` + pp.effects.map((e) => `// Effect: ${e.type} \u2014 ${JSON.stringify(e.properties)}`).join("\n");
163
- },
164
- audio: (block) => {
165
- const audio = compileAudioSourceBlock(block);
166
- return audioSourceToPlayCanvas(audio, `db${blockIdx++}`);
167
- },
168
- weather: (block) => {
169
- const weather = compileWeatherBlock(block);
170
- return `// Weather: ${weather.keyword} "${weather.name || ""}" \u2014 implement via PlayCanvas particle system
171
- ` + weather.layers.map((l) => `// Layer: ${l.type} \u2014 ${JSON.stringify(l.properties)}`).join("\n");
172
- }
173
- },
174
- (block) => `// Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}"`
175
- );
176
- for (const line of compiled) {
177
- for (const l of line.split("\n")) {
178
- this.emit(l);
179
- }
180
- }
181
- }
182
- // --- Imports ---
183
- emitImports(_composition) {
184
- this.emit('import * as pc from "playcanvas";');
185
- }
186
- // --- Scene Setup ---
187
- emitSceneSetup(_composition) {
188
- if (this.options.enablePhysics) {
189
- this.emit("this.app.systems.rigidbody?.setGravity(0, -9.81, 0);");
190
- }
191
- this.emit("");
192
- }
193
- // --- Environment ---
194
- emitEnvironment(env) {
195
- for (const prop of env.properties) {
196
- if (prop.key === "skybox" || prop.key === "preset") {
197
- this.emit(`this.app.scene.setSkybox(null); // Skybox: "${prop.value}"`);
198
- this.emit(`this.app.scene.skyboxIntensity = 1.0;`);
199
- } else if (prop.key === "fog" && typeof prop.value === "object") {
200
- const fog = prop.value;
201
- this.emit(`this.app.scene.fog = pc.FOG_LINEAR;`);
202
- if (fog.color) this.emit(`this.app.scene.fogColor = ${this.toPlayCanvasColor(fog.color)};`);
203
- if (fog.near !== void 0) this.emit(`this.app.scene.fogStart = ${fog.near};`);
204
- if (fog.far !== void 0) this.emit(`this.app.scene.fogEnd = ${fog.far};`);
205
- } else if (prop.key === "ambient_light") {
206
- this.emit(
207
- `this.app.scene.ambientLight = new pc.Color(${prop.value}, ${prop.value}, ${prop.value});`
208
- );
209
- } else if (prop.key === "ground") {
210
- this.emit('const ground = new pc.Entity("ground");');
211
- this.emit('ground.addComponent("render", { type: "plane" });');
212
- this.emit("ground.setLocalScale(100, 1, 100);");
213
- if (typeof prop.value === "object" && prop.value !== null) {
214
- const g = prop.value;
215
- if (g.color) {
216
- this.emit("const groundMat = new pc.StandardMaterial();");
217
- this.emit(`groundMat.diffuse = ${this.toPlayCanvasColor(g.color)};`);
218
- this.emit("groundMat.update();");
219
- this.emit("ground.render!.meshInstances[0].material = groundMat;");
220
- }
221
- }
222
- this.emit("this.app.root.addChild(ground);");
223
- }
224
- }
225
- this.emit("");
226
- }
227
- // --- Objects ---
228
- emitObject(obj, parentVar) {
229
- const v = this.sanitizeName(obj.name);
230
- let geom = "cube", modelSrc, textContent;
231
- let position, rotation, scale, size;
232
- const mat = {};
233
- for (const p of obj.properties) {
234
- switch (p.key) {
235
- case "geometry":
236
- case "mesh":
237
- case "type":
238
- if (typeof p.value === "string") geom = p.value;
239
- break;
240
- case "position":
241
- if (Array.isArray(p.value)) position = p.value;
242
- break;
243
- case "rotation":
244
- if (Array.isArray(p.value)) rotation = p.value;
245
- break;
246
- case "scale":
247
- scale = p.value;
248
- break;
249
- case "size":
250
- size = p.value;
251
- break;
252
- case "color":
253
- mat.color = p.value;
254
- break;
255
- case "roughness":
256
- mat.roughness = p.value;
257
- break;
258
- case "metalness":
259
- case "metallic":
260
- mat.metalness = p.value;
261
- break;
262
- case "opacity":
263
- mat.opacity = p.value;
264
- break;
265
- case "emissive":
266
- mat.emissive = p.value;
267
- break;
268
- case "emissive_intensity":
269
- case "emissiveIntensity":
270
- mat.emissiveIntensity = p.value;
271
- break;
272
- case "material":
273
- if (typeof p.value === "object" && p.value !== null)
274
- Object.assign(mat, p.value);
275
- break;
276
- case "model":
277
- case "src":
278
- if (typeof p.value === "string") modelSrc = p.value;
279
- break;
280
- case "text":
281
- if (typeof p.value === "string") textContent = p.value;
282
- break;
283
- }
284
- }
285
- this.emit(`// Object: ${this.escapeStringValue(obj.name, "TypeScript")}`);
286
- this.emit(
287
- `const ${v} = new pc.Entity("${this.escapeStringValue(obj.name, "TypeScript")}");`
288
- );
289
- if (modelSrc) {
290
- this.emit(`// Model: ${modelSrc} \u2014 load via asset registry`);
291
- this.emit(`${v}.addComponent("render", { type: "asset" });`);
292
- } else if (geom === "text" || textContent) {
293
- this.emit(`${v}.addComponent("element", {`);
294
- this.indent();
295
- this.emit(`type: "text",`);
296
- this.emit(`text: "${textContent || ""}",`);
297
- this.emit(`fontSize: 48,`);
298
- this.emit(`color: new pc.Color(1, 1, 1),`);
299
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
300
- this.dedent();
301
- this.emit("});");
302
- } else {
303
- const prim = this.mapShapeToPrimitive(geom);
304
- this.emit(`${v}.addComponent("render", { type: "${prim}" });`);
305
- if (Object.keys(mat).length > 0) {
306
- this.emit(`const ${v}Mat = new pc.StandardMaterial();`);
307
- if (mat.color) this.emit(`${v}Mat.diffuse = ${this.toPlayCanvasColor(mat.color)};`);
308
- if (mat.roughness !== void 0)
309
- this.emit(`${v}Mat.shininess = ${(1 - mat.roughness) * 100};`);
310
- if (mat.metalness !== void 0) this.emit(`${v}Mat.metalness = ${mat.metalness};`);
311
- if (mat.opacity !== void 0 && mat.opacity < 1) {
312
- this.emit(`${v}Mat.opacity = ${mat.opacity};`);
313
- this.emit(`${v}Mat.blendType = pc.BLEND_NORMAL;`);
314
- }
315
- if (mat.emissive) this.emit(`${v}Mat.emissive = ${this.toPlayCanvasColor(mat.emissive)};`);
316
- if (mat.emissiveIntensity !== void 0)
317
- this.emit(`${v}Mat.emissiveIntensity = ${mat.emissiveIntensity};`);
318
- this.emit(`${v}Mat.update();`);
319
- this.emit(`${v}.render!.meshInstances[0].material = ${v}Mat;`);
320
- }
321
- }
322
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
323
- if (rotation) this.emit(`${v}.setEulerAngles(${rotation[0]}, ${rotation[1]}, ${rotation[2]});`);
324
- if (scale) {
325
- if (Array.isArray(scale))
326
- this.emit(`${v}.setLocalScale(${scale[0]}, ${scale[1]}, ${scale[2]});`);
327
- else this.emit(`${v}.setLocalScale(${scale}, ${scale}, ${scale});`);
328
- }
329
- if (size) {
330
- const s = typeof size === "number" ? size : 1;
331
- this.emit(`${v}.setLocalScale(${s}, ${s}, ${s});`);
332
- }
333
- for (const trait of obj.traits || []) {
334
- if (trait.name === "grabbable") {
335
- this.emit(`${v}.addComponent("button", { active: true });`);
336
- this.emit(
337
- `${v}.button!.on("click", () => { console.log("Picked: ${this.escapeStringValue(obj.name, "TypeScript")}"); });`
338
- );
339
- } else if (trait.name === "physics" || trait.name === "collidable") {
340
- const mt = (trait.config?.type || "dynamic") === "static" ? "static" : "dynamic";
341
- this.emit(`${v}.addComponent("rigidbody", {`);
342
- this.indent();
343
- this.emit(`type: "${mt}",`);
344
- this.emit(`mass: ${trait.config?.mass ?? 1},`);
345
- if (trait.config?.restitution !== void 0)
346
- this.emit(`restitution: ${trait.config.restitution},`);
347
- if (trait.config?.friction !== void 0) this.emit(`friction: ${trait.config.friction},`);
348
- this.dedent();
349
- this.emit("});");
350
- this.emit(`${v}.addComponent("collision", { type: "${this.mapShapeToPrimitive(geom)}" });`);
351
- } else if (trait.name === "hoverable") {
352
- this.emit(`${v}.addComponent("button", { active: true });`);
353
- this.emit(`${v}.button!.on("mouseenter", () => { /* hover enter */ });`);
354
- this.emit(`${v}.button!.on("mouseleave", () => { /* hover exit */ });`);
355
- } else if (trait.name === "accessible") {
356
- this.emit(
357
- `// @accessible: role="${trait.config?.role || "generic"}" for "${this.escapeStringValue(obj.name, "TypeScript")}"`
358
- );
359
- } else if (trait.name === "shadow") {
360
- this.emit(`${v}.render!.castShadows = true;`);
361
- this.emit(`${v}.render!.receiveShadows = true;`);
362
- } else {
363
- this.emit(
364
- `// @${this.escapeStringValue(trait.name, "TypeScript")}: ${JSON.stringify(trait.config || {})}`
365
- );
366
- }
367
- }
368
- if (obj.traits && Array.isArray(obj.traits) && obj.traits.length > 0) {
369
- const traitNames = obj.traits.map((t) => t.name);
370
- const compositor = new TraitCompositor();
371
- const composed = compositor.compose(traitNames);
372
- if (Object.keys(composed).length > 0) {
373
- const matVar = `${v}ComposedMat`;
374
- this.emit(`// TraitCompositor: composed ${traitNames.join(" + ")}`);
375
- this.emit(`const ${matVar} = new pc.StandardMaterial();`);
376
- if (composed.color)
377
- this.emit(`${matVar}.diffuse = ${this.toPlayCanvasColor(composed.color)};`);
378
- if (composed.roughness !== void 0)
379
- this.emit(`${matVar}.shininess = ${(1 - composed.roughness) * 100};`);
380
- if (composed.metalness !== void 0)
381
- this.emit(`${matVar}.metalness = ${composed.metalness};`);
382
- if (composed.opacity !== void 0 && composed.opacity < 1) {
383
- this.emit(`${matVar}.opacity = ${composed.opacity};`);
384
- this.emit(`${matVar}.blendType = pc.BLEND_NORMAL;`);
385
- }
386
- if (composed.emissive)
387
- this.emit(`${matVar}.emissive = ${this.toPlayCanvasColor(composed.emissive)};`);
388
- if (composed.emissiveIntensity !== void 0)
389
- this.emit(`${matVar}.emissiveIntensity = ${composed.emissiveIntensity};`);
390
- this.emit(`${matVar}.update();`);
391
- this.emit(`${v}.render!.meshInstances[0].material = ${matVar};`);
392
- }
393
- }
394
- const parent = parentVar || "this.app.root";
395
- this.emit(`${parent}.addChild(${v});`);
396
- if (obj.children?.length) for (const child of obj.children) this.emitObject(child, v);
397
- this.emit("");
398
- }
399
- // --- Groups ---
400
- emitGroup(group, parentVar) {
401
- const v = this.sanitizeName(group.name);
402
- this.emit(
403
- `const ${v} = new pc.Entity("${this.escapeStringValue(group.name, "TypeScript")}");`
404
- );
405
- for (const p of group.properties) {
406
- if (p.key === "position" && Array.isArray(p.value))
407
- this.emit(`${v}.setPosition(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
408
- else if (p.key === "rotation" && Array.isArray(p.value))
409
- this.emit(`${v}.setEulerAngles(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
410
- else if (p.key === "scale") {
411
- if (Array.isArray(p.value))
412
- this.emit(`${v}.setLocalScale(${p.value[0]}, ${p.value[1]}, ${p.value[2]});`);
413
- else this.emit(`${v}.setLocalScale(${p.value}, ${p.value}, ${p.value});`);
414
- }
415
- }
416
- const parent = parentVar || "this.app.root";
417
- this.emit(`${parent}.addChild(${v});`);
418
- for (const obj of group.objects) this.emitObject(obj, v);
419
- if (group.groups) for (const sub of group.groups) this.emitGroup(sub, v);
420
- this.emit("");
421
- }
422
- // --- Lights ---
423
- emitLight(light) {
424
- const v = this.sanitizeName(light.name);
425
- let pos, color, intensity;
426
- let dir, castShadow = false, angle, dist;
427
- for (const p of light.properties) {
428
- if (p.key === "position" && Array.isArray(p.value)) pos = p.value;
429
- else if (p.key === "color") color = p.value;
430
- else if (p.key === "intensity") intensity = p.value;
431
- else if (p.key === "direction" && Array.isArray(p.value)) dir = p.value;
432
- else if (p.key === "cast_shadow" || p.key === "castShadow") castShadow = !!p.value;
433
- else if (p.key === "angle") angle = p.value;
434
- else if (p.key === "distance") dist = p.value;
435
- }
436
- const pcType = this.mapLightType(light.lightType);
437
- this.emit(
438
- `const ${v} = new pc.Entity("${this.escapeStringValue(light.name, "TypeScript")}");`
439
- );
440
- this.emit(`${v}.addComponent("light", {`);
441
- this.indent();
442
- this.emit(`type: "${pcType}",`);
443
- if (color) this.emit(`color: ${this.toPlayCanvasColor(color)},`);
444
- if (intensity !== void 0) this.emit(`intensity: ${intensity},`);
445
- if (castShadow) this.emit("castShadows: true,");
446
- if (dist !== void 0) this.emit(`range: ${dist},`);
447
- if (angle !== void 0 && pcType === "spot")
448
- this.emit(`outerConeAngle: ${angle * (180 / Math.PI)},`);
449
- this.dedent();
450
- this.emit("});");
451
- if (pos) this.emit(`${v}.setPosition(${pos[0]}, ${pos[1]}, ${pos[2]});`);
452
- if (dir) this.emit(`${v}.setEulerAngles(${this.directionToEuler(dir)});`);
453
- this.emit("this.app.root.addChild(" + v + ");");
454
- this.emit("");
455
- }
456
- // --- Camera ---
457
- emitCamera(cam) {
458
- let fov, pos, lookAt;
459
- let near, far;
460
- for (const p of cam.properties) {
461
- if (p.key === "fov" || p.key === "field_of_view") fov = p.value;
462
- else if (p.key === "position" && Array.isArray(p.value)) pos = p.value;
463
- else if ((p.key === "look_at" || p.key === "lookAt") && Array.isArray(p.value))
464
- lookAt = p.value;
465
- else if (p.key === "near") near = p.value;
466
- else if (p.key === "far") far = p.value;
467
- }
468
- this.emit('const camera = new pc.Entity("camera");');
469
- this.emit('camera.addComponent("camera", {');
470
- this.indent();
471
- this.emit("clearColor: new pc.Color(0.05, 0.05, 0.1),");
472
- if (cam.cameraType === "orthographic") {
473
- this.emit("projection: pc.PROJECTION_ORTHOGRAPHIC,");
474
- }
475
- if (fov !== void 0) this.emit(`fov: ${fov},`);
476
- if (near !== void 0) this.emit(`nearClip: ${near},`);
477
- if (far !== void 0) this.emit(`farClip: ${far},`);
478
- this.dedent();
479
- this.emit("});");
480
- if (pos) this.emit(`camera.setPosition(${pos[0]}, ${pos[1]}, ${pos[2]});`);
481
- else this.emit("camera.setPosition(0, 5, 10);");
482
- if (lookAt) this.emit(`camera.lookAt(${lookAt[0]}, ${lookAt[1]}, ${lookAt[2]});`);
483
- else this.emit("camera.lookAt(0, 0, 0);");
484
- this.emit("this.app.root.addChild(camera);");
485
- this.emit("");
486
- }
487
- // --- Timeline ---
488
- emitTimeline(timeline) {
489
- this.sanitizeName(timeline.name);
490
- this.emit(`// Timeline: "${this.escapeStringValue(timeline.name, "TypeScript")}"`);
491
- for (const entry of timeline.entries) {
492
- const a = entry.action;
493
- if (a.kind === "animate") {
494
- this.emit(`// @${entry.time}s: animate ${a.target} ${JSON.stringify(a.properties)}`);
495
- } else if (a.kind === "emit") {
496
- this.emit(
497
- `// @${entry.time}s: emit "${this.escapeStringValue(a.event, "TypeScript")}"`
498
- );
499
- } else if (a.kind === "call") {
500
- this.emit(
501
- `// @${entry.time}s: call ${this.escapeStringValue(a.method, "TypeScript")}()`
502
- );
503
- }
504
- }
505
- if (timeline.autoplay) this.emit(`// autoplay: ${timeline.loop ? "loop" : "once"}`);
506
- this.emit("");
507
- }
508
- // --- Audio ---
509
- emitAudio(audio) {
510
- const v = this.sanitizeName(audio.name);
511
- let src = "", volume = 1, loop = false, spatial = false;
512
- let position, dist;
513
- for (const p of audio.properties) {
514
- if (p.key === "src" || p.key === "source") src = String(p.value);
515
- else if (p.key === "volume") volume = p.value;
516
- else if (p.key === "loop") loop = !!p.value;
517
- else if (p.key === "spatial") spatial = !!p.value;
518
- else if (p.key === "position" && Array.isArray(p.value)) position = p.value;
519
- else if (p.key === "distance") dist = p.value;
520
- }
521
- this.emit(
522
- `const ${v} = new pc.Entity("${this.escapeStringValue(audio.name, "TypeScript")}");`
523
- );
524
- this.emit(`${v}.addComponent("sound");`);
525
- this.emit(`${v}.sound!.addSlot("default", {`);
526
- this.indent();
527
- this.emit(`asset: null, // Load "${src}" via asset registry`);
528
- this.emit(`loop: ${loop},`);
529
- this.emit(`volume: ${volume},`);
530
- this.emit(`autoPlay: true,`);
531
- if (dist !== void 0) this.emit(`maxDistance: ${dist},`);
532
- if (spatial) this.emit("positional: true,");
533
- this.dedent();
534
- this.emit("});");
535
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
536
- this.emit(`this.app.root.addChild(${v});`);
537
- this.emit("");
538
- }
539
- // --- Zone ---
540
- emitZone(zone) {
541
- const v = this.sanitizeName(zone.name);
542
- let shape = "box", position, size, radius;
543
- for (const p of zone.properties) {
544
- if (p.key === "shape") shape = String(p.value);
545
- else if (p.key === "position" && Array.isArray(p.value)) position = p.value;
546
- else if (p.key === "size") size = p.value;
547
- else if (p.key === "radius") radius = p.value;
548
- }
549
- this.emit(
550
- `const ${v} = new pc.Entity("${this.escapeStringValue(zone.name, "TypeScript")}");`
551
- );
552
- if (shape === "sphere") {
553
- this.emit(`${v}.addComponent("collision", { type: "sphere", radius: ${radius || 5} });`);
554
- } else {
555
- const s = Array.isArray(size) ? size : [size || 5, size || 5, size || 5];
556
- this.emit(
557
- `${v}.addComponent("collision", { type: "box", halfExtents: new pc.Vec3(${s[0] / 2}, ${s[1] / 2}, ${s[2] / 2}) });`
558
- );
559
- }
560
- this.emit(`${v}.addComponent("rigidbody", { type: "static" });`);
561
- if (position) this.emit(`${v}.setPosition(${position[0]}, ${position[1]}, ${position[2]});`);
562
- if (zone.handlers?.length) {
563
- for (const h of zone.handlers) {
564
- const event = h.event === "on_enter" ? "triggerenter" : h.event === "on_exit" ? "triggerleave" : h.event;
565
- this.emit(
566
- `${v}.collision!.on("${event}", (result: unknown) => { /* ${this.escapeStringValue(h.event, "TypeScript")} */ });`
567
- );
568
- }
569
- }
570
- this.emit(`this.app.root.addChild(${v});`);
571
- this.emit("");
572
- }
573
- // --- UI ---
574
- emitUI(ui) {
575
- this.emit('const screenEntity = new pc.Entity("screen");');
576
- this.emit(
577
- 'screenEntity.addComponent("screen", { screenSpace: true, referenceResolution: new pc.Vec2(1280, 720) });'
578
- );
579
- this.emit("this.app.root.addChild(screenEntity);");
580
- for (const el of ui.elements) {
581
- const v = this.sanitizeName(el.name);
582
- let elType = "text", text = "", fontSize = 24, color = "#ffffff";
583
- for (const p of el.properties) {
584
- if (p.key === "type") elType = String(p.value);
585
- else if (p.key === "text") text = String(p.value);
586
- else if (p.key === "font_size" || p.key === "fontSize") fontSize = p.value;
587
- else if (p.key === "color") color = String(p.value);
588
- else if (p.key === "background") String(p.value);
589
- }
590
- this.emit(
591
- `const ${v} = new pc.Entity("${this.escapeStringValue(el.name, "TypeScript")}");`
592
- );
593
- if (elType === "button") {
594
- this.emit(`${v}.addComponent("element", {`);
595
- this.indent();
596
- this.emit(`type: "text",`);
597
- this.emit(`text: "${text}",`);
598
- this.emit(`fontSize: ${fontSize},`);
599
- this.emit(`color: ${this.toPlayCanvasColor(color)},`);
600
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
601
- this.emit(`pivot: new pc.Vec2(0.5, 0.5),`);
602
- this.emit(`width: 150,`);
603
- this.emit(`height: 40,`);
604
- this.dedent();
605
- this.emit("});");
606
- this.emit(`${v}.addComponent("button", { active: true });`);
607
- } else if (elType === "progress") {
608
- this.emit(`${v}.addComponent("element", {`);
609
- this.indent();
610
- this.emit('type: "image",');
611
- this.emit("anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),");
612
- this.emit("width: 200,");
613
- this.emit("height: 20,");
614
- this.dedent();
615
- this.emit("});");
616
- } else {
617
- this.emit(`${v}.addComponent("element", {`);
618
- this.indent();
619
- this.emit(`type: "text",`);
620
- this.emit(`text: "${text}",`);
621
- this.emit(`fontSize: ${fontSize},`);
622
- this.emit(`color: ${this.toPlayCanvasColor(color)},`);
623
- this.emit(`anchor: new pc.Vec4(0.5, 0.5, 0.5, 0.5),`);
624
- this.dedent();
625
- this.emit("});");
626
- }
627
- this.emit(`screenEntity.addChild(${v});`);
628
- }
629
- this.emit("");
630
- }
631
- // --- Effects ---
632
- emitEffects(effects) {
633
- for (const fx of effects.effects) {
634
- const p = fx.properties;
635
- switch (fx.effectType) {
636
- case "bloom":
637
- this.emit("// Post-processing: Bloom");
638
- this.emit("this.app.scene.rendering.toneMapping = pc.TONEMAP_ACES;");
639
- if (p.intensity !== void 0) this.emit(`// bloom intensity: ${p.intensity}`);
640
- break;
641
- case "ssao":
642
- this.emit("// Post-processing: SSAO");
643
- if (p.radius !== void 0) this.emit(`// ssao radius: ${p.radius}`);
644
- break;
645
- case "vignette":
646
- this.emit("// Post-processing: Vignette");
647
- if (p.weight !== void 0) this.emit(`// vignette weight: ${p.weight}`);
648
- break;
649
- case "tone_mapping":
650
- this.emit("this.app.scene.rendering.toneMapping = pc.TONEMAP_ACES;");
651
- break;
652
- default:
653
- this.emit(`// Effect "${fx.effectType}": ${JSON.stringify(p)}`);
654
- }
655
- }
656
- this.emit("");
657
- }
658
- // --- Transition ---
659
- emitTransition(tr) {
660
- let target, effect, duration;
661
- for (const p of tr.properties) {
662
- if (p.key === "target") target = String(p.value);
663
- else if (p.key === "effect") effect = String(p.value);
664
- else if (p.key === "duration") duration = p.value;
665
- }
666
- this.emit(
667
- `// Transition "${this.escapeStringValue(tr.name, "TypeScript")}": navigate to "${target || "?"}" with ${effect || "fade"} over ${duration || 1}s`
668
- );
669
- }
670
- // --- XR ---
671
- emitXRSetup() {
672
- this.emit("if (this.app.xr.supported) {");
673
- this.indent();
674
- this.emit(
675
- 'this.app.xr.start(this.app.root.findByName("camera")?.camera!, pc.XRTYPE_VR, pc.XRSPACE_LOCAL);'
676
- );
677
- this.dedent();
678
- this.emit("}");
679
- this.emit("");
680
- }
681
- // --- Start App ---
682
- emitStartApp() {
683
- this.emit("this.app.start();");
684
- this.emit('window.addEventListener("resize", () => { this.app.resizeCanvas(); });');
685
- }
686
- // --- Value Conversion Helpers ---
687
- toPlayCanvasColor(value) {
688
- if (typeof value === "string" && value.startsWith("#")) {
689
- const h = value.slice(1);
690
- const r = parseInt(h.substring(0, 2), 16) / 255;
691
- const g = parseInt(h.substring(2, 4), 16) / 255;
692
- const b = parseInt(h.substring(4, 6), 16) / 255;
693
- return `new pc.Color(${r.toFixed(3)}, ${g.toFixed(3)}, ${b.toFixed(3)})`;
694
- }
695
- if (typeof value === "object" && value !== null && "r" in value) {
696
- const c = value;
697
- const rVal = Number(c.r);
698
- const gVal = Number(c.g);
699
- const bVal = Number(c.b);
700
- const r = rVal > 1 ? rVal / 255 : rVal;
701
- const g = gVal > 1 ? gVal / 255 : gVal;
702
- const b = bVal > 1 ? bVal / 255 : bVal;
703
- return `new pc.Color(${r.toFixed(3)}, ${g.toFixed(3)}, ${b.toFixed(3)})`;
704
- }
705
- return "new pc.Color(1, 1, 1)";
706
- }
707
- mapShapeToPrimitive(type) {
708
- return SHAPE_TO_PRIMITIVE[type] || "box";
709
- }
710
- mapLightType(type) {
711
- switch (type) {
712
- case "hemisphere":
713
- case "ambient":
714
- return "directional";
715
- case "directional":
716
- return "directional";
717
- case "point":
718
- return "point";
719
- case "spot":
720
- return "spot";
721
- case "area":
722
- return "point";
723
- default:
724
- return "directional";
725
- }
726
- }
727
- directionToEuler(dir) {
728
- const x = Number(dir[0]) || 0, y = Number(dir[1]) || 0, z = Number(dir[2]) || 0;
729
- const pitch = Math.atan2(-y, Math.sqrt(x * x + z * z)) * (180 / Math.PI);
730
- const yaw = Math.atan2(x, z) * (180 / Math.PI);
731
- return `${pitch.toFixed(1)}, ${yaw.toFixed(1)}, 0`;
732
- }
733
- // --- Emit Helpers ---
734
- emit(line) {
735
- this.lines.push(this.options.indent.repeat(this.indentLevel) + line);
736
- }
737
- indent() {
738
- this.indentLevel++;
739
- }
740
- dedent() {
741
- this.indentLevel = Math.max(0, this.indentLevel - 1);
742
- }
743
- sanitizeName(name) {
744
- return name.replace(/[^a-zA-Z0-9_]/g, "_");
745
- }
746
- };
747
- }
748
- });
749
-
750
- export { PlayCanvasCompiler, PlayCanvasCompiler_exports, init_PlayCanvasCompiler };
751
- //# sourceMappingURL=chunk-S565K7NK.js.map
752
- //# sourceMappingURL=chunk-S565K7NK.js.map