@connected-web/terrain-editor 0.1.4 → 0.1.5

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 CHANGED
@@ -941,10 +941,16 @@ async function initTerrainViewer(container, dataset, options = {}) {
941
941
  let viewportWidth = width;
942
942
  let viewportHeight = height;
943
943
  let viewOffsetPixels = 0;
944
+ const maxPixelRatio = Math.max(1, options.maxPixelRatio ?? 1.5);
945
+ let currentPixelRatio = 1;
946
+ function resolvePixelRatio() {
947
+ return Math.max(1, Math.min(window.devicePixelRatio || 1, maxPixelRatio));
948
+ }
944
949
  const renderer = new THREE2.WebGLRenderer({ antialias: true, alpha: true });
945
950
  renderer.toneMapping = THREE2.ACESFilmicToneMapping;
946
951
  renderer.toneMappingExposure = 1.08;
947
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
952
+ currentPixelRatio = resolvePixelRatio();
953
+ renderer.setPixelRatio(currentPixelRatio);
948
954
  const hostStyle = window.getComputedStyle(container);
949
955
  if (hostStyle.position === "static") {
950
956
  container.style.position = "relative";
@@ -1471,6 +1477,11 @@ async function initTerrainViewer(container, dataset, options = {}) {
1471
1477
  viewOffsetPixels = shiftTarget;
1472
1478
  camera.aspect = clientWidth / clientHeight;
1473
1479
  camera.updateProjectionMatrix();
1480
+ const nextPixelRatio = resolvePixelRatio();
1481
+ if (nextPixelRatio !== currentPixelRatio) {
1482
+ currentPixelRatio = nextPixelRatio;
1483
+ renderer.setPixelRatio(currentPixelRatio);
1484
+ }
1474
1485
  renderer.setSize(clientWidth, clientHeight, false);
1475
1486
  applyViewOffset();
1476
1487
  });
@@ -1497,6 +1508,8 @@ async function initTerrainViewer(container, dataset, options = {}) {
1497
1508
  const markerId = pickMarkerId();
1498
1509
  if (markerId !== hoveredLocationId) {
1499
1510
  hoveredLocationId = markerId;
1511
+ const hoveredLocation = markerId ? currentLocations.find((location) => location.id === markerId) : void 0;
1512
+ renderer.domElement.title = hoveredLocation?.name || hoveredLocation?.id || "";
1500
1513
  options.onLocationHover?.(markerId);
1501
1514
  updateMarkerVisuals();
1502
1515
  }
package/dist/index.d.cts CHANGED
@@ -82,6 +82,7 @@ type TerrainLocation = {
82
82
  id: string;
83
83
  name?: string;
84
84
  icon?: string;
85
+ description?: string;
85
86
  showBorder?: boolean;
86
87
  pixel: {
87
88
  x: number;
@@ -119,6 +120,7 @@ type TerrainInitOptions = {
119
120
  onLifecycleChange?: (state: ViewerLifecycleState) => void;
120
121
  heightScale?: number;
121
122
  waterLevelPercent?: number;
123
+ maxPixelRatio?: number;
122
124
  layers?: LayerToggleState;
123
125
  interactive?: boolean;
124
126
  onLocationPick?: (payload: LocationPickPayload) => void;
package/dist/index.d.ts CHANGED
@@ -82,6 +82,7 @@ type TerrainLocation = {
82
82
  id: string;
83
83
  name?: string;
84
84
  icon?: string;
85
+ description?: string;
85
86
  showBorder?: boolean;
86
87
  pixel: {
87
88
  x: number;
@@ -119,6 +120,7 @@ type TerrainInitOptions = {
119
120
  onLifecycleChange?: (state: ViewerLifecycleState) => void;
120
121
  heightScale?: number;
121
122
  waterLevelPercent?: number;
123
+ maxPixelRatio?: number;
122
124
  layers?: LayerToggleState;
123
125
  interactive?: boolean;
124
126
  onLocationPick?: (payload: LocationPickPayload) => void;
package/dist/index.js CHANGED
@@ -888,10 +888,16 @@ async function initTerrainViewer(container, dataset, options = {}) {
888
888
  let viewportWidth = width;
889
889
  let viewportHeight = height;
890
890
  let viewOffsetPixels = 0;
891
+ const maxPixelRatio = Math.max(1, options.maxPixelRatio ?? 1.5);
892
+ let currentPixelRatio = 1;
893
+ function resolvePixelRatio() {
894
+ return Math.max(1, Math.min(window.devicePixelRatio || 1, maxPixelRatio));
895
+ }
891
896
  const renderer = new THREE2.WebGLRenderer({ antialias: true, alpha: true });
892
897
  renderer.toneMapping = THREE2.ACESFilmicToneMapping;
893
898
  renderer.toneMappingExposure = 1.08;
894
- renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
899
+ currentPixelRatio = resolvePixelRatio();
900
+ renderer.setPixelRatio(currentPixelRatio);
895
901
  const hostStyle = window.getComputedStyle(container);
896
902
  if (hostStyle.position === "static") {
897
903
  container.style.position = "relative";
@@ -1418,6 +1424,11 @@ async function initTerrainViewer(container, dataset, options = {}) {
1418
1424
  viewOffsetPixels = shiftTarget;
1419
1425
  camera.aspect = clientWidth / clientHeight;
1420
1426
  camera.updateProjectionMatrix();
1427
+ const nextPixelRatio = resolvePixelRatio();
1428
+ if (nextPixelRatio !== currentPixelRatio) {
1429
+ currentPixelRatio = nextPixelRatio;
1430
+ renderer.setPixelRatio(currentPixelRatio);
1431
+ }
1421
1432
  renderer.setSize(clientWidth, clientHeight, false);
1422
1433
  applyViewOffset();
1423
1434
  });
@@ -1444,6 +1455,8 @@ async function initTerrainViewer(container, dataset, options = {}) {
1444
1455
  const markerId = pickMarkerId();
1445
1456
  if (markerId !== hoveredLocationId) {
1446
1457
  hoveredLocationId = markerId;
1458
+ const hoveredLocation = markerId ? currentLocations.find((location) => location.id === markerId) : void 0;
1459
+ renderer.domElement.title = hoveredLocation?.name || hoveredLocation?.id || "";
1447
1460
  options.onLocationHover?.(markerId);
1448
1461
  updateMarkerVisuals();
1449
1462
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connected-web/terrain-editor",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Reusable viewer/editor utilities for Wyn terrain files.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",