Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <html lang="en">

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>THREE Example</title>
  <link rel="stylesheet" href="src/main.css">

  <p><a href="">"Low Poly Medieval Island"</a> by <a href="">Boooooop</a> is licensed under Creative Commons Attribution. To view a copy of this license, visit <a href=""></a>.</p>

  <div id="container"></div>
  <script type="module" src="src/main.js"></script>



body {
  margin: 0;
  padding: 0;
  background: #3b3b3b;
html {
  overflow: hidden;
p {
  color: white;
  position: absolute;
  bottom: 0;  
  margin: 10px auto;
  width: 100%;
  left: 0;
  right: 0;
  text-align: center;
  color: white;



                import * as THREE from "";
import { GLTFLoader } from "";
import { OrbitControls } from "";

Scene and Camera Setup
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
    25, // FOV (field of view) in Grad
    window.innerWidth / window.innerHeight, // Verhältnis des render context
    0.1, // near - Objekte mit einer kleineren Distanz als dieser Wert werden nicht angezeigt
    1000 // far - Objekte mit einer größeren Distanz als dieser Wert werden nicht angezeigt

Renderer setup
const renderer = new THREE.WebGLRenderer(); // ein von THREE.js erzeugtes <canvas> Element
renderer.setSize(window.innerWidth, window.innerHeight); // Größe des Canvas
scene.background = new THREE.Color(0x20252f); //Setting the canvas background-color
camera.position.z = 70; // Die Position der Kamera muss angepasst werden, damit die Objekte zu sehen sind

Loader setup
const loader = new GLTFLoader();
loader.load(    "",
    function (gltf) {
    // called while loading is progressing
    function (xhr) {
        console.log((xhr.loaded / * 100 + "% loaded");
    // called when loading has errors
    function (error) {
        console.log("An error happened!");

Light setup
const ambientLight = new THREE.AmbientLight(0xcccccc, 0.6);

const pointLight = new THREE.PointLight(0xffffcc, 2, 100);
pointLight.position.set(0, 10, 0);
pointLight.castShadow = true; = 1; = 60;
pointLight.shadow.bias = -0.005;


const sphereSize = 1;
const pointLightHelper = new THREE.PointLightHelper(pointLight, sphereSize);

Control Setup
const controls = new OrbitControls(camera, renderer.domElement);
controls.minDistance = 50;
controls.maxDistance = 150;
controls.enableDamping = true;

Render Loop
function draw() {

    renderer.render(scene, camera);