<script type="importmap">
	{
		"imports": {
			"three": "https://unpkg.com/three@0.157.0/build/three.module.js",
			"three/": "https://unpkg.com/three@0.157.0/"
		}
	}
</script>

<canvas id="canvas"></canvas>
body {
	margin: 0;
	overflow: hidden;
}

canvas {display: block}
import * as THREE from 'three'
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js'

const canvas = document.getElementById('canvas')
var renderer = new THREE.WebGLRenderer({
	canvas,
	antialias: true
});

renderer.setClearColor(0x4581b5);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);

var scene = new THREE.Scene();

var camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 3000);
camera.position.set(0, 0, 50);
scene.add(camera);

var light = new THREE.AmbientLight('white', 1.5);
scene.add(light);
var light2 = new THREE.PointLight('white', 1600);
camera.add(light2);

var geometry = new THREE.PlaneGeometry(100, 100);
var material = new THREE.MeshPhysicalMaterial({
	map: new THREE.TextureLoader().load("https://docs.lume.io/textures/stone-brick-wall/diff_2k.jpg"),
	bumpMap: new THREE.TextureLoader().load("https://docs.lume.io/textures/stone-brick-wall/disp_2k.png"),
	roughness: 0.1,
	metalness: 0.2,
	shininess: 5000,
});
var mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);

const controls = new OrbitControls(camera, canvas)

requestAnimationFrame(render);

function render() {
	renderer.render(scene, camera);
	requestAnimationFrame(render);
}

window.addEventListener('resize', onResize, false);

function onResize() {
	//changes the size of the canavs and updates it
	camera.aspect = window.innerWidth / window.innerHeight;
	camera.updateProjectionMatrix();
	renderer.setSize(window.innerWidth, window.innerHeight);
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.