diff --git a/js/lights.js b/js/lights.js index 2c35c46..d1c1ea0 100644 --- a/js/lights.js +++ b/js/lights.js @@ -87,21 +87,21 @@ function changeDirectLight() { } function changePointLight() { - lights.point.x = $('#point-light-position-x').val() - lights.point.y = $('#point-light-position-y').val() - lights.point.z = $('#point-light-position-z').val() - lights.point.decay = $('#point-light-decay').val() + lights.point.x = parseFloat($('#point-light-position-x').val()) + lights.point.y = parseFloat($('#point-light-position-y').val()) + lights.point.z = parseFloat($('#point-light-position-z').val()) + lights.point.decay = parseFloat($('#point-light-decay').val()) } function changeSpotLight() { - lights.spot.x = $('#spot-light-position-x').val() - lights.spot.y = $('#spot-light-position-y').val() - lights.spot.z = $('#spot-light-position-z').val() - lights.spot.decay = $('#spot-light-decay').val() + lights.spot.x = parseFloat($('#spot-light-position-x').val()) + lights.spot.y = parseFloat($('#spot-light-position-y').val()) + lights.spot.z = parseFloat($('#spot-light-position-z').val()) + lights.spot.decay = parseFloat($('#spot-light-decay').val()) lights.spot.phi = utils.degToRad($('#spot-light-position-phi').val()) lights.spot.theta = utils.degToRad($('#spot-light-position-theta').val()) - lights.spot.coneIn = $('#spot-light-cone-in').val() - lights.spot.coneOut = $('#spot-light-cone-out').val() + lights.spot.coneIn = parseFloat($('#spot-light-cone-in').val()) + lights.spot.coneOut = parseFloat($('#spot-light-cone-out').val()) } function setColor() { @@ -114,9 +114,9 @@ function setColor() { } function setSpecShine() { - lights.shiny = $('#specular-shiny').val() + lights.shiny = parseFloat($('#specular-shiny').val()) } function setTextureMix() { - lights.tMix = $('#texture-mix').val() + lights.tMix = parseFloat($('#texture-mix').val()) } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 14e1637..db865bd 100644 --- a/js/main.js +++ b/js/main.js @@ -61,8 +61,9 @@ function drawScene() { drawModel(missile.model1 ? models.missile1 : models.missile2, missileWorldMatrix, cm) drawModel(models.landscape, utils.MakeWorld(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1), cm) if (lights.lightType[1] === 1) { - drawModel(models.sphere, utils.MakeWorld(lights.point.x, lights.point.y + 0.1, lights.point.z, 0, 0, 0, 0.05), - cm, decodeColor(lights.colors.light), true) + let lightColor = decodeColor(lights.colors.light) + for (let i = 0; i < lightColor.length; i++) lightColor[i] *= 0.8 + lights.point.decay / 10.0 + drawModel(models.sphere, utils.MakeWorld(lights.point.x, lights.point.y, lights.point.z, 0, 0, 0, 0.05), cm, lightColor, true) } else if (lights.lightType[2] === 1) { const angle = lights.lightType[2] === 1 ? lights.spot.phi : 0 const elevation = lights.lightType[2] === 1 ? lights.spot.theta : 0