@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,129 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkILRBGFVD_cjs = require('./chunk-ILRBGFVD.cjs');
4
- var orbital = require('@holoscript/engine/orbital');
5
-
6
- // src/traits/MitosisTrait.ts
7
- var mitosisHandler = {
8
- name: "mitosis",
9
- defaultConfig: {
10
- strategy: "collaborative",
11
- max_children: 5,
12
- auto_cleanup: true
13
- },
14
- onAttach(node, config, context) {
15
- const state = {
16
- parent_id: ("parent_id" in config ? config.parent_id : null) || null,
17
- active_children: [],
18
- tasks_delegated: 0,
19
- completed_tasks: 0,
20
- last_sync_time: Date.now()
21
- };
22
- node.__mitosisState = state;
23
- context.emit?.("mitosis_init", {
24
- nodeId: node.id,
25
- strategy: config.strategy,
26
- parent_id: state.parent_id
27
- });
28
- },
29
- onDetach(node, config, context) {
30
- const state = node.__mitosisState;
31
- if (state && config.auto_cleanup) {
32
- for (const childId of state.active_children) {
33
- context.emit?.("mitosis_despawn_child", { childId });
34
- }
35
- }
36
- delete node.__mitosisState;
37
- },
38
- onEvent(node, config, context, event) {
39
- const state = node.__mitosisState;
40
- if (!state) return;
41
- if (event.type === "mitosis_spawned") {
42
- const childId = event.childId;
43
- const parentId = event.parentId;
44
- if (node.id === parentId) {
45
- state.active_children.push(childId);
46
- state.tasks_delegated++;
47
- context.emit?.("on_mitosis_spawned", { childId, parentId: node.id });
48
- }
49
- } else if (event.type === "mitosis_child_complete") {
50
- const childId = "childId" in event ? event.childId : "";
51
- const parentId = "parentId" in event ? event.parentId : "";
52
- const result = "result" in event ? event.result : void 0;
53
- if (node.id === parentId) {
54
- state.completed_tasks++;
55
- state.last_sync_time = Date.now();
56
- context.emit?.("mitosis_synced", {
57
- parentId: node.id,
58
- childId,
59
- result
60
- });
61
- if (config.strategy === "collaborative") {
62
- if (result && typeof result === "object") {
63
- Object.assign(node.properties || {}, result);
64
- }
65
- }
66
- }
67
- } else if (event.type === "mitosis_child_failed") {
68
- context.emit?.("on_mitosis_error", {
69
- parentId: node.id,
70
- childId: event.childId,
71
- error: event.error
72
- });
73
- }
74
- }
75
- };
76
- var orbitalHandler = {
77
- name: "orbital",
78
- defaultConfig: {},
79
- /**
80
- * Called when trait is attached to a node
81
- */
82
- onAttach(node, _config, _context) {
83
- chunkILRBGFVD_cjs.logger.info(`[OrbitalTrait] Attached to ${node.name}`);
84
- },
85
- /**
86
- * Called every frame to update orbital position
87
- */
88
- onUpdate(node, config, context, _delta) {
89
- const properties = node.properties || {};
90
- const mergedConfig = { ...properties, ...config };
91
- if (!mergedConfig || !mergedConfig.semiMajorAxis) {
92
- return;
93
- }
94
- const julianDate = context.julianDate || 0;
95
- const visualScale = context.getScaleMultiplier() * 50;
96
- const satelliteScale = 5;
97
- const rawPosition = orbital.calculatePosition(mergedConfig, julianDate);
98
- const currentScale = mergedConfig.parent ? visualScale * satelliteScale : visualScale;
99
- let finalPosition = {
100
- x: rawPosition.x * currentScale,
101
- y: rawPosition.z * currentScale,
102
- z: rawPosition.y * currentScale
103
- };
104
- if (mergedConfig.parent) {
105
- let parentNode = context.getNode?.(mergedConfig.parent);
106
- if (!parentNode && typeof mergedConfig.parent === "object" && mergedConfig.parent && mergedConfig.parent.position) {
107
- parentNode = mergedConfig.parent;
108
- }
109
- if (parentNode && parentNode.position) {
110
- finalPosition = {
111
- x: finalPosition.x + (parentNode.position.x || 0),
112
- y: finalPosition.y + (parentNode.position.y || 0),
113
- z: finalPosition.z + (parentNode.position.z || 0)
114
- };
115
- } else {
116
- if (typeof mergedConfig.parent === "string") {
117
- chunkILRBGFVD_cjs.logger.warn(`[OrbitalTrait] Parent "${mergedConfig.parent}" not found for ${node.name}`);
118
- }
119
- }
120
- }
121
- node.position = finalPosition;
122
- context.emit("position_update", { position: finalPosition });
123
- }
124
- };
125
-
126
- exports.mitosisHandler = mitosisHandler;
127
- exports.orbitalHandler = orbitalHandler;
128
- //# sourceMappingURL=chunk-TSH3MSQU.cjs.map
129
- //# sourceMappingURL=chunk-TSH3MSQU.cjs.map
@@ -1,504 +0,0 @@
1
- import { init_DomainBlockCompilerMixin, compileDomainBlocks, compileWeatherBlock, compileAudioSourceBlock, compilePhysicsBlock, physicsToSDF, compileMaterialBlock, materialToSDF } from './chunk-YQK5JNFK.js';
2
- import { init_CompilerBase, CompilerBase } from './chunk-6XSERL6L.js';
3
- import { __export, __esm } from './chunk-2CWOLHTE.js';
4
- import { ANSCapabilityPath } from '@holoscript/platform';
5
-
6
- // src/compiler/SDFCompiler.ts
7
- var SDFCompiler_exports = {};
8
- __export(SDFCompiler_exports, {
9
- SDFCompiler: () => SDFCompiler,
10
- default: () => SDFCompiler_default
11
- });
12
- var SDFCompiler, SDFCompiler_default;
13
- var init_SDFCompiler = __esm({
14
- "src/compiler/SDFCompiler.ts"() {
15
- init_CompilerBase();
16
- init_DomainBlockCompilerMixin();
17
- SDFCompiler = class extends CompilerBase {
18
- constructor(options = {}) {
19
- super();
20
- this.compilerName = "SDFCompiler";
21
- this.lines = [];
22
- this.indentLevel = 0;
23
- this.options = {
24
- worldName: options.worldName || "holoscript_world",
25
- sdfVersion: options.sdfVersion || "1.8",
26
- includePhysics: options.includePhysics ?? true,
27
- physicsEngine: options.physicsEngine || "ode",
28
- realTimeFactor: options.realTimeFactor ?? 1,
29
- includeScene: options.includeScene ?? true,
30
- meshPathPrefix: options.meshPathPrefix || "model://"
31
- };
32
- }
33
- getRequiredCapability() {
34
- return ANSCapabilityPath.SDF;
35
- }
36
- compile(composition, agentToken, outputPath) {
37
- this.validateCompilerAccess(agentToken, outputPath);
38
- this.lines = [];
39
- this.indentLevel = 0;
40
- this.emit('<?xml version="1.0"?>');
41
- this.emit(`<!-- Auto-generated by HoloScript SDFCompiler -->`);
42
- this.emit(
43
- `<!-- Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}" -->`
44
- );
45
- this.emit("");
46
- this.emit(`<sdf version="${this.options.sdfVersion}">`);
47
- this.indentLevel++;
48
- this.emit(`<world name="${this.escapeXml(this.options.worldName)}">`);
49
- this.indentLevel++;
50
- if (this.options.includePhysics) {
51
- this.emitPhysics();
52
- }
53
- if (this.options.includeScene) {
54
- this.emitScene(composition.environment);
55
- }
56
- this.emitGroundPlane();
57
- this.emitSunLight();
58
- if (composition.lights) {
59
- for (const light of composition.lights) {
60
- this.emitLight(light);
61
- }
62
- }
63
- if (composition.objects) {
64
- for (const obj of composition.objects) {
65
- this.emitModel(obj);
66
- }
67
- }
68
- if (composition.spatialGroups) {
69
- for (const group of composition.spatialGroups) {
70
- this.emitSpatialGroup(group);
71
- }
72
- }
73
- this.emitSDFDomainBlocks(composition);
74
- this.indentLevel--;
75
- this.emit("</world>");
76
- this.indentLevel--;
77
- this.emit("</sdf>");
78
- return this.lines.join("\n");
79
- }
80
- emitSDFDomainBlocks(composition) {
81
- const domainBlocks = composition.domainBlocks ?? [];
82
- if (domainBlocks.length === 0) return;
83
- this.emit("");
84
- this.emit("<!-- v4.2 Domain Blocks -->");
85
- const compiled = compileDomainBlocks(
86
- domainBlocks,
87
- {
88
- material: (block) => {
89
- const mat = compileMaterialBlock(block);
90
- return materialToSDF(mat);
91
- },
92
- physics: (block) => {
93
- const phys = compilePhysicsBlock(block);
94
- return physicsToSDF(phys);
95
- },
96
- audio: (block) => {
97
- const audio = compileAudioSourceBlock(block);
98
- return `<!-- Audio: ${this.escapeStringValue(audio.name, "TypeScript")} (${audio.keyword}) clip="${audio.properties.clip || ""}" -->`;
99
- },
100
- weather: (block) => {
101
- const weather = compileWeatherBlock(block);
102
- const layers = weather.layers.map((l) => `<!-- ${l.type}: ${JSON.stringify(l.properties)} -->`).join("\n");
103
- return `<!-- Weather: ${weather.keyword} "${weather.name || ""}" -->
104
- ${layers}`;
105
- }
106
- },
107
- (block) => `<!-- Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}" -->`
108
- );
109
- for (const output of compiled) {
110
- for (const line of output.split("\n")) {
111
- this.emit(line);
112
- }
113
- }
114
- }
115
- // ===== Property extraction helpers =====
116
- getEnvProp(env, key) {
117
- if (!env) return void 0;
118
- if (Array.isArray(env.properties)) {
119
- const prop = env.properties.find((p) => p.key === key);
120
- return prop?.value;
121
- } else {
122
- return env[key];
123
- }
124
- }
125
- getLightProp(light, key, fallback) {
126
- if (Array.isArray(light.properties)) {
127
- const prop = light.properties.find((p) => p.key === key);
128
- return prop?.value ?? fallback;
129
- } else if (light[key] !== void 0) {
130
- return light[key];
131
- }
132
- return fallback;
133
- }
134
- getTraitName(trait) {
135
- return typeof trait === "string" ? trait : trait.name;
136
- }
137
- hasTrait(obj, traitName) {
138
- return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
139
- }
140
- emitPhysics() {
141
- this.emit(`<physics name="default_physics" type="${this.options.physicsEngine}">`);
142
- this.indentLevel++;
143
- this.emit("<max_step_size>0.001</max_step_size>");
144
- this.emit(`<real_time_factor>${this.options.realTimeFactor}</real_time_factor>`);
145
- this.emit("<real_time_update_rate>1000</real_time_update_rate>");
146
- if (this.options.physicsEngine === "ode") {
147
- this.emit("<ode>");
148
- this.indentLevel++;
149
- this.emit("<solver>");
150
- this.indentLevel++;
151
- this.emit("<type>quick</type>");
152
- this.emit("<iters>50</iters>");
153
- this.emit("<sor>1.3</sor>");
154
- this.indentLevel--;
155
- this.emit("</solver>");
156
- this.emit("<constraints>");
157
- this.indentLevel++;
158
- this.emit("<cfm>0</cfm>");
159
- this.emit("<erp>0.2</erp>");
160
- this.indentLevel--;
161
- this.emit("</constraints>");
162
- this.indentLevel--;
163
- this.emit("</ode>");
164
- }
165
- this.indentLevel--;
166
- this.emit("</physics>");
167
- this.emit("");
168
- }
169
- emitScene(environment) {
170
- this.emit("<scene>");
171
- this.indentLevel++;
172
- const ambientLevel = this.getEnvProp(environment, "ambient_light") ?? 0.4;
173
- this.emit(`<ambient>${ambientLevel} ${ambientLevel} ${ambientLevel} 1</ambient>`);
174
- const skybox = this.getEnvProp(environment, "skybox");
175
- if (skybox) {
176
- const skyColors = {
177
- sunset: "0.9 0.5 0.3 1",
178
- night: "0.05 0.05 0.1 1",
179
- nebula: "0.1 0.05 0.2 1",
180
- day: "0.3 0.5 0.9 1",
181
- overcast: "0.5 0.5 0.5 1"
182
- };
183
- this.emit(`<background>${skyColors[skybox] || "0.7 0.7 0.7 1"}</background>`);
184
- } else {
185
- this.emit("<background>0.7 0.7 0.7 1</background>");
186
- }
187
- this.emit("<shadows>true</shadows>");
188
- this.indentLevel--;
189
- this.emit("</scene>");
190
- this.emit("");
191
- }
192
- emitGroundPlane() {
193
- this.emit('<model name="ground_plane">');
194
- this.indentLevel++;
195
- this.emit("<static>true</static>");
196
- this.emit('<link name="link">');
197
- this.indentLevel++;
198
- this.emit('<collision name="collision">');
199
- this.indentLevel++;
200
- this.emit("<geometry>");
201
- this.indentLevel++;
202
- this.emit("<plane>");
203
- this.indentLevel++;
204
- this.emit("<normal>0 0 1</normal>");
205
- this.emit("<size>100 100</size>");
206
- this.indentLevel--;
207
- this.emit("</plane>");
208
- this.indentLevel--;
209
- this.emit("</geometry>");
210
- this.indentLevel--;
211
- this.emit("</collision>");
212
- this.emit('<visual name="visual">');
213
- this.indentLevel++;
214
- this.emit("<geometry>");
215
- this.indentLevel++;
216
- this.emit("<plane>");
217
- this.indentLevel++;
218
- this.emit("<normal>0 0 1</normal>");
219
- this.emit("<size>100 100</size>");
220
- this.indentLevel--;
221
- this.emit("</plane>");
222
- this.indentLevel--;
223
- this.emit("</geometry>");
224
- this.emit("<material>");
225
- this.indentLevel++;
226
- this.emit("<ambient>0.8 0.8 0.8 1</ambient>");
227
- this.emit("<diffuse>0.8 0.8 0.8 1</diffuse>");
228
- this.indentLevel--;
229
- this.emit("</material>");
230
- this.indentLevel--;
231
- this.emit("</visual>");
232
- this.indentLevel--;
233
- this.emit("</link>");
234
- this.indentLevel--;
235
- this.emit("</model>");
236
- this.emit("");
237
- }
238
- emitSunLight() {
239
- this.emit('<light name="sun" type="directional">');
240
- this.indentLevel++;
241
- this.emit("<cast_shadows>true</cast_shadows>");
242
- this.emit("<pose>0 0 10 0 0 0</pose>");
243
- this.emit("<diffuse>0.8 0.8 0.8 1</diffuse>");
244
- this.emit("<specular>0.2 0.2 0.2 1</specular>");
245
- this.emit("<direction>-0.5 0.1 -0.9</direction>");
246
- this.indentLevel--;
247
- this.emit("</light>");
248
- this.emit("");
249
- }
250
- emitLight(light) {
251
- const name = this.sanitizeName(light.name || "light");
252
- const lightTypeValue = light.lightType || (typeof light.type === "string" && ["point", "directional", "spot", "hemisphere", "ambient", "area"].includes(
253
- light.type
254
- ) ? light.type : void 0);
255
- const type = this.mapLightType(lightTypeValue);
256
- this.emit(`<light name="${name}" type="${type}">`);
257
- this.indentLevel++;
258
- let castShadow = this.getLightProp(light, "cast_shadow", void 0);
259
- if (castShadow === void 0) {
260
- castShadow = this.getLightProp(light, "castShadow", true);
261
- }
262
- this.emit(`<cast_shadows>${castShadow}</cast_shadows>`);
263
- const pos = this.getLightProp(light, "position", [0, 0, 5]);
264
- this.emit(`<pose>${pos[0]} ${pos[1]} ${pos[2]} 0 0 0</pose>`);
265
- const colorVal = this.getLightProp(light, "color", "#ffffff");
266
- const color = this.parseColor(typeof colorVal === "string" ? colorVal : "#ffffff");
267
- const intensity = this.getLightProp(light, "intensity", 1);
268
- this.emit(
269
- `<diffuse>${color.r * intensity} ${color.g * intensity} ${color.b * intensity} 1</diffuse>`
270
- );
271
- this.emit(`<specular>${color.r * 0.3} ${color.g * 0.3} ${color.b * 0.3} 1</specular>`);
272
- if (type === "spot") {
273
- const angle = this.getLightProp(light, "angle", 45);
274
- this.emit("<spot>");
275
- this.indentLevel++;
276
- this.emit(`<inner_angle>${angle * 0.8 * Math.PI / 180}</inner_angle>`);
277
- this.emit(`<outer_angle>${angle * Math.PI / 180}</outer_angle>`);
278
- this.emit("<falloff>1</falloff>");
279
- this.indentLevel--;
280
- this.emit("</spot>");
281
- }
282
- const range = this.getLightProp(light, "range", 0);
283
- if (range > 0) {
284
- this.emit("<attenuation>");
285
- this.indentLevel++;
286
- this.emit(`<range>${range}</range>`);
287
- this.emit("<constant>0.5</constant>");
288
- this.emit("<linear>0.01</linear>");
289
- this.emit("<quadratic>0.001</quadratic>");
290
- this.indentLevel--;
291
- this.emit("</attenuation>");
292
- }
293
- this.indentLevel--;
294
- this.emit("</light>");
295
- this.emit("");
296
- }
297
- emitModel(obj) {
298
- const name = this.sanitizeName(obj.name);
299
- const isStatic = !this.hasTrait(obj, "physics") && !this.hasTrait(obj, "rigid");
300
- this.emit(`<model name="${name}">`);
301
- this.indentLevel++;
302
- if (isStatic) {
303
- this.emit("<static>true</static>");
304
- }
305
- const pos = this.extractPosition(obj);
306
- const rot = this.extractRotation(obj);
307
- this.emit(`<pose>${pos[0]} ${pos[1]} ${pos[2]} ${rot[0]} ${rot[1]} ${rot[2]}</pose>`);
308
- this.emit(`<link name="${name}_link">`);
309
- this.indentLevel++;
310
- if (!isStatic) {
311
- const mass = this.extractMass(obj) || 1;
312
- this.emit("<inertial>");
313
- this.indentLevel++;
314
- this.emit(`<mass>${mass}</mass>`);
315
- this.emit("<inertia>");
316
- this.indentLevel++;
317
- this.emit(`<ixx>${mass * 0.1}</ixx><ixy>0</ixy><ixz>0</ixz>`);
318
- this.emit(`<iyy>${mass * 0.1}</iyy><iyz>0</iyz>`);
319
- this.emit(`<izz>${mass * 0.1}</izz>`);
320
- this.indentLevel--;
321
- this.emit("</inertia>");
322
- this.indentLevel--;
323
- this.emit("</inertial>");
324
- }
325
- if (this.hasTrait(obj, "collidable") || this.hasTrait(obj, "physics") || this.hasTrait(obj, "rigid")) {
326
- this.emit('<collision name="collision">');
327
- this.indentLevel++;
328
- this.emitGeometry(obj);
329
- this.indentLevel--;
330
- this.emit("</collision>");
331
- }
332
- this.emit('<visual name="visual">');
333
- this.indentLevel++;
334
- this.emitGeometry(obj);
335
- this.emitMaterial(obj);
336
- this.indentLevel--;
337
- this.emit("</visual>");
338
- this.indentLevel--;
339
- this.emit("</link>");
340
- this.indentLevel--;
341
- this.emit("</model>");
342
- this.emit("");
343
- }
344
- emitSpatialGroup(group) {
345
- this.emit(
346
- `<!-- Spatial Group: ${this.escapeStringValue(group.name, "TypeScript")} -->`
347
- );
348
- if (group.objects) {
349
- for (const obj of group.objects) {
350
- this.emitModel(obj);
351
- }
352
- }
353
- }
354
- emitGeometry(obj) {
355
- const geometryProp = obj.properties.find((p) => p.key === "geometry");
356
- const geometryValue = geometryProp ? this.getStringValue(geometryProp.value) : "box";
357
- const scale = this.extractScale(obj);
358
- this.emit("<geometry>");
359
- this.indentLevel++;
360
- switch (geometryValue) {
361
- case "cube":
362
- case "box":
363
- this.emit(`<box><size>${scale} ${scale} ${scale}</size></box>`);
364
- break;
365
- case "sphere":
366
- this.emit(`<sphere><radius>${scale / 2}</radius></sphere>`);
367
- break;
368
- case "cylinder":
369
- this.emit(`<cylinder><radius>${scale / 2}</radius><length>${scale}</length></cylinder>`);
370
- break;
371
- case "plane":
372
- this.emit(`<plane><normal>0 0 1</normal><size>${scale} ${scale}</size></plane>`);
373
- break;
374
- case "capsule":
375
- this.emit(`<capsule><radius>${scale / 3}</radius><length>${scale}</length></capsule>`);
376
- break;
377
- default:
378
- if (geometryValue.includes(".")) {
379
- this.emit(`<mesh><uri>${this.options.meshPathPrefix}${geometryValue}</uri></mesh>`);
380
- } else {
381
- this.emit(`<box><size>${scale} ${scale} ${scale}</size></box>`);
382
- }
383
- }
384
- this.indentLevel--;
385
- this.emit("</geometry>");
386
- }
387
- emitMaterial(obj) {
388
- const color = this.extractColor(obj);
389
- this.emit("<material>");
390
- this.indentLevel++;
391
- if (color) {
392
- const rgb = this.parseColor(color);
393
- this.emit(`<ambient>${rgb.r} ${rgb.g} ${rgb.b} 1</ambient>`);
394
- this.emit(`<diffuse>${rgb.r} ${rgb.g} ${rgb.b} 1</diffuse>`);
395
- this.emit(`<specular>0.1 0.1 0.1 1</specular>`);
396
- if (this.hasTrait(obj, "glowing") || this.hasTrait(obj, "emissive")) {
397
- this.emit(`<emissive>${rgb.r * 0.5} ${rgb.g * 0.5} ${rgb.b * 0.5} 1</emissive>`);
398
- }
399
- } else {
400
- this.emit("<ambient>0.7 0.7 0.7 1</ambient>");
401
- this.emit("<diffuse>0.7 0.7 0.7 1</diffuse>");
402
- }
403
- this.indentLevel--;
404
- this.emit("</material>");
405
- }
406
- extractPosition(obj) {
407
- const posProp = obj.properties.find((p) => p.key === "position");
408
- if (posProp && Array.isArray(posProp.value)) {
409
- return [
410
- Number(posProp.value[0]) || 0,
411
- Number(posProp.value[1]) || 0,
412
- Number(posProp.value[2]) || 0
413
- ];
414
- }
415
- return [0, 0, 0];
416
- }
417
- extractRotation(obj) {
418
- const rotProp = obj.properties.find((p) => p.key === "rotation");
419
- if (rotProp && Array.isArray(rotProp.value)) {
420
- return [
421
- (Number(rotProp.value[0]) || 0) * Math.PI / 180,
422
- (Number(rotProp.value[1]) || 0) * Math.PI / 180,
423
- (Number(rotProp.value[2]) || 0) * Math.PI / 180
424
- ];
425
- }
426
- return [0, 0, 0];
427
- }
428
- extractScale(obj) {
429
- const scaleProp = obj.properties.find((p) => p.key === "scale");
430
- if (scaleProp) {
431
- if (typeof scaleProp.value === "number") return scaleProp.value;
432
- if (Array.isArray(scaleProp.value)) return Number(scaleProp.value[0]) || 1;
433
- }
434
- return 1;
435
- }
436
- extractColor(obj) {
437
- const colorProp = obj.properties.find((p) => p.key === "color");
438
- return colorProp ? this.getStringValue(colorProp.value) : void 0;
439
- }
440
- extractMass(obj) {
441
- const physicsProp = obj.properties.find((p) => p.key === "physics");
442
- if (physicsProp && typeof physicsProp.value === "object" && !Array.isArray(physicsProp.value)) {
443
- const massEntry = physicsProp.value.mass;
444
- if (typeof massEntry === "number") return massEntry;
445
- }
446
- return void 0;
447
- }
448
- mapLightType(type) {
449
- switch (type) {
450
- case "point":
451
- return "point";
452
- case "directional":
453
- return "directional";
454
- case "spot":
455
- return "spot";
456
- default:
457
- return "point";
458
- }
459
- }
460
- parseColor(color) {
461
- if (color.startsWith("#")) {
462
- const hex = color.slice(1);
463
- return {
464
- r: parseInt(hex.slice(0, 2), 16) / 255,
465
- g: parseInt(hex.slice(2, 4), 16) / 255,
466
- b: parseInt(hex.slice(4, 6), 16) / 255
467
- };
468
- }
469
- const colors = {
470
- red: { r: 1, g: 0, b: 0 },
471
- green: { r: 0, g: 1, b: 0 },
472
- blue: { r: 0, g: 0, b: 1 },
473
- white: { r: 1, g: 1, b: 1 },
474
- black: { r: 0, g: 0, b: 0 },
475
- yellow: { r: 1, g: 1, b: 0 },
476
- cyan: { r: 0, g: 1, b: 1 },
477
- magenta: { r: 1, g: 0, b: 1 }
478
- };
479
- return colors[color.toLowerCase()] || { r: 0.7, g: 0.7, b: 0.7 };
480
- }
481
- emit(line) {
482
- const indent = " ".repeat(this.indentLevel);
483
- this.lines.push(indent + line);
484
- }
485
- sanitizeName(name) {
486
- return name.replace(/[^a-zA-Z0-9_]/g, "_").toLowerCase();
487
- }
488
- escapeXml(str) {
489
- return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
490
- }
491
- getStringValue(value) {
492
- if (typeof value === "string") return value;
493
- if (typeof value === "number") return String(value);
494
- if (typeof value === "boolean") return String(value);
495
- return "";
496
- }
497
- };
498
- SDFCompiler_default = SDFCompiler;
499
- }
500
- });
501
-
502
- export { SDFCompiler, SDFCompiler_default, SDFCompiler_exports, init_SDFCompiler };
503
- //# sourceMappingURL=chunk-UERJ3YJV.js.map
504
- //# sourceMappingURL=chunk-UERJ3YJV.js.map