-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimal-demo.html
56 lines (51 loc) · 1.62 KB
/
minimal-demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>autostereogram renderer - minimal demo</title>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body>
<script type="module">
// import three.js and autostereogram renderer
import * as THREE from "https://threejsfundamentals.org/threejs/resources/threejs/r115/build/three.module.js";
import * as STEREO from "https://flo-bit.github.io/autostereogram-renderer/autostereogram.js";
// create your own three.js renderer, scene and camera and add some objects
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
4
);
// create example mesh
let mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(2.5, 0),
new THREE.MeshStandardMaterial()
);
mesh.position.z = -4;
scene.add(mesh);
// create a new autostereogram renderer, pass the three.js renderer, scene and camera
var stereo = new STEREO.AutostereogramRenderer(renderer, camera, scene);
// render the autostereogram
function render() {
requestAnimationFrame(render);
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.004;
stereo.render();
}
render();
</script>
</body>
</html>