Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


                <div class="container">
  <div class="iframe-container">
    <iframe id="api-frame"></iframe>
  <div class="explainer" id="explainer">
    It's possible to use annotations to trigger other actions. Click annotation 1 to hide or show the teapot. Click annotation 2 to change the opacity of the material of the disc.
    In this example the annotation tooltips and automatic camera movement has been disabled.
  <div class="controls" id="controls">
    <button id="teapotVisibility">Toggle teapot visibility</button>
    <button id="discOpacity">Toggle disc opacity</button>



html, body {
    padding: 0;
    margin: 0;
    width: 100vw;
    height: 100vh;

    -webkit-font-smoothing: antialiased;
    -moz-font-smoothing: grayscale;
    font-family: Open Sans, sans-serif;

* {
    box-sizing: border-box;

.container {
    display: flex;
    flex-direction: column;
    height: 100%;

.iframe-container {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;

.iframe-container > iframe {
    border: 0;
    width: 100%;
    flex: 1;

.explainer {
    height: 120px;
    padding: 15px 15px 0 15px;
    background-color: #E2E2E2;
    overflow: auto;

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    height: 80px;
    padding: 15px 0 0 15px;
    background-color: #F2F2F2;
    overflow: auto;

.controls > * {
    margin-right: 15px;
    margin-bottom: 15px;



                let version = '1.11.0';
let urlid = '0767c47d62db4018a3db02cde21a5ebb'
let iframeID = 'api-frame'
let api = null
let materialListByName = {}
let teapotVisible = true
let discOpacity = 1

Several methods here come from different codepens. You can find them in 
this collection:

// get the list of materials in the Sketchfab scene. Store this list in an object for easy access
function setMaterialListByName() {
  api.getMaterialList(function (err, sceneMaterials) {
    sceneMaterials.forEach(material => {
      materialListByName[] = material

// change a material property of the locally stored material
// and send the changed material to the Sketchfab scene
function setMaterialProperty(materialName, materialChannel, channelProperty, channelValue) {
    A material has a fixed structure
    Material object
    > name
    > channels
    > > channel (e.g. Opacity)
    > > > channelproperties
  materialListByName[materialName].channels[materialChannel][channelProperty] = channelValue
  api.setMaterial(materialListByName[materialName], function () {})    

function toggleTeapot() {
  teapotVisible = !teapotVisible
  setVisibilityByNodename(api, ['Teapot001'], teapotVisible)

function toggleDisc() {
  if (discOpacity === 1) {
    discOpacity = 0.25
  } else {
    discOpacity = 1
  setMaterialProperty("Disk", "Opacity", "enable", true) // make sure the opacity channel is enabled
  setMaterialProperty("Disk", "Opacity", "factor", discOpacity)

function actionSkfb() {
  var iframe = document.getElementById(iframeID);
  var client = new window.Sketchfab(version, iframe);

  var success = function(sketchfabApi) {
    api = sketchfabApi
    api.start(() => {
      api.addEventListener('viewerready', function() {
        // Avoid the camera movement when clicking an annotation
        api.setAnnotationCameraTransition(false, true)

        document.getElementById('teapotVisibility').addEventListener('click', function() {toggleTeapot()});
        document.getElementById('discOpacity').addEventListener('click', function() {toggleDisc()});
      // ATTENTION: annotation 1 has the index 0. This is a bit confusing.      
      api.addEventListener('annotationSelect', function(index) {
        console.log('Selected annotation', index)
        if (index === 0) toggleTeapot()
        if (index === 1) toggleDisc()

  client.init(urlid, {
    success: success,
    ui_stop: 0,
    ui_inspector: 0,
    ui_infos: 0,
    ui_controls: 0,
    ui_watermark: 0,
    annotation_tooltip_visible: 0 // don't show the annotation tooltip