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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                
              
            
!

CSS

              
                html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
}
canvas {
  width: 100%;
  height: 100%;
}

              
            
!

JS

              
                var scene = new THREE.Scene();

// CAMERA 

var camera = new THREE.OrthographicCamera (
  window.innerWidth  / - 0.5,
  window.innerWidth  / 0.5,
  window.innerHeight / 0.5,
  window.innerHeight / - 0.5,
  1000,
  4000 );

camera.position.set(0, -200, 1400);
scene.add(camera);

// LIGHTS 

var light = new THREE.DirectionalLight( 0xf2f2f2, 0.3 );
light.position.x = 10;
light.position.y = 0;
light.position.z = 0;
scene.add( light );

var ambientLight = new THREE.AmbientLight(0x660000, 0.7);
scene.add(ambientLight);

// RENDERER 

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

// TEXT GEOMETRY 

var textMaterial = new THREE.MeshPhongMaterial({color: 0xffffff});

var textMesh1; // A
var textMesh2; // B
var textMesh3; // C
var textMesh4; // D
var textMesh5; // E

var loader = new THREE.FontLoader();

loader.load( 'https://t-k-f.ch/data/json/sofia.json', function ( font ) {

  // 1
  var textGeometry1 = new THREE.TextGeometry( 'A', {
    font: font,
    size: 400,
    height: 100,
    curveSegments: 20,
    bevelEnabled: false
  } );

  textMesh1 = new THREE.Mesh( textGeometry1, textMaterial );
  textMesh1.position.x = -1200;
  scene.add( textMesh1 );

  // 2
  var textGeometry2 = new THREE.TextGeometry( 'B', {
    font: font,
    size: 400,
    height: 100,
    curveSegments: 20,
    bevelEnabled: false
  } );

  textMesh2 = new THREE.Mesh( textGeometry2, textMaterial );
  textMesh2.position.x = -800;
  scene.add( textMesh2 );

  // 3
  var textGeometry3 = new THREE.TextGeometry( 'C', {
    font: font,
    size: 400,
    height: 100,
    curveSegments: 20,
    bevelEnabled: false
  } );

  textMesh3 = new THREE.Mesh( textGeometry3, textMaterial );
  textMesh3.position.x = -400;
  scene.add( textMesh3 );

  // 4
  var textGeometry4 = new THREE.TextGeometry( 'D', {
    font: font,
    size: 400,
    height: 100,
    curveSegments: 20,
    bevelEnabled: false
  } );

  textMesh4 = new THREE.Mesh( textGeometry4, textMaterial );
  textMesh4.position.x = 0;
  scene.add( textMesh4 );

  // 5
  var textGeometry5 = new THREE.TextGeometry( 'E', {
    font: font,
    size: 400,
    height: 100,
    curveSegments: 20,
    bevelEnabled: false
  } );

  textMesh5 = new THREE.Mesh( textGeometry5, textMaterial );
  textMesh5.position.x = 400;
  scene.add( textMesh5 );

} );


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


// let helper = new THREE.CameraHelper(camera);
// scene.add(helper);


function onMouseMove(event) {
  getMouseDirection(event);
};

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

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

var oldX = 0;
var oldY = 0;

function getMouseDirection(e) {

  if (oldX < e.pageX) {
    textMesh1.rotation.y += 0.05;  // Right
    textMesh2.rotation.y += 0.05;
    textMesh3.rotation.y += 0.05;
    textMesh4.rotation.y += 0.05;
    textMesh5.rotation.y += 0.05;
  } else {
    textMesh1.rotation.y -= 0.05;  // Left
    textMesh2.rotation.y -= 0.05;
    textMesh3.rotation.y -= 0.05;
    textMesh4.rotation.y -= 0.05;
    textMesh5.rotation.y -= 0.05;
  }


  //deal with the vertical case
  if (oldY < e.pageY) {
    textMesh1.rotation.x = textMesh1.rotation.x;
    textMesh2.rotation.x = textMesh2.rotation.x;
    textMesh3.rotation.x = textMesh3.rotation.x;
    textMesh4.rotation.x = textMesh4.rotation.x;
    textMesh5.rotation.x = textMesh5.rotation.x;
  } else {
    textMesh1.rotation.x = textMesh1.rotation.x;
    textMesh2.rotation.x = textMesh2.rotation.x;
    textMesh3.rotation.x = textMesh3.rotation.x;
    textMesh4.rotation.x = textMesh4.rotation.x;
    textMesh5.rotation.x = textMesh5.rotation.x;
  }

  oldX = e.pageX;
  oldY = e.pageY;
}

animate();
              
            
!
999px

Console