| @@ -1,4 +1,4 @@ | |||
| export function createSimpleButtons(buttons: Record<string, (btn: HTMLButtonElement) => void>) { | |||
| export function createSimpleButtons(buttons: Record<string, (btn: HTMLButtonElement) => void>, container = document.body) { | |||
| const entries = Object.entries(buttons) | |||
| entries.forEach(([text, onclick], i) => { | |||
| const btn = document.createElement('button') | |||
| @@ -8,6 +8,6 @@ export function createSimpleButtons(buttons: Record<string, (btn: HTMLButtonElem | |||
| btn.style.right = '3rem' | |||
| btn.style.zIndex = '10000' | |||
| btn.onclick = async() => onclick(btn) | |||
| document.body.appendChild(btn) | |||
| container.appendChild(btn) | |||
| }) | |||
| } | |||
| @@ -2,7 +2,7 @@ | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="UTF-8"> | |||
| <title>Extra importer plugins</title> | |||
| <title>Extra Importer Plugins</title> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <!-- Import maps polyfill --> | |||
| <!-- Remove this when import maps will be widely supported --> | |||
| @@ -78,13 +78,12 @@ async function init() { | |||
| autoScaleRadius: 0.5, | |||
| clearSceneObjects: false, | |||
| } | |||
| let i = 0 | |||
| const models = await Promise.allSettled(urls.map(async url => | |||
| viewer.load<IObject3D>(url, options).then(res => { | |||
| if (!res) return | |||
| const i = urls.indexOf(url) | |||
| res.position.set(i % 4 - 1.5, 0, Math.floor(i / 4) - 1.5).multiplyScalar(1) | |||
| res.setDirty() | |||
| i++ | |||
| return res | |||
| }))) | |||
| @@ -16,12 +16,12 @@ async function init() { | |||
| createSimpleButtons({ | |||
| ['Enter/Exit fullscreen']: () => { | |||
| if (fullScreenPlugin.isFullScreen()) fullScreenPlugin.exit() | |||
| else fullScreenPlugin.enter(document.body) // parameter is optional, if not specified, the viewer canvas will be used | |||
| else fullScreenPlugin.enter(viewer.container) // parameter is optional, if not specified, the viewer canvas will be used | |||
| // or just use | |||
| // fullScreenPlugin.toggle(document.body) | |||
| }, | |||
| }) | |||
| }, viewer.container) | |||
| const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true)) | |||
| @@ -2,7 +2,7 @@ | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="UTF-8"> | |||
| <title>Render Target Preview</title> | |||
| <title>Geometry UV Preview</title> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <!-- Import maps polyfill --> | |||
| <!-- Remove this when import maps will be widely supported --> | |||
| @@ -2,7 +2,7 @@ | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="UTF-8"> | |||
| <title>Depth Buffer Plugin</title> | |||
| <title>Normal Buffer Plugin</title> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <!-- Import maps polyfill --> | |||
| <!-- Remove this when import maps will be widely supported --> | |||