@babylonjs/core 5.51.0 → 5.53.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/Animations/animatable.d.ts +5 -3
- package/Animations/animatable.js +11 -8
- package/Animations/animatable.js.map +1 -1
- package/Animations/animationGroup.js +3 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +1 -0
- package/Animations/runtimeAnimation.js +1 -0
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +2 -1
- package/Collisions/pickingInfo.js +4 -3
- package/Collisions/pickingInfo.js.map +1 -1
- package/DeviceInput/eventFactory.js +4 -0
- package/DeviceInput/eventFactory.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +17 -9
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/engine.d.ts +2 -0
- package/Engines/engine.js +5 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +3 -3
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.js +5 -12
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +4 -0
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +37 -2
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialDecorator.d.ts +1 -1
- package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
- package/Materials/PBR/pbrMaterial.js +1 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +7 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +3 -2
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginManager.js +13 -3
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +2 -0
- package/Materials/uniformBuffer.js +4 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.frustum.d.ts +8 -1
- package/Maths/math.frustum.js +14 -0
- package/Maths/math.frustum.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +2 -1
- package/Meshes/instancedMesh.js +3 -2
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +10 -5
- package/Meshes/mesh.js +40 -16
- package/Meshes/mesh.js.map +1 -1
- package/Misc/environmentTextureTools.js +7 -0
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/filesInput.d.ts +5 -2
- package/Misc/filesInput.js +39 -20
- package/Misc/filesInput.js.map +1 -1
- package/Misc/observable.js +3 -0
- package/Misc/observable.js.map +1 -1
- package/Misc/sceneOptimizer.js +3 -0
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/virtualJoystick.js +2 -2
- package/Misc/virtualJoystick.js.map +1 -1
- package/Particles/gpuParticleSystem.js +18 -14
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +126 -19
- package/Physics/v2/IPhysicsEnginePlugin.js +6 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +7 -1
- package/Physics/v2/physicsAggregate.js +23 -9
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +50 -31
- package/Physics/v2/physicsBody.js +75 -34
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +6 -6
- package/Physics/v2/physicsConstraint.js +6 -6
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +10 -0
- package/Physics/v2/physicsEngineComponent.js +27 -0
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/physicsMaterial.d.ts +52 -46
- package/Physics/v2/physicsMaterial.js +23 -80
- package/Physics/v2/physicsMaterial.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +34 -9
- package/Physics/v2/physicsShape.js +59 -8
- package/Physics/v2/physicsShape.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +59 -13
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +131 -54
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/depthRendererSceneComponent.d.ts +2 -1
- package/Rendering/depthRendererSceneComponent.js +2 -2
- package/Rendering/depthRendererSceneComponent.js.map +1 -1
- package/Shaders/sprites.fragment.js +6 -1
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Shaders/ssao2.fragment.js +0 -2
- package/Shaders/ssao2.fragment.js.map +1 -1
- package/Sprites/spriteManager.d.ts +7 -0
- package/Sprites/spriteManager.js +27 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +8 -0
- package/Sprites/spriteRenderer.js +42 -19
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
- package/XR/features/WebXRControllerTeleportation.js +28 -4
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ export class PhysicsConstraint {
|
|
|
43
43
|
* @returns The type of the constraint.
|
|
44
44
|
*
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
get type() {
|
|
47
47
|
return this._type;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
@@ -52,21 +52,21 @@ export class PhysicsConstraint {
|
|
|
52
52
|
* @returns The physics constraint parameters.
|
|
53
53
|
*
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
get options() {
|
|
56
56
|
return this._options;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Enable/disable the constraint
|
|
60
60
|
* @param isEnabled value for the constraint
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
set isEnabled(isEnabled) {
|
|
63
63
|
this._physicsPlugin.setEnabled(this, isEnabled);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
*
|
|
67
67
|
* @returns true if constraint is enabled
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
get isEnabled() {
|
|
70
70
|
return this._physicsPlugin.getEnabled(this);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -75,7 +75,7 @@ export class PhysicsConstraint {
|
|
|
75
75
|
* @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.
|
|
76
76
|
*
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
set isCollisionsEnabled(isEnabled) {
|
|
79
79
|
this._physicsPlugin.setCollisionsEnabled(this, isEnabled);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -84,7 +84,7 @@ export class PhysicsConstraint {
|
|
|
84
84
|
* @returns `true` if collisions are enabled, `false` otherwise.
|
|
85
85
|
*
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
get isCollisionsEnabled() {
|
|
88
88
|
return this._physicsPlugin.getCollisionsEnabled(this);
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QApBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM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AK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public getType(): ConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public getOptions(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis.\r\n *\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis.\r\n *\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis.\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis.\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QApBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SAC1E;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa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KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public get type(): ConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public get options(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public set isEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public get isEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public set isCollisionsEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public get isCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis.\r\n *\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis.\r\n *\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis.\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis.\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
|
|
@@ -3,6 +3,7 @@ import type { Observer } from "../../Misc/observable";
|
|
|
3
3
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
4
4
|
import type { Node } from "../../node";
|
|
5
5
|
import type { PhysicsBody } from "./physicsBody";
|
|
6
|
+
import type { PhysicsShape } from "./physicsShape";
|
|
6
7
|
import "../joinedPhysicsEngineComponent";
|
|
7
8
|
declare module "../../Meshes/transformNode" {
|
|
8
9
|
/**
|
|
@@ -20,6 +21,15 @@ declare module "../../Meshes/transformNode" {
|
|
|
20
21
|
*
|
|
21
22
|
*/
|
|
22
23
|
getPhysicsBody(): Nullable<PhysicsBody>;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
_physicsShape: Nullable<PhysicsShape>;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
physicsShape: Nullable<PhysicsShape>;
|
|
32
|
+
getPhysicsShape(): Nullable<PhysicsShape>;
|
|
23
33
|
/** Apply a physic impulse to the mesh
|
|
24
34
|
* @param force defines the force to apply
|
|
25
35
|
* @param contactPoint defines where to apply the force
|
|
@@ -33,6 +33,33 @@ Object.defineProperty(TransformNode.prototype, "physicsBody", {
|
|
|
33
33
|
TransformNode.prototype.getPhysicsBody = function () {
|
|
34
34
|
return this.physicsBody;
|
|
35
35
|
};
|
|
36
|
+
Object.defineProperty(TransformNode.prototype, "physicsShape", {
|
|
37
|
+
get: function () {
|
|
38
|
+
return this._physicsShape;
|
|
39
|
+
},
|
|
40
|
+
set: function (value) {
|
|
41
|
+
if (this._physicsShape === value) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this._physicsShape) {
|
|
45
|
+
//<todo.eoin Remove from body
|
|
46
|
+
}
|
|
47
|
+
this._physicsShape = value;
|
|
48
|
+
if (this._physicsShape) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
50
|
+
let cur = this;
|
|
51
|
+
while (cur) {
|
|
52
|
+
if (cur instanceof TransformNode && cur.physicsBody) {
|
|
53
|
+
cur.physicsBody.addNodeShape(this);
|
|
54
|
+
}
|
|
55
|
+
cur = cur.parent;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
TransformNode.prototype.getPhysicsShape = function () {
|
|
61
|
+
return this.physicsShape;
|
|
62
|
+
};
|
|
36
63
|
/**
|
|
37
64
|
* Apply a physic impulse to the mesh
|
|
38
65
|
* @param force defines the force to apply
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../l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,EAAE;YAC9B,OAAO;SACV;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,6BAA6B;SAChC;QAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,4DAA4D;YAC5D,IAAI,GAAG,GAAmB,IAAI,CAAC;YAC/B,OAAO,GAAG,EAAE;gBACR,IAAI,GAAG,YAAY,aAAa,IAAI,GAAG,CAAC,WAAW,EAAE;oBACjD,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBACtC;gBAED,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;aACpB;SACJ;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,aAAa,CAAC,SAAS,CAAC,eAAe,GAAG;IACtC,OAAO,IAAI,CAAC,YAAY,CAAC;AAC7B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,gBAAgB;AAChB,aAAa,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IAClF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\n\r\nimport \"../joinedPhysicsEngineComponent\";\r\n\r\ndeclare module \"../../Meshes/transformNode\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface TransformNode {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n _physicsShape: Nullable<PhysicsShape>;\r\n\r\n /**\r\n *\r\n */\r\n physicsShape: Nullable<PhysicsShape>;\r\n\r\n getPhysicsShape(): Nullable<PhysicsShape>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsBody\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics body\r\n * @returns a physics body or null\r\n */\r\n/** @internal */\r\nTransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\r\n};\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsShape\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsShape;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsShape>) {\r\n if (this._physicsShape === value) {\r\n return;\r\n }\r\n\r\n if (this._physicsShape) {\r\n //<todo.eoin Remove from body\r\n }\r\n\r\n this._physicsShape = value;\r\n if (this._physicsShape) {\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n let cur: Nullable<Node> = this;\r\n while (cur) {\r\n if (cur instanceof TransformNode && cur.physicsBody) {\r\n cur.physicsBody.addNodeShape(this);\r\n }\r\n\r\n cur = cur.parent;\r\n }\r\n }\r\n },\r\n});\r\n\r\nTransformNode.prototype.getPhysicsShape = function (): Nullable<PhysicsShape> {\r\n return this.physicsShape;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nTransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n"]}
|
|
@@ -1,72 +1,78 @@
|
|
|
1
|
-
import type { Scene } from "../../scene";
|
|
2
|
-
import type { IPhysicsEnginePluginV2 } from "./IPhysicsEnginePlugin";
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Determines how values from the PhysicsMaterial are combined when
|
|
3
|
+
* two objects are in contact. When each PhysicsMaterial specifies
|
|
4
|
+
* a different combine mode for some property, the combine mode which
|
|
5
|
+
* is used will be selected based on their order in this enum - i.e.
|
|
6
|
+
* a value later in this list will be preferentially used.
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare enum PhysicsMaterialCombineMode {
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* The final value will be the geometric mean of the two values:
|
|
11
|
+
* sqrt( valueA * valueB )
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
GEOMETRIC_MEAN = 0,
|
|
12
14
|
/**
|
|
13
|
-
* The
|
|
15
|
+
* The final value will be the smaller of the two:
|
|
16
|
+
* min( valueA , valueB )
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
MINIMUM = 1,
|
|
19
|
+
MAXIMUM = 2,
|
|
20
|
+
ARITHMETIC_MEAN = 3,
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param restitution - The restitution of the material.
|
|
20
|
-
* @param scene - The scene to which the physics engine belongs.
|
|
21
|
-
*
|
|
22
|
-
* This code is useful for initializing the physics material with the
|
|
23
|
-
* given friction, restitution and scene. It also checks if the
|
|
24
|
-
* physics engine and plugin are available and if the plugin version
|
|
25
|
-
* is correct. If all conditions are met, it initializes the material
|
|
26
|
-
* with the physics plugin.
|
|
22
|
+
* The final value will be the product of the two values:
|
|
23
|
+
* valueA * valueB
|
|
27
24
|
*/
|
|
28
|
-
|
|
25
|
+
MULTIPLY = 4
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Physics material class
|
|
29
|
+
* Helps setting friction and restitution that are used to compute responding forces in collision response
|
|
30
|
+
*/
|
|
31
|
+
export interface PhysicsMaterial {
|
|
29
32
|
/**
|
|
30
|
-
* Sets the friction
|
|
31
|
-
* @param friction - The friction to set.
|
|
33
|
+
* Sets the friction used by this material
|
|
32
34
|
*
|
|
33
|
-
* This method is useful for setting the friction of the physics engine, which is important for simulating realistic physics.
|
|
34
35
|
* The friction determines how much an object will slow down when it is in contact with another object.
|
|
35
36
|
* This is important for simulating realistic physics, such as when an object slides across a surface.
|
|
37
|
+
*
|
|
38
|
+
* If not provided, a default value of 0.5 will be used.
|
|
36
39
|
*/
|
|
37
|
-
|
|
40
|
+
friction?: number;
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @returns The friction of the physics engine.
|
|
42
|
+
* Sets the static friction used by this material.
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* Static friction is the friction that must be overcome before a pair of objects can start sliding
|
|
45
|
+
* relative to each other; for physically-realistic behaviour, it should be at least as high as the
|
|
46
|
+
* normal friction value. If not provided, the friction value will be used
|
|
45
47
|
*/
|
|
46
|
-
|
|
48
|
+
staticFriction?: number;
|
|
47
49
|
/**
|
|
48
|
-
* Sets the restitution of the physics
|
|
49
|
-
*
|
|
50
|
+
* Sets the restitution of the physics material.
|
|
51
|
+
*
|
|
52
|
+
* The restitution is a factor which describes, the amount of energy that is retained after a collision,
|
|
53
|
+
* which should be a number between 0 and 1..
|
|
54
|
+
*
|
|
55
|
+
* A restitution of 0 means that no energy is retained and the objects will not bounce off each other,
|
|
56
|
+
* while a restitution of 1 means that all energy is retained and the objects will bounce.
|
|
57
|
+
*
|
|
58
|
+
* Note, though, due that due to the simulation implementation, an object with a restitution of 1 may
|
|
59
|
+
* still lose energy over time.
|
|
50
60
|
*
|
|
51
|
-
*
|
|
52
|
-
* A restitution of 0 means that no energy is retained, while a restitution of 1 means that all energy is retained.
|
|
53
|
-
* Setting the restitution of a body can help to create realistic physics simulations.
|
|
61
|
+
* If not provided, a default value of 0 will be used.
|
|
54
62
|
*/
|
|
55
|
-
|
|
63
|
+
restitution?: number;
|
|
56
64
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
65
|
+
* Describes how two different friction values should be combined. See PhysicsMaterialCombineMode for
|
|
66
|
+
* more details.
|
|
59
67
|
*
|
|
60
|
-
*
|
|
61
|
-
* Knowing the restitution of the physics engine can help to accurately simulate the behavior of objects in the physics engine.
|
|
68
|
+
* If not provided, will use PhysicsMaterialCombineMode.MINIMUM
|
|
62
69
|
*/
|
|
63
|
-
|
|
70
|
+
frictionCombine?: PhysicsMaterialCombineMode;
|
|
64
71
|
/**
|
|
65
|
-
*
|
|
72
|
+
* Describes how two different restitution values should be combined. See PhysicsMaterialCombineMode for
|
|
73
|
+
* more details.
|
|
66
74
|
*
|
|
67
|
-
*
|
|
68
|
-
* It calls the disposeMaterial method of the physics plugin, which is responsible for disposing the material and freeing up any resources associated with it.
|
|
69
|
-
* This ensures that the material is properly disposed of and does not cause any memory leaks.
|
|
75
|
+
* If not provided, will use PhysicsMaterialCombineMode.MAXIMUM
|
|
70
76
|
*/
|
|
71
|
-
|
|
77
|
+
restitutionCombine?: PhysicsMaterialCombineMode;
|
|
72
78
|
}
|
|
@@ -1,91 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Determines how values from the PhysicsMaterial are combined when
|
|
3
|
+
* two objects are in contact. When each PhysicsMaterial specifies
|
|
4
|
+
* a different combine mode for some property, the combine mode which
|
|
5
|
+
* is used will be selected based on their order in this enum - i.e.
|
|
6
|
+
* a value later in this list will be preferentially used.
|
|
4
7
|
*/
|
|
5
|
-
export
|
|
8
|
+
export var PhysicsMaterialCombineMode;
|
|
9
|
+
(function (PhysicsMaterialCombineMode) {
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param restitution - The restitution of the material.
|
|
10
|
-
* @param scene - The scene to which the physics engine belongs.
|
|
11
|
-
*
|
|
12
|
-
* This code is useful for initializing the physics material with the
|
|
13
|
-
* given friction, restitution and scene. It also checks if the
|
|
14
|
-
* physics engine and plugin are available and if the plugin version
|
|
15
|
-
* is correct. If all conditions are met, it initializes the material
|
|
16
|
-
* with the physics plugin.
|
|
11
|
+
* The final value will be the geometric mean of the two values:
|
|
12
|
+
* sqrt( valueA * valueB )
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* V2 Physics plugin private data for a physics material
|
|
21
|
-
*/
|
|
22
|
-
this._pluginData = undefined;
|
|
23
|
-
const physicsEngine = scene.getPhysicsEngine();
|
|
24
|
-
if (!physicsEngine) {
|
|
25
|
-
throw new Error("No Physics Engine available.");
|
|
26
|
-
}
|
|
27
|
-
if (physicsEngine.getPluginVersion() != 2) {
|
|
28
|
-
throw new Error("Plugin version is incorrect. Expected version 2.");
|
|
29
|
-
}
|
|
30
|
-
const physicsPlugin = physicsEngine.getPhysicsPlugin();
|
|
31
|
-
if (!physicsPlugin) {
|
|
32
|
-
throw new Error("No Physics Plugin available.");
|
|
33
|
-
}
|
|
34
|
-
this._physicsPlugin = physicsPlugin;
|
|
35
|
-
this._physicsPlugin.initMaterial(this);
|
|
36
|
-
}
|
|
14
|
+
PhysicsMaterialCombineMode[PhysicsMaterialCombineMode["GEOMETRIC_MEAN"] = 0] = "GEOMETRIC_MEAN";
|
|
37
15
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* This method is useful for setting the friction of the physics engine, which is important for simulating realistic physics.
|
|
42
|
-
* The friction determines how much an object will slow down when it is in contact with another object.
|
|
43
|
-
* This is important for simulating realistic physics, such as when an object slides across a surface.
|
|
16
|
+
* The final value will be the smaller of the two:
|
|
17
|
+
* min( valueA , valueB )
|
|
44
18
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Gets the friction of the physics engine.
|
|
50
|
-
*
|
|
51
|
-
* @returns The friction of the physics engine.
|
|
52
|
-
*
|
|
53
|
-
* This method is useful for getting the friction of the physics engine, which is used to calculate the force of friction between two objects.
|
|
54
|
-
* Knowing the friction of the engine can help to accurately simulate the physical behavior of objects in the engine.
|
|
55
|
-
*/
|
|
56
|
-
getFriction() {
|
|
57
|
-
return this._physicsPlugin.getFriction(this);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Sets the restitution of the physics body.
|
|
61
|
-
* @param restitution A number between 0 and 1 that represents the restitution of the body.
|
|
62
|
-
*
|
|
63
|
-
* This method is useful for setting the restitution of a physics body, which is the amount of energy that is retained after a collision.
|
|
64
|
-
* A restitution of 0 means that no energy is retained, while a restitution of 1 means that all energy is retained.
|
|
65
|
-
* Setting the restitution of a body can help to create realistic physics simulations.
|
|
19
|
+
PhysicsMaterialCombineMode[PhysicsMaterialCombineMode["MINIMUM"] = 1] = "MINIMUM";
|
|
20
|
+
/* The final value will be the larger of the two:
|
|
21
|
+
* max( valueA , valueB )
|
|
66
22
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Gets the restitution of the physics engine.
|
|
72
|
-
* @returns The restitution of the physics engine.
|
|
73
|
-
*
|
|
74
|
-
* This method is useful for retrieving the restitution of the physics engine, which is the amount of energy that is preserved after two objects collide.
|
|
75
|
-
* Knowing the restitution of the physics engine can help to accurately simulate the behavior of objects in the physics engine.
|
|
23
|
+
PhysicsMaterialCombineMode[PhysicsMaterialCombineMode["MAXIMUM"] = 2] = "MAXIMUM";
|
|
24
|
+
/* The final value will be the arithmetic mean of the two values:
|
|
25
|
+
* (valueA + valueB) / 2
|
|
76
26
|
*/
|
|
77
|
-
|
|
78
|
-
return this._physicsPlugin.getRestitution(this);
|
|
79
|
-
}
|
|
27
|
+
PhysicsMaterialCombineMode[PhysicsMaterialCombineMode["ARITHMETIC_MEAN"] = 3] = "ARITHMETIC_MEAN";
|
|
80
28
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* This method is useful for cleaning up the material when it is no longer needed.
|
|
84
|
-
* It calls the disposeMaterial method of the physics plugin, which is responsible for disposing the material and freeing up any resources associated with it.
|
|
85
|
-
* This ensures that the material is properly disposed of and does not cause any memory leaks.
|
|
29
|
+
* The final value will be the product of the two values:
|
|
30
|
+
* valueA * valueB
|
|
86
31
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
}
|
|
32
|
+
PhysicsMaterialCombineMode[PhysicsMaterialCombineMode["MULTIPLY"] = 4] = "MULTIPLY";
|
|
33
|
+
})(PhysicsMaterialCombineMode || (PhysicsMaterialCombineMode = {}));
|
|
91
34
|
//# sourceMappingURL=physicsMaterial.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,0BAwBX;AAxBD,WAAY,0BAA0B;IAClC;;;OAGG;IACH,+FAAc,CAAA;IACd;;;OAGG;IACH,iFAAO,CAAA;IACP;;OAEG;IACH,iFAAO,CAAA;IACP;;OAEG;IACH,iGAAe,CAAA;IACf;;;OAGG;IACH,mFAAQ,CAAA;AACZ,CAAC,EAxBW,0BAA0B,KAA1B,0BAA0B,QAwBrC","sourcesContent":["/**\r\n * Determines how values from the PhysicsMaterial are combined when\r\n * two objects are in contact. When each PhysicsMaterial specifies\r\n * a different combine mode for some property, the combine mode which\r\n * is used will be selected based on their order in this enum - i.e.\r\n * a value later in this list will be preferentially used.\r\n */\r\nexport enum PhysicsMaterialCombineMode {\r\n /**\r\n * The final value will be the geometric mean of the two values:\r\n * sqrt( valueA * valueB )\r\n */\r\n GEOMETRIC_MEAN,\r\n /**\r\n * The final value will be the smaller of the two:\r\n * min( valueA , valueB )\r\n */\r\n MINIMUM,\r\n /* The final value will be the larger of the two:\r\n * max( valueA , valueB )\r\n */\r\n MAXIMUM,\r\n /* The final value will be the arithmetic mean of the two values:\r\n * (valueA + valueB) / 2\r\n */\r\n ARITHMETIC_MEAN,\r\n /**\r\n * The final value will be the product of the two values:\r\n * valueA * valueB\r\n */\r\n MULTIPLY,\r\n}\r\n\r\n/**\r\n * Physics material class\r\n * Helps setting friction and restitution that are used to compute responding forces in collision response\r\n */\r\nexport interface PhysicsMaterial {\r\n /**\r\n * Sets the friction used by this material\r\n *\r\n * The friction determines how much an object will slow down when it is in contact with another object.\r\n * This is important for simulating realistic physics, such as when an object slides across a surface.\r\n *\r\n * If not provided, a default value of 0.5 will be used.\r\n */\r\n friction?: number;\r\n\r\n /**\r\n * Sets the static friction used by this material.\r\n *\r\n * Static friction is the friction that must be overcome before a pair of objects can start sliding\r\n * relative to each other; for physically-realistic behaviour, it should be at least as high as the\r\n * normal friction value. If not provided, the friction value will be used\r\n */\r\n staticFriction?: number;\r\n\r\n /**\r\n * Sets the restitution of the physics material.\r\n *\r\n * The restitution is a factor which describes, the amount of energy that is retained after a collision,\r\n * which should be a number between 0 and 1..\r\n *\r\n * A restitution of 0 means that no energy is retained and the objects will not bounce off each other,\r\n * while a restitution of 1 means that all energy is retained and the objects will bounce.\r\n *\r\n * Note, though, due that due to the simulation implementation, an object with a restitution of 1 may\r\n * still lose energy over time.\r\n *\r\n * If not provided, a default value of 0 will be used.\r\n */\r\n restitution?: number;\r\n\r\n /**\r\n * Describes how two different friction values should be combined. See PhysicsMaterialCombineMode for\r\n * more details.\r\n *\r\n * If not provided, will use PhysicsMaterialCombineMode.MINIMUM\r\n */\r\n frictionCombine?: PhysicsMaterialCombineMode;\r\n\r\n /**\r\n * Describes how two different restitution values should be combined. See PhysicsMaterialCombineMode for\r\n * more details.\r\n *\r\n * If not provided, will use PhysicsMaterialCombineMode.MAXIMUM\r\n */\r\n restitutionCombine?: PhysicsMaterialCombineMode;\r\n}\r\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TransformNode } from "../../Meshes/transformNode";
|
|
2
|
+
import type { AbstractMesh } from "../../Meshes/abstractMesh";
|
|
2
3
|
import type { BoundingBox } from "../../Culling/boundingBox";
|
|
3
4
|
import { ShapeType } from "./IPhysicsEnginePlugin";
|
|
4
5
|
import type { PhysicsShapeParameters } from "./IPhysicsEnginePlugin";
|
|
5
6
|
import type { PhysicsMaterial } from "./physicsMaterial";
|
|
6
|
-
import
|
|
7
|
-
import type { Quaternion } from "../../Maths/math.vector";
|
|
7
|
+
import { Vector3, Quaternion } from "../../Maths/math.vector";
|
|
8
8
|
import type { Mesh } from "../../Meshes/mesh";
|
|
9
9
|
import type { Scene } from "../../scene";
|
|
10
10
|
/**
|
|
@@ -39,6 +39,7 @@ export declare class PhysicsShape {
|
|
|
39
39
|
*/
|
|
40
40
|
private _physicsPlugin;
|
|
41
41
|
private _type;
|
|
42
|
+
private _material;
|
|
42
43
|
/**
|
|
43
44
|
* Constructs a new physics shape.
|
|
44
45
|
* @param options The options for the physics shape. These are:
|
|
@@ -61,31 +62,31 @@ export declare class PhysicsShape {
|
|
|
61
62
|
*
|
|
62
63
|
* @param layer
|
|
63
64
|
*/
|
|
64
|
-
|
|
65
|
+
set filterLayer(layer: number);
|
|
65
66
|
/**
|
|
66
67
|
*
|
|
67
68
|
* @returns
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
+
get filterLayer(): number;
|
|
70
71
|
/**
|
|
71
72
|
*
|
|
72
|
-
* @param
|
|
73
|
+
* @param material
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
|
+
set material(material: PhysicsMaterial);
|
|
75
76
|
/**
|
|
76
77
|
*
|
|
77
78
|
* @returns
|
|
78
79
|
*/
|
|
79
|
-
|
|
80
|
+
get material(): PhysicsMaterial;
|
|
80
81
|
/**
|
|
81
82
|
*
|
|
82
83
|
* @param density
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
+
set density(density: number);
|
|
85
86
|
/**
|
|
86
87
|
*
|
|
87
88
|
*/
|
|
88
|
-
|
|
89
|
+
get density(): number;
|
|
89
90
|
/**
|
|
90
91
|
*
|
|
91
92
|
* @param newChild
|
|
@@ -123,6 +124,12 @@ export declare class PhysicsShapeSphere extends PhysicsShape {
|
|
|
123
124
|
* @param scene scene to attach to
|
|
124
125
|
*/
|
|
125
126
|
constructor(center: Vector3, radius: number, scene: Scene);
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param mesh
|
|
130
|
+
* @returns PhysicsShapeSphere
|
|
131
|
+
*/
|
|
132
|
+
static FromMesh(mesh: AbstractMesh): PhysicsShapeSphere;
|
|
126
133
|
}
|
|
127
134
|
/**
|
|
128
135
|
* Helper object to create a capsule shape
|
|
@@ -136,6 +143,12 @@ export declare class PhysicsShapeCapsule extends PhysicsShape {
|
|
|
136
143
|
* @param scene scene to attach to
|
|
137
144
|
*/
|
|
138
145
|
constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene);
|
|
146
|
+
/**
|
|
147
|
+
* Derive an approximate capsule from the transform node. Note, this is
|
|
148
|
+
* not the optimal bounding capsule.
|
|
149
|
+
* @param TransformNode node Node from which to derive a cylinder shape
|
|
150
|
+
*/
|
|
151
|
+
static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule;
|
|
139
152
|
}
|
|
140
153
|
/**
|
|
141
154
|
* Helper object to create a cylinder shape
|
|
@@ -149,6 +162,12 @@ export declare class PhysicsShapeCylinder extends PhysicsShape {
|
|
|
149
162
|
* @param scene scene to attach to
|
|
150
163
|
*/
|
|
151
164
|
constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene);
|
|
165
|
+
/**
|
|
166
|
+
* Derive an approximate cylinder from the transform node. Note, this is
|
|
167
|
+
* not the optimal bounding cylinder.
|
|
168
|
+
* @param TransformNode node Node from which to derive a cylinder shape
|
|
169
|
+
*/
|
|
170
|
+
static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder;
|
|
152
171
|
}
|
|
153
172
|
/**
|
|
154
173
|
* Helper object to create a box shape
|
|
@@ -162,6 +181,12 @@ export declare class PhysicsShapeBox extends PhysicsShape {
|
|
|
162
181
|
* @param scene scene to attach to
|
|
163
182
|
*/
|
|
164
183
|
constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene);
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
* @param mesh
|
|
187
|
+
* @returns PhysicsShapeBox
|
|
188
|
+
*/
|
|
189
|
+
static FromMesh(mesh: AbstractMesh): PhysicsShapeBox;
|
|
165
190
|
}
|
|
166
191
|
/**
|
|
167
192
|
* Helper object to create a convex hull shape
|