mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-06 17:31:09 +08:00
Convert some files to typescript
This commit is contained in:
parent
c57c015401
commit
a2e9115d6b
23
js/api.js
23
js/api.js
@ -206,7 +206,7 @@ export const Blockbench = {
|
||||
Blockbench.showQuickMessage(message)
|
||||
}
|
||||
},
|
||||
showMessageBox(options = 0, cb) {
|
||||
showMessageBox(options, cb) {
|
||||
return new MessageBox(options, cb).show();
|
||||
},
|
||||
/**
|
||||
@ -219,7 +219,7 @@ export const Blockbench = {
|
||||
* @param {string} options.description Description for the text input
|
||||
* @returns {Promise<string>} Input value
|
||||
*/
|
||||
async textPrompt(title, value, callback, options = 0) {
|
||||
async textPrompt(title, value, callback, options = {}) {
|
||||
if (typeof options == 'string') {
|
||||
options = {placeholder: options};
|
||||
console.warn('textPrompt: 4th argument is expected to be a string');
|
||||
@ -338,6 +338,25 @@ export const Blockbench = {
|
||||
if (LastVersion && compareVersions(version, LastVersion) && !Blockbench.isOlderThan(version)) {
|
||||
callback(LastVersion);
|
||||
}
|
||||
},
|
||||
// Globals
|
||||
get Format() {
|
||||
return window.Format;
|
||||
},
|
||||
set Format(format) {
|
||||
return window.Format = format;
|
||||
},
|
||||
get Project() {
|
||||
return window.Project;
|
||||
},
|
||||
set Project(project) {
|
||||
return window.Project = project;
|
||||
},
|
||||
get Undo() {
|
||||
return window.Undo;
|
||||
},
|
||||
set Undo(undo_system) {
|
||||
return window.Undo = undo_system;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Blockbench } from "./api";
|
||||
import { translateUI } from "./languages";
|
||||
import { loadInstalledPlugins } from "./plugin_loader";
|
||||
import { animate } from "./preview/preview";
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { Blockbench } from "./api";
|
||||
|
||||
Blockbench.Outliner = Outliner;
|
||||
Blockbench.OutlinerNode = OutlinerNode;
|
||||
Blockbench.OutlinerElement = OutlinerElement;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { translateUI } from "../languages";
|
||||
|
||||
export class ResizeLine {
|
||||
constructor(id, data) {
|
||||
var scope = this;
|
||||
|
@ -1,9 +1,277 @@
|
||||
import { Vue } from "../../lib/libs";
|
||||
import { Blockbench } from "../api";
|
||||
import { setProjectTitle } from "../interface/interface";
|
||||
import { Settings } from "../interface/settings";
|
||||
import { Mode, Modes } from "../modes";
|
||||
import { Group } from "../outliner/group";
|
||||
import { Canvas } from "../preview/canvas";
|
||||
import { DefaultCameraPresets } from "../preview/preview";
|
||||
import { Property } from "../util/property";
|
||||
|
||||
// @ts-ignore
|
||||
window.Format = 0;
|
||||
export const Formats = {};
|
||||
|
||||
//Formats
|
||||
export class ModelFormat {
|
||||
constructor(id, data) {
|
||||
interface FormatOptions {
|
||||
id: string
|
||||
icon: string
|
||||
name?: string
|
||||
description?: string
|
||||
category?: string
|
||||
target?: string | string[]
|
||||
confidential?: boolean
|
||||
condition?: ConditionResolvable
|
||||
show_on_start_screen?: boolean
|
||||
show_in_new_list?: boolean
|
||||
can_convert_to?: boolean
|
||||
plugin?: string
|
||||
format_page?: FormatPage
|
||||
onFormatPage?(): void
|
||||
onStart?(): void
|
||||
onSetup?(project: ModelProject, newModel?: boolean): void
|
||||
new?(): boolean
|
||||
convertTo?(): void
|
||||
|
||||
/**
|
||||
* Enables Box UV on cubes by default or something
|
||||
*/
|
||||
box_uv: boolean
|
||||
/**
|
||||
* If true, box UV is optional and can be toggled on the project or per cube
|
||||
*/
|
||||
optional_box_uv: boolean
|
||||
/**
|
||||
* If true, only one texture can be assigned to the model at a time, instead of textures being assigned per face
|
||||
*/
|
||||
single_texture: boolean
|
||||
/**
|
||||
* If true, a single texture is used as default, but textures can still be assigned to faces
|
||||
*/
|
||||
single_texture_default: boolean
|
||||
/**
|
||||
* If true, textures can be assigned per group instead of per face
|
||||
*/
|
||||
per_group_texture: boolean
|
||||
/**
|
||||
* If true, UV size (the size of the texture in UV space) will be defined per texture and not per project
|
||||
*/
|
||||
per_texture_uv_size: boolean
|
||||
/**
|
||||
* Enable a model identifier field in the project settings. Default is true
|
||||
*/
|
||||
model_identifier: boolean
|
||||
/**
|
||||
* If true, the file name of a project will be editable in the project settings
|
||||
*/
|
||||
legacy_editable_file_name: boolean
|
||||
/**
|
||||
* If true, enables a field in the project settings to set a parent model ID
|
||||
*/
|
||||
parent_model_id: boolean
|
||||
/**
|
||||
* Adds a toggle in the project settings to enable project wide vertex color ambient occlusion
|
||||
*/
|
||||
vertex_color_ambient_occlusion: boolean
|
||||
/**
|
||||
* Enable flipbook animated textures
|
||||
*/
|
||||
animated_textures: boolean
|
||||
/**
|
||||
* Enable groups to work as bones and rig the model
|
||||
*/
|
||||
bone_rig: boolean
|
||||
/**
|
||||
* Align the grid center with the model origin, instead of the grid corner
|
||||
*/
|
||||
centered_grid: boolean
|
||||
/**
|
||||
* Add the ability to rotate cubes
|
||||
*/
|
||||
rotate_cubes: boolean
|
||||
/**
|
||||
* Add the ability to stretch cubes. Stretch scales cubes from the center without affecting UV
|
||||
*/
|
||||
stretch_cubes: boolean
|
||||
/**
|
||||
* If true, cube sizes are limited to integer values
|
||||
*/
|
||||
integer_size: boolean
|
||||
/**
|
||||
* Enable mesh elements
|
||||
*/
|
||||
meshes: boolean
|
||||
/**
|
||||
* Enable texture meshes
|
||||
*/
|
||||
texture_meshes: boolean
|
||||
/**
|
||||
* Enable locators
|
||||
*/
|
||||
locators: boolean
|
||||
/**
|
||||
* Enforces a rotation limit for cubes of up to 45 degrees in either direction and one axis at a time
|
||||
*/
|
||||
rotation_limit: boolean
|
||||
/**
|
||||
* Forces cube rotations to snap to 22.5 degree increments
|
||||
*/
|
||||
rotation_snap: boolean
|
||||
/**
|
||||
* Allows cube UVs to be rotated
|
||||
*/
|
||||
uv_rotation: boolean
|
||||
/**
|
||||
* Enables Minecraft Java block/item model specific cube face features (tint and export)
|
||||
*/
|
||||
java_face_properties: boolean
|
||||
/**
|
||||
* Allows assigning one texture to be used as a texture for particles related to the model
|
||||
*/
|
||||
select_texture_for_particles: boolean
|
||||
/**
|
||||
* Enable mcmeta files for animated texture files
|
||||
*/
|
||||
texture_mcmeta: boolean
|
||||
/**
|
||||
* Enables an option to set an expression for bone bindings
|
||||
*/
|
||||
bone_binding_expression: boolean
|
||||
/**
|
||||
* If true, animations will be saved into files
|
||||
*/
|
||||
animation_files: boolean
|
||||
/**
|
||||
* Enables a folder path per texture that can be set in the texture properties window
|
||||
*/
|
||||
texture_folder: boolean
|
||||
/**
|
||||
* Enables the 2D image editor
|
||||
*/
|
||||
image_editor: boolean
|
||||
/**
|
||||
* Enables edit mode. Default is true
|
||||
*/
|
||||
edit_mode: boolean
|
||||
/**
|
||||
* Enables paint mode. Default is true
|
||||
*/
|
||||
paint_mode: boolean
|
||||
/**
|
||||
* Enables display mode
|
||||
*/
|
||||
display_mode: boolean
|
||||
/**
|
||||
* Emaböes animation mode
|
||||
*/
|
||||
animation_mode: boolean
|
||||
/**
|
||||
* Enables pose mode
|
||||
*/
|
||||
pose_mode: boolean
|
||||
/**
|
||||
* Enables animation controllers
|
||||
*/
|
||||
animation_controllers: boolean
|
||||
/**
|
||||
* If true, cube sizes will not be floored to calculate UV sizes with box UV. This can result in UVs not aligning with pixel edges
|
||||
*/
|
||||
box_uv_float_size: boolean
|
||||
/**
|
||||
* Enables properties for Minecraft Java block/item models related to block shading (shading option and light emission value)
|
||||
*/
|
||||
java_cube_shading_properties: boolean
|
||||
/**
|
||||
* Enables cullfaces, the ability on faces in Minecraft block models to set a direction, that, if covered by another block, will cause the face to unrender
|
||||
*/
|
||||
cullfaces: boolean
|
||||
/**
|
||||
* A set of characters that is allowed in node names (names of elements and groups that can be referenced externally, this does not apply to cubes or meshes)
|
||||
*/
|
||||
node_name_regex: string
|
||||
/**
|
||||
* Set the default render sides for textures
|
||||
*/
|
||||
render_sides: 'front' | 'double' | 'back' | (() => 'front' | 'double' | 'back')
|
||||
|
||||
/**
|
||||
* Options to limit the size of cubes
|
||||
*/
|
||||
cube_size_limiter?: CubeSizeLimiter
|
||||
|
||||
codec?: Codec
|
||||
onActivation?(): void
|
||||
onDeactivation?(): void
|
||||
}
|
||||
|
||||
export class ModelFormat implements FormatOptions {
|
||||
id: string
|
||||
icon: string
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
target: string | string[]
|
||||
confidential: boolean
|
||||
condition: ConditionResolvable
|
||||
show_on_start_screen: boolean
|
||||
show_in_new_list: boolean
|
||||
can_convert_to: boolean
|
||||
plugin: string
|
||||
format_page?: FormatPage
|
||||
onFormatPage?(): void
|
||||
onStart?(): void
|
||||
onSetup?(project: ModelProject, newModel?: boolean): void
|
||||
|
||||
box_uv: boolean
|
||||
optional_box_uv: boolean
|
||||
single_texture: boolean
|
||||
single_texture_default: boolean
|
||||
per_group_texture: boolean
|
||||
per_texture_uv_size: boolean
|
||||
model_identifier: boolean
|
||||
legacy_editable_file_name: boolean
|
||||
parent_model_id: boolean
|
||||
vertex_color_ambient_occlusion: boolean
|
||||
animated_textures: boolean
|
||||
bone_rig: boolean
|
||||
centered_grid: boolean
|
||||
rotate_cubes: boolean
|
||||
stretch_cubes: boolean
|
||||
integer_size: boolean
|
||||
meshes: boolean
|
||||
texture_meshes: boolean
|
||||
locators: boolean
|
||||
rotation_limit: boolean
|
||||
rotation_snap: boolean
|
||||
uv_rotation: boolean
|
||||
java_face_properties: boolean
|
||||
select_texture_for_particles: boolean
|
||||
texture_mcmeta: boolean
|
||||
bone_binding_expression: boolean
|
||||
animation_files: boolean
|
||||
texture_folder: boolean
|
||||
image_editor: boolean
|
||||
edit_mode: boolean
|
||||
paint_mode: boolean
|
||||
display_mode: boolean
|
||||
animation_mode: boolean
|
||||
pose_mode: boolean
|
||||
animation_controllers: boolean
|
||||
box_uv_float_size: boolean
|
||||
java_cube_shading_properties: boolean
|
||||
cullfaces: boolean
|
||||
node_name_regex: string
|
||||
render_sides: 'front' | 'double' | 'back' | (() => 'front' | 'double' | 'back')
|
||||
|
||||
cube_size_limiter?: CubeSizeLimiter
|
||||
|
||||
codec?: Codec
|
||||
onActivation?(): void
|
||||
onDeactivation?(): void
|
||||
|
||||
static properties: Record<string, Property>
|
||||
|
||||
constructor(id, data: FormatOptions) {
|
||||
if (typeof id == 'object') {
|
||||
data = id;
|
||||
id = data.id;
|
||||
@ -16,10 +284,7 @@ export class ModelFormat {
|
||||
this.category = data.category || 'other';
|
||||
this.target = data.target;
|
||||
this.show_on_start_screen = true;
|
||||
this.show_in_new_list = true;
|
||||
this.can_convert_to = true;
|
||||
this.confidential = false;
|
||||
this.plugin = data.plugin || (typeof Plugins != 'undefined' ? Plugins.currently_loading : '');
|
||||
|
||||
for (let id in ModelFormat.properties) {
|
||||
ModelFormat.properties[id].reset(this);
|
||||
@ -56,7 +321,7 @@ export class ModelFormat {
|
||||
if (Format && typeof Format.onDeactivation == 'function') {
|
||||
Format.onDeactivation()
|
||||
}
|
||||
Format = Project.format = this;
|
||||
Blockbench.Format = Blockbench.Project.format = this;
|
||||
if (typeof this.onActivation == 'function') {
|
||||
Format.onActivation()
|
||||
}
|
||||
@ -74,13 +339,15 @@ export class ModelFormat {
|
||||
Settings.updateSettingsInProfiles();
|
||||
Preview.all.forEach(preview => {
|
||||
if (preview.isOrtho && typeof preview.angle == 'number') {
|
||||
preview.loadAnglePreset(DefaultCameraPresets[preview.angle+1])
|
||||
// @ts-ignore Incompatible internal and external types
|
||||
preview.loadAnglePreset(DefaultCameraPresets[preview.angle+1] as AnglePreset)
|
||||
}
|
||||
})
|
||||
if (Mode.selected && !Condition(Mode.selected.condition)) {
|
||||
(this.pose_mode ? Modes.options.paint : Modes.options.edit).select();
|
||||
}
|
||||
Interface.Panels.animations.inside_vue._data.animation_files_enabled = this.animation_files;
|
||||
Interface.Panels.animations.inside_vue.$data.animation_files_enabled = this.animation_files;
|
||||
// @ts-ignore
|
||||
Interface.status_bar.vue.Format = this;
|
||||
UVEditor.vue.cube_uv_rotation = this.uv_rotation;
|
||||
if (Modes.vue) Modes.vue.$forceUpdate();
|
||||
@ -90,11 +357,13 @@ export class ModelFormat {
|
||||
Blockbench.dispatchEvent('select_format', {format: this, project: Project});
|
||||
return this;
|
||||
}
|
||||
new() {
|
||||
new(): boolean {
|
||||
// @ts-ignore Conflicting internal and external types
|
||||
if (newProject(this)) {
|
||||
BarItems.project_window.click();
|
||||
(BarItems.project_window as Action).click();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
convertTo() {
|
||||
|
||||
@ -148,7 +417,9 @@ export class ModelFormat {
|
||||
el.addTo(root_group)
|
||||
})
|
||||
}
|
||||
// @ts-ignore
|
||||
if (!Project.geometry_name && Project.name) {
|
||||
// @ts-ignore
|
||||
Project.geometry_name = Project.name;
|
||||
}
|
||||
}
|
||||
@ -174,7 +445,8 @@ export class ModelFormat {
|
||||
|
||||
if (!Format.single_texture && old_format.single_texture && Texture.all.length) {
|
||||
let texture = Texture.getDefault();
|
||||
Outliner.elements.filter(el => el.applyTexture).forEach(el => {
|
||||
Outliner.elements.filter((el: OutlinerElement) => 'applyTexture' in el).forEach(el => {
|
||||
// @ts-ignore
|
||||
el.applyTexture(texture, true)
|
||||
})
|
||||
}
|
||||
@ -251,6 +523,7 @@ export class ModelFormat {
|
||||
}
|
||||
delete() {
|
||||
delete Formats[this.id];
|
||||
// @ts-ignore
|
||||
if (this.codec && this.codec.format == this) delete this.codec.format;
|
||||
Blockbench.dispatchEvent('delete_format', {format: this});
|
||||
}
|
@ -1185,7 +1185,7 @@ var codec = new Codec('bedrock', {
|
||||
throw 'Incompatible format';
|
||||
}
|
||||
var i = 0;
|
||||
for (model of data['minecraft:geometry']) {
|
||||
for (let model of data['minecraft:geometry']) {
|
||||
if (model.description && model.description.identifier == model_id) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -181,7 +181,7 @@ export function buildSkinnedMesh(root_group, scale) {
|
||||
function addGroup(group, parent_bone) {
|
||||
if (group.export == false) return;
|
||||
|
||||
for (child of group.children) {
|
||||
for (let child of group.children) {
|
||||
if (!child.faces || child.export == false) continue;
|
||||
let {geometry} = child.mesh;
|
||||
let matrix = new THREE.Matrix4().copy(child.mesh.matrixWorld);
|
||||
@ -238,7 +238,7 @@ export function buildSkinnedMesh(root_group, scale) {
|
||||
parent_bone.add(bone);
|
||||
}
|
||||
// Children
|
||||
for (child of group.children) {
|
||||
for (let child of group.children) {
|
||||
if (child instanceof Group) {
|
||||
addGroup(child, bone);
|
||||
}
|
||||
|
@ -134,11 +134,10 @@ var codec = new Codec('java_block', {
|
||||
}
|
||||
}
|
||||
function iterate(arr) {
|
||||
var i = 0;
|
||||
if (!arr || !arr.length) {
|
||||
return;
|
||||
}
|
||||
for (i=0; i<arr.length; i++) {
|
||||
for (let i=0; i<arr.length; i++) {
|
||||
if (arr[i].type === 'cube') {
|
||||
computeCube(arr[i])
|
||||
} else if (arr[i].type === 'group') {
|
||||
|
@ -340,7 +340,7 @@ export const skin_dialog = new Dialog({
|
||||
}
|
||||
},
|
||||
onCancel() {
|
||||
Format = 0;
|
||||
Blockbench.Format = 0;
|
||||
Settings.updateSettingsInProfiles();
|
||||
}
|
||||
});
|
||||
|
@ -180,8 +180,8 @@ export class ModelProject {
|
||||
return this;
|
||||
}
|
||||
loadEditorState() {
|
||||
Project = this;
|
||||
Undo = this.undo;
|
||||
Blockbench.Project = this;
|
||||
Blockbench.Undo = this.undo;
|
||||
this.selected = true;
|
||||
this.format.select();
|
||||
BarItems.view_mode.set(this.view_mode);
|
||||
@ -325,9 +325,9 @@ export class ModelProject {
|
||||
scene.remove(this.model_3d);
|
||||
OutlinerNode.uuids = {};
|
||||
MirrorModeling.cached_elements = {};
|
||||
Format = 0;
|
||||
Project = 0;
|
||||
Undo = 0;
|
||||
Blockbench.Format = 0;
|
||||
Blockbench.Project = 0;
|
||||
Blockbench.Undo = 0;
|
||||
if (Modes.selected) Modes.selected.unselect();
|
||||
Settings.updateSettingsInProfiles();
|
||||
|
||||
@ -424,7 +424,7 @@ export class ModelProject {
|
||||
let index = ModelProject.all.indexOf(this);
|
||||
ModelProject.all.remove(this);
|
||||
delete ProjectData[this.uuid];
|
||||
Project = 0;
|
||||
Blockbench.Project = 0;
|
||||
|
||||
await AutoBackup.removeBackup(this.uuid);
|
||||
|
||||
@ -596,8 +596,8 @@ export function newProject(format) {
|
||||
export function selectNoProject() {
|
||||
setStartScreen(true);
|
||||
|
||||
Project = 0;
|
||||
Undo = null;
|
||||
Blockbench.Project = 0;
|
||||
Blockbench.Undo = null;
|
||||
|
||||
// Setup Data
|
||||
OutlinerNode.uuids = {};
|
||||
@ -738,7 +738,7 @@ onVueSetup(() => {
|
||||
if (Project) {
|
||||
Project.unselect()
|
||||
}
|
||||
Project = 0;
|
||||
Blockbench.Project = 0;
|
||||
Interface.tab_bar.new_tab.selected = true;
|
||||
setProjectTitle(ModelProject.all.length ? tl('projects.new_tab') : null);
|
||||
updateInterface();
|
||||
|
@ -1,7 +1,17 @@
|
||||
BARS.defineActions(function() {
|
||||
import { Blockbench } from "../api";
|
||||
import { Dialog } from "../interface/dialog";
|
||||
import { settings } from "../interface/settings";
|
||||
import { BARS } from "../interface/toolbars";
|
||||
import { tl } from "../languages";
|
||||
import { Mesh } from "../outliner/mesh";
|
||||
import { Outliner } from "../outliner/outliner";
|
||||
import { ReferenceImage } from "../preview/reference_images";
|
||||
import { capitalizeFirstLetter } from "../util/util";
|
||||
import { Codecs } from "./codec";
|
||||
|
||||
BARS.defineActions(function() {
|
||||
function uploadSketchfabModel() {
|
||||
if (elements.length === 0 || !Format) {
|
||||
if (Outliner.elements.length === 0 || !Format) {
|
||||
return;
|
||||
}
|
||||
let tag_suggestions = ['low-poly', 'pixel-art', 'NoAI'];
|
||||
@ -34,8 +44,7 @@ BARS.defineActions(function() {
|
||||
"weapons-military": "Weapons & Military",
|
||||
}
|
||||
|
||||
var dialog = new Dialog({
|
||||
id: 'sketchfab_uploader',
|
||||
var dialog = new Dialog('sketchfab_uploader', {
|
||||
title: 'dialog.sketchfab_uploader.title',
|
||||
width: 640,
|
||||
form: {
|
||||
@ -60,31 +69,31 @@ BARS.defineActions(function() {
|
||||
private: {label: 'dialog.sketchfab_uploader.private', type: 'checkbox'},
|
||||
password: {label: 'dialog.sketchfab_uploader.password'},
|
||||
},
|
||||
onConfirm: function(formResult) {
|
||||
onConfirm(formResult) {
|
||||
|
||||
if (!formResult.token || !formResult.name) {
|
||||
Blockbench.showQuickMessage('message.sketchfab.name_or_token', 1800)
|
||||
return;
|
||||
}
|
||||
if (!formResult.tags.split(' ').includes('blockbench')) {
|
||||
if (!(formResult.tags as string).split(' ').includes('blockbench')) {
|
||||
formResult.tags += ' blockbench';
|
||||
}
|
||||
var data = new FormData()
|
||||
data.append('token', formResult.token)
|
||||
data.append('name', formResult.name)
|
||||
data.append('description', formResult.description)
|
||||
data.append('tags', formResult.tags)
|
||||
data.append('isPublished', !formResult.draft)
|
||||
data.append('token', formResult.token as string)
|
||||
data.append('name', formResult.name as string)
|
||||
data.append('description', formResult.description as string)
|
||||
data.append('tags', formResult.tags as string)
|
||||
data.append('isPublished', (!formResult.draft as boolean).toString())
|
||||
//data.append('background', JSON.stringify({color: '#00ff00'}))
|
||||
data.append('private', formResult.private)
|
||||
data.append('password', formResult.password)
|
||||
data.append('private', (formResult.private as boolean).toString())
|
||||
data.append('password', formResult.password as string)
|
||||
data.append('source', 'blockbench')
|
||||
|
||||
if (formResult.category1 || formResult.category2) {
|
||||
let selected_categories = [];
|
||||
if (formResult.category1) selected_categories.push(formResult.category1);
|
||||
if (formResult.category2) selected_categories.push(formResult.category2);
|
||||
data.append('categories', selected_categories);
|
||||
let selected_categories: string[] = [];
|
||||
if (formResult.category1) selected_categories.push(formResult.category1 as string);
|
||||
if (formResult.category2) selected_categories.push(formResult.category2 as string);
|
||||
data.append('categories', selected_categories.join(' '));
|
||||
}
|
||||
|
||||
settings.sketchfab_token.set(formResult.token);
|
||||
@ -151,10 +160,11 @@ BARS.defineActions(function() {
|
||||
condition: () => Project && Outliner.elements.length,
|
||||
async click() {
|
||||
let thumbnail = await new Promise(resolve => {
|
||||
// @ts-ignore
|
||||
Preview.selected.screenshot({width: 640, height: 480}, resolve);
|
||||
});
|
||||
let image = new Image();
|
||||
image.src = thumbnail;
|
||||
image.src = thumbnail as string;
|
||||
image.width = 320;
|
||||
image.style.display = 'block';
|
||||
image.style.margin = 'auto';
|
||||
@ -192,7 +202,7 @@ BARS.defineActions(function() {
|
||||
absolute_paths: false,
|
||||
reference_images: formResult.reference_images
|
||||
});
|
||||
let data = {name, expire_time, model}
|
||||
let data = {name, expire_time, model, thumbnail: undefined};
|
||||
if (formResult.thumbnail) data.thumbnail = thumbnail;
|
||||
|
||||
$.ajax({
|
@ -37,7 +37,7 @@ export const data = {
|
||||
zh_tw: zh_tw,
|
||||
};
|
||||
|
||||
window.tl = function(string, variables, default_value) {
|
||||
export const tl = function(string, variables, default_value) {
|
||||
if (string && string.length > 100) return string;
|
||||
var result = Language.data[string]
|
||||
if (result && result.length > 0) {
|
||||
@ -58,14 +58,14 @@ window.tl = function(string, variables, default_value) {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
window.translateUI = function() {
|
||||
export const translateUI = function() {
|
||||
$('.tl').each(function(i, obj) {
|
||||
var text = tl($(obj).text())
|
||||
$(obj).text(text)
|
||||
})
|
||||
}
|
||||
|
||||
window.Language = {
|
||||
export const Language = {
|
||||
data: {},
|
||||
code: 'en',
|
||||
options: {
|
||||
@ -114,3 +114,8 @@ if (code && Language.options[code]) {
|
||||
|
||||
|
||||
Language.data = data[Language.code];
|
||||
|
||||
Object.assign(window, {
|
||||
tl,
|
||||
Language
|
||||
})
|
||||
|
@ -394,7 +394,7 @@ export const Vertexsnap = {
|
||||
var local_offset = new THREE.Vector3().copy(global_delta).applyQuaternion(q)
|
||||
ignoreVectorAxes(local_offset);
|
||||
|
||||
for (i=0; i<3; i++) {
|
||||
for (let i=0; i<3; i++) {
|
||||
if (m[i] === 1) {
|
||||
obj.to[i] = obj.to[i] + local_offset.getComponent(i);
|
||||
} else {
|
||||
|
@ -114,6 +114,7 @@ export class Mode extends KeybindItem {
|
||||
}
|
||||
delete Modes.options[this.id];
|
||||
}
|
||||
static selected = null;
|
||||
}
|
||||
export const Modes = {
|
||||
get id() {
|
||||
|
1
js/types.d.ts
vendored
Normal file
1
js/types.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="blockbench-types" />
|
@ -482,8 +482,8 @@ export function pathToExtension(path) {
|
||||
}
|
||||
Object.defineProperty(String.prototype, 'hashCode', {
|
||||
value() {
|
||||
var hash = 0, i, chr;
|
||||
for (i = 0; i < this.length; i++) {
|
||||
var hash = 0, chr;
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
chr = this.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
|
11
lib/libs.js
11
lib/libs.js
@ -10,6 +10,17 @@ import GIF from 'gif.js'
|
||||
const THREE = Object.assign({}, threejs);
|
||||
//Vue.use(Sortable);
|
||||
|
||||
export {
|
||||
GIFEnc,
|
||||
GIF,
|
||||
THREE,
|
||||
$,
|
||||
$ as jQuery,
|
||||
FIK,
|
||||
Vue,
|
||||
JSZip,
|
||||
Prism
|
||||
}
|
||||
Object.assign(window, {
|
||||
GIFEnc,
|
||||
GIF,
|
||||
|
107
package-lock.json
generated
107
package-lock.json
generated
@ -10,6 +10,7 @@
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.1.2",
|
||||
"blockbench-types": "^4.12.1",
|
||||
"electron-color-picker": "^0.2.0",
|
||||
"electron-updater": "^6.3.4",
|
||||
"file-saver": "^2.0.5",
|
||||
@ -2809,6 +2810,15 @@
|
||||
"@types/ms": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/dompurify": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.5.tgz",
|
||||
"integrity": "sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/trusted-types": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/fs-extra": {
|
||||
"version": "9.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz",
|
||||
@ -2824,6 +2834,15 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz",
|
||||
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA=="
|
||||
},
|
||||
"node_modules/@types/jquery": {
|
||||
"version": "3.5.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.32.tgz",
|
||||
"integrity": "sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/sizzle": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/keyv": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz",
|
||||
@ -2860,6 +2879,12 @@
|
||||
"xmlbuilder": ">=11.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/prismjs": {
|
||||
"version": "1.26.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz",
|
||||
"integrity": "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
|
||||
@ -2877,11 +2902,28 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/sizzle": {
|
||||
"version": "2.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.9.tgz",
|
||||
"integrity": "sha512-xzLEyKB50yqCUPUJkIsrVvoWNfFUbIZI+RspLWt8u+tIW/BetMBZtgV2LY/2o+tYH8dRvQ+eoPf3NdhQCcLE2w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/three": {
|
||||
"version": "0.129.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.129.2.tgz",
|
||||
"integrity": "sha512-fZDNRtUFnq3baNjDiAzi4QoHYcczWtEdsduH/tpiwk91fbVk8COJiT/iLoN3tIOjLKMySoYsjUfP0VTmUfZKLw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/tinycolor2": {
|
||||
"version": "1.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz",
|
||||
"integrity": "sha512-iEN8J0BoMnsWBqjVbWH/c0G0Hh7O21lpR2/+PrvAVgWdzL7eexIFm4JN/Wn10PTcmNdtS6U67r499mlWMXOxNw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/verror": {
|
||||
@ -3395,6 +3437,60 @@
|
||||
"readable-stream": "^3.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blockbench-types": {
|
||||
"version": "4.12.1",
|
||||
"resolved": "https://registry.npmjs.org/blockbench-types/-/blockbench-types-4.12.1.tgz",
|
||||
"integrity": "sha512-y4EoqvQWAQ8FeqjU/xqyFJDuxZz5133ESuSfq+L0Rv8Hy6ijzdxxFG4BSUBLvFWWhm9nh4s9CNAaMmnom3kO8Q==",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.20.7",
|
||||
"@types/dompurify": "^3.0.5",
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@types/three": "^0.129.2",
|
||||
"@types/tinycolor2": "^1.4.6",
|
||||
"dompurify": "^3.0.1",
|
||||
"electron": "^33.3.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"tinycolor2": "^1.6.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vue": "2.7.14",
|
||||
"wintersky": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blockbench-types/node_modules/@vue/compiler-sfc": {
|
||||
"version": "2.7.14",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz",
|
||||
"integrity": "sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.18.4",
|
||||
"postcss": "^8.4.14",
|
||||
"source-map": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/blockbench-types/node_modules/typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blockbench-types/node_modules/vue": {
|
||||
"version": "2.7.14",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz",
|
||||
"integrity": "sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==",
|
||||
"deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-sfc": "2.7.14",
|
||||
"csstype": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bluebird": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||
@ -4296,6 +4392,15 @@
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.4.tgz",
|
||||
"integrity": "sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-9.0.2.tgz",
|
||||
|
@ -143,6 +143,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.1.2",
|
||||
"blockbench-types": "^4.12.1",
|
||||
"electron-color-picker": "^0.2.0",
|
||||
"electron-updater": "^6.3.4",
|
||||
"file-saver": "^2.0.5",
|
||||
|
Loading…
x
Reference in New Issue
Block a user