Skip to content

Commit

Permalink
Update stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAcPT committed Nov 2, 2023
1 parent e621000 commit e621000
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 248 deletions.
26 changes: 12 additions & 14 deletions src/routes/tools/bbmodel-generator/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { writable } from "svelte/store";
import init, { WasmPlayerModel, generate_blockbench_model } from "../../../tools/bbmodel-generator/bbmodel-generator_wasm";
import init, { WasmPlayerModel, generate_blockbench_model } from "../../../tools/bbmodel-generator/bbmodel_generator";
import { saveAs } from "file-saver";
import { browser } from "$app/environment";
import SkinDropZone from "../../../components/SkinDropZone.svelte";
Expand All @@ -22,21 +22,19 @@
async function handleSkinFile(file: File) {
let result = generate_blockbench_model(new Uint8Array(await file.arrayBuffer()), $skinModel, $hasLayers);
let model = result.value();
let error = result.is_error();
try {
let model = result;
let blob = new Blob([JSON.stringify(model, replacer)], { type: "application/json" });
if (error) {
alert(model);
return;
}
let blob = new Blob([JSON.stringify(model, replacer)], { type: "application/json" });
let fileName = file.name.split(".");
fileName.pop();
fileName.push("bbmodel");
let fileName = file.name.split(".");
fileName.pop();
fileName.push("bbmodel");
saveAs(blob, fileName.join("."));
saveAs(blob, fileName.join("."));
} catch (error) {
alert("An error occurred while generating the model. Please notify @nickac on Discord.");
console.error(error);
}
}
function handleSkinFiles(event: CustomEvent<FileList>) {
Expand Down
7 changes: 3 additions & 4 deletions src/routes/tools/region-eraser/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
import type { WasmEarsEraseWorkspace } from "../../../tools/ears-eraser/ears-eraser_wasm";
import init, { decode_ears_image, encode_ears_image } from "../../../tools/ears-eraser/ears-eraser_wasm";
import init, { decode_ears_image, EarsImageWorkspace, encode_ears_image } from "../../../tools/ears-eraser/ears_eraser";
import Selecto from "svelte-selecto";
import Moveable, { type OnBeforeResize, type OnDrag, type OnResize } from "svelte-moveable";
Expand Down Expand Up @@ -83,7 +82,7 @@
e.target.style.transform = e.transform;
}
let workspace = writable<WasmEarsEraseWorkspace | undefined>(undefined);
let workspace = writable<EarsImageWorkspace | undefined>(undefined);
let regions = writable<EraseRegion[]>([]);
let lastSkin = writable<File | undefined>(undefined);
Expand Down Expand Up @@ -378,7 +377,7 @@
boundContainer={imgCanvas}
dragCondition={(e) => {
const offset = 10;

const withinX = e.inputEvent.clientX >= imgCanvasBounds.left - offset && e.inputEvent.clientX <= imgCanvasBounds.right + offset;
const withinY = e.inputEvent.clientY >= imgCanvasBounds.top - offset && e.inputEvent.clientY <= imgCanvasBounds.bottom + offset;

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,27 @@
/* eslint-disable */
/**
* @param {Uint8Array} skin_bytes
* @param {number} model
* @param {WasmPlayerModel} model
* @param {boolean} layers
* @returns {ConversionResult}
* @returns {any}
*/
export function generate_blockbench_model(skin_bytes: Uint8Array, model: number, layers: boolean): ConversionResult;
export function generate_blockbench_model(skin_bytes: Uint8Array, model: WasmPlayerModel, layers: boolean): any;
/**
*/
export enum WasmPlayerModel {
Steve = 0,
Alex = 1,
}
/**
*/
export class ConversionResult {
free(): void;
/**
* @returns {any}
*/
value(): any;
/**
* @returns {boolean}
*/
is_error(): boolean;
}

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly __wbg_conversionresult_free: (a: number) => void;
readonly conversionresult_value: (a: number) => number;
readonly conversionresult_is_error: (a: number) => number;
readonly generate_blockbench_model: (a: number, b: number, c: number, d: number) => number;
readonly generate_blockbench_model: (a: number, b: number, c: number, d: number, e: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_export_0: (a: number, b: number) => number;
readonly __wbindgen_export_1: (a: number, b: number, c: number) => void;
readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_3: (a: number) => void;
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_2: (a: number) => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
Expand Down
Loading

0 comments on commit e621000

Please sign in to comment.