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

              
                
              
            
!

CSS

              
                body {
	background-color: #000;
	margin: 0px;
	overflow: hidden;
}
#canvas{
  width: 100%;
  height:100%
}
              
            
!

JS

              
                import { OrbitControls } from "https://threejs.org/examples/jsm/controls/OrbitControls.js";
import { GUI } from "https://threejs.org/examples/jsm/libs/dat.gui.module.js";

var renderer, scene, camera, controls;
let arrowX, arrowY, arrowZ;
let arrowXm, arrowYm, arrowZm;
let aCircle, bCircle, cCircle, aCirclem


const rotEuler = new function() {
  this.a = 30
  this.b = 0;
  this.c = 0
}

init()
animate()

function init() {

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

    // scene
    scene = new THREE.Scene();
    scene.background = new THREE.Color( 0xcce0ff );
    
    // camera
    camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.set( 50, 50, 50 );

    // controls
    controls = new OrbitControls( camera, renderer.domElement );
  
  				//

		window.addEventListener( 'resize', onWindowResize );
  
  
    
    // ambient
    scene.add( new THREE.AmbientLight( 0x222222 ) );
    
    // light
  scene.add( new THREE.AmbientLight( 0x666666 ) );
    var light = new THREE.DirectionalLight( 0xffffff, 1 );
    light.position.set( 20,20, 0 );
    scene.add( light );
    
    // axes
    scene.add( new THREE.AxesHelper( 20 ) );
    
    var aLength = 20
    var sWidth = 1
    var sL = aLength- 2*sWidth
    
    const hWidth = 2 * sWidth
    // geometry
    const shaft = new THREE.CylinderGeometry( 1, 1,sL , 10 );
    shaft.translate(0,sL/2,0)
    const head = new THREE.ConeGeometry(hWidth,hWidth*2,10);
    head.translate(0,sL + hWidth,0)
  
  
    var shaftMesh = new THREE.Mesh(shaft);
    var headMesh = new THREE.Mesh(head);
    arrowX = new THREE.Geometry();
  arrowX.matrixAutoUpdate = false;
    arrowY = new THREE.Geometry();
  arrowX.matrixAutoUpdate = false;
    arrowZ = new THREE.Geometry();
  arrowX.matrixAutoUpdate = false;

    shaftMesh.updateMatrix()
    arrowX.merge(shaftMesh.geometry, shaftMesh.matrix)
  
    headMesh.updateMatrix()
    arrowX.merge(headMesh.geometry, headMesh.matrix)
    // material
    const green = new THREE.MeshPhongMaterial( {
        color: 0x00ff00, 
        flatShading: true,
        transparent: true,
        opacity: 0.7,
    } );
      const red = new THREE.MeshPhongMaterial( {
        color: 0xff0000, 
        flatShading: true,
        transparent: true,
        opacity: 0.7,
    } );
        const blue = new THREE.MeshPhongMaterial( {
        color: 0x0000ff, 
        flatShading: true,
        transparent: true,
        opacity: 0.7,
    } );
  

    
    arrowY = arrowX.clone().rotateZ(-Math.PI/2)
    arrowZ = arrowX.clone().rotateX(Math.PI/2)
    // mesh
  
    arrowXm = new THREE.Mesh( arrowX, green )
    arrowYm = new THREE.Mesh( arrowY, red )
    arrowZm = new THREE.Mesh( arrowZ, blue )
    scene.add( arrowXm );
    scene.add(arrowYm );
    scene.add( arrowZm );

    const gui = new GUI({ autoPlace: true });
    gui.add(rotEuler, 'a', 0,360 ).name( 'α' );
    gui.add(rotEuler, 'b', 0,360).name( 'β' );
    gui.add(rotEuler, 'c',0,360 ).name( '𝛾' );
}

//

function onWindowResize() {

  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();

  renderer.setSize( window.innerWidth, window.innerHeight );

}

function animate() {

    requestAnimationFrame( animate );
    
    //controls.update();
    render();

    renderer.render( scene, camera );

}


function render() {
  const eu = new THREE.Euler(rotEuler.a * Math.PI / 180 , rotEuler.b * Math.PI / 180, rotEuler.c * Math.PI / 180, 'XYZ' );
  arrowXm.setRotationFromEuler(eu)
  arrowYm.setRotationFromEuler(eu)
  arrowZm.setRotationFromEuler(eu)
}
              
            
!
999px

Console