Import fiddle as a JS Module - chain fiddles together

HTML

<div id="info">
  <a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - AMF loader
</div>

<button id="start">start</button>
<button id="top">top</button>
<button id="bottom">bottom</button>
<button id="right">right</button>

<script type="importmap">
			{
				"imports": {
					"three": "https://cdn.jsdelivr.net/npm/three@0.172.0/build/three.module.js"
				}
			}
</script>

CSS

body {
	margin: 0;
	background-color: #000;
	color: #fff;
	font-family: Monospace;
	font-size: 13px;
	line-height: 24px;
	overscroll-behavior: none;
}

a {
	color: #ff0;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

button {
	cursor: pointer;
	text-transform: uppercase;
}

#info {
	position: absolute;
	top: 0px;
	width: 100%;
	padding: 10px;
	box-sizing: border-box;
	text-align: center;
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
	z-index: 1; /* TODO Solve this in HTML */
}

a, button, input, select {
	pointer-events: auto;
}

.lil-gui {
	z-index: 2 !important; /* TODO Solve this in HTML */
}

@media all and ( max-width: 640px ) {
	.lil-gui.root { 
		right: auto;
		top: auto;
		max-height: 50%;
		max-width: 80%;
		bottom: 0;
		left: 0;
	}
}

#overlay {
	position: absolute;
	font-size: 16px;
	z-index: 2;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	background: rgba(0,0,0,0.7);
}

	#overlay button {
		background: transparent;
		border: 0;
		border: 1px solid rgb(255, 255, 255);
		border-radius: 4px;
		color: #ffffff;
		padding: 12px 18px;
		text-transform: uppercase;
		cursor: pointer;
	}

#notSupported {
	width: 50%;
	margin: auto;
	background-color: #f00;
	margin-top: 20px;
	padding: 10px;
}

body {
  background-color: #999;
}

JavaScript

//original: https://github.com/mrdoob/three.js/blob/r172/examples/webgl_loader_amf.html

import * as THREE from "three"

import { OrbitControls } from "https://cdn.jsdelivr.net/npm/three@0.172.0/examples/jsm/controls/OrbitControls.js"
import { AMFLoader } from "https://cdn.jsdelivr.net/npm/three@0.172.0/examples/jsm/loaders/AMFLoader.js"

let camera, scene, renderer

init()

function init() {
  scene = new THREE.Scene()
  scene.background = new THREE.Color(0x999999)

  scene.add(new THREE.AmbientLight(0x999999))

  camera = new THREE.PerspectiveCamera(
    35,
    window.innerWidth / window.innerHeight,
    1,
    500,
  )

  // Z is up for objects intended to be 3D printed.

  camera.up.set(0, 0, 1)
  camera.position.set(-5, 9, 6)

  camera.add(new THREE.PointLight(0xffffff, 250))

  scene.add(camera)

  const grid = new THREE.GridHelper(50, 50, 0xffffff, 0x555555)
  grid.rotateOnAxis(new THREE.Vector3(1, 0, 0), 90 * (Math.PI / 180))
  scene.add(grid)

  renderer = new THREE.WebGLRenderer({ antialias: true })
  renderer.setPixelRatio(window.devicePixelRatio)
  renderer.setSize(window.innerWidth, window.innerHeight)
  document.body.appendChild(renderer.domElement)

  const loader = new AMFLoader()
  loader.load(
    "https://threejs.org/examples/models/amf/rook.amf",
    function (amfobject) {
      scene.add(amfobject)
      render()
    },
  )

  const controls = new OrbitControls(camera, renderer.domElement)
  controls.addEventListener("change", render)
  controls.target.set(0, 0, 2)
  controls.enableZoom = false
  controls.update()

  window.addEventListener("resize", onWindowResize)

  document.querySelector("#start").onclick = () => {
    move({ x: 0, y: 0, z: 0 }, { x: -5, y: 9, z: 6 })
  }
  document.querySelector("#top").onclick = () => {
    move({ x: -3.04, y: 0, z: -Math.PI }, { x: 0, y: 1, z: 35 })
  }
  document.querySelector("#bottom").onclick = () => {
    move({ x: 3.04, y: 0, z: Math.PI }, { x: 0, y: -1, z: -35 })
  }
 ...