diff --git a/Extensions/Physics2Behavior/JsExtension.js b/Extensions/Physics2Behavior/JsExtension.js
index 6d30f4be3942..594d3c1f1615 100644
--- a/Extensions/Physics2Behavior/JsExtension.js
+++ b/Extensions/Physics2Behavior/JsExtension.js
@@ -695,7 +695,7 @@ module.exports = {
.addCondition(
'IsDynamic',
_('Is dynamic'),
- _('Test if an object is dynamic.'),
+ _('Check if an object is dynamic.'),
_('_PARAM0_ is dynamic'),
_('Dynamics'),
'res/physics32.png',
@@ -727,7 +727,7 @@ module.exports = {
.addCondition(
'IsStatic',
_('Is static'),
- _('Test if an object is static.'),
+ _('Check if an object is static.'),
_('_PARAM0_ is static'),
_('Dynamics'),
'res/physics32.png',
@@ -759,7 +759,7 @@ module.exports = {
.addCondition(
'IsKinematic',
_('Is kinematic'),
- _('Test if an object is kinematic.'),
+ _('Check if an object is kinematic.'),
_('_PARAM0_ is kinematic'),
_('Dynamics'),
'res/physics32.png',
@@ -791,7 +791,7 @@ module.exports = {
.addCondition(
'IsBullet',
_('Is treat as bullet'),
- _('Test if an object is being treat as a bullet.'),
+ _('Check if an object is being treat as a bullet.'),
_('_PARAM0_ is bullet'),
_('Dynamics'),
'res/physics32.png',
@@ -825,7 +825,7 @@ module.exports = {
.addCondition(
'HasFixedRotation',
_('Has fixed rotation'),
- _('Test if an object has fixed rotation.'),
+ _('Check if an object has fixed rotation.'),
_('_PARAM0_ has fixed rotation'),
_('Dynamics'),
'res/physics32.png',
@@ -859,7 +859,7 @@ module.exports = {
.addCondition(
'IsSleepingAllowed',
_('Is sleeping allowed'),
- _('Test if an object can sleep.'),
+ _('Check if an object can sleep.'),
_('_PARAM0_ can sleep'),
_('Dynamics'),
'res/physics32.png',
@@ -898,7 +898,7 @@ module.exports = {
.addCondition(
'IsSleeping',
_('Is sleeping'),
- _('Test if an object is sleeping.'),
+ _('Check if an object is sleeping.'),
_('_PARAM0_ is sleeping'),
_('Dynamics'),
'res/physics32.png',
@@ -1267,7 +1267,7 @@ module.exports = {
.addCondition(
'LayerEnabled',
_('Layer enabled'),
- _('Test if an object has a specific layer enabled.'),
+ _('Check if an object has a specific layer enabled.'),
_('_PARAM0_ has layer _PARAM2_ enabled'),
_('Filtering'),
'res/physics32.png',
@@ -1303,7 +1303,7 @@ module.exports = {
.addCondition(
'MaskEnabled',
_('Mask enabled'),
- _('Test if an object has a specific mask enabled.'),
+ _('Check if an object has a specific mask enabled.'),
_('_PARAM0_ has mask _PARAM2_ enabled'),
_('Filtering'),
'res/physics32.png',
@@ -1897,7 +1897,7 @@ module.exports = {
.addCondition(
'JointFirstObject',
_('Joint first object'),
- _('Test if an object is the first object on a joint.'),
+ _('Check if an object is the first object on a joint.'),
_('_PARAM0_ is the first object for joint _PARAM2_'),
_('Joints'),
'res/physics32.png',
@@ -1913,7 +1913,7 @@ module.exports = {
.addCondition(
'JointSecondObject',
_('Joint second object'),
- _('Test if an object is the second object on a joint.'),
+ _('Check if an object is the second object on a joint.'),
_('_PARAM0_ is the second object for joint _PARAM2_'),
_('Joints'),
'res/physics32.png',
@@ -2382,7 +2382,7 @@ module.exports = {
.addCondition(
'RevoluteJointLimitsEnabled',
_('Revolute joint limits enabled'),
- _('Test if a revolute joint limits are enabled.'),
+ _('Check if a revolute joint limits are enabled.'),
_('Limits for revolute joint _PARAM2_ are enabled'),
_('Joints/Revolute'),
'JsPlatform/Extensions/revolute_joint24.png',
@@ -2461,7 +2461,7 @@ module.exports = {
.addCondition(
'RevoluteJointMotorEnabled',
_('Revolute joint motor enabled'),
- _('Test if a revolute joint motor is enabled.'),
+ _('Check if a revolute joint motor is enabled.'),
_('Motor of revolute joint _PARAM2_ is enabled'),
_('Joints/Revolute'),
'JsPlatform/Extensions/revolute_joint24.png',
@@ -2700,7 +2700,7 @@ module.exports = {
.addCondition(
'PrismaticJointLimitsEnabled',
_('Prismatic joint limits enabled'),
- _('Test if a prismatic joint limits are enabled.'),
+ _('Check if a prismatic joint limits are enabled.'),
_('Limits for prismatic joint _PARAM2_ are enabled'),
_('Joints/Prismatic'),
'JsPlatform/Extensions/prismatic_joint24.png',
@@ -2779,7 +2779,7 @@ module.exports = {
.addCondition(
'PrismaticJointMotorEnabled',
_('Prismatic joint motor enabled'),
- _('Test if a prismatic joint motor is enabled.'),
+ _('Check if a prismatic joint motor is enabled.'),
_('Motor for prismatic joint _PARAM2_ is enabled'),
_('Joints/Prismatic'),
'JsPlatform/Extensions/prismatic_joint24.png',
@@ -3459,7 +3459,7 @@ module.exports = {
.addCondition(
'WheelJointMotorEnabled',
_('Wheel joint motor enabled'),
- _('Test if a wheel joint motor is enabled.'),
+ _('Check if a wheel joint motor is enabled.'),
_('Motor for wheel joint _PARAM2_ is enabled'),
_('Joints/Wheel'),
'JsPlatform/Extensions/wheel_joint24.png',
diff --git a/Extensions/Physics3DBehavior/JsExtension.js b/Extensions/Physics3DBehavior/JsExtension.js
new file mode 100644
index 000000000000..79431d88171c
--- /dev/null
+++ b/Extensions/Physics3DBehavior/JsExtension.js
@@ -0,0 +1,2404 @@
+//@ts-check
+///
+/**
+ * This is a declaration of an extension for GDevelop 5.
+ *
+ * ℹ️ Changes in this file are watched and automatically imported if the editor
+ * is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
+ *
+ * The file must be named "JsExtension.js", otherwise GDevelop won't load it.
+ * ⚠️ If you make a change and the extension is not loaded, open the developer console
+ * and search for any errors.
+ *
+ * More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
+ */
+
+/** @type {ExtensionModule} */
+module.exports = {
+ createExtension: function (_, gd) {
+ const extension = new gd.PlatformExtension();
+ extension
+ .setExtensionInformation(
+ 'Physics3D',
+ _('3D Physics Engine'),
+ "The physics engine simulates realistic object physics, with gravity, forces, joints, etc. It's perfect for games that need to have realistic behaving objects and a gameplay centered around it.",
+ 'Florian Rival',
+ 'MIT'
+ )
+ .setExtensionHelpPath('/behaviors/physics3d')
+ .setCategory('Movement')
+ .setTags('physics, gravity, obstacle, collision');
+ extension
+ .addInstructionOrExpressionGroupMetadata(_('3D Physics Engine'))
+ .setIcon('JsPlatform/Extensions/physics3d.svg');
+ {
+ const behavior = new gd.BehaviorJsImplementation();
+ behavior.updateProperty = function (
+ behaviorContent,
+ propertyName,
+ newValue
+ ) {
+ if (propertyName === 'Object3D') {
+ behaviorContent.getChild('Object3D').setStringValue(newValue);
+ return true;
+ }
+
+ if (propertyName === 'bodyType') {
+ behaviorContent.getChild('bodyType').setStringValue(newValue);
+ return true;
+ }
+
+ if (propertyName === 'bullet') {
+ behaviorContent.getChild('bullet').setBoolValue(newValue === '1');
+ return true;
+ }
+
+ if (propertyName === 'fixedRotation') {
+ behaviorContent
+ .getChild('fixedRotation')
+ .setBoolValue(newValue === '1');
+ return true;
+ }
+
+ if (propertyName === 'shape') {
+ behaviorContent.getChild('shape').setStringValue(newValue);
+ return true;
+ }
+
+ if (propertyName === 'shapeOrientation') {
+ behaviorContent.getChild('shapeOrientation').setStringValue(newValue);
+ return true;
+ }
+
+ if (propertyName === 'shapeDimensionA') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeDimensionA')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'shapeDimensionB') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeDimensionB')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'shapeDimensionC') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeDimensionC')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'shapeOffsetX') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeOffsetX')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'shapeOffsetY') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeOffsetY')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'shapeOffsetZ') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('shapeOffsetZ')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'density') {
+ behaviorContent
+ .getChild('density')
+ .setDoubleValue(parseFloat(newValue));
+ return true;
+ }
+
+ if (propertyName === 'friction') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent.getChild('friction').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'restitution') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('restitution')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'linearDamping') {
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('linearDamping')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'angularDamping') {
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('angularDamping')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'gravityScale') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('gravityScale')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'layers') {
+ behaviorContent
+ .getChild('layers')
+ .setIntValue(parseInt(newValue, 10));
+ return true;
+ }
+
+ if (propertyName === 'masks') {
+ behaviorContent.getChild('masks').setIntValue(parseInt(newValue, 10));
+ return true;
+ }
+
+ return false;
+ };
+ behavior.getProperties = function (behaviorContent) {
+ const behaviorProperties = new gd.MapStringPropertyDescriptor();
+
+ behaviorProperties
+ .getOrCreate('Object3D')
+ .setValue(behaviorContent.getChild('Object3D').getStringValue())
+ .setType('Behavior')
+ .setLabel('3D capability')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .addExtraInfo('Scene3D::Base3DBehavior');
+
+ behaviorProperties
+ .getOrCreate('bodyType')
+ .setValue(behaviorContent.getChild('bodyType').getStringValue())
+ .setType('Choice')
+ .setLabel('Type')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .addExtraInfo('Static')
+ .addExtraInfo('Dynamic')
+ .addExtraInfo('Kinematic')
+ .setDescription(
+ _(
+ "A static object won't move (perfect for obstacles). Dynamic objects can move. Kinematic will move according to forces applied to it only (useful for characters or specific mechanisms)."
+ )
+ );
+ behaviorProperties
+ .getOrCreate('bullet')
+ .setValue(
+ behaviorContent.getChild('bullet').getBoolValue() ? 'true' : 'false'
+ )
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setType('Boolean')
+ .setLabel(_('Considered as a bullet'))
+ .setDescription(
+ _(
+ 'Useful for fast moving objects which requires a more accurate collision detection.'
+ )
+ )
+ .setGroup(_('Physics body advanced settings'))
+ .setAdvanced(true);
+ behaviorProperties
+ .getOrCreate('fixedRotation')
+ .setValue(
+ behaviorContent.getChild('fixedRotation').getBoolValue()
+ ? 'true'
+ : 'false'
+ )
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setType('Boolean')
+ .setLabel('Fixed Rotation')
+ .setDescription(
+ _(
+ "If enabled, the object won't rotate and will stay at the same angle. Useful for characters for example."
+ )
+ )
+ .setGroup(_('Movement'));
+ behaviorProperties
+ .getOrCreate('shape')
+ .setValue(behaviorContent.getChild('shape').getStringValue())
+ .setType('Choice')
+ .setLabel('Shape')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .addExtraInfo('Sphere')
+ .addExtraInfo('Box')
+ .addExtraInfo('Capsule')
+ .addExtraInfo('Cylinder');
+ behaviorProperties
+ .getOrCreate('shapeOrientation')
+ .setValue(
+ behaviorContent.getChild('shapeOrientation').getStringValue()
+ )
+ .setType('Choice')
+ .setLabel('Shape orientation')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .addExtraInfo('Z')
+ .addExtraInfo('Y')
+ .addExtraInfo('X');
+ behaviorProperties
+ .getOrCreate('shapeDimensionA')
+ .setValue(
+ behaviorContent
+ .getChild('shapeDimensionA')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Dimension A')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('shapeDimensionB')
+ .setValue(
+ behaviorContent
+ .getChild('shapeDimensionB')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Dimension B')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('shapeDimensionC')
+ .setValue(
+ behaviorContent
+ .getChild('shapeDimensionC')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Dimension C')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('shapeOffsetX')
+ .setValue(
+ behaviorContent
+ .getChild('shapeOffsetX')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Offset X')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('shapeOffsetY')
+ .setValue(
+ behaviorContent
+ .getChild('shapeOffsetY')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Offset Y')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('shapeOffsetZ')
+ .setValue(
+ behaviorContent
+ .getChild('shapeOffsetZ')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setLabel('Shape Offset Z')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('density')
+ .setValue(
+ behaviorContent.getChild('density').getDoubleValue().toString(10)
+ )
+ .setType('Number')
+ .setLabel(_('Density'))
+ .setDescription(
+ _(
+ 'Define the weight of the object, according to its size. The bigger the density, the heavier the object.'
+ )
+ );
+ behaviorProperties
+ .getOrCreate('friction')
+ .setValue(
+ behaviorContent.getChild('friction').getDoubleValue().toString(10)
+ )
+ .setType('Number')
+ .setLabel(_('Friction'))
+ .setDescription(
+ _(
+ 'The friction applied when touching other objects. The higher the value, the more friction.'
+ )
+ );
+ behaviorProperties
+ .getOrCreate('restitution')
+ .setValue(
+ behaviorContent
+ .getChild('restitution')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setLabel(_('Restitution'))
+ .setDescription(
+ _(
+ 'The "bounciness" of the object. The higher the value, the more other objects will bounce against it.'
+ )
+ );
+ behaviorProperties
+ .getOrCreate('linearDamping')
+ .setValue(
+ behaviorContent
+ .getChild('linearDamping')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setLabel(_('Linear Damping'))
+ .setGroup(_('Movement'));
+
+ behaviorProperties
+ .getOrCreate('angularDamping')
+ .setValue(
+ behaviorContent
+ .getChild('angularDamping')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setLabel(_('Angular Damping'))
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setGroup(_('Movement'));
+ behaviorProperties
+ .getOrCreate('gravityScale')
+ .setValue(
+ behaviorContent
+ .getChild('gravityScale')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setType('Number')
+ .setLabel('Gravity Scale')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setGroup(_('Gravity'))
+ .setAdvanced(true);
+ behaviorProperties
+ .getOrCreate('layers')
+ .setValue(
+ behaviorContent.getChild('layers').getIntValue().toString(10)
+ )
+ .setType('Number')
+ .setLabel('Layers')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+ behaviorProperties
+ .getOrCreate('masks')
+ .setValue(
+ behaviorContent.getChild('masks').getIntValue().toString(10)
+ )
+ .setType('Number')
+ .setLabel('Masks')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setHidden(true); // Hidden as required to be changed in the full editor.
+
+ return behaviorProperties;
+ };
+
+ behavior.initializeContent = function (behaviorContent) {
+ behaviorContent.addChild('Object3D').setStringValue('');
+ behaviorContent.addChild('bodyType').setStringValue('Dynamic');
+ behaviorContent.addChild('bullet').setBoolValue(false);
+ behaviorContent.addChild('fixedRotation').setBoolValue(false);
+ behaviorContent.addChild('shape').setStringValue('Sphere');
+ behaviorContent.addChild('shapeOrientation').setStringValue('Z');
+ behaviorContent.addChild('shapeDimensionA').setDoubleValue(0);
+ behaviorContent.addChild('shapeDimensionB').setDoubleValue(0);
+ behaviorContent.addChild('shapeDimensionC').setDoubleValue(0);
+ behaviorContent.addChild('shapeOffsetX').setDoubleValue(0);
+ behaviorContent.addChild('shapeOffsetY').setDoubleValue(0);
+ behaviorContent.addChild('shapeOffsetZ').setDoubleValue(0);
+ behaviorContent.addChild('density').setDoubleValue(1.0);
+ behaviorContent.addChild('friction').setDoubleValue(0.3);
+ behaviorContent.addChild('restitution').setDoubleValue(0.1);
+ behaviorContent.addChild('linearDamping').setDoubleValue(0.1);
+ behaviorContent.addChild('angularDamping').setDoubleValue(0.1);
+ behaviorContent.addChild('gravityScale').setDoubleValue(1);
+ behaviorContent.addChild('layers').setIntValue((1 << 4) | (1 << 0));
+ behaviorContent.addChild('masks').setIntValue((1 << 4) | (1 << 0));
+ };
+
+ const sharedData = new gd.BehaviorSharedDataJsImplementation();
+ sharedData.updateProperty = function (
+ sharedContent,
+ propertyName,
+ newValue
+ ) {
+ if (propertyName === 'gravityX') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ sharedContent.getChild('gravityX').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'gravityY') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ sharedContent.getChild('gravityY').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'gravityZ') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ sharedContent.getChild('gravityZ').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'worldScale') {
+ const newValueAsNumber = parseInt(newValue, 10);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ if (!sharedContent.hasChild('worldScale')) {
+ sharedContent.addChild('worldScale');
+ }
+ sharedContent.getChild('worldScale').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+ return false;
+ };
+ sharedData.getProperties = function (sharedContent) {
+ const sharedProperties = new gd.MapStringPropertyDescriptor();
+
+ sharedProperties
+ .getOrCreate('gravityX')
+ .setValue(
+ sharedContent.getChild('gravityX').getDoubleValue().toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
+ sharedProperties
+ .getOrCreate('gravityY')
+ .setValue(
+ sharedContent.getChild('gravityY').getDoubleValue().toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
+ sharedProperties
+ .getOrCreate('gravityZ')
+ .setValue(
+ sharedContent.getChild('gravityZ').getDoubleValue().toString(10)
+ )
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
+
+ sharedProperties
+ .getOrCreate('worldScale')
+ .setValue(
+ sharedContent.getChild('worldScale').getDoubleValue().toString(10)
+ )
+ .setType('Number');
+
+ return sharedProperties;
+ };
+ sharedData.initializeContent = function (behaviorContent) {
+ behaviorContent.addChild('gravityX').setDoubleValue(0);
+ behaviorContent.addChild('gravityY').setDoubleValue(0);
+ behaviorContent.addChild('gravityZ').setDoubleValue(-9.8);
+ behaviorContent.addChild('worldScale').setDoubleValue(100);
+ };
+
+ const aut = extension
+ .addBehavior(
+ 'Physics3DBehavior',
+ _('3D physics engine'),
+ 'Physics3D',
+ _('Simulate realistic object physics with gravity, forces, etc.'),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'Physics3DBehavior',
+ //@ts-ignore The class hierarchy is incorrect leading to a type error, but this is valid.
+ behavior,
+ sharedData
+ )
+ .addIncludeFile(
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
+ )
+ //.addIncludeFile('Extensions/Physics3DBehavior/jolt-physics.multithread.wasm-compat.js')
+ .setOpenFullEditorLabel(_('Edit shape and advanced settings'));
+
+ // Global
+ aut
+ .addExpression(
+ 'WorldScale',
+ _('World scale'),
+ _('Return the world scale.'),
+ _('Global'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getWorldScale');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'GravityX',
+ _('World gravity on X axis'),
+ _('the world gravity on X axis') +
+ ' ' +
+ _(
+ 'While an object is needed, this will apply to all objects using the behavior.'
+ ),
+ _('the world gravity on X axis'),
+ _('Global'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Gravity (in Newton)')
+ )
+ )
+ .setFunctionName('setGravityX')
+ .setGetter('getGravityX');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'GravityY',
+ _('World gravity on Y axis'),
+ _('the world gravity on Y axis') +
+ ' ' +
+ _(
+ 'While an object is needed, this will apply to all objects using the behavior.'
+ ),
+ _('the world gravity on Y axis'),
+ _('Global'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Gravity (in Newton)')
+ )
+ )
+ .setFunctionName('setGravityY')
+ .setGetter('getGravityY');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'GravityZ',
+ _('World gravity on Z axis'),
+ _('the world gravity on Z axis') +
+ ' ' +
+ _(
+ 'While an object is needed, this will apply to all objects using the behavior.'
+ ),
+ _('the world gravity on Z axis'),
+ _('Global'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Gravity (in Newton)')
+ )
+ )
+ .setFunctionName('setGravityZ')
+ .setGetter('getGravityZ');
+
+ aut
+ .addScopedCondition(
+ 'IsDynamic',
+ _('Is dynamic'),
+ _('Check if an object is dynamic.'),
+ _('_PARAM0_ is dynamic'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('isDynamic');
+
+ aut
+ .addScopedCondition(
+ 'IsStatic',
+ _('Is static'),
+ _('Check if an object is static.'),
+ _('_PARAM0_ is static'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('isStatic');
+
+ aut
+ .addScopedCondition(
+ 'IsKinematic',
+ _('Is kinematic'),
+ _('Check if an object is kinematic.'),
+ _('_PARAM0_ is kinematic'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('isKinematic');
+
+ aut
+ .addScopedCondition(
+ 'IsBullet',
+ _('Is treat as bullet'),
+ _('Check if an object is being treat as a bullet.'),
+ _('_PARAM0_ is bullet'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('isBullet');
+
+ aut
+ .addScopedAction(
+ 'SetBullet',
+ _('Treat as bullet'),
+ _(
+ 'Treat the object as a bullet. Better collision handling on high speeds at cost of some performance.'
+ ),
+ _('Treat _PARAM0_ as bullet: _PARAM2_'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('yesorno', _('Treat as bullet?'), '', false)
+ .setDefaultValue('false')
+ .getCodeExtraInformation()
+ .setFunctionName('setBullet');
+
+ aut
+ .addScopedCondition(
+ 'HasFixedRotation',
+ _('Has fixed rotation'),
+ _('Check if an object has fixed rotation.'),
+ _('_PARAM0_ has fixed rotation'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('hasFixedRotation');
+
+ aut
+ .addScopedAction(
+ 'SetFixedRotation',
+ _('Fixed rotation'),
+ _(
+ "Enable or disable an object fixed rotation. If enabled the object won't be able to rotate."
+ ),
+ _('Set _PARAM0_ fixed rotation: _PARAM2_'),
+ _('Dynamics'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('yesorno', _('Fixed rotation?'), '', false)
+ .setDefaultValue('false')
+ .getCodeExtraInformation()
+ .setFunctionName('setFixedRotation');
+
+ // Body settings
+ aut
+ .addScopedAction(
+ 'ShapeScale',
+ _('Shape scale'),
+ _(
+ 'Modify an object shape scale. It affects custom shape dimensions and shape offset, if custom dimensions are not set the body will be scaled automatically to the object size.'
+ ),
+ _('the shape scale'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardOperatorParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Scale (1 by default)')
+ )
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('setShapeScale')
+ .setGetter('getShapeScale');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'Density',
+ _('Density'),
+ _(
+ "the object density. The body's density and volume determine its mass."
+ ),
+ _('the density'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
+ .setFunctionName('setDensity')
+ .setGetter('getDensity');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'Friction',
+ _('Friction'),
+ _(
+ "the object friction. How much energy is lost from the movement of one object over another. The combined friction from two bodies is calculated as 'sqrt(bodyA.friction * bodyB.friction)'."
+ ),
+ _('the friction'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
+ .setFunctionName('setFriction')
+ .setGetter('getFriction');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'Restitution',
+ _('Restitution'),
+ _(
+ "the object restitution. Energy conservation on collision. The combined restitution from two bodies is calculated as 'max(bodyA.restitution, bodyB.restitution)'."
+ ),
+ _('the restitution'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
+ .setFunctionName('setRestitution')
+ .setGetter('getRestitution');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'LinearDamping',
+ _('Linear damping'),
+ _(
+ 'the object linear damping. How much movement speed is lost across the time.'
+ ),
+ _('the linear damping'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
+ .setFunctionName('setLinearDamping')
+ .setGetter('getLinearDamping');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'AngularDamping',
+ _('Angular damping'),
+ _(
+ 'the object angular damping. How much angular speed is lost across the time.'
+ ),
+ _('the angular damping'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
+ .setFunctionName('setAngularDamping')
+ .setGetter('getAngularDamping');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'GravityScale',
+ _('Gravity scale'),
+ _(
+ 'the object gravity scale. The gravity applied to an object is the world gravity multiplied by the object gravity scale.'
+ ),
+ _('the gravity scale'),
+ _('Body settings'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Scale (1 by default)')
+ )
+ )
+ .setFunctionName('setGravityScale')
+ .setGetter('getGravityScale');
+
+ // Filtering
+ aut
+ .addScopedCondition(
+ 'LayerEnabled',
+ _('Layer enabled'),
+ _('Check if an object has a specific layer enabled.'),
+ _('_PARAM0_ has layer _PARAM2_ enabled'),
+ _('Filtering'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Layer (1 - 8)'))
+ .getCodeExtraInformation()
+ .setFunctionName('layerEnabled');
+
+ aut
+ .addScopedAction(
+ 'EnableLayer',
+ _('Enable layer'),
+ _(
+ 'Enable or disable a layer for an object. Two objects collide if any layer of the first object matches any mask of the second one and vice versa.'
+ ),
+ _('Enable layer _PARAM2_ for _PARAM0_: _PARAM3_'),
+ _('Filtering'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Layer (1 - 8)'))
+ .addParameter('yesorno', _('Enable?'), '', false)
+ .setDefaultValue('true')
+ .getCodeExtraInformation()
+ .setFunctionName('enableLayer');
+
+ aut
+ .addScopedCondition(
+ 'MaskEnabled',
+ _('Mask enabled'),
+ _('Check if an object has a specific mask enabled.'),
+ _('_PARAM0_ has mask _PARAM2_ enabled'),
+ _('Filtering'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Mask (1 - 8)'))
+ .getCodeExtraInformation()
+ .setFunctionName('maskEnabled');
+
+ aut
+ .addScopedAction(
+ 'EnableMask',
+ _('Enable mask'),
+ _(
+ 'Enable or disable a mask for an object. Two objects collide if any layer of the first object matches any mask of the second one and vice versa.'
+ ),
+ _('Enable mask _PARAM2_ for _PARAM0_: _PARAM3_'),
+ _('Filtering'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Mask (1 - 8)'))
+ .addParameter('yesorno', _('Enable?'), '', false)
+ .setDefaultValue('true')
+ .getCodeExtraInformation()
+ .setFunctionName('enableMask');
+
+ // Velocity
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'LinearVelocityX',
+ _('Linear velocity X'),
+ _('the object linear velocity on X.'),
+ _('the linear velocity on X'),
+ _('Velocity'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setLinearVelocityX')
+ .setGetter('getLinearVelocityX');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'LinearVelocityY',
+ _('Linear velocity Y'),
+ _('the object linear velocity on Y.'),
+ _('the linear velocity on Y'),
+ _('Velocity'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setLinearVelocityY')
+ .setGetter('getLinearVelocityY');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'LinearVelocityZ',
+ _('Linear velocity Z'),
+ _('the object linear velocity on Z.'),
+ _('the linear velocity on Z'),
+ _('Velocity'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setLinearVelocityZ')
+ .setGetter('getLinearVelocityZ');
+
+ aut
+ .addExpressionAndCondition(
+ 'number',
+ 'LinearVelocityLength',
+ _('Linear velocity'),
+ _('the object linear velocity length.'),
+ _('the linear velocity length'),
+ _('Velocity'),
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed to compare to (in pixels per second)')
+ )
+ )
+ .setFunctionName('getLinearVelocityLength');
+
+ // Forces and impulses
+ aut
+ .addScopedAction(
+ 'ApplyForce',
+ _('Apply force (at a point)'),
+ _(
+ 'Apply a force to the object over time. It "accelerates" an object and must be used every frame during a time period.'
+ ),
+ _(
+ 'Apply a force of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ at _PARAM5_ ; _PARAM6_ ; _PARAM7_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('X component (N)'))
+ .addParameter('expression', _('Y component (N)'))
+ .addParameter('expression', _('Z component (N)'))
+ .setParameterLongDescription(
+ _('A force is like an acceleration but depends on the mass.')
+ )
+ .addParameter('expression', _('Application point on X axis'))
+ .addParameter('expression', _('Application point on Y axis'))
+ .addParameter('expression', _('Application point on Z axis'))
+ .setParameterLongDescription(
+ _(
+ 'Use `MassCenterX` and `MassCenterY` expressions to avoid any rotation.'
+ )
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyForce');
+
+ aut
+ .addScopedAction(
+ 'ApplyForceAtCenter',
+ _('Apply force (at center)'),
+ _(
+ 'Apply a force to the object over time. It "accelerates" an object and must be used every frame during a time period.'
+ ),
+ _(
+ 'Apply a force of _PARAM2_ ; _PARAM3_ ; _PARAM4_ at the center of _PARAM0_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('X component (N)'))
+ .addParameter('expression', _('Y component (N)'))
+ .addParameter('expression', _('Z component (N)'))
+ .setParameterLongDescription(
+ _('A force is like an acceleration but depends on the mass.')
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyForceAtCenter');
+
+ aut
+ .addScopedAction(
+ 'ApplyForceTowardPosition',
+ _('Apply force toward position'),
+ _(
+ 'Apply a force to the object over time to move it toward a position. It "accelerates" an object and must be used every frame during a time period.'
+ ),
+ _(
+ 'Apply to _PARAM0_ a force of length _PARAM2_ towards _PARAM3_ ; _PARAM4_ ; _PARAM5_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Length (N)'))
+ .setParameterLongDescription(
+ _('A force is like an acceleration but depends on the mass.')
+ )
+ .addParameter('expression', _('X position'))
+ .addParameter('expression', _('Y position'))
+ .addParameter('expression', _('Z position'))
+ .getCodeExtraInformation()
+ .setFunctionName('applyForceTowardPosition');
+
+ aut
+ .addScopedAction(
+ 'ApplyImpulse',
+ _('Apply impulse (at a point)'),
+ _(
+ 'Apply an impulse to the object. It instantly changes the speed, to give an initial speed for instance.'
+ ),
+ _(
+ 'Apply an impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ at _PARAM5_ ; _PARAM6_ ; _PARAM7_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('X component (N·s or kg·m·s⁻¹)'))
+ .addParameter('expression', _('Y component (N·s or kg·m·s⁻¹)'))
+ .addParameter('expression', _('Z component (N·s or kg·m·s⁻¹)'))
+ .setParameterLongDescription(
+ _('An impulse is like a speed addition but depends on the mass.')
+ )
+ .addParameter('expression', _('Application point on X axis'))
+ .addParameter('expression', _('Application point on Y axis'))
+ .addParameter('expression', _('Application point on Z axis'))
+ .setParameterLongDescription(
+ _(
+ 'Use `MassCenterX`, `MassCenterY` and `MassCenterZ` expressions to avoid any rotation.'
+ )
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyImpulse');
+
+ aut
+ .addScopedAction(
+ 'ApplyImpulseAtCenter',
+ _('Apply impulse (at center)'),
+ _(
+ 'Apply an impulse to the object. It instantly changes the speed, to give an initial speed for instance.'
+ ),
+ _(
+ 'Apply an impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ at the center of _PARAM0_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('X component (N·s or kg·m·s⁻¹)'))
+ .addParameter('expression', _('Y component (N·s or kg·m·s⁻¹)'))
+ .addParameter('expression', _('Z component (N·s or kg·m·s⁻¹)'))
+ .setParameterLongDescription(
+ _('An impulse is like a speed addition but depends on the mass.')
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyImpulseAtCenter');
+
+ aut
+ .addScopedAction(
+ 'ApplyImpulseTowardPosition',
+ _('Apply impulse toward position'),
+ _(
+ 'Apply an impulse to the object to move it toward a position. It instantly changes the speed, to give an initial speed for instance.'
+ ),
+ _(
+ 'Apply to _PARAM0_ an impulse of length _PARAM2_ towards _PARAM3_ ; _PARAM4_ ; _PARAM5_'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Length (N·s or kg·m·s⁻¹)'))
+ .setParameterLongDescription(
+ _('An impulse is like a speed addition but depends on the mass.')
+ )
+ .addParameter('expression', _('X position'))
+ .addParameter('expression', _('Y position'))
+ .addParameter('expression', _('Z position'))
+ .getCodeExtraInformation()
+ .setFunctionName('applyImpulseTowardPosition');
+
+ aut
+ .addScopedAction(
+ 'ApplyTorque',
+ _('Apply torque (rotational force)'),
+ _(
+ 'Apply a torque (also called "rotational force") to the object. It "accelerates" an object rotation and must be used every frame during a time period.'
+ ),
+ _('Apply a torque of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ an'),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Torque around X (N·m)'))
+ .addParameter('expression', _('Torque around Y (N·m)'))
+ .addParameter('expression', _('Torque around Z (N·m)'))
+ .setParameterLongDescription(
+ _('A torque is like a rotation acceleration but depends on the mass.')
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyTorque');
+
+ aut
+ .addScopedAction(
+ 'ApplyAngularImpulse',
+ _('Apply angular impulse (rotational impulse)'),
+ _(
+ 'Apply an angular impulse (also called a "rotational impulse") to the object. It instantly changes the rotation speed, to give an initial speed for instance.'
+ ),
+ _(
+ 'Apply angular impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ an'
+ ),
+ _('Forces & impulses'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('expression', _('Angular impulse around X (N·m·s)'))
+ .addParameter('expression', _('Angular impulse around Y (N·m·s)'))
+ .addParameter('expression', _('Angular impulse around Z (N·m·s)'))
+ .setParameterLongDescription(
+ _(
+ 'An impulse is like a rotation speed addition but depends on the mass.'
+ )
+ )
+ .getCodeExtraInformation()
+ .setFunctionName('applyAngularImpulse');
+
+ aut
+ .addExpression(
+ 'Mass',
+ _('Mass'),
+ _('Return the mass of the object (in kilograms)'),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getMass');
+
+ aut
+ .addExpression(
+ 'InertiaAroundX',
+ _('Inertia around X'),
+ _(
+ 'Return the inertia around X axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
+ ),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getInertiaAroundX');
+
+ aut
+ .addExpression(
+ 'InertiaAroundY',
+ _('Inertia around Y'),
+ _(
+ 'Return the inertia around Y axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
+ ),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getInertiaAroundY');
+
+ aut
+ .addExpression(
+ 'InertiaAroundZ',
+ _('Inertia around Z'),
+ _(
+ 'Return the inertia around Z axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
+ ),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getInertiaAroundZ');
+
+ aut
+ .addExpression(
+ 'MassCenterX',
+ _('Mass center X'),
+ _('Mass center X'),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getMassCenterX');
+
+ aut
+ .addExpression(
+ 'MassCenterY',
+ _('Mass center Y'),
+ _('Mass center Y'),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .getCodeExtraInformation()
+ .setFunctionName('getMassCenterY');
+ }
+ // Collision
+ extension
+ .addCondition(
+ 'Collision',
+ _('Collision'),
+ _('Check if two objects collide.'),
+ _('_PARAM0_ is colliding with _PARAM2_'),
+ '',
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addCodeOnlyParameter('conditionInverted', '')
+ .getCodeExtraInformation()
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
+ .addIncludeFile(
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
+ )
+ .setFunctionName('gdjs.physics3d.objectsCollide');
+
+ extension
+ .addCondition(
+ 'CollisionStarted',
+ _('Collision started'),
+ _('Check if two objects just started colliding during this frame.'),
+ _('_PARAM0_ started colliding with _PARAM2_'),
+ _('Collision'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addCodeOnlyParameter('conditionInverted', '')
+ .getCodeExtraInformation()
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
+ .addIncludeFile(
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
+ )
+ .setFunctionName('gdjs.physics3d.haveObjectsStartedColliding');
+
+ extension
+ .addCondition(
+ 'CollisionStopped',
+ _('Collision stopped'),
+ _('Check if two objects just stopped colliding at this frame.'),
+ _('_PARAM0_ stopped colliding with _PARAM2_'),
+ _('Collision'),
+ 'JsPlatform/Extensions/physics3d.svg',
+ 'JsPlatform/Extensions/physics3d.svg'
+ )
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addCodeOnlyParameter('conditionInverted', '')
+ .getCodeExtraInformation()
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
+ .addIncludeFile(
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
+ )
+ .setFunctionName('gdjs.physics3d.haveObjectsStoppedColliding');
+
+ {
+ const behavior = new gd.BehaviorJsImplementation();
+ behavior.updateProperty = function (
+ behaviorContent,
+ propertyName,
+ newValue
+ ) {
+ if (propertyName === 'Physics3D') {
+ behaviorContent.getChild('Physics3D').setStringValue(newValue);
+ return true;
+ }
+
+ if (propertyName === 'JumpHeight') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('jumpHeight')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'JumpSustainTime') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('jumpSustainTime')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'Gravity') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent.getChild('gravity').setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'FallingSpeedMax') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('fallingSpeedMax')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'ForwardAcceleration') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('forwardAcceleration')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'ForwardDeceleration') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('forwardDeceleration')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'ForwardSpeedMax') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('forwardSpeedMax')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'SidewaysAcceleration') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('sidewaysAcceleration')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'SidewaysDeceleration') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('sidewaysDeceleration')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'SidewaysSpeedMax') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('sidewaysSpeedMax')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ if (propertyName === 'SlopeMaxAngle') {
+ const newValueAsNumber = parseFloat(newValue);
+ if (newValueAsNumber !== newValueAsNumber) return false;
+ behaviorContent
+ .getChild('slopeMaxAngle')
+ .setDoubleValue(newValueAsNumber);
+ return true;
+ }
+
+ return false;
+ };
+ behavior.getProperties = function (behaviorContent) {
+ const behaviorProperties = new gd.MapStringPropertyDescriptor();
+
+ behaviorProperties
+ .getOrCreate('Physics3D')
+ .setValue(behaviorContent.getChild('Physics3D').getStringValue())
+ .setType('Behavior')
+ .setLabel('3D capability')
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .addExtraInfo('Physics3D::Physics3DBehavior');
+
+ behaviorProperties
+ .getOrCreate('JumpHeight')
+ .setLabel(_('Jump height'))
+ .setGroup(_('Jump'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
+ .setValue(
+ behaviorContent.getChild('jumpHeight').getDoubleValue().toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('JumpSustainTime')
+ .setLabel(_('Jump sustain time'))
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
+ .setGroup(_('Jump'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getSecond())
+ .setValue(
+ behaviorContent
+ .getChild('jumpSustainTime')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setDescription(
+ _(
+ 'Maximum time (in seconds) during which the jump strength is sustained if the jump key is held - allowing variable height jumps.'
+ )
+ );
+
+ behaviorProperties
+ .getOrCreate('Gravity')
+ .setLabel(_('Gravity'))
+ .setGroup(_('Jump'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
+ .setValue(
+ behaviorContent.getChild('gravity').getDoubleValue().toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('FallingSpeedMax')
+ .setLabel(_('Max. falling speed'))
+ .setGroup(_('Jump'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
+ .setValue(
+ behaviorContent
+ .getChild('fallingSpeedMax')
+ .getDoubleValue()
+ .toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('ForwardAcceleration')
+ .setLabel(_('Forward acceleration'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
+ .setValue(
+ behaviorContent
+ .getChild('forwardAcceleration')
+ .getDoubleValue()
+ .toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('ForwardDeceleration')
+ .setLabel(_('Forward deceleration'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
+ .setValue(
+ behaviorContent
+ .getChild('forwardDeceleration')
+ .getDoubleValue()
+ .toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('ForwardSpeedMax')
+ .setLabel(_('Max. forward speed'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
+ .setValue(
+ behaviorContent
+ .getChild('forwardSpeedMax')
+ .getDoubleValue()
+ .toString(10)
+ );
+
+ behaviorProperties
+ .getOrCreate('SidewaysAcceleration')
+ .setLabel(_('Sideways acceleration'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
+ .setValue(
+ behaviorContent
+ .getChild('sidewaysAcceleration')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setAdvanced(true);
+
+ behaviorProperties
+ .getOrCreate('SidewaysDeceleration')
+ .setLabel(_('Sideways deceleration'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
+ .setValue(
+ behaviorContent
+ .getChild('sidewaysDeceleration')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setAdvanced(true);
+
+ behaviorProperties
+ .getOrCreate('SidewaysSpeedMax')
+ .setLabel(_('Max. sideways speed'))
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
+ .setValue(
+ behaviorContent
+ .getChild('sidewaysSpeedMax')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setAdvanced(true);
+
+ behaviorProperties
+ .getOrCreate('SlopeMaxAngle')
+ .setLabel('Slope max. angle')
+ .setGroup(_('Walk'))
+ .setType('Number')
+ .setMeasurementUnit(gd.MeasurementUnit.getDegreeAngle())
+ .setValue(
+ behaviorContent
+ .getChild('slopeMaxAngle')
+ .getDoubleValue()
+ .toString(10)
+ )
+ .setAdvanced(true)
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden);
+
+ return behaviorProperties;
+ };
+
+ behavior.initializeContent = function (behaviorContent) {
+ behaviorContent.addChild('Physics3D').setStringValue('');
+ behaviorContent.addChild('jumpHeight').setDoubleValue(200);
+ behaviorContent.addChild('jumpSustainTime').setDoubleValue(0.2);
+ behaviorContent.addChild('gravity').setDoubleValue(1000);
+ behaviorContent.addChild('fallingSpeedMax').setDoubleValue(700);
+ behaviorContent.addChild('forwardAcceleration').setDoubleValue(1200);
+ behaviorContent.addChild('forwardDeceleration').setDoubleValue(1200);
+ behaviorContent.addChild('forwardSpeedMax').setDoubleValue(600);
+ behaviorContent.addChild('sidewaysAcceleration').setDoubleValue(800);
+ behaviorContent.addChild('sidewaysDeceleration').setDoubleValue(800);
+ behaviorContent.addChild('sidewaysSpeedMax').setDoubleValue(400);
+ behaviorContent.addChild('slopeMaxAngle').setDoubleValue(50);
+ // TODO Add a property to make the angle of movement follow the object angle.
+ };
+
+ const aut = extension
+ .addBehavior(
+ 'PhysicsCharacter3D',
+ _('3D physics character'),
+ 'PhysicsCharacter3D',
+ _('Jump and run on platforms.'),
+ '',
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'PhysicsCharacter3D',
+ //@ts-ignore The class hierarchy is incorrect leading to a type error, but this is valid.
+ behavior,
+ new gd.BehaviorsSharedData()
+ )
+ .addIncludeFile(
+ 'Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js'
+ );
+
+ aut
+ .addScopedAction(
+ 'SimulateForwardKey',
+ _('Simulate move forward key press'),
+ _('Simulate a press of the move forward key.'),
+ _('Simulate pressing Forward key for _PARAM0_'),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('simulateForwardKey');
+
+ aut
+ .addScopedAction(
+ 'SimulateBackwardKey',
+ _('Simulate move backward key press'),
+ _('Simulate a press of the move backward key.'),
+ _('Simulate pressing Backward key for _PARAM0_'),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('simulateBackwardKey');
+
+ aut
+ .addScopedAction(
+ 'SimulateRightKey',
+ _('Simulate move right key press'),
+ _('Simulate a press of the move right key.'),
+ _('Simulate pressing Right key for _PARAM0_'),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('simulateRightKey');
+
+ aut
+ .addScopedAction(
+ 'SimulateLeftKey',
+ _('Simulate move left key press'),
+ _('Simulate a press of the move left key.'),
+ _('Simulate pressing Left key for _PARAM0_'),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('simulateLeftKey');
+
+ aut
+ .addScopedAction(
+ 'SimulateJumpKey',
+ _('Simulate jump key press'),
+ _('Simulate a press of the jump key.'),
+ _('Simulate pressing Jump key for _PARAM0_'),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('simulateJumpKey');
+
+ aut
+ .addScopedAction(
+ 'SimulateStick',
+ _('Simulate stick control'),
+ _('Simulate a stick control.'),
+ _(
+ 'Simulate a stick control for _PARAM0_ with a _PARAM2_ angle and a _PARAM3_ force'
+ ),
+ _('Character controls'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .addParameter('expression', _('Stick angle (in degrees)'))
+ .addParameter('expression', _('Stick force (between 0 and 1)'))
+ .markAsAdvanced()
+ .setFunctionName('simulateStick');
+
+ aut
+ .addScopedAction(
+ 'SetCanJump',
+ _('Allow jumping again'),
+ _(
+ "When this action is executed, the object is able to jump again, even if it is in the air: this can be useful to allow a double jump for example. This is not a permanent effect: you must call again this action every time you want to allow the object to jump (apart if it's on the floor)."
+ ),
+ _('Allow _PARAM0_ to jump again'),
+ _('Platformer state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .markAsSimple()
+ .setFunctionName('setCanJump');
+
+ aut
+ .addScopedAction(
+ 'SetCanNotAirJump',
+ _('Forbid jumping again in the air'),
+ _(
+ 'This revokes the effect of "Allow jumping again". The object is made unable to jump while in mid air. This has no effect if the object is not in the air.'
+ ),
+ _('Forbid _PARAM0_ to air jump'),
+ _('Platformer state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('setCanNotAirJump');
+
+ aut
+ .addScopedAction(
+ 'AbortJump',
+ _('Abort jump'),
+ _(
+ "Abort the current jump and stop the object vertically. This action doesn't have any effect when the character is not jumping."
+ ),
+ _('Abort the current jump of _PARAM0_'),
+ _('Platformer state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('abortJump');
+
+ aut
+ .addScopedCondition(
+ 'CanJump',
+ _('Can jump'),
+ _('Check if the object can jump.'),
+ _('_PARAM0_ can jump'),
+ _('Platformer state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .markAsSimple()
+ .setFunctionName('canJump');
+
+ aut
+ .addScopedCondition(
+ 'IsMovingEvenALittle',
+ _('Is moving'),
+ _(
+ 'Check if the object is moving (whether it is on the floor or in the air).'
+ ),
+ _('_PARAM0_ is moving'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .markAsSimple()
+ .setFunctionName('isMovingEvenALittle');
+
+ aut
+ .addScopedCondition(
+ 'IsOnFloor',
+ _('Is on floor'),
+ _('Check if the object is on a platform.'),
+ _('_PARAM0_ is on floor'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .markAsSimple()
+ .setFunctionName('isOnFloor');
+
+ aut
+ .addScopedCondition(
+ 'IsJumping',
+ _('Is jumping'),
+ _('Check if the object is jumping.'),
+ _('_PARAM0_ is jumping'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .markAsSimple()
+ .setFunctionName('isJumping');
+
+ aut
+ .addScopedCondition(
+ 'IsFalling',
+ _('Is falling'),
+ _(
+ 'Check if the object is falling.\nNote that the object can be flagged as jumping and falling at the same time: at the end of a jump, the fall speed becomes higher than the jump speed.'
+ ),
+ _('_PARAM0_ is falling'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('isFalling');
+
+ aut
+ .addScopedCondition(
+ 'IsForwardAngleAround',
+ _('Forward angle'),
+ _('Compare the angle used by the character to go forward.'),
+ _('Forward angle of _PARAM0_ is _PARAM2_ ± _PARAM3_°'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .addParameter('expression', _('Angle (in degrees)'))
+ .addParameter('expression', _('Tolerance (in degrees)'))
+ .setFunctionName('isForwardAngleAround');
+
+ aut
+ .addScopedAction(
+ 'SetForwardAngle',
+ _('Forward angle'),
+ _('Change the angle used by the character to go forward.'),
+ _('the forward angle'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardOperatorParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Angle (in degrees)')
+ )
+ )
+ .setFunctionName('setForwardAngle')
+ .setGetter('getForwardAngle');
+
+ aut
+ .addExpression(
+ 'ForwardAngle',
+ _('Forward angle of the character'),
+ _('Return the angle used by the character to go forward.'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .setFunctionName('getForwardAngle');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'CurrentForwardSpeed',
+ _('Current forward speed'),
+ _(
+ 'the current forward speed of the object. The object moves backward with negative values and forward with positive ones'
+ ),
+ _('the current forward speed'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setCurrentForwardSpeed')
+ .setGetter('getCurrentForwardSpeed');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'ForwardAcceleration',
+ _('Forward acceleration'),
+ _('the forward acceleration of an object.'),
+ _('the forward acceleration'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Acceleration (in pixels per second per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setForwardAcceleration')
+ .setGetter('getForwardAcceleration');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'ForwardDeceleration',
+ _('Forward deceleration'),
+ _('the forward deceleration of an object.'),
+ _('the forward deceleration'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Deceleration (in pixels per second per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setForwardDeceleration')
+ .setGetter('getForwardDeceleration');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'ForwardSpeedMax',
+ _('Forward max speed'),
+ _('the forward max speed of the object.'),
+ _('the forward max speed'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setForwardSpeedMax')
+ .setGetter('getForwardSpeedMax');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'CurrentSidewaysSpeed',
+ _('Current sideways speed'),
+ _(
+ 'the current sideways speed of the object. The object moves to the left with negative values and to the right with positive ones'
+ ),
+ _('the current sideways speed'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setCurrentSidewaysSpeed')
+ .setGetter('getCurrentSidewaysSpeed');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'SidewaysAcceleration',
+ _('Sideways acceleration'),
+ _('the sideways acceleration of an object.'),
+ _('the sideways acceleration'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Acceleration (in pixels per second per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setSidewaysAcceleration')
+ .setGetter('getSidewaysAcceleration');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'SidewaysDeceleration',
+ _('Sideways deceleration'),
+ _('the sideways deceleration of an object.'),
+ _('the sideways deceleration'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Deceleration (in pixels per second per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setSidewaysDeceleration')
+ .setGetter('getSidewaysDeceleration');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'SidewaysSpeedMax',
+ _('Sideways max speed'),
+ _('the sideways max speed of the object.'),
+ _('the sideways max speed'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setSidewaysSpeedMax')
+ .setGetter('getSidewaysSpeedMax');
+
+ aut
+ .addExpressionAndCondition(
+ 'number',
+ 'CurrentFallSpeed',
+ _('Current falling speed'),
+ _(
+ 'Compare the current falling speed of the object. Its value is always positive.'
+ ),
+ _('the current falling speed'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed to compare to (in pixels per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('getCurrentFallSpeed');
+
+ aut
+ .addScopedAction(
+ 'SetCurrentFallSpeed',
+ _('Current falling speed'),
+ _(
+ "Change the current falling speed of the object. This action doesn't have any effect when the character is not falling or is in the first phase of a jump."
+ ),
+ _('the current falling speed'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardOperatorParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setCurrentFallSpeed')
+ .setGetter('getCurrentFallSpeed');
+
+ aut
+ .addExpressionAndCondition(
+ 'number',
+ 'CurrentJumpSpeed',
+ _('Current jump speed'),
+ _(
+ 'Compare the current jump speed of the object. Its value is always positive.'
+ ),
+ _('the current jump speed'),
+ _('Character state'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed to compare to (in pixels per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('getCurrentJumpSpeed');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'JumpSpeed',
+ _('Jump speed'),
+ _('the jump speed of an object. Its value is always positive.'),
+ _('the jump speed'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Speed (in pixels per second)')
+ )
+ )
+ .setFunctionName('setJumpSpeed')
+ .setGetter('getJumpSpeed');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'JumpSustainTime',
+ _('Jump sustain time'),
+ _(
+ 'the jump sustain time of an object. This is the time during which keeping the jump button held allow the initial jump speed to be maintained.'
+ ),
+ _('the jump sustain time'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Duration (in seconds)')
+ )
+ )
+ .setFunctionName('setJumpSustainTime')
+ .setGetter('getJumpSustainTime');
+
+ aut
+ .addExpressionAndConditionAndAction(
+ 'number',
+ 'Gravity',
+ _('Gravity'),
+ _('the gravity applied on an object.'),
+ _('the gravity'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Gravity (in pixels per second per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('setGravity')
+ .setGetter('getGravity');
+
+ aut
+ .addExpressionAndCondition(
+ 'number',
+ 'FallingSpeedMax',
+ _('Maximum falling speed'),
+ _('the maximum falling speed of an object.'),
+ _('the maximum falling speed'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Max speed (in pixels per second)')
+ )
+ )
+ .markAsAdvanced()
+ .setFunctionName('getMaxFallingSpeed');
+
+ aut
+ .addScopedAction(
+ 'FallingSpeedMax',
+ _('Maximum falling speed'),
+ _('Change the maximum falling speed of an object.'),
+ _('the maximum falling speed'),
+ _('Character configuration'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('object', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .useStandardOperatorParameters(
+ 'number',
+ gd.ParameterOptions.makeNewOptions().setDescription(
+ _('Max speed (in pixels per second)')
+ )
+ )
+ .addParameter(
+ 'yesorno',
+ _('If jumping, try to preserve the current speed in the air')
+ )
+ .markAsAdvanced()
+ .setFunctionName('setMaxFallingSpeed')
+ .setGetter('getMaxFallingSpeed');
+ }
+
+ extension
+ .addCondition(
+ 'IsObjectOnGivenFloor',
+ _('Character is on given platform'),
+ _('Check if a platformer character is on a given platform.'),
+ _('_PARAM0_ is on platform _PARAM2_'),
+ _('Collision'),
+ 'JsPlatform/Extensions/physics_character3d.svg',
+ 'JsPlatform/Extensions/physics_character3d.svg'
+ )
+ .addParameter('objectList', _('Object'), '', false)
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
+ .addParameter('objectList', _('Platforms'), '', false)
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
+ .addCodeOnlyParameter('conditionInverted', '')
+ .setFunctionName('gdjs.physics3d.isOnPlatform')
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js');
+
+ return extension;
+ },
+
+ runExtensionSanityTests: function (gd, extension) {
+ const dummyBehavior = extension
+ .getBehaviorMetadata('Physics3D::Physics3DBehavior')
+ .get();
+ const sharedData = extension
+ .getBehaviorMetadata('Physics3D::Physics3DBehavior')
+ .getSharedDataInstance();
+ return [
+ gd.ProjectHelper.sanityCheckBehaviorProperty(
+ dummyBehavior,
+ 'density',
+ '123'
+ ),
+ gd.ProjectHelper.sanityCheckBehaviorsSharedDataProperty(
+ sharedData,
+ 'gravityY',
+ '456'
+ ),
+ ];
+ },
+};
diff --git a/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.ts b/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.ts
new file mode 100644
index 000000000000..d524e0c9d875
--- /dev/null
+++ b/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.ts
@@ -0,0 +1,1795 @@
+///
+
+namespace Jolt {
+ export interface Body {
+ gdjsAssociatedBehavior: gdjs.Physics3DRuntimeBehavior | null;
+ }
+}
+
+namespace gdjs {
+ gdjs.registerAsynchronouslyLoadingLibraryPromise(
+ new Promise((resolve) => {
+ const tryInitializeJoltPhysics = () => {
+ // @ts-ignore
+ if (globalThis.initializeJoltPhysics) {
+ resolve(
+ // @ts-ignore
+ globalThis.initializeJoltPhysics().then((Jolt: any) => {
+ window.Jolt = Jolt;
+ })
+ );
+ return;
+ }
+ // Jolt is not ready yet, wait another 200ms
+ setTimeout(tryInitializeJoltPhysics, 200);
+ };
+ tryInitializeJoltPhysics();
+ })
+ );
+
+ export interface RuntimeScene {
+ physics3DSharedData: gdjs.Physics3DSharedData | null;
+ }
+ interface Physics3DNetworkSyncDataType {
+ px: number | undefined;
+ py: number | undefined;
+ pz: number | undefined;
+ rx: number | undefined;
+ ry: number | undefined;
+ rz: number | undefined;
+ rw: number | undefined;
+ lvx: number | undefined;
+ lvy: number | undefined;
+ lvz: number | undefined;
+ avx: number | undefined;
+ avy: number | undefined;
+ avz: number | undefined;
+ aw: boolean | undefined;
+ layers: number;
+ masks: number;
+ }
+
+ export interface Physics3DNetworkSyncData extends BehaviorNetworkSyncData {
+ props: Physics3DNetworkSyncDataType;
+ }
+
+ export class Physics3DSharedData {
+ gravityX: float;
+ gravityY: float;
+ gravityZ: float;
+ worldScale: float;
+ worldInvScale: float;
+
+ jolt: Jolt.JoltInterface;
+ physicsSystem: Jolt.PhysicsSystem;
+ bodyInterface: Jolt.BodyInterface;
+ /** Contact listener to keep track of current collisions */
+ contactListener: Jolt.ContactListenerJS;
+ /** Avoid creating new vectors all the time */
+ _tempVec3 = new Jolt.Vec3();
+ _tempRVec3 = new Jolt.RVec3();
+ _tempQuat = new Jolt.Quat();
+
+ stepped: boolean = false;
+ /**
+ * List of physics behavior in the runtimeScene. It should be updated
+ * when a new physics object is created (constructor), on destruction (onDestroy),
+ * on behavior activation (onActivate) and on behavior deactivation (onDeActivate).
+ */
+ _registeredBehaviors: Set;
+
+ private _physics3DHooks: Array<
+ gdjs.Physics3DRuntimeBehavior.Physics3DHook
+ > = [];
+
+ constructor(instanceContainer: gdjs.RuntimeInstanceContainer, sharedData) {
+ this._registeredBehaviors = new Set();
+ this.gravityX = sharedData.gravityX;
+ this.gravityY = sharedData.gravityY;
+ this.gravityZ = sharedData.gravityZ;
+ this.worldScale = sharedData.worldScale;
+ this.worldInvScale = 1 / this.worldScale;
+
+ // Initialize Jolt
+ const settings = new Jolt.JoltSettings();
+ gdjs.Physics3DSharedData.setupCollisionFiltering(settings);
+ this.jolt = new Jolt.JoltInterface(settings);
+ Jolt.destroy(settings);
+ this.physicsSystem = this.jolt.GetPhysicsSystem();
+ this.physicsSystem.SetGravity(
+ this.getVec3(this.gravityX, this.gravityY, this.gravityZ)
+ );
+ this.bodyInterface = this.physicsSystem.GetBodyInterface();
+
+ this.contactListener = new Jolt.ContactListenerJS();
+ this.physicsSystem.SetContactListener(this.contactListener);
+ this.contactListener.OnContactAdded = (
+ bodyPtrA: number,
+ bodyPtrB: number,
+ manifoldPtr: number,
+ settingsPtr: number
+ ): void => {
+ const bodyA = Jolt.wrapPointer(bodyPtrA, Jolt.Body);
+ const bodyB = Jolt.wrapPointer(bodyPtrB, Jolt.Body);
+
+ const behaviorA = bodyA.gdjsAssociatedBehavior;
+ const behaviorB = bodyB.gdjsAssociatedBehavior;
+ if (!behaviorA || !behaviorB) {
+ return;
+ }
+
+ behaviorA.onContactBegin(behaviorB);
+ behaviorB.onContactBegin(behaviorA);
+ };
+ this.contactListener.OnContactRemoved = (
+ subShapePairPtr: number
+ ): void => {
+ const subShapePair = Jolt.wrapPointer(
+ subShapePairPtr,
+ Jolt.SubShapeIDPair
+ );
+
+ // This is ok because bodies are not deleted during the Physics step.
+ const bodyLockInterface = this.physicsSystem.GetBodyLockInterface();
+ const bodyA = bodyLockInterface.TryGetBody(subShapePair.GetBody1ID());
+ const bodyB = bodyLockInterface.TryGetBody(subShapePair.GetBody2ID());
+
+ const behaviorA = bodyA.gdjsAssociatedBehavior;
+ const behaviorB = bodyB.gdjsAssociatedBehavior;
+ if (!behaviorA || !behaviorB) {
+ return;
+ }
+
+ behaviorA.onContactEnd(behaviorB);
+ behaviorB.onContactEnd(behaviorA);
+ };
+ this.contactListener.OnContactPersisted = (
+ bodyPtrA: number,
+ bodyPtrB: number,
+ manifoldPtr: number,
+ settingsPtr: number
+ ): void => {
+ // TODO we could rely on this event.
+ };
+ this.contactListener.OnContactValidate = (
+ bodyPtrA: number,
+ bodyPtrB: number,
+ inBaseOffset: number,
+ inCollisionResult: number
+ ): number => {
+ return Jolt.ValidateResult_AcceptAllContactsForThisBodyPair;
+ };
+ }
+
+ getVec3(x: float, y: float, z: float): Jolt.Vec3 {
+ const tempVec3 = this._tempVec3;
+ tempVec3.Set(x, y, z);
+ return tempVec3;
+ }
+
+ getRVec3(x: float, y: float, z: float): Jolt.RVec3 {
+ const tempRVec3 = this._tempRVec3;
+ tempRVec3.Set(x, y, z);
+ return tempRVec3;
+ }
+
+ getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {
+ const tempQuat = this._tempQuat;
+ tempQuat.Set(x, y, z, w);
+ return tempQuat;
+ }
+
+ static getSharedData(
+ runtimeScene: gdjs.RuntimeScene,
+ behaviorName: string
+ ): gdjs.Physics3DSharedData {
+ // Create one if needed
+ if (!runtimeScene.physics3DSharedData) {
+ const initialData = runtimeScene.getInitialSharedDataForBehavior(
+ behaviorName
+ );
+ runtimeScene.physics3DSharedData = new gdjs.Physics3DSharedData(
+ runtimeScene,
+ initialData
+ );
+ }
+ return runtimeScene.physics3DSharedData;
+ }
+
+ // There are 4 bits for static layers and 4 bits for dynamic layers.
+ static readonly staticLayersMask = 0x0f;
+ static readonly dynamicLayersMask = 0xf0;
+ static readonly allLayersMask = 0xff;
+ static readonly staticBroadPhaseLayerIndex = 1;
+ static readonly dynamicBroadPhaseLayerIndex = 1;
+
+ static setupCollisionFiltering(settings: Jolt.JoltSettings) {
+ const objectFilter = new Jolt.ObjectLayerPairFilterMask();
+ const staticBroadPhaseLayer = new Jolt.BroadPhaseLayer(
+ gdjs.Physics3DSharedData.staticBroadPhaseLayerIndex
+ );
+ const dynamicBroadPhaseLayer = new Jolt.BroadPhaseLayer(
+ gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex
+ );
+ const broadPhaseLayerInterfaceMask = new Jolt.BroadPhaseLayerInterfaceMask(
+ 2
+ );
+ broadPhaseLayerInterfaceMask.ConfigureLayer(
+ staticBroadPhaseLayer,
+ gdjs.Physics3DSharedData.staticLayersMask,
+ 0
+ );
+ broadPhaseLayerInterfaceMask.ConfigureLayer(
+ dynamicBroadPhaseLayer,
+ gdjs.Physics3DSharedData.dynamicLayersMask,
+ 0
+ );
+ // BroadPhaseLayer have been copied into bpInterface
+ Jolt.destroy(staticBroadPhaseLayer);
+ Jolt.destroy(dynamicBroadPhaseLayer);
+
+ settings.mObjectLayerPairFilter = objectFilter;
+ settings.mBroadPhaseLayerInterface = broadPhaseLayerInterfaceMask;
+ settings.mObjectVsBroadPhaseLayerFilter = new Jolt.ObjectVsBroadPhaseLayerFilterMask(
+ broadPhaseLayerInterfaceMask
+ );
+ }
+
+ /**
+ * Add a physics object to the list of existing object.
+ */
+ addToBehaviorsList(physicsBehavior: gdjs.Physics3DRuntimeBehavior): void {
+ this._registeredBehaviors.add(physicsBehavior);
+ }
+
+ /**
+ * Remove a physics object to the list of existing object.
+ */
+ removeFromBehaviorsList(
+ physicsBehavior: gdjs.Physics3DRuntimeBehavior
+ ): void {
+ this._registeredBehaviors.delete(physicsBehavior);
+ }
+
+ step(deltaTime: float): void {
+ // Reset started and ended contacts array for all physics instances.
+ for (const physicsBehavior of this._registeredBehaviors) {
+ physicsBehavior.contactsStartedThisFrame.length = 0;
+ physicsBehavior.contactsEndedThisFrame.length = 0;
+ }
+ for (const physicsBehavior of this._registeredBehaviors) {
+ physicsBehavior.updateBodyFromObject();
+ }
+ for (const physics3DHook of this._physics3DHooks) {
+ physics3DHook.doBeforePhysicsStep(deltaTime);
+ }
+
+ // When running below 55 Hz, do 2 steps instead of 1
+ const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;
+
+ // Step the physics world
+ this.jolt.Step(deltaTime, numSteps);
+ this.stepped = true;
+
+ // It's important that updateBodyFromObject and updateObjectFromBody are
+ // called at the same time because other behavior may move the object in
+ // their doStepPreEvents.
+ for (const physicsBehavior of this._registeredBehaviors) {
+ physicsBehavior.updateObjectFromBody();
+ }
+ }
+
+ /**
+ * A hook must typically be registered by a behavior that requires this one
+ * in its onCreate function.
+ * The hook must stay forever to avoid side effects like a hooks order
+ * change. To handle deactivated behavior, the hook can check that its
+ * behavior is activated before doing anything.
+ */
+ registerHook(hook: gdjs.Physics3DRuntimeBehavior.Physics3DHook) {
+ this._physics3DHooks.push(hook);
+ }
+ }
+ gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {
+ const physics3DSharedData = runtimeScene.physics3DSharedData;
+ if (physics3DSharedData) {
+ Jolt.destroy(physics3DSharedData.jolt);
+ Jolt.destroy(physics3DSharedData.contactListener);
+ Jolt.destroy(physics3DSharedData._tempVec3);
+ Jolt.destroy(physics3DSharedData._tempRVec3);
+ Jolt.destroy(physics3DSharedData._tempQuat);
+ runtimeScene.physics3DSharedData = null;
+ }
+ });
+
+ export class Physics3DRuntimeBehavior extends gdjs.RuntimeBehavior {
+ bodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;
+ owner3D: gdjs.RuntimeObject3D;
+
+ bodyType: string;
+ bullet: boolean;
+ fixedRotation: boolean;
+ shape: string;
+ shapeOrientation: string;
+ shapeDimensionA: any;
+ shapeDimensionB: any;
+ shapeDimensionC: any;
+ density: float;
+ friction: float;
+ restitution: float;
+ linearDamping: float;
+ angularDamping: float;
+ gravityScale: float;
+ layers: integer;
+ masks: integer;
+ shapeScale: number = 1;
+
+ /**
+ * Array containing the beginning of contacts reported by onContactBegin. Each contact
+ * should be unique to avoid recording glitches where the object loses and regain
+ * contact between two frames. The array is updated each time the method
+ * onContactBegin is called by the listener, which is only called when stepping
+ * the world i.e. in the first preEvent called by a physics behavior. This array is
+ * cleared just before stepping the world.
+ */
+ contactsStartedThisFrame: Array = [];
+
+ /**
+ * Array containing the end of contacts reported by onContactEnd. The array is updated
+ * each time the method onContactEnd is called by the listener, which can be called at
+ * any time. This array is cleared just before stepping the world.
+ */
+ contactsEndedThisFrame: Array = [];
+
+ /**
+ * Array containing the exact current contacts with the objects. It is updated
+ * each time the methods onContactBegin and onContactEnd are called by the contact
+ * listener.
+ */
+ currentContacts: Array = [];
+
+ destroyedDuringFrameLogic: boolean;
+ _body: Jolt.Body | null = null;
+ needToRecreateBody: boolean = false;
+ needToRecreateShape: boolean = false;
+ shapeHalfDepth: float = 0;
+
+ /**
+ * sharedData is a reference to the shared data of the scene, that registers
+ * every physics behavior that is created so that collisions can be cleared
+ * before stepping the world.
+ */
+ _sharedData: Physics3DSharedData;
+
+ _objectOldX: float = 0;
+ _objectOldY: float = 0;
+ _objectOldZ: float = 0;
+ _objectOldRotationX: float = 0;
+ _objectOldRotationY: float = 0;
+ _objectOldRotationZ: float = 0;
+ _objectOldWidth: float = 0;
+ _objectOldHeight: float = 0;
+ _objectOldDepth: float = 0;
+
+ constructor(
+ instanceContainer: gdjs.RuntimeInstanceContainer,
+ behaviorData,
+ owner: gdjs.RuntimeObject3D
+ ) {
+ super(instanceContainer, behaviorData, owner);
+ this.bodyUpdater = new gdjs.Physics3DRuntimeBehavior.DefaultBodyUpdater(
+ this
+ );
+ this.owner3D = owner;
+ this.bodyType = behaviorData.bodyType;
+ this.bullet = behaviorData.bullet;
+ this.fixedRotation = behaviorData.fixedRotation;
+ this.shape = behaviorData.shape;
+ this.shapeOrientation = behaviorData.shapeOrientation;
+ this.shapeDimensionA = behaviorData.shapeDimensionA;
+ this.shapeDimensionB = behaviorData.shapeDimensionB;
+ this.shapeDimensionC = behaviorData.shapeDimensionC;
+ this.density = behaviorData.density;
+ this.friction = behaviorData.friction;
+ this.restitution = behaviorData.restitution;
+ this.linearDamping = Math.max(0, behaviorData.linearDamping);
+ this.angularDamping = Math.max(0, behaviorData.angularDamping);
+ this.gravityScale = behaviorData.gravityScale;
+ this.layers = behaviorData.layers;
+ this.masks = behaviorData.masks;
+ this.destroyedDuringFrameLogic = false;
+ this._sharedData = Physics3DSharedData.getSharedData(
+ instanceContainer.getScene(),
+ behaviorData.name
+ );
+ this._sharedData.addToBehaviorsList(this);
+ }
+
+ private getVec3(x: float, y: float, z: float): Jolt.Vec3 {
+ const tempVec3 = this._sharedData._tempVec3;
+ tempVec3.Set(x, y, z);
+ return tempVec3;
+ }
+
+ private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {
+ const tempRVec3 = this._sharedData._tempRVec3;
+ tempRVec3.Set(x, y, z);
+ return tempRVec3;
+ }
+
+ private getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {
+ const tempQuat = this._sharedData._tempQuat;
+ tempQuat.Set(x, y, z, w);
+ return tempQuat;
+ }
+
+ updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {
+ if (oldBehaviorData.bullet !== newBehaviorData.bullet) {
+ this.setBullet(newBehaviorData.bullet);
+ }
+ if (oldBehaviorData.fixedRotation !== newBehaviorData.fixedRotation) {
+ this.setFixedRotation(newBehaviorData.fixedRotation);
+ }
+ if (oldBehaviorData.shapeDimensionA !== newBehaviorData.shapeDimensionA) {
+ this.shapeDimensionA = newBehaviorData.shapeDimensionA;
+ this.needToRecreateShape = true;
+ }
+ if (oldBehaviorData.shapeDimensionB !== newBehaviorData.shapeDimensionB) {
+ this.shapeDimensionB = newBehaviorData.shapeDimensionB;
+ this.needToRecreateShape = true;
+ }
+ if (oldBehaviorData.density !== newBehaviorData.density) {
+ this.setDensity(newBehaviorData.density);
+ }
+ if (oldBehaviorData.friction !== newBehaviorData.friction) {
+ this.setFriction(newBehaviorData.friction);
+ }
+ if (oldBehaviorData.restitution !== newBehaviorData.restitution) {
+ this.setRestitution(newBehaviorData.restitution);
+ }
+ if (oldBehaviorData.linearDamping !== newBehaviorData.linearDamping) {
+ this.setLinearDamping(newBehaviorData.linearDamping);
+ }
+ if (oldBehaviorData.angularDamping !== newBehaviorData.angularDamping) {
+ this.setAngularDamping(newBehaviorData.angularDamping);
+ }
+ if (oldBehaviorData.gravityScale !== newBehaviorData.gravityScale) {
+ this.setGravityScale(newBehaviorData.gravityScale);
+ }
+
+ // TODO: make these properties updatable.
+ if (oldBehaviorData.layers !== newBehaviorData.layers) {
+ return false;
+ }
+ if (oldBehaviorData.masks !== newBehaviorData.masks) {
+ return false;
+ }
+ if (oldBehaviorData.vertices !== newBehaviorData.vertices) {
+ return false;
+ }
+ if (oldBehaviorData.bodyType !== newBehaviorData.bodyType) {
+ return false;
+ }
+ if (oldBehaviorData.shape !== newBehaviorData.shape) {
+ return false;
+ }
+ return true;
+ }
+
+ getNetworkSyncData(): Physics3DNetworkSyncData {
+ let bodyProps;
+ if (this._body) {
+ const position = this._body.GetPosition();
+ const rotation = this._body.GetRotation();
+ const linearVelocity = this._body.GetLinearVelocity();
+ const angularVelocity = this._body.GetAngularVelocity();
+ bodyProps = {
+ px: position.GetX(),
+ py: position.GetY(),
+ pz: position.GetZ(),
+ rx: rotation.GetX(),
+ ry: rotation.GetY(),
+ rz: rotation.GetZ(),
+ rw: rotation.GetW(),
+ lvx: linearVelocity.GetX(),
+ lvy: linearVelocity.GetY(),
+ lvz: linearVelocity.GetZ(),
+ avx: angularVelocity.GetX(),
+ avy: angularVelocity.GetY(),
+ avz: angularVelocity.GetZ(),
+ aw: this._body.IsActive(),
+ };
+ } else {
+ bodyProps = {
+ px: undefined,
+ py: undefined,
+ pz: undefined,
+ rx: undefined,
+ ry: undefined,
+ rz: undefined,
+ rw: undefined,
+ lvx: undefined,
+ lvy: undefined,
+ lvz: undefined,
+ avx: undefined,
+ avy: undefined,
+ avz: undefined,
+ aw: undefined,
+ };
+ }
+ return {
+ ...super.getNetworkSyncData(),
+ props: {
+ ...bodyProps,
+ layers: this.layers,
+ masks: this.masks,
+ },
+ };
+ }
+
+ updateFromNetworkSyncData(networkSyncData: Physics3DNetworkSyncData) {
+ super.updateFromNetworkSyncData(networkSyncData);
+
+ const behaviorSpecificProps = networkSyncData.props;
+ if (
+ behaviorSpecificProps.px !== undefined &&
+ behaviorSpecificProps.py !== undefined &&
+ behaviorSpecificProps.pz !== undefined
+ ) {
+ if (this._body) {
+ this._sharedData.bodyInterface.SetPosition(
+ this._body.GetID(),
+ this.getVec3(
+ behaviorSpecificProps.px,
+ behaviorSpecificProps.py,
+ behaviorSpecificProps.pz
+ ),
+ Jolt.EActivation_DontActivate
+ );
+ }
+ }
+ if (
+ behaviorSpecificProps.rx !== undefined &&
+ behaviorSpecificProps.ry !== undefined &&
+ behaviorSpecificProps.rz !== undefined &&
+ behaviorSpecificProps.rw !== undefined
+ ) {
+ if (this._body) {
+ this._sharedData.bodyInterface.SetRotation(
+ this._body.GetID(),
+ this.getQuat(
+ behaviorSpecificProps.rx,
+ behaviorSpecificProps.ry,
+ behaviorSpecificProps.rz,
+ behaviorSpecificProps.rw
+ ),
+ Jolt.EActivation_DontActivate
+ );
+ }
+ }
+ if (
+ behaviorSpecificProps.lvx !== undefined &&
+ behaviorSpecificProps.lvy !== undefined &&
+ behaviorSpecificProps.lvz !== undefined
+ ) {
+ if (this._body) {
+ this._sharedData.bodyInterface.SetLinearVelocity(
+ this._body.GetID(),
+ this.getVec3(
+ behaviorSpecificProps.lvx,
+ behaviorSpecificProps.lvy,
+ behaviorSpecificProps.lvz
+ )
+ );
+ }
+ }
+ if (
+ behaviorSpecificProps.avx !== undefined &&
+ behaviorSpecificProps.avy !== undefined &&
+ behaviorSpecificProps.avz !== undefined
+ ) {
+ if (this._body) {
+ this._sharedData.bodyInterface.SetAngularVelocity(
+ this._body.GetID(),
+ this.getVec3(
+ behaviorSpecificProps.avx,
+ behaviorSpecificProps.avy,
+ behaviorSpecificProps.avz
+ )
+ );
+ }
+ }
+ if (behaviorSpecificProps.layers !== undefined) {
+ this.layers = behaviorSpecificProps.layers;
+ }
+ if (behaviorSpecificProps.masks !== undefined) {
+ this.masks = behaviorSpecificProps.masks;
+ }
+ }
+
+ onDeActivate() {
+ this._sharedData.removeFromBehaviorsList(this);
+ if (this._body !== null) {
+ this._sharedData.bodyInterface.RemoveBody(this._body.GetID());
+ this._sharedData.bodyInterface.DestroyBody(this._body.GetID());
+ this._body = null;
+ }
+ this.contactsEndedThisFrame.length = 0;
+ this.contactsStartedThisFrame.length = 0;
+ this.currentContacts.length = 0;
+ }
+
+ onActivate() {
+ this._sharedData.addToBehaviorsList(this);
+
+ this.contactsEndedThisFrame.length = 0;
+ this.contactsStartedThisFrame.length = 0;
+ this.currentContacts.length = 0;
+ this.updateBodyFromObject();
+ }
+
+ onDestroy() {
+ this.destroyedDuringFrameLogic = true;
+ this.onDeActivate();
+ }
+
+ createShape(offsetZ: float = 0): Jolt.Shape {
+ let width = this.owner3D.getWidth() * this._sharedData.worldInvScale;
+ let height = this.owner3D.getHeight() * this._sharedData.worldInvScale;
+ let depth = this.owner3D.getDepth() * this._sharedData.worldInvScale;
+ if (this.shapeOrientation === 'X') {
+ const swap = depth;
+ depth = width;
+ width = swap;
+ } else if (this.shapeOrientation === 'Y') {
+ const swap = depth;
+ depth = height;
+ height = swap;
+ }
+
+ const shapeScale = this.shapeScale * this._sharedData.worldInvScale;
+
+ const shapeDimensionA = this.shapeDimensionA * shapeScale;
+ const shapeDimensionB = this.shapeDimensionB * shapeScale;
+ const shapeDimensionC = this.shapeDimensionC * shapeScale;
+
+ const onePixel = this._sharedData.worldInvScale;
+
+ let shapeSettings: Jolt.ConvexShapeSettings;
+ /** This is fine only because no other Quat is used locally. */
+ let quat: Jolt.Quat;
+ if (this.shape === 'Box') {
+ const boxWidth =
+ shapeDimensionA > 0 ? shapeDimensionA : width > 0 ? width : onePixel;
+ const boxHeight =
+ shapeDimensionB > 0
+ ? shapeDimensionB
+ : height > 0
+ ? height
+ : onePixel;
+ const boxDepth =
+ shapeDimensionC > 0 ? shapeDimensionC : depth > 0 ? depth : onePixel;
+ // The convex radius should not eat up the whole volume.
+ const convexRadius = Math.min(
+ onePixel,
+ Math.min(boxWidth, boxHeight, boxDepth) / 4
+ );
+ shapeSettings = new Jolt.BoxShapeSettings(
+ this.getVec3(boxWidth / 2, boxHeight / 2, boxDepth / 2),
+ convexRadius
+ );
+ quat = this.getQuat(0, 0, 0, 1);
+ this.shapeHalfDepth = boxDepth / 2;
+ } else if (this.shape === 'Capsule') {
+ const radius =
+ shapeDimensionA > 0
+ ? shapeDimensionA
+ : width > 0
+ ? Math.sqrt(width * height) / 2
+ : onePixel;
+ const capsuleDepth =
+ shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;
+ shapeSettings = new Jolt.CapsuleShapeSettings(
+ Math.max(0, capsuleDepth / 2 - radius),
+ radius
+ );
+ quat = this._getShapeOrientationQuat();
+ this.shapeHalfDepth =
+ this.shapeOrientation !== 'Z' ? radius : capsuleDepth / 2;
+ } else if (this.shape === 'Cylinder') {
+ const radius =
+ shapeDimensionA > 0
+ ? shapeDimensionA
+ : width > 0
+ ? Math.sqrt(width * height) / 2
+ : onePixel;
+ const cylinderDepth =
+ shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;
+ // The convex radius should not eat up the whole volume.
+ const convexRadius = Math.min(
+ onePixel,
+ Math.min(cylinderDepth, radius) / 4
+ );
+ shapeSettings = new Jolt.CylinderShapeSettings(
+ cylinderDepth / 2,
+ radius,
+ convexRadius
+ );
+ quat = this._getShapeOrientationQuat();
+ this.shapeHalfDepth =
+ this.shapeOrientation !== 'Z' ? radius : cylinderDepth / 2;
+ } else {
+ // Create a 'Sphere' by default.
+ const radius =
+ shapeDimensionA > 0
+ ? shapeDimensionA
+ : width > 0
+ ? Math.pow(width * height * depth, 1 / 3) / 2
+ : onePixel;
+ shapeSettings = new Jolt.SphereShapeSettings(radius);
+ quat = this.getQuat(0, 0, 0, 1);
+ this.shapeHalfDepth = radius;
+ }
+ shapeSettings.mDensity = this.density;
+ const rotatedShape = new Jolt.RotatedTranslatedShapeSettings(
+ //this.getVec3(shapeOffsetX, shapeOffsetY, shapeOffsetZ),
+ this.getVec3(0, 0, 0), //offsetZ ? offsetZ * shapeDepth : 0),
+ quat,
+ shapeSettings
+ )
+ .Create()
+ .Get();
+
+ Jolt.destroy(shapeSettings);
+ return rotatedShape;
+ }
+
+ private _getShapeOrientationQuat(): Jolt.Quat {
+ if (this.shapeOrientation === 'X') {
+ // Top on X axis.
+ return this.getQuat(0, 0, Math.sqrt(2) / 2, -Math.sqrt(2) / 2);
+ } else if (this.shapeOrientation === 'Y') {
+ // Top on Y axis.
+ return this.getQuat(0, 0, 0, 1);
+ } else {
+ // Top on Z axis.
+ return this.getQuat(Math.sqrt(2) / 2, 0, 0, Math.sqrt(2) / 2);
+ }
+ }
+
+ recreateShape(): void {
+ this.bodyUpdater.recreateShape();
+
+ this._objectOldWidth = this.owner3D.getWidth();
+ this._objectOldHeight = this.owner3D.getHeight();
+ this._objectOldDepth = this.owner3D.getDepth();
+ }
+
+ getShapeScale(): float {
+ return this.shapeScale;
+ }
+
+ setShapeScale(shapeScale: float): void {
+ if (shapeScale !== this.shapeScale && shapeScale > 0) {
+ this.shapeScale = shapeScale;
+ this.needToRecreateShape = true;
+ }
+ }
+
+ getBody(): Jolt.Body {
+ if (this._body === null) {
+ this.createBody();
+ }
+ return this._body!;
+ }
+
+ createBody(): boolean {
+ this.needToRecreateBody = false;
+ this.needToRecreateShape = false;
+
+ if (!this.activated() || this.destroyedDuringFrameLogic) return false;
+
+ this._body = this.bodyUpdater.createAndAddBody();
+ this._body.gdjsAssociatedBehavior = this;
+
+ this._objectOldWidth = this.owner3D.getWidth();
+ this._objectOldHeight = this.owner3D.getHeight();
+ this._objectOldDepth = this.owner3D.getDepth();
+ return true;
+ }
+
+ /**
+ * @returns The body layer id according to the behavior configuration.
+ */
+ getBodyLayer(): number {
+ return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(
+ // Make sure objects don't register in the wrong layer group.
+ this.bodyType === 'Static'
+ ? this.layers & gdjs.Physics3DSharedData.staticLayersMask
+ : this.layers & gdjs.Physics3DSharedData.dynamicLayersMask,
+ // Static objects accept all collisions as it's the mask of dynamic objects that matters.
+ this.bodyType === 'Static'
+ ? gdjs.Physics3DSharedData.allLayersMask
+ : this.masks
+ );
+ }
+
+ doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
+ // Step the world if not done this frame yet.
+ // Don't step at the first frame to allow events to handle overlapping objects.
+ if (
+ !this._sharedData.stepped &&
+ !instanceContainer.getScene().getTimeManager().isFirstFrame()
+ ) {
+ this._sharedData.step(
+ instanceContainer.getScene().getTimeManager().getElapsedTime() /
+ 1000.0
+ );
+ }
+ }
+
+ doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
+ // Reset world step to update next frame
+ this._sharedData.stepped = false;
+ }
+
+ onObjectHotReloaded() {
+ this.updateBodyFromObject();
+ }
+
+ recreateBody() {
+ if (!this._body) {
+ this.createBody();
+ return;
+ }
+
+ const bodyInterface = this._sharedData.bodyInterface;
+ const linearVelocity = this._body.GetLinearVelocity();
+ const linearVelocityX = linearVelocity.GetX();
+ const linearVelocityY = linearVelocity.GetY();
+ const linearVelocityZ = linearVelocity.GetZ();
+ const angularVelocity = this._body.GetAngularVelocity();
+ const angularVelocityX = angularVelocity.GetX();
+ const angularVelocityY = angularVelocity.GetY();
+ const angularVelocityZ = angularVelocity.GetZ();
+
+ let bodyID = this._body.GetID();
+ bodyInterface.RemoveBody(bodyID);
+ bodyInterface.DestroyBody(bodyID);
+ this.contactsEndedThisFrame.length = 0;
+ this.contactsStartedThisFrame.length = 0;
+ this.currentContacts.length = 0;
+
+ this.createBody();
+ if (!this._body) {
+ return;
+ }
+ bodyID = this._body.GetID();
+ bodyInterface.SetLinearVelocity(
+ bodyID,
+ this.getVec3(linearVelocityX, linearVelocityY, linearVelocityZ)
+ );
+ bodyInterface.SetAngularVelocity(
+ bodyID,
+ this.getVec3(angularVelocityX, angularVelocityY, angularVelocityZ)
+ );
+ }
+
+ updateObjectFromBody() {
+ this.bodyUpdater.updateObjectFromBody();
+
+ // Update cached transform.
+ this._objectOldX = this.owner3D.getX();
+ this._objectOldY = this.owner3D.getY();
+ this._objectOldZ = this.owner3D.getZ();
+ this._objectOldRotationX = this.owner3D.getRotationX();
+ this._objectOldRotationY = this.owner3D.getRotationY();
+ this._objectOldRotationZ = this.owner3D.getAngle();
+ }
+
+ updateBodyFromObject() {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+
+ if (this.needToRecreateBody) {
+ this.recreateBody();
+ }
+
+ // The object size has changed, recreate the shape.
+ // The width has changed and there is no custom dimension A (box: width, circle: radius, edge: length) or
+ // The height has changed, the shape is not an edge (edges doesn't have height),
+ // it isn't a box with custom height or a circle with custom radius
+ if (
+ this.needToRecreateShape ||
+ (!this.hasCustomShapeDimension() &&
+ (this._objectOldWidth !== this.owner3D.getWidth() ||
+ this._objectOldHeight !== this.owner3D.getHeight() ||
+ this._objectOldDepth !== this.owner3D.getDepth()))
+ ) {
+ this.needToRecreateShape = false;
+ this.recreateShape();
+ }
+
+ this.bodyUpdater.updateBodyFromObject();
+ }
+
+ hasCustomShapeDimension() {
+ return (
+ this.shapeDimensionA > 0 ||
+ this.shapeDimensionB > 0 ||
+ this.shapeDimensionC > 0
+ );
+ }
+
+ getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {
+ result.Set(
+ this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,
+ this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,
+ this.owner3D.getCenterZInScene() * this._sharedData.worldInvScale
+ );
+ return result;
+ }
+
+ getPhysicsRotation(result: Jolt.Quat): Jolt.Quat {
+ const threeObject = this.owner3D.get3DRendererObject();
+ result.Set(
+ threeObject.quaternion.x,
+ threeObject.quaternion.y,
+ threeObject.quaternion.z,
+ threeObject.quaternion.w
+ );
+ return result;
+ }
+
+ moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {
+ this.owner3D.setCenterXInScene(
+ physicsPosition.GetX() * this._sharedData.worldScale
+ );
+ this.owner3D.setCenterYInScene(
+ physicsPosition.GetY() * this._sharedData.worldScale
+ );
+ this.owner3D.setCenterZInScene(
+ physicsPosition.GetZ() * this._sharedData.worldScale
+ );
+ }
+
+ getWorldScale(): float {
+ return this._sharedData.worldScale;
+ }
+
+ getGravityX(): float {
+ return this._sharedData.gravityX;
+ }
+
+ getGravityY(): float {
+ return this._sharedData.gravityY;
+ }
+
+ getGravityZ(): float {
+ return this._sharedData.gravityZ;
+ }
+
+ setGravityX(gravityX: float): void {
+ if (this._sharedData.gravityX === gravityX) {
+ return;
+ }
+
+ this._sharedData.gravityX = gravityX;
+ this._sharedData.physicsSystem.SetGravity(
+ this.getVec3(
+ this._sharedData.gravityX,
+ this._sharedData.gravityY,
+ this._sharedData.gravityZ
+ )
+ );
+ }
+
+ setGravityY(gravityY: float): void {
+ if (this._sharedData.gravityX === gravityY) {
+ return;
+ }
+
+ this._sharedData.gravityX = gravityY;
+ this._sharedData.physicsSystem.SetGravity(
+ this.getVec3(
+ this._sharedData.gravityX,
+ this._sharedData.gravityY,
+ this._sharedData.gravityZ
+ )
+ );
+ }
+
+ setGravityZ(gravityZ: float): void {
+ if (this._sharedData.gravityX === gravityZ) {
+ return;
+ }
+
+ this._sharedData.gravityZ = gravityZ;
+ this._sharedData.physicsSystem.SetGravity(
+ this.getVec3(
+ this._sharedData.gravityX,
+ this._sharedData.gravityY,
+ this._sharedData.gravityZ
+ )
+ );
+ }
+
+ isDynamic(): boolean {
+ return this.bodyType === 'Dynamic';
+ }
+
+ isStatic(): boolean {
+ return this.bodyType === 'Static';
+ }
+
+ isKinematic(): boolean {
+ return this.bodyType === 'Kinematic';
+ }
+
+ isBullet(): boolean {
+ return this.bullet;
+ }
+
+ setBullet(enable: boolean): void {
+ if (this.bullet === enable) {
+ return;
+ }
+ this.bullet = enable;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetMotionQuality(
+ body.GetID(),
+ this.bullet
+ ? Jolt.EMotionQuality_LinearCast
+ : Jolt.EMotionQuality_Discrete
+ );
+ }
+
+ hasFixedRotation(): boolean {
+ return this.fixedRotation;
+ }
+
+ setFixedRotation(enable: boolean): void {
+ if (this.fixedRotation === enable) {
+ return;
+ }
+ this.fixedRotation = enable;
+ this.needToRecreateBody = true;
+ }
+
+ getDensity() {
+ return this.density;
+ }
+
+ setDensity(density: float): void {
+ // Non-negative values only
+ if (density < 0) {
+ density = 0;
+ }
+ if (this.density === density) {
+ return;
+ }
+ this.density = density;
+ this.needToRecreateShape = true;
+ }
+
+ getFriction(): float {
+ return this.friction;
+ }
+
+ setFriction(friction: float): void {
+ // Non-negative values only
+ if (friction < 0) {
+ friction = 0;
+ }
+ if (this.friction === friction) {
+ return;
+ }
+ this.friction = friction;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetFriction(body.GetID(), friction);
+ }
+
+ getRestitution(): float {
+ return this.restitution;
+ }
+
+ setRestitution(restitution: float): void {
+ // Non-negative values only
+ if (restitution < 0) {
+ restitution = 0;
+ }
+ if (this.restitution === restitution) {
+ return;
+ }
+ this.restitution = restitution;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetRestitution(body.GetID(), restitution);
+ }
+
+ getLinearDamping(): float {
+ return this.linearDamping;
+ }
+
+ setLinearDamping(linearDamping: float): void {
+ // Non-negative values only
+ if (linearDamping < 0) {
+ linearDamping = 0;
+ }
+ if (this.linearDamping === linearDamping) {
+ return;
+ }
+ this.linearDamping = linearDamping;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ body.GetMotionProperties().SetLinearDamping(linearDamping);
+ }
+
+ getAngularDamping(): float {
+ return this.angularDamping;
+ }
+
+ setAngularDamping(angularDamping: float): void {
+ // Non-negative values only
+ if (angularDamping < 0) {
+ angularDamping = 0;
+ }
+ if (this.angularDamping === angularDamping) {
+ return;
+ }
+ this.angularDamping = angularDamping;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ body.GetMotionProperties().SetAngularDamping(angularDamping);
+ }
+
+ getGravityScale(): float {
+ return this.gravityScale;
+ }
+
+ setGravityScale(gravityScale: float): void {
+ if (this.gravityScale === gravityScale) {
+ return;
+ }
+ this.gravityScale = gravityScale;
+
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ body.GetMotionProperties().SetGravityFactor(gravityScale);
+ }
+
+ layerEnabled(layer: integer): boolean {
+ // Layer must be an integer
+ layer = Math.floor(layer);
+ if (layer < 1 || layer > 8) {
+ return false;
+ }
+ return !!(this.layers & (1 << (layer - 1)));
+ }
+
+ enableLayer(layer: integer, enable: boolean): void {
+ // Layer must be an integer
+ layer = Math.floor(layer);
+ if (layer < 1 || layer > 8) {
+ return;
+ }
+
+ if (enable) {
+ this.layers |= 1 << (layer - 1);
+ } else {
+ this.layers &= ~(1 << (layer - 1));
+ }
+
+ this.needToRecreateBody = true;
+ }
+
+ maskEnabled(mask: integer): boolean {
+ // Mask must be an integer
+ mask = Math.floor(mask);
+ if (mask < 1 || mask > 16) {
+ return false;
+ }
+ return !!(this.masks & (1 << (mask - 1)));
+ }
+
+ enableMask(mask: integer, enable: boolean): void {
+ // Mask must be an integer
+ mask = Math.floor(mask);
+ if (mask < 1 || mask > 16) {
+ return;
+ }
+
+ if (enable) {
+ this.masks |= 1 << (mask - 1);
+ } else {
+ this.masks &= ~(1 << (mask - 1));
+ }
+
+ this.needToRecreateBody = true;
+ }
+
+ getLinearVelocityX(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return body.GetLinearVelocity().GetX() * this._sharedData.worldScale;
+ }
+
+ setLinearVelocityX(linearVelocityX: float): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetLinearVelocity(
+ body.GetID(),
+ this.getVec3(
+ linearVelocityX * this._sharedData.worldInvScale,
+ body.GetLinearVelocity().GetY(),
+ body.GetLinearVelocity().GetZ()
+ )
+ );
+ }
+
+ getLinearVelocityY(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return body.GetLinearVelocity().GetY() * this._sharedData.worldScale;
+ }
+
+ setLinearVelocityY(linearVelocityY: float): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetLinearVelocity(
+ body.GetID(),
+ this.getVec3(
+ body.GetLinearVelocity().GetX(),
+ linearVelocityY * this._sharedData.worldInvScale,
+ body.GetLinearVelocity().GetZ()
+ )
+ );
+ }
+
+ getLinearVelocityZ(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return body.GetLinearVelocity().GetZ() * this._sharedData.worldScale;
+ }
+
+ setLinearVelocityZ(linearVelocityZ: float): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.SetLinearVelocity(
+ body.GetID(),
+ this.getVec3(
+ body.GetLinearVelocity().GetX(),
+ body.GetLinearVelocity().GetY(),
+ linearVelocityZ * this._sharedData.worldInvScale
+ )
+ );
+ }
+
+ getLinearVelocityLength(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return body.GetLinearVelocity().Length() * this._sharedData.worldScale;
+ }
+
+ applyForce(
+ forceX: float,
+ forceY: float,
+ forceZ: float,
+ positionX: float,
+ positionY: float,
+ positionZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddForce(
+ body.GetID(),
+ this.getVec3(forceX, forceY, forceZ),
+ this.getRVec3(
+ positionX * this._sharedData.worldInvScale,
+ positionY * this._sharedData.worldInvScale,
+ positionZ * this._sharedData.worldInvScale
+ ),
+ Jolt.EActivation_Activate
+ );
+ }
+
+ applyForceAtCenter(forceX: float, forceY: float, forceZ: float): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddForce(
+ body.GetID(),
+ this.getVec3(forceX, forceY, forceZ),
+ Jolt.EActivation_Activate
+ );
+ }
+
+ applyForceTowardPosition(
+ length: float,
+ towardX: float,
+ towardY: float,
+ towardZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ const deltaX = towardX - body.GetPosition().GetX();
+ const deltaY = towardY - body.GetPosition().GetY();
+ const deltaZ = towardZ - body.GetPosition().GetZ();
+ const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
+ if (distance === 0) {
+ return;
+ }
+ const ratio = length / distance;
+
+ this._sharedData.bodyInterface.AddForce(
+ body.GetID(),
+ this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),
+ Jolt.EActivation_Activate
+ );
+ }
+
+ applyImpulse(
+ impulseX: float,
+ impulseY: float,
+ impulseZ: float,
+ positionX: float,
+ positionY: float,
+ positionZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddImpulse(
+ body.GetID(),
+ this.getVec3(impulseX, impulseY, impulseZ),
+ this.getRVec3(
+ positionX * this._sharedData.worldInvScale,
+ positionY * this._sharedData.worldInvScale,
+ positionZ * this._sharedData.worldInvScale
+ )
+ );
+ }
+
+ applyImpulseAtCenter(
+ impulseX: float,
+ impulseY: float,
+ impulseZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddImpulse(
+ body.GetID(),
+ this.getVec3(impulseX, impulseY, impulseZ)
+ );
+ }
+
+ applyImpulseTowardPosition(
+ length: float,
+ towardX: float,
+ towardY: float,
+ towardZ: float,
+ originX: float,
+ originY: float,
+ originZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ const deltaX = towardX - originX;
+ const deltaY = towardY - originY;
+ const deltaZ = towardZ - originZ;
+ const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
+ if (distance === 0) {
+ return;
+ }
+ const ratio = length / distance;
+
+ this._sharedData.bodyInterface.AddImpulse(
+ body.GetID(),
+ this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),
+ this.getRVec3(
+ originX * this._sharedData.worldInvScale,
+ originY * this._sharedData.worldInvScale,
+ originZ * this._sharedData.worldInvScale
+ )
+ );
+ }
+
+ applyTorque(torqueX: float, torqueY: float, torqueZ: float): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddTorque(
+ body.GetID(),
+ this.getVec3(torqueX, torqueY, torqueZ),
+ Jolt.EActivation_Activate
+ );
+ }
+
+ applyAngularImpulse(
+ angularImpulseX: float,
+ angularImpulseY: float,
+ angularImpulseZ: float
+ ): void {
+ if (this._body === null) {
+ if (!this.createBody()) return;
+ }
+ const body = this._body!;
+
+ this._sharedData.bodyInterface.AddAngularImpulse(
+ body.GetID(),
+ this.getVec3(angularImpulseX, angularImpulseY, angularImpulseZ)
+ );
+ }
+
+ getMass(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return 1 / body.GetMotionProperties().GetInverseMass();
+ }
+
+ /**
+ * @returns The inertia for a rotation around X axis of the object at its
+ * default rotation (0°; 0°; 0°).
+ */
+ getInertiaAroundX(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetX();
+ }
+
+ /**
+ * @returns The inertia for a rotation around Y axis of the object at its
+ * default rotation (0°; 0°; 0°).
+ */
+ getInertiaAroundY(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetY();
+ }
+
+ /**
+ * @returns The inertia for a rotation around Z axis of the object at its
+ * default rotation (0°; 0°; 0°).
+ */
+ getInertiaAroundZ(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetZ();
+ }
+
+ getMassCenterX(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return (
+ body.GetCenterOfMassPosition().GetX() * this._sharedData.worldScale
+ );
+ }
+
+ getMassCenterY(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return (
+ body.GetCenterOfMassPosition().GetY() * this._sharedData.worldScale
+ );
+ }
+
+ getMassCenterZ(): float {
+ if (this._body === null) {
+ if (!this.createBody()) return 0;
+ }
+ const body = this._body!;
+
+ return (
+ body.GetCenterOfMassPosition().GetZ() * this._sharedData.worldScale
+ );
+ }
+
+ onContactBegin(otherBehavior: Physics3DRuntimeBehavior): void {
+ this.currentContacts.push(otherBehavior);
+
+ // There might be contacts that end during the frame and
+ // start again right away. It is considered a glitch
+ // and should not be detected.
+ let i = this.contactsEndedThisFrame.indexOf(otherBehavior);
+ if (i !== -1) {
+ this.contactsEndedThisFrame.splice(i, 1);
+ } else {
+ this.contactsStartedThisFrame.push(otherBehavior);
+ }
+ }
+
+ onContactEnd(otherBehavior: Physics3DRuntimeBehavior): void {
+ this.contactsEndedThisFrame.push(otherBehavior);
+
+ const index = this.currentContacts.indexOf(otherBehavior);
+ if (index !== -1) {
+ this.currentContacts.splice(index, 1);
+ }
+ }
+
+ static areObjectsColliding(
+ object1: gdjs.RuntimeObject,
+ object2: gdjs.RuntimeObject,
+ behaviorName: string
+ ): boolean {
+ // Test if the second object is in the list of contacts of the first one
+ const behavior1 = object1.getBehavior(
+ behaviorName
+ ) as Physics3DRuntimeBehavior | null;
+ if (!behavior1) return false;
+
+ if (
+ behavior1.currentContacts.some((behavior) => behavior.owner === object2)
+ ) {
+ return true;
+ }
+ // If a contact has started at this frame and ended right away, it
+ // won't appear in current contacts but the condition should return
+ // true anyway.
+ if (
+ behavior1.contactsStartedThisFrame.some(
+ (behavior) => behavior.owner === object2
+ )
+ ) {
+ return true;
+ }
+
+ // No contact found
+ return false;
+ }
+
+ static hasCollisionStartedBetween(
+ object1: gdjs.RuntimeObject,
+ object2: gdjs.RuntimeObject,
+ behaviorName: string
+ ): boolean {
+ // Test if the second object is in the list of contacts of the first one
+ const behavior1 = object1.getBehavior(
+ behaviorName
+ ) as Physics3DRuntimeBehavior | null;
+ if (!behavior1) return false;
+
+ return behavior1.contactsStartedThisFrame.some(
+ (behavior) => behavior.owner === object2
+ );
+ }
+
+ static hasCollisionStoppedBetween(
+ object1: gdjs.RuntimeObject,
+ object2: gdjs.RuntimeObject,
+ behaviorName: string
+ ): boolean {
+ // Test if the second object is in the list of contacts of the first one
+ const behavior1 = object1.getBehavior(
+ behaviorName
+ ) as Physics3DRuntimeBehavior | null;
+ if (!behavior1) return false;
+
+ return behavior1.contactsEndedThisFrame.some(
+ (behavior) => behavior.owner === object2
+ );
+ }
+ }
+
+ gdjs.registerBehavior(
+ 'Physics3D::Physics3DBehavior',
+ gdjs.Physics3DRuntimeBehavior
+ );
+
+ export namespace Physics3DRuntimeBehavior {
+ /**
+ * Allow extensions relying on the 3D physics to customize its
+ * behavior a bit.
+ */
+ export interface Physics3DHook {
+ /**
+ * Called before the physics engine step.
+ */
+ doBeforePhysicsStep(timeDelta: float): void;
+ }
+
+ export interface BodyUpdater {
+ createAndAddBody(): Jolt.Body;
+ updateObjectFromBody(): void;
+ updateBodyFromObject(): void;
+ recreateShape(): void;
+ }
+
+ export class DefaultBodyUpdater {
+ behavior: gdjs.Physics3DRuntimeBehavior;
+
+ constructor(behavior: gdjs.Physics3DRuntimeBehavior) {
+ this.behavior = behavior;
+ }
+
+ createAndAddBody(): Jolt.Body {
+ const { behavior } = this;
+ const { _sharedData } = behavior;
+
+ const shape = behavior.createShape();
+ const bodyCreationSettings = new Jolt.BodyCreationSettings(
+ shape,
+ behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),
+ behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),
+ behavior.bodyType === 'Static'
+ ? Jolt.EMotionType_Static
+ : behavior.bodyType === 'Kinematic'
+ ? Jolt.EMotionType_Kinematic
+ : Jolt.EMotionType_Dynamic,
+ behavior.getBodyLayer()
+ );
+ bodyCreationSettings.mMotionQuality = behavior.bullet
+ ? Jolt.EMotionQuality_LinearCast
+ : Jolt.EMotionQuality_Discrete;
+ bodyCreationSettings.mAllowedDOFs = behavior.fixedRotation
+ ? Jolt.EAllowedDOFs_TranslationX |
+ Jolt.EAllowedDOFs_TranslationY |
+ Jolt.EAllowedDOFs_TranslationZ
+ : Jolt.EAllowedDOFs_All;
+ bodyCreationSettings.mFriction = behavior.friction;
+ bodyCreationSettings.mRestitution = behavior.restitution;
+ bodyCreationSettings.mLinearDamping = behavior.linearDamping;
+ bodyCreationSettings.mAngularDamping = behavior.angularDamping;
+ bodyCreationSettings.mGravityFactor = behavior.gravityScale;
+
+ const bodyInterface = _sharedData.bodyInterface;
+ const body = bodyInterface.CreateBody(bodyCreationSettings);
+ Jolt.destroy(bodyCreationSettings);
+
+ bodyInterface.AddBody(body.GetID(), Jolt.EActivation_Activate);
+ return body;
+ }
+
+ updateObjectFromBody() {
+ const { behavior } = this;
+ const { owner3D, _body } = behavior;
+ // Copy transform from body to the GD object.
+ // It's possible the behavior was either deactivated or the object deleted
+ // just before this doStepPreEvents (for example, another behavior deleted
+ // the object during its own doStepPreEvents). If the body is null, we just
+ // don't do anything (but still run the physics simulation - this is independent).
+ if (_body !== null) {
+ behavior.moveObjectToPhysicsPosition(_body.GetPosition());
+
+ const quaternion = _body.GetRotation();
+ const threeObject = owner3D.get3DRendererObject();
+ threeObject.quaternion.x = quaternion.GetX();
+ threeObject.quaternion.y = quaternion.GetY();
+ threeObject.quaternion.z = quaternion.GetZ();
+ threeObject.quaternion.w = quaternion.GetW();
+ const euler = new THREE.Euler(0, 0, 0, 'ZYX');
+ euler.setFromQuaternion(threeObject.quaternion);
+ owner3D.setRotationX(gdjs.toDegrees(euler.x));
+ owner3D.setRotationY(gdjs.toDegrees(euler.y));
+ owner3D.setAngle(gdjs.toDegrees(euler.z));
+ }
+ }
+
+ updateBodyFromObject() {
+ const { behavior } = this;
+ const { owner3D, _sharedData } = behavior;
+ if (behavior._body === null) {
+ if (!behavior.createBody()) return;
+ }
+ const body = behavior._body!;
+
+ // The object object transform has changed, update body transform:
+ if (
+ this.behavior._objectOldX !== owner3D.getX() ||
+ this.behavior._objectOldY !== owner3D.getY() ||
+ this.behavior._objectOldZ !== owner3D.getZ() ||
+ this.behavior._objectOldRotationX !== owner3D.getRotationX() ||
+ this.behavior._objectOldRotationY !== owner3D.getRotationY() ||
+ this.behavior._objectOldRotationZ !== owner3D.getAngle()
+ ) {
+ _sharedData.bodyInterface.SetPositionAndRotationWhenChanged(
+ body.GetID(),
+ this.behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),
+ this.behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),
+ Jolt.EActivation_Activate
+ );
+ }
+ }
+
+ recreateShape() {
+ const { behavior } = this;
+ const { _sharedData } = behavior;
+ if (behavior._body === null) {
+ if (!behavior.createBody()) return;
+ }
+ const body = behavior._body!;
+
+ const bodyInterface = _sharedData.bodyInterface;
+ bodyInterface.SetShape(
+ body.GetID(),
+ behavior.createShape(),
+ true,
+ Jolt.EActivation_Activate
+ );
+ }
+ }
+ }
+}
diff --git a/Extensions/Physics3DBehavior/Physics3DTools.ts b/Extensions/Physics3DBehavior/Physics3DTools.ts
new file mode 100644
index 000000000000..a150dba010a6
--- /dev/null
+++ b/Extensions/Physics3DBehavior/Physics3DTools.ts
@@ -0,0 +1,90 @@
+namespace gdjs {
+ export namespace physics3d {
+ export const objectsCollide = function (
+ objectsLists1: Hashtable>,
+ behaviorName: string,
+ objectsLists2: Hashtable>,
+ behaviorName2: string,
+ inverted: boolean
+ ) {
+ return gdjs.evtTools.object.twoListsTest(
+ gdjs.Physics3DRuntimeBehavior.areObjectsColliding,
+ objectsLists1,
+ objectsLists2,
+ inverted,
+ behaviorName
+ );
+ };
+
+ export const haveObjectsStartedColliding = function (
+ objectsLists1: Hashtable>,
+ behaviorName: string,
+ objectsLists2: Hashtable>,
+ behaviorName2: string,
+ inverted: boolean
+ ) {
+ return gdjs.evtTools.object.twoListsTest(
+ gdjs.Physics3DRuntimeBehavior.hasCollisionStartedBetween,
+ objectsLists1,
+ objectsLists2,
+ inverted,
+ behaviorName
+ );
+ };
+
+ export const haveObjectsStoppedColliding = function (
+ objectsLists1: Hashtable>,
+ behaviorName: string,
+ objectsLists2: Hashtable>,
+ behaviorName2: string,
+ inverted: boolean
+ ) {
+ return gdjs.evtTools.object.twoListsTest(
+ gdjs.Physics3DRuntimeBehavior.hasCollisionStoppedBetween,
+ objectsLists1,
+ objectsLists2,
+ inverted,
+ behaviorName
+ );
+ };
+
+ type BehaviorNamePair = { character: string; physics: string };
+
+ const isOnPlatformAdapter = (
+ characterObject: gdjs.RuntimeObject,
+ physicsObject: gdjs.RuntimeObject,
+ behaviorNamePair: BehaviorNamePair
+ ): boolean => {
+ const characterBehavior = characterObject.getBehavior(
+ behaviorNamePair.character
+ ) as gdjs.PhysicsCharacter3DRuntimeBehavior;
+ const physicsBehavior = physicsObject.getBehavior(
+ behaviorNamePair.physics
+ ) as gdjs.Physics3DRuntimeBehavior;
+ if (!characterBehavior || !physicsBehavior) {
+ return false;
+ }
+ return characterBehavior.isOnFloorObject(physicsBehavior);
+ };
+
+ const behaviorNamePair: BehaviorNamePair = { character: '', physics: '' };
+
+ export const isOnPlatform = (
+ characterObjectsLists: Hashtable>,
+ characterBehaviorName: string,
+ physicsObjectsLists: Hashtable>,
+ physicsBehaviorName: string,
+ inverted: boolean
+ ) => {
+ behaviorNamePair.character = characterBehaviorName;
+ behaviorNamePair.physics = physicsBehaviorName;
+ return gdjs.evtTools.object.twoListsTest(
+ isOnPlatformAdapter,
+ characterObjectsLists,
+ physicsObjectsLists,
+ inverted,
+ behaviorNamePair
+ );
+ };
+ }
+}
diff --git a/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.ts b/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.ts
new file mode 100644
index 000000000000..9e1b81ebaa99
--- /dev/null
+++ b/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.ts
@@ -0,0 +1,1407 @@
+///
+
+namespace Jolt {
+ export interface Body {
+ gdjsAssociatedCharacterBehavior: gdjs.PhysicsCharacter3DRuntimeBehavior | null;
+ }
+}
+
+namespace gdjs {
+ interface PhysicsCharacter3DNetworkSyncDataType {
+ fws: float;
+ sws: float;
+ fs: float;
+ js: float;
+ cj: boolean;
+ lek: boolean;
+ rik: boolean;
+ upk: boolean;
+ dok: boolean;
+ juk: boolean;
+ us: boolean;
+ sa: float;
+ sf: float;
+ tscjs: float;
+ jkhsjs: boolean;
+ }
+
+ export interface PhysicsCharacter3DNetworkSyncData
+ extends BehaviorNetworkSyncData {
+ props: PhysicsCharacter3DNetworkSyncDataType;
+ }
+
+ type Physics3D = {
+ behavior: gdjs.Physics3DRuntimeBehavior;
+ extendedUpdateSettings: Jolt.ExtendedUpdateSettings;
+ broadPhaseLayerFilter: Jolt.BroadPhaseLayerFilter;
+ objectLayerFilter: Jolt.ObjectLayerFilter;
+ bodyFilter: Jolt.BodyFilter;
+ shapeFilter: Jolt.ShapeFilter;
+ };
+
+ export class PhysicsCharacter3DRuntimeBehavior
+ extends gdjs.RuntimeBehavior
+ implements gdjs.Physics3DRuntimeBehavior.Physics3DHook {
+ owner3D: gdjs.RuntimeObject3D;
+ physics3DBehaviorName: string;
+ physics3D: Physics3D | null = null;
+ character: Jolt.CharacterVirtual | null = null;
+ /**
+ * sharedData is a reference to the shared data of the scene, that registers
+ * every physics behavior that is created so that collisions can be cleared
+ * before stepping the world.
+ */
+ _sharedData: gdjs.Physics3DSharedData;
+
+ // TODO Should there be angle were the character can climb but will slip?
+ _slopeMaxAngle: float;
+ _slopeClimbingFactor: float = 1;
+ _slopeClimbingMinNormalZ: float = Math.cos(Math.PI / 4);
+ private _forwardAngle: float = 0;
+ _forwardAcceleration: float;
+ _forwardDeceleration: float;
+ _forwardSpeedMax: float;
+ _sidewaysAcceleration: float;
+ _sidewaysDeceleration: float;
+ _sidewaysSpeedMax: float;
+ _gravity: float;
+ _maxFallingSpeed: float;
+ _jumpSpeed: float;
+ _jumpSustainTime: float;
+
+ hasPressedForwardKey: boolean = false;
+ hasPressedBackwardKey: boolean = false;
+ hasPressedRightKey: boolean = false;
+ hasPressedLeftKey: boolean = false;
+ hasPressedJumpKey: boolean = false;
+ hasUsedStick: boolean = false;
+ private _stickAngle: float = 0;
+ private _stickForce: float = 0;
+ _currentForwardSpeed: float = 0;
+ _currentSidewaysSpeed: float = 0;
+ _currentFallSpeed: float = 0;
+ _canJump: boolean = false;
+ _currentJumpSpeed: float = 0;
+ _timeSinceCurrentJumpStart: float = 0;
+ _jumpKeyHeldSinceJumpStart: boolean = false;
+ private _hasReallyMoved: boolean = false;
+ oldPhysicsPosition: FloatPoint = [0, 0];
+
+ // This is useful for extensions that need to know
+ // which keys were pressed and doesn't know the mapping
+ // done by the scene events.
+ private _wasLeftKeyPressed: boolean = false;
+ private _wasRightKeyPressed: boolean = false;
+ private _wasForwardKeyPressed: boolean = false;
+ private _wasBackwardKeyPressed: boolean = false;
+ private _wasJumpKeyPressed: boolean = false;
+ private _wasStickUsed: boolean = false;
+
+ // This is useful when the object is synchronized by an external source
+ // like in a multiplayer game, and we want to be able to predict the
+ // movement of the object, even if the inputs are not updated every frame.
+ _dontClearInputsBetweenFrames: boolean = false;
+
+ /**
+ * A very small value compare to 1 pixel, yet very huge compare to rounding errors.
+ */
+ private static readonly epsilon = 2 ** -20;
+
+ constructor(
+ instanceContainer: gdjs.RuntimeInstanceContainer,
+ behaviorData,
+ owner: gdjs.RuntimeObject3D
+ ) {
+ super(instanceContainer, behaviorData, owner);
+ this.owner3D = owner;
+ this.physics3DBehaviorName = behaviorData.Physics3D;
+ this._sharedData = gdjs.Physics3DSharedData.getSharedData(
+ instanceContainer.getScene(),
+ behaviorData.Physics3D
+ );
+
+ this._slopeMaxAngle = 0;
+ this.setSlopeMaxAngle(behaviorData.slopeMaxAngle);
+ this._forwardAcceleration = behaviorData.forwardAcceleration;
+ this._forwardDeceleration = behaviorData.forwardDeceleration;
+ this._forwardSpeedMax = behaviorData.forwardSpeedMax;
+ this._sidewaysAcceleration = behaviorData.sidewaysAcceleration;
+ this._sidewaysDeceleration = behaviorData.sidewaysDeceleration;
+ this._sidewaysSpeedMax = behaviorData.sidewaysSpeedMax;
+ this._gravity = behaviorData.gravity;
+ this._maxFallingSpeed = behaviorData.fallingSpeedMax;
+ this._jumpSustainTime = behaviorData.jumpSustainTime;
+ this._jumpSpeed = this.getJumpSpeedToReach(behaviorData.jumpHeight);
+ }
+
+ private getVec3(x: float, y: float, z: float): Jolt.Vec3 {
+ const tempVec3 = this._sharedData._tempVec3;
+ tempVec3.Set(x, y, z);
+ return tempVec3;
+ }
+
+ private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {
+ const tempRVec3 = this._sharedData._tempRVec3;
+ tempRVec3.Set(x, y, z);
+ return tempRVec3;
+ }
+
+ getPhysics3D(): Physics3D {
+ if (this.physics3D) {
+ return this.physics3D;
+ }
+ const behavior = this.owner.getBehavior(
+ this.physics3DBehaviorName
+ ) as gdjs.Physics3DRuntimeBehavior;
+
+ const sharedData = behavior._sharedData;
+ const jolt = sharedData.jolt;
+ const extendedUpdateSettings = new Jolt.ExtendedUpdateSettings();
+ extendedUpdateSettings.mWalkStairsStepUp = this.getVec3(0, 0, 0.4);
+ const broadPhaseLayerFilter = new Jolt.DefaultBroadPhaseLayerFilter(
+ jolt.GetObjectVsBroadPhaseLayerFilter(),
+ gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex
+ );
+ const objectLayerFilter = new Jolt.DefaultObjectLayerFilter(
+ jolt.GetObjectLayerPairFilter(),
+ behavior.getBodyLayer()
+ );
+ const bodyFilter = new Jolt.BodyFilter();
+ const shapeFilter = new Jolt.ShapeFilter();
+
+ this.physics3D = {
+ behavior,
+ extendedUpdateSettings,
+ broadPhaseLayerFilter,
+ objectLayerFilter,
+ bodyFilter,
+ shapeFilter,
+ };
+ sharedData.registerHook(this);
+
+ behavior.bodyUpdater = new gdjs.PhysicsCharacter3DRuntimeBehavior.CharacterBodyUpdater(
+ this
+ );
+ behavior.recreateBody();
+
+ // Begin in the direction of the object.
+ this._forwardAngle = this.owner.getAngle();
+
+ return this.physics3D;
+ }
+
+ updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {
+ if (oldBehaviorData.gravity !== newBehaviorData.gravity) {
+ this.setGravity(newBehaviorData.gravity);
+ }
+ if (oldBehaviorData.maxFallingSpeed !== newBehaviorData.maxFallingSpeed) {
+ this.setMaxFallingSpeed(newBehaviorData.maxFallingSpeed);
+ }
+ if (
+ oldBehaviorData.forwardAcceleration !==
+ newBehaviorData.forwardAcceleration
+ ) {
+ this.setForwardAcceleration(newBehaviorData.forwardAcceleration);
+ }
+ if (
+ oldBehaviorData.forwardDeceleration !==
+ newBehaviorData.forwardDeceleration
+ ) {
+ this.setForwardDeceleration(newBehaviorData.forwardDeceleration);
+ }
+ if (oldBehaviorData.forwardSpeedMax !== newBehaviorData.forwardSpeedMax) {
+ this.setForwardSpeedMax(newBehaviorData.forwardSpeedMax);
+ }
+ if (
+ oldBehaviorData.sidewaysAcceleration !==
+ newBehaviorData.sidewaysAcceleration
+ ) {
+ this.setSidewaysAcceleration(newBehaviorData.sidewaysAcceleration);
+ }
+ if (
+ oldBehaviorData.sidewaysDeceleration !==
+ newBehaviorData.sidewaysDeceleration
+ ) {
+ this.setSidewaysDeceleration(newBehaviorData.sidewaysDeceleration);
+ }
+ if (
+ oldBehaviorData.sidewaysSpeedMax !== newBehaviorData.sidewaysSpeedMax
+ ) {
+ this.setSidewaysSpeedMax(newBehaviorData.sidewaysSpeedMax);
+ }
+ if (oldBehaviorData.jumpSustainTime !== newBehaviorData.jumpSustainTime) {
+ this.setJumpSustainTime(newBehaviorData.jumpSustainTime);
+ }
+ if (oldBehaviorData.jumpHeight !== newBehaviorData.jumpHeight) {
+ this.setJumpSpeed(this.getJumpSpeedToReach(newBehaviorData.jumpHeight));
+ }
+ return true;
+ }
+
+ getNetworkSyncData(): PhysicsCharacter3DNetworkSyncData {
+ // This method is called, so we are synchronizing this object.
+ // Let's clear the inputs between frames as we control it.
+ this._dontClearInputsBetweenFrames = false;
+
+ return {
+ ...super.getNetworkSyncData(),
+ props: {
+ fws: this._currentForwardSpeed,
+ sws: this._currentSidewaysSpeed,
+ fs: this._currentFallSpeed,
+ js: this._currentJumpSpeed,
+ cj: this._canJump,
+ lek: this._wasLeftKeyPressed,
+ rik: this._wasRightKeyPressed,
+ upk: this._wasForwardKeyPressed,
+ dok: this._wasBackwardKeyPressed,
+ juk: this._wasJumpKeyPressed,
+ us: this._wasStickUsed,
+ sa: this._stickAngle,
+ sf: this._stickForce,
+ tscjs: this._timeSinceCurrentJumpStart,
+ jkhsjs: this._jumpKeyHeldSinceJumpStart,
+ },
+ };
+ }
+
+ updateFromNetworkSyncData(
+ networkSyncData: PhysicsCharacter3DNetworkSyncData
+ ) {
+ super.updateFromNetworkSyncData(networkSyncData);
+
+ const behaviorSpecificProps = networkSyncData.props;
+ this._currentForwardSpeed = behaviorSpecificProps.fws;
+ this._currentSidewaysSpeed = behaviorSpecificProps.sws;
+ this._currentFallSpeed = behaviorSpecificProps.fs;
+ this._currentJumpSpeed = behaviorSpecificProps.js;
+ this._canJump = behaviorSpecificProps.cj;
+ this.hasPressedForwardKey = behaviorSpecificProps.upk;
+ this.hasPressedBackwardKey = behaviorSpecificProps.dok;
+ this.hasPressedLeftKey = behaviorSpecificProps.lek;
+ this.hasPressedRightKey = behaviorSpecificProps.rik;
+ this.hasPressedJumpKey = behaviorSpecificProps.juk;
+ this.hasUsedStick = behaviorSpecificProps.us;
+ this._stickAngle = behaviorSpecificProps.sa;
+ this._stickForce = behaviorSpecificProps.sf;
+ this._timeSinceCurrentJumpStart = behaviorSpecificProps.tscjs;
+ this._jumpKeyHeldSinceJumpStart = behaviorSpecificProps.jkhsjs;
+
+ // When the object is synchronized from the network, the inputs must not be cleared.
+ this._dontClearInputsBetweenFrames = true;
+ }
+
+ getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {
+ const { behavior } = this.getPhysics3D();
+ result.Set(
+ this.owner3D.getX() * this._sharedData.worldInvScale,
+ this.owner3D.getY() * this._sharedData.worldInvScale,
+ this.owner3D.getZ() * this._sharedData.worldInvScale +
+ behavior.shapeHalfDepth
+ );
+ return result;
+ }
+
+ moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {
+ const { behavior } = this.getPhysics3D();
+ this.owner3D.setX(physicsPosition.GetX() * this._sharedData.worldScale);
+ this.owner3D.setY(physicsPosition.GetY() * this._sharedData.worldScale);
+ this.owner3D.setZ(
+ (physicsPosition.GetZ() - behavior.shapeHalfDepth) *
+ this._sharedData.worldScale
+ );
+ }
+
+ onDeActivate() {}
+
+ onActivate() {}
+
+ onDestroy() {
+ this.onDeActivate();
+ }
+
+ doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {
+ // Trigger createAndAddBody()
+ this.getPhysics3D();
+ }
+
+ doBeforePhysicsStep(timeDelta: float): void {
+ const {
+ behavior,
+ extendedUpdateSettings,
+ broadPhaseLayerFilter,
+ objectLayerFilter,
+ bodyFilter,
+ shapeFilter,
+ } = this.getPhysics3D();
+ if (!this.character) {
+ return;
+ }
+ const characterBody = behavior._body;
+ if (!characterBody) {
+ return;
+ }
+ const worldInvScale = this._sharedData.worldInvScale;
+
+ const oldX = this.character.GetPosition().GetX();
+ const oldY = this.character.GetPosition().GetY();
+ const oldZ = this.character.GetPosition().GetZ();
+
+ this.updateCharacterSpeedFromInputs(timeDelta);
+
+ if (this._currentJumpSpeed > 0) {
+ this._timeSinceCurrentJumpStart += timeDelta;
+ }
+ // Check if the jump key is continuously held since
+ // the beginning of the jump.
+ if (!this.hasPressedJumpKey) {
+ this._jumpKeyHeldSinceJumpStart = false;
+ }
+ if (
+ this._canJump &&
+ this.hasPressedJumpKey &&
+ // Avoid the character to jump in loop when the jump key is held.
+ !this._jumpKeyHeldSinceJumpStart
+ ) {
+ this._currentJumpSpeed = this._jumpSpeed;
+ this._currentFallSpeed = 0;
+ this._canJump = false;
+ this._jumpKeyHeldSinceJumpStart = true;
+ this._timeSinceCurrentJumpStart = 0;
+ }
+ if (!this.isOnFloor()) {
+ // Decrease jump speed after the (optional) jump sustain time is over.
+ const sustainJumpSpeed =
+ this._jumpKeyHeldSinceJumpStart &&
+ this._timeSinceCurrentJumpStart < this._jumpSustainTime;
+ if (!sustainJumpSpeed) {
+ this._currentJumpSpeed = Math.max(
+ 0,
+ this._currentJumpSpeed - this._gravity * timeDelta
+ );
+ }
+ this._currentFallSpeed = Math.min(
+ this._maxFallingSpeed,
+ this._currentFallSpeed + this._gravity * timeDelta
+ );
+ }
+
+ let groundVelocityX = 0;
+ let groundVelocityY = 0;
+ let groundVelocityZ = 0;
+ if (this.character.IsSupported()) {
+ this.updateGroundVelocity(behavior, timeDelta);
+ const groundVelocity = this.character.GetGroundVelocity();
+ groundVelocityX = groundVelocity.GetX();
+ groundVelocityY = groundVelocity.GetY();
+ groundVelocityZ = groundVelocity.GetZ();
+ }
+
+ let forwardSpeed = this._currentForwardSpeed;
+ let sidewaysSpeed = this._currentSidewaysSpeed;
+ if (sidewaysSpeed !== 0 && forwardSpeed !== 0) {
+ // It avoids the speed vector to go outside of an ellipse.
+ const speedNormalizationInverseRatio = Math.hypot(
+ forwardSpeed / this._forwardSpeedMax,
+ sidewaysSpeed / this._sidewaysSpeedMax
+ );
+ if (speedNormalizationInverseRatio > 1) {
+ forwardSpeed /= speedNormalizationInverseRatio;
+ sidewaysSpeed /= speedNormalizationInverseRatio;
+ }
+ }
+ forwardSpeed *= worldInvScale;
+ sidewaysSpeed *= worldInvScale;
+ const angle = gdjs.toRad(this._forwardAngle);
+ const cosA = Math.cos(angle);
+ const sinA = Math.sin(angle);
+ const speedX = forwardSpeed * cosA - sidewaysSpeed * sinA;
+ const speedY = forwardSpeed * sinA + sidewaysSpeed * cosA;
+ this.character.SetLinearVelocity(
+ this.getVec3(
+ groundVelocityX + speedX,
+ groundVelocityY + speedY,
+ // The ground velocity is not added on Z as it's handled by mStickToFloorStepDown.
+ (this._currentJumpSpeed - this._currentFallSpeed) * worldInvScale
+ )
+ );
+
+ if (this.isOnFloor()) {
+ // Keep the character on the floor when walking down-hill.
+ const walkingDistance = Math.max(
+ Math.hypot(
+ this.character.GetPosition().GetX() - this.oldPhysicsPosition[0],
+ this.character.GetPosition().GetY() - this.oldPhysicsPosition[1]
+ ),
+ Math.hypot(
+ this.character.GetLinearVelocity().GetX(),
+ this.character.GetLinearVelocity().GetY()
+ ) * timeDelta
+ );
+ this.oldPhysicsPosition[0] = this.character.GetPosition().GetX();
+ this.oldPhysicsPosition[1] = this.character.GetPosition().GetY();
+
+ // A safety margin is taken as if the ground normal is too steep, the
+ // character will fall next step anyway.
+ const stickToFloorStepDownZ = Math.max(
+ -0.01 +
+ 1.01 *
+ Math.min(
+ // Follow the platform slope...
+ -walkingDistance * this._slopeClimbingFactor,
+ // ...and follow a platform falling...
+ groundVelocityZ * timeDelta
+ ),
+ // ...but never fall faster than the max fall speed.
+ -this._maxFallingSpeed * worldInvScale * timeDelta
+ );
+ extendedUpdateSettings.mStickToFloorStepDown.Set(
+ 0,
+ 0,
+ stickToFloorStepDownZ
+ );
+ } else {
+ extendedUpdateSettings.mStickToFloorStepDown.Set(0, 0, 0);
+ }
+
+ this.character.ExtendedUpdate(
+ timeDelta,
+ this.character.GetUp(),
+ extendedUpdateSettings,
+ broadPhaseLayerFilter,
+ objectLayerFilter,
+ bodyFilter,
+ shapeFilter,
+ this._sharedData.jolt.GetTempAllocator()
+ );
+
+ if (this.isOnFloor()) {
+ this._canJump = true;
+ this._currentFallSpeed = 0;
+ this._currentJumpSpeed = 0;
+ }
+
+ this._wasForwardKeyPressed = this.hasPressedForwardKey;
+ this._wasBackwardKeyPressed = this.hasPressedBackwardKey;
+ this._wasRightKeyPressed = this.hasPressedRightKey;
+ this._wasLeftKeyPressed = this.hasPressedLeftKey;
+ this._wasJumpKeyPressed = this.hasPressedJumpKey;
+ this._wasStickUsed = this.hasPressedJumpKey;
+
+ if (!this._dontClearInputsBetweenFrames) {
+ this.hasPressedForwardKey = false;
+ this.hasPressedBackwardKey = false;
+ this.hasPressedRightKey = false;
+ this.hasPressedLeftKey = false;
+ this.hasPressedJumpKey = false;
+ this.hasUsedStick = false;
+ }
+
+ this._hasReallyMoved =
+ Math.abs(this.character.GetPosition().GetX() - oldX) >
+ PhysicsCharacter3DRuntimeBehavior.epsilon ||
+ Math.abs(this.character.GetPosition().GetY() - oldY) >
+ PhysicsCharacter3DRuntimeBehavior.epsilon ||
+ Math.abs(this.character.GetPosition().GetZ() - oldZ) >
+ PhysicsCharacter3DRuntimeBehavior.epsilon;
+ }
+
+ private updateCharacterSpeedFromInputs(timeDelta: float) {
+ /** A stick with a half way force targets a lower speed than the maximum speed. */
+ let targetedForwardSpeed = 0;
+ // Change the speed according to the player's input.
+ // TODO Give priority to the last key for faster reaction time.
+ if (this.hasPressedBackwardKey !== this.hasPressedForwardKey) {
+ if (this.hasPressedBackwardKey) {
+ targetedForwardSpeed = -this._forwardSpeedMax;
+ } else if (this.hasPressedForwardKey) {
+ targetedForwardSpeed = this._forwardSpeedMax;
+ }
+ } else if (this.hasUsedStick) {
+ targetedForwardSpeed =
+ -this._forwardSpeedMax *
+ this._stickForce *
+ Math.sin(gdjs.toRad(this._stickAngle));
+ }
+ if (targetedForwardSpeed < 0) {
+ if (this._currentForwardSpeed <= targetedForwardSpeed) {
+ // Reduce the speed to match the stick force.
+ this._currentForwardSpeed = Math.min(
+ targetedForwardSpeed,
+ this._currentForwardSpeed + this._forwardDeceleration * timeDelta
+ );
+ } else if (this._currentForwardSpeed <= 0) {
+ this._currentForwardSpeed -= this._forwardAcceleration * timeDelta;
+ } else {
+ // Turn back at least as fast as it would stop.
+ this._currentForwardSpeed -=
+ Math.max(this._forwardAcceleration, this._forwardDeceleration) *
+ timeDelta;
+ }
+ } else if (targetedForwardSpeed > 0) {
+ if (this._currentForwardSpeed >= targetedForwardSpeed) {
+ // Reduce the speed to match the stick force.
+ this._currentForwardSpeed = Math.max(
+ targetedForwardSpeed,
+ this._currentForwardSpeed - this._forwardDeceleration * timeDelta
+ );
+ } else if (this._currentForwardSpeed >= 0) {
+ this._currentForwardSpeed += this._forwardAcceleration * timeDelta;
+ } else {
+ // Turn back at least as fast as it would stop.
+ this._currentForwardSpeed +=
+ Math.max(this._forwardAcceleration, this._forwardDeceleration) *
+ timeDelta;
+ }
+ } else {
+ if (this._currentForwardSpeed < 0) {
+ this._currentForwardSpeed = Math.max(
+ this._currentForwardSpeed + this._forwardDeceleration * timeDelta,
+ 0
+ );
+ }
+ if (this._currentForwardSpeed > 0) {
+ this._currentForwardSpeed = Math.min(
+ this._currentForwardSpeed - this._forwardDeceleration * timeDelta,
+ 0
+ );
+ }
+ }
+ this._currentForwardSpeed = gdjs.evtTools.common.clamp(
+ this._currentForwardSpeed,
+ -this._forwardSpeedMax,
+ this._forwardSpeedMax
+ );
+
+ /** A stick with a half way force targets a lower speed than the maximum speed. */
+ let targetedSidewaysSpeed = 0;
+ if (this.hasPressedLeftKey !== this.hasPressedRightKey) {
+ if (this.hasPressedLeftKey) {
+ targetedSidewaysSpeed = -this._sidewaysSpeedMax;
+ } else if (this.hasPressedRightKey) {
+ targetedSidewaysSpeed = this._sidewaysSpeedMax;
+ }
+ } else if (this.hasUsedStick) {
+ targetedSidewaysSpeed =
+ this._sidewaysSpeedMax *
+ this._stickForce *
+ Math.cos(gdjs.toRad(this._stickAngle));
+ }
+ if (targetedSidewaysSpeed < 0) {
+ if (this._currentSidewaysSpeed <= targetedSidewaysSpeed) {
+ // Reduce the speed to match the stick force.
+ this._currentSidewaysSpeed = Math.min(
+ targetedSidewaysSpeed,
+ this._currentSidewaysSpeed + this._sidewaysDeceleration * timeDelta
+ );
+ } else if (this._currentSidewaysSpeed <= 0) {
+ this._currentSidewaysSpeed -= this._sidewaysAcceleration * timeDelta;
+ } else {
+ // Turn back at least as fast as it would stop.
+ this._currentSidewaysSpeed -=
+ Math.max(this._sidewaysAcceleration, this._sidewaysDeceleration) *
+ timeDelta;
+ }
+ } else if (targetedSidewaysSpeed > 0) {
+ if (this._currentSidewaysSpeed >= targetedSidewaysSpeed) {
+ // Reduce the speed to match the stick force.
+ this._currentSidewaysSpeed = Math.max(
+ targetedSidewaysSpeed,
+ this._currentSidewaysSpeed - this._sidewaysDeceleration * timeDelta
+ );
+ } else if (this._currentSidewaysSpeed >= 0) {
+ this._currentSidewaysSpeed += this._sidewaysAcceleration * timeDelta;
+ } else {
+ this._currentSidewaysSpeed +=
+ Math.max(this._sidewaysAcceleration, this._sidewaysDeceleration) *
+ timeDelta;
+ }
+ } else {
+ if (this._currentSidewaysSpeed < 0) {
+ this._currentSidewaysSpeed = Math.max(
+ this._currentSidewaysSpeed + this._sidewaysDeceleration * timeDelta,
+ 0
+ );
+ }
+ if (this._currentSidewaysSpeed > 0) {
+ this._currentSidewaysSpeed = Math.min(
+ this._currentSidewaysSpeed - this._sidewaysDeceleration * timeDelta,
+ 0
+ );
+ }
+ }
+ this._currentSidewaysSpeed = gdjs.evtTools.common.clamp(
+ this._currentSidewaysSpeed,
+ -this._sidewaysSpeedMax,
+ this._sidewaysSpeedMax
+ );
+ }
+
+ private updateGroundVelocity(
+ behavior: Physics3DRuntimeBehavior,
+ timeDelta: float
+ ) {
+ if (!this.character) {
+ return;
+ }
+ const characterBody = behavior._body;
+ if (!characterBody) {
+ return;
+ }
+ const worldInvScale = this._sharedData.worldInvScale;
+
+ if (!this.character.IsSupported()) {
+ return;
+ }
+
+ const groundBody = this._sharedData.physicsSystem
+ .GetBodyLockInterface()
+ .TryGetBody(this.character.GetGroundBodyID());
+
+ const stillKinematicPlatform =
+ groundBody.IsKinematic() &&
+ groundBody.GetLinearVelocity().Equals(Jolt.Vec3.prototype.sZero()) &&
+ groundBody.GetAngularVelocity().Equals(Jolt.Vec3.prototype.sZero());
+ if (stillKinematicPlatform) {
+ const groundBehavior = groundBody.gdjsAssociatedBehavior;
+ if (groundBehavior) {
+ const inverseTimeDelta = 1 / timeDelta;
+ // The platform may be moved by position changes instead of velocity.
+ // Emulate a velocity from the position changes.
+ groundBody.SetLinearVelocity(
+ this.getVec3(
+ (groundBehavior.owner3D.getX() - groundBehavior._objectOldX) *
+ worldInvScale *
+ inverseTimeDelta,
+ (groundBehavior.owner3D.getY() - groundBehavior._objectOldY) *
+ worldInvScale *
+ inverseTimeDelta,
+ (groundBehavior.owner3D.getZ() - groundBehavior._objectOldZ) *
+ worldInvScale *
+ inverseTimeDelta
+ )
+ );
+ groundBody.SetAngularVelocity(
+ this.getVec3(
+ 0,
+ 0,
+ gdjs.toRad(
+ gdjs.evtTools.common.angleDifference(
+ groundBehavior.owner3D.getAngle(),
+ groundBehavior._objectOldRotationZ
+ )
+ ) * inverseTimeDelta
+ )
+ );
+ }
+ }
+ this.character.UpdateGroundVelocity();
+
+ const groundAngularVelocityZ = groundBody.GetAngularVelocity().GetZ();
+ if (groundAngularVelocityZ !== 0) {
+ // Make the character rotate with the platform on Z axis.
+ const rotation = Jolt.Quat.prototype.sEulerAngles(
+ this.getVec3(
+ 0,
+ 0,
+ characterBody
+ .GetRotation()
+ .GetRotationAngle(Jolt.Vec3.prototype.sAxisZ()) +
+ groundAngularVelocityZ * timeDelta
+ )
+ );
+ // TODO Should the character be used instead of the body directly?
+ this._sharedData.bodyInterface.SetPositionAndRotation(
+ characterBody.GetID(),
+ this.getPhysicsPosition(this.getRVec3(0, 0, 0)),
+ rotation,
+ Jolt.EActivation_Activate
+ );
+ }
+ if (stillKinematicPlatform) {
+ groundBody.SetLinearVelocity(Jolt.Vec3.prototype.sZero());
+ groundBody.SetAngularVelocity(Jolt.Vec3.prototype.sZero());
+ }
+ }
+
+ doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
+
+ onObjectHotReloaded() {}
+
+ /**
+ * Get maximum angle of a slope for the Character to run on it as a floor.
+ * @returns the slope maximum angle, in degrees.
+ */
+ getSlopeMaxAngle(): float {
+ return this._slopeMaxAngle;
+ }
+
+ /**
+ * Set the maximum slope angle of the Character.
+ * @param slopeMaxAngle The new maximum slope angle.
+ */
+ setSlopeMaxAngle(slopeMaxAngle: float): void {
+ if (slopeMaxAngle < 0 || slopeMaxAngle >= 90) {
+ return;
+ }
+ this._slopeMaxAngle = slopeMaxAngle;
+
+ //Avoid rounding errors
+ if (slopeMaxAngle === 45) {
+ this._slopeClimbingFactor = 1;
+ } else {
+ // Avoid a `_slopeClimbingFactor` set to exactly 0.
+ // Otherwise, this can lead the floor finding functions to consider
+ // a floor to be "too high" to reach, even if the object is very slightly
+ // inside it, which can happen because of rounding errors.
+ // See "Floating-point error mitigations" tests.
+ this._slopeClimbingFactor = Math.max(
+ 1 / 1024,
+ Math.tan(gdjs.toRad(slopeMaxAngle))
+ );
+ }
+ // The floor is in 3D but to go back to 2D trigonometry, we can take the
+ // 2D space generated by the floor normal and the Z axis, given that:
+ // - The normal keeps the same Z coordinate (as the Z axis is included in the 2D space)
+ // - The normal keeps the same length (as the normal is included in the 2D space)
+ this._slopeClimbingMinNormalZ = Math.min(
+ Math.cos(gdjs.toRad(slopeMaxAngle)),
+ 1 - 1 / 1024
+ );
+ }
+
+ /**
+ * Get the gravity of the Character.
+ * @returns The current gravity.
+ */
+ getGravity(): float {
+ return this._gravity;
+ }
+
+ /**
+ * Set the gravity of the Character.
+ * @param gravity The new gravity.
+ */
+ setGravity(gravity: float): void {
+ this._gravity = gravity;
+ }
+
+ /**
+ * Get the maximum falling speed of the Character.
+ * @returns The maximum falling speed.
+ */
+ getMaxFallingSpeed(): float {
+ return this._maxFallingSpeed;
+ }
+
+ /**
+ * Set the maximum falling speed of the Character.
+ * @param maxFallingSpeed The maximum falling speed.
+ * @param tryToPreserveAirSpeed If true and if jumping, tune the current
+ * jump speed to preserve the overall speed in the air.
+ */
+ setMaxFallingSpeed(
+ maxFallingSpeed: float,
+ tryToPreserveAirSpeed: boolean = false
+ ): void {
+ if (tryToPreserveAirSpeed && !this.isOnFloor()) {
+ // If the falling speed is too high compared to the new max falling speed,
+ // reduce it and adapt the jump speed to preserve the overall vertical speed.
+ const fallingSpeedOverflow = this._currentFallSpeed - maxFallingSpeed;
+ if (fallingSpeedOverflow > 0) {
+ this._currentFallSpeed -= fallingSpeedOverflow;
+ this._currentJumpSpeed = Math.max(
+ 0,
+ this.getCurrentJumpSpeed() - fallingSpeedOverflow
+ );
+ }
+ }
+ this._maxFallingSpeed = maxFallingSpeed;
+ }
+
+ /**
+ * Get the forward acceleration value of the Character.
+ * @returns The current acceleration.
+ */
+ getForwardAcceleration(): float {
+ return this._forwardAcceleration;
+ }
+
+ /**
+ * Set the forward acceleration of the Character.
+ * @param forwardAcceleration The new acceleration.
+ */
+ setForwardAcceleration(forwardAcceleration: float): void {
+ this._forwardAcceleration = forwardAcceleration;
+ }
+
+ /**
+ * Get the forward deceleration of the Character.
+ * @returns The current deceleration.
+ */
+ getForwardDeceleration(): float {
+ return this._forwardDeceleration;
+ }
+
+ /**
+ * Set the forward deceleration of the Character.
+ * @param forwardDeceleration The new deceleration.
+ */
+ setForwardDeceleration(forwardDeceleration: float): void {
+ this._forwardDeceleration = forwardDeceleration;
+ }
+
+ /**
+ * Get the forward maximum speed of the Character.
+ * @returns The maximum speed.
+ */
+ getForwardSpeedMax(): float {
+ return this._forwardSpeedMax;
+ }
+
+ /**
+ * Set the forward maximum speed of the Character.
+ * @param forwardSpeedMax The new maximum speed.
+ */
+ setForwardSpeedMax(forwardSpeedMax: float): void {
+ this._forwardSpeedMax = forwardSpeedMax;
+ }
+
+ /**
+ * Get the sideways acceleration value of the Character.
+ * @returns The current acceleration.
+ */
+ getSidewaysAcceleration(): float {
+ return this._sidewaysAcceleration;
+ }
+
+ /**
+ * Set the sideways acceleration of the Character.
+ * @param sidewaysAcceleration The new acceleration.
+ */
+ setSidewaysAcceleration(sidewaysAcceleration: float): void {
+ this._sidewaysAcceleration = sidewaysAcceleration;
+ }
+
+ /**
+ * Get the sideways deceleration of the Character.
+ * @returns The current deceleration.
+ */
+ getSidewaysDeceleration(): float {
+ return this._sidewaysDeceleration;
+ }
+
+ /**
+ * Set the sideways deceleration of the Character.
+ * @param sidewaysDeceleration The new deceleration.
+ */
+ setSidewaysDeceleration(sidewaysDeceleration: float): void {
+ this._sidewaysDeceleration = sidewaysDeceleration;
+ }
+
+ /**
+ * Get the sideways maximum speed of the Character.
+ * @returns The maximum speed.
+ */
+ getSidewaysSpeedMax(): float {
+ return this._sidewaysSpeedMax;
+ }
+
+ /**
+ * Set the sideways maximum speed of the Character.
+ * @param sidewaysSpeedMax The new maximum speed.
+ */
+ setSidewaysSpeedMax(sidewaysSpeedMax: float): void {
+ this._sidewaysSpeedMax = sidewaysSpeedMax;
+ }
+
+ /**
+ * Get the jump speed of the Character.
+ * @returns The jump speed.
+ */
+ getJumpSpeed(): float {
+ return this._jumpSpeed;
+ }
+
+ /**
+ * Set the jump speed of the Character.
+ * @param jumpSpeed The new jump speed.
+ */
+ setJumpSpeed(jumpSpeed: float): void {
+ this._jumpSpeed = jumpSpeed;
+ }
+
+ /**
+ * Get the jump sustain time of the Character.
+ * @returns The jump sustain time.
+ */
+ getJumpSustainTime(): float {
+ return this._jumpSustainTime;
+ }
+
+ /**
+ * Set the jump sustain time of the Character.
+ * @param jumpSpeed The new jump sustain time.
+ */
+ setJumpSustainTime(jumpSustainTime: float): void {
+ this._jumpSustainTime = jumpSustainTime;
+ }
+
+ getForwardAngle(): float {
+ return this._forwardAngle;
+ }
+
+ setForwardAngle(angle: float): void {
+ this._forwardAngle = angle;
+ }
+
+ isForwardAngleAround(degreeAngle: float, tolerance: float) {
+ return (
+ Math.abs(
+ gdjs.evtTools.common.angleDifference(this._forwardAngle, degreeAngle)
+ ) <= tolerance
+ );
+ }
+
+ /**
+ * Get the current speed of the Character.
+ * @returns The current speed.
+ */
+ getCurrentForwardSpeed(): float {
+ return this._currentForwardSpeed;
+ }
+
+ /**
+ * Set the current speed of the Character.
+ * @param currentForwardSpeed The current speed.
+ */
+ setCurrentForwardSpeed(currentForwardSpeed: float): void {
+ this._currentForwardSpeed = gdjs.evtTools.common.clamp(
+ currentForwardSpeed,
+ -this._currentForwardSpeed,
+ this._currentForwardSpeed
+ );
+ }
+
+ /**
+ * Get the current speed of the Character.
+ * @returns The current speed.
+ */
+ getCurrentSidewaysSpeed(): float {
+ return this._currentSidewaysSpeed;
+ }
+
+ /**
+ * Set the current speed of the Character.
+ * @param currentSidewaysSpeed The current speed.
+ */
+ setCurrentSidewaysSpeed(currentSidewaysSpeed: float): void {
+ this._currentSidewaysSpeed = gdjs.evtTools.common.clamp(
+ currentSidewaysSpeed,
+ -this._currentSidewaysSpeed,
+ this._currentSidewaysSpeed
+ );
+ }
+
+ /**
+ * Get the speed at which the object is falling. It is 0 when the object is
+ * on a floor, and non 0 as soon as the object leaves the floor.
+ * @returns The current fall speed.
+ */
+ getCurrentFallSpeed(): float {
+ return this._currentFallSpeed;
+ }
+
+ /**
+ * Set the current fall speed.
+ *
+ * When the character is not in the falling state this method has no effect.
+ */
+ setCurrentFallSpeed(currentFallSpeed: float) {
+ if (this.isFalling()) {
+ this._currentFallSpeed = gdjs.evtTools.common.clamp(
+ currentFallSpeed,
+ 0,
+ this._maxFallingSpeed
+ );
+ }
+ }
+
+ /**
+ * Get the current jump speed of the Character.
+ * @returns The current jump speed.
+ */
+ getCurrentJumpSpeed(): float {
+ return this._currentJumpSpeed;
+ }
+
+ /**
+ * Check if the Character can jump.
+ * @returns Returns true if the object can jump.
+ */
+ canJump(): boolean {
+ return this._canJump;
+ }
+
+ /**
+ * Allow the Character to jump again.
+ */
+ setCanJump(): void {
+ this._canJump = true;
+ }
+
+ /**
+ * Forbid the Character to air jump.
+ */
+ setCanNotAirJump(): void {
+ if (this.isJumping() || this.isFalling()) {
+ this._canJump = false;
+ }
+ }
+
+ /**
+ * Abort the current jump.
+ *
+ * When the character is not in the jumping state this method has no effect.
+ */
+ abortJump(): void {
+ if (this.isJumping()) {
+ this._currentFallSpeed = 0;
+ this._currentJumpSpeed = 0;
+ }
+ }
+
+ simulateForwardKey(): void {
+ this.hasPressedForwardKey = true;
+ }
+
+ wasForwardKeyPressed(): boolean {
+ return this._wasForwardKeyPressed;
+ }
+
+ simulateBackwardKey(): void {
+ this.hasPressedBackwardKey = true;
+ }
+
+ wasBackwardKeyPressed(): boolean {
+ return this._wasBackwardKeyPressed;
+ }
+
+ simulateRightKey(): void {
+ this.hasPressedRightKey = true;
+ }
+
+ wasRightKeyPressed(): boolean {
+ return this._wasRightKeyPressed;
+ }
+
+ simulateLeftKey(): void {
+ this.hasPressedLeftKey = true;
+ }
+
+ wasLeftKeyPressed(): boolean {
+ return this._wasLeftKeyPressed;
+ }
+
+ simulateJumpKey(): void {
+ this.hasPressedJumpKey = true;
+ }
+
+ wasJumpKeyPressed(): boolean {
+ return this._wasJumpKeyPressed;
+ }
+
+ simulateStick(stickAngle: float, stickForce: float) {
+ this.hasUsedStick = true;
+ this._stickAngle = stickAngle;
+ this._stickForce = Math.max(0, Math.min(1, stickForce));
+ }
+
+ wasStickUsed(): boolean {
+ return this._wasStickUsed;
+ }
+
+ getStickAngle(): float {
+ return this._wasStickUsed ? this._stickAngle : 0;
+ }
+
+ getStickForce(): float {
+ return this._wasStickUsed ? this._stickForce : 0;
+ }
+
+ // TODO Should we add a "is sliding" condition?
+ /**
+ * Check if the Character is on a floor.
+ * @returns Returns true if on a floor and false if not.
+ */
+ isOnFloor(): boolean {
+ return this.character
+ ? this.character.IsSupported() &&
+ // Ensure characters don't land on too step floor.
+ this.character.GetGroundNormal().GetZ() >=
+ this._slopeClimbingMinNormalZ &&
+ // Ensure characters don't land on a platform corner while jumping.
+ this._currentJumpSpeed <= this._currentFallSpeed
+ : false;
+ }
+
+ /**
+ * Check if the Character is on the given object.
+ * @returns Returns true if on the object and false if not.
+ */
+ isOnFloorObject(physics3DBehavior: gdjs.Physics3DRuntimeBehavior): boolean {
+ if (!physics3DBehavior._body || !this.character || !this.isOnFloor()) {
+ return false;
+ }
+ return (
+ this.character.GetGroundBodyID().GetIndexAndSequenceNumber() ===
+ physics3DBehavior._body.GetID().GetIndexAndSequenceNumber()
+ );
+ }
+
+ /**
+ * Check if the Character is jumping.
+ * @returns Returns true if jumping and false if not.
+ */
+ isJumping(): boolean {
+ return this._currentJumpSpeed > 0;
+ }
+
+ /**
+ * Check if the Character is in the falling state. This is false
+ * if the object is jumping, even if the object is going down after reaching
+ * the jump peak.
+ * @returns Returns true if it is falling and false if not.
+ */
+ isFallingWithoutJumping(): boolean {
+ return !this.isOnFloor() && this._currentJumpSpeed === 0;
+ }
+
+ /**
+ * Check if the Character is "going down", either because it's in the
+ * falling state *or* because it's jumping but reached the jump peak and
+ * is now going down (because the jump speed can't compensate anymore the
+ * falling speed).
+ *
+ * If you want to check if the object is falling outside of a jump (or because
+ * the jump is entirely finished and there is no jump speed applied to the object
+ * anymore), consider using `isFallingWithoutJumping`.
+ *
+ * @returns Returns true if it is "going down" and false if not.
+ */
+ isFalling(): boolean {
+ return (
+ !this.isOnFloor() && this._currentJumpSpeed < this._currentFallSpeed
+ );
+ }
+
+ /**
+ * Check if the Character is moving.
+ * @returns Returns true if it is moving and false if not.
+ */
+ isMovingEvenALittle(): boolean {
+ return (
+ (this._hasReallyMoved && this._currentForwardSpeed !== 0) ||
+ this._currentJumpSpeed !== 0 ||
+ this._currentFallSpeed !== 0
+ );
+ }
+
+ getJumpSpeedToReach(jumpHeight: float): float {
+ // Formulas used in this extension were generated from a math model.
+ // They are probably not understandable on their own.
+ // If you need to modify them or need to write new feature,
+ // please take a look at the platformer extension documentation:
+ // https://github.com/4ian/GDevelop/tree/master/Extensions/PlatformBehavior#readme
+
+ jumpHeight = -Math.abs(jumpHeight);
+
+ const gravity = this._gravity;
+ const maxFallingSpeed = this._maxFallingSpeed;
+ const jumpSustainTime = this._jumpSustainTime;
+
+ const maxFallingSpeedReachedTime = maxFallingSpeed / gravity;
+
+ // The implementation jumps from one quadratic resolution to another
+ // to find the right formula to use as the time is unknown.
+
+ const sustainCase = (jumpHeight) => Math.sqrt(-jumpHeight * gravity * 2);
+ const maxFallingCase = (jumpHeight) =>
+ -gravity * jumpSustainTime +
+ maxFallingSpeed +
+ Math.sqrt(
+ gravity * gravity * jumpSustainTime * jumpSustainTime -
+ 2 * jumpHeight * gravity -
+ maxFallingSpeed * maxFallingSpeed
+ );
+
+ let jumpSpeed = 0;
+ let peakTime = 0;
+ if (maxFallingSpeedReachedTime > jumpSustainTime) {
+ // common case
+ jumpSpeed =
+ -gravity * jumpSustainTime +
+ Math.sqrt(
+ 2 * gravity * gravity * jumpSustainTime * jumpSustainTime -
+ 4 * jumpHeight * gravity
+ );
+ peakTime = (gravity * jumpSustainTime + jumpSpeed) / (2 * gravity);
+ if (peakTime < jumpSustainTime) {
+ jumpSpeed = sustainCase(jumpHeight);
+ } else if (peakTime > maxFallingSpeedReachedTime) {
+ jumpSpeed = maxFallingCase(jumpHeight);
+ }
+ } else {
+ // affine case can't have a maximum
+
+ // sustain case
+ jumpSpeed = sustainCase(jumpHeight);
+ peakTime = jumpSpeed / gravity;
+ if (peakTime > maxFallingSpeedReachedTime) {
+ jumpSpeed = maxFallingCase(jumpHeight);
+ }
+ }
+ return jumpSpeed;
+ }
+ }
+
+ gdjs.registerBehavior(
+ 'Physics3D::PhysicsCharacter3D',
+ gdjs.PhysicsCharacter3DRuntimeBehavior
+ );
+
+ export namespace PhysicsCharacter3DRuntimeBehavior {
+ export class CharacterBodyUpdater {
+ characterBehavior: gdjs.PhysicsCharacter3DRuntimeBehavior;
+
+ constructor(characterBehavior: gdjs.PhysicsCharacter3DRuntimeBehavior) {
+ this.characterBehavior = characterBehavior;
+ }
+
+ createAndAddBody(): Jolt.Body {
+ const { _slopeMaxAngle, owner3D } = this.characterBehavior;
+ const { behavior } = this.characterBehavior.getPhysics3D();
+ const { _sharedData } = behavior;
+
+ const shape = behavior.createShape(0.5);
+
+ const settings = new Jolt.CharacterVirtualSettings();
+ settings.mInnerBodyLayer = behavior.getBodyLayer();
+ settings.mInnerBodyShape = shape;
+ settings.mMass = shape.GetMassProperties().get_mMass();
+ settings.mMaxSlopeAngle = gdjs.toRad(_slopeMaxAngle);
+ settings.mShape = shape;
+ settings.mUp = Jolt.Vec3.prototype.sAxisZ();
+ settings.mBackFaceMode = Jolt.EBackFaceMode_CollideWithBackFaces;
+ // TODO Should we make them configurable?
+ //settings.mMaxStrength = maxStrength;
+ //settings.mCharacterPadding = characterPadding;
+ //settings.mPenetrationRecoverySpeed = penetrationRecoverySpeed;
+ //settings.mPredictiveContactDistance = predictiveContactDistance;
+ const depth = owner3D.getDepth() * _sharedData.worldInvScale;
+ const width = owner3D.getWidth() * _sharedData.worldInvScale;
+ const height = owner3D.getHeight() * _sharedData.worldInvScale;
+ // Only the bottom of the capsule can make a contact with the floor.
+ // It avoids characters from sticking to walls.
+ const capsuleHalfLength = depth / 2;
+ const capsuleRadius = Math.sqrt(width * height) / 2;
+ settings.mSupportingVolume = new Jolt.Plane(
+ Jolt.Vec3.prototype.sAxisZ(),
+ // TODO It's strange that the value is positive.
+ // Use a big safety margin as the ground normal will be checked anyway.
+ // It only avoids to detect walls as ground.
+ capsuleHalfLength -
+ capsuleRadius *
+ (1 - Math.cos(gdjs.toRad(Math.min(_slopeMaxAngle + 20, 70))))
+ );
+ const character = new Jolt.CharacterVirtual(
+ settings,
+ this.characterBehavior.getPhysicsPosition(
+ _sharedData.getRVec3(0, 0, 0)
+ ),
+ behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),
+ _sharedData.physicsSystem
+ );
+ const body = _sharedData.physicsSystem
+ .GetBodyLockInterface()
+ .TryGetBody(character.GetInnerBodyID());
+ this.characterBehavior.character = character;
+ // TODO This is not really reliable. We could choose to disable it and force user to use the "is on platform" condition.
+ //body.SetCollideKinematicVsNonDynamic(true);
+ return body;
+ }
+
+ updateObjectFromBody() {
+ const { character } = this.characterBehavior;
+ if (!character) {
+ return;
+ }
+ // We can't rely on the body position because of mCharacterPadding.
+ this.characterBehavior.moveObjectToPhysicsPosition(
+ character.GetPosition()
+ );
+ // No need to update the rotation as CharacterVirtual doesn't change it.
+ }
+
+ updateBodyFromObject() {
+ const { behavior } = this.characterBehavior.getPhysics3D();
+ const { _sharedData } = behavior;
+ const { character, owner3D } = this.characterBehavior;
+ if (!character) {
+ return;
+ }
+ // The object object transform has changed, update body transform:
+ if (
+ behavior._objectOldX !== owner3D.getX() ||
+ behavior._objectOldY !== owner3D.getY() ||
+ behavior._objectOldZ !== owner3D.getZ()
+ ) {
+ character.SetPosition(
+ this.characterBehavior.getPhysicsPosition(
+ _sharedData.getRVec3(0, 0, 0)
+ )
+ );
+ }
+ if (
+ behavior._objectOldRotationX !== owner3D.getRotationX() ||
+ behavior._objectOldRotationY !== owner3D.getRotationY() ||
+ behavior._objectOldRotationZ !== owner3D.getAngle()
+ ) {
+ behavior.getPhysicsRotation(
+ behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1))
+ );
+ }
+ }
+
+ recreateShape() {
+ const {
+ behavior,
+ broadPhaseLayerFilter,
+ objectLayerFilter,
+ bodyFilter,
+ shapeFilter,
+ } = this.characterBehavior.getPhysics3D();
+ const { _sharedData } = behavior;
+ const { character } = this.characterBehavior;
+ if (!character) {
+ return;
+ }
+ const shape = behavior.createShape(0.5);
+ const isShapeValid = character.SetShape(
+ shape,
+ Number.MAX_VALUE,
+ broadPhaseLayerFilter,
+ objectLayerFilter,
+ bodyFilter,
+ shapeFilter,
+ _sharedData.jolt.GetTempAllocator()
+ );
+ if (!isShapeValid) {
+ return;
+ }
+ character.SetInnerBodyShape(shape);
+ character.SetMass(shape.GetMassProperties().get_mMass());
+ }
+ }
+ }
+}
diff --git a/Extensions/Physics3DBehavior/jolt-physics.d.ts b/Extensions/Physics3DBehavior/jolt-physics.d.ts
new file mode 100644
index 000000000000..5ba025eb9991
--- /dev/null
+++ b/Extensions/Physics3DBehavior/jolt-physics.d.ts
@@ -0,0 +1,4874 @@
+declare namespace Jolt {
+ function destroy(obj: any): void;
+ function _malloc(size: number): number;
+ function _free(ptr: number): void;
+ function wrapPointer any>(
+ ptr: number,
+ Class: C
+ ): InstanceType;
+ function getPointer(obj: unknown): number;
+ function castObject any>(
+ object: unknown,
+ Class: C
+ ): InstanceType;
+ function compare(object1: unknown, object2: unknown): boolean;
+ const HEAP8: Int8Array;
+ const HEAP16: Int16Array;
+ const HEAP32: Int32Array;
+ const HEAPU8: Uint8Array;
+ const HEAPU16: Uint16Array;
+ const HEAPU32: Uint32Array;
+ const HEAPF32: Float32Array;
+ const HEAPF64: Float64Array;
+ class JPHString {
+ constructor(str: string, length: number);
+ c_str(): string;
+ size(): number;
+ }
+ class ArrayVec3 {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Vec3;
+ push_back(inValue: Vec3): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): Vec3MemRef;
+ }
+ class ArrayQuat {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Quat;
+ push_back(inValue: Quat): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): QuatMemRef;
+ }
+ class ArrayMat44 {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Mat44;
+ push_back(inValue: Mat44): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): Mat44MemRef;
+ }
+ const EBodyType_RigidBody: number;
+ const EBodyType_SoftBody: number;
+ type EBodyType = typeof EBodyType_RigidBody | typeof EBodyType_SoftBody;
+ function _emscripten_enum_EBodyType_EBodyType_RigidBody(): EBodyType;
+ function _emscripten_enum_EBodyType_EBodyType_SoftBody(): EBodyType;
+ const EMotionType_Static: number;
+ const EMotionType_Kinematic: number;
+ const EMotionType_Dynamic: number;
+ type EMotionType =
+ | typeof EMotionType_Static
+ | typeof EMotionType_Kinematic
+ | typeof EMotionType_Dynamic;
+ function _emscripten_enum_EMotionType_EMotionType_Static(): EMotionType;
+ function _emscripten_enum_EMotionType_EMotionType_Kinematic(): EMotionType;
+ function _emscripten_enum_EMotionType_EMotionType_Dynamic(): EMotionType;
+ const EMotionQuality_Discrete: number;
+ const EMotionQuality_LinearCast: number;
+ type EMotionQuality =
+ | typeof EMotionQuality_Discrete
+ | typeof EMotionQuality_LinearCast;
+ function _emscripten_enum_EMotionQuality_EMotionQuality_Discrete(): EMotionQuality;
+ function _emscripten_enum_EMotionQuality_EMotionQuality_LinearCast(): EMotionQuality;
+ const EActivation_Activate: number;
+ const EActivation_DontActivate: number;
+ type EActivation =
+ | typeof EActivation_Activate
+ | typeof EActivation_DontActivate;
+ function _emscripten_enum_EActivation_EActivation_Activate(): EActivation;
+ function _emscripten_enum_EActivation_EActivation_DontActivate(): EActivation;
+ const EShapeType_Convex: number;
+ const EShapeType_Compound: number;
+ const EShapeType_Decorated: number;
+ const EShapeType_Mesh: number;
+ const EShapeType_HeightField: number;
+ const EShapeType_Plane: number;
+ const EShapeType_Empty: number;
+ type EShapeType =
+ | typeof EShapeType_Convex
+ | typeof EShapeType_Compound
+ | typeof EShapeType_Decorated
+ | typeof EShapeType_Mesh
+ | typeof EShapeType_HeightField
+ | typeof EShapeType_Plane
+ | typeof EShapeType_Empty;
+ function _emscripten_enum_EShapeType_EShapeType_Convex(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_Compound(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_Decorated(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_Mesh(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_HeightField(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_Plane(): EShapeType;
+ function _emscripten_enum_EShapeType_EShapeType_Empty(): EShapeType;
+ const EShapeSubType_Sphere: number;
+ const EShapeSubType_Box: number;
+ const EShapeSubType_Capsule: number;
+ const EShapeSubType_TaperedCapsule: number;
+ const EShapeSubType_Cylinder: number;
+ const EShapeSubType_TaperedCylinder: number;
+ const EShapeSubType_ConvexHull: number;
+ const EShapeSubType_StaticCompound: number;
+ const EShapeSubType_MutableCompound: number;
+ const EShapeSubType_RotatedTranslated: number;
+ const EShapeSubType_Scaled: number;
+ const EShapeSubType_OffsetCenterOfMass: number;
+ const EShapeSubType_Mesh: number;
+ const EShapeSubType_HeightField: number;
+ const EShapeSubType_Plane: number;
+ const EShapeSubType_Empty: number;
+ type EShapeSubType =
+ | typeof EShapeSubType_Sphere
+ | typeof EShapeSubType_Box
+ | typeof EShapeSubType_Capsule
+ | typeof EShapeSubType_TaperedCapsule
+ | typeof EShapeSubType_Cylinder
+ | typeof EShapeSubType_TaperedCylinder
+ | typeof EShapeSubType_ConvexHull
+ | typeof EShapeSubType_StaticCompound
+ | typeof EShapeSubType_MutableCompound
+ | typeof EShapeSubType_RotatedTranslated
+ | typeof EShapeSubType_Scaled
+ | typeof EShapeSubType_OffsetCenterOfMass
+ | typeof EShapeSubType_Mesh
+ | typeof EShapeSubType_HeightField
+ | typeof EShapeSubType_Plane
+ | typeof EShapeSubType_Empty;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Sphere(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Box(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Capsule(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_TaperedCapsule(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Cylinder(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_TaperedCylinder(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_ConvexHull(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_StaticCompound(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_MutableCompound(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_RotatedTranslated(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Scaled(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_OffsetCenterOfMass(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Mesh(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_HeightField(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Plane(): EShapeSubType;
+ function _emscripten_enum_EShapeSubType_EShapeSubType_Empty(): EShapeSubType;
+ const EConstraintSpace_LocalToBodyCOM: number;
+ const EConstraintSpace_WorldSpace: number;
+ type EConstraintSpace =
+ | typeof EConstraintSpace_LocalToBodyCOM
+ | typeof EConstraintSpace_WorldSpace;
+ function _emscripten_enum_EConstraintSpace_EConstraintSpace_LocalToBodyCOM(): EConstraintSpace;
+ function _emscripten_enum_EConstraintSpace_EConstraintSpace_WorldSpace(): EConstraintSpace;
+ const ESpringMode_FrequencyAndDamping: number;
+ const ESpringMode_StiffnessAndDamping: number;
+ type ESpringMode =
+ | typeof ESpringMode_FrequencyAndDamping
+ | typeof ESpringMode_StiffnessAndDamping;
+ function _emscripten_enum_ESpringMode_ESpringMode_FrequencyAndDamping(): ESpringMode;
+ function _emscripten_enum_ESpringMode_ESpringMode_StiffnessAndDamping(): ESpringMode;
+ const EOverrideMassProperties_CalculateMassAndInertia: number;
+ const EOverrideMassProperties_CalculateInertia: number;
+ const EOverrideMassProperties_MassAndInertiaProvided: number;
+ type EOverrideMassProperties =
+ | typeof EOverrideMassProperties_CalculateMassAndInertia
+ | typeof EOverrideMassProperties_CalculateInertia
+ | typeof EOverrideMassProperties_MassAndInertiaProvided;
+ function _emscripten_enum_EOverrideMassProperties_EOverrideMassProperties_CalculateMassAndInertia(): EOverrideMassProperties;
+ function _emscripten_enum_EOverrideMassProperties_EOverrideMassProperties_CalculateInertia(): EOverrideMassProperties;
+ function _emscripten_enum_EOverrideMassProperties_EOverrideMassProperties_MassAndInertiaProvided(): EOverrideMassProperties;
+ const EAllowedDOFs_TranslationX: number;
+ const EAllowedDOFs_TranslationY: number;
+ const EAllowedDOFs_TranslationZ: number;
+ const EAllowedDOFs_RotationX: number;
+ const EAllowedDOFs_RotationY: number;
+ const EAllowedDOFs_RotationZ: number;
+ const EAllowedDOFs_Plane2D: number;
+ const EAllowedDOFs_All: number;
+ type EAllowedDOFs =
+ | typeof EAllowedDOFs_TranslationX
+ | typeof EAllowedDOFs_TranslationY
+ | typeof EAllowedDOFs_TranslationZ
+ | typeof EAllowedDOFs_RotationX
+ | typeof EAllowedDOFs_RotationY
+ | typeof EAllowedDOFs_RotationZ
+ | typeof EAllowedDOFs_Plane2D
+ | typeof EAllowedDOFs_All;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_TranslationX(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_TranslationY(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_TranslationZ(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_RotationX(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_RotationY(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_RotationZ(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_Plane2D(): EAllowedDOFs;
+ function _emscripten_enum_EAllowedDOFs_EAllowedDOFs_All(): EAllowedDOFs;
+ const EStateRecorderState_None: number;
+ const EStateRecorderState_Global: number;
+ const EStateRecorderState_Bodies: number;
+ const EStateRecorderState_Contacts: number;
+ const EStateRecorderState_Constraints: number;
+ const EStateRecorderState_All: number;
+ type EStateRecorderState =
+ | typeof EStateRecorderState_None
+ | typeof EStateRecorderState_Global
+ | typeof EStateRecorderState_Bodies
+ | typeof EStateRecorderState_Contacts
+ | typeof EStateRecorderState_Constraints
+ | typeof EStateRecorderState_All;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_None(): EStateRecorderState;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_Global(): EStateRecorderState;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_Bodies(): EStateRecorderState;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_Contacts(): EStateRecorderState;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_Constraints(): EStateRecorderState;
+ function _emscripten_enum_EStateRecorderState_EStateRecorderState_All(): EStateRecorderState;
+ const EBackFaceMode_IgnoreBackFaces: number;
+ const EBackFaceMode_CollideWithBackFaces: number;
+ type EBackFaceMode =
+ | typeof EBackFaceMode_IgnoreBackFaces
+ | typeof EBackFaceMode_CollideWithBackFaces;
+ function _emscripten_enum_EBackFaceMode_EBackFaceMode_IgnoreBackFaces(): EBackFaceMode;
+ function _emscripten_enum_EBackFaceMode_EBackFaceMode_CollideWithBackFaces(): EBackFaceMode;
+ const EGroundState_OnGround: number;
+ const EGroundState_OnSteepGround: number;
+ const EGroundState_NotSupported: number;
+ const EGroundState_InAir: number;
+ type EGroundState =
+ | typeof EGroundState_OnGround
+ | typeof EGroundState_OnSteepGround
+ | typeof EGroundState_NotSupported
+ | typeof EGroundState_InAir;
+ function _emscripten_enum_EGroundState_EGroundState_OnGround(): EGroundState;
+ function _emscripten_enum_EGroundState_EGroundState_OnSteepGround(): EGroundState;
+ function _emscripten_enum_EGroundState_EGroundState_NotSupported(): EGroundState;
+ function _emscripten_enum_EGroundState_EGroundState_InAir(): EGroundState;
+ const ValidateResult_AcceptAllContactsForThisBodyPair: number;
+ const ValidateResult_AcceptContact: number;
+ const ValidateResult_RejectContact: number;
+ const ValidateResult_RejectAllContactsForThisBodyPair: number;
+ type ValidateResult =
+ | typeof ValidateResult_AcceptAllContactsForThisBodyPair
+ | typeof ValidateResult_AcceptContact
+ | typeof ValidateResult_RejectContact
+ | typeof ValidateResult_RejectAllContactsForThisBodyPair;
+ function _emscripten_enum_ValidateResult_ValidateResult_AcceptAllContactsForThisBodyPair(): ValidateResult;
+ function _emscripten_enum_ValidateResult_ValidateResult_AcceptContact(): ValidateResult;
+ function _emscripten_enum_ValidateResult_ValidateResult_RejectContact(): ValidateResult;
+ function _emscripten_enum_ValidateResult_ValidateResult_RejectAllContactsForThisBodyPair(): ValidateResult;
+ const SoftBodyValidateResult_AcceptContact: number;
+ const SoftBodyValidateResult_RejectContact: number;
+ type SoftBodyValidateResult =
+ | typeof SoftBodyValidateResult_AcceptContact
+ | typeof SoftBodyValidateResult_RejectContact;
+ function _emscripten_enum_SoftBodyValidateResult_SoftBodyValidateResult_AcceptContact(): SoftBodyValidateResult;
+ function _emscripten_enum_SoftBodyValidateResult_SoftBodyValidateResult_RejectContact(): SoftBodyValidateResult;
+ const EActiveEdgeMode_CollideOnlyWithActive: number;
+ const EActiveEdgeMode_CollideWithAll: number;
+ type EActiveEdgeMode =
+ | typeof EActiveEdgeMode_CollideOnlyWithActive
+ | typeof EActiveEdgeMode_CollideWithAll;
+ function _emscripten_enum_EActiveEdgeMode_EActiveEdgeMode_CollideOnlyWithActive(): EActiveEdgeMode;
+ function _emscripten_enum_EActiveEdgeMode_EActiveEdgeMode_CollideWithAll(): EActiveEdgeMode;
+ const ECollectFacesMode_CollectFaces: number;
+ const ECollectFacesMode_NoFaces: number;
+ type ECollectFacesMode =
+ | typeof ECollectFacesMode_CollectFaces
+ | typeof ECollectFacesMode_NoFaces;
+ function _emscripten_enum_ECollectFacesMode_ECollectFacesMode_CollectFaces(): ECollectFacesMode;
+ function _emscripten_enum_ECollectFacesMode_ECollectFacesMode_NoFaces(): ECollectFacesMode;
+ const SixDOFConstraintSettings_EAxis_TranslationX: number;
+ const SixDOFConstraintSettings_EAxis_TranslationY: number;
+ const SixDOFConstraintSettings_EAxis_TranslationZ: number;
+ const SixDOFConstraintSettings_EAxis_RotationX: number;
+ const SixDOFConstraintSettings_EAxis_RotationY: number;
+ const SixDOFConstraintSettings_EAxis_RotationZ: number;
+ type SixDOFConstraintSettings_EAxis =
+ | typeof SixDOFConstraintSettings_EAxis_TranslationX
+ | typeof SixDOFConstraintSettings_EAxis_TranslationY
+ | typeof SixDOFConstraintSettings_EAxis_TranslationZ
+ | typeof SixDOFConstraintSettings_EAxis_RotationX
+ | typeof SixDOFConstraintSettings_EAxis_RotationY
+ | typeof SixDOFConstraintSettings_EAxis_RotationZ;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_TranslationX(): SixDOFConstraintSettings_EAxis;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_TranslationY(): SixDOFConstraintSettings_EAxis;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_TranslationZ(): SixDOFConstraintSettings_EAxis;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_RotationX(): SixDOFConstraintSettings_EAxis;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_RotationY(): SixDOFConstraintSettings_EAxis;
+ function _emscripten_enum_SixDOFConstraintSettings_EAxis_SixDOFConstraintSettings_EAxis_RotationZ(): SixDOFConstraintSettings_EAxis;
+ const EConstraintType_Constraint: number;
+ const EConstraintType_TwoBodyConstraint: number;
+ type EConstraintType =
+ | typeof EConstraintType_Constraint
+ | typeof EConstraintType_TwoBodyConstraint;
+ function _emscripten_enum_EConstraintType_EConstraintType_Constraint(): EConstraintType;
+ function _emscripten_enum_EConstraintType_EConstraintType_TwoBodyConstraint(): EConstraintType;
+ const EConstraintSubType_Fixed: number;
+ const EConstraintSubType_Point: number;
+ const EConstraintSubType_Hinge: number;
+ const EConstraintSubType_Slider: number;
+ const EConstraintSubType_Distance: number;
+ const EConstraintSubType_Cone: number;
+ const EConstraintSubType_SwingTwist: number;
+ const EConstraintSubType_SixDOF: number;
+ const EConstraintSubType_Path: number;
+ const EConstraintSubType_Vehicle: number;
+ const EConstraintSubType_RackAndPinion: number;
+ const EConstraintSubType_Gear: number;
+ const EConstraintSubType_Pulley: number;
+ type EConstraintSubType =
+ | typeof EConstraintSubType_Fixed
+ | typeof EConstraintSubType_Point
+ | typeof EConstraintSubType_Hinge
+ | typeof EConstraintSubType_Slider
+ | typeof EConstraintSubType_Distance
+ | typeof EConstraintSubType_Cone
+ | typeof EConstraintSubType_SwingTwist
+ | typeof EConstraintSubType_SixDOF
+ | typeof EConstraintSubType_Path
+ | typeof EConstraintSubType_Vehicle
+ | typeof EConstraintSubType_RackAndPinion
+ | typeof EConstraintSubType_Gear
+ | typeof EConstraintSubType_Pulley;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Fixed(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Point(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Hinge(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Slider(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Distance(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Cone(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_SwingTwist(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_SixDOF(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Path(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Vehicle(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_RackAndPinion(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Gear(): EConstraintSubType;
+ function _emscripten_enum_EConstraintSubType_EConstraintSubType_Pulley(): EConstraintSubType;
+ const EMotorState_Off: number;
+ const EMotorState_Velocity: number;
+ const EMotorState_Position: number;
+ type EMotorState =
+ | typeof EMotorState_Off
+ | typeof EMotorState_Velocity
+ | typeof EMotorState_Position;
+ function _emscripten_enum_EMotorState_EMotorState_Off(): EMotorState;
+ function _emscripten_enum_EMotorState_EMotorState_Velocity(): EMotorState;
+ function _emscripten_enum_EMotorState_EMotorState_Position(): EMotorState;
+ const ETransmissionMode_Auto: number;
+ const ETransmissionMode_Manual: number;
+ type ETransmissionMode =
+ | typeof ETransmissionMode_Auto
+ | typeof ETransmissionMode_Manual;
+ function _emscripten_enum_ETransmissionMode_ETransmissionMode_Auto(): ETransmissionMode;
+ function _emscripten_enum_ETransmissionMode_ETransmissionMode_Manual(): ETransmissionMode;
+ const ETireFrictionDirection_Longitudinal: number;
+ const ETireFrictionDirection_Lateral: number;
+ type ETireFrictionDirection =
+ | typeof ETireFrictionDirection_Longitudinal
+ | typeof ETireFrictionDirection_Lateral;
+ function _emscripten_enum_ETireFrictionDirection_ETireFrictionDirection_Longitudinal(): ETireFrictionDirection;
+ function _emscripten_enum_ETireFrictionDirection_ETireFrictionDirection_Lateral(): ETireFrictionDirection;
+ const ESwingType_Cone: number;
+ const ESwingType_Pyramid: number;
+ type ESwingType = typeof ESwingType_Cone | typeof ESwingType_Pyramid;
+ function _emscripten_enum_ESwingType_ESwingType_Cone(): ESwingType;
+ function _emscripten_enum_ESwingType_ESwingType_Pyramid(): ESwingType;
+ const EPathRotationConstraintType_Free: number;
+ const EPathRotationConstraintType_ConstrainAroundTangent: number;
+ const EPathRotationConstraintType_ConstrainAroundNormal: number;
+ const EPathRotationConstraintType_ConstrainAroundBinormal: number;
+ const EPathRotationConstraintType_ConstrainToPath: number;
+ const EPathRotationConstraintType_FullyConstrained: number;
+ type EPathRotationConstraintType =
+ | typeof EPathRotationConstraintType_Free
+ | typeof EPathRotationConstraintType_ConstrainAroundTangent
+ | typeof EPathRotationConstraintType_ConstrainAroundNormal
+ | typeof EPathRotationConstraintType_ConstrainAroundBinormal
+ | typeof EPathRotationConstraintType_ConstrainToPath
+ | typeof EPathRotationConstraintType_FullyConstrained;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_Free(): EPathRotationConstraintType;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_ConstrainAroundTangent(): EPathRotationConstraintType;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_ConstrainAroundNormal(): EPathRotationConstraintType;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_ConstrainAroundBinormal(): EPathRotationConstraintType;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_ConstrainToPath(): EPathRotationConstraintType;
+ function _emscripten_enum_EPathRotationConstraintType_EPathRotationConstraintType_FullyConstrained(): EPathRotationConstraintType;
+ const SoftBodySharedSettings_EBendType_None: number;
+ const SoftBodySharedSettings_EBendType_Distance: number;
+ const SoftBodySharedSettings_EBendType_Dihedral: number;
+ type SoftBodySharedSettings_EBendType =
+ | typeof SoftBodySharedSettings_EBendType_None
+ | typeof SoftBodySharedSettings_EBendType_Distance
+ | typeof SoftBodySharedSettings_EBendType_Dihedral;
+ function _emscripten_enum_SoftBodySharedSettings_EBendType_SoftBodySharedSettings_EBendType_None(): SoftBodySharedSettings_EBendType;
+ function _emscripten_enum_SoftBodySharedSettings_EBendType_SoftBodySharedSettings_EBendType_Distance(): SoftBodySharedSettings_EBendType;
+ function _emscripten_enum_SoftBodySharedSettings_EBendType_SoftBodySharedSettings_EBendType_Dihedral(): SoftBodySharedSettings_EBendType;
+ const SoftBodySharedSettings_ELRAType_None: number;
+ const SoftBodySharedSettings_ELRAType_EuclideanDistance: number;
+ const SoftBodySharedSettings_ELRAType_GeodesicDistance: number;
+ type SoftBodySharedSettings_ELRAType =
+ | typeof SoftBodySharedSettings_ELRAType_None
+ | typeof SoftBodySharedSettings_ELRAType_EuclideanDistance
+ | typeof SoftBodySharedSettings_ELRAType_GeodesicDistance;
+ function _emscripten_enum_SoftBodySharedSettings_ELRAType_SoftBodySharedSettings_ELRAType_None(): SoftBodySharedSettings_ELRAType;
+ function _emscripten_enum_SoftBodySharedSettings_ELRAType_SoftBodySharedSettings_ELRAType_EuclideanDistance(): SoftBodySharedSettings_ELRAType;
+ function _emscripten_enum_SoftBodySharedSettings_ELRAType_SoftBodySharedSettings_ELRAType_GeodesicDistance(): SoftBodySharedSettings_ELRAType;
+ class Vec3MemRef {}
+ class QuatMemRef {}
+ class Mat44MemRef {}
+ class FloatMemRef {}
+ class Uint8MemRef {}
+ class UintMemRef {}
+ class Vec3 {
+ constructor();
+ constructor(inV: Float3);
+ constructor(inX: number, inY: number, inZ: number);
+ sZero(): Vec3;
+ sAxisX(): Vec3;
+ sAxisY(): Vec3;
+ sAxisZ(): Vec3;
+ sReplicate(inValue: number): Vec3;
+ sMin(inLHS: Vec3, inRHS: Vec3): Vec3;
+ sMax(inLHS: Vec3, inRHS: Vec3): Vec3;
+ sClamp(inValue: Vec3, inMin: Vec3, inMax: Vec3): Vec3;
+ sUnitSpherical(inTheta: number, inPhi: number): Vec3;
+ GetComponent(inCoordinate: number): number;
+ Equals(inV: Vec3): boolean;
+ NotEquals(inV: Vec3): boolean;
+ LengthSq(): number;
+ Length(): number;
+ Normalized(): Vec3;
+ NormalizedOr(inZeroValue: Vec3): Vec3;
+ GetNormalizedPerpendicular(): Vec3;
+ GetX(): number;
+ GetY(): number;
+ GetZ(): number;
+ SetX(inX: number): void;
+ SetY(inY: number): void;
+ SetZ(inZ: number): void;
+ Set(inX: number, inY: number, inZ: number): void;
+ SetComponent(inCoordinate: number, inValue: number): void;
+ IsNearZero(inMaxDistSq?: number): boolean;
+ IsClose(inV: Vec3, inMaxDistSq?: number): boolean;
+ IsNormalized(inTolerance?: number): boolean;
+ GetLowestComponentIndex(): number;
+ GetHighestComponentIndex(): number;
+ Abs(): Vec3;
+ Reciprocal(): Vec3;
+ Cross(inRHS: Vec3): Vec3;
+ Dot(inRHS: Vec3): number;
+ Add(inV: Vec3): Vec3;
+ Sub(inV: Vec3): Vec3;
+ Mul(inV: number): Vec3;
+ Div(inV: number): Vec3;
+ ReduceMin(): number;
+ ReduceMax(): number;
+ Sqrt(): Vec3;
+ GetSign(): Vec3;
+ }
+ class RVec3 {
+ constructor();
+ constructor(inX: number, inY: number, inZ: number);
+ sZero(): RVec3;
+ sAxisX(): RVec3;
+ sAxisY(): RVec3;
+ sAxisZ(): RVec3;
+ sReplicate(inValue: number): RVec3;
+ sMin(inLHS: RVec3, inRHS: RVec3): RVec3;
+ sMax(inLHS: RVec3, inRHS: RVec3): RVec3;
+ sClamp(inValue: RVec3, inMin: RVec3, inMax: RVec3): RVec3;
+ GetComponent(inCoordinate: number): number;
+ Equals(inV: RVec3): boolean;
+ NotEquals(inV: RVec3): boolean;
+ LengthSq(): number;
+ Length(): number;
+ Normalized(): RVec3;
+ GetX(): number;
+ GetY(): number;
+ GetZ(): number;
+ SetX(inX: number): void;
+ SetY(inY: number): void;
+ SetZ(inZ: number): void;
+ Set(inX: number, inY: number, inZ: number): void;
+ SetComponent(inCoordinate: number, inValue: number): void;
+ IsNearZero(inMaxDistSq?: number): boolean;
+ IsClose(inV: RVec3, inMaxDistSq?: number): boolean;
+ IsNormalized(inTolerance?: number): boolean;
+ Abs(): RVec3;
+ Reciprocal(): RVec3;
+ Cross(inRHS: RVec3): RVec3;
+ Dot(inRHS: RVec3): number;
+ Add(inV: Vec3): RVec3;
+ Sub(inV: Vec3): RVec3;
+ Mul(inV: number): RVec3;
+ Div(inV: number): RVec3;
+ Sqrt(): RVec3;
+ GetSign(): RVec3;
+ }
+ class Vec4 {
+ constructor();
+ constructor(inV: Vec4);
+ constructor(inV: Vec3, inW: number);
+ constructor(inX: number, inY: number, inZ: number, inW: number);
+ GetX(): number;
+ GetY(): number;
+ GetZ(): number;
+ GetW(): number;
+ SetX(inX: number): void;
+ SetY(inY: number): void;
+ SetZ(inZ: number): void;
+ SetW(inW: number): void;
+ Set(inX: number, inY: number, inZ: number, inW: number): void;
+ GetComponent(inCoordinate: number): number;
+ }
+ class Vector2 {
+ constructor();
+ SetZero(): void;
+ IsZero(): void;
+ IsClose(inV: Vector2, inMaxDistSq?: number): void;
+ IsNormalized(inTolerance?: number): void;
+ Normalized(): Vector2;
+ GetComponent(inCoordinate: number): number;
+ Add(inV: Vector2): Vector2;
+ Sub(inV: Vector2): Vector2;
+ Mul(inV: number): Vector2;
+ Div(inV: number): Vector2;
+ Dot(inRHS: Vector2): number;
+ }
+ class Quat {
+ constructor();
+ constructor(inX: number, inY: number, inZ: number, inW: number);
+ sZero(): Quat;
+ sIdentity(): Quat;
+ sRotation(inRotation: Vec3, inAngle: number): Quat;
+ sFromTo(inFrom: Vec3, inTo: Vec3): Quat;
+ Equals(inQ: Quat): boolean;
+ NotEquals(inQ: Quat): boolean;
+ MulQuat(inQ: Quat): Quat;
+ MulVec3(inV: Vec3): Vec3;
+ MulFloat(inV: number): Quat;
+ IsClose(inQ: Quat, inMaxDistSq?: number): boolean;
+ IsNormalized(inTolerance?: number): boolean;
+ Length(): number;
+ LengthSq(): number;
+ Normalized(): Quat;
+ sEulerAngles(inInput: Vec3): Quat;
+ GetEulerAngles(): Vec3;
+ GetX(): number;
+ GetY(): number;
+ GetZ(): number;
+ GetW(): number;
+ GetXYZ(): Vec3;
+ SetX(inX: number): void;
+ SetY(inY: number): void;
+ SetZ(inZ: number): void;
+ SetW(inW: number): void;
+ Set(inX: number, inY: number, inZ: number, inW: number): void;
+ InverseRotate(inV: Vec3): Vec3;
+ RotateAxisX(): Vec3;
+ RotateAxisY(): Vec3;
+ RotateAxisZ(): Vec3;
+ Dot(inQ: Quat): number;
+ Conjugated(): Quat;
+ Inversed(): Quat;
+ EnsureWPositive(): Quat;
+ GetPerpendicular(): Quat;
+ GetRotationAngle(inAxis: Vec3): number;
+ GetTwist(inAxis: Vec3): Quat;
+ GetSwingTwist(outSwing: Quat, outTwist: Quat): void;
+ LERP(inDestination: Quat, inFraction: number): Quat;
+ SLERP(inDestination: Quat, inFraction: number): Quat;
+ }
+ class Float3 {
+ constructor(inX: number, inY: number, inZ: number);
+ Equals(inV: Float3): boolean;
+ NotEquals(inV: Float3): boolean;
+ get_x(): number;
+ set_x(x: number): void;
+ x: number;
+ get_y(): number;
+ set_y(y: number): void;
+ y: number;
+ get_z(): number;
+ set_z(z: number): void;
+ z: number;
+ }
+ class Mat44 {
+ constructor();
+ sZero(): Mat44;
+ sIdentity(): Mat44;
+ sRotationX(inX: number): Mat44;
+ sRotationY(inY: number): Mat44;
+ sRotationZ(inZ: number): Mat44;
+ sRotation(inQ: Quat): Mat44;
+ sTranslation(inTranslation: Vec3): Mat44;
+ sRotationTranslation(inRotation: Quat, inTranslation: Vec3): Mat44;
+ sInverseRotationTranslation(inRotation: Quat, inTranslation: Vec3): Mat44;
+ sScale(inScale: number): Mat44;
+ sPerspective(
+ inFovY: number,
+ inAspect: number,
+ inNear: number,
+ inFar: number
+ ): Mat44;
+ GetAxisX(): Vec3;
+ GetAxisY(): Vec3;
+ GetAxisZ(): Vec3;
+ GetRotation(): Mat44;
+ GetQuaternion(): Quat;
+ GetTranslation(): Vec3;
+ IsClose(inM: Mat44, inMaxDistSq?: number): boolean;
+ Multiply3x3(inV: Vec3): Vec3;
+ Multiply3x3Transposed(inV: Vec3): Vec3;
+ Transposed(): Mat44;
+ Transposed3x3(): Mat44;
+ Inversed(): Mat44;
+ InversedRotationTranslation(): Mat44;
+ GetDeterminant3x3(): number;
+ Inversed3x3(): Mat44;
+ GetDirectionPreservingMatrix(): Mat44;
+ PreTranslated(inTranslation: Vec3): Mat44;
+ PostTranslated(inTranslation: Vec3): Mat44;
+ PreScaled(inScale: Vec3): Mat44;
+ PostScaled(inScale: Vec3): Mat44;
+ SetColumn3(inCol: number, inV: Vec3): void;
+ SetAxisX(inV: Vec3): void;
+ SetAxisY(inV: Vec3): void;
+ SetAxisZ(inV: Vec3): void;
+ SetTranslation(inV: Vec3): void;
+ SetColumn4(inCol: number, inV: Vec4): void;
+ GetColumn4(inCol: number): Vec4;
+ }
+ class RMat44 {
+ constructor();
+ sZero(): RMat44;
+ sIdentity(): RMat44;
+ sRotation(inQ: Quat): RMat44;
+ sTranslation(inTranslation: RVec3): RMat44;
+ sRotationTranslation(inRotation: Quat, inTranslation: RVec3): RMat44;
+ sInverseRotationTranslation(inRotation: Quat, inTranslation: RVec3): RMat44;
+ GetAxisX(): Vec3;
+ GetAxisY(): Vec3;
+ GetAxisZ(): Vec3;
+ GetRotation(): Mat44;
+ GetQuaternion(): Quat;
+ GetTranslation(): RVec3;
+ IsClose(inM: RMat44, inMaxDistSq?: number): boolean;
+ Multiply3x3(inV: Vec3): Vec3;
+ Multiply3x3Transposed(inV: Vec3): Vec3;
+ Transposed3x3(): Mat44;
+ Inversed(): RMat44;
+ InversedRotationTranslation(): RMat44;
+ PreTranslated(inTranslation: Vec3): RMat44;
+ PostTranslated(inTranslation: Vec3): RMat44;
+ PreScaled(inScale: Vec3): RMat44;
+ PostScaled(inScale: Vec3): RMat44;
+ SetColumn3(inCol: number, inV: Vec3): void;
+ SetAxisX(inV: Vec3): void;
+ SetAxisY(inV: Vec3): void;
+ SetAxisZ(inV: Vec3): void;
+ SetTranslation(inV: RVec3): void;
+ SetColumn4(inCol: number, inV: Vec4): void;
+ GetColumn4(inCol: number): Vec4;
+ }
+ class AABox {
+ constructor();
+ constructor(inMin: Vec3, inMax: Vec3);
+ sBiggest(): AABox;
+ get_mMin(): Vec3;
+ set_mMin(mMin: Vec3): void;
+ mMin: Vec3;
+ get_mMax(): Vec3;
+ set_mMax(mMax: Vec3): void;
+ mMax: Vec3;
+ Overlaps(inOther: AABox): boolean;
+ }
+ class OrientedBox {
+ constructor();
+ constructor(inOrientation: Mat44, inHalfExtents: Vec3);
+ get_mOrientation(): Mat44;
+ set_mOrientation(mOrientation: Mat44): void;
+ mOrientation: Mat44;
+ get_mHalfExtents(): Vec3;
+ set_mHalfExtents(mHalfExtents: Vec3): void;
+ mHalfExtents: Vec3;
+ }
+ class RayCast {
+ constructor();
+ constructor(inOrigin: Vec3, inDirection: Vec3);
+ Transformed(inTransform: Mat44): RayCast;
+ Translated(inTranslation: Vec3): RayCast;
+ GetPointOnRay(inFraction: number): Vec3;
+ get_mOrigin(): Vec3;
+ set_mOrigin(mOrigin: Vec3): void;
+ mOrigin: Vec3;
+ get_mDirection(): Vec3;
+ set_mDirection(mDirection: Vec3): void;
+ mDirection: Vec3;
+ }
+ class RRayCast {
+ constructor();
+ constructor(inOrigin: RVec3, inDirection: Vec3);
+ Transformed(inTransform: RMat44): RRayCast;
+ Translated(inTranslation: RVec3): RRayCast;
+ GetPointOnRay(inFraction: number): RVec3;
+ get_mOrigin(): RVec3;
+ set_mOrigin(mOrigin: RVec3): void;
+ mOrigin: RVec3;
+ get_mDirection(): Vec3;
+ set_mDirection(mDirection: Vec3): void;
+ mDirection: Vec3;
+ }
+ class BroadPhaseCastResult {
+ constructor();
+ Reset(): void;
+ get_mBodyID(): BodyID;
+ set_mBodyID(mBodyID: BodyID): void;
+ mBodyID: BodyID;
+ get_mFraction(): number;
+ set_mFraction(mFraction: number): void;
+ mFraction: number;
+ }
+ class RayCastResult extends BroadPhaseCastResult {
+ constructor();
+ get_mSubShapeID2(): SubShapeID;
+ set_mSubShapeID2(mSubShapeID2: SubShapeID): void;
+ mSubShapeID2: SubShapeID;
+ }
+ class AABoxCast {
+ constructor();
+ get_mBox(): AABox;
+ set_mBox(mBox: AABox): void;
+ mBox: AABox;
+ get_mDirection(): Vec3;
+ set_mDirection(mDirection: Vec3): void;
+ mDirection: Vec3;
+ }
+ class ShapeCast {
+ constructor(
+ inShape: Shape,
+ inScale: Vec3,
+ inCenterOfMassStart: Mat44,
+ inDirection: Vec3
+ );
+ get_mShape(): Shape;
+ set_mShape(mShape: Shape): void;
+ readonly mShape: Shape;
+ get_mScale(): Vec3;
+ set_mScale(mScale: Vec3): void;
+ readonly mScale: Vec3;
+ get_mCenterOfMassStart(): Mat44;
+ set_mCenterOfMassStart(mCenterOfMassStart: Mat44): void;
+ readonly mCenterOfMassStart: Mat44;
+ get_mDirection(): Vec3;
+ set_mDirection(mDirection: Vec3): void;
+ readonly mDirection: Vec3;
+ GetPointOnRay(inFraction: number): Vec3;
+ }
+ class RShapeCast {
+ constructor(
+ inShape: Shape,
+ inScale: Vec3,
+ inCenterOfMassStart: RMat44,
+ inDirection: Vec3
+ );
+ get_mShape(): Shape;
+ set_mShape(mShape: Shape): void;
+ readonly mShape: Shape;
+ get_mScale(): Vec3;
+ set_mScale(mScale: Vec3): void;
+ readonly mScale: Vec3;
+ get_mCenterOfMassStart(): RMat44;
+ set_mCenterOfMassStart(mCenterOfMassStart: RMat44): void;
+ readonly mCenterOfMassStart: RMat44;
+ get_mDirection(): Vec3;
+ set_mDirection(mDirection: Vec3): void;
+ readonly mDirection: Vec3;
+ GetPointOnRay(inFraction: number): RVec3;
+ }
+ class Plane {
+ constructor(inNormal: Vec3, inConstant: number);
+ GetNormal(): Vec3;
+ SetNormal(inNormal: Vec3): void;
+ GetConstant(): number;
+ SetConstant(inConstant: number): void;
+ sFromPointAndNormal(inPoint: Vec3, inNormal: Vec3): Plane;
+ sFromPointsCCW(inPoint1: Vec3, inPoint2: Vec3, inPoint3: Vec3): Plane;
+ Offset(inDistance: number): Plane;
+ Scaled(inScale: Vec3): Plane;
+ GetTransformed(inTransform: Mat44): Plane;
+ ProjectPointOnPlane(inPoint: Vec3): Vec3;
+ SignedDistance(inPoint: Vec3): number;
+ }
+ class TransformedShape {
+ constructor();
+ CastRay(inRay: RRayCast, ioHit: RayCastResult): void;
+ CastRay(
+ inRay: RRayCast,
+ inRayCastSettings: RayCastSettings,
+ ioCollector: CastRayCollector,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollidePoint(
+ inPoint: RVec3,
+ ioCollector: CollidePointCollector,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollideShape(
+ inShape: Shape,
+ inShapeScale: Vec3,
+ inCenterOfMassTransform: RMat44,
+ inCollideShapeSettings: CollideShapeSettings,
+ inBaseOffset: RVec3,
+ ioCollector: CollideShapeCollector,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CastShape(
+ inShapeCast: RShapeCast,
+ inShapeCastSettings: ShapeCastSettings,
+ inBaseOffset: RVec3,
+ ioCollector: CastShapeCollector,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollectTransformedShapes(
+ inBox: AABox,
+ ioCollector: TransformedShapeCollector,
+ inShapeFilter: ShapeFilter
+ ): void;
+ GetShapeScale(): Vec3;
+ SetShapeScale(inScale: Vec3): void;
+ GetCenterOfMassTransform(): RMat44;
+ GetInverseCenterOfMassTransform(): RMat44;
+ SetWorldTransform(inPosition: RVec3, inRotation: Quat, inScale: Vec3): void;
+ SetWorldTransform(inTransform: RMat44): void;
+ GetWorldTransform(): RMat44;
+ GetWorldSpaceBounds(): AABox;
+ GetWorldSpaceSurfaceNormal(
+ inSubShapeID: SubShapeID,
+ inPosition: RVec3
+ ): Vec3;
+ GetMaterial(inSubShapeID: SubShapeID): PhysicsMaterial;
+ get_mShapePositionCOM(): RVec3;
+ set_mShapePositionCOM(mShapePositionCOM: RVec3): void;
+ mShapePositionCOM: RVec3;
+ get_mShapeRotation(): Quat;
+ set_mShapeRotation(mShapeRotation: Quat): void;
+ mShapeRotation: Quat;
+ get_mShape(): Shape;
+ set_mShape(mShape: Shape): void;
+ mShape: Shape;
+ get_mShapeScale(): Float3;
+ set_mShapeScale(mShapeScale: Float3): void;
+ mShapeScale: Float3;
+ get_mBodyID(): BodyID;
+ set_mBodyID(mBodyID: BodyID): void;
+ mBodyID: BodyID;
+ }
+ class PhysicsMaterial {
+ constructor();
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ }
+ class PhysicsMaterialList {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): PhysicsMaterial;
+ push_back(inMaterial: PhysicsMaterial): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class Triangle {
+ constructor();
+ constructor(
+ inV1: Vec3,
+ inV2: Vec3,
+ inV3: Vec3,
+ inMaterialIndex?: number,
+ inUserData?: number
+ );
+ get_mV(index: number): Float3;
+ set_mV(index: number, mV: Float3): void;
+ mV: Float3;
+ get_mMaterialIndex(): number;
+ set_mMaterialIndex(mMaterialIndex: number): void;
+ mMaterialIndex: number;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ }
+ class TriangleList {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Triangle;
+ push_back(inTriangle: Triangle): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class VertexList {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Float3;
+ push_back(inVertex: Float3): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class IndexedTriangle {
+ constructor();
+ constructor(
+ inI1: number,
+ inI2: number,
+ inI3: number,
+ inMaterialIndex: number,
+ inUserData?: number
+ );
+ get_mIdx(index: number): number;
+ set_mIdx(index: number, mIdx: number): void;
+ mIdx: number;
+ get_mMaterialIndex(): number;
+ set_mMaterialIndex(mMaterialIndex: number): void;
+ mMaterialIndex: number;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ }
+ class IndexedTriangleList {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): IndexedTriangle;
+ push_back(inTriangle: IndexedTriangle): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ShapeResult {
+ IsValid(): boolean;
+ HasError(): boolean;
+ GetError(): JPHString;
+ Get(): Shape;
+ Clear(): void;
+ }
+ class ShapeSettings {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ Create(): ShapeResult;
+ ClearCachedResult(): void;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ }
+ class Shape {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ GetType(): EShapeType;
+ GetSubType(): EShapeSubType;
+ MustBeStatic(): boolean;
+ GetLocalBounds(): AABox;
+ GetWorldSpaceBounds(inCenterOfMassTransform: Mat44, inScale: Vec3): AABox;
+ GetCenterOfMass(): Vec3;
+ GetUserData(): number;
+ SetUserData(inUserData: number): void;
+ GetSubShapeIDBitsRecursive(): number;
+ GetInnerRadius(): number;
+ GetMassProperties(): MassProperties;
+ GetLeafShape(inSubShapeID: SubShapeID, outRemainder: SubShapeID): Shape;
+ GetMaterial(inSubShapeID: SubShapeID): PhysicsMaterial;
+ GetSurfaceNormal(
+ inSubShapeID: SubShapeID,
+ inLocalSurfacePosition: Vec3
+ ): Vec3;
+ GetSubShapeUserData(inSubShapeID: SubShapeID): number;
+ GetSubShapeTransformedShape(
+ inSubShapeID: SubShapeID,
+ inPositionCOM: Vec3,
+ inRotation: Quat,
+ inScale: Vec3,
+ outRemainder: SubShapeID
+ ): TransformedShape;
+ GetVolume(): number;
+ IsValidScale(inScale: Vec3): boolean;
+ MakeScaleValid(inScale: Vec3): Vec3;
+ ScaleShape(inScale: Vec3): ShapeResult;
+ }
+ class ShapeGetTriangles {
+ constructor(
+ inShape: Shape,
+ inBox: AABox,
+ inPositionCOM: Vec3,
+ inRotation: Quat,
+ inScale: Vec3
+ );
+ GetNumTriangles(): number;
+ GetVerticesSize(): number;
+ GetVerticesData(): any;
+ GetMaterial(inTriangle: number): PhysicsMaterial;
+ }
+ class ConvexShapeSettings extends ShapeSettings {
+ get_mMaterial(): PhysicsMaterial;
+ set_mMaterial(mMaterial: PhysicsMaterial): void;
+ mMaterial: PhysicsMaterial;
+ get_mDensity(): number;
+ set_mDensity(mDensity: number): void;
+ mDensity: number;
+ }
+ class ConvexShape extends Shape {
+ GetDensity(): number;
+ SetDensity(inDensity: number): void;
+ }
+ class SphereShapeSettings extends ConvexShapeSettings {
+ constructor(inRadius: number, inMaterial?: PhysicsMaterial);
+ get_mRadius(): number;
+ set_mRadius(mRadius: number): void;
+ mRadius: number;
+ }
+ class SphereShape extends ConvexShape {
+ constructor(inRadius: number, inMaterial?: PhysicsMaterial);
+ GetRadius(): number;
+ }
+ class BoxShapeSettings extends ConvexShapeSettings {
+ constructor(
+ inHalfExtent: Vec3,
+ inConvexRadius?: number,
+ inMaterial?: PhysicsMaterial
+ );
+ get_mHalfExtent(): Vec3;
+ set_mHalfExtent(mHalfExtent: Vec3): void;
+ mHalfExtent: Vec3;
+ get_mConvexRadius(): number;
+ set_mConvexRadius(mConvexRadius: number): void;
+ mConvexRadius: number;
+ }
+ class BoxShape extends ConvexShape {
+ constructor(
+ inHalfExtent: Vec3,
+ inConvexRadius?: number,
+ inMaterial?: PhysicsMaterial
+ );
+ GetHalfExtent(): Vec3;
+ }
+ class CylinderShapeSettings extends ConvexShapeSettings {
+ constructor(
+ inHalfHeight: number,
+ inRadius: number,
+ inConvexRadius?: number,
+ inMaterial?: PhysicsMaterial
+ );
+ get_mHalfHeight(): number;
+ set_mHalfHeight(mHalfHeight: number): void;
+ mHalfHeight: number;
+ get_mRadius(): number;
+ set_mRadius(mRadius: number): void;
+ mRadius: number;
+ get_mConvexRadius(): number;
+ set_mConvexRadius(mConvexRadius: number): void;
+ mConvexRadius: number;
+ }
+ class CylinderShape extends ConvexShape {
+ constructor(
+ inHalfHeight: number,
+ inRadius: number,
+ inConvexRadius: number,
+ inMaterial?: PhysicsMaterial
+ );
+ GetRadius(): number;
+ GetHalfHeight(): number;
+ }
+ class TaperedCylinderShapeSettings extends ConvexShapeSettings {
+ constructor(
+ inHalfHeightOfTaperedCylinder: number,
+ inTopRadius: number,
+ inBottomRadius: number,
+ inConvexRadius?: number,
+ inMaterial?: PhysicsMaterial
+ );
+ get_mHalfHeight(): number;
+ set_mHalfHeight(mHalfHeight: number): void;
+ mHalfHeight: number;
+ get_mTopRadius(): number;
+ set_mTopRadius(mTopRadius: number): void;
+ mTopRadius: number;
+ get_mBottomRadius(): number;
+ set_mBottomRadius(mBottomRadius: number): void;
+ mBottomRadius: number;
+ get_mConvexRadius(): number;
+ set_mConvexRadius(mConvexRadius: number): void;
+ mConvexRadius: number;
+ }
+ class TaperedCylinderShape extends ConvexShape {
+ GetHalfHeight(): number;
+ GetTopRadius(): number;
+ GetBottomRadius(): number;
+ GetConvexRadius(): number;
+ }
+ class CapsuleShapeSettings extends ConvexShapeSettings {
+ constructor(
+ inHalfHeight: number,
+ inRadius: number,
+ inMaterial?: PhysicsMaterial
+ );
+ get_mRadius(): number;
+ set_mRadius(mRadius: number): void;
+ mRadius: number;
+ get_mHalfHeightOfCylinder(): number;
+ set_mHalfHeightOfCylinder(mHalfHeightOfCylinder: number): void;
+ mHalfHeightOfCylinder: number;
+ }
+ class CapsuleShape extends ConvexShape {
+ constructor(
+ inHalfHeight: number,
+ inRadius: number,
+ inMaterial?: PhysicsMaterial
+ );
+ GetRadius(): number;
+ GetHalfHeightOfCylinder(): number;
+ }
+ class TaperedCapsuleShapeSettings extends ConvexShapeSettings {
+ constructor(
+ inHalfHeightOfTaperedCylinder: number,
+ inTopRadius: number,
+ inBottomRadius: number,
+ inMaterial?: PhysicsMaterial
+ );
+ get_mHalfHeightOfTaperedCylinder(): number;
+ set_mHalfHeightOfTaperedCylinder(
+ mHalfHeightOfTaperedCylinder: number
+ ): void;
+ mHalfHeightOfTaperedCylinder: number;
+ get_mTopRadius(): number;
+ set_mTopRadius(mTopRadius: number): void;
+ mTopRadius: number;
+ get_mBottomRadius(): number;
+ set_mBottomRadius(mBottomRadius: number): void;
+ mBottomRadius: number;
+ }
+ class TaperedCapsuleShape extends ConvexShape {
+ GetHalfHeight(): number;
+ GetTopRadius(): number;
+ GetBottomRadius(): number;
+ }
+ class ConvexHullShapeSettings extends ConvexShapeSettings {
+ constructor();
+ get_mPoints(): ArrayVec3;
+ set_mPoints(mPoints: ArrayVec3): void;
+ mPoints: ArrayVec3;
+ get_mMaxConvexRadius(): number;
+ set_mMaxConvexRadius(mMaxConvexRadius: number): void;
+ mMaxConvexRadius: number;
+ get_mMaxErrorConvexRadius(): number;
+ set_mMaxErrorConvexRadius(mMaxErrorConvexRadius: number): void;
+ mMaxErrorConvexRadius: number;
+ get_mHullTolerance(): number;
+ set_mHullTolerance(mHullTolerance: number): void;
+ mHullTolerance: number;
+ }
+ class ConvexHullShape extends ConvexShape {}
+ class CompoundShapeSettings extends ShapeSettings {
+ AddShape(
+ inPosition: Vec3,
+ inRotation: Quat,
+ inShape: ShapeSettings,
+ inUserData: number
+ ): void;
+ }
+ class CompoundShapeSubShape {
+ GetPositionCOM(): Vec3;
+ GetRotation(): Quat;
+ get_mShape(): Shape;
+ set_mShape(mShape: Shape): void;
+ mShape: Shape;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ }
+ class CompoundShape extends Shape {
+ GetNumSubShapes(): number;
+ GetSubShape(inIdx: number): CompoundShapeSubShape;
+ }
+ class StaticCompoundShapeSettings extends CompoundShapeSettings {
+ constructor();
+ }
+ class StaticCompoundShape extends CompoundShape {}
+ class MutableCompoundShapeSettings extends CompoundShapeSettings {
+ constructor();
+ }
+ class MutableCompoundShape extends CompoundShape {
+ AddShape(
+ inPosition: Vec3,
+ inRotation: Quat,
+ inShape: Shape,
+ inUserData: number
+ ): number;
+ RemoveShape(inIndex: number): void;
+ ModifyShape(inIndex: number, inPosition: Vec3, inRotation: Quat): void;
+ ModifyShape(
+ inIndex: number,
+ inPosition: Vec3,
+ inRotation: Quat,
+ inShape: Shape
+ ): void;
+ ModifyShapes(
+ inStartIndex: number,
+ inNumber: number,
+ inPositions: Vec3MemRef,
+ inRotations: QuatMemRef
+ ): void;
+ AdjustCenterOfMass(): void;
+ }
+ class DecoratedShapeSettings extends ShapeSettings {}
+ class DecoratedShape extends Shape {
+ GetInnerShape(): Shape;
+ }
+ class ScaledShapeSettings extends DecoratedShapeSettings {
+ constructor(inShape: ShapeSettings, inScale: Vec3);
+ get_mScale(): Vec3;
+ set_mScale(mScale: Vec3): void;
+ mScale: Vec3;
+ }
+ class ScaledShape extends DecoratedShape {
+ constructor(inShape: Shape, inScale: Vec3);
+ GetScale(): Vec3;
+ }
+ class OffsetCenterOfMassShapeSettings extends DecoratedShapeSettings {
+ constructor(inOffset: Vec3, inShape: ShapeSettings);
+ get_mOffset(): Vec3;
+ set_mOffset(mOffset: Vec3): void;
+ mOffset: Vec3;
+ }
+ class OffsetCenterOfMassShape extends DecoratedShape {
+ constructor(inShape: Shape, inOffset: Vec3);
+ }
+ class RotatedTranslatedShapeSettings extends DecoratedShapeSettings {
+ constructor(inPosition: Vec3, inRotation: Quat, inShape: ShapeSettings);
+ get_mPosition(): Vec3;
+ set_mPosition(mPosition: Vec3): void;
+ mPosition: Vec3;
+ get_mRotation(): Quat;
+ set_mRotation(mRotation: Quat): void;
+ mRotation: Quat;
+ }
+ class RotatedTranslatedShape extends DecoratedShape {
+ GetRotation(): Quat;
+ GetPosition(): Vec3;
+ }
+ class MeshShapeSettings extends ShapeSettings {
+ constructor();
+ constructor(
+ inTriangleList: TriangleList,
+ inMaterialList?: PhysicsMaterialList
+ );
+ constructor(
+ inVertices: VertexList,
+ inTriangles: IndexedTriangleList,
+ inMaterialList: PhysicsMaterialList
+ );
+ Sanitize(): void;
+ get_mTriangleVertices(): VertexList;
+ set_mTriangleVertices(mTriangleVertices: VertexList): void;
+ mTriangleVertices: VertexList;
+ get_mIndexedTriangles(): IndexedTriangleList;
+ set_mIndexedTriangles(mIndexedTriangles: IndexedTriangleList): void;
+ mIndexedTriangles: IndexedTriangleList;
+ get_mMaterials(): PhysicsMaterialList;
+ set_mMaterials(mMaterials: PhysicsMaterialList): void;
+ mMaterials: PhysicsMaterialList;
+ get_mMaxTrianglesPerLeaf(): number;
+ set_mMaxTrianglesPerLeaf(mMaxTrianglesPerLeaf: number): void;
+ mMaxTrianglesPerLeaf: number;
+ get_mActiveEdgeCosThresholdAngle(): number;
+ set_mActiveEdgeCosThresholdAngle(
+ mActiveEdgeCosThresholdAngle: number
+ ): void;
+ mActiveEdgeCosThresholdAngle: number;
+ get_mPerTriangleUserData(): boolean;
+ set_mPerTriangleUserData(mPerTriangleUserData: boolean): void;
+ mPerTriangleUserData: boolean;
+ }
+ class MeshShape extends Shape {
+ GetTriangleUserData(inSubShapeID: SubShapeID): number;
+ }
+ class HeightFieldShapeConstantValues {
+ get_cNoCollisionValue(): number;
+ set_cNoCollisionValue(cNoCollisionValue: number): void;
+ readonly cNoCollisionValue: number;
+ }
+ class HeightFieldShapeSettings extends ShapeSettings {
+ constructor();
+ get_mOffset(): Vec3;
+ set_mOffset(mOffset: Vec3): void;
+ mOffset: Vec3;
+ get_mScale(): Vec3;
+ set_mScale(mScale: Vec3): void;
+ mScale: Vec3;
+ get_mSampleCount(): number;
+ set_mSampleCount(mSampleCount: number): void;
+ mSampleCount: number;
+ get_mMinHeightValue(): number;
+ set_mMinHeightValue(mMinHeightValue: number): void;
+ mMinHeightValue: number;
+ get_mMaxHeightValue(): number;
+ set_mMaxHeightValue(mMaxHeightValue: number): void;
+ mMaxHeightValue: number;
+ get_mMaterialsCapacity(): number;
+ set_mMaterialsCapacity(mMaterialsCapacity: number): void;
+ mMaterialsCapacity: number;
+ get_mBlockSize(): number;
+ set_mBlockSize(mBlockSize: number): void;
+ mBlockSize: number;
+ get_mBitsPerSample(): number;
+ set_mBitsPerSample(mBitsPerSample: number): void;
+ mBitsPerSample: number;
+ get_mHeightSamples(): ArrayFloat;
+ set_mHeightSamples(mHeightSamples: ArrayFloat): void;
+ mHeightSamples: ArrayFloat;
+ get_mMaterialIndices(): ArrayUint8;
+ set_mMaterialIndices(mMaterialIndices: ArrayUint8): void;
+ mMaterialIndices: ArrayUint8;
+ get_mMaterials(): PhysicsMaterialList;
+ set_mMaterials(mMaterials: PhysicsMaterialList): void;
+ mMaterials: PhysicsMaterialList;
+ get_mActiveEdgeCosThresholdAngle(): number;
+ set_mActiveEdgeCosThresholdAngle(
+ mActiveEdgeCosThresholdAngle: number
+ ): void;
+ mActiveEdgeCosThresholdAngle: number;
+ }
+ class HeightFieldShape extends Shape {
+ GetSampleCount(): number;
+ GetBlockSize(): number;
+ GetPosition(inX: number, inY: number): Vec3;
+ IsNoCollision(inX: number, inY: number): boolean;
+ GetMinHeightValue(): number;
+ GetMaxHeightValue(): number;
+ GetHeights(
+ inX: number,
+ inY: number,
+ inSizeX: number,
+ inSizeY: number,
+ outHeights: FloatMemRef,
+ inHeightsStride: number
+ ): void;
+ SetHeights(
+ inX: number,
+ inY: number,
+ inSizeX: number,
+ inSizeY: number,
+ inHeights: FloatMemRef,
+ inHeightsStride: number,
+ inAllocator: TempAllocator,
+ inActiveEdgeCosThresholdAngle?: number
+ ): void;
+ GetMaterials(
+ inX: number,
+ inY: number,
+ inSizeX: number,
+ inSizeY: number,
+ outMaterials: Uint8MemRef,
+ inMaterialsStride: number
+ ): void;
+ SetMaterials(
+ inX: number,
+ inY: number,
+ inSizeX: number,
+ inSizeY: number,
+ inMaterials: Uint8MemRef,
+ inMaterialsStride: number,
+ inMaterialList: PhysicsMaterialList,
+ inAllocator: TempAllocator
+ ): boolean;
+ }
+ class PlaneShapeSettings extends ShapeSettings {
+ constructor(
+ inPlane: Plane,
+ inMaterial?: PhysicsMaterial,
+ inHalfExtent?: number
+ );
+ get_mPlane(): Plane;
+ set_mPlane(mPlane: Plane): void;
+ mPlane: Plane;
+ get_mMaterial(): PhysicsMaterial;
+ set_mMaterial(mMaterial: PhysicsMaterial): void;
+ mMaterial: PhysicsMaterial;
+ get_mHalfExtent(): number;
+ set_mHalfExtent(mHalfExtent: number): void;
+ mHalfExtent: number;
+ }
+ class PlaneShape extends Shape {
+ constructor(
+ inPlane: Plane,
+ inMaterial?: PhysicsMaterial,
+ inHalfExtent?: number
+ );
+ GetPlane(): Plane;
+ GetHalfExtent(): number;
+ }
+ class EmptyShapeSettings extends ShapeSettings {
+ constructor();
+ get_mCenterOfMass(): Vec3;
+ set_mCenterOfMass(mCenterOfMass: Vec3): void;
+ mCenterOfMass: Vec3;
+ }
+ class EmptyShape extends Shape {
+ constructor(inCenterOfMass?: Vec3);
+ }
+ class ConstraintSettings {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ get_mEnabled(): boolean;
+ set_mEnabled(mEnabled: boolean): void;
+ mEnabled: boolean;
+ get_mNumVelocityStepsOverride(): number;
+ set_mNumVelocityStepsOverride(mNumVelocityStepsOverride: number): void;
+ mNumVelocityStepsOverride: number;
+ get_mNumPositionStepsOverride(): number;
+ set_mNumPositionStepsOverride(mNumPositionStepsOverride: number): void;
+ mNumPositionStepsOverride: number;
+ }
+ class Constraint {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ GetType(): EConstraintType;
+ GetSubType(): EConstraintSubType;
+ GetConstraintPriority(): number;
+ SetConstraintPriority(inPriority: number): void;
+ SetNumVelocityStepsOverride(inN: number): void;
+ GetNumVelocityStepsOverride(): number;
+ SetNumPositionStepsOverride(inN: number): void;
+ GetNumPositionStepsOverride(): number;
+ SetEnabled(inEnabled: boolean): void;
+ GetEnabled(): boolean;
+ IsActive(): boolean;
+ GetUserData(): number;
+ SetUserData(inUserData: number): void;
+ ResetWarmStart(): void;
+ }
+ class TwoBodyConstraintSettings extends ConstraintSettings {
+ Create(inBody1: Body, inBody2: Body): Constraint;
+ }
+ class TwoBodyConstraint extends Constraint {
+ GetBody1(): Body;
+ GetBody2(): Body;
+ GetConstraintToBody1Matrix(): Mat44;
+ GetConstraintToBody2Matrix(): Mat44;
+ }
+ class FixedConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mAutoDetectPoint(): boolean;
+ set_mAutoDetectPoint(mAutoDetectPoint: boolean): void;
+ mAutoDetectPoint: boolean;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mAxisX1(): Vec3;
+ set_mAxisX1(mAxisX1: Vec3): void;
+ mAxisX1: Vec3;
+ get_mAxisY1(): Vec3;
+ set_mAxisY1(mAxisY1: Vec3): void;
+ mAxisY1: Vec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ get_mAxisX2(): Vec3;
+ set_mAxisX2(mAxisX2: Vec3): void;
+ mAxisX2: Vec3;
+ get_mAxisY2(): Vec3;
+ set_mAxisY2(mAxisY2: Vec3): void;
+ mAxisY2: Vec3;
+ }
+ class SpringSettings {
+ constructor();
+ HasStiffness(): boolean;
+ get_mMode(): ESpringMode;
+ set_mMode(mMode: ESpringMode): void;
+ mMode: ESpringMode;
+ get_mFrequency(): number;
+ set_mFrequency(mFrequency: number): void;
+ mFrequency: number;
+ get_mStiffness(): number;
+ set_mStiffness(mStiffness: number): void;
+ mStiffness: number;
+ get_mDamping(): number;
+ set_mDamping(mDamping: number): void;
+ mDamping: number;
+ }
+ class MotorSettings {
+ constructor();
+ get_mSpringSettings(): SpringSettings;
+ set_mSpringSettings(mSpringSettings: SpringSettings): void;
+ mSpringSettings: SpringSettings;
+ get_mMinForceLimit(): number;
+ set_mMinForceLimit(mMinForceLimit: number): void;
+ mMinForceLimit: number;
+ get_mMaxForceLimit(): number;
+ set_mMaxForceLimit(mMaxForceLimit: number): void;
+ mMaxForceLimit: number;
+ get_mMinTorqueLimit(): number;
+ set_mMinTorqueLimit(mMinTorqueLimit: number): void;
+ mMinTorqueLimit: number;
+ get_mMaxTorqueLimit(): number;
+ set_mMaxTorqueLimit(mMaxTorqueLimit: number): void;
+ mMaxTorqueLimit: number;
+ }
+ class DistanceConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ get_mMinDistance(): number;
+ set_mMinDistance(mMinDistance: number): void;
+ mMinDistance: number;
+ get_mMaxDistance(): number;
+ set_mMaxDistance(mMaxDistance: number): void;
+ mMaxDistance: number;
+ get_mLimitsSpringSettings(): SpringSettings;
+ set_mLimitsSpringSettings(mLimitsSpringSettings: SpringSettings): void;
+ mLimitsSpringSettings: SpringSettings;
+ }
+ class DistanceConstraint extends TwoBodyConstraint {
+ SetDistance(inMinDistance: number, inMaxDistance: number): void;
+ GetMinDistance(): number;
+ GetMaxDistance(): number;
+ GetLimitsSpringSettings(): SpringSettings;
+ SetLimitsSpringSettings(inSettings: SpringSettings): void;
+ GetTotalLambdaPosition(): number;
+ }
+ class PointConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ }
+ class PointConstraint extends TwoBodyConstraint {
+ GetLocalSpacePoint1(): Vec3;
+ GetLocalSpacePoint2(): Vec3;
+ GetTotalLambdaPosition(): Vec3;
+ }
+ class HingeConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mHingeAxis1(): Vec3;
+ set_mHingeAxis1(mHingeAxis1: Vec3): void;
+ mHingeAxis1: Vec3;
+ get_mNormalAxis1(): Vec3;
+ set_mNormalAxis1(mNormalAxis1: Vec3): void;
+ mNormalAxis1: Vec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ get_mHingeAxis2(): Vec3;
+ set_mHingeAxis2(mHingeAxis2: Vec3): void;
+ mHingeAxis2: Vec3;
+ get_mNormalAxis2(): Vec3;
+ set_mNormalAxis2(mNormalAxis2: Vec3): void;
+ mNormalAxis2: Vec3;
+ get_mLimitsMin(): number;
+ set_mLimitsMin(mLimitsMin: number): void;
+ mLimitsMin: number;
+ get_mLimitsMax(): number;
+ set_mLimitsMax(mLimitsMax: number): void;
+ mLimitsMax: number;
+ get_mLimitsSpringSettings(): SpringSettings;
+ set_mLimitsSpringSettings(mLimitsSpringSettings: SpringSettings): void;
+ mLimitsSpringSettings: SpringSettings;
+ get_mMaxFrictionTorque(): number;
+ set_mMaxFrictionTorque(mMaxFrictionTorque: number): void;
+ mMaxFrictionTorque: number;
+ get_mMotorSettings(): MotorSettings;
+ set_mMotorSettings(mMotorSettings: MotorSettings): void;
+ mMotorSettings: MotorSettings;
+ }
+ class HingeConstraint extends TwoBodyConstraint {
+ GetLocalSpacePoint1(): Vec3;
+ GetLocalSpacePoint2(): Vec3;
+ GetLocalSpaceHingeAxis1(): Vec3;
+ GetLocalSpaceHingeAxis2(): Vec3;
+ GetLocalSpaceNormalAxis1(): Vec3;
+ GetLocalSpaceNormalAxis2(): Vec3;
+ GetCurrentAngle(): number;
+ SetMaxFrictionTorque(inFrictionTorque: number): void;
+ GetMaxFrictionTorque(): number;
+ GetMotorSettings(): MotorSettings;
+ SetMotorState(inState: EMotorState): void;
+ GetMotorState(): EMotorState;
+ SetTargetAngularVelocity(inAngularVelocity: number): void;
+ GetTargetAngularVelocity(): number;
+ SetTargetAngle(inAngle: number): void;
+ GetTargetAngle(): number;
+ SetLimits(inLimitsMin: number, inLimitsMax: number): void;
+ GetLimitsMin(): number;
+ GetLimitsMax(): number;
+ HasLimits(): boolean;
+ GetLimitsSpringSettings(): SpringSettings;
+ SetLimitsSpringSettings(inLimitsSpringSettings: SpringSettings): void;
+ GetTotalLambdaPosition(): Vec3;
+ GetTotalLambdaRotation(): Vector2;
+ GetTotalLambdaRotationLimits(): number;
+ GetTotalLambdaMotor(): number;
+ }
+ class ConeConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mTwistAxis1(): Vec3;
+ set_mTwistAxis1(mTwistAxis1: Vec3): void;
+ mTwistAxis1: Vec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ get_mTwistAxis2(): Vec3;
+ set_mTwistAxis2(mTwistAxis2: Vec3): void;
+ mTwistAxis2: Vec3;
+ get_mHalfConeAngle(): number;
+ set_mHalfConeAngle(mHalfConeAngle: number): void;
+ mHalfConeAngle: number;
+ }
+ class ConeConstraint extends TwoBodyConstraint {
+ SetHalfConeAngle(inHalfConeAngle: number): void;
+ GetCosHalfConeAngle(): number;
+ GetTotalLambdaPosition(): Vec3;
+ GetTotalLambdaRotation(): number;
+ }
+ class SliderConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mAutoDetectPoint(): boolean;
+ set_mAutoDetectPoint(mAutoDetectPoint: boolean): void;
+ mAutoDetectPoint: boolean;
+ get_mPoint1(): RVec3;
+ set_mPoint1(mPoint1: RVec3): void;
+ mPoint1: RVec3;
+ get_mSliderAxis1(): Vec3;
+ set_mSliderAxis1(mSliderAxis1: Vec3): void;
+ mSliderAxis1: Vec3;
+ get_mNormalAxis1(): Vec3;
+ set_mNormalAxis1(mNormalAxis1: Vec3): void;
+ mNormalAxis1: Vec3;
+ get_mPoint2(): RVec3;
+ set_mPoint2(mPoint2: RVec3): void;
+ mPoint2: RVec3;
+ get_mSliderAxis2(): Vec3;
+ set_mSliderAxis2(mSliderAxis2: Vec3): void;
+ mSliderAxis2: Vec3;
+ get_mNormalAxis2(): Vec3;
+ set_mNormalAxis2(mNormalAxis2: Vec3): void;
+ mNormalAxis2: Vec3;
+ get_mLimitsMin(): number;
+ set_mLimitsMin(mLimitsMin: number): void;
+ mLimitsMin: number;
+ get_mLimitsMax(): number;
+ set_mLimitsMax(mLimitsMax: number): void;
+ mLimitsMax: number;
+ get_mLimitsSpringSettings(): SpringSettings;
+ set_mLimitsSpringSettings(mLimitsSpringSettings: SpringSettings): void;
+ mLimitsSpringSettings: SpringSettings;
+ get_mMaxFrictionForce(): number;
+ set_mMaxFrictionForce(mMaxFrictionForce: number): void;
+ mMaxFrictionForce: number;
+ get_mMotorSettings(): MotorSettings;
+ set_mMotorSettings(mMotorSettings: MotorSettings): void;
+ mMotorSettings: MotorSettings;
+ }
+ class SliderConstraint extends TwoBodyConstraint {
+ GetCurrentPosition(): number;
+ SetMaxFrictionForce(inFrictionForce: number): void;
+ GetMaxFrictionForce(): number;
+ GetMotorSettings(): MotorSettings;
+ SetMotorState(inState: EMotorState): void;
+ GetMotorState(): EMotorState;
+ SetTargetVelocity(inVelocity: number): void;
+ GetTargetVelocity(): number;
+ SetTargetPosition(inPosition: number): void;
+ GetTargetPosition(): number;
+ SetLimits(inLimitsMin: number, inLimitsMax: number): void;
+ GetLimitsMin(): number;
+ GetLimitsMax(): number;
+ HasLimits(): boolean;
+ GetLimitsSpringSettings(): SpringSettings;
+ SetLimitsSpringSettings(inLimitsSpringSettings: SpringSettings): void;
+ GetTotalLambdaPosition(): Vector2;
+ GetTotalLambdaPositionLimits(): number;
+ GetTotalLambdaRotation(): Vec3;
+ GetTotalLambdaMotor(): number;
+ }
+ class SwingTwistConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPosition1(): RVec3;
+ set_mPosition1(mPosition1: RVec3): void;
+ mPosition1: RVec3;
+ get_mTwistAxis1(): Vec3;
+ set_mTwistAxis1(mTwistAxis1: Vec3): void;
+ mTwistAxis1: Vec3;
+ get_mPlaneAxis1(): Vec3;
+ set_mPlaneAxis1(mPlaneAxis1: Vec3): void;
+ mPlaneAxis1: Vec3;
+ get_mPosition2(): RVec3;
+ set_mPosition2(mPosition2: RVec3): void;
+ mPosition2: RVec3;
+ get_mTwistAxis2(): Vec3;
+ set_mTwistAxis2(mTwistAxis2: Vec3): void;
+ mTwistAxis2: Vec3;
+ get_mPlaneAxis2(): Vec3;
+ set_mPlaneAxis2(mPlaneAxis2: Vec3): void;
+ mPlaneAxis2: Vec3;
+ get_mSwingType(): ESwingType;
+ set_mSwingType(mSwingType: ESwingType): void;
+ mSwingType: ESwingType;
+ get_mNormalHalfConeAngle(): number;
+ set_mNormalHalfConeAngle(mNormalHalfConeAngle: number): void;
+ mNormalHalfConeAngle: number;
+ get_mPlaneHalfConeAngle(): number;
+ set_mPlaneHalfConeAngle(mPlaneHalfConeAngle: number): void;
+ mPlaneHalfConeAngle: number;
+ get_mTwistMinAngle(): number;
+ set_mTwistMinAngle(mTwistMinAngle: number): void;
+ mTwistMinAngle: number;
+ get_mTwistMaxAngle(): number;
+ set_mTwistMaxAngle(mTwistMaxAngle: number): void;
+ mTwistMaxAngle: number;
+ get_mMaxFrictionTorque(): number;
+ set_mMaxFrictionTorque(mMaxFrictionTorque: number): void;
+ mMaxFrictionTorque: number;
+ get_mSwingMotorSettings(): MotorSettings;
+ set_mSwingMotorSettings(mSwingMotorSettings: MotorSettings): void;
+ mSwingMotorSettings: MotorSettings;
+ get_mTwistMotorSettings(): MotorSettings;
+ set_mTwistMotorSettings(mTwistMotorSettings: MotorSettings): void;
+ mTwistMotorSettings: MotorSettings;
+ }
+ class SwingTwistConstraint extends TwoBodyConstraint {
+ GetLocalSpacePosition1(): Vec3;
+ GetLocalSpacePosition2(): Vec3;
+ GetConstraintToBody1(): Quat;
+ GetConstraintToBody2(): Quat;
+ GetNormalHalfConeAngle(): number;
+ SetNormalHalfConeAngle(inAngle: number): void;
+ GetPlaneHalfConeAngle(): number;
+ SetPlaneHalfConeAngle(inAngle: number): void;
+ GetTwistMinAngle(): number;
+ SetTwistMinAngle(inAngle: number): void;
+ GetTwistMaxAngle(): number;
+ SetTwistMaxAngle(inAngle: number): void;
+ GetSwingMotorSettings(): MotorSettings;
+ GetTwistMotorSettings(): MotorSettings;
+ SetMaxFrictionTorque(inFrictionTorque: number): void;
+ GetMaxFrictionTorque(): number;
+ SetSwingMotorState(inState: EMotorState): void;
+ GetSwingMotorState(): EMotorState;
+ SetTwistMotorState(inState: EMotorState): void;
+ GetTwistMotorState(): EMotorState;
+ SetTargetAngularVelocityCS(inAngularVelocity: Vec3): void;
+ GetTargetAngularVelocityCS(): Vec3;
+ SetTargetOrientationCS(inOrientation: Quat): void;
+ GetTargetOrientationCS(): Quat;
+ SetTargetOrientationBS(inOrientation: Quat): void;
+ GetRotationInConstraintSpace(): Quat;
+ GetTotalLambdaPosition(): Vec3;
+ GetTotalLambdaTwist(): number;
+ GetTotalLambdaSwingY(): number;
+ GetTotalLambdaSwingZ(): number;
+ GetTotalLambdaMotor(): Vec3;
+ }
+ class SixDOFConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ MakeFreeAxis(inAxis: SixDOFConstraintSettings_EAxis): void;
+ IsFreeAxis(inAxis: SixDOFConstraintSettings_EAxis): boolean;
+ MakeFixedAxis(inAxis: SixDOFConstraintSettings_EAxis): void;
+ IsFixedAxis(inAxis: SixDOFConstraintSettings_EAxis): boolean;
+ SetLimitedAxis(
+ inAxis: SixDOFConstraintSettings_EAxis,
+ inMin: number,
+ inMax: number
+ ): void;
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mPosition1(): RVec3;
+ set_mPosition1(mPosition1: RVec3): void;
+ mPosition1: RVec3;
+ get_mAxisX1(): Vec3;
+ set_mAxisX1(mAxisX1: Vec3): void;
+ mAxisX1: Vec3;
+ get_mAxisY1(): Vec3;
+ set_mAxisY1(mAxisY1: Vec3): void;
+ mAxisY1: Vec3;
+ get_mPosition2(): RVec3;
+ set_mPosition2(mPosition2: RVec3): void;
+ mPosition2: RVec3;
+ get_mAxisX2(): Vec3;
+ set_mAxisX2(mAxisX2: Vec3): void;
+ mAxisX2: Vec3;
+ get_mAxisY2(): Vec3;
+ set_mAxisY2(mAxisY2: Vec3): void;
+ mAxisY2: Vec3;
+ get_mMaxFriction(index: number): number;
+ set_mMaxFriction(index: number, mMaxFriction: number): void;
+ mMaxFriction: number;
+ get_mSwingType(): ESwingType;
+ set_mSwingType(mSwingType: ESwingType): void;
+ mSwingType: ESwingType;
+ get_mLimitMin(index: number): number;
+ set_mLimitMin(index: number, mLimitMin: number): void;
+ mLimitMin: number;
+ get_mLimitMax(index: number): number;
+ set_mLimitMax(index: number, mLimitMax: number): void;
+ mLimitMax: number;
+ get_mLimitsSpringSettings(index: number): SpringSettings;
+ set_mLimitsSpringSettings(
+ index: number,
+ mLimitsSpringSettings: SpringSettings
+ ): void;
+ mLimitsSpringSettings: SpringSettings;
+ get_mMotorSettings(index: number): MotorSettings;
+ set_mMotorSettings(index: number, mMotorSettings: MotorSettings): void;
+ mMotorSettings: MotorSettings;
+ }
+ class SixDOFConstraint extends TwoBodyConstraint {
+ SetTranslationLimits(inLimitMin: Vec3, inLimitMax: Vec3): void;
+ SetRotationLimits(inLimitMin: Vec3, inLimitMax: Vec3): void;
+ GetLimitsMin(inAxis: SixDOFConstraintSettings_EAxis): number;
+ GetLimitsMax(inAxis: SixDOFConstraintSettings_EAxis): number;
+ GetTranslationLimitsMin(): Vec3;
+ GetTranslationLimitsMax(): Vec3;
+ GetRotationLimitsMin(): Vec3;
+ GetRotationLimitsMax(): Vec3;
+ IsFixedAxis(inAxis: SixDOFConstraintSettings_EAxis): boolean;
+ IsFreeAxis(inAxis: SixDOFConstraintSettings_EAxis): boolean;
+ GetLimitsSpringSettings(
+ inAxis: SixDOFConstraintSettings_EAxis
+ ): SpringSettings;
+ SetLimitsSpringSettings(
+ inAxis: SixDOFConstraintSettings_EAxis,
+ inLimitsSpringSettings: SpringSettings
+ ): void;
+ SetMaxFriction(
+ inAxis: SixDOFConstraintSettings_EAxis,
+ inFriction: number
+ ): void;
+ GetMaxFriction(inAxis: SixDOFConstraintSettings_EAxis): number;
+ GetRotationInConstraintSpace(): Quat;
+ GetMotorSettings(inAxis: SixDOFConstraintSettings_EAxis): MotorSettings;
+ SetMotorState(
+ inAxis: SixDOFConstraintSettings_EAxis,
+ inState: EMotorState
+ ): void;
+ GetMotorState(inAxis: SixDOFConstraintSettings_EAxis): EMotorState;
+ GetTargetVelocityCS(): Vec3;
+ SetTargetVelocityCS(inVelocity: Vec3): void;
+ SetTargetAngularVelocityCS(inAngularVelocity: Vec3): void;
+ GetTargetAngularVelocityCS(): Vec3;
+ GetTargetPositionCS(): Vec3;
+ SetTargetPositionCS(inPosition: Vec3): void;
+ SetTargetOrientationCS(inOrientation: Quat): void;
+ GetTargetOrientationCS(): Quat;
+ SetTargetOrientationBS(inOrientation: Quat): void;
+ GetTotalLambdaPosition(): Vec3;
+ GetTotalLambdaRotation(): Vec3;
+ GetTotalLambdaMotorTranslation(): Vec3;
+ GetTotalLambdaMotorRotation(): Vec3;
+ }
+ class PathConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mPath(): PathConstraintPath;
+ set_mPath(mPath: PathConstraintPath): void;
+ mPath: PathConstraintPath;
+ get_mPathPosition(): Vec3;
+ set_mPathPosition(mPathPosition: Vec3): void;
+ mPathPosition: Vec3;
+ get_mPathRotation(): Quat;
+ set_mPathRotation(mPathRotation: Quat): void;
+ mPathRotation: Quat;
+ get_mPathFraction(): number;
+ set_mPathFraction(mPathFraction: number): void;
+ mPathFraction: number;
+ get_mMaxFrictionForce(): number;
+ set_mMaxFrictionForce(mMaxFrictionForce: number): void;
+ mMaxFrictionForce: number;
+ get_mRotationConstraintType(): EPathRotationConstraintType;
+ set_mRotationConstraintType(
+ mRotationConstraintType: EPathRotationConstraintType
+ ): void;
+ mRotationConstraintType: EPathRotationConstraintType;
+ get_mPositionMotorSettings(): MotorSettings;
+ set_mPositionMotorSettings(mPositionMotorSettings: MotorSettings): void;
+ mPositionMotorSettings: MotorSettings;
+ }
+ class PathConstraintPath {
+ IsLooping(): boolean;
+ SetIsLooping(inIsLooping: boolean): void;
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ }
+ class PathConstraintPathEm extends PathConstraintPath {}
+ class PathConstraintPathJS extends PathConstraintPathEm {
+ constructor();
+ GetPathMaxFraction(): number;
+ GetClosestPoint(inPosition: number, inFractionHint: number): number;
+ GetPointOnPath(
+ inFraction: number,
+ outPathPosition: number,
+ outPathTangent: number,
+ outPathNormal: number,
+ outPathBinormal: number
+ ): void;
+ }
+ class PathConstraint extends TwoBodyConstraint {
+ SetPath(inPath: PathConstraintPath, inPathFraction: number): void;
+ GetPath(): PathConstraintPath;
+ GetPathFraction(): number;
+ SetMaxFrictionForce(inFrictionForce: number): void;
+ GetMaxFrictionForce(): number;
+ GetPositionMotorSettings(): MotorSettings;
+ SetPositionMotorState(inState: EMotorState): void;
+ GetPositionMotorState(): EMotorState;
+ SetTargetVelocity(inVelocity: number): void;
+ GetTargetVelocity(): number;
+ SetTargetPathFraction(inFraction: number): void;
+ GetTargetPathFraction(): number;
+ }
+ class PulleyConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mBodyPoint1(): RVec3;
+ set_mBodyPoint1(mBodyPoint1: RVec3): void;
+ mBodyPoint1: RVec3;
+ get_mFixedPoint1(): RVec3;
+ set_mFixedPoint1(mFixedPoint1: RVec3): void;
+ mFixedPoint1: RVec3;
+ get_mBodyPoint2(): RVec3;
+ set_mBodyPoint2(mBodyPoint2: RVec3): void;
+ mBodyPoint2: RVec3;
+ get_mFixedPoint2(): RVec3;
+ set_mFixedPoint2(mFixedPoint2: RVec3): void;
+ mFixedPoint2: RVec3;
+ get_mRatio(): number;
+ set_mRatio(mRatio: number): void;
+ mRatio: number;
+ get_mMinLength(): number;
+ set_mMinLength(mMinLength: number): void;
+ mMinLength: number;
+ get_mMaxLength(): number;
+ set_mMaxLength(mMaxLength: number): void;
+ mMaxLength: number;
+ }
+ class PulleyConstraint extends TwoBodyConstraint {
+ SetLength(inMinLength: number, inMaxLength: number): void;
+ GetMinLength(): number;
+ GetMaxLength(): number;
+ GetCurrentLength(): number;
+ }
+ class GearConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ SetRatio(inNumTeethGear1: number, inNumTeethGear2: number): void;
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mHingeAxis1(): Vec3;
+ set_mHingeAxis1(mHingeAxis1: Vec3): void;
+ mHingeAxis1: Vec3;
+ get_mHingeAxis2(): Vec3;
+ set_mHingeAxis2(mHingeAxis2: Vec3): void;
+ mHingeAxis2: Vec3;
+ get_mRatio(): number;
+ set_mRatio(mRatio: number): void;
+ mRatio: number;
+ }
+ class GearConstraint extends TwoBodyConstraint {
+ SetConstraints(inGear1: Constraint, inGear2: Constraint): void;
+ GetTotalLambda(): number;
+ }
+ class RackAndPinionConstraintSettings extends TwoBodyConstraintSettings {
+ constructor();
+ SetRatio(
+ inNumTeethRack: number,
+ inRackLength: number,
+ inNumTeethPinion: number
+ ): void;
+ get_mSpace(): EConstraintSpace;
+ set_mSpace(mSpace: EConstraintSpace): void;
+ mSpace: EConstraintSpace;
+ get_mHingeAxis(): Vec3;
+ set_mHingeAxis(mHingeAxis: Vec3): void;
+ mHingeAxis: Vec3;
+ get_mSliderAxis(): Vec3;
+ set_mSliderAxis(mSliderAxis: Vec3): void;
+ mSliderAxis: Vec3;
+ get_mRatio(): number;
+ set_mRatio(mRatio: number): void;
+ mRatio: number;
+ }
+ class RackAndPinionConstraint extends TwoBodyConstraint {
+ SetConstraints(inPinion: Constraint, inRack: Constraint): void;
+ GetTotalLambda(): number;
+ }
+ class BodyID {
+ constructor();
+ constructor(inIndexAndSequenceNumber: number);
+ GetIndex(): number;
+ GetIndexAndSequenceNumber(): number;
+ }
+ class SubShapeID {
+ constructor();
+ GetValue(): number;
+ SetValue(inValue: number): void;
+ }
+ class MotionProperties {
+ GetMotionQuality(): EMotionQuality;
+ GetAllowedDOFs(): EAllowedDOFs;
+ GetAllowSleeping(): boolean;
+ GetLinearVelocity(): Vec3;
+ SetLinearVelocity(inVelocity: Vec3): void;
+ SetLinearVelocityClamped(inVelocity: Vec3): void;
+ GetAngularVelocity(): Vec3;
+ SetAngularVelocity(inVelocity: Vec3): void;
+ SetAngularVelocityClamped(inVelocity: Vec3): void;
+ MoveKinematic(
+ inPosition: Vec3,
+ inRotation: Quat,
+ inDeltaTime: number
+ ): void;
+ GetMaxLinearVelocity(): number;
+ SetMaxLinearVelocity(inVelocity: number): void;
+ GetMaxAngularVelocity(): number;
+ SetMaxAngularVelocity(inVelocity: number): void;
+ ClampLinearVelocity(): void;
+ ClampAngularVelocity(): void;
+ GetLinearDamping(): number;
+ SetLinearDamping(inDamping: number): void;
+ GetAngularDamping(): number;
+ SetAngularDamping(inDamping: number): void;
+ GetGravityFactor(): number;
+ SetGravityFactor(inFactor: number): void;
+ SetMassProperties(
+ inAllowedDOFs: EAllowedDOFs,
+ inMassProperties: MassProperties
+ ): void;
+ GetInverseMass(): number;
+ GetInverseMassUnchecked(): number;
+ SetInverseMass(inInvM: number): void;
+ GetInverseInertiaDiagonal(): Vec3;
+ GetInertiaRotation(): Quat;
+ SetInverseInertia(inInvI: Vec3, inRotation: Quat): void;
+ GetLocalSpaceInverseInertia(): Mat44;
+ GetInverseInertiaForRotation(inRotation: Mat44): Mat44;
+ MultiplyWorldSpaceInverseInertiaByVector(inRotation: Quat, inV: Vec3): Vec3;
+ GetPointVelocityCOM(inPointRelativeToCOM: Vec3): Vec3;
+ GetAccumulatedForce(): Vec3;
+ GetAccumulatedTorque(): Vec3;
+ ResetForce(): void;
+ ResetTorque(): void;
+ ResetMotion(): void;
+ LockTranslation(inV: Vec3): Vec3;
+ LockAngular(inV: Vec3): Vec3;
+ SetNumVelocityStepsOverride(inN: number): void;
+ GetNumVelocityStepsOverride(): number;
+ SetNumPositionStepsOverride(inN: number): void;
+ GetNumPositionStepsOverride(): number;
+ }
+ class GroupFilter {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ }
+ class GroupFilterJS extends GroupFilter {
+ constructor();
+ CanCollide(inGroup1: number, inGroup2: number): boolean;
+ }
+ class GroupFilterTable extends GroupFilter {
+ constructor(inNumGroups: number);
+ DisableCollision(inSubGroup1: number, inSubGroup2: number): void;
+ EnableCollision(inSubGroup1: number, inSubGroup2: number): void;
+ IsCollisionEnabled(inSubGroup1: number, inSubGroup2: number): boolean;
+ }
+ class CollisionGroup {
+ constructor();
+ constructor(inFilter: GroupFilter, inGroupID: number, inSubGroupID: number);
+ SetGroupFilter(inFilter: GroupFilter): void;
+ GetGroupFilter(): GroupFilter;
+ SetGroupID(inGroupID: number): void;
+ GetGroupID(): number;
+ SetSubGroupID(inSubGroupID: number): void;
+ GetSubGroupID(): number;
+ }
+ class Body {
+ GetID(): BodyID;
+ IsActive(): boolean;
+ IsRigidBody(): boolean;
+ IsSoftBody(): boolean;
+ IsStatic(): boolean;
+ IsKinematic(): boolean;
+ IsDynamic(): boolean;
+ CanBeKinematicOrDynamic(): boolean;
+ GetBodyType(): EBodyType;
+ GetMotionType(): EMotionType;
+ SetIsSensor(inIsSensor: boolean): void;
+ IsSensor(): boolean;
+ SetCollideKinematicVsNonDynamic(inCollide: boolean): void;
+ GetCollideKinematicVsNonDynamic(): boolean;
+ SetUseManifoldReduction(inUseReduction: boolean): void;
+ GetUseManifoldReduction(): boolean;
+ SetApplyGyroscopicForce(inApply: boolean): void;
+ GetApplyGyroscopicForce(): boolean;
+ SetEnhancedInternalEdgeRemoval(inApply: boolean): void;
+ GetEnhancedInternalEdgeRemoval(): boolean;
+ GetObjectLayer(): number;
+ GetCollisionGroup(): CollisionGroup;
+ GetAllowSleeping(): boolean;
+ SetAllowSleeping(inAllow: boolean): void;
+ ResetSleepTimer(): void;
+ GetFriction(): number;
+ SetFriction(inFriction: number): void;
+ GetRestitution(): number;
+ SetRestitution(inRestitution: number): void;
+ GetLinearVelocity(): Vec3;
+ SetLinearVelocity(inVelocity: Vec3): void;
+ SetLinearVelocityClamped(inVelocity: Vec3): void;
+ GetAngularVelocity(): Vec3;
+ SetAngularVelocity(inVelocity: Vec3): void;
+ SetAngularVelocityClamped(inVelocity: Vec3): void;
+ AddForce(inForce: Vec3): void;
+ AddForce(inForce: Vec3, inPosition: RVec3): void;
+ AddTorque(inTorque: Vec3): void;
+ GetAccumulatedForce(): Vec3;
+ GetAccumulatedTorque(): Vec3;
+ ResetForce(): void;
+ ResetTorque(): void;
+ ResetMotion(): void;
+ AddImpulse(inImpulse: Vec3): void;
+ AddImpulse(inImpulse: Vec3, inPosition: RVec3): void;
+ AddAngularImpulse(inAngularImpulse: Vec3): void;
+ MoveKinematic(
+ inPosition: RVec3,
+ inRotation: Quat,
+ inDeltaTime: number
+ ): void;
+ ApplyBuoyancyImpulse(
+ inSurfacePosition: RVec3,
+ inSurfaceNormal: Vec3,
+ inBuoyancy: number,
+ inLinearDrag: number,
+ inAngularDrag: number,
+ inFluidVelocity: Vec3,
+ inGravity: Vec3,
+ inDeltaTime: number
+ ): boolean;
+ IsInBroadPhase(): boolean;
+ GetInverseInertia(): Mat44;
+ GetShape(): Shape;
+ GetPosition(): RVec3;
+ GetRotation(): Quat;
+ GetWorldTransform(): RMat44;
+ GetCenterOfMassPosition(): RVec3;
+ GetCenterOfMassTransform(): RMat44;
+ GetInverseCenterOfMassTransform(): RMat44;
+ GetWorldSpaceBounds(): AABox;
+ GetTransformedShape(): TransformedShape;
+ GetBodyCreationSettings(): BodyCreationSettings;
+ GetSoftBodyCreationSettings(): SoftBodyCreationSettings;
+ GetMotionProperties(): MotionProperties;
+ GetWorldSpaceSurfaceNormal(
+ inSubShapeID: SubShapeID,
+ inPosition: RVec3
+ ): Vec3;
+ GetUserData(): number;
+ SetUserData(inUserData: number): void;
+ }
+ class BodyInterface {
+ CreateBody(inSettings: BodyCreationSettings): Body;
+ CreateSoftBody(inSettings: SoftBodyCreationSettings): Body;
+ CreateBodyWithID(inBodyID: BodyID, inSettings: BodyCreationSettings): void;
+ CreateSoftBodyWithID(
+ inBodyID: BodyID,
+ inSettings: SoftBodyCreationSettings
+ ): void;
+ CreateBodyWithoutID(inSettings: BodyCreationSettings): Body;
+ CreateSoftBodyWithoutID(inSettings: SoftBodyCreationSettings): Body;
+ DestroyBodyWithoutID(inBody: Body): void;
+ AssignBodyID(ioBody: Body): boolean;
+ AssignBodyID(ioBody: Body, inBodyID: BodyID): boolean;
+ UnassignBodyID(inBodyID: BodyID): Body;
+ DestroyBody(inBodyID: BodyID): void;
+ AddBody(inBodyID: BodyID, inActivationMode: EActivation): void;
+ RemoveBody(inBodyID: BodyID): void;
+ IsAdded(inBodyID: BodyID): boolean;
+ CreateAndAddBody(
+ inSettings: BodyCreationSettings,
+ inActivationMode: EActivation
+ ): BodyID;
+ CreateAndAddSoftBody(
+ inSettings: SoftBodyCreationSettings,
+ inActivationMode: EActivation
+ ): BodyID;
+ CreateConstraint(
+ inSettings: TwoBodyConstraintSettings,
+ inBodyID1: BodyID,
+ inBodyID2: BodyID
+ ): TwoBodyConstraint;
+ ActivateConstraint(inConstraint: TwoBodyConstraint): void;
+ GetShape(inBodyID: BodyID): Shape;
+ SetShape(
+ inBodyID: BodyID,
+ inShape: Shape,
+ inUpdateMassProperties: boolean,
+ inActivationMode: EActivation
+ ): void;
+ NotifyShapeChanged(
+ inBodyID: BodyID,
+ inPreviousCenterOfMass: Vec3,
+ inUpdateMassProperties: boolean,
+ inActivationMode: EActivation
+ ): void;
+ SetObjectLayer(inBodyID: BodyID, inLayer: number): void;
+ GetObjectLayer(inBodyID: BodyID): number;
+ SetPositionAndRotation(
+ inBodyID: BodyID,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inActivationMode: EActivation
+ ): void;
+ SetPositionAndRotationWhenChanged(
+ inBodyID: BodyID,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inActivationMode: EActivation
+ ): void;
+ GetPositionAndRotation(
+ inBodyID: BodyID,
+ outPosition: RVec3,
+ outRotation: Quat
+ ): void;
+ SetPosition(
+ inBodyID: BodyID,
+ inPosition: RVec3,
+ inActivationMode: EActivation
+ ): void;
+ GetPosition(inBodyID: BodyID): RVec3;
+ SetRotation(
+ inBodyID: BodyID,
+ inRotation: Quat,
+ inActivationMode: EActivation
+ ): void;
+ GetRotation(inBodyID: BodyID): Quat;
+ GetWorldTransform(inBodyID: BodyID): RMat44;
+ GetCenterOfMassTransform(inBodyID: BodyID): RMat44;
+ SetLinearVelocity(inBodyID: BodyID, inLinearVelocity: Vec3): void;
+ GetLinearVelocity(inBodyID: BodyID): Vec3;
+ AddLinearVelocity(inBodyID: BodyID, inLinearVelocity: Vec3): void;
+ AddLinearAndAngularVelocity(
+ inBodyID: BodyID,
+ inLinearVelocity: Vec3,
+ inAngularVelocity: Vec3
+ ): void;
+ SetAngularVelocity(inBodyID: BodyID, inAngularVelocity: Vec3): void;
+ GetAngularVelocity(inBodyID: BodyID): Vec3;
+ GetPointVelocity(inBodyID: BodyID, inPoint: RVec3): Vec3;
+ SetPositionRotationAndVelocity(
+ inBodyID: BodyID,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inLinearVelocity: Vec3,
+ inAngularVelocity: Vec3
+ ): void;
+ MoveKinematic(
+ inBodyID: BodyID,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inDeltaTime: number
+ ): void;
+ ActivateBody(inBodyID: BodyID): void;
+ ActivateBodiesInAABox(
+ inBox: AABox,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ DeactivateBody(inBodyID: BodyID): void;
+ IsActive(inBodyID: BodyID): boolean;
+ ResetSleepTimer(inBodyID: BodyID): void;
+ GetBodyType(inBodyID: BodyID): EBodyType;
+ SetMotionType(
+ inBodyID: BodyID,
+ inMotionType: EMotionType,
+ inActivationMode: EActivation
+ ): void;
+ GetMotionType(inBodyID: BodyID): EMotionType;
+ SetMotionQuality(inBodyID: BodyID, inMotionQuality: EMotionQuality): void;
+ GetMotionQuality(inBodyID: BodyID): EMotionQuality;
+ GetInverseInertia(inBodyID: BodyID): Mat44;
+ SetRestitution(inBodyID: BodyID, inRestitution: number): void;
+ GetRestitution(inBodyID: BodyID): number;
+ SetFriction(inBodyID: BodyID, inFriction: number): void;
+ GetFriction(inBodyID: BodyID): number;
+ SetGravityFactor(inBodyID: BodyID, inFactor: number): void;
+ GetGravityFactor(inBodyID: BodyID): number;
+ SetUseManifoldReduction(inBodyID: BodyID, inUseReduction: boolean): void;
+ GetUseManifoldReduction(inBodyID: BodyID): boolean;
+ AddForce(
+ inBodyID: BodyID,
+ inForce: Vec3,
+ inActivationMode: EActivation
+ ): void;
+ AddForce(
+ inBodyID: BodyID,
+ inForce: Vec3,
+ inPoint: RVec3,
+ inActivationMode: EActivation
+ ): void;
+ AddTorque(
+ inBodyID: BodyID,
+ inTorque: Vec3,
+ inActivationMode: EActivation
+ ): void;
+ AddForceAndTorque(
+ inBodyID: BodyID,
+ inForce: Vec3,
+ inTorque: Vec3,
+ inActivationMode: EActivation
+ ): void;
+ ApplyBuoyancyImpulse(
+ inBodyID: BodyID,
+ inSurfacePosition: RVec3,
+ inSurfaceNormal: Vec3,
+ inBuoyancy: number,
+ inLinearDrag: number,
+ inAngularDrag: number,
+ inFluidVelocity: Vec3,
+ inGravity: Vec3,
+ inDeltaTime: number
+ ): boolean;
+ AddImpulse(inBodyID: BodyID, inImpulse: Vec3): void;
+ AddImpulse(inBodyID: BodyID, inImpulse: Vec3, inPosition: RVec3): void;
+ AddAngularImpulse(inBodyID: BodyID, inAngularImpulse: Vec3): void;
+ GetTransformedShape(inBodyID: BodyID): TransformedShape;
+ GetUserData(inBodyID: BodyID): number;
+ SetUserData(inBodyID: BodyID, inUserData: number): void;
+ GetMaterial(inBodyID: BodyID, inSubShapeID: SubShapeID): PhysicsMaterial;
+ InvalidateContactCache(inBodyID: BodyID): void;
+ }
+ class StateRecorderFilter {}
+ class StateRecorderFilterJS extends StateRecorderFilter {
+ constructor();
+ ShouldSaveBody(inBody: number): boolean;
+ ShouldSaveConstraint(inConstraint: number): boolean;
+ ShouldSaveContact(inBody1: number, inBody2: number): boolean;
+ ShouldRestoreContact(inBody1: number, inBody2: number): boolean;
+ }
+ class StateRecorder {
+ SetValidating(inValidating: boolean): void;
+ IsValidating(): boolean;
+ SetIsLastPart(inIsLastPart: boolean): void;
+ IsLastPart(): boolean;
+ }
+ class StateRecorderEm extends StateRecorder {}
+ class StateRecorderJS extends StateRecorderEm {
+ constructor();
+ ReadBytes(outData: number, inNumBytes: number): void;
+ WriteBytes(inData: number, inNumBytes: number): void;
+ IsEOF(): boolean;
+ IsFailed(): boolean;
+ }
+ class StateRecorderImpl extends StateRecorder {
+ constructor();
+ Clear(): void;
+ Rewind(): void;
+ IsEqual(inReference: StateRecorderImpl): boolean;
+ }
+ class BodyLockInterface {
+ TryGetBody(inBodyID: BodyID): Body;
+ }
+ class BodyLockInterfaceNoLock extends BodyLockInterface {}
+ class BodyLockInterfaceLocking extends BodyLockInterface {}
+ class PhysicsSettings {
+ constructor();
+ get_mMaxInFlightBodyPairs(): number;
+ set_mMaxInFlightBodyPairs(mMaxInFlightBodyPairs: number): void;
+ mMaxInFlightBodyPairs: number;
+ get_mStepListenersBatchSize(): number;
+ set_mStepListenersBatchSize(mStepListenersBatchSize: number): void;
+ mStepListenersBatchSize: number;
+ get_mStepListenerBatchesPerJob(): number;
+ set_mStepListenerBatchesPerJob(mStepListenerBatchesPerJob: number): void;
+ mStepListenerBatchesPerJob: number;
+ get_mBaumgarte(): number;
+ set_mBaumgarte(mBaumgarte: number): void;
+ mBaumgarte: number;
+ get_mSpeculativeContactDistance(): number;
+ set_mSpeculativeContactDistance(mSpeculativeContactDistance: number): void;
+ mSpeculativeContactDistance: number;
+ get_mPenetrationSlop(): number;
+ set_mPenetrationSlop(mPenetrationSlop: number): void;
+ mPenetrationSlop: number;
+ get_mLinearCastThreshold(): number;
+ set_mLinearCastThreshold(mLinearCastThreshold: number): void;
+ mLinearCastThreshold: number;
+ get_mLinearCastMaxPenetration(): number;
+ set_mLinearCastMaxPenetration(mLinearCastMaxPenetration: number): void;
+ mLinearCastMaxPenetration: number;
+ get_mManifoldToleranceSq(): number;
+ set_mManifoldToleranceSq(mManifoldToleranceSq: number): void;
+ mManifoldToleranceSq: number;
+ get_mMaxPenetrationDistance(): number;
+ set_mMaxPenetrationDistance(mMaxPenetrationDistance: number): void;
+ mMaxPenetrationDistance: number;
+ get_mBodyPairCacheMaxDeltaPositionSq(): number;
+ set_mBodyPairCacheMaxDeltaPositionSq(
+ mBodyPairCacheMaxDeltaPositionSq: number
+ ): void;
+ mBodyPairCacheMaxDeltaPositionSq: number;
+ get_mBodyPairCacheCosMaxDeltaRotationDiv2(): number;
+ set_mBodyPairCacheCosMaxDeltaRotationDiv2(
+ mBodyPairCacheCosMaxDeltaRotationDiv2: number
+ ): void;
+ mBodyPairCacheCosMaxDeltaRotationDiv2: number;
+ get_mContactNormalCosMaxDeltaRotation(): number;
+ set_mContactNormalCosMaxDeltaRotation(
+ mContactNormalCosMaxDeltaRotation: number
+ ): void;
+ mContactNormalCosMaxDeltaRotation: number;
+ get_mContactPointPreserveLambdaMaxDistSq(): number;
+ set_mContactPointPreserveLambdaMaxDistSq(
+ mContactPointPreserveLambdaMaxDistSq: number
+ ): void;
+ mContactPointPreserveLambdaMaxDistSq: number;
+ get_mNumVelocitySteps(): number;
+ set_mNumVelocitySteps(mNumVelocitySteps: number): void;
+ mNumVelocitySteps: number;
+ get_mNumPositionSteps(): number;
+ set_mNumPositionSteps(mNumPositionSteps: number): void;
+ mNumPositionSteps: number;
+ get_mMinVelocityForRestitution(): number;
+ set_mMinVelocityForRestitution(mMinVelocityForRestitution: number): void;
+ mMinVelocityForRestitution: number;
+ get_mTimeBeforeSleep(): number;
+ set_mTimeBeforeSleep(mTimeBeforeSleep: number): void;
+ mTimeBeforeSleep: number;
+ get_mPointVelocitySleepThreshold(): number;
+ set_mPointVelocitySleepThreshold(
+ mPointVelocitySleepThreshold: number
+ ): void;
+ mPointVelocitySleepThreshold: number;
+ get_mDeterministicSimulation(): boolean;
+ set_mDeterministicSimulation(mDeterministicSimulation: boolean): void;
+ mDeterministicSimulation: boolean;
+ get_mConstraintWarmStart(): boolean;
+ set_mConstraintWarmStart(mConstraintWarmStart: boolean): void;
+ mConstraintWarmStart: boolean;
+ get_mUseBodyPairContactCache(): boolean;
+ set_mUseBodyPairContactCache(mUseBodyPairContactCache: boolean): void;
+ mUseBodyPairContactCache: boolean;
+ get_mUseManifoldReduction(): boolean;
+ set_mUseManifoldReduction(mUseManifoldReduction: boolean): void;
+ mUseManifoldReduction: boolean;
+ get_mUseLargeIslandSplitter(): boolean;
+ set_mUseLargeIslandSplitter(mUseLargeIslandSplitter: boolean): void;
+ mUseLargeIslandSplitter: boolean;
+ get_mAllowSleeping(): boolean;
+ set_mAllowSleeping(mAllowSleeping: boolean): void;
+ mAllowSleeping: boolean;
+ get_mCheckActiveEdges(): boolean;
+ set_mCheckActiveEdges(mCheckActiveEdges: boolean): void;
+ mCheckActiveEdges: boolean;
+ }
+ class CollideShapeResultFace {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Vec3;
+ push_back(inValue: Vec3): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class CollideShapeResult {
+ constructor();
+ get_mContactPointOn1(): Vec3;
+ set_mContactPointOn1(mContactPointOn1: Vec3): void;
+ mContactPointOn1: Vec3;
+ get_mContactPointOn2(): Vec3;
+ set_mContactPointOn2(mContactPointOn2: Vec3): void;
+ mContactPointOn2: Vec3;
+ get_mPenetrationAxis(): Vec3;
+ set_mPenetrationAxis(mPenetrationAxis: Vec3): void;
+ mPenetrationAxis: Vec3;
+ get_mPenetrationDepth(): number;
+ set_mPenetrationDepth(mPenetrationDepth: number): void;
+ mPenetrationDepth: number;
+ get_mSubShapeID1(): SubShapeID;
+ set_mSubShapeID1(mSubShapeID1: SubShapeID): void;
+ mSubShapeID1: SubShapeID;
+ get_mSubShapeID2(): SubShapeID;
+ set_mSubShapeID2(mSubShapeID2: SubShapeID): void;
+ mSubShapeID2: SubShapeID;
+ get_mBodyID2(): BodyID;
+ set_mBodyID2(mBodyID2: BodyID): void;
+ mBodyID2: BodyID;
+ get_mShape1Face(): CollideShapeResultFace;
+ set_mShape1Face(mShape1Face: CollideShapeResultFace): void;
+ mShape1Face: CollideShapeResultFace;
+ get_mShape2Face(): CollideShapeResultFace;
+ set_mShape2Face(mShape2Face: CollideShapeResultFace): void;
+ mShape2Face: CollideShapeResultFace;
+ }
+ class ContactPoints {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): Vec3;
+ push_back(inValue: Vec3): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ContactManifold {
+ constructor();
+ SwapShapes(): ContactManifold;
+ GetWorldSpaceContactPointOn1(inIndex: number): RVec3;
+ GetWorldSpaceContactPointOn2(inIndex: number): RVec3;
+ get_mBaseOffset(): RVec3;
+ set_mBaseOffset(mBaseOffset: RVec3): void;
+ mBaseOffset: RVec3;
+ get_mWorldSpaceNormal(): Vec3;
+ set_mWorldSpaceNormal(mWorldSpaceNormal: Vec3): void;
+ mWorldSpaceNormal: Vec3;
+ get_mPenetrationDepth(): number;
+ set_mPenetrationDepth(mPenetrationDepth: number): void;
+ mPenetrationDepth: number;
+ get_mSubShapeID1(): SubShapeID;
+ set_mSubShapeID1(mSubShapeID1: SubShapeID): void;
+ mSubShapeID1: SubShapeID;
+ get_mSubShapeID2(): SubShapeID;
+ set_mSubShapeID2(mSubShapeID2: SubShapeID): void;
+ mSubShapeID2: SubShapeID;
+ get_mRelativeContactPointsOn1(): ContactPoints;
+ set_mRelativeContactPointsOn1(
+ mRelativeContactPointsOn1: ContactPoints
+ ): void;
+ mRelativeContactPointsOn1: ContactPoints;
+ get_mRelativeContactPointsOn2(): ContactPoints;
+ set_mRelativeContactPointsOn2(
+ mRelativeContactPointsOn2: ContactPoints
+ ): void;
+ mRelativeContactPointsOn2: ContactPoints;
+ }
+ class ContactSettings {
+ constructor();
+ get_mCombinedFriction(): number;
+ set_mCombinedFriction(mCombinedFriction: number): void;
+ mCombinedFriction: number;
+ get_mCombinedRestitution(): number;
+ set_mCombinedRestitution(mCombinedRestitution: number): void;
+ mCombinedRestitution: number;
+ get_mInvMassScale1(): number;
+ set_mInvMassScale1(mInvMassScale1: number): void;
+ mInvMassScale1: number;
+ get_mInvInertiaScale1(): number;
+ set_mInvInertiaScale1(mInvInertiaScale1: number): void;
+ mInvInertiaScale1: number;
+ get_mInvMassScale2(): number;
+ set_mInvMassScale2(mInvMassScale2: number): void;
+ mInvMassScale2: number;
+ get_mInvInertiaScale2(): number;
+ set_mInvInertiaScale2(mInvInertiaScale2: number): void;
+ mInvInertiaScale2: number;
+ get_mIsSensor(): boolean;
+ set_mIsSensor(mIsSensor: boolean): void;
+ mIsSensor: boolean;
+ get_mRelativeLinearSurfaceVelocity(): Vec3;
+ set_mRelativeLinearSurfaceVelocity(
+ mRelativeLinearSurfaceVelocity: Vec3
+ ): void;
+ mRelativeLinearSurfaceVelocity: Vec3;
+ get_mRelativeAngularSurfaceVelocity(): Vec3;
+ set_mRelativeAngularSurfaceVelocity(
+ mRelativeAngularSurfaceVelocity: Vec3
+ ): void;
+ mRelativeAngularSurfaceVelocity: Vec3;
+ }
+ class SubShapeIDPair {
+ constructor();
+ GetBody1ID(): BodyID;
+ GetSubShapeID1(): SubShapeID;
+ GetBody2ID(): BodyID;
+ GetSubShapeID2(): SubShapeID;
+ }
+ class ContactListener {}
+ class ContactListenerEm extends ContactListener {}
+ class ContactListenerJS extends ContactListenerEm {
+ constructor();
+ OnContactValidate(
+ inBody1: number,
+ inBody2: number,
+ inBaseOffset: number,
+ inCollisionResult: number
+ ): number;
+ OnContactAdded(
+ inBody1: number,
+ inBody2: number,
+ inManifold: number,
+ ioSettings: number
+ ): void;
+ OnContactPersisted(
+ inBody1: number,
+ inBody2: number,
+ inManifold: number,
+ ioSettings: number
+ ): void;
+ OnContactRemoved(inSubShapePair: number): void;
+ }
+ class SoftBodyManifold {
+ GetVertices(): ArraySoftBodyVertex;
+ HasContact(inVertex: SoftBodyVertex): boolean;
+ GetLocalContactPoint(inVertex: SoftBodyVertex): Vec3;
+ GetContactNormal(inVertex: SoftBodyVertex): Vec3;
+ GetContactBodyID(inVertex: SoftBodyVertex): BodyID;
+ GetNumSensorContacts(): number;
+ GetSensorContactBodyID(inIndex: number): BodyID;
+ }
+ class SoftBodyContactSettings {
+ get_mInvMassScale1(): number;
+ set_mInvMassScale1(mInvMassScale1: number): void;
+ mInvMassScale1: number;
+ get_mInvMassScale2(): number;
+ set_mInvMassScale2(mInvMassScale2: number): void;
+ mInvMassScale2: number;
+ get_mInvInertiaScale2(): number;
+ set_mInvInertiaScale2(mInvInertiaScale2: number): void;
+ mInvInertiaScale2: number;
+ get_mIsSensor(): boolean;
+ set_mIsSensor(mIsSensor: boolean): void;
+ mIsSensor: boolean;
+ }
+ class SoftBodyContactListener {}
+ class SoftBodyContactListenerEm extends SoftBodyContactListener {}
+ class SoftBodyContactListenerJS extends SoftBodyContactListenerEm {
+ constructor();
+ OnSoftBodyContactValidate(
+ inSoftBody: number,
+ inOtherBody: number,
+ ioSettings: number
+ ): number;
+ OnSoftBodyContactAdded(inSoftBody: number, inManifold: number): void;
+ }
+ class RayCastBodyCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class RayCastBodyCollectorJS extends RayCastBodyCollector {
+ constructor();
+ Reset(): void;
+ AddHit(inResult: number): void;
+ }
+ class CollideShapeBodyCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CollideShapeBodyCollectorJS extends CollideShapeBodyCollector {
+ constructor();
+ Reset(): void;
+ AddHit(inResult: number): void;
+ }
+ class CastShapeBodyCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CastShapeBodyCollectorJS extends CastShapeBodyCollector {
+ constructor();
+ Reset(): void;
+ AddHit(inResult: number): void;
+ }
+ class BroadPhaseQuery {
+ CastRay(
+ inRay: RayCast,
+ ioCollector: RayCastBodyCollector,
+ inBroadPhaseFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ CollideAABox(
+ inBox: AABox,
+ ioCollector: CollideShapeBodyCollector,
+ inBroadPhaseFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ CollideSphere(
+ inCenter: Vec3,
+ inRadius: number,
+ ioCollector: CollideShapeBodyCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ CollidePoint(
+ inPoint: Vec3,
+ ioCollector: CollideShapeBodyCollector,
+ inBroadPhaseFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ CollideOrientedBox(
+ inBox: OrientedBox,
+ ioCollector: CollideShapeBodyCollector,
+ inBroadPhaseFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ CastAABox(
+ inBox: AABoxCast,
+ ioCollector: CastShapeBodyCollector,
+ inBroadPhaseFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter
+ ): void;
+ }
+ class RayCastSettings {
+ constructor();
+ SetBackFaceMode(inBackFaceMode: EBackFaceMode): void;
+ get_mBackFaceModeTriangles(): EBackFaceMode;
+ set_mBackFaceModeTriangles(mBackFaceModeTriangles: EBackFaceMode): void;
+ mBackFaceModeTriangles: EBackFaceMode;
+ get_mBackFaceModeConvex(): EBackFaceMode;
+ set_mBackFaceModeConvex(mBackFaceModeConvex: EBackFaceMode): void;
+ mBackFaceModeConvex: EBackFaceMode;
+ get_mTreatConvexAsSolid(): boolean;
+ set_mTreatConvexAsSolid(mTreatConvexAsSolid: boolean): void;
+ mTreatConvexAsSolid: boolean;
+ }
+ class CastRayCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CastRayCollectorJS extends CastRayCollector {
+ constructor();
+ Reset(): void;
+ OnBody(inBody: number): void;
+ AddHit(inResult: number): void;
+ }
+ class ArrayRayCastResult {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): RayCastResult;
+ push_back(inValue: RayCastResult): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class CastRayAllHitCollisionCollector extends CastRayCollector {
+ constructor();
+ Sort(): void;
+ HadHit(): boolean;
+ get_mHits(): ArrayRayCastResult;
+ set_mHits(mHits: ArrayRayCastResult): void;
+ mHits: ArrayRayCastResult;
+ }
+ class CastRayClosestHitCollisionCollector extends CastRayCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): RayCastResult;
+ set_mHit(mHit: RayCastResult): void;
+ mHit: RayCastResult;
+ }
+ class CastRayAnyHitCollisionCollector extends CastRayCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): RayCastResult;
+ set_mHit(mHit: RayCastResult): void;
+ mHit: RayCastResult;
+ }
+ class CollidePointResult {
+ constructor();
+ get_mBodyID(): BodyID;
+ set_mBodyID(mBodyID: BodyID): void;
+ mBodyID: BodyID;
+ get_mSubShapeID2(): SubShapeID;
+ set_mSubShapeID2(mSubShapeID2: SubShapeID): void;
+ mSubShapeID2: SubShapeID;
+ }
+ class CollidePointCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CollidePointCollectorJS extends CollidePointCollector {
+ constructor();
+ Reset(): void;
+ OnBody(inBody: number): void;
+ AddHit(inResult: number): void;
+ }
+ class ArrayCollidePointResult {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): CollidePointResult;
+ push_back(inValue: CollidePointResult): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class CollidePointAllHitCollisionCollector extends CollidePointCollector {
+ constructor();
+ Sort(): void;
+ HadHit(): boolean;
+ get_mHits(): ArrayCollidePointResult;
+ set_mHits(mHits: ArrayCollidePointResult): void;
+ mHits: ArrayCollidePointResult;
+ }
+ class CollidePointClosestHitCollisionCollector extends CollidePointCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): CollidePointResult;
+ set_mHit(mHit: CollidePointResult): void;
+ mHit: CollidePointResult;
+ }
+ class CollidePointAnyHitCollisionCollector extends CollidePointCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): CollidePointResult;
+ set_mHit(mHit: CollidePointResult): void;
+ mHit: CollidePointResult;
+ }
+ class CollideSettingsBase {
+ get_mActiveEdgeMode(): EActiveEdgeMode;
+ set_mActiveEdgeMode(mActiveEdgeMode: EActiveEdgeMode): void;
+ mActiveEdgeMode: EActiveEdgeMode;
+ get_mCollectFacesMode(): ECollectFacesMode;
+ set_mCollectFacesMode(mCollectFacesMode: ECollectFacesMode): void;
+ mCollectFacesMode: ECollectFacesMode;
+ get_mCollisionTolerance(): number;
+ set_mCollisionTolerance(mCollisionTolerance: number): void;
+ mCollisionTolerance: number;
+ get_mPenetrationTolerance(): number;
+ set_mPenetrationTolerance(mPenetrationTolerance: number): void;
+ mPenetrationTolerance: number;
+ get_mActiveEdgeMovementDirection(): Vec3;
+ set_mActiveEdgeMovementDirection(mActiveEdgeMovementDirection: Vec3): void;
+ mActiveEdgeMovementDirection: Vec3;
+ }
+ class CollideShapeSettings extends CollideSettingsBase {
+ constructor();
+ get_mMaxSeparationDistance(): number;
+ set_mMaxSeparationDistance(mMaxSeparationDistance: number): void;
+ mMaxSeparationDistance: number;
+ get_mBackFaceMode(): EBackFaceMode;
+ set_mBackFaceMode(mBackFaceMode: EBackFaceMode): void;
+ mBackFaceMode: EBackFaceMode;
+ }
+ class CollideShapeCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CollideShapeCollectorJS extends CollideShapeCollector {
+ constructor();
+ Reset(): void;
+ OnBody(inBody: number): void;
+ AddHit(inResult: number): void;
+ }
+ class ArrayCollideShapeResult {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): CollideShapeResult;
+ push_back(inValue: CollideShapeResult): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class CollideShapeAllHitCollisionCollector extends CollideShapeCollector {
+ constructor();
+ Sort(): void;
+ HadHit(): boolean;
+ get_mHits(): ArrayCollideShapeResult;
+ set_mHits(mHits: ArrayCollideShapeResult): void;
+ mHits: ArrayCollideShapeResult;
+ }
+ class CollideShapeClosestHitCollisionCollector extends CollideShapeCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): CollideShapeResult;
+ set_mHit(mHit: CollideShapeResult): void;
+ mHit: CollideShapeResult;
+ }
+ class CollideShapeAnyHitCollisionCollector extends CollideShapeCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): CollideShapeResult;
+ set_mHit(mHit: CollideShapeResult): void;
+ mHit: CollideShapeResult;
+ }
+ class ShapeCastSettings extends CollideSettingsBase {
+ constructor();
+ get_mBackFaceModeTriangles(): EBackFaceMode;
+ set_mBackFaceModeTriangles(mBackFaceModeTriangles: EBackFaceMode): void;
+ mBackFaceModeTriangles: EBackFaceMode;
+ get_mBackFaceModeConvex(): EBackFaceMode;
+ set_mBackFaceModeConvex(mBackFaceModeConvex: EBackFaceMode): void;
+ mBackFaceModeConvex: EBackFaceMode;
+ get_mUseShrunkenShapeAndConvexRadius(): boolean;
+ set_mUseShrunkenShapeAndConvexRadius(
+ mUseShrunkenShapeAndConvexRadius: boolean
+ ): void;
+ mUseShrunkenShapeAndConvexRadius: boolean;
+ get_mReturnDeepestPoint(): boolean;
+ set_mReturnDeepestPoint(mReturnDeepestPoint: boolean): void;
+ mReturnDeepestPoint: boolean;
+ }
+ class ShapeCastResult extends CollideShapeResult {
+ constructor();
+ get_mFraction(): number;
+ set_mFraction(mFraction: number): void;
+ mFraction: number;
+ get_mIsBackFaceHit(): boolean;
+ set_mIsBackFaceHit(mIsBackFaceHit: boolean): void;
+ mIsBackFaceHit: boolean;
+ }
+ class CastShapeCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class CastShapeCollectorJS extends CastShapeCollector {
+ constructor();
+ Reset(): void;
+ OnBody(inBody: number): void;
+ AddHit(inResult: number): void;
+ }
+ class ArrayShapeCastResult {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): ShapeCastResult;
+ push_back(inValue: ShapeCastResult): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class CastShapeAllHitCollisionCollector extends CastShapeCollector {
+ constructor();
+ Sort(): void;
+ HadHit(): boolean;
+ get_mHits(): ArrayShapeCastResult;
+ set_mHits(mHits: ArrayShapeCastResult): void;
+ mHits: ArrayShapeCastResult;
+ }
+ class CastShapeClosestHitCollisionCollector extends CastShapeCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): ShapeCastResult;
+ set_mHit(mHit: ShapeCastResult): void;
+ mHit: ShapeCastResult;
+ }
+ class CastShapeAnyHitCollisionCollector extends CastShapeCollector {
+ constructor();
+ HadHit(): boolean;
+ get_mHit(): ShapeCastResult;
+ set_mHit(mHit: ShapeCastResult): void;
+ mHit: ShapeCastResult;
+ }
+ class TransformedShapeCollector {
+ Reset(): void;
+ SetContext(inContext: TransformedShape): void;
+ GetContext(): TransformedShape;
+ UpdateEarlyOutFraction(inFraction: number): void;
+ ResetEarlyOutFraction(inFraction?: number): void;
+ ForceEarlyOut(): void;
+ ShouldEarlyOut(): boolean;
+ GetEarlyOutFraction(): number;
+ GetPositiveEarlyOutFraction(): number;
+ }
+ class TransformedShapeCollectorJS extends TransformedShapeCollector {
+ constructor();
+ Reset(): void;
+ OnBody(inBody: number): void;
+ AddHit(inResult: number): void;
+ }
+ class NarrowPhaseQuery {
+ CastRay(
+ inRay: RRayCast,
+ inRayCastSettings: RayCastSettings,
+ ioCollector: CastRayCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollidePoint(
+ inPoint: RVec3,
+ ioCollector: CollidePointCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollideShape(
+ inShape: Shape,
+ inShapeScale: Vec3,
+ inCenterOfMassTransform: RMat44,
+ inCollideShapeSettings: CollideShapeSettings,
+ inBaseOffset: RVec3,
+ ioCollector: CollideShapeCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CastShape(
+ inShapeCast: RShapeCast,
+ inShapeCastSettings: ShapeCastSettings,
+ inBaseOffset: RVec3,
+ ioCollector: CastShapeCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter
+ ): void;
+ CollectTransformedShapes(
+ inBox: AABox,
+ ioCollector: TransformedShapeCollector,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter
+ ): void;
+ }
+ class PhysicsStepListenerContext {
+ get_mDeltaTime(): number;
+ set_mDeltaTime(mDeltaTime: number): void;
+ mDeltaTime: number;
+ get_mIsFirstStep(): boolean;
+ set_mIsFirstStep(mIsFirstStep: boolean): void;
+ mIsFirstStep: boolean;
+ get_mIsLastStep(): boolean;
+ set_mIsLastStep(mIsLastStep: boolean): void;
+ mIsLastStep: boolean;
+ get_mPhysicsSystem(): PhysicsSystem;
+ set_mPhysicsSystem(mPhysicsSystem: PhysicsSystem): void;
+ mPhysicsSystem: PhysicsSystem;
+ }
+ class PhysicsStepListener {}
+ class PhysicsStepListenerJS extends PhysicsStepListener {
+ constructor();
+ OnStep(inContext: number): void;
+ }
+ class BodyActivationListener {}
+ class BodyActivationListenerJS extends BodyActivationListener {
+ constructor();
+ OnBodyActivated(inBodyID: number, inBodyUserData: number): void;
+ OnBodyDeactivated(inBodyID: number, inBodyUserData: number): void;
+ }
+ class BodyIDVector {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): BodyID;
+ push_back(inBodyID: BodyID): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class PhysicsSystem {
+ SetGravity(inGravity: Vec3): void;
+ GetGravity(): Vec3;
+ GetPhysicsSettings(): PhysicsSettings;
+ SetPhysicsSettings(inPhysicsSettings: PhysicsSettings): void;
+ GetNumBodies(): number;
+ GetNumActiveBodies(inBodyType: EBodyType): number;
+ GetMaxBodies(): number;
+ GetBodies(outBodies: BodyIDVector): void;
+ GetActiveBodies(inBodyType: EBodyType, outBodies: BodyIDVector): void;
+ GetBounds(): AABox;
+ AddConstraint(inConstraint: Constraint): void;
+ RemoveConstraint(inConstraint: Constraint): void;
+ SetContactListener(inListener: ContactListener): void;
+ GetContactListener(): ContactListener;
+ SetSoftBodyContactListener(inListener: SoftBodyContactListener): void;
+ GetSoftBodyContactListener(): SoftBodyContactListener;
+ OptimizeBroadPhase(): void;
+ GetBodyInterface(): BodyInterface;
+ GetBodyInterfaceNoLock(): BodyInterface;
+ GetBodyLockInterfaceNoLock(): BodyLockInterfaceNoLock;
+ GetBodyLockInterface(): BodyLockInterfaceLocking;
+ GetBroadPhaseQuery(): BroadPhaseQuery;
+ GetNarrowPhaseQuery(): NarrowPhaseQuery;
+ GetNarrowPhaseQueryNoLock(): NarrowPhaseQuery;
+ SaveState(
+ inStream: StateRecorder,
+ inState?: EStateRecorderState,
+ inFilter?: StateRecorderFilter
+ ): void;
+ RestoreState(
+ inStream: StateRecorder,
+ inFilter?: StateRecorderFilter
+ ): boolean;
+ AddStepListener(inListener: PhysicsStepListener): void;
+ RemoveStepListener(inListener: PhysicsStepListener): void;
+ SetBodyActivationListener(inListener: BodyActivationListener): void;
+ GetBodyActivationListener(): BodyActivationListener;
+ WereBodiesInContact(inBodyID1: BodyID, inBodyID2: BodyID): boolean;
+ }
+ class MassProperties {
+ constructor();
+ SetMassAndInertiaOfSolidBox(inBoxSize: Vec3, inDensity: number): void;
+ ScaleToMass(inMass: number): void;
+ sGetEquivalentSolidBoxSize(inMass: number, inInertiaDiagonal: Vec3): Vec3;
+ Rotate(inRotation: Mat44): void;
+ Translate(inTranslation: Vec3): void;
+ Scale(inScale: Vec3): void;
+ get_mMass(): number;
+ set_mMass(mMass: number): void;
+ mMass: number;
+ get_mInertia(): Mat44;
+ set_mInertia(mInertia: Mat44): void;
+ mInertia: Mat44;
+ }
+ class BodyCreationSettings {
+ constructor();
+ constructor(
+ inShape: Shape,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inMotionType: EMotionType,
+ inObjectLayer: number
+ );
+ GetShapeSettings(): ShapeSettings;
+ SetShapeSettings(inShape: ShapeSettings): void;
+ ConvertShapeSettings(): ShapeResult;
+ GetShape(): Shape;
+ SetShape(inShape: Shape): void;
+ HasMassProperties(): boolean;
+ GetMassProperties(): MassProperties;
+ get_mPosition(): RVec3;
+ set_mPosition(mPosition: RVec3): void;
+ mPosition: RVec3;
+ get_mRotation(): Quat;
+ set_mRotation(mRotation: Quat): void;
+ mRotation: Quat;
+ get_mLinearVelocity(): Vec3;
+ set_mLinearVelocity(mLinearVelocity: Vec3): void;
+ mLinearVelocity: Vec3;
+ get_mAngularVelocity(): Vec3;
+ set_mAngularVelocity(mAngularVelocity: Vec3): void;
+ mAngularVelocity: Vec3;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ get_mObjectLayer(): number;
+ set_mObjectLayer(mObjectLayer: number): void;
+ mObjectLayer: number;
+ get_mCollisionGroup(): CollisionGroup;
+ set_mCollisionGroup(mCollisionGroup: CollisionGroup): void;
+ mCollisionGroup: CollisionGroup;
+ get_mMotionType(): EMotionType;
+ set_mMotionType(mMotionType: EMotionType): void;
+ mMotionType: EMotionType;
+ get_mAllowedDOFs(): EAllowedDOFs;
+ set_mAllowedDOFs(mAllowedDOFs: EAllowedDOFs): void;
+ mAllowedDOFs: EAllowedDOFs;
+ get_mAllowDynamicOrKinematic(): boolean;
+ set_mAllowDynamicOrKinematic(mAllowDynamicOrKinematic: boolean): void;
+ mAllowDynamicOrKinematic: boolean;
+ get_mIsSensor(): boolean;
+ set_mIsSensor(mIsSensor: boolean): void;
+ mIsSensor: boolean;
+ get_mUseManifoldReduction(): boolean;
+ set_mUseManifoldReduction(mUseManifoldReduction: boolean): void;
+ mUseManifoldReduction: boolean;
+ get_mCollideKinematicVsNonDynamic(): boolean;
+ set_mCollideKinematicVsNonDynamic(
+ mCollideKinematicVsNonDynamic: boolean
+ ): void;
+ mCollideKinematicVsNonDynamic: boolean;
+ get_mApplyGyroscopicForce(): boolean;
+ set_mApplyGyroscopicForce(mApplyGyroscopicForce: boolean): void;
+ mApplyGyroscopicForce: boolean;
+ get_mMotionQuality(): EMotionQuality;
+ set_mMotionQuality(mMotionQuality: EMotionQuality): void;
+ mMotionQuality: EMotionQuality;
+ get_mEnhancedInternalEdgeRemoval(): boolean;
+ set_mEnhancedInternalEdgeRemoval(
+ mEnhancedInternalEdgeRemoval: boolean
+ ): void;
+ mEnhancedInternalEdgeRemoval: boolean;
+ get_mAllowSleeping(): boolean;
+ set_mAllowSleeping(mAllowSleeping: boolean): void;
+ mAllowSleeping: boolean;
+ get_mFriction(): number;
+ set_mFriction(mFriction: number): void;
+ mFriction: number;
+ get_mRestitution(): number;
+ set_mRestitution(mRestitution: number): void;
+ mRestitution: number;
+ get_mLinearDamping(): number;
+ set_mLinearDamping(mLinearDamping: number): void;
+ mLinearDamping: number;
+ get_mAngularDamping(): number;
+ set_mAngularDamping(mAngularDamping: number): void;
+ mAngularDamping: number;
+ get_mMaxLinearVelocity(): number;
+ set_mMaxLinearVelocity(mMaxLinearVelocity: number): void;
+ mMaxLinearVelocity: number;
+ get_mMaxAngularVelocity(): number;
+ set_mMaxAngularVelocity(mMaxAngularVelocity: number): void;
+ mMaxAngularVelocity: number;
+ get_mGravityFactor(): number;
+ set_mGravityFactor(mGravityFactor: number): void;
+ mGravityFactor: number;
+ get_mNumVelocityStepsOverride(): number;
+ set_mNumVelocityStepsOverride(mNumVelocityStepsOverride: number): void;
+ mNumVelocityStepsOverride: number;
+ get_mNumPositionStepsOverride(): number;
+ set_mNumPositionStepsOverride(mNumPositionStepsOverride: number): void;
+ mNumPositionStepsOverride: number;
+ get_mOverrideMassProperties(): EOverrideMassProperties;
+ set_mOverrideMassProperties(
+ mOverrideMassProperties: EOverrideMassProperties
+ ): void;
+ mOverrideMassProperties: EOverrideMassProperties;
+ get_mInertiaMultiplier(): number;
+ set_mInertiaMultiplier(mInertiaMultiplier: number): void;
+ mInertiaMultiplier: number;
+ get_mMassPropertiesOverride(): MassProperties;
+ set_mMassPropertiesOverride(mMassPropertiesOverride: MassProperties): void;
+ mMassPropertiesOverride: MassProperties;
+ }
+ class SoftBodySharedSettingsVertex {
+ constructor();
+ get_mPosition(): Float3;
+ set_mPosition(mPosition: Float3): void;
+ mPosition: Float3;
+ get_mVelocity(): Float3;
+ set_mVelocity(mVelocity: Float3): void;
+ mVelocity: Float3;
+ get_mInvMass(): number;
+ set_mInvMass(mInvMass: number): void;
+ mInvMass: number;
+ }
+ class SoftBodySharedSettingsFace {
+ constructor(
+ inVertex1: number,
+ inVertex2: number,
+ inVertex3: number,
+ inMaterialIndex: number
+ );
+ get_mVertex(index: number): number;
+ set_mVertex(index: number, mVertex: number): void;
+ mVertex: number;
+ get_mMaterialIndex(): number;
+ set_mMaterialIndex(mMaterialIndex: number): void;
+ mMaterialIndex: number;
+ }
+ class SoftBodySharedSettingsEdge {
+ constructor(inVertex1: number, inVertex2: number, inCompliance: number);
+ get_mVertex(index: number): number;
+ set_mVertex(index: number, mVertex: number): void;
+ mVertex: number;
+ get_mRestLength(): number;
+ set_mRestLength(mRestLength: number): void;
+ mRestLength: number;
+ get_mCompliance(): number;
+ set_mCompliance(mCompliance: number): void;
+ mCompliance: number;
+ }
+ class SoftBodySharedSettingsDihedralBend {
+ constructor(
+ inVertex1: number,
+ inVertex2: number,
+ inVertex3: number,
+ inVertex4: number,
+ inCompliance: number
+ );
+ get_mVertex(index: number): number;
+ set_mVertex(index: number, mVertex: number): void;
+ mVertex: number;
+ get_mCompliance(): number;
+ set_mCompliance(mCompliance: number): void;
+ mCompliance: number;
+ get_mInitialAngle(): number;
+ set_mInitialAngle(mInitialAngle: number): void;
+ mInitialAngle: number;
+ }
+ class SoftBodySharedSettingsVolume {
+ constructor(
+ inVertex1: number,
+ inVertex2: number,
+ inVertex3: number,
+ inVertex4: number,
+ inCompliance: number
+ );
+ get_mVertex(index: number): number;
+ set_mVertex(index: number, mVertex: number): void;
+ mVertex: number;
+ get_mSixRestVolume(): number;
+ set_mSixRestVolume(mSixRestVolume: number): void;
+ mSixRestVolume: number;
+ get_mCompliance(): number;
+ set_mCompliance(mCompliance: number): void;
+ mCompliance: number;
+ }
+ class SoftBodySharedSettingsInvBind {
+ get_mJointIndex(): number;
+ set_mJointIndex(mJointIndex: number): void;
+ mJointIndex: number;
+ get_mInvBind(): Mat44;
+ set_mInvBind(mInvBind: Mat44): void;
+ mInvBind: Mat44;
+ }
+ class SoftBodySharedSettingsSkinWeight {
+ get_mInvBindIndex(): number;
+ set_mInvBindIndex(mInvBindIndex: number): void;
+ mInvBindIndex: number;
+ get_mWeight(): number;
+ set_mWeight(mWeight: number): void;
+ mWeight: number;
+ }
+ class SoftBodySharedSettingsSkinned {
+ get_mVertex(): number;
+ set_mVertex(mVertex: number): void;
+ mVertex: number;
+ get_mWeights(index: number): SoftBodySharedSettingsSkinWeight;
+ set_mWeights(
+ index: number,
+ mWeights: SoftBodySharedSettingsSkinWeight
+ ): void;
+ mWeights: SoftBodySharedSettingsSkinWeight;
+ get_mMaxDistance(): number;
+ set_mMaxDistance(mMaxDistance: number): void;
+ mMaxDistance: number;
+ get_mBackStopDistance(): number;
+ set_mBackStopDistance(mBackStopDistance: number): void;
+ mBackStopDistance: number;
+ get_mBackStopRadius(): number;
+ set_mBackStopRadius(mBackStopRadius: number): void;
+ mBackStopRadius: number;
+ }
+ class SoftBodySharedSettingsLRA {
+ constructor(inVertex1: number, inVertex2: number, inMaxDistance: number);
+ get_mVertex(index: number): number;
+ set_mVertex(index: number, mVertex: number): void;
+ mVertex: number;
+ get_mMaxDistance(): number;
+ set_mMaxDistance(mMaxDistance: number): void;
+ mMaxDistance: number;
+ }
+ class ArraySoftBodySharedSettingsVertex {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsVertex;
+ push_back(inValue: SoftBodySharedSettingsVertex): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsFace {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsFace;
+ push_back(inValue: SoftBodySharedSettingsFace): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsEdge {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsEdge;
+ push_back(inValue: SoftBodySharedSettingsEdge): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsDihedralBend {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsDihedralBend;
+ push_back(inValue: SoftBodySharedSettingsDihedralBend): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsVolume {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsVolume;
+ push_back(inValue: SoftBodySharedSettingsVolume): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsInvBind {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsInvBind;
+ push_back(inValue: SoftBodySharedSettingsInvBind): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsSkinned {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsSkinned;
+ push_back(inValue: SoftBodySharedSettingsSkinned): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArraySoftBodySharedSettingsLRA {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsLRA;
+ push_back(inValue: SoftBodySharedSettingsLRA): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class SoftBodySharedSettingsVertexAttributes {
+ constructor();
+ get_mCompliance(): number;
+ set_mCompliance(mCompliance: number): void;
+ mCompliance: number;
+ get_mShearCompliance(): number;
+ set_mShearCompliance(mShearCompliance: number): void;
+ mShearCompliance: number;
+ get_mBendCompliance(): number;
+ set_mBendCompliance(mBendCompliance: number): void;
+ mBendCompliance: number;
+ get_mLRAType(): SoftBodySharedSettings_ELRAType;
+ set_mLRAType(mLRAType: SoftBodySharedSettings_ELRAType): void;
+ mLRAType: SoftBodySharedSettings_ELRAType;
+ get_mLRAMaxDistanceMultiplier(): number;
+ set_mLRAMaxDistanceMultiplier(mLRAMaxDistanceMultiplier: number): void;
+ mLRAMaxDistanceMultiplier: number;
+ }
+ class ArraySoftBodySharedSettingsVertexAttributes {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodySharedSettingsVertexAttributes;
+ push_back(inValue: SoftBodySharedSettingsVertexAttributes): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): SoftBodySharedSettingsVertexAttributes;
+ }
+ class SoftBodySharedSettings {
+ constructor();
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ CreateConstraints(
+ inVertexAttributes: SoftBodySharedSettingsVertexAttributes,
+ inVertexAttributesLength: number,
+ inBendType?: SoftBodySharedSettings_EBendType,
+ inAngleTolerance?: number
+ ): void;
+ AddFace(inFace: SoftBodySharedSettingsFace): void;
+ CalculateEdgeLengths(): void;
+ CalculateLRALengths(): void;
+ CalculateBendConstraintConstants(): void;
+ CalculateVolumeConstraintVolumes(): void;
+ CalculateSkinnedConstraintNormals(): void;
+ Optimize(): void;
+ Clone(): SoftBodySharedSettings;
+ get_mVertices(): ArraySoftBodySharedSettingsVertex;
+ set_mVertices(mVertices: ArraySoftBodySharedSettingsVertex): void;
+ mVertices: ArraySoftBodySharedSettingsVertex;
+ get_mFaces(): ArraySoftBodySharedSettingsFace;
+ set_mFaces(mFaces: ArraySoftBodySharedSettingsFace): void;
+ mFaces: ArraySoftBodySharedSettingsFace;
+ get_mEdgeConstraints(): ArraySoftBodySharedSettingsEdge;
+ set_mEdgeConstraints(
+ mEdgeConstraints: ArraySoftBodySharedSettingsEdge
+ ): void;
+ mEdgeConstraints: ArraySoftBodySharedSettingsEdge;
+ get_mDihedralBendConstraints(): ArraySoftBodySharedSettingsDihedralBend;
+ set_mDihedralBendConstraints(
+ mDihedralBendConstraints: ArraySoftBodySharedSettingsDihedralBend
+ ): void;
+ mDihedralBendConstraints: ArraySoftBodySharedSettingsDihedralBend;
+ get_mVolumeConstraints(): ArraySoftBodySharedSettingsVolume;
+ set_mVolumeConstraints(
+ mVolumeConstraints: ArraySoftBodySharedSettingsVolume
+ ): void;
+ mVolumeConstraints: ArraySoftBodySharedSettingsVolume;
+ get_mSkinnedConstraints(): ArraySoftBodySharedSettingsSkinned;
+ set_mSkinnedConstraints(
+ mSkinnedConstraints: ArraySoftBodySharedSettingsSkinned
+ ): void;
+ mSkinnedConstraints: ArraySoftBodySharedSettingsSkinned;
+ get_mInvBindMatrices(): ArraySoftBodySharedSettingsInvBind;
+ set_mInvBindMatrices(
+ mInvBindMatrices: ArraySoftBodySharedSettingsInvBind
+ ): void;
+ mInvBindMatrices: ArraySoftBodySharedSettingsInvBind;
+ get_mLRAConstraints(): ArraySoftBodySharedSettingsLRA;
+ set_mLRAConstraints(mLRAConstraints: ArraySoftBodySharedSettingsLRA): void;
+ mLRAConstraints: ArraySoftBodySharedSettingsLRA;
+ get_mMaterials(): PhysicsMaterialList;
+ set_mMaterials(mMaterials: PhysicsMaterialList): void;
+ mMaterials: PhysicsMaterialList;
+ get_mVertexRadius(): number;
+ set_mVertexRadius(mVertexRadius: number): void;
+ mVertexRadius: number;
+ }
+ class SoftBodyCreationSettings {
+ constructor(
+ inSettings: SoftBodySharedSettings,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inObjectLayer: number
+ );
+ get_mPosition(): RVec3;
+ set_mPosition(mPosition: RVec3): void;
+ mPosition: RVec3;
+ get_mRotation(): Quat;
+ set_mRotation(mRotation: Quat): void;
+ mRotation: Quat;
+ get_mUserData(): number;
+ set_mUserData(mUserData: number): void;
+ mUserData: number;
+ get_mObjectLayer(): number;
+ set_mObjectLayer(mObjectLayer: number): void;
+ mObjectLayer: number;
+ get_mCollisionGroup(): CollisionGroup;
+ set_mCollisionGroup(mCollisionGroup: CollisionGroup): void;
+ mCollisionGroup: CollisionGroup;
+ get_mNumIterations(): number;
+ set_mNumIterations(mNumIterations: number): void;
+ mNumIterations: number;
+ get_mLinearDamping(): number;
+ set_mLinearDamping(mLinearDamping: number): void;
+ mLinearDamping: number;
+ get_mMaxLinearVelocity(): number;
+ set_mMaxLinearVelocity(mMaxLinearVelocity: number): void;
+ mMaxLinearVelocity: number;
+ get_mRestitution(): number;
+ set_mRestitution(mRestitution: number): void;
+ mRestitution: number;
+ get_mFriction(): number;
+ set_mFriction(mFriction: number): void;
+ mFriction: number;
+ get_mPressure(): number;
+ set_mPressure(mPressure: number): void;
+ mPressure: number;
+ get_mGravityFactor(): number;
+ set_mGravityFactor(mGravityFactor: number): void;
+ mGravityFactor: number;
+ get_mUpdatePosition(): boolean;
+ set_mUpdatePosition(mUpdatePosition: boolean): void;
+ mUpdatePosition: boolean;
+ get_mMakeRotationIdentity(): boolean;
+ set_mMakeRotationIdentity(mMakeRotationIdentity: boolean): void;
+ mMakeRotationIdentity: boolean;
+ get_mAllowSleeping(): boolean;
+ set_mAllowSleeping(mAllowSleeping: boolean): void;
+ mAllowSleeping: boolean;
+ }
+ class SoftBodyVertex {
+ get_mPreviousPosition(): Vec3;
+ set_mPreviousPosition(mPreviousPosition: Vec3): void;
+ mPreviousPosition: Vec3;
+ get_mPosition(): Vec3;
+ set_mPosition(mPosition: Vec3): void;
+ mPosition: Vec3;
+ get_mVelocity(): Vec3;
+ set_mVelocity(mVelocity: Vec3): void;
+ mVelocity: Vec3;
+ get_mInvMass(): number;
+ set_mInvMass(mInvMass: number): void;
+ mInvMass: number;
+ }
+ class SoftBodyVertexTraits {
+ get_mPreviousPositionOffset(): number;
+ set_mPreviousPositionOffset(mPreviousPositionOffset: number): void;
+ readonly mPreviousPositionOffset: number;
+ get_mPositionOffset(): number;
+ set_mPositionOffset(mPositionOffset: number): void;
+ readonly mPositionOffset: number;
+ get_mVelocityOffset(): number;
+ set_mVelocityOffset(mVelocityOffset: number): void;
+ readonly mVelocityOffset: number;
+ }
+ class ArraySoftBodyVertex {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SoftBodyVertex;
+ push_back(inValue: SoftBodyVertex): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class SoftBodyMotionProperties extends MotionProperties {
+ GetSettings(): SoftBodySharedSettings;
+ GetVertices(): ArraySoftBodyVertex;
+ GetVertex(inIndex: number): SoftBodyVertex;
+ GetMaterials(): PhysicsMaterialList;
+ GetFaces(): ArraySoftBodySharedSettingsFace;
+ GetFace(inIndex: number): SoftBodySharedSettingsFace;
+ GetNumIterations(): number;
+ SetNumIterations(inNumIterations: number): void;
+ GetPressure(): number;
+ SetPressure(inPressure: number): void;
+ GetUpdatePosition(): boolean;
+ SetUpdatePosition(inUpdatePosition: boolean): void;
+ GetEnableSkinConstraints(): boolean;
+ SetEnableSkinConstraints(inEnableSkinConstraints: boolean): void;
+ GetSkinnedMaxDistanceMultiplier(): number;
+ SetSkinnedMaxDistanceMultiplier(
+ inSkinnedMaxDistanceMultiplier: number
+ ): void;
+ GetLocalBounds(): AABox;
+ CustomUpdate(
+ inDeltaTime: number,
+ ioSoftBody: Body,
+ inSystem: PhysicsSystem
+ ): void;
+ SkinVertices(
+ inRootTransform: RMat44,
+ inJointMatrices: Mat44MemRef,
+ inNumJoints: number,
+ inHardSkinAll: boolean,
+ ioTempAllocator: TempAllocator
+ ): void;
+ }
+ class SoftBodyShape extends Shape {
+ GetSubShapeIDBits(): number;
+ GetFaceIndex(inSubShapeID: SubShapeID): number;
+ }
+ class CharacterBaseSettings {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ get_mUp(): Vec3;
+ set_mUp(mUp: Vec3): void;
+ mUp: Vec3;
+ get_mSupportingVolume(): Plane;
+ set_mSupportingVolume(mSupportingVolume: Plane): void;
+ mSupportingVolume: Plane;
+ get_mMaxSlopeAngle(): number;
+ set_mMaxSlopeAngle(mMaxSlopeAngle: number): void;
+ mMaxSlopeAngle: number;
+ get_mEnhancedInternalEdgeRemoval(): boolean;
+ set_mEnhancedInternalEdgeRemoval(
+ mEnhancedInternalEdgeRemoval: boolean
+ ): void;
+ mEnhancedInternalEdgeRemoval: boolean;
+ get_mShape(): Shape;
+ set_mShape(mShape: Shape): void;
+ mShape: Shape;
+ }
+ class CharacterVirtualSettings extends CharacterBaseSettings {
+ constructor();
+ get_mMass(): number;
+ set_mMass(mMass: number): void;
+ mMass: number;
+ get_mMaxStrength(): number;
+ set_mMaxStrength(mMaxStrength: number): void;
+ mMaxStrength: number;
+ get_mShapeOffset(): Vec3;
+ set_mShapeOffset(mShapeOffset: Vec3): void;
+ mShapeOffset: Vec3;
+ get_mBackFaceMode(): EBackFaceMode;
+ set_mBackFaceMode(mBackFaceMode: EBackFaceMode): void;
+ mBackFaceMode: EBackFaceMode;
+ get_mPredictiveContactDistance(): number;
+ set_mPredictiveContactDistance(mPredictiveContactDistance: number): void;
+ mPredictiveContactDistance: number;
+ get_mMaxCollisionIterations(): number;
+ set_mMaxCollisionIterations(mMaxCollisionIterations: number): void;
+ mMaxCollisionIterations: number;
+ get_mMaxConstraintIterations(): number;
+ set_mMaxConstraintIterations(mMaxConstraintIterations: number): void;
+ mMaxConstraintIterations: number;
+ get_mMinTimeRemaining(): number;
+ set_mMinTimeRemaining(mMinTimeRemaining: number): void;
+ mMinTimeRemaining: number;
+ get_mCollisionTolerance(): number;
+ set_mCollisionTolerance(mCollisionTolerance: number): void;
+ mCollisionTolerance: number;
+ get_mCharacterPadding(): number;
+ set_mCharacterPadding(mCharacterPadding: number): void;
+ mCharacterPadding: number;
+ get_mMaxNumHits(): number;
+ set_mMaxNumHits(mMaxNumHits: number): void;
+ mMaxNumHits: number;
+ get_mHitReductionCosMaxAngle(): number;
+ set_mHitReductionCosMaxAngle(mHitReductionCosMaxAngle: number): void;
+ mHitReductionCosMaxAngle: number;
+ get_mPenetrationRecoverySpeed(): number;
+ set_mPenetrationRecoverySpeed(mPenetrationRecoverySpeed: number): void;
+ mPenetrationRecoverySpeed: number;
+ get_mInnerBodyShape(): Shape;
+ set_mInnerBodyShape(mInnerBodyShape: Shape): void;
+ mInnerBodyShape: Shape;
+ get_mInnerBodyLayer(): number;
+ set_mInnerBodyLayer(mInnerBodyLayer: number): void;
+ mInnerBodyLayer: number;
+ }
+ class CharacterContactSettings {
+ constructor();
+ get_mCanPushCharacter(): boolean;
+ set_mCanPushCharacter(mCanPushCharacter: boolean): void;
+ mCanPushCharacter: boolean;
+ get_mCanReceiveImpulses(): boolean;
+ set_mCanReceiveImpulses(mCanReceiveImpulses: boolean): void;
+ mCanReceiveImpulses: boolean;
+ }
+ class CharacterContactListener {}
+ class CharacterContactListenerEm extends CharacterContactListener {}
+ class CharacterContactListenerJS extends CharacterContactListenerEm {
+ constructor();
+ OnAdjustBodyVelocity(
+ inCharacter: number,
+ inBody2: number,
+ ioLinearVelocity: number,
+ ioAngularVelocity: number
+ ): void;
+ OnContactValidate(
+ inCharacter: number,
+ inBodyID2: number,
+ inSubShapeID2: number
+ ): boolean;
+ OnCharacterContactValidate(
+ inCharacter: number,
+ inOtherCharacter: number,
+ inSubShapeID2: number
+ ): boolean;
+ OnContactAdded(
+ inCharacter: number,
+ inBodyID2: number,
+ inSubShapeID2: number,
+ inContactPosition: number,
+ inContactNormal: number,
+ ioSettings: number
+ ): void;
+ OnCharacterContactAdded(
+ inCharacter: number,
+ inOtherCharacter: number,
+ inSubShapeID2: number,
+ inContactPosition: number,
+ inContactNormal: number,
+ ioSettings: number
+ ): void;
+ OnContactSolve(
+ inCharacter: number,
+ inBodyID2: number,
+ inSubShapeID2: number,
+ inContactPosition: number,
+ inContactNormal: number,
+ inContactVelocity: number,
+ inContactMaterial: number,
+ inCharacterVelocity: number,
+ ioNewCharacterVelocity: number
+ ): void;
+ OnCharacterContactSolve(
+ inCharacter: number,
+ inOtherCharacter: number,
+ inSubShapeID2: number,
+ inContactPosition: number,
+ inContactNormal: number,
+ inContactVelocity: number,
+ inContactMaterial: number,
+ inCharacterVelocity: number,
+ ioNewCharacterVelocity: number
+ ): void;
+ }
+ class CharacterVsCharacterCollision {}
+ class CharacterVsCharacterCollisionSimple extends CharacterVsCharacterCollision {
+ Add(inCharacter: CharacterVirtual): void;
+ Remove(inCharacter: CharacterVirtual): void;
+ }
+ class ExtendedUpdateSettings {
+ constructor();
+ get_mStickToFloorStepDown(): Vec3;
+ set_mStickToFloorStepDown(mStickToFloorStepDown: Vec3): void;
+ mStickToFloorStepDown: Vec3;
+ get_mWalkStairsStepUp(): Vec3;
+ set_mWalkStairsStepUp(mWalkStairsStepUp: Vec3): void;
+ mWalkStairsStepUp: Vec3;
+ get_mWalkStairsMinStepForward(): number;
+ set_mWalkStairsMinStepForward(mWalkStairsMinStepForward: number): void;
+ mWalkStairsMinStepForward: number;
+ get_mWalkStairsStepForwardTest(): number;
+ set_mWalkStairsStepForwardTest(mWalkStairsStepForwardTest: number): void;
+ mWalkStairsStepForwardTest: number;
+ get_mWalkStairsCosAngleForwardContact(): number;
+ set_mWalkStairsCosAngleForwardContact(
+ mWalkStairsCosAngleForwardContact: number
+ ): void;
+ mWalkStairsCosAngleForwardContact: number;
+ get_mWalkStairsStepDownExtra(): Vec3;
+ set_mWalkStairsStepDownExtra(mWalkStairsStepDownExtra: Vec3): void;
+ mWalkStairsStepDownExtra: Vec3;
+ }
+ class TempAllocator {}
+ class BroadPhaseLayerFilter {
+ constructor();
+ }
+ class ObjectVsBroadPhaseLayerFilter {
+ constructor();
+ }
+ class ObjectVsBroadPhaseLayerFilterEm extends ObjectVsBroadPhaseLayerFilter {}
+ class ObjectVsBroadPhaseLayerFilterJS extends ObjectVsBroadPhaseLayerFilterEm {
+ constructor();
+ ShouldCollide(inLayer1: number, inLayer2: number): boolean;
+ }
+ class DefaultBroadPhaseLayerFilter extends ObjectLayerFilter {
+ constructor(inFilter: ObjectVsBroadPhaseLayerFilter, inObjectLayer: number);
+ }
+ class ObjectLayerFilter {
+ constructor();
+ }
+ class ObjectLayerFilterJS extends ObjectLayerFilter {
+ constructor();
+ ShouldCollide(inLayer: number): boolean;
+ }
+ class ObjectLayerPairFilter {
+ constructor();
+ ShouldCollide(inLayer1: number, inLayer2: number): boolean;
+ }
+ class ObjectLayerPairFilterJS extends ObjectLayerPairFilter {
+ constructor();
+ ShouldCollide(inLayer1: number, inLayer2: number): boolean;
+ }
+ class DefaultObjectLayerFilter extends ObjectLayerFilter {
+ constructor(inFilter: ObjectLayerPairFilter, inObjectLayer: number);
+ }
+ class SpecifiedObjectLayerFilter extends ObjectLayerFilter {
+ constructor(inObjectLayer: number);
+ }
+ class BodyFilter {
+ constructor();
+ }
+ class BodyFilterJS extends BodyFilter {
+ constructor();
+ ShouldCollide(inBodyID: number): boolean;
+ ShouldCollideLocked(inBody: number): boolean;
+ }
+ class IgnoreSingleBodyFilter extends BodyFilter {
+ constructor(inBodyID: BodyID);
+ }
+ class IgnoreMultipleBodiesFilter extends BodyFilter {
+ constructor();
+ Clear(): void;
+ Reserve(inSize: number): void;
+ IgnoreBody(inBodyID: BodyID): void;
+ }
+ class ShapeFilter {
+ constructor();
+ }
+ class ShapeFilterJS extends ShapeFilter {
+ constructor();
+ ShouldCollide(inShape2: number, inSubShapeIDOfShape2: number): boolean;
+ }
+ class ShapeFilterJS2 extends ShapeFilter {
+ constructor();
+ ShouldCollide(
+ inShape1: number,
+ inSubShapeIDOfShape1: number,
+ inShape2: number,
+ inSubShapeIDOfShape2: number
+ ): boolean;
+ }
+ class CharacterBase {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ SetMaxSlopeAngle(inMaxSlopeAngle: number): void;
+ GetCosMaxSlopeAngle(): number;
+ SetUp(inUp: Vec3): void;
+ GetUp(): Vec3;
+ GetShape(): Shape;
+ GetGroundState(): EGroundState;
+ IsSlopeTooSteep(inNormal: Vec3): boolean;
+ IsSupported(): boolean;
+ GetGroundPosition(): RVec3;
+ GetGroundNormal(): Vec3;
+ GetGroundVelocity(): Vec3;
+ GetGroundMaterial(): PhysicsMaterial;
+ GetGroundBodyID(): BodyID;
+ }
+ class CharacterVirtual extends CharacterBase {
+ constructor(
+ inSettings: CharacterVirtualSettings,
+ inPosition: RVec3,
+ inRotation: Quat,
+ inSystem: PhysicsSystem
+ );
+ SetListener(inListener: CharacterContactListener): void;
+ SetCharacterVsCharacterCollision(
+ inCharacterVsCharacterCollision: CharacterVsCharacterCollision
+ ): void;
+ GetListener(): CharacterContactListener;
+ GetLinearVelocity(): Vec3;
+ SetLinearVelocity(inLinearVelocity: Vec3): void;
+ GetPosition(): RVec3;
+ SetPosition(inPosition: RVec3): void;
+ GetRotation(): Quat;
+ SetRotation(inRotation: Quat): void;
+ GetCenterOfMassPosition(): RVec3;
+ GetWorldTransform(): RMat44;
+ GetCenterOfMassTransform(): RMat44;
+ GetMass(): number;
+ SetMass(inMass: number): void;
+ GetMaxStrength(): number;
+ SetMaxStrength(inMaxStrength: number): void;
+ GetPenetrationRecoverySpeed(): number;
+ SetPenetrationRecoverySpeed(inSpeed: number): void;
+ GetCharacterPadding(): number;
+ GetMaxNumHits(): number;
+ SetMaxNumHits(inMaxHits: number): void;
+ GetHitReductionCosMaxAngle(): number;
+ SetHitReductionCosMaxAngle(inCosMaxAngle: number): void;
+ GetMaxHitsExceeded(): boolean;
+ GetShapeOffset(): Vec3;
+ SetShapeOffset(inShapeOffset: Vec3): void;
+ GetUserData(): number;
+ SetUserData(inUserData: number): void;
+ GetInnerBodyID(): BodyID;
+ CancelVelocityTowardsSteepSlopes(inDesiredVelocity: Vec3): Vec3;
+ Update(
+ inDeltaTime: number,
+ inGravity: Vec3,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): void;
+ CanWalkStairs(inLinearVelocity: Vec3): boolean;
+ WalkStairs(
+ inDeltaTime: number,
+ inStepUp: Vec3,
+ inStepForward: Vec3,
+ inStepForwardTest: Vec3,
+ inStepDownExtra: Vec3,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): boolean;
+ StickToFloor(
+ inStepDown: Vec3,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): boolean;
+ ExtendedUpdate(
+ inDeltaTime: number,
+ inGravity: Vec3,
+ inSettings: ExtendedUpdateSettings,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): void;
+ RefreshContacts(
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): void;
+ UpdateGroundVelocity(): void;
+ SetShape(
+ inShape: Shape,
+ inMaxPenetrationDepth: number,
+ inBroadPhaseLayerFilter: BroadPhaseLayerFilter,
+ inObjectLayerFilter: ObjectLayerFilter,
+ inBodyFilter: BodyFilter,
+ inShapeFilter: ShapeFilter,
+ inAllocator: TempAllocator
+ ): boolean;
+ SetInnerBodyShape(inShape: Shape): void;
+ GetTransformedShape(): TransformedShape;
+ }
+ class LinearCurve {
+ constructor();
+ Clear(): void;
+ Reserve(inSize: number): void;
+ AddPoint(inX: number, inY: number): void;
+ Sort(): void;
+ GetMinX(): number;
+ GetMaxX(): number;
+ GetValue(inX: number): number;
+ }
+ class ArrayFloat {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): number;
+ push_back(inValue: number): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): FloatMemRef;
+ }
+ class ArrayUint {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): number;
+ push_back(inValue: number): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): UintMemRef;
+ }
+ class ArrayUint8 {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): number;
+ push_back(inValue: number): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ data(): Uint8MemRef;
+ }
+ class ArrayVehicleAntiRollBar {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): VehicleAntiRollBar;
+ push_back(inValue: VehicleAntiRollBar): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArrayWheelSettings {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): WheelSettings;
+ push_back(inValue: WheelSettings): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class ArrayVehicleDifferentialSettings {
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): VehicleDifferentialSettings;
+ push_back(inValue: VehicleDifferentialSettings): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class VehicleCollisionTester {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ }
+ class VehicleCollisionTesterRay extends VehicleCollisionTester {
+ constructor(inObjectLayer: number, inUp?: Vec3, inMaxSlopeAngle?: number);
+ }
+ class VehicleCollisionTesterCastSphere extends VehicleCollisionTester {
+ constructor(
+ inObjectLayer: number,
+ inRadius: number,
+ inUp?: Vec3,
+ inMaxSlopeAngle?: number
+ );
+ }
+ class VehicleCollisionTesterCastCylinder extends VehicleCollisionTester {
+ constructor(inObjectLayer: number, inConvexRadiusFraction?: number);
+ }
+ class VehicleConstraintSettings extends ConstraintSettings {
+ constructor();
+ get_mUp(): Vec3;
+ set_mUp(mUp: Vec3): void;
+ mUp: Vec3;
+ get_mForward(): Vec3;
+ set_mForward(mForward: Vec3): void;
+ mForward: Vec3;
+ get_mMaxPitchRollAngle(): number;
+ set_mMaxPitchRollAngle(mMaxPitchRollAngle: number): void;
+ mMaxPitchRollAngle: number;
+ get_mWheels(): ArrayWheelSettings;
+ set_mWheels(mWheels: ArrayWheelSettings): void;
+ mWheels: ArrayWheelSettings;
+ get_mAntiRollBars(): ArrayVehicleAntiRollBar;
+ set_mAntiRollBars(mAntiRollBars: ArrayVehicleAntiRollBar): void;
+ mAntiRollBars: ArrayVehicleAntiRollBar;
+ get_mController(): VehicleControllerSettings;
+ set_mController(mController: VehicleControllerSettings): void;
+ mController: VehicleControllerSettings;
+ }
+ class VehicleConstraint extends Constraint {
+ constructor(inVehicleBody: Body, inSettings: VehicleConstraintSettings);
+ SetMaxPitchRollAngle(inMaxPitchRollAngle: number): void;
+ SetVehicleCollisionTester(inTester: VehicleCollisionTester): void;
+ OverrideGravity(inGravity: Vec3): void;
+ IsGravityOverridden(): boolean;
+ GetGravityOverride(): Vec3;
+ ResetGravityOverride(): void;
+ GetLocalUp(): Vec3;
+ GetLocalForward(): Vec3;
+ GetWorldUp(): Vec3;
+ GetVehicleBody(): Body;
+ GetController(): VehicleController;
+ GetWheel(inIdx: number): Wheel;
+ GetWheelLocalTransform(
+ inWheelIndex: number,
+ inWheelRight: Vec3,
+ inWheelUp: Vec3
+ ): Mat44;
+ GetWheelWorldTransform(
+ inWheelIndex: number,
+ inWheelRight: Vec3,
+ inWheelUp: Vec3
+ ): RMat44;
+ SetNumStepsBetweenCollisionTestActive(inSteps: number): void;
+ GetNumStepsBetweenCollisionTestActive(): number;
+ SetNumStepsBetweenCollisionTestInactive(inSteps: number): void;
+ GetNumStepsBetweenCollisionTestInactive(): number;
+ }
+ class VehicleConstraintStepListener extends PhysicsStepListener {
+ constructor(inConstraint: VehicleConstraint);
+ }
+ class VehicleConstraintCallbacksEm {
+ SetVehicleConstraint(inConstraint: VehicleConstraint): void;
+ }
+ class VehicleConstraintCallbacksJS extends VehicleConstraintCallbacksEm {
+ constructor();
+ GetCombinedFriction(
+ inWheelIndex: number,
+ inTireFrictionDirection: number,
+ inTireFriction: number,
+ inBody2: number,
+ inSubShapeID2: number
+ ): number;
+ OnPreStepCallback(inVehicle: number, inContext: number): void;
+ OnPostCollideCallback(inVehicle: number, inContext: number): void;
+ OnPostStepCallback(inVehicle: number, inContext: number): void;
+ }
+ class TireMaxImpulseCallbackResult {
+ get_mLongitudinalImpulse(): number;
+ set_mLongitudinalImpulse(mLongitudinalImpulse: number): void;
+ mLongitudinalImpulse: number;
+ get_mLateralImpulse(): number;
+ set_mLateralImpulse(mLateralImpulse: number): void;
+ mLateralImpulse: number;
+ }
+ class WheeledVehicleControllerCallbacksEm {
+ SetWheeledVehicleController(inController: WheeledVehicleController): void;
+ }
+ class WheeledVehicleControllerCallbacksJS extends WheeledVehicleControllerCallbacksEm {
+ constructor();
+ OnTireMaxImpulseCallback(
+ inWheelIndex: number,
+ outResult: number,
+ inSuspensionImpulse: number,
+ inLongitudinalFriction: number,
+ inLateralFriction: number,
+ inLongitudinalSlip: number,
+ inLateralSlip: number,
+ inDeltaTime: number
+ ): void;
+ }
+ class WheelSettings {
+ constructor();
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ get_mPosition(): Vec3;
+ set_mPosition(mPosition: Vec3): void;
+ mPosition: Vec3;
+ get_mSuspensionForcePoint(): Vec3;
+ set_mSuspensionForcePoint(mSuspensionForcePoint: Vec3): void;
+ mSuspensionForcePoint: Vec3;
+ get_mSuspensionDirection(): Vec3;
+ set_mSuspensionDirection(mSuspensionDirection: Vec3): void;
+ mSuspensionDirection: Vec3;
+ get_mSteeringAxis(): Vec3;
+ set_mSteeringAxis(mSteeringAxis: Vec3): void;
+ mSteeringAxis: Vec3;
+ get_mWheelUp(): Vec3;
+ set_mWheelUp(mWheelUp: Vec3): void;
+ mWheelUp: Vec3;
+ get_mWheelForward(): Vec3;
+ set_mWheelForward(mWheelForward: Vec3): void;
+ mWheelForward: Vec3;
+ get_mSuspensionSpring(): SpringSettings;
+ set_mSuspensionSpring(mSuspensionSpring: SpringSettings): void;
+ mSuspensionSpring: SpringSettings;
+ get_mSuspensionMinLength(): number;
+ set_mSuspensionMinLength(mSuspensionMinLength: number): void;
+ mSuspensionMinLength: number;
+ get_mSuspensionMaxLength(): number;
+ set_mSuspensionMaxLength(mSuspensionMaxLength: number): void;
+ mSuspensionMaxLength: number;
+ get_mSuspensionPreloadLength(): number;
+ set_mSuspensionPreloadLength(mSuspensionPreloadLength: number): void;
+ mSuspensionPreloadLength: number;
+ get_mRadius(): number;
+ set_mRadius(mRadius: number): void;
+ mRadius: number;
+ get_mWidth(): number;
+ set_mWidth(mWidth: number): void;
+ mWidth: number;
+ get_mEnableSuspensionForcePoint(): boolean;
+ set_mEnableSuspensionForcePoint(mEnableSuspensionForcePoint: boolean): void;
+ mEnableSuspensionForcePoint: boolean;
+ }
+ class VehicleAntiRollBar {
+ constructor();
+ get_mLeftWheel(): number;
+ set_mLeftWheel(mLeftWheel: number): void;
+ mLeftWheel: number;
+ get_mRightWheel(): number;
+ set_mRightWheel(mRightWheel: number): void;
+ mRightWheel: number;
+ get_mStiffness(): number;
+ set_mStiffness(mStiffness: number): void;
+ mStiffness: number;
+ }
+ class Wheel {
+ constructor(inSettings: WheelSettings);
+ GetSettings(): WheelSettings;
+ GetAngularVelocity(): number;
+ SetAngularVelocity(inVel: number): void;
+ GetRotationAngle(): number;
+ SetRotationAngle(inAngle: number): void;
+ GetSteerAngle(): number;
+ SetSteerAngle(inAngle: number): void;
+ HasContact(): boolean;
+ GetContactBodyID(): BodyID;
+ GetContactPosition(): RVec3;
+ GetContactPointVelocity(): Vec3;
+ GetContactNormal(): Vec3;
+ GetContactLongitudinal(): Vec3;
+ GetContactLateral(): Vec3;
+ GetSuspensionLength(): number;
+ HasHitHardPoint(): boolean;
+ GetSuspensionLambda(): number;
+ GetLongitudinalLambda(): number;
+ GetLateralLambda(): number;
+ }
+ class WheelSettingsWV extends WheelSettings {
+ constructor();
+ get_mInertia(): number;
+ set_mInertia(mInertia: number): void;
+ mInertia: number;
+ get_mAngularDamping(): number;
+ set_mAngularDamping(mAngularDamping: number): void;
+ mAngularDamping: number;
+ get_mMaxSteerAngle(): number;
+ set_mMaxSteerAngle(mMaxSteerAngle: number): void;
+ mMaxSteerAngle: number;
+ get_mLongitudinalFriction(): LinearCurve;
+ set_mLongitudinalFriction(mLongitudinalFriction: LinearCurve): void;
+ mLongitudinalFriction: LinearCurve;
+ get_mLateralFriction(): LinearCurve;
+ set_mLateralFriction(mLateralFriction: LinearCurve): void;
+ mLateralFriction: LinearCurve;
+ get_mMaxBrakeTorque(): number;
+ set_mMaxBrakeTorque(mMaxBrakeTorque: number): void;
+ mMaxBrakeTorque: number;
+ get_mMaxHandBrakeTorque(): number;
+ set_mMaxHandBrakeTorque(mMaxHandBrakeTorque: number): void;
+ mMaxHandBrakeTorque: number;
+ }
+ class WheelWV extends Wheel {
+ constructor(inWheel: WheelSettingsWV);
+ GetSettings(): WheelSettingsWV;
+ get_mLongitudinalSlip(): number;
+ set_mLongitudinalSlip(mLongitudinalSlip: number): void;
+ mLongitudinalSlip: number;
+ get_mLateralSlip(): number;
+ set_mLateralSlip(mLateralSlip: number): void;
+ mLateralSlip: number;
+ get_mCombinedLongitudinalFriction(): number;
+ set_mCombinedLongitudinalFriction(
+ mCombinedLongitudinalFriction: number
+ ): void;
+ mCombinedLongitudinalFriction: number;
+ get_mCombinedLateralFriction(): number;
+ set_mCombinedLateralFriction(mCombinedLateralFriction: number): void;
+ mCombinedLateralFriction: number;
+ get_mBrakeImpulse(): number;
+ set_mBrakeImpulse(mBrakeImpulse: number): void;
+ mBrakeImpulse: number;
+ }
+ class WheelSettingsTV extends WheelSettings {
+ constructor();
+ get_mLongitudinalFriction(): number;
+ set_mLongitudinalFriction(mLongitudinalFriction: number): void;
+ mLongitudinalFriction: number;
+ get_mLateralFriction(): number;
+ set_mLateralFriction(mLateralFriction: number): void;
+ mLateralFriction: number;
+ }
+ class WheelTV extends Wheel {
+ constructor(inWheel: WheelSettingsTV);
+ GetSettings(): WheelSettingsTV;
+ get_mTrackIndex(): number;
+ set_mTrackIndex(mTrackIndex: number): void;
+ mTrackIndex: number;
+ get_mCombinedLongitudinalFriction(): number;
+ set_mCombinedLongitudinalFriction(
+ mCombinedLongitudinalFriction: number
+ ): void;
+ mCombinedLongitudinalFriction: number;
+ get_mCombinedLateralFriction(): number;
+ set_mCombinedLateralFriction(mCombinedLateralFriction: number): void;
+ mCombinedLateralFriction: number;
+ get_mBrakeImpulse(): number;
+ set_mBrakeImpulse(mBrakeImpulse: number): void;
+ mBrakeImpulse: number;
+ }
+ class VehicleTrackSettings {
+ get_mDrivenWheel(): number;
+ set_mDrivenWheel(mDrivenWheel: number): void;
+ mDrivenWheel: number;
+ get_mWheels(): ArrayUint;
+ set_mWheels(mWheels: ArrayUint): void;
+ mWheels: ArrayUint;
+ get_mInertia(): number;
+ set_mInertia(mInertia: number): void;
+ mInertia: number;
+ get_mAngularDamping(): number;
+ set_mAngularDamping(mAngularDamping: number): void;
+ mAngularDamping: number;
+ get_mMaxBrakeTorque(): number;
+ set_mMaxBrakeTorque(mMaxBrakeTorque: number): void;
+ mMaxBrakeTorque: number;
+ get_mDifferentialRatio(): number;
+ set_mDifferentialRatio(mDifferentialRatio: number): void;
+ mDifferentialRatio: number;
+ }
+ class VehicleTrack extends VehicleTrackSettings {
+ get_mAngularVelocity(): number;
+ set_mAngularVelocity(mAngularVelocity: number): void;
+ mAngularVelocity: number;
+ }
+ class WheeledVehicleControllerSettings extends VehicleControllerSettings {
+ constructor();
+ get_mEngine(): VehicleEngineSettings;
+ set_mEngine(mEngine: VehicleEngineSettings): void;
+ mEngine: VehicleEngineSettings;
+ get_mTransmission(): VehicleTransmissionSettings;
+ set_mTransmission(mTransmission: VehicleTransmissionSettings): void;
+ mTransmission: VehicleTransmissionSettings;
+ get_mDifferentials(): ArrayVehicleDifferentialSettings;
+ set_mDifferentials(mDifferentials: ArrayVehicleDifferentialSettings): void;
+ mDifferentials: ArrayVehicleDifferentialSettings;
+ get_mDifferentialLimitedSlipRatio(): number;
+ set_mDifferentialLimitedSlipRatio(
+ mDifferentialLimitedSlipRatio: number
+ ): void;
+ mDifferentialLimitedSlipRatio: number;
+ }
+ class TrackedVehicleControllerSettings extends VehicleControllerSettings {
+ constructor();
+ get_mEngine(): VehicleEngineSettings;
+ set_mEngine(mEngine: VehicleEngineSettings): void;
+ mEngine: VehicleEngineSettings;
+ get_mTransmission(): VehicleTransmissionSettings;
+ set_mTransmission(mTransmission: VehicleTransmissionSettings): void;
+ mTransmission: VehicleTransmissionSettings;
+ get_mTracks(index: number): VehicleTrackSettings;
+ set_mTracks(index: number, mTracks: VehicleTrackSettings): void;
+ mTracks: VehicleTrackSettings;
+ }
+ class TrackedVehicleController extends VehicleController {
+ constructor(
+ inSettings: TrackedVehicleControllerSettings,
+ inConstraint: VehicleConstraint
+ );
+ SetDriverInput(
+ inForward: number,
+ inLeftRatio: number,
+ inRightRatio: number,
+ inBrake: number
+ ): void;
+ SetForwardInput(inForward: number): void;
+ GetForwardInput(): number;
+ SetLeftRatio(inLeftRatio: number): void;
+ GetLeftRatio(): number;
+ SetRightRatio(inRightRatio: number): void;
+ GetRightRatio(): number;
+ SetBrakeInput(inBrake: number): void;
+ GetBrakeInput(): number;
+ GetEngine(): VehicleEngine;
+ GetTransmission(): VehicleTransmission;
+ GetTracks(): ReadonlyArray;
+ }
+ class VehicleEngineSettings {
+ get_mMaxTorque(): number;
+ set_mMaxTorque(mMaxTorque: number): void;
+ mMaxTorque: number;
+ get_mMinRPM(): number;
+ set_mMinRPM(mMinRPM: number): void;
+ mMinRPM: number;
+ get_mMaxRPM(): number;
+ set_mMaxRPM(mMaxRPM: number): void;
+ mMaxRPM: number;
+ get_mNormalizedTorque(): LinearCurve;
+ set_mNormalizedTorque(mNormalizedTorque: LinearCurve): void;
+ mNormalizedTorque: LinearCurve;
+ get_mInertia(): number;
+ set_mInertia(mInertia: number): void;
+ mInertia: number;
+ get_mAngularDamping(): number;
+ set_mAngularDamping(mAngularDamping: number): void;
+ mAngularDamping: number;
+ }
+ class VehicleEngine extends VehicleEngineSettings {
+ ClampRPM(): void;
+ GetCurrentRPM(): number;
+ SetCurrentRPM(inRPM: number): void;
+ GetAngularVelocity(): number;
+ GetTorque(inAcceleration: number): number;
+ }
+ class VehicleTransmissionSettings {
+ get_mMode(): ETransmissionMode;
+ set_mMode(mMode: ETransmissionMode): void;
+ mMode: ETransmissionMode;
+ get_mGearRatios(): ArrayFloat;
+ set_mGearRatios(mGearRatios: ArrayFloat): void;
+ mGearRatios: ArrayFloat;
+ get_mReverseGearRatios(): ArrayFloat;
+ set_mReverseGearRatios(mReverseGearRatios: ArrayFloat): void;
+ mReverseGearRatios: ArrayFloat;
+ get_mSwitchTime(): number;
+ set_mSwitchTime(mSwitchTime: number): void;
+ mSwitchTime: number;
+ get_mClutchReleaseTime(): number;
+ set_mClutchReleaseTime(mClutchReleaseTime: number): void;
+ mClutchReleaseTime: number;
+ get_mSwitchLatency(): number;
+ set_mSwitchLatency(mSwitchLatency: number): void;
+ mSwitchLatency: number;
+ get_mShiftUpRPM(): number;
+ set_mShiftUpRPM(mShiftUpRPM: number): void;
+ mShiftUpRPM: number;
+ get_mShiftDownRPM(): number;
+ set_mShiftDownRPM(mShiftDownRPM: number): void;
+ mShiftDownRPM: number;
+ get_mClutchStrength(): number;
+ set_mClutchStrength(mClutchStrength: number): void;
+ mClutchStrength: number;
+ }
+ class VehicleTransmission extends VehicleTransmissionSettings {
+ Set(inCurrentGear: number, inClutchFriction: number): void;
+ GetCurrentGear(): number;
+ GetClutchFriction(): number;
+ IsSwitchingGear(): boolean;
+ GetCurrentRatio(): number;
+ }
+ class VehicleDifferentialSettings {
+ constructor();
+ get_mLeftWheel(): number;
+ set_mLeftWheel(mLeftWheel: number): void;
+ mLeftWheel: number;
+ get_mRightWheel(): number;
+ set_mRightWheel(mRightWheel: number): void;
+ mRightWheel: number;
+ get_mDifferentialRatio(): number;
+ set_mDifferentialRatio(mDifferentialRatio: number): void;
+ mDifferentialRatio: number;
+ get_mLeftRightSplit(): number;
+ set_mLeftRightSplit(mLeftRightSplit: number): void;
+ mLeftRightSplit: number;
+ get_mLimitedSlipRatio(): number;
+ set_mLimitedSlipRatio(mLimitedSlipRatio: number): void;
+ mLimitedSlipRatio: number;
+ get_mEngineTorqueRatio(): number;
+ set_mEngineTorqueRatio(mEngineTorqueRatio: number): void;
+ mEngineTorqueRatio: number;
+ }
+ class VehicleControllerSettings {}
+ class VehicleController {
+ GetRefCount(): number;
+ AddRef(): void;
+ Release(): void;
+ }
+ class WheeledVehicleController extends VehicleController {
+ constructor(
+ inSettings: WheeledVehicleControllerSettings,
+ inConstraint: VehicleConstraint
+ );
+ SetDriverInput(
+ inForward: number,
+ inRight: number,
+ inBrake: number,
+ inHandBrake: number
+ ): void;
+ SetForwardInput(inForward: number): void;
+ GetForwardInput(): number;
+ SetRightInput(inRight: number): void;
+ GetRightInput(): number;
+ SetBrakeInput(inBrake: number): void;
+ GetBrakeInput(): number;
+ SetHandBrakeInput(inHandBrake: number): void;
+ GetHandBrakeInput(): number;
+ GetEngine(): VehicleEngine;
+ GetTransmission(): VehicleTransmission;
+ GetDifferentials(): ArrayVehicleDifferentialSettings;
+ GetDifferentialLimitedSlipRatio(): number;
+ SetDifferentialLimitedSlipRatio(inV: number): void;
+ GetWheelSpeedAtClutch(): number;
+ }
+ class MotorcycleControllerSettings extends WheeledVehicleControllerSettings {
+ constructor();
+ get_mMaxLeanAngle(): number;
+ set_mMaxLeanAngle(mMaxLeanAngle: number): void;
+ mMaxLeanAngle: number;
+ get_mLeanSpringConstant(): number;
+ set_mLeanSpringConstant(mLeanSpringConstant: number): void;
+ mLeanSpringConstant: number;
+ get_mLeanSpringDamping(): number;
+ set_mLeanSpringDamping(mLeanSpringDamping: number): void;
+ mLeanSpringDamping: number;
+ get_mLeanSpringIntegrationCoefficient(): number;
+ set_mLeanSpringIntegrationCoefficient(
+ mLeanSpringIntegrationCoefficient: number
+ ): void;
+ mLeanSpringIntegrationCoefficient: number;
+ get_mLeanSpringIntegrationCoefficientDecay(): number;
+ set_mLeanSpringIntegrationCoefficientDecay(
+ mLeanSpringIntegrationCoefficientDecay: number
+ ): void;
+ mLeanSpringIntegrationCoefficientDecay: number;
+ get_mLeanSmoothingFactor(): number;
+ set_mLeanSmoothingFactor(mLeanSmoothingFactor: number): void;
+ mLeanSmoothingFactor: number;
+ }
+ class MotorcycleController extends WheeledVehicleController {
+ constructor(
+ inSettings: MotorcycleControllerSettings,
+ inConstraint: VehicleConstraint
+ );
+ GetWheelBase(): number;
+ EnableLeanController(inEnable: boolean): void;
+ IsLeanControllerEnabled(): boolean;
+ }
+ class Skeleton {
+ constructor();
+ AddJoint(inName: JPHString, inParentIndex: number): number;
+ GetJointCount(): number;
+ AreJointsCorrectlyOrdered(): boolean;
+ CalculateParentJointIndices(): void;
+ }
+ class SkeletalAnimationJointState {
+ FromMatrix(inMatrix: Mat44): void;
+ ToMatrix(): Mat44;
+ get_mTranslation(): Vec3;
+ set_mTranslation(mTranslation: Vec3): void;
+ mTranslation: Vec3;
+ get_mRotation(): Quat;
+ set_mRotation(mRotation: Quat): void;
+ mRotation: Quat;
+ }
+ class SkeletalAnimationKeyframe extends SkeletalAnimationJointState {
+ constructor();
+ get_mTime(): number;
+ set_mTime(mTime: number): void;
+ mTime: number;
+ }
+ class ArraySkeletonKeyframe {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SkeletalAnimationKeyframe;
+ push_back(inValue: SkeletalAnimationKeyframe): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class SkeletalAnimationAnimatedJoint {
+ constructor();
+ get_mJointName(): JPHString;
+ set_mJointName(mJointName: JPHString): void;
+ mJointName: JPHString;
+ get_mKeyframes(): ArraySkeletonKeyframe;
+ set_mKeyframes(mKeyframes: ArraySkeletonKeyframe): void;
+ mKeyframes: ArraySkeletonKeyframe;
+ }
+ class ArraySkeletonAnimatedJoint {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): SkeletalAnimationAnimatedJoint;
+ push_back(inValue: SkeletalAnimationAnimatedJoint): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class SkeletalAnimation {
+ constructor();
+ GetDuration(): number;
+ ScaleJoints(inScale: number): void;
+ Sample(inTime: number, ioPose: SkeletonPose): void;
+ GetAnimatedJoints(): ArraySkeletonAnimatedJoint;
+ }
+ class SkeletonPose {
+ constructor();
+ SetSkeleton(inSkeleton: Skeleton): void;
+ GetSkeleton(): Skeleton;
+ SetRootOffset(inOffset: RVec3): void;
+ GetRootOffset(): RVec3;
+ GetJointCount(): number;
+ GetJoint(inJoint: number): SkeletalAnimationJointState;
+ GetJointMatrices(): ArrayMat44;
+ GetJointMatrix(inJoint: number): Mat44;
+ CalculateJointMatrices(): void;
+ CalculateJointStates(): void;
+ }
+ class RagdollPart extends BodyCreationSettings {
+ get_mToParent(): TwoBodyConstraintSettings;
+ set_mToParent(mToParent: TwoBodyConstraintSettings): void;
+ mToParent: TwoBodyConstraintSettings;
+ }
+ class ArrayRagdollPart {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): RagdollPart;
+ push_back(inValue: RagdollPart): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class RagdollAdditionalConstraint {
+ get_mBodyIdx(index: number): number;
+ set_mBodyIdx(index: number, mBodyIdx: number): void;
+ mBodyIdx: number;
+ get_mConstraint(): TwoBodyConstraintSettings;
+ set_mConstraint(mConstraint: TwoBodyConstraintSettings): void;
+ mConstraint: TwoBodyConstraintSettings;
+ }
+ class ArrayRagdollAdditionalConstraint {
+ constructor();
+ empty(): boolean;
+ size(): number;
+ at(inIndex: number): RagdollAdditionalConstraint;
+ push_back(inValue: RagdollAdditionalConstraint): void;
+ reserve(inSize: number): void;
+ resize(inSize: number): void;
+ clear(): void;
+ }
+ class RagdollSettings {
+ constructor();
+ Stabilize(): boolean;
+ CreateRagdoll(
+ inCollisionGroup: number,
+ inUserData: number,
+ inSystem: PhysicsSystem
+ ): Ragdoll;
+ GetSkeleton(): Skeleton;
+ DisableParentChildCollisions(
+ inJointMatrices?: Mat44MemRef,
+ inMinSeparationDistance?: number
+ ): void;
+ CalculateBodyIndexToConstraintIndex(): void;
+ CalculateConstraintIndexToBodyIdxPair(): void;
+ get_mSkeleton(): Skeleton;
+ set_mSkeleton(mSkeleton: Skeleton): void;
+ mSkeleton: Skeleton;
+ get_mParts(): ArrayRagdollPart;
+ set_mParts(mParts: ArrayRagdollPart): void;
+ mParts: ArrayRagdollPart;
+ get_mAdditionalConstraints(): ArrayRagdollAdditionalConstraint;
+ set_mAdditionalConstraints(
+ mAdditionalConstraints: ArrayRagdollAdditionalConstraint
+ ): void;
+ mAdditionalConstraints: ArrayRagdollAdditionalConstraint;
+ }
+ class Ragdoll {
+ constructor(inSystem: PhysicsSystem);
+ AddToPhysicsSystem(
+ inActivationMode: EActivation,
+ inLockBodies?: boolean
+ ): void;
+ RemoveFromPhysicsSystem(inLockBodies?: boolean): void;
+ Activate(inLockBodies?: boolean): void;
+ IsActive(inLockBodies?: boolean): boolean;
+ SetGroupID(inGroupID: number, inLockBodies?: boolean): void;
+ SetPose(inPose: SkeletonPose, inLockBodies?: boolean): void;
+ GetPose(outPose: SkeletonPose, inLockBodies?: boolean): void;
+ ResetWarmStart(): void;
+ DriveToPoseUsingKinematics(
+ inPose: SkeletonPose,
+ inDeltaTime: number,
+ inLockBodies?: boolean
+ ): void;
+ DriveToPoseUsingMotors(inPose: SkeletonPose): void;
+ SetLinearAndAngularVelocity(
+ inLinearVelocity: Vec3,
+ inAngularVelocity: Vec3,
+ inLockBodies?: boolean
+ ): void;
+ SetLinearVelocity(inLinearVelocity: Vec3, inLockBodies?: boolean): void;
+ AddLinearVelocity(inLinearVelocity: Vec3, inLockBodies?: boolean): void;
+ AddImpulse(inImpulse: Vec3, inLockBodies?: boolean): void;
+ GetRootTransform(
+ outPosition: RVec3,
+ outRotation: Quat,
+ inLockBodies?: boolean
+ ): void;
+ GetBodyCount(): number;
+ GetBodyID(inBodyIndex: number): BodyID;
+ GetBodyIDs(): BodyIDVector;
+ GetConstraintCount(): number;
+ GetWorldSpaceBounds(inLockBodies?: boolean): AABox;
+ GetConstraint(inConstraintIndex: number): TwoBodyConstraint;
+ GetRagdollSettings(): RagdollSettings;
+ }
+ class BroadPhaseLayerInterface {
+ GetNumBroadPhaseLayers(): number;
+ }
+ class BroadPhaseLayer {
+ constructor(inLayer: number);
+ GetValue(): number;
+ }
+ class BroadPhaseLayerInterfaceEm extends BroadPhaseLayerInterface {}
+ class BroadPhaseLayerInterfaceJS extends BroadPhaseLayerInterfaceEm {
+ constructor();
+ GetNumBroadPhaseLayers(): number;
+ GetBPLayer(inLayer: number): number;
+ }
+ class BroadPhaseLayerInterfaceTable extends BroadPhaseLayerInterface {
+ constructor(inNumObjectLayers: number, inNumBroadPhaseLayers: number);
+ MapObjectToBroadPhaseLayer(
+ inObjectLayer: number,
+ inBroadPhaseLayer: BroadPhaseLayer
+ ): void;
+ }
+ class ObjectVsBroadPhaseLayerFilterTable extends ObjectVsBroadPhaseLayerFilter {
+ constructor(
+ inBroadPhaseLayerInterface: BroadPhaseLayerInterface,
+ inNumBroadPhaseLayers: number,
+ inObjectLayerPairFilter: ObjectLayerPairFilter,
+ inNumObjectLayers: number
+ );
+ }
+ class ObjectLayerPairFilterTable extends ObjectLayerPairFilter {
+ constructor(inNumObjectLayers: number);
+ GetNumObjectLayers(): number;
+ DisableCollision(inLayer1: number, inLayer2: number): void;
+ EnableCollision(inLayer1: number, inLayer2: number): void;
+ }
+ class BroadPhaseLayerInterfaceMask extends BroadPhaseLayerInterface {
+ constructor(inNumBroadPhaseLayers: number);
+ ConfigureLayer(
+ inBroadPhaseLayer: BroadPhaseLayer,
+ inGroupsToInclude: number,
+ inGroupsToExclude: number
+ ): void;
+ }
+ class ObjectVsBroadPhaseLayerFilterMask extends ObjectVsBroadPhaseLayerFilter {
+ constructor(inBroadPhaseLayerInterface: BroadPhaseLayerInterfaceMask);
+ }
+ class ObjectLayerPairFilterMask extends ObjectLayerPairFilter {
+ constructor();
+ sGetObjectLayer(inGroup: number, inMask: number): number;
+ sGetGroup(inObjectLayer: number): number;
+ sGetMask(inObjectLayer: number): number;
+ }
+ class JoltSettings {
+ constructor();
+ get_mMaxBodies(): number;
+ set_mMaxBodies(mMaxBodies: number): void;
+ mMaxBodies: number;
+ get_mMaxBodyPairs(): number;
+ set_mMaxBodyPairs(mMaxBodyPairs: number): void;
+ mMaxBodyPairs: number;
+ get_mMaxContactConstraints(): number;
+ set_mMaxContactConstraints(mMaxContactConstraints: number): void;
+ mMaxContactConstraints: number;
+ get_mBroadPhaseLayerInterface(): BroadPhaseLayerInterface;
+ set_mBroadPhaseLayerInterface(
+ mBroadPhaseLayerInterface: BroadPhaseLayerInterface
+ ): void;
+ mBroadPhaseLayerInterface: BroadPhaseLayerInterface;
+ get_mObjectVsBroadPhaseLayerFilter(): ObjectVsBroadPhaseLayerFilter;
+ set_mObjectVsBroadPhaseLayerFilter(
+ mObjectVsBroadPhaseLayerFilter: ObjectVsBroadPhaseLayerFilter
+ ): void;
+ mObjectVsBroadPhaseLayerFilter: ObjectVsBroadPhaseLayerFilter;
+ get_mObjectLayerPairFilter(): ObjectLayerPairFilter;
+ set_mObjectLayerPairFilter(
+ mObjectLayerPairFilter: ObjectLayerPairFilter
+ ): void;
+ mObjectLayerPairFilter: ObjectLayerPairFilter;
+ }
+ class JoltInterface {
+ constructor(inSettings: JoltSettings);
+ Step(inDeltaTime: number, inCollisionSteps: number): void;
+ GetPhysicsSystem(): PhysicsSystem;
+ GetTempAllocator(): TempAllocator;
+ GetObjectLayerPairFilter(): ObjectLayerPairFilter;
+ GetObjectVsBroadPhaseLayerFilter(): ObjectVsBroadPhaseLayerFilter;
+ sGetTotalMemory(): number;
+ sGetFreeMemory(): number;
+ }
+}
diff --git a/Extensions/Physics3DBehavior/tests/Physics3DRuntimeBehavior.spec.js b/Extensions/Physics3DBehavior/tests/Physics3DRuntimeBehavior.spec.js
new file mode 100644
index 000000000000..60455eb894e8
--- /dev/null
+++ b/Extensions/Physics3DBehavior/tests/Physics3DRuntimeBehavior.spec.js
@@ -0,0 +1 @@
+describe('Physics3DRuntimeBehavior', () => {});
diff --git a/Extensions/PlatformBehavior/platformerobjectruntimebehavior.ts b/Extensions/PlatformBehavior/platformerobjectruntimebehavior.ts
index abd576e40802..9a2407ae2277 100644
--- a/Extensions/PlatformBehavior/platformerobjectruntimebehavior.ts
+++ b/Extensions/PlatformBehavior/platformerobjectruntimebehavior.ts
@@ -231,9 +231,13 @@ namespace gdjs {
...super.getNetworkSyncData(),
props: {
cs: this._currentSpeed,
+
+ // TODO Try to remove these 3 fields from the synch
+ // They are reset every frame and are not part of the state.
rdx: this._requestedDeltaX,
rdy: this._requestedDeltaY,
ldy: this._lastDeltaY,
+
cfs: this._currentFallSpeed,
cj: this._canJump,
ldl: this._lastDirectionIsLeft,
diff --git a/GDJS/Runtime/index.html b/GDJS/Runtime/index.html
index 01a50212924d..90da4ef870ed 100644
--- a/GDJS/Runtime/index.html
+++ b/GDJS/Runtime/index.html
@@ -30,7 +30,12 @@
-
+