Hi everyone
Super newbie to Three.js. I have followed a tutorial instructions to the letter but the cube is not rendering on the screen. Please can someone have a look at my code and see where the problem is.
I have no idea how to debug because the html simply displays as <canvas> in the console.
Thank you
import * as THREE from “three”;
let renderer, camera, container, scene;
window.addEventListener(“load”, function () {
start();
});
async function start() {
renderer = new THREE.WebGL1Renderer({ antialias: true });
renderer.setSize(window.innerHeight, window.innerWidth);
container = document.getElementById(“threejsContainer”);
container.appendChild(renderer.domElement);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(
60, window.innerHeight, window.innerWidth, 0.1, 1000,);
camera.position.z = 5000;
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0xffff });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
renderer.render(scene, camera);
console.log(scene, camera, renderer);
}
