mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-12 17:41:57 +08:00
Fix code indentation
This commit is contained in:
parent
69f6b50da1
commit
0412341ad1
@ -372,7 +372,7 @@ class Animation {
|
||||
Blockbench.showMessageBox({
|
||||
translateKey: 'delete_animation',
|
||||
icon: 'movie',
|
||||
buttons: ['generic.delete', 'dialog.cancel'],
|
||||
buttons: ['generic.delete', 'dialog.cancel'],
|
||||
confirm: 0,
|
||||
cancel: 1,
|
||||
}, (result) => {
|
||||
|
@ -289,7 +289,7 @@ const Timeline = {
|
||||
times.push('00')
|
||||
}
|
||||
var node = $('#timeline_corner').get(0).childNodes[0]
|
||||
var selection = window.getSelection();
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
|
||||
var sel = [0, node.length]
|
||||
@ -735,9 +735,9 @@ BARS.defineActions(function() {
|
||||
if (!Animation.selected) return;
|
||||
for (var uuid in Animation.selected.animators) {
|
||||
var ba = Animation.selected.animators[uuid]
|
||||
if (ba && ba.keyframes.length) {
|
||||
ba.addToTimeline();
|
||||
}
|
||||
if (ba && ba.keyframes.length) {
|
||||
ba.addToTimeline();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -748,7 +748,7 @@ BARS.defineActions(function() {
|
||||
condition: {modes: ['animate']},
|
||||
click: function () {
|
||||
for (var animator of Timeline.animators) {
|
||||
animator.expanded = false;
|
||||
animator.expanded = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -477,5 +477,3 @@ function closeBlockbenchWindow() {
|
||||
}
|
||||
})
|
||||
})()
|
||||
|
||||
|
||||
|
@ -2063,4 +2063,4 @@ Interface.definePanels(function() {
|
||||
DisplayMode.vue = Interface.Panels.display.inside_vue;
|
||||
})
|
||||
|
||||
})()
|
||||
})()
|
||||
|
@ -460,5 +460,5 @@ Interface.definePanels(function() {
|
||||
}
|
||||
})
|
||||
BarItems.toggle_chat.toElement('#chat_title_bar')
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -279,7 +279,7 @@ Object.assign(Blockbench, {
|
||||
if (options.savetype === 'zip') {
|
||||
var fileReader = new FileReader();
|
||||
fileReader.onload = function(event) {
|
||||
var buffer = Buffer.from(new Uint8Array(this.result));
|
||||
var buffer = Buffer.from(new Uint8Array(this.result));
|
||||
fs.writeFileSync(file_path, buffer)
|
||||
if (cb) {
|
||||
cb(file_path)
|
||||
|
@ -424,21 +424,21 @@ $(document).on('keydown mousedown', function(e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Blockbench.hasFlag('renaming')) {
|
||||
if (Keybinds.extra.confirm.keybind.isTriggered(e)) {
|
||||
stopRenameOutliner()
|
||||
} else if (Keybinds.extra.cancel.keybind.isTriggered(e)) {
|
||||
stopRenameOutliner(false)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ($('input#chat_input:focus').length && EditSession.active) {
|
||||
if (Keybinds.extra.confirm.keybind.isTriggered(e)) {
|
||||
Chat.send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($('pre.prism-editor__code:focus').length) return;
|
||||
if (Blockbench.hasFlag('renaming')) {
|
||||
if (Keybinds.extra.confirm.keybind.isTriggered(e)) {
|
||||
stopRenameOutliner()
|
||||
} else if (Keybinds.extra.cancel.keybind.isTriggered(e)) {
|
||||
stopRenameOutliner(false)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ($('input#chat_input:focus').length && EditSession.active) {
|
||||
if (Keybinds.extra.confirm.keybind.isTriggered(e)) {
|
||||
Chat.send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($('pre.prism-editor__code:focus').length) return;
|
||||
if (Keybinds.extra.confirm.keybind.isTriggered(e) || Keybinds.extra.cancel.keybind.isTriggered(e)) {
|
||||
$(document).click()
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ class Panel {
|
||||
this.onResize = data.onResize;
|
||||
if (data.toolbars) {
|
||||
this.toolbars = data.toolbars;
|
||||
} else {
|
||||
} else {
|
||||
this.toolbars = {};
|
||||
}
|
||||
// Vue
|
||||
if (data.component) {
|
||||
// Vue
|
||||
if (data.component) {
|
||||
data.component.name = 'inside-vue'
|
||||
let bar = $(`.sidebar#${data.default_side||'left'}_bar`);
|
||||
let node = $(`<div id="mount-panel-${this.id}"></div>`);
|
||||
@ -29,13 +29,13 @@ class Panel {
|
||||
bar.append(node)
|
||||
}
|
||||
|
||||
this.vue = new Vue({
|
||||
components: {
|
||||
'inside-vue': data.component
|
||||
},
|
||||
this.vue = new Vue({
|
||||
components: {
|
||||
'inside-vue': data.component
|
||||
},
|
||||
template: `<div class="panel ${this.selection_only ? 'selection_only' : ''} ${this.growable ? 'grow' : ''}" id="${this.id}">
|
||||
<h3 class="panel_handle">${this.name}</h3>
|
||||
<inside-vue class="panel_inside" ref="inside"></inside-vue>
|
||||
<inside-vue class="panel_inside" ref="inside"></inside-vue>
|
||||
</div>`,
|
||||
mounted() {
|
||||
Vue.nextTick(() => {
|
||||
@ -49,7 +49,7 @@ class Panel {
|
||||
this.node = $('.panel#'+this.id).get(0)
|
||||
this.handle = $(this.node).find('h3.panel_handle').get(0)
|
||||
|
||||
} else {
|
||||
} else {
|
||||
this.node = $('.panel#'+this.id).get(0)
|
||||
this.handle = $('<h3 class="panel_handle">'+this.name+'</h3>').get(0)
|
||||
$(this.node).prepend(this.handle)
|
||||
@ -187,7 +187,7 @@ class Panel {
|
||||
}
|
||||
delete() {
|
||||
delete Interface.Panels[this.id];
|
||||
$(this.node).detach()
|
||||
$(this.node).detach()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ const Settings = {
|
||||
new Setting('display_skin', {category: 'preview', value: false, type: 'click', condition: isApp, icon: 'icon-player', click: function() { changeDisplaySkin() }});
|
||||
|
||||
//Edit
|
||||
new Setting('undo_limit', {category: 'edit', value: 256, type: 'number'});
|
||||
new Setting('undo_limit', {category: 'edit', value: 256, type: 'number'});
|
||||
new Setting('canvas_unselect', {category: 'edit', value: false});
|
||||
new Setting('highlight_cubes', {category: 'edit', value: true, onChange() {
|
||||
updateCubeHighlights();
|
||||
|
@ -37,7 +37,7 @@ const CustomTheme = {
|
||||
el: '#theme_editor',
|
||||
data: CustomTheme.data,
|
||||
components: {
|
||||
VuePrismEditor
|
||||
VuePrismEditor
|
||||
},
|
||||
watch: {
|
||||
main_font() {
|
||||
|
@ -549,8 +549,8 @@ const Canvas = {
|
||||
}
|
||||
|
||||
vUv = uv;
|
||||
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
}`
|
||||
var fragShader = `
|
||||
#ifdef GL_ES
|
||||
@ -569,9 +569,9 @@ const Canvas = {
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 Ca = texture2D(t0, vUv);
|
||||
vec4 Cb = texture2D(t1, vUv);
|
||||
vec4 Cc = texture2D(t2, vUv);
|
||||
vec4 Ca = texture2D(t0, vUv);
|
||||
vec4 Cb = texture2D(t1, vUv);
|
||||
vec4 Cc = texture2D(t2, vUv);
|
||||
|
||||
vec3 ctemp = Ca.rgb * Ca.a + Cb.rgb * Cb.a * (1.0 - Ca.a);
|
||||
vec4 ctemp4 = vec4(ctemp, Ca.a + (1.0 - Ca.a) * Cb.a);
|
||||
|
@ -453,7 +453,7 @@ class Preview {
|
||||
Math.degToRad(preset.rotation[2]),
|
||||
'ZYX'
|
||||
));
|
||||
this.controls.target.add(this.camera.position);
|
||||
this.controls.target.add(this.camera.position);
|
||||
}
|
||||
if (preset.projection !== 'unset') {
|
||||
this.setProjectionMode(preset.projection == 'orthographic')
|
||||
|
196
js/property.js
196
js/property.js
@ -1,107 +1,107 @@
|
||||
class Property {
|
||||
constructor(target_class, type = 'boolean', name, options = 0) {
|
||||
if (!target_class.properties) {
|
||||
target_class.properties = {};
|
||||
}
|
||||
target_class.properties[name] = this;
|
||||
constructor(target_class, type = 'boolean', name, options = 0) {
|
||||
if (!target_class.properties) {
|
||||
target_class.properties = {};
|
||||
}
|
||||
target_class.properties[name] = this;
|
||||
|
||||
let scope = this;
|
||||
let scope = this;
|
||||
|
||||
this.class = target_class;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.class = target_class;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
|
||||
if (options.default) {
|
||||
this.default = options.default;
|
||||
} else {
|
||||
switch (this.type) {
|
||||
case 'string': this.default = ''; break;
|
||||
case 'molang': this.default = '0'; break;
|
||||
case 'number': this.default = 0; break;
|
||||
case 'boolean': this.default = false; break;
|
||||
case 'array': this.default = []; break;
|
||||
case 'vector': this.default = [0, 0, 0]; break;
|
||||
case 'vector2': this.default = [0, 0]; break;
|
||||
}
|
||||
}
|
||||
switch (this.type) {
|
||||
case 'string': this.isString = true; break;
|
||||
case 'molang': this.isMolang = true; break;
|
||||
case 'number': this.isNumber = true; break;
|
||||
case 'boolean': this.isBoolean = true; break;
|
||||
case 'array': this.isArray = true; break;
|
||||
case 'vector': this.isVector = true; break;
|
||||
case 'vector2': this.isVector2 = true; break;
|
||||
}
|
||||
if (options.default) {
|
||||
this.default = options.default;
|
||||
} else {
|
||||
switch (this.type) {
|
||||
case 'string': this.default = ''; break;
|
||||
case 'molang': this.default = '0'; break;
|
||||
case 'number': this.default = 0; break;
|
||||
case 'boolean': this.default = false; break;
|
||||
case 'array': this.default = []; break;
|
||||
case 'vector': this.default = [0, 0, 0]; break;
|
||||
case 'vector2': this.default = [0, 0]; break;
|
||||
}
|
||||
}
|
||||
switch (this.type) {
|
||||
case 'string': this.isString = true; break;
|
||||
case 'molang': this.isMolang = true; break;
|
||||
case 'number': this.isNumber = true; break;
|
||||
case 'boolean': this.isBoolean = true; break;
|
||||
case 'array': this.isArray = true; break;
|
||||
case 'vector': this.isVector = true; break;
|
||||
case 'vector2': this.isVector2 = true; break;
|
||||
}
|
||||
|
||||
if (this.isMolang) {
|
||||
Object.defineProperty(target_class.prototype, `${name}_string`, {
|
||||
get() {
|
||||
return typeof this[name] == 'number' ? trimFloatNumber(this[name]) || scope.default : this[name];
|
||||
},
|
||||
set(val) {
|
||||
this[name] = val;
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.isMolang) {
|
||||
Object.defineProperty(target_class.prototype, `${name}_string`, {
|
||||
get() {
|
||||
return typeof this[name] == 'number' ? trimFloatNumber(this[name]) || scope.default : this[name];
|
||||
},
|
||||
set(val) {
|
||||
this[name] = val;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof options.merge == 'function') this.merge = options.merge;
|
||||
if (typeof options.reset == 'function') this.reset = options.reset;
|
||||
if (typeof options.merge_validation == 'function') this.merge_validation = options.merge_validation;
|
||||
if (options.condition) this.condition = options.condition;
|
||||
if (options.exposed == false) this.exposed = false;
|
||||
if (options.label) this.label = options.label;
|
||||
if (options.options) this.options = options.options;
|
||||
}
|
||||
merge(instance, data) {
|
||||
if (data[this.name] == undefined || !Condition(this.condition, instance)) return;
|
||||
if (typeof options.merge == 'function') this.merge = options.merge;
|
||||
if (typeof options.reset == 'function') this.reset = options.reset;
|
||||
if (typeof options.merge_validation == 'function') this.merge_validation = options.merge_validation;
|
||||
if (options.condition) this.condition = options.condition;
|
||||
if (options.exposed == false) this.exposed = false;
|
||||
if (options.label) this.label = options.label;
|
||||
if (options.options) this.options = options.options;
|
||||
}
|
||||
merge(instance, data) {
|
||||
if (data[this.name] == undefined || !Condition(this.condition, instance)) return;
|
||||
|
||||
if (this.isString) {
|
||||
Merge.string(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isNumber) {
|
||||
Merge.number(instance, data, this.name)
|
||||
}
|
||||
else if (this.isMolang) {
|
||||
Merge.molang(instance, data, this.name)
|
||||
}
|
||||
else if (this.isBoolean) {
|
||||
Merge.boolean(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (data[this.name] instanceof Array) {
|
||||
if (instance[this.name] instanceof Array == false) {
|
||||
instance[this.name] = [];
|
||||
}
|
||||
instance[this.name].replace(data[this.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
copy(instance, target) {
|
||||
if (!Condition(this.condition, instance)) return;
|
||||
if (this.isString) {
|
||||
Merge.string(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isNumber) {
|
||||
Merge.number(instance, data, this.name)
|
||||
}
|
||||
else if (this.isMolang) {
|
||||
Merge.molang(instance, data, this.name)
|
||||
}
|
||||
else if (this.isBoolean) {
|
||||
Merge.boolean(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (data[this.name] instanceof Array) {
|
||||
if (instance[this.name] instanceof Array == false) {
|
||||
instance[this.name] = [];
|
||||
}
|
||||
instance[this.name].replace(data[this.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
copy(instance, target) {
|
||||
if (!Condition(this.condition, instance)) return;
|
||||
|
||||
if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (instance[this.name] instanceof Array) {
|
||||
target[this.name] = instance[this.name].slice();
|
||||
}
|
||||
} else {
|
||||
target[this.name] = instance[this.name];
|
||||
}
|
||||
}
|
||||
reset(instance) {
|
||||
if (instance[this.name] == undefined && !Condition(this.condition, instance)) return;
|
||||
if (typeof this.default == 'function') {
|
||||
var dft = this.default(instance);
|
||||
} else {
|
||||
var dft = this.default;
|
||||
}
|
||||
if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (instance[this.name] instanceof Array == false) {
|
||||
instance[this.name] = [];
|
||||
}
|
||||
instance[this.name].replace(dft);
|
||||
} else {
|
||||
instance[this.name] = dft;
|
||||
}
|
||||
}
|
||||
if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (instance[this.name] instanceof Array) {
|
||||
target[this.name] = instance[this.name].slice();
|
||||
}
|
||||
} else {
|
||||
target[this.name] = instance[this.name];
|
||||
}
|
||||
}
|
||||
reset(instance) {
|
||||
if (instance[this.name] == undefined && !Condition(this.condition, instance)) return;
|
||||
if (typeof this.default == 'function') {
|
||||
var dft = this.default(instance);
|
||||
} else {
|
||||
var dft = this.default;
|
||||
}
|
||||
if (this.isArray || this.isVector || this.isVector2) {
|
||||
if (instance[this.name] instanceof Array == false) {
|
||||
instance[this.name] = [];
|
||||
}
|
||||
instance[this.name].replace(dft);
|
||||
} else {
|
||||
instance[this.name] = dft;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,94 +230,94 @@ Interface.definePanels(() => {
|
||||
|
||||
if (extension === 'ase') {
|
||||
let colorContents = file.content;
|
||||
let colorBuffer = Buffer.from(colorContents);
|
||||
let signature = colorBuffer.toString('utf-8', 0, 4);
|
||||
let versionMajor = colorBuffer.slice(4, 6).readInt16BE(0);
|
||||
let versionMin = colorBuffer.slice(6, 8).readInt16BE(0);
|
||||
let count = colorBuffer.slice(8, 12).readInt32BE(0);
|
||||
let colorBuffer = Buffer.from(colorContents);
|
||||
let signature = colorBuffer.toString('utf-8', 0, 4);
|
||||
let versionMajor = colorBuffer.slice(4, 6).readInt16BE(0);
|
||||
let versionMin = colorBuffer.slice(6, 8).readInt16BE(0);
|
||||
let count = colorBuffer.slice(8, 12).readInt32BE(0);
|
||||
|
||||
if (colorBuffer.length > 12 && signature !== 'ASEF' && versionMajor !== 1 && versionMin !== 0) {
|
||||
console.log('Invalid ASE swatch file');
|
||||
return;
|
||||
}
|
||||
if (colorBuffer.length > 12 && signature !== 'ASEF' && versionMajor !== 1 && versionMin !== 0) {
|
||||
console.log('Invalid ASE swatch file');
|
||||
return;
|
||||
}
|
||||
|
||||
let i = 12;
|
||||
while (i < colorBuffer.length) {
|
||||
let i = 12;
|
||||
while (i < colorBuffer.length) {
|
||||
|
||||
let blockLength;
|
||||
let blockType = colorBuffer.slice(i, i + 2).readInt16BE(0).toString(16);
|
||||
i += 2;
|
||||
let blockLength;
|
||||
let blockType = colorBuffer.slice(i, i + 2).readInt16BE(0).toString(16);
|
||||
i += 2;
|
||||
|
||||
// Ignore group start c001, end c002
|
||||
if (blockType === 'c001') {
|
||||
blockLength = colorBuffer.slice(i, i + 4).readInt32BE(0);
|
||||
i += blockLength;
|
||||
}
|
||||
if (blockType === 'c002') {
|
||||
i += 2;
|
||||
}
|
||||
// Ignore group start c001, end c002
|
||||
if (blockType === 'c001') {
|
||||
blockLength = colorBuffer.slice(i, i + 4).readInt32BE(0);
|
||||
i += blockLength;
|
||||
}
|
||||
if (blockType === 'c002') {
|
||||
i += 2;
|
||||
}
|
||||
|
||||
// Color entry, start 0001
|
||||
if (blockType === '1') {
|
||||
blockLength = colorBuffer.slice(i, i + 4).readInt32BE(0);
|
||||
let nameLength = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let colorName = '';
|
||||
let color;
|
||||
for (let j = 0; j < nameLength * 2 - 2; j += 2) {
|
||||
colorName += String.fromCodePoint(colorBuffer.slice(i + 6 + j, i + 8 + j).readInt16BE(0));
|
||||
}
|
||||
let _i = i + 6 + nameLength * 2;
|
||||
let colorModel = colorBuffer.slice(_i, _i + 4).toString('utf-8', 0, 4);
|
||||
_i += 4;
|
||||
if (colorModel === 'RGB ') {
|
||||
let r = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let g = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let b = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
// Color entry, start 0001
|
||||
if (blockType === '1') {
|
||||
blockLength = colorBuffer.slice(i, i + 4).readInt32BE(0);
|
||||
let nameLength = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let colorName = '';
|
||||
let color;
|
||||
for (let j = 0; j < nameLength * 2 - 2; j += 2) {
|
||||
colorName += String.fromCodePoint(colorBuffer.slice(i + 6 + j, i + 8 + j).readInt16BE(0));
|
||||
}
|
||||
let _i = i + 6 + nameLength * 2;
|
||||
let colorModel = colorBuffer.slice(_i, _i + 4).toString('utf-8', 0, 4);
|
||||
_i += 4;
|
||||
if (colorModel === 'RGB ') {
|
||||
let r = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let g = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let b = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
|
||||
color = new tinycolor({r: r*255, g: g*255, b: b*255})
|
||||
//nscolor = color.colorWithRGBA(r * 255, g * 255, b * 255, 1.0);
|
||||
} else if (colorModel === 'CMYK') {
|
||||
let c = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let m = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let y = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let k = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
//nscolor = color.colorWithCMYKA(c * 100, m * 100, y * 100, k * 100, 1.0);
|
||||
color = new tinycolor({
|
||||
color = new tinycolor({r: r*255, g: g*255, b: b*255})
|
||||
//nscolor = color.colorWithRGBA(r * 255, g * 255, b * 255, 1.0);
|
||||
} else if (colorModel === 'CMYK') {
|
||||
let c = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let m = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let y = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let k = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
//nscolor = color.colorWithCMYKA(c * 100, m * 100, y * 100, k * 100, 1.0);
|
||||
color = new tinycolor({
|
||||
r: 255 * (1 - c) * (1 - k),
|
||||
g: 255 * (1 - m) * (1 - k),
|
||||
b: 255 * (1 - y) * (1 - k)
|
||||
})
|
||||
})
|
||||
|
||||
} else if (colorModel === 'LAB ') {
|
||||
let l = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let a = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let b = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
//nscolor = color.colorWithLABA(l * 100, a * 100, b * 100, 1.0);
|
||||
} else if (colorModel === 'Gray') {
|
||||
let g = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
color = new tinycolor({r: g*255, g: g*255, b: g*255})
|
||||
}
|
||||
} else if (colorModel === 'LAB ') {
|
||||
let l = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let a = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
_i += 4;
|
||||
let b = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
//nscolor = color.colorWithLABA(l * 100, a * 100, b * 100, 1.0);
|
||||
} else if (colorModel === 'Gray') {
|
||||
let g = colorBuffer.slice(_i, _i + 4).readFloatBE(0);
|
||||
color = new tinycolor({r: g*255, g: g*255, b: g*255})
|
||||
}
|
||||
|
||||
colors.push(color.toHexString());
|
||||
colors.push(color.toHexString());
|
||||
|
||||
i += blockLength;
|
||||
}
|
||||
}
|
||||
i += blockLength;
|
||||
}
|
||||
}
|
||||
} else if (extension === 'aco') {
|
||||
|
||||
let colorContents = file.content;
|
||||
let colorBuffer = Buffer.from(colorContents);
|
||||
|
||||
if (colorBuffer.length < 4) {
|
||||
UI.message('Invalid ACO file');
|
||||
return;
|
||||
UI.message('Invalid ACO file');
|
||||
return;
|
||||
}
|
||||
|
||||
let version = colorBuffer.slice(0, 2).readUInt16BE(0);
|
||||
@ -326,71 +326,71 @@ Interface.definePanels(() => {
|
||||
// version 1
|
||||
let i;
|
||||
if (version === 1 && (colorBuffer.length - 4) / 10 === count) {
|
||||
i = 4;
|
||||
while (i < colorBuffer.length) {
|
||||
let colorSpace = colorBuffer.slice(i, i + 2).readUInt16BE(0);
|
||||
let r = colorBuffer.slice(i + 2, i + 4).readUInt16BE(0);
|
||||
let g = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let b = colorBuffer.slice(i + 6, i + 8).readUInt16BE(0);
|
||||
let z = colorBuffer.slice(i + 8, i + 10).readUInt16BE(0);
|
||||
i = 4;
|
||||
while (i < colorBuffer.length) {
|
||||
let colorSpace = colorBuffer.slice(i, i + 2).readUInt16BE(0);
|
||||
let r = colorBuffer.slice(i + 2, i + 4).readUInt16BE(0);
|
||||
let g = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let b = colorBuffer.slice(i + 6, i + 8).readUInt16BE(0);
|
||||
let z = colorBuffer.slice(i + 8, i + 10).readUInt16BE(0);
|
||||
|
||||
if (colorSpace === 0) {
|
||||
let color = new tinycolor({
|
||||
r: Math.floor(r/255),
|
||||
g: Math.floor(g/255),
|
||||
b: Math.floor(b/255)
|
||||
})
|
||||
colors.push(color.toHexString());
|
||||
}
|
||||
i += 10;
|
||||
}
|
||||
if (colorSpace === 0) {
|
||||
let color = new tinycolor({
|
||||
r: Math.floor(r/255),
|
||||
g: Math.floor(g/255),
|
||||
b: Math.floor(b/255)
|
||||
})
|
||||
colors.push(color.toHexString());
|
||||
}
|
||||
i += 10;
|
||||
}
|
||||
}
|
||||
// version 2
|
||||
if (
|
||||
(version === 2) ||
|
||||
(
|
||||
version === 1 &&
|
||||
colorBuffer.length > count * 10 + 8 &&
|
||||
colorBuffer.slice(4 + count * 10, 6 + count * 10).readUInt16BE(0) === 2 &&
|
||||
colorBuffer.slice(6 + count * 10, 8 + count * 10).readUInt16BE(0) === count
|
||||
)
|
||||
(version === 2) ||
|
||||
(
|
||||
version === 1 &&
|
||||
colorBuffer.length > count * 10 + 8 &&
|
||||
colorBuffer.slice(4 + count * 10, 6 + count * 10).readUInt16BE(0) === 2 &&
|
||||
colorBuffer.slice(6 + count * 10, 8 + count * 10).readUInt16BE(0) === count
|
||||
)
|
||||
) {
|
||||
i = 4 + count * 10 + 4;
|
||||
if (version === 2) {
|
||||
i = 4;
|
||||
}
|
||||
while (i < colorBuffer.length) {
|
||||
let colorSpace = colorBuffer.slice(i, i + 2).readUInt16BE(0);
|
||||
let r = colorBuffer.slice(i + 2, i + 4).readUInt16BE(0);
|
||||
let g = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let b = colorBuffer.slice(i + 6, i + 8).readUInt16BE(0);
|
||||
let z = colorBuffer.slice(i + 8, i + 10).readUInt16BE(0);
|
||||
let colorName = '';
|
||||
let nameLength = colorBuffer.slice(i + 12, i + 14).readUInt16BE(0);
|
||||
/*for (let j = 0; j < nameLength * 2 - 2; j += 2) {
|
||||
colorName += String.fromCodePoint(colorBuffer.slice(i + 14 + j, i + 16 + j).readUInt16BE(0));
|
||||
}*/
|
||||
// colorspace: [0: RGB, 1: HSB (hsv), 2: CMYK, 7: Lab, 8: Gray]
|
||||
if (colorSpace === 0) {
|
||||
let color = new tinycolor({
|
||||
r: Math.floor(r/255),
|
||||
g: Math.floor(g/255),
|
||||
b: Math.floor(b/255)
|
||||
})
|
||||
colors.push(color.toHexString());
|
||||
}
|
||||
i += 14 + nameLength * 2;
|
||||
}
|
||||
i = 4 + count * 10 + 4;
|
||||
if (version === 2) {
|
||||
i = 4;
|
||||
}
|
||||
while (i < colorBuffer.length) {
|
||||
let colorSpace = colorBuffer.slice(i, i + 2).readUInt16BE(0);
|
||||
let r = colorBuffer.slice(i + 2, i + 4).readUInt16BE(0);
|
||||
let g = colorBuffer.slice(i + 4, i + 6).readUInt16BE(0);
|
||||
let b = colorBuffer.slice(i + 6, i + 8).readUInt16BE(0);
|
||||
let z = colorBuffer.slice(i + 8, i + 10).readUInt16BE(0);
|
||||
let colorName = '';
|
||||
let nameLength = colorBuffer.slice(i + 12, i + 14).readUInt16BE(0);
|
||||
/*for (let j = 0; j < nameLength * 2 - 2; j += 2) {
|
||||
colorName += String.fromCodePoint(colorBuffer.slice(i + 14 + j, i + 16 + j).readUInt16BE(0));
|
||||
}*/
|
||||
// colorspace: [0: RGB, 1: HSB (hsv), 2: CMYK, 7: Lab, 8: Gray]
|
||||
if (colorSpace === 0) {
|
||||
let color = new tinycolor({
|
||||
r: Math.floor(r/255),
|
||||
g: Math.floor(g/255),
|
||||
b: Math.floor(b/255)
|
||||
})
|
||||
colors.push(color.toHexString());
|
||||
}
|
||||
i += 14 + nameLength * 2;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (extension === 'act') {
|
||||
|
||||
let colorContents = file.content;
|
||||
let colorBuffer = Buffer.from(colorContents);
|
||||
let maxLength = Math.min(colorBuffer.length, 768);
|
||||
if (colorBuffer.length === 772) {
|
||||
maxLength = colorBuffer[769]*3
|
||||
}
|
||||
let colorBuffer = Buffer.from(colorContents);
|
||||
let maxLength = Math.min(colorBuffer.length, 768);
|
||||
if (colorBuffer.length === 772) {
|
||||
maxLength = colorBuffer[769]*3
|
||||
}
|
||||
|
||||
for (var i = 0; i < maxLength; i += 3) {
|
||||
let color = new tinycolor({
|
||||
|
@ -35,7 +35,7 @@ const TextureGenerator = {
|
||||
power: {label: 'dialog.create_texture.power', type: 'checkbox', value: true},
|
||||
double_use: {label: 'dialog.create_texture.double_use', type: 'checkbox', value: true, condition: Project.box_uv},
|
||||
box_uv: {label: 'dialog.project.box_uv', type: 'checkbox', value: false, condition: !Project.box_uv},
|
||||
padding: {label: 'dialog.create_texture.padding', type: 'checkbox', value: false},
|
||||
padding: {label: 'dialog.create_texture.padding', type: 'checkbox', value: false},
|
||||
color: {label: 'data.color', type: 'color', colorpicker: TextureGenerator.background_color},
|
||||
resolution: {label: 'dialog.create_texture.resolution', type: 'select', value: 16, options: {
|
||||
16: '16',
|
||||
|
@ -87,37 +87,37 @@ function moveCubesRelative(difference, index, event) { //Multiple
|
||||
var _has_groups = Format.bone_rig && Group.selected && Group.selected.matchesSelection() && Toolbox.selected.transformerMode == 'translate';
|
||||
|
||||
Undo.initEdit({elements: Cube.selected, outliner: _has_groups})
|
||||
var axes = []
|
||||
// < >
|
||||
// PageUpDown
|
||||
// ^ v
|
||||
var facing = quad_previews.current.getFacingDirection()
|
||||
var height = quad_previews.current.getFacingHeight()
|
||||
switch (facing) {
|
||||
case 'north': axes = [0, 2, 1]; break;
|
||||
case 'south': axes = [0, 2, 1]; break;
|
||||
case 'west': axes = [2, 0, 1]; break;
|
||||
case 'east': axes = [2, 0, 1]; break;
|
||||
}
|
||||
var axes = []
|
||||
// < >
|
||||
// PageUpDown
|
||||
// ^ v
|
||||
var facing = quad_previews.current.getFacingDirection()
|
||||
var height = quad_previews.current.getFacingHeight()
|
||||
switch (facing) {
|
||||
case 'north': axes = [0, 2, 1]; break;
|
||||
case 'south': axes = [0, 2, 1]; break;
|
||||
case 'west': axes = [2, 0, 1]; break;
|
||||
case 'east': axes = [2, 0, 1]; break;
|
||||
}
|
||||
|
||||
if (height !== 'middle') {
|
||||
if (index === 1) {
|
||||
index = 2
|
||||
} else if (index === 2) {
|
||||
index = 1
|
||||
}
|
||||
}
|
||||
if (facing === 'south' && (index === 0 || index === 1)) difference *= -1
|
||||
if (facing === 'west' && index === 0) difference *= -1
|
||||
if (facing === 'east' && index === 1) difference *= -1
|
||||
if (index === 2 && height !== 'down') difference *= -1
|
||||
if (index === 1 && height === 'up') difference *= -1
|
||||
if (height !== 'middle') {
|
||||
if (index === 1) {
|
||||
index = 2
|
||||
} else if (index === 2) {
|
||||
index = 1
|
||||
}
|
||||
}
|
||||
if (facing === 'south' && (index === 0 || index === 1)) difference *= -1
|
||||
if (facing === 'west' && index === 0) difference *= -1
|
||||
if (facing === 'east' && index === 1) difference *= -1
|
||||
if (index === 2 && height !== 'down') difference *= -1
|
||||
if (index === 1 && height === 'up') difference *= -1
|
||||
|
||||
if (event) {
|
||||
difference *= canvasGridSize(event.shiftKey, event.ctrlOrCmd);
|
||||
}
|
||||
if (event) {
|
||||
difference *= canvasGridSize(event.shiftKey, event.ctrlOrCmd);
|
||||
}
|
||||
|
||||
moveElementsInSpace(difference, axes[index])
|
||||
moveElementsInSpace(difference, axes[index])
|
||||
|
||||
Undo.finishEdit('move')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user