1 |
- {"ast":null,"code":"import { Vector3 } from \"../../Maths/math.vector.js\";\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult.js\";\nimport { _WarnImport } from \"../../Misc/devTools.js\";\n/**\n * Class used to control physics engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\n */\nexport class PhysicsEngine {\n /**\n *\n * @returns physics plugin version\n */\n getPluginVersion() {\n return this._physicsPlugin.getPluginVersion();\n }\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Factory used to create the default physics plugin.\n * @returns The default physics plugin\n */\n static DefaultPluginFactory() {\n throw _WarnImport(\"\");\n }\n /**\n * Creates a new Physics Engine\n * @param gravity defines the gravity vector used by the simulation\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\n */\n constructor(gravity, _physicsPlugin = PhysicsEngine.DefaultPluginFactory()) {\n this._physicsPlugin = _physicsPlugin;\n /** @internal */\n this._physicsBodies = [];\n this._subTimeStep = 0;\n gravity = gravity || new Vector3(0, -9.807, 0);\n this.setGravity(gravity);\n this.setTimeStep();\n }\n /**\n * Sets the gravity vector used by the simulation\n * @param gravity defines the gravity vector to use\n */\n setGravity(gravity) {\n this.gravity = gravity;\n this._physicsPlugin.setGravity(this.gravity);\n }\n /**\n * Set the time step of the physics engine.\n * Default is 1/60.\n * To slow it down, enter 1/600 for example.\n * To speed it up, 1/30\n * Unit is seconds.\n * @param newTimeStep defines the new timestep to apply to this world.\n */\n setTimeStep(newTimeStep = 1 / 60) {\n this._physicsPlugin.setTimeStep(newTimeStep);\n }\n /**\n * Get the time step of the physics engine.\n * @returns the current time step\n */\n getTimeStep() {\n return this._physicsPlugin.getTimeStep();\n }\n /**\n * Set the sub time step of the physics engine.\n * Default is 0 meaning there is no sub steps\n * To increase physics resolution precision, set a small value (like 1 ms)\n * @param subTimeStep defines the new sub timestep used for physics resolution.\n */\n setSubTimeStep(subTimeStep = 0) {\n this._subTimeStep = subTimeStep;\n }\n /**\n * Get the sub time step of the physics engine.\n * @returns the current sub time step\n */\n getSubTimeStep() {\n return this._subTimeStep;\n }\n /**\n * Release all resources\n */\n dispose() {\n this._physicsPlugin.dispose();\n }\n /**\n * Gets the name of the current physics plugin\n * @returns the name of the plugin\n */\n getPhysicsPluginName() {\n return this._physicsPlugin.name;\n }\n /**\n * Set the maximum allowed linear and angular velocities\n * @param maxLinearVelocity maximum allowed linear velocity\n * @param maxAngularVelocity maximum allowed angular velocity\n */\n setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {\n this._physicsPlugin.setVelocityLimits(maxLinearVelocity, maxAngularVelocity);\n }\n /**\n * @returns maximum allowed linear velocity\n */\n getMaxLinearVelocity() {\n return this._physicsPlugin.getMaxLinearVelocity();\n }\n /**\n * @returns maximum allowed angular velocity\n */\n getMaxAngularVelocity() {\n return this._physicsPlugin.getMaxAngularVelocity();\n }\n /**\n * Adding a new impostor for the impostor tracking.\n * This will be done by the impostor itself.\n * @param impostor the impostor to add\n */\n /**\n * Called by the scene. No need to call it.\n * @param delta defines the timespan between frames\n */\n _step(delta) {\n if (delta > 0.1) {\n delta = 0.1;\n } else if (delta <= 0) {\n delta = 1.0 / 60.0;\n }\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\n }\n /**\n * Add a body as an active component of this engine\n * @param physicsBody The body to add\n */\n addBody(physicsBody) {\n this._physicsBodies.push(physicsBody);\n }\n /**\n * Removes a particular body from this engine\n * @param physicsBody The body to remove from the simulation\n */\n removeBody(physicsBody) {\n const index = this._physicsBodies.indexOf(physicsBody);\n if (index > -1) {\n /*const removed =*/this._physicsBodies.splice(index, 1);\n }\n }\n /**\n * @returns an array of bodies added to this engine\n */\n getBodies() {\n return this._physicsBodies;\n }\n /**\n * Gets the current plugin used to run the simulation\n * @returns current plugin\n */\n getPhysicsPlugin() {\n return this._physicsPlugin;\n }\n /**\n * Does a raycast in the physics world\n * @param from when should the ray start?\n * @param to when should the ray end?\n * @param result resulting PhysicsRaycastResult\n * @param query raycast query object\n */\n raycastToRef(from, to, result, query) {\n this._physicsPlugin.raycast(from, to, result, query);\n }\n /**\n * Does a raycast in the physics world\n * @param from when should the ray start?\n * @param to when should the ray end?\n * @param query raycast query object\n * @returns PhysicsRaycastResult\n */\n raycast(from, to, query) {\n const result = new PhysicsRaycastResult();\n this._physicsPlugin.raycast(from, to, result, query);\n return result;\n }\n}","map":{"version":3,"names":["Vector3","PhysicsRaycastResult","_WarnImport","PhysicsEngine","getPluginVersion","_physicsPlugin","DefaultPluginFactory","constructor","gravity","_physicsBodies","_subTimeStep","setGravity","setTimeStep","newTimeStep","getTimeStep","setSubTimeStep","subTimeStep","getSubTimeStep","dispose","getPhysicsPluginName","name","setVelocityLimits","maxLinearVelocity","maxAngularVelocity","getMaxLinearVelocity","getMaxAngularVelocity","_step","delta","executeStep","addBody","physicsBody","push","removeBody","index","indexOf","splice","getBodies","getPhysicsPlugin","raycastToRef","from","to","result","query","raycast"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Physics/v2/physicsEngine.js"],"sourcesContent":["import { Vector3 } from \"../../Maths/math.vector.js\";\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult.js\";\nimport { _WarnImport } from \"../../Misc/devTools.js\";\n/**\n * Class used to control physics engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\n */\nexport class PhysicsEngine {\n /**\n *\n * @returns physics plugin version\n */\n getPluginVersion() {\n return this._physicsPlugin.getPluginVersion();\n }\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Factory used to create the default physics plugin.\n * @returns The default physics plugin\n */\n static DefaultPluginFactory() {\n throw _WarnImport(\"\");\n }\n /**\n * Creates a new Physics Engine\n * @param gravity defines the gravity vector used by the simulation\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\n */\n constructor(gravity, _physicsPlugin = PhysicsEngine.DefaultPluginFactory()) {\n this._physicsPlugin = _physicsPlugin;\n /** @internal */\n this._physicsBodies = [];\n this._subTimeStep = 0;\n gravity = gravity || new Vector3(0, -9.807, 0);\n this.setGravity(gravity);\n this.setTimeStep();\n }\n /**\n * Sets the gravity vector used by the simulation\n * @param gravity defines the gravity vector to use\n */\n setGravity(gravity) {\n this.gravity = gravity;\n this._physicsPlugin.setGravity(this.gravity);\n }\n /**\n * Set the time step of the physics engine.\n * Default is 1/60.\n * To slow it down, enter 1/600 for example.\n * To speed it up, 1/30\n * Unit is seconds.\n * @param newTimeStep defines the new timestep to apply to this world.\n */\n setTimeStep(newTimeStep = 1 / 60) {\n this._physicsPlugin.setTimeStep(newTimeStep);\n }\n /**\n * Get the time step of the physics engine.\n * @returns the current time step\n */\n getTimeStep() {\n return this._physicsPlugin.getTimeStep();\n }\n /**\n * Set the sub time step of the physics engine.\n * Default is 0 meaning there is no sub steps\n * To increase physics resolution precision, set a small value (like 1 ms)\n * @param subTimeStep defines the new sub timestep used for physics resolution.\n */\n setSubTimeStep(subTimeStep = 0) {\n this._subTimeStep = subTimeStep;\n }\n /**\n * Get the sub time step of the physics engine.\n * @returns the current sub time step\n */\n getSubTimeStep() {\n return this._subTimeStep;\n }\n /**\n * Release all resources\n */\n dispose() {\n this._physicsPlugin.dispose();\n }\n /**\n * Gets the name of the current physics plugin\n * @returns the name of the plugin\n */\n getPhysicsPluginName() {\n return this._physicsPlugin.name;\n }\n /**\n * Set the maximum allowed linear and angular velocities\n * @param maxLinearVelocity maximum allowed linear velocity\n * @param maxAngularVelocity maximum allowed angular velocity\n */\n setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {\n this._physicsPlugin.setVelocityLimits(maxLinearVelocity, maxAngularVelocity);\n }\n /**\n * @returns maximum allowed linear velocity\n */\n getMaxLinearVelocity() {\n return this._physicsPlugin.getMaxLinearVelocity();\n }\n /**\n * @returns maximum allowed angular velocity\n */\n getMaxAngularVelocity() {\n return this._physicsPlugin.getMaxAngularVelocity();\n }\n /**\n * Adding a new impostor for the impostor tracking.\n * This will be done by the impostor itself.\n * @param impostor the impostor to add\n */\n /**\n * Called by the scene. No need to call it.\n * @param delta defines the timespan between frames\n */\n _step(delta) {\n if (delta > 0.1) {\n delta = 0.1;\n }\n else if (delta <= 0) {\n delta = 1.0 / 60.0;\n }\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\n }\n /**\n * Add a body as an active component of this engine\n * @param physicsBody The body to add\n */\n addBody(physicsBody) {\n this._physicsBodies.push(physicsBody);\n }\n /**\n * Removes a particular body from this engine\n * @param physicsBody The body to remove from the simulation\n */\n removeBody(physicsBody) {\n const index = this._physicsBodies.indexOf(physicsBody);\n if (index > -1) {\n /*const removed =*/ this._physicsBodies.splice(index, 1);\n }\n }\n /**\n * @returns an array of bodies added to this engine\n */\n getBodies() {\n return this._physicsBodies;\n }\n /**\n * Gets the current plugin used to run the simulation\n * @returns current plugin\n */\n getPhysicsPlugin() {\n return this._physicsPlugin;\n }\n /**\n * Does a raycast in the physics world\n * @param from when should the ray start?\n * @param to when should the ray end?\n * @param result resulting PhysicsRaycastResult\n * @param query raycast query object\n */\n raycastToRef(from, to, result, query) {\n this._physicsPlugin.raycast(from, to, result, query);\n }\n /**\n * Does a raycast in the physics world\n * @param from when should the ray start?\n * @param to when should the ray end?\n * @param query raycast query object\n * @returns PhysicsRaycastResult\n */\n raycast(from, to, query) {\n const result = new PhysicsRaycastResult();\n this._physicsPlugin.raycast(from, to, result, query);\n return result;\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,4BAA4B;AACpD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,WAAW,QAAQ,wBAAwB;AACpD;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EACvB;AACJ;AACA;AACA;EACIC,gBAAgBA,CAAA,EAAG;IACf,OAAO,IAAI,CAACC,cAAc,CAACD,gBAAgB,CAAC,CAAC;EACjD;EACA;EACA;AACJ;AACA;AACA;EACI,OAAOE,oBAAoBA,CAAA,EAAG;IAC1B,MAAMJ,WAAW,CAAC,EAAE,CAAC;EACzB;EACA;AAC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AACA;AACA;AACA;EACIiC,YAAYA,CAACC,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAClC,IAAI,CAACrC,cAAc,CAACsC,OAAO,CAACJ,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAEC,KAAK,CAAC;EACxD;EACA;AACJ;AACA;AACA;AACA;AACA;AACA;EACIC,OAAOA,CAACJ,IAAI,EAAEC,EAAE,EAAEE,KAAK,EAAE;IACrB,MAAMD,MAAM,GAAG,IAAIxC,oBAAoB,CAAC,CAAC;IACzC,IAAI,CAACI,cAAc,CAACsC,OAAO,CAACJ,IAAI,EAAEC,EAAE,EAAEC,MAAM,EAAEC,KAAK,CAAC;IACpD,OAAOD,MAAM;EACjB;AACJ","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|