Skip to content

Commit

Permalink
Add cylinder scene
Browse files Browse the repository at this point in the history
  • Loading branch information
SinclaM committed Jul 15, 2023
1 parent e96ec56 commit 4bc6e61
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 1 deletion.
189 changes: 189 additions & 0 deletions scenes/cylinders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"camera": {
"width": 800,
"height": 400,
"field-of-view": 0.314,
"from": [8, 3.5, -9],
"to": [0, 0.3, 0],
"up": [0, 1, 0]
},
"lights": [
{
"point-light": {
"position": [1, 6.9, -4.9],
"intensity": [1, 1, 1]

}
}
],
"objects": [
{
"type": { "plane": {} },
"material": {
"pattern": {
"type": {
"checkers": [
{ "type": { "solid": [0.5, 0.5, 0.5] } },
{ "type": { "solid": [0.75, 0.75, 0.75] } }
]
},
"transform": [
{ "scale": [0.25, 0.25, 0.25] },
{ "rotate-y": 0.3 }
]
},
"ambient": 0.2,
"diffuse": 0.9,
"specular": 0
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.75, "closed": true } },
"transform": [
{ "scale": [0.5, 1, 0.5] },
{ "translate": [-1, 0, 1] }
],
"material": {
"pattern": { "type": { "solid": [0, 0, 0.6] } },
"diffuse": 0.1,
"specular": 0.9,
"shininess": 300,
"reflective": 0.9
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.2, "closed": false } },
"transform": [
{ "scale": [0.8, 1, 0.8] },
{ "translate": [1, 0, 0] }
],
"material": {
"pattern": { "type": { "solid": [1, 1, 0.3] } },
"ambient": 0.1,
"diffuse": 0.8,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.3, "closed": false } },
"transform": [
{ "scale": [0.6, 1, 0.6] },
{ "translate": [1, 0, 0] }
],
"material": {
"pattern": { "type": { "solid": [1, 0.9, 0.4] } },
"ambient": 0.1,
"diffuse": 0.8,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.4, "closed": false } },
"transform": [
{ "scale": [0.4, 1, 0.4] },
{ "translate": [1, 0, 0] }
],
"material": {
"pattern": { "type": { "solid": [1, 0.8, 0.5] } },
"ambient": 0.1,
"diffuse": 0.8,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.5, "closed": true } },
"transform": [
{ "scale": [0.2, 1, 0.2] },
{ "translate": [1, 0, 0] }
],
"material": {
"pattern": { "type": { "solid": [1, 0.7, 0.6] } },
"ambient": 0.1,
"diffuse": 0.8,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.3, "closed": true } },
"transform": [
{ "scale": [0.05, 1, 0.05] },
{ "translate": [0, 0, -0.75] }
],
"material": {
"pattern": { "type": { "solid": [1, 0, 0] } },
"ambient": 0.1,
"diffuse": 0.9,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.3, "closed": true } },
"transform": [
{ "scale": [0.05, 1, 0.05] },
{ "translate": [0, 0, 1.5] },
{ "rotate-y": -0.15},
{ "translate": [0, 0, -2.25] }
],
"material": {
"pattern": { "type": { "solid": [1, 1, 0] } },
"ambient": 0.1,
"diffuse": 0.9,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.3, "closed": true } },
"transform": [
{ "scale": [0.05, 1, 0.05] },
{ "translate": [0, 0, 1.5] },
{ "rotate-y": -0.3},
{ "translate": [0, 0, -2.25] }
],
"material": {
"pattern": { "type": { "solid": [0, 1, 0] } },
"ambient": 0.1,
"diffuse": 0.9,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0, "max": 0.3, "closed": true } },
"transform": [
{ "scale": [0.05, 1, 0.05] },
{ "translate": [0, 0, 1.5] },
{ "rotate-y": -0.45},
{ "translate": [0, 0, -2.25] }
],
"material": {
"pattern": { "type": { "solid": [0, 1, 1] } },
"ambient": 0.1,
"diffuse": 0.9,
"specular": 0.9,
"shininess": 300
}
},
{
"type": { "cylinder": { "min": 0.0001, "max": 0.5, "closed": true } },
"transform": [
{ "scale": [0.33, 1, 0.33] },
{ "translate": [0, 0, -1.5] }
],
"material": {
"pattern": { "type": { "solid": [0.25, 0, 0] } },
"diffuse": 0.1,
"specular": 0.9,
"shininess": 300,
"reflective": 0.9,
"transparency": 0.9,
"refractive-index": 1.5
}
}
]
}
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<div id="header-title">The Ray Tracer Challenge <span style="color: #f7a41e">(in Zig)</span></div>
<div id="scene-choices" class="select">
<select id="standard-select">
<option value="cylinders.json">Cylinders</option>
<option value="cubes.json">Cubes</option>
<option value="cover.json">Cover Scene</option>
<option value="ch11_reflection_and_refraction.json">
Expand Down
2 changes: 1 addition & 1 deletion www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const render = () => {
const wasm_initialized = window.performance.now();
console.log(`WASM initialized in ${wasm_initialized - start}ms`);

const default_scene = await fetch("cubes.json").then((r) => r.text());
const default_scene = await fetch("cylinders.json").then((r) => r.text());

editor.setValue(default_scene);
editor.clearSelection();
Expand Down

0 comments on commit 4bc6e61

Please sign in to comment.