mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2025-12-11 20:15:30 +01:00
Fixed auto adjusting size for constraint axis
This commit is contained in:
parent
79a5dbf9ce
commit
a827e427db
@ -28,7 +28,8 @@ export class AppContext {
|
|||||||
|
|
||||||
private _workerController: WorkerController;
|
private _workerController: WorkerController;
|
||||||
private _lastAction?: EAction;
|
private _lastAction?: EAction;
|
||||||
public maxConstraint?: Vector3;
|
public minConstraint?: { x: number, z: number };
|
||||||
|
public maxConstraint?: { x: number, z: number };
|
||||||
private _materialManager: MaterialMapManager;
|
private _materialManager: MaterialMapManager;
|
||||||
private _loadedFilename: string | null;
|
private _loadedFilename: string | null;
|
||||||
|
|
||||||
@ -109,8 +110,17 @@ export class AppContext {
|
|||||||
AppConsole.success(LOC('import.imported_mesh'));
|
AppConsole.success(LOC('import.imported_mesh'));
|
||||||
this._addWorkerMessagesToConsole(resultImport.messages);
|
this._addWorkerMessagesToConsole(resultImport.messages);
|
||||||
|
|
||||||
|
UI.Get._ui.voxelise.components.constraintAxis.setValue('y');
|
||||||
|
UI.Get._ui.voxelise.components.size.setValue(80);
|
||||||
|
|
||||||
|
this.minConstraint = Vector3.copy(resultImport.result.dimensions)
|
||||||
|
.mulScalar(AppConfig.Get.CONSTRAINT_MINIMUM_HEIGHT).ceil();
|
||||||
this.maxConstraint = Vector3.copy(resultImport.result.dimensions)
|
this.maxConstraint = Vector3.copy(resultImport.result.dimensions)
|
||||||
.mulScalar(AppConfig.Get.CONSTRAINT_MAXIMUM_HEIGHT / 8.0).floor();
|
.mulScalar(AppConfig.Get.CONSTRAINT_MAXIMUM_HEIGHT).floor();
|
||||||
|
|
||||||
|
UI.Get._ui.voxelise.components.constraintAxis.setOptionEnabled(0, this.minConstraint.x > 0 && this.minConstraint.x <= this.maxConstraint.x);
|
||||||
|
UI.Get._ui.voxelise.components.constraintAxis.setOptionEnabled(2, this.minConstraint.z > 0 && this.minConstraint.z <= this.maxConstraint.z);
|
||||||
|
|
||||||
this._materialManager = new MaterialMapManager(resultImport.result.materials);
|
this._materialManager = new MaterialMapManager(resultImport.result.materials);
|
||||||
UI.Get.updateMaterialsAction(this._materialManager);
|
UI.Get.updateMaterialsAction(this._materialManager);
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,11 @@ export class ComboboxComponent<T> extends ConfigComponent<T, HTMLSelectElement>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setOptionEnabled(index: number, enabled: boolean) {
|
||||||
|
const option = UIUtil.getElementById(this._getId() + '-' + index) as HTMLOptionElement;
|
||||||
|
option.disabled = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public override _generateInnerHTML() {
|
public override _generateInnerHTML() {
|
||||||
const builder = new HTMLBuilder();
|
const builder = new HTMLBuilder();
|
||||||
|
|
||||||
@ -130,4 +135,8 @@ export class ComboboxComponent<T> extends ConfigComponent<T, HTMLSelectElement>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setValue(value: T) {
|
||||||
|
this._setValue(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,10 @@ export class SliderComponent extends ConfigComponent<number, HTMLDivElement> {
|
|||||||
this._valueHovered = false;
|
this._valueHovered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setValue(value: number) {
|
||||||
|
this._setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
public override setDefaultValue(value: number) {
|
public override setDefaultValue(value: number) {
|
||||||
super.setDefaultValue(value);
|
super.setDefaultValue(value);
|
||||||
this._internalValue = value;
|
this._internalValue = value;
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import { VectorComponent } from './components/vector';
|
|||||||
import { AppConsole } from './console';
|
import { AppConsole } from './console';
|
||||||
import { AppIcons } from './icons';
|
import { AppIcons } from './icons';
|
||||||
import { HTMLBuilder, MiscComponents } from './misc';
|
import { HTMLBuilder, MiscComponents } from './misc';
|
||||||
|
import { AppConfig } from '../config';
|
||||||
|
|
||||||
export type Group = {
|
export type Group = {
|
||||||
id: string,
|
id: string,
|
||||||
@ -83,7 +84,7 @@ export class UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public uiOrder = ['settings', 'import', 'materials', 'voxelise', 'assign', 'export'];
|
public uiOrder = ['settings', 'import', 'materials', 'voxelise', 'assign', 'export'];
|
||||||
private _ui = {
|
public _ui = {
|
||||||
'settings': {
|
'settings': {
|
||||||
id: 'settings',
|
id: 'settings',
|
||||||
label: LOC('settings.heading'),
|
label: LOC('settings.heading'),
|
||||||
@ -130,20 +131,27 @@ export class UI {
|
|||||||
.addItem({ payload: 'z', displayLocKey: 'voxelise.components.z_axis' })
|
.addItem({ payload: 'z', displayLocKey: 'voxelise.components.z_axis' })
|
||||||
.setLabel('voxelise.components.constraint_axis')
|
.setLabel('voxelise.components.constraint_axis')
|
||||||
.addValueChangedListener((value: TAxis) => {
|
.addValueChangedListener((value: TAxis) => {
|
||||||
/*
|
|
||||||
TODO:
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 'x':
|
case 'x': {
|
||||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.x ?? 400);
|
ASSERT(this._appContext !== undefined && this._appContext.minConstraint !== undefined && this._appContext.maxConstraint !== undefined);
|
||||||
break;
|
console.log('min', this._appContext.minConstraint, 'max', this._appContext.maxConstraint);
|
||||||
case 'y':
|
this._ui.voxelise.components.size.setMin(this._appContext.minConstraint.x);
|
||||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.y ?? AppConfig.Get.CONSTRAINT_MAXIMUM_HEIGHT);
|
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint.x);
|
||||||
break;
|
|
||||||
case 'z':
|
|
||||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.z ?? 400);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
case 'y': {
|
||||||
|
this._ui.voxelise.components.size.setMin(AppConfig.Get.CONSTRAINT_MINIMUM_HEIGHT);
|
||||||
|
this._ui.voxelise.components.size.setMax(AppConfig.Get.CONSTRAINT_MAXIMUM_HEIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'z': {
|
||||||
|
ASSERT(this._appContext !== undefined && this._appContext.minConstraint !== undefined && this._appContext.maxConstraint !== undefined);
|
||||||
|
console.log('min', this._appContext.minConstraint, 'max', this._appContext.maxConstraint);
|
||||||
|
this._ui.voxelise.components.size.setMin(this._appContext.minConstraint.z);
|
||||||
|
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint.z);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
'size': new SliderComponent()
|
'size': new SliderComponent()
|
||||||
.setMin(3)
|
.setMin(3)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user