Three JS es una libreria para desplegar 3d por medio del navegador.
La forma de estructura un documento básico es esta:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="vieport" content="width=device-with, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie-edge" />
<title>A ver si ya con esta</title>
<style>
body {
margin: 0;
}
canvas{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r119/three.js"></script>
<script src="main01.js"></script>
</body>
</html>
y el archivo main01.js debe quedar de la siguiente manera
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth/window.innerHeight,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
Y este es el resultado.
0 comentarios