@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.
- package/dist/bundle/index.js +7782 -6543
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +23 -10
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -0
- package/dist/cjs/src/animationManager.js +15 -15
- package/dist/cjs/src/componentManager.js +8 -8
- package/dist/cjs/src/disposalManager.js +12 -12
- package/dist/cjs/src/environmentManager.js +392 -99
- package/dist/cjs/src/hotReloadManager.js +26 -26
- package/dist/cjs/src/index.js +19 -66
- package/dist/cjs/src/keyboardControlsManager.js +23 -23
- package/dist/cjs/src/nameUtils.js +21 -21
- package/dist/cjs/src/pathfindingManager.js +311 -129
- package/dist/cjs/src/performanceMonitor.js +52 -52
- package/dist/cjs/src/sceneExportManager.js +23 -23
- package/dist/cjs/src/sceneInitializationManager.js +18 -18
- package/dist/cjs/src/textureConfig.js +469 -40
- package/dist/cjs/src/transformControlsManager.js +79 -79
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +21 -10
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -0
- package/dist/esm/src/animationManager.js +15 -15
- package/dist/esm/src/componentManager.js +8 -8
- package/dist/esm/src/disposalManager.js +12 -12
- package/dist/esm/src/environmentManager.js +393 -100
- package/dist/esm/src/hotReloadManager.js +26 -26
- package/dist/esm/src/index.js +19 -66
- package/dist/esm/src/keyboardControlsManager.js +23 -23
- package/dist/esm/src/nameUtils.js +21 -21
- package/dist/esm/src/pathfindingManager.js +313 -129
- package/dist/esm/src/performanceMonitor.js +52 -52
- package/dist/esm/src/sceneExportManager.js +23 -23
- package/dist/esm/src/sceneInitializationManager.js +18 -18
- package/dist/esm/src/textureConfig.js +469 -42
- package/dist/esm/src/transformControlsManager.js +79 -79
- package/dist/index.d.ts +255 -259
- package/package.json +52 -53
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -360
- package/dist/cjs/src/sceneOperationsManager.js +0 -560
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -337
- package/dist/esm/src/sceneOperationsManager.js +0 -536
|
@@ -1,10 +1,51 @@
|
|
|
1
|
-
import { createClass as _createClass, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, classCallCheck as _classCallCheck, regeneratorValues as _regeneratorValues, createForOfIteratorHelper as _createForOfIteratorHelper } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { createClass as _createClass, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, classCallCheck as _classCallCheck, regeneratorValues as _regeneratorValues, createForOfIteratorHelper as _createForOfIteratorHelper, slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { logger } from './debugLogger.js';
|
|
4
4
|
|
|
5
5
|
// We'll need to import RGBELoader from three examples
|
|
6
6
|
var RGBELoader;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to get asset paths that works in both bundled and modular contexts
|
|
10
|
+
* @param {string} assetPath - Relative path from the assets directory
|
|
11
|
+
* @returns {string} - The full path to the asset
|
|
12
|
+
*/
|
|
13
|
+
function getAssetPath(assetPath) {
|
|
14
|
+
// Strip leading slash if present
|
|
15
|
+
if (assetPath.startsWith('/')) {
|
|
16
|
+
assetPath = assetPath.substring(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// In browser context, check for different module formats
|
|
20
|
+
if (typeof window !== 'undefined') {
|
|
21
|
+
// For bundled version, assets should be in dist/bundle/assets/
|
|
22
|
+
// For ESM/CJS, assets should be in their respective folders
|
|
23
|
+
|
|
24
|
+
// Try to determine if we're using the bundled version or ESM/CJS
|
|
25
|
+
var isBundled = typeof CentralPlantUtils !== 'undefined';
|
|
26
|
+
|
|
27
|
+
// Check if we're running in a Nuxt.js environment (localhost:3000 is a common dev server)
|
|
28
|
+
var isNuxtEnv = window.location.hostname === 'localhost' && (window.location.port === '3000' || window.location.port === '3001');
|
|
29
|
+
if (isNuxtEnv) {
|
|
30
|
+
// In Nuxt.js environment, assets are likely in the /static directory at the root
|
|
31
|
+
return "/".concat(assetPath); // No /assets/ prefix in the URL path
|
|
32
|
+
} else if (isBundled) {
|
|
33
|
+
// Get the base URL for the module
|
|
34
|
+
var baseUrl = import.meta.url;
|
|
35
|
+
// In bundled format, assets are in the assets folder next to the bundle
|
|
36
|
+
return new URL("./assets/".concat(assetPath), baseUrl).href;
|
|
37
|
+
} else {
|
|
38
|
+
// Get the base URL for the module
|
|
39
|
+
var _baseUrl = import.meta.url;
|
|
40
|
+
// In ESM/CJS format, need to go up relative to current module path
|
|
41
|
+
return new URL("../assets/".concat(assetPath), _baseUrl).href;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// In Node.js context
|
|
46
|
+
return "assets/".concat(assetPath);
|
|
47
|
+
}
|
|
48
|
+
|
|
8
49
|
// Dynamic import for browser compatibility
|
|
9
50
|
function importThreeLoaders() {
|
|
10
51
|
return _importThreeLoaders.apply(this, arguments);
|
|
@@ -41,13 +82,17 @@ function _importThreeLoaders() {
|
|
|
41
82
|
}));
|
|
42
83
|
return _importThreeLoaders.apply(this, arguments);
|
|
43
84
|
}
|
|
44
|
-
var
|
|
85
|
+
var textureConfig = {
|
|
86
|
+
loadTextureSetAndCreateMaterial: null,
|
|
87
|
+
checkThreeJSCompatibility: null,
|
|
88
|
+
forceUpdateMaterials: null
|
|
89
|
+
};
|
|
45
90
|
function importTextureConfig() {
|
|
46
91
|
return _importTextureConfig.apply(this, arguments);
|
|
47
92
|
}
|
|
48
93
|
function _importTextureConfig() {
|
|
49
94
|
_importTextureConfig = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
50
|
-
var module, _t1;
|
|
95
|
+
var module, importedFunctions, _t1;
|
|
51
96
|
return _regenerator().w(function (_context1) {
|
|
52
97
|
while (1) switch (_context1.n) {
|
|
53
98
|
case 0:
|
|
@@ -61,8 +106,28 @@ function _importTextureConfig() {
|
|
|
61
106
|
return import('./textureConfig.js');
|
|
62
107
|
case 2:
|
|
63
108
|
module = _context1.v;
|
|
64
|
-
|
|
65
|
-
|
|
109
|
+
// Store all exported functions
|
|
110
|
+
textureConfig.loadTextureSetAndCreateMaterial = module.loadTextureSetAndCreateMaterial;
|
|
111
|
+
textureConfig.checkThreeJSCompatibility = module.checkThreeJSCompatibility;
|
|
112
|
+
textureConfig.forceUpdateMaterials = module.forceUpdateMaterials;
|
|
113
|
+
|
|
114
|
+
// Check what was successfully imported
|
|
115
|
+
importedFunctions = Object.entries(textureConfig).filter(function (_ref2) {
|
|
116
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
117
|
+
_ref3[0];
|
|
118
|
+
var fn = _ref3[1];
|
|
119
|
+
return typeof fn === 'function';
|
|
120
|
+
}).map(function (_ref4) {
|
|
121
|
+
var _ref5 = _slicedToArray(_ref4, 1),
|
|
122
|
+
name = _ref5[0];
|
|
123
|
+
return name;
|
|
124
|
+
});
|
|
125
|
+
console.log("\u2705 TextureConfig imported successfully with functions: ".concat(importedFunctions.join(', ')));
|
|
126
|
+
|
|
127
|
+
// Run compatibility check if available
|
|
128
|
+
if (typeof textureConfig.checkThreeJSCompatibility === 'function') {
|
|
129
|
+
textureConfig.checkThreeJSCompatibility();
|
|
130
|
+
}
|
|
66
131
|
return _context1.a(2, true);
|
|
67
132
|
case 3:
|
|
68
133
|
_context1.p = 3;
|
|
@@ -118,15 +183,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
118
183
|
}
|
|
119
184
|
return initLoaders;
|
|
120
185
|
}()
|
|
121
|
-
/**
|
|
122
|
-
* Create skybox with HDR environment mapping
|
|
186
|
+
/**
|
|
187
|
+
* Create skybox with HDR environment mapping
|
|
123
188
|
*/
|
|
124
189
|
}, {
|
|
125
190
|
key: "createSkybox",
|
|
126
191
|
value: (function () {
|
|
127
192
|
var _createSkybox = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
128
193
|
var _this = this;
|
|
129
|
-
var component, isContextLost, pmremGenerator, loaders, applyEnvironmentMap, _loop, _ret, _i, _loaders, _t4, _t5, _t6;
|
|
194
|
+
var component, isContextLost, pmremGenerator, hdrPath1, hdrPath2, jpgPath, loaders, applyEnvironmentMap, _loop, _ret, _i, _loaders, _t4, _t5, _t6;
|
|
130
195
|
return _regenerator().w(function (_context4) {
|
|
131
196
|
while (1) switch (_context4.n) {
|
|
132
197
|
case 0:
|
|
@@ -193,22 +258,23 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
193
258
|
this.createFallbackEnvironment();
|
|
194
259
|
return _context4.a(2);
|
|
195
260
|
case 9:
|
|
261
|
+
// Get resolved paths for better debugging
|
|
262
|
+
hdrPath1 = getAssetPath('skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr');
|
|
263
|
+
hdrPath2 = getAssetPath('skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr');
|
|
264
|
+
jpgPath = getAssetPath('skyboxes/sky_fallback.jpg');
|
|
265
|
+
console.log('🔍 Resolved HDR paths:', {
|
|
266
|
+
hdr2k: hdrPath1,
|
|
267
|
+
hdr1k: hdrPath2,
|
|
268
|
+
jpg: jpgPath
|
|
269
|
+
});
|
|
196
270
|
loaders = [{
|
|
197
271
|
type: 'hdr',
|
|
198
272
|
loader: new RGBELoader(),
|
|
199
|
-
paths: [
|
|
200
|
-
// Try local paths first
|
|
201
|
-
'/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr', '/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr',
|
|
202
|
-
// Fall back to S3 paths
|
|
203
|
-
'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']
|
|
273
|
+
paths: [hdrPath1, hdrPath2]
|
|
204
274
|
}, {
|
|
205
275
|
type: 'jpeg',
|
|
206
276
|
loader: component.textureLoader || new THREE.TextureLoader(),
|
|
207
|
-
paths: [
|
|
208
|
-
// Try local paths first
|
|
209
|
-
'/skyboxes/sky_fallback.jpg',
|
|
210
|
-
// Fall back to S3 path
|
|
211
|
-
'https://central-plant-assets.s3.us-east-1.amazonaws.com/skyboxes/sky_fallback.jpg']
|
|
277
|
+
paths: [jpgPath]
|
|
212
278
|
}]; // Configure texture loaders with CORS settings
|
|
213
279
|
loaders.forEach(function (_ref) {
|
|
214
280
|
var loader = _ref.loader;
|
|
@@ -275,7 +341,7 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
275
341
|
case 0:
|
|
276
342
|
path = _step.value;
|
|
277
343
|
_context2.p = 1;
|
|
278
|
-
if (!path.startsWith('/')) {
|
|
344
|
+
if (!(path.startsWith('/') && !path.includes('://'))) {
|
|
279
345
|
_context2.n = 3;
|
|
280
346
|
break;
|
|
281
347
|
}
|
|
@@ -415,8 +481,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
415
481
|
}
|
|
416
482
|
return createSkybox;
|
|
417
483
|
}()
|
|
418
|
-
/**
|
|
419
|
-
* Create a fallback environment when renderer issues occur
|
|
484
|
+
/**
|
|
485
|
+
* Create a fallback environment when renderer issues occur
|
|
420
486
|
*/
|
|
421
487
|
)
|
|
422
488
|
}, {
|
|
@@ -436,8 +502,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
436
502
|
component.scene.background = new THREE.Color(0x87CEEB);
|
|
437
503
|
}
|
|
438
504
|
|
|
439
|
-
/**
|
|
440
|
-
* Create procedural sky when textures fail to load
|
|
505
|
+
/**
|
|
506
|
+
* Create procedural sky when textures fail to load
|
|
441
507
|
*/
|
|
442
508
|
}, {
|
|
443
509
|
key: "createProceduralSky",
|
|
@@ -477,8 +543,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
477
543
|
}
|
|
478
544
|
}
|
|
479
545
|
|
|
480
|
-
/**
|
|
481
|
-
* Setup scene lighting
|
|
546
|
+
/**
|
|
547
|
+
* Setup scene lighting
|
|
482
548
|
*/
|
|
483
549
|
}, {
|
|
484
550
|
key: "setupLighting",
|
|
@@ -527,8 +593,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
527
593
|
logger.info('Scene lighting setup complete');
|
|
528
594
|
}
|
|
529
595
|
|
|
530
|
-
/**
|
|
531
|
-
* Create ground plane
|
|
596
|
+
/**
|
|
597
|
+
* Create ground plane
|
|
532
598
|
*/
|
|
533
599
|
}, {
|
|
534
600
|
key: "createGround",
|
|
@@ -562,8 +628,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
562
628
|
return ground;
|
|
563
629
|
}
|
|
564
630
|
|
|
565
|
-
/**
|
|
566
|
-
* Create walls for the environment
|
|
631
|
+
/**
|
|
632
|
+
* Create walls for the environment
|
|
567
633
|
*/
|
|
568
634
|
}, {
|
|
569
635
|
key: "createWalls",
|
|
@@ -627,8 +693,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
627
693
|
return walls;
|
|
628
694
|
}
|
|
629
695
|
|
|
630
|
-
/**
|
|
631
|
-
* Set fog in the scene
|
|
696
|
+
/**
|
|
697
|
+
* Set fog in the scene
|
|
632
698
|
*/
|
|
633
699
|
}, {
|
|
634
700
|
key: "setFog",
|
|
@@ -642,15 +708,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
642
708
|
}
|
|
643
709
|
component.scene.fog = new THREE.FogExp2(color, density);
|
|
644
710
|
logger.info('Scene fog applied');
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
*/
|
|
711
|
+
} /**
|
|
712
|
+
* Initialize the default environment
|
|
713
|
+
*/
|
|
649
714
|
}, {
|
|
650
715
|
key: "initializeEnvironment",
|
|
651
716
|
value: (function () {
|
|
652
717
|
var _initializeEnvironment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
653
|
-
var
|
|
718
|
+
var _this2 = this;
|
|
719
|
+
var component, loadersReady, textureConfigReady, ground, walls, _t7;
|
|
654
720
|
return _regenerator().w(function (_context5) {
|
|
655
721
|
while (1) switch (_context5.n) {
|
|
656
722
|
case 0:
|
|
@@ -676,39 +742,91 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
676
742
|
_t7 = _context5.v;
|
|
677
743
|
console.warn('⚠️ Error initializing environment loaders:', _t7);
|
|
678
744
|
case 5:
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
745
|
+
if (component) {
|
|
746
|
+
_context5.n = 6;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
logger.error('❌ Cannot initialize environment: component is null');
|
|
750
|
+
return _context5.a(2);
|
|
751
|
+
case 6:
|
|
752
|
+
if (component.renderer) {
|
|
753
|
+
_context5.n = 7;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
logger.error('❌ Cannot initialize environment: renderer is null');
|
|
757
|
+
return _context5.a(2);
|
|
758
|
+
case 7:
|
|
759
|
+
// Configure renderer for proper HDR rendering
|
|
760
|
+
console.log('🎨 Configuring renderer for environment...');
|
|
761
|
+
|
|
762
|
+
// Don't override existing settings from sceneInitializationManager
|
|
763
|
+
// Just ensure we have reasonable values set
|
|
764
|
+
if (!component.renderer.toneMapping) {
|
|
682
765
|
component.renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
683
|
-
component.renderer.toneMappingExposure = 1.0;
|
|
684
|
-
// For all Three.js versions from r152+
|
|
685
|
-
if (component.renderer.outputColorSpace !== undefined) {
|
|
686
|
-
component.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
687
|
-
}
|
|
688
|
-
// For older Three.js versions (legacy support)
|
|
689
|
-
else if (component.renderer.outputEncoding !== undefined) {
|
|
690
|
-
component.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
691
|
-
}
|
|
692
|
-
logger.info("Renderer configured for HDR:\n - Tone mapping: ".concat(component.renderer.toneMapping, "\n - Color space: ").concat(component.renderer.outputColorSpace || component.renderer.outputEncoding));
|
|
693
766
|
}
|
|
767
|
+
component.renderer.toneMappingExposure = 1.0;
|
|
768
|
+
|
|
769
|
+
// Ensure correct color space is set based on Three.js version
|
|
770
|
+
if (component.renderer.outputColorSpace !== undefined) {
|
|
771
|
+
component.renderer.outputColorSpace = THREE.SRGBColorSpace; // For newer Three.js
|
|
772
|
+
console.log('✅ Set SRGBColorSpace for renderer (newer Three.js)');
|
|
773
|
+
} else if (component.renderer.outputEncoding !== undefined) {
|
|
774
|
+
component.renderer.outputEncoding = THREE.sRGBEncoding; // For older Three.js
|
|
775
|
+
console.log('✅ Set sRGBEncoding for renderer (older Three.js)');
|
|
776
|
+
}
|
|
777
|
+
logger.info("Renderer configured for HDR:\n - Tone mapping: ".concat(component.renderer.toneMapping, "\n - Color space: ").concat(component.renderer.outputColorSpace || component.renderer.outputEncoding));
|
|
694
778
|
|
|
695
779
|
// Create skybox (includes base lighting)
|
|
696
|
-
_context5.n =
|
|
780
|
+
_context5.n = 8;
|
|
697
781
|
return this.createSkybox();
|
|
698
|
-
case
|
|
782
|
+
case 8:
|
|
699
783
|
// Add additional lighting
|
|
700
784
|
this.setupLighting();
|
|
701
785
|
|
|
702
786
|
// Use textured ground instead of basic ground
|
|
703
|
-
|
|
787
|
+
console.log('🌍 Creating ground with texture...');
|
|
788
|
+
_context5.n = 9;
|
|
704
789
|
return this.addTexturedGround();
|
|
705
|
-
case
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
790
|
+
case 9:
|
|
791
|
+
ground = _context5.v;
|
|
792
|
+
if (!ground) {
|
|
793
|
+
logger.error('❌ Failed to create textured ground');
|
|
794
|
+
} else {
|
|
795
|
+
logger.info('✅ Ground created successfully');
|
|
796
|
+
}
|
|
709
797
|
|
|
710
|
-
|
|
711
|
-
|
|
798
|
+
// Add walls with textures
|
|
799
|
+
console.log('🧱 Creating walls with textures...');
|
|
800
|
+
_context5.n = 10;
|
|
801
|
+
return this.addBrickWalls();
|
|
802
|
+
case 10:
|
|
803
|
+
walls = _context5.v;
|
|
804
|
+
if (!walls || walls.length === 0) {
|
|
805
|
+
logger.warn('⚠️ No walls were created');
|
|
806
|
+
} else {
|
|
807
|
+
logger.info("\u2705 Created ".concat(walls.length, " walls"));
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Add atmospheric fog
|
|
811
|
+
this.addHorizonFog();
|
|
812
|
+
logger.info('Environment initialization complete'); // Force material refresh to ensure textures are applied correctly
|
|
813
|
+
this.forceRefreshMaterials();
|
|
814
|
+
|
|
815
|
+
// Force renderer refresh
|
|
816
|
+
if (component.renderer && component.scene && component.camera) {
|
|
817
|
+
component.renderer.render(component.scene, component.camera);
|
|
818
|
+
console.log('🔄 Forced initial render to refresh scene');
|
|
819
|
+
|
|
820
|
+
// Schedule another render after a short delay to catch any async texture loading
|
|
821
|
+
setTimeout(function () {
|
|
822
|
+
if (component.renderer && !component.isDestroyed) {
|
|
823
|
+
_this2.forceRefreshMaterials();
|
|
824
|
+
component.renderer.render(component.scene, component.camera);
|
|
825
|
+
console.log('🔄 Performed delayed render to catch async texture loads');
|
|
826
|
+
}
|
|
827
|
+
}, 1000);
|
|
828
|
+
}
|
|
829
|
+
case 11:
|
|
712
830
|
return _context5.a(2);
|
|
713
831
|
}
|
|
714
832
|
}, _callee3, this, [[1, 4]]);
|
|
@@ -718,74 +836,149 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
718
836
|
}
|
|
719
837
|
return initializeEnvironment;
|
|
720
838
|
}()
|
|
721
|
-
/**
|
|
722
|
-
* Add textured ground with materials from textureConfig
|
|
839
|
+
/**
|
|
840
|
+
* Add textured ground with materials from textureConfig
|
|
723
841
|
*/
|
|
724
842
|
)
|
|
725
843
|
}, {
|
|
726
844
|
key: "addTexturedGround",
|
|
727
845
|
value: (function () {
|
|
728
846
|
var _addTexturedGround = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
729
|
-
var component, groundMaterial, groundGeometry, ground, _t8;
|
|
847
|
+
var component, groundMaterial, debugMaterial, groundGeometry, ground, debugGround, errorGeometry, errorMaterial, errorGround, _t8;
|
|
730
848
|
return _regenerator().w(function (_context6) {
|
|
731
849
|
while (1) switch (_context6.n) {
|
|
732
850
|
case 0:
|
|
733
|
-
if (loadTextureSetAndCreateMaterial) {
|
|
734
|
-
_context6.n =
|
|
851
|
+
if (textureConfig.loadTextureSetAndCreateMaterial) {
|
|
852
|
+
_context6.n = 2;
|
|
735
853
|
break;
|
|
736
854
|
}
|
|
855
|
+
console.log('🔄 TextureConfig module not yet loaded, importing now...');
|
|
737
856
|
_context6.n = 1;
|
|
738
857
|
return importTextureConfig();
|
|
739
858
|
case 1:
|
|
859
|
+
if (textureConfig.loadTextureSetAndCreateMaterial) {
|
|
860
|
+
_context6.n = 2;
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
console.error('❌ Failed to load textureConfig module, falling back to basic ground');
|
|
864
|
+
return _context6.a(2, this.createGround());
|
|
865
|
+
case 2:
|
|
740
866
|
component = this.component;
|
|
741
867
|
if (!(!component || !component.scene)) {
|
|
742
|
-
_context6.n =
|
|
868
|
+
_context6.n = 3;
|
|
743
869
|
break;
|
|
744
870
|
}
|
|
745
871
|
logger.warn('Cannot create textured ground: component or scene not available');
|
|
746
872
|
return _context6.a(2, null);
|
|
747
|
-
case
|
|
873
|
+
case 3:
|
|
874
|
+
// Force texture loading with crossOrigin support
|
|
875
|
+
if (!component.textureLoader) {
|
|
876
|
+
console.log('🔄 Creating texture loader in component');
|
|
877
|
+
component.textureLoader = new THREE.TextureLoader();
|
|
878
|
+
component.textureLoader.setCrossOrigin('anonymous');
|
|
879
|
+
}
|
|
880
|
+
|
|
748
881
|
// Remove existing ground if present
|
|
749
882
|
component.scene.traverse(function (object) {
|
|
750
883
|
if (object.userData && object.userData.type === 'ground') {
|
|
751
884
|
component.scene.remove(object);
|
|
752
885
|
}
|
|
753
886
|
});
|
|
754
|
-
_context6.p =
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
887
|
+
_context6.p = 4;
|
|
888
|
+
console.log('🌍 Creating textured ground plane...');
|
|
889
|
+
// Use the gravel_embedded_concrete texture set
|
|
890
|
+
console.log('🔄 Loading ground material textures...');
|
|
891
|
+
_context6.n = 5;
|
|
892
|
+
return textureConfig.loadTextureSetAndCreateMaterial(component, 'gravel_embedded_concrete');
|
|
893
|
+
case 5:
|
|
758
894
|
groundMaterial = _context6.v;
|
|
759
|
-
|
|
895
|
+
if (groundMaterial) {
|
|
896
|
+
_context6.n = 6;
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
throw new Error('Failed to create ground material');
|
|
900
|
+
case 6:
|
|
901
|
+
console.log('✅ Ground material created');
|
|
902
|
+
|
|
903
|
+
// First create a colored material to verify the mesh creation works
|
|
904
|
+
debugMaterial = new THREE.MeshBasicMaterial({
|
|
905
|
+
color: 0x22ff22,
|
|
906
|
+
// Bright green for visibility
|
|
907
|
+
wireframe: false,
|
|
908
|
+
side: THREE.DoubleSide
|
|
909
|
+
}); // Create a composite ground with both materials
|
|
910
|
+
groundGeometry = new THREE.PlaneGeometry(100, 100); // Create the main ground mesh
|
|
760
911
|
ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
|
761
912
|
ground.rotation.x = -Math.PI / 2; // Rotate to be horizontal
|
|
762
913
|
ground.position.y = -0.01; // Slightly below origin
|
|
763
914
|
ground.receiveShadow = true;
|
|
764
915
|
|
|
916
|
+
// Create a debug ground mesh slightly below the main ground
|
|
917
|
+
debugGround = new THREE.Mesh(groundGeometry, debugMaterial);
|
|
918
|
+
debugGround.rotation.x = -Math.PI / 2;
|
|
919
|
+
debugGround.position.y = -0.02; // Below the main ground
|
|
920
|
+
debugGround.visible = false; // Hide by default
|
|
921
|
+
|
|
765
922
|
// Set user data for identification
|
|
766
923
|
ground.userData = {
|
|
767
924
|
isEnvironmentObject: true,
|
|
925
|
+
isBaseGround: true,
|
|
768
926
|
type: 'ground'
|
|
769
927
|
};
|
|
928
|
+
debugGround.userData = {
|
|
929
|
+
isEnvironmentObject: true,
|
|
930
|
+
type: 'ground-debug'
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
// Add both to scene
|
|
770
934
|
component.scene.add(ground);
|
|
935
|
+
component.scene.add(debugGround);
|
|
936
|
+
|
|
937
|
+
// Log some properties about the created ground
|
|
938
|
+
console.log('🌍 Textured ground created with properties:', {
|
|
939
|
+
material: groundMaterial.type,
|
|
940
|
+
hasMap: !!groundMaterial.map,
|
|
941
|
+
hasNormalMap: !!groundMaterial.normalMap,
|
|
942
|
+
hasRoughnessMap: !!groundMaterial.roughnessMap,
|
|
943
|
+
hasMetalnessMap: !!groundMaterial.metalnessMap,
|
|
944
|
+
hasAoMap: !!groundMaterial.aoMap,
|
|
945
|
+
hasBumpMap: !!groundMaterial.bumpMap,
|
|
946
|
+
materialColor: groundMaterial.color ? "#".concat(groundMaterial.color.getHexString()) : 'none'
|
|
947
|
+
});
|
|
771
948
|
logger.info('Textured ground created');
|
|
772
949
|
return _context6.a(2, ground);
|
|
773
|
-
case
|
|
774
|
-
_context6.p =
|
|
950
|
+
case 7:
|
|
951
|
+
_context6.p = 7;
|
|
775
952
|
_t8 = _context6.v;
|
|
776
953
|
logger.error('Error creating textured ground:', _t8);
|
|
777
|
-
//
|
|
778
|
-
|
|
954
|
+
// Create a bright colored ground so it's obvious something was wrong
|
|
955
|
+
errorGeometry = new THREE.PlaneGeometry(100, 100);
|
|
956
|
+
errorMaterial = new THREE.MeshBasicMaterial({
|
|
957
|
+
color: 0xff0000,
|
|
958
|
+
wireframe: true,
|
|
959
|
+
side: THREE.DoubleSide
|
|
960
|
+
});
|
|
961
|
+
errorGround = new THREE.Mesh(errorGeometry, errorMaterial);
|
|
962
|
+
errorGround.rotation.x = -Math.PI / 2;
|
|
963
|
+
errorGround.position.y = -0.01;
|
|
964
|
+
errorGround.userData = {
|
|
965
|
+
isEnvironmentObject: true,
|
|
966
|
+
isBaseGround: true,
|
|
967
|
+
type: 'ground-error'
|
|
968
|
+
};
|
|
969
|
+
component.scene.add(errorGround);
|
|
970
|
+
console.error('⚠️ Fallback to error ground (red wireframe) due to texture loading failure:', _t8);
|
|
971
|
+
return _context6.a(2, errorGround);
|
|
779
972
|
}
|
|
780
|
-
}, _callee4, this, [[
|
|
973
|
+
}, _callee4, this, [[4, 7]]);
|
|
781
974
|
}));
|
|
782
975
|
function addTexturedGround() {
|
|
783
976
|
return _addTexturedGround.apply(this, arguments);
|
|
784
977
|
}
|
|
785
978
|
return addTexturedGround;
|
|
786
979
|
}()
|
|
787
|
-
/**
|
|
788
|
-
* Add brick walls with materials from textureConfig
|
|
980
|
+
/**
|
|
981
|
+
* Add brick walls with materials from textureConfig
|
|
789
982
|
*/
|
|
790
983
|
)
|
|
791
984
|
}, {
|
|
@@ -796,31 +989,41 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
796
989
|
return _regenerator().w(function (_context7) {
|
|
797
990
|
while (1) switch (_context7.n) {
|
|
798
991
|
case 0:
|
|
799
|
-
if (loadTextureSetAndCreateMaterial) {
|
|
800
|
-
_context7.n =
|
|
992
|
+
if (textureConfig.loadTextureSetAndCreateMaterial) {
|
|
993
|
+
_context7.n = 2;
|
|
801
994
|
break;
|
|
802
995
|
}
|
|
996
|
+
console.log('🔄 TextureConfig module not yet loaded for brick walls, importing now...');
|
|
803
997
|
_context7.n = 1;
|
|
804
998
|
return importTextureConfig();
|
|
805
999
|
case 1:
|
|
1000
|
+
if (textureConfig.loadTextureSetAndCreateMaterial) {
|
|
1001
|
+
_context7.n = 2;
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
console.error('❌ Failed to load textureConfig module for brick walls');
|
|
1005
|
+
return _context7.a(2, this.createWalls());
|
|
1006
|
+
case 2:
|
|
806
1007
|
component = this.component;
|
|
807
1008
|
if (!(!component || !component.scene)) {
|
|
808
|
-
_context7.n =
|
|
1009
|
+
_context7.n = 3;
|
|
809
1010
|
break;
|
|
810
1011
|
}
|
|
811
1012
|
logger.warn('Cannot create brick walls: component or scene not available');
|
|
812
1013
|
return _context7.a(2, []);
|
|
813
|
-
case
|
|
1014
|
+
case 3:
|
|
814
1015
|
// Remove existing walls if present
|
|
815
1016
|
component.scene.traverse(function (object) {
|
|
816
1017
|
if (object.userData && object.userData.type === 'wall') {
|
|
817
1018
|
component.scene.remove(object);
|
|
818
1019
|
}
|
|
819
1020
|
});
|
|
820
|
-
_context7.p =
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
1021
|
+
_context7.p = 4;
|
|
1022
|
+
// Use the brick texture set
|
|
1023
|
+
console.log('🧱 Loading brick wall material textures...');
|
|
1024
|
+
_context7.n = 5;
|
|
1025
|
+
return textureConfig.loadTextureSetAndCreateMaterial(component, 'brick');
|
|
1026
|
+
case 5:
|
|
824
1027
|
wallMaterial = _context7.v;
|
|
825
1028
|
walls = [];
|
|
826
1029
|
wallHeight = 20;
|
|
@@ -860,22 +1063,22 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
860
1063
|
}
|
|
861
1064
|
logger.info('Textured environment walls created');
|
|
862
1065
|
return _context7.a(2, walls);
|
|
863
|
-
case
|
|
864
|
-
_context7.p =
|
|
1066
|
+
case 6:
|
|
1067
|
+
_context7.p = 6;
|
|
865
1068
|
_t9 = _context7.v;
|
|
866
1069
|
logger.error('Error creating brick walls:', _t9);
|
|
867
1070
|
// Fallback to simple walls
|
|
868
1071
|
return _context7.a(2, this.createWalls());
|
|
869
1072
|
}
|
|
870
|
-
}, _callee5, this, [[
|
|
1073
|
+
}, _callee5, this, [[4, 6]]);
|
|
871
1074
|
}));
|
|
872
1075
|
function addBrickWalls() {
|
|
873
1076
|
return _addBrickWalls.apply(this, arguments);
|
|
874
1077
|
}
|
|
875
1078
|
return addBrickWalls;
|
|
876
1079
|
}()
|
|
877
|
-
/**
|
|
878
|
-
* Add horizon fog effect
|
|
1080
|
+
/**
|
|
1081
|
+
* Add horizon fog effect
|
|
879
1082
|
*/
|
|
880
1083
|
)
|
|
881
1084
|
}, {
|
|
@@ -895,10 +1098,10 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
895
1098
|
logger.info('Horizon fog applied');
|
|
896
1099
|
}
|
|
897
1100
|
|
|
898
|
-
/**
|
|
899
|
-
* Helper to check if a texture exists locally in static directory
|
|
900
|
-
* @param {string} path - Relative path to texture in static directory
|
|
901
|
-
* @returns {Promise<boolean>}
|
|
1101
|
+
/**
|
|
1102
|
+
* Helper to check if a texture exists locally in static directory
|
|
1103
|
+
* @param {string} path - Relative path to texture in static directory
|
|
1104
|
+
* @returns {Promise<boolean>}
|
|
902
1105
|
*/
|
|
903
1106
|
}, {
|
|
904
1107
|
key: "checkLocalTextureExists",
|
|
@@ -926,9 +1129,8 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
926
1129
|
return resolve(false);
|
|
927
1130
|
};
|
|
928
1131
|
|
|
929
|
-
//
|
|
930
|
-
|
|
931
|
-
img.src = fullPath;
|
|
1132
|
+
// Use the path directly - it should already be processed by getAssetPath
|
|
1133
|
+
img.src = path;
|
|
932
1134
|
|
|
933
1135
|
// Set a timeout in case the image load hangs
|
|
934
1136
|
setTimeout(function () {
|
|
@@ -944,15 +1146,106 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
944
1146
|
return _checkLocalTextureExists.apply(this, arguments);
|
|
945
1147
|
}
|
|
946
1148
|
return checkLocalTextureExists;
|
|
947
|
-
}()
|
|
1149
|
+
}()
|
|
1150
|
+
/**
|
|
1151
|
+
* Force refresh all materials in the scene
|
|
1152
|
+
* Helpful for ensuring textures are correctly displayed
|
|
1153
|
+
*/
|
|
1154
|
+
)
|
|
1155
|
+
}, {
|
|
1156
|
+
key: "forceRefreshMaterials",
|
|
1157
|
+
value: function forceRefreshMaterials() {
|
|
1158
|
+
var component = this.component;
|
|
1159
|
+
if (!component || !component.scene) {
|
|
1160
|
+
logger.warn('Cannot refresh materials: component or scene not available');
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
console.log('🔄 Forcing material refresh for all objects...');
|
|
1164
|
+
var updatedMaterials = 0;
|
|
1165
|
+
var textureFixes = 0;
|
|
1166
|
+
|
|
1167
|
+
// Import helper functions if available
|
|
1168
|
+
var hasValidImageData = textureConfig.hasValidImageData || function (texture) {
|
|
1169
|
+
return texture && texture.image;
|
|
1170
|
+
};
|
|
1171
|
+
var createPlaceholderTexture = textureConfig.createPlaceholderTexture || function () {
|
|
1172
|
+
return null;
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
// Traverse all meshes in the scene
|
|
1176
|
+
component.scene.traverse(function (object) {
|
|
1177
|
+
if (object.isMesh && object.material) {
|
|
1178
|
+
// Handle both single materials and material arrays
|
|
1179
|
+
var materials = Array.isArray(object.material) ? object.material : [object.material];
|
|
1180
|
+
materials.forEach(function (material) {
|
|
1181
|
+
if (material) {
|
|
1182
|
+
// Update material properties
|
|
1183
|
+
material.needsUpdate = true;
|
|
1184
|
+
|
|
1185
|
+
// Ensure color values are properly set
|
|
1186
|
+
if (material.color) {
|
|
1187
|
+
if (typeof material.color.convertSRGBToLinear === 'function') {
|
|
1188
|
+
material.color.convertSRGBToLinear();
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// Check for maps and ensure they're correctly configured
|
|
1193
|
+
var maps = ['map', 'normalMap', 'roughnessMap', 'metalnessMap', 'aoMap', 'bumpMap'];
|
|
1194
|
+
maps.forEach(function (mapType) {
|
|
1195
|
+
var map = material[mapType];
|
|
1196
|
+
if (map) {
|
|
1197
|
+
// Check if this texture might trigger the warning
|
|
1198
|
+
var hasValidData = hasValidImageData(map);
|
|
1199
|
+
if (!hasValidData) {
|
|
1200
|
+
console.warn("\u26A0\uFE0F Found texture without valid image data in ".concat(mapType, " for object ").concat(object.name || object.uuid));
|
|
1201
|
+
|
|
1202
|
+
// Create and use a placeholder texture for now
|
|
1203
|
+
if (createPlaceholderTexture) {
|
|
1204
|
+
var placeholderColor = mapType === 'normalMap' ? 0x8080ff : 0xcccccc;
|
|
1205
|
+
var placeholder = createPlaceholderTexture(placeholderColor);
|
|
1206
|
+
if (placeholder) {
|
|
1207
|
+
material[mapType] = placeholder;
|
|
1208
|
+
textureFixes++;
|
|
1209
|
+
console.log("\uD83D\uDD04 Replaced missing image texture with placeholder for ".concat(mapType));
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
} else {
|
|
1213
|
+
map.needsUpdate = true;
|
|
1214
|
+
|
|
1215
|
+
// Ensure correct color space for diffuse maps
|
|
1216
|
+
if (mapType === 'map' && map.colorSpace !== undefined) {
|
|
1217
|
+
map.colorSpace = THREE.SRGBColorSpace;
|
|
1218
|
+
} else if (mapType === 'map' && map.encoding !== undefined) {
|
|
1219
|
+
map.encoding = THREE.sRGBEncoding;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
updatedMaterials++;
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
// Use the dedicated function from textureConfig if available
|
|
1231
|
+
if (textureConfig.forceUpdateMaterials) {
|
|
1232
|
+
textureConfig.forceUpdateMaterials(component.scene);
|
|
1233
|
+
}
|
|
1234
|
+
console.log("\u2705 Refreshed ".concat(updatedMaterials, " materials, fixed ").concat(textureFixes, " texture warnings"));
|
|
1235
|
+
|
|
1236
|
+
// Force a renderer update if possible
|
|
1237
|
+
if (component.renderer && component.camera) {
|
|
1238
|
+
component.renderer.render(component.scene, component.camera);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
948
1241
|
}]);
|
|
949
1242
|
}();
|
|
950
1243
|
|
|
951
1244
|
// Create a singleton instance
|
|
952
1245
|
var environmentManager = null;
|
|
953
1246
|
|
|
954
|
-
/**
|
|
955
|
-
* Get the global environment manager instance
|
|
1247
|
+
/**
|
|
1248
|
+
* Get the global environment manager instance
|
|
956
1249
|
*/
|
|
957
1250
|
function getEnvironmentManager() {
|
|
958
1251
|
var component = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|