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

              
                script(src='https://unpkg.com/posenet-pointer@0.0.1')

//- We'll inject video/canvas into here
#debug

//- About
p
  video(id="demo-video" src='https://i.imgur.com/3lBstel.mp4' autoplay controls loop width=600)
p
  button(onclick='startPosenetPointer()') 👋 Start Posenet Pointer
p
  small Model is ~3Mb, please allow a few moments on slow connections
p(style='margin-top: 100px') Scroll by moving cursor down here 👇
.pointer

//- Filler so that we can scroll
.dummy
  each i in [0,1,2,3,4,5]
    h1(style='margin-top: 300px') Dummy content for scrolling
    p "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    p "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    p "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

              
            
!

CSS

              
                .pointer
  pointer-events none
  height 20px
  width 20px
  background red
  border-radius 100%
  position fixed
  left 50%
  top 50px

#debug video
  visibility hidden !important
  
body
  text-align center

button
  font-size 24px
  padding 20px
  
.dummy
  text-align left
  font-size 18px
  line-height 1.5
              
            
!

JS

              
                // Instantiate with debug turned on
const pointer = new PosenetPointer({
  debug: true,
  target: document.querySelector('#debug')
})

function startPosenetPointer () {
  const $pointer = document.querySelector('.pointer')
  document.querySelector('#demo-video').remove()
  
  // Start PoseNet Pointer
  pointer.start()
  
  // Add a "plugin" to update pointer position
  pointer.use('placePointer', poses => {
    $pointer.style.left = `${poses[0].pointedAt.x}px`
    $pointer.style.top = `${poses[0].pointedAt.y}px`
  })
  
  // Add another one to handle scrolling
  // You could do this in the same one, but keeping functionality
  // separately will allow you to toggle plugins on/off later
  pointer.use('scrollPage', poses => {
    let y = poses[0].pointedAt.y;
    if (y < 0) window.scrollTo(0, window.scrollY + y * 0.05);
    else if (y > window.innerHeight)
      window.scrollTo(0, window.scrollY + (y - window.innerHeight) * 0.05);
  })
}
              
            
!
999px

Console