@holoscript/core 6.0.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,769 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkHHS6FMOU_cjs = require('./chunk-HHS6FMOU.cjs');
4
- var chunkQHVVVN47_cjs = require('./chunk-QHVVVN47.cjs');
5
-
6
- // src/compiler/USDPhysicsCompiler.ts
7
- chunkQHVVVN47_cjs.init_CompilerBase();
8
- chunkQHVVVN47_cjs.init_ANSNamespace();
9
- chunkHHS6FMOU_cjs.init_DomainBlockCompilerMixin();
10
- var USDPhysicsCompiler = class extends chunkQHVVVN47_cjs.CompilerBase {
11
- constructor(options = {}) {
12
- super();
13
- this.compilerName = "USDPhysicsCompiler";
14
- this.lines = [];
15
- this.indentLevel = 0;
16
- this.prims = [];
17
- this.joints = [];
18
- this.materials = /* @__PURE__ */ new Map();
19
- this.options = {
20
- stageName: options.stageName ?? "HoloScriptPhysicsStage",
21
- upAxis: options.upAxis ?? "Z",
22
- // Isaac Sim default
23
- metersPerUnit: options.metersPerUnit ?? 1,
24
- timeCodesPerSecond: options.timeCodesPerSecond ?? 60,
25
- includePhysicsScene: options.includePhysicsScene ?? true,
26
- gravity: options.gravity ?? [0, 0, -9.81],
27
- physicsTimestep: options.physicsTimestep ?? 1 / 60,
28
- enableGPUDynamics: options.enableGPUDynamics ?? true,
29
- includeCollision: options.includeCollision ?? true,
30
- includeVisual: options.includeVisual ?? true,
31
- defaultMass: options.defaultMass ?? 1,
32
- defaultStaticFriction: options.defaultStaticFriction ?? 0.5,
33
- defaultDynamicFriction: options.defaultDynamicFriction ?? 0.5,
34
- defaultRestitution: options.defaultRestitution ?? 0.1,
35
- enableArticulation: options.enableArticulation ?? true
36
- };
37
- }
38
- getRequiredCapability() {
39
- return chunkQHVVVN47_cjs.ANSCapabilityPath.USD;
40
- }
41
- // ===========================================================================
42
- // HELPER METHODS
43
- // ===========================================================================
44
- /** Get trait name from either string or object format */
45
- getTraitName(trait) {
46
- return typeof trait === "string" ? trait : trait.name;
47
- }
48
- /** Check if object has a specific trait */
49
- hasTrait(obj, traitName) {
50
- return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
51
- }
52
- /** Get trait configuration object */
53
- getTraitConfig(obj, traitName) {
54
- const trait = obj.traits?.find((t) => this.getTraitName(t) === traitName);
55
- if (!trait) return void 0;
56
- if (typeof trait === "string") return {};
57
- const traitObj = trait;
58
- if ("config" in traitObj && typeof traitObj.config === "object") {
59
- return traitObj.config;
60
- }
61
- const { name: _name, ...rest } = traitObj;
62
- if (rest.type === "ObjectTrait") {
63
- const { type: _type, ...config } = rest;
64
- return config;
65
- }
66
- return rest;
67
- }
68
- /** Sanitize name for USD path */
69
- sanitizeName(name) {
70
- let sanitized = name.replace(/[^a-zA-Z0-9_]/g, "_");
71
- if (/^[0-9]/.test(sanitized)) {
72
- sanitized = "_" + sanitized;
73
- }
74
- return sanitized;
75
- }
76
- /** Emit a line with current indent */
77
- emit(line) {
78
- const indent = " ".repeat(this.indentLevel);
79
- this.lines.push(indent + line);
80
- }
81
- /** Emit empty line */
82
- emitBlank() {
83
- this.lines.push("");
84
- }
85
- /** Get property value from object properties array */
86
- getPropertyValue(obj, key) {
87
- const prop = obj.properties?.find((p) => p.key === key);
88
- return prop?.value;
89
- }
90
- /** Extract position from object properties */
91
- extractPosition(obj) {
92
- const pos = this.getPropertyValue(obj, "position");
93
- if (Array.isArray(pos) && pos.length >= 3) {
94
- return [Number(pos[0]) || 0, Number(pos[1]) || 0, Number(pos[2]) || 0];
95
- }
96
- return [0, 0, 0];
97
- }
98
- /** Extract rotation as quaternion from object properties */
99
- extractRotation(obj) {
100
- const rot = this.getPropertyValue(obj, "rotation");
101
- if (Array.isArray(rot) && rot.length >= 3) {
102
- const euler = [
103
- (Number(rot[0]) || 0) * (Math.PI / 180),
104
- (Number(rot[1]) || 0) * (Math.PI / 180),
105
- (Number(rot[2]) || 0) * (Math.PI / 180)
106
- ];
107
- return this.eulerToQuaternion(euler[0], euler[1], euler[2]);
108
- }
109
- return [0, 0, 0, 1];
110
- }
111
- /** Convert Euler angles (radians) to quaternion */
112
- eulerToQuaternion(roll, pitch, yaw) {
113
- const cy = Math.cos(yaw * 0.5);
114
- const sy = Math.sin(yaw * 0.5);
115
- const cp = Math.cos(pitch * 0.5);
116
- const sp = Math.sin(pitch * 0.5);
117
- const cr = Math.cos(roll * 0.5);
118
- const sr = Math.sin(roll * 0.5);
119
- return [
120
- sr * cp * cy - cr * sp * sy,
121
- // x
122
- cr * sp * cy + sr * cp * sy,
123
- // y
124
- cr * cp * sy - sr * sp * cy,
125
- // z
126
- cr * cp * cy + sr * sp * sy
127
- // w
128
- ];
129
- }
130
- /** Extract scale from object properties */
131
- extractScale(obj) {
132
- const scale = this.getPropertyValue(obj, "scale");
133
- if (Array.isArray(scale) && scale.length >= 3) {
134
- return [Number(scale[0]) || 1, Number(scale[1]) || 1, Number(scale[2]) || 1];
135
- }
136
- if (typeof scale === "number") {
137
- return [scale, scale, scale];
138
- }
139
- return [1, 1, 1];
140
- }
141
- /** Extract geometry type from object */
142
- extractGeometry(obj) {
143
- const geom = this.getPropertyValue(obj, "geometry");
144
- if (!geom) return void 0;
145
- const geomType = String(geom);
146
- const scale = this.extractScale(obj);
147
- switch (geomType) {
148
- case "cube":
149
- case "box":
150
- return { type: "Cube", size: scale };
151
- case "sphere":
152
- return { type: "Sphere", radius: Math.max(...scale) / 2 };
153
- case "cylinder":
154
- return { type: "Cylinder", radius: Math.max(scale[0], scale[2]) / 2 };
155
- case "capsule":
156
- return { type: "Capsule", radius: Math.max(scale[0], scale[2]) / 2 };
157
- case "cone":
158
- return { type: "Cone", radius: Math.max(scale[0], scale[2]) / 2 };
159
- default:
160
- if (geomType.endsWith(".usd") || geomType.endsWith(".usda") || geomType.endsWith(".usdc")) {
161
- return { type: "Reference", size: scale };
162
- }
163
- return { type: "Cube", size: scale };
164
- }
165
- }
166
- /** Map HoloScript joint types to USD joint types */
167
- mapJointType(holoType) {
168
- switch (holoType) {
169
- case "hinge":
170
- case "revolute":
171
- return "revolute";
172
- case "slider":
173
- case "prismatic":
174
- return "prismatic";
175
- case "ball":
176
- case "spherical":
177
- return "spherical";
178
- case "fixed":
179
- return "fixed";
180
- case "6dof":
181
- case "d6":
182
- return "d6";
183
- default:
184
- return "fixed";
185
- }
186
- }
187
- /** Map axis string to USD axis */
188
- mapAxis(axis) {
189
- if (Array.isArray(axis)) {
190
- const absX = Math.abs(Number(axis[0]) || 0);
191
- const absY = Math.abs(Number(axis[1]) || 0);
192
- const absZ = Math.abs(Number(axis[2]) || 0);
193
- if (absX >= absY && absX >= absZ) return "X";
194
- if (absY >= absX && absY >= absZ) return "Y";
195
- return "Z";
196
- }
197
- const axisStr = String(axis).toUpperCase();
198
- if (axisStr === "X" || axisStr === "Y" || axisStr === "Z") {
199
- return axisStr;
200
- }
201
- return "Z";
202
- }
203
- // ===========================================================================
204
- // COMPILATION
205
- // ===========================================================================
206
- /**
207
- * Compile HoloScript composition to USD ASCII with physics schemas
208
- */
209
- compile(composition, agentToken, outputPath) {
210
- this.validateCompilerAccess(agentToken, outputPath);
211
- this.lines = [];
212
- this.prims = [];
213
- this.joints = [];
214
- this.materials.clear();
215
- this.indentLevel = 0;
216
- this.extractFromComposition(composition);
217
- this.emitHeader(composition.name);
218
- this.emitBlank();
219
- this.emit(`def Xform "${this.sanitizeName(composition.name)}" (`);
220
- this.indentLevel++;
221
- this.emit(`kind = "component"`);
222
- this.indentLevel--;
223
- this.emit(`)
224
- {`);
225
- this.indentLevel++;
226
- if (this.options.includePhysicsScene) {
227
- this.emitPhysicsScene();
228
- this.emitBlank();
229
- }
230
- if (this.materials.size > 0) {
231
- this.emitPhysicsMaterials();
232
- this.emitBlank();
233
- }
234
- const isRobot = this.prims.some(
235
- (p) => p.apis.some((a) => a.type === "PhysicsArticulationRootAPI")
236
- );
237
- if (isRobot && this.options.enableArticulation) {
238
- this.emitArticulationRoot();
239
- } else {
240
- for (const prim of this.prims) {
241
- this.emitPrim(prim);
242
- this.emitBlank();
243
- }
244
- }
245
- for (const joint of this.joints) {
246
- this.emitJoint(joint);
247
- this.emitBlank();
248
- }
249
- const domainBlocks = composition.domainBlocks ?? [];
250
- if (domainBlocks.length > 0) {
251
- this.emitBlank();
252
- this.emit(`# === v4.2 Domain Blocks ===`);
253
- const compiled = chunkHHS6FMOU_cjs.compileDomainBlocks(
254
- domainBlocks,
255
- {
256
- material: (block) => {
257
- const mat = chunkHHS6FMOU_cjs.compileMaterialBlock(block);
258
- return chunkHHS6FMOU_cjs.materialToUSD(mat);
259
- },
260
- physics: (block) => {
261
- const phys = chunkHHS6FMOU_cjs.compilePhysicsBlock(block);
262
- const urdf = chunkHHS6FMOU_cjs.physicsToURDF(phys);
263
- return `# Physics: ${phys.keyword} "${phys.name || ""}"
264
- ` + urdf.split("\n").map((l) => `# URDF: ${l}`).join("\n");
265
- },
266
- vfx: (block) => {
267
- const ps = chunkHHS6FMOU_cjs.compileParticleBlock(block);
268
- return chunkHHS6FMOU_cjs.particlesToUSD(ps);
269
- },
270
- postfx: (block) => {
271
- const pp = chunkHHS6FMOU_cjs.compilePostProcessingBlock(block);
272
- return chunkHHS6FMOU_cjs.postProcessingToUSD(pp);
273
- },
274
- audio: (block) => {
275
- const audio = chunkHHS6FMOU_cjs.compileAudioSourceBlock(block);
276
- return chunkHHS6FMOU_cjs.audioSourceToUSD(audio);
277
- },
278
- weather: (block) => {
279
- const weather = chunkHHS6FMOU_cjs.compileWeatherBlock(block);
280
- return chunkHHS6FMOU_cjs.weatherToUSD(weather);
281
- }
282
- },
283
- (block) => `# Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}"`
284
- );
285
- for (const output of compiled) {
286
- this.emitBlank();
287
- for (const line of output.split("\n")) {
288
- this.emit(line);
289
- }
290
- }
291
- }
292
- this.indentLevel--;
293
- this.emit(`}`);
294
- return this.lines.join("\n");
295
- }
296
- // ===========================================================================
297
- // HEADER EMISSION
298
- // ===========================================================================
299
- emitHeader(name) {
300
- this.emit(`#usda 1.0`);
301
- this.emit(`(`);
302
- this.indentLevel++;
303
- this.emit(`defaultPrim = "${this.sanitizeName(name)}"`);
304
- this.emit(`doc = "Generated by HoloScript USDPhysicsCompiler for NVIDIA Isaac Sim"`);
305
- this.emit(`metersPerUnit = ${this.options.metersPerUnit}`);
306
- this.emit(`upAxis = "${this.options.upAxis}"`);
307
- this.emit(`timeCodesPerSecond = ${this.options.timeCodesPerSecond}`);
308
- this.emit(`customLayerData = {`);
309
- this.indentLevel++;
310
- this.emit(`string generator = "HoloScript v3.0"`);
311
- this.emit(`string targetRuntime = "Isaac Sim / Omniverse"`);
312
- this.indentLevel--;
313
- this.emit(`}`);
314
- this.indentLevel--;
315
- this.emit(`)`);
316
- }
317
- // ===========================================================================
318
- // PHYSICS SCENE
319
- // ===========================================================================
320
- emitPhysicsScene() {
321
- const gravityMag = Math.sqrt(
322
- this.options.gravity[0] ** 2 + this.options.gravity[1] ** 2 + this.options.gravity[2] ** 2
323
- );
324
- const gravityDir = gravityMag > 0 ? [
325
- this.options.gravity[0] / gravityMag,
326
- this.options.gravity[1] / gravityMag,
327
- this.options.gravity[2] / gravityMag
328
- ] : [0, 0, -1];
329
- this.emit(`def PhysicsScene "PhysicsScene"`);
330
- this.emit(`{`);
331
- this.indentLevel++;
332
- this.emit(
333
- `float3 physics:gravityDirection = (${gravityDir[0]}, ${gravityDir[1]}, ${gravityDir[2]})`
334
- );
335
- this.emit(`float physics:gravityMagnitude = ${gravityMag}`);
336
- this.emit(`# Isaac Sim GPU dynamics`);
337
- this.emit(`bool physxScene:enableGPUDynamics = ${this.options.enableGPUDynamics}`);
338
- this.emit(`float physxScene:timestep = ${this.options.physicsTimestep}`);
339
- this.emit(`uint physxScene:solverType = 1 # TGS solver`);
340
- this.indentLevel--;
341
- this.emit(`}`);
342
- }
343
- // ===========================================================================
344
- // PHYSICS MATERIALS
345
- // ===========================================================================
346
- emitPhysicsMaterials() {
347
- this.emit(`def Scope "PhysicsMaterials"`);
348
- this.emit(`{`);
349
- this.indentLevel++;
350
- for (const [_key, mat] of this.materials) {
351
- this.emit(`def Material "${this.escapeStringValue(mat.name, "TypeScript")}" (`);
352
- this.indentLevel++;
353
- this.emit(`prepend apiSchemas = ["PhysicsMaterialAPI"]`);
354
- this.indentLevel--;
355
- this.emit(`)`);
356
- this.emit(`{`);
357
- this.indentLevel++;
358
- this.emit(`float physics:staticFriction = ${mat.staticFriction}`);
359
- this.emit(`float physics:dynamicFriction = ${mat.dynamicFriction}`);
360
- this.emit(`float physics:restitution = ${mat.restitution}`);
361
- if (mat.density !== void 0) {
362
- this.emit(`float physics:density = ${mat.density}`);
363
- }
364
- this.indentLevel--;
365
- this.emit(`}`);
366
- }
367
- this.indentLevel--;
368
- this.emit(`}`);
369
- }
370
- // ===========================================================================
371
- // ARTICULATION ROOT
372
- // ===========================================================================
373
- emitArticulationRoot() {
374
- this.emit(`def Xform "RobotArticulation" (`);
375
- this.indentLevel++;
376
- this.emit(`prepend apiSchemas = ["PhysicsArticulationRootAPI"]`);
377
- this.indentLevel--;
378
- this.emit(`)`);
379
- this.emit(`{`);
380
- this.indentLevel++;
381
- this.emit(`bool physics:articulationEnabled = true`);
382
- this.emit(`# Isaac Sim articulation settings`);
383
- this.emit(`bool physxArticulation:enabledSelfCollisions = false`);
384
- this.emit(`uint physxArticulation:solverPositionIterationCount = 32`);
385
- this.emit(`uint physxArticulation:solverVelocityIterationCount = 1`);
386
- this.emitBlank();
387
- for (const prim of this.prims) {
388
- this.emitPrim(prim);
389
- this.emitBlank();
390
- }
391
- this.indentLevel--;
392
- this.emit(`}`);
393
- }
394
- // ===========================================================================
395
- // PRIM EMISSION
396
- // ===========================================================================
397
- emitPrim(prim) {
398
- const apiSchemas = prim.apis.map((api) => {
399
- switch (api.type) {
400
- case "PhysicsRigidBodyAPI":
401
- return "PhysicsRigidBodyAPI";
402
- case "PhysicsCollisionAPI":
403
- return "PhysicsCollisionAPI";
404
- case "PhysicsMassAPI":
405
- return "PhysicsMassAPI";
406
- case "PhysicsArticulationRootAPI":
407
- return "PhysicsArticulationRootAPI";
408
- default:
409
- return null;
410
- }
411
- }).filter(Boolean);
412
- if (apiSchemas.length > 0) {
413
- const schemasStr = apiSchemas.map((s) => `"${s}"`).join(", ");
414
- this.emit(
415
- `def ${prim.typeName} "${this.escapeStringValue(prim.name, "TypeScript")}" (`
416
- );
417
- this.indentLevel++;
418
- this.emit(`prepend apiSchemas = [${schemasStr}]`);
419
- this.indentLevel--;
420
- this.emit(`)`);
421
- } else {
422
- this.emit(
423
- `def ${prim.typeName} "${this.escapeStringValue(prim.name, "TypeScript")}"`
424
- );
425
- }
426
- this.emit(`{`);
427
- this.indentLevel++;
428
- if (prim.translation) {
429
- this.emit(
430
- `double3 xformOp:translate = (${prim.translation[0]}, ${prim.translation[1]}, ${prim.translation[2]})`
431
- );
432
- }
433
- if (prim.rotation && !this.isIdentityQuaternion(prim.rotation)) {
434
- this.emit(
435
- `quatd xformOp:orient = (${prim.rotation[3]}, ${prim.rotation[0]}, ${prim.rotation[1]}, ${prim.rotation[2]})`
436
- );
437
- }
438
- if (prim.scale && !this.isUniformScale(prim.scale)) {
439
- this.emit(`double3 xformOp:scale = (${prim.scale[0]}, ${prim.scale[1]}, ${prim.scale[2]})`);
440
- }
441
- const hasTransform = prim.translation || prim.rotation || prim.scale;
442
- if (hasTransform) {
443
- const ops = [];
444
- if (prim.translation) ops.push('"xformOp:translate"');
445
- if (prim.rotation && !this.isIdentityQuaternion(prim.rotation)) ops.push('"xformOp:orient"');
446
- if (prim.scale && !this.isUniformScale(prim.scale)) ops.push('"xformOp:scale"');
447
- this.emit(`uniform token[] xformOpOrder = [${ops.join(", ")}]`);
448
- }
449
- for (const api of prim.apis) {
450
- this.emitAPIAttributes(api);
451
- }
452
- for (const child of prim.children) {
453
- this.emitBlank();
454
- this.emitPrim(child);
455
- }
456
- this.indentLevel--;
457
- this.emit(`}`);
458
- }
459
- isIdentityQuaternion(q) {
460
- return Math.abs(q[0]) < 1e-4 && Math.abs(q[1]) < 1e-4 && Math.abs(q[2]) < 1e-4 && Math.abs(q[3] - 1) < 1e-4;
461
- }
462
- isUniformScale(s) {
463
- return Math.abs(s[0] - 1) < 1e-4 && Math.abs(s[1] - 1) < 1e-4 && Math.abs(s[2] - 1) < 1e-4;
464
- }
465
- emitAPIAttributes(api) {
466
- switch (api.type) {
467
- case "PhysicsRigidBodyAPI":
468
- this.emitBlank();
469
- this.emit(`# PhysicsRigidBodyAPI`);
470
- this.emit(`bool physics:rigidBodyEnabled = ${api.rigidBodyEnabled}`);
471
- if (api.kinematicEnabled !== void 0) {
472
- this.emit(`bool physics:kinematicEnabled = ${api.kinematicEnabled}`);
473
- }
474
- if (api.startsAsleep !== void 0) {
475
- this.emit(`bool physics:startsAsleep = ${api.startsAsleep}`);
476
- }
477
- if (api.linearVelocity) {
478
- this.emit(
479
- `float3 physics:velocity = (${api.linearVelocity[0]}, ${api.linearVelocity[1]}, ${api.linearVelocity[2]})`
480
- );
481
- }
482
- if (api.angularVelocity) {
483
- this.emit(
484
- `float3 physics:angularVelocity = (${api.angularVelocity[0]}, ${api.angularVelocity[1]}, ${api.angularVelocity[2]})`
485
- );
486
- }
487
- break;
488
- case "PhysicsCollisionAPI":
489
- this.emitBlank();
490
- this.emit(`# PhysicsCollisionAPI`);
491
- this.emit(`bool physics:collisionEnabled = ${api.collisionEnabled}`);
492
- break;
493
- case "PhysicsMassAPI":
494
- this.emitBlank();
495
- this.emit(`# PhysicsMassAPI`);
496
- this.emit(`float physics:mass = ${api.mass}`);
497
- if (api.density !== void 0) {
498
- this.emit(`float physics:density = ${api.density}`);
499
- }
500
- if (api.centerOfMass) {
501
- this.emit(
502
- `point3f physics:centerOfMass = (${api.centerOfMass[0]}, ${api.centerOfMass[1]}, ${api.centerOfMass[2]})`
503
- );
504
- }
505
- if (api.diagonalInertia) {
506
- this.emit(
507
- `float3 physics:diagonalInertia = (${api.diagonalInertia[0]}, ${api.diagonalInertia[1]}, ${api.diagonalInertia[2]})`
508
- );
509
- }
510
- break;
511
- case "PhysicsArticulationRootAPI":
512
- this.emitBlank();
513
- this.emit(`# PhysicsArticulationRootAPI`);
514
- this.emit(`bool physics:articulationEnabled = ${api.articulationEnabled}`);
515
- break;
516
- }
517
- }
518
- // ===========================================================================
519
- // JOINT EMISSION
520
- // ===========================================================================
521
- emitJoint(joint) {
522
- const jointClass = this.getUSDJointClass(joint.jointType);
523
- const hasLimits = joint.lowerLimit !== void 0 || joint.upperLimit !== void 0;
524
- const hasDrives = joint.drives && joint.drives.length > 0;
525
- this.emit(`def ${jointClass} "${joint.body0}_to_${joint.body1}_joint"`);
526
- this.emit(`{`);
527
- this.indentLevel++;
528
- this.emit(`rel physics:body0 = <${joint.body0}>`);
529
- this.emit(`rel physics:body1 = <${joint.body1}>`);
530
- if (joint.localPos0) {
531
- this.emit(
532
- `point3f physics:localPos0 = (${joint.localPos0[0]}, ${joint.localPos0[1]}, ${joint.localPos0[2]})`
533
- );
534
- }
535
- if (joint.localPos1) {
536
- this.emit(
537
- `point3f physics:localPos1 = (${joint.localPos1[0]}, ${joint.localPos1[1]}, ${joint.localPos1[2]})`
538
- );
539
- }
540
- if (joint.localRot0) {
541
- this.emit(
542
- `quatf physics:localRot0 = (${joint.localRot0[3]}, ${joint.localRot0[0]}, ${joint.localRot0[1]}, ${joint.localRot0[2]})`
543
- );
544
- }
545
- if (joint.localRot1) {
546
- this.emit(
547
- `quatf physics:localRot1 = (${joint.localRot1[3]}, ${joint.localRot1[0]}, ${joint.localRot1[1]}, ${joint.localRot1[2]})`
548
- );
549
- }
550
- if (joint.jointType === "revolute" || joint.jointType === "prismatic") {
551
- this.emit(`token physics:axis = "${joint.axis || "Z"}"`);
552
- }
553
- if (hasLimits) {
554
- this.emitBlank();
555
- this.emit(`# Joint limits`);
556
- if (joint.lowerLimit !== void 0) {
557
- this.emit(`float physics:lowerLimit = ${joint.lowerLimit}`);
558
- }
559
- if (joint.upperLimit !== void 0) {
560
- this.emit(`float physics:upperLimit = ${joint.upperLimit}`);
561
- }
562
- }
563
- if (hasDrives) {
564
- for (const drive of joint.drives) {
565
- this.emitDrive(drive, joint.axis || "Z");
566
- }
567
- }
568
- this.indentLevel--;
569
- this.emit(`}`);
570
- }
571
- getUSDJointClass(jointType) {
572
- switch (jointType) {
573
- case "revolute":
574
- return "PhysicsRevoluteJoint";
575
- case "prismatic":
576
- return "PhysicsPrismaticJoint";
577
- case "spherical":
578
- return "PhysicsSphericalJoint";
579
- case "fixed":
580
- return "PhysicsFixedJoint";
581
- case "d6":
582
- return "PhysicsD6Joint";
583
- default:
584
- return "PhysicsFixedJoint";
585
- }
586
- }
587
- emitDrive(drive, axis) {
588
- const driveAttr = `physics:${axis.toLowerCase()}Drive`;
589
- this.emitBlank();
590
- this.emit(`# PhysicsDriveAPI`);
591
- this.emit(`token ${driveAttr}:type = "${drive.driveType}"`);
592
- if (drive.maxForce !== void 0) {
593
- this.emit(`float ${driveAttr}:maxForce = ${drive.maxForce}`);
594
- }
595
- if (drive.targetPosition !== void 0) {
596
- this.emit(`float ${driveAttr}:targetPosition = ${drive.targetPosition}`);
597
- }
598
- if (drive.targetVelocity !== void 0) {
599
- this.emit(`float ${driveAttr}:targetVelocity = ${drive.targetVelocity}`);
600
- }
601
- if (drive.stiffness !== void 0) {
602
- this.emit(`float ${driveAttr}:stiffness = ${drive.stiffness}`);
603
- }
604
- if (drive.damping !== void 0) {
605
- this.emit(`float ${driveAttr}:damping = ${drive.damping}`);
606
- }
607
- }
608
- // ===========================================================================
609
- // EXTRACTION FROM COMPOSITION
610
- // ===========================================================================
611
- extractFromComposition(composition) {
612
- this.materials.set("default", {
613
- path: "/PhysicsMaterials/DefaultMaterial",
614
- name: "DefaultMaterial",
615
- staticFriction: this.options.defaultStaticFriction,
616
- dynamicFriction: this.options.defaultDynamicFriction,
617
- restitution: this.options.defaultRestitution
618
- });
619
- if (composition.objects) {
620
- for (const obj of composition.objects) {
621
- const prim = this.processObject(obj);
622
- if (prim) {
623
- this.prims.push(prim);
624
- }
625
- }
626
- }
627
- if (composition.spatialGroups) {
628
- for (const group of composition.spatialGroups) {
629
- const groupPrims = this.processSpatialGroup(group);
630
- this.prims.push(...groupPrims);
631
- }
632
- }
633
- }
634
- processObject(obj, parentPath) {
635
- const name = this.sanitizeName(obj.name);
636
- const path = parentPath ? `${parentPath}/${name}` : name;
637
- const hasPhysics = this.hasTrait(obj, "physics") || this.hasTrait(obj, "rigid");
638
- const hasCollider = this.hasTrait(obj, "collidable") || this.hasTrait(obj, "trigger");
639
- const isKinematic = this.hasTrait(obj, "kinematic");
640
- const isArticulationRoot = this.hasTrait(obj, "articulation_root");
641
- const physicsConfig = this.getTraitConfig(obj, "physics") || {};
642
- const jointConfig = this.getTraitConfig(obj, "joint");
643
- const geometry = this.extractGeometry(obj);
644
- const position = this.extractPosition(obj);
645
- const rotation = this.extractRotation(obj);
646
- const scale = this.extractScale(obj);
647
- let typeName = "Xform";
648
- if (geometry) {
649
- typeName = geometry.type === "Reference" ? "Xform" : geometry.type;
650
- }
651
- const apis = [];
652
- if (hasPhysics) {
653
- apis.push({
654
- type: "PhysicsRigidBodyAPI",
655
- rigidBodyEnabled: true,
656
- kinematicEnabled: isKinematic
657
- });
658
- }
659
- if (hasCollider || hasPhysics) {
660
- apis.push({
661
- type: "PhysicsCollisionAPI",
662
- collisionEnabled: true
663
- });
664
- }
665
- if (hasPhysics) {
666
- const mass = physicsConfig.mass ?? this.options.defaultMass;
667
- apis.push({
668
- type: "PhysicsMassAPI",
669
- mass
670
- });
671
- }
672
- if (isArticulationRoot) {
673
- apis.push({
674
- type: "PhysicsArticulationRootAPI",
675
- articulationEnabled: true
676
- });
677
- }
678
- if (jointConfig) {
679
- const jointType = this.mapJointType(String(jointConfig.type || "fixed"));
680
- const parentBody = String(jointConfig.connectedBody || "base_link");
681
- const axis = this.mapAxis(jointConfig.axis);
682
- const joint = {
683
- type: "PhysicsJoint",
684
- jointType,
685
- body0: parentBody,
686
- body1: `RobotArticulation/${name}`,
687
- axis
688
- };
689
- if (jointConfig.lowerLimit !== void 0 || jointConfig.upperLimit !== void 0) {
690
- const isRevolute = jointType === "revolute";
691
- joint.lowerLimit = jointConfig.lowerLimit !== void 0 ? isRevolute ? Number(jointConfig.lowerLimit) * (Math.PI / 180) : Number(jointConfig.lowerLimit) : void 0;
692
- joint.upperLimit = jointConfig.upperLimit !== void 0 ? isRevolute ? Number(jointConfig.upperLimit) * (Math.PI / 180) : Number(jointConfig.upperLimit) : void 0;
693
- }
694
- if (jointConfig.motor) {
695
- const motorConfig = jointConfig.motor;
696
- joint.drives = [
697
- {
698
- type: "PhysicsDriveAPI",
699
- driveType: motorConfig.type || "position",
700
- maxForce: motorConfig.maxForce,
701
- stiffness: motorConfig.stiffness,
702
- damping: motorConfig.damping
703
- }
704
- ];
705
- }
706
- this.joints.push(joint);
707
- }
708
- return {
709
- path,
710
- name,
711
- typeName,
712
- translation: position,
713
- rotation,
714
- scale,
715
- children: [],
716
- apis
717
- };
718
- }
719
- processSpatialGroup(group) {
720
- const prims = [];
721
- const groupName = this.sanitizeName(group.name);
722
- const groupPrim = {
723
- path: groupName,
724
- name: groupName,
725
- typeName: "Xform",
726
- children: [],
727
- apis: []
728
- };
729
- const hasRobotObjects = group.objects?.some((obj) => this.hasTrait(obj, "joint"));
730
- if (hasRobotObjects) {
731
- groupPrim.apis.push({
732
- type: "PhysicsArticulationRootAPI",
733
- articulationEnabled: true
734
- });
735
- }
736
- if (group.objects) {
737
- for (const obj of group.objects) {
738
- const childPrim = this.processObject(obj, groupName);
739
- if (childPrim) {
740
- groupPrim.children.push(childPrim);
741
- }
742
- }
743
- }
744
- prims.push(groupPrim);
745
- return prims;
746
- }
747
- };
748
- function compileToUSDPhysics(composition, options) {
749
- const compiler = new USDPhysicsCompiler(options);
750
- return compiler.compile(composition, "system");
751
- }
752
- function compileForIsaacSim(composition, options) {
753
- const isaacOptions = {
754
- upAxis: "Z",
755
- metersPerUnit: 1,
756
- enableGPUDynamics: true,
757
- enableArticulation: true,
758
- timeCodesPerSecond: 60,
759
- ...options
760
- };
761
- const compiler = new USDPhysicsCompiler(isaacOptions);
762
- return compiler.compile(composition, "system");
763
- }
764
-
765
- exports.USDPhysicsCompiler = USDPhysicsCompiler;
766
- exports.compileForIsaacSim = compileForIsaacSim;
767
- exports.compileToUSDPhysics = compileToUSDPhysics;
768
- //# sourceMappingURL=chunk-VJVCD5T5.cjs.map
769
- //# sourceMappingURL=chunk-VJVCD5T5.cjs.map