Pen Settings

HTML

CSS

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

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

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

              
                
              
            
!

CSS

              
                body {
  background: black;
  color: white;
  font-family: arial;
  font-size: 14px;
  margin: 0px;
  overflow: hidden;
}
              
            
!

JS

              
                
var container;
var camera, scene, renderer;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;

init();
animate();

function init() {
  container = document.createElement('div');
  document.body.appendChild(container);

  camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 2000);
  camera.position.z = 100;

  scene = new THREE.Scene();

  var ambient = new THREE.AmbientLight(0);//0xbbbbbb);
  scene.add(ambient);

  var directionalLight = new THREE.DirectionalLight(0xdddddd);
  directionalLight.position.set(0, 25, 50);
  directionalLight.castShadow = true;    
  scene.add(directionalLight);

  var directionalLight2 = new THREE.DirectionalLight(0xc04040);
  directionalLight2.position.set(-25, -25, -25);
  directionalLight2.castShadow = true;
  scene.add(directionalLight2);

  /*
  var helper = new THREE.DirectionalLightHelper(directionalLight, 50);
  scene.add(helper);
  var helper1 = new THREE.DirectionalLightHelper(directionalLight2, 50);
  scene.add(helper1);
*/
  
  var onError = function(xhr) {};
  var mtlLoader = new THREE.MTLLoader();
  //mtlLoader.setTexturePath("https://untamed.zone/miscFolder/Elite/Cobra3/");
  //mtlLoader.setCrossOrigin(true);
  mtlLoader.load("https://untamed.zone/miscFolder/Elite/Cobra3/oolite_cobra3.mtl.txt", function (materials) {
    materials.preload();
    var textureLoader = new THREE.TextureLoader();
    textureLoader.setCrossOrigin(true);
    textureLoader.load("https://untamed.zone/miscFolder/Elite/Cobra3/oolite_cobra3_emissive.png", function ( texture ) {
      materials.materials.Hull.emissiveMap = texture;
      materials.materials.Hull.emissiveIntensity = 8;
      materials.materials.Hull.emissive = new THREE.Color(.1, .3, 1);
      var objLoader = new THREE.OBJLoader();
      objLoader.setMaterials(materials);
      objLoader.load("https://untamed.zone/miscFolder/Elite/Cobra3/oolite_cobra3.obj", function (meshObject) {
        meshObject.scale.x = 1;
        meshObject.scale.y = 1;
        meshObject.scale.z = 1;
        meshObject.rotation.y = 3;
        meshObject.position.y = -10.5;
        meshObject.castShadow = true;
        meshObject.receiveShadow = true;
        scene.add(meshObject); 

      });

    });
  });



  renderer = new THREE.WebGLRenderer({ alpha: true });
  renderer.setPixelRatio(window.devicePixelRatio);
  renderer.setSize(window.innerWidth, window.innerHeight);
  container.appendChild(renderer.domElement);

  document.addEventListener('mousemove', onDocumentMouseMove, false);

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

}

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

function onDocumentMouseMove(event) {
  mouseX = (event.clientX - windowHalfX) / 2;
  mouseY = (event.clientY - windowHalfY) / 2;
}

function animate() {
  requestAnimationFrame(animate);
  render();
}

function render() {
  camera.position.x += (mouseX - camera.position.x) * .05;
  camera.position.y += (-mouseY - camera.position.y) * .05;
  camera.lookAt(scene.position);
  renderer.render(scene, camera);
}
              
            
!
999px

Console