1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

added imesh initial velocities

This commit is contained in:
1AlbertChen 2021-12-08 14:28:16 +08:00
parent 86664a06d8
commit 4ab88bda6d

View File

@ -159,7 +159,17 @@ export default function useCannon(options) {
if (mesh.userData.dampings?.[i]) damping = mesh.userData.dampings?.[i] if (mesh.userData.dampings?.[i]) damping = mesh.userData.dampings?.[i]
else if (mesh.userData.damping) damping = mesh.userData.damping else if (mesh.userData.damping) damping = mesh.userData.damping
const body = new Body({ shape, position, mass, linearDamping: damping, angularDamping: damping }) let velocity = new Vec3(0, 0, 0)
if (mesh.userData.velocities?.[i]) velocity = new Vec3(
mesh.userData.velocities?.[i].x,
mesh.userData.velocities?.[i].y,
mesh.userData.velocities?.[i].z)
else if (mesh.userData.velocities) velocity = new Vec3(
mesh.userData.velocities.x,
mesh.userData.velocities.y,
mesh.userData.velocities.z)
const body = new Body({ shape, position, velocity, mass, linearDamping: damping, angularDamping: damping })
world.addBody(body) world.addBody(body)
bodies.push(body) bodies.push(body)
} }