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

              
                <script src="https://lopez-creative.com/threejs/Three.js"></script>
<script src="https://lopez-creative.com/threejs/examples/js/controls/OrbitControls.js"></script>
<script src="https://lopez-creative.com/threejs/examples/js/loaders/DRACOLoader.js"></script>
<script src="https://lopez-creative.com/threejs/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://lopez-creative.com/threejs/examples/js/utils/SceneUtils.js"></script>
<link href="https://fonts.googleapis.com/css?family=Libre+Franklin&display=swap" rel="stylesheet">


<doctype html>
  <body>
    <div id='cameraContainer'></div>
    <div class="page-title-container">
      <h1 class="page-title">
        <span>Bob</span> <span>Barker</span>
      </h1>
    </div>
  </body>
</html>
              
            
!

CSS

              
                body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ff502e;
}

#cameraContainer {
  opacity: 0;
  -webkit-transition: opacity 1s ease-in;
  -moz-transition: opacity 1s ease-in;
  -ms-transition: opacity 1s ease-in;
  -o-transition: opacity 1s ease-in;
  transition: opacity 1s ease-in;
}
#cameraContainer.loaded {
  opacity: 1;
}

.page-title-container {
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 2.5vw;
}

.page-title-container .page-title {
  color: #fff;
  font-size: 25vh;
  text-transform: uppercase;
  font-family: "Libre Franklin", sans-serif;
}

.page-title-container .page-title span {
  display: block;
}

              
            
!

JS

              
                var container;
var camera, controls, scene;
var oldObject;
var newObject;
var renderer;

var mouseX = 0;
var mouseY = 0;
var targetX = 0;
var targetY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;

init();
animate();

function init() {
  container = document.getElementById("cameraContainer");
  scene = new THREE.Scene();

  renderer = new THREE.WebGLRenderer();
  renderer.setSize(window.innerWidth, window.innerHeight);
  renderer.setClearColor(0xff502e);
  container.appendChild(renderer.domElement);

  camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 100);
  // camera.position.set(0, 0, 5);
  camera.position.set(-5, 10, 42);

  document.addEventListener("mousemove", onDocumentMouseMove, false);
  window.addEventListener("resize", onWindowResize, false);
} 

var dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( "https://lopez-creative.com/threejs/examples/js/loaders/" );
dracoLoader.setDecoderConfig({ type: "js" });

var loader = new THREE.GLTFLoader();
loader.crossOrigin = true;
loader.setDRACOLoader(dracoLoader);
loader.load("https://lopez-creative.com/models/camera3-draco.glb", function( gltf ) {
  var objectScene = gltf.scene;
  var objectGroup = gltf.scene.children[0];
  console.log(gltf);
  
  var objectGroupBase = objectGroup.clone();
  objectGroupBase.traverse(node => {
    if (!node.isMesh) return;
     node.material = new THREE.MeshBasicMaterial({ color: 0xff502e });
  })
  
  objectGroup.traverse(node => {
    if (!node.isMesh) return;
     node.material = new THREE.MeshBasicMaterial({
      color: 0x000000,
      wireframe: true,
      transparent: true,
      opacity: 0.15
    });
  });

  objectGroupBase.rotation.x = Math.PI / 2;
  objectGroupBase.rotation.y = 0;
  objectGroupBase.rotation.z = Math.PI / 2;
  
  objectGroup.rotation.x = Math.PI / 2;
  objectGroup.rotation.y = 0;
  objectGroup.rotation.z = Math.PI / 2;

  newObject = new THREE.Object3D();
  newObject.rotation.x = -5;
  newObject.add(objectGroup);
  newObject.add(objectGroupBase);
  
  scene.add(newObject);
});

function render() {
  targetX = mouseX * 0.001;
  targetY = mouseY * 0.001;

  if (newObject) {
    newObject.rotation.y += 0.05 * (targetX - newObject.rotation.y);
    newObject.rotation.x += 0.05 * (targetY - newObject.rotation.x);
  }

  renderer.render(scene, camera);
}

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

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;
  mouseY = event.clientY - windowHalfY;
}

THREE.DefaultLoadingManager.onLoad = function() {
  console.log("Loading Complete!");
  container.classList.add("loaded");
};
              
            
!
999px

Console