@ifc-lite/viewer 1.17.4 → 1.17.6
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/.turbo/turbo-build.log +16 -16
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +117 -0
- package/DESKTOP_CONTRACT_VERSION +1 -1
- package/dist/assets/{basketViewActivator-BmnNtVfZ.js → basketViewActivator-86rgogji.js} +1 -1
- package/dist/assets/drawing-2d-DoxKMqbO.js +257 -0
- package/dist/assets/{exporters-ChAtBmlj.js → exporters-CcPS9MK5.js} +2274 -2227
- package/dist/assets/{geometry.worker-BQ0rzNo-.js → geometry.worker-BFUYA08u.js} +1 -1
- package/dist/assets/ids-DQ5jY0E8.js +1 -0
- package/dist/assets/ifc-lite_bg-BINvzoCP.wasm +0 -0
- package/dist/assets/{index-Co8E2-FE.js → index-Bfms9I4A.js} +35160 -33084
- package/dist/assets/index-_bfZsDCC.css +1 -0
- package/dist/assets/{native-bridge-BRvbckFQ.js → native-bridge-DUyLCMZS.js} +104 -104
- package/dist/assets/{sandbox-DZiNLNMk.js → sandbox-C8575tul.js} +4340 -4322
- package/dist/assets/{server-client-BV8zHZ7Y.js → server-client-BuZK7OST.js} +1 -1
- package/dist/assets/{wasm-bridge-g01g7T9b.js → wasm-bridge-JsqEGDV8.js} +1 -1
- package/dist/index.html +8 -7
- package/index.html +1 -0
- package/package.json +7 -7
- package/src/App.tsx +16 -2
- package/src/components/viewer/CesiumOverlay.tsx +62 -19
- package/src/components/viewer/ChatPanel.tsx +195 -91
- package/src/components/viewer/MainToolbar.tsx +4 -3
- package/src/components/viewer/PropertiesPanel.tsx +16 -2
- package/src/components/viewer/SettingsPage.tsx +252 -101
- package/src/components/viewer/ThemeSwitch.tsx +63 -7
- package/src/components/viewer/ViewerLayout.tsx +1 -0
- package/src/components/viewer/Viewport.tsx +14 -2
- package/src/components/viewer/ViewportContainer.tsx +49 -64
- package/src/components/viewer/ViewportOverlays.tsx +5 -2
- package/src/components/viewer/bcf/BCFTopicDetail.tsx +4 -4
- package/src/components/viewer/chat/ModelSelector.tsx +90 -54
- package/src/components/viewer/properties/GeoreferencingPanel.tsx +113 -51
- package/src/components/viewer/properties/LocationMap.tsx +9 -7
- package/src/components/viewer/properties/ModelMetadataPanel.tsx +1 -1
- package/src/components/viewer/tools/SectionCapControls.tsx +237 -0
- package/src/components/viewer/tools/SectionPanel.tsx +39 -18
- package/src/components/viewer/useAnimationLoop.ts +9 -1
- package/src/components/viewer/useRenderUpdates.ts +1 -1
- package/src/hooks/ids/idsDataAccessor.ts +60 -24
- package/src/hooks/ingest/viewerModelIngest.ts +7 -2
- package/src/hooks/useIfcFederation.ts +326 -71
- package/src/hooks/useIfcLoader.ts +1 -0
- package/src/hooks/useViewControls.ts +13 -5
- package/src/index.css +484 -10
- package/src/lib/desktop-entitlement.ts +2 -4
- package/src/lib/geo/cesium-bridge.ts +15 -7
- package/src/lib/geo/effective-georef.test.ts +73 -0
- package/src/lib/geo/effective-georef.ts +111 -0
- package/src/lib/geo/reproject.ts +105 -19
- package/src/lib/llm/byok-guard.test.ts +77 -0
- package/src/lib/llm/byok-guard.ts +39 -0
- package/src/lib/llm/free-models.test.ts +0 -6
- package/src/lib/llm/models.ts +104 -42
- package/src/lib/llm/stream-client.ts +74 -110
- package/src/lib/llm/stream-direct.test.ts +130 -0
- package/src/lib/llm/stream-direct.ts +316 -0
- package/src/lib/llm/types.ts +14 -2
- package/src/main.tsx +1 -10
- package/src/services/api-keys.ts +73 -0
- package/src/store/constants.ts +20 -2
- package/src/store/index.ts +12 -5
- package/src/store/slices/cesiumSlice.ts +5 -0
- package/src/store/slices/chatSlice.test.ts +6 -76
- package/src/store/slices/chatSlice.ts +17 -58
- package/src/store/slices/sectionSlice.test.ts +87 -7
- package/src/store/slices/sectionSlice.ts +151 -5
- package/src/store/slices/uiSlice.ts +28 -5
- package/src/store/types.ts +26 -0
- package/src/utils/nativeSpatialDataStore.ts +4 -1
- package/src/utils/viewportUtils.ts +7 -2
- package/src/vite-env.d.ts +0 -4
- package/dist/assets/drawing-2d-gWfpdfYe.js +0 -257
- package/dist/assets/ids-B4jTqB1O.js +0 -1
- package/dist/assets/ifc-lite_bg-BX4E7TX8.wasm +0 -0
- package/dist/assets/index-DckuDqlv.css +0 -1
- package/src/components/viewer/UpgradePage.tsx +0 -71
- package/src/lib/desktop/ClerkDesktopEntitlementSync.tsx +0 -175
- package/src/lib/llm/ClerkChatSync.tsx +0 -74
- package/src/lib/llm/clerk-auth.ts +0 -62
|
@@ -16,6 +16,9 @@ import { useViewerStore } from '@/store';
|
|
|
16
16
|
import type { CoordinateInfo, GeometryResult } from '@ifc-lite/geometry';
|
|
17
17
|
import { EpsgLookupDialog, type EpsgResult } from './EpsgLookupDialog';
|
|
18
18
|
import { LocationMap, type PickedPosition } from './LocationMap';
|
|
19
|
+
import { mergeMapConversion, mergeProjectedCRS } from '@/lib/geo/effective-georef';
|
|
20
|
+
import { useIfc } from '@/hooks/useIfc';
|
|
21
|
+
import { toast } from '@/components/ui/toast';
|
|
19
22
|
|
|
20
23
|
// ── Field-specific assistance data ─────────────────────────────────────
|
|
21
24
|
|
|
@@ -319,9 +322,11 @@ export interface GeoreferencingPanelProps {
|
|
|
319
322
|
coordinateInfo?: CoordinateInfo;
|
|
320
323
|
/** GeometryResult for KMZ export */
|
|
321
324
|
geometryResult?: GeometryResult | null;
|
|
325
|
+
/** IFC project length unit → metres (e.g. 0.001 for mm models). Default 1. */
|
|
326
|
+
lengthUnitScale?: number;
|
|
322
327
|
}
|
|
323
328
|
|
|
324
|
-
export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVersion, coordinateInfo, geometryResult }: GeoreferencingPanelProps) {
|
|
329
|
+
export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVersion, coordinateInfo, geometryResult, lengthUnitScale }: GeoreferencingPanelProps) {
|
|
325
330
|
const georefMutations = useViewerStore(s => s.georefMutations);
|
|
326
331
|
const setGeorefField = useViewerStore(s => s.setGeorefField);
|
|
327
332
|
const setGeorefFields = useViewerStore(s => s.setGeorefFields);
|
|
@@ -330,10 +335,14 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
330
335
|
const setCesiumTerrainClamp = useViewerStore(s => s.setCesiumTerrainClamp);
|
|
331
336
|
const cesiumTerrainHeight = useViewerStore(s => s.cesiumTerrainHeight);
|
|
332
337
|
const cesiumSourceModelId = useViewerStore(s => s.cesiumSourceModelId);
|
|
338
|
+
const models = useViewerStore(s => s.models);
|
|
339
|
+
const loading = useViewerStore(s => s.loading);
|
|
340
|
+
const { addModel, clearAllModels } = useIfc();
|
|
333
341
|
// Only show terrain actions when this panel's model is the one backing the Cesium overlay
|
|
334
342
|
const isActiveCesiumModel = !!modelId && modelId === cesiumSourceModelId;
|
|
335
343
|
const [crsOpen, setCrsOpen] = useState(false);
|
|
336
344
|
const [conversionOpen, setConversionOpen] = useState(false);
|
|
345
|
+
const [showReloadPrompt, setShowReloadPrompt] = useState(false);
|
|
337
346
|
|
|
338
347
|
useViewerStore(s => s.mutationVersion);
|
|
339
348
|
|
|
@@ -341,37 +350,12 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
341
350
|
const supportsStandardGeoreferencing = !schemaVersion?.toUpperCase().includes('2X3');
|
|
342
351
|
|
|
343
352
|
const mergedCRS = useMemo((): ProjectedCRS | undefined => {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (!base && !muts) return undefined;
|
|
347
|
-
return {
|
|
348
|
-
id: base?.id ?? 0,
|
|
349
|
-
name: muts?.name ?? base?.name ?? '',
|
|
350
|
-
description: muts?.description ?? base?.description,
|
|
351
|
-
geodeticDatum: muts?.geodeticDatum ?? base?.geodeticDatum,
|
|
352
|
-
verticalDatum: muts?.verticalDatum ?? base?.verticalDatum,
|
|
353
|
-
mapProjection: muts?.mapProjection ?? base?.mapProjection,
|
|
354
|
-
mapZone: muts?.mapZone ?? base?.mapZone,
|
|
355
|
-
mapUnit: muts?.mapUnit ?? base?.mapUnit,
|
|
356
|
-
};
|
|
357
|
-
}, [georef, mutations]);
|
|
353
|
+
return mergeProjectedCRS(georef?.projectedCRS, mutations?.projectedCRS, lengthUnitScale ?? 1);
|
|
354
|
+
}, [georef?.projectedCRS, mutations?.projectedCRS, lengthUnitScale]);
|
|
358
355
|
|
|
359
356
|
const mergedConversion = useMemo((): MapConversion | undefined => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (!base && !muts) return undefined;
|
|
363
|
-
return {
|
|
364
|
-
id: base?.id ?? 0,
|
|
365
|
-
sourceCRS: base?.sourceCRS ?? 0,
|
|
366
|
-
targetCRS: base?.targetCRS ?? 0,
|
|
367
|
-
eastings: muts?.eastings ?? base?.eastings ?? 0,
|
|
368
|
-
northings: muts?.northings ?? base?.northings ?? 0,
|
|
369
|
-
orthogonalHeight: muts?.orthogonalHeight ?? base?.orthogonalHeight ?? 0,
|
|
370
|
-
xAxisAbscissa: muts?.xAxisAbscissa ?? base?.xAxisAbscissa,
|
|
371
|
-
xAxisOrdinate: muts?.xAxisOrdinate ?? base?.xAxisOrdinate,
|
|
372
|
-
scale: muts?.scale ?? base?.scale,
|
|
373
|
-
};
|
|
374
|
-
}, [georef, mutations]);
|
|
357
|
+
return mergeMapConversion(georef?.mapConversion, mutations?.mapConversion);
|
|
358
|
+
}, [georef?.mapConversion, mutations?.mapConversion]);
|
|
375
359
|
|
|
376
360
|
const angleToGridNorth = useMemo(() => {
|
|
377
361
|
return computeAngleToGridNorth(mergedConversion?.xAxisAbscissa, mergedConversion?.xAxisOrdinate);
|
|
@@ -399,22 +383,69 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
399
383
|
return field in entityMuts;
|
|
400
384
|
}, [mutations]);
|
|
401
385
|
|
|
386
|
+
const requestAlignmentReload = useCallback(() => {
|
|
387
|
+
if (models.size > 1) {
|
|
388
|
+
setShowReloadPrompt(true);
|
|
389
|
+
}
|
|
390
|
+
}, [models.size]);
|
|
391
|
+
|
|
392
|
+
const reloadModelsForAlignment = useCallback(async () => {
|
|
393
|
+
const state = useViewerStore.getState();
|
|
394
|
+
const snapshot = Array.from(state.models.values()).sort((a, b) => (a.loadedAt ?? 0) - (b.loadedAt ?? 0));
|
|
395
|
+
const missingSource = snapshot.find(model => !model.sourceFile);
|
|
396
|
+
if (snapshot.length < 2) {
|
|
397
|
+
setShowReloadPrompt(false);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (missingSource) {
|
|
401
|
+
toast.error(`Cannot reload ${missingSource.name}: source file is not available`);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
try {
|
|
406
|
+
clearAllModels();
|
|
407
|
+
for (const model of snapshot) {
|
|
408
|
+
const sourceFile = model.sourceFile;
|
|
409
|
+
if (!sourceFile) continue;
|
|
410
|
+
const reloadedModelId = await addModel(sourceFile, {
|
|
411
|
+
name: model.name,
|
|
412
|
+
modelId: model.id,
|
|
413
|
+
loadedAt: model.loadedAt,
|
|
414
|
+
visible: model.visible,
|
|
415
|
+
collapsed: model.collapsed,
|
|
416
|
+
});
|
|
417
|
+
if (!reloadedModelId) {
|
|
418
|
+
throw new Error(`Failed to reload ${model.name}`);
|
|
419
|
+
}
|
|
420
|
+
if (model.visible === false) {
|
|
421
|
+
useViewerStore.getState().setModelVisibility(model.id, false);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
setShowReloadPrompt(false);
|
|
425
|
+
toast.success('Reloaded models for edited georeferencing');
|
|
426
|
+
} catch (error) {
|
|
427
|
+
toast.error(error instanceof Error ? error.message : 'Reload failed');
|
|
428
|
+
}
|
|
429
|
+
}, [addModel, clearAllModels]);
|
|
430
|
+
|
|
402
431
|
const handleSave = useCallback((entity: 'projectedCRS' | 'mapConversion', field: string, value: string | number) => {
|
|
403
432
|
if (!modelId || !setGeorefField) return;
|
|
404
433
|
const oldValue = entity === 'projectedCRS'
|
|
405
|
-
?
|
|
406
|
-
:
|
|
434
|
+
? mergedCRS?.[field as keyof ProjectedCRS]
|
|
435
|
+
: mergedConversion?.[field as keyof MapConversion];
|
|
407
436
|
setGeorefField(modelId, entity, field, value, oldValue as string | number | undefined);
|
|
408
|
-
|
|
437
|
+
requestAlignmentReload();
|
|
438
|
+
}, [modelId, setGeorefField, mergedCRS, mergedConversion, requestAlignmentReload]);
|
|
409
439
|
|
|
410
440
|
// Handle angle edit: compute and set both XAxisAbscissa and XAxisOrdinate
|
|
411
441
|
const handleAngleChange = useCallback((abscissa: number, ordinate: number) => {
|
|
412
442
|
if (!modelId || !setGeorefFields) return;
|
|
413
443
|
setGeorefFields(modelId, 'mapConversion', [
|
|
414
|
-
{ field: 'xAxisAbscissa', value: abscissa, oldValue:
|
|
415
|
-
{ field: 'xAxisOrdinate', value: ordinate, oldValue:
|
|
444
|
+
{ field: 'xAxisAbscissa', value: abscissa, oldValue: mergedConversion?.xAxisAbscissa },
|
|
445
|
+
{ field: 'xAxisOrdinate', value: ordinate, oldValue: mergedConversion?.xAxisOrdinate },
|
|
416
446
|
]);
|
|
417
|
-
|
|
447
|
+
requestAlignmentReload();
|
|
448
|
+
}, [modelId, setGeorefFields, mergedConversion, requestAlignmentReload]);
|
|
418
449
|
|
|
419
450
|
// Handle position picked from the map (reverse-projected easting/northing + optional terrain height)
|
|
420
451
|
const handleApplyPosition = useCallback((position: PickedPosition) => {
|
|
@@ -432,35 +463,37 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
432
463
|
}
|
|
433
464
|
setGeorefFields(modelId, 'mapConversion', fields);
|
|
434
465
|
setConversionOpen(true);
|
|
435
|
-
|
|
466
|
+
requestAlignmentReload();
|
|
467
|
+
}, [modelId, setGeorefFields, mergedConversion, requestAlignmentReload]);
|
|
436
468
|
|
|
437
469
|
const initializeMapConversionDefaults = useCallback(() => {
|
|
438
470
|
if (!modelId || !setGeorefFields) return;
|
|
439
471
|
setGeorefFields(modelId, 'mapConversion', [
|
|
440
|
-
{ field: 'eastings', value:
|
|
441
|
-
{ field: 'northings', value:
|
|
442
|
-
{ field: 'orthogonalHeight', value:
|
|
443
|
-
{ field: 'xAxisAbscissa', value:
|
|
444
|
-
{ field: 'xAxisOrdinate', value:
|
|
445
|
-
{ field: 'scale', value:
|
|
472
|
+
{ field: 'eastings', value: mergedConversion?.eastings ?? 0, oldValue: mergedConversion?.eastings },
|
|
473
|
+
{ field: 'northings', value: mergedConversion?.northings ?? 0, oldValue: mergedConversion?.northings },
|
|
474
|
+
{ field: 'orthogonalHeight', value: mergedConversion?.orthogonalHeight ?? 0, oldValue: mergedConversion?.orthogonalHeight },
|
|
475
|
+
{ field: 'xAxisAbscissa', value: mergedConversion?.xAxisAbscissa ?? 1, oldValue: mergedConversion?.xAxisAbscissa },
|
|
476
|
+
{ field: 'xAxisOrdinate', value: mergedConversion?.xAxisOrdinate ?? 0, oldValue: mergedConversion?.xAxisOrdinate },
|
|
477
|
+
{ field: 'scale', value: mergedConversion?.scale ?? 1, oldValue: mergedConversion?.scale },
|
|
446
478
|
]);
|
|
447
479
|
setConversionOpen(true);
|
|
448
|
-
|
|
480
|
+
requestAlignmentReload();
|
|
481
|
+
}, [modelId, setGeorefFields, mergedConversion, requestAlignmentReload]);
|
|
449
482
|
|
|
450
483
|
const handleEpsgSelect = useCallback((result: EpsgResult) => {
|
|
451
484
|
if (!modelId || !setGeorefFields) return;
|
|
452
485
|
const epsgName = `EPSG:${result.code}`;
|
|
453
486
|
const fieldUpdates: Array<{ field: string; value: string | number; oldValue?: string | number }> = [
|
|
454
|
-
{ field: 'name', value: epsgName, oldValue:
|
|
487
|
+
{ field: 'name', value: epsgName, oldValue: mergedCRS?.name },
|
|
455
488
|
];
|
|
456
489
|
if (result.name) {
|
|
457
|
-
fieldUpdates.push({ field: 'description', value: result.name, oldValue:
|
|
490
|
+
fieldUpdates.push({ field: 'description', value: result.name, oldValue: mergedCRS?.description });
|
|
458
491
|
}
|
|
459
492
|
if (result.datum) {
|
|
460
|
-
fieldUpdates.push({ field: 'geodeticDatum', value: result.datum, oldValue:
|
|
493
|
+
fieldUpdates.push({ field: 'geodeticDatum', value: result.datum, oldValue: mergedCRS?.geodeticDatum });
|
|
461
494
|
}
|
|
462
495
|
if (result.projection) {
|
|
463
|
-
fieldUpdates.push({ field: 'mapProjection', value: result.projection, oldValue:
|
|
496
|
+
fieldUpdates.push({ field: 'mapProjection', value: result.projection, oldValue: mergedCRS?.mapProjection });
|
|
464
497
|
}
|
|
465
498
|
if (result.unit) {
|
|
466
499
|
const unitUpper = result.unit.toUpperCase();
|
|
@@ -471,14 +504,15 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
471
504
|
: unitUpper.includes('FOOT') || unitUpper.includes('FEET')
|
|
472
505
|
? 'FOOT'
|
|
473
506
|
: result.unit;
|
|
474
|
-
fieldUpdates.push({ field: 'mapUnit', value: mapUnit, oldValue:
|
|
507
|
+
fieldUpdates.push({ field: 'mapUnit', value: mapUnit, oldValue: mergedCRS?.mapUnit });
|
|
475
508
|
}
|
|
476
509
|
setGeorefFields(modelId, 'projectedCRS', fieldUpdates);
|
|
477
|
-
if (!
|
|
510
|
+
if (!mergedConversion && !mutations?.mapConversion) {
|
|
478
511
|
initializeMapConversionDefaults();
|
|
479
512
|
}
|
|
480
513
|
setCrsOpen(true);
|
|
481
|
-
|
|
514
|
+
requestAlignmentReload();
|
|
515
|
+
}, [modelId, setGeorefFields, mergedCRS, mergedConversion, mutations, initializeMapConversionDefaults, requestAlignmentReload]);
|
|
482
516
|
|
|
483
517
|
const hasData = mergedCRS || mergedConversion;
|
|
484
518
|
const editable = enableEditing && !!modelId && supportsStandardGeoreferencing;
|
|
@@ -513,6 +547,33 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
513
547
|
|
|
514
548
|
return (
|
|
515
549
|
<div>
|
|
550
|
+
{showReloadPrompt && (
|
|
551
|
+
<div className="mx-2 my-2 border border-teal-300 dark:border-teal-700 bg-teal-50 dark:bg-teal-950/40 px-2.5 py-2">
|
|
552
|
+
<div className="flex items-start gap-2">
|
|
553
|
+
<MapPin className="h-3.5 w-3.5 text-teal-600 dark:text-teal-400 shrink-0 mt-0.5" />
|
|
554
|
+
<div className="min-w-0 flex-1">
|
|
555
|
+
<p className="text-[10px] text-zinc-700 dark:text-zinc-300">
|
|
556
|
+
Georeference saved. Reload loaded models to recompute 3D alignment?
|
|
557
|
+
</p>
|
|
558
|
+
<div className="mt-1.5 flex items-center gap-2">
|
|
559
|
+
<button
|
|
560
|
+
onClick={reloadModelsForAlignment}
|
|
561
|
+
disabled={loading}
|
|
562
|
+
className="px-2 py-0.5 text-[10px] font-medium text-white bg-teal-600 hover:bg-teal-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
563
|
+
>
|
|
564
|
+
Reload models
|
|
565
|
+
</button>
|
|
566
|
+
<button
|
|
567
|
+
onClick={() => setShowReloadPrompt(false)}
|
|
568
|
+
className="px-2 py-0.5 text-[10px] text-zinc-600 dark:text-zinc-300 hover:bg-zinc-200/60 dark:hover:bg-zinc-800"
|
|
569
|
+
>
|
|
570
|
+
Later
|
|
571
|
+
</button>
|
|
572
|
+
</div>
|
|
573
|
+
</div>
|
|
574
|
+
</div>
|
|
575
|
+
</div>
|
|
576
|
+
)}
|
|
516
577
|
{/* CRS summary — always visible */}
|
|
517
578
|
<div className="px-2 py-1.5 flex items-center gap-2">
|
|
518
579
|
<Globe className="h-3 w-3 text-teal-500 shrink-0" />
|
|
@@ -663,6 +724,7 @@ export function GeoreferencingPanel({ georef, modelId, enableEditing, schemaVers
|
|
|
663
724
|
projectedCRS={mergedCRS}
|
|
664
725
|
coordinateInfo={coordinateInfo}
|
|
665
726
|
geometryResult={geometryResult}
|
|
727
|
+
lengthUnitScale={lengthUnitScale}
|
|
666
728
|
editable={editable}
|
|
667
729
|
onApplyPosition={editable ? handleApplyPosition : undefined}
|
|
668
730
|
/>
|
|
@@ -49,6 +49,8 @@ export interface LocationMapProps {
|
|
|
49
49
|
coordinateInfo?: CoordinateInfo;
|
|
50
50
|
/** Geometry result for KMZ export (optional — KMZ button hidden if not provided) */
|
|
51
51
|
geometryResult?: GeometryResult | null;
|
|
52
|
+
/** IFC project length unit → metres (e.g. 0.001 for mm models). Default 1 (metres). */
|
|
53
|
+
lengthUnitScale?: number;
|
|
52
54
|
/** Whether the map is in edit mode (allows repositioning) */
|
|
53
55
|
editable?: boolean;
|
|
54
56
|
/** Called when the user applies a new position from the map */
|
|
@@ -138,7 +140,7 @@ function removeFootprintFromMap(map: InstanceType<typeof import('maplibre-gl').M
|
|
|
138
140
|
|
|
139
141
|
export function LocationMap({
|
|
140
142
|
mapConversion, projectedCRS, coordinateInfo, geometryResult,
|
|
141
|
-
editable, onApplyPosition,
|
|
143
|
+
lengthUnitScale = 1, editable, onApplyPosition,
|
|
142
144
|
}: LocationMapProps) {
|
|
143
145
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
144
146
|
const mapRef = useRef<InstanceType<typeof import('maplibre-gl').Map> | null>(null);
|
|
@@ -195,14 +197,14 @@ export function LocationMap({
|
|
|
195
197
|
|
|
196
198
|
let cancelled = false;
|
|
197
199
|
|
|
198
|
-
computeFootprintGeoJSON(mapConversion, projectedCRS, coordinateInfo).then(fp => {
|
|
200
|
+
computeFootprintGeoJSON(mapConversion, projectedCRS, coordinateInfo, lengthUnitScale).then(fp => {
|
|
199
201
|
if (cancelled) return;
|
|
200
202
|
setFootprint(fp);
|
|
201
203
|
footprintRef.current = fp;
|
|
202
204
|
});
|
|
203
205
|
|
|
204
206
|
return () => { cancelled = true; };
|
|
205
|
-
}, [mapConversion, projectedCRS, coordinateInfo]);
|
|
207
|
+
}, [mapConversion, projectedCRS, coordinateInfo, lengthUnitScale]);
|
|
206
208
|
|
|
207
209
|
// Geocode search
|
|
208
210
|
useEffect(() => {
|
|
@@ -234,7 +236,7 @@ export function LocationMap({
|
|
|
234
236
|
setMapState('loading');
|
|
235
237
|
setError(null);
|
|
236
238
|
|
|
237
|
-
reprojectToLatLon(mapConversion, projectedCRS, coordinateInfo).then(result => {
|
|
239
|
+
reprojectToLatLon(mapConversion, projectedCRS, coordinateInfo, lengthUnitScale).then(result => {
|
|
238
240
|
if (cancelled) return;
|
|
239
241
|
if (result) {
|
|
240
242
|
setLatLon(result);
|
|
@@ -247,7 +249,7 @@ export function LocationMap({
|
|
|
247
249
|
});
|
|
248
250
|
|
|
249
251
|
return () => { cancelled = true; };
|
|
250
|
-
}, [mapConversion, projectedCRS, coordinateInfo]);
|
|
252
|
+
}, [mapConversion, projectedCRS, coordinateInfo, lengthUnitScale]);
|
|
251
253
|
|
|
252
254
|
// When a picked position changes, reverse-project and query elevation
|
|
253
255
|
useEffect(() => {
|
|
@@ -262,7 +264,7 @@ export function LocationMap({
|
|
|
262
264
|
|
|
263
265
|
// Reverse-project to get IfcMapConversion eastings/northings
|
|
264
266
|
// Accounts for model local geometry offset, rotation, and scale
|
|
265
|
-
reprojectFromLatLon(pickedLatLon, projectedCRS, mapConversion, coordinateInfo).then(coords => {
|
|
267
|
+
reprojectFromLatLon(pickedLatLon, projectedCRS, mapConversion, coordinateInfo, lengthUnitScale).then(coords => {
|
|
266
268
|
if (!cancelled) setProjectedCoords(coords);
|
|
267
269
|
});
|
|
268
270
|
|
|
@@ -276,7 +278,7 @@ export function LocationMap({
|
|
|
276
278
|
});
|
|
277
279
|
|
|
278
280
|
return () => { cancelled = true; };
|
|
279
|
-
}, [pickedLatLon, projectedCRS, mapConversion, coordinateInfo]);
|
|
281
|
+
}, [pickedLatLon, projectedCRS, mapConversion, coordinateInfo, lengthUnitScale]);
|
|
280
282
|
|
|
281
283
|
// Place or move the picked marker on the map
|
|
282
284
|
const updatePickedMarker = useCallback((pos: LatLon, maplibregl: typeof import('maplibre-gl')) => {
|
|
@@ -212,7 +212,7 @@ export function ModelMetadataPanel({ model }: { model: FederatedModel }) {
|
|
|
212
212
|
</div>
|
|
213
213
|
|
|
214
214
|
{/* Georeferencing */}
|
|
215
|
-
<GeoreferencingPanel georef={georef} modelId={model.id} enableEditing schemaVersion={model.schemaVersion} coordinateInfo={model.geometryResult?.coordinateInfo} geometryResult={model.geometryResult} />
|
|
215
|
+
<GeoreferencingPanel georef={georef} modelId={model.id} enableEditing schemaVersion={model.schemaVersion} coordinateInfo={model.geometryResult?.coordinateInfo} geometryResult={model.geometryResult} lengthUnitScale={unitInfo?.scale} />
|
|
216
216
|
|
|
217
217
|
{/* IfcProject Data */}
|
|
218
218
|
{projectData && (
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cap-surface appearance controls shown inside the expanded Section panel.
|
|
7
|
+
*
|
|
8
|
+
* Layout principle (tight compact panel, ≤ 260 px wide):
|
|
9
|
+
* [Display] Surfaces ⬛ Lines ⬛
|
|
10
|
+
* ───────────────────────────────────────────────
|
|
11
|
+
* [Hatch] <pattern select>
|
|
12
|
+
* [Colours] Fill ▣ Hatch ▣
|
|
13
|
+
* [Shape] Spacing __px Angle __° Width __px
|
|
14
|
+
*
|
|
15
|
+
* Surfaces and Lines toggle independently so users can get a clean
|
|
16
|
+
* "architectural drawing" look (outlines only), a pure hatched fill, or
|
|
17
|
+
* the combination. All style inputs are hidden when Surfaces is off.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useCallback, useId } from 'react';
|
|
21
|
+
import { useViewerStore } from '@/store';
|
|
22
|
+
import type { SectionCapHatchId } from '@/store/types';
|
|
23
|
+
|
|
24
|
+
const PATTERN_LABELS: Record<SectionCapHatchId, string> = {
|
|
25
|
+
solid: 'Solid fill',
|
|
26
|
+
diagonal: 'Diagonal',
|
|
27
|
+
crossHatch: 'Cross-hatch',
|
|
28
|
+
horizontal: 'Horizontal',
|
|
29
|
+
vertical: 'Vertical',
|
|
30
|
+
concrete: 'Concrete',
|
|
31
|
+
brick: 'Brick',
|
|
32
|
+
insulation: 'Insulation',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const PATTERN_IDS: SectionCapHatchId[] = [
|
|
36
|
+
'diagonal', 'crossHatch', 'horizontal', 'vertical',
|
|
37
|
+
'concrete', 'brick', 'insulation', 'solid',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
function rgbaToHex(c: [number, number, number, number]): string {
|
|
41
|
+
const to2 = (v: number) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).padStart(2, '0');
|
|
42
|
+
return `#${to2(c[0])}${to2(c[1])}${to2(c[2])}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function hexToRgba(hex: string, alpha: number): [number, number, number, number] {
|
|
46
|
+
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
47
|
+
if (!m) return [1, 1, 1, alpha];
|
|
48
|
+
return [
|
|
49
|
+
parseInt(m[1], 16) / 255,
|
|
50
|
+
parseInt(m[2], 16) / 255,
|
|
51
|
+
parseInt(m[3], 16) / 255,
|
|
52
|
+
alpha,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface DisplayToggleProps {
|
|
57
|
+
active: boolean;
|
|
58
|
+
label: string;
|
|
59
|
+
onToggle: () => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function DisplayToggle({ active, label, onToggle }: DisplayToggleProps): React.JSX.Element {
|
|
63
|
+
return (
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
onClick={onToggle}
|
|
67
|
+
aria-pressed={active}
|
|
68
|
+
className={`flex items-center justify-center gap-1.5 px-2 py-1 text-[10px] font-mono uppercase tracking-wide border rounded transition-colors ${
|
|
69
|
+
active
|
|
70
|
+
? 'bg-primary text-primary-foreground border-primary'
|
|
71
|
+
: 'bg-muted text-muted-foreground border-muted hover:border-foreground/20'
|
|
72
|
+
}`}
|
|
73
|
+
title={`${active ? 'Hide' : 'Show'} ${label.toLowerCase()}`}
|
|
74
|
+
>
|
|
75
|
+
<span
|
|
76
|
+
aria-hidden
|
|
77
|
+
className={`inline-block h-1.5 w-1.5 rounded-full ${active ? 'bg-primary-foreground' : 'bg-muted-foreground'}`}
|
|
78
|
+
/>
|
|
79
|
+
{label}
|
|
80
|
+
</button>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function SectionCapControls(): React.JSX.Element {
|
|
85
|
+
const sectionPlane = useViewerStore((s) => s.sectionPlane);
|
|
86
|
+
const setShowCap = useViewerStore((s) => s.setSectionShowCap);
|
|
87
|
+
const setShowOutlines = useViewerStore((s) => s.setSectionShowOutlines);
|
|
88
|
+
const setCapStyle = useViewerStore((s) => s.setSectionCapStyle);
|
|
89
|
+
|
|
90
|
+
const onPattern = useCallback((e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
91
|
+
setCapStyle({ pattern: e.target.value as SectionCapHatchId });
|
|
92
|
+
}, [setCapStyle]);
|
|
93
|
+
|
|
94
|
+
const onFillColor = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
95
|
+
setCapStyle({ fillColor: hexToRgba(e.target.value, sectionPlane.capStyle.fillColor[3]) });
|
|
96
|
+
}, [setCapStyle, sectionPlane.capStyle.fillColor]);
|
|
97
|
+
|
|
98
|
+
const onStrokeColor = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
99
|
+
setCapStyle({ strokeColor: hexToRgba(e.target.value, sectionPlane.capStyle.strokeColor[3]) });
|
|
100
|
+
}, [setCapStyle, sectionPlane.capStyle.strokeColor]);
|
|
101
|
+
|
|
102
|
+
const onSpacing = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
103
|
+
const v = Number(e.target.value);
|
|
104
|
+
if (Number.isFinite(v)) setCapStyle({ spacingPx: Math.max(2, v) });
|
|
105
|
+
}, [setCapStyle]);
|
|
106
|
+
|
|
107
|
+
const onAngle = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
108
|
+
const deg = Number(e.target.value);
|
|
109
|
+
if (Number.isFinite(deg)) setCapStyle({ angleRad: (deg * Math.PI) / 180 });
|
|
110
|
+
}, [setCapStyle]);
|
|
111
|
+
|
|
112
|
+
const onWidth = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
113
|
+
const v = Number(e.target.value);
|
|
114
|
+
if (Number.isFinite(v)) setCapStyle({ widthPx: Math.max(1, v) });
|
|
115
|
+
}, [setCapStyle]);
|
|
116
|
+
|
|
117
|
+
const onToggleCap = useCallback(() => setShowCap(!sectionPlane.showCap), [setShowCap, sectionPlane.showCap]);
|
|
118
|
+
const onToggleOutlines = useCallback(() => setShowOutlines(!sectionPlane.showOutlines), [setShowOutlines, sectionPlane.showOutlines]);
|
|
119
|
+
|
|
120
|
+
const angleDeg = Math.round((sectionPlane.capStyle.angleRad * 180) / Math.PI);
|
|
121
|
+
|
|
122
|
+
// Stable ids for label/control association. Multiple instances of the
|
|
123
|
+
// panel (rare, but possible during HMR) each get their own id namespace.
|
|
124
|
+
const baseId = useId();
|
|
125
|
+
const patternId = `${baseId}-pattern`;
|
|
126
|
+
const fillId = `${baseId}-fill`;
|
|
127
|
+
const strokeId = `${baseId}-stroke`;
|
|
128
|
+
const spacingId = `${baseId}-spacing`;
|
|
129
|
+
const angleId = `${baseId}-angle`;
|
|
130
|
+
const widthId = `${baseId}-width`;
|
|
131
|
+
|
|
132
|
+
const hatchInputsDisabled = !sectionPlane.showCap;
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<div className="mt-3 border-t pt-3 space-y-3">
|
|
136
|
+
{/* Display toggles — surfaces and lines independently. */}
|
|
137
|
+
<div>
|
|
138
|
+
<div className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5">Display</div>
|
|
139
|
+
<div className="grid grid-cols-2 gap-2">
|
|
140
|
+
<DisplayToggle active={sectionPlane.showCap} label="Surfaces" onToggle={onToggleCap} />
|
|
141
|
+
<DisplayToggle active={sectionPlane.showOutlines} label="Lines" onToggle={onToggleOutlines} />
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{/* Hatch style — disabled visually when surfaces are off. */}
|
|
146
|
+
<fieldset
|
|
147
|
+
disabled={hatchInputsDisabled}
|
|
148
|
+
className={`space-y-2 ${hatchInputsDisabled ? 'opacity-50 pointer-events-none' : ''}`}
|
|
149
|
+
>
|
|
150
|
+
<div>
|
|
151
|
+
<label htmlFor={patternId} className="text-[10px] uppercase tracking-wider text-muted-foreground block mb-1">
|
|
152
|
+
Hatch pattern
|
|
153
|
+
</label>
|
|
154
|
+
<select
|
|
155
|
+
id={patternId}
|
|
156
|
+
value={sectionPlane.capStyle.pattern}
|
|
157
|
+
onChange={onPattern}
|
|
158
|
+
className="w-full text-xs bg-muted px-2 py-1.5 rounded border-none"
|
|
159
|
+
>
|
|
160
|
+
{PATTERN_IDS.map((id) => (
|
|
161
|
+
<option key={id} value={id}>{PATTERN_LABELS[id]}</option>
|
|
162
|
+
))}
|
|
163
|
+
</select>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div className="grid grid-cols-2 gap-2">
|
|
167
|
+
<label htmlFor={fillId} className="flex items-center gap-2 text-[10px] uppercase tracking-wider text-muted-foreground">
|
|
168
|
+
<input
|
|
169
|
+
id={fillId}
|
|
170
|
+
type="color"
|
|
171
|
+
value={rgbaToHex(sectionPlane.capStyle.fillColor)}
|
|
172
|
+
onChange={onFillColor}
|
|
173
|
+
className="h-5 w-5 rounded cursor-pointer border border-muted"
|
|
174
|
+
aria-label="Fill colour"
|
|
175
|
+
/>
|
|
176
|
+
Fill
|
|
177
|
+
</label>
|
|
178
|
+
<label htmlFor={strokeId} className="flex items-center gap-2 text-[10px] uppercase tracking-wider text-muted-foreground">
|
|
179
|
+
<input
|
|
180
|
+
id={strokeId}
|
|
181
|
+
type="color"
|
|
182
|
+
value={rgbaToHex(sectionPlane.capStyle.strokeColor)}
|
|
183
|
+
onChange={onStrokeColor}
|
|
184
|
+
className="h-5 w-5 rounded cursor-pointer border border-muted"
|
|
185
|
+
aria-label="Hatch colour"
|
|
186
|
+
/>
|
|
187
|
+
Hatch
|
|
188
|
+
</label>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<div className="grid grid-cols-3 gap-2">
|
|
192
|
+
<div>
|
|
193
|
+
<label htmlFor={spacingId} className="text-[10px] text-muted-foreground block mb-1">Spacing (px)</label>
|
|
194
|
+
<input
|
|
195
|
+
id={spacingId}
|
|
196
|
+
type="number"
|
|
197
|
+
min="2"
|
|
198
|
+
max="64"
|
|
199
|
+
step="1"
|
|
200
|
+
value={sectionPlane.capStyle.spacingPx}
|
|
201
|
+
onChange={onSpacing}
|
|
202
|
+
className="w-full text-xs bg-muted px-1.5 py-0.5 rounded border-none text-right"
|
|
203
|
+
/>
|
|
204
|
+
</div>
|
|
205
|
+
<div>
|
|
206
|
+
<label htmlFor={angleId} className="text-[10px] text-muted-foreground block mb-1">Angle (°)</label>
|
|
207
|
+
<input
|
|
208
|
+
id={angleId}
|
|
209
|
+
type="number"
|
|
210
|
+
min="-180"
|
|
211
|
+
max="180"
|
|
212
|
+
step="5"
|
|
213
|
+
value={angleDeg}
|
|
214
|
+
onChange={onAngle}
|
|
215
|
+
className="w-full text-xs bg-muted px-1.5 py-0.5 rounded border-none text-right"
|
|
216
|
+
/>
|
|
217
|
+
</div>
|
|
218
|
+
<div>
|
|
219
|
+
<label htmlFor={widthId} className="text-[10px] text-muted-foreground block mb-1">Width (px)</label>
|
|
220
|
+
<input
|
|
221
|
+
id={widthId}
|
|
222
|
+
type="number"
|
|
223
|
+
min="1"
|
|
224
|
+
max="16"
|
|
225
|
+
step="0.5"
|
|
226
|
+
value={sectionPlane.capStyle.widthPx}
|
|
227
|
+
onChange={onWidth}
|
|
228
|
+
className="w-full text-xs bg-muted px-1.5 py-0.5 rounded border-none text-right"
|
|
229
|
+
/>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</fieldset>
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default SectionCapControls;
|