Skip to content

Instantly share code, notes, and snippets.

@essingen123
Created October 2, 2019 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save essingen123/32c6f544de1555acdd496d477ed77052 to your computer and use it in GitHub Desktop.
Save essingen123/32c6f544de1555acdd496d477ed77052 to your computer and use it in GitHub Desktop.
nested simulations
<canvas></canvas>
<!-- Click to generate a new image -->

nested simulations

Even if we are a simulated reality, there is no way to be sure the beings running the simulation are not themselves a simulation, and the operators of that simulation are not a simulation. - David Deutsch

A Pen by Karl Lindberg on CodePen.

License.

"use strict";
{
const code = {
setup() {
this.render({
startShape: 'WHOLE',
transform: {s: 4, b: 0.7},
background: '#333',
minSize: 0.2,
fov: 60,
camDist: 8,
lightPosition: [0.0, 0.0, -8.0],
ambientColor: [0.12, 0.12, 0.12],
specularColor: [1.5, 1.0, 0.25],
diffuseColor: [0.25, 0.5, 1.2],
shininess: 6
});
},
rules() {
return {
WHOLE: s => {
this.QUAD(s, {x: -0.5, y: -0.5, z: -0.5});
this.QUAD(s, {x: 0.5, y: -0.5, z: -0.5});
this.QUAD(s, {x: -0.5, y: 0.5, z: -0.5});
this.QUAD(s, {x: 0.5, y: 0.5, z: -0.5});
this.QUAD(s, {x: -0.5, y: -0.5, z: 0.5});
this.QUAD(s, {x: 0.5, y: -0.5, z: 0.5});
this.QUAD(s, {x: -0.5, y: 0.5, z: 0.5});
//this.QUAD(s, {x: 0.5, y: 0.5, z: 0.5});
},
QUAD: [
1, s => {
this.CUBE(s, {ry: this.randpos([0, 90])});
},
5, s => {
this.WHOLE(s, {s: 0.45});
},
0.5, s => {}
]
};
}
};
// import cfdg library
cfdg.apply(code);
// run code
code.setup();
// Click canvas to generate a new image
["click", "touchdown"].forEach(event => {
document.addEventListener(event, e => code.setup(), false);
});
}
<script src="https://codepen.io/ge1doot/pen/rdwPLr/"></script>
html, body {
overflow: hidden;
touch-action: none;
position: absolute;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: #000;
}
canvas {
position: absolute;
width: 100%;
height: 100%;
user-select: none;
cursor: pointer;
background: #000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment