@project-skymap/library 0.7.1 → 0.7.3

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/dist/index.js CHANGED
@@ -316,6 +316,10 @@ var BLEND_CHUNK, MASK_CHUNK;
316
316
  var init_shaders = __esm({
317
317
  "src/engine/shaders.ts"() {
318
318
  BLEND_CHUNK = `
319
+ #ifdef GL_ES
320
+ precision highp float;
321
+ #endif
322
+
319
323
  uniform float uScale;
320
324
  uniform float uAspect;
321
325
  uniform float uBlend;
@@ -360,6 +364,10 @@ vec4 smartProject(vec4 viewPos) {
360
364
  }
361
365
  `;
362
366
  MASK_CHUNK = `
367
+ #ifdef GL_ES
368
+ precision highp float;
369
+ #endif
370
+
363
371
  uniform float uAspect;
364
372
  uniform float uBlend;
365
373
  uniform int uProjectionType;
@@ -425,10 +433,12 @@ var init_ConstellationArtworkLayer = __esm({
425
433
  ConstellationArtworkLayer = class {
426
434
  root;
427
435
  items = [];
428
- textureLoader = new THREE5.TextureLoader();
436
+ textureLoader;
429
437
  hoveredId = null;
430
438
  focusedId = null;
431
439
  constructor(root) {
440
+ this.textureLoader = new THREE5.TextureLoader();
441
+ this.textureLoader.crossOrigin = "anonymous";
432
442
  this.root = new THREE5.Group();
433
443
  this.root.renderOrder = -1;
434
444
  root.add(this.root);
@@ -519,12 +529,16 @@ var init_ConstellationArtworkLayer = __esm({
519
529
  // uScale, uAspect (screen) are injected by createSmartMaterial/globalUniforms
520
530
  },
521
531
  vertexShaderBody: `
532
+ #ifdef GL_ES
533
+ precision highp float;
534
+ #endif
535
+
522
536
  uniform float uSize;
523
537
  uniform float uImgRotation;
524
538
  uniform float uImgAspect;
525
-
539
+
526
540
  varying vec2 vUv;
527
-
541
+
528
542
  void main() {
529
543
  vUv = uv;
530
544
 
@@ -578,6 +592,9 @@ var init_ConstellationArtworkLayer = __esm({
578
592
  }
579
593
  `,
580
594
  fragmentShader: `
595
+ #ifdef GL_ES
596
+ precision highp float;
597
+ #endif
581
598
  uniform sampler2D uMap;
582
599
  uniform float uOpacity;
583
600
  varying vec2 vUv;
@@ -594,12 +611,23 @@ var init_ConstellationArtworkLayer = __esm({
594
611
  blending,
595
612
  side: THREE5.DoubleSide
596
613
  });
597
- material.uniforms.uMap.value = this.textureLoader.load(texPath, (tex) => {
598
- if (c.aspectRatio === void 0 && tex.image.width && tex.image.height) {
599
- const natAspect = tex.image.width / tex.image.height;
600
- material.uniforms.uImgAspect.value = natAspect;
614
+ material.uniforms.uMap.value = this.textureLoader.load(
615
+ texPath,
616
+ (tex) => {
617
+ tex.minFilter = THREE5.LinearFilter;
618
+ tex.magFilter = THREE5.LinearFilter;
619
+ tex.generateMipmaps = false;
620
+ tex.needsUpdate = true;
621
+ if (c.aspectRatio === void 0 && tex.image.width && tex.image.height) {
622
+ const natAspect = tex.image.width / tex.image.height;
623
+ material.uniforms.uImgAspect.value = natAspect;
624
+ }
625
+ },
626
+ void 0,
627
+ (err) => {
628
+ console.warn(`Failed to load constellation texture: ${texPath}`, err);
601
629
  }
602
- });
630
+ );
603
631
  if (c.zBias) {
604
632
  material.polygonOffset = true;
605
633
  material.polygonOffsetFactor = -c.zBias;
@@ -822,6 +850,12 @@ var createEngine_exports = {};
822
850
  __export(createEngine_exports, {
823
851
  createEngine: () => createEngine
824
852
  });
853
+ function triggerHaptic(style = "light") {
854
+ if (typeof navigator !== "undefined" && "vibrate" in navigator) {
855
+ const durations = { light: 10, medium: 25, heavy: 50 };
856
+ navigator.vibrate(durations[style]);
857
+ }
858
+ }
825
859
  function createEngine({
826
860
  container,
827
861
  onSelect,
@@ -2437,6 +2471,7 @@ function createEngine({
2437
2471
  clientY: state.touchStartY
2438
2472
  };
2439
2473
  const hit = pick(syntheticEvent);
2474
+ triggerHaptic("heavy");
2440
2475
  handlers.onLongPress?.(hit?.node ?? null, state.touchStartX, state.touchStartY);
2441
2476
  }
2442
2477
  }, ENGINE_CONFIG.longPressDelay);
@@ -2486,9 +2521,19 @@ function createEngine({
2486
2521
  const t1 = touches[1];
2487
2522
  const newDistance = getTouchDistance(t0, t1);
2488
2523
  const scale = newDistance / state.pinchStartDistance;
2524
+ const prevFov = state.fov;
2489
2525
  state.fov = state.pinchStartFov / scale;
2490
2526
  state.fov = Math.max(ENGINE_CONFIG.minFov, Math.min(ENGINE_CONFIG.maxFov, state.fov));
2491
2527
  handlers.onFovChange?.(state.fov);
2528
+ if (state.fov > prevFov && state.fov > ENGINE_CONFIG.zenithStartFov) {
2529
+ const range = ENGINE_CONFIG.maxFov - ENGINE_CONFIG.zenithStartFov;
2530
+ let t = (state.fov - ENGINE_CONFIG.zenithStartFov) / range;
2531
+ t = Math.max(0, Math.min(1, t));
2532
+ const bias = ENGINE_CONFIG.zenithStrength * t;
2533
+ const zenithLat = Math.PI / 2 - 1e-3;
2534
+ state.lat = state.lat * (1 - bias) + zenithLat * bias;
2535
+ state.targetLat = state.lat;
2536
+ }
2492
2537
  const center = getTouchCenter(t0, t1);
2493
2538
  const deltaX = center.x - state.lastMouseX;
2494
2539
  const deltaY = center.y - state.lastMouseY;
@@ -2531,6 +2576,7 @@ function createEngine({
2531
2576
  const hit = pick(syntheticEvent);
2532
2577
  if (isDoubleTap) {
2533
2578
  if (hit) {
2579
+ triggerHaptic("medium");
2534
2580
  flyTo(hit.node.id, ENGINE_CONFIG.minFov);
2535
2581
  handlers.onSelect?.(hit.node);
2536
2582
  }
@@ -2539,6 +2585,7 @@ function createEngine({
2539
2585
  state.lastTapY = 0;
2540
2586
  } else {
2541
2587
  if (hit) {
2588
+ triggerHaptic("light");
2542
2589
  handlers.onSelect?.(hit.node);
2543
2590
  constellationLayer.setFocused(hit.node.id);
2544
2591
  if (hit.node.level === 2) setFocusedBook(hit.node.id);