@babylonjs/core 5.40.0 → 5.41.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/Debug/physicsViewer.d.ts +13 -1
- package/Debug/physicsViewer.js +45 -0
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +13 -1
- package/Gizmos/axisDragGizmo.js +22 -12
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +13 -4
- package/Gizmos/axisScaleGizmo.js +23 -15
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +8 -3
- package/Gizmos/boundingBoxGizmo.js +35 -30
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +1 -1
- package/Gizmos/gizmo.js +3 -3
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +12 -0
- package/Gizmos/planeDragGizmo.js +12 -0
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +12 -0
- package/Gizmos/planeRotationGizmo.js +12 -0
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +12 -0
- package/Gizmos/scaleGizmo.js +12 -0
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +2 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/material.d.ts +2 -0
- package/Materials/material.js.map +1 -1
- package/Materials/shadowDepthWrapper.js +0 -1
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Misc/assetsManager.d.ts +1 -1
- package/Misc/assetsManager.js +1 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Physics/IPhysicsEngine.d.ts +1 -1
- package/Physics/IPhysicsEngine.js.map +1 -1
- package/Physics/physicsEngineComponent.d.ts +1 -1
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +8 -4
- package/Physics/v2/IPhysicsEnginePlugin.js +1 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +11 -1
- package/Physics/v2/physicsBody.js +23 -2
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +2 -2
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +19 -8
- package/Physics/v2/physicsEngine.js +23 -8
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsMaterial.d.ts +2 -2
- package/Physics/v2/physicsMaterial.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +1 -1
- package/Physics/v2/physicsShape.js +3 -3
- package/Physics/v2/physicsShape.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js +2 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/node.d.ts +2 -0
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,WAAW;IAYpB;;;;OAIG;IACH,YAAY,IAAmB,EAAE,KAAY;QAhB7C,gBAAgB;QACT,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAYzC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK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pC,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,MAAe;QACzC,OAAO,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,MAAe;QACrC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,uBAAuB,CAAC,MAAe;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,QAAiB,EAAE,OAAgB;QACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,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\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsBody {\r\n /** @internal */\r\n public _pluginData: any = undefined;\r\n /**\r\n *\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n *\r\n */\r\n node: TransformNode;\r\n /**\r\n *\r\n * @param scene\r\n * @returns\r\n */\r\n constructor(node: 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 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 (!node.rotationQuaternion) {\r\n node.rotationQuaternion = Quaternion.FromEulerAngles(node.rotation.x, node.rotation.y, node.rotation.z);\r\n }\r\n // instances?\r\n const m = node 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, node.position, node.rotationQuaternion);\r\n }\r\n this.node = node;\r\n physicsEngine.addBody(this);\r\n }\r\n /**\r\n *\r\n * @param shape\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param group\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param eventMask\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param massProps\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param damping\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param damping\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param linVel\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n *\r\n * @param angVel\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\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 *\r\n * @param location\r\n * @param impulse\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 public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeBody(this);\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Scene } from "../../scene";
|
|
2
2
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from "./IPhysicsEnginePlugin";
|
|
4
4
|
import { ConstraintType } from "./IPhysicsEnginePlugin";
|
|
5
5
|
import type { PhysicsBody } from "./physicsBody";
|
|
6
6
|
/**
|
|
@@ -15,7 +15,7 @@ export declare class PhysicsConstraint {
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
_pluginData: any;
|
|
18
|
-
protected _physicsPlugin:
|
|
18
|
+
protected _physicsPlugin: IPhysicsEnginePluginV2;
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
@@ -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;AAGxD;;;;GAIG;AACH,gBAAgB;AAChB,MAAM,OAAO,iBAAiB;IAQ1B;;OAEG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QAVpF,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAOhC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM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,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IACxD,gBAAgB;IAChB,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePlugin, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\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\n/** @internal */\r\nexport class PhysicsConstraint {\r\n /** @internal */\r\n /**\r\n *\r\n */\r\n public _pluginData: any = undefined;\r\n protected _physicsPlugin: IPhysicsEnginePlugin;\r\n\r\n /**\r\n *\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n return;\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 IPhysicsEnginePlugin;\r\n this._physicsPlugin.initConstraint(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setParentBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setParentBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getParentBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getParentBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setChildBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setChildBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getChildBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getChildBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot +\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInParent(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInChild(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\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\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param friction\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 *\r\n * @param axis\r\n * @returns\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 *\r\n * @param axis\r\n * @param limitMode\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 * @param axis\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintBallAndSocket extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintDistance extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintHinge extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintSlider extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintLock extends PhysicsConstraint {\r\n /** @internal */\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"]}
|
|
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;AAGxD;;;;GAIG;AACH,gBAAgB;AAChB,MAAM,OAAO,iBAAiB;IAQ1B;;OAEG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QAVpF,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAOhC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,cAAc,CAAC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AM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,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\nimport type { PhysicsBody } from \"./physicsBody\";\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\n/** @internal */\r\nexport class PhysicsConstraint {\r\n /** @internal */\r\n /**\r\n *\r\n */\r\n public _pluginData: any = undefined;\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n *\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n return;\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._physicsPlugin.initConstraint(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setParentBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setParentBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getParentBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getParentBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setChildBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setChildBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getChildBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getChildBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot +\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInParent(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInChild(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\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\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param friction\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 *\r\n * @param axis\r\n * @returns\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 *\r\n * @param axis\r\n * @param limitMode\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 * @param axis\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintBallAndSocket extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintDistance extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintHinge extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintSlider extends PhysicsConstraint {\r\n /** @internal */\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 *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintLock extends PhysicsConstraint {\r\n /** @internal */\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"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Nullable } from "../../types";
|
|
2
2
|
import { Vector3 } from "../../Maths/math.vector";
|
|
3
3
|
import type { IPhysicsEngine } from "../IPhysicsEngine";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IPhysicsEnginePluginV2 } from "./IPhysicsEnginePlugin";
|
|
5
5
|
import { PhysicsRaycastResult } from "../physicsRaycastResult";
|
|
6
|
+
import type { PhysicsBody } from "./physicsBody";
|
|
6
7
|
/**
|
|
7
8
|
* Class used to control physics engine
|
|
8
9
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
@@ -11,27 +12,28 @@ import { PhysicsRaycastResult } from "../physicsRaycastResult";
|
|
|
11
12
|
export declare class PhysicsEngine implements IPhysicsEngine {
|
|
12
13
|
private _physicsPlugin;
|
|
13
14
|
/** @internal */
|
|
14
|
-
|
|
15
|
-
* Global value used to control the smallest number supported by the simulation
|
|
16
|
-
*/
|
|
17
|
-
static Epsilon: number;
|
|
15
|
+
private _physicsBodies;
|
|
18
16
|
private _subTimeStep;
|
|
19
17
|
/**
|
|
20
18
|
* Gets the gravity vector used by the simulation
|
|
21
19
|
*/
|
|
22
20
|
gravity: Vector3;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @returns physics plugin version
|
|
24
|
+
*/
|
|
23
25
|
getPluginVersion(): number;
|
|
24
26
|
/**
|
|
25
27
|
* Factory used to create the default physics plugin.
|
|
26
28
|
* @returns The default physics plugin
|
|
27
29
|
*/
|
|
28
|
-
static DefaultPluginFactory():
|
|
30
|
+
static DefaultPluginFactory(): IPhysicsEnginePluginV2;
|
|
29
31
|
/**
|
|
30
32
|
* Creates a new Physics Engine
|
|
31
33
|
* @param gravity defines the gravity vector used by the simulation
|
|
32
34
|
* @param _physicsPlugin defines the plugin to use (CannonJS by default)
|
|
33
35
|
*/
|
|
34
|
-
constructor(gravity: Nullable<Vector3>, _physicsPlugin?:
|
|
36
|
+
constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePluginV2);
|
|
35
37
|
/**
|
|
36
38
|
* Sets the gravity vector used by the simulation
|
|
37
39
|
* @param gravity defines the gravity vector to use
|
|
@@ -81,11 +83,20 @@ export declare class PhysicsEngine implements IPhysicsEngine {
|
|
|
81
83
|
* @param delta defines the timespan between frames
|
|
82
84
|
*/
|
|
83
85
|
_step(delta: number): void;
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param body
|
|
89
|
+
*/
|
|
90
|
+
addBody(physicsBody: PhysicsBody): void;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
removeBody(physicsBody: PhysicsBody): void;
|
|
84
95
|
/**
|
|
85
96
|
* Gets the current plugin used to run the simulation
|
|
86
97
|
* @returns current plugin
|
|
87
98
|
*/
|
|
88
|
-
getPhysicsPlugin():
|
|
99
|
+
getPhysicsPlugin(): IPhysicsEnginePluginV2;
|
|
89
100
|
/**
|
|
90
101
|
* Does a raycast in the physics world
|
|
91
102
|
* @param from when should the ray start?
|
|
@@ -14,13 +14,17 @@ export class PhysicsEngine {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(gravity, _physicsPlugin = PhysicsEngine.DefaultPluginFactory()) {
|
|
16
16
|
this._physicsPlugin = _physicsPlugin;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** @internal */
|
|
18
|
+
this._physicsBodies = [];
|
|
19
19
|
this._subTimeStep = 0;
|
|
20
20
|
gravity = gravity || new Vector3(0, -9.807, 0);
|
|
21
21
|
this.setGravity(gravity);
|
|
22
22
|
this.setTimeStep();
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @returns physics plugin version
|
|
27
|
+
*/
|
|
24
28
|
getPluginVersion() {
|
|
25
29
|
return this._physicsPlugin.getPluginVersion();
|
|
26
30
|
}
|
|
@@ -108,7 +112,23 @@ export class PhysicsEngine {
|
|
|
108
112
|
else if (delta <= 0) {
|
|
109
113
|
delta = 1.0 / 60.0;
|
|
110
114
|
}
|
|
111
|
-
this._physicsPlugin.executeStep(delta);
|
|
115
|
+
this._physicsPlugin.executeStep(delta, this._physicsBodies);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @param body
|
|
120
|
+
*/
|
|
121
|
+
addBody(physicsBody) {
|
|
122
|
+
this._physicsBodies.push(physicsBody);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
removeBody(physicsBody) {
|
|
128
|
+
const index = this._physicsBodies.indexOf(physicsBody);
|
|
129
|
+
if (index > -1) {
|
|
130
|
+
/*const removed =*/ this._physicsBodies.splice(index, 1);
|
|
131
|
+
}
|
|
112
132
|
}
|
|
113
133
|
/**
|
|
114
134
|
* Gets the current plugin used to run the simulation
|
|
@@ -138,9 +158,4 @@ export class PhysicsEngine {
|
|
|
138
158
|
return result;
|
|
139
159
|
}
|
|
140
160
|
}
|
|
141
|
-
/** @internal */
|
|
142
|
-
/**
|
|
143
|
-
* Global value used to control the smallest number supported by the simulation
|
|
144
|
-
*/
|
|
145
|
-
PhysicsEngine.Epsilon = 0.001;
|
|
146
161
|
//# sourceMappingURL=physicsEngine.js.map
|
|
@@ -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;
|
|
1
|
+
{"version":3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c,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 //check if any mesh has no body / requires an update\r\n /*this._impostors.forEach((impostor) => {\r\n if (impostor.isBodyInitRequired()) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n });\r\n*/\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 *\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 *\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 /**\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Scene } from "../../scene";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IPhysicsEnginePluginV2 } from "./IPhysicsEnginePlugin";
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
@@ -10,7 +10,7 @@ export declare class PhysicsMaterial {
|
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
_pluginData: any;
|
|
13
|
-
protected _physicsPlugin:
|
|
13
|
+
protected _physicsPlugin: IPhysicsEnginePluginV2;
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param friction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,eAAe;IASxB;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,WAAmB,EAAE,KAAY;QAd/D,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAWhC,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,eAAe;IASxB;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,WAAmB,EAAE,KAAY;QAd/D,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAWhC,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD;;;OAGG;IACI,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,cAAc;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsMaterial {\r\n /** @internal */\r\n /**\r\n *\r\n */\r\n public _pluginData: any = undefined;\r\n\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n *\r\n * @param friction\r\n * @param restitution\r\n * @param scene\r\n */\r\n constructor(friction: number, restitution: number, scene: Scene) {\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._physicsPlugin.initMaterial(this);\r\n }\r\n /**\r\n *\r\n * @param friction\r\n */\r\n public setFriction(friction: number): void {\r\n this._physicsPlugin.setFriction(this, friction);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFriction(): number {\r\n return this._physicsPlugin.getFriction(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param restitution\r\n */\r\n public setRestitution(restitution: number): void {\r\n this._physicsPlugin.setRestitution(this, restitution);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getRestitution(): number {\r\n return this._physicsPlugin.getRestitution(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeMaterial(this);\r\n }\r\n}\r\n"]}
|
|
@@ -56,8 +56,8 @@ export class PhysicsShape {
|
|
|
56
56
|
*
|
|
57
57
|
* @param materialId
|
|
58
58
|
*/
|
|
59
|
-
setMaterial(
|
|
60
|
-
this._physicsPlugin.setMaterial(this,
|
|
59
|
+
setMaterial(material) {
|
|
60
|
+
this._physicsPlugin.setMaterial(this, material);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
*
|
|
@@ -127,7 +127,7 @@ export class PhysicsShapeSphere extends PhysicsShape {
|
|
|
127
127
|
* @param scene
|
|
128
128
|
*/
|
|
129
129
|
constructor(center, radius, scene) {
|
|
130
|
-
super(ShapeType.
|
|
130
|
+
super(ShapeType.SPHERE, { center: center, radius: radius }, scene);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
/***
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAQrB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAkC,EAAE,EAAE,KAAY;QAd5E,gBAAgB;QACT,gBAAW,GAAQ,SAAS,CAAC;QAchC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAqC,CAAC;QAC5D,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,KAAa;QAC/B,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC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AAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,YAAY;IACxD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePlugin, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShape {\r\n /** @internal */\r\n public _pluginData: any = undefined;\r\n\r\n private _physicsPlugin: IPhysicsEnginePlugin;\r\n\r\n private _type: ShapeType;\r\n\r\n /**\r\n *\r\n * @param type\r\n * @param options\r\n * @param scene\r\n * @returns\r\n */\r\n constructor(type: number, options: PhysicsShapeParameters = {}, scene: Scene) {\r\n this._type = type;\r\n if (!scene) {\r\n return;\r\n }\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 IPhysicsEnginePlugin;\r\n this._physicsPlugin.initShape(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get type(): ShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n *\r\n * @param layer\r\n */\r\n public setFilterLayer(layer: number): void {\r\n this._physicsPlugin.setFilterLayer(this, layer);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterLayer(): number {\r\n return this._physicsPlugin.getFilterLayer(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param materialId\r\n */\r\n public setMaterial(materialId: PhysicsMaterial): void {\r\n this._physicsPlugin.setMaterial(this, materialId);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMaterial(): PhysicsMaterial | undefined {\r\n return this._physicsPlugin.getMaterial(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public setDensity(density: number): void {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getDensity(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param newChild\r\n * @param childTransform\r\n */\r\n public addChild(newChild: PhysicsShape, childTransform: TransformNode): void {\r\n this._physicsPlugin.addChild(this, newChild, childTransform);\r\n }\r\n\r\n /**\r\n *\r\n * @param childIndex\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.BOX, { center: center, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/***\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CAPSULE, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CYLINDER, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeBox extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param rotation\r\n * @param extents\r\n * @param scene\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super(ShapeType.BOX, { center: center, rotation: rotation, extents: extents }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeConvexHull extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONVEX_HULL, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeMesh extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.MESH, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeContainer extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONTAINER, {}, scene);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAQrB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAkC,EAAE,EAAE,KAAY;QAd5E,gBAAgB;QACT,gBAAW,GAAQ,SAAS,CAAC;QAchC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD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,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAClD,gBAAgB;IAChB;;;;;;OAMG;IACH,YAAY,MAAe,EAAE,QAAoB,EAAE,OAAgB,EAAE,KAAY;QAC7E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1F,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,2BAA4B,SAAQ,YAAY;IACzD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,YAAY;IACxD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShape {\r\n /** @internal */\r\n public _pluginData: any = undefined;\r\n\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: ShapeType;\r\n\r\n /**\r\n *\r\n * @param type\r\n * @param options\r\n * @param scene\r\n * @returns\r\n */\r\n constructor(type: number, options: PhysicsShapeParameters = {}, scene: Scene) {\r\n this._type = type;\r\n if (!scene) {\r\n return;\r\n }\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._physicsPlugin.initShape(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get type(): ShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n *\r\n * @param layer\r\n */\r\n public setFilterLayer(layer: number): void {\r\n this._physicsPlugin.setFilterLayer(this, layer);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterLayer(): number {\r\n return this._physicsPlugin.getFilterLayer(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param materialId\r\n */\r\n public setMaterial(material: PhysicsMaterial): void {\r\n this._physicsPlugin.setMaterial(this, material);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMaterial(): PhysicsMaterial | undefined {\r\n return this._physicsPlugin.getMaterial(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public setDensity(density: number): void {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getDensity(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param newChild\r\n * @param childTransform\r\n */\r\n public addChild(newChild: PhysicsShape, childTransform: TransformNode): void {\r\n this._physicsPlugin.addChild(this, newChild, childTransform);\r\n }\r\n\r\n /**\r\n *\r\n * @param childIndex\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.SPHERE, { center: center, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/***\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CAPSULE, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CYLINDER, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeBox extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param rotation\r\n * @param extents\r\n * @param scene\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super(ShapeType.BOX, { center: center, rotation: rotation, extents: extents }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeConvexHull extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONVEX_HULL, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeMesh extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.MESH, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeContainer extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONTAINER, {}, scene);\r\n }\r\n}\r\n"]}
|
|
@@ -597,6 +597,8 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
597
597
|
cone.renderingGroupId = this._options.renderingGroupId;
|
|
598
598
|
}
|
|
599
599
|
this._options.teleportationTargetMesh = teleportationTarget;
|
|
600
|
+
// hide the teleportation target mesh right after creating it.
|
|
601
|
+
this._setTargetMeshVisibility(false);
|
|
600
602
|
}
|
|
601
603
|
_detachController(xrControllerUniqueId) {
|
|
602
604
|
const controllerData = this._controllers[xrControllerUniqueId];
|