@babylonjs/core 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Collisions/pickingInfo.js +24 -9
- package/Collisions/pickingInfo.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +1 -0
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/engine.d.ts +90 -0
- package/Engines/thinEngine.js +21 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -6
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gamepads/gamepadManager.js +2 -4
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/gizmo.js +1 -0
- package/Gizmos/gizmo.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +4 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +44 -6
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.d.ts +1 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js +3 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +2 -1
- package/Materials/PBR/pbrMaterial.js +3 -2
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +2 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +6 -0
- package/Materials/Textures/baseTexture.js +8 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.d.ts +7 -0
- package/Materials/Textures/cubeTexture.js +25 -2
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +1 -1
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/material.js +1 -1
- package/Materials/material.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -1
- package/Materials/standardMaterial.js +3 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +4 -0
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +19 -4
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/decorators.d.ts +5 -1
- package/Misc/decorators.js +12 -4
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.js +1 -1
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/error.d.ts +1 -1
- package/Misc/error.js.map +1 -1
- package/Misc/tools.d.ts +10 -9
- package/Misc/tools.js +48 -16
- package/Misc/tools.js.map +1 -1
- package/Physics/physicsRaycastResult.js +6 -6
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +20 -5
- package/Physics/v2/Plugins/havokPlugin.js +66 -8
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +5 -51
- package/Physics/v2/physicsAggregate.js +7 -6
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +17 -1
- package/Physics/v2/physicsBody.js +22 -2
- package/Physics/v2/physicsBody.js.map +1 -1
- package/assetContainer.d.ts +2 -3
- package/assetContainer.js +13 -4
- package/assetContainer.js.map +1 -1
- package/node.d.ts +8 -0
- package/node.js +23 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbW,8BAA8B,KAA9B,8BAA8B,QAazC;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAY,qBAqCX;AArCD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;;OAIG;IACH,uFAAe,CAAA;AACnB,CAAC,EArCW,qBAAqB,KAArB,qBAAqB,QAqChC;AAED,yBAAyB;AACzB,MAAM,CAAN,IAAY,qBAsCX;AAtCD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,uFAAmB,CAAA;IACnB;;;OAGG;IACH,yEAAY,CAAA;IACZ;;;OAGG;IACH,mEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,iEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAa,CAAA;IACb;;;;OAIG;IACH,uEAAW,CAAA;AACf,CAAC,EAtCW,qBAAqB,KAArB,qBAAqB,QAsChC;AAED,oBAAoB;AACpB,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IACxB,2DAAM,CAAA;IACN,6DAAO,CAAA;IACP,+DAAQ,CAAA;IACR,qDAAG,CAAA;IACH,qEAAW,CAAA;IACX,iEAAS,CAAA;IACT,uDAAI,CAAA;IACJ,qEAAW,CAAA;AACf,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED,qGAAqG;AACrG,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,2EAAI,CAAA;IACJ,mFAAQ,CAAA;IACR,mFAAQ,CAAA;AACZ,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AA+KD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintMotorType;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbW,8BAA8B,KAA9B,8BAA8B,QAazC;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAY,qBAqCX;AArCD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;;OAIG;IACH,uFAAe,CAAA;AACnB,CAAC,EArCW,qBAAqB,KAArB,qBAAqB,QAqChC;AAED,yBAAyB;AACzB,MAAM,CAAN,IAAY,qBAsCX;AAtCD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,uFAAmB,CAAA;IACnB;;;OAGG;IACH,yEAAY,CAAA;IACZ;;;OAGG;IACH,mEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,iEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAa,CAAA;IACb;;;;OAIG;IACH,uEAAW,CAAA;AACf,CAAC,EAtCW,qBAAqB,KAArB,qBAAqB,QAsChC;AAED,oBAAoB;AACpB,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IACxB,2DAAM,CAAA;IACN,6DAAO,CAAA;IACP,+DAAQ,CAAA;IACR,qDAAG,CAAA;IACH,qEAAW,CAAA;IACX,iEAAS,CAAA;IACT,uDAAI,CAAA;IACJ,qEAAW,CAAA;AACf,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED,qGAAqG;AACrG,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,2EAAI,CAAA;IACJ,mFAAQ,CAAA;IACR,mFAAQ,CAAA;AACZ,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AA+KD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintMotorType;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../../../Maths/math.vector";
|
|
2
|
-
import { PhysicsShapeType, PhysicsMotionType } from "../IPhysicsEnginePlugin";
|
|
3
|
-
import type { PhysicsShapeParameters,
|
|
2
|
+
import { PhysicsShapeType, PhysicsMotionType, PhysicsConstraintMotorType, PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode } from "../IPhysicsEnginePlugin";
|
|
3
|
+
import type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent } from "../IPhysicsEnginePlugin";
|
|
4
4
|
import type { PhysicsBody } from "../physicsBody";
|
|
5
5
|
import type { PhysicsConstraint } from "../physicsConstraint";
|
|
6
6
|
import type { PhysicsMaterial } from "../physicsMaterial";
|
|
7
|
-
import { PhysicsConstraintAxis } from "../IPhysicsEnginePlugin";
|
|
8
|
-
import { PhysicsConstraintAxisLimitMode } from "../IPhysicsEnginePlugin";
|
|
9
7
|
import { PhysicsShape } from "../physicsShape";
|
|
10
8
|
import type { BoundingBox } from "../../../Culling/boundingBox";
|
|
11
9
|
import type { TransformNode } from "../../../Meshes/transformNode";
|
|
@@ -101,6 +99,7 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
101
99
|
* Initializes a physics body with the given position and orientation.
|
|
102
100
|
*
|
|
103
101
|
* @param body - The physics body to initialize.
|
|
102
|
+
* @param motionType - The motion type of the body.
|
|
104
103
|
* @param position - The position of the body.
|
|
105
104
|
* @param orientation - The orientation of the body.
|
|
106
105
|
* This code is useful for initializing a physics body with the given position and orientation.
|
|
@@ -350,6 +349,20 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
350
349
|
* same transformation.
|
|
351
350
|
*/
|
|
352
351
|
setPhysicsBodyTransformation(body: PhysicsBody, node: TransformNode): void;
|
|
352
|
+
/**
|
|
353
|
+
* Sets the gravity factor of a body
|
|
354
|
+
* @param body the physics body to set the gravity factor for
|
|
355
|
+
* @param factor the gravity factor
|
|
356
|
+
* @param instanceIndex the index of the instance in an instanced body
|
|
357
|
+
*/
|
|
358
|
+
setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;
|
|
359
|
+
/**
|
|
360
|
+
* Get the gravity factor of a body
|
|
361
|
+
* @param body the physics body to get the gravity factor from
|
|
362
|
+
* @param instanceIndex the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.
|
|
363
|
+
* @returns the gravity factor
|
|
364
|
+
*/
|
|
365
|
+
getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;
|
|
353
366
|
/**
|
|
354
367
|
* Disposes a physics body.
|
|
355
368
|
*
|
|
@@ -481,7 +494,7 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
481
494
|
* @param body - The main body to which the constraint is applied.
|
|
482
495
|
* @param childBody - The body to which the constraint is applied.
|
|
483
496
|
* @param constraint - The constraint to be applied.
|
|
484
|
-
*
|
|
497
|
+
* @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
|
|
485
498
|
* @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
|
|
486
499
|
*/
|
|
487
500
|
addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;
|
|
@@ -679,6 +692,8 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
679
692
|
private _v3ToBvecRef;
|
|
680
693
|
private _bVecToV3;
|
|
681
694
|
private _bQuatToV4;
|
|
695
|
+
private _constraintMotorTypeToNative;
|
|
696
|
+
private _nativeToMotorType;
|
|
682
697
|
private _materialCombineToNative;
|
|
683
698
|
private _constraintAxisToNative;
|
|
684
699
|
private _nativeToLimitMode;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Matrix, Quaternion, TmpVectors, Vector3 } from "../../../Maths/math.vector.js";
|
|
2
|
-
import { PhysicsShapeType, PhysicsConstraintType, PhysicsMotionType } from "../IPhysicsEnginePlugin.js";
|
|
2
|
+
import { PhysicsShapeType, PhysicsConstraintType, PhysicsMotionType, PhysicsConstraintMotorType, PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode, } from "../IPhysicsEnginePlugin.js";
|
|
3
3
|
import { Logger } from "../../../Misc/logger.js";
|
|
4
4
|
import { PhysicsMaterialCombineMode } from "../physicsMaterial.js";
|
|
5
|
-
import { PhysicsConstraintAxis } from "../IPhysicsEnginePlugin.js";
|
|
6
|
-
import { PhysicsConstraintAxisLimitMode } from "../IPhysicsEnginePlugin.js";
|
|
7
5
|
import { PhysicsShape } from "../physicsShape.js";
|
|
8
6
|
import { Mesh } from "../../../Meshes/mesh.js";
|
|
9
7
|
import { VertexBuffer } from "../../../Buffers/buffer.js";
|
|
@@ -276,6 +274,7 @@ export class HavokPlugin {
|
|
|
276
274
|
* Initializes a physics body with the given position and orientation.
|
|
277
275
|
*
|
|
278
276
|
* @param body - The physics body to initialize.
|
|
277
|
+
* @param motionType - The motion type of the body.
|
|
279
278
|
* @param position - The position of the body.
|
|
280
279
|
* @param orientation - The orientation of the body.
|
|
281
280
|
* This code is useful for initializing a physics body with the given position and orientation.
|
|
@@ -384,12 +383,14 @@ export class HavokPlugin {
|
|
|
384
383
|
for (let i = pluginInstancesCount; i < instancesCount; i++) {
|
|
385
384
|
this._hknp.HP_Body_SetShape(body._pluginDataInstances[i].hpBodyId, firstBodyShape);
|
|
386
385
|
this._internalUpdateMassProperties(body._pluginDataInstances[i]);
|
|
386
|
+
this._bodies.set(body._pluginDataInstances[i].hpBodyId[0], { body: body, index: i });
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
else if (instancesCount < pluginInstancesCount) {
|
|
390
390
|
const instancesToRemove = pluginInstancesCount - instancesCount;
|
|
391
391
|
for (let i = 0; i < instancesToRemove; i++) {
|
|
392
392
|
const hkbody = body._pluginDataInstances.pop();
|
|
393
|
+
this._bodies.delete(hkbody.hpBodyId[0]);
|
|
393
394
|
this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);
|
|
394
395
|
this._hknp.HP_Body_Release(hkbody.hpBodyId);
|
|
395
396
|
}
|
|
@@ -449,8 +450,21 @@ export class HavokPlugin {
|
|
|
449
450
|
const bodyTranslation = bodyTransform[0];
|
|
450
451
|
const bodyOrientation = bodyTransform[1];
|
|
451
452
|
const quat = TmpVectors.Quaternion[0];
|
|
452
|
-
transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);
|
|
453
453
|
quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);
|
|
454
|
+
const parent = transformNode.parent;
|
|
455
|
+
// transform position/orientation in parent space
|
|
456
|
+
if (parent && parent.absoluteRotationQuaternion) {
|
|
457
|
+
TmpVectors.Vector3[2].set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);
|
|
458
|
+
parent.absoluteRotationQuaternion.conjugateToRef(TmpVectors.Quaternion[1]);
|
|
459
|
+
quat.multiplyInPlace(TmpVectors.Quaternion[1]);
|
|
460
|
+
TmpVectors.Vector3[2].subtractToRef(parent.absolutePosition, TmpVectors.Vector3[0]);
|
|
461
|
+
const localPosition = TmpVectors.Vector3[1];
|
|
462
|
+
TmpVectors.Vector3[0].rotateByQuaternionToRef(TmpVectors.Quaternion[1], localPosition);
|
|
463
|
+
transformNode.position.set(localPosition.x, localPosition.y, localPosition.z); // use set so position._isDirty is true
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);
|
|
467
|
+
}
|
|
454
468
|
if (transformNode.rotationQuaternion) {
|
|
455
469
|
transformNode.rotationQuaternion.copyFrom(quat);
|
|
456
470
|
}
|
|
@@ -837,6 +851,27 @@ export class HavokPlugin {
|
|
|
837
851
|
this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));
|
|
838
852
|
}
|
|
839
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Sets the gravity factor of a body
|
|
856
|
+
* @param body the physics body to set the gravity factor for
|
|
857
|
+
* @param factor the gravity factor
|
|
858
|
+
* @param instanceIndex the index of the instance in an instanced body
|
|
859
|
+
*/
|
|
860
|
+
setGravityFactor(body, factor, instanceIndex) {
|
|
861
|
+
this._applyToBodyOrInstances(body, (pluginRef) => {
|
|
862
|
+
this._hknp.HP_Body_SetGravityFactor(pluginRef.hpBodyId, factor);
|
|
863
|
+
}, instanceIndex);
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Get the gravity factor of a body
|
|
867
|
+
* @param body the physics body to get the gravity factor from
|
|
868
|
+
* @param instanceIndex the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.
|
|
869
|
+
* @returns the gravity factor
|
|
870
|
+
*/
|
|
871
|
+
getGravityFactor(body, instanceIndex) {
|
|
872
|
+
const pluginRef = this._getPluginReference(body, instanceIndex);
|
|
873
|
+
return this._hknp.HP_Body_GetGravityFactor(pluginRef.hpBodyId)[1];
|
|
874
|
+
}
|
|
840
875
|
/**
|
|
841
876
|
* Disposes a physics body.
|
|
842
877
|
*
|
|
@@ -996,6 +1031,10 @@ export class HavokPlugin {
|
|
|
996
1031
|
* It then creates an array containing the position and orientation of the node and returns it.
|
|
997
1032
|
*/
|
|
998
1033
|
_getTransformInfos(node) {
|
|
1034
|
+
if (node.parent) {
|
|
1035
|
+
node.computeWorldMatrix();
|
|
1036
|
+
return [this._bVecToV3(node.absolutePosition), this._bQuatToV4(node.absoluteRotationQuaternion)];
|
|
1037
|
+
}
|
|
999
1038
|
let orientation = TmpVectors.Quaternion[0];
|
|
1000
1039
|
if (node.rotationQuaternion) {
|
|
1001
1040
|
orientation = node.rotationQuaternion;
|
|
@@ -1205,7 +1244,7 @@ export class HavokPlugin {
|
|
|
1205
1244
|
* @param body - The main body to which the constraint is applied.
|
|
1206
1245
|
* @param childBody - The body to which the constraint is applied.
|
|
1207
1246
|
* @param constraint - The constraint to be applied.
|
|
1208
|
-
*
|
|
1247
|
+
* @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
|
|
1209
1248
|
* @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
|
|
1210
1249
|
*/
|
|
1211
1250
|
addConstraint(body, childBody, constraint, instanceIndex, childInstanceIndex) {
|
|
@@ -1269,7 +1308,7 @@ export class HavokPlugin {
|
|
|
1269
1308
|
*
|
|
1270
1309
|
*/
|
|
1271
1310
|
getAxisFriction(constraint, axis) {
|
|
1272
|
-
return this._hknp.
|
|
1311
|
+
return this._hknp.HP_Constraint_GetAxisFriction(constraint._pluginData, this._constraintAxisToNative(axis))[1];
|
|
1273
1312
|
}
|
|
1274
1313
|
/**
|
|
1275
1314
|
* Sets the limit mode of the specified axis of the given constraint.
|
|
@@ -1342,7 +1381,7 @@ export class HavokPlugin {
|
|
|
1342
1381
|
*
|
|
1343
1382
|
*/
|
|
1344
1383
|
setAxisMotorType(constraint, axis, motorType) {
|
|
1345
|
-
this._hknp.HP_Constraint_SetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis), motorType);
|
|
1384
|
+
this._hknp.HP_Constraint_SetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis), this._constraintMotorTypeToNative(motorType));
|
|
1346
1385
|
}
|
|
1347
1386
|
/**
|
|
1348
1387
|
* Gets the motor type of the specified axis of the given constraint.
|
|
@@ -1352,7 +1391,7 @@ export class HavokPlugin {
|
|
|
1352
1391
|
*
|
|
1353
1392
|
*/
|
|
1354
1393
|
getAxisMotorType(constraint, axis) {
|
|
1355
|
-
return this._hknp.HP_Constraint_GetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis))[1];
|
|
1394
|
+
return this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(constraint._pluginData, this._constraintAxisToNative(axis))[1]);
|
|
1356
1395
|
}
|
|
1357
1396
|
/**
|
|
1358
1397
|
* Sets the target of an axis motor of a constraint.
|
|
@@ -1424,6 +1463,7 @@ export class HavokPlugin {
|
|
|
1424
1463
|
raycast(from, to, result) {
|
|
1425
1464
|
const queryMembership = ~0;
|
|
1426
1465
|
const queryCollideWith = ~0;
|
|
1466
|
+
result.reset(from, to);
|
|
1427
1467
|
const query = [this._bVecToV3(from), this._bVecToV3(to), [queryMembership, queryCollideWith]];
|
|
1428
1468
|
this._hknp.HP_World_CastRayWithCollector(this.world, this._queryCollector, query);
|
|
1429
1469
|
if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
|
|
@@ -1535,6 +1575,24 @@ export class HavokPlugin {
|
|
|
1535
1575
|
_bQuatToV4(q) {
|
|
1536
1576
|
return [q._x, q._y, q._z, q._w];
|
|
1537
1577
|
}
|
|
1578
|
+
_constraintMotorTypeToNative(motorType) {
|
|
1579
|
+
switch (motorType) {
|
|
1580
|
+
case PhysicsConstraintMotorType.POSITION:
|
|
1581
|
+
return this._hknp.ConstraintMotorType.POSITION;
|
|
1582
|
+
case PhysicsConstraintMotorType.VELOCITY:
|
|
1583
|
+
return this._hknp.ConstraintMotorType.VELOCITY;
|
|
1584
|
+
}
|
|
1585
|
+
return this._hknp.ConstraintMotorType.NONE;
|
|
1586
|
+
}
|
|
1587
|
+
_nativeToMotorType(motorType) {
|
|
1588
|
+
switch (motorType) {
|
|
1589
|
+
case this._hknp.ConstraintMotorType.POSITION:
|
|
1590
|
+
return PhysicsConstraintMotorType.POSITION;
|
|
1591
|
+
case this._hknp.ConstraintMotorType.VELOCITY:
|
|
1592
|
+
return PhysicsConstraintMotorType.VELOCITY;
|
|
1593
|
+
}
|
|
1594
|
+
return PhysicsConstraintMotorType.NONE;
|
|
1595
|
+
}
|
|
1538
1596
|
_materialCombineToNative(mat) {
|
|
1539
1597
|
switch (mat) {
|
|
1540
1598
|
case PhysicsMaterialCombineMode.GEOMETRIC_MEAN:
|