|
149 | 149 | // Persisted zoom; recompute only on viewport changes
|
150 | 150 | let computed_zoom = $state<number>(initial_zoom)
|
151 | 151 | $effect(() => {
|
152 |
| - if (width > 0 && height > 0) return |
| 152 | + if (!(width > 0) || !(height > 0)) return |
153 | 153 | // Avoid depending on structure/structure_size so trajectories don't retrigger zoom
|
154 | 154 | const structure_max_dim = Math.max(1, untrack(() => structure_size))
|
155 | 155 | const viewer_min_dim = Math.min(width, height)
|
156 | 156 | const scale_factor = viewer_min_dim / (structure_max_dim * 50) // 50px per unit
|
157 |
| - let next = initial_zoom * scale_factor |
158 |
| - if (min_zoom != null) next = Math.max(min_zoom, next) |
159 |
| - if (max_zoom != null) next = Math.min(max_zoom, next) |
160 |
| - computed_zoom = next |
| 157 | + let new_zoom = initial_zoom * scale_factor |
| 158 | + if (min_zoom && min_zoom > 0) new_zoom = Math.max(min_zoom, new_zoom) |
| 159 | + if (max_zoom && max_zoom > 0) new_zoom = Math.min(max_zoom, new_zoom) |
| 160 | + computed_zoom = new_zoom |
161 | 161 | })
|
162 | 162 |
|
163 | 163 | $effect.pre(() => {
|
|
308 | 308 | enablePan: pan_speed > 0,
|
309 | 309 | panSpeed: pan_speed,
|
310 | 310 | target: rotation_target,
|
311 |
| - maxZoom: camera_projection === `orthographic` ? (max_zoom ?? 200) : max_zoom, |
312 |
| - minZoom: camera_projection === `orthographic` ? (min_zoom ?? 0.1) : min_zoom, |
| 311 | + maxZoom: camera_projection === `orthographic` ? (max_zoom || 200) : max_zoom, |
| 312 | + minZoom: camera_projection === `orthographic` ? (min_zoom || 0.1) : min_zoom, |
313 | 313 | autoRotate: Boolean(auto_rotate),
|
314 | 314 | autoRotateSpeed: auto_rotate,
|
315 | 315 | enableDamping: Boolean(rotation_damping),
|
|
0 commit comments