Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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

              
                <!-- Code forked from https://codepen.io/wrtchd/pen/YXGKrB -->
              
            
!

CSS

              
                body {
    overflow: hidden;
    background-color: #c33;
}

* { margin:0; padding:0; }
              
            
!

JS

              
                var init = function() {

    var width = 500,
        height = 400;

    //create scene w/ fog
    var scene = new THREE.Scene();
    // scene.fog = new THREE.FogExp2(0xffffff, 0.1); // (color, density)
    // scene.background = new THREE.Color( 0x00FFFFFF );


    //create geometry using simplex noise 
    var geometry = new THREE.PlaneGeometry(3, 1, width - 1, height - 1), // (width, height, widthSegments, heightSegments)
        simplexNoise = new SimplexNoise(),
        octaves = 4,
        persistence = 2,
        frequency,
        amplitude,
        totalAmplitude,
        noise;
    
    for (var x = 0; x < width; x++) {
        for (var y = 0; y < height; y++) {
            noise = 0;
            frequency = 10;
            amplitude = 0.125;
            totalAmplitude = 1;
            for (var i = 0; i < octaves; i++) {
                noise += (simplexNoise.noise2D(x / frequency, y / frequency) / 3 + 0.5) * amplitude;
                totalAmplitude += amplitude;
                amplitude *= persistence;
                frequency *= (i === 0) ? 3 : 2;
            }
            noise /= totalAmplitude;
            geometry.vertices[x + y * width].z += (noise - 0.5) * 3;
        }
    } //*/

    /*
    //create random geometry
    var geometry = new THREE.PlaneGeometry(500, 500, 97, 97); // (width, height, widthSegments, heightSegments)
    for (var i = 0; i < geometry.vertices.length; i++) {
        geometry.vertices[i].x += ((Math.random() > 0.5) ? 1 : -1) * Math.random() * 1.5;// random(-1.5, 1.5) x
        geometry.vertices[i].y += ((Math.random() > 0.5) ? 1 : -1) * Math.random() * 1.5;// random(-1.5, 1.5) y
        geometry.vertices[i].z += ((Math.random() > 0.5) ? 1 : -1) * Math.random() * 2.0;// random(-2.0, 2.0) z
    }//*/

    /*
	//alternate random geometry using PlaneBufferGeometry
    var geometry = new THREE.PlaneBufferGeometry(500, 500, 75, 75);
    var defaultVertices = geometry.attributes.position.clone().array;
    var vertices = geometry.attributes.position.array;
    for (var i = 0; i <= vertices.length; i += 3) {
        vertices[i] = defaultVertices[i] + (Math.random() * 1.43 * ((Math.random() > 0.5) ? 1 : -1));//x
        vertices[i + 1] = defaultVertices[i + 1] + (Math.random() * 1.43 * ((Math.random() > 0.5) ? 1 : -1));//y
        vertices[i + 2] = defaultVertices[i + 2] + Math.random() * 4.43 * ((Math.random() > 0.5) ? 1 : -1);//z
    }//*/
    geometry.dynamic = true;
    geometry.verticesNeedUpdate = true;
    geometry.computeFaceNormals();
    geometry.computeVertexNormals();
    geometry.normalsNeedUpdate = true;

    //create face coloring
    for (i = 0; i < geometry.faces.length; i++) {
        var color;
        if (geometry.vertices[geometry.faces[i].a].z >= 0)
            // color = 0xd4ad97;
            color = 0x000000;
        else if (geometry.vertices[geometry.faces[i].a].z >= -0.3)
            color = 0x000000;
        else if (geometry.vertices[geometry.faces[i].a].z >= -0.5)
            color = 0x000000;
        else if (geometry.vertices[geometry.faces[i].a].z >= -0.65)
            color = 0x000000;
        else
            color = 0x000000;
        /*if (geometry.vertices[geometry.faces[i].a].z >= 0.45)
            color = 0xd4ad97;
        else if (geometry.vertices[geometry.faces[i].a].z >= 0.3)
            color = 0xc28c6e;
        else if (geometry.vertices[geometry.faces[i].a].z >= 0)
            color = 0xa95c30;
        else if (geometry.vertices[geometry.faces[i].a].z >= -0.3)
            color = 0x764021;
        else
            color = 0x542e18;*/
        if (geometry.faces[i] instanceof THREE.Face4) {
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
        } else if (geometry.faces[i] instanceof THREE.Face3) {
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
            geometry.faces[i].vertexColors.push(new THREE.Color(color));
        }
    }
    geometry.colorsNeedUpdate = true; //*/

    //create material
    var material = new THREE.MeshLambertMaterial({
        vertexColors: THREE.VertexColors,
        shading: THREE.FlatShading,
        wireframe: true
    });

    //apply material to geometry
    var mesh = new THREE.Mesh(geometry, material);
    mesh.scale.set(3, 3, 0.4)
    mesh.scale.multiplyScalar(10);

    //create lighting
    // var ambientLight = new THREE.AmbientLight(0xa95c30); // (color)
  var ambientLight = new THREE.AmbientLight(0x000000); // (color)
    var primaryLight = new THREE.DirectionalLight(0x000000, 0.325); // (color, intensity)
    primaryLight.position.set(2, 10, 10);
    var secondaryLight = new THREE.DirectionalLight(0x000000, 0.325); // (color, intensity)
    secondaryLight.position.set(-2, 0, 10);

    //create camera
    var camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1500); // (fov, aspect, near, far)
    camera.quaternion.x = 84 * Math.PI / 180;
    camera.position.set(0, -10, 1);
    //camera.lookAt(mesh.position);

    //add objects to scene
    scene.add(mesh);
    scene.add(ambientLight);
    scene.add(primaryLight);
    scene.add(secondaryLight);
    scene.add(camera);

    //create renderer
    var renderer = new THREE.WebGLRenderer({
        antialiase: true,
        alpha: true
    });
    renderer.setClearColor( 0x000000, 0 );
    renderer.setSize(window.innerWidth, window.innerHeight);
    renderer.domElement.id = 'homepage-bg';
    document.body.appendChild(renderer.domElement);

    //create stats
    // stats = new Stats();
    // stats.setMode(0); // 0: fps, 1: ms
    // stats.domElement.style.position = 'absolute';
    // stats.domElement.style.top = '0px';
    // stats.domElement.style.right = '0px';
    // document.body.appendChild(stats.domElement); //*/
       
    //create user controls
    controls = new THREE.OrbitControls(camera);
    controls.autoRotate = true;
    controls.enabled = false;
    controls.minPolarAngle = 90 * Math.PI / 180;
	controls.maxPolarAngle = 210 * Math.PI / 180;
    controls.minAzimuthAngle = 0;
	controls.maxAzimuthAngle = 0;
    // controls.panSpeed = 2;
    // controls.rotateSpeed = 3;
    // controls.autoRotateSpeed = 6.0;
    controls.noKeys = true;
    document.body.addEventListener("mousedown", function(e) {
       // controls.enabled = true;
    });
    document.body.addEventListener("mouseup", function(e) {
       // controls.enabled = false;
    });//*/

    var render = function() {

        //rotate terrain: changing 0.2 to any other value defines speed of rotation
        mesh.rotation.z -= 0.2 * Math.PI / 180;

        renderer.render(scene, camera);
    };

    //animation loop
    var animate = function() {

        requestAnimationFrame(animate);

        render();
        // stats.update();
    };

    //handle resizing
    window.addEventListener('resize', onWindowResize, false);

    function onWindowResize() {
        camera.aspect = window.innerWidth / window.innerHeight;
        camera.updateProjectionMatrix();
        renderer.setSize(window.innerWidth, window.innerHeight);
    }

    animate();

}();
              
            
!
999px

Console