Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Launches a new ball from the camera position to the camera direction.
private _launchBall(info: PointerInfo): void {
// Create a new ball instance
const ballInstance = this._ball.createInstance("ballInstance");
// Create physics impostor for the ball instance
ballInstance.physicsImpostor = new PhysicsImpostor(ballInstance, PhysicsImpostor.SphereImpostor, { mass: 1, friction: 0.2, restitution: 0.2 });
// Apply impulse on ball
const force = this.getDirection(new Vector3(0, 0, 1)).multiplyByFloats(this._ballForceFactor, this._ballForceFactor, this._ballForceFactor);
ballInstance.applyImpulse(force, ballInstance.getAbsolutePosition());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.