cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              /! Made with http://infamous.io
script src="//unpkg.com/infamous@18.0.5/global.js"

/! Lights and shadows are powered by WebGL, but written with HTML:
i-scene experimental-webgl="true" id="scene" TODO-perspective="800" backgroundColor="0 0 0" backgroundOpacity="0" style="perspective: 800px" shadowmap-type="pcfsoft"

    i-ambient-light color="#404040" intensity="1"

    i-dom-plane id="bg" sizeMode="proportional proportional" size="1 1 0"

        i-node id="button-container" position="0 0 6" size="600 31 0" align="0.5 0.5 0" mountPoint="0.5 0.5 0"

            - for n in (0..4)
                i-dom-plane sizeMode="literal proportional" size="100 1 0" align="#{n*0.25} 0 0" mountPoint="#{n*0.25} 0 0"
                    button button #{n+1}

        i-point-light id="light" color="white" position="300 300 120" size="0 0 0" cast-shadow="true" intensity="1"
            i-mesh has="sphere-geometry basic-material" size="10 10 10" color="white" receive-shadow="false" cast-shadow="false" style="pointer-events: none"
            
          
!
            
              /* made with http://infamous.io */

body, html
    width 100%
    height 100%
    margin 0
    padding 0
    font-family sans-serif
    touch-action none

i-node
    text-align center

button-color = #FB752C
bg-color = #62B997

#bg
    background bg-color

button
    width 100%
    height 100%
    white-space nowrap
    border-radius 0px
    border 1px solid darken(button-color, 50%)
    background lighten(button-color, 20%)
    color darken(button-color, 50%)
    outline none // remove those darn ugly browser-specific outlines
    &:focus, &:hover
        background darken(button-color, 10%)
        color darken(button-color, 75%)
        border-color darken(button-color, 60%)
            
          
!
            
              // made with http://infamous.io

// defines the default names for the HTML elements
infamous.html.useDefaultNames()

var light = document.querySelector('#light')
light.threeObject3d.shadow.radius = 3
light.threeObject3d.distance = 20000
light.threeObject3d.shadow.bias = 0.00001

// prevent default touch actions so we can move the light with touch
document.querySelector('html').setAttribute('touch-action', 'none')
document.querySelector('body').setAttribute('touch-action', 'none')

document.addEventListener('pointermove', function(e) {
    console.log('move!')
    e.preventDefault()
    light.position.x = e.clientX
    light.position.y = e.clientY
})

var Motor = infamous.core.Motor
var downTween, upTween, pressedButton

// On mouse down animate the button downward
document.addEventListener('pointerdown', function(e) {
    if ( is( e.target, 'button' ) ) {

        pressedButton = e.target

        if (upTween) {
            upTween.stop()
            upTween = null
        }

        downTween = new TWEEN.Tween(e.target.parentNode.position)
            .to({z: -6}, 75)
            .start()
            .onComplete(function () { downTween = null })

        Motor.addRenderTask(function(time) {
            if (!downTween) return false
            downTween.update(time)
        })
        
    }
})

// On mouse up animate the button upward
document.addEventListener('pointerup', function(e) {
    if ( pressedButton ) {
    
        if (downTween) {
            downTween.stop()
            downTween = null
        }

        upTween = new TWEEN.Tween(pressedButton.parentNode.position)
            .to({z: 0}, 75)
            .start()
            .onComplete(function() { upTween = null })

        Motor.addRenderTask(function(time) {
            if (!upTween) return false
            upTween.update(time)
        })
        
    }
})

// The following is a temporary hack because opacity isn't
// exposed through the HTML API yet. work-in-progress...
var scene = document.querySelector('#scene')
setTimeout(function() {
    Array.from( document.querySelectorAll('i-dom-plane') ).forEach(function(n) {
        n.threeObject3d.material.opacity = 0.3
    })
    
    document.querySelector('#bg')
        .threeObject3d.material.opacity = 0.3
    document.querySelector('#bg')
        .threeObject3d.material.dithering = true

    scene._needsToBeRendered()
}, 0)

function is( el, selector ) {
    if ( [].includes.call( document.querySelectorAll( selector ), el ) ) return true
    return false
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console