belowjs 1.7.4 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,15 +5,32 @@ All notable changes to BelowJS will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [1.7.4] - 2026-04-28
8
+ ## [1.7.6] - 2026-04-28
9
+
10
+ ### Fixed
11
+ - Hotfix: GLB loading no longer bakes detected photogrammetry mesh transforms into geometry, fixing distorted or cube-like models in the basic viewer.
12
+
13
+ ## [1.7.5] - 2026-04-28
14
+
15
+ > Deprecated: this release introduced a regression in some GLB model loading paths. Use 1.7.6 or later.
9
16
 
10
17
  ### Changed
11
- - Sketchfab GLB downloads are now the recommended starting point; optimisation is still recommended for VR and faster downloads.
18
+ - Improved GLB loading for Sketchfab photogrammetry exports, with more consistent material handling and cleaner shading.
19
+ - In the guides, clarified how to load directly from [Sketchfab GLB exports](docs/guides/sketchfab-models.html).
20
+
21
+ ### Fixed
22
+ - Reduced texture banding and glossy-material bleed-through on photogrammetry and comparison heatmap views.
23
+ - Model comparison camera locking now waits for a valid alignment solve.
24
+ - Pressing `0` in model comparison reframes the loaded model view.
25
+ - Improved model comparison stability when switching views, dragging markers, and running C2C or height comparisons.
26
+
27
+ ## [1.7.4] - 2026-04-28
28
+
29
+ ### Added
30
+ - Added the model comparison viewer for aligning two survey models with matched markers, viewing overlay/difference modes, and generating C2C and height comparison maps.
12
31
 
13
32
  ### Fixed
14
- - GLB models now keep their exported surface normals, avoiding blotchy shading on photogrammetry models.
15
- - Large photogrammetry textures no longer show mipmap striping in the viewer.
16
- - Survey lighting now casts cleaner shadows on close-range photogrammetry surfaces.
33
+ - Survey lighting casts cleaner shadows on close-range photogrammetry surfaces.
17
34
  - Long-pressing the viewer on mobile no longer triggers stray text selection, while form controls and editable fields inside the viewer still allow normal text interaction.
18
35
 
19
36
  ## [1.7.3] - 2026-03-06
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  📖 **[Full Documentation & Examples](https://patrick-morrison.github.io/belowjs/)**
8
8
 
9
- > **Current Version:** `1.7.4` - Photogrammetry GLB rendering fixes and updated Sketchfab workflow guidance.
9
+ > **Current Version:** `1.7.6` - Hotfix for GLB loading in the basic viewer.
10
10
 
11
11
  **Dive Shipwrecks in Virtual Reality**
12
12
 
@@ -60,11 +60,11 @@ This gives you a complete VR-ready 3D viewer with dive lighting, measurement too
60
60
  {
61
61
  "imports": {
62
62
  "three": "https://cdn.jsdelivr.net/npm/three@0.179.1/+esm",
63
- "belowjs": "https://cdn.jsdelivr.net/npm/belowjs@1.7.4/dist/belowjs.js"
63
+ "belowjs": "https://cdn.jsdelivr.net/npm/belowjs@1.7.6/dist/belowjs.js"
64
64
  }
65
65
  }
66
66
  </script>
67
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/belowjs@1.7.4/dist/belowjs.css">
67
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/belowjs@1.7.6/dist/belowjs.css">
68
68
  <style>
69
69
  body, html { margin: 0; padding: 0; overflow: hidden; }
70
70
  </style>
package/dist/belowjs.js CHANGED
@@ -3723,40 +3723,18 @@ class ee {
3723
3723
  });
3724
3724
  }
3725
3725
  processModel(e) {
3726
- const t = e.scene, s = this.getMaxAnisotropy();
3727
- t.traverse((n) => {
3728
- if (n.isLight && (n.visible = !1), n.isMesh && n.material) {
3729
- n.castShadow = !0, n.receiveShadow = !0;
3730
- const o = Array.isArray(n.material) ? n.material : [n.material];
3731
- o.forEach((r, l) => {
3732
- if (r.emissive && r.emissive.setHex(0), r.emissiveIntensity !== void 0 && (r.emissiveIntensity = 0), r.emissiveMap && (r.emissiveMap = null), r.lightMap && (r.lightMap = null), r.lightMapIntensity !== void 0 && (r.lightMapIntensity = 0), r.type === "MeshBasicMaterial" || r.type === "MeshPhongMaterial") {
3733
- const A = new f.MeshStandardMaterial({
3734
- // Only include common, safe params; set specialized textures conditionally below
3735
- color: r.color || new f.Color(16777215),
3736
- side: r.side !== void 0 ? r.side : f.FrontSide,
3737
- wireframe: r.wireframe || !1,
3738
- vertexColors: r.vertexColors || !1,
3739
- fog: r.fog !== void 0 ? r.fog : !0,
3740
- flatShading: !1,
3741
- // Realistic shipwreck appearance
3742
- roughness: 0.8,
3743
- // Weathered, corroded metal/wood
3744
- metalness: 0.3
3745
- // Mix of metal and non-metal
3746
- });
3747
- r.map && (A.map = r.map), r.alphaMap && (A.alphaMap = r.alphaMap), r.aoMap && (A.aoMap = r.aoMap), typeof r.aoMapIntensity == "number" && (A.aoMapIntensity = r.aoMapIntensity), r.envMap && (A.envMap = r.envMap), r.roughnessMap && (A.roughnessMap = r.roughnessMap), r.metalnessMap && (A.metalnessMap = r.metalnessMap), r.transparent !== void 0 && (A.transparent = r.transparent), typeof r.opacity == "number" && (A.opacity = r.opacity), r.normalMap && (A.normalMap = r.normalMap, A.normalScale = r.normalScale || new f.Vector2(1, 1)), ["map", "normalMap", "roughnessMap", "metalnessMap", "aoMap"].forEach((d) => {
3748
- A[d] && this.processTexture(A[d], s, { disableMipmaps: d === "map" });
3749
- }), A.needsUpdate = !0, Array.isArray(n.material) ? n.material[l] = A : n.material = A, r !== A && typeof r?.dispose == "function" && r.dispose();
3750
- } else (r.type === "MeshStandardMaterial" || r.type === "MeshPhysicalMaterial") && (["map", "normalMap", "roughnessMap", "metalnessMap", "aoMap", "emissiveMap"].forEach((h) => {
3751
- r[h] && this.processTexture(r[h], s, { disableMipmaps: h === "map" });
3752
- }), r.needsUpdate = !0);
3753
- const c = Array.isArray(n.material) ? n.material[l] : n.material;
3754
- c && c.needsUpdate !== void 0 && (c.needsUpdate = !0);
3755
- }), n.geometry && (n.geometry.attributes?.normal || n.geometry.computeVertexNormals(), n.geometry.normalizeNormals(), o.some((l) => l.normalMap) && this.canComputeTangents(n.geometry) && n.geometry.computeTangents());
3726
+ const t = e.scene, s = this.getMaxAnisotropy(), i = e.parser || null, n = this.shouldNormalizePhotogrammetryAtlas(i);
3727
+ t.traverse((r) => {
3728
+ if (r.isLight && (r.visible = !1), r.isMesh && r.material) {
3729
+ r.castShadow = !0, r.receiveShadow = !0;
3730
+ const c = (Array.isArray(r.material) ? r.material : [r.material]).map(
3731
+ (A) => this.normalizeMaterial(A, i, n, s)
3732
+ );
3733
+ r.material = Array.isArray(r.material) ? c : c[0], r.geometry && (n ? r.geometry.computeVertexNormals() : r.geometry.attributes?.normal || r.geometry.computeVertexNormals(), r.geometry.normalizeNormals(), c.some((h) => h?.normalMap) && this.canComputeTangents(r.geometry) && r.geometry.computeTangents());
3756
3734
  }
3757
3735
  });
3758
- const i = new f.Box3().setFromObject(t);
3759
- return t.userData.boundingBox = i, t;
3736
+ const o = new f.Box3().setFromObject(t);
3737
+ return t.userData.boundingBox = o, t;
3760
3738
  }
3761
3739
  getMaxAnisotropy() {
3762
3740
  if (!this.renderer || !this.renderer.capabilities || typeof this.renderer.capabilities.getMaxAnisotropy != "function")
@@ -3767,8 +3745,74 @@ class ee {
3767
3745
  processMaterial(e) {
3768
3746
  e && e.needsUpdate !== void 0 && (e.needsUpdate = !0);
3769
3747
  }
3770
- processTexture(e, t = null, { disableMipmaps: s = !1 } = {}) {
3771
- e && (t !== null && (e.anisotropy = t), s && !e.isCompressedTexture && Array.isArray(e.mipmaps) && e.mipmaps.length === 0 && (e.generateMipmaps = !1, e.minFilter = f.LinearFilter), e.needsUpdate = !0);
3748
+ normalizeMaterial(e, t, s, i) {
3749
+ if (!e)
3750
+ return e;
3751
+ this.clearBakedLighting(e);
3752
+ const n = this.getGLTFMaterialDef(t, e), r = s || e.type === "MeshBasicMaterial" || e.type === "MeshPhongMaterial" ? this.createStandardMaterial(e, n, s) : e;
3753
+ return this.processMaterialTextures(r, i, s), r.needsUpdate !== void 0 && (r.needsUpdate = !0), e !== r && typeof e.dispose == "function" && e.dispose(), r;
3754
+ }
3755
+ clearBakedLighting(e) {
3756
+ e.emissive && e.emissive.setHex(0), e.emissiveIntensity !== void 0 && (e.emissiveIntensity = 0), e.emissiveMap && (e.emissiveMap = null), e.lightMap && (e.lightMap = null), e.lightMapIntensity !== void 0 && (e.lightMapIntensity = 0);
3757
+ }
3758
+ createStandardMaterial(e, t, s) {
3759
+ const i = t?.pbrMetallicRoughness || {}, n = e.color?.clone?.() || new f.Color(16777215), o = new f.MeshStandardMaterial({
3760
+ color: n,
3761
+ side: s ? f.FrontSide : e.side ?? f.FrontSide,
3762
+ wireframe: e.wireframe || !1,
3763
+ vertexColors: e.vertexColors || !1,
3764
+ fog: e.fog ?? !0,
3765
+ flatShading: !1,
3766
+ roughness: s ? 1 : i.roughnessFactor ?? e.roughness ?? 0.8,
3767
+ metalness: s ? 0 : i.metallicFactor ?? e.metalness ?? 0.3
3768
+ });
3769
+ return e.map && (o.map = e.map), e.alphaMap && (o.alphaMap = e.alphaMap), e.transparent !== void 0 && (o.transparent = e.transparent), typeof e.opacity == "number" && (o.opacity = e.opacity), s || (e.aoMap && (o.aoMap = e.aoMap), typeof e.aoMapIntensity == "number" && (o.aoMapIntensity = e.aoMapIntensity), e.envMap && (o.envMap = e.envMap), e.roughnessMap && (o.roughnessMap = e.roughnessMap), e.metalnessMap && (o.metalnessMap = e.metalnessMap), e.normalMap && (o.normalMap = e.normalMap, o.normalScale = e.normalScale || new f.Vector2(1, 1))), o;
3770
+ }
3771
+ processMaterialTextures(e, t, s) {
3772
+ [
3773
+ "map",
3774
+ "alphaMap",
3775
+ "normalMap",
3776
+ "roughnessMap",
3777
+ "metalnessMap",
3778
+ "aoMap",
3779
+ "emissiveMap"
3780
+ ].forEach((n) => {
3781
+ e[n] && this.processTexture(e[n], t, {
3782
+ fixPhotogrammetryAtlas: s && n === "map"
3783
+ });
3784
+ });
3785
+ }
3786
+ getGLTFMaterialDef(e, t) {
3787
+ const s = e?.associations?.get?.(t)?.materials;
3788
+ return s == null ? null : e?.json?.materials?.[s] || null;
3789
+ }
3790
+ shouldNormalizePhotogrammetryAtlas(e) {
3791
+ const t = e?.json;
3792
+ if (!t)
3793
+ return !1;
3794
+ const s = t.materials || [], i = t.meshes || [], n = t.accessors || [];
3795
+ if (!s.length || !i.length)
3796
+ return !1;
3797
+ const o = s.some(
3798
+ (c) => c?.pbrMetallicRoughness?.baseColorTexture !== void 0
3799
+ ), r = s.some(
3800
+ (c) => c?.normalTexture || c?.occlusionTexture || c?.emissiveTexture || c?.pbrMetallicRoughness?.metallicRoughnessTexture
3801
+ );
3802
+ if (!o || r)
3803
+ return !1;
3804
+ let l = 0;
3805
+ for (const c of i)
3806
+ for (const A of c.primitives || []) {
3807
+ if (A?.attributes?.POSITION === void 0 || A.attributes.TEXCOORD_0 === void 0)
3808
+ return !1;
3809
+ const h = n[A.attributes.POSITION]?.count || 0, d = A.indices !== void 0 ? n[A.indices]?.count || 0 : h;
3810
+ l += Math.floor(d / 3);
3811
+ }
3812
+ return l >= 5e4;
3813
+ }
3814
+ processTexture(e, t = null, { fixPhotogrammetryAtlas: s = !1 } = {}) {
3815
+ e && (t !== null && (e.anisotropy = t), s && (e.isCompressedTexture || (e.generateMipmaps = !1), e.minFilter = f.LinearFilter, e.wrapS = f.ClampToEdgeWrapping, e.wrapT = f.ClampToEdgeWrapping), e.needsUpdate = !0);
3772
3816
  }
3773
3817
  canComputeTangents(e) {
3774
3818
  return !!(e?.index && e.attributes?.position && e.attributes?.normal && e.attributes?.uv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "belowjs",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "A modular Three.js library for creating immersive underwater/dive model viewers with VR support",
5
5
  "main": "dist/belowjs.js",
6
6
  "module": "dist/belowjs.js",