File size: 1,297 Bytes
7dc9c15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php
 $id = $_GET['id'];

 // Load the story data
 $story = json_decode(file_get_contents("stories/".$id .".json"), true);

 // Create a new Three.js scene
 const scene = new THREE.Scene();
 // Create a new Three.js camera and set its position
 const camera = new THREE.PerspectiveCamera(100, window.innerWidth / window.innerHeight, 0.1, 1000);
 camera.position.set(0, 0, 50);

 // Add a Three.js directional light to the scene
 const light = new THREE.DirectionalLight(0xffffff, 1);
 light.position.set(1, 1, 1);
 scene.add(light);

 // Add a Three.js wireframe geometry to the scene
 const geometry = new THREE.BoxGeometry(10, 10, 10);
 const material = new THREE.MeshBasicMaterial({ color: 0xCFCFCF });
 const cube = new THREE.Mesh(geometry, material);
 scene.add(cube);

 // Set the renderer and add it to the HTML body
 const renderer = new THREE.WebGLRenderer({
    canvas: document.querySelector('#c'),
    antialias: true
 });
 renderer.setSize(window.innerWidth, window.innerHeight);
 document.body.appendChild(renderer.domElement);

 // Game loop
 function animate() {
    requestAnimationFrame(animate);

    // Update the Three.js camera position
    camera.position.x += 0.05;
    camera.position.y += 0.05;

    // Render the scene
    renderer.render(scene, camera);
 }
 animate();