From 99d891a2e88eb93280b9e0ce31eaca011d105f84 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 22 Nov 2022 10:25:34 +0200 Subject: [OKG/HWK2] animationData property getting is approximated --- .../Homework 2/mannequin.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html index 2864dbc..3099725 100644 --- a/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html +++ b/Year 2/Computer Graphics Fundamentals/Homework 2/mannequin.html @@ -174,8 +174,9 @@ { t = Math.floor(t) / 100; - if (animationData.hasOwnProperty(t)) { - for (var instr of animationData[t]) { + var prop = approxProp(animationData, t); + if (prop) + for (var instr of prop) { if (instr[1].constructor === Array) { executeHooks.push({ start : t, @@ -203,7 +204,6 @@ }); } } - } const executeLength = executeHooks.length; for (var i = 0; i < executeLength; i++) { @@ -303,6 +303,15 @@ return p; } + function approxProp(object, property) { + if (object.hasOwnProperty(property)) + return object[property]; + var toCheck = property.toFixed(1); + if (object.hasOwnProperty(toCheck)) + return object[toCheck]; + return null; + } + /* * За функции, генериращи обекти */ @@ -665,7 +674,7 @@ 3, [50, 0, 0], [0, -10, 0], false ] ], - 5.01: [ + 5: [ [ 3, jotaro, null, -- cgit v1.3.1-26-gb76a