2019-12-16 03:04:31 +08:00
|
|
|
|
|
|
|
const Clipbench = {
|
|
|
|
elements: [],
|
2020-03-05 03:56:17 +08:00
|
|
|
types: {
|
|
|
|
text: 'text',
|
|
|
|
display_slot: 'display_slot',
|
|
|
|
keyframe: 'keyframe',
|
2021-12-11 05:03:34 +08:00
|
|
|
animation: 'animation',
|
2020-03-05 03:56:17 +08:00
|
|
|
face: 'face',
|
2021-09-23 04:56:54 +08:00
|
|
|
mesh_selection: 'mesh_selection',
|
2020-03-05 03:56:17 +08:00
|
|
|
texture: 'texture',
|
2023-10-21 05:35:22 +08:00
|
|
|
layer: 'layer',
|
2020-03-05 03:56:17 +08:00
|
|
|
outliner: 'outliner',
|
|
|
|
texture_selection: 'texture_selection',
|
2022-09-07 01:38:38 +08:00
|
|
|
image: 'image',
|
2020-03-05 03:56:17 +08:00
|
|
|
},
|
2021-10-13 19:12:55 +08:00
|
|
|
type_icons: {
|
|
|
|
face: 'aspect_ratio',
|
|
|
|
mesh_selection: 'fa-gem',
|
|
|
|
outliner: 'fas.fa-cube',
|
|
|
|
},
|
2020-03-05 03:56:17 +08:00
|
|
|
getCopyType(mode, check) {
|
|
|
|
// mode: 1 = copy, 2 = paste
|
|
|
|
let p = Prop.active_panel;
|
|
|
|
let text;
|
|
|
|
if (!check) {
|
2020-08-30 19:41:50 +08:00
|
|
|
text = getFocusedTextInput() && window.getSelection()+'';
|
2020-03-05 03:56:17 +08:00
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
if (text) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.text;
|
|
|
|
}
|
|
|
|
if (Painter.selection.canvas && Toolbox.selected.id == 'copy_paste_tool') {
|
|
|
|
return Clipbench.types.texture_selection;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2023-11-17 05:45:06 +08:00
|
|
|
if (Modes.display) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.display_slot
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2021-12-11 05:03:34 +08:00
|
|
|
if (Animator.open && Prop.active_panel == 'animations') {
|
|
|
|
return Clipbench.types.animation
|
|
|
|
}
|
2020-08-30 19:41:50 +08:00
|
|
|
if (Animator.open && Timeline.animators.length && (Timeline.selected.length || mode === 2) && ['keyframe', 'timeline', 'preview'].includes(p)) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.keyframe
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2021-09-24 03:35:36 +08:00
|
|
|
if (Modes.edit && p == 'preview' && Mesh.selected[0] && Mesh.selected[0].getSelectedVertices().length && (mode !== 2 || Clipbench.vertices)) {
|
2021-09-23 04:56:54 +08:00
|
|
|
return Clipbench.types.mesh_selection;
|
|
|
|
}
|
|
|
|
if (mode == 2 && Modes.edit && Format.meshes && Clipbench.last_copied == 'mesh_selection' && (p == 'preview' || p == 'outliner')) {
|
|
|
|
return Clipbench.types.mesh_selection;
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
if ((p == 'uv' || p == 'preview') && Modes.edit) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.face;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2021-01-17 06:37:58 +08:00
|
|
|
if (p == 'textures' && (Texture.selected || mode === 2)) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.texture;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2023-10-21 05:35:22 +08:00
|
|
|
if (p == 'layers' && Texture.selected && Texture.selected.selected_layer) {
|
|
|
|
return Clipbench.types.layer;
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
if (p == 'outliner' && Modes.edit) {
|
2020-03-05 03:56:17 +08:00
|
|
|
return Clipbench.types.outliner;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2022-09-07 01:38:38 +08:00
|
|
|
if (!Project) {
|
|
|
|
return Clipbench.types.image;
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
},
|
2021-10-08 17:28:41 +08:00
|
|
|
async getPasteType() {
|
|
|
|
let p = Prop.active_panel;
|
|
|
|
if (getFocusedTextInput()) {
|
|
|
|
return Clipbench.types.text;
|
|
|
|
}
|
2022-10-20 19:05:59 +08:00
|
|
|
if (!Project) {
|
|
|
|
return Clipbench.types.image;
|
|
|
|
}
|
2021-10-08 17:28:41 +08:00
|
|
|
if (Painter.selection.canvas && Toolbox.selected.id == 'copy_paste_tool') {
|
|
|
|
return Clipbench.types.texture_selection;
|
|
|
|
}
|
2023-11-17 05:45:06 +08:00
|
|
|
if (Modes.display) {
|
2021-10-08 17:28:41 +08:00
|
|
|
return Clipbench.types.display_slot
|
|
|
|
}
|
2021-12-11 05:03:34 +08:00
|
|
|
if (Animator.open && Prop.active_panel == 'animations') {
|
|
|
|
return Clipbench.types.animation
|
|
|
|
}
|
2021-10-08 17:28:41 +08:00
|
|
|
if (Animator.open && Timeline.animators.length && ['keyframe', 'timeline', 'preview'].includes(p)) {
|
|
|
|
return Clipbench.types.keyframe
|
|
|
|
}
|
|
|
|
if (Modes.edit && p == 'preview') {
|
|
|
|
let options = [];
|
|
|
|
if (Clipbench.elements.length || Clipbench.group) {
|
|
|
|
options.push(Clipbench.types.outliner);
|
|
|
|
}
|
|
|
|
if (Mesh.selected[0] && Mesh.selected[0].getSelectedVertices().length && Clipbench.vertices) {
|
|
|
|
options.push(Clipbench.types.mesh_selection);
|
|
|
|
}
|
2023-02-05 02:48:32 +08:00
|
|
|
if (UVEditor.getMappableElements().length && UVEditor.clipboard?.length) {
|
2021-10-08 17:28:41 +08:00
|
|
|
options.push(Clipbench.types.face);
|
|
|
|
}
|
2021-11-30 01:55:17 +08:00
|
|
|
if (options.length > 1 && options.includes(settings.preview_paste_behavior.value)) {
|
|
|
|
return settings.preview_paste_behavior.value;
|
|
|
|
} else if (options.length > 1) {
|
2021-10-08 17:28:41 +08:00
|
|
|
return await new Promise((resolve, reject) => {
|
|
|
|
new Menu(options.map(option => {
|
|
|
|
return {
|
|
|
|
id: option,
|
|
|
|
name: tl(`menu.paste.${option}`),
|
2021-10-13 19:12:55 +08:00
|
|
|
icon: Clipbench.type_icons[option],
|
2021-10-08 17:28:41 +08:00
|
|
|
click() {
|
|
|
|
resolve(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})).show('mouse');
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
return options[0]
|
|
|
|
}
|
|
|
|
}
|
2023-02-05 02:48:32 +08:00
|
|
|
if (p == 'uv' && Modes.edit && UVEditor.clipboard?.length) {
|
2021-10-08 17:28:41 +08:00
|
|
|
return Clipbench.types.face;
|
|
|
|
}
|
2021-10-14 22:39:02 +08:00
|
|
|
if (p == 'textures') {
|
2021-10-08 17:28:41 +08:00
|
|
|
return Clipbench.types.texture;
|
|
|
|
}
|
2023-10-21 05:35:22 +08:00
|
|
|
if (p == 'layers' && Texture.selected && Texture.selected.selected_layer) {
|
|
|
|
return Clipbench.types.layer;
|
|
|
|
}
|
2021-10-08 17:28:41 +08:00
|
|
|
if (p == 'outliner' && Modes.edit) {
|
|
|
|
return Clipbench.types.outliner;
|
|
|
|
}
|
|
|
|
},
|
2019-12-16 03:04:31 +08:00
|
|
|
copy(event, cut) {
|
2023-10-27 19:02:28 +08:00
|
|
|
let match = SharedActions.run('copy', event, cut);
|
|
|
|
if (match) return;
|
|
|
|
|
2021-09-23 04:56:54 +08:00
|
|
|
let copy_type = Clipbench.getCopyType(1);
|
|
|
|
Clipbench.last_copied = copy_type;
|
|
|
|
switch (copy_type) {
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'text':
|
|
|
|
Clipbench.setText(window.getSelection()+'');
|
|
|
|
break;
|
|
|
|
case 'display_slot':
|
|
|
|
DisplayMode.copy();
|
|
|
|
break;
|
2021-12-11 05:03:34 +08:00
|
|
|
case 'animation':
|
|
|
|
Clipbench.setAnimation();
|
|
|
|
break;
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'keyframe':
|
|
|
|
if (Timeline.selected.length) {
|
|
|
|
Clipbench.setKeyframes();
|
|
|
|
if (cut) {
|
|
|
|
BarItems.delete.trigger();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'face':
|
2021-08-18 04:02:23 +08:00
|
|
|
UVEditor.copy(event);
|
2023-11-04 20:10:11 +08:00
|
|
|
if (Prop.active_panel == 'uv') {
|
|
|
|
Clipbench.group = undefined;
|
|
|
|
Clipbench.elements = [];
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
break;
|
2021-09-23 04:56:54 +08:00
|
|
|
case 'mesh_selection':
|
2021-10-08 17:28:41 +08:00
|
|
|
UVEditor.copy(event);
|
2021-09-23 04:56:54 +08:00
|
|
|
Clipbench.setMeshSelection(Mesh.selected[0], event);
|
|
|
|
break;
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'texture':
|
2020-07-16 15:32:59 +08:00
|
|
|
Clipbench.setTexture(Texture.selected);
|
2019-12-16 03:04:31 +08:00
|
|
|
if (cut) {
|
|
|
|
BarItems.delete.trigger();
|
|
|
|
}
|
|
|
|
break;
|
2021-09-23 04:56:54 +08:00
|
|
|
}
|
|
|
|
if (copy_type == 'outliner' || (copy_type == 'face' && Prop.active_panel == 'preview')) {
|
|
|
|
Clipbench.setElements();
|
|
|
|
Clipbench.setGroup();
|
|
|
|
if (Group.selected) {
|
|
|
|
Clipbench.setGroup(Group.selected);
|
|
|
|
} else {
|
|
|
|
Clipbench.setElements(selected);
|
|
|
|
}
|
|
|
|
if (cut) {
|
|
|
|
BarItems.delete.trigger();
|
|
|
|
}
|
2023-11-04 20:10:11 +08:00
|
|
|
if (Prop.active_panel == 'outliner') {
|
|
|
|
UVEditor.clipboard = []
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
|
|
|
},
|
2021-10-08 17:28:41 +08:00
|
|
|
async paste(event) {
|
2023-10-27 19:02:28 +08:00
|
|
|
let match = SharedActions.run('paste', event);
|
|
|
|
if (match) return;
|
|
|
|
|
2021-10-08 17:28:41 +08:00
|
|
|
switch (await Clipbench.getPasteType()) {
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'text':
|
|
|
|
Clipbench.setText(window.getSelection()+'');
|
|
|
|
break;
|
2020-03-05 03:56:17 +08:00
|
|
|
case 'texture_selection':
|
2021-08-18 04:02:23 +08:00
|
|
|
UVEditor.addPastingOverlay();
|
2019-12-16 03:04:31 +08:00
|
|
|
break;
|
|
|
|
case 'display_slot':
|
|
|
|
DisplayMode.paste();
|
|
|
|
break;
|
2021-12-11 05:03:34 +08:00
|
|
|
case 'animation':
|
|
|
|
Clipbench.pasteAnimation();
|
|
|
|
break;
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'keyframe':
|
|
|
|
Clipbench.pasteKeyframes()
|
|
|
|
break;
|
|
|
|
case 'face':
|
2021-08-18 04:02:23 +08:00
|
|
|
UVEditor.paste(event);
|
2019-12-16 03:04:31 +08:00
|
|
|
break;
|
2021-09-23 04:56:54 +08:00
|
|
|
case 'mesh_selection':
|
|
|
|
Clipbench.pasteMeshSelection();
|
|
|
|
break;
|
2019-12-16 03:04:31 +08:00
|
|
|
case 'texture':
|
|
|
|
Clipbench.pasteTextures();
|
|
|
|
break;
|
|
|
|
case 'outliner':
|
|
|
|
Clipbench.pasteOutliner(event);
|
|
|
|
break;
|
2022-09-07 01:38:38 +08:00
|
|
|
case 'image':
|
|
|
|
Clipbench.pasteImage(event);
|
|
|
|
break;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setGroup(group) {
|
|
|
|
if (!group) {
|
|
|
|
Clipbench.group = undefined
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Clipbench.group = group.getSaveCopy()
|
|
|
|
if (isApp) {
|
|
|
|
clipboard.writeHTML(JSON.stringify({type: 'group', content: Clipbench.group}))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setElements(arr) {
|
|
|
|
if (!arr) {
|
|
|
|
Clipbench.elements = []
|
|
|
|
return;
|
|
|
|
}
|
2021-02-20 17:00:24 +08:00
|
|
|
arr.forEach(function(element) {
|
|
|
|
Clipbench.elements.push(element.getSaveCopy())
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|
|
|
|
if (isApp) {
|
|
|
|
clipboard.writeHTML(JSON.stringify({type: 'elements', content: Clipbench.elements}))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setText(text) {
|
|
|
|
if (isApp) {
|
|
|
|
clipboard.writeText(text)
|
2021-01-17 06:37:58 +08:00
|
|
|
} else if (navigator.clipboard) {
|
|
|
|
navigator.clipboard.writeText(text);
|
2019-12-16 03:04:31 +08:00
|
|
|
} else {
|
|
|
|
document.execCommand('copy')
|
|
|
|
}
|
|
|
|
},
|
2021-09-23 04:56:54 +08:00
|
|
|
setMeshSelection(mesh) {
|
|
|
|
this.vertices = {};
|
|
|
|
this.faces = {};
|
|
|
|
mesh.getSelectedVertices().forEach(vkey => {
|
|
|
|
this.vertices[vkey] = mesh.vertices[vkey].slice();
|
|
|
|
})
|
|
|
|
for (let fkey in mesh.faces) {
|
|
|
|
let face = mesh.faces[fkey];
|
2023-07-20 05:43:56 +08:00
|
|
|
if (face.isSelected(fkey)) {
|
2021-09-23 04:56:54 +08:00
|
|
|
this.faces[fkey] = new MeshFace(null, face);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pasteMeshSelection() {
|
|
|
|
let elements = Mesh.selected.slice();
|
|
|
|
Undo.initEdit({elements});
|
|
|
|
let new_mesh;
|
|
|
|
if (!elements.length) {
|
|
|
|
new_mesh = new Mesh({name: 'pasted', vertices: []});
|
|
|
|
elements.push(new_mesh);
|
|
|
|
}
|
2023-06-28 03:33:02 +08:00
|
|
|
let selection_mode_before = BarItems.selection_mode.value;
|
|
|
|
BarItems.selection_mode.change('vertex');
|
2021-09-23 04:56:54 +08:00
|
|
|
elements.forEach(mesh => {
|
|
|
|
let old_vertices = Object.keys(this.vertices);
|
|
|
|
let vertices_positions = old_vertices.map(vkey => this.vertices[vkey]);
|
|
|
|
let new_vertices = mesh.addVertices(...vertices_positions);
|
|
|
|
|
|
|
|
for (let old_fkey in this.faces) {
|
|
|
|
let old_face = this.faces[old_fkey];
|
|
|
|
let new_face = new MeshFace(mesh, old_face);
|
2022-05-07 05:43:50 +08:00
|
|
|
Property.resetUniqueValues(MeshFace, new_face);
|
2021-09-23 04:56:54 +08:00
|
|
|
let new_face_vertices = new_face.vertices.map(old_vkey => {
|
|
|
|
let new_vkey = new_vertices[old_vertices.indexOf(old_vkey)];
|
|
|
|
new_face.uv[new_vkey] = new_face.uv[old_vkey];
|
|
|
|
delete new_face.uv[old_vkey];
|
|
|
|
return new_vkey;
|
|
|
|
})
|
|
|
|
new_face.vertices.replace(new_face_vertices);
|
|
|
|
mesh.addFaces(new_face);
|
|
|
|
}
|
|
|
|
mesh.getSelectedVertices(true).replace(new_vertices);
|
|
|
|
})
|
|
|
|
if (new_mesh) {
|
|
|
|
new_mesh.init().select();
|
|
|
|
}
|
2023-06-28 03:33:02 +08:00
|
|
|
// Update vertex selection to appropriate selection mode
|
|
|
|
BarItems.selection_mode.change(selection_mode_before);
|
|
|
|
|
2021-09-23 04:56:54 +08:00
|
|
|
Undo.finishEdit('Paste mesh selection');
|
|
|
|
Canvas.updateView({elements: Mesh.selected, selection: true})
|
|
|
|
},
|
2019-12-16 03:04:31 +08:00
|
|
|
pasteOutliner(event) {
|
|
|
|
Undo.initEdit({outliner: true, elements: [], selection: true});
|
|
|
|
//Group
|
|
|
|
var target = 'root'
|
|
|
|
if (Group.selected) {
|
|
|
|
target = Group.selected
|
|
|
|
Group.selected.isOpen = true
|
|
|
|
} else if (selected[0]) {
|
|
|
|
target = selected[0]
|
|
|
|
}
|
|
|
|
selected.length = 0
|
|
|
|
if (isApp) {
|
|
|
|
var raw = clipboard.readHTML()
|
|
|
|
try {
|
|
|
|
var data = JSON.parse(raw)
|
|
|
|
if (data.type === 'elements' && data.content) {
|
|
|
|
Clipbench.group = undefined;
|
|
|
|
Clipbench.elements = data.content;
|
|
|
|
} else if (data.type === 'group' && data.content) {
|
|
|
|
Clipbench.group = data.content;
|
|
|
|
Clipbench.elements = [];
|
|
|
|
}
|
|
|
|
} catch (err) {}
|
|
|
|
}
|
|
|
|
if (Clipbench.group) {
|
|
|
|
function iterate(obj, parent) {
|
|
|
|
if (obj.children) {
|
2024-04-19 02:17:49 +08:00
|
|
|
let copy = new Group(obj).addTo(parent).init();
|
2022-08-12 02:09:04 +08:00
|
|
|
copy._original_name = copy.name;
|
2020-01-24 01:53:36 +08:00
|
|
|
copy.createUniqueName();
|
2022-05-07 05:43:50 +08:00
|
|
|
Property.resetUniqueValues(Group, copy);
|
2020-01-24 01:53:36 +08:00
|
|
|
|
2019-12-16 03:04:31 +08:00
|
|
|
if (obj.children && obj.children.length) {
|
|
|
|
obj.children.forEach((child) => {
|
|
|
|
iterate(child, copy)
|
|
|
|
})
|
|
|
|
}
|
2024-04-19 02:17:49 +08:00
|
|
|
return copy;
|
2021-07-30 00:17:26 +08:00
|
|
|
} else if (OutlinerElement.isTypePermitted(obj.type)) {
|
2022-05-07 05:43:50 +08:00
|
|
|
var copy = OutlinerElement.fromSave(obj).addTo(parent).selectLow();
|
|
|
|
copy.createUniqueName();
|
|
|
|
Property.resetUniqueValues(copy.constructor, copy);
|
|
|
|
copy.preview_controller.updateTransform(copy);
|
2024-04-19 02:17:49 +08:00
|
|
|
return copy;
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-19 02:17:49 +08:00
|
|
|
let copy = iterate(Clipbench.group, target);
|
|
|
|
copy.select();
|
2019-12-16 03:04:31 +08:00
|
|
|
|
|
|
|
} else if (Clipbench.elements && Clipbench.elements.length) {
|
2021-05-22 18:27:29 +08:00
|
|
|
let elements = [];
|
2019-12-16 03:04:31 +08:00
|
|
|
Clipbench.elements.forEach(function(obj) {
|
2021-07-30 00:17:26 +08:00
|
|
|
if (!OutlinerElement.isTypePermitted(obj.type)) return;
|
2022-05-07 05:43:50 +08:00
|
|
|
var copy = OutlinerElement.fromSave(obj).addTo(target).selectLow();
|
|
|
|
copy.createUniqueName();
|
|
|
|
Property.resetUniqueValues(copy.constructor, copy);
|
|
|
|
elements.push(copy);
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|
2021-05-22 18:27:29 +08:00
|
|
|
Canvas.updateView({elements});
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2021-10-23 18:45:06 +08:00
|
|
|
|
|
|
|
//Rotate Cubes
|
|
|
|
if (!Format.rotate_cubes) {
|
|
|
|
elements.forEach(cube => {
|
|
|
|
if (cube instanceof Cube == false) return;
|
|
|
|
cube.rotation.V3_set(0, 0, 0)
|
|
|
|
})
|
|
|
|
Canvas.updateView({elements, element_aspects: {transform: true}});
|
|
|
|
}
|
|
|
|
|
|
|
|
//Canvas Limit
|
2022-06-03 05:02:13 +08:00
|
|
|
if (Format.cube_size_limiter && !settings.deactivate_size_limit.value) {
|
2021-10-23 18:45:06 +08:00
|
|
|
|
|
|
|
elements.forEach(s => {
|
2022-06-03 05:02:13 +08:00
|
|
|
if (s instanceof Cube) {
|
|
|
|
//Push elements into 3x3 block box
|
|
|
|
Format.cube_size_limiter.move(s);
|
|
|
|
}
|
2021-10-23 18:45:06 +08:00
|
|
|
})
|
|
|
|
Canvas.updateView({elements, element_aspects: {transform: true, geometry: true}});
|
|
|
|
}
|
|
|
|
|
|
|
|
//Rotation Limit
|
|
|
|
if (Format.rotation_limit && Format.rotate_cubes) {
|
|
|
|
elements.forEach(cube => {
|
|
|
|
if (cube instanceof Cube == false) return;
|
|
|
|
if (!cube.rotation.allEqual(0)) {
|
2021-10-27 01:27:32 +08:00
|
|
|
var axis = getAxisNumber(cube.rotationAxis()) || 0;
|
2022-10-17 17:31:31 +08:00
|
|
|
var cube_rotation = Format.rotation_snap ? Math.round(cube.rotation[axis]/22.5)*22.5 : cube.rotation[axis];
|
2022-10-17 17:27:37 +08:00
|
|
|
var angle = limitNumber( cube_rotation, -45, 45 );
|
2021-10-23 18:45:06 +08:00
|
|
|
cube.rotation.V3_set(0, 0, 0);
|
|
|
|
cube.rotation[axis] = angle;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
Canvas.updateView({elements, element_aspects: {transform: true}});
|
|
|
|
}
|
|
|
|
|
2021-06-06 15:28:22 +08:00
|
|
|
Undo.finishEdit('Paste Elements', {outliner: true, elements: selected, selection: true});
|
2022-09-07 01:38:38 +08:00
|
|
|
},
|
|
|
|
pasteImage() {
|
|
|
|
function loadFromDataUrl(dataUrl) {
|
|
|
|
if (!dataUrl || dataUrl.length < 32) return;
|
2022-10-20 19:05:59 +08:00
|
|
|
|
|
|
|
Codecs.image.load(dataUrl);
|
2022-09-07 01:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isApp) {
|
|
|
|
var image = clipboard.readImage().toDataURL();
|
|
|
|
loadFromDataUrl(image);
|
|
|
|
} else {
|
|
|
|
navigator.clipboard.read().then(content => {
|
|
|
|
if (content && content[0] && content[0].types.includes('image/png')) {
|
|
|
|
content[0].getType('image/png').then(blob => {
|
|
|
|
let url = URL.createObjectURL(blob);
|
|
|
|
loadFromDataUrl(url);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(() => {})
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BARS.defineActions(function() {
|
|
|
|
|
|
|
|
new Action('copy', {
|
|
|
|
icon: 'fa-copy',
|
|
|
|
category: 'edit',
|
|
|
|
work_in_dialog: true,
|
2023-10-27 19:02:28 +08:00
|
|
|
condition: () => Clipbench.getCopyType(1, true) || SharedActions.condition('copy'),
|
2024-06-25 04:54:35 +08:00
|
|
|
keybind: new Keybind({key: 'c', ctrl: true}, {
|
|
|
|
multiple: 'shift'
|
|
|
|
}),
|
|
|
|
variations: {
|
|
|
|
multiple: {
|
|
|
|
name: 'action.copy.multiple',
|
|
|
|
description: 'action.copy.multiple.desc',
|
|
|
|
}
|
|
|
|
},
|
2023-02-01 06:48:29 +08:00
|
|
|
click(event) {
|
|
|
|
Clipbench.copy(event)
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|
|
|
|
new Action('cut', {
|
|
|
|
icon: 'fa-cut',
|
|
|
|
category: 'edit',
|
|
|
|
work_in_dialog: true,
|
2023-10-27 19:02:28 +08:00
|
|
|
condition: () => Clipbench.getCopyType(1, true) || SharedActions.condition('copy'),
|
2024-06-25 04:54:35 +08:00
|
|
|
keybind: new Keybind({key: 'x', ctrl: true}, {
|
|
|
|
multiple: 'shift'
|
|
|
|
}),
|
|
|
|
variations: {
|
|
|
|
multiple: {
|
|
|
|
name: 'action.copy.multiple',
|
|
|
|
description: 'action.copy.multiple.desc',
|
|
|
|
}
|
|
|
|
},
|
2023-02-01 06:48:29 +08:00
|
|
|
click(event) {
|
|
|
|
Clipbench.copy(event, true)
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|
2023-02-01 06:48:29 +08:00
|
|
|
let paste = new Action('paste', {
|
2019-12-16 03:04:31 +08:00
|
|
|
icon: 'fa-clipboard',
|
|
|
|
category: 'edit',
|
|
|
|
work_in_dialog: true,
|
2023-10-27 19:02:28 +08:00
|
|
|
condition: () => Clipbench.getCopyType(2, true) || SharedActions.condition('paste'),
|
2024-06-25 04:54:35 +08:00
|
|
|
keybind: new Keybind({key: 'v', ctrl: true}, {
|
|
|
|
multiple: 'shift'
|
|
|
|
}),
|
|
|
|
variations: {
|
|
|
|
multiple: {
|
|
|
|
name: 'action.paste.multiple',
|
|
|
|
}
|
|
|
|
},
|
2023-02-01 06:48:29 +08:00
|
|
|
click(event) {
|
|
|
|
Clipbench.paste(event)
|
|
|
|
}
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|
2023-02-01 06:48:29 +08:00
|
|
|
paste.addSubKeybind('outliner', 'menu.paste.outliner', null, event => {
|
|
|
|
Clipbench.pasteOutliner(event);
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('face', 'menu.paste.face', null, event => {
|
|
|
|
UVEditor.paste(event);
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('mesh_selection', 'menu.paste.mesh_selection', null, event => {
|
|
|
|
Clipbench.pasteMeshSelection();
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('texture', 'data.texture', null, event => {
|
|
|
|
Clipbench.pasteTextures();
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('image', 'format.image', null, event => {
|
|
|
|
Clipbench.pasteImage(event);
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('animation', 'menu.animation', null, event => {
|
|
|
|
Clipbench.pasteAnimation();
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('keyframe', 'menu.keyframe', null, event => {
|
|
|
|
Clipbench.pasteKeyframes();
|
|
|
|
});
|
|
|
|
paste.addSubKeybind('display_slot', 'category.display', null, event => {
|
|
|
|
DisplayMode.paste();
|
|
|
|
});
|
2019-12-16 03:04:31 +08:00
|
|
|
})
|