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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                	<title> Our WebGL Skeleton Framework</title>

	<style>
	
		body{
			margin:0;
			overflow:hidden;
			
		}
	</style>
	
	<body>
	
		<div id ="webGL-container">
		</div>
		
		
	</body>
              
            
!

CSS

              
                
              
            
!

JS

              
                $(function() {

  /*global variables*/
  var scene, camera, renderer;
  var controls, guiControls, datGUI;
  var stats;
  var SCREEN_WIDTH, SCREEN_HEIGHT;
  var map, tex, spr, geom, composer, effect, clock;
  var newVal = 1;

  function init() {
    /*creates empty scene object and renderer*/
    scene = new THREE.Scene();
    camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, .1, 20000);
    renderer = new THREE.WebGLRenderer({
      antialias: true
    });

    renderer.setClearColor(0x000000);
    renderer.setSize(window.innerWidth, window.innerHeight);
    renderer.shadowMapEnabled = false;
    renderer.shadowMapSoft = false;

    /*add controls*/
    controls = new THREE.OrbitControls(camera, renderer.domElement);
    controls.addEventListener('change', render);

    camera.position.x = -67;
    camera.position.y = -32;
    camera.position.z = -227;
    camera.lookAt(scene.position);

    /*datGUI controls object*/
    guiControls = new function() {
      this.SceneToConsole = function() {
        console.log(scene);
        console.log(camera.position.x + " X Position");
        console.log(camera.position.y + " Y Position");
        console.log(camera.position.z + " Z Position");
      };

      this.nIntensity = 10.0;
      this.sIntensity = 0.65;
      this.sCount = 4096;
      this.grayscale = 0.9;

    }

    /*adds controls to scene*/
    datGUI = new dat.GUI();
    datGUI.add(guiControls, 'SceneToConsole');
    datGUI.add(guiControls, 'nIntensity', 0.0, 10.0)
    datGUI.add(guiControls, 'sIntensity', 0.0, 10.0)
    datGUI.add(guiControls, 'sCount', 0, 8192)
    datGUI.add(guiControls, 'grayscale', 0.0, 1.0)
    datGUI.close();

    geom = new THREE.Geometry();
    createVertCloud(geom);
    createPartCloud(geom);

    createSky();

    var loader = new THREE.ObjectLoader();
    loader.load("https://cdn.rawgit.com/wpdildine/wpdildine.github.com/master/models/space_scene.json", function(obj) {
      scene.add(obj);
    });

    var pointLight = new THREE.PointLight(0x999980, 1, 0);
    pointLight.position.set(-250, 500, -250);
    scene.add(pointLight);

    //post processing effects
    composer = new THREE.EffectComposer(renderer);
    composer.addPass(new THREE.RenderPass(scene, camera));

    effect = new THREE.ShaderPass(THREE.FilmShader);
    effect.uniforms['time'].value = 0.0;
    effect.uniforms['nIntensity'].value = guiControls.nIntensity;
    effect.uniforms['sIntensity'].value = guiControls.sIntensity;
    effect.uniforms['sCount'].value = guiControls.sCount;
    effect.uniforms['grayscale'].value = guiControls.grayscale;

    composer.addPass(effect);

    var effect1 = new THREE.ShaderPass(THREE.RGBShiftShader);
    effect1.uniforms['amount'].value = 0.0015;
    effect1.renderToScreen = true;
    composer.addPass(effect1);

    //add a timer
    clock = new THREE.Clock;

    $("#webGL-container").append(renderer.domElement);
    /*stats*/
    stats = new Stats();
    stats.domElement.style.position = 'absolute';
    stats.domElement.style.left = '0px';
    stats.domElement.style.top = '0px';
    $("#webGL-container").append(stats.domElement);

  }

  function createVertCloud(emptyGeo) {

    for (i = 0; i < 10000; i++) {

      this.verts = new THREE.Vector3();

      verts.x = Math.random() * 3000 - 1500;
      verts.y = Math.random() * 3000 - 1500;
      verts.z = Math.random() * 3000 - 1500;

      emptyGeo.vertices.push(verts);

    }

  }

  function createPartCloud(geo) {

THREE.ImageUtils.crossOrigin = '';
        tex = THREE.ImageUtils.loadTexture("http://crossorigin.me/http://i.imgur.com/rylmFFe.png");

    mat = new THREE.PointCloudMaterial({
      size: 5,
      map: tex,
      transparent: true,
      opacity: 1,
      blending: "AdditiveBlending"
    });

    var particles = new THREE.PointCloud(geo, mat);

    scene.add(particles);

  }

  function createSky() {

    var imageList = ""
      // 1 / 2 / 3 / 4 /5 /6 
    THREE.ImageUtils.crossOrigin = '';
    var faces = ["http://crossorigin.me/http://i.imgur.com/I1spdOv", "http://crossorigin.me/http://i.imgur.com/PqXqIUX", "http://crossorigin.me/http://i.imgur.com/zUrvtzN", "http://crossorigin.me/http://i.imgur.com/59isRnE", "http://crossorigin.me/http://i.imgur.com/Fgid82j", "http://crossorigin.me/http://i.imgur.com/INDuPnF"]; // from blender 1-6
    var imgType = ".png";
    var skyGeo = new THREE.BoxGeometry(5000, 5000, 5000);
    var matFacesArray = [];

    for (var i = 0; i < 6; i++) {
      matFacesArray.push(new THREE.MeshBasicMaterial({
        map: THREE.ImageUtils.loadTexture(imageList + faces[i] + imgType),
        side: THREE.BackSide
      }));

    }

    var sky = new THREE.MeshFaceMaterial(matFacesArray);
    skyBox = new THREE.Mesh(skyGeo, sky);

    scene.add(skyBox);

  }

  var sizeTracker = 1;
  var direction = 1;
  //update pointcloud animation

  function updateSize() {
    sizeTracker += direction;
    direction *= (((sizeTracker % 100) == 0) ? -1 : 1);
    mat.size = sizeTracker / 50;

  }

  //animation speed function
  var frameRate = 15;
  var curTime;
  var oldTime = Date.now();
  var interval = 1000 / frameRate;
  var delta;

  function refRate() {

    curTime = Date.now();
    delta = curTime - oldTime;

    if (delta > interval) {
      oldTime = curTime - (delta % interval);
      updateSize();
    }

  }

  //stopped rotation on cube
  function sceneRotate() {
    scene.traverse(function(child) {
      if (child instanceof THREE.Mesh && child.id != "4") {
        child.rotation.z += .0001;
      }
    });
  }

  function render() {
    refRate();
    sceneRotate();

    var change = clock.getDelta();
    effect.uniforms['time'].value = change * 100;
    effect.uniforms['nIntensity'].value = guiControls.nIntensity;
    effect.uniforms['sIntensity'].value = guiControls.sIntensity;
    effect.uniforms['sCount'].value = guiControls.sCount;
    effect.uniforms['grayscale'].value = guiControls.grayscale;
    composer.render();

  }

  function animate() {

    requestAnimationFrame(animate);
    render();
    stats.update();

  }

  init();
  animate();

  $(window).resize(function() {
    SCREEN_WIDTH = window.innerWidth;
    SCREEN_HEIGHT = window.innerHeight;
    camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
    camera.updateProjectionMatrix();
    renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
  });

});
              
            
!
999px

Console