@a2f0/skyline 0.2.64 → 0.2.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2f0/skyline",
3
- "version": "0.2.64",
3
+ "version": "0.2.66",
4
4
  "description": "Interactive Chicago skyline viewer and reusable Three.js building models",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -94,7 +94,7 @@
94
94
  }
95
95
  },
96
96
  "devDependencies": {
97
- "@a2f0/agent-tool": "0.1.40",
97
+ "@a2f0/agent-tool": "0.1.46",
98
98
  "@tsconfig/strictest": "^2.0.8",
99
99
  "@types/bun": "^1.4.4",
100
100
  "esbuild": "0.28.2",
@@ -140,6 +140,10 @@ export function createBuildingStudy({ models, defaultView = "quarter", views = {
140
140
  let interacting = false;
141
141
  let frameId = 0;
142
142
  let lastTime = 0;
143
+ // Whether the canvas has a size to draw at. A study with none, such as the viewer's scene
144
+ // while the drawing shows, keeps its turntable on, but holds the camera and stops drawing
145
+ // frame after frame until its viewport shows again and resizes it.
146
+ let shown = true;
143
147
  let fittedDistance = 400;
144
148
  let activeView = defaultView;
145
149
  let frameFit = fit;
@@ -174,14 +178,14 @@ export function createBuildingStudy({ models, defaultView = "quarter", views = {
174
178
  }
175
179
  function render(time) {
176
180
  frameId = 0;
177
- if (turning && !document.hidden) {
181
+ if (turning && shown && !document.hidden) {
178
182
  const delta = lastTime ? Math.min((time - lastTime) / 1000, 0.1) : 0;
179
183
  const offset = camera.position.clone().sub(controls.target);
180
184
  offset.applyAxisAngle(new THREE.Vector3(0, 1, 0), delta * 0.16);
181
185
  camera.position.copy(controls.target).add(offset);
182
186
  controls.update();
183
187
  }
184
- lastTime = time;
188
+ lastTime = shown ? time : 0;
185
189
  renderer.render(scene, camera);
186
190
  labelLayer.hidden = !camera.isOrthographicCamera;
187
191
  const layerWidth = labelLayer.clientWidth, layerHeight = labelLayer.clientHeight;
@@ -200,7 +204,7 @@ export function createBuildingStudy({ models, defaultView = "quarter", views = {
200
204
  : placement === "below" ? [-12, layerHeight - height - 12] : [height + 10, layerHeight + 10];
201
205
  element.style.top = `${height && layerHeight ? Math.min(Math.max(y, top), Math.max(top, bottom)) : y}px`;
202
206
  }
203
- if (turning)
207
+ if (turning && shown)
204
208
  requestRender();
205
209
  }
206
210
  function clearHighlight() {
@@ -289,7 +293,8 @@ export function createBuildingStudy({ models, defaultView = "quarter", views = {
289
293
  const { width, height } = canvas.getBoundingClientRect();
290
294
  // A frame with no size, such as the skyline viewer's 3D scene while another mode shows,
291
295
  // has nothing to fit, and fitting to it would move an orbited eye.
292
- if (!width || !height)
296
+ shown = Boolean(width && height);
297
+ if (!shown)
293
298
  return;
294
299
  const previousFit = fittedDistance;
295
300
  const aspect = width / Math.max(height, 1);