From 3d83129453d2d299af30632b80a3f3f1f701aff6 Mon Sep 17 00:00:00 2001 From: lrsb Date: Tue, 8 Sep 2020 16:27:14 +0200 Subject: [PATCH] final --- js/main.js | 2 +- js/misc.js | 2 +- js/models.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index 58ece88..573fbd3 100644 --- a/js/main.js +++ b/js/main.js @@ -61,6 +61,7 @@ function drawScene() { events.playing = false updateButtons() } + const missileDirection = utils.normalizeVector3(utils.subVector(nextPosition, position)) const missileWorldMatrix = utils.MakeWorldFromBetweenVectors(position[0], position[1], position[2], [0, 0, 1], missileDirection, 0.01) drawModel(missile.model1 ? models.missile1 : models.missile2, missileWorldMatrix, cm) @@ -84,7 +85,6 @@ function drawScene() { drawModel(models.sphere, sphereWorldMatrix, cm, [0, 0, 1], true) } - if (events.playing) missile.completion += (Date.now() - events.lastDrawTimestamp) / (1000.0 * settings.flightTime) events.lastDrawTimestamp = Date.now() diff --git a/js/misc.js b/js/misc.js index e1d99c4..c1e34bf 100644 --- a/js/misc.js +++ b/js/misc.js @@ -5,7 +5,7 @@ function getParabolicPoint(start, end, height, completion) { const distance = utils.modulusVector3(direction) const g = 9.81 * height - let alpha = Math.asin((end[1] - start[1]) / distance) + const alpha = Math.asin((end[1] - start[1]) / distance) const gamma = Math.atan2(0.5 * g * Math.cos(alpha), 0.5 * g * Math.sin(alpha) + distance) + alpha const v0 = 0.5 * g * Math.cos(alpha) / Math.sin(gamma - alpha) diff --git a/js/models.js b/js/models.js index bd3bb1c..91eda68 100644 --- a/js/models.js +++ b/js/models.js @@ -42,7 +42,7 @@ async function loadModel(modelName) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) gl.bindTexture(gl.TEXTURE_2D, null) events.onLoad-- - if (events.onLoad === 0) $('body').removeClass('loading') + if (!events.onLoad) $('body').removeClass('loading') } return {vao, mesh, texture} }