@onerjs/core 8.30.5 → 8.30.6
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/Actions/action.d.ts +5 -0
- package/Actions/action.js.map +1 -1
- package/Actions/actionManager.js +6 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +0 -2
- package/Animations/runtimeAnimation.js +3 -5
- package/Animations/runtimeAnimation.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +1 -0
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +2 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +18 -8
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +8 -3
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Collisions/gpuPicker.js +0 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +3 -1
- package/Decorators/nodeDecorator.js +2 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +12 -13
- package/Engines/nativeEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
- package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +8 -1
- package/FrameGraph/frameGraphContext.js +9 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
- package/FrameGraph/frameGraphRenderContext.js +11 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +8 -0
- package/FrameGraph/frameGraphTask.js +12 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +4 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/shaderMaterial.js +1 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +31 -5
- package/Maths/math.vector.functions.js +41 -4
- package/Maths/math.vector.functions.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +10 -0
- package/Misc/copyTextureToTexture.js +15 -0
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +29 -1
- package/Particles/Node/Blocks/systemBlock.js +74 -3
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +7 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +223 -58
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
- package/Physics/v2/Plugins/havokPlugin.js +72 -8
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +12 -2
- package/Physics/v2/physicsEngine.js +15 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/picking.fragment.js +1 -1
- package/Shaders/picking.fragment.js.map +1 -1
- package/Shaders/picking.vertex.js +1 -1
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +1 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +1 -1
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/Sprites/spriteRenderer.js +10 -8
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +8 -0
- package/XR/features/WebXRLightEstimation.js +6 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/assetContainer.d.ts +1 -1
- package/assetContainer.js +1 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +5 -2
- package/scene.js +9 -14
- package/scene.js.map +1 -1
|
@@ -416,6 +416,6 @@ export interface IPhysicsEnginePluginV2 {
|
|
|
416
416
|
getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;
|
|
417
417
|
disposeConstraint(constraint: PhysicsConstraint): void;
|
|
418
418
|
getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];
|
|
419
|
-
raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult
|
|
419
|
+
raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult | Array<PhysicsRaycastResult>, query?: IRaycastQuery): void;
|
|
420
420
|
dispose(): void;
|
|
421
421
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAaA,6CAA6C;AAC7C,MAAM,CAAN,IAAkB,8BAajB;AAbD,WAAkB,8BAA8B;IAC5C;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbiB,8BAA8B,KAA9B,8BAA8B,QAa/C;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAkB,qBAqCjB;AArCD,WAAkB,qBAAqB;IACnC;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;;OAIG;IACH,uFAAe,CAAA;AACnB,CAAC,EArCiB,qBAAqB,KAArB,qBAAqB,QAqCtC;AAED,yBAAyB;AACzB,MAAM,CAAN,IAAkB,qBAsCjB;AAtCD,WAAkB,qBAAqB;IACnC;;;OAGG;IACH,uFAAmB,CAAA;IACnB;;;OAGG;IACH,yEAAY,CAAA;IACZ;;;OAGG;IACH,mEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,iEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAa,CAAA;IACb;;;;OAIG;IACH,uEAAW,CAAA;AACf,CAAC,EAtCiB,qBAAqB,KAArB,qBAAqB,QAsCtC;AAED,oBAAoB;AACpB,MAAM,CAAN,IAAkB,gBASjB;AATD,WAAkB,gBAAgB;IAC9B,2DAAM,CAAA;IACN,6DAAO,CAAA;IACP,+DAAQ,CAAA;IACR,qDAAG,CAAA;IACH,qEAAW,CAAA;IACX,iEAAS,CAAA;IACT,uDAAI,CAAA;IACJ,qEAAW,CAAA;AACf,CAAC,EATiB,gBAAgB,KAAhB,gBAAgB,QASjC;AAED,qGAAqG;AACrG,MAAM,CAAN,IAAkB,0BAIjB;AAJD,WAAkB,0BAA0B;IACxC,2EAAI,CAAA;IACJ,mFAAQ,CAAA;IACR,mFAAQ,CAAA;AACZ,CAAC,EAJiB,0BAA0B,KAA1B,0BAA0B,QAI3C;AAED,MAAM,CAAN,IAAkB,gBAMjB;AAND,WAAkB,gBAAgB;IAC9B,2DAAuC,CAAA;IACvC,+DAA2C,CAAA;IAC3C,6DAAyC,CAAA;IACzC,uDAAmC,CAAA;IACnC,qDAAiC,CAAA;AACrC,CAAC,EANiB,gBAAgB,KAAhB,gBAAgB,QAMjC;AAoND;;GAEG;AACH,MAAM,CAAN,IAAkB,iBAIjB;AAJD,WAAkB,iBAAiB;IAC/B,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJiB,iBAAiB,KAAjB,iBAAiB,QAIlC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,mEAAQ,CAAA;IACR,mEAAQ,CAAA;IACR,+DAAM,CAAA;AACV,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAkB,wBAIjB;AAJD,WAAkB,wBAAwB;IACtC,yGAAqB,CAAA;IACrB,yFAAa,CAAA;IACb,6FAAe,CAAA;AACnB,CAAC,EAJiB,wBAAwB,KAAxB,wBAAwB,QAIzC","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observable } from \"../../Misc/observable\";\r\nimport type { GroundMesh } from \"../../Meshes/groundMesh\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport const enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport const enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport const enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport const enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport const enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport const enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n /**\r\n * The size of the heightfield in the X axis\r\n */\r\n heightFieldSizeX?: number;\r\n /**\r\n * The size of the heightfield in the Z axis\r\n */\r\n heightFieldSizeZ?: number;\r\n /**\r\n * The number of samples along the X axis\r\n */\r\n numHeightFieldSamplesX?: number;\r\n /**\r\n * The number of samples along the Z axis\r\n */\r\n numHeightFieldSamplesZ?: number;\r\n /**\r\n * The data for the heightfield\r\n */\r\n heightFieldData?: Float32Array;\r\n /**\r\n * Ground mesh used for display\r\n */\r\n groundMesh?: GroundMesh;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport const enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/**\r\n * Indicates how to handle position/rotation change of transform node attached to a physics body\r\n */\r\nexport enum PhysicsPrestepType {\r\n DISABLED,\r\n TELEPORT,\r\n ACTION,\r\n}\r\n\r\n/**\r\n * Controls the body sleep mode.\r\n */\r\nexport const enum PhysicsActivationControl {\r\n SIMULATION_CONTROLLED,\r\n ALWAYS_ACTIVE,\r\n ALWAYS_INACTIVE,\r\n}\r\n\r\n/**\r\n * Represents a pair of bodies connected by a constraint.\r\n */\r\nexport type ConstrainedBodyPair = { parentBody: PhysicsBody; parentBodyIndex: number; childBody: PhysicsBody; childBodyIndex: number };\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n /**\r\n * Collision ended observable\r\n */\r\n onCollisionEndedObservable: Observable<IBasePhysicsCollisionEvent>;\r\n /**\r\n * Trigger observable\r\n */\r\n onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n setVelocityLimits(maxLinearVelocity: number, maxAngularVelocity: number): void;\r\n getMaxLinearVelocity(): number;\r\n getMaxAngularVelocity(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyAngularImpulse(body: PhysicsBody, angularImpulse: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): object;\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n getMaterial(shape: PhysicsShape): PhysicsMaterial;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n getBodyBoundingBox(body: PhysicsBody): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAaA,6CAA6C;AAC7C,MAAM,CAAN,IAAkB,8BAajB;AAbD,WAAkB,8BAA8B;IAC5C;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbiB,8BAA8B,KAA9B,8BAA8B,QAa/C;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAkB,qBAqCjB;AArCD,WAAkB,qBAAqB;IACnC;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;OAGG;IACH,2EAAS,CAAA;IACT;;;;OAIG;IACH,uFAAe,CAAA;AACnB,CAAC,EArCiB,qBAAqB,KAArB,qBAAqB,QAqCtC;AAED,yBAAyB;AACzB,MAAM,CAAN,IAAkB,qBAsCjB;AAtCD,WAAkB,qBAAqB;IACnC;;;OAGG;IACH,uFAAmB,CAAA;IACnB;;;OAGG;IACH,yEAAY,CAAA;IACZ;;;OAGG;IACH,mEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAU,CAAA;IACV;;;OAGG;IACH,iEAAQ,CAAA;IACR;;;OAGG;IACH,2EAAa,CAAA;IACb;;;;OAIG;IACH,uEAAW,CAAA;AACf,CAAC,EAtCiB,qBAAqB,KAArB,qBAAqB,QAsCtC;AAED,oBAAoB;AACpB,MAAM,CAAN,IAAkB,gBASjB;AATD,WAAkB,gBAAgB;IAC9B,2DAAM,CAAA;IACN,6DAAO,CAAA;IACP,+DAAQ,CAAA;IACR,qDAAG,CAAA;IACH,qEAAW,CAAA;IACX,iEAAS,CAAA;IACT,uDAAI,CAAA;IACJ,qEAAW,CAAA;AACf,CAAC,EATiB,gBAAgB,KAAhB,gBAAgB,QASjC;AAED,qGAAqG;AACrG,MAAM,CAAN,IAAkB,0BAIjB;AAJD,WAAkB,0BAA0B;IACxC,2EAAI,CAAA;IACJ,mFAAQ,CAAA;IACR,mFAAQ,CAAA;AACZ,CAAC,EAJiB,0BAA0B,KAA1B,0BAA0B,QAI3C;AAED,MAAM,CAAN,IAAkB,gBAMjB;AAND,WAAkB,gBAAgB;IAC9B,2DAAuC,CAAA;IACvC,+DAA2C,CAAA;IAC3C,6DAAyC,CAAA;IACzC,uDAAmC,CAAA;IACnC,qDAAiC,CAAA;AACrC,CAAC,EANiB,gBAAgB,KAAhB,gBAAgB,QAMjC;AAoND;;GAEG;AACH,MAAM,CAAN,IAAkB,iBAIjB;AAJD,WAAkB,iBAAiB;IAC/B,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJiB,iBAAiB,KAAjB,iBAAiB,QAIlC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,mEAAQ,CAAA;IACR,mEAAQ,CAAA;IACR,+DAAM,CAAA;AACV,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAkB,wBAIjB;AAJD,WAAkB,wBAAwB;IACtC,yGAAqB,CAAA;IACrB,yFAAa,CAAA;IACb,6FAAe,CAAA;AACnB,CAAC,EAJiB,wBAAwB,KAAxB,wBAAwB,QAIzC","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observable } from \"../../Misc/observable\";\r\nimport type { GroundMesh } from \"../../Meshes/groundMesh\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport const enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport const enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport const enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport const enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport const enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport const enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n /**\r\n * The size of the heightfield in the X axis\r\n */\r\n heightFieldSizeX?: number;\r\n /**\r\n * The size of the heightfield in the Z axis\r\n */\r\n heightFieldSizeZ?: number;\r\n /**\r\n * The number of samples along the X axis\r\n */\r\n numHeightFieldSamplesX?: number;\r\n /**\r\n * The number of samples along the Z axis\r\n */\r\n numHeightFieldSamplesZ?: number;\r\n /**\r\n * The data for the heightfield\r\n */\r\n heightFieldData?: Float32Array;\r\n /**\r\n * Ground mesh used for display\r\n */\r\n groundMesh?: GroundMesh;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport const enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/**\r\n * Indicates how to handle position/rotation change of transform node attached to a physics body\r\n */\r\nexport enum PhysicsPrestepType {\r\n DISABLED,\r\n TELEPORT,\r\n ACTION,\r\n}\r\n\r\n/**\r\n * Controls the body sleep mode.\r\n */\r\nexport const enum PhysicsActivationControl {\r\n SIMULATION_CONTROLLED,\r\n ALWAYS_ACTIVE,\r\n ALWAYS_INACTIVE,\r\n}\r\n\r\n/**\r\n * Represents a pair of bodies connected by a constraint.\r\n */\r\nexport type ConstrainedBodyPair = { parentBody: PhysicsBody; parentBodyIndex: number; childBody: PhysicsBody; childBodyIndex: number };\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n /**\r\n * Collision ended observable\r\n */\r\n onCollisionEndedObservable: Observable<IBasePhysicsCollisionEvent>;\r\n /**\r\n * Trigger observable\r\n */\r\n onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n setVelocityLimits(maxLinearVelocity: number, maxAngularVelocity: number): void;\r\n getMaxLinearVelocity(): number;\r\n getMaxAngularVelocity(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyAngularImpulse(body: PhysicsBody, angularImpulse: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): object;\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n getMaterial(shape: PhysicsShape): PhysicsMaterial;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n getBodyBoundingBox(body: PhysicsBody): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult | Array<PhysicsRaycastResult>, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../../../Maths/math.vector.js";
|
|
2
2
|
import { PhysicsShapeType, PhysicsMotionType, PhysicsConstraintMotorType, PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode, PhysicsActivationControl } from "../IPhysicsEnginePlugin.js";
|
|
3
3
|
import type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent, IBasePhysicsCollisionEvent, ConstrainedBodyPair } from "../IPhysicsEnginePlugin.js";
|
|
4
|
-
import type { IRaycastQuery
|
|
4
|
+
import type { IRaycastQuery } from "../../physicsRaycastResult.js";
|
|
5
|
+
import { PhysicsRaycastResult } from "../../physicsRaycastResult.js";
|
|
5
6
|
import type { PhysicsBody } from "../physicsBody.js";
|
|
6
7
|
import type { PhysicsConstraint } from "../physicsConstraint.js";
|
|
7
8
|
import type { PhysicsMaterial } from "../physicsMaterial.js";
|
|
@@ -22,6 +23,12 @@ declare class BodyPluginData {
|
|
|
22
23
|
worldTransformOffset: number;
|
|
23
24
|
userMassProps: PhysicsMassProperties;
|
|
24
25
|
}
|
|
26
|
+
export interface HavokPluginParameters {
|
|
27
|
+
/**
|
|
28
|
+
* Maximum number of raycast hits to process
|
|
29
|
+
*/
|
|
30
|
+
maxQueryCollectorHits?: number;
|
|
31
|
+
}
|
|
25
32
|
/**
|
|
26
33
|
* The Havok Physics plugin
|
|
27
34
|
*/
|
|
@@ -43,7 +50,9 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
43
50
|
* We only have a single raycast in-flight right now
|
|
44
51
|
*/
|
|
45
52
|
private _queryCollector;
|
|
53
|
+
private _multiQueryCollector;
|
|
46
54
|
private _fixedTimeStep;
|
|
55
|
+
private _maxQueryCollectorHits;
|
|
47
56
|
private _tmpVec3;
|
|
48
57
|
private _bodies;
|
|
49
58
|
private _shapes;
|
|
@@ -63,7 +72,7 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
63
72
|
* Observable for trigger entered and trigger exited events
|
|
64
73
|
*/
|
|
65
74
|
onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>;
|
|
66
|
-
constructor(_useDeltaForWorldStep?: boolean, hpInjection?: any);
|
|
75
|
+
constructor(_useDeltaForWorldStep?: boolean, hpInjection?: any, parameters?: HavokPluginParameters);
|
|
67
76
|
/**
|
|
68
77
|
* If this plugin is supported
|
|
69
78
|
* @returns true if its supported
|
|
@@ -90,6 +99,18 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
90
99
|
*
|
|
91
100
|
*/
|
|
92
101
|
getTimeStep(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the maximum number of raycast hits to process.
|
|
104
|
+
*
|
|
105
|
+
* @param maxQueryCollectorHits - The maximum number of raycast hits to process.
|
|
106
|
+
*/
|
|
107
|
+
setMaxQueryCollectorHits(maxQueryCollectorHits: number): void;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the maximum number of raycast hits to process.
|
|
110
|
+
*
|
|
111
|
+
* @returns The maximum number of raycast hits to process.
|
|
112
|
+
*/
|
|
113
|
+
getMaxQueryCollectorHits(): number;
|
|
93
114
|
/**
|
|
94
115
|
* Executes a single step of the physics engine.
|
|
95
116
|
*
|
|
@@ -782,13 +803,15 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
|
|
|
782
803
|
*
|
|
783
804
|
* @param from - The start point of the raycast.
|
|
784
805
|
* @param to - The end point of the raycast.
|
|
785
|
-
* @param result - The PhysicsRaycastResult object to store the result of the raycast.
|
|
806
|
+
* @param result - The PhysicsRaycastResult object (or array of PhysicsRaycastResults) to store the result of the raycast.
|
|
786
807
|
* @param query - The raycast query options. See [[IRaycastQuery]] for more information.
|
|
787
808
|
*
|
|
788
809
|
* Performs a raycast. It takes in two points, from and to, and a PhysicsRaycastResult object to store the result of the raycast.
|
|
789
810
|
* It then performs the raycast and stores the hit data in the PhysicsRaycastResult object.
|
|
811
|
+
* If result is an empty array, it will be populated with every detected raycast hit.
|
|
812
|
+
* If result is a populated array, it will only fill the PhysicsRaycastResults present in the array.
|
|
790
813
|
*/
|
|
791
|
-
raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult
|
|
814
|
+
raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult | Array<PhysicsRaycastResult>, query?: IRaycastQuery): void;
|
|
792
815
|
/**
|
|
793
816
|
* Given a point, returns the closest physics
|
|
794
817
|
* body to that point.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
import { Matrix, Quaternion, TmpVectors, Vector3 } from "../../../Maths/math.vector.js";
|
|
4
4
|
import { PhysicsPrestepType, } from "../IPhysicsEnginePlugin.js";
|
|
5
|
+
import { PhysicsRaycastResult } from "../../physicsRaycastResult.js";
|
|
5
6
|
import { Logger } from "../../../Misc/logger.js";
|
|
6
7
|
import { PhysicsShape } from "../physicsShape.js";
|
|
7
8
|
import { BoundingBox } from "../../../Culling/boundingBox.js";
|
|
@@ -209,7 +210,7 @@ class TriggerEvent {
|
|
|
209
210
|
* The Havok Physics plugin
|
|
210
211
|
*/
|
|
211
212
|
export class HavokPlugin {
|
|
212
|
-
constructor(_useDeltaForWorldStep = true, hpInjection = HK) {
|
|
213
|
+
constructor(_useDeltaForWorldStep = true, hpInjection = HK, parameters = {}) {
|
|
213
214
|
this._useDeltaForWorldStep = _useDeltaForWorldStep;
|
|
214
215
|
/**
|
|
215
216
|
* Reference to the WASM library
|
|
@@ -219,7 +220,9 @@ export class HavokPlugin {
|
|
|
219
220
|
* Name of the plugin
|
|
220
221
|
*/
|
|
221
222
|
this.name = "HavokPlugin";
|
|
223
|
+
this._multiQueryCollector = undefined;
|
|
222
224
|
this._fixedTimeStep = 1 / 60;
|
|
225
|
+
this._maxQueryCollectorHits = 1;
|
|
223
226
|
this._tmpVec3 = BuildArray(3, Vector3.Zero);
|
|
224
227
|
this._bodies = new Map();
|
|
225
228
|
this._shapes = new Map();
|
|
@@ -252,6 +255,7 @@ export class HavokPlugin {
|
|
|
252
255
|
}
|
|
253
256
|
this.world = this._hknp.HP_World_Create()[1];
|
|
254
257
|
this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1];
|
|
258
|
+
this.setMaxQueryCollectorHits(parameters.maxQueryCollectorHits ?? 1);
|
|
255
259
|
}
|
|
256
260
|
/**
|
|
257
261
|
* If this plugin is supported
|
|
@@ -287,6 +291,31 @@ export class HavokPlugin {
|
|
|
287
291
|
getTimeStep() {
|
|
288
292
|
return this._fixedTimeStep;
|
|
289
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Sets the maximum number of raycast hits to process.
|
|
296
|
+
*
|
|
297
|
+
* @param maxQueryCollectorHits - The maximum number of raycast hits to process.
|
|
298
|
+
*/
|
|
299
|
+
setMaxQueryCollectorHits(maxQueryCollectorHits) {
|
|
300
|
+
if (maxQueryCollectorHits === this._maxQueryCollectorHits) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (this._multiQueryCollector) {
|
|
304
|
+
this._hknp.HP_QueryCollector_Release(this._multiQueryCollector);
|
|
305
|
+
this._multiQueryCollector = undefined;
|
|
306
|
+
}
|
|
307
|
+
if (maxQueryCollectorHits > 1) {
|
|
308
|
+
this._multiQueryCollector = this._hknp.HP_QueryCollector_Create(maxQueryCollectorHits)[1];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Gets the maximum number of raycast hits to process.
|
|
313
|
+
*
|
|
314
|
+
* @returns The maximum number of raycast hits to process.
|
|
315
|
+
*/
|
|
316
|
+
getMaxQueryCollectorHits() {
|
|
317
|
+
return this._maxQueryCollectorHits;
|
|
318
|
+
}
|
|
290
319
|
/**
|
|
291
320
|
* Executes a single step of the physics engine.
|
|
292
321
|
*
|
|
@@ -1870,24 +1899,55 @@ export class HavokPlugin {
|
|
|
1870
1899
|
*
|
|
1871
1900
|
* @param from - The start point of the raycast.
|
|
1872
1901
|
* @param to - The end point of the raycast.
|
|
1873
|
-
* @param result - The PhysicsRaycastResult object to store the result of the raycast.
|
|
1902
|
+
* @param result - The PhysicsRaycastResult object (or array of PhysicsRaycastResults) to store the result of the raycast.
|
|
1874
1903
|
* @param query - The raycast query options. See [[IRaycastQuery]] for more information.
|
|
1875
1904
|
*
|
|
1876
1905
|
* Performs a raycast. It takes in two points, from and to, and a PhysicsRaycastResult object to store the result of the raycast.
|
|
1877
1906
|
* It then performs the raycast and stores the hit data in the PhysicsRaycastResult object.
|
|
1907
|
+
* If result is an empty array, it will be populated with every detected raycast hit.
|
|
1908
|
+
* If result is a populated array, it will only fill the PhysicsRaycastResults present in the array.
|
|
1878
1909
|
*/
|
|
1879
1910
|
raycast(from, to, result, query) {
|
|
1880
1911
|
const queryMembership = query?.membership ?? ~0;
|
|
1881
1912
|
const queryCollideWith = query?.collideWith ?? ~0;
|
|
1882
1913
|
const shouldHitTriggers = query?.shouldHitTriggers ?? false;
|
|
1883
|
-
result.reset(from, to);
|
|
1884
1914
|
const bodyToIgnore = query?.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
|
|
1915
|
+
const results = Array.isArray(result) ? result : [result];
|
|
1916
|
+
for (const raycastResult of results) {
|
|
1917
|
+
raycastResult.reset(from, to);
|
|
1918
|
+
}
|
|
1885
1919
|
const hkQuery = [this._bVecToV3(from), this._bVecToV3(to), [queryMembership, queryCollideWith], shouldHitTriggers, bodyToIgnore];
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1920
|
+
const queryCollector = results.length === 1 || !this._multiQueryCollector ? this._queryCollector : this._multiQueryCollector;
|
|
1921
|
+
this._hknp.HP_World_CastRayWithCollector(this.world, queryCollector, hkQuery);
|
|
1922
|
+
const numHits = this._hknp.HP_QueryCollector_GetNumHits(queryCollector)[1];
|
|
1923
|
+
if (numHits <= 0) {
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
if (!results.length) {
|
|
1927
|
+
for (let i = 0; i < numHits; i++) {
|
|
1928
|
+
const raycastResult = new PhysicsRaycastResult();
|
|
1929
|
+
raycastResult.reset(from, to);
|
|
1930
|
+
results.push(raycastResult);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
// QueryCollector results are not sorted by distance, so we need to sort them manually
|
|
1934
|
+
const hitDatas = new Array(numHits);
|
|
1935
|
+
for (let i = 0; i < numHits; i++) {
|
|
1936
|
+
const [, hitData] = this._hknp.HP_QueryCollector_GetCastRayResult(queryCollector, i)[1];
|
|
1937
|
+
const hitPos = hitData[3];
|
|
1938
|
+
from.subtractFromFloatsToRef(hitPos[0], hitPos[1], hitPos[2], this._tmpVec3[0]);
|
|
1939
|
+
const distance = this._tmpVec3[0].lengthSquared();
|
|
1940
|
+
hitDatas[i] = {
|
|
1941
|
+
hitData,
|
|
1942
|
+
distance: distance,
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
hitDatas.sort((a, b) => a.distance - b.distance);
|
|
1946
|
+
for (let i = 0; i < Math.min(numHits, results.length); i++) {
|
|
1947
|
+
const raycastResult = results[i];
|
|
1948
|
+
const hitData = hitDatas[i];
|
|
1949
|
+
this._populateHitData(hitData.hitData, raycastResult);
|
|
1950
|
+
raycastResult.setHitDistance(Math.sqrt(hitData.distance));
|
|
1891
1951
|
}
|
|
1892
1952
|
}
|
|
1893
1953
|
/**
|
|
@@ -2137,6 +2197,10 @@ export class HavokPlugin {
|
|
|
2137
2197
|
this._hknp.HP_QueryCollector_Release(this._queryCollector);
|
|
2138
2198
|
this._queryCollector = undefined;
|
|
2139
2199
|
}
|
|
2200
|
+
if (this._multiQueryCollector) {
|
|
2201
|
+
this._hknp.HP_QueryCollector_Release(this._multiQueryCollector);
|
|
2202
|
+
this._multiQueryCollector;
|
|
2203
|
+
}
|
|
2140
2204
|
if (this.world) {
|
|
2141
2205
|
this._hknp.HP_World_Release(this.world);
|
|
2142
2206
|
this.world = undefined;
|