点击反馈
-
注册点击事件
import React, { useRef } from 'react' import { Debug, Physics, RigidBody } from "@react-three/rapier" const cube = useRef() const cubeJump = () => {cube.current.applyImpulse({ x: 0, y: 2, z: 0 })cube.current.applyTorqueImpulse({x: Math.random() - 0.5,y: Math.random() - 0.5,z: Math.random() - 0.5})} ... <RigidBodyref={cube}position={[1.5, 3, 0]} restitution={1}friction={0} // 摩擦度 ><mesh castShadow onClick={cubeJump}><boxGeometry /><meshStandardMaterial color="mediumpurple" /></mesh> </RigidBody> ...
-
碰撞事件
const collisitonEnter = () => {console.log("collisitonEnter")}c