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 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

              
                

<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r124/three.min.js"></script>
<script src="https://unpkg.com/three@0.126.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src ="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.6.0/gsap.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.6.0/ScrollTrigger.min.js"></script>
              
            
!

CSS

              
                body {
  font-family: Monospace;
  background: #222;
  color: #fff;
  margin: 0px;
}
h3 {
  font-weight: normal;
}
#info {
  color: #fff;
  position: absolute;
  top: 10px;
  width: 100%;
  text-align: center;
  z-index: 100;
  display: block;
}
#info a {
  color: #75ddc1;
  font-weight: bold;
}

              
            
!

JS

              
                 //===================================================== canvas
  var renderer = new THREE.WebGLRenderer({ alpha: true, antialiase: true });
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement);

  //===================================================== scene
  var scene = new THREE.Scene();

  //===================================================== camera
  var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000);
  camera.position.z = 5;
  camera.position.y = 1.5;

  //===================================================== lights
  var light = new THREE.DirectionalLight(0xefefff, 3);
  light.position.set(1, 1, 1).normalize();
  scene.add(light);
  var light = new THREE.DirectionalLight(0xffefef, 3);
  light.position.set(-1, -1, -1).normalize();
  scene.add(light);

  //===================================================== resize
  window.addEventListener("resize", function() {
    let width = window.innerWidth;
    let height = window.innerHeight;
    renderer.setSize(width, height);
    camera.aspect = width / height;
    camera.updateProjectionMatrix();
  });


  //===================================================== model
  var loader = new THREE.GLTFLoader();
  var mixer;
  var model;
  loader.load(
    "https://raw.githubusercontent.com/baronwatts/models/master/robber.glb", function(gltf) {

       gltf.scene.traverse( function( node ) {
          if ( node instanceof THREE.Mesh ) { 
            node.castShadow = true; 
            node.material.side = THREE.DoubleSide;
          }
        });

       
      model = gltf.scene;
      model.scale.set(.35,.35,.35);
      scene.add(model);

      mixer = new THREE.AnimationMixer(model);
      mixer.clipAction(gltf.animations[1]).play();

 
 
  });



var clock = new THREE.Clock();
function render() {
  requestAnimationFrame(render);
  var delta = clock.getDelta();
  if (mixer != null) mixer.update(delta);
  if (model) model.rotation.y += 0.025;

  renderer.render(scene, camera);
}

render();
gsap.registerPlugin(ScrollTrigger);
   let scrollingTL = gsap.timeline({
            scrollTrigger: {
                trigger: renderer.domElement,
                start: 'top top',
                end: '+=500%',
                pin: true,
                scrub: true,
                onUpdate: function () {
                    camera.updateProjectionMatrix();
                }
            },
        })

        scrollingTL
            .to(camera.position, {
                x: 3,
                ease: 'ease:Circ.easeOut',
            }, 0)

              
            
!
999px

Console