JSFiddle - React, Tailwind, and code Playground

by realhunts

HTML

<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src="https://threejs.org/examples/js/WebGL.js"></script>
<script src="https://stemkoski.github.io/Three.js/js/Stats.js"></script>

JavaScript

// a basic three.js scene

var container, renderer, scene, camera, controls, mesh;
var raycaster = new THREE.Raycaster (), mesh, ground;
var mouse = { x: 0, y: 0, down: false };
const HEIGHT_AMPLIFIER = 1
const SIZE_AMPLIFIER = 1;
var canvas = document.createElement ('canvas');
canvas.width = 156; canvas.height = 156;

var context = canvas.getContext ('2d');
context.rect (0, 0, canvas.width, canvas.height);
context.fillStyle = 'white';
context.fill ();

var texture = new THREE.Texture (canvas);
texture.needsUpdate = true;


                    
  var heightmapImage = new Image();
  heightmapImage.id = "pic"
  heightmapImage.crossOrigin = "Anonymous";
  var heightmapContext;

var helper;

init();
animate();

function init() {

    // renderer
    renderer = new THREE.WebGLRenderer({
        antialias: true
    });
    renderer.setSize(window.innerWidth, window.innerHeight);
    renderer.setClearColor(0xccccff);
    container = document.createElement('div');
    document.body.appendChild(container);
    container.appendChild(renderer.domElement);
// STATS
	stats = new Stats();
	stats.domElement.style.position = 'absolute';
	stats.domElement.style.bottom = '0px';
	stats.domElement.style.zIndex = 100;
	container.appendChild( stats.domElement );
    // scene
    scene = new THREE.Scene();

    // camera
    camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
    camera.position.set(0, 200, 800);
    camera.lookAt(scene.position);

console.log(camera.fov)
    // (camera) controls
    // mouse controls: left button to rotate, 
    //    mouse wheel to zoom, right button to pan
    controls = new THREE.OrbitControls(camera, renderer.domElement);
		controls.enabled = false
    // lights
    var amblight = new THREE.AmbientLight( "gray" ); // soft white light
		scene.add( amblight );

    var light = new THREE.PointLight(0xffffff);
    light.position.set(100, 250, 250);
    scene.add(light);


    var planeGeometry = new...