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

              
                <div class="section section-00"></div>
<div class="section section-01"></div>
<div class="section section-02"></div>
<div class="section"></div>
              
            
!

CSS

              
                body{margin: 0; padding: 0;}

canvas{display: block; width: 100%; height: 100vh; position: fixed; top: 0; left: 0; z-index: -1;}

.section{display: block; width: 100%; height: 100vh; border-bottom: 1px solid rgba(0,0,0,0.8);}
              
            
!

JS

              
                	gsap.registerPlugin(ScrollTrigger);

		var scene = new THREE.Scene();
		var gltfLoader = new THREE.GLTFLoader();

		var camera = new THREE.PerspectiveCamera(50, window.innerWidth/window.innerHeight, 0.1, 2000);
		//camera.position.z = 10;
		camera.position.set(0,0,20);
		camera.up = new THREE.Vector3(0,0,0);
		camera.lookAt(new THREE.Vector3(0,0,0));

		var renderCalls = [];
		function render () {
		  requestAnimationFrame( render );
		  renderCalls.forEach((callback)=>{ callback(); });
		}
		render();

		var renderer = new THREE.WebGLRenderer({antialias: true});
		renderer.setClearColor("#e5e5e5");
		renderer.setSize(window.innerWidth,window.innerHeight);

		document.body.appendChild(renderer.domElement);

		window.addEventListener('resize', () => {
			renderer.setSize(window.innerWidth,window.innerHeight);
			camera.aspect = window.innerWidth,window.innerHeight;
			camera.updateProjectionMatrix();
		});


		window.addEventListener( 'resize', function () {
		  camera.aspect = window.innerWidth / window.innerHeight;
		  camera.updateProjectionMatrix();
		  renderer.setSize( window.innerWidth, window.innerHeight );
		}, false );


		var geometry = new THREE.BoxGeometry(1, 1, 1);
		var material = new THREE.MeshLambertMaterial({color: 0xFFCC00});

		var meshtest = new THREE.Mesh(geometry, material);
		meshtest.position.set(0, 0, 1);
		meshtest.scale.set(0.3, 0.3, 0.3);

		var mesh1 = new THREE.Mesh(geometry, material);
		mesh1.position.set(0, 0, 0);

		var mesh2 = new THREE.Mesh(geometry, material);
		mesh2.position.set(0, 0, 0);

		var mesh3 = new THREE.Mesh(geometry, material);
		mesh3.position.set(0, 0, 0);

		var mesh4 = new THREE.Mesh(geometry, material);
		mesh4.position.set(0, 0, 0);

		var mesh5 = new THREE.Mesh(geometry, material);
		mesh5.position.set(0, 0, 0);

		var mesh6 = new THREE.Mesh(geometry, material);
		mesh6.position.set(0, 0, 0);

		var mesh7 = new THREE.Mesh(geometry, material);
		mesh7.position.set(0, 0, 0);

		var mesh8 = new THREE.Mesh(geometry, material);
		mesh8.position.set(0, 0, 0);

		var mesh9 = new THREE.Mesh(geometry, material);
		mesh9.position.set(0, 0, 0);

		var mesh10 = new THREE.Mesh(geometry, material);
		mesh10.position.set(0, 0, 0);

		var mesh11 = new THREE.Mesh(geometry, material);
		mesh11.position.set(0, 0, 0);

		var mesh12 = new THREE.Mesh(geometry, material);
		mesh12.position.set(0, 0, 0);

		var mesh13 = new THREE.Mesh(geometry, material);
		mesh13.position.set(0, 0, 0);

		var mesh14 = new THREE.Mesh(geometry, material);
		mesh14.position.set(0, 0, 0);

		var mesh15 = new THREE.Mesh(geometry, material);
		mesh15.position.set(0, 0, 0);

		var mesh16 = new THREE.Mesh(geometry, material);
		mesh16.position.set(0, 0, 0);

		var phdgroup = new THREE.Group();
		phdgroup.add(meshtest);
		phdgroup.add(mesh1);
		phdgroup.add(mesh2);
		phdgroup.add(mesh3);
		phdgroup.add(mesh4);
		phdgroup.add(mesh5);
		phdgroup.add(mesh6);
		phdgroup.add(mesh7);
		phdgroup.add(mesh8);
		phdgroup.add(mesh9);
		phdgroup.add(mesh10);
		phdgroup.add(mesh11);
		phdgroup.add(mesh12);
		phdgroup.add(mesh13);
		phdgroup.add(mesh14);
		phdgroup.add(mesh15);
		phdgroup.add(mesh16);
		phdgroup.rotation.set(1.57, -1.57, 0);
		phdgroup.scale.set(10, 10, 10);
		scene.add(phdgroup);

		var light = new THREE.PointLight(0xFFFFFF, 1, 500);
		light.position.set(10,0,10);
		scene.add(light);

		var render = function() {
			requestAnimationFrame(render);
			renderer.render(scene, camera);
		}
		render();

  		// 		// GSAP Timeline
		var timeline01 = gsap.timeline();

		// Animation Step 01 (.section-00)
		timeline01.to(this.phdgroup.rotation, {x: 0, y: 0,
			scrollTrigger: {
       	trigger: '.section-00',
        start: 'top',
        scrub: true,
        end: 'bottom',
        markers: true
	    }
		});
		timeline01.to(this.phdgroup.scale, {x: 1, y: 1, z: 1, scrollTrigger: {trigger: '.section-00', start: 'top', scrub: true, end: 'bottom', markers: true} });

		// Animation Step 01 (.section-01)
		timeline01.to(this.phdgroup.rotation, {x: -0.75, y: 0, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.phdgroup.scale, {x: 2, y: 2, z: 2, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh1.position, {x: -3, y: -3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh2.position, {x: -3, y: -1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh3.position, {x: -3, y: 1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh4.position, {x: -3, y: 3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh5.position, {x: -1, y: -3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh6.position, {x: -1, y: -1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh7.position, {x: -1, y: 1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh8.position, {x: -1, y: 3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh9.position, {x: 1, y: -3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh10.position, {x: 1, y: -1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh11.position, {x: 1, y: 1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh12.position, {x: 1, y: 3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh13.position, {x: 3, y: -3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh14.position, {x: 3, y: -1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh15.position, {x: 3, y: 1, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.mesh16.position, {x: 3, y: 3, immediateRender: false, scrollTrigger: {trigger: '.section-01', start: 'top', scrub: true, end: 'bottom', markers: true} });

			// Animation Step 02 (.section-02)
		timeline01.to(this.phdgroup.rotation, {x: '0.2', y: '1', z: '0', immediateRender: false, scrollTrigger: {trigger: '.section-02', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.phdgroup.scale, {x: '1', y: '1', z: '1', immediateRender: false, scrollTrigger: {trigger: '.section-02', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.phdgroup.position, {x: '-5',  y: '0', immediateRender: false, scrollTrigger: {trigger: '.section-02', start: 'top', scrub: true, end: 'bottom', markers: true} });
		timeline01.to(this.camera.position, {x: '0', y: '0', z: '15', immediateRender: false, scrollTrigger: {trigger: '.section-02', start: 'top', scrub: true, end: 'bottom', markers: true, onUpdate: function() {camera.lookAt( mesh7.position );} } });

              
            
!
999px

Console