← Commit history

Load the laser head assembly and Gerber textures in the wiki viewer

John Lauer ·bbf153271c · ·parent f6ad434
4 files changed +19−2
head-board/laser-head-preview.glbadded
⋯ 1 unchanged line ⋯
head-board/silkscreen_bottom.pngadded
⋯ 1 unchanged line ⋯
head-board/silkscreen_top.pngadded
⋯ 1 unchanged line ⋯
head-board/viewer.html+19−2
@@ -18,7 +18,7 @@ const message = document.getElementById("message"); const assets = "https://wiki.adom.inc/static/vendor/adom-3d-viewer-babylon9/"; try {   await import(assets + "adom-3d-viewer-babylon9.esm.js");-  const engine = window.BABYLON;+  const engine = await window.Adom3DViewerBabylon9.loadBabylon();   if (engine?.DracoCompression) {     engine.DracoCompression.Configuration = {decoder: {       wasmUrl: assets + "draco/draco_wasm_wrapper_gltf.js",@@ -28,7 +28,24 @@ try {   }   const viewer = window.Adom3DViewerBabylon9.init(document.getElementById("assembly"), {zUp:true});   await viewer.whenReady();-  await viewer.loadModel("https://wiki.adom.inc/api/pages/john/self-mixing-interferometer/files/head-board/laser-head.glb?v=1.3.0");+  await viewer.loadModel("https://wiki.adom.inc/api/pages/john/self-mixing-interferometer/files/head-board/laser-head-preview.glb?v=1.3.1");+  const scene = viewer.getScene();+  if (!scene) throw new Error("The head assembly scene could not be found");+  for (const name of ["silkscreen_top", "silkscreen_bottom"]) {+    const material = scene.getMaterialByName(name);+    if (!material) throw new Error("Missing " + name);+    const src = "https://wiki.adom.inc/api/pages/john/self-mixing-interferometer/files/head-board/" + name + ".png?v=1.3.1";+    const image = new Image();+    image.crossOrigin = "anonymous";+    image.src = src;+    await image.decode();+    const texture = new engine.DynamicTexture(name, {width:image.width, height:image.height}, scene, false);+    texture.getContext().drawImage(image, 0, 0);+    texture.hasAlpha = true;+    texture.update(false);+    material.albedoTexture = texture;+    material.useAlphaFromAlbedoTexture = true;+  }   if (viewer.goHome) viewer.goHome(); else viewer.frameModel();   message.hidden = true;   document.documentElement.dataset.modelLoaded = "true";