// 测试模型加载的控制台脚本 console.log('=== 开始测试模型加载 ==='); // 检查 Three.js 是否加载 if (typeof THREE === 'undefined') { console.error('Three.js 未加载'); } else { console.log('Three.js 已加载,版本:', THREE.REVISION); } // 检查 GLTFLoader 是否加载 if (typeof GLTFLoader === 'undefined') { console.error('GLTFLoader 未加载'); } else { console.log('GLTFLoader 已加载'); } // 检查 Cesium 是否加载 if (typeof window.viewer === 'undefined') { console.error('Cesium viewer 未初始化'); } else { console.log('Cesium viewer 已初始化'); } // 测试模型加载 function testModelLoad() { console.log('开始测试模型加载'); if (typeof THREE === 'undefined' || typeof GLTFLoader === 'undefined') { console.error('Three.js 或 GLTFLoader 未加载'); return; } const loader = new GLTFLoader(); console.log('GLTFLoader 实例创建成功'); loader.load( '/models/启闭机.glb', function (gltf) { console.log('模型加载成功:', gltf); console.log('模型场景:', gltf.scene); console.log('模型部件数量:', gltf.scene.children.length); }, function (xhr) { const percent = (xhr.loaded / xhr.total * 100).toFixed(0); console.log(`加载进度: ${percent}%`); }, function (error) { console.error('模型加载失败:', error); } ); } // 导出测试函数 window.testModelLoad = testModelLoad; console.log('=== 测试脚本加载完成 ==='); console.log('请在控制台中执行 testModelLoad() 来测试模型加载');