forked from mirror/ObjToSchematic
Added toggle for calculating lighting
This commit is contained in:
parent
99d6572281
commit
2be9d9bc02
@ -323,6 +323,8 @@ export class AppContext {
|
||||
this._ui.getActionOutput(EAction.Assign)
|
||||
.setTaskInProgress('action', '[Block Mesh]: Loading...');
|
||||
|
||||
Renderer.Get.setLightingAvailable(uiElements.calculateLighting.getCachedValue());
|
||||
|
||||
const payload: TToWorkerMessage = {
|
||||
action: 'Assign',
|
||||
params: {
|
||||
@ -332,6 +334,7 @@ export class AppContext {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: uiElements.fallable.getCachedValue() as FallableBehaviour,
|
||||
resolution: Math.pow(2, uiElements.colourAccuracy.getCachedValue()),
|
||||
calculateLighting: uiElements.calculateLighting.getCachedValue(),
|
||||
lightThreshold: uiElements.lightThreshold.getCachedValue(),
|
||||
},
|
||||
};
|
||||
|
@ -48,11 +48,13 @@ export class BlockMesh {
|
||||
blockMesh._assignBlocks(blockMeshParams);
|
||||
|
||||
//blockMesh._calculateLighting(blockMeshParams.lightThreshold);
|
||||
blockMesh._lighting.init();
|
||||
blockMesh._lighting.addSunLightValues();
|
||||
blockMesh._lighting.addEmissiveBlocks();
|
||||
blockMesh._lighting.addLightToDarkness(blockMeshParams.lightThreshold);
|
||||
blockMesh._lighting.dumpInfo();
|
||||
if (blockMeshParams.calculateLighting) {
|
||||
blockMesh._lighting.init();
|
||||
blockMesh._lighting.addSunLightValues();
|
||||
blockMesh._lighting.addEmissiveBlocks();
|
||||
blockMesh._lighting.addLightToDarkness(blockMeshParams.lightThreshold);
|
||||
blockMesh._lighting.dumpInfo();
|
||||
}
|
||||
|
||||
return blockMesh;
|
||||
}
|
||||
|
@ -126,6 +126,14 @@ export class Renderer {
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private _lightingAvailable: boolean = false;
|
||||
public setLightingAvailable(isAvailable: boolean) {
|
||||
this._lightingAvailable = isAvailable;
|
||||
if (!isAvailable) {
|
||||
this._nightVisionEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public toggleIsGridEnabled() {
|
||||
this._gridEnabled = !this._gridEnabled;
|
||||
}
|
||||
@ -142,8 +150,15 @@ export class Renderer {
|
||||
this._axesEnabled = !this._axesEnabled;
|
||||
}
|
||||
|
||||
public canToggleNightVision() {
|
||||
return this._lightingAvailable;
|
||||
}
|
||||
|
||||
public toggleIsNightVisionEnabled() {
|
||||
this._nightVisionEnabled = !this._nightVisionEnabled;
|
||||
if (!this._lightingAvailable) {
|
||||
this._nightVisionEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public isNightVisionEnabled() {
|
||||
|
@ -13,7 +13,10 @@ export abstract class BaseUIElement<Type> {
|
||||
this._isEnabled = true;
|
||||
}
|
||||
|
||||
public setEnabled(isEnabled: boolean) {
|
||||
public setEnabled(isEnabled: boolean, isGroupEnable: boolean = true) {
|
||||
if (isEnabled && isGroupEnable && !this._obeyGroupEnables) {
|
||||
return;
|
||||
}
|
||||
this._isEnabled = isEnabled;
|
||||
this._onEnabledChanged();
|
||||
}
|
||||
@ -37,4 +40,10 @@ export abstract class BaseUIElement<Type> {
|
||||
|
||||
|
||||
protected abstract _onEnabledChanged(): void;
|
||||
|
||||
private _obeyGroupEnables: boolean = true;
|
||||
public setObeyGroupEnables(shouldListen: boolean) {
|
||||
this._obeyGroupEnables = shouldListen;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,14 @@ export class ComboBoxElement<T> extends LabelledElement<T> {
|
||||
}
|
||||
|
||||
public registerEvents(): void {
|
||||
const element = document.getElementById(this._id) as HTMLSelectElement;
|
||||
ASSERT(element !== null);
|
||||
|
||||
element.addEventListener('change', () => {
|
||||
if (this._onValueChangedDelegate) {
|
||||
this._onValueChangedDelegate(element.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected getValue() {
|
||||
@ -43,5 +51,13 @@ export class ComboBoxElement<T> extends LabelledElement<T> {
|
||||
const element = document.getElementById(this._id) as HTMLSelectElement;
|
||||
ASSERT(element !== null);
|
||||
element.disabled = !this._isEnabled;
|
||||
|
||||
this._onValueChangedDelegate?.(element.value);
|
||||
}
|
||||
|
||||
private _onValueChangedDelegate?: (value: any) => void;
|
||||
public onValueChanged(delegate: (value: any) => void) {
|
||||
this._onValueChangedDelegate = delegate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,10 @@ export class ToolbarItemElement {
|
||||
|
||||
element.classList.remove('toolbar-item-disabled');
|
||||
element.classList.remove('toolbar-item-active');
|
||||
element.classList.remove('toolbar-item-disabled-active');
|
||||
svgElement.classList.remove('icon-disabled');
|
||||
svgElement.classList.remove('icon-active');
|
||||
svgElement.classList.remove('icon-disabled-active');
|
||||
|
||||
if (this._isEnabled) {
|
||||
if (this._isActive) {
|
||||
@ -107,8 +109,13 @@ export class ToolbarItemElement {
|
||||
svgElement.classList.add('icon-active');
|
||||
}
|
||||
} else {
|
||||
element.classList.add('toolbar-item-disabled');
|
||||
svgElement.classList.add('icon-disabled');
|
||||
if (this._isActive) {
|
||||
element.classList.add('toolbar-item-disabled-active');
|
||||
svgElement.classList.add('icon-disabled-active');
|
||||
} else {
|
||||
element.classList.add('toolbar-item-disabled');
|
||||
svgElement.classList.add('icon-disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,9 +151,20 @@ export class UI {
|
||||
},
|
||||
]),
|
||||
'colourAccuracy': new SliderElement('Colour accuracy', 1, 8, 1, 5, 0.1),
|
||||
'lightThreshold': new SliderElement('Light threshold', 0, 14, 0, 0, 1),
|
||||
'calculateLighting': new ComboBoxElement<boolean>('Calculate lighting', [
|
||||
{ id: false, displayText: 'Off' },
|
||||
{ id: true, displayText: 'On' },
|
||||
]).onValueChanged((value: any) => {
|
||||
if (value === 'true') {
|
||||
this._ui.assign.elements.lightThreshold.setEnabled(true, false);
|
||||
} else {
|
||||
this._ui.assign.elements.lightThreshold.setEnabled(false, false);
|
||||
}
|
||||
}),
|
||||
'lightThreshold': new SliderElement('Light threshold', 0, 14, 0, 0, 1)
|
||||
.setObeyGroupEnables(false),
|
||||
},
|
||||
elementsOrder: ['textureAtlas', 'blockPalette', 'dithering', 'fallable', 'colourAccuracy', 'lightThreshold'],
|
||||
elementsOrder: ['textureAtlas', 'blockPalette', 'dithering', 'fallable', 'colourAccuracy', 'calculateLighting', 'lightThreshold'],
|
||||
submitButton: new ButtonElement('Assign blocks', () => {
|
||||
this._appContext.do(EAction.Assign);
|
||||
}),
|
||||
@ -240,6 +251,9 @@ export class UI {
|
||||
})
|
||||
.isActive(() => {
|
||||
return Renderer.Get.isNightVisionEnabled();
|
||||
})
|
||||
.isEnabled(() => {
|
||||
return Renderer.Get.canToggleNightVision();
|
||||
}),
|
||||
},
|
||||
elementsOrder: ['grid', 'axes', 'night-vision'],
|
||||
|
@ -96,6 +96,7 @@ export namespace AssignParams {
|
||||
colourSpace: ColourSpace,
|
||||
fallable: FallableBehaviour,
|
||||
resolution: RGBAUtil.TColourAccuracy,
|
||||
calculateLighting: boolean,
|
||||
lightThreshold: number,
|
||||
}
|
||||
|
||||
|
@ -447,6 +447,11 @@ select:disabled {
|
||||
border: 1px solid var(--prop-accent-border-hovered) !important;
|
||||
}
|
||||
|
||||
.toolbar-item-disabled-active {
|
||||
background-color: var(--prop-accent-disabled) !important;
|
||||
border: 1px solid var(--prop-accent-disabled) !important;
|
||||
}
|
||||
|
||||
.toolbar-item-disabled {
|
||||
background-color: var(--prop-disabled) !important;
|
||||
border: 1px solid var(--prop-disabled) !important;
|
||||
@ -482,6 +487,10 @@ svg {
|
||||
stroke: var(--text-disabled) !important;
|
||||
}
|
||||
|
||||
.icon-disabled-active {
|
||||
stroke: #808080 !important;
|
||||
}
|
||||
|
||||
.palette-container {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
|
@ -23,6 +23,8 @@ const baseConfig: THeadlessConfig = {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: 'replace-falling',
|
||||
resolution: 32,
|
||||
calculateLighting: false,
|
||||
lightThreshold: 0,
|
||||
},
|
||||
export: {
|
||||
filepath: '', // Must be an absolute path to the file (can be anywhere)
|
||||
|
@ -23,6 +23,8 @@ const baseConfig: THeadlessConfig = {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: 'replace-falling',
|
||||
resolution: 32,
|
||||
calculateLighting: false,
|
||||
lightThreshold: 0,
|
||||
},
|
||||
export: {
|
||||
filepath: '', // Must be an absolute path to the file (can be anywhere)
|
||||
|
@ -23,6 +23,8 @@ const baseConfig: THeadlessConfig = {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: 'replace-falling',
|
||||
resolution: 32,
|
||||
calculateLighting: false,
|
||||
lightThreshold: 0,
|
||||
},
|
||||
export: {
|
||||
filepath: '', // Must be an absolute path to the file (can be anywhere)
|
||||
|
@ -23,6 +23,8 @@ const baseConfig: THeadlessConfig = {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: 'replace-falling',
|
||||
resolution: 32,
|
||||
calculateLighting: false,
|
||||
lightThreshold: 0,
|
||||
},
|
||||
export: {
|
||||
filepath: '', // Must be an absolute path to the file (can be anywhere)
|
||||
|
@ -21,6 +21,7 @@ export const headlessConfig: THeadlessConfig = {
|
||||
colourSpace: ColourSpace.RGB,
|
||||
fallable: 'replace-falling',
|
||||
resolution: 32,
|
||||
calculateLighting: false,
|
||||
lightThreshold: 0,
|
||||
},
|
||||
export: {
|
||||
|
Loading…
Reference in New Issue
Block a user