forked from mirror/ObjToSchematic
Cleanup for 0.1 release
This commit is contained in:
parent
8b056b8c65
commit
e3135b1c2e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/node_modules
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
ObjToSchematic-win32-x64
|
15
package.json
15
package.json
@ -4,8 +4,8 @@
|
||||
"description": "A tool to convert .obj files into voxels and then into Minecraft Schematic files",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "electron ."
|
||||
"start": "electron .",
|
||||
"build": "electron-packager . ObjToSchematic --platform=win32 --arch=x64"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -19,13 +19,16 @@
|
||||
"homepage": "https://github.com/LucasDower/ObjToSchematic#readme",
|
||||
"devDependencies": {
|
||||
"electron": "^13.1.4",
|
||||
"electron-packager": "^15.2.0",
|
||||
"expand-vertex-data": "^1.1.2",
|
||||
"load-wavefront-obj": "^0.8.0",
|
||||
"twgl.js": "^4.19.1",
|
||||
"wavefront-obj-parser": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"twgl.js": "^4.19.1",
|
||||
"load-wavefront-obj": "^0.8.0",
|
||||
"wavefront-obj-parser": "^2.0.1",
|
||||
"expand-vertex-data": "^1.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "^5.0.2",
|
||||
"obj2json": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
const { Renderer } = require('./src/renderer.js');
|
||||
const { Vector3 } = require('./src/vector.js');
|
||||
const { Triangle } = require('./src/triangle.js');
|
||||
const { Mesh } = require('./src/mesh.js');
|
||||
const { VoxelManager } = require('./src/voxel_manager.js');
|
||||
|
||||
const voxelSize = 0.5;
|
||||
const voxelSize = 0.05;
|
||||
let renderer = new Renderer(voxelSize);
|
||||
const voxelManager = new VoxelManager(voxelSize);
|
||||
|
||||
@ -12,14 +10,12 @@ const nav = document.querySelector("#nav");
|
||||
let canvas = document.querySelector("#c");
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.height = window.innerHeight - 62;
|
||||
canvas.height = window.innerHeight - 54;
|
||||
canvas.width = window.innerWidth;
|
||||
}
|
||||
|
||||
resizeCanvas();
|
||||
|
||||
console.log(nav.getBoundingClientRect());
|
||||
|
||||
/*
|
||||
const suzanneLeft = new Mesh('./resources/suzanne_left.obj');
|
||||
voxelManager.voxeliseMesh(suzanneLeft);
|
||||
@ -29,24 +25,20 @@ const suzanneRight = new Mesh('./resources/suzanne_right.obj');
|
||||
renderer.registerMesh(suzanneRight);
|
||||
*/
|
||||
|
||||
renderer.registerVoxel(new Vector3(0, 0, 0), true);
|
||||
renderer.compileRegister();
|
||||
|
||||
document.querySelector("#objBtn").addEventListener('click', () => {
|
||||
const files = document.querySelector("#objFile").files;
|
||||
//console.log(files[0].path);
|
||||
|
||||
if (files.length != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mesh = new Mesh(files[0].path);
|
||||
renderer.clear();
|
||||
|
||||
voxelManager.voxeliseMesh(mesh);
|
||||
renderer.registerVoxels(voxelManager.voxels);
|
||||
|
||||
//renderer.registerMesh(mesh);
|
||||
renderer.compileRegister();
|
||||
console.log("done");
|
||||
});
|
||||
|
||||
function render(time) {
|
||||
|
@ -1,15 +1,29 @@
|
||||
const twgl = require('twgl.js');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const gl = document.querySelector("#c").getContext("webgl");
|
||||
|
||||
function getShader(filename) {
|
||||
const absPath = path.join(__dirname, '../shaders/' + filename);
|
||||
return fs.readFileSync(absPath, 'utf8');
|
||||
}
|
||||
|
||||
const shadedVertexShader = getShader('shaded_vertex.vs');
|
||||
const shadedFragmentShader = getShader('shaded_fragment.fs');
|
||||
|
||||
const debugVertexShader = getShader('debug_vertex.vs');
|
||||
const debugFragmentShader = getShader('debug_fragment.fs');
|
||||
|
||||
/*
|
||||
const shaded_vertex_shader = fs.readFileSync('./shaders/shaded_vertex.vs', 'utf8');
|
||||
const shaded_fragment_shader = fs.readFileSync('./shaders/shaded_fragment.fs', 'utf8');
|
||||
|
||||
const debug_vertex_shader = fs.readFileSync('./shaders/debug_vertex.vs', 'utf8');
|
||||
const debug_fragment_shader = fs.readFileSync('./shaders/debug_fragment.fs', 'utf8');
|
||||
*/
|
||||
|
||||
const shadedProgram = twgl.createProgramInfo(gl, [shaded_vertex_shader, shaded_fragment_shader]);
|
||||
const debugProgram = twgl.createProgramInfo(gl, [debug_vertex_shader, debug_fragment_shader]);
|
||||
const shadedProgram = twgl.createProgramInfo(gl, [shadedVertexShader, shadedFragmentShader]);
|
||||
const debugProgram = twgl.createProgramInfo(gl, [debugVertexShader, debugFragmentShader]);
|
||||
|
||||
module.exports.shadedProgram = shadedProgram;
|
||||
module.exports.debugProgram = debugProgram;
|
||||
|
Loading…
Reference in New Issue
Block a user