@wovvmap/renderer-three 0.0.0-stage → 1.2.0
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/controllers/ImageController.d.ts +95 -0
- package/dist/controllers/ImageController.d.ts.map +1 -0
- package/dist/controllers/ImageController.js +129 -0
- package/dist/controllers/ShapeController.d.ts +95 -0
- package/dist/controllers/ShapeController.d.ts.map +1 -0
- package/dist/controllers/ShapeController.js +139 -0
- package/dist/controllers/TextController.d.ts +120 -0
- package/dist/controllers/TextController.d.ts.map +1 -0
- package/dist/controllers/TextController.js +161 -0
- package/dist/controllers/ViewerElementsController.d.ts +254 -0
- package/dist/controllers/ViewerElementsController.d.ts.map +1 -0
- package/dist/controllers/ViewerElementsController.js +490 -0
- package/dist/engine/CameraFollow.d.ts +13 -0
- package/dist/engine/CameraFollow.d.ts.map +1 -0
- package/dist/engine/CameraFollow.js +52 -0
- package/dist/engine/CameraManager.d.ts +143 -0
- package/dist/engine/CameraManager.d.ts.map +1 -0
- package/dist/engine/CameraManager.js +566 -0
- package/dist/engine/ControlsManager.d.ts +123 -0
- package/dist/engine/ControlsManager.d.ts.map +1 -0
- package/dist/engine/ControlsManager.js +604 -0
- package/dist/engine/InteractionManager.d.ts +45 -0
- package/dist/engine/InteractionManager.d.ts.map +1 -0
- package/dist/engine/InteractionManager.js +99 -0
- package/dist/engine/LightingManager.d.ts +25 -0
- package/dist/engine/LightingManager.d.ts.map +1 -0
- package/dist/engine/LightingManager.js +74 -0
- package/dist/engine/MapViewerEngine.d.ts +350 -0
- package/dist/engine/MapViewerEngine.d.ts.map +1 -0
- package/dist/engine/MapViewerEngine.js +1041 -0
- package/dist/engine/RendererManager.d.ts +77 -0
- package/dist/engine/RendererManager.d.ts.map +1 -0
- package/dist/engine/RendererManager.js +243 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/services/image-services/ImageCacheService.d.ts +49 -0
- package/dist/services/image-services/ImageCacheService.d.ts.map +1 -0
- package/dist/services/image-services/ImageCacheService.js +121 -0
- package/dist/services/image-services/ImagePlaneService.d.ts +29 -0
- package/dist/services/image-services/ImagePlaneService.d.ts.map +1 -0
- package/dist/services/image-services/ImagePlaneService.js +82 -0
- package/dist/services/image-services/ImageService.d.ts +170 -0
- package/dist/services/image-services/ImageService.d.ts.map +1 -0
- package/dist/services/image-services/ImageService.js +537 -0
- package/dist/services/image-services/ImageSpriteService.d.ts +39 -0
- package/dist/services/image-services/ImageSpriteService.d.ts.map +1 -0
- package/dist/services/image-services/ImageSpriteService.js +135 -0
- package/dist/services/routes/RouteArrows.d.ts +34 -0
- package/dist/services/routes/RouteArrows.d.ts.map +1 -0
- package/dist/services/routes/RouteArrows.js +157 -0
- package/dist/services/routes/RouteCursor.d.ts +19 -0
- package/dist/services/routes/RouteCursor.d.ts.map +1 -0
- package/dist/services/routes/RouteCursor.js +68 -0
- package/dist/services/routes/RouteMotion.d.ts +31 -0
- package/dist/services/routes/RouteMotion.d.ts.map +1 -0
- package/dist/services/routes/RouteMotion.js +132 -0
- package/dist/services/routes/RouteRenderer.d.ts +52 -0
- package/dist/services/routes/RouteRenderer.d.ts.map +1 -0
- package/dist/services/routes/RouteRenderer.js +445 -0
- package/dist/services/routes/RouteStepHighlight.d.ts +22 -0
- package/dist/services/routes/RouteStepHighlight.d.ts.map +1 -0
- package/dist/services/routes/RouteStepHighlight.js +84 -0
- package/dist/services/routes/routeMarkers.d.ts +6 -0
- package/dist/services/routes/routeMarkers.d.ts.map +1 -0
- package/dist/services/routes/routeMarkers.js +41 -0
- package/dist/services/selectionPaint.d.ts +12 -0
- package/dist/services/selectionPaint.d.ts.map +1 -0
- package/dist/services/selectionPaint.js +8 -0
- package/dist/services/shape-services/ExtrudeShapeService.d.ts +54 -0
- package/dist/services/shape-services/ExtrudeShapeService.d.ts.map +1 -0
- package/dist/services/shape-services/ExtrudeShapeService.js +204 -0
- package/dist/services/shape-services/FlatShapeService.d.ts +25 -0
- package/dist/services/shape-services/FlatShapeService.d.ts.map +1 -0
- package/dist/services/shape-services/FlatShapeService.js +49 -0
- package/dist/services/shape-services/IShapeService.d.ts +24 -0
- package/dist/services/shape-services/IShapeService.d.ts.map +1 -0
- package/dist/services/shape-services/IShapeService.js +6 -0
- package/dist/services/shape-services/MaterialUtils.d.ts +15 -0
- package/dist/services/shape-services/MaterialUtils.d.ts.map +1 -0
- package/dist/services/shape-services/MaterialUtils.js +71 -0
- package/dist/services/shape-services/ShapeFactory.d.ts +20 -0
- package/dist/services/shape-services/ShapeFactory.d.ts.map +1 -0
- package/dist/services/shape-services/ShapeFactory.js +28 -0
- package/dist/services/shape-services/ShapeHighlightService.d.ts +13 -0
- package/dist/services/shape-services/ShapeHighlightService.d.ts.map +1 -0
- package/dist/services/shape-services/ShapeHighlightService.js +57 -0
- package/dist/services/shape-services/ShapeService.d.ts +129 -0
- package/dist/services/shape-services/ShapeService.d.ts.map +1 -0
- package/dist/services/shape-services/ShapeService.js +480 -0
- package/dist/services/shape-services/preparedGeometry.d.ts +13 -0
- package/dist/services/shape-services/preparedGeometry.d.ts.map +1 -0
- package/dist/services/shape-services/preparedGeometry.js +37 -0
- package/dist/services/text-services/ITextRenderStrategy.d.ts +79 -0
- package/dist/services/text-services/ITextRenderStrategy.d.ts.map +1 -0
- package/dist/services/text-services/ITextRenderStrategy.js +7 -0
- package/dist/services/text-services/Text2DService.d.ts +66 -0
- package/dist/services/text-services/Text2DService.d.ts.map +1 -0
- package/dist/services/text-services/Text2DService.js +483 -0
- package/dist/services/text-services/Text3DService.d.ts +51 -0
- package/dist/services/text-services/Text3DService.d.ts.map +1 -0
- package/dist/services/text-services/Text3DService.js +246 -0
- package/dist/services/text-services/TextCollisionService.d.ts +29 -0
- package/dist/services/text-services/TextCollisionService.d.ts.map +1 -0
- package/dist/services/text-services/TextCollisionService.js +117 -0
- package/dist/services/text-services/TextService.d.ts +159 -0
- package/dist/services/text-services/TextService.d.ts.map +1 -0
- package/dist/services/text-services/TextService.js +398 -0
- package/dist/services/text-services/TextStrategyRegistry.d.ts +36 -0
- package/dist/services/text-services/TextStrategyRegistry.d.ts.map +1 -0
- package/dist/services/text-services/TextStrategyRegistry.js +44 -0
- package/dist/services/threeDisposeHelper.d.ts +12 -0
- package/dist/services/threeDisposeHelper.d.ts.map +1 -0
- package/dist/services/threeDisposeHelper.js +57 -0
- package/package.json +40 -3
- package/README.md +0 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ImageSpriteService.ts
|
|
3
|
+
* @description Generates and updates vertical camera-facing transit/amenity icon sprites.
|
|
4
|
+
* Escalator, Elevator, Restroom jaise vertical transit icons jo camera ki taraf face karte hain (THREE.Sprite).
|
|
5
|
+
*/
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
import { resolveModeDepth, resolveSurfaceElevation } from '@wovvmap/contracts';
|
|
8
|
+
/**
|
|
9
|
+
* Creates and updates billboard sprites for vertical transit and amenity waypoints.
|
|
10
|
+
* Camera ki taraf auto-face karne wale icon sprites create karein.
|
|
11
|
+
*/
|
|
12
|
+
export class ImageSpriteService {
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a sprite group containing a circular background badge and the amenity icon.
|
|
15
|
+
* Background circle aur amenity icon sprite ka group banayein.
|
|
16
|
+
*/
|
|
17
|
+
static create(texture, imageAsset, node, scale = 1, currentMode = '3D', depthConfig, tintColor = '#62236b') {
|
|
18
|
+
const group = new THREE.Group();
|
|
19
|
+
group.userData.floorBash = Boolean(node.shapeDetail?.floorBash);
|
|
20
|
+
group.userData.isFloorBase = Boolean(node.shapeDetail?.floorBash);
|
|
21
|
+
// 1. Background circular badge
|
|
22
|
+
const bgSprite = this.createBackgroundCircle(tintColor);
|
|
23
|
+
bgSprite.name = 'bg-circle';
|
|
24
|
+
group.add(bgSprite);
|
|
25
|
+
// 2. Icon sprite
|
|
26
|
+
const material = new THREE.SpriteMaterial({
|
|
27
|
+
map: texture || null,
|
|
28
|
+
transparent: true,
|
|
29
|
+
depthWrite: false,
|
|
30
|
+
depthTest: true,
|
|
31
|
+
color: texture ? 0xffffff : 0xcccccc,
|
|
32
|
+
});
|
|
33
|
+
const iconSprite = new THREE.Sprite(material);
|
|
34
|
+
iconSprite.name = 'icon-sprite';
|
|
35
|
+
group.add(iconSprite);
|
|
36
|
+
const width = (imageAsset.width ?? 10) * scale;
|
|
37
|
+
const height = (imageAsset.height ?? 10) * scale;
|
|
38
|
+
iconSprite.scale.set(width, height, 1);
|
|
39
|
+
const bgSize = Math.max(width, height) * 1.5;
|
|
40
|
+
bgSprite.scale.set(bgSize, bgSize, 1);
|
|
41
|
+
const modeConfig = resolveModeDepth(currentMode, depthConfig);
|
|
42
|
+
const surfaceElevation = resolveSurfaceElevation(node, currentMode, depthConfig);
|
|
43
|
+
const yPos = surfaceElevation + modeConfig.extraDepthSprite;
|
|
44
|
+
group.position.set((imageAsset.x ?? 0) * scale + width / 2, yPos, (imageAsset.y ?? 0) * scale + height / 2);
|
|
45
|
+
group.userData = {
|
|
46
|
+
isSpriteGroup: true,
|
|
47
|
+
originalWidth: imageAsset.width,
|
|
48
|
+
originalHeight: imageAsset.height,
|
|
49
|
+
};
|
|
50
|
+
return group;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generates a circular canvas texture for the background pin badge.
|
|
54
|
+
* Background pin badge ke liye circular canvas texture banayein.
|
|
55
|
+
*/
|
|
56
|
+
static createBackgroundCircle(tintColor = '#62236b') {
|
|
57
|
+
let texture;
|
|
58
|
+
if (typeof document !== 'undefined') {
|
|
59
|
+
const canvas = document.createElement('canvas');
|
|
60
|
+
canvas.width = 64;
|
|
61
|
+
canvas.height = 64;
|
|
62
|
+
const ctx = canvas.getContext('2d');
|
|
63
|
+
if (ctx) {
|
|
64
|
+
ctx.beginPath();
|
|
65
|
+
ctx.arc(32, 32, 30, 0, Math.PI * 2);
|
|
66
|
+
ctx.fillStyle = '#ffffff';
|
|
67
|
+
ctx.fill();
|
|
68
|
+
}
|
|
69
|
+
texture = new THREE.CanvasTexture(canvas);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Headless / Node / Test environment fallback
|
|
73
|
+
texture = new THREE.Texture();
|
|
74
|
+
}
|
|
75
|
+
const material = new THREE.SpriteMaterial({
|
|
76
|
+
map: texture,
|
|
77
|
+
transparent: true,
|
|
78
|
+
depthWrite: false,
|
|
79
|
+
depthTest: true,
|
|
80
|
+
color: new THREE.Color(tintColor),
|
|
81
|
+
});
|
|
82
|
+
return new THREE.Sprite(material);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Updates background badge tint color.
|
|
86
|
+
* Background badge ka color update karein.
|
|
87
|
+
*/
|
|
88
|
+
static updateTheme(object, tintColor = '#62236b') {
|
|
89
|
+
let bgSprite;
|
|
90
|
+
if (object instanceof THREE.Group) {
|
|
91
|
+
bgSprite = object.getObjectByName('bg-circle');
|
|
92
|
+
}
|
|
93
|
+
else if (object instanceof THREE.Sprite && object.name === 'bg-circle') {
|
|
94
|
+
bgSprite = object;
|
|
95
|
+
}
|
|
96
|
+
if (bgSprite && bgSprite.material instanceof THREE.SpriteMaterial) {
|
|
97
|
+
bgSprite.material.color.set(tintColor);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Updates texture and dimension scale on an existing sprite group.
|
|
102
|
+
* Existing sprite group ka texture aur scale update karein.
|
|
103
|
+
*/
|
|
104
|
+
static updateTexture(group, texture, imageAsset, _node, scale = 1, _currentMode = '3D', _depthConfig) {
|
|
105
|
+
const iconSprite = group.getObjectByName('icon-sprite');
|
|
106
|
+
const bgSprite = group.getObjectByName('bg-circle');
|
|
107
|
+
if (!iconSprite)
|
|
108
|
+
return;
|
|
109
|
+
iconSprite.material.map = texture;
|
|
110
|
+
iconSprite.material.color.setHex(0xffffff);
|
|
111
|
+
iconSprite.material.needsUpdate = true;
|
|
112
|
+
const targetHeight = (imageAsset.height ?? imageAsset.width ?? 10) * scale;
|
|
113
|
+
const img = texture.image;
|
|
114
|
+
let width = targetHeight;
|
|
115
|
+
if (img && img.width && img.height) {
|
|
116
|
+
const aspect = img.width / img.height;
|
|
117
|
+
width = targetHeight * aspect;
|
|
118
|
+
}
|
|
119
|
+
iconSprite.scale.set(width, targetHeight, 1);
|
|
120
|
+
if (bgSprite) {
|
|
121
|
+
const bgSize = Math.max(width, targetHeight) * 1.5;
|
|
122
|
+
bgSprite.scale.set(bgSize, bgSize, 1);
|
|
123
|
+
}
|
|
124
|
+
// Preserve active Y elevation to prevent resetting height if viewMode changed during texture fetch
|
|
125
|
+
group.position.set((imageAsset.x ?? 0) * scale + width / 2, group.position.y, (imageAsset.y ?? 0) * scale + targetHeight / 2);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Updates vertical Y coordinate elevation.
|
|
129
|
+
* Vertical height position update karein.
|
|
130
|
+
*/
|
|
131
|
+
static updateHeight(group, surfaceHeight, mode = '3D', depthConfig) {
|
|
132
|
+
const modeConfig = resolveModeDepth(mode, depthConfig);
|
|
133
|
+
group.position.y = surfaceHeight + modeConfig.extraDepthSprite;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { type PreparedRouteRun, type PreparedRouteArtifacts } from '@wovvmap/contracts';
|
|
3
|
+
import { RouteMotion } from './RouteMotion.js';
|
|
4
|
+
/** Display-only instancing over server-prepared runs; no routing, NodePoint or frame scheduler.
|
|
5
|
+
* Hinglish: Sirf capped arrows interpolate hon; har frame full path scan, graph solve ya UI state update nahi. */
|
|
6
|
+
export declare class RouteArrows {
|
|
7
|
+
private readonly parent;
|
|
8
|
+
private readonly placement;
|
|
9
|
+
readonly motion: RouteMotion;
|
|
10
|
+
private readonly slots;
|
|
11
|
+
private mesh?;
|
|
12
|
+
private readonly dummy;
|
|
13
|
+
private lastTime?;
|
|
14
|
+
private enabled;
|
|
15
|
+
private floor;
|
|
16
|
+
private color;
|
|
17
|
+
private supported;
|
|
18
|
+
private disposed;
|
|
19
|
+
constructor(parent: THREE.Group, points: readonly number[], placement: PreparedRouteArtifacts['placement']);
|
|
20
|
+
addRun(run: PreparedRouteRun): void;
|
|
21
|
+
assertSupported(): void;
|
|
22
|
+
setEnabled(enabled: boolean): void;
|
|
23
|
+
setFloor(floor: number): void;
|
|
24
|
+
setColor(color: string): void;
|
|
25
|
+
get moving(): boolean;
|
|
26
|
+
resetClock(): void;
|
|
27
|
+
private bindFloor;
|
|
28
|
+
/** First/resumed delta is zero; only at most500 instances are touched, with bounded edge lookup.
|
|
29
|
+
* Hinglish: Hidden gap ka catch-up jump nahi; prefix double precision rakhe taaki tiny valid legs na kho jayein. */
|
|
30
|
+
update(time: number): boolean;
|
|
31
|
+
private releaseMesh;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=RouteArrows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteArrows.d.ts","sourceRoot":"","sources":["../../../src/services/routes/RouteArrows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAyB,MAAM,eAAe,CAAA;AAOlE;kHACkH;AAClH,qBAAa,WAAW;IAYpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,IAAI,CAAC,CAAoE;IACjF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAI;IACjB,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,QAAQ,CAAQ;gBAEL,MAAM,EAAE,KAAK,CAAC,KAAK,EACpC,MAAM,EAAE,SAAS,MAAM,EAAE,EACR,SAAS,EAAE,sBAAsB,CAAC,WAAW,CAAC;IAIjE,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAKnC,eAAe,IAAI,IAAI;IAMvB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,IAAI,MAAM,IAAI,OAAO,CAEpB;IACD,UAAU,IAAI,IAAI;IAGlB,OAAO,CAAC,SAAS;IAuDjB;wHACoH;IACpH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAqB7B,OAAO,CAAC,WAAW;IAUnB,OAAO,IAAI,IAAI;CAMhB"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ViewerCommandError, } from '@wovvmap/contracts';
|
|
3
|
+
import { RouteMotion } from './RouteMotion.js';
|
|
4
|
+
const MAX_ARROWS = 500, GAP = 15, SPEED = 4;
|
|
5
|
+
/** Display-only instancing over server-prepared runs; no routing, NodePoint or frame scheduler.
|
|
6
|
+
* Hinglish: Sirf capped arrows interpolate hon; har frame full path scan, graph solve ya UI state update nahi. */
|
|
7
|
+
export class RouteArrows {
|
|
8
|
+
parent;
|
|
9
|
+
placement;
|
|
10
|
+
motion;
|
|
11
|
+
slots = [];
|
|
12
|
+
mesh;
|
|
13
|
+
dummy = new THREE.Object3D();
|
|
14
|
+
lastTime;
|
|
15
|
+
enabled = false;
|
|
16
|
+
floor = 0;
|
|
17
|
+
color = '#ffffff';
|
|
18
|
+
supported = true;
|
|
19
|
+
disposed = false;
|
|
20
|
+
constructor(parent, points, placement) {
|
|
21
|
+
this.parent = parent;
|
|
22
|
+
this.placement = placement;
|
|
23
|
+
this.motion = new RouteMotion(points, placement.height);
|
|
24
|
+
}
|
|
25
|
+
addRun(run) {
|
|
26
|
+
this.motion.addRun(run);
|
|
27
|
+
if (run.geometry && run.edges.length && !run.motion)
|
|
28
|
+
this.supported = false;
|
|
29
|
+
}
|
|
30
|
+
assertSupported() {
|
|
31
|
+
if (!this.supported)
|
|
32
|
+
throw new ViewerCommandError('Regenerate this route to enable moving arrows.', {
|
|
33
|
+
code: 'UNAVAILABLE',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
setEnabled(enabled) {
|
|
37
|
+
if (this.disposed || this.enabled === enabled)
|
|
38
|
+
return;
|
|
39
|
+
if (enabled)
|
|
40
|
+
this.assertSupported();
|
|
41
|
+
this.enabled = enabled;
|
|
42
|
+
if (enabled)
|
|
43
|
+
this.bindFloor();
|
|
44
|
+
else
|
|
45
|
+
this.releaseMesh();
|
|
46
|
+
}
|
|
47
|
+
setFloor(floor) {
|
|
48
|
+
if (this.floor === floor)
|
|
49
|
+
return;
|
|
50
|
+
this.floor = floor;
|
|
51
|
+
if (this.enabled)
|
|
52
|
+
this.bindFloor();
|
|
53
|
+
}
|
|
54
|
+
setColor(color) {
|
|
55
|
+
this.color = color;
|
|
56
|
+
this.mesh?.material.color.set(color);
|
|
57
|
+
}
|
|
58
|
+
get moving() {
|
|
59
|
+
return this.enabled && this.slots.length > 0 && !this.disposed;
|
|
60
|
+
}
|
|
61
|
+
resetClock() {
|
|
62
|
+
this.lastTime = undefined;
|
|
63
|
+
}
|
|
64
|
+
bindFloor() {
|
|
65
|
+
this.slots.length = 0;
|
|
66
|
+
this.resetClock();
|
|
67
|
+
for (const run of this.motion.floors.get(this.floor) ?? []) {
|
|
68
|
+
if (!run.supported)
|
|
69
|
+
continue;
|
|
70
|
+
const size = Math.min(this.placement.width * 0.9, run.length * 0.5);
|
|
71
|
+
const span = run.length - size;
|
|
72
|
+
if (size <= 1e-8 || span <= 0)
|
|
73
|
+
continue;
|
|
74
|
+
const count = Math.min(MAX_ARROWS - this.slots.length, Math.max(1, Math.floor(run.length / GAP) + 1));
|
|
75
|
+
for (let i = 0; i < count; i++)
|
|
76
|
+
this.slots.push({ run, size, span, distance: ((i + 0.5) / count) * span });
|
|
77
|
+
if (this.slots.length === MAX_ARROWS)
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (!this.slots.length) {
|
|
81
|
+
if (this.mesh)
|
|
82
|
+
this.mesh.visible = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!this.mesh) {
|
|
86
|
+
// A shared unit chevron is a render icon, not the private source-shape/ribbon builder.
|
|
87
|
+
// Hinglish: Ek primitive/material reuse ho; texture request, per-arrow mesh ya async asset race nahi.
|
|
88
|
+
const geometry = new THREE.BufferGeometry();
|
|
89
|
+
geometry.setAttribute('position', new THREE.Float32BufferAttribute([-0.5, 0, -0.5, 0, 0, -0.25, 0.5, 0, -0.5, 0, 0, 0.5], 3));
|
|
90
|
+
geometry.setIndex([0, 1, 3, 1, 2, 3]);
|
|
91
|
+
const material = new THREE.MeshBasicMaterial({
|
|
92
|
+
color: this.color,
|
|
93
|
+
// Share the ribbon's transparent pass so it cannot paint over a non-depth-writing arrow.
|
|
94
|
+
// Hinglish: Opaque pass mein arrow pehle draw hoga; ribbon ke baad hi arrow render hona chahiye.
|
|
95
|
+
transparent: true,
|
|
96
|
+
side: THREE.DoubleSide,
|
|
97
|
+
depthTest: true,
|
|
98
|
+
depthWrite: false,
|
|
99
|
+
polygonOffset: true,
|
|
100
|
+
polygonOffsetFactor: -4,
|
|
101
|
+
polygonOffsetUnits: -4,
|
|
102
|
+
});
|
|
103
|
+
this.mesh = new THREE.InstancedMesh(geometry, material, MAX_ARROWS);
|
|
104
|
+
this.mesh.name = 'wovvmap-route-arrows';
|
|
105
|
+
this.mesh.userData.routeArrows = true;
|
|
106
|
+
this.mesh.frustumCulled = false;
|
|
107
|
+
this.mesh.renderOrder = 15;
|
|
108
|
+
this.mesh.raycast = () => { };
|
|
109
|
+
this.mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
110
|
+
this.parent.add(this.mesh);
|
|
111
|
+
}
|
|
112
|
+
this.mesh.visible = true;
|
|
113
|
+
this.mesh.count = this.slots.length;
|
|
114
|
+
this.update(0);
|
|
115
|
+
this.resetClock();
|
|
116
|
+
}
|
|
117
|
+
/** First/resumed delta is zero; only at most500 instances are touched, with bounded edge lookup.
|
|
118
|
+
* Hinglish: Hidden gap ka catch-up jump nahi; prefix double precision rakhe taaki tiny valid legs na kho jayein. */
|
|
119
|
+
update(time) {
|
|
120
|
+
if (!this.moving || !this.mesh)
|
|
121
|
+
return false;
|
|
122
|
+
const valid = Number.isFinite(time);
|
|
123
|
+
const delta = valid && this.lastTime !== undefined
|
|
124
|
+
? Math.max(0, Math.min(0.1, (time - this.lastTime) / 1000))
|
|
125
|
+
: 0;
|
|
126
|
+
this.lastTime = valid ? Math.max(this.lastTime ?? time, time) : undefined;
|
|
127
|
+
for (let i = 0; i < this.slots.length; i++) {
|
|
128
|
+
const slot = this.slots[i], run = slot.run;
|
|
129
|
+
slot.distance = (slot.distance + delta * SPEED) % slot.span;
|
|
130
|
+
const distance = slot.distance + slot.size / 2;
|
|
131
|
+
this.motion.sample(run, distance, this.dummy);
|
|
132
|
+
this.dummy.scale.setScalar(slot.size);
|
|
133
|
+
this.dummy.updateMatrix();
|
|
134
|
+
this.mesh.setMatrixAt(i, this.dummy.matrix);
|
|
135
|
+
}
|
|
136
|
+
this.mesh.instanceMatrix.needsUpdate = true;
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
releaseMesh() {
|
|
140
|
+
this.slots.length = 0;
|
|
141
|
+
this.resetClock();
|
|
142
|
+
if (!this.mesh)
|
|
143
|
+
return;
|
|
144
|
+
this.mesh.removeFromParent();
|
|
145
|
+
this.mesh.geometry.dispose();
|
|
146
|
+
this.mesh.material.dispose();
|
|
147
|
+
this.mesh.dispose();
|
|
148
|
+
this.mesh = undefined;
|
|
149
|
+
}
|
|
150
|
+
dispose() {
|
|
151
|
+
if (this.disposed)
|
|
152
|
+
return;
|
|
153
|
+
this.releaseMesh();
|
|
154
|
+
this.motion.dispose();
|
|
155
|
+
this.disposed = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { RoutePlaybackScope } from '@wovvmap/contracts';
|
|
3
|
+
import type { RouteMotion } from './RouteMotion.js';
|
|
4
|
+
/** One non-pickable display cursor; no route solver, clock, RAF or second trajectory.
|
|
5
|
+
* Hinglish: Sirf shared prepared run sample hota hai; permissions/backend policy yahan nahi. */
|
|
6
|
+
export declare class RouteCursor {
|
|
7
|
+
private readonly parent;
|
|
8
|
+
private readonly motion;
|
|
9
|
+
private readonly size;
|
|
10
|
+
private mesh?;
|
|
11
|
+
private color;
|
|
12
|
+
constructor(parent: THREE.Group, motion: RouteMotion, size: number);
|
|
13
|
+
get object(): THREE.Object3D | undefined;
|
|
14
|
+
position(scope: RoutePlaybackScope, distance: number): void;
|
|
15
|
+
setColor(color: string): void;
|
|
16
|
+
setFloor(floor: number): void;
|
|
17
|
+
release(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=RouteCursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteCursor.d.ts","sourceRoot":"","sources":["../../../src/services/routes/RouteCursor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD;gGACgG;AAChG,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IALvB,OAAO,CAAC,IAAI,CAAC,CAA2D;IACxE,OAAO,CAAC,KAAK,CAAY;gBAEN,MAAM,EAAE,KAAK,CAAC,KAAK,EACnB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM;IAE/B,IAAI,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,SAAS,CAEvC;IACD,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAkC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,OAAO,IAAI,IAAI;CAQhB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/** One non-pickable display cursor; no route solver, clock, RAF or second trajectory.
|
|
3
|
+
* Hinglish: Sirf shared prepared run sample hota hai; permissions/backend policy yahan nahi. */
|
|
4
|
+
export class RouteCursor {
|
|
5
|
+
parent;
|
|
6
|
+
motion;
|
|
7
|
+
size;
|
|
8
|
+
mesh;
|
|
9
|
+
color = '#ffffff';
|
|
10
|
+
constructor(parent, motion, size) {
|
|
11
|
+
this.parent = parent;
|
|
12
|
+
this.motion = motion;
|
|
13
|
+
this.size = size;
|
|
14
|
+
}
|
|
15
|
+
get object() {
|
|
16
|
+
return this.mesh;
|
|
17
|
+
}
|
|
18
|
+
position(scope, distance) {
|
|
19
|
+
if (!this.mesh) {
|
|
20
|
+
const geometry = new THREE.BufferGeometry();
|
|
21
|
+
geometry.setAttribute('position', new THREE.Float32BufferAttribute([-0.6, 0, -0.5, 0.6, 0, -0.5, 0, 0, 1], 3));
|
|
22
|
+
geometry.setIndex([0, 1, 2]);
|
|
23
|
+
const material = new THREE.MeshBasicMaterial({
|
|
24
|
+
color: this.color,
|
|
25
|
+
transparent: true,
|
|
26
|
+
depthTest: true,
|
|
27
|
+
depthWrite: false,
|
|
28
|
+
side: THREE.DoubleSide,
|
|
29
|
+
polygonOffset: true,
|
|
30
|
+
polygonOffsetFactor: -5,
|
|
31
|
+
polygonOffsetUnits: -5,
|
|
32
|
+
});
|
|
33
|
+
this.mesh = new THREE.Mesh(geometry, material);
|
|
34
|
+
this.mesh.name = 'wovvmap-route-playback';
|
|
35
|
+
this.mesh.userData.routePlayback = true;
|
|
36
|
+
this.mesh.renderOrder = 16;
|
|
37
|
+
this.mesh.frustumCulled = false;
|
|
38
|
+
this.mesh.raycast = () => { };
|
|
39
|
+
this.mesh.scale.setScalar(Math.min(this.size, scope.length / 2));
|
|
40
|
+
const mesh = this.mesh;
|
|
41
|
+
this.parent.add(mesh);
|
|
42
|
+
// Three.js child-added handlers can synchronously clear the route during adoption.
|
|
43
|
+
// Hinglish: Callback ne cursor release kiya ho to disposed mesh ko dobara sample mat karo.
|
|
44
|
+
if (this.mesh !== mesh)
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.mesh.userData.runIndex = scope.runIndex;
|
|
48
|
+
this.motion.sample(this.motion.runs[scope.runIndex], distance, this.mesh);
|
|
49
|
+
}
|
|
50
|
+
setColor(color) {
|
|
51
|
+
this.color = color;
|
|
52
|
+
this.mesh?.material.color.set(color);
|
|
53
|
+
}
|
|
54
|
+
setFloor(floor) {
|
|
55
|
+
if (this.mesh)
|
|
56
|
+
this.mesh.visible =
|
|
57
|
+
this.motion.runs[this.mesh.userData.runIndex]?.floorIndex === floor;
|
|
58
|
+
}
|
|
59
|
+
release() {
|
|
60
|
+
const mesh = this.mesh;
|
|
61
|
+
if (!mesh)
|
|
62
|
+
return;
|
|
63
|
+
this.mesh = undefined;
|
|
64
|
+
mesh.removeFromParent();
|
|
65
|
+
mesh.geometry.dispose();
|
|
66
|
+
mesh.material.dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type PreparedRouteRun, type RoutePlaybackMode, type RoutePlaybackScope, type PreparedPlaybackStep, type PreparedPlaybackJourney } from '@wovvmap/contracts';
|
|
2
|
+
import type * as THREE from 'three';
|
|
3
|
+
export type MotionRun = RoutePlaybackScope & {
|
|
4
|
+
floorLabel: string;
|
|
5
|
+
edges: PreparedRouteRun['edges'];
|
|
6
|
+
lengths: Float64Array;
|
|
7
|
+
steps?: readonly PreparedPlaybackStep[];
|
|
8
|
+
supported: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** Hydrate prepared motion once; decoration and playback share points/prefixes and bounded sampling.
|
|
11
|
+
* Hinglish: Zero-length visits bhi index mein rahenge; A/B/A ko kabhi ek fake path nahi banayenge. */
|
|
12
|
+
export declare class RouteMotion {
|
|
13
|
+
readonly height: number;
|
|
14
|
+
private hasJourney;
|
|
15
|
+
private readonly nextRuns;
|
|
16
|
+
private points;
|
|
17
|
+
readonly runs: MotionRun[];
|
|
18
|
+
readonly floors: Map<number, MotionRun[]>;
|
|
19
|
+
constructor(points: readonly number[], height: number);
|
|
20
|
+
addRun(run: PreparedRouteRun): void;
|
|
21
|
+
scope(mode: RoutePlaybackMode, floor: number, bound?: RoutePlaybackScope): MotionRun;
|
|
22
|
+
setJourney(journey: PreparedPlaybackJourney | undefined): void;
|
|
23
|
+
next(scope: RoutePlaybackScope): MotionRun | undefined;
|
|
24
|
+
private spanRun;
|
|
25
|
+
private spanIndex;
|
|
26
|
+
setSteps(steps: readonly PreparedPlaybackStep[], validate?: (step: PreparedPlaybackStep) => void): void;
|
|
27
|
+
step(scope: RoutePlaybackScope, distance: number): PreparedPlaybackStep | null;
|
|
28
|
+
sample(run: MotionRun, distance: number, target: THREE.Object3D): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RouteMotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteMotion.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EACtC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAC9C,IAAI;IAmBP,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI;IAoB9E,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI;IAwBtE,OAAO,IAAI,IAAI;CAOhB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ViewerCommandError, } from '@wovvmap/contracts';
|
|
2
|
+
/** Hydrate prepared motion once; decoration and playback share points/prefixes and bounded sampling.
|
|
3
|
+
* Hinglish: Zero-length visits bhi index mein rahenge; A/B/A ko kabhi ek fake path nahi banayenge. */
|
|
4
|
+
export class RouteMotion {
|
|
5
|
+
height;
|
|
6
|
+
hasJourney = false;
|
|
7
|
+
nextRuns = new Map();
|
|
8
|
+
points;
|
|
9
|
+
runs = [];
|
|
10
|
+
floors = new Map();
|
|
11
|
+
constructor(points, height) {
|
|
12
|
+
this.height = height;
|
|
13
|
+
this.points = Float64Array.from(points);
|
|
14
|
+
}
|
|
15
|
+
addRun(run) {
|
|
16
|
+
const lengths = Float64Array.from(run.motion?.cumulativeLengths ?? [0]);
|
|
17
|
+
const entry = {
|
|
18
|
+
runIndex: this.runs.length,
|
|
19
|
+
floorIndex: run.floorIndex,
|
|
20
|
+
floorLabel: run.floorLabel,
|
|
21
|
+
edges: run.edges,
|
|
22
|
+
lengths,
|
|
23
|
+
length: lengths[lengths.length - 1],
|
|
24
|
+
supported: (!run.geometry && !run.edges.length) || !!run.motion,
|
|
25
|
+
};
|
|
26
|
+
this.runs.push(entry);
|
|
27
|
+
const bucket = this.floors.get(run.floorIndex) ?? [];
|
|
28
|
+
bucket.push(entry);
|
|
29
|
+
this.floors.set(run.floorIndex, bucket);
|
|
30
|
+
}
|
|
31
|
+
scope(mode, floor, bound) {
|
|
32
|
+
const run = bound
|
|
33
|
+
? this.runs[bound.runIndex]
|
|
34
|
+
: mode === 'full-route'
|
|
35
|
+
? this.runs[0]
|
|
36
|
+
: this.floors.get(floor)?.[0];
|
|
37
|
+
if (!run ||
|
|
38
|
+
!run.supported ||
|
|
39
|
+
(run.floorIndex !== floor && (mode !== 'full-route' || !!bound || !this.hasJourney)) ||
|
|
40
|
+
(mode === 'full-route' && this.runs.length !== 1 && !this.hasJourney))
|
|
41
|
+
throw new ViewerCommandError('Playback is unavailable for this route, mode or floor.', {
|
|
42
|
+
code: 'UNAVAILABLE',
|
|
43
|
+
});
|
|
44
|
+
return run;
|
|
45
|
+
}
|
|
46
|
+
setJourney(journey) {
|
|
47
|
+
if (!journey)
|
|
48
|
+
return;
|
|
49
|
+
this.hasJourney = true;
|
|
50
|
+
for (const visit of journey.visits) {
|
|
51
|
+
const run = this.runs[visit.runIndex];
|
|
52
|
+
Object.assign(run, { offset: visit.offset, totalLength: journey.totalLength });
|
|
53
|
+
if (visit.next) {
|
|
54
|
+
const target = this.runs[visit.next.runIndex];
|
|
55
|
+
Object.assign(target, {
|
|
56
|
+
transition: {
|
|
57
|
+
fromFloorIndex: run.floorIndex,
|
|
58
|
+
toFloorIndex: target.floorIndex,
|
|
59
|
+
transport: visit.next.transport,
|
|
60
|
+
direction: visit.next.direction,
|
|
61
|
+
toFloorLabel: target.floorLabel,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
this.nextRuns.set(run.runIndex, target);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
next(scope) {
|
|
69
|
+
return this.nextRuns.get(scope.runIndex);
|
|
70
|
+
}
|
|
71
|
+
spanRun = -1;
|
|
72
|
+
spanIndex = 0;
|
|
73
|
+
setSteps(steps, validate) {
|
|
74
|
+
const buckets = this.runs.map(() => []);
|
|
75
|
+
for (const step of steps) {
|
|
76
|
+
const run = this.runs[step.runIndex];
|
|
77
|
+
if (!run ||
|
|
78
|
+
step.floorIndex !== run.floorIndex ||
|
|
79
|
+
step.fromDistance < 0 ||
|
|
80
|
+
step.toDistance > run.length)
|
|
81
|
+
throw new ViewerCommandError('Invalid playback index.', { code: 'INVALID_ROUTE_RESPONSE' });
|
|
82
|
+
validate?.(step);
|
|
83
|
+
buckets[step.runIndex].push(step);
|
|
84
|
+
}
|
|
85
|
+
this.runs.forEach((run, i) => {
|
|
86
|
+
run.steps = buckets[i];
|
|
87
|
+
});
|
|
88
|
+
this.spanRun = -1;
|
|
89
|
+
}
|
|
90
|
+
step(scope, distance) {
|
|
91
|
+
const steps = this.runs[scope.runIndex]?.steps;
|
|
92
|
+
if (!steps?.length)
|
|
93
|
+
return null;
|
|
94
|
+
if (this.spanRun === scope.runIndex &&
|
|
95
|
+
distance >= steps[this.spanIndex].fromDistance &&
|
|
96
|
+
(this.spanIndex === steps.length - 1 || distance < steps[this.spanIndex + 1].fromDistance))
|
|
97
|
+
return steps[this.spanIndex];
|
|
98
|
+
let lo = 0, hi = steps.length - 1;
|
|
99
|
+
while (lo < hi) {
|
|
100
|
+
const mid = (lo + hi + 1) >>> 1;
|
|
101
|
+
if (steps[mid].fromDistance <= distance)
|
|
102
|
+
lo = mid;
|
|
103
|
+
else
|
|
104
|
+
hi = mid - 1;
|
|
105
|
+
}
|
|
106
|
+
this.spanRun = scope.runIndex;
|
|
107
|
+
this.spanIndex = lo;
|
|
108
|
+
return steps[lo];
|
|
109
|
+
}
|
|
110
|
+
sample(run, distance, target) {
|
|
111
|
+
let lo = 0, hi = run.edges.length - 1;
|
|
112
|
+
while (lo < hi) {
|
|
113
|
+
const mid = (lo + hi) >>> 1;
|
|
114
|
+
if (run.lengths[mid + 1] <= distance)
|
|
115
|
+
lo = mid + 1;
|
|
116
|
+
else
|
|
117
|
+
hi = mid;
|
|
118
|
+
}
|
|
119
|
+
const edge = run.edges[lo], a = edge.fromPathIndex * 3, b = edge.toPathIndex * 3;
|
|
120
|
+
const t = Math.max(0, Math.min(1, (distance - run.lengths[lo]) / (run.lengths[lo + 1] - run.lengths[lo])));
|
|
121
|
+
const dx = this.points[b] - this.points[a], dz = this.points[b + 2] - this.points[a + 2];
|
|
122
|
+
target.position.set(this.points[a] + dx * t, this.points[a + 1] + (this.points[b + 1] - this.points[a + 1]) * t + this.height, this.points[a + 2] + dz * t);
|
|
123
|
+
target.rotation.set(0, Math.atan2(dx, dz), 0);
|
|
124
|
+
}
|
|
125
|
+
dispose() {
|
|
126
|
+
this.hasJourney = false;
|
|
127
|
+
this.nextRuns.clear();
|
|
128
|
+
this.runs.length = 0;
|
|
129
|
+
this.floors.clear();
|
|
130
|
+
this.points = new Float64Array(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { MapTheme, RouteGeometryResponse, RouteSelection, RouteInstruction, ResolvedNavigationConfig, RoutePlaybackBinding, RoutePlaybackIndexResponse } from '@wovvmap/contracts';
|
|
3
|
+
/** Ready GPU resources only; path/ribbon/instruction preparation stays in the private API.
|
|
4
|
+
* Hinglish: Y elevation aur X/Z scale packet mein baked hain; renderer dobara math nahi karega. */
|
|
5
|
+
export interface RouteRenderResources {
|
|
6
|
+
hasPlaybackSteps?(routeId: string): boolean;
|
|
7
|
+
setPlaybackSteps?(routeId: string, value: RoutePlaybackIndexResponse): void;
|
|
8
|
+
playback(routeId: string): RoutePlaybackBinding;
|
|
9
|
+
show(selectedRouteId: string, active: boolean): void;
|
|
10
|
+
bounds(routeId: string | null, floorIndex: number): THREE.Box3;
|
|
11
|
+
runBounds(routeId: string, runIndex: number): THREE.Box3;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
highlightStep(routeId: string, step: RouteInstruction | null): void;
|
|
14
|
+
stepBounds(routeId: string, step: RouteInstruction): THREE.Box3;
|
|
15
|
+
stepDirection?(routeId: string, step: RouteInstruction): THREE.Vector3 | undefined;
|
|
16
|
+
setPathAnimation(mode: ResolvedNavigationConfig['pathAnimation']): void;
|
|
17
|
+
}
|
|
18
|
+
/** Renderer-local hit metadata, never a host event or a routing decision.
|
|
19
|
+
* Hinglish: Distance sirf visible mesh hit compare karne ke liye; graph/cost ka data nahi. */
|
|
20
|
+
export interface RoutePreviewHit {
|
|
21
|
+
readonly selection: RouteSelection;
|
|
22
|
+
readonly distance: number;
|
|
23
|
+
}
|
|
24
|
+
export declare class RouteRenderer {
|
|
25
|
+
private readonly scene;
|
|
26
|
+
private readonly invalidate;
|
|
27
|
+
private readonly follow?;
|
|
28
|
+
private readonly sets;
|
|
29
|
+
private floor;
|
|
30
|
+
private floorBaseDepth?;
|
|
31
|
+
private color;
|
|
32
|
+
private highlightColor;
|
|
33
|
+
private arrowColor;
|
|
34
|
+
private animation?;
|
|
35
|
+
/** Only the accepted attached arrow owner ticks; there is no renderer-owned RAF.
|
|
36
|
+
* Hinglish: Engine ki single frame loop hi call kare; hidden/retired sets par work nahi. */
|
|
37
|
+
get hasAnimation(): boolean;
|
|
38
|
+
update(time: number): boolean;
|
|
39
|
+
resetAnimationClock(): void;
|
|
40
|
+
constructor(scene: THREE.Scene, invalidate: () => void, follow?: ((position: THREE.Vector3 | null, forward?: THREE.Vector3, delta?: number) => void) | undefined);
|
|
41
|
+
setFloor(floor: number): void;
|
|
42
|
+
/** Hit-test visible ready ribbons; the shared viewer decides whether selection is permitted.
|
|
43
|
+
* Hinglish: Visible path ka tap background clear na bane; choose karna preview stage ka kaam hai. */
|
|
44
|
+
pick(raycaster: THREE.Raycaster): RoutePreviewHit | null;
|
|
45
|
+
setTheme(theme: MapTheme): void;
|
|
46
|
+
/** Only a display delta from the prepared base; never add the already-baked elevation twice.
|
|
47
|
+
* Hinglish: Live wall/base styling ka sirf difference lage; buffer/graph/source dobara na bane. */
|
|
48
|
+
setFloorBaseDepth(value: number | undefined): void;
|
|
49
|
+
prepare(items: readonly RouteGeometryResponse[]): RouteRenderResources;
|
|
50
|
+
dispose(): void;
|
|
51
|
+
}
|
|
52
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