JSFiddle - React, Tailwind, and code Playground

by Paul West

CSS

body {
	margin: 0;
	background-color: #000;
	color: #fff;
	font-family: Monospace;
	font-size: 13px;
	line-height: 24px;
	overscroll-behavior: none;
}

a {
	color: #ff0;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

button {
	cursor: pointer;
	text-transform: uppercase;
}

#info {
	position: absolute;
	top: 0px;
	width: 100%;
	padding: 10px;
	box-sizing: border-box;
	text-align: center;
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
	z-index: 1; /* TODO Solve this in HTML */
}

a, button, input, select {
	pointer-events: auto;
}

.dg.ac {
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	z-index: 2 !important; /* TODO Solve this in HTML */
}

#overlay {
	position: absolute;
	font-size: 16px;
	z-index: 2;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	background: rgba(0,0,0,0.7);
}

	#overlay button {
		background: transparent;
		border: 0;
		border: 1px solid rgb(255, 255, 255);
		border-radius: 4px;
		color: #ffffff;
		padding: 12px 18px;
		text-transform: uppercase;
		cursor: pointer;
	}

#notSupported {
	width: 50%;
	margin: auto;
	background-color: #f00;
	margin-top: 20px;
	padding: 10px;
}

    © 2021 GitHub, Inc.
    Terms
    Privacy
    Security
    Status
    Docs

    Contact GitHub
    Pricing
    API
    Training
    Blog
    About

Loading complete

JavaScript

console.clear();

import * as THREE from "https://cdn.skypack.dev/three@0.135.0/build/three.module.js";
import {
  OrbitControls
} from "https://cdn.skypack.dev/three@0.135.0/examples/jsm/controls/OrbitControls.js";

let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 1, 1000);
camera.position.set(0, 21, 34);
let renderer = new THREE.WebGLRenderer({
  antialias: true
});
renderer.setSize(innerWidth, innerHeight);
renderer.setClearColor(0x202020);
document.body.appendChild(renderer.domElement);

let controls = new OrbitControls(camera, renderer.domElement);

scene.add(new THREE.GridHelper(100, 10));

let shift = new THREE.Vector3()
      	.random()
        .subScalar(0.5)
        .setLength(2 + Math.random() * 4);
let triPts = new Array(3).fill().map(p => {
	return new THREE.Vector3()
  	.random()
    .subScalar(0.5)
    .multiplyScalar(5)
    .add(shift);
})

let points = new THREE.Points(new THREE.BufferGeometry().setFromPoints(triPts), new THREE.PointsMaterial({color: "yellow"}));
scene.add(points);

let tri = new THREE.Triangle(triPts[0], triPts[1], triPts[2]);
let c = new THREE.Vector3();
tri.getMidpoint(c);
let n = new THREE.Vector3();
tri.getNormal(n);

let grid = new THREE.GridHelper(10, 10, "aqua", "magenta");
grid.geometry.rotateX(Math.PI * 0.5);
grid.position.copy(c);
grid.lookAt(c.add(n));
scene.add(grid);

window.addEventListener("resize", onWindowResize);

animate();

function animate() {

  requestAnimationFrame( animate );
  renderer.render(scene, camera);

}

function onWindowResize() {

  camera.aspect = innerWidth / innerHeight;
  camera.updateProjectionMatrix();

  renderer.setSize(innerWidth, innerHeight);

}