@babylonjs/core 5.45.1 → 5.45.2
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/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.js +12 -1
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +1 -0
- package/Materials/Textures/videoTexture.js +19 -8
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Physics/index.d.ts +1 -0
- package/Physics/index.js +1 -0
- package/Physics/index.js.map +1 -1
- package/Physics/physicsHelper.d.ts +452 -1
- package/Physics/physicsHelper.js +877 -2
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v1/index.d.ts +0 -1
- package/Physics/v1/index.js +0 -1
- package/Physics/v1/index.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/index.d.ts +1 -0
- package/Physics/v2/index.js +1 -0
- package/Physics/v2/index.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +18 -0
- package/Physics/v2/physicsAggregate.js +44 -2
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +22 -1
- package/Physics/v2/physicsBody.js +54 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +7 -2
- package/Physics/v2/physicsEngine.js +9 -2
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +4 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/package.json +1 -1
- package/Physics/v1/physicsHelper.d.ts +0 -411
- package/Physics/v1/physicsHelper.js +0 -709
- package/Physics/v1/physicsHelper.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["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d,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACI,iBAAiB,CAAC,IAA6F;QAClH,OAAO,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,IAA6F;QACpH,OAAO,IAAI,CAAC,cAAc,CAAC,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\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 if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param location The location of the impulse.\r\n * @param impulse The impulse vector.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(location: Vector3, impulse: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, location, impulse);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Register a collision callback that is called when the body collides\r\n * Filtering by body is inefficient. It's more preferable to register a collision callback for the entire world\r\n * and do the filtering on the user side.\r\n */\r\n public registerOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.registerOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Unregister a collision callback that is called when the body collides\r\n */\r\n public unregisterOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.unregisterOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Disposes the body 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() {\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM9D;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;;;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,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1B,yBAAyB;YACzB,IAAI,CAAC,aAAa,CAAC,kBAAkB,GAAG,CAAC,CAAC;YAC1C,kDAAkD;YAClD,IAAI,CAAC,aAAa,CAAC,kBAAkB,IAAI,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACrF,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,WAAW,CAAC,oBAAoB,CAAC;SAC3C;IACL,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,OAAO;QACP,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;;AA1Vc,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\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 if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param location The location of the impulse.\r\n * @param impulse The impulse vector.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(location: Vector3, impulse: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, location, impulse);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param location The location of the force.\r\n * @param force The force vector.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(location: Vector3, force: Vector3): void {\r\n this._physicsPlugin.applyForce(this, location, force);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Register a collision callback that is called when the body collides\r\n * Filtering by body is inefficient. It's more preferable to register a collision callback for the entire world\r\n * and do the filtering on the user side.\r\n */\r\n public registerOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.registerOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Unregister a collision callback that is called when the body collides\r\n */\r\n public unregisterOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.unregisterOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * return geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n // TODO\r\n return new Vector3(0, 0, 0);\r\n }\r\n\r\n /**\r\n * Disposes the body 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() {\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n }\r\n}\r\n"]}
|
|
@@ -84,14 +84,19 @@ export declare class PhysicsEngine implements IPhysicsEngine {
|
|
|
84
84
|
*/
|
|
85
85
|
_step(delta: number): void;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Add a body as an active component of this engine
|
|
88
88
|
* @param body
|
|
89
89
|
*/
|
|
90
90
|
addBody(physicsBody: PhysicsBody): void;
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Removes a particular body from this engine
|
|
93
93
|
*/
|
|
94
94
|
removeBody(physicsBody: PhysicsBody): void;
|
|
95
|
+
/**
|
|
96
|
+
* Returns an array of bodies added to this engine
|
|
97
|
+
|
|
98
|
+
*/
|
|
99
|
+
getBodies(): Array<PhysicsBody>;
|
|
95
100
|
/**
|
|
96
101
|
* Gets the current plugin used to run the simulation
|
|
97
102
|
* @returns current plugin
|
|
@@ -108,14 +108,14 @@ export class PhysicsEngine {
|
|
|
108
108
|
this._physicsPlugin.executeStep(delta, this._physicsBodies);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* Add a body as an active component of this engine
|
|
112
112
|
* @param body
|
|
113
113
|
*/
|
|
114
114
|
addBody(physicsBody) {
|
|
115
115
|
this._physicsBodies.push(physicsBody);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Removes a particular body from this engine
|
|
119
119
|
*/
|
|
120
120
|
removeBody(physicsBody) {
|
|
121
121
|
const index = this._physicsBodies.indexOf(physicsBody);
|
|
@@ -123,6 +123,13 @@ export class PhysicsEngine {
|
|
|
123
123
|
/*const removed =*/ this._physicsBodies.splice(index, 1);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns an array of bodies added to this engine
|
|
128
|
+
|
|
129
|
+
*/
|
|
130
|
+
getBodies() {
|
|
131
|
+
return this._physicsBodies;
|
|
132
|
+
}
|
|
126
133
|
/**
|
|
127
134
|
* Gets the current plugin used to run the simulation
|
|
128
135
|
* @returns current plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IA0BtB;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAyC,aAAa,CAAC,oBAAoB,EAAE;QAA7E,mBAAc,GAAd,cAAc,CAA+D;QA9B7H,gBAAgB;QACR,mBAAc,GAAuB,EAAE,CAAC;QACxC,iBAAY,GAAW,CAAC,CAAC;QA6B7B,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAxBD;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAaD;;;OAGG;IACI,UAAU,CAAC,OAAgB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAC,cAAsB,CAAC,GAAG,EAAE;QAC3C,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,CAA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,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n //private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n
|
|
1
|
+
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IA0BtB;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAyC,aAAa,CAAC,oBAAoB,EAAE;QAA7E,mBAAc,GAAd,cAAc,CAA+D;QA9B7H,gBAAgB;QACR,mBAAc,GAAuB,EAAE,CAAC;QACxC,iBAAY,GAAW,CAAC,CAAC;QA6B7B,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAxBD;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAaD;;;OAGG;IACI,UAAU,CAAC,OAAgB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,WAA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AS;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n //private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param body\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * Returns an array of bodies added to this engine\r\n\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._physicsPlugin.raycast(from, to, result);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result);\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -5,7 +5,10 @@ const shader = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTRO
|
|
|
5
5
|
#if defined(TANGENT) && defined(NORMAL)
|
|
6
6
|
varying mat3 vTBN;
|
|
7
7
|
#ifdef OBJECTSPACE_NORMALMAP
|
|
8
|
-
uniform mat4 normalMatrix;
|
|
8
|
+
uniform mat4 normalMatrix;
|
|
9
|
+
mat4 toNormalMatrix(mat4 wMatrix)
|
|
10
|
+
mat4 toNormalMatrix(mat4 m)
|
|
11
|
+
#endif
|
|
9
12
|
vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
|
|
10
13
|
normal=normalize(normal*vec3(scale,scale,1.0));
|
|
11
14
|
return normalize(cotangentFrame*normal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bumpFragmentMainFunctions.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/ShadersInclude/bumpFragmentMainFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,2BAA2B,CAAC;AACzC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"bumpFragmentMainFunctions.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/ShadersInclude/bumpFragmentMainFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,2BAA2B,CAAC;AACzC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Fd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"bumpFragmentMainFunctions\";\nconst shader = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\r#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\r#if defined(WEBGL2) || defined(WEBGPU)\nmat4 toNormalMatrix(mat4 wMatrix)\r{\rmat4 ret=inverse(wMatrix);\rret=transpose(ret);\rret[0][3]=0.;\rret[1][3]=0.;\rret[2][3]=0.;\rret[3]=vec4(0.,0.,0.,1.);\rreturn ret;\r}\r#else\nmat4 toNormalMatrix(mat4 m)\r{\rfloat\ra00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],\ra10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],\ra20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],\ra30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],\rb00=a00*a11-a01*a10,\rb01=a00*a12-a02*a10,\rb02=a00*a13-a03*a10,\rb03=a01*a12-a02*a11,\rb04=a01*a13-a03*a11,\rb05=a02*a13-a03*a12,\rb06=a20*a31-a21*a30,\rb07=a20*a32-a22*a30,\rb08=a20*a33-a23*a30,\rb09=a21*a32-a22*a31,\rb10=a21*a33-a23*a31,\rb11=a22*a33-a23*a32,\rdet=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;\rmat4 mi=mat4(\ra11*b11-a12*b10+a13*b09,\ra02*b10-a01*b11-a03*b09,\ra31*b05-a32*b04+a33*b03,\ra22*b04-a21*b05-a23*b03,\ra12*b08-a10*b11-a13*b07,\ra00*b11-a02*b08+a03*b07,\ra32*b02-a30*b05-a33*b01,\ra20*b05-a22*b02+a23*b01,\ra10*b10-a11*b08+a13*b06,\ra01*b08-a00*b10-a03*b06,\ra30*b04-a31*b02+a33*b00,\ra21*b02-a20*b04-a23*b00,\ra11*b07-a10*b09-a12*b06,\ra00*b09-a01*b07+a02*b06,\ra31*b01-a30*b03-a32*b00,\ra20*b03-a21*b01+a22*b00)/det;\rreturn mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],\rmi[0][1],mi[1][1],mi[2][1],mi[3][1],\rmi[0][2],mi[1][2],mi[2][2],mi[3][2],\rmi[0][3],mi[1][3],mi[2][3],mi[3][3]);\r}\r#endif\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\r{\r#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\r#endif\nreturn normalize(cotangentFrame*normal);\r}\rvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\r{\rreturn perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);\r}\rmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\r{\rvec3 dp1=dFdx(p);\rvec3 dp2=dFdy(p);\rvec2 duv1=dFdx(uv);\rvec2 duv2=dFdy(uv);\rvec3 dp2perp=cross(dp2,normal);\rvec3 dp1perp=cross(normal,dp1);\rvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\rvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\rtangent*=tangentSpaceParams.x;\rbitangent*=tangentSpaceParams.y;\rfloat det=max(dot(tangent,tangent),dot(bitangent,bitangent));\rfloat invmax=det==0.0 ? 0.0 : inversesqrt(det);\rreturn mat3(tangent*invmax,bitangent*invmax,normal);\r}\r#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const bumpFragmentMainFunctions = { name, shader };\n"]}
|
package/package.json
CHANGED
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import type { Nullable } from "../../types";
|
|
2
|
-
import { Vector3 } from "../../Maths/math.vector";
|
|
3
|
-
import type { Mesh } from "../../Meshes/mesh";
|
|
4
|
-
import type { Scene } from "../../scene";
|
|
5
|
-
import type { PhysicsImpostor } from "./physicsImpostor";
|
|
6
|
-
/**
|
|
7
|
-
* A helper for physics simulations
|
|
8
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
9
|
-
*/
|
|
10
|
-
export declare class PhysicsHelper {
|
|
11
|
-
private _scene;
|
|
12
|
-
private _physicsEngine;
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the Physics helper
|
|
15
|
-
* @param scene Babylon.js scene
|
|
16
|
-
*/
|
|
17
|
-
constructor(scene: Scene);
|
|
18
|
-
/**
|
|
19
|
-
* Applies a radial explosion impulse
|
|
20
|
-
* @param origin the origin of the explosion
|
|
21
|
-
* @param radiusOrEventOptions the radius or the options of radial explosion
|
|
22
|
-
* @param strength the explosion strength
|
|
23
|
-
* @param falloff possible options: Constant & Linear. Defaults to Constant
|
|
24
|
-
* @returns A physics radial explosion event, or null
|
|
25
|
-
*/
|
|
26
|
-
applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
|
|
27
|
-
/**
|
|
28
|
-
* Applies a radial explosion force
|
|
29
|
-
* @param origin the origin of the explosion
|
|
30
|
-
* @param radiusOrEventOptions the radius or the options of radial explosion
|
|
31
|
-
* @param strength the explosion strength
|
|
32
|
-
* @param falloff possible options: Constant & Linear. Defaults to Constant
|
|
33
|
-
* @returns A physics radial explosion event, or null
|
|
34
|
-
*/
|
|
35
|
-
applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
|
|
36
|
-
/**
|
|
37
|
-
* Creates a gravitational field
|
|
38
|
-
* @param origin the origin of the explosion
|
|
39
|
-
* @param radiusOrEventOptions the radius or the options of radial explosion
|
|
40
|
-
* @param strength the explosion strength
|
|
41
|
-
* @param falloff possible options: Constant & Linear. Defaults to Constant
|
|
42
|
-
* @returns A physics gravitational field event, or null
|
|
43
|
-
*/
|
|
44
|
-
gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a physics updraft event
|
|
47
|
-
* @param origin the origin of the updraft
|
|
48
|
-
* @param radiusOrEventOptions the radius or the options of the updraft
|
|
49
|
-
* @param strength the strength of the updraft
|
|
50
|
-
* @param height the height of the updraft
|
|
51
|
-
* @param updraftMode possible options: Center & Perpendicular. Defaults to Center
|
|
52
|
-
* @returns A physics updraft event, or null
|
|
53
|
-
*/
|
|
54
|
-
updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a physics vortex event
|
|
57
|
-
* @param origin the of the vortex
|
|
58
|
-
* @param radiusOrEventOptions the radius or the options of the vortex
|
|
59
|
-
* @param strength the strength of the vortex
|
|
60
|
-
* @param height the height of the vortex
|
|
61
|
-
* @returns a Physics vortex event, or null
|
|
62
|
-
* A physics vortex event or null
|
|
63
|
-
*/
|
|
64
|
-
vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Represents a physics radial explosion event
|
|
68
|
-
*/
|
|
69
|
-
declare class PhysicsRadialExplosionEvent {
|
|
70
|
-
private _scene;
|
|
71
|
-
private _options;
|
|
72
|
-
private _sphere;
|
|
73
|
-
private _dataFetched;
|
|
74
|
-
/**
|
|
75
|
-
* Initializes a radial explosion event
|
|
76
|
-
* @param _scene BabylonJS scene
|
|
77
|
-
* @param _options The options for the vortex event
|
|
78
|
-
*/
|
|
79
|
-
constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
|
|
80
|
-
/**
|
|
81
|
-
* Returns the data related to the radial explosion event (sphere).
|
|
82
|
-
* @returns The radial explosion event data
|
|
83
|
-
*/
|
|
84
|
-
getData(): PhysicsRadialExplosionEventData;
|
|
85
|
-
/**
|
|
86
|
-
* Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
|
|
87
|
-
* @param impostor A physics imposter
|
|
88
|
-
* @param origin the origin of the explosion
|
|
89
|
-
* @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
|
|
90
|
-
*/
|
|
91
|
-
getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
|
|
92
|
-
/**
|
|
93
|
-
* Triggers affected impostors callbacks
|
|
94
|
-
* @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
|
|
95
|
-
*/
|
|
96
|
-
triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
|
|
97
|
-
/**
|
|
98
|
-
* Disposes the sphere.
|
|
99
|
-
* @param force Specifies if the sphere should be disposed by force
|
|
100
|
-
*/
|
|
101
|
-
dispose(force?: boolean): void;
|
|
102
|
-
/*** Helpers ***/
|
|
103
|
-
private _prepareSphere;
|
|
104
|
-
private _intersectsWithSphere;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Represents a gravitational field event
|
|
108
|
-
*/
|
|
109
|
-
declare class PhysicsGravitationalFieldEvent {
|
|
110
|
-
private _physicsHelper;
|
|
111
|
-
private _scene;
|
|
112
|
-
private _origin;
|
|
113
|
-
private _options;
|
|
114
|
-
private _tickCallback;
|
|
115
|
-
private _sphere;
|
|
116
|
-
private _dataFetched;
|
|
117
|
-
/**
|
|
118
|
-
* Initializes the physics gravitational field event
|
|
119
|
-
* @param _physicsHelper A physics helper
|
|
120
|
-
* @param _scene BabylonJS scene
|
|
121
|
-
* @param _origin The origin position of the gravitational field event
|
|
122
|
-
* @param _options The options for the vortex event
|
|
123
|
-
*/
|
|
124
|
-
constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
|
|
125
|
-
/**
|
|
126
|
-
* Returns the data related to the gravitational field event (sphere).
|
|
127
|
-
* @returns A gravitational field event
|
|
128
|
-
*/
|
|
129
|
-
getData(): PhysicsGravitationalFieldEventData;
|
|
130
|
-
/**
|
|
131
|
-
* Enables the gravitational field.
|
|
132
|
-
*/
|
|
133
|
-
enable(): void;
|
|
134
|
-
/**
|
|
135
|
-
* Disables the gravitational field.
|
|
136
|
-
*/
|
|
137
|
-
disable(): void;
|
|
138
|
-
/**
|
|
139
|
-
* Disposes the sphere.
|
|
140
|
-
* @param force The force to dispose from the gravitational field event
|
|
141
|
-
*/
|
|
142
|
-
dispose(force?: boolean): void;
|
|
143
|
-
private _tick;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Represents a physics updraft event
|
|
147
|
-
*/
|
|
148
|
-
declare class PhysicsUpdraftEvent {
|
|
149
|
-
private _scene;
|
|
150
|
-
private _origin;
|
|
151
|
-
private _options;
|
|
152
|
-
private _physicsEngine;
|
|
153
|
-
private _originTop;
|
|
154
|
-
private _originDirection;
|
|
155
|
-
private _tickCallback;
|
|
156
|
-
private _cylinder;
|
|
157
|
-
private _cylinderPosition;
|
|
158
|
-
private _dataFetched;
|
|
159
|
-
/**
|
|
160
|
-
* Initializes the physics updraft event
|
|
161
|
-
* @param _scene BabylonJS scene
|
|
162
|
-
* @param _origin The origin position of the updraft
|
|
163
|
-
* @param _options The options for the updraft event
|
|
164
|
-
*/
|
|
165
|
-
constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
|
|
166
|
-
/**
|
|
167
|
-
* Returns the data related to the updraft event (cylinder).
|
|
168
|
-
* @returns A physics updraft event
|
|
169
|
-
*/
|
|
170
|
-
getData(): PhysicsUpdraftEventData;
|
|
171
|
-
/**
|
|
172
|
-
* Enables the updraft.
|
|
173
|
-
*/
|
|
174
|
-
enable(): void;
|
|
175
|
-
/**
|
|
176
|
-
* Disables the updraft.
|
|
177
|
-
*/
|
|
178
|
-
disable(): void;
|
|
179
|
-
/**
|
|
180
|
-
* Disposes the cylinder.
|
|
181
|
-
* @param force Specifies if the updraft should be disposed by force
|
|
182
|
-
*/
|
|
183
|
-
dispose(force?: boolean): void;
|
|
184
|
-
private _getImpostorHitData;
|
|
185
|
-
private _tick;
|
|
186
|
-
/*** Helpers ***/
|
|
187
|
-
private _prepareCylinder;
|
|
188
|
-
private _intersectsWithCylinder;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Represents a physics vortex event
|
|
192
|
-
*/
|
|
193
|
-
declare class PhysicsVortexEvent {
|
|
194
|
-
private _scene;
|
|
195
|
-
private _origin;
|
|
196
|
-
private _options;
|
|
197
|
-
private _physicsEngine;
|
|
198
|
-
private _originTop;
|
|
199
|
-
private _tickCallback;
|
|
200
|
-
private _cylinder;
|
|
201
|
-
private _cylinderPosition;
|
|
202
|
-
private _dataFetched;
|
|
203
|
-
/**
|
|
204
|
-
* Initializes the physics vortex event
|
|
205
|
-
* @param _scene The BabylonJS scene
|
|
206
|
-
* @param _origin The origin position of the vortex
|
|
207
|
-
* @param _options The options for the vortex event
|
|
208
|
-
*/
|
|
209
|
-
constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
|
|
210
|
-
/**
|
|
211
|
-
* Returns the data related to the vortex event (cylinder).
|
|
212
|
-
* @returns The physics vortex event data
|
|
213
|
-
*/
|
|
214
|
-
getData(): PhysicsVortexEventData;
|
|
215
|
-
/**
|
|
216
|
-
* Enables the vortex.
|
|
217
|
-
*/
|
|
218
|
-
enable(): void;
|
|
219
|
-
/**
|
|
220
|
-
* Disables the cortex.
|
|
221
|
-
*/
|
|
222
|
-
disable(): void;
|
|
223
|
-
/**
|
|
224
|
-
* Disposes the sphere.
|
|
225
|
-
* @param force
|
|
226
|
-
*/
|
|
227
|
-
dispose(force?: boolean): void;
|
|
228
|
-
private _getImpostorHitData;
|
|
229
|
-
private _tick;
|
|
230
|
-
/*** Helpers ***/
|
|
231
|
-
private _prepareCylinder;
|
|
232
|
-
private _intersectsWithCylinder;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Options fot the radial explosion event
|
|
236
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
237
|
-
*/
|
|
238
|
-
export declare class PhysicsRadialExplosionEventOptions {
|
|
239
|
-
/**
|
|
240
|
-
* The radius of the sphere for the radial explosion.
|
|
241
|
-
*/
|
|
242
|
-
radius: number;
|
|
243
|
-
/**
|
|
244
|
-
* The strength of the explosion.
|
|
245
|
-
*/
|
|
246
|
-
strength: number;
|
|
247
|
-
/**
|
|
248
|
-
* The strength of the force in correspondence to the distance of the affected object
|
|
249
|
-
*/
|
|
250
|
-
falloff: PhysicsRadialImpulseFalloff;
|
|
251
|
-
/**
|
|
252
|
-
* Sphere options for the radial explosion.
|
|
253
|
-
*/
|
|
254
|
-
sphere: {
|
|
255
|
-
segments: number;
|
|
256
|
-
diameter: number;
|
|
257
|
-
};
|
|
258
|
-
/**
|
|
259
|
-
* Sphere options for the radial explosion.
|
|
260
|
-
*/
|
|
261
|
-
affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Options fot the updraft event
|
|
265
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
266
|
-
*/
|
|
267
|
-
export declare class PhysicsUpdraftEventOptions {
|
|
268
|
-
/**
|
|
269
|
-
* The radius of the cylinder for the vortex
|
|
270
|
-
*/
|
|
271
|
-
radius: number;
|
|
272
|
-
/**
|
|
273
|
-
* The strength of the updraft.
|
|
274
|
-
*/
|
|
275
|
-
strength: number;
|
|
276
|
-
/**
|
|
277
|
-
* The height of the cylinder for the updraft.
|
|
278
|
-
*/
|
|
279
|
-
height: number;
|
|
280
|
-
/**
|
|
281
|
-
* The mode for the the updraft.
|
|
282
|
-
*/
|
|
283
|
-
updraftMode: PhysicsUpdraftMode;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Options fot the vortex event
|
|
287
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
288
|
-
*/
|
|
289
|
-
export declare class PhysicsVortexEventOptions {
|
|
290
|
-
/**
|
|
291
|
-
* The radius of the cylinder for the vortex
|
|
292
|
-
*/
|
|
293
|
-
radius: number;
|
|
294
|
-
/**
|
|
295
|
-
* The strength of the vortex.
|
|
296
|
-
*/
|
|
297
|
-
strength: number;
|
|
298
|
-
/**
|
|
299
|
-
* The height of the cylinder for the vortex.
|
|
300
|
-
*/
|
|
301
|
-
height: number;
|
|
302
|
-
/**
|
|
303
|
-
* At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
|
|
304
|
-
*/
|
|
305
|
-
centripetalForceThreshold: number;
|
|
306
|
-
/**
|
|
307
|
-
* This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
|
|
308
|
-
*/
|
|
309
|
-
centripetalForceMultiplier: number;
|
|
310
|
-
/**
|
|
311
|
-
* This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
|
|
312
|
-
*/
|
|
313
|
-
centrifugalForceMultiplier: number;
|
|
314
|
-
/**
|
|
315
|
-
* This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
|
|
316
|
-
*/
|
|
317
|
-
updraftForceMultiplier: number;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* The strength of the force in correspondence to the distance of the affected object
|
|
321
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
322
|
-
*/
|
|
323
|
-
export declare enum PhysicsRadialImpulseFalloff {
|
|
324
|
-
/** Defines that impulse is constant in strength across it's whole radius */
|
|
325
|
-
Constant = 0,
|
|
326
|
-
/** Defines that impulse gets weaker if it's further from the origin */
|
|
327
|
-
Linear = 1
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* The strength of the force in correspondence to the distance of the affected object
|
|
331
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
332
|
-
*/
|
|
333
|
-
export declare enum PhysicsUpdraftMode {
|
|
334
|
-
/** Defines that the upstream forces will pull towards the top center of the cylinder */
|
|
335
|
-
Center = 0,
|
|
336
|
-
/** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
|
|
337
|
-
Perpendicular = 1
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Interface for a physics hit data
|
|
341
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
342
|
-
*/
|
|
343
|
-
export interface PhysicsHitData {
|
|
344
|
-
/**
|
|
345
|
-
* The force applied at the contact point
|
|
346
|
-
*/
|
|
347
|
-
force: Vector3;
|
|
348
|
-
/**
|
|
349
|
-
* The contact point
|
|
350
|
-
*/
|
|
351
|
-
contactPoint: Vector3;
|
|
352
|
-
/**
|
|
353
|
-
* The distance from the origin to the contact point
|
|
354
|
-
*/
|
|
355
|
-
distanceFromOrigin: number;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Interface for radial explosion event data
|
|
359
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
360
|
-
*/
|
|
361
|
-
export interface PhysicsRadialExplosionEventData {
|
|
362
|
-
/**
|
|
363
|
-
* A sphere used for the radial explosion event
|
|
364
|
-
*/
|
|
365
|
-
sphere: Mesh;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Interface for gravitational field event data
|
|
369
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
370
|
-
*/
|
|
371
|
-
export interface PhysicsGravitationalFieldEventData {
|
|
372
|
-
/**
|
|
373
|
-
* A sphere mesh used for the gravitational field event
|
|
374
|
-
*/
|
|
375
|
-
sphere: Mesh;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Interface for updraft event data
|
|
379
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
380
|
-
*/
|
|
381
|
-
export interface PhysicsUpdraftEventData {
|
|
382
|
-
/**
|
|
383
|
-
* A cylinder used for the updraft event
|
|
384
|
-
*/
|
|
385
|
-
cylinder: Mesh;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Interface for vortex event data
|
|
389
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
390
|
-
*/
|
|
391
|
-
export interface PhysicsVortexEventData {
|
|
392
|
-
/**
|
|
393
|
-
* A cylinder used for the vortex event
|
|
394
|
-
*/
|
|
395
|
-
cylinder: Mesh;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Interface for an affected physics impostor
|
|
399
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
|
|
400
|
-
*/
|
|
401
|
-
export interface PhysicsAffectedImpostorWithData {
|
|
402
|
-
/**
|
|
403
|
-
* The impostor affected by the effect
|
|
404
|
-
*/
|
|
405
|
-
impostor: PhysicsImpostor;
|
|
406
|
-
/**
|
|
407
|
-
* The data about the hit/force from the explosion
|
|
408
|
-
*/
|
|
409
|
-
hitData: PhysicsHitData;
|
|
410
|
-
}
|
|
411
|
-
export {};
|