@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.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
|
|
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);
|
|
@@ -444,6 +454,7 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
444
454
|
}
|
|
445
455
|
load(config, getPosition) {
|
|
446
456
|
this.clear();
|
|
457
|
+
console.log(`[Constellation] Loading ${config.constellations.length} constellations from ${config.atlasBasePath}`);
|
|
447
458
|
const basePath = config.atlasBasePath.replace(/\/$/, "");
|
|
448
459
|
config.constellations.forEach((c) => {
|
|
449
460
|
let center = new THREE5.Vector3();
|
|
@@ -519,12 +530,16 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
519
530
|
// uScale, uAspect (screen) are injected by createSmartMaterial/globalUniforms
|
|
520
531
|
},
|
|
521
532
|
vertexShaderBody: `
|
|
533
|
+
#ifdef GL_ES
|
|
534
|
+
precision highp float;
|
|
535
|
+
#endif
|
|
536
|
+
|
|
522
537
|
uniform float uSize;
|
|
523
538
|
uniform float uImgRotation;
|
|
524
539
|
uniform float uImgAspect;
|
|
525
|
-
|
|
540
|
+
|
|
526
541
|
varying vec2 vUv;
|
|
527
|
-
|
|
542
|
+
|
|
528
543
|
void main() {
|
|
529
544
|
vUv = uv;
|
|
530
545
|
|
|
@@ -578,6 +593,9 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
578
593
|
}
|
|
579
594
|
`,
|
|
580
595
|
fragmentShader: `
|
|
596
|
+
#ifdef GL_ES
|
|
597
|
+
precision highp float;
|
|
598
|
+
#endif
|
|
581
599
|
uniform sampler2D uMap;
|
|
582
600
|
uniform float uOpacity;
|
|
583
601
|
varying vec2 vUv;
|
|
@@ -594,12 +612,25 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
594
612
|
blending,
|
|
595
613
|
side: THREE5.DoubleSide
|
|
596
614
|
});
|
|
597
|
-
material.uniforms.uMap.value = this.textureLoader.load(
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
615
|
+
material.uniforms.uMap.value = this.textureLoader.load(
|
|
616
|
+
texPath,
|
|
617
|
+
(tex) => {
|
|
618
|
+
tex.minFilter = THREE5.LinearFilter;
|
|
619
|
+
tex.magFilter = THREE5.LinearFilter;
|
|
620
|
+
tex.generateMipmaps = false;
|
|
621
|
+
tex.needsUpdate = true;
|
|
622
|
+
if (c.aspectRatio === void 0 && tex.image.width && tex.image.height) {
|
|
623
|
+
const natAspect = tex.image.width / tex.image.height;
|
|
624
|
+
material.uniforms.uImgAspect.value = natAspect;
|
|
625
|
+
}
|
|
626
|
+
console.log(`[Constellation] Loaded: ${c.id} (${tex.image.width}x${tex.image.height})`);
|
|
627
|
+
},
|
|
628
|
+
(progress) => {
|
|
629
|
+
},
|
|
630
|
+
(err) => {
|
|
631
|
+
console.error(`[Constellation] Failed to load: ${texPath}`, err);
|
|
601
632
|
}
|
|
602
|
-
|
|
633
|
+
);
|
|
603
634
|
if (c.zBias) {
|
|
604
635
|
material.polygonOffset = true;
|
|
605
636
|
material.polygonOffsetFactor = -c.zBias;
|
|
@@ -618,7 +649,9 @@ var init_ConstellationArtworkLayer = __esm({
|
|
|
618
649
|
}
|
|
619
650
|
update(fov, showArt) {
|
|
620
651
|
this.root.visible = showArt;
|
|
621
|
-
if (!showArt)
|
|
652
|
+
if (!showArt) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
622
655
|
for (const item of this.items) {
|
|
623
656
|
const { fade } = item.config;
|
|
624
657
|
let opacity = fade.maxOpacity;
|
|
@@ -939,6 +972,8 @@ function createEngine({
|
|
|
939
972
|
if (currentConfig?.fitProjection) {
|
|
940
973
|
if (aspect > 1) {
|
|
941
974
|
scale /= aspect;
|
|
975
|
+
} else {
|
|
976
|
+
scale *= aspect;
|
|
942
977
|
}
|
|
943
978
|
}
|
|
944
979
|
globalUniforms.uScale.value = scale;
|
|
@@ -2493,9 +2528,19 @@ function createEngine({
|
|
|
2493
2528
|
const t1 = touches[1];
|
|
2494
2529
|
const newDistance = getTouchDistance(t0, t1);
|
|
2495
2530
|
const scale = newDistance / state.pinchStartDistance;
|
|
2531
|
+
const prevFov = state.fov;
|
|
2496
2532
|
state.fov = state.pinchStartFov / scale;
|
|
2497
2533
|
state.fov = Math.max(ENGINE_CONFIG.minFov, Math.min(ENGINE_CONFIG.maxFov, state.fov));
|
|
2498
2534
|
handlers.onFovChange?.(state.fov);
|
|
2535
|
+
if (state.fov > prevFov && state.fov > ENGINE_CONFIG.zenithStartFov) {
|
|
2536
|
+
const range = ENGINE_CONFIG.maxFov - ENGINE_CONFIG.zenithStartFov;
|
|
2537
|
+
let t = (state.fov - ENGINE_CONFIG.zenithStartFov) / range;
|
|
2538
|
+
t = Math.max(0, Math.min(1, t));
|
|
2539
|
+
const bias = ENGINE_CONFIG.zenithStrength * t;
|
|
2540
|
+
const zenithLat = Math.PI / 2 - 1e-3;
|
|
2541
|
+
state.lat = state.lat * (1 - bias) + zenithLat * bias;
|
|
2542
|
+
state.targetLat = state.lat;
|
|
2543
|
+
}
|
|
2499
2544
|
const center = getTouchCenter(t0, t1);
|
|
2500
2545
|
const deltaX = center.x - state.lastMouseX;
|
|
2501
2546
|
const deltaY = center.y - state.lastMouseY;
|