diff --git a/js/animations/animation.js b/js/animations/animation.js
index 3ab3f819..e56def4e 100644
--- a/js/animations/animation.js
+++ b/js/animations/animation.js
@@ -405,7 +405,7 @@ class Animation {
}
}
get time() {
- return (this.length && this.loop === 'loop') ? (Timeline.time % this.length) : Timeline.time;
+ return (this.length && this.loop === 'loop') ? ((Timeline.time - 0.001) % this.length) + 0.001 : Timeline.time;
}
createUniqueName(arr) {
var scope = this;
@@ -2127,8 +2127,8 @@ Interface.definePanels(function() {
diff --git a/js/animations/timeline.js b/js/animations/timeline.js
index 6b330ef9..34401cf5 100644
--- a/js/animations/timeline.js
+++ b/js/animations/timeline.js
@@ -648,20 +648,21 @@ Interface.definePanels(() => {
for (let time = Math.clamp(this.scroll_left - 9, 0, Infinity); time < (clientWidth + this.scroll_left - this.head_width); time += step) {
Timeline.time = time / this.size;
+
let snap_kf = keyframes.find(kf => Timeline.time <= kf.time && Timeline.time > kf.time - step / this.size );
if (snap_kf) {
Timeline.time = snap_kf.time;
}
let value = ba.interpolate(this.graph_editor_channel, false, this.graph_editor_axis);
- points.push(value);
- min = Math.min(min, value);
- max = Math.max(max, value);
if (snap_kf) snap_kf.display_value = value;
-
- if (time >= Animation.selected.length && Animation.selected.length && Animation.selected.loop === 'loop') {
- Timeline.time = Animation.selected.time;
- let value = ba.interpolate(this.graph_editor_channel, false, this.graph_editor_axis);
+
+ if (Timeline.time > Animation.selected.length && Animation.selected.length && Animation.selected.loop === 'loop') {
+ if (points.length && !loop_points.length) loop_points.push(points.last())
loop_points.push(value);
+ } else {
+ points.push(value);
+ min = Math.min(min, value);
+ max = Math.max(max, value);
}
}
@@ -682,7 +683,7 @@ Interface.definePanels(() => {
this.loop_graph = '';
if (loop_points.length) {
loop_points.forEach((value, i) => {
- i = i + points.length - loop_points.length;
+ i = i + points.length - 1;
this.loop_graph += `${this.loop_graph.length ? 'L' : 'M'}${i*step} ${this.graph_offset - value * this.graph_size} `
})
}
@@ -942,7 +943,8 @@ Interface.definePanels(() => {
addEventListeners(document, 'mouseup touchend', off);
},
clamp: Math.clamp,
- trimFloatNumber
+ trimFloatNumber,
+ a() {console.trace('nee')}
},
watch: {
size() {this.updateTimecodes()},
diff --git a/js/interface/keyboard.js b/js/interface/keyboard.js
index 374b2c12..0c803313 100644
--- a/js/interface/keyboard.js
+++ b/js/interface/keyboard.js
@@ -611,10 +611,16 @@ addEventListeners(document, 'keydown mousedown', function(e) {
//Tab
if (e.which == 9 && !open_dialog) {
- var all_inputs = $('.tab_target:visible:not(.prism-editor-wrapper), .prism-editor-wrapper.tab_target:visible > pre[contenteditable="true"]')
- var index = all_inputs.index(input_focus)+1;
- if (index >= all_inputs.length) index = 0;
- var next = $(all_inputs.get(index))
+ let all_visible_inputs = [];
+ var all_inputs = document.querySelectorAll('.tab_target:not(.prism-editor-wrapper), .prism-editor-wrapper.tab_target > pre[contenteditable="true"]')
+ all_inputs.forEach(input => {
+ if (input.isConnected && input.offsetParent && $(input).is(':visible')) {
+ all_visible_inputs.push(input);
+ }
+ })
+ var index = all_visible_inputs.indexOf(input_focus)+1;
+ if (index >= all_visible_inputs.length) index = 0;
+ var next = $(all_visible_inputs[index])
if (next.length) {
if (next.hasClass('cube_name')) {
diff --git a/lib/molang.umd.js b/lib/molang.umd.js
index e5f50b3f..f002358e 100644
--- a/lib/molang.umd.js
+++ b/lib/molang.umd.js
@@ -1 +1 @@
-!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).Molang=r()}(this,(function(){"use strict";const e=e=>((e+180)%360+180)%360;var r={clamp:(e,r,t)=>(e>t&&(e=t),(ee+Math.random()*(r-e),randomInt:(e,r)=>(e=Math.ceil(e),r=Math.floor(r),e+Math.floor(Math.random()*(r-e+1))),dieRoll(e,r,t){e=this.clamp(e,0,1e9);let n=0;for(var a=0;ae+(r-e)*t,lerpRotate(r,t,n){let a=e(r),s=e(t);a>s&&([a,s]=[s,a]);var u=s-a;return u>180?e(s+n*(360-u)):a+n*u}};const t={true:1,false:0};return function(){const e=this;this.global_variables={},this.cache_enabled=!0,this.use_radians=!1,this.variableHandler=null;let n={},a={},s=!1;function u(e){this.lines=e.split(";").map((e=>h(e)))}function i(e,r,t,n){this.operator=e,this.a=h(r),void 0!==t&&(this.b=h(t)),void 0!==n&&(this.c=h(n))}function c(e,r){this.query=e,this.args=r.map((e=>h(e)))}function l(e,r){this.value=h(r),this.name=e}function o(e,r){this.value=h(r),this.type=e}let f=()=>this.use_radians?1:Math.PI/180;function h(e){if(!e)return 0;if(!isNaN(e))return parseFloat(e);for(e=e.replace(/\s/g,"");b(e);)e=e.substr(1,e.length-2);var r;if(r=e.length>5&&e.match(/^return/))return new o(r[0],e.substr(r[0].length));if("."==e.substring(1,2)){let r=e.substring(0,1);"q"==r&&(e="query"+e.substring(1)),"v"==r&&(e="variable"+e.substring(1)),"t"==r&&(e="temp"+e.substring(1)),"c"==r&&(e="context"+e.substring(1))}if((r=e.length>4&&e.match(/(temp|variable)\.\w+=/))&&"="!==e[r.index+r[0].length]){return new l(r[0].replace(/=$/,""),e.substr(r.index+r[0].length))}if(t=p(e,"??",19))return t;var t,n=g(e,"?");if(n){let e=g(n[1],":");return e&&e.length?new i(10,n[0],e[0],e[1]):new i(10,n[0],n[1],0)}if(t=p(e,"&&",11)||p(e,"||",12)||p(e,"<=",14)||p(e,"<",13)||p(e,">=",16)||p(e,">",15)||p(e,"==",17)||p(e,"!=",18)||p(e,"+",1,!0)||function(e,r,t,n){var a=g(e,r,n);if(a){if(0===a[0].length)return new i(t,0,a[1]);if(!1==="+*/<>=|&?:".includes(a[0].substr(-1)))return new i(t,a[0],a[1])}}(e,"-",2,!0)||p(e,"*",3)||p(e,"/",4,!0)||function(e,r){if(e[0]==r&&e.length>1)return new i(5,e.substr(1),0)}(e,"!"))return t;if("math."===e.substr(0,5)){if("math.pi"===e.substr(0,7))return Math.PI;let r=e.search(/\(/),t=e.substr(5,r-5),n=e.substr(r+1,e.length-r-2),s=g(n,",")||[n];if(s.length>1){var a=g(s[1],",");a&&a.length>1&&(s[1]=a[0],s[2]=a[1])}switch(t){case"abs":return new i(100,s[0]);case"sin":return new i(101,s[0]);case"cos":return new i(102,s[0]);case"exp":return new i(103,s[0]);case"ln":return new i(104,s[0]);case"pow":return new i(105,s[0],s[1]);case"sqrt":return new i(106,s[0]);case"random":return new i(107,s[0],s[1]);case"ceil":return new i(108,s[0]);case"round":return new i(109,s[0]);case"trunc":return new i(110,s[0]);case"floor":return new i(111,s[0]);case"mod":return new i(112,s[0],s[1]);case"min":return new i(113,s[0],s[1]);case"max":return new i(114,s[0],s[1]);case"clamp":return new i(115,s[0],s[1],s[2]);case"lerp":return new i(116,s[0],s[1],s[2]);case"lerprotate":return new i(117,s[0],s[1],s[2]);case"asin":return new i(118,s[0]);case"acos":return new i(119,s[0]);case"atan":return new i(120,s[0]);case"atan2":return new i(121,s[0],s[1]);case"die_roll":return new i(122,s[0],s[1],s[2]);case"die_roll_integer":return new i(123,s[0],s[1],s[2]);case"hermite_blend":return new i(124,s[0]);case"random_integer":return new i(125,s[0],s[1],s[2])}}if((n=e.match(/[a-zA-Z0-9._]{2,}/g))&&1===n.length&&n[0].length>=e.length-2)return e;if(e.includes("(")&&")"==e[e.length-1]){let r,t=e.search(/\(/),n=e.substr(0,t),a=[e.substr(t+1,e.length-t-2)];for(;r=g(a[a.length-1],",");)a.splice(a.length-1,1,...r);return new c(n,a)}return 0}function b(e){if("("===e.substr(0,1)&&")"===e.substr(-1)){let t=0;for(var r=0;r=0:aw(e)));return"function"==typeof a[n.query]?a[n.query](...r):"function"==typeof e.global_variables[n.query]?e.global_variables[n.query](...r):("function"==typeof e.variableHandler&&(h=e.variableHandler(n.query,a,r)),0)}if(n instanceof i)switch(n.operator){case 1:return w(n.a)+w(n.b);case 2:return w(n.a)-w(n.b);case 3:return w(n.a)*w(n.b);case 4:return w(n.a)/w(n.b);case 5:return 0==w(n.a)?1:0;case 10:return w(n.a)?w(n.b):w(n.c);case 11:return w(n.a)&&w(n.b)?1:0;case 12:return w(n.a)||w(n.b)?1:0;case 13:return w(n.a)w(n.b)?1:0;case 16:return w(n.a)>=w(n.b)?1:0;case 17:return d(n.a,n.b)?1:0;case 18:return d(n.a,n.b)?0:1;case 19:var b=w(n.a);return s?w(n.b):b;case 100:return Math.abs(w(n.a));case 101:return Math.sin(w(n.a)*f());case 102:return Math.cos(w(n.a)*f());case 103:return Math.exp(w(n.a));case 104:return Math.log(w(n.a));case 105:return Math.pow(w(n.a),w(n.b));case 106:return Math.sqrt(w(n.a));case 107:return r.random(w(n.a),w(n.b));case 108:return Math.ceil(w(n.a));case 109:return Math.round(w(n.a));case 110:return Math.trunc(w(n.a));case 111:return Math.floor(w(n.a));case 112:return w(n.a)%w(n.b);case 113:return Math.min(w(n.a),w(n.b));case 114:return Math.max(w(n.a),w(n.b));case 115:return r.clamp(w(n.a),w(n.b),w(n.c));case 116:return r.lerp(w(n.a),w(n.b),w(n.c));case 117:return r.lerpRotate(w(n.a),w(n.b),w(n.c));case 118:return Math.asin(w(n.a))/f();case 119:return Math.acos(w(n.a))/f();case 120:return Math.atan(w(n.a))/f();case 121:return Math.atan2(w(n.a),w(n.b))/f();case 122:return r.dieRoll(w(n.a),w(n.b),w(n.c));case 123:return r.dieRollInt(w(n.a),w(n.b),w(n.c));case 124:let e=w(n.a);return 3*Math.pow(e,2)-2*Math.pow(e,3);case 125:return r.randomInt(w(n.a),w(n.b))}return 0}this.parse=(e,r)=>{if("number"==typeof e)return isNaN(e)?0:e;if("string"!=typeof e)return 0;var t;if((t=(t=e).toLowerCase().trim()).includes(";")&&(t=t.replace(/;\s+/g,";").replace(/;\s*$/,"")),e=t,this.cache_enabled&&n[e])var s=n[e];else{s=new u(e);this.cache_enabled&&(n[e]=s)}return function(e,r){if(r)for(var t in r)a[t]=r[t];var n=0;for(var s of e.lines){let r=w(s);if(++n==e.lines.length||s instanceof o&&"return"===s.type)return r}return 0}(s,r)},this.resetVariables=()=>{a={}}}}));
+!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).Molang=r()}(this,(function(){"use strict";const e=e=>((e+180)%360+180)%360;var r={clamp:(e,r,t)=>(e>t&&(e=t),(ee+Math.random()*(r-e),randomInt:(e,r)=>(e=Math.ceil(e),r=Math.floor(r),e+Math.floor(Math.random()*(r-e+1))),dieRoll(e,r,t){e=this.clamp(e,0,1e9);let n=0;for(var a=0;ae+(r-e)*t,lerpRotate(r,t,n){let a=e(r),s=e(t);a>s&&([a,s]=[s,a]);var u=s-a;return u>180?e(s+n*(360-u)):a+n*u}};const t={true:1,false:0};return function(){const e=this;this.global_variables={},this.cache_enabled=!0,this.use_radians=!1,this.variables={},this.variableHandler=null;let n={},a={},s=!1;function u(e){this.lines=e.split(";").map((e=>h(e)))}function i(e,r,t,n){this.operator=e,this.a=h(r),void 0!==t&&(this.b=h(t)),void 0!==n&&(this.c=h(n))}function c(e,r){this.query=e,this.args=r.map((e=>h(e)))}function l(e,r){this.value=h(r),this.name=e}function o(e,r){this.value=h(r),this.type=e}let f=()=>this.use_radians?1:Math.PI/180;function h(e){if(!e)return 0;if(!isNaN(e))return parseFloat(e);for(e=e.replace(/\s/g,"");b(e);)e=e.substr(1,e.length-2);var r;if(r=e.length>5&&e.match(/^return/))return new o(r[0],e.substr(r[0].length));if("."==e.substring(1,2)){let r=e.substring(0,1);"q"==r&&(e="query"+e.substring(1)),"v"==r&&(e="variable"+e.substring(1)),"t"==r&&(e="temp"+e.substring(1)),"c"==r&&(e="context"+e.substring(1))}if((r=e.length>4&&e.match(/(temp|variable)\.\w+=/))&&"="!==e[r.index+r[0].length]){return new l(r[0].replace(/=$/,""),e.substr(r.index+r[0].length))}if(t=p(e,"??",19))return t;var t,n=g(e,"?");if(n){let e=g(n[1],":");return e&&e.length?new i(10,n[0],e[0],e[1]):new i(10,n[0],n[1],0)}if(t=p(e,"&&",11)||p(e,"||",12)||p(e,"<=",14)||p(e,"<",13)||p(e,">=",16)||p(e,">",15)||p(e,"==",17)||p(e,"!=",18)||p(e,"+",1,!0)||function(e,r,t,n){var a=g(e,r,n);if(a){if(0===a[0].length)return new i(t,0,a[1]);if(!1==="+*/<>=|&?:".includes(a[0].substr(-1)))return new i(t,a[0],a[1])}}(e,"-",2,!0)||p(e,"*",3)||p(e,"/",4,!0)||function(e,r){if(e[0]==r&&e.length>1)return new i(5,e.substr(1),0)}(e,"!"))return t;if("math."===e.substr(0,5)){if("math.pi"===e.substr(0,7))return Math.PI;let r=e.search(/\(/),t=e.substr(5,r-5),n=e.substr(r+1,e.length-r-2),s=g(n,",")||[n];if(s.length>1){var a=g(s[1],",");a&&a.length>1&&(s[1]=a[0],s[2]=a[1])}switch(t){case"abs":return new i(100,s[0]);case"sin":return new i(101,s[0]);case"cos":return new i(102,s[0]);case"exp":return new i(103,s[0]);case"ln":return new i(104,s[0]);case"pow":return new i(105,s[0],s[1]);case"sqrt":return new i(106,s[0]);case"random":return new i(107,s[0],s[1]);case"ceil":return new i(108,s[0]);case"round":return new i(109,s[0]);case"trunc":return new i(110,s[0]);case"floor":return new i(111,s[0]);case"mod":return new i(112,s[0],s[1]);case"min":return new i(113,s[0],s[1]);case"max":return new i(114,s[0],s[1]);case"clamp":return new i(115,s[0],s[1],s[2]);case"lerp":return new i(116,s[0],s[1],s[2]);case"lerprotate":return new i(117,s[0],s[1],s[2]);case"asin":return new i(118,s[0]);case"acos":return new i(119,s[0]);case"atan":return new i(120,s[0]);case"atan2":return new i(121,s[0],s[1]);case"die_roll":return new i(122,s[0],s[1],s[2]);case"die_roll_integer":return new i(123,s[0],s[1],s[2]);case"hermite_blend":return new i(124,s[0]);case"random_integer":return new i(125,s[0],s[1],s[2])}}if((n=e.match(/[a-zA-Z0-9._]{2,}/g))&&1===n.length&&n[0].length>=e.length-2)return e;if(e.includes("(")&&")"==e[e.length-1]){let r,t=e.search(/\(/),n=e.substr(0,t),a=[e.substr(t+1,e.length-t-2)];for(;r=g(a[a.length-1],",");)a.splice(a.length-1,1,...r);return new c(n,a)}return 0}function b(e){if("("===e.substr(0,1)&&")"===e.substr(-1)){let t=0;for(var r=0;r=0:av(e)));return"function"==typeof e.variables[n.query]?e.variables[n.query](...r):"function"==typeof e.global_variables[n.query]?e.global_variables[n.query](...r):("function"==typeof e.variableHandler&&(u=e.variableHandler(n.query,e.variables,r)),0)}if(n instanceof i)switch(n.operator){case 1:return v(n.a)+v(n.b);case 2:return v(n.a)-v(n.b);case 3:return v(n.a)*v(n.b);case 4:return v(n.a)/v(n.b);case 5:return 0==v(n.a)?1:0;case 10:return v(n.a)?v(n.b):v(n.c);case 11:return v(n.a)&&v(n.b)?1:0;case 12:return v(n.a)||v(n.b)?1:0;case 13:return v(n.a)v(n.b)?1:0;case 16:return v(n.a)>=v(n.b)?1:0;case 17:return d(n.a,n.b)?1:0;case 18:return d(n.a,n.b)?0:1;case 19:var h=v(n.a);return s?v(n.b):h;case 100:return Math.abs(v(n.a));case 101:return Math.sin(v(n.a)*f());case 102:return Math.cos(v(n.a)*f());case 103:return Math.exp(v(n.a));case 104:return Math.log(v(n.a));case 105:return Math.pow(v(n.a),v(n.b));case 106:return Math.sqrt(v(n.a));case 107:return r.random(v(n.a),v(n.b));case 108:return Math.ceil(v(n.a));case 109:return Math.round(v(n.a));case 110:return Math.trunc(v(n.a));case 111:return Math.floor(v(n.a));case 112:return v(n.a)%v(n.b);case 113:return Math.min(v(n.a),v(n.b));case 114:return Math.max(v(n.a),v(n.b));case 115:return r.clamp(v(n.a),v(n.b),v(n.c));case 116:return r.lerp(v(n.a),v(n.b),v(n.c));case 117:return r.lerpRotate(v(n.a),v(n.b),v(n.c));case 118:return Math.asin(v(n.a))/f();case 119:return Math.acos(v(n.a))/f();case 120:return Math.atan(v(n.a))/f();case 121:return Math.atan2(v(n.a),v(n.b))/f();case 122:return r.dieRoll(v(n.a),v(n.b),v(n.c));case 123:return r.dieRollInt(v(n.a),v(n.b),v(n.c));case 124:let e=v(n.a);return 3*Math.pow(e,2)-2*Math.pow(e,3);case 125:return r.randomInt(v(n.a),v(n.b))}return 0}this.parse=(e,r)=>{if("number"==typeof e)return isNaN(e)?0:e;if("string"!=typeof e)return 0;var t;if((t=(t=e).toLowerCase().trim()).includes(";")&&(t=t.replace(/;\s+/g,";").replace(/;\s*$/,"")),e=t,this.cache_enabled&&a[e])var s=a[e];else{s=new u(e);this.cache_enabled&&(a[e]=s)}return function(e,r){if(r)for(var t in r)n[t]=r[t];let a=0,s=0;for(let r of e.lines){let t=v(r);if(a++,a==e.lines.length||r instanceof o&&"return"===r.type){s=t;break}}return n={},s}(s,r)},this.resetVariables=()=>{e.variables={}}}}));