forked from JannisX11/blockbench-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble_sided_cubes.js
More file actions
53 lines (51 loc) · 1.5 KB
/
Copy pathdouble_sided_cubes.js
File metadata and controls
53 lines (51 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(()=> {
let cube_action;
Plugin.register('double_sided_cubes', {
title: 'Double Sided Cubes',
author: 'SnaveSutit',
description: 'Creates inverted duplicates of the selected cube(s) to allow double-sided rendering in java edition.',
tags: ["Minecraft: Java Edition"],
icon: 'flip_to_back',
version: '1.0.1',
variant: 'both',
onload() {
cube_action = new Action({
id:"create_double_sided_cubes",
name: 'Create Double Sided Cube',
icon: 'flip_to_back',
category: 'edit',
condition: () => !Project.box_uv,
click: function(ev) {
if (selected.length === 0) {
Blockbench.showMessage('No cubes selected', 'center')
return;
};
Undo.initEdit({elements:[]});
let cubes = [];
Cube.selected.forEach((cube) => {
const new_cube = cube.duplicate();
new_cube.name = new_cube.name + " inverted";
if (cube.parent !== "root") {
new_cube.addTo(cube.parent);
};
for (i=0; i<3; i++){
new_cube.flip(i, 0, false)
};
new_cube.from = [...cube.to];
new_cube.to = [...cube.from];
new_cube.inflate = -new_cube.inflate;
new_cube.origin = [-new_cube.origin[0],-new_cube.origin[1],-new_cube.origin[2]];
Canvas.adaptObjectPosition(new_cube);
Canvas.updateUV(new_cube);
cubes.push(new_cube);
});
Undo.finishEdit('create_double_sided_cube', {elements:cubes});
}
});
MenuBar.addAction(cube_action, 'filter');
},
onunload() {
cube_action.delete();
}
});
})();