Merge branch 'refactor' of https://github.com/LucasDower/ObjToSchematic into refactor

This commit is contained in:
Lucas Dower 2022-02-24 22:16:53 +00:00
commit 32068d55af
4 changed files with 14 additions and 9 deletions

View File

@ -48,8 +48,8 @@ You can either download the [latest release](https://github.com/LucasDower/ObjTo
0.5
* ⚪ Support for simplifying complex meshes
* 🟡 Load custom block palettes and texture atlases
* 🟢 Optimise construction of voxel mesh vertex buffers
* 🟢 **Load custom block palettes and texture atlases**
* 🟢 **Optimise construction of voxel mesh vertex buffers**
* 🟡 Web workers (see [web-workers](https://github.com/LucasDower/ObjToSchematic/tree/web-workers))
* Progress bar
* Prevent UI hanging
@ -75,5 +75,12 @@ This is an non-commercial **unofficial** tool that is neither approved, endorsed
![MinecraftPreview](/resources/minecraft.png)
# Debugging
# Contributing
Any contributions are welcome, just fork and submit a PR! Just make sure the code style follows the rulings in the `.eslintrc.json` and pass the CI build task.
Currently there's not much docs but if you're looking for where to get started, look at `app_context.ts` and follow `_import()`, `_simplify()`, `_voxelise()`, `_palette()`, and `_export()`. If you're looking to add elements to the UI, look at `ui/layout.ts`, I'm not using a UI framework because I'm a nutter. If you have any questions or need help getting started then feel free to message me.
Adding more file formats to import from and export to would be nice. Adding new default block palettes would be great also.
### Debugging
To allow for your favourite debugging tools like breakpoints and call stacks, I've included launch options for debugging in VSCode. Use `Ctrl+Shift+D`, and run "*Debug Main Process*" and once the Electron window has initialised, run "*Attach to Render Process*".

View File

@ -1,6 +1,5 @@
{
"atlasSize": 17,
"atlasTexture": "C:\\Users\\lucas\\ObjToSchematic\\resources\\atlases\\vanilla.png",
"blocks": [
{
"name": "acacia_log",

View File

@ -46,7 +46,7 @@ export class BlockAtlas {
private _atlasSize: number;
private _atlasLoaded: boolean;
private _paletteLoaded: boolean;
private _atlasTexturePath?: string;
private _atlasTextureID?: string;
private static _instance: BlockAtlas;
public static get Get() {
@ -77,7 +77,7 @@ export class BlockAtlas {
const json = JSON.parse(blocksString);
this._atlasSize = json.atlasSize;
this._atlasTexturePath = json.atlasTexture;
this._atlasTextureID = atlasID;
this._blocks = json.blocks;
for (const block of this._blocks) {
block.colour = new RGB(
@ -138,7 +138,7 @@ export class BlockAtlas {
public getAtlasTexturePath() {
ASSERT(this._atlasLoaded, 'No atlas texture available');
ASSERT(this._atlasTexturePath, 'No atlas texture path available');
return this._atlasTexturePath;
ASSERT(this._atlasTextureID, 'No atlas texture ID available');
return path.join(__dirname, '../resources/atlases', this._atlasTextureID + '.png');
}
}

View File

@ -342,7 +342,6 @@ async function buildAtlas() {
log(LogStyle.Success, `${atlasName}.png exported to /resources/atlases/`);
const outputJSON = {
atlasSize: atlasSize,
atlasTexture: atlasDir,
blocks: allModels,
};
fs.writeFileSync(path.join(__dirname, `../resources/atlases/${atlasName}.atlas`), JSON.stringify(outputJSON, null, 4));