@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,765 +0,0 @@
1
- import { init_DomainBlockCompilerMixin, compileDomainBlocks, compileWeatherBlock, weatherToUSD, compileAudioSourceBlock, audioSourceToUSD, compilePostProcessingBlock, postProcessingToUSD, compileParticleBlock, particlesToUSD, compilePhysicsBlock, physicsToURDF, compileMaterialBlock, materialToUSD } from './chunk-KDB6BUMB.js';
2
- import { init_CompilerBase, init_ANSNamespace, CompilerBase, ANSCapabilityPath } from './chunk-QWKUKVRE.js';
3
-
4
- // src/compiler/USDPhysicsCompiler.ts
5
- init_CompilerBase();
6
- init_ANSNamespace();
7
- init_DomainBlockCompilerMixin();
8
- var USDPhysicsCompiler = class extends CompilerBase {
9
- constructor(options = {}) {
10
- super();
11
- this.compilerName = "USDPhysicsCompiler";
12
- this.lines = [];
13
- this.indentLevel = 0;
14
- this.prims = [];
15
- this.joints = [];
16
- this.materials = /* @__PURE__ */ new Map();
17
- this.options = {
18
- stageName: options.stageName ?? "HoloScriptPhysicsStage",
19
- upAxis: options.upAxis ?? "Z",
20
- // Isaac Sim default
21
- metersPerUnit: options.metersPerUnit ?? 1,
22
- timeCodesPerSecond: options.timeCodesPerSecond ?? 60,
23
- includePhysicsScene: options.includePhysicsScene ?? true,
24
- gravity: options.gravity ?? [0, 0, -9.81],
25
- physicsTimestep: options.physicsTimestep ?? 1 / 60,
26
- enableGPUDynamics: options.enableGPUDynamics ?? true,
27
- includeCollision: options.includeCollision ?? true,
28
- includeVisual: options.includeVisual ?? true,
29
- defaultMass: options.defaultMass ?? 1,
30
- defaultStaticFriction: options.defaultStaticFriction ?? 0.5,
31
- defaultDynamicFriction: options.defaultDynamicFriction ?? 0.5,
32
- defaultRestitution: options.defaultRestitution ?? 0.1,
33
- enableArticulation: options.enableArticulation ?? true
34
- };
35
- }
36
- getRequiredCapability() {
37
- return ANSCapabilityPath.USD;
38
- }
39
- // ===========================================================================
40
- // HELPER METHODS
41
- // ===========================================================================
42
- /** Get trait name from either string or object format */
43
- getTraitName(trait) {
44
- return typeof trait === "string" ? trait : trait.name;
45
- }
46
- /** Check if object has a specific trait */
47
- hasTrait(obj, traitName) {
48
- return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
49
- }
50
- /** Get trait configuration object */
51
- getTraitConfig(obj, traitName) {
52
- const trait = obj.traits?.find((t) => this.getTraitName(t) === traitName);
53
- if (!trait) return void 0;
54
- if (typeof trait === "string") return {};
55
- const traitObj = trait;
56
- if ("config" in traitObj && typeof traitObj.config === "object") {
57
- return traitObj.config;
58
- }
59
- const { name: _name, ...rest } = traitObj;
60
- if (rest.type === "ObjectTrait") {
61
- const { type: _type, ...config } = rest;
62
- return config;
63
- }
64
- return rest;
65
- }
66
- /** Sanitize name for USD path */
67
- sanitizeName(name) {
68
- let sanitized = name.replace(/[^a-zA-Z0-9_]/g, "_");
69
- if (/^[0-9]/.test(sanitized)) {
70
- sanitized = "_" + sanitized;
71
- }
72
- return sanitized;
73
- }
74
- /** Emit a line with current indent */
75
- emit(line) {
76
- const indent = " ".repeat(this.indentLevel);
77
- this.lines.push(indent + line);
78
- }
79
- /** Emit empty line */
80
- emitBlank() {
81
- this.lines.push("");
82
- }
83
- /** Get property value from object properties array */
84
- getPropertyValue(obj, key) {
85
- const prop = obj.properties?.find((p) => p.key === key);
86
- return prop?.value;
87
- }
88
- /** Extract position from object properties */
89
- extractPosition(obj) {
90
- const pos = this.getPropertyValue(obj, "position");
91
- if (Array.isArray(pos) && pos.length >= 3) {
92
- return [Number(pos[0]) || 0, Number(pos[1]) || 0, Number(pos[2]) || 0];
93
- }
94
- return [0, 0, 0];
95
- }
96
- /** Extract rotation as quaternion from object properties */
97
- extractRotation(obj) {
98
- const rot = this.getPropertyValue(obj, "rotation");
99
- if (Array.isArray(rot) && rot.length >= 3) {
100
- const euler = [
101
- (Number(rot[0]) || 0) * (Math.PI / 180),
102
- (Number(rot[1]) || 0) * (Math.PI / 180),
103
- (Number(rot[2]) || 0) * (Math.PI / 180)
104
- ];
105
- return this.eulerToQuaternion(euler[0], euler[1], euler[2]);
106
- }
107
- return [0, 0, 0, 1];
108
- }
109
- /** Convert Euler angles (radians) to quaternion */
110
- eulerToQuaternion(roll, pitch, yaw) {
111
- const cy = Math.cos(yaw * 0.5);
112
- const sy = Math.sin(yaw * 0.5);
113
- const cp = Math.cos(pitch * 0.5);
114
- const sp = Math.sin(pitch * 0.5);
115
- const cr = Math.cos(roll * 0.5);
116
- const sr = Math.sin(roll * 0.5);
117
- return [
118
- sr * cp * cy - cr * sp * sy,
119
- // x
120
- cr * sp * cy + sr * cp * sy,
121
- // y
122
- cr * cp * sy - sr * sp * cy,
123
- // z
124
- cr * cp * cy + sr * sp * sy
125
- // w
126
- ];
127
- }
128
- /** Extract scale from object properties */
129
- extractScale(obj) {
130
- const scale = this.getPropertyValue(obj, "scale");
131
- if (Array.isArray(scale) && scale.length >= 3) {
132
- return [Number(scale[0]) || 1, Number(scale[1]) || 1, Number(scale[2]) || 1];
133
- }
134
- if (typeof scale === "number") {
135
- return [scale, scale, scale];
136
- }
137
- return [1, 1, 1];
138
- }
139
- /** Extract geometry type from object */
140
- extractGeometry(obj) {
141
- const geom = this.getPropertyValue(obj, "geometry");
142
- if (!geom) return void 0;
143
- const geomType = String(geom);
144
- const scale = this.extractScale(obj);
145
- switch (geomType) {
146
- case "cube":
147
- case "box":
148
- return { type: "Cube", size: scale };
149
- case "sphere":
150
- return { type: "Sphere", radius: Math.max(...scale) / 2 };
151
- case "cylinder":
152
- return { type: "Cylinder", radius: Math.max(scale[0], scale[2]) / 2 };
153
- case "capsule":
154
- return { type: "Capsule", radius: Math.max(scale[0], scale[2]) / 2 };
155
- case "cone":
156
- return { type: "Cone", radius: Math.max(scale[0], scale[2]) / 2 };
157
- default:
158
- if (geomType.endsWith(".usd") || geomType.endsWith(".usda") || geomType.endsWith(".usdc")) {
159
- return { type: "Reference", size: scale };
160
- }
161
- return { type: "Cube", size: scale };
162
- }
163
- }
164
- /** Map HoloScript joint types to USD joint types */
165
- mapJointType(holoType) {
166
- switch (holoType) {
167
- case "hinge":
168
- case "revolute":
169
- return "revolute";
170
- case "slider":
171
- case "prismatic":
172
- return "prismatic";
173
- case "ball":
174
- case "spherical":
175
- return "spherical";
176
- case "fixed":
177
- return "fixed";
178
- case "6dof":
179
- case "d6":
180
- return "d6";
181
- default:
182
- return "fixed";
183
- }
184
- }
185
- /** Map axis string to USD axis */
186
- mapAxis(axis) {
187
- if (Array.isArray(axis)) {
188
- const absX = Math.abs(Number(axis[0]) || 0);
189
- const absY = Math.abs(Number(axis[1]) || 0);
190
- const absZ = Math.abs(Number(axis[2]) || 0);
191
- if (absX >= absY && absX >= absZ) return "X";
192
- if (absY >= absX && absY >= absZ) return "Y";
193
- return "Z";
194
- }
195
- const axisStr = String(axis).toUpperCase();
196
- if (axisStr === "X" || axisStr === "Y" || axisStr === "Z") {
197
- return axisStr;
198
- }
199
- return "Z";
200
- }
201
- // ===========================================================================
202
- // COMPILATION
203
- // ===========================================================================
204
- /**
205
- * Compile HoloScript composition to USD ASCII with physics schemas
206
- */
207
- compile(composition, agentToken, outputPath) {
208
- this.validateCompilerAccess(agentToken, outputPath);
209
- this.lines = [];
210
- this.prims = [];
211
- this.joints = [];
212
- this.materials.clear();
213
- this.indentLevel = 0;
214
- this.extractFromComposition(composition);
215
- this.emitHeader(composition.name);
216
- this.emitBlank();
217
- this.emit(`def Xform "${this.sanitizeName(composition.name)}" (`);
218
- this.indentLevel++;
219
- this.emit(`kind = "component"`);
220
- this.indentLevel--;
221
- this.emit(`)
222
- {`);
223
- this.indentLevel++;
224
- if (this.options.includePhysicsScene) {
225
- this.emitPhysicsScene();
226
- this.emitBlank();
227
- }
228
- if (this.materials.size > 0) {
229
- this.emitPhysicsMaterials();
230
- this.emitBlank();
231
- }
232
- const isRobot = this.prims.some(
233
- (p) => p.apis.some((a) => a.type === "PhysicsArticulationRootAPI")
234
- );
235
- if (isRobot && this.options.enableArticulation) {
236
- this.emitArticulationRoot();
237
- } else {
238
- for (const prim of this.prims) {
239
- this.emitPrim(prim);
240
- this.emitBlank();
241
- }
242
- }
243
- for (const joint of this.joints) {
244
- this.emitJoint(joint);
245
- this.emitBlank();
246
- }
247
- const domainBlocks = composition.domainBlocks ?? [];
248
- if (domainBlocks.length > 0) {
249
- this.emitBlank();
250
- this.emit(`# === v4.2 Domain Blocks ===`);
251
- const compiled = compileDomainBlocks(
252
- domainBlocks,
253
- {
254
- material: (block) => {
255
- const mat = compileMaterialBlock(block);
256
- return materialToUSD(mat);
257
- },
258
- physics: (block) => {
259
- const phys = compilePhysicsBlock(block);
260
- const urdf = physicsToURDF(phys);
261
- return `# Physics: ${phys.keyword} "${phys.name || ""}"
262
- ` + urdf.split("\n").map((l) => `# URDF: ${l}`).join("\n");
263
- },
264
- vfx: (block) => {
265
- const ps = compileParticleBlock(block);
266
- return particlesToUSD(ps);
267
- },
268
- postfx: (block) => {
269
- const pp = compilePostProcessingBlock(block);
270
- return postProcessingToUSD(pp);
271
- },
272
- audio: (block) => {
273
- const audio = compileAudioSourceBlock(block);
274
- return audioSourceToUSD(audio);
275
- },
276
- weather: (block) => {
277
- const weather = compileWeatherBlock(block);
278
- return weatherToUSD(weather);
279
- }
280
- },
281
- (block) => `# Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}"`
282
- );
283
- for (const output of compiled) {
284
- this.emitBlank();
285
- for (const line of output.split("\n")) {
286
- this.emit(line);
287
- }
288
- }
289
- }
290
- this.indentLevel--;
291
- this.emit(`}`);
292
- return this.lines.join("\n");
293
- }
294
- // ===========================================================================
295
- // HEADER EMISSION
296
- // ===========================================================================
297
- emitHeader(name) {
298
- this.emit(`#usda 1.0`);
299
- this.emit(`(`);
300
- this.indentLevel++;
301
- this.emit(`defaultPrim = "${this.sanitizeName(name)}"`);
302
- this.emit(`doc = "Generated by HoloScript USDPhysicsCompiler for NVIDIA Isaac Sim"`);
303
- this.emit(`metersPerUnit = ${this.options.metersPerUnit}`);
304
- this.emit(`upAxis = "${this.options.upAxis}"`);
305
- this.emit(`timeCodesPerSecond = ${this.options.timeCodesPerSecond}`);
306
- this.emit(`customLayerData = {`);
307
- this.indentLevel++;
308
- this.emit(`string generator = "HoloScript v3.0"`);
309
- this.emit(`string targetRuntime = "Isaac Sim / Omniverse"`);
310
- this.indentLevel--;
311
- this.emit(`}`);
312
- this.indentLevel--;
313
- this.emit(`)`);
314
- }
315
- // ===========================================================================
316
- // PHYSICS SCENE
317
- // ===========================================================================
318
- emitPhysicsScene() {
319
- const gravityMag = Math.sqrt(
320
- this.options.gravity[0] ** 2 + this.options.gravity[1] ** 2 + this.options.gravity[2] ** 2
321
- );
322
- const gravityDir = gravityMag > 0 ? [
323
- this.options.gravity[0] / gravityMag,
324
- this.options.gravity[1] / gravityMag,
325
- this.options.gravity[2] / gravityMag
326
- ] : [0, 0, -1];
327
- this.emit(`def PhysicsScene "PhysicsScene"`);
328
- this.emit(`{`);
329
- this.indentLevel++;
330
- this.emit(
331
- `float3 physics:gravityDirection = (${gravityDir[0]}, ${gravityDir[1]}, ${gravityDir[2]})`
332
- );
333
- this.emit(`float physics:gravityMagnitude = ${gravityMag}`);
334
- this.emit(`# Isaac Sim GPU dynamics`);
335
- this.emit(`bool physxScene:enableGPUDynamics = ${this.options.enableGPUDynamics}`);
336
- this.emit(`float physxScene:timestep = ${this.options.physicsTimestep}`);
337
- this.emit(`uint physxScene:solverType = 1 # TGS solver`);
338
- this.indentLevel--;
339
- this.emit(`}`);
340
- }
341
- // ===========================================================================
342
- // PHYSICS MATERIALS
343
- // ===========================================================================
344
- emitPhysicsMaterials() {
345
- this.emit(`def Scope "PhysicsMaterials"`);
346
- this.emit(`{`);
347
- this.indentLevel++;
348
- for (const [_key, mat] of this.materials) {
349
- this.emit(`def Material "${this.escapeStringValue(mat.name, "TypeScript")}" (`);
350
- this.indentLevel++;
351
- this.emit(`prepend apiSchemas = ["PhysicsMaterialAPI"]`);
352
- this.indentLevel--;
353
- this.emit(`)`);
354
- this.emit(`{`);
355
- this.indentLevel++;
356
- this.emit(`float physics:staticFriction = ${mat.staticFriction}`);
357
- this.emit(`float physics:dynamicFriction = ${mat.dynamicFriction}`);
358
- this.emit(`float physics:restitution = ${mat.restitution}`);
359
- if (mat.density !== void 0) {
360
- this.emit(`float physics:density = ${mat.density}`);
361
- }
362
- this.indentLevel--;
363
- this.emit(`}`);
364
- }
365
- this.indentLevel--;
366
- this.emit(`}`);
367
- }
368
- // ===========================================================================
369
- // ARTICULATION ROOT
370
- // ===========================================================================
371
- emitArticulationRoot() {
372
- this.emit(`def Xform "RobotArticulation" (`);
373
- this.indentLevel++;
374
- this.emit(`prepend apiSchemas = ["PhysicsArticulationRootAPI"]`);
375
- this.indentLevel--;
376
- this.emit(`)`);
377
- this.emit(`{`);
378
- this.indentLevel++;
379
- this.emit(`bool physics:articulationEnabled = true`);
380
- this.emit(`# Isaac Sim articulation settings`);
381
- this.emit(`bool physxArticulation:enabledSelfCollisions = false`);
382
- this.emit(`uint physxArticulation:solverPositionIterationCount = 32`);
383
- this.emit(`uint physxArticulation:solverVelocityIterationCount = 1`);
384
- this.emitBlank();
385
- for (const prim of this.prims) {
386
- this.emitPrim(prim);
387
- this.emitBlank();
388
- }
389
- this.indentLevel--;
390
- this.emit(`}`);
391
- }
392
- // ===========================================================================
393
- // PRIM EMISSION
394
- // ===========================================================================
395
- emitPrim(prim) {
396
- const apiSchemas = prim.apis.map((api) => {
397
- switch (api.type) {
398
- case "PhysicsRigidBodyAPI":
399
- return "PhysicsRigidBodyAPI";
400
- case "PhysicsCollisionAPI":
401
- return "PhysicsCollisionAPI";
402
- case "PhysicsMassAPI":
403
- return "PhysicsMassAPI";
404
- case "PhysicsArticulationRootAPI":
405
- return "PhysicsArticulationRootAPI";
406
- default:
407
- return null;
408
- }
409
- }).filter(Boolean);
410
- if (apiSchemas.length > 0) {
411
- const schemasStr = apiSchemas.map((s) => `"${s}"`).join(", ");
412
- this.emit(
413
- `def ${prim.typeName} "${this.escapeStringValue(prim.name, "TypeScript")}" (`
414
- );
415
- this.indentLevel++;
416
- this.emit(`prepend apiSchemas = [${schemasStr}]`);
417
- this.indentLevel--;
418
- this.emit(`)`);
419
- } else {
420
- this.emit(
421
- `def ${prim.typeName} "${this.escapeStringValue(prim.name, "TypeScript")}"`
422
- );
423
- }
424
- this.emit(`{`);
425
- this.indentLevel++;
426
- if (prim.translation) {
427
- this.emit(
428
- `double3 xformOp:translate = (${prim.translation[0]}, ${prim.translation[1]}, ${prim.translation[2]})`
429
- );
430
- }
431
- if (prim.rotation && !this.isIdentityQuaternion(prim.rotation)) {
432
- this.emit(
433
- `quatd xformOp:orient = (${prim.rotation[3]}, ${prim.rotation[0]}, ${prim.rotation[1]}, ${prim.rotation[2]})`
434
- );
435
- }
436
- if (prim.scale && !this.isUniformScale(prim.scale)) {
437
- this.emit(`double3 xformOp:scale = (${prim.scale[0]}, ${prim.scale[1]}, ${prim.scale[2]})`);
438
- }
439
- const hasTransform = prim.translation || prim.rotation || prim.scale;
440
- if (hasTransform) {
441
- const ops = [];
442
- if (prim.translation) ops.push('"xformOp:translate"');
443
- if (prim.rotation && !this.isIdentityQuaternion(prim.rotation)) ops.push('"xformOp:orient"');
444
- if (prim.scale && !this.isUniformScale(prim.scale)) ops.push('"xformOp:scale"');
445
- this.emit(`uniform token[] xformOpOrder = [${ops.join(", ")}]`);
446
- }
447
- for (const api of prim.apis) {
448
- this.emitAPIAttributes(api);
449
- }
450
- for (const child of prim.children) {
451
- this.emitBlank();
452
- this.emitPrim(child);
453
- }
454
- this.indentLevel--;
455
- this.emit(`}`);
456
- }
457
- isIdentityQuaternion(q) {
458
- 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;
459
- }
460
- isUniformScale(s) {
461
- return Math.abs(s[0] - 1) < 1e-4 && Math.abs(s[1] - 1) < 1e-4 && Math.abs(s[2] - 1) < 1e-4;
462
- }
463
- emitAPIAttributes(api) {
464
- switch (api.type) {
465
- case "PhysicsRigidBodyAPI":
466
- this.emitBlank();
467
- this.emit(`# PhysicsRigidBodyAPI`);
468
- this.emit(`bool physics:rigidBodyEnabled = ${api.rigidBodyEnabled}`);
469
- if (api.kinematicEnabled !== void 0) {
470
- this.emit(`bool physics:kinematicEnabled = ${api.kinematicEnabled}`);
471
- }
472
- if (api.startsAsleep !== void 0) {
473
- this.emit(`bool physics:startsAsleep = ${api.startsAsleep}`);
474
- }
475
- if (api.linearVelocity) {
476
- this.emit(
477
- `float3 physics:velocity = (${api.linearVelocity[0]}, ${api.linearVelocity[1]}, ${api.linearVelocity[2]})`
478
- );
479
- }
480
- if (api.angularVelocity) {
481
- this.emit(
482
- `float3 physics:angularVelocity = (${api.angularVelocity[0]}, ${api.angularVelocity[1]}, ${api.angularVelocity[2]})`
483
- );
484
- }
485
- break;
486
- case "PhysicsCollisionAPI":
487
- this.emitBlank();
488
- this.emit(`# PhysicsCollisionAPI`);
489
- this.emit(`bool physics:collisionEnabled = ${api.collisionEnabled}`);
490
- break;
491
- case "PhysicsMassAPI":
492
- this.emitBlank();
493
- this.emit(`# PhysicsMassAPI`);
494
- this.emit(`float physics:mass = ${api.mass}`);
495
- if (api.density !== void 0) {
496
- this.emit(`float physics:density = ${api.density}`);
497
- }
498
- if (api.centerOfMass) {
499
- this.emit(
500
- `point3f physics:centerOfMass = (${api.centerOfMass[0]}, ${api.centerOfMass[1]}, ${api.centerOfMass[2]})`
501
- );
502
- }
503
- if (api.diagonalInertia) {
504
- this.emit(
505
- `float3 physics:diagonalInertia = (${api.diagonalInertia[0]}, ${api.diagonalInertia[1]}, ${api.diagonalInertia[2]})`
506
- );
507
- }
508
- break;
509
- case "PhysicsArticulationRootAPI":
510
- this.emitBlank();
511
- this.emit(`# PhysicsArticulationRootAPI`);
512
- this.emit(`bool physics:articulationEnabled = ${api.articulationEnabled}`);
513
- break;
514
- }
515
- }
516
- // ===========================================================================
517
- // JOINT EMISSION
518
- // ===========================================================================
519
- emitJoint(joint) {
520
- const jointClass = this.getUSDJointClass(joint.jointType);
521
- const hasLimits = joint.lowerLimit !== void 0 || joint.upperLimit !== void 0;
522
- const hasDrives = joint.drives && joint.drives.length > 0;
523
- this.emit(`def ${jointClass} "${joint.body0}_to_${joint.body1}_joint"`);
524
- this.emit(`{`);
525
- this.indentLevel++;
526
- this.emit(`rel physics:body0 = <${joint.body0}>`);
527
- this.emit(`rel physics:body1 = <${joint.body1}>`);
528
- if (joint.localPos0) {
529
- this.emit(
530
- `point3f physics:localPos0 = (${joint.localPos0[0]}, ${joint.localPos0[1]}, ${joint.localPos0[2]})`
531
- );
532
- }
533
- if (joint.localPos1) {
534
- this.emit(
535
- `point3f physics:localPos1 = (${joint.localPos1[0]}, ${joint.localPos1[1]}, ${joint.localPos1[2]})`
536
- );
537
- }
538
- if (joint.localRot0) {
539
- this.emit(
540
- `quatf physics:localRot0 = (${joint.localRot0[3]}, ${joint.localRot0[0]}, ${joint.localRot0[1]}, ${joint.localRot0[2]})`
541
- );
542
- }
543
- if (joint.localRot1) {
544
- this.emit(
545
- `quatf physics:localRot1 = (${joint.localRot1[3]}, ${joint.localRot1[0]}, ${joint.localRot1[1]}, ${joint.localRot1[2]})`
546
- );
547
- }
548
- if (joint.jointType === "revolute" || joint.jointType === "prismatic") {
549
- this.emit(`token physics:axis = "${joint.axis || "Z"}"`);
550
- }
551
- if (hasLimits) {
552
- this.emitBlank();
553
- this.emit(`# Joint limits`);
554
- if (joint.lowerLimit !== void 0) {
555
- this.emit(`float physics:lowerLimit = ${joint.lowerLimit}`);
556
- }
557
- if (joint.upperLimit !== void 0) {
558
- this.emit(`float physics:upperLimit = ${joint.upperLimit}`);
559
- }
560
- }
561
- if (hasDrives) {
562
- for (const drive of joint.drives) {
563
- this.emitDrive(drive, joint.axis || "Z");
564
- }
565
- }
566
- this.indentLevel--;
567
- this.emit(`}`);
568
- }
569
- getUSDJointClass(jointType) {
570
- switch (jointType) {
571
- case "revolute":
572
- return "PhysicsRevoluteJoint";
573
- case "prismatic":
574
- return "PhysicsPrismaticJoint";
575
- case "spherical":
576
- return "PhysicsSphericalJoint";
577
- case "fixed":
578
- return "PhysicsFixedJoint";
579
- case "d6":
580
- return "PhysicsD6Joint";
581
- default:
582
- return "PhysicsFixedJoint";
583
- }
584
- }
585
- emitDrive(drive, axis) {
586
- const driveAttr = `physics:${axis.toLowerCase()}Drive`;
587
- this.emitBlank();
588
- this.emit(`# PhysicsDriveAPI`);
589
- this.emit(`token ${driveAttr}:type = "${drive.driveType}"`);
590
- if (drive.maxForce !== void 0) {
591
- this.emit(`float ${driveAttr}:maxForce = ${drive.maxForce}`);
592
- }
593
- if (drive.targetPosition !== void 0) {
594
- this.emit(`float ${driveAttr}:targetPosition = ${drive.targetPosition}`);
595
- }
596
- if (drive.targetVelocity !== void 0) {
597
- this.emit(`float ${driveAttr}:targetVelocity = ${drive.targetVelocity}`);
598
- }
599
- if (drive.stiffness !== void 0) {
600
- this.emit(`float ${driveAttr}:stiffness = ${drive.stiffness}`);
601
- }
602
- if (drive.damping !== void 0) {
603
- this.emit(`float ${driveAttr}:damping = ${drive.damping}`);
604
- }
605
- }
606
- // ===========================================================================
607
- // EXTRACTION FROM COMPOSITION
608
- // ===========================================================================
609
- extractFromComposition(composition) {
610
- this.materials.set("default", {
611
- path: "/PhysicsMaterials/DefaultMaterial",
612
- name: "DefaultMaterial",
613
- staticFriction: this.options.defaultStaticFriction,
614
- dynamicFriction: this.options.defaultDynamicFriction,
615
- restitution: this.options.defaultRestitution
616
- });
617
- if (composition.objects) {
618
- for (const obj of composition.objects) {
619
- const prim = this.processObject(obj);
620
- if (prim) {
621
- this.prims.push(prim);
622
- }
623
- }
624
- }
625
- if (composition.spatialGroups) {
626
- for (const group of composition.spatialGroups) {
627
- const groupPrims = this.processSpatialGroup(group);
628
- this.prims.push(...groupPrims);
629
- }
630
- }
631
- }
632
- processObject(obj, parentPath) {
633
- const name = this.sanitizeName(obj.name);
634
- const path = parentPath ? `${parentPath}/${name}` : name;
635
- const hasPhysics = this.hasTrait(obj, "physics") || this.hasTrait(obj, "rigid");
636
- const hasCollider = this.hasTrait(obj, "collidable") || this.hasTrait(obj, "trigger");
637
- const isKinematic = this.hasTrait(obj, "kinematic");
638
- const isArticulationRoot = this.hasTrait(obj, "articulation_root");
639
- const physicsConfig = this.getTraitConfig(obj, "physics") || {};
640
- const jointConfig = this.getTraitConfig(obj, "joint");
641
- const geometry = this.extractGeometry(obj);
642
- const position = this.extractPosition(obj);
643
- const rotation = this.extractRotation(obj);
644
- const scale = this.extractScale(obj);
645
- let typeName = "Xform";
646
- if (geometry) {
647
- typeName = geometry.type === "Reference" ? "Xform" : geometry.type;
648
- }
649
- const apis = [];
650
- if (hasPhysics) {
651
- apis.push({
652
- type: "PhysicsRigidBodyAPI",
653
- rigidBodyEnabled: true,
654
- kinematicEnabled: isKinematic
655
- });
656
- }
657
- if (hasCollider || hasPhysics) {
658
- apis.push({
659
- type: "PhysicsCollisionAPI",
660
- collisionEnabled: true
661
- });
662
- }
663
- if (hasPhysics) {
664
- const mass = physicsConfig.mass ?? this.options.defaultMass;
665
- apis.push({
666
- type: "PhysicsMassAPI",
667
- mass
668
- });
669
- }
670
- if (isArticulationRoot) {
671
- apis.push({
672
- type: "PhysicsArticulationRootAPI",
673
- articulationEnabled: true
674
- });
675
- }
676
- if (jointConfig) {
677
- const jointType = this.mapJointType(String(jointConfig.type || "fixed"));
678
- const parentBody = String(jointConfig.connectedBody || "base_link");
679
- const axis = this.mapAxis(jointConfig.axis);
680
- const joint = {
681
- type: "PhysicsJoint",
682
- jointType,
683
- body0: parentBody,
684
- body1: `RobotArticulation/${name}`,
685
- axis
686
- };
687
- if (jointConfig.lowerLimit !== void 0 || jointConfig.upperLimit !== void 0) {
688
- const isRevolute = jointType === "revolute";
689
- joint.lowerLimit = jointConfig.lowerLimit !== void 0 ? isRevolute ? Number(jointConfig.lowerLimit) * (Math.PI / 180) : Number(jointConfig.lowerLimit) : void 0;
690
- joint.upperLimit = jointConfig.upperLimit !== void 0 ? isRevolute ? Number(jointConfig.upperLimit) * (Math.PI / 180) : Number(jointConfig.upperLimit) : void 0;
691
- }
692
- if (jointConfig.motor) {
693
- const motorConfig = jointConfig.motor;
694
- joint.drives = [
695
- {
696
- type: "PhysicsDriveAPI",
697
- driveType: motorConfig.type || "position",
698
- maxForce: motorConfig.maxForce,
699
- stiffness: motorConfig.stiffness,
700
- damping: motorConfig.damping
701
- }
702
- ];
703
- }
704
- this.joints.push(joint);
705
- }
706
- return {
707
- path,
708
- name,
709
- typeName,
710
- translation: position,
711
- rotation,
712
- scale,
713
- children: [],
714
- apis
715
- };
716
- }
717
- processSpatialGroup(group) {
718
- const prims = [];
719
- const groupName = this.sanitizeName(group.name);
720
- const groupPrim = {
721
- path: groupName,
722
- name: groupName,
723
- typeName: "Xform",
724
- children: [],
725
- apis: []
726
- };
727
- const hasRobotObjects = group.objects?.some((obj) => this.hasTrait(obj, "joint"));
728
- if (hasRobotObjects) {
729
- groupPrim.apis.push({
730
- type: "PhysicsArticulationRootAPI",
731
- articulationEnabled: true
732
- });
733
- }
734
- if (group.objects) {
735
- for (const obj of group.objects) {
736
- const childPrim = this.processObject(obj, groupName);
737
- if (childPrim) {
738
- groupPrim.children.push(childPrim);
739
- }
740
- }
741
- }
742
- prims.push(groupPrim);
743
- return prims;
744
- }
745
- };
746
- function compileToUSDPhysics(composition, options) {
747
- const compiler = new USDPhysicsCompiler(options);
748
- return compiler.compile(composition, "system");
749
- }
750
- function compileForIsaacSim(composition, options) {
751
- const isaacOptions = {
752
- upAxis: "Z",
753
- metersPerUnit: 1,
754
- enableGPUDynamics: true,
755
- enableArticulation: true,
756
- timeCodesPerSecond: 60,
757
- ...options
758
- };
759
- const compiler = new USDPhysicsCompiler(isaacOptions);
760
- return compiler.compile(composition, "system");
761
- }
762
-
763
- export { USDPhysicsCompiler, compileForIsaacSim, compileToUSDPhysics };
764
- //# sourceMappingURL=chunk-AC4BSHFV.js.map
765
- //# sourceMappingURL=chunk-AC4BSHFV.js.map