Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

online javascript editor, testing javascript online, online ide, online code editor, html, css, coffeescript, scss online editor

HTML
xxxxxxxxxx
 
1
<script src="http://threejs.org/build/three.min.js"></script>
2
<script src="http://threejs.org/examples/js/controls/OrbitControls.js"></script>
3
    JavaScript
    xxxxxxxxxx
    1
    // Isometric Projection using an Orthographic Camera
    2
    // useful:
    3
    // cube with gradients http://jsfiddle.net/FtML5/3/
    4
    // rotating cube http://jsfiddle.net/b45xk38d/1/
    5
    // quad gradient https://jsfiddle.net/eh3k7u93/
    6
    // rgb cube definition https://www.researchgate.net/profile/Zaher_Aghbari/publication/223162168/figure/fig5/AS:305176415096858@1449771135873/Fig-6-The-eight-corners-of-RGB-cube.png
    7
    // previous complex method
    8
    // http://jsfiddle.net/9hhgmpL8/
    9
    // simpler method modified from
    10
    // https://stemkoski.github.io/Three.js/Vertex-Colors.html
    11
    // great examples
    12
    // https://stemkoski.github.io/Three.js/
    13
    var cube, pyramid, renderer, scene, camera;
    14
    15
    var width = 500;
    16
    var height = 500;
    17
    18
    init();
    19
    render();
    20
    animate();
    21
    22
    function init() {
    23
    24
      // renderer
    25
      renderer = new THREE.WebGLRenderer({antialias:true, alpha: true});
    26
      renderer.setSize(width, height);
    27
      document.body.appendChild( renderer.domElement );
    28
    29
      // scene
    30
      scene = new THREE.Scene();
    31
    32
      
    33
      // axes
    34
      scene.add( new THREE.AxisHelper( 20 ) );
    35
    36
      // camera
    37
      var aspect = width / height;
    38
      var d = 15;
    39
      camera = new THREE.OrthographicCamera( - d * aspect, d * aspect, d, - d, 1, 1000 );
    40
      camera.position.set( d, d, d );
    41
      camera.lookAt( scene.position );
    42
      
    43
            // camera = new THREE.PerspectiveCamera(50, 1, 1, 1000 );
    44
            // camera.position.y = 20;
    45
            // camera.position.z = 20;
    46
    47
      
    48
      
    49
      controls = new THREE.OrbitControls( camera );
    50
      controls.minDistance = 10;
    51
      controls.maxDistance = 50;
    52
    53
      pyramid = coloredPyramid();
      CSS
      xxxxxxxxxx
       
      1
      body {
      2
        background-color: #000;
      3
        margin: 0px;
      4
        overflow: hidden;
      5
      }
      6

        Language

        Doctype

        Body tag

        Language

        Frameworks & Extensions

        Load type

        Framework <script> attribute

        Language

        Options