@@ -281,6 +281,20 @@ async function RapierPhysics() {
281281
282282 }
283283
284+ function applyImpulse ( mesh , impulse , index = 0 ) {
285+
286+ let { body } = meshMap . get ( mesh ) ;
287+
288+ if ( mesh . isInstancedMesh ) {
289+
290+ body = body [ index ] ;
291+
292+ }
293+
294+ body . applyImpulse ( impulse , true ) ;
295+
296+ }
297+
284298 function addHeightfield ( mesh , width , depth , heights , scale ) {
285299
286300 const shape = RAPIER . ColliderDesc . heightfield ( width , depth , heights , scale ) ;
@@ -414,7 +428,7 @@ async function RapierPhysics() {
414428
415429 /**
416430 * Adds a heightfield terrain to the physics simulation.
417- *
431+ *
418432 * @method
419433 * @name RapierPhysics#addHeightfield
420434 * @param {Mesh } mesh - The Three.js mesh representing the terrain.
@@ -427,7 +441,18 @@ async function RapierPhysics() {
427441 * @param {number } scale.z - Scale factor for depth.
428442 * @returns {RigidBody } The created Rapier rigid body for the heightfield.
429443 */
430- addHeightfield : addHeightfield
444+ addHeightfield : addHeightfield ,
445+
446+ /**
447+ * Applies an impulse to the given mesh which is part of the physics simulation.
448+ *
449+ * @method
450+ * @name RapierPhysics#applyImpulse
451+ * @param {Mesh } mesh - The mesh to apply the impulse to.
452+ * @param {Vector3 } impulse - The impulse to apply.
453+ * @param {number } [index=0] - If the mesh is instanced, the index represents the instanced ID.
454+ */
455+ applyImpulse : applyImpulse
431456
432457 } ;
433458
0 commit comments