forked from mirror/ObjToSchematic
Removed unused dependencies, minor importer refactor
This commit is contained in:
parent
5aca2d2cda
commit
bc1ee90b92
1152
package-lock.json
generated
1152
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -30,25 +30,20 @@
|
||||
},
|
||||
"homepage": "https://github.com/LucasDower/ObjToSchematic#readme",
|
||||
"devDependencies": {
|
||||
"@loaders.gl/core": "^3.4.14",
|
||||
"@loaders.gl/gltf": "^3.4.14",
|
||||
"@types/adm-zip": "^0.5.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/jquery": "^3.5.6",
|
||||
"@types/merge-images": "^1.2.1",
|
||||
"@types/pngjs": "^6.0.1",
|
||||
"@types/prompt": "^1.1.2",
|
||||
"@types/sharp": "^0.31.0",
|
||||
"@types/varint": "^6.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
||||
"@typescript-eslint/parser": "^5.9.1",
|
||||
"browserify-zlib": "^0.2.0",
|
||||
"bvh-tree": "^1.0.1",
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^11.0.0",
|
||||
"css-loader": "^6.7.3",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"dependency-cruiser": "^13.1.5",
|
||||
"eslint": "^8.7.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-plugin-simple-import-sort": "^8.0.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"ga-gtag": "^1.1.7",
|
||||
"hsv-rgb": "^1.0.0",
|
||||
@ -56,7 +51,6 @@
|
||||
"i18next": "^22.4.14",
|
||||
"jest": "^27.5.1",
|
||||
"jpeg-js": "^0.4.4",
|
||||
"json-loader": "^0.5.7",
|
||||
"jszip": "^3.10.1",
|
||||
"node-polyfill-webpack-plugin": "^2.0.1",
|
||||
"pngjs": "^7.0.0",
|
||||
@ -64,6 +58,7 @@
|
||||
"prompt": "^1.2.1",
|
||||
"raw-loader": "^4.0.2",
|
||||
"sharp": "^0.31.3",
|
||||
"split.js": "^1.6.5",
|
||||
"ts-jest": "^27.1.3",
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.1.0",
|
||||
@ -74,13 +69,6 @@
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"webpack-merge": "^5.8.0",
|
||||
"webpack-strip-block": "^0.3.0",
|
||||
"worker-loader": "^3.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"@loaders.gl/core": "^3.3.1",
|
||||
"@loaders.gl/gltf": "^3.3.1",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"split.js": "^1.6.5"
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,9 @@ export class WorkerClient {
|
||||
|
||||
const importer = ImporterFactor.GetImporter(parsed.ext === '.obj' ? 'obj' : 'gltf');
|
||||
|
||||
this._loadedMesh = await importer.import(params.file);
|
||||
const fileBuffer = await params.file.arrayBuffer();
|
||||
|
||||
this._loadedMesh = await importer.import(fileBuffer);
|
||||
|
||||
const err = this._loadedMesh.processMesh(params.rotation.y, params.rotation.x, params.rotation.z);
|
||||
if (err !== null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Mesh } from '../mesh';
|
||||
|
||||
export abstract class IImporter {
|
||||
public abstract import(file: File): Promise<Mesh>;
|
||||
public abstract import(file: ArrayBuffer): Promise<Mesh>;
|
||||
}
|
@ -21,7 +21,7 @@ export class GltfImporterError extends Error {
|
||||
}
|
||||
|
||||
export class GltfLoader extends IImporter {
|
||||
public override async import(file: File): Promise<Mesh> {
|
||||
public override async import(file: ArrayBuffer): Promise<Mesh> {
|
||||
// TODO: StatusRework
|
||||
//StatusHandler.warning(LOC('import.gltf_experimental'));
|
||||
|
||||
|
@ -222,8 +222,9 @@ export class ObjImporter extends IImporter {
|
||||
},
|
||||
];
|
||||
|
||||
public override async import(file: File): Promise<Mesh> {
|
||||
const fileSource = await file.text();
|
||||
public override async import(file: ArrayBuffer): Promise<Mesh> {
|
||||
const decoder = new TextDecoder(); //utf8
|
||||
const fileSource = decoder.decode(file);
|
||||
|
||||
if (fileSource.includes('<27>')) {
|
||||
throw new ObjImporterError({ type: 'invalid-encoding' });
|
||||
|
@ -45,7 +45,8 @@ export class OtS_VoxelMesh {
|
||||
collisions: 1,
|
||||
}
|
||||
this._voxels.set(key, voxel);
|
||||
this._bounds.extendByPoint(position);
|
||||
//this._bounds.extendByPoint(position);
|
||||
this._isBoundsDirty = true;
|
||||
} else {
|
||||
if (useReplaceMode === 'average') {
|
||||
voxel.colour.r = ((voxel.colour.r * voxel.collisions) + colour.r) / (voxel.collisions + 1);
|
||||
|
@ -7,7 +7,6 @@ import { LinearAllocator } from './linear_allocator';
|
||||
import { Axes, Ray, rayIntersectTriangle } from './ray';
|
||||
import { Bounds } from './bounds';
|
||||
import { RGBA, RGBAColours, RGBAUtil } from './colour';
|
||||
import { UV } from './util';
|
||||
|
||||
export type OtS_VoxelMesh_ConverterConfig = {
|
||||
constraintAxis: TAxis,
|
||||
|
46
tools/benchmark.ts
Normal file
46
tools/benchmark.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { ObjImporter } from "../src/runtime/importers/obj_importer";
|
||||
import { OtS_VoxelMesh_Converter } from '../src/runtime/ots_voxel_mesh_converter';
|
||||
import { BlockMesh } from '../src/runtime/block_mesh';
|
||||
import { PALETTE_ALL_RELEASE } from '../res/palettes/all';
|
||||
|
||||
(async () => {
|
||||
const p = path.join(__dirname, '../res/samples/skull.obj');
|
||||
//console.log(p);
|
||||
const file = fs.readFileSync(p);
|
||||
|
||||
const loader = new ObjImporter();
|
||||
console.time('Mesh');
|
||||
const mesh = await loader.import(file);
|
||||
mesh.processMesh(0, 0, 0);
|
||||
console.timeEnd('Mesh');
|
||||
|
||||
const converter = new OtS_VoxelMesh_Converter();
|
||||
converter.setConfig({
|
||||
constraintAxis: 'y',
|
||||
size: 380,
|
||||
multisampling: true,
|
||||
replaceMode: 'average',
|
||||
});
|
||||
|
||||
console.time('VoxelMesh');
|
||||
const voxelMesh = converter.process(mesh);
|
||||
console.timeEnd('VoxelMesh');
|
||||
|
||||
console.time('BlockMesh');
|
||||
const blockMesh = BlockMesh.createFromVoxelMesh(voxelMesh, {
|
||||
atlasJSON: JSON.parse(fs.readFileSync(path.join(__dirname, '../res/atlases/vanilla.atlas'), 'utf8')),
|
||||
blockPalette: new Set(PALETTE_ALL_RELEASE),
|
||||
calculateLighting: false,
|
||||
contextualAveraging: true,
|
||||
dithering: 'off',
|
||||
ditheringMagnitude: 0,
|
||||
errorWeight: 0.02,
|
||||
resolution: 16,
|
||||
fallable: 'do-nothing',
|
||||
lightThreshold: 0,
|
||||
});
|
||||
console.timeEnd('BlockMesh');
|
||||
})();
|
@ -1,11 +1,18 @@
|
||||
{
|
||||
"ts-node": {
|
||||
// these options are overrides used only by ts-node
|
||||
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
}
|
||||
},
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"allowJs": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"outDir": "./build",
|
||||
"downlevelIteration": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
|
Loading…
Reference in New Issue
Block a user