@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,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ViewerElementsController.ts
|
|
3
|
+
* @description Unified facade controller orchestrating Shapes, Images, and Text labels.
|
|
4
|
+
* Shapes, images aur text controllers ko ek sath coordinate karne wala unified facade controller.
|
|
5
|
+
*/
|
|
6
|
+
import { resolveMapTheme } from '@wovvmap/contracts';
|
|
7
|
+
import { ShapeController } from './ShapeController.js';
|
|
8
|
+
import { ImageController } from './ImageController.js';
|
|
9
|
+
import { TextController } from './TextController.js';
|
|
10
|
+
/**
|
|
11
|
+
* Orchestrates 3D store meshes, brand logo planes, transit sprites, and text labels (2D DOM / 3D Troika mesh).
|
|
12
|
+
* Maintains exact legacy parity with wovvmap_frontend ViewerElementsController while adhering to SOLID principles.
|
|
13
|
+
*
|
|
14
|
+
* Map ke 3D unit meshes, store logos aur text labels ko build aur coordinate karta hai.
|
|
15
|
+
*/
|
|
16
|
+
export class ViewerElementsController {
|
|
17
|
+
shapeController;
|
|
18
|
+
imageController;
|
|
19
|
+
textController;
|
|
20
|
+
onInvalidate;
|
|
21
|
+
currentTheme;
|
|
22
|
+
selectedNodeKeys = [];
|
|
23
|
+
originNodeKeys = [];
|
|
24
|
+
destinationNodeKeys = [];
|
|
25
|
+
selectionPaint = new Map();
|
|
26
|
+
constructor(shapeController, imageController, textController, theme) {
|
|
27
|
+
this.shapeController = shapeController || new ShapeController();
|
|
28
|
+
this.imageController = imageController || new ImageController();
|
|
29
|
+
this.textController = textController || new TextController();
|
|
30
|
+
this.currentTheme = resolveMapTheme(theme);
|
|
31
|
+
this.imageController.setThemeSpriteColors(this.currentTheme.spriteBackgroundColor, this.currentTheme.spriteBackgroundColors);
|
|
32
|
+
if (this.currentTheme.anchorStoreGradient) {
|
|
33
|
+
this.shapeController.updateAnchorGradient(this.currentTheme.anchorStoreGradient);
|
|
34
|
+
}
|
|
35
|
+
if (this.currentTheme.shapeEdgeColor) {
|
|
36
|
+
this.shapeController.updateEdgeColor(this.currentTheme.shapeEdgeColor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sets callback to trigger engine redraw when asynchronous assets (logos, 3D text) sync.
|
|
41
|
+
* Asynchronous assets sync hone par redraw trigger karne wala callback.
|
|
42
|
+
*/
|
|
43
|
+
setOnInvalidate(callback) {
|
|
44
|
+
this.onInvalidate = callback;
|
|
45
|
+
this.textController.setOnInvalidate(callback);
|
|
46
|
+
}
|
|
47
|
+
/** Normal selection is a renderer projection; the SDK remains the selected-node owner.
|
|
48
|
+
* Hinglish: Renderer sirf selected key ka paint rakhta hai; domain selection SDK ki hi hai. */
|
|
49
|
+
setSelection(key) {
|
|
50
|
+
return this.setSelectionKeys(key === null ? [] : [key]);
|
|
51
|
+
}
|
|
52
|
+
/** Membership is renderer projection only; canonical group resolution remains in the SDK.
|
|
53
|
+
* Hinglish: Renderer sirf mili hui keys paint kare; group kaun sa hai ye SDK hi decide kare. */
|
|
54
|
+
setSelectionKeys(keys) {
|
|
55
|
+
const next = new Set(keys);
|
|
56
|
+
if (next.size === this.selectedNodeKeys.length &&
|
|
57
|
+
this.selectedNodeKeys.every((key) => next.has(key)))
|
|
58
|
+
return false;
|
|
59
|
+
this.selectedNodeKeys = [...next];
|
|
60
|
+
return this.applySelection();
|
|
61
|
+
}
|
|
62
|
+
/** Project endpoint roles without mutating ordinary selection, layer visibility or camera state.
|
|
63
|
+
* Hinglish: Start/end ka paint alag roles se aaye; normal selection, visibility aur camera na badlein. */
|
|
64
|
+
setEndpointSelectionKeys(origin, destination) {
|
|
65
|
+
this.originNodeKeys = origin;
|
|
66
|
+
this.destinationNodeKeys = destination;
|
|
67
|
+
return this.applySelection();
|
|
68
|
+
}
|
|
69
|
+
applySelection(force = false) {
|
|
70
|
+
const theme = this.currentTheme;
|
|
71
|
+
const style = theme.selection;
|
|
72
|
+
const color = style?.color ?? theme.textColors?.endPoint2D ?? '#CFA44E';
|
|
73
|
+
const next = new Map();
|
|
74
|
+
const normal = {
|
|
75
|
+
color,
|
|
76
|
+
text2D: style?.text2D ?? color,
|
|
77
|
+
text3D: style?.text3D ?? theme.textColors?.endPoint3D ?? '#ffffff',
|
|
78
|
+
};
|
|
79
|
+
for (const key of this.selectedNodeKeys)
|
|
80
|
+
next.set(key, normal);
|
|
81
|
+
const originColor = theme.endpoints?.origin?.color ?? theme.textColors?.startPoint2D ?? '#CFA44E';
|
|
82
|
+
const origin = {
|
|
83
|
+
color: originColor,
|
|
84
|
+
text2D: theme.endpoints?.origin?.text2D ??
|
|
85
|
+
theme.endpoints?.origin?.color ??
|
|
86
|
+
theme.textColors?.startPoint2D ??
|
|
87
|
+
originColor,
|
|
88
|
+
text3D: theme.endpoints?.origin?.text3D ?? theme.textColors?.startPoint3D ?? '#ffffff',
|
|
89
|
+
};
|
|
90
|
+
const destinationColor = theme.endpoints?.destination?.color ?? theme.textColors?.endPoint2D ?? '#CFA44E';
|
|
91
|
+
const destination = {
|
|
92
|
+
color: destinationColor,
|
|
93
|
+
text2D: theme.endpoints?.destination?.text2D ??
|
|
94
|
+
theme.endpoints?.destination?.color ??
|
|
95
|
+
theme.textColors?.endPoint2D ??
|
|
96
|
+
destinationColor,
|
|
97
|
+
text3D: theme.endpoints?.destination?.text3D ?? theme.textColors?.endPoint3D ?? '#ffffff',
|
|
98
|
+
};
|
|
99
|
+
// Resolve priority once for all features; only the affected memberships are traversed.
|
|
100
|
+
// Hinglish: Priority ek baar resolve ho; full map nahi, sirf selected role keys par kaam ho.
|
|
101
|
+
for (const key of this.originNodeKeys)
|
|
102
|
+
next.set(key, origin);
|
|
103
|
+
for (const key of this.destinationNodeKeys)
|
|
104
|
+
next.set(key, destination);
|
|
105
|
+
let changed = force || next.size !== this.selectionPaint.size;
|
|
106
|
+
if (!changed)
|
|
107
|
+
for (const [key, paint] of next) {
|
|
108
|
+
const previous = this.selectionPaint.get(key);
|
|
109
|
+
if (paint.color !== previous?.color ||
|
|
110
|
+
paint.text2D !== previous?.text2D ||
|
|
111
|
+
paint.text3D !== previous?.text3D) {
|
|
112
|
+
changed = true;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!changed)
|
|
117
|
+
return false;
|
|
118
|
+
this.selectionPaint = next;
|
|
119
|
+
this.shapeController.setSelectionPaint(next);
|
|
120
|
+
this.imageController.setSelectionPaint(next);
|
|
121
|
+
this.textController.setSelectionPaint(next);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Switches active text label type ('2D' or '3D') across the text controller.
|
|
126
|
+
* Text label type ('2D' ya '3D') set karein.
|
|
127
|
+
*/
|
|
128
|
+
setTextType(type) {
|
|
129
|
+
this.textController.setTextType(type);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns current active text label type ('2D' or '3D').
|
|
133
|
+
* Active text label type prapt karein.
|
|
134
|
+
*/
|
|
135
|
+
getTextType() {
|
|
136
|
+
return this.textController.getTextType();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Determines whether a node point should generate a text label.
|
|
140
|
+
* If a point has brand images, it renders the logo plane instead of text by default.
|
|
141
|
+
*
|
|
142
|
+
* Node point ke liye text label banana chahiye ya logo plane render hoga.
|
|
143
|
+
*/
|
|
144
|
+
shouldCreateText(node, forceCreateText) {
|
|
145
|
+
if (forceCreateText)
|
|
146
|
+
return true;
|
|
147
|
+
const pointImages = node.assets?.pointImages;
|
|
148
|
+
const hasImage = Boolean(pointImages && pointImages.src);
|
|
149
|
+
return !hasImage;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Builds the 3D unit mesh, brand logo plane / icon sprite, and text label for a node point.
|
|
153
|
+
* Ek node point ke liye shape, logo aur text label create karein.
|
|
154
|
+
*/
|
|
155
|
+
createElements(node, mallId = '', options) {
|
|
156
|
+
const invalidateCb = options?.onInvalidate ?? this.onInvalidate;
|
|
157
|
+
// 1. Create extruded unit shape
|
|
158
|
+
const shapeDetail = node.shapeDetail ? { ...node.shapeDetail } : undefined;
|
|
159
|
+
if (shapeDetail) {
|
|
160
|
+
const cat = node.categoryCode !== undefined ? String(node.categoryCode) : undefined;
|
|
161
|
+
if (cat !== undefined) {
|
|
162
|
+
shapeDetail.category = cat;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
this.shapeController.handleShapeCreation(shapeDetail, node.key);
|
|
166
|
+
// 2. Create planar logo or transit sprite
|
|
167
|
+
this.imageController.createImage(node, {
|
|
168
|
+
depthConfig: options?.depthConfig,
|
|
169
|
+
viewMode: options?.viewMode,
|
|
170
|
+
themeColor: options?.themeColor,
|
|
171
|
+
themeColors: options?.themeColors,
|
|
172
|
+
onInvalidate: invalidateCb,
|
|
173
|
+
});
|
|
174
|
+
// 3. Create text label if eligible
|
|
175
|
+
if (this.shouldCreateText(node, options?.forceCreateText)) {
|
|
176
|
+
this.textController.createText(node, {
|
|
177
|
+
mallId,
|
|
178
|
+
depthConfig: options?.depthConfig,
|
|
179
|
+
viewMode: options?.viewMode,
|
|
180
|
+
onInvalidate: invalidateCb,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// --- Shape Delegates ---
|
|
185
|
+
/**
|
|
186
|
+
* Retrieves floor-level group for all 3D shapes.
|
|
187
|
+
* Kisi floor ke sabhi shapes ka container group prapt karein.
|
|
188
|
+
*/
|
|
189
|
+
getFloorWiseShapes(z) {
|
|
190
|
+
return this.shapeController.getFloorWiseShapes(z);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns all shape objects generated across all floors.
|
|
194
|
+
* Sabhi shapes ki array prapt karein.
|
|
195
|
+
*/
|
|
196
|
+
getAllShapes() {
|
|
197
|
+
return this.shapeController.getAllShapes();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Looks up a specific 3D shape mesh by its unique key.
|
|
201
|
+
* Unique key se specific store shape dhoondein.
|
|
202
|
+
*/
|
|
203
|
+
getShapeByKey(key) {
|
|
204
|
+
return this.shapeController.getShapeByKey(key);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Removes a specific shape and cleans its WebGL memory.
|
|
208
|
+
* Shape ko delete aur memory free karein.
|
|
209
|
+
*/
|
|
210
|
+
removeShape(id) {
|
|
211
|
+
return this.shapeController.removeShape(id);
|
|
212
|
+
}
|
|
213
|
+
// --- Image Delegates ---
|
|
214
|
+
/**
|
|
215
|
+
* Retrieves floor-level group for all brand logo planes and transit sprites.
|
|
216
|
+
* Kisi floor ke sabhi images ka container group prapt karein.
|
|
217
|
+
*/
|
|
218
|
+
getFloorWiseImages(z) {
|
|
219
|
+
return this.imageController.getFloorWiseImages(z);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Returns all image objects across all floors.
|
|
223
|
+
* Sabhi active image objects ki array prapt karein.
|
|
224
|
+
*/
|
|
225
|
+
getAllImages() {
|
|
226
|
+
return this.imageController.getAllImages();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Looks up an image object by node key.
|
|
230
|
+
* Unique key se specific image dhoondein.
|
|
231
|
+
*/
|
|
232
|
+
getImageByKey(key) {
|
|
233
|
+
return this.imageController.getImageByKey(key);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Removes an image and releases its memory.
|
|
237
|
+
* Image ko remove karein.
|
|
238
|
+
*/
|
|
239
|
+
removeImage(id) {
|
|
240
|
+
return this.imageController.removeImage(id);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Flips planar roof logos horizontally when camera rotation is inverted to keep text readable.
|
|
244
|
+
* Camera rotation ke according store logos ko flip karein taaki text ulta na dikhe.
|
|
245
|
+
*/
|
|
246
|
+
updateImageRotation(rotation, activeFloor) {
|
|
247
|
+
this.imageController.updateImageRotation(rotation, activeFloor);
|
|
248
|
+
}
|
|
249
|
+
// --- Text Delegates ---
|
|
250
|
+
/**
|
|
251
|
+
* Retrieves floor-level group for all text objects.
|
|
252
|
+
* Kisi floor ke sabhi text labels ka container group prapt karein.
|
|
253
|
+
*/
|
|
254
|
+
getFloorWiseTexts(z) {
|
|
255
|
+
return this.textController.getFloorWiseTexts(z);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns all text label objects across all floors.
|
|
259
|
+
* Sabhi active text label objects prapt karein.
|
|
260
|
+
*/
|
|
261
|
+
getAllTexts() {
|
|
262
|
+
return this.textController.getAllTexts();
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Looks up a text label object by node key.
|
|
266
|
+
* Unique key se text label dhoondein.
|
|
267
|
+
*/
|
|
268
|
+
getTextByKey(key) {
|
|
269
|
+
return this.textController.getTextByKey(key);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Removes a text label and disposes its resources.
|
|
273
|
+
* Text label ko remove aur clean karein.
|
|
274
|
+
*/
|
|
275
|
+
removeText(id) {
|
|
276
|
+
return this.textController.removeText(id);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Checks all texts to see if they overlap heavily on screen relative to camera view.
|
|
280
|
+
* Camera frustum ke mutabik labels ko auto-declutter karein.
|
|
281
|
+
*/
|
|
282
|
+
updateTextCollision(camera, activeFloor) {
|
|
283
|
+
this.textController.updateCollision(camera, activeFloor);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Schedules or executes text collision check.
|
|
287
|
+
* Text collision resolution run karne wala delegate method.
|
|
288
|
+
*/
|
|
289
|
+
scheduleTextCollision(camera, activeFloor) {
|
|
290
|
+
this.textController.scheduleCollision(camera, activeFloor);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Utility facade to update both camera rotation and collision synchronously.
|
|
294
|
+
* Camera rotation update hone par logos aur 3D text flip karein.
|
|
295
|
+
*/
|
|
296
|
+
updateCameraRotation(rotation, activeFloor) {
|
|
297
|
+
this.updateImageRotation(rotation, activeFloor);
|
|
298
|
+
this.textController.updateTextRotation(rotation, activeFloor);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Destroys existing text labels and regenerates them from a node collection.
|
|
302
|
+
* Sabhi text labels ko dubara generate karein.
|
|
303
|
+
*/
|
|
304
|
+
regenerateAllTexts(nodeMap, mallId = '', options) {
|
|
305
|
+
this.textController.clear();
|
|
306
|
+
const invalidateCb = options?.onInvalidate ?? this.onInvalidate;
|
|
307
|
+
const nodes = Array.isArray(nodeMap)
|
|
308
|
+
? nodeMap
|
|
309
|
+
: nodeMap instanceof Map
|
|
310
|
+
? Array.from(nodeMap.values())
|
|
311
|
+
: Object.values(nodeMap);
|
|
312
|
+
for (const node of nodes) {
|
|
313
|
+
if (this.shouldCreateText(node, options?.forceCreateText)) {
|
|
314
|
+
this.textController.createText(node, {
|
|
315
|
+
mallId,
|
|
316
|
+
depthConfig: options?.depthConfig,
|
|
317
|
+
viewMode: options?.viewMode,
|
|
318
|
+
onInvalidate: invalidateCb,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
this.applySelection(true);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Safely disposes and removes lingering CSS2D DOM elements on floor switch.
|
|
326
|
+
* Floor switch hone par ghost HTML text divs ko document se clean karein.
|
|
327
|
+
*/
|
|
328
|
+
cleanupTextDOM() {
|
|
329
|
+
this.textController.cleanupTextDOM();
|
|
330
|
+
}
|
|
331
|
+
// --- Theme & View Mode Coordination ---
|
|
332
|
+
/**
|
|
333
|
+
* Updates material and colors for a specific store shape.
|
|
334
|
+
* Kisi specific shape ka theme color update karein.
|
|
335
|
+
*/
|
|
336
|
+
updateNodeTheme(key, shapeDetail) {
|
|
337
|
+
const shape = this.getShapeByKey(key);
|
|
338
|
+
if (shape) {
|
|
339
|
+
this.shapeController.updateTheme(shape, shapeDetail);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Iterates through shapes and updates materials based on the active theme.
|
|
344
|
+
* Sabhi shapes aur icon badges ka theme color update karein.
|
|
345
|
+
*/
|
|
346
|
+
updateAllThemes(nodeMap, tintColor) {
|
|
347
|
+
if (nodeMap) {
|
|
348
|
+
const entries = nodeMap instanceof Map ? Array.from(nodeMap.entries()) : Object.entries(nodeMap);
|
|
349
|
+
for (const [key, node] of entries) {
|
|
350
|
+
if (node.shapeDetail) {
|
|
351
|
+
this.updateNodeTheme(key, node.shapeDetail);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
this.imageController.updateAllThemes(tintColor);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Updates map theme across shapes, images, and text labels.
|
|
359
|
+
* English: Propagates current theme configuration to shape, image, and text controllers.
|
|
360
|
+
* Hinglish: Map theme ko elements controller ke zariye shapes, images aur text labels me apply karein.
|
|
361
|
+
*/
|
|
362
|
+
setTheme(theme) {
|
|
363
|
+
this.currentTheme = resolveMapTheme(theme);
|
|
364
|
+
this.imageController.setThemeSpriteColors(this.currentTheme.spriteBackgroundColor, this.currentTheme.spriteBackgroundColors);
|
|
365
|
+
if (this.currentTheme.anchorStoreGradient) {
|
|
366
|
+
this.shapeController.updateAnchorGradient(this.currentTheme.anchorStoreGradient);
|
|
367
|
+
}
|
|
368
|
+
this.shapeController.updateEdgeColor(this.currentTheme.shapeEdgeColor);
|
|
369
|
+
this.applySelection();
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Updates anchor store gradient fill colors.
|
|
373
|
+
* English: Updates gradient colors used to highlight anchor retail stores.
|
|
374
|
+
* Hinglish: Anchor retail stores ke liye gradient colors update karein.
|
|
375
|
+
*/
|
|
376
|
+
updateAnchorGradient(gradient) {
|
|
377
|
+
this.shapeController.updateAnchorGradient(gradient);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Toggles visibility of 3D unit shape meshes.
|
|
381
|
+
* English: Toggles visibility for all unit shape meshes in the scene.
|
|
382
|
+
* Hinglish: Sabhi unit shape meshes ki visibility toggle karein.
|
|
383
|
+
*/
|
|
384
|
+
toggleShapes(visible) {
|
|
385
|
+
this.shapeController.toggleShapes(visible);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Toggles visibility of 2D DOM and 3D Troika text labels across all floors.
|
|
389
|
+
* English: Toggles visibility for all store text label groups across floors.
|
|
390
|
+
* Hinglish: Sabhi floors ke store text labels ki visibility toggle karein.
|
|
391
|
+
*/
|
|
392
|
+
toggleLabels(visible) {
|
|
393
|
+
this.textController.toggleLabels(visible);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Updates text label colors globally or on a per-type basis.
|
|
397
|
+
* English: Updates 3D Troika mesh text colors globally or per unit category.
|
|
398
|
+
* Hinglish: Text labels ke rang globally ya per-unit type ke mutabik update karein.
|
|
399
|
+
*/
|
|
400
|
+
updateTextColors(colorOrMap) {
|
|
401
|
+
this.textController.updateTextColors(colorOrMap);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Updates custom per-unit shape colors.
|
|
405
|
+
* English: Applies customized fill colors to individual store shapes by node key.
|
|
406
|
+
* Hinglish: Specific store shapes ke liye custom colors map apply karein.
|
|
407
|
+
*/
|
|
408
|
+
updateShapeColors(colorsMap) {
|
|
409
|
+
this.shapeController.updateShapeColors(colorsMap);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Updates stroke edge line color on unit shapes.
|
|
413
|
+
* English: Updates stroke line edge colors on extruded store shapes.
|
|
414
|
+
* Hinglish: Store shapes ke kinaro (edges) ka outline stroke color update karein.
|
|
415
|
+
*/
|
|
416
|
+
updateEdgeColor(color) {
|
|
417
|
+
this.shapeController.updateEdgeColor(color);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Updates circular background badge colors on icon sprites.
|
|
421
|
+
* English: Sets sprite background badge colors globally or per transit/amenity type.
|
|
422
|
+
* Hinglish: Transit/amenity sprites ke background circular badge colors update karein.
|
|
423
|
+
*/
|
|
424
|
+
updateSpriteThemes(colorOrMap) {
|
|
425
|
+
this.imageController.updateSpriteThemes(colorOrMap);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Toggles visibility and filtering of logos and sprites.
|
|
429
|
+
* English: Toggles visibility and filter criteria for brand logos and amenity icon sprites.
|
|
430
|
+
* Hinglish: Brand logos aur amenity icon sprites ki visibility aur filters toggle karein.
|
|
431
|
+
*/
|
|
432
|
+
toggleImages(visible, filter) {
|
|
433
|
+
this.imageController.toggleImages(visible, filter);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Coordinates 2D vs. 3D depth scaling across shapes, images, and labels.
|
|
437
|
+
* 2D aur 3D mode switch hone par shapes, images aur text ki vertical height sync karein.
|
|
438
|
+
*/
|
|
439
|
+
setShapeScale(z, mode = '3D', depth2D = 0.1, depth3D = 6, floorBaseDepth, animate = false, onUpdate, durationMs = 400, onComplete) {
|
|
440
|
+
const binaryMode = mode === '2D' ? '2D' : '3D';
|
|
441
|
+
const effectiveFloorBaseDepth = floorBaseDepth !== undefined ? floorBaseDepth : depth2D;
|
|
442
|
+
let pending = 3;
|
|
443
|
+
const checkDone = () => {
|
|
444
|
+
pending--;
|
|
445
|
+
if (pending <= 0 && onComplete) {
|
|
446
|
+
onComplete();
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
this.shapeController.setFloorScale(z, binaryMode, depth2D, depth3D, effectiveFloorBaseDepth, animate, onUpdate, durationMs, checkDone);
|
|
450
|
+
this.imageController.setFloorScale(z, mode, {
|
|
451
|
+
defaultUnitDepth: depth3D,
|
|
452
|
+
floorBaseDepth: effectiveFloorBaseDepth,
|
|
453
|
+
}, animate, onUpdate, durationMs, checkDone);
|
|
454
|
+
this.textController.setFloorScale(z, mode, {
|
|
455
|
+
defaultUnitDepth: depth3D,
|
|
456
|
+
floorBaseDepth: effectiveFloorBaseDepth,
|
|
457
|
+
}, animate, onUpdate, durationMs, checkDone);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Sets floor height scale across all elements using the active depth configuration.
|
|
461
|
+
* English: Synchronizes floor elevation scaling using configured 2D and 3D depth limits.
|
|
462
|
+
* Hinglish: Active depth configuration ke mutabik floor ke sabhi elements ki height scale karein.
|
|
463
|
+
*/
|
|
464
|
+
setFloorScale(z, mode = '3D', depthConfig, animate = false, onUpdate, durationMs = 400, onComplete) {
|
|
465
|
+
const depth2D = 0.1;
|
|
466
|
+
const depth3D = depthConfig?.defaultUnitDepth ?? 6;
|
|
467
|
+
const floorBaseDepth = depthConfig?.floorBaseDepth;
|
|
468
|
+
this.setShapeScale(z, mode, depth2D, depth3D, floorBaseDepth, animate, onUpdate, durationMs, onComplete);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Clears and disposes all shapes, images, and texts.
|
|
472
|
+
* Sabhi resources ko completely clear karein.
|
|
473
|
+
*/
|
|
474
|
+
clear() {
|
|
475
|
+
this.selectedNodeKeys = [];
|
|
476
|
+
this.originNodeKeys = [];
|
|
477
|
+
this.destinationNodeKeys = [];
|
|
478
|
+
this.applySelection();
|
|
479
|
+
this.shapeController.clear();
|
|
480
|
+
this.imageController.clear();
|
|
481
|
+
this.textController.clear();
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Full disposal of all elements and WebGL/DOM resources.
|
|
485
|
+
* Sabhi elements ko dispose karein.
|
|
486
|
+
*/
|
|
487
|
+
dispose() {
|
|
488
|
+
this.clear();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
3
|
+
/** Display interpolation only; one caller-owned RAF and no route, timer or writable host state.
|
|
4
|
+
* Hinglish: Ready world position follow hoti hai; sky/street projection aur caller limits preserve hain. */
|
|
5
|
+
export declare class CameraFollow {
|
|
6
|
+
active: boolean;
|
|
7
|
+
private readonly desired;
|
|
8
|
+
private readonly direction;
|
|
9
|
+
private readonly target;
|
|
10
|
+
reset(): void;
|
|
11
|
+
update(camera: THREE.Camera, controls: OrbitControls, position: THREE.Vector3, forward: THREE.Vector3, view: string, delta: number): boolean;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=CameraFollow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraFollow.d.ts","sourceRoot":"","sources":["../../src/engine/CameraFollow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAEjF;4GAC4G;AAC5G,qBAAa,YAAY;IACvB,MAAM,UAAQ;IACd,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,KAAK,IAAI,IAAI;IAGb,MAAM,CACJ,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,KAAK,CAAC,OAAO,EACvB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO;CA+CX"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/** Display interpolation only; one caller-owned RAF and no route, timer or writable host state.
|
|
3
|
+
* Hinglish: Ready world position follow hoti hai; sky/street projection aur caller limits preserve hain. */
|
|
4
|
+
export class CameraFollow {
|
|
5
|
+
active = false;
|
|
6
|
+
desired = new THREE.Vector3();
|
|
7
|
+
direction = new THREE.Vector3();
|
|
8
|
+
target = new THREE.Vector3();
|
|
9
|
+
reset() {
|
|
10
|
+
this.active = false;
|
|
11
|
+
}
|
|
12
|
+
update(camera, controls, position, forward, view, delta) {
|
|
13
|
+
this.active = true;
|
|
14
|
+
if (!(delta > 0) || !controls.enabled)
|
|
15
|
+
return false;
|
|
16
|
+
this.direction.copy(forward).setY(0);
|
|
17
|
+
if (this.direction.lengthSq() < 1e-10)
|
|
18
|
+
this.direction.set(0, 0, 1);
|
|
19
|
+
this.direction.normalize();
|
|
20
|
+
const sky = view === 'sky';
|
|
21
|
+
const angle = THREE.MathUtils.clamp(sky ? 0 : Math.atan2(20, 35), controls.minPolarAngle, controls.maxPolarAngle);
|
|
22
|
+
const distance = THREE.MathUtils.clamp(sky ? 70 : Math.hypot(20, 35), controls.minDistance, controls.maxDistance);
|
|
23
|
+
// Use actual projection/viewport, not window width; no second scene transform.
|
|
24
|
+
// Hinglish: Narrow canvas par offset projection se aaye; camera type ya zoom reset nahi hota.
|
|
25
|
+
const aspect = camera instanceof THREE.PerspectiveCamera
|
|
26
|
+
? camera.aspect
|
|
27
|
+
: camera instanceof THREE.OrthographicCamera
|
|
28
|
+
? (camera.right - camera.left) / (camera.top - camera.bottom)
|
|
29
|
+
: 1;
|
|
30
|
+
const height = camera instanceof THREE.PerspectiveCamera
|
|
31
|
+
? 2 * distance * Math.tan(THREE.MathUtils.degToRad(camera.getEffectiveFOV()) / 2)
|
|
32
|
+
: camera instanceof THREE.OrthographicCamera
|
|
33
|
+
? (camera.top - camera.bottom) / camera.zoom
|
|
34
|
+
: 0;
|
|
35
|
+
this.target.copy(position);
|
|
36
|
+
// Bound look-ahead by the visible vertical span so the cursor stays comfortably in frame.
|
|
37
|
+
// Hinglish: Zoom/FOV chhota ho to fixed15 units cursor ko bottom ke bahar na dhakele.
|
|
38
|
+
if (!sky)
|
|
39
|
+
this.target.addScaledVector(this.direction, Math.min(15, height * 0.15));
|
|
40
|
+
if (!sky && aspect < 1) {
|
|
41
|
+
this.target.y -= height * 0.1;
|
|
42
|
+
}
|
|
43
|
+
this.desired.copy(this.target).addScaledVector(this.direction, -Math.sin(angle) * distance);
|
|
44
|
+
this.desired.y += Math.cos(angle) * distance;
|
|
45
|
+
const alpha = 1 - Math.exp(-8 * Math.min(delta, 0.1));
|
|
46
|
+
camera.position.lerp(this.desired, alpha);
|
|
47
|
+
controls.target.lerp(this.target, alpha);
|
|
48
|
+
controls.update();
|
|
49
|
+
camera.updateMatrixWorld();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|