<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Import glTF 3D Models | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
--calcite-font-size--2: 0.95rem;
<arcgis-scene item-id="414a28cfca7a471180e8e952cf14c60f">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
<arcgis-compass slot="top-left"></arcgis-compass>
<calcite-panel slot="top-right">
label="UI for adding symbols into the scene"
description="Select a symbol and place it in the scene:"
><calcite-button id="tent" width="full">Tent</calcite-button>
<calcite-button id="canoe" width="full">Canoe</calcite-button>
Tent and canoe glTF models from
<a href="https://www.kenney.nl/assets/" target="_blank">Kenney game assets</a> under
<a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank"
const [GraphicsLayer, SketchViewModel] = await $arcgis.import([
"@arcgis/core/layers/GraphicsLayer.js",
"@arcgis/core/widgets/Sketch/SketchViewModel.js",
/*****************************************************************
* Get a reference to the Scene component and add layers
*****************************************************************/
const viewElement = document.querySelector("arcgis-scene");
const graphicsLayer = new GraphicsLayer({
elevationInfo: { mode: "on-the-ground" },
await viewElement.viewOnReady();
viewElement.map.add(graphicsLayer);
const tentButton = document.getElementById("tent");
const canoeButton = document.getElementById("canoe");
// This sample uses the SketchViewModel to add points to a
// GraphicsLayer. The points have 3D glTF models as symbols.
const sketchVM = new SketchViewModel({
function setupButtonClick(button, modelName) {
button.addEventListener("click", () => {
// Reference the relative path to the glTF model
// in the resource of an ObjectSymbol3DLayer
href: `https://developers.arcgis.com/javascript/latest/assets/sample-code/import-gltf/${modelName}.glb`,
sketchVM.create("point");
button.setAttribute("appearance", "outline");
// Set up event listeners for both buttons
setupButtonClick(tentButton, "tent");
setupButtonClick(canoeButton, "canoe");
sketchVM.on("create", (event) => {
sketchVM.update(event.graphic);
function makeButtonsSolid() {
const elements = document.querySelectorAll("calcite-button");
for (const element of elements) {
element.setAttribute("appearance", "solid");