@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.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +3 -2
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/index.d.ts +501 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/tools/index.d.ts +22 -1
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +105 -57
- package/dist/GLTFPipeline-DEN36VNK.js +0 -12
- package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
- package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
- package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
- package/dist/USDZExporter-NTMBNTDB.js +0 -707
- package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2CWOLHTE.js +0 -69
- package/dist/chunk-33LSUQDD.cjs +0 -835
- package/dist/chunk-3FJCK5XA.js +0 -2232
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3SAK5KFL.cjs +0 -83
- package/dist/chunk-4XSNJCLC.cjs +0 -1859
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5BGSECRJ.cjs +0 -2237
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5O6TQC6M.cjs +0 -1871
- package/dist/chunk-5OEOHAAW.cjs +0 -682
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-5WUNN6ZN.cjs +0 -428
- package/dist/chunk-6TZPZCOJ.cjs +0 -1404
- package/dist/chunk-6UEHYZ7V.cjs +0 -773
- package/dist/chunk-6XSERL6L.js +0 -5678
- package/dist/chunk-72EQECGT.cjs +0 -908
- package/dist/chunk-7AGYRWKW.cjs +0 -507
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-A7PIMZGU.js +0 -263
- package/dist/chunk-ATSKSYVE.cjs +0 -51683
- package/dist/chunk-B5TCIAPQ.cjs +0 -117
- package/dist/chunk-BF2235SI.cjs +0 -5714
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BND3ST2K.cjs +0 -662
- package/dist/chunk-BU7VWW2K.js +0 -2522
- package/dist/chunk-BWFJEM5A.js +0 -5419
- package/dist/chunk-CAUCGUEA.cjs +0 -130
- package/dist/chunk-CBJSLA2E.cjs +0 -5423
- package/dist/chunk-CDPGV4DN.js +0 -114
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CS2EMTGF.js +0 -1966
- package/dist/chunk-DMG7C4H2.js +0 -975
- package/dist/chunk-DXJQDCFL.js +0 -468
- package/dist/chunk-E3FWRT3Z.js +0 -608
- package/dist/chunk-E3UALNFA.js +0 -421
- package/dist/chunk-EONILVMF.js +0 -762
- package/dist/chunk-EQV4R3EV.cjs +0 -769
- package/dist/chunk-F3HH56EB.cjs +0 -5538
- package/dist/chunk-F4IULT7N.js +0 -1488
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-FFKU7BTK.cjs +0 -1046
- package/dist/chunk-FHQVYCH2.js +0 -70
- package/dist/chunk-FSF7EQVA.cjs +0 -1974
- package/dist/chunk-G4VZTCIB.js +0 -659
- package/dist/chunk-G7CT3EMP.cjs +0 -1002
- package/dist/chunk-GGHSW2NN.js +0 -51334
- package/dist/chunk-GVUR45UF.cjs +0 -777
- package/dist/chunk-H5Z7NASB.js +0 -9662
- package/dist/chunk-HE7ULERA.cjs +0 -697
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HPS76H7Q.js +0 -309
- package/dist/chunk-HQUEA5R6.cjs +0 -424
- package/dist/chunk-HYNTS5CP.js +0 -422
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IBDG74G2.cjs +0 -1219
- package/dist/chunk-IFNQFCTM.js +0 -3098
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-IWI6J7FX.js +0 -421
- package/dist/chunk-K3JDKWGI.cjs +0 -270
- package/dist/chunk-K6EKD26I.js +0 -630
- package/dist/chunk-KCQ5NDYC.cjs +0 -3172
- package/dist/chunk-KED34ILP.js +0 -832
- package/dist/chunk-KSGXLT74.cjs +0 -457
- package/dist/chunk-L4G4RLXX.js +0 -767
- package/dist/chunk-LDP5OK6G.js +0 -1216
- package/dist/chunk-LGGRPKTV.cjs +0 -735
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-LSW7P7ML.js +0 -3675
- package/dist/chunk-LXJ4667L.cjs +0 -3874
- package/dist/chunk-LZ266PCM.cjs +0 -4499
- package/dist/chunk-MD6KDHVE.cjs +0 -237
- package/dist/chunk-MEASWI2Y.js +0 -126
- package/dist/chunk-MPXBVFHQ.js +0 -768
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUKG4SK.cjs +0 -3075
- package/dist/chunk-NDQNIJEH.js +0 -1715
- package/dist/chunk-NOZZ46QU.js +0 -168
- package/dist/chunk-OFKWH2IP.js +0 -449
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PMGODDJA.cjs +0 -319
- package/dist/chunk-Q4QX3AET.cjs +0 -1505
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-Q5JT3YML.cjs +0 -129
- package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
- package/dist/chunk-QGKNANZ3.js +0 -3071
- package/dist/chunk-QLEAOI3Q.cjs +0 -424
- package/dist/chunk-R7MA7QWV.js +0 -732
- package/dist/chunk-RVYPEYPX.js +0 -678
- package/dist/chunk-S2N5TNMA.js +0 -1855
- package/dist/chunk-S565K7NK.js +0 -752
- package/dist/chunk-SDAMZIRE.js +0 -765
- package/dist/chunk-T36DDXSF.js +0 -4250
- package/dist/chunk-T4NKMBDL.js +0 -5474
- package/dist/chunk-T7LEXZUZ.cjs +0 -2526
- package/dist/chunk-TEWCN33Y.js +0 -694
- package/dist/chunk-TQSZUOW5.cjs +0 -793
- package/dist/chunk-TSH3MSQU.cjs +0 -129
- package/dist/chunk-UERJ3YJV.js +0 -504
- package/dist/chunk-UPJBDCVF.js +0 -1395
- package/dist/chunk-V3NN3HPP.js +0 -4462
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-WB4Z63GG.js +0 -229
- package/dist/chunk-WDW67DZB.cjs +0 -9728
- package/dist/chunk-WGMEAYBG.js +0 -126
- package/dist/chunk-X4ZF6CNE.cjs +0 -473
- package/dist/chunk-X6SEAXAX.cjs +0 -3681
- package/dist/chunk-XCWFGZAA.js +0 -1043
- package/dist/chunk-XD6IYDUX.js +0 -903
- package/dist/chunk-XG23EUQX.cjs +0 -1717
- package/dist/chunk-XRKWN5PL.cjs +0 -173
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-XUTX5CBW.js +0 -126
- package/dist/chunk-XWPNTWDN.cjs +0 -755
- package/dist/chunk-XXINBTZK.cjs +0 -633
- package/dist/chunk-YCXFCXDS.js +0 -1868
- package/dist/chunk-YQK5JNFK.js +0 -3725
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-Z34RLXRA.cjs +0 -612
- package/dist/chunk-ZP4D3CSX.cjs +0 -72
- package/dist/cli/holoscript-runner.cjs +0 -2259
- package/dist/cli/holoscript-runner.js +0 -2234
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -28
- package/dist/compiler/agent-inference.js +0 -5
- package/dist/compiler/android-xr.cjs +0 -19
- package/dist/compiler/android-xr.js +0 -9
- package/dist/compiler/android.cjs +0 -20
- package/dist/compiler/android.js +0 -10
- package/dist/compiler/ar.cjs +0 -20
- package/dist/compiler/ar.js +0 -8
- package/dist/compiler/babylon.cjs +0 -17
- package/dist/compiler/babylon.js +0 -11
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -602
- package/dist/compiler/domain-block-utils.js +0 -8
- package/dist/compiler/dtdl.cjs +0 -24
- package/dist/compiler/dtdl.js +0 -8
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -15
- package/dist/compiler/godot.js +0 -9
- package/dist/compiler/incremental.cjs +0 -29
- package/dist/compiler/incremental.js +0 -4
- package/dist/compiler/index.cjs +0 -2578
- package/dist/compiler/index.js +0 -2383
- package/dist/compiler/ios.cjs +0 -20
- package/dist/compiler/ios.js +0 -10
- package/dist/compiler/multi-layer.cjs +0 -20
- package/dist/compiler/multi-layer.js +0 -11
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -15
- package/dist/compiler/openxr.js +0 -9
- package/dist/compiler/playcanvas.cjs +0 -16
- package/dist/compiler/playcanvas.js +0 -10
- package/dist/compiler/r3f.cjs +0 -34
- package/dist/compiler/r3f.js +0 -12
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -21
- package/dist/compiler/sdf.js +0 -9
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -17
- package/dist/compiler/state.js +0 -7
- package/dist/compiler/trait-composition.cjs +0 -26
- package/dist/compiler/trait-composition.js +0 -5
- package/dist/compiler/unity.cjs +0 -15
- package/dist/compiler/unity.js +0 -9
- package/dist/compiler/unreal.cjs +0 -19
- package/dist/compiler/unreal.js +0 -9
- package/dist/compiler/urdf.cjs +0 -45
- package/dist/compiler/urdf.js +0 -9
- package/dist/compiler/usd-physics.cjs +0 -23
- package/dist/compiler/usd-physics.js +0 -6
- package/dist/compiler/visionos.cjs +0 -15
- package/dist/compiler/visionos.js +0 -9
- package/dist/compiler/vrchat.cjs +0 -19
- package/dist/compiler/vrchat.js +0 -9
- package/dist/compiler/vrr.cjs +0 -21
- package/dist/compiler/vrr.js +0 -9
- package/dist/compiler/wasm.cjs +0 -33
- package/dist/compiler/wasm.js +0 -9
- package/dist/compiler/webgpu.cjs +0 -15
- package/dist/compiler/webgpu.js +0 -9
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -68
- package/dist/entries/scripting.js +0 -11
- package/dist/index.cjs +0 -40921
- package/dist/index.js +0 -37763
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
- package/dist/ml-dsa-WYLJHJO6.js +0 -1178
- package/dist/parser.cjs +0 -27
- package/dist/parser.js +0 -10
- package/dist/playwright-5OSAPTNH.js +0 -98660
- package/dist/playwright-RL6GY4F7.cjs +0 -98673
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14649
- package/dist/traits/index.js +0 -12243
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
package/dist/chunk-EQV4R3EV.cjs
DELETED
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkLXJ4667L_cjs = require('./chunk-LXJ4667L.cjs');
|
|
4
|
-
var chunkBF2235SI_cjs = require('./chunk-BF2235SI.cjs');
|
|
5
|
-
var platform = require('@holoscript/platform');
|
|
6
|
-
|
|
7
|
-
// src/compiler/USDPhysicsCompiler.ts
|
|
8
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
9
|
-
chunkLXJ4667L_cjs.init_DomainBlockCompilerMixin();
|
|
10
|
-
var USDPhysicsCompiler = class extends chunkBF2235SI_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 platform.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 = chunkLXJ4667L_cjs.compileDomainBlocks(
|
|
254
|
-
domainBlocks,
|
|
255
|
-
{
|
|
256
|
-
material: (block) => {
|
|
257
|
-
const mat = chunkLXJ4667L_cjs.compileMaterialBlock(block);
|
|
258
|
-
return chunkLXJ4667L_cjs.materialToUSD(mat);
|
|
259
|
-
},
|
|
260
|
-
physics: (block) => {
|
|
261
|
-
const phys = chunkLXJ4667L_cjs.compilePhysicsBlock(block);
|
|
262
|
-
const urdf = chunkLXJ4667L_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 = chunkLXJ4667L_cjs.compileParticleBlock(block);
|
|
268
|
-
return chunkLXJ4667L_cjs.particlesToUSD(ps);
|
|
269
|
-
},
|
|
270
|
-
postfx: (block) => {
|
|
271
|
-
const pp = chunkLXJ4667L_cjs.compilePostProcessingBlock(block);
|
|
272
|
-
return chunkLXJ4667L_cjs.postProcessingToUSD(pp);
|
|
273
|
-
},
|
|
274
|
-
audio: (block) => {
|
|
275
|
-
const audio = chunkLXJ4667L_cjs.compileAudioSourceBlock(block);
|
|
276
|
-
return chunkLXJ4667L_cjs.audioSourceToUSD(audio);
|
|
277
|
-
},
|
|
278
|
-
weather: (block) => {
|
|
279
|
-
const weather = chunkLXJ4667L_cjs.compileWeatherBlock(block);
|
|
280
|
-
return chunkLXJ4667L_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-EQV4R3EV.cjs.map
|
|
769
|
-
//# sourceMappingURL=chunk-EQV4R3EV.cjs.map
|