@2112-lab/central-plant 0.1.0 → 0.1.2

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 (43) hide show
  1. package/dist/bundle/index.js +7782 -6543
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +23 -10
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -0
  4. package/dist/cjs/src/animationManager.js +15 -15
  5. package/dist/cjs/src/componentManager.js +8 -8
  6. package/dist/cjs/src/disposalManager.js +12 -12
  7. package/dist/cjs/src/environmentManager.js +392 -99
  8. package/dist/cjs/src/hotReloadManager.js +26 -26
  9. package/dist/cjs/src/index.js +19 -66
  10. package/dist/cjs/src/keyboardControlsManager.js +23 -23
  11. package/dist/cjs/src/nameUtils.js +21 -21
  12. package/dist/cjs/src/pathfindingManager.js +311 -129
  13. package/dist/cjs/src/performanceMonitor.js +52 -52
  14. package/dist/cjs/src/sceneExportManager.js +23 -23
  15. package/dist/cjs/src/sceneInitializationManager.js +18 -18
  16. package/dist/cjs/src/textureConfig.js +469 -40
  17. package/dist/cjs/src/transformControlsManager.js +79 -79
  18. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +21 -10
  19. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -0
  20. package/dist/esm/src/animationManager.js +15 -15
  21. package/dist/esm/src/componentManager.js +8 -8
  22. package/dist/esm/src/disposalManager.js +12 -12
  23. package/dist/esm/src/environmentManager.js +393 -100
  24. package/dist/esm/src/hotReloadManager.js +26 -26
  25. package/dist/esm/src/index.js +19 -66
  26. package/dist/esm/src/keyboardControlsManager.js +23 -23
  27. package/dist/esm/src/nameUtils.js +21 -21
  28. package/dist/esm/src/pathfindingManager.js +313 -129
  29. package/dist/esm/src/performanceMonitor.js +52 -52
  30. package/dist/esm/src/sceneExportManager.js +23 -23
  31. package/dist/esm/src/sceneInitializationManager.js +18 -18
  32. package/dist/esm/src/textureConfig.js +469 -42
  33. package/dist/esm/src/transformControlsManager.js +79 -79
  34. package/dist/index.d.ts +255 -259
  35. package/package.json +52 -53
  36. package/dist/cjs/src/ConnectionManager.js +0 -114
  37. package/dist/cjs/src/Pathfinder.js +0 -88
  38. package/dist/cjs/src/modelPreloader.js +0 -360
  39. package/dist/cjs/src/sceneOperationsManager.js +0 -560
  40. package/dist/esm/src/ConnectionManager.js +0 -110
  41. package/dist/esm/src/Pathfinder.js +0 -84
  42. package/dist/esm/src/modelPreloader.js +0 -337
  43. package/dist/esm/src/sceneOperationsManager.js +0 -536
@@ -29,6 +29,47 @@ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
29
29
  // We'll need to import RGBELoader from three examples
30
30
  var RGBELoader;
31
31
 
32
+ /**
33
+ * Helper function to get asset paths that works in both bundled and modular contexts
34
+ * @param {string} assetPath - Relative path from the assets directory
35
+ * @returns {string} - The full path to the asset
36
+ */
37
+ function getAssetPath(assetPath) {
38
+ // Strip leading slash if present
39
+ if (assetPath.startsWith('/')) {
40
+ assetPath = assetPath.substring(1);
41
+ }
42
+
43
+ // In browser context, check for different module formats
44
+ if (typeof window !== 'undefined') {
45
+ // For bundled version, assets should be in dist/bundle/assets/
46
+ // For ESM/CJS, assets should be in their respective folders
47
+
48
+ // Try to determine if we're using the bundled version or ESM/CJS
49
+ var isBundled = typeof CentralPlantUtils !== 'undefined';
50
+
51
+ // Check if we're running in a Nuxt.js environment (localhost:3000 is a common dev server)
52
+ var isNuxtEnv = window.location.hostname === 'localhost' && (window.location.port === '3000' || window.location.port === '3001');
53
+ if (isNuxtEnv) {
54
+ // In Nuxt.js environment, assets are likely in the /static directory at the root
55
+ return "/".concat(assetPath); // No /assets/ prefix in the URL path
56
+ } else if (isBundled) {
57
+ // Get the base URL for the module
58
+ var baseUrl = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('src/environmentManager.js', document.baseURI).href));
59
+ // In bundled format, assets are in the assets folder next to the bundle
60
+ return new URL("./assets/".concat(assetPath), baseUrl).href;
61
+ } else {
62
+ // Get the base URL for the module
63
+ var _baseUrl = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('src/environmentManager.js', document.baseURI).href));
64
+ // In ESM/CJS format, need to go up relative to current module path
65
+ return new URL("../assets/".concat(assetPath), _baseUrl).href;
66
+ }
67
+ }
68
+
69
+ // In Node.js context
70
+ return "assets/".concat(assetPath);
71
+ }
72
+
32
73
  // Dynamic import for browser compatibility
33
74
  function importThreeLoaders() {
34
75
  return _importThreeLoaders.apply(this, arguments);
@@ -65,13 +106,17 @@ function _importThreeLoaders() {
65
106
  }));
66
107
  return _importThreeLoaders.apply(this, arguments);
67
108
  }
68
- var loadTextureSetAndCreateMaterial;
109
+ var textureConfig = {
110
+ loadTextureSetAndCreateMaterial: null,
111
+ checkThreeJSCompatibility: null,
112
+ forceUpdateMaterials: null
113
+ };
69
114
  function importTextureConfig() {
70
115
  return _importTextureConfig.apply(this, arguments);
71
116
  }
72
117
  function _importTextureConfig() {
73
118
  _importTextureConfig = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee9() {
74
- var module, _t1;
119
+ var module, importedFunctions, _t1;
75
120
  return _rollupPluginBabelHelpers.regenerator().w(function (_context1) {
76
121
  while (1) switch (_context1.n) {
77
122
  case 0:
@@ -85,8 +130,28 @@ function _importTextureConfig() {
85
130
  return Promise.resolve().then(function () { return require('./textureConfig.js'); });
86
131
  case 2:
87
132
  module = _context1.v;
88
- loadTextureSetAndCreateMaterial = module.loadTextureSetAndCreateMaterial;
89
- console.log('✅ TextureConfig imported successfully:', loadTextureSetAndCreateMaterial ? 'Available' : 'Undefined');
133
+ // Store all exported functions
134
+ textureConfig.loadTextureSetAndCreateMaterial = module.loadTextureSetAndCreateMaterial;
135
+ textureConfig.checkThreeJSCompatibility = module.checkThreeJSCompatibility;
136
+ textureConfig.forceUpdateMaterials = module.forceUpdateMaterials;
137
+
138
+ // Check what was successfully imported
139
+ importedFunctions = Object.entries(textureConfig).filter(function (_ref2) {
140
+ var _ref3 = _rollupPluginBabelHelpers.slicedToArray(_ref2, 2);
141
+ _ref3[0];
142
+ var fn = _ref3[1];
143
+ return typeof fn === 'function';
144
+ }).map(function (_ref4) {
145
+ var _ref5 = _rollupPluginBabelHelpers.slicedToArray(_ref4, 1),
146
+ name = _ref5[0];
147
+ return name;
148
+ });
149
+ console.log("\u2705 TextureConfig imported successfully with functions: ".concat(importedFunctions.join(', ')));
150
+
151
+ // Run compatibility check if available
152
+ if (typeof textureConfig.checkThreeJSCompatibility === 'function') {
153
+ textureConfig.checkThreeJSCompatibility();
154
+ }
90
155
  return _context1.a(2, true);
91
156
  case 3:
92
157
  _context1.p = 3;
@@ -142,15 +207,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
142
207
  }
143
208
  return initLoaders;
144
209
  }()
145
- /**
146
- * Create skybox with HDR environment mapping
210
+ /**
211
+ * Create skybox with HDR environment mapping
147
212
  */
148
213
  }, {
149
214
  key: "createSkybox",
150
215
  value: (function () {
151
216
  var _createSkybox = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2() {
152
217
  var _this = this;
153
- var component, isContextLost, pmremGenerator, loaders, applyEnvironmentMap, _loop, _ret, _i, _loaders, _t4, _t5, _t6;
218
+ var component, isContextLost, pmremGenerator, hdrPath1, hdrPath2, jpgPath, loaders, applyEnvironmentMap, _loop, _ret, _i, _loaders, _t4, _t5, _t6;
154
219
  return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
155
220
  while (1) switch (_context4.n) {
156
221
  case 0:
@@ -217,22 +282,23 @@ var EnvironmentManager = /*#__PURE__*/function () {
217
282
  this.createFallbackEnvironment();
218
283
  return _context4.a(2);
219
284
  case 9:
285
+ // Get resolved paths for better debugging
286
+ hdrPath1 = getAssetPath('skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr');
287
+ hdrPath2 = getAssetPath('skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr');
288
+ jpgPath = getAssetPath('skyboxes/sky_fallback.jpg');
289
+ console.log('🔍 Resolved HDR paths:', {
290
+ hdr2k: hdrPath1,
291
+ hdr1k: hdrPath2,
292
+ jpg: jpgPath
293
+ });
220
294
  loaders = [{
221
295
  type: 'hdr',
222
296
  loader: new RGBELoader(),
223
- paths: [
224
- // Try local paths first
225
- '/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr', '/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr',
226
- // Fall back to S3 paths
227
- 'https://central-plant-assets.s3.us-east-1.amazonaws.com/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr', 'https://central-plant-assets.s3.us-east-1.amazonaws.com/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr']
297
+ paths: [hdrPath1, hdrPath2]
228
298
  }, {
229
299
  type: 'jpeg',
230
300
  loader: component.textureLoader || new THREE__namespace.TextureLoader(),
231
- paths: [
232
- // Try local paths first
233
- '/skyboxes/sky_fallback.jpg',
234
- // Fall back to S3 path
235
- 'https://central-plant-assets.s3.us-east-1.amazonaws.com/skyboxes/sky_fallback.jpg']
301
+ paths: [jpgPath]
236
302
  }]; // Configure texture loaders with CORS settings
237
303
  loaders.forEach(function (_ref) {
238
304
  var loader = _ref.loader;
@@ -299,7 +365,7 @@ var EnvironmentManager = /*#__PURE__*/function () {
299
365
  case 0:
300
366
  path = _step.value;
301
367
  _context2.p = 1;
302
- if (!path.startsWith('/')) {
368
+ if (!(path.startsWith('/') && !path.includes('://'))) {
303
369
  _context2.n = 3;
304
370
  break;
305
371
  }
@@ -439,8 +505,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
439
505
  }
440
506
  return createSkybox;
441
507
  }()
442
- /**
443
- * Create a fallback environment when renderer issues occur
508
+ /**
509
+ * Create a fallback environment when renderer issues occur
444
510
  */
445
511
  )
446
512
  }, {
@@ -460,8 +526,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
460
526
  component.scene.background = new THREE__namespace.Color(0x87CEEB);
461
527
  }
462
528
 
463
- /**
464
- * Create procedural sky when textures fail to load
529
+ /**
530
+ * Create procedural sky when textures fail to load
465
531
  */
466
532
  }, {
467
533
  key: "createProceduralSky",
@@ -501,8 +567,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
501
567
  }
502
568
  }
503
569
 
504
- /**
505
- * Setup scene lighting
570
+ /**
571
+ * Setup scene lighting
506
572
  */
507
573
  }, {
508
574
  key: "setupLighting",
@@ -551,8 +617,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
551
617
  debugLogger.logger.info('Scene lighting setup complete');
552
618
  }
553
619
 
554
- /**
555
- * Create ground plane
620
+ /**
621
+ * Create ground plane
556
622
  */
557
623
  }, {
558
624
  key: "createGround",
@@ -586,8 +652,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
586
652
  return ground;
587
653
  }
588
654
 
589
- /**
590
- * Create walls for the environment
655
+ /**
656
+ * Create walls for the environment
591
657
  */
592
658
  }, {
593
659
  key: "createWalls",
@@ -651,8 +717,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
651
717
  return walls;
652
718
  }
653
719
 
654
- /**
655
- * Set fog in the scene
720
+ /**
721
+ * Set fog in the scene
656
722
  */
657
723
  }, {
658
724
  key: "setFog",
@@ -666,15 +732,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
666
732
  }
667
733
  component.scene.fog = new THREE__namespace.FogExp2(color, density);
668
734
  debugLogger.logger.info('Scene fog applied');
669
- }
670
- /**
671
- * Initialize the default environment
672
- */
735
+ } /**
736
+ * Initialize the default environment
737
+ */
673
738
  }, {
674
739
  key: "initializeEnvironment",
675
740
  value: (function () {
676
741
  var _initializeEnvironment = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3() {
677
- var component, loadersReady, textureConfigReady, _t7;
742
+ var _this2 = this;
743
+ var component, loadersReady, textureConfigReady, ground, walls, _t7;
678
744
  return _rollupPluginBabelHelpers.regenerator().w(function (_context5) {
679
745
  while (1) switch (_context5.n) {
680
746
  case 0:
@@ -700,39 +766,91 @@ var EnvironmentManager = /*#__PURE__*/function () {
700
766
  _t7 = _context5.v;
701
767
  console.warn('⚠️ Error initializing environment loaders:', _t7);
702
768
  case 5:
703
- // Configure renderer for proper HDR rendering if it exists
704
- if (component && component.renderer) {
705
- // Ensure proper tone mapping is set for HDR
769
+ if (component) {
770
+ _context5.n = 6;
771
+ break;
772
+ }
773
+ debugLogger.logger.error('❌ Cannot initialize environment: component is null');
774
+ return _context5.a(2);
775
+ case 6:
776
+ if (component.renderer) {
777
+ _context5.n = 7;
778
+ break;
779
+ }
780
+ debugLogger.logger.error('❌ Cannot initialize environment: renderer is null');
781
+ return _context5.a(2);
782
+ case 7:
783
+ // Configure renderer for proper HDR rendering
784
+ console.log('🎨 Configuring renderer for environment...');
785
+
786
+ // Don't override existing settings from sceneInitializationManager
787
+ // Just ensure we have reasonable values set
788
+ if (!component.renderer.toneMapping) {
706
789
  component.renderer.toneMapping = THREE__namespace.ACESFilmicToneMapping;
707
- component.renderer.toneMappingExposure = 1.0;
708
- // For all Three.js versions from r152+
709
- if (component.renderer.outputColorSpace !== undefined) {
710
- component.renderer.outputColorSpace = THREE__namespace.SRGBColorSpace;
711
- }
712
- // For older Three.js versions (legacy support)
713
- else if (component.renderer.outputEncoding !== undefined) {
714
- component.renderer.outputEncoding = THREE__namespace.sRGBEncoding;
715
- }
716
- debugLogger.logger.info("Renderer configured for HDR:\n - Tone mapping: ".concat(component.renderer.toneMapping, "\n - Color space: ").concat(component.renderer.outputColorSpace || component.renderer.outputEncoding));
717
790
  }
791
+ component.renderer.toneMappingExposure = 1.0;
792
+
793
+ // Ensure correct color space is set based on Three.js version
794
+ if (component.renderer.outputColorSpace !== undefined) {
795
+ component.renderer.outputColorSpace = THREE__namespace.SRGBColorSpace; // For newer Three.js
796
+ console.log('✅ Set SRGBColorSpace for renderer (newer Three.js)');
797
+ } else if (component.renderer.outputEncoding !== undefined) {
798
+ component.renderer.outputEncoding = THREE__namespace.sRGBEncoding; // For older Three.js
799
+ console.log('✅ Set sRGBEncoding for renderer (older Three.js)');
800
+ }
801
+ debugLogger.logger.info("Renderer configured for HDR:\n - Tone mapping: ".concat(component.renderer.toneMapping, "\n - Color space: ").concat(component.renderer.outputColorSpace || component.renderer.outputEncoding));
718
802
 
719
803
  // Create skybox (includes base lighting)
720
- _context5.n = 6;
804
+ _context5.n = 8;
721
805
  return this.createSkybox();
722
- case 6:
806
+ case 8:
723
807
  // Add additional lighting
724
808
  this.setupLighting();
725
809
 
726
810
  // Use textured ground instead of basic ground
727
- _context5.n = 7;
811
+ console.log('🌍 Creating ground with texture...');
812
+ _context5.n = 9;
728
813
  return this.addTexturedGround();
729
- case 7:
730
- // No walls or fog by default
731
- // await this.addBrickWalls();
732
- // this.addHorizonFog();
814
+ case 9:
815
+ ground = _context5.v;
816
+ if (!ground) {
817
+ debugLogger.logger.error('❌ Failed to create textured ground');
818
+ } else {
819
+ debugLogger.logger.info('✅ Ground created successfully');
820
+ }
733
821
 
734
- debugLogger.logger.info('Environment initialization complete');
735
- case 8:
822
+ // Add walls with textures
823
+ console.log('🧱 Creating walls with textures...');
824
+ _context5.n = 10;
825
+ return this.addBrickWalls();
826
+ case 10:
827
+ walls = _context5.v;
828
+ if (!walls || walls.length === 0) {
829
+ debugLogger.logger.warn('⚠️ No walls were created');
830
+ } else {
831
+ debugLogger.logger.info("\u2705 Created ".concat(walls.length, " walls"));
832
+ }
833
+
834
+ // Add atmospheric fog
835
+ this.addHorizonFog();
836
+ debugLogger.logger.info('Environment initialization complete'); // Force material refresh to ensure textures are applied correctly
837
+ this.forceRefreshMaterials();
838
+
839
+ // Force renderer refresh
840
+ if (component.renderer && component.scene && component.camera) {
841
+ component.renderer.render(component.scene, component.camera);
842
+ console.log('🔄 Forced initial render to refresh scene');
843
+
844
+ // Schedule another render after a short delay to catch any async texture loading
845
+ setTimeout(function () {
846
+ if (component.renderer && !component.isDestroyed) {
847
+ _this2.forceRefreshMaterials();
848
+ component.renderer.render(component.scene, component.camera);
849
+ console.log('🔄 Performed delayed render to catch async texture loads');
850
+ }
851
+ }, 1000);
852
+ }
853
+ case 11:
736
854
  return _context5.a(2);
737
855
  }
738
856
  }, _callee3, this, [[1, 4]]);
@@ -742,74 +860,149 @@ var EnvironmentManager = /*#__PURE__*/function () {
742
860
  }
743
861
  return initializeEnvironment;
744
862
  }()
745
- /**
746
- * Add textured ground with materials from textureConfig
863
+ /**
864
+ * Add textured ground with materials from textureConfig
747
865
  */
748
866
  )
749
867
  }, {
750
868
  key: "addTexturedGround",
751
869
  value: (function () {
752
870
  var _addTexturedGround = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4() {
753
- var component, groundMaterial, groundGeometry, ground, _t8;
871
+ var component, groundMaterial, debugMaterial, groundGeometry, ground, debugGround, errorGeometry, errorMaterial, errorGround, _t8;
754
872
  return _rollupPluginBabelHelpers.regenerator().w(function (_context6) {
755
873
  while (1) switch (_context6.n) {
756
874
  case 0:
757
- if (loadTextureSetAndCreateMaterial) {
758
- _context6.n = 1;
875
+ if (textureConfig.loadTextureSetAndCreateMaterial) {
876
+ _context6.n = 2;
759
877
  break;
760
878
  }
879
+ console.log('🔄 TextureConfig module not yet loaded, importing now...');
761
880
  _context6.n = 1;
762
881
  return importTextureConfig();
763
882
  case 1:
883
+ if (textureConfig.loadTextureSetAndCreateMaterial) {
884
+ _context6.n = 2;
885
+ break;
886
+ }
887
+ console.error('❌ Failed to load textureConfig module, falling back to basic ground');
888
+ return _context6.a(2, this.createGround());
889
+ case 2:
764
890
  component = this.component;
765
891
  if (!(!component || !component.scene)) {
766
- _context6.n = 2;
892
+ _context6.n = 3;
767
893
  break;
768
894
  }
769
895
  debugLogger.logger.warn('Cannot create textured ground: component or scene not available');
770
896
  return _context6.a(2, null);
771
- case 2:
897
+ case 3:
898
+ // Force texture loading with crossOrigin support
899
+ if (!component.textureLoader) {
900
+ console.log('🔄 Creating texture loader in component');
901
+ component.textureLoader = new THREE__namespace.TextureLoader();
902
+ component.textureLoader.setCrossOrigin('anonymous');
903
+ }
904
+
772
905
  // Remove existing ground if present
773
906
  component.scene.traverse(function (object) {
774
907
  if (object.userData && object.userData.type === 'ground') {
775
908
  component.scene.remove(object);
776
909
  }
777
910
  });
778
- _context6.p = 3;
779
- _context6.n = 4;
780
- return loadTextureSetAndCreateMaterial(component, 'gravel_embedded_concrete');
781
- case 4:
911
+ _context6.p = 4;
912
+ console.log('🌍 Creating textured ground plane...');
913
+ // Use the gravel_embedded_concrete texture set
914
+ console.log('🔄 Loading ground material textures...');
915
+ _context6.n = 5;
916
+ return textureConfig.loadTextureSetAndCreateMaterial(component, 'gravel_embedded_concrete');
917
+ case 5:
782
918
  groundMaterial = _context6.v;
783
- groundGeometry = new THREE__namespace.PlaneGeometry(100, 100);
919
+ if (groundMaterial) {
920
+ _context6.n = 6;
921
+ break;
922
+ }
923
+ throw new Error('Failed to create ground material');
924
+ case 6:
925
+ console.log('✅ Ground material created');
926
+
927
+ // First create a colored material to verify the mesh creation works
928
+ debugMaterial = new THREE__namespace.MeshBasicMaterial({
929
+ color: 0x22ff22,
930
+ // Bright green for visibility
931
+ wireframe: false,
932
+ side: THREE__namespace.DoubleSide
933
+ }); // Create a composite ground with both materials
934
+ groundGeometry = new THREE__namespace.PlaneGeometry(100, 100); // Create the main ground mesh
784
935
  ground = new THREE__namespace.Mesh(groundGeometry, groundMaterial);
785
936
  ground.rotation.x = -Math.PI / 2; // Rotate to be horizontal
786
937
  ground.position.y = -0.01; // Slightly below origin
787
938
  ground.receiveShadow = true;
788
939
 
940
+ // Create a debug ground mesh slightly below the main ground
941
+ debugGround = new THREE__namespace.Mesh(groundGeometry, debugMaterial);
942
+ debugGround.rotation.x = -Math.PI / 2;
943
+ debugGround.position.y = -0.02; // Below the main ground
944
+ debugGround.visible = false; // Hide by default
945
+
789
946
  // Set user data for identification
790
947
  ground.userData = {
791
948
  isEnvironmentObject: true,
949
+ isBaseGround: true,
792
950
  type: 'ground'
793
951
  };
952
+ debugGround.userData = {
953
+ isEnvironmentObject: true,
954
+ type: 'ground-debug'
955
+ };
956
+
957
+ // Add both to scene
794
958
  component.scene.add(ground);
959
+ component.scene.add(debugGround);
960
+
961
+ // Log some properties about the created ground
962
+ console.log('🌍 Textured ground created with properties:', {
963
+ material: groundMaterial.type,
964
+ hasMap: !!groundMaterial.map,
965
+ hasNormalMap: !!groundMaterial.normalMap,
966
+ hasRoughnessMap: !!groundMaterial.roughnessMap,
967
+ hasMetalnessMap: !!groundMaterial.metalnessMap,
968
+ hasAoMap: !!groundMaterial.aoMap,
969
+ hasBumpMap: !!groundMaterial.bumpMap,
970
+ materialColor: groundMaterial.color ? "#".concat(groundMaterial.color.getHexString()) : 'none'
971
+ });
795
972
  debugLogger.logger.info('Textured ground created');
796
973
  return _context6.a(2, ground);
797
- case 5:
798
- _context6.p = 5;
974
+ case 7:
975
+ _context6.p = 7;
799
976
  _t8 = _context6.v;
800
977
  debugLogger.logger.error('Error creating textured ground:', _t8);
801
- // Fallback to simple ground
802
- return _context6.a(2, this.createGround());
978
+ // Create a bright colored ground so it's obvious something was wrong
979
+ errorGeometry = new THREE__namespace.PlaneGeometry(100, 100);
980
+ errorMaterial = new THREE__namespace.MeshBasicMaterial({
981
+ color: 0xff0000,
982
+ wireframe: true,
983
+ side: THREE__namespace.DoubleSide
984
+ });
985
+ errorGround = new THREE__namespace.Mesh(errorGeometry, errorMaterial);
986
+ errorGround.rotation.x = -Math.PI / 2;
987
+ errorGround.position.y = -0.01;
988
+ errorGround.userData = {
989
+ isEnvironmentObject: true,
990
+ isBaseGround: true,
991
+ type: 'ground-error'
992
+ };
993
+ component.scene.add(errorGround);
994
+ console.error('⚠️ Fallback to error ground (red wireframe) due to texture loading failure:', _t8);
995
+ return _context6.a(2, errorGround);
803
996
  }
804
- }, _callee4, this, [[3, 5]]);
997
+ }, _callee4, this, [[4, 7]]);
805
998
  }));
806
999
  function addTexturedGround() {
807
1000
  return _addTexturedGround.apply(this, arguments);
808
1001
  }
809
1002
  return addTexturedGround;
810
1003
  }()
811
- /**
812
- * Add brick walls with materials from textureConfig
1004
+ /**
1005
+ * Add brick walls with materials from textureConfig
813
1006
  */
814
1007
  )
815
1008
  }, {
@@ -820,31 +1013,41 @@ var EnvironmentManager = /*#__PURE__*/function () {
820
1013
  return _rollupPluginBabelHelpers.regenerator().w(function (_context7) {
821
1014
  while (1) switch (_context7.n) {
822
1015
  case 0:
823
- if (loadTextureSetAndCreateMaterial) {
824
- _context7.n = 1;
1016
+ if (textureConfig.loadTextureSetAndCreateMaterial) {
1017
+ _context7.n = 2;
825
1018
  break;
826
1019
  }
1020
+ console.log('🔄 TextureConfig module not yet loaded for brick walls, importing now...');
827
1021
  _context7.n = 1;
828
1022
  return importTextureConfig();
829
1023
  case 1:
1024
+ if (textureConfig.loadTextureSetAndCreateMaterial) {
1025
+ _context7.n = 2;
1026
+ break;
1027
+ }
1028
+ console.error('❌ Failed to load textureConfig module for brick walls');
1029
+ return _context7.a(2, this.createWalls());
1030
+ case 2:
830
1031
  component = this.component;
831
1032
  if (!(!component || !component.scene)) {
832
- _context7.n = 2;
1033
+ _context7.n = 3;
833
1034
  break;
834
1035
  }
835
1036
  debugLogger.logger.warn('Cannot create brick walls: component or scene not available');
836
1037
  return _context7.a(2, []);
837
- case 2:
1038
+ case 3:
838
1039
  // Remove existing walls if present
839
1040
  component.scene.traverse(function (object) {
840
1041
  if (object.userData && object.userData.type === 'wall') {
841
1042
  component.scene.remove(object);
842
1043
  }
843
1044
  });
844
- _context7.p = 3;
845
- _context7.n = 4;
846
- return loadTextureSetAndCreateMaterial(component, 'brick');
847
- case 4:
1045
+ _context7.p = 4;
1046
+ // Use the brick texture set
1047
+ console.log('🧱 Loading brick wall material textures...');
1048
+ _context7.n = 5;
1049
+ return textureConfig.loadTextureSetAndCreateMaterial(component, 'brick');
1050
+ case 5:
848
1051
  wallMaterial = _context7.v;
849
1052
  walls = [];
850
1053
  wallHeight = 20;
@@ -884,22 +1087,22 @@ var EnvironmentManager = /*#__PURE__*/function () {
884
1087
  }
885
1088
  debugLogger.logger.info('Textured environment walls created');
886
1089
  return _context7.a(2, walls);
887
- case 5:
888
- _context7.p = 5;
1090
+ case 6:
1091
+ _context7.p = 6;
889
1092
  _t9 = _context7.v;
890
1093
  debugLogger.logger.error('Error creating brick walls:', _t9);
891
1094
  // Fallback to simple walls
892
1095
  return _context7.a(2, this.createWalls());
893
1096
  }
894
- }, _callee5, this, [[3, 5]]);
1097
+ }, _callee5, this, [[4, 6]]);
895
1098
  }));
896
1099
  function addBrickWalls() {
897
1100
  return _addBrickWalls.apply(this, arguments);
898
1101
  }
899
1102
  return addBrickWalls;
900
1103
  }()
901
- /**
902
- * Add horizon fog effect
1104
+ /**
1105
+ * Add horizon fog effect
903
1106
  */
904
1107
  )
905
1108
  }, {
@@ -919,10 +1122,10 @@ var EnvironmentManager = /*#__PURE__*/function () {
919
1122
  debugLogger.logger.info('Horizon fog applied');
920
1123
  }
921
1124
 
922
- /**
923
- * Helper to check if a texture exists locally in static directory
924
- * @param {string} path - Relative path to texture in static directory
925
- * @returns {Promise<boolean>}
1125
+ /**
1126
+ * Helper to check if a texture exists locally in static directory
1127
+ * @param {string} path - Relative path to texture in static directory
1128
+ * @returns {Promise<boolean>}
926
1129
  */
927
1130
  }, {
928
1131
  key: "checkLocalTextureExists",
@@ -950,9 +1153,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
950
1153
  return resolve(false);
951
1154
  };
952
1155
 
953
- // Create full path relative to app root
954
- var fullPath = window.location.origin + '/' + path;
955
- img.src = fullPath;
1156
+ // Use the path directly - it should already be processed by getAssetPath
1157
+ img.src = path;
956
1158
 
957
1159
  // Set a timeout in case the image load hangs
958
1160
  setTimeout(function () {
@@ -968,15 +1170,106 @@ var EnvironmentManager = /*#__PURE__*/function () {
968
1170
  return _checkLocalTextureExists.apply(this, arguments);
969
1171
  }
970
1172
  return checkLocalTextureExists;
971
- }())
1173
+ }()
1174
+ /**
1175
+ * Force refresh all materials in the scene
1176
+ * Helpful for ensuring textures are correctly displayed
1177
+ */
1178
+ )
1179
+ }, {
1180
+ key: "forceRefreshMaterials",
1181
+ value: function forceRefreshMaterials() {
1182
+ var component = this.component;
1183
+ if (!component || !component.scene) {
1184
+ debugLogger.logger.warn('Cannot refresh materials: component or scene not available');
1185
+ return;
1186
+ }
1187
+ console.log('🔄 Forcing material refresh for all objects...');
1188
+ var updatedMaterials = 0;
1189
+ var textureFixes = 0;
1190
+
1191
+ // Import helper functions if available
1192
+ var hasValidImageData = textureConfig.hasValidImageData || function (texture) {
1193
+ return texture && texture.image;
1194
+ };
1195
+ var createPlaceholderTexture = textureConfig.createPlaceholderTexture || function () {
1196
+ return null;
1197
+ };
1198
+
1199
+ // Traverse all meshes in the scene
1200
+ component.scene.traverse(function (object) {
1201
+ if (object.isMesh && object.material) {
1202
+ // Handle both single materials and material arrays
1203
+ var materials = Array.isArray(object.material) ? object.material : [object.material];
1204
+ materials.forEach(function (material) {
1205
+ if (material) {
1206
+ // Update material properties
1207
+ material.needsUpdate = true;
1208
+
1209
+ // Ensure color values are properly set
1210
+ if (material.color) {
1211
+ if (typeof material.color.convertSRGBToLinear === 'function') {
1212
+ material.color.convertSRGBToLinear();
1213
+ }
1214
+ }
1215
+
1216
+ // Check for maps and ensure they're correctly configured
1217
+ var maps = ['map', 'normalMap', 'roughnessMap', 'metalnessMap', 'aoMap', 'bumpMap'];
1218
+ maps.forEach(function (mapType) {
1219
+ var map = material[mapType];
1220
+ if (map) {
1221
+ // Check if this texture might trigger the warning
1222
+ var hasValidData = hasValidImageData(map);
1223
+ if (!hasValidData) {
1224
+ console.warn("\u26A0\uFE0F Found texture without valid image data in ".concat(mapType, " for object ").concat(object.name || object.uuid));
1225
+
1226
+ // Create and use a placeholder texture for now
1227
+ if (createPlaceholderTexture) {
1228
+ var placeholderColor = mapType === 'normalMap' ? 0x8080ff : 0xcccccc;
1229
+ var placeholder = createPlaceholderTexture(placeholderColor);
1230
+ if (placeholder) {
1231
+ material[mapType] = placeholder;
1232
+ textureFixes++;
1233
+ console.log("\uD83D\uDD04 Replaced missing image texture with placeholder for ".concat(mapType));
1234
+ }
1235
+ }
1236
+ } else {
1237
+ map.needsUpdate = true;
1238
+
1239
+ // Ensure correct color space for diffuse maps
1240
+ if (mapType === 'map' && map.colorSpace !== undefined) {
1241
+ map.colorSpace = THREE__namespace.SRGBColorSpace;
1242
+ } else if (mapType === 'map' && map.encoding !== undefined) {
1243
+ map.encoding = THREE__namespace.sRGBEncoding;
1244
+ }
1245
+ }
1246
+ }
1247
+ });
1248
+ updatedMaterials++;
1249
+ }
1250
+ });
1251
+ }
1252
+ });
1253
+
1254
+ // Use the dedicated function from textureConfig if available
1255
+ if (textureConfig.forceUpdateMaterials) {
1256
+ textureConfig.forceUpdateMaterials(component.scene);
1257
+ }
1258
+ console.log("\u2705 Refreshed ".concat(updatedMaterials, " materials, fixed ").concat(textureFixes, " texture warnings"));
1259
+
1260
+ // Force a renderer update if possible
1261
+ if (component.renderer && component.camera) {
1262
+ component.renderer.render(component.scene, component.camera);
1263
+ }
1264
+ }
972
1265
  }]);
973
1266
  }();
974
1267
 
975
1268
  // Create a singleton instance
976
1269
  var environmentManager = null;
977
1270
 
978
- /**
979
- * Get the global environment manager instance
1271
+ /**
1272
+ * Get the global environment manager instance
980
1273
  */
981
1274
  function getEnvironmentManager() {
982
1275
  var component = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;