forked from mirror/ObjToSchematic
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 _lastAction?: EAction;
|
||||
public maxConstraint?: Vector3;
|
||||
public minConstraint?: { x: number, z: number };
|
||||
public maxConstraint?: { x: number, z: number };
|
||||
private _materialManager: MaterialMapManager;
|
||||
private _loadedFilename: string | null;
|
||||
|
||||
@ -109,8 +110,17 @@ export class AppContext {
|
||||
AppConsole.success(LOC('import.imported_mesh'));
|
||||
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)
|
||||
.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);
|
||||
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() {
|
||||
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;
|
||||
}
|
||||
|
||||
public setValue(value: number) {
|
||||
this._setValue(value);
|
||||
}
|
||||
|
||||
public override setDefaultValue(value: number) {
|
||||
super.setDefaultValue(value);
|
||||
this._internalValue = value;
|
||||
|
@ -33,6 +33,7 @@ import { VectorComponent } from './components/vector';
|
||||
import { AppConsole } from './console';
|
||||
import { AppIcons } from './icons';
|
||||
import { HTMLBuilder, MiscComponents } from './misc';
|
||||
import { AppConfig } from '../config';
|
||||
|
||||
export type Group = {
|
||||
id: string,
|
||||
@ -83,7 +84,7 @@ export class UI {
|
||||
}
|
||||
|
||||
public uiOrder = ['settings', 'import', 'materials', 'voxelise', 'assign', 'export'];
|
||||
private _ui = {
|
||||
public _ui = {
|
||||
'settings': {
|
||||
id: 'settings',
|
||||
label: LOC('settings.heading'),
|
||||
@ -130,20 +131,27 @@ export class UI {
|
||||
.addItem({ payload: 'z', displayLocKey: 'voxelise.components.z_axis' })
|
||||
.setLabel('voxelise.components.constraint_axis')
|
||||
.addValueChangedListener((value: TAxis) => {
|
||||
/*
|
||||
TODO:
|
||||
switch (value) {
|
||||
case 'x':
|
||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.x ?? 400);
|
||||
case 'x': {
|
||||
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.x);
|
||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint.x);
|
||||
break;
|
||||
case 'y':
|
||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.y ?? AppConfig.Get.CONSTRAINT_MAXIMUM_HEIGHT);
|
||||
}
|
||||
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':
|
||||
this._ui.voxelise.components.size.setMax(this._appContext.maxConstraint?.z ?? 400);
|
||||
}
|
||||
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()
|
||||
.setMin(3)
|
||||
|
Loading…
Reference in New Issue
Block a user