@project-skymap/library 0.7.2 → 0.7.4
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 +54 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -9
- 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);
|
|
@@ -466,6 +476,7 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
466
476
|
}
|
|
467
477
|
load(config, getPosition) {
|
|
468
478
|
this.clear();
|
|
479
|
+
console.log(`[Constellation] Loading ${config.constellations.length} constellations from ${config.atlasBasePath}`);
|
|
469
480
|
const basePath = config.atlasBasePath.replace(/\/$/, "");
|
|
470
481
|
config.constellations.forEach((c) => {
|
|
471
482
|
let center = new THREE5__namespace.Vector3();
|
|
@@ -541,12 +552,16 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
541
552
|
// uScale, uAspect (screen) are injected by createSmartMaterial/globalUniforms
|
|
542
553
|
},
|
|
543
554
|
vertexShaderBody: `
|
|
555
|
+
#ifdef GL_ES
|
|
556
|
+
precision highp float;
|
|
557
|
+
#endif
|
|
558
|
+
|
|
544
559
|
uniform float uSize;
|
|
545
560
|
uniform float uImgRotation;
|
|
546
561
|
uniform float uImgAspect;
|
|
547
|
-
|
|
562
|
+
|
|
548
563
|
varying vec2 vUv;
|
|
549
|
-
|
|
564
|
+
|
|
550
565
|
void main() {
|
|
551
566
|
vUv = uv;
|
|
552
567
|
|
|
@@ -600,6 +615,9 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
600
615
|
}
|
|
601
616
|
`,
|
|
602
617
|
fragmentShader: `
|
|
618
|
+
#ifdef GL_ES
|
|
619
|
+
precision highp float;
|
|
620
|
+
#endif
|
|
603
621
|
uniform sampler2D uMap;
|
|
604
622
|
uniform float uOpacity;
|
|
605
623
|
varying vec2 vUv;
|
|
@@ -616,12 +634,25 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
616
634
|
blending,
|
|
617
635
|
side: THREE5__namespace.DoubleSide
|
|
618
636
|
});
|
|
619
|
-
material.uniforms.uMap.value = this.textureLoader.load(
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
637
|
+
material.uniforms.uMap.value = this.textureLoader.load(
|
|
638
|
+
texPath,
|
|
639
|
+
(tex) => {
|
|
640
|
+
tex.minFilter = THREE5__namespace.LinearFilter;
|
|
641
|
+
tex.magFilter = THREE5__namespace.LinearFilter;
|
|
642
|
+
tex.generateMipmaps = false;
|
|
643
|
+
tex.needsUpdate = true;
|
|
644
|
+
if (c.aspectRatio === void 0 && tex.image.width && tex.image.height) {
|
|
645
|
+
const natAspect = tex.image.width / tex.image.height;
|
|
646
|
+
material.uniforms.uImgAspect.value = natAspect;
|
|
647
|
+
}
|
|
648
|
+
console.log(`[Constellation] Loaded: ${c.id} (${tex.image.width}x${tex.image.height})`);
|
|
649
|
+
},
|
|
650
|
+
(progress) => {
|
|
651
|
+
},
|
|
652
|
+
(err) => {
|
|
653
|
+
console.error(`[Constellation] Failed to load: ${texPath}`, err);
|
|
623
654
|
}
|
|
624
|
-
|
|
655
|
+
);
|
|
625
656
|
if (c.zBias) {
|
|
626
657
|
material.polygonOffset = true;
|
|
627
658
|
material.polygonOffsetFactor = -c.zBias;
|
|
@@ -640,7 +671,9 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
640
671
|
}
|
|
641
672
|
update(fov, showArt) {
|
|
642
673
|
this.root.visible = showArt;
|
|
643
|
-
if (!showArt)
|
|
674
|
+
if (!showArt) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
644
677
|
for (const item of this.items) {
|
|
645
678
|
const { fade } = item.config;
|
|
646
679
|
let opacity = fade.maxOpacity;
|
|
@@ -961,6 +994,8 @@ function createEngine({
|
|
|
961
994
|
if (currentConfig?.fitProjection) {
|
|
962
995
|
if (aspect > 1) {
|
|
963
996
|
scale /= aspect;
|
|
997
|
+
} else {
|
|
998
|
+
scale *= aspect;
|
|
964
999
|
}
|
|
965
1000
|
}
|
|
966
1001
|
globalUniforms.uScale.value = scale;
|
|
@@ -2515,9 +2550,19 @@ function createEngine({
|
|
|
2515
2550
|
const t1 = touches[1];
|
|
2516
2551
|
const newDistance = getTouchDistance(t0, t1);
|
|
2517
2552
|
const scale = newDistance / state.pinchStartDistance;
|
|
2553
|
+
const prevFov = state.fov;
|
|
2518
2554
|
state.fov = state.pinchStartFov / scale;
|
|
2519
2555
|
state.fov = Math.max(ENGINE_CONFIG.minFov, Math.min(ENGINE_CONFIG.maxFov, state.fov));
|
|
2520
2556
|
handlers.onFovChange?.(state.fov);
|
|
2557
|
+
if (state.fov > prevFov && state.fov > ENGINE_CONFIG.zenithStartFov) {
|
|
2558
|
+
const range = ENGINE_CONFIG.maxFov - ENGINE_CONFIG.zenithStartFov;
|
|
2559
|
+
let t = (state.fov - ENGINE_CONFIG.zenithStartFov) / range;
|
|
2560
|
+
t = Math.max(0, Math.min(1, t));
|
|
2561
|
+
const bias = ENGINE_CONFIG.zenithStrength * t;
|
|
2562
|
+
const zenithLat = Math.PI / 2 - 1e-3;
|
|
2563
|
+
state.lat = state.lat * (1 - bias) + zenithLat * bias;
|
|
2564
|
+
state.targetLat = state.lat;
|
|
2565
|
+
}
|
|
2521
2566
|
const center = getTouchCenter(t0, t1);
|
|
2522
2567
|
const deltaX = center.x - state.lastMouseX;
|
|
2523
2568
|
const deltaY = center.y - state.lastMouseY;
|