diff --git a/css/window.css b/css/window.css index aebd97f25..213e911ad 100644 --- a/css/window.css +++ b/css/window.css @@ -660,6 +660,11 @@ color: var(--color-bright_ui_text); opacity: 0.8; } + @media (max-height: 400px) { + #mobile_menu_bar { + top: 0; + } + } /* Tab Bar */ #tab_bar { diff --git a/js/interface/dialog.js b/js/interface/dialog.js index 8938f29cb..e7b1a1f51 100644 --- a/js/interface/dialog.js +++ b/js/interface/dialog.js @@ -128,7 +128,7 @@ function buildForm(dialog) { let select_input = new Interface.CustomElements.SelectInput(form_id, { options: data.options, value: data.value || data.default, - onChange() { + onInput() { dialog.updateFormValues(); } }); diff --git a/js/interface/interface.js b/js/interface/interface.js index ccad0a47a..d01cdbea2 100644 --- a/js/interface/interface.js +++ b/js/interface/interface.js @@ -756,7 +756,7 @@ Interface.CustomElements.SelectInput = function(id, data) { let options = typeof data.options == 'function' ? data.options() : data.options; let value = data.value || data.default || Object.keys(options)[0]; let select = Interface.createElement('bb-select', {id, class: 'half', value: value}, getNameFor(options[value])); - function setKey(key, options) { + function setKey(key, options, input_event) { if (!options) { options = typeof data.options == 'function' ? data.options() : data.options; } @@ -766,6 +766,9 @@ Interface.CustomElements.SelectInput = function(id, data) { if (typeof data.onChange == 'function') { data.onChange(value); } + if (input_event && typeof data.onInput == 'function') { + data.onInput(value, input_event); + } } select.addEventListener('click', function(event) { if (Menu.closed_in_this_click == id) return this; @@ -779,8 +782,8 @@ Interface.CustomElements.SelectInput = function(id, data) { icon: val.icon || ((value == key) ? 'far.fa-dot-circle' : 'far.fa-circle'), color: val.color, condition: val.condition, - click: (e) => { - setKey(key, options); + click: (context, event) => { + setKey(key, options, event || 1); } }) } diff --git a/js/interface/menu.js b/js/interface/menu.js index 9b5d9ab08..d843b0dd8 100644 --- a/js/interface/menu.js +++ b/js/interface/menu.js @@ -16,10 +16,14 @@ function handleMenuOverflow(node) { function offset(amount) { let top = parseInt(node.style.top); let offset = top - $(node).offset().top; + let top_gap = 26; + if (Blockbench.isMobile && Menu.open instanceof BarMenu) { + top_gap = window.innerHeight > 400 ? 106 : 56; + } top = Math.clamp( top + amount, window.innerHeight - node.clientHeight + offset, - offset + 26 + offset + top_gap ); node.style.top = `${top}px`; } @@ -100,17 +104,21 @@ class Menu { } } - let window_height = window.innerHeight - 26; + let top_gap = 26; + if (Blockbench.isMobile && this instanceof BarMenu) { + top_gap = window.innerHeight > 400 ? 106 : 56; + } + let window_height = window.innerHeight - top_gap; if (el_height > window_height) { childlist.css('margin-top', '0').css('top', '0') - childlist.css('top', (-childlist.offset().top + 26) + 'px') + childlist.css('top', (-childlist.offset().top + top_gap) + 'px') handleMenuOverflow(childlist); } else if (offset.top + el_height > window_height) { - childlist.css('margin-top', 26-childlist.height() + 'px') - if (childlist.offset().top < 26) { - childlist.offset({top: 26}) + childlist.css('margin-top', top_gap-childlist.height() + 'px') + if (childlist.offset().top < top_gap) { + childlist.offset({top: top_gap}) } } } @@ -510,9 +518,13 @@ class Menu { let content_list = typeof this.structure == 'function' ? this.structure(context) : this.structure; populateList(content_list, ctxmenu, this.options.searchable); - var el_width = ctxmenu.width() - var el_height = ctxmenu.height() - let window_height = window.innerHeight - 26; + let el_width = ctxmenu.width() + let el_height = ctxmenu.height() + let top_gap = 26; + if (Blockbench.isMobile && this instanceof BarMenu) { + top_gap = window.innerHeight > 400 ? 106 : 56; + } + let window_height = window.innerHeight - top_gap; if (position && position.clientX !== undefined) { var offset_left = position.clientX @@ -553,7 +565,7 @@ class Menu { offset_top = window_height - el_height; } } - offset_top = Math.max(offset_top, 26); + offset_top = Math.max(offset_top, top_gap); ctxmenu.css('left', offset_left+'px') ctxmenu.css('top', offset_top +'px') diff --git a/js/interface/themes.js b/js/interface/themes.js index 1560e7c75..1c56c7e51 100644 --- a/js/interface/themes.js +++ b/js/interface/themes.js @@ -435,13 +435,8 @@ const CustomTheme = { CustomTheme.updateColors(); }, loadThumbnailStyles() { - let split_regex; - try { - // Soft fail for iOS 16.3 and older - split_regex = eval('/(? Format.per_group_texture, children() { + function applyTexture(texture_value, undo_message) { + let affected_groups = Group.all.filter(g => g.selected); + Undo.initEdit({outliner: true}); + for (let group of affected_groups) { + group.texture = texture_value; + } + Undo.finishEdit(undo_message); + Canvas.updateAllFaces(); + } let arr = [ {icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(group) { - Undo.initEdit({group: group}); - group.texture = ''; - Undo.finishEdit('Unassign texture from group'); - group.forEachChild(child => { - if (child.preview_controller?.updateFaces) child.preview_controller.updateFaces(child); - }) + applyTexture('', 'Unassign texture from group'); }} ] Texture.all.forEach(t => { @@ -469,12 +473,7 @@ class Group extends OutlinerNode { name: t.name, icon: (t.mode === 'link' ? t.img : t.source), click(group) { - Undo.initEdit({group: group}); - group.texture = t.uuid; - Undo.finishEdit('Apply texture to group'); - group.forEachChild(child => { - if (child.preview_controller?.updateFaces) child.preview_controller.updateFaces(child); - }) + applyTexture(t.uuid, 'Apply texture to group'); } }) }) diff --git a/js/outliner/mesh.js b/js/outliner/mesh.js index fcc7c35a9..11975006a 100644 --- a/js/outliner/mesh.js +++ b/js/outliner/mesh.js @@ -817,7 +817,7 @@ class Mesh extends OutlinerElement { var scope = this; if (faces === true) { var sides = Object.keys(this.faces); - } else if (faces === undefined) { + } else if (!faces) { var sides = this.getSelectedFaces() } else { var sides = faces @@ -872,21 +872,23 @@ class Mesh extends OutlinerElement { } }}) }}, - {name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture, children: function() { + {name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture, children() { var arr = [ - {icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click: function(cube) { - cube.forSelected(function(obj) { - obj.applyTexture(false, true) + {icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(mesh) { + let all_faces = BarItems.selection_mode.value != 'face' || Mesh.selected[0]?.getSelectedFaces().length == 0; + mesh.forSelected((obj) => { + obj.applyTexture(false, all_faces) }, 'texture blank') }} ] - Texture.all.forEach(function(t) { + Texture.all.forEach((t) => { arr.push({ name: t.name, icon: (t.mode === 'link' ? t.img : t.source), - click: function(cube) { - cube.forSelected(function(obj) { - obj.applyTexture(t, true) + click(mesh) { + let all_faces = BarItems.selection_mode.value != 'face' || Mesh.selected[0]?.getSelectedFaces().length == 0; + mesh.forSelected((obj) => { + obj.applyTexture(t, all_faces) }, 'apply texture') } }) @@ -1153,12 +1155,19 @@ new NodePreviewController(Mesh, { ? [tex.getUVWidth(), tex.getUVHeight()] : [Project.texture_width, Project.texture_height]; + let first_values; face.vertices.forEach((key, i) => { let u = (face.uv[key] ? face.uv[key][0] : 0) / uv_size[0]; let v = (face.uv[key] ? face.uv[key][1] : 0) / uv_size[1]; if (stretch > 1) { v = (v + frame) / stretch; } + // Fix grainy visuals when UV all in one point + if (!first_values) { + first_values = [u, v]; + } else if (first_values[0] == u && first_values[1] == v) { + i < 2 ? u += 0.00005 : v += 0.00005; + } uv_array.push(u, 1-v); }) } diff --git a/js/plugin_loader.js b/js/plugin_loader.js index 19304214b..22360a850 100644 --- a/js/plugin_loader.js +++ b/js/plugin_loader.js @@ -1023,7 +1023,12 @@ BARS.defineActions(function() { return pureMarked(about); }, reduceLink(url) { - return url.replace('https://', '').substring(0, 50)+'...'; + url = url.replace('https://', '').replace(/\/$/, ''); + if (url.length > 50) { + return url.substring(0, 50)+'...'; + } else { + return url; + } }, printDate(input_date) { return getDateDisplay(input_date).short; diff --git a/js/preview/screenshot.js b/js/preview/screenshot.js index ecd89f8ac..00a91b286 100644 --- a/js/preview/screenshot.js +++ b/js/preview/screenshot.js @@ -562,7 +562,7 @@ const Screencam = { vars.recording = true; vars.loop = setInterval(() => { if (vars.animation && options.play) { - Timeline.setTime(vars.interval*vars.frames / 1000); + Timeline.setTime((Timeline.playback_speed/100) * vars.interval*vars.frames / 1000); Animator.preview(true); } vars.frames++; diff --git a/js/texturing/textures.js b/js/texturing/textures.js index 2a47bddad..0e806a9fd 100644 --- a/js/texturing/textures.js +++ b/js/texturing/textures.js @@ -1030,7 +1030,7 @@ class Texture { } }); groups = groups.filter(g => g instanceof Group); - let affected_elements = []; + affected_elements = []; Undo.initEdit({outliner: true}); groups.forEach(group => { group.texture = this.uuid; diff --git a/js/undo.js b/js/undo.js index b69d784df..a8d77fb62 100644 --- a/js/undo.js +++ b/js/undo.js @@ -539,6 +539,9 @@ class UndoSystem { if ((save.outliner || save.group) && Format.bone_rig) { Canvas.updateAllBones(); } + if (save.outliner && Format.per_group_texture) { + Canvas.updateAllFaces(); + } if (Modes.animate) { Animator.preview(); } diff --git a/lang/cz.json b/lang/cz.json index ef242c0ba..8afd241f2 100644 --- a/lang/cz.json +++ b/lang/cz.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/de.json b/lang/de.json index 405775e7a..0eec9134d 100644 --- a/lang/de.json +++ b/lang/de.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Einzelbild hinzufügen", "dialog.animated_texture_editor.resize_frames": "Bildgröße ändern...", "dialog.animated_texture_editor.apply": "Anwenden", - "dialog.add_primitive.shape.rounded_cuboid": "Quader mit Kanten", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Kantenbreite", "dialog.change_animation_speed.speed": "Geschwindigkeit", "dialog.change_animation_speed.adjust_snapping": "Einrastintervall anpassen", diff --git a/lang/es.json b/lang/es.json index 18e534c7e..55aa09b24 100644 --- a/lang/es.json +++ b/lang/es.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/fr.json b/lang/fr.json index 69da880b9..e2dc207a6 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/it.json b/lang/it.json index b1dbc9bd8..a14d38c57 100644 --- a/lang/it.json +++ b/lang/it.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/ja.json b/lang/ja.json index 4928bcce8..f5a338bf2 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/ko.json b/lang/ko.json index d95e068f4..b25129f4c 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/nl.json b/lang/nl.json index 271cbe95a..6a750699b 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/pl.json b/lang/pl.json index eb2029a20..86fd91f10 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/pt.json b/lang/pt.json index caa7d5b3b..bbe5f975e 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/ru.json b/lang/ru.json index f5b926ae5..ee4945eb4 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/sv.json b/lang/sv.json index ab379c2b0..68ae8f984 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/uk.json b/lang/uk.json index 7b1176581..301ec9805 100644 --- a/lang/uk.json +++ b/lang/uk.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/vi.json b/lang/vi.json index 19f16c5ee..11d95f261 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/zh.json b/lang/zh.json index 6d70a6b3f..3370fa8e2 100644 --- a/lang/zh.json +++ b/lang/zh.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lang/zh_tw.json b/lang/zh_tw.json index b9fb6c684..254ea05a8 100644 --- a/lang/zh_tw.json +++ b/lang/zh_tw.json @@ -2081,7 +2081,7 @@ "dialog.animated_texture_editor.add_frame": "Add Frame", "dialog.animated_texture_editor.resize_frames": "Resize Frames...", "dialog.animated_texture_editor.apply": "Apply", - "dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges", + "dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid", "dialog.add_primitive.edge_size": "Edge Size", "dialog.change_animation_speed.speed": "Speed", "dialog.change_animation_speed.adjust_snapping": "Adjust Snapping", diff --git a/lib/molang.umd.js b/lib/molang.umd.js index 949704967..2543b3e96 100644 --- a/lib/molang.umd.js +++ b/lib/molang.umd.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Molang=t()}(this,(function(){"use strict";const e=e=>((e+180)%360+180)%360;var t={clamp:(e,t,r)=>(e>r&&(e=r),(ee+Math.random()*(t-e),randomInt:(e,t)=>(e=Math.ceil(e),t=Math.floor(t),e+Math.floor(Math.random()*(t-e+1))),dieRoll(e,t,r){e=this.clamp(e,0,1e9);let n=0;for(var a=0;ae+(t-e)*r,lerpRotate(t,r,n){let a=e(t),s=e(r);a>s&&([a,s]=[s,a]);var u=s-a;return u>180?e(s+n*(360-u)):a+n*u},inRange:(e,t,r)=>e<=r&&e>=t?1:0,all:(e,...t)=>-1===t.findIndex((t=>t!==e))?1:0,any:(e,...t)=>t.findIndex((t=>t==e))>=0?1:0,approxEq:(e,...t)=>-1===t.findIndex((t=>Math.abs(e-t)>1e-7))?1:0};return function(){const e=this;this.global_variables={},this.cache_enabled=!0,this.use_radians=!1,this.variables={},this.variableHandler=null;let r=!1,n=0,a={},s=0;function u(e){this.lines=[];for(let t of e){if(!t)continue;let e=M(t);if(this.lines.push(e),e instanceof f)break}}function i(e,t){this.iterations=M(e),this.body=M(t)}function c(e,t,r,n){this.operator=e,this.a=M(t),void 0!==r&&(this.b=M(r)),void 0!==n&&(this.c=M(n))}function l(e,t){this.query=e,this.args=t.map((e=>M(e)))}function o(e,t){this.value=M(t),this.name=w(e)}function f(e){this.value=M(e)}function h(){}function b(){}let d=()=>this.use_radians?1:Math.PI/180,g=/^-?\d+(\.\d+f?)?$/;function p(e){return g.test(e)}function w(e){if(e[1]!==v)return e;switch(e[0]){case"q":return"query"+e.substring(1);case"v":return"variable"+e.substring(1);case"t":return"temp"+e.substring(1);case"c":return"context"+e.substring(1);default:return e}}const m=/[&|<>=]/,y=/^(temp|variable|t|v)\.\w+=/,v=".";function M(e){if(!e)return 0;for(e.endsWith(";")&&(e=e.substring(0,e.length-1));x(e);)e=e.substr(1,e.length-2);if(p(e))return parseFloat(e);let t=R(e,";");if(t)return new u(t);if(e.startsWith("return"))return new f(e.substr(6));switch(e){case"true":return 1;case"false":return 0;case"break":return new h;case"continue":return new b}let r=-1!==e.indexOf("="),n=r&&e.length>4&&e.match(y);if(n&&"="!==e[n.index+n[0].length]){return new o(n[0].substring(0,n[0].length-1),e.substr(n.index+n[0].length))}let a=-1!==e.indexOf("?"),s=a&&q(e,"??",19);if(s)return s;let d=a&&W(e,"?");if(d){let e=W(d[1],":");return e&&e.length?new c(10,d[0],e[0],e[1]):new c(10,d[0],d[1],0)}if(s=m.test(e)&&(q(e,"&&",11)||q(e,"||",12)||r&&q(e,"==",17)||r&&q(e,"!=",18)||r&&q(e,"<=",14)||q(e,"<",13)||r&&q(e,">=",16)||q(e,">",15))||q(e,"+",1,!0)||function(e,t,r){let n=H(e,t);if(n)return 0===n[0].length?new c(r,0,n[1]):new c(r,n[0],n[1])}(e,"-",2)||q(e,"*",3)||q(e,"/",4,!0)||function(e){if(e.startsWith("!")&&e.length>1)return new c(5,e.substr(1),0)}(e),s instanceof c)return s;if(e.startsWith("math.")){if("math.pi"===e)return Math.PI;let t=e.indexOf("("),r=e.substr(5,t-5),n=e.substr(t+1,e.length-t-2),a=R(n,",");switch(a||(a=[n]),r){case"abs":return new c(100,a[0]);case"sin":return new c(101,a[0]);case"cos":return new c(102,a[0]);case"exp":return new c(103,a[0]);case"ln":return new c(104,a[0]);case"pow":return new c(105,a[0],a[1]);case"sqrt":return new c(106,a[0]);case"random":return new c(107,a[0],a[1]);case"ceil":return new c(108,a[0]);case"round":return new c(109,a[0]);case"trunc":return new c(110,a[0]);case"floor":return new c(111,a[0]);case"mod":return new c(112,a[0],a[1]);case"min":return new c(113,a[0],a[1]);case"max":return new c(114,a[0],a[1]);case"clamp":return new c(115,a[0],a[1],a[2]);case"lerp":return new c(116,a[0],a[1],a[2]);case"lerprotate":return new c(117,a[0],a[1],a[2]);case"asin":return new c(118,a[0]);case"acos":return new c(119,a[0]);case"atan":return new c(120,a[0]);case"atan2":return new c(121,a[0],a[1]);case"die_roll":return new c(122,a[0],a[1],a[2]);case"die_roll_integer":return new c(123,a[0],a[1],a[2]);case"hermite_blend":return new c(124,a[0]);case"random_integer":return new c(125,a[0],a[1])}}if(e.startsWith("loop(")){let t=R(e.substring(5,e.length-1),",");if(t)return new i(...t)}if(d=e.match(/[a-z0-9._]{2,}/g),d&&1===d.length&&d[0].length>=e.length-2)return w(e);if(e.includes("(")&&")"==e[e.length-1]){let t=e.search(/\(/),r=w(e.substr(0,t)),n=e.substr(t+1,e.length-t-2),a=R(n,",");return a||(a=[n]),new l(r,a)}return 0}function x(e){let t=e.startsWith(_)&&e.endsWith(k);if(t||e.startsWith(I)&&e.endsWith(O)){if(e.indexOf(t?k:O)===e.length-1)return!0;let r=0;for(let t=0;t=0;){switch(e[r]){case _:case I:n++;break;case k:case O:n--;break;default:if(!(0!==n||t[0]!==e[r]||1!==t.length&&t!==e.substr(r,t.length)||"-"===t&&!1!=="+*/<>=|&?:".includes(e[r-1])))return[e.substr(0,r),e.substr(r+t.length)]}r--}}function j(e,t,r){return"string"==typeof e&&"'"==e[0]||(e=E(e,r,!0)),"string"==typeof t&&"'"==t[0]||(t=E(t,r,!0)),e===t}function E(a,s,g){if("number"==typeof a)return a;if("string"==typeof a){let t=s[a];if(void 0===t&&"function"==typeof e.variableHandler&&(t=e.variableHandler(a,s)),"number"==typeof t)return t;if("string"==typeof t&&!g)return e.parse(t,s)||0;if(void 0===t)r=!0;else if("function"==typeof t)return t()||0;return t||0}if(void 0===a)return 0;switch(a.constructor){case c:switch(a.operator){case 1:return E(a.a,s)+E(a.b,s);case 2:return E(a.a,s)-E(a.b,s);case 3:return E(a.a,s)*E(a.b,s);case 4:return E(a.a,s)/E(a.b,s);case 5:return 0==E(a.a,s)?1:0;case 10:return E(a.a,s)?E(a.b,s):E(a.c,s);case 11:return E(a.a,s)&&E(a.b,s)?1:0;case 12:return E(a.a,s)||E(a.b,s)?1:0;case 13:return E(a.a,s)E(a.b,s)?1:0;case 16:return E(a.a,s)>=E(a.b,s)?1:0;case 17:return j(a.a,a.b,s)?1:0;case 18:return j(a.a,a.b,s)?0:1;case 19:r=!1;let e=E(a.a,s);return r?E(a.b,s):e;case 100:return Math.abs(E(a.a,s));case 101:return Math.sin(E(a.a,s)*d());case 102:return Math.cos(E(a.a,s)*d());case 103:return Math.exp(E(a.a,s));case 104:return Math.log(E(a.a,s));case 105:return Math.pow(E(a.a,s),E(a.b,s));case 106:return Math.sqrt(E(a.a,s));case 107:return t.random(E(a.a,s),E(a.b,s));case 108:return Math.ceil(E(a.a,s));case 109:return Math.round(E(a.a,s));case 110:return Math.trunc(E(a.a,s));case 111:return Math.floor(E(a.a,s));case 112:return E(a.a,s)%E(a.b,s);case 113:return Math.min(E(a.a,s),E(a.b,s));case 114:return Math.max(E(a.a,s),E(a.b,s));case 115:return t.clamp(E(a.a,s),E(a.b,s),E(a.c,s));case 116:return t.lerp(E(a.a,s),E(a.b,s),E(a.c,s));case 117:return t.lerpRotate(E(a.a,s),E(a.b,s),E(a.c,s));case 118:return Math.asin(E(a.a,s))/d();case 119:return Math.acos(E(a.a,s))/d();case 120:return Math.atan(E(a.a,s))/d();case 121:return Math.atan2(E(a.a,s),E(a.b,s))/d();case 122:return t.dieRoll(E(a.a,s),E(a.b,s),E(a.c,s));case 123:return t.dieRollInt(E(a.a,s),E(a.b,s),E(a.c,s));case 124:let n=E(a.a,s);return 3*Math.pow(n,2)-2*Math.pow(n,3);case 125:return t.randomInt(E(a.a,s),E(a.b,s))}break;case f:return n=1,E(a.value,s);case o:return s[a.name]=e.variables[a.name]=E(a.value,s),0;case l:let g=a.args.map((e=>E(e,s)));switch(a.query){case"query.in_range":return t.inRange(...g);case"query.all":return t.all(...g);case"query.any":return t.any(...g);case"query.approx_eq":return t.approxEq(...g)}return"function"==typeof s[a.query]?s[a.query](...g)||0:"function"==typeof e.variableHandler&&e.variableHandler(a.query,s,g)||0;case u:n=0;let p=0;for(let e of a.lines)if(p=E(e,s),n>0)break;return p;case i:let w=0,m=t.clamp(E(a.iterations,s),0,1024);for(let e=0;e{if("number"==typeof t)return t||0;if("string"!=typeof t||0===t.length)return 0;if(t.length<9&&p(t))return parseFloat(t);let u=this.cache_enabled&&a[t];return u||(u=M(t.toLowerCase().replace(/\s/g,"")),this.cache_enabled&&function(e,t){if(a[e]=t,s++,s>400){let e=Object.keys(a);for(let t=0;t<10;t++)delete a[e[t]];s-=10}}(t,u)),function(t,r){let a={};for(let t in e.global_variables)a[t]=e.global_variables[t];for(let t in e.variables)a[t]=e.variables[t];if(r)for(let e in r)a[e]=r[e];let s=E(t,a);return n=0,s}(u,r)||0},this.resetVariables=()=>{e.variables={}}}})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Molang=t()}(this,(function(){"use strict";const e=e=>((e+180)%360+180)%360;var t={clamp:(e,t,r)=>(e>r&&(e=r),(ee+Math.random()*(t-e),randomInt:(e,t)=>(e=Math.ceil(e),t=Math.floor(t),e+Math.floor(Math.random()*(t-e+1))),dieRoll(e,t,r){e=this.clamp(e,0,1e9);let n=0;for(var a=0;ae+(t-e)*r,lerpRotate(t,r,n){let a=e(t),s=e(r);a>s&&([a,s]=[s,a]);var u=s-a;return u>180?e(s+n*(360-u)):a+n*u},inRange:(e,t,r)=>e<=r&&e>=t?1:0,all:(e,...t)=>-1===t.findIndex((t=>t!==e))?1:0,any:(e,...t)=>t.findIndex((t=>t==e))>=0?1:0,approxEq:(e,...t)=>-1===t.findIndex((t=>Math.abs(e-t)>1e-7))?1:0};return function(){const e=this;this.global_variables={},this.cache_enabled=!0,this.use_radians=!1,this.variables={},this.variableHandler=null;let r=!1,n=0,a={},s=0;function u(e){this.lines=[];for(let t of e){if(!t)continue;let e=M(t);if(this.lines.push(e),e instanceof f)break}}function i(e,t){this.iterations=M(e),this.body=M(t)}function c(e,t,r,n){this.operator=e,this.a=M(t),void 0!==r&&(this.b=M(r)),void 0!==n&&(this.c=M(n))}function l(e,t){this.query=e,this.args=t.map((e=>M(e)))}function o(e,t){this.value=M(t),this.name=w(e)}function f(e){this.value=M(e)}function h(){}function b(){}let d=()=>this.use_radians?1:Math.PI/180,g=/^-?\d+(\.\d+f?)?$/;function p(e){return g.test(e)}function w(e){if(e[1]!==v)return e;switch(e[0]){case"q":return"query"+e.substring(1);case"v":return"variable"+e.substring(1);case"t":return"temp"+e.substring(1);case"c":return"context"+e.substring(1);default:return e}}const m=/[&|<>=]/,y=/^(temp|variable|t|v)\.\w+=/,v=".";function M(e){if(!e)return 0;for(e.endsWith(";")&&(e=e.substring(0,e.length-1));x(e);)e=e.substr(1,e.length-2);if(p(e))return parseFloat(e);let t=R(e,";");if(t)return new u(t);if(e.startsWith("return"))return new f(e.substr(6));switch(e){case"true":return 1;case"false":return 0;case"break":return new h;case"continue":return new b}let r=-1!==e.indexOf("="),n=r&&e.length>4&&e.match(y);if(n&&"="!==e[n.index+n[0].length]){return new o(n[0].substring(0,n[0].length-1),e.substr(n.index+n[0].length))}let a=-1!==e.indexOf("?"),s=a&&q(e,"??",19);if(s)return s;let d=a&&W(e,"?");if(d){let e=W(d[1],":");return e&&e.length?new c(10,d[0],e[0],e[1]):new c(10,d[0],d[1],0)}if(s=m.test(e)&&(q(e,"&&",11)||q(e,"||",12)||r&&q(e,"==",17)||r&&q(e,"!=",18)||r&&q(e,"<=",14)||q(e,"<",13)||r&&q(e,">=",16)||q(e,">",15))||q(e,"+",1,!0)||function(e,t,r){let n=H(e,t);if(n)return 0===n[0].length?new c(r,0,n[1]):new c(r,n[0],n[1])}(e,"-",2)||q(e,"*",3)||q(e,"/",4,!0)||function(e){if(e.startsWith("!")&&e.length>1)return new c(5,e.substr(1),0)}(e),s instanceof c)return s;if(e.startsWith("math.")){if("math.pi"===e)return Math.PI;let t=e.indexOf("("),r=e.substr(5,t-5),n=e.substr(t+1,e.length-t-2),a=R(n,",");switch(a||(a=[n]),r){case"abs":return new c(100,a[0]);case"sin":return new c(101,a[0]);case"cos":return new c(102,a[0]);case"exp":return new c(103,a[0]);case"ln":return new c(104,a[0]);case"pow":return new c(105,a[0],a[1]);case"sqrt":return new c(106,a[0]);case"random":return new c(107,a[0],a[1]);case"ceil":return new c(108,a[0]);case"round":return new c(109,a[0]);case"trunc":return new c(110,a[0]);case"floor":return new c(111,a[0]);case"mod":return new c(112,a[0],a[1]);case"min":return new c(113,a[0],a[1]);case"max":return new c(114,a[0],a[1]);case"clamp":return new c(115,a[0],a[1],a[2]);case"lerp":return new c(116,a[0],a[1],a[2]);case"lerprotate":return new c(117,a[0],a[1],a[2]);case"asin":return new c(118,a[0]);case"acos":return new c(119,a[0]);case"atan":return new c(120,a[0]);case"atan2":return new c(121,a[0],a[1]);case"die_roll":return new c(122,a[0],a[1],a[2]);case"die_roll_integer":return new c(123,a[0],a[1],a[2]);case"hermite_blend":return new c(124,a[0]);case"random_integer":return new c(125,a[0],a[1])}}if(e.startsWith("loop(")){let t=R(e.substring(5,e.length-1),",");if(t)return new i(...t)}if(d=e.match(/[a-z0-9._]{2,}/g),d&&1===d.length&&d[0].length>=e.length-2)return w(e);if(e.includes("(")&&")"==e[e.length-1]){let t=e.search(/\(/),r=w(e.substr(0,t)),n=e.substr(t+1,e.length-t-2),a=R(n,",");return a||(a=[n]),new l(r,a)}return 0}function x(e){let t=e.startsWith(_)&&e.endsWith(k);if(t||e.startsWith(I)&&e.endsWith(O)){if(e.indexOf(t?k:O)===e.length-1)return!0;let r=0;for(let t=0;t=0;){switch(e[r]){case _:case I:n++;break;case k:case O:n--;break;default:if(!(0!==n||t[0]!==e[r]||1!==t.length&&t!==e.substr(r,t.length)||"-"===t&&!1!=="+*/<>=|&?:".includes(e[r-1])))return[e.substr(0,r),e.substr(r+t.length)]}r--}}function j(e,t,r){return"string"==typeof e&&"'"==e[0]||(e=E(e,r,!0)),"string"==typeof t&&"'"==t[0]||(t=E(t,r,!0)),e===t}function E(a,s,g){if("number"==typeof a)return a;if("string"==typeof a){let t=s[a];if(void 0===t&&"function"==typeof e.variableHandler&&(t=e.variableHandler(a,s)),"number"==typeof t)return t;if("string"==typeof t&&!g)return e.parse(t,s)||0;if(void 0===t)r=!0;else if("function"==typeof t)return t()||0;return t||0}if(void 0===a)return 0;switch(a.constructor){case c:switch(a.operator){case 1:return E(a.a,s)+E(a.b,s);case 2:return E(a.a,s)-E(a.b,s);case 3:return E(a.a,s)*E(a.b,s);case 4:return E(a.a,s)/E(a.b,s);case 5:return 0==E(a.a,s)?1:0;case 10:return E(a.a,s)?E(a.b,s):E(a.c,s);case 11:return E(a.a,s)&&E(a.b,s)?1:0;case 12:return E(a.a,s)||E(a.b,s)?1:0;case 13:return E(a.a,s)E(a.b,s)?1:0;case 16:return E(a.a,s)>=E(a.b,s)?1:0;case 17:return j(a.a,a.b,s)?1:0;case 18:return j(a.a,a.b,s)?0:1;case 19:r=!1;let e=E(a.a,s);return r?E(a.b,s):e;case 100:return Math.abs(E(a.a,s));case 101:return Math.sin(E(a.a,s)*d());case 102:return Math.cos(E(a.a,s)*d());case 103:return Math.exp(E(a.a,s));case 104:return Math.log(E(a.a,s));case 105:return E(a.a,s)**E(a.b,s);case 106:return Math.sqrt(E(a.a,s));case 107:return t.random(E(a.a,s),E(a.b,s));case 108:return Math.ceil(E(a.a,s));case 109:return Math.round(E(a.a,s));case 110:return Math.trunc(E(a.a,s));case 111:return Math.floor(E(a.a,s));case 112:return E(a.a,s)%E(a.b,s);case 113:return Math.min(E(a.a,s),E(a.b,s));case 114:return Math.max(E(a.a,s),E(a.b,s));case 115:return t.clamp(E(a.a,s),E(a.b,s),E(a.c,s));case 116:return t.lerp(E(a.a,s),E(a.b,s),E(a.c,s));case 117:return t.lerpRotate(E(a.a,s),E(a.b,s),E(a.c,s));case 118:return Math.asin(E(a.a,s))/d();case 119:return Math.acos(E(a.a,s))/d();case 120:return Math.atan(E(a.a,s))/d();case 121:return Math.atan2(E(a.a,s),E(a.b,s))/d();case 122:return t.dieRoll(E(a.a,s),E(a.b,s),E(a.c,s));case 123:return t.dieRollInt(E(a.a,s),E(a.b,s),E(a.c,s));case 124:let n=E(a.a,s);return 3*n**2-2*n**3;case 125:return t.randomInt(E(a.a,s),E(a.b,s))}break;case f:return n=1,E(a.value,s);case o:return s[a.name]=e.variables[a.name]=E(a.value,s),0;case l:let g=a.args.map((e=>E(e,s)));switch(a.query){case"query.in_range":return t.inRange(...g);case"query.all":return t.all(...g);case"query.any":return t.any(...g);case"query.approx_eq":return t.approxEq(...g)}return"function"==typeof s[a.query]?s[a.query](...g)||0:"function"==typeof e.variableHandler&&e.variableHandler(a.query,s,g)||0;case u:n=0;let p=0;for(let e of a.lines)if(p=E(e,s),n>0)break;return p;case i:let w=0,m=t.clamp(E(a.iterations,s),0,1024);for(let e=0;e{if("number"==typeof t)return t||0;if("string"!=typeof t||0===t.length)return 0;if(t.length<9&&p(t))return parseFloat(t);let u=this.cache_enabled&&a[t];return u||(u=M(t.toLowerCase().replace(/\s/g,"")),this.cache_enabled&&function(e,t){if(a[e]=t,s++,s>400){let e=Object.keys(a);for(let t=0;t<10;t++)delete a[e[t]];s-=10}}(t,u)),function(t,r){let a={};for(let t in e.global_variables)a[t]=e.global_variables[t];for(let t in e.variables)a[t]=e.variables[t];if(r)for(let e in r)a[e]=r[e];let s=E(t,a);return n=0,s}(u,r)||0},this.resetVariables=()=>{e.variables={}}}})); diff --git a/package.json b/package.json index bb8cbde79..7f01822f5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Blockbench", "description": "Low-poly modeling and animation software", - "version": "4.10.0", + "version": "4.10.1", "license": "GPL-3.0-or-later", "author": { "name": "JannisX11",