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

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

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  ArcGIS API for JavaScript,
  For more information about the building-scene-layer-slice sample, read the original sample description at
<title>BuildingSceneLayer with Slice widget - 4.10</title>

    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;

    .action-button {
      font-size: 1.2em;
      font-family: sans-serif;
      background-color: white;
      border: 1px solid #D3D3D3;
      padding: 0.5em;
      color: #0079c1;
      text-align: center;
      box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
      cursor: pointer;

    .active {
      background: #0079c1;
      color: white;

    #menu {
      padding: 0.8em;

  <link href="" rel="stylesheet"
  <script src=""></script>

  ], function(WebScene, SceneView, BuildingSceneLayer, Slice, LayerList, Collection) {

    // Load webscene and display it in a SceneView
    const webscene = new WebScene({
      portalItem: {
        id: "c7470b0e4e4c44288cf287d658155300"

    const view = new SceneView({
      container: "viewDiv",
      map: webscene

    // Create the BuildingSceneLayer and add it to the webscene
    const buildingLayer = new BuildingSceneLayer({
      url: "",
      title: "Administration Building, Redlands - Building Scene Layer"

    const excludedLayers = [];
    let doorsLayer;

    buildingLayer.when(function() {

      // Iterate through the flat array of sublayers and extract the ones
      // that should be excluded from the slice widget
      buildingLayer.allSublayers.forEach(function(layer) {
        // modelName is standard accross all BuildingSceneLayer,
        // use it to identify a certain layer
        switch (layer.modelName) {
          // Because of performance reasons, the Full Model view is
          // by default set to false. In this scene the Full Model should be visible.
          case "FullModel":
            layer.visible = true;
          case "Overview":
            layer.visible = false;
          // Extract the layers that should not be hidden by the slice widget
          case "Doors":
            doorsLayer = layer;
          case "StructuralColumns":
          case "Floors":
          case "Furniture":
          case "CurtainWallPanels":


    view.when(function() {

      const sliceButton = document.getElementById("slice");
      view.ui.add(sliceButton, "top-right");
      let sliceWidget = null;

      sliceButton.addEventListener("click", function() {

        if (sliceWidget) {
          sliceWidget = null;
        else {
          sliceWidget = new Slice({
            view: view
          // programmatically add layers that should be excluded from slicing
          view.ui.add(sliceWidget, "top-right");

    document.getElementById("color").addEventListener("change", function(event) {

      if ( {
        // A renderer can be set on a BuildingComponentSublayer
        doorsLayer.renderer = {
          type: "unique-value",  // autocasts as new UniqueValueRenderer()
          field: "AssemblyDesc",
          uniqueValueInfos: [{
            // All interior doors are displayed red
            value: "Interior Doors",
            symbol: {
              type: "mesh-3d",  // autocasts as new MeshSymbol3D()
                type: "fill", // autocasts as new FillSymbol3DLayer()
                material: {
                  color: "red"
      else {
        doorsLayer.renderer = null;


    view.ui.add("menu", "top-left");

    // Add a layer list widget
    const layerList = new LayerList({
        view: view

    view.ui.add(layerList, "top-left");


  <div id="viewDiv"></div>
  <button class="action-button" id="slice" type="button" title="Slice layers">Slice
  <div id="menu" class="esri-widget">
    <input type="checkbox" id="color"><label for="color">Display all interior
      doors with a red color</label>

🕑 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.