@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.
Files changed (116) hide show
  1. package/dist/controllers/ImageController.d.ts +95 -0
  2. package/dist/controllers/ImageController.d.ts.map +1 -0
  3. package/dist/controllers/ImageController.js +129 -0
  4. package/dist/controllers/ShapeController.d.ts +95 -0
  5. package/dist/controllers/ShapeController.d.ts.map +1 -0
  6. package/dist/controllers/ShapeController.js +139 -0
  7. package/dist/controllers/TextController.d.ts +120 -0
  8. package/dist/controllers/TextController.d.ts.map +1 -0
  9. package/dist/controllers/TextController.js +161 -0
  10. package/dist/controllers/ViewerElementsController.d.ts +254 -0
  11. package/dist/controllers/ViewerElementsController.d.ts.map +1 -0
  12. package/dist/controllers/ViewerElementsController.js +490 -0
  13. package/dist/engine/CameraFollow.d.ts +13 -0
  14. package/dist/engine/CameraFollow.d.ts.map +1 -0
  15. package/dist/engine/CameraFollow.js +52 -0
  16. package/dist/engine/CameraManager.d.ts +143 -0
  17. package/dist/engine/CameraManager.d.ts.map +1 -0
  18. package/dist/engine/CameraManager.js +566 -0
  19. package/dist/engine/ControlsManager.d.ts +123 -0
  20. package/dist/engine/ControlsManager.d.ts.map +1 -0
  21. package/dist/engine/ControlsManager.js +604 -0
  22. package/dist/engine/InteractionManager.d.ts +45 -0
  23. package/dist/engine/InteractionManager.d.ts.map +1 -0
  24. package/dist/engine/InteractionManager.js +99 -0
  25. package/dist/engine/LightingManager.d.ts +25 -0
  26. package/dist/engine/LightingManager.d.ts.map +1 -0
  27. package/dist/engine/LightingManager.js +74 -0
  28. package/dist/engine/MapViewerEngine.d.ts +350 -0
  29. package/dist/engine/MapViewerEngine.d.ts.map +1 -0
  30. package/dist/engine/MapViewerEngine.js +1041 -0
  31. package/dist/engine/RendererManager.d.ts +77 -0
  32. package/dist/engine/RendererManager.d.ts.map +1 -0
  33. package/dist/engine/RendererManager.js +243 -0
  34. package/dist/index.d.ts +40 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +39 -0
  37. package/dist/services/image-services/ImageCacheService.d.ts +49 -0
  38. package/dist/services/image-services/ImageCacheService.d.ts.map +1 -0
  39. package/dist/services/image-services/ImageCacheService.js +121 -0
  40. package/dist/services/image-services/ImagePlaneService.d.ts +29 -0
  41. package/dist/services/image-services/ImagePlaneService.d.ts.map +1 -0
  42. package/dist/services/image-services/ImagePlaneService.js +82 -0
  43. package/dist/services/image-services/ImageService.d.ts +170 -0
  44. package/dist/services/image-services/ImageService.d.ts.map +1 -0
  45. package/dist/services/image-services/ImageService.js +537 -0
  46. package/dist/services/image-services/ImageSpriteService.d.ts +39 -0
  47. package/dist/services/image-services/ImageSpriteService.d.ts.map +1 -0
  48. package/dist/services/image-services/ImageSpriteService.js +135 -0
  49. package/dist/services/routes/RouteArrows.d.ts +34 -0
  50. package/dist/services/routes/RouteArrows.d.ts.map +1 -0
  51. package/dist/services/routes/RouteArrows.js +157 -0
  52. package/dist/services/routes/RouteCursor.d.ts +19 -0
  53. package/dist/services/routes/RouteCursor.d.ts.map +1 -0
  54. package/dist/services/routes/RouteCursor.js +68 -0
  55. package/dist/services/routes/RouteMotion.d.ts +31 -0
  56. package/dist/services/routes/RouteMotion.d.ts.map +1 -0
  57. package/dist/services/routes/RouteMotion.js +132 -0
  58. package/dist/services/routes/RouteRenderer.d.ts +52 -0
  59. package/dist/services/routes/RouteRenderer.d.ts.map +1 -0
  60. package/dist/services/routes/RouteRenderer.js +445 -0
  61. package/dist/services/routes/RouteStepHighlight.d.ts +22 -0
  62. package/dist/services/routes/RouteStepHighlight.d.ts.map +1 -0
  63. package/dist/services/routes/RouteStepHighlight.js +84 -0
  64. package/dist/services/routes/routeMarkers.d.ts +6 -0
  65. package/dist/services/routes/routeMarkers.d.ts.map +1 -0
  66. package/dist/services/routes/routeMarkers.js +41 -0
  67. package/dist/services/selectionPaint.d.ts +12 -0
  68. package/dist/services/selectionPaint.d.ts.map +1 -0
  69. package/dist/services/selectionPaint.js +8 -0
  70. package/dist/services/shape-services/ExtrudeShapeService.d.ts +54 -0
  71. package/dist/services/shape-services/ExtrudeShapeService.d.ts.map +1 -0
  72. package/dist/services/shape-services/ExtrudeShapeService.js +204 -0
  73. package/dist/services/shape-services/FlatShapeService.d.ts +25 -0
  74. package/dist/services/shape-services/FlatShapeService.d.ts.map +1 -0
  75. package/dist/services/shape-services/FlatShapeService.js +49 -0
  76. package/dist/services/shape-services/IShapeService.d.ts +24 -0
  77. package/dist/services/shape-services/IShapeService.d.ts.map +1 -0
  78. package/dist/services/shape-services/IShapeService.js +6 -0
  79. package/dist/services/shape-services/MaterialUtils.d.ts +15 -0
  80. package/dist/services/shape-services/MaterialUtils.d.ts.map +1 -0
  81. package/dist/services/shape-services/MaterialUtils.js +71 -0
  82. package/dist/services/shape-services/ShapeFactory.d.ts +20 -0
  83. package/dist/services/shape-services/ShapeFactory.d.ts.map +1 -0
  84. package/dist/services/shape-services/ShapeFactory.js +28 -0
  85. package/dist/services/shape-services/ShapeHighlightService.d.ts +13 -0
  86. package/dist/services/shape-services/ShapeHighlightService.d.ts.map +1 -0
  87. package/dist/services/shape-services/ShapeHighlightService.js +57 -0
  88. package/dist/services/shape-services/ShapeService.d.ts +129 -0
  89. package/dist/services/shape-services/ShapeService.d.ts.map +1 -0
  90. package/dist/services/shape-services/ShapeService.js +480 -0
  91. package/dist/services/shape-services/preparedGeometry.d.ts +13 -0
  92. package/dist/services/shape-services/preparedGeometry.d.ts.map +1 -0
  93. package/dist/services/shape-services/preparedGeometry.js +37 -0
  94. package/dist/services/text-services/ITextRenderStrategy.d.ts +79 -0
  95. package/dist/services/text-services/ITextRenderStrategy.d.ts.map +1 -0
  96. package/dist/services/text-services/ITextRenderStrategy.js +7 -0
  97. package/dist/services/text-services/Text2DService.d.ts +66 -0
  98. package/dist/services/text-services/Text2DService.d.ts.map +1 -0
  99. package/dist/services/text-services/Text2DService.js +483 -0
  100. package/dist/services/text-services/Text3DService.d.ts +51 -0
  101. package/dist/services/text-services/Text3DService.d.ts.map +1 -0
  102. package/dist/services/text-services/Text3DService.js +246 -0
  103. package/dist/services/text-services/TextCollisionService.d.ts +29 -0
  104. package/dist/services/text-services/TextCollisionService.d.ts.map +1 -0
  105. package/dist/services/text-services/TextCollisionService.js +117 -0
  106. package/dist/services/text-services/TextService.d.ts +159 -0
  107. package/dist/services/text-services/TextService.d.ts.map +1 -0
  108. package/dist/services/text-services/TextService.js +398 -0
  109. package/dist/services/text-services/TextStrategyRegistry.d.ts +36 -0
  110. package/dist/services/text-services/TextStrategyRegistry.d.ts.map +1 -0
  111. package/dist/services/text-services/TextStrategyRegistry.js +44 -0
  112. package/dist/services/threeDisposeHelper.d.ts +12 -0
  113. package/dist/services/threeDisposeHelper.d.ts.map +1 -0
  114. package/dist/services/threeDisposeHelper.js +57 -0
  115. package/package.json +40 -3
  116. package/README.md +0 -3
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @file ExtrudeShapeService.ts
3
+ * @description Uploads prepared extruded geometry and applies dynamic depth and materials.
4
+ * English: Prepared unit meshes retain per-instance anchor gradients, category tagging and reset support.
5
+ * Hinglish: Geometry private API banati hai; yahan ready buffers, depth aur materials apply hote hain.
6
+ */
7
+ import * as THREE from 'three';
8
+ import type { shapeDetail } from '@wovvmap/contracts';
9
+ import type { IShapeService } from './IShapeService.js';
10
+ /**
11
+ * Creates 3D extruded store shapes with bevels and physical materials.
12
+ * Physical material aur dynamic depth ke sath 3D dukan create karein.
13
+ */
14
+ export declare class ExtrudeShapeService implements IShapeService {
15
+ /**
16
+ * Anchor store color codes for multiplexes, hypermarkets, and key brands.
17
+ * Anchor stores ke pehchan ke liye color hex codes.
18
+ */
19
+ static readonly ANCHOR_STORE_COLOR_CODES: Set<string>;
20
+ /**
21
+ * Default gradient palette used for anchor stores [top, bottom].
22
+ * Anchor stores ke liye default top-to-bottom vertical gradient palette.
23
+ */
24
+ static readonly DEFAULT_ANCHOR_GRADIENT: [string, string];
25
+ private anchorGradient;
26
+ setAnchorGradient(gradient: [string, string]): void;
27
+ getAnchorGradient(): [string, string];
28
+ /**
29
+ * Checks if a given hex color belongs to an anchor store.
30
+ * Diya gaya color anchor store ka hai ya nahi check karein.
31
+ */
32
+ isAnchorStoreColor(color?: string): boolean;
33
+ /**
34
+ * Applies vertical linear gradient shader material to anchor store meshes.
35
+ * Anchor store mesh par vertical gradient shader apply karein.
36
+ */
37
+ applyAnchorGradient(mesh: THREE.Mesh, gradientColors?: string[]): void;
38
+ /**
39
+ * Helper to update physical materials on a mesh (converting from shader material if needed).
40
+ * Shader material ko standard physical materials me convert ya update karein.
41
+ */
42
+ private updatePhysicalMaterials;
43
+ /**
44
+ * Constructs a 3D extruded mesh from shape boundary points.
45
+ * Shape boundary points se 3D extruded mesh create karein.
46
+ */
47
+ createShape(shapeDetail: shapeDetail, id: string): THREE.Object3D;
48
+ /**
49
+ * Updates base color and side materials when theme or customColors changes.
50
+ * Theme change hone par mesh ke colors update karein.
51
+ */
52
+ updateTheme(mesh: THREE.Object3D, shapeDetail: Partial<shapeDetail>): void;
53
+ }
54
+ //# sourceMappingURL=ExtrudeShapeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtrudeShapeService.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/ExtrudeShapeService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIpD;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD;;;OAGG;IACH,gBAAuB,wBAAwB,cAAkC;IAEjF;;;OAGG;IACH,gBAAuB,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAyB;IAEzF,OAAO,CAAC,cAAc,CAAgE;IAE/E,iBAAiB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAInD,iBAAiB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAI5C;;;OAGG;IACI,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAMlD;;;OAGG;IACI,mBAAmB,CACxB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,cAAc,GAAE,MAAM,EAAwB,GAC7C,IAAI;IAmBP;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IA0D/B;;;OAGG;IACI,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ;IA2ExE;;;OAGG;IACI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;CA8BlF"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @file ExtrudeShapeService.ts
3
+ * @description Uploads prepared extruded geometry and applies dynamic depth and materials.
4
+ * English: Prepared unit meshes retain per-instance anchor gradients, category tagging and reset support.
5
+ * Hinglish: Geometry private API banati hai; yahan ready buffers, depth aur materials apply hote hain.
6
+ */
7
+ import * as THREE from 'three';
8
+ import { setGradientMaterial } from './MaterialUtils.js';
9
+ import { uploadPreparedGeometry } from './preparedGeometry.js';
10
+ /**
11
+ * Creates 3D extruded store shapes with bevels and physical materials.
12
+ * Physical material aur dynamic depth ke sath 3D dukan create karein.
13
+ */
14
+ export class ExtrudeShapeService {
15
+ /**
16
+ * Anchor store color codes for multiplexes, hypermarkets, and key brands.
17
+ * Anchor stores ke pehchan ke liye color hex codes.
18
+ */
19
+ static ANCHOR_STORE_COLOR_CODES = new Set(['#62236b', '#62206b']);
20
+ /**
21
+ * Default gradient palette used for anchor stores [top, bottom].
22
+ * Anchor stores ke liye default top-to-bottom vertical gradient palette.
23
+ */
24
+ static DEFAULT_ANCHOR_GRADIENT = ['#8b3a99', '#4a1552'];
25
+ anchorGradient = ExtrudeShapeService.DEFAULT_ANCHOR_GRADIENT;
26
+ setAnchorGradient(gradient) {
27
+ this.anchorGradient = gradient;
28
+ }
29
+ getAnchorGradient() {
30
+ return this.anchorGradient;
31
+ }
32
+ /**
33
+ * Checks if a given hex color belongs to an anchor store.
34
+ * Diya gaya color anchor store ka hai ya nahi check karein.
35
+ */
36
+ isAnchorStoreColor(color) {
37
+ return Boolean(color && ExtrudeShapeService.ANCHOR_STORE_COLOR_CODES.has(color.trim().toLowerCase()));
38
+ }
39
+ /**
40
+ * Applies vertical linear gradient shader material to anchor store meshes.
41
+ * Anchor store mesh par vertical gradient shader apply karein.
42
+ */
43
+ applyAnchorGradient(mesh, gradientColors = this.anchorGradient) {
44
+ setGradientMaterial(mesh, gradientColors);
45
+ const representativeColor = (gradientColors[0] ??
46
+ mesh.userData.originalColor ??
47
+ '#62236b').trim();
48
+ mesh.userData.effectiveColor = representativeColor;
49
+ const darkColor = new THREE.Color(representativeColor).multiplyScalar(0.3);
50
+ mesh.children.forEach((child) => {
51
+ if (child instanceof THREE.LineSegments &&
52
+ child.material instanceof THREE.LineBasicMaterial) {
53
+ child.material.color.copy(darkColor);
54
+ }
55
+ });
56
+ }
57
+ /**
58
+ * Helper to update physical materials on a mesh (converting from shader material if needed).
59
+ * Shader material ko standard physical materials me convert ya update karein.
60
+ */
61
+ updatePhysicalMaterials(mesh, colorStr) {
62
+ let normalized = colorStr.trim();
63
+ if (normalized.startsWith('rgba')) {
64
+ const match = normalized.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*[\d.]+)?\s*\)/i);
65
+ if (match) {
66
+ normalized = `rgb(${match[1]}, ${match[2]}, ${match[3]})`;
67
+ }
68
+ }
69
+ const baseColor = new THREE.Color(normalized);
70
+ const darkColor = baseColor.clone().multiplyScalar(0.3);
71
+ mesh.userData.effectiveColor = normalized;
72
+ if (Array.isArray(mesh.material)) {
73
+ if (mesh.material[0] instanceof THREE.MeshPhysicalMaterial) {
74
+ mesh.material[0].color.copy(baseColor);
75
+ }
76
+ if (mesh.material[1] instanceof THREE.MeshPhysicalMaterial) {
77
+ mesh.material[1].color.copy(darkColor);
78
+ }
79
+ }
80
+ else {
81
+ // English: Dispose previous single shader/gradient material to prevent GPU memory leak.
82
+ // Hinglish: Naya physical material assign karne se pehle purane material ko dispose karein.
83
+ if (mesh.material) {
84
+ if (Array.isArray(mesh.material)) {
85
+ mesh.material.forEach((m) => m.dispose());
86
+ }
87
+ else {
88
+ mesh.material.dispose();
89
+ }
90
+ }
91
+ const topMaterial = new THREE.MeshPhysicalMaterial({
92
+ color: baseColor,
93
+ side: THREE.DoubleSide,
94
+ roughness: 0.5,
95
+ metalness: 0.1,
96
+ clearcoat: 0.2,
97
+ clearcoatRoughness: 0.6,
98
+ });
99
+ const sideMaterial = new THREE.MeshPhysicalMaterial({
100
+ color: darkColor,
101
+ side: THREE.DoubleSide,
102
+ roughness: 0.6,
103
+ metalness: 0.1,
104
+ });
105
+ mesh.material = [topMaterial, sideMaterial];
106
+ }
107
+ mesh.children.forEach((child) => {
108
+ if (child instanceof THREE.LineSegments &&
109
+ child.material instanceof THREE.LineBasicMaterial) {
110
+ child.material.color.copy(darkColor);
111
+ }
112
+ });
113
+ }
114
+ /**
115
+ * Constructs a 3D extruded mesh from shape boundary points.
116
+ * Shape boundary points se 3D extruded mesh create karein.
117
+ */
118
+ createShape(shapeDetail, id) {
119
+ const { color } = shapeDetail;
120
+ const { geometry, edges, originalDepth: effectiveDepth, isFloorBase, position, rotation, } = uploadPreparedGeometry(shapeDetail);
121
+ let baseColorStr = color && color.trim() !== '' ? color.trim() : '#CCCCCC';
122
+ // Support rgba(r,g,b,a) by converting to rgb(r,g,b) to prevent Three.js console warnings
123
+ // rgba string ko rgb me convert karein taaki Three.js console warning na aaye; opacity/transparency untouched rahe.
124
+ if (baseColorStr.startsWith('rgba')) {
125
+ const match = baseColorStr.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*[\d.]+)?\s*\)/i);
126
+ if (match) {
127
+ baseColorStr = `rgb(${match[1]}, ${match[2]}, ${match[3]})`;
128
+ }
129
+ }
130
+ const baseColor = new THREE.Color(baseColorStr);
131
+ const darkColor = baseColor.clone().multiplyScalar(0.3);
132
+ const topMaterial = new THREE.MeshPhysicalMaterial({
133
+ color: baseColor,
134
+ side: THREE.DoubleSide,
135
+ roughness: 0.5,
136
+ metalness: 0.1,
137
+ clearcoat: 0.2,
138
+ clearcoatRoughness: 0.6,
139
+ });
140
+ const sideMaterial = new THREE.MeshPhysicalMaterial({
141
+ color: darkColor,
142
+ side: THREE.DoubleSide,
143
+ roughness: 0.6,
144
+ metalness: 0.1,
145
+ });
146
+ const mesh = new THREE.Mesh(geometry, [topMaterial, sideMaterial]);
147
+ const isAnchor = this.isAnchorStoreColor(color);
148
+ mesh.userData.id = id;
149
+ mesh.userData.nodeId = id;
150
+ mesh.userData.category = shapeDetail.category;
151
+ mesh.userData.originalDepth = effectiveDepth;
152
+ mesh.userData.originalColor = baseColorStr;
153
+ mesh.userData.effectiveColor = baseColorStr;
154
+ mesh.userData.originalIsAnchorStore = isAnchor;
155
+ mesh.userData.floorBash = isFloorBase;
156
+ mesh.userData.isFloorBase = isFloorBase;
157
+ mesh.userData.floorBaseDepth = isFloorBase ? effectiveDepth : undefined;
158
+ mesh.name = id;
159
+ mesh.position.set(position.x, position.y, position.z);
160
+ mesh.rotation.set(rotation.x, rotation.y, rotation.z);
161
+ // Edge lines for crisp visual definition
162
+ const edgeLines = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: darkColor }));
163
+ mesh.add(edgeLines);
164
+ // Apply vertical gradient if unit is an anchor store
165
+ if (isAnchor) {
166
+ mesh.userData.isAnchorStore = true;
167
+ this.applyAnchorGradient(mesh, this.anchorGradient);
168
+ }
169
+ return mesh;
170
+ }
171
+ /**
172
+ * Updates base color and side materials when theme or customColors changes.
173
+ * Theme change hone par mesh ke colors update karein.
174
+ */
175
+ updateTheme(mesh, shapeDetail) {
176
+ if (!(mesh instanceof THREE.Mesh))
177
+ return;
178
+ const color = shapeDetail.color;
179
+ if (!color) {
180
+ mesh.userData.hasCustomColor = false;
181
+ const originalColorStr = mesh.userData.originalColor ?? '#CCCCCC';
182
+ mesh.userData.effectiveColor = originalColorStr;
183
+ // Declarative reset: restore original node styling
184
+ if (mesh.userData.originalIsAnchorStore) {
185
+ mesh.userData.isAnchorStore = true;
186
+ this.applyAnchorGradient(mesh, this.anchorGradient);
187
+ }
188
+ else if (mesh.userData.originalColor) {
189
+ this.updatePhysicalMaterials(mesh, mesh.userData.originalColor);
190
+ }
191
+ return;
192
+ }
193
+ // Re-apply gradient if it is an anchor store color and not overridden
194
+ if (this.isAnchorStoreColor(color)) {
195
+ mesh.userData.isAnchorStore = true;
196
+ this.applyAnchorGradient(mesh, this.anchorGradient);
197
+ return;
198
+ }
199
+ // Explicit color override on mesh (handles single gradient shader material as well)
200
+ this.updatePhysicalMaterials(mesh, color);
201
+ mesh.userData.isAnchorStore = false;
202
+ mesh.userData.hasCustomColor = true;
203
+ }
204
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @file FlatShapeService.ts
3
+ * @description Uploads prepared planar geometry and applies floor boundary materials.
4
+ * Hinglish: Private API ki ready 2D geometry se floor mesh aur materials banayein.
5
+ */
6
+ import * as THREE from 'three';
7
+ import type { shapeDetail } from '@wovvmap/contracts';
8
+ import type { IShapeService } from './IShapeService.js';
9
+ /**
10
+ * Creates 2D flat planar floor boundary polygons.
11
+ * Floor footprint ke liye 2D planar mesh banayein.
12
+ */
13
+ export declare class FlatShapeService implements IShapeService {
14
+ /**
15
+ * Constructs a 2D planar mesh from prepared buffers.
16
+ * Hinglish: Ready buffers se 2D flat mesh banayein.
17
+ */
18
+ createShape(shapeDetail: shapeDetail, id: string): THREE.Object3D;
19
+ /**
20
+ * Updates base color for flat shapes.
21
+ * Flat shape ka color update karein.
22
+ */
23
+ updateTheme(mesh: THREE.Object3D, shapeDetail: shapeDetail): void;
24
+ }
25
+ //# sourceMappingURL=FlatShapeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatShapeService.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/FlatShapeService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGpD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD;;;OAGG;IACI,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ;IA4BxE;;;OAGG;IACI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;CAQzE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @file FlatShapeService.ts
3
+ * @description Uploads prepared planar geometry and applies floor boundary materials.
4
+ * Hinglish: Private API ki ready 2D geometry se floor mesh aur materials banayein.
5
+ */
6
+ import * as THREE from 'three';
7
+ import { uploadPreparedGeometry } from './preparedGeometry.js';
8
+ /**
9
+ * Creates 2D flat planar floor boundary polygons.
10
+ * Floor footprint ke liye 2D planar mesh banayein.
11
+ */
12
+ export class FlatShapeService {
13
+ /**
14
+ * Constructs a 2D planar mesh from prepared buffers.
15
+ * Hinglish: Ready buffers se 2D flat mesh banayein.
16
+ */
17
+ createShape(shapeDetail, id) {
18
+ const { color } = shapeDetail;
19
+ const { geometry, edges, position, rotation } = uploadPreparedGeometry(shapeDetail);
20
+ const material = new THREE.MeshBasicMaterial({
21
+ color: color && color.trim() !== '' ? color : '#E0E0E0',
22
+ side: THREE.DoubleSide,
23
+ transparent: true,
24
+ opacity: 0.8,
25
+ });
26
+ const mesh = new THREE.Mesh(geometry, material);
27
+ mesh.userData.id = id;
28
+ mesh.name = id;
29
+ // Slightly elevated to prevent z-fighting with the canvas background
30
+ mesh.position.set(position.x, position.y, position.z);
31
+ mesh.rotation.set(rotation.x, rotation.y, rotation.z);
32
+ // Outline edges
33
+ const edgeLines = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0x888888 }));
34
+ mesh.add(edgeLines);
35
+ return mesh;
36
+ }
37
+ /**
38
+ * Updates base color for flat shapes.
39
+ * Flat shape ka color update karein.
40
+ */
41
+ updateTheme(mesh, shapeDetail) {
42
+ if (!(mesh instanceof THREE.Mesh) || !(mesh.material instanceof THREE.MeshBasicMaterial)) {
43
+ return;
44
+ }
45
+ if (shapeDetail.color) {
46
+ mesh.material.color.set(shapeDetail.color);
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file IShapeService.ts
3
+ * @description Strategy interface for Three.js 2D and 3D shape rendering.
4
+ * 2D aur 3D Three.js shapes create aur update karne ke liye strategy interface.
5
+ */
6
+ import type * as THREE from 'three';
7
+ import type { shapeDetail } from '@wovvmap/contracts';
8
+ /**
9
+ * Strategy contract implemented by concrete shape generators (ExtrudeShapeService, FlatShapeService).
10
+ * Shape generators ke liye strategy contract.
11
+ */
12
+ export interface IShapeService {
13
+ /**
14
+ * Creates a Three.js 3D/2D visual object from shapeDetail.
15
+ * shapeDetail se Three.js object create karein.
16
+ */
17
+ createShape(shapeDetail: shapeDetail, id: string): THREE.Object3D;
18
+ /**
19
+ * Updates visual material, theme, or color on an existing shape mesh.
20
+ * Shape mesh ka material ya color update karein.
21
+ */
22
+ updateTheme(mesh: THREE.Object3D, shapeDetail: Partial<shapeDetail>): void;
23
+ }
24
+ //# sourceMappingURL=IShapeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IShapeService.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/IShapeService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAA;IAEjE;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;CAC3E"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file IShapeService.ts
3
+ * @description Strategy interface for Three.js 2D and 3D shape rendering.
4
+ * 2D aur 3D Three.js shapes create aur update karne ke liye strategy interface.
5
+ */
6
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file MaterialUtils.ts
3
+ * @description Shader and material utility for vertical height gradient blending on Three.js meshes.
4
+ * 3D mesh par vertical gradient material apply karne wala utility shader.
5
+ */
6
+ import * as THREE from 'three';
7
+ /**
8
+ * Applies a vertical gradient material to a mesh along its height axis.
9
+ * Mesh ke bounding box ke along top se bottom tak linear gradient shader apply karein.
10
+ *
11
+ * @param mesh Target Three.js mesh.
12
+ * @param colors Array of color hex strings (first is top, last is bottom).
13
+ */
14
+ export declare function setGradientMaterial(mesh: THREE.Mesh, colors: string[]): void;
15
+ //# sourceMappingURL=MaterialUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaterialUtils.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/MaterialUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAoE5E"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @file MaterialUtils.ts
3
+ * @description Shader and material utility for vertical height gradient blending on Three.js meshes.
4
+ * 3D mesh par vertical gradient material apply karne wala utility shader.
5
+ */
6
+ import * as THREE from 'three';
7
+ /**
8
+ * Applies a vertical gradient material to a mesh along its height axis.
9
+ * Mesh ke bounding box ke along top se bottom tak linear gradient shader apply karein.
10
+ *
11
+ * @param mesh Target Three.js mesh.
12
+ * @param colors Array of color hex strings (first is top, last is bottom).
13
+ */
14
+ export function setGradientMaterial(mesh, colors) {
15
+ if (!mesh || !mesh.geometry)
16
+ return;
17
+ const geometry = mesh.geometry;
18
+ if (!geometry.attributes['position'])
19
+ return;
20
+ const positionAttr = geometry.attributes['position'];
21
+ const bbox = new THREE.Box3().setFromBufferAttribute(positionAttr);
22
+ const bbMin = bbox.min.clone();
23
+ const bbMax = bbox.max.clone();
24
+ const topColorHex = colors[0] ?? '#8b3a99';
25
+ const bottomColorHex = colors[colors.length - 1] ?? '#4a1552';
26
+ // Gradient standard material
27
+ const gradientMaterial = new THREE.MeshStandardMaterial({
28
+ roughness: 0.5,
29
+ metalness: 0.1,
30
+ side: THREE.DoubleSide,
31
+ });
32
+ gradientMaterial.onBeforeCompile = (shader) => {
33
+ const uniforms = shader.uniforms;
34
+ uniforms['bbMin'] = { value: bbMin };
35
+ uniforms['bbMax'] = { value: bbMax };
36
+ uniforms['color1'] = { value: new THREE.Color(topColorHex) };
37
+ uniforms['color2'] = { value: new THREE.Color(bottomColorHex) };
38
+ shader.vertexShader =
39
+ `
40
+ varying vec3 vPos;
41
+ ` +
42
+ shader.vertexShader.replace('#include <begin_vertex>', `#include <begin_vertex>
43
+ vPos = transformed;`);
44
+ shader.fragmentShader =
45
+ `
46
+ uniform vec3 bbMin;
47
+ uniform vec3 bbMax;
48
+ uniform vec3 color1;
49
+ uniform vec3 color2;
50
+ varying vec3 vPos;
51
+ ` +
52
+ shader.fragmentShader.replace('vec4 diffuseColor = vec4( diffuse, opacity );', `
53
+ float f = clamp((vPos.y - bbMin.y) / max(bbMax.y - bbMin.y, 0.0001), 0., 1.);
54
+ vec3 col = mix(color2, color1, f);
55
+ vec4 diffuseColor = vec4( col, opacity );
56
+ `);
57
+ };
58
+ gradientMaterial.needsUpdate = true;
59
+ // English: Dispose previous material before applying new gradient shader to avoid memory leaks.
60
+ // Hinglish: Naya gradient shader lagane se pehle purane material ko dispose karein taaki shader leak na ho.
61
+ const oldMat = mesh.material;
62
+ if (oldMat) {
63
+ if (Array.isArray(oldMat)) {
64
+ oldMat.forEach((m) => m.dispose());
65
+ }
66
+ else {
67
+ oldMat.dispose();
68
+ }
69
+ }
70
+ mesh.material = gradientMaterial;
71
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @file ShapeFactory.ts
3
+ * @description Factory resolving appropriate shape rendering strategies (extruded vs flat).
4
+ * Shape type ke aadhar par sahi shape strategy choose karne wali factory.
5
+ */
6
+ import type { IShapeService } from './IShapeService.js';
7
+ export type ShapeType = 'extruded' | 'flat';
8
+ /**
9
+ * Factory class returning singleton strategy instances for extruded or flat shapes.
10
+ * Shape creation strategies resolve karne ki factory.
11
+ */
12
+ export declare class ShapeFactory {
13
+ private static readonly strategies;
14
+ /**
15
+ * Retrieves the strategy for the given shape type. Defaults to 'extruded'.
16
+ * Diye gaye shape type ke liye strategy return karein.
17
+ */
18
+ static getStrategy(type?: ShapeType): IShapeService;
19
+ }
20
+ //# sourceMappingURL=ShapeFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeFactory.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/ShapeFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,MAAM,CAAA;AAE3C;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAGjC;IAED;;;OAGG;WACW,WAAW,CAAC,IAAI,GAAE,SAAsB,GAAG,aAAa;CAOvE"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @file ShapeFactory.ts
3
+ * @description Factory resolving appropriate shape rendering strategies (extruded vs flat).
4
+ * Shape type ke aadhar par sahi shape strategy choose karne wali factory.
5
+ */
6
+ import { ExtrudeShapeService } from './ExtrudeShapeService.js';
7
+ import { FlatShapeService } from './FlatShapeService.js';
8
+ /**
9
+ * Factory class returning singleton strategy instances for extruded or flat shapes.
10
+ * Shape creation strategies resolve karne ki factory.
11
+ */
12
+ export class ShapeFactory {
13
+ static strategies = {
14
+ extruded: new ExtrudeShapeService(),
15
+ flat: new FlatShapeService(),
16
+ };
17
+ /**
18
+ * Retrieves the strategy for the given shape type. Defaults to 'extruded'.
19
+ * Diye gaye shape type ke liye strategy return karein.
20
+ */
21
+ static getStrategy(type = 'extruded') {
22
+ const strategy = this.strategies[type];
23
+ if (!strategy) {
24
+ return this.strategies.extruded;
25
+ }
26
+ return strategy;
27
+ }
28
+ }
@@ -0,0 +1,13 @@
1
+ import * as THREE from 'three';
2
+ /** Owns temporary selection materials without changing the shape's base styling or geometry.
3
+ * Hinglish: Selection ke temporary materials alag rakhein; asli style aur geometry nahi badalte. */
4
+ export declare class ShapeHighlightService {
5
+ private readonly overlays;
6
+ has(shape: THREE.Object3D): boolean;
7
+ apply(shape: THREE.Object3D, color: string): void;
8
+ /** Restore exact material references before normal styling/disposal can replace their resources.
9
+ * Hinglish: Base update ya cleanup se pehle wahi asli material references wapas lagayein. */
10
+ detach(shape?: THREE.Object3D): void;
11
+ private release;
12
+ }
13
+ //# sourceMappingURL=ShapeHighlightService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeHighlightService.d.ts","sourceRoot":"","sources":["../../../src/services/shape-services/ShapeHighlightService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B;oGACoG;AACpG,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+C;IAEjE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,GAAG,OAAO;IAInC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAyBxD;iGAC6F;IACtF,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI;IAW3C,OAAO,CAAC,OAAO;CAOhB"}
@@ -0,0 +1,57 @@
1
+ import * as THREE from 'three';
2
+ /** Owns temporary selection materials without changing the shape's base styling or geometry.
3
+ * Hinglish: Selection ke temporary materials alag rakhein; asli style aur geometry nahi badalte. */
4
+ export class ShapeHighlightService {
5
+ overlays = new Map();
6
+ has(shape) {
7
+ return this.overlays.has(shape);
8
+ }
9
+ apply(shape, color) {
10
+ if (shape.userData.floorBash === true || shape.userData.isFloorBase === true)
11
+ return;
12
+ this.detach(shape);
13
+ const overlays = [];
14
+ shape.traverse((object) => {
15
+ if (!(object instanceof THREE.Mesh || object instanceof THREE.LineSegments))
16
+ return;
17
+ const original = object.material;
18
+ const tint = new THREE.Color(color);
19
+ if (object instanceof THREE.LineSegments)
20
+ tint.multiplyScalar(0.3);
21
+ const cloneMaterial = (material) => {
22
+ const clone = material.clone();
23
+ clone.color?.copy(tint);
24
+ return clone;
25
+ };
26
+ const overlay = Array.isArray(original)
27
+ ? original.map(cloneMaterial)
28
+ : cloneMaterial(original);
29
+ overlays.push({ object, original, overlay });
30
+ object.material = overlay;
31
+ });
32
+ this.overlays.set(shape, overlays);
33
+ }
34
+ /** Restore exact material references before normal styling/disposal can replace their resources.
35
+ * Hinglish: Base update ya cleanup se pehle wahi asli material references wapas lagayein. */
36
+ detach(shape) {
37
+ if (shape) {
38
+ const overlays = this.overlays.get(shape);
39
+ if (overlays)
40
+ this.release(overlays);
41
+ this.overlays.delete(shape);
42
+ return;
43
+ }
44
+ for (const overlays of this.overlays.values())
45
+ this.release(overlays);
46
+ this.overlays.clear();
47
+ }
48
+ release(overlays) {
49
+ for (const { object, original, overlay } of overlays) {
50
+ object.material = original;
51
+ if (Array.isArray(overlay))
52
+ overlay.forEach((material) => material.dispose());
53
+ else
54
+ overlay.dispose();
55
+ }
56
+ }
57
+ }