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

Merge pull request #106 from 1albertchen/mesh-init-velocity

Set mesh initial velocity in cannonWorld
This commit is contained in:
Kevin LEVRON 2021-12-07 11:10:27 +01:00 committed by GitHub
commit 808df1dc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,12 @@ export default function useCannon(options) {
const mass = mesh.userData.mass ? mesh.userData.mass : 0
const damping = mesh.userData.damping ? mesh.userData.damping : 0.01
const body = new Body({ shape, position, quaternion, mass, linearDamping: damping, angularDamping: damping })
const velocity = mesh.userData.velocity ? new Vec3(
mesh.userData.velocity.x,
mesh.userData.velocity.y,
mesh.userData.velocity.z) : new Vec3(0, 0, 0)
const body = new Body({ shape, position, velocity, quaternion, mass, linearDamping: damping, angularDamping: damping })
world.addBody(body)
mesh.userData.body = body