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

              
                
              
            
!

JS

              
                const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const FPS = 30;
const angularSpeed = Math.PI/4;

const innerRadius = 1;
const outerRadius = innerRadius*2;
const barLenght = innerRadius;

let clock = new THREE.Clock();
let delta = 0;
const interval = 1 / FPS;

// create scanline
const outerMaterial = new THREE.ShaderMaterial({
    uniforms: {
		scanAngle: {type: 'float', value: 0.},
	},
    fragmentShader: fragmentShader(),
    onBeforeCompile: shader => {
        shader.fragmentShader
    }
});

const outerCircle = new THREE.Mesh(new THREE.CircleGeometry(outerRadius, 60), outerMaterial);
scene.add(outerCircle);

// Create innerCircle 
const innerMaterial = new THREE.MeshBasicMaterial({color: 0x0000ff});
const innerCircle = new THREE.Mesh(new THREE.CircleGeometry(innerRadius, 60), innerMaterial);
scene.add(innerCircle);


// create staticLine
const staticLine = new THREE.Mesh(new THREE.PlaneGeometry(0.05, barLenght), new THREE.MeshBasicMaterial({color: 0xff0000, side: THREE.DoubleSide}));
scene.add(staticLine);

// create scanLine
const scanLine = new THREE.Mesh(new THREE.PlaneGeometry(0.05, barLenght), new THREE.MeshBasicMaterial({color: 0xff0000, side: THREE.DoubleSide}));
scene.add(scanLine);

// position staticLine
staticLine.position.y = innerRadius + barLenght/2;

// position scanLine
scanLine.position.y = innerRadius + barLenght/2;

// create pivot to rotate dateline
const pivot = new THREE.Group();
pivot.position.set( 0.0, 0.0, 0 );
pivot.add(scanLine);
scene.add(pivot);

camera.position.z = 5;

function vertexShader() {
    return `
        varying vec4 pixelpos;
        void main() {
            pixelpos = 
            gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
        }
    `
}

function fragmentShader() {
    return `
        uniform float scanAngle;
        
        void main() {
            
            if (-3.14 < scanAngle) {
                gl_FragColor = vec4(0, 1, 1, 1);
            }
            else {
                gl_FragColor = vec4(1, 0, 1, 1);
            }
        }
    `
}

// game logic update here!
function update() {
    pivot.rotation.z -= angularSpeed / FPS;
    pivot.rotation.z = pivot.rotation.z % (2*Math.PI);
    outerMaterial.uniforms.scanAngle.value = pivot.rotation.z;
    console.log(pivot.rotation.z);
}

// Constant FPS gameloop
function gameloop() {
    requestAnimationFrame(gameloop);
    delta += clock.getDelta();
    if (delta  > interval) {
        update();
        renderer.render(scene, camera);
        delta = delta % interval;
    }
}


gameloop();
              
            
!
999px

Console