Add aliases for MjModel loading functions and expose string constants as properties.
Introduces `from_xml_path` and `from_binary_path` as more idiomatic aliases for `mj_loadXML` and `mj_loadModel` respectively. Refactors the binding of `mj*STRING` constants. Instead of exposing `get_mj*STRING` functions, these constants are now available as properties on the `Module` object. Runtime getters are added via EM_ASM to lazily call the underlying C++ functions. PiperOrigin-RevId: 882566011 Change-Id: Id3bd5c23704fd122af30a50aed089bd3143fbc96
This commit is contained in:
committed by
Copybara-Service
parent
a62501f305
commit
df0bc58578
@@ -683,24 +683,24 @@ describe('MuJoCo WASM Bindings', () => {
|
||||
|
||||
it('should check constants values', () => {
|
||||
expect(mujoco.mjNEQDATA).toBe(11);
|
||||
expect(mujoco.get_mjDISABLESTRING()).toEqual([
|
||||
expect(mujoco.mjDISABLESTRING).toEqual([
|
||||
'Constraint', 'Equality', 'Frictionloss', 'Limit', 'Contact', 'Spring',
|
||||
'Damper', 'Gravity', 'Clampctrl', 'Warmstart', 'Filterparent',
|
||||
'Actuation', 'Refsafe', 'Sensor', 'Midphase', 'Eulerdamp', 'AutoReset',
|
||||
'NativeCCD', 'Island'
|
||||
]);
|
||||
expect(mujoco.get_mjRNDSTRING()).toEqual([
|
||||
expect(mujoco.mjRNDSTRING).toEqual([
|
||||
['Shadow', '1', 'S'], ['Wireframe', '0', 'W'], ['Reflection', '1', 'R'],
|
||||
['Additive', '0', 'L'], ['Skybox', '1', 'K'], ['Fog', '0', 'G'],
|
||||
['Haze', '1', '/'], ['Depth', '0', ''], ['Segment', '0', ','],
|
||||
['Id Color', '0', ''], ['Cull Face', '1', '']
|
||||
]);
|
||||
expect(mujoco.get_mjFRAMESTRING().length)
|
||||
.toEqual(mujoco.mjtFrame.mjNFRAME.value);
|
||||
expect(mujoco.get_mjVISSTRING().length)
|
||||
expect(mujoco.mjFRAMESTRING.length).toEqual(mujoco.mjtFrame.mjNFRAME.value);
|
||||
expect(mujoco.mjVISSTRING.length)
|
||||
.toEqual(mujoco.mjtVisFlag.mjNVISFLAG.value);
|
||||
expect(mujoco.get_mjVISSTRING()[mujoco.mjtVisFlag.mjVIS_INERTIA.value])
|
||||
.toEqual(['Inertia', '0', 'I']);
|
||||
expect(mujoco.mjVISSTRING[mujoco.mjtVisFlag.mjVIS_INERTIA.value]).toEqual([
|
||||
'Inertia', '0', 'I'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should create a spec from XML', () => {
|
||||
|
||||
Reference in New Issue
Block a user