@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.cjs +55 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -338,6 +338,10 @@ var BLEND_CHUNK, MASK_CHUNK;
|
|
|
338
338
|
var init_shaders = __esm({
|
|
339
339
|
"src/engine/shaders.ts"() {
|
|
340
340
|
BLEND_CHUNK = `
|
|
341
|
+
#ifdef GL_ES
|
|
342
|
+
precision highp float;
|
|
343
|
+
#endif
|
|
344
|
+
|
|
341
345
|
uniform float uScale;
|
|
342
346
|
uniform float uAspect;
|
|
343
347
|
uniform float uBlend;
|
|
@@ -382,6 +386,10 @@ vec4 smartProject(vec4 viewPos) {
|
|
|
382
386
|
}
|
|
383
387
|
`;
|
|
384
388
|
MASK_CHUNK = `
|
|
389
|
+
#ifdef GL_ES
|
|
390
|
+
precision highp float;
|
|
391
|
+
#endif
|
|
392
|
+
|
|
385
393
|
uniform float uAspect;
|
|
386
394
|
uniform float uBlend;
|
|
387
395
|
uniform int uProjectionType;
|
|
@@ -447,10 +455,12 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
447
455
|
ConstellationArtworkLayer = class {
|
|
448
456
|
root;
|
|
449
457
|
items = [];
|
|
450
|
-
textureLoader
|
|
458
|
+
textureLoader;
|
|
451
459
|
hoveredId = null;
|
|
452
460
|
focusedId = null;
|
|
453
461
|
constructor(root) {
|
|
462
|
+
this.textureLoader = new THREE5__namespace.TextureLoader();
|
|
463
|
+
this.textureLoader.crossOrigin = "anonymous";
|
|
454
464
|
this.root = new THREE5__namespace.Group();
|
|
455
465
|
this.root.renderOrder = -1;
|
|
456
466
|
root.add(this.root);
|
|
@@ -541,12 +551,16 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
541
551
|
// uScale, uAspect (screen) are injected by createSmartMaterial/globalUniforms
|
|
542
552
|
},
|
|
543
553
|
vertexShaderBody: `
|
|
554
|
+
#ifdef GL_ES
|
|
555
|
+
precision highp float;
|
|
556
|
+
#endif
|
|
557
|
+
|
|
544
558
|
uniform float uSize;
|
|
545
559
|
uniform float uImgRotation;
|
|
546
560
|
uniform float uImgAspect;
|
|
547
|
-
|
|
561
|
+
|
|
548
562
|
varying vec2 vUv;
|
|
549
|
-
|
|
563
|
+
|
|
550
564
|
void main() {
|
|
551
565
|
vUv = uv;
|
|
552
566
|
|
|
@@ -600,6 +614,9 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
600
614
|
}
|
|
601
615
|
`,
|
|
602
616
|
fragmentShader: `
|
|
617
|
+
#ifdef GL_ES
|
|
618
|
+
precision highp float;
|
|
619
|
+
#endif
|
|
603
620
|
uniform sampler2D uMap;
|
|
604
621
|
uniform float uOpacity;
|
|
605
622
|
varying vec2 vUv;
|
|
@@ -616,12 +633,23 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
616
633
|
blending,
|
|
617
634
|
side: THREE5__namespace.DoubleSide
|
|
618
635
|
});
|
|
619
|
-
material.uniforms.uMap.value = this.textureLoader.load(
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
636
|
+
material.uniforms.uMap.value = this.textureLoader.load(
|
|
637
|
+
texPath,
|
|
638
|
+
(tex) => {
|
|
639
|
+
tex.minFilter = THREE5__namespace.LinearFilter;
|
|
640
|
+
tex.magFilter = THREE5__namespace.LinearFilter;
|
|
641
|
+
tex.generateMipmaps = false;
|
|
642
|
+
tex.needsUpdate = true;
|
|
643
|
+
if (c.aspectRatio === void 0 && tex.image.width && tex.image.height) {
|
|
644
|
+
const natAspect = tex.image.width / tex.image.height;
|
|
645
|
+
material.uniforms.uImgAspect.value = natAspect;
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
void 0,
|
|
649
|
+
(err) => {
|
|
650
|
+
console.warn(`Failed to load constellation texture: ${texPath}`, err);
|
|
623
651
|
}
|
|
624
|
-
|
|
652
|
+
);
|
|
625
653
|
if (c.zBias) {
|
|
626
654
|
material.polygonOffset = true;
|
|
627
655
|
material.polygonOffsetFactor = -c.zBias;
|
|
@@ -844,6 +872,12 @@ var createEngine_exports = {};
|
|
|
844
872
|
__export(createEngine_exports, {
|
|
845
873
|
createEngine: () => createEngine
|
|
846
874
|
});
|
|
875
|
+
function triggerHaptic(style = "light") {
|
|
876
|
+
if (typeof navigator !== "undefined" && "vibrate" in navigator) {
|
|
877
|
+
const durations = { light: 10, medium: 25, heavy: 50 };
|
|
878
|
+
navigator.vibrate(durations[style]);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
847
881
|
function createEngine({
|
|
848
882
|
container,
|
|
849
883
|
onSelect,
|
|
@@ -2459,6 +2493,7 @@ function createEngine({
|
|
|
2459
2493
|
clientY: state.touchStartY
|
|
2460
2494
|
};
|
|
2461
2495
|
const hit = pick(syntheticEvent);
|
|
2496
|
+
triggerHaptic("heavy");
|
|
2462
2497
|
handlers.onLongPress?.(hit?.node ?? null, state.touchStartX, state.touchStartY);
|
|
2463
2498
|
}
|
|
2464
2499
|
}, ENGINE_CONFIG.longPressDelay);
|
|
@@ -2508,9 +2543,19 @@ function createEngine({
|
|
|
2508
2543
|
const t1 = touches[1];
|
|
2509
2544
|
const newDistance = getTouchDistance(t0, t1);
|
|
2510
2545
|
const scale = newDistance / state.pinchStartDistance;
|
|
2546
|
+
const prevFov = state.fov;
|
|
2511
2547
|
state.fov = state.pinchStartFov / scale;
|
|
2512
2548
|
state.fov = Math.max(ENGINE_CONFIG.minFov, Math.min(ENGINE_CONFIG.maxFov, state.fov));
|
|
2513
2549
|
handlers.onFovChange?.(state.fov);
|
|
2550
|
+
if (state.fov > prevFov && state.fov > ENGINE_CONFIG.zenithStartFov) {
|
|
2551
|
+
const range = ENGINE_CONFIG.maxFov - ENGINE_CONFIG.zenithStartFov;
|
|
2552
|
+
let t = (state.fov - ENGINE_CONFIG.zenithStartFov) / range;
|
|
2553
|
+
t = Math.max(0, Math.min(1, t));
|
|
2554
|
+
const bias = ENGINE_CONFIG.zenithStrength * t;
|
|
2555
|
+
const zenithLat = Math.PI / 2 - 1e-3;
|
|
2556
|
+
state.lat = state.lat * (1 - bias) + zenithLat * bias;
|
|
2557
|
+
state.targetLat = state.lat;
|
|
2558
|
+
}
|
|
2514
2559
|
const center = getTouchCenter(t0, t1);
|
|
2515
2560
|
const deltaX = center.x - state.lastMouseX;
|
|
2516
2561
|
const deltaY = center.y - state.lastMouseY;
|
|
@@ -2553,6 +2598,7 @@ function createEngine({
|
|
|
2553
2598
|
const hit = pick(syntheticEvent);
|
|
2554
2599
|
if (isDoubleTap) {
|
|
2555
2600
|
if (hit) {
|
|
2601
|
+
triggerHaptic("medium");
|
|
2556
2602
|
flyTo(hit.node.id, ENGINE_CONFIG.minFov);
|
|
2557
2603
|
handlers.onSelect?.(hit.node);
|
|
2558
2604
|
}
|
|
@@ -2561,6 +2607,7 @@ function createEngine({
|
|
|
2561
2607
|
state.lastTapY = 0;
|
|
2562
2608
|
} else {
|
|
2563
2609
|
if (hit) {
|
|
2610
|
+
triggerHaptic("light");
|
|
2564
2611
|
handlers.onSelect?.(hit.node);
|
|
2565
2612
|
constellationLayer.setFocused(hit.node.id);
|
|
2566
2613
|
if (hit.node.level === 2) setFocusedBook(hit.node.id);
|