-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
388e34a
commit b579bee
Showing
3 changed files
with
86 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
const lib = require("textvox3d"); | ||
const lib = require('textvox3d'); | ||
|
||
function caliblrateViewportDimensions(camera, d, cubeSize) { | ||
const focalLength = camera.fl; | ||
const viewportHeight = 2 * cubeSize; | ||
const viewportWidth = (viewportHeight * d) / focalLength; | ||
|
||
return { width: viewportWidth, height: viewportHeight }; | ||
return {width: viewportWidth, height: viewportHeight}; | ||
} | ||
|
||
let f = 0; | ||
let camera = new lib.camera(55, 10, [7,-7,5], [64,0,47]); | ||
let viewport = new lib.viewport(process.stdout.columns, process.stdout.rows-1); | ||
const f = 0; | ||
const camera = new lib.camera(55, 10, [7, -7, 5], [64, 0, 47]); | ||
const viewport = new lib.viewport(process.stdout.columns, process.stdout.rows-1); | ||
|
||
let cubeMesh = lib.getMesh("cube"); | ||
let cube = new lib.item(cubeMesh, [0,0,0]/*pos*/, [0,0,0]/*rot*/, [2, 2, 2]/*scale*/); | ||
//console.log(`Cube mesh: points: ${cubeMesh.points}, edges: ${cubeMesh.edges}`); | ||
const cubeMesh = lib.getMesh('cube'); | ||
const cube = new lib.item(cubeMesh, [0, 0, 0]/* pos*/, [0, 0, 0]/* rot*/, [2, 2, 2]/* scale*/); | ||
// console.log(`Cube mesh: points: ${cubeMesh.points}, edges: ${cubeMesh.edges}`); | ||
|
||
//console.log(`Columns: ${process.stdout.columns}, Rows: ${process.stdout.rows}`); | ||
// console.log(`Columns: ${process.stdout.columns}, Rows: ${process.stdout.rows}`); | ||
|
||
function viewportTest() { | ||
let i=0; | ||
while (i<viewport.height) { | ||
if (i==0){ | ||
let a = lib.repeatStringNumTimes("0", (viewport.width-(f.toString().length + 2))); | ||
console.log(`${a}f=${f}`); | ||
}else { | ||
console.log("0"); | ||
} | ||
i++; | ||
} | ||
let i=0; | ||
while (i<viewport.height) { | ||
if (i==0) { | ||
const a = lib.repeatStringNumTimes('0', (viewport.width-(f.toString().length + 2))); | ||
console.log(`${a}f=${f}`); | ||
} else { | ||
console.log('0'); | ||
} | ||
i++; | ||
} | ||
}; | ||
|
||
function frame() { | ||
viewportTest(); | ||
fn++; | ||
viewportTest(); | ||
fn++; | ||
} | ||
|
||
//frame(); | ||
//setInterval(frame, 50) | ||
// frame(); | ||
// setInterval(frame, 50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
const lib = require("./index"); | ||
const lib = require('./index'); | ||
|
||
test("Camera", () => { | ||
expect(new lib.camera(70, 10, [7,-7,5], [64,0,47])).toEqual({"fov":70, "samples":10, "pos": [7,-7,5], "rot":[64,0,47]}); | ||
test('Camera', () => { | ||
expect(new lib.camera(70, 10, [7, -7, 5], [64, 0, 47])).toEqual({'fov': 70, 'samples': 10, 'pos': [7, -7, 5], 'rot': [64, 0, 47]}); | ||
}); | ||
test("Mesh", () => { | ||
expect(new lib.mesh([1,1,1], [1,1,1], [1,1,1])).toEqual({"points":[1,1,1], "edges":[1,1,1], "faces":[1,1,1]}) | ||
test('Mesh', () => { | ||
expect(new lib.mesh([1, 1, 1], [1, 1, 1], [1, 1, 1])).toEqual({'points': [1, 1, 1], 'edges': [1, 1, 1], 'faces': [1, 1, 1]}); | ||
}); | ||
test("Item", () => { | ||
expect(new lib.item("cube", [1,1,1], [0,0,0])).toEqual({"mesh":"cube", "pos":[1,1,1], "rot":[0,0,0]}) | ||
test('Item', () => { | ||
expect(new lib.item('cube', [1, 1, 1], [0, 0, 0])).toEqual({'mesh': 'cube', 'pos': [1, 1, 1], 'rot': [0, 0, 0]}); | ||
}); | ||
test("Viewport", () => { | ||
expect(new lib.viewport(100, 100)).toEqual({"width":100, "height":100}) | ||
test('Viewport', () => { | ||
expect(new lib.viewport(100, 100)).toEqual({'width': 100, 'height': 100}); | ||
}); | ||
test("Repeat string func", () => { | ||
expect(lib.repeatStringNumTimes("a", 3)).toEqual("aaa") | ||
test('Repeat string func', () => { | ||
expect(lib.repeatStringNumTimes('a', 3)).toEqual('aaa'); | ||
}); | ||
test('Get Mesh', () => { | ||
expect(lib.getMesh('cube')).toEqual({'points': [[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1], [1, -1, -1], [1, 1, -1], [-1, -1, -1], [-1, 1, -1]], 'edges': [[0, 1], [0, 5], [0, 3], [1, 2], [1, 7], [2, 3], [2, 6], [3, 4], [4, 5], [4, 6], [5, 7], [7, 6]], 'faces': [[1, 3, 5, 2], [2, 8, 3, 7], [7, 5, 9, 6], [0, 4, 1, 10], [3, 4, 6, 11]]}); | ||
}); | ||
test("Get Mesh", () => { | ||
expect(lib.getMesh("cube")).toEqual({"points":[[1,1,1], [-1,1,1], [-1,-1,1], [1,-1,1], [1,-1,-1], [1,1,-1], [-1,-1,-1], [-1,1,-1]], "edges":[[0,1], [0,5], [0,3], [1,2], [1,7], [2,3], [2,6], [3,4], [4,5], [4,6], [5,7], [7,6]], "faces":[[1,3,5,2], [2,8,3,7], [7,5,9,6], [0,4,1,10], [3,4,6,11]]}) | ||
}); |