gdcore-tools 2.0.0-gd-v5.4.218-autobuild → 2.0.0-gd-v5.4.219-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
- package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
- package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
- package/dist/Runtime/RuntimeLayer.js +1 -1
- package/dist/Runtime/RuntimeLayer.js.map +2 -2
- package/dist/Runtime/layer.js +1 -1
- package/dist/Runtime/layer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/types/global-types.d.ts +20 -3
- package/dist/Runtime/types/project-data.d.ts +1 -1
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +13 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(r){class
|
|
1
|
+
var gdjs;(function(r){class n extends r.CustomRuntimeObject{constructor(t,i){super(t,i);this._z=0;this._minZ=0;this._maxZ=0;this._scaleZ=1;this._flippedZ=!1;this._rotationX=0;this._rotationY=0;this._customCenterZ=0;this._renderer.reinitialize(this,t)}_createRender(){const t=this._runtimeScene;return new r.CustomRuntimeObject3DRenderer(this,this._instanceContainer,t)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}get3DRendererObject(){return this.getRenderer().get3DRendererObject()}extraInitializationFromInitialInstance(t){super.extraInitializationFromInitialInstance(t),t.depth!==void 0&&this.setDepth(t.depth),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY),t.flippedZ&&this.flipZ(t.flippedZ)}setZ(t){t!==this._z&&(this._z=t,this.getRenderer().updatePosition())}getZ(){return this._z}getDrawableZ(){let t=0;this._innerArea?t=this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._minZ);const i=this.getScaleZ();return this._flippedZ?this._z+(-t-this.getUnscaledDepth()+2*this.getUnscaledCenterZ())*i:this._z+t*i}getCenterZ(){return this.getDepth()/2}getCenterZInScene(){return this.getDrawableZ()+this.getCenterZ()}setCenterZInScene(t){this.setZ(t+this._z-(this.getDrawableZ()+this.getCenterZ()))}getUnrotatedAABBMinZ(){return this.getDrawableZ()}getUnrotatedAABBMaxZ(){return this.getDrawableZ()+this.getDepth()}setRotationX(t){this._rotationX=t,this.getRenderer().updateRotation()}setRotationY(t){this._rotationY=t,this.getRenderer().updateRotation()}getRotationX(){return this._rotationX}getRotationY(){return this._rotationY}turnAroundX(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(1,0,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundY(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,1,0);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}turnAroundZ(t){const i=r.CustomRuntimeObject3D._temporaryVector;i.set(0,0,1);const e=this.get3DRendererObject();e.rotateOnWorldAxis(i,r.toRad(t)),this._rotationX=r.toDegrees(e.rotation.x),this._rotationY=r.toDegrees(e.rotation.y),this.setAngle(r.toDegrees(e.rotation.z))}getInnerAreaMinZ(){return this._innerArea?this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._minZ)}getInnerAreaMaxZ(){return this._innerArea?this._innerArea.max[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ)}getUnscaledDepth(){return this._innerArea?this._innerArea.max[2]-this._innerArea.min[2]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._maxZ-this._minZ)}_updateUntransformedHitBoxes(){super._updateUntransformedHitBoxes();let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(const e of this._instanceContainer.getAdhocListOfAllInstances())!e.isIncludedInParentCollisionMask()||!r.Base3DHandler.is3D(e)||(t=Math.min(t,e.getUnrotatedAABBMinZ()),i=Math.max(i,e.getUnrotatedAABBMaxZ()));t===Number.MAX_VALUE&&(t=0,i=1),this._minZ=t,this._maxZ=i}getUnscaledCenterZ(){return this.hasCustomRotationCenter()?this._customCenterZ:this._innerArea?(this._innerArea.min[2]+this._innerArea.max[2])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._minZ+this._maxZ)/2)}setRotationCenter3D(t,i,e){this._customCenterZ=e,this.setRotationCenter(t,i)}getDepth(){return this.getUnscaledDepth()*this.getScaleZ()}setDepth(t){const i=this.getUnscaledDepth();if(i===0)return;const e=t/i;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[2]*=e,this._innerArea.max[2]*=e):this.setScaleZ(e)}setScale(t){super.setScale(t),this.setScaleZ(t)}setScaleZ(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleZ)&&(this._scaleZ=t*(this._flippedZ?-1:1),this.getRenderer().updateSize()))}getScale(){const t=this.getScaleX(),i=this.getScaleY(),e=this.getScaleZ();return t===i&&t===e?t:Math.pow(t*i*e,1/3)}getScaleZ(){return Math.abs(this._scaleZ)}flipZ(t){t!==this._flippedZ&&(this._flippedZ=t,this.getRenderer().updateSize())}isFlippedZ(){return this._flippedZ}}n._temporaryVector=new THREE.Vector3,r.CustomRuntimeObject3D=n})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=CustomRuntimeObject3D.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/3D/CustomRuntimeObject3D.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._z + this._minZ;\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAeS,eACG,GAAK,mBACiB,CAwB9B,YACE,EACA,EACA,CACA,MAAM,EAAQ,GAxBR,QAAY,EACZ,WAAe,EACf,WAAe,EACf,aAAiB,EACjB,eAAqB,GAMrB,gBAAoB,EAMpB,gBAAoB,EACpB,oBAAwB,EAQ9B,KAAK,UAAU,aAAa,KAAM,GAG1B,eAAgB,CACxB,KAAM,GAAS,KAAK,cACpB,MAAO,IAAI,GAAK,8BACd,KACA,KAAK,mBACL,GAIM,uBAA8B,CACtC,KAAK,cAAc,aAAa,KAAM,KAAK,aAG7C,aAAkD,CAChD,MAAO,OAAM,cAGf,qBAAsB,CAGpB,MAAO,MAAK,cAAc,sBAG5B,uCAAuC,EAAmC,CACxE,MAAM,uCAAuC,GACzC,EAAoB,QAAU,QAChC,KAAK,SAAS,EAAoB,OAEhC,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAE7B,EAAoB,UACtB,KAAK,MAAM,EAAoB,UAOnC,KAAK,EAAgB,CACnB,AAAI,IAAM,KAAK,IACf,MAAK,GAAK,EACV,KAAK,cAAc,kBAMrB,MAAc,CACZ,MAAO,MAAK,GAYd,cAAsB,CACpB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n export interface Object3DDataContent {\n width: float;\n height: float;\n depth: float;\n }\n /** Base parameters for {@link gdjs.RuntimeObject3D} */\n export interface Object3DData extends ObjectData {\n /** The base parameters of the RuntimeObject3D */\n content: Object3DDataContent;\n }\n\n /**\n * Base class for 3D custom objects.\n */\n export class CustomRuntimeObject3D\n extends gdjs.CustomRuntimeObject\n implements gdjs.Base3DHandler {\n /**\n * Position on the Z axis.\n */\n private _z: float = 0;\n private _minZ: float = 0;\n private _maxZ: float = 0;\n private _scaleZ: float = 1;\n private _flippedZ: boolean = false;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationX: float = 0;\n /**\n * Euler angle with the `ZYX` order.\n *\n * Note that `_rotationZ` is `angle` from `gdjs.RuntimeObject`.\n */\n private _rotationY: float = 0;\n private _customCenterZ: float = 0;\n private static _temporaryVector = new THREE.Vector3();\n\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: Object3DData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._renderer.reinitialize(this, parent);\n }\n\n protected _createRender() {\n const parent = this._runtimeScene;\n return new gdjs.CustomRuntimeObject3DRenderer(\n this,\n this._instanceContainer,\n parent\n );\n }\n\n protected _reinitializeRenderer(): void {\n this.getRenderer().reinitialize(this, this.getParent());\n }\n\n getRenderer(): gdjs.CustomRuntimeObject3DRenderer {\n return super.getRenderer() as gdjs.CustomRuntimeObject3DRenderer;\n }\n\n get3DRendererObject() {\n // It can't be null because Three.js is always loaded\n // when a custom 3D object is used.\n return this.getRenderer().get3DRendererObject()!;\n }\n\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n super.extraInitializationFromInitialInstance(initialInstanceData);\n if (initialInstanceData.depth !== undefined) {\n this.setDepth(initialInstanceData.depth);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n if (initialInstanceData.flippedZ) {\n this.flipZ(initialInstanceData.flippedZ);\n }\n }\n\n /**\n * Set the object position on the Z axis.\n */\n setZ(z: float): void {\n if (z === this._z) return;\n this._z = z;\n this.getRenderer().updatePosition();\n }\n\n /**\n * Get the object position on the Z axis.\n */\n getZ(): float {\n return this._z;\n }\n\n /**\n * Get the Z position of the rendered object.\n *\n * For most objects, this will returns the same value as getZ(). But if the\n * object has an origin that is not the same as the point (0,0,0) of the\n * object displayed, getDrawableZ will differ.\n *\n * @return The Z position of the rendered object.\n */\n getDrawableZ(): float {\n let minZ = 0;\n if (this._innerArea) {\n minZ = this._innerArea.min[2];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minZ = this._minZ;\n }\n const absScaleZ = this.getScaleZ();\n if (!this._flippedZ) {\n return this._z + minZ * absScaleZ;\n } else {\n return (\n this._z +\n (-minZ - this.getUnscaledDepth() + 2 * this.getUnscaledCenterZ()) *\n absScaleZ\n );\n }\n }\n\n /**\n * Return the Z position of the object center, **relative to the object Z\n * position** (`getDrawableX`).\n *\n * Use `getCenterZInScene` to get the position of the center in the scene.\n *\n * @return the Z position of the object center, relative to\n * `getDrawableZ()`.\n */\n getCenterZ(): float {\n return this.getDepth() / 2;\n }\n\n getCenterZInScene(): float {\n return this.getDrawableZ() + this.getCenterZ();\n }\n\n setCenterZInScene(z: float): void {\n this.setZ(z + this._z - (this.getDrawableZ() + this.getCenterZ()));\n }\n\n /**\n * Return the bottom Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMinZ(): number {\n return this.getDrawableZ();\n }\n\n /**\n * Return the top Z of the object.\n * Rotations around X and Y are not taken into account.\n */\n getUnrotatedAABBMaxZ(): number {\n return this.getDrawableZ() + this.getDepth();\n }\n\n /**\n * Set the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationX(angle: float): void {\n this._rotationX = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Set the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n setRotationY(angle: float): void {\n this._rotationY = angle;\n this.getRenderer().updateRotation();\n }\n\n /**\n * Get the object rotation on the X axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationX(): float {\n return this._rotationX;\n }\n\n /**\n * Get the object rotation on the Y axis.\n *\n * This is an Euler angle. Objects use the `ZYX` order.\n */\n getRotationY(): float {\n return this._rotationY;\n }\n\n /**\n * Turn the object around the scene x axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundX(deltaAngle: float): void {\n const axisX = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisX.set(1, 0, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisX, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene y axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundY(deltaAngle: float): void {\n const axisY = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisY.set(0, 1, 0);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisY, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * Turn the object around the scene z axis at its center.\n * @param deltaAngle the rotation angle\n */\n turnAroundZ(deltaAngle: float): void {\n const axisZ = gdjs.CustomRuntimeObject3D._temporaryVector;\n axisZ.set(0, 0, 1);\n\n const mesh = this.get3DRendererObject();\n mesh.rotateOnWorldAxis(axisZ, gdjs.toRad(deltaAngle));\n this._rotationX = gdjs.toDegrees(mesh.rotation.x);\n this._rotationY = gdjs.toDegrees(mesh.rotation.y);\n this.setAngle(gdjs.toDegrees(mesh.rotation.z));\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinZ(): number {\n if (this._innerArea) {\n return this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._minZ;\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxZ(): number {\n if (this._innerArea) {\n return this._innerArea.max[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ;\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledDepth(): float {\n if (this._innerArea) {\n return this._innerArea.max[2] - this._innerArea.min[2];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._maxZ - this._minZ;\n }\n\n _updateUntransformedHitBoxes(): void {\n super._updateUntransformedHitBoxes();\n\n let minZ = Number.MAX_VALUE;\n let maxZ = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n if (!gdjs.Base3DHandler.is3D(childInstance)) {\n continue;\n }\n minZ = Math.min(minZ, childInstance.getUnrotatedAABBMinZ());\n maxZ = Math.max(maxZ, childInstance.getUnrotatedAABBMaxZ());\n }\n if (minZ === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minZ = 0;\n maxZ = 1;\n }\n this._minZ = minZ;\n this._maxZ = maxZ;\n }\n\n /**\n * @returns the center Z from the local origin (0;0).\n */\n getUnscaledCenterZ(): float {\n if (this.hasCustomRotationCenter()) {\n return this._customCenterZ;\n }\n if (this._innerArea) {\n return (this._innerArea.min[2] + this._innerArea.max[2]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._minZ + this._maxZ) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter3D(x: float, y: float, z: float) {\n this._customCenterZ = z;\n this.setRotationCenter(x, y);\n }\n\n /**\n * Get the object size on the Z axis (called \"depth\").\n */\n getDepth(): float {\n return this.getUnscaledDepth() * this.getScaleZ();\n }\n\n /**\n * Set the object size on the Z axis (called \"depth\").\n */\n setDepth(depth: float): void {\n const unscaledDepth = this.getUnscaledDepth();\n if (unscaledDepth === 0) {\n return;\n }\n const scaleZ = depth / unscaledDepth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[2] *= scaleZ;\n this._innerArea.max[2] *= scaleZ;\n } else {\n this.setScaleZ(scaleZ);\n }\n }\n\n /**\n * Change the scale on X, Y and Z axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: number): void {\n super.setScale(newScale);\n this.setScaleZ(newScale);\n }\n\n /**\n * Change the scale on Z axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleZ(newScale: number): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleZ)) {\n return;\n }\n this._scaleZ = newScale * (this._flippedZ ? -1 : 1);\n this.getRenderer().updateSize();\n }\n\n /**\n * Get the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n *\n * @return the scale of the object (or the geometric average of X, Y and Z scale in case they are different).\n */\n getScale(): number {\n const scaleX = this.getScaleX();\n const scaleY = this.getScaleY();\n const scaleZ = this.getScaleZ();\n return scaleX === scaleY && scaleX === scaleZ\n ? scaleX\n : Math.pow(scaleX * scaleY * scaleZ, 1 / 3);\n }\n\n /**\n * Get the scale of the object on Z axis.\n *\n * @return the scale of the object on Z axis\n */\n getScaleZ(): float {\n return Math.abs(this._scaleZ);\n }\n\n flipZ(enable: boolean) {\n if (enable === this._flippedZ) {\n return;\n }\n this._flippedZ = enable;\n this.getRenderer().updateSize();\n }\n\n isFlippedZ(): boolean {\n return this._flippedZ;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(E){let o;(function(t){t[t.None=0]="None",t[t.WindowLeft=1]="WindowLeft",t[t.WindowRight=2]="WindowRight",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(o||(o={}));let n;(function(t){t[t.None=0]="None",t[t.WindowTop=1]="WindowTop",t[t.WindowBottom=2]="WindowBottom",t[t.Proportional=3]="Proportional",t[t.WindowCenter=4]="WindowCenter"})(n||(n={}));class R extends E.RuntimeBehavior{constructor(e,i,s){super(e,i,s);this._invalidDistances=!0;this._leftEdgeDistance=0;this._rightEdgeDistance=0;this._topEdgeDistance=0;this._bottomEdgeDistance=0;this._useLegacyBottomAndRightAnchors=!1;this._relativeToOriginalWindowSize=!!i.relativeToOriginalWindowSize,this._leftEdgeAnchor=i.leftEdgeAnchor,this._rightEdgeAnchor=i.rightEdgeAnchor,this._topEdgeAnchor=i.topEdgeAnchor,this._bottomEdgeAnchor=i.bottomEdgeAnchor,this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors===void 0?!0:i.useLegacyBottomAndRightAnchors}updateFromBehaviorData(e,i){return e.leftEdgeAnchor!==i.leftEdgeAnchor&&(this._leftEdgeAnchor=i.leftEdgeAnchor),e.rightEdgeAnchor!==i.rightEdgeAnchor&&(this._rightEdgeAnchor=i.rightEdgeAnchor),e.topEdgeAnchor!==i.topEdgeAnchor&&(this._topEdgeAnchor=i.topEdgeAnchor),e.bottomEdgeAnchor!==i.bottomEdgeAnchor&&(this._bottomEdgeAnchor=i.bottomEdgeAnchor),e.useLegacyTrajectory!==i.useLegacyTrajectory&&(this._useLegacyBottomAndRightAnchors=i.useLegacyBottomAndRightAnchors),e.relativeToOriginalWindowSize===i.relativeToOriginalWindowSize}onActivate(){this._invalidDistances=!0}doStepPreEvents(e){const i=E.staticArray(E.AnchorRuntimeBehavior.prototype.doStepPreEvents);let s=e.getUnrotatedViewportMinX(),h=e.getUnrotatedViewportMinY(),t=e.getUnrotatedViewportMaxX(),d=e.getUnrotatedViewportMaxY(),_=(t+s)/2,w=(d+h)/2,f=t-s,a=d-h;const b=e.getLayer(this.owner.getLayer());if(this._invalidDistances){this._relativeToOriginalWindowSize&&(s=e.getInitialUnrotatedViewportMinX(),h=e.getInitialUnrotatedViewportMinY(),t=e.getInitialUnrotatedViewportMaxX(),d=e.getInitialUnrotatedViewportMaxY(),_=(t+s)/2,w=(d+h)/2,f=t-s,a=d-h);const r=this._relativeToOriginalWindowSize?[this.owner.getDrawableX(),this.owner.getDrawableY()]:this._convertInverseCoords(e,b,this.owner.getDrawableX(),this.owner.getDrawableY(),i);this._leftEdgeAnchor===1?this._leftEdgeDistance=r[0]-s:this._leftEdgeAnchor===2?this._leftEdgeDistance=r[0]-t:this._leftEdgeAnchor===3?this._leftEdgeDistance=(r[0]-s)/f:this._leftEdgeAnchor===4&&(this._leftEdgeDistance=r[0]-_),this._topEdgeAnchor===1?this._topEdgeDistance=r[1]-h:this._topEdgeAnchor===2?this._topEdgeDistance=r[1]-d:this._topEdgeAnchor===3?this._topEdgeDistance=(r[1]-h)/a:this._topEdgeAnchor===4&&(this._topEdgeDistance=r[1]-w);const g=this._relativeToOriginalWindowSize?[this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight()]:this._convertInverseCoords(e,b,this.owner.getDrawableX()+this.owner.getWidth(),this.owner.getDrawableY()+this.owner.getHeight(),i);this._rightEdgeAnchor===1?this._rightEdgeDistance=g[0]-s:this._rightEdgeAnchor===2?this._rightEdgeDistance=g[0]-t:this._rightEdgeAnchor===3?this._rightEdgeDistance=(g[0]-s)/f:this._rightEdgeAnchor===4&&(this._rightEdgeDistance=g[0]-_),this._bottomEdgeAnchor===1?this._bottomEdgeDistance=g[1]-h:this._bottomEdgeAnchor===2?this._bottomEdgeDistance=g[1]-d:this._bottomEdgeAnchor===3?this._bottomEdgeDistance=(g[1]-h)/a:this._bottomEdgeAnchor===4&&(this._bottomEdgeDistance=g[1]-w),this._invalidDistances=!1}else{let r=0,g=0,A=0,p=0;this._leftEdgeAnchor===1?r=s+this._leftEdgeDistance:this._leftEdgeAnchor===2?r=t+this._leftEdgeDistance:this._leftEdgeAnchor===3?r=s+this._leftEdgeDistance*f:this._leftEdgeAnchor===4&&(r=_+this._leftEdgeDistance),this._topEdgeAnchor===1?g=h+this._topEdgeDistance:this._topEdgeAnchor===2?g=d+this._topEdgeDistance:this._topEdgeAnchor===3?g=h+this._topEdgeDistance*a:this._topEdgeAnchor===4&&(g=w+this._topEdgeDistance),this._rightEdgeAnchor===1?A=s+this._rightEdgeDistance:this._rightEdgeAnchor===2?A=t+this._rightEdgeDistance:this._rightEdgeAnchor===3?A=s+this._rightEdgeDistance*f:this._rightEdgeAnchor===4&&(A=_+this._rightEdgeDistance),this._bottomEdgeAnchor===1?p=h+this._bottomEdgeDistance:this._bottomEdgeAnchor===2?p=d+this._bottomEdgeDistance:this._bottomEdgeAnchor===3?p=h+this._bottomEdgeDistance*a:this._bottomEdgeAnchor===4&&(p=w+this._bottomEdgeDistance);const D=this._convertCoords(e,b,r,g,i);let c=D[0],l=D[1];const P=this._convertCoords(e,b,A,p,i),W=P[0],u=P[1];if(this._useLegacyBottomAndRightAnchors)this._rightEdgeAnchor!==0&&this.owner.setWidth(W-c),this._bottomEdgeAnchor!==0&&this.owner.setHeight(u-l),this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._topEdgeAnchor!==0&&this.owner.setY(l+this.owner.getY()-this.owner.getDrawableY());else{if(this._rightEdgeAnchor!==0&&this._leftEdgeAnchor!==0){const m=W-c;this.owner.setX(this.owner.getX()===this.owner.getDrawableX()?c:c+(this.owner.getX()-this.owner.getDrawableX())*m/this.owner.getWidth()),this.owner.setWidth(m)}else this._leftEdgeAnchor!==0&&this.owner.setX(c+this.owner.getX()-this.owner.getDrawableX()),this._rightEdgeAnchor!==0&&this.owner.setX(W+this.owner.getX()-this.owner.getDrawableX()-this.owner.getWidth());if(this._bottomEdgeAnchor!==0&&this._topEdgeAnchor!==0){const m=u-l;this.owner.setY(this.owner.getY()===this.owner.getDrawableY()?l:l+(this.owner.getY()-this.owner.getDrawableY())*m/this.owner.getHeight()),this.owner.setHeight(m)}else this._topEdgeAnchor!==0&&this.owner.setY(l+this.owner.getY()-this.owner.getDrawableY()),this._bottomEdgeAnchor!==0&&this.owner.setY(u+this.owner.getY()-this.owner.getDrawableY()-this.owner.getHeight())}}}doStepPostEvents(e){}_convertCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertCoords(s,h,0,t)}_convertInverseCoords(e,i,s,h,t){return e!==e.getScene()?(t[0]=s,t[1]=h,t):i.convertInverseCoords(s,h,0,t)}}E.AnchorRuntimeBehavior=R,E.registerBehavior("AnchorBehavior::AnchorBehavior",E.AnchorRuntimeBehavior)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=anchorruntimebehavior.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/AnchorBehavior/anchorruntimebehavior.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n _relativeToOriginalWindowSize: any;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: any;\n _bottomEdgeAnchor: any;\n _invalidDistances: boolean = true;\n _leftEdgeDistance: number = 0;\n _rightEdgeDistance: number = 0;\n _topEdgeDistance: number = 0;\n _bottomEdgeDistance: number = 0;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize = !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n onActivate() {\n this._invalidDistances = true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n let parentCenterX = (parentMaxX + parentMinX) / 2;\n let parentCenterY = (parentMaxY + parentMinY) / 2;\n let parentWidth = parentMaxX - parentMinX;\n let parentHeight = parentMaxY - parentMinY;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n if (this._invalidDistances) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n parentCenterX = (parentMaxX + parentMinX) / 2;\n parentCenterY = (parentMaxY + parentMinY) / 2;\n parentWidth = parentMaxX - parentMinX;\n parentHeight = parentMaxY - parentMinY;\n }\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._convertCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._convertCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._invalidDistances = false;\n } else {\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertInverseCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n const left = topLeftCoord[0];\n const top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertInverseCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n }\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,+BACA,iCACA,mCACA,qCALS,WAOX,GAAW,GAAX,UAAW,EAAX,CACE,SAAO,GAAP,OACA,6BACA,mCACA,mCACA,qCALS,WAQJ,eAAoC,GAAK,eAAgB,CAa9D,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAZzC,uBAA6B,GAC7B,uBAA4B,EAC5B,wBAA6B,EAC7B,sBAA2B,EAC3B,yBAA8B,EAC9B,qCAA2C,GAQzC,KAAK,8BAAgC,CAAC,CAAC,EAAa,6BACpD,KAAK,gBAAkB,EAAa,eACpC,KAAK,iBAAmB,EAAa,gBACrC,KAAK,eAAiB,EAAa,cACnC,KAAK,kBAAoB,EAAa,iBACtC,KAAK,gCACH,EAAa,iCAAmC,OAC5C,GACA,EAAa,+BAGrB,uBAAuB,EAAiB,EAA0B,CAsBhE,MArBI,GAAgB,iBAAmB,EAAgB,gBACrD,MAAK,gBAAkB,EAAgB,gBAErC,EAAgB,kBAAoB,EAAgB,iBACtD,MAAK,iBAAmB,EAAgB,iBAEtC,EAAgB,gBAAkB,EAAgB,eACpD,MAAK,eAAiB,EAAgB,eAGtC,EAAgB,mBAAqB,EAAgB,kBAErD,MAAK,kBAAoB,EAAgB,kBAGzC,EAAgB,sBAChB,EAAgB,qBAEhB,MAAK,gCACH,EAAgB,gCAGlB,EAAgB,+BAChB,EAAgB,6BAOpB,YAAa,CACX,KAAK,kBAAoB,GAG3B,gBAAgB,EAAkD,CAChE,KAAM,GAA2B,EAAK,YACpC,EAAK,sBAAsB,UAAU,iBAEvC,GAAI,GAAa,EAAkB,2BAC/B,EAAa,EAAkB,2BAC/B,EAAa,EAAkB,2BAC/B,EAAa,EAAkB,2BAC/B,EAAiB,GAAa,GAAc,EAC5C,EAAiB,GAAa,GAAc,EAC5C,EAAc,EAAa,EAC3B,EAAe,EAAa,EAChC,KAAM,GAAQ,EAAkB,SAAS,KAAK,MAAM,YACpD,GAAI,KAAK,kBAAmB,CAC1B,AAAI,KAAK,+BACP,GAAa,EAAkB,kCAC/B,EAAa,EAAkB,kCAC/B,EAAa,EAAkB,kCAC/B,EAAa,EAAkB,kCAC/B,EAAiB,GAAa,GAAc,EAC5C,EAAiB,GAAa,GAAc,EAC5C,EAAc,EAAa,EAC3B,EAAe,EAAa,GAI9B,KAAM,GAAe,KAAK,
|
|
4
|
+
"sourcesContent": ["/*\nGDevelop - Anchor Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n const enum HorizontalAnchor {\n None = 0,\n WindowLeft,\n WindowRight,\n Proportional,\n WindowCenter,\n }\n const enum VerticalAnchor {\n None = 0,\n WindowTop,\n WindowBottom,\n Proportional,\n WindowCenter,\n }\n\n export class AnchorRuntimeBehavior extends gdjs.RuntimeBehavior {\n _relativeToOriginalWindowSize: any;\n _leftEdgeAnchor: HorizontalAnchor;\n _rightEdgeAnchor: HorizontalAnchor;\n _topEdgeAnchor: any;\n _bottomEdgeAnchor: any;\n _invalidDistances: boolean = true;\n _leftEdgeDistance: number = 0;\n _rightEdgeDistance: number = 0;\n _topEdgeDistance: number = 0;\n _bottomEdgeDistance: number = 0;\n _useLegacyBottomAndRightAnchors: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._relativeToOriginalWindowSize = !!behaviorData.relativeToOriginalWindowSize;\n this._leftEdgeAnchor = behaviorData.leftEdgeAnchor;\n this._rightEdgeAnchor = behaviorData.rightEdgeAnchor;\n this._topEdgeAnchor = behaviorData.topEdgeAnchor;\n this._bottomEdgeAnchor = behaviorData.bottomEdgeAnchor;\n this._useLegacyBottomAndRightAnchors =\n behaviorData.useLegacyBottomAndRightAnchors === undefined\n ? true\n : behaviorData.useLegacyBottomAndRightAnchors;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.leftEdgeAnchor !== newBehaviorData.leftEdgeAnchor) {\n this._leftEdgeAnchor = newBehaviorData.leftEdgeAnchor;\n }\n if (oldBehaviorData.rightEdgeAnchor !== newBehaviorData.rightEdgeAnchor) {\n this._rightEdgeAnchor = newBehaviorData.rightEdgeAnchor;\n }\n if (oldBehaviorData.topEdgeAnchor !== newBehaviorData.topEdgeAnchor) {\n this._topEdgeAnchor = newBehaviorData.topEdgeAnchor;\n }\n if (\n oldBehaviorData.bottomEdgeAnchor !== newBehaviorData.bottomEdgeAnchor\n ) {\n this._bottomEdgeAnchor = newBehaviorData.bottomEdgeAnchor;\n }\n if (\n oldBehaviorData.useLegacyTrajectory !==\n newBehaviorData.useLegacyTrajectory\n ) {\n this._useLegacyBottomAndRightAnchors =\n newBehaviorData.useLegacyBottomAndRightAnchors;\n }\n if (\n oldBehaviorData.relativeToOriginalWindowSize !==\n newBehaviorData.relativeToOriginalWindowSize\n ) {\n return false;\n }\n return true;\n }\n\n onActivate() {\n this._invalidDistances = true;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const workingPoint: FloatPoint = gdjs.staticArray(\n gdjs.AnchorRuntimeBehavior.prototype.doStepPreEvents\n ) as FloatPoint;\n let parentMinX = instanceContainer.getUnrotatedViewportMinX();\n let parentMinY = instanceContainer.getUnrotatedViewportMinY();\n let parentMaxX = instanceContainer.getUnrotatedViewportMaxX();\n let parentMaxY = instanceContainer.getUnrotatedViewportMaxY();\n let parentCenterX = (parentMaxX + parentMinX) / 2;\n let parentCenterY = (parentMaxY + parentMinY) / 2;\n let parentWidth = parentMaxX - parentMinX;\n let parentHeight = parentMaxY - parentMinY;\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n if (this._invalidDistances) {\n if (this._relativeToOriginalWindowSize) {\n parentMinX = instanceContainer.getInitialUnrotatedViewportMinX();\n parentMinY = instanceContainer.getInitialUnrotatedViewportMinY();\n parentMaxX = instanceContainer.getInitialUnrotatedViewportMaxX();\n parentMaxY = instanceContainer.getInitialUnrotatedViewportMaxY();\n parentCenterX = (parentMaxX + parentMinX) / 2;\n parentCenterY = (parentMaxY + parentMinY) / 2;\n parentWidth = parentMaxX - parentMinX;\n parentHeight = parentMaxY - parentMinY;\n }\n\n //Calculate the distances from the window's bounds.\n const topLeftPixel = this._relativeToOriginalWindowSize\n ? [this.owner.getDrawableX(), this.owner.getDrawableY()]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX(),\n this.owner.getDrawableY(),\n workingPoint\n );\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMinX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._leftEdgeDistance = topLeftPixel[0] - parentMaxX;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n this._leftEdgeDistance = (topLeftPixel[0] - parentMinX) / parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._leftEdgeDistance = topLeftPixel[0] - parentCenterX;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n this._topEdgeDistance = topLeftPixel[1] - parentMinY;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._topEdgeDistance = topLeftPixel[1] - parentMaxY;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n this._topEdgeDistance = (topLeftPixel[1] - parentMinY) / parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._topEdgeDistance = topLeftPixel[1] - parentCenterY;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const bottomRightPixel = this._relativeToOriginalWindowSize\n ? [\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n ]\n : this._convertInverseCoords(\n instanceContainer,\n layer,\n this.owner.getDrawableX() + this.owner.getWidth(),\n this.owner.getDrawableY() + this.owner.getHeight(),\n workingPoint\n );\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMinX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentMaxX;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n this._rightEdgeDistance =\n (bottomRightPixel[0] - parentMinX) / parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n this._rightEdgeDistance = bottomRightPixel[0] - parentCenterX;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMinY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentMaxY;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n this._bottomEdgeDistance =\n (bottomRightPixel[1] - parentMinY) / parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n this._bottomEdgeDistance = bottomRightPixel[1] - parentCenterY;\n }\n\n this._invalidDistances = false;\n } else {\n //Move and resize the object if needed\n let leftPixel = 0;\n let topPixel = 0;\n let rightPixel = 0;\n let bottomPixel = 0;\n\n // Left edge\n if (this._leftEdgeAnchor === HorizontalAnchor.WindowLeft) {\n leftPixel = parentMinX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowRight) {\n leftPixel = parentMaxX + this._leftEdgeDistance;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.Proportional) {\n leftPixel = parentMinX + this._leftEdgeDistance * parentWidth;\n } else if (this._leftEdgeAnchor === HorizontalAnchor.WindowCenter) {\n leftPixel = parentCenterX + this._leftEdgeDistance;\n }\n\n // Top edge\n if (this._topEdgeAnchor === VerticalAnchor.WindowTop) {\n topPixel = parentMinY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowBottom) {\n topPixel = parentMaxY + this._topEdgeDistance;\n } else if (this._topEdgeAnchor === VerticalAnchor.Proportional) {\n topPixel = parentMinY + this._topEdgeDistance * parentHeight;\n } else if (this._topEdgeAnchor === VerticalAnchor.WindowCenter) {\n topPixel = parentCenterY + this._topEdgeDistance;\n }\n\n // Right edge\n if (this._rightEdgeAnchor === HorizontalAnchor.WindowLeft) {\n rightPixel = parentMinX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowRight) {\n rightPixel = parentMaxX + this._rightEdgeDistance;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.Proportional) {\n rightPixel = parentMinX + this._rightEdgeDistance * parentWidth;\n } else if (this._rightEdgeAnchor === HorizontalAnchor.WindowCenter) {\n rightPixel = parentCenterX + this._rightEdgeDistance;\n }\n\n // Bottom edge\n if (this._bottomEdgeAnchor === VerticalAnchor.WindowTop) {\n bottomPixel = parentMinY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowBottom) {\n bottomPixel = parentMaxY + this._bottomEdgeDistance;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.Proportional) {\n bottomPixel = parentMinY + this._bottomEdgeDistance * parentHeight;\n } else if (this._bottomEdgeAnchor === VerticalAnchor.WindowCenter) {\n bottomPixel = parentCenterY + this._bottomEdgeDistance;\n }\n\n // It's fine to reuse workingPoint as topLeftPixel is no longer used.\n const topLeftCoord = this._convertCoords(\n instanceContainer,\n layer,\n leftPixel,\n topPixel,\n workingPoint\n );\n let left = topLeftCoord[0];\n let top = topLeftCoord[1];\n\n const bottomRightCoord = this._convertCoords(\n instanceContainer,\n layer,\n rightPixel,\n bottomPixel,\n workingPoint\n );\n const right = bottomRightCoord[0];\n const bottom = bottomRightCoord[1];\n\n // Compatibility with GD <= 5.0.133\n if (this._useLegacyBottomAndRightAnchors) {\n //Move and resize the object according to the anchors\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setWidth(right - left);\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setHeight(bottom - top);\n }\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n }\n // End of compatibility code\n else {\n // Resize if right and left anchors are set\n if (\n this._rightEdgeAnchor !== HorizontalAnchor.None &&\n this._leftEdgeAnchor !== HorizontalAnchor.None\n ) {\n const width = right - left;\n this.owner.setX(\n this.owner.getX() === this.owner.getDrawableX()\n ? left\n : // It uses the position of the origin relatively to the object\n // size to apply it with the new size.\n // This is the same as doing:\n // lerp(left, right, (this.owner.getX() - this.owner.getDrawableX() / this.owner.getWidth())\n // But, the division is done at the end to avoid rounding errors.\n left +\n ((this.owner.getX() - this.owner.getDrawableX()) * width) /\n this.owner.getWidth()\n );\n this.owner.setWidth(width);\n } else {\n if (this._leftEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n left + this.owner.getX() - this.owner.getDrawableX()\n );\n }\n if (this._rightEdgeAnchor !== HorizontalAnchor.None) {\n this.owner.setX(\n right +\n this.owner.getX() -\n this.owner.getDrawableX() -\n this.owner.getWidth()\n );\n }\n }\n // Resize if top and bottom anchors are set\n if (\n this._bottomEdgeAnchor !== VerticalAnchor.None &&\n this._topEdgeAnchor !== VerticalAnchor.None\n ) {\n const height = bottom - top;\n this.owner.setY(\n this.owner.getY() === this.owner.getDrawableY()\n ? top\n : top +\n ((this.owner.getY() - this.owner.getDrawableY()) * height) /\n this.owner.getHeight()\n );\n this.owner.setHeight(height);\n } else {\n if (this._topEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n top + this.owner.getY() - this.owner.getDrawableY()\n );\n }\n if (this._bottomEdgeAnchor !== VerticalAnchor.None) {\n this.owner.setY(\n bottom +\n this.owner.getY() -\n this.owner.getDrawableY() -\n this.owner.getHeight()\n );\n }\n }\n }\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}\n\n private _convertCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertCoords(x, y, 0, result);\n }\n\n private _convertInverseCoords(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n layer: gdjs.RuntimeLayer,\n x: float,\n y: float,\n result: FloatPoint\n ) {\n const isParentACustomObject =\n instanceContainer !== instanceContainer.getScene();\n if (isParentACustomObject) {\n result[0] = x;\n result[1] = y;\n return result;\n }\n return layer.convertInverseCoords(x, y, 0, result);\n }\n }\n gdjs.registerBehavior(\n 'AnchorBehavior::AnchorBehavior',\n gdjs.AnchorRuntimeBehavior\n );\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(l){class x{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._tempb2Vec2=new Box2D.b2Vec2(0,0);this._tempb2Vec2Sec=new Box2D.b2Vec2(0,0);this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX||100,this.scaleY=t.scaleY||100,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.worldScale=t.worldScale||Math.sqrt(this.scaleX*this.scaleY),this.worldInvScale=1/this.worldScale,this.timeStep=1/60,this.world=new Box2D.b2World(this.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}b2Vec2(e,t){const i=this._tempb2Vec2;return i.set_x(e),i.set_y(t),i}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new l.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}resetStartedAndEndedCollisions(){for(const e of this._registeredBehaviors)e.contactsStartedThisFrame.length=0,e.contactsEndedThisFrame.length=0}updateBodiesFromObjects(){for(const e of this._registeredBehaviors)e.updateBodyFromObject()}step(e){this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}l.Physics2SharedData=x,l.registerRuntimeSceneUnloadedCallback(function(S){const e=S.physics2SharedData;e&&e.world&&(Box2D.destroy(e.world),Box2D.destroy(e._tempb2Vec2),Box2D.destroy(e._tempb2Vec2Sec))});const B=class extends l.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=Math.max(0,t.linearDamping),this.angularDamping=Math.max(0,t.angularDamping),this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=x.getSharedData(e.getScene(),t.name),this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){const i=this._sharedData._tempb2Vec2;return i.set_x(e),i.set_y(t),i}b2Vec2Sec(e,t){const i=this._sharedData._tempb2Vec2Sec;return i.set_x(e),i.set_y(t),i}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw),t.layers!==void 0&&(this.layers=t.layers),t.masks!==void 0&&(this.masks=t.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),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=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new l.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.worldInvScale:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.worldInvScale:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(this.shapeDimensionA*this.shapeScale*this._sharedData.worldInvScale);else{const n=(this.owner.getWidth()*this._sharedData.worldInvScale+this.owner.getHeight()*this._sharedData.worldInvScale)/4;i.set_m_radius(n>0?n:1)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){let n=(this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale,a=(this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let h=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+h>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.worldInvScale+e,Box2D.HEAPF32[this._verticesBuffer+(h+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.worldInvScale+t,h+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale;let a=this.owner.getHeight()>0?this.owner.getHeight()*this._sharedData.worldInvScale:0;const h=this.shapeDimensionB?l.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(h)+e,a/2-n/2*Math.sin(h)+t),this.b2Vec2Sec(n/2*Math.cos(h)+e,a/2+n/2*Math.sin(h)+t))}else{i=new Box2D.b2PolygonShape;let n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale,a=(this.shapeDimensionB>0?this.shapeDimensionB*this.shapeScale:this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef,t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale;e.set_position(this.b2Vec2(Number.isFinite(t)?t:0,Number.isFinite(i)?i:0));const o=l.toRad(this.owner.getAngle());return Number.isFinite(o)&&e.set_angle(o),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&(this._sharedData.resetStartedAndEndedCollisions(),this._sharedData.updateBodiesFromObjects(),this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)),this._body!==null&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.worldScale-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.worldScale-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(l.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale,o=this.b2Vec2(Number.isFinite(t)?t:e.GetPosition().x,Number.isFinite(i)?i:e.GetPosition().y),s=l.toRad(this.owner.getAngle());e.SetTransform(o,Number.isFinite(s)?s:e.GetAngle()),e.SetAwake(!0)}}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(e<0&&(e=0),this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(e<0&&(e=0),this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.worldScale}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.worldInvScale,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.worldScale}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.worldInvScale))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.worldScale,e.GetLinearVelocity().get_y()*this._sharedData.worldScale).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.worldScale,e.GetLinearVelocity().get_x()*this._sharedData.worldScale))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=l.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.worldInvScale,t*Math.sin(e)*this._sharedData.worldInvScale))}isLinearVelocityAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(l.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.worldScale}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const f=new Box2D.b2DistanceJointDef;f.set_bodyA(u),f.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(r),f.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_length(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),f.set_frequencyHz(a>=0?a:0),f.set_dampingRatio(h>=0?h:1),f.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.worldScale}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_enableLimit(i),r.set_referenceAngle(l.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(l.toRad(s)),r.set_upperAngle(l.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(l.toRad(h)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(f)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=this._body,g=new Box2D.b2RevoluteJointDef;if(g.set_bodyA(_),g.set_localAnchorA(_.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(b),g.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_enableLimit(n),g.set_referenceAngle(l.toRad(a)),d<h){const J=h;h=d,d=J}g.set_lowerAngle(l.toRad(h)),g.set_upperAngle(l.toRad(d)),g.set_enableMotor(c),g.set_motorSpeed(l.toRad(u)),g.set_maxMotorTorque(r>=0?r:0),g.set_collideConnected(f);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2RevoluteJoint));D.setNumber(y)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(l.toRad(t),l.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(l.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const g=this._body,y=new Box2D.b2PrismaticJointDef;if(y.set_bodyA(g),y.set_localAnchorA(g.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),y.set_bodyB(_),y.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-g.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_referenceAngle(l.toRad(a)),y.set_enableLimit(h),c<d){const m=d;d=c,c=m}y.set_lowerTranslation(d<0?d*this._sharedData.worldInvScale:0),y.set_upperTranslation(c>0?c*this._sharedData.worldInvScale:0),y.set_enableMotor(u),y.set_motorSpeed(r*this._sharedData.worldInvScale),y.set_maxMotorForce(f),y.set_collideConnected(D);const J=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2PrismaticJoint));b.setNumber(J)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.worldScale}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.worldScale}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.worldScale}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.worldScale}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.worldInvScale)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const g=new Box2D.b2PulleyJointDef;g.set_bodyA(b),g.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(_),g.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_groundAnchorA(this.b2Vec2(n*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale)),g.set_groundAnchorB(this.b2Vec2(h*this._sharedData.worldInvScale,d*this._sharedData.worldInvScale)),g.set_lengthA(c>0?c*this._sharedData.worldInvScale:this.b2Vec2((n-e)*this._sharedData.worldInvScale,(a-t)*this._sharedData.worldInvScale).Length()),g.set_lengthB(u>0?u*this._sharedData.worldInvScale:this.b2Vec2((h-o)*this._sharedData.worldInvScale,(d-s)*this._sharedData.worldInvScale).Length()),g.set_ratio(r>0?r:1),g.set_collideConnected(f);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2PulleyJoint));D.setNumber(y)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.worldScale}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.worldScale}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.worldScale}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.worldScale}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const h=this._sharedData.getJoint(t);if(h===null||h.GetType()!==Box2D.e_revoluteJoint&&h.GetType()!==Box2D.e_prismaticJoint||a===h)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(h),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,h=new Box2D.b2MouseJointDef;h.set_bodyA(this._sharedData.staticBody),h.set_bodyB(a),h.set_target(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale)),h.set_maxForce(i>=0?i:0),h.set_frequencyHz(o>0?o:1),h.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(h),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.worldScale}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.worldScale}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,h,d,c,u,r,f){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=new Box2D.b2WheelJointDef;_.set_bodyA(D),_.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),_.set_bodyB(b),_.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-D.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_frequencyHz(a>0?a:1),_.set_dampingRatio(h>=0?h:0),_.set_enableMotor(d),_.set_motorSpeed(l.toRad(c)),_.set_maxMotorTorque(u),_.set_collideConnected(r);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2WheelJoint));f.setNumber(g)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(l.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,f=new Box2D.b2WeldJointDef;f.set_bodyA(r),f.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(u),f.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_referenceAngle(l.toRad(n)),f.set_frequencyHz(a>0?a:1),f.set_dampingRatio(h>=0?h:0),f.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2WeldJoint);D.referenceAngle=f.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:l.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,h){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),u.set_maxLength(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));h.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.worldScale}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(f)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),r.set_angularOffset(l.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(f)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.worldScale}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.worldScale}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:l.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(l.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let p=B;p.collisionTest=B.areObjectsColliding,l.Physics2RuntimeBehavior=p,l.registerBehavior("Physics2::Physics2Behavior",l.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(l){class S{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._tempb2Vec2=new Box2D.b2Vec2(0,0);this._tempb2Vec2Sec=new Box2D.b2Vec2(0,0);this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX||100,this.scaleY=t.scaleY||100,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.worldScale=t.worldScale||Math.sqrt(this.scaleX*this.scaleY),this.worldInvScale=1/this.worldScale,this.timeStep=1/60,this.world=new Box2D.b2World(this.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}b2Vec2(e,t){const i=this._tempb2Vec2;return i.set_x(e),i.set_y(t),i}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new l.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}step(e){for(const i of this._registeredBehaviors)i.contactsStartedThisFrame.length=0,i.contactsEndedThisFrame.length=0;for(const i of this._registeredBehaviors)i.updateBodyFromObject();this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0;for(const i of this._registeredBehaviors)i.updateObjectFromBody()}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}l.Physics2SharedData=S,l.registerRuntimeSceneUnloadedCallback(function(x){const e=x.physics2SharedData;e&&e.world&&(Box2D.destroy(e.world),Box2D.destroy(e._tempb2Vec2),Box2D.destroy(e._tempb2Vec2Sec))});const B=class extends l.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=Math.max(0,t.linearDamping),this.angularDamping=Math.max(0,t.angularDamping),this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=S.getSharedData(e.getScene(),t.name),this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){const i=this._sharedData._tempb2Vec2;return i.set_x(e),i.set_y(t),i}b2Vec2Sec(e,t){const i=this._sharedData._tempb2Vec2Sec;return i.set_x(e),i.set_y(t),i}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw),t.layers!==void 0&&(this.layers=t.layers),t.masks!==void 0&&(this.masks=t.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),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=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new l.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.worldInvScale:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.worldInvScale:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(Math.max(.1,this.shapeDimensionA)*this.shapeScale*this._sharedData.worldInvScale);else{const n=(Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale+Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale)/4;i.set_m_radius(n)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){const n=Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let h=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+h>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.worldInvScale+e,Box2D.HEAPF32[this._verticesBuffer+(h+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.worldInvScale+t,h+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale,h=this.shapeDimensionB?l.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(h)+e,a/2-n/2*Math.sin(h)+t),this.b2Vec2Sec(n/2*Math.cos(h)+e,a/2+n/2*Math.sin(h)+t))}else{i=new Box2D.b2PolygonShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=(this.shapeDimensionB>0?Math.max(.1,this.shapeDimensionB*this.shapeScale):Math.max(.1,this.owner.getHeight()))*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef,t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale;e.set_position(this.b2Vec2(Number.isFinite(t)?t:0,Number.isFinite(i)?i:0));const o=l.toRad(this.owner.getAngle());return Number.isFinite(o)&&e.set_angle(o),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateObjectFromBody(){this._body!==null&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.worldScale-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.worldScale-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(l.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale,o=this.b2Vec2(Number.isFinite(t)?t:e.GetPosition().x,Number.isFinite(i)?i:e.GetPosition().y),s=l.toRad(this.owner.getAngle());e.SetTransform(o,Number.isFinite(s)?s:e.GetAngle()),e.SetAwake(!0)}}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(e<0&&(e=0),this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(e<0&&(e=0),this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.worldScale}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.worldInvScale,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.worldScale}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.worldInvScale))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.worldScale,e.GetLinearVelocity().get_y()*this._sharedData.worldScale).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.worldScale,e.GetLinearVelocity().get_x()*this._sharedData.worldScale))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=l.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.worldInvScale,t*Math.sin(e)*this._sharedData.worldInvScale))}isLinearVelocityAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(l.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.worldScale}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const f=new Box2D.b2DistanceJointDef;f.set_bodyA(u),f.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(r),f.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_length(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),f.set_frequencyHz(a>=0?a:0),f.set_dampingRatio(h>=0?h:1),f.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.worldScale}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_enableLimit(i),r.set_referenceAngle(l.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(l.toRad(s)),r.set_upperAngle(l.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(l.toRad(h)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(f)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=this._body,g=new Box2D.b2RevoluteJointDef;if(g.set_bodyA(y),g.set_localAnchorA(y.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(b),g.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_enableLimit(n),g.set_referenceAngle(l.toRad(a)),d<h){const J=h;h=d,d=J}g.set_lowerAngle(l.toRad(h)),g.set_upperAngle(l.toRad(d)),g.set_enableMotor(c),g.set_motorSpeed(l.toRad(u)),g.set_maxMotorTorque(r>=0?r:0),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2RevoluteJoint));D.setNumber(_)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(l.toRad(t),l.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(l.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=this._body,_=new Box2D.b2PrismaticJointDef;if(_.set_bodyA(g),_.set_localAnchorA(g.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),_.set_bodyB(y),_.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-g.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_referenceAngle(l.toRad(a)),_.set_enableLimit(h),c<d){const m=d;d=c,c=m}_.set_lowerTranslation(d<0?d*this._sharedData.worldInvScale:0),_.set_upperTranslation(c>0?c*this._sharedData.worldInvScale:0),_.set_enableMotor(u),_.set_motorSpeed(r*this._sharedData.worldInvScale),_.set_maxMotorForce(f),_.set_collideConnected(D);const J=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2PrismaticJoint));b.setNumber(J)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.worldScale}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.worldScale}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.worldScale}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.worldScale}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.worldInvScale)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=new Box2D.b2PulleyJointDef;g.set_bodyA(b),g.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(y),g.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_groundAnchorA(this.b2Vec2(n*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale)),g.set_groundAnchorB(this.b2Vec2(h*this._sharedData.worldInvScale,d*this._sharedData.worldInvScale)),g.set_lengthA(c>0?c*this._sharedData.worldInvScale:this.b2Vec2((n-e)*this._sharedData.worldInvScale,(a-t)*this._sharedData.worldInvScale).Length()),g.set_lengthB(u>0?u*this._sharedData.worldInvScale:this.b2Vec2((h-o)*this._sharedData.worldInvScale,(d-s)*this._sharedData.worldInvScale).Length()),g.set_ratio(r>0?r:1),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2PulleyJoint));D.setNumber(_)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.worldScale}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.worldScale}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.worldScale}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.worldScale}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const h=this._sharedData.getJoint(t);if(h===null||h.GetType()!==Box2D.e_revoluteJoint&&h.GetType()!==Box2D.e_prismaticJoint||a===h)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(h),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,h=new Box2D.b2MouseJointDef;h.set_bodyA(this._sharedData.staticBody),h.set_bodyB(a),h.set_target(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale)),h.set_maxForce(i>=0?i:0),h.set_frequencyHz(o>0?o:1),h.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(h),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.worldScale}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.worldScale}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,h,d,c,u,r,f){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=new Box2D.b2WheelJointDef;y.set_bodyA(D),y.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),y.set_bodyB(b),y.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-D.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_frequencyHz(a>0?a:1),y.set_dampingRatio(h>=0?h:0),y.set_enableMotor(d),y.set_motorSpeed(l.toRad(c)),y.set_maxMotorTorque(u),y.set_collideConnected(r);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2WheelJoint));f.setNumber(g)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(l.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,f=new Box2D.b2WeldJointDef;f.set_bodyA(r),f.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(u),f.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_referenceAngle(l.toRad(n)),f.set_frequencyHz(a>0?a:1),f.set_dampingRatio(h>=0?h:0),f.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2WeldJoint);D.referenceAngle=f.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:l.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,h){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),u.set_maxLength(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));h.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.worldScale}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(f)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),r.set_angularOffset(l.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(f)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.worldScale}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.worldScale}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:l.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(l.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let p=B;p.collisionTest=B.areObjectsColliding,l.Physics2RuntimeBehavior=p,l.registerBehavior("Physics2::Physics2Behavior",l.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=physics2runtimebehavior.js.map
|