From cc6d3871008a89fcf48814596d7bfec05f2706e4 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 7 Feb 2021 19:22:56 -0500 Subject: Added rotational dynamics to the examples --- frontend/_rigidbody/rigidbody_1.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'frontend/_rigidbody/rigidbody_1.js') diff --git a/frontend/_rigidbody/rigidbody_1.js b/frontend/_rigidbody/rigidbody_1.js index 5021162..c5e4f0a 100644 --- a/frontend/_rigidbody/rigidbody_1.js +++ b/frontend/_rigidbody/rigidbody_1.js @@ -72,9 +72,17 @@ function main() { ev.preventDefault(); ev.stopPropagation(); - const lXValue = $(this).find('.vec2_x_input').val(), + let lXValue = $(this).find('.vec2_x_input').val(), lYValue = $(this).find('.vec2_y_input').val(); + if (lXValue.length === 0) { + lXValue = 0; + } + + if (lYValue.length === 0) { + lYValue = 5000; + } + console.log('Applying force: ' + lXValue + ', ' + lYValue); lCircle.force = addVec2(lCircle.force, vec2(Number(lXValue), Number(lYValue))); } -- cgit v1.2.1