Skip to content

Instantly share code, notes, and snippets.

@ancientstraits
Created November 8, 2023 18:53
Show Gist options
  • Save ancientstraits/b315311750e2f31924ee377a799c4dbb to your computer and use it in GitHub Desktop.
Save ancientstraits/b315311750e2f31924ee377a799c4dbb to your computer and use it in GitHub Desktop.
XWOMBBE
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.min.js"></script>
<div id="viewer"></div>
<select id="models"></select>
import { initViewer, listModels, loadModel } from 'https://aps-codepen.autodesk.io/utils.js';
const viewer = await initViewer(document.getElementById('viewer'), { extensions: ['Autodesk.DocumentBrowser'] });
const models = await listModels();
const dropdown = document.getElementById('models');
dropdown.innerHTML = models.map(m => `<option value="${m.urn}">${m.name}</option>`).join('');
dropdown.onchange = () => dropdown.value && loadModel(viewer, dropdown.value);
dropdown.onchange();
#viewer {
position: absolute;
inset: 0;
}
#models {
position: absolute;
left: 1em;
top: 1em;
z-index: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment