sf-9a1 / game.php
kemsa51's picture
Add 4 files
7dc9c15 verified
<?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();