1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

Merge pull request #110 from 1AlbertChen/imesh-init-velocities

Set InstancedMesh initial velocities in cannonWorld
This commit is contained in:
Kevin LEVRON 2021-12-15 18:30:42 +01:00 committed by GitHub
commit aee1719ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)
} }