之前分别用阿里通义千问 Qwen2.5-Max 和 Grok 3 生成了 3D 地月系统模拟的代码。两者都一次性生成了准确完整的代码,Qwen 生成的较为美观,Grok 速度更快,操作性更强。

那么,Claude 3.7 Sonnet 的推理能力表现如何?在相同的生成提示下,它共进行了 8 轮推理,耗时 5 分钟,最终生成的代码中存在一个错误。将系统报出的错误直接反馈给 Claude 后,它又进行了 2 轮推理,并自动修正了代码。

与 Qwen2.5-Max 和 Grok 3 生成的代码相比,Claude 3.7 Sonnet 的代码更加精准细致。除了完整实现地月系统的运行过程外,它还额外增加了星空背景、太阳光源、地球和月球的精美纹理贴图(包括蓝色海洋、绿色陆地、半透明的云层),以及月球公转的虚拟轨道(轨道倾斜5.1度)。地球自转和月球公转的速度更接近真实数据,旋转和缩放操作也更加流畅。

总得来说,虽然 Claude 3.7 Sonnet 的生成速度较慢,且首次生成的代码存在错误,但代码的整体质量相比 Qwen2.5-Max 和 Grok 3 有了显著提升。

提示词

演示

Claude 3.7 Sonnet 生成 3D 地月系统模拟

完整演示

Claude 3.7 Sonnet 完整推理过程


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <!-- 从CDN引入Three.js -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.min.js"></script>
    <!-- 引入OrbitControls控制器 -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js"></script>
    
    <script>
        // 这里将添加Three.js代码
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <!-- 从CDN引入Three.js -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.min.js"></script>
    <!-- 引入OrbitControls控制器 -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/examples/js/controls/OrbitControls.js"></script>
    
    <script>
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 5;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 10, 30);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        const earthMaterial = new THREE.MeshPhongMaterial();
        
        // 加载地球纹理
        const textureLoader = new THREE.TextureLoader();
        
        // 地球表面纹理
        const earthTexture = textureLoader.load('https://threejs.org/examples/textures/planets/earth_atmos_2048.jpg');
        earthMaterial.map = earthTexture;
        
        // 地球凹凸纹理(使地形有高低差)
        const earthBumpMap = textureLoader.load('https://threejs.org/examples/textures/planets/earth_normal_2048.jpg');
        earthMaterial.bumpMap = earthBumpMap;
        earthMaterial.bumpScale = 0.05;
        
        // 地球镜面纹理(反光效果)
        const earthSpecularMap = textureLoader.load('https://threejs.org/examples/textures/planets/earth_specular_2048.jpg');
        earthMaterial.specularMap = earthSpecularMap;
        earthMaterial.specular = new THREE.Color(0x333333);
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        scene.add(earth);

        // 创建地球的云层
        const cloudGeometry = new THREE.SphereGeometry(5.1, 64, 64);
        const cloudMaterial = new THREE.MeshPhongMaterial({
            map: textureLoader.load('https://threejs.org/examples/textures/planets/earth_clouds_1024.jpg'),
            transparent: true,
            opacity: 0.4
        });
        const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
        scene.add(clouds);

        // 创建月球和轨道
        const moonGroup = new THREE.Group();
        scene.add(moonGroup);
        
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            map: textureLoader.load('https://threejs.org/examples/textures/planets/moon_1024.jpg'),
            bumpMap: textureLoader.load('https://threejs.org/examples/textures/planets/moon_1024.jpg'),
            bumpScale: 0.002,
        });
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(15, 0, 0);
        moonGroup.add(moon);

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转
            earth.rotation.y += 0.002;
            clouds.rotation.y += 0.0025;
            
            // 月球公转
            moonGroup.rotation.y += 0.0005;
            // 月球自转 (同步自转,始终同一面朝向地球)
            moon.rotation.y += 0.0005;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <!-- 从CDN引入Three.js -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.min.js"></script>
    <!-- 引入OrbitControls控制器 -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js"></script>
    
    <script>
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 5;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 10, 30);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 使用程序化生成纹理代替外部URL
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        scene.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        scene.add(land);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222, 
        });
        
        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(15, 0, 0);
        moonOrbit.add(moon);

        // 创建随机的月球表面凹坑
        createMoonCraters(moon, 30);

        // 函数:创建随机的月球凹坑
        function createMoonCraters(moonMesh, count) {
            for (let i = 0; i < count; i++) {
                const size = 0.1 + Math.random() * 0.3;
                const craterGeometry = new THREE.CircleGeometry(size, 16);
                const craterMaterial = new THREE.MeshBasicMaterial({
                    color: 0x888888,
                    side: THREE.DoubleSide
                });
                
                const crater = new THREE.Mesh(craterGeometry, craterMaterial);
                
                // 随机位置
                const phi = Math.random() * Math.PI * 2;
                const theta = Math.random() * Math.PI;
                
                crater.position.x = 1.3 * Math.sin(theta) * Math.cos(phi);
                crater.position.y = 1.3 * Math.sin(theta) * Math.sin(phi);
                crater.position.z = 1.3 * Math.cos(theta);
                
                // 让凹坑面向月球中心
                crater.lookAt(0, 0, 0);
                
                moon.add(crater);
            }
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 50;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 5; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 10 + Math.random() * 30;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转
            earth.rotation.y += 0.002;
            land.rotation.y += 0.002;
            
            // 月球公转
            moonOrbit.rotation.y += 0.005;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <!-- 从CDN引入Three.js核心 -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.min.js"></script>
    <!-- 引入OrbitControls控制器 -->
    <script src="https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js"></script>
    
    <script>
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器 - 需要从正确的模块路径导入
        const controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 5;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 10, 30);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 使用程序化生成纹理代替外部URL
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        scene.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        scene.add(land);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222, 
        });
        
        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(15, 0, 0);
        moonOrbit.add(moon);

        // 创建随机的月球表面凹坑
        createMoonCraters(moon, 30);

        // 函数:创建随机的月球凹坑
        function createMoonCraters(moonMesh, count) {
            for (let i = 0; i < count; i++) {
                const size = 0.1 + Math.random() * 0.3;
                const craterGeometry = new THREE.CircleGeometry(size, 16);
                const craterMaterial = new THREE.MeshBasicMaterial({
                    color: 0x888888,
                    side: THREE.DoubleSide
                });
                
                const crater = new THREE.Mesh(craterGeometry, craterMaterial);
                
                // 随机位置
                const phi = Math.random() * Math.PI * 2;
                const theta = Math.random() * Math.PI;
                
                crater.position.x = 1.3 * Math.sin(theta) * Math.cos(phi);
                crater.position.y = 1.3 * Math.sin(theta) * Math.sin(phi);
                crater.position.z = 1.3 * Math.cos(theta);
                
                // 让凹坑面向月球中心
                crater.lookAt(0, 0, 0);
                
                moon.add(crater);
            }
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 50;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 5; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 10 + Math.random() * 30;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转
            earth.rotation.y += 0.002;
            land.rotation.y += 0.002;
            
            // 月球公转
            moonOrbit.rotation.y += 0.005;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <!-- 从CDN引入Three.js核心 -->
    <script type="module">
        import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.module.js';
        import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js';
        
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 5;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 10, 30);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 使用程序化生成纹理代替外部URL
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        scene.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        scene.add(land);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222, 
        });
        
        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(15, 0, 0);
        moonOrbit.add(moon);

        // 创建随机的月球表面凹坑
        createMoonCraters(moon, 30);

        // 函数:创建随机的月球凹坑
        function createMoonCraters(moonMesh, count) {
            for (let i = 0; i < count; i++) {
                const size = 0.1 + Math.random() * 0.3;
                const craterGeometry = new THREE.CircleGeometry(size, 16);
                const craterMaterial = new THREE.MeshBasicMaterial({
                    color: 0x888888,
                    side: THREE.DoubleSide
                });
                
                const crater = new THREE.Mesh(craterGeometry, craterMaterial);
                
                // 随机位置
                const phi = Math.random() * Math.PI * 2;
                const theta = Math.random() * Math.PI;
                
                crater.position.x = 1.3 * Math.sin(theta) * Math.cos(phi);
                crater.position.y = 1.3 * Math.sin(theta) * Math.sin(phi);
                crater.position.z = 1.3 * Math.cos(theta);
                
                // 让凹坑面向月球中心
                crater.lookAt(0, 0, 0);
                
                moon.add(crater);
            }
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 50;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 5; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 10 + Math.random() * 30;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转
            earth.rotation.y += 0.002;
            land.rotation.y += 0.002;
            
            // 月球公转
            moonOrbit.rotation.y += 0.005;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <script type="module">
        import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.module.js';
        import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js';
        
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 10;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 20, 40);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建一个系统组
        const earthSystem = new THREE.Group();
        // 添加23.5度的倾斜角度,模拟地球倾斜
        earthSystem.rotation.z = THREE.MathUtils.degToRad(23.5);
        scene.add(earthSystem);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        earthSystem.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        earthSystem.add(land);

        // 添加云层
        const cloudGeometry = new THREE.SphereGeometry(5.1, 64, 64);
        const cloudMaterial = new THREE.MeshPhongMaterial({
            color: 0xffffff,
            transparent: true,
            opacity: 0.3,
            alphaMap: createCloudAlphaTexture()
        });
        const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
        earthSystem.add(clouds);

        // 月球轨道半径
        const moonOrbitRadius = 15;
        
        // 创建月球轨道线
        const moonOrbitGeometry = new THREE.RingGeometry(moonOrbitRadius - 0.1, moonOrbitRadius + 0.1, 64);
        const moonOrbitMaterial = new THREE.MeshBasicMaterial({
            color: 0x444444,
            side: THREE.DoubleSide,
            transparent: true,
            opacity: 0.3
        });
        const moonOrbitLine = new THREE.Mesh(moonOrbitGeometry, moonOrbitMaterial);
        moonOrbitLine.rotation.x = Math.PI / 2; // 使轨道水平
        scene.add(moonOrbitLine);

        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        // 添加5.1度的倾角,模拟月球轨道倾角
        moonOrbit.rotation.x = THREE.MathUtils.degToRad(5.1);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222,
        });
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(moonOrbitRadius, 0, 0);
        moonOrbit.add(moon);

        // 创建月球表面纹理
        createMoonTexture(moon);

        // 函数:创建月球表面纹理
        function createMoonTexture(moonMesh) {
            // 创建一个画布
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const ctx = canvas.getContext('2d');
            
            // 填充灰色背景
            ctx.fillStyle = '#888';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            // 添加随机的暗色斑点
            for (let i = 0; i < 1000; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 0.5 + Math.random() * 3;
                const darkness = Math.random() * 0.4;
                
                ctx.fillStyle = `rgba(40, 40, 40, ${darkness})`;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
            }
            
            // 添加一些更大的环形山
            for (let i = 0; i < 50; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 3 + Math.random() * 10;
                
                ctx.fillStyle = 'rgba(70, 70, 70, 0.8)';
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
                
                ctx.strokeStyle = 'rgba(120, 120, 120, 0.6)';
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.arc(x, y, radius * 0.8, 0, Math.PI * 2);
                ctx.stroke();
            }
            
            // 应用纹理
            const texture = new THREE.CanvasTexture(canvas);
            moonMesh.material.map = texture;
            moonMesh.material.needsUpdate = true;
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 70;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 8; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 20 + Math.random() * 40;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 函数:创建云层的Alpha贴图
        function createCloudAlphaTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制随机的云
            context.fillStyle = 'rgba(255, 255, 255, 0.7)';
            
            // 创建许多小云团
            for (let i = 0; i < 100; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 5 + Math.random() * 20;
                
                for (let j = 0; j < 5; j++) {
                    const cloudX = x + (Math.random() - 0.5) * radius * 2;
                    const cloudY = y + (Math.random() - 0.5) * radius * 2;
                    const cloudSize = radius * (0.5 + Math.random() * 0.5);
                    
                    context.beginPath();
                    context.arc(cloudX, cloudY, cloudSize, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转 (一天自转一圈,但这里加快速度)
            earth.rotation.y += 0.01;
            land.rotation.y += 0.01;
            clouds.rotation.y += 0.012; // 云层稍快一点
            
            // 月球公转 (一个月公转一圈,但加快速度)
            moonOrbit.rotation.y += 0.002;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <script type="module">
        import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.module.js';
        import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js';
        
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 10;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 20, 40);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建一个系统组
        const earthSystem = new THREE.Group();
        // 添加23.5度的倾斜角度,模拟地球倾斜
        earthSystem.rotation.z = THREE.MathUtils.degToRad(23.5);
        scene.add(earthSystem);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        earthSystem.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        earthSystem.add(land);

        // 添加云层
        const cloudGeometry = new THREE.SphereGeometry(5.1, 64, 64);
        const cloudMaterial = new THREE.MeshPhongMaterial({
            color: 0xffffff,
            transparent: true,
            opacity: 0.3,
            alphaMap: createCloudAlphaTexture()
        });
        const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
        earthSystem.add(clouds);

        // 月球轨道半径
        const moonOrbitRadius = 15;
        
        // 创建月球轨道线
        const moonOrbitGeometry = new THREE.RingGeometry(moonOrbitRadius - 0.1, moonOrbitRadius + 0.1, 64);
        const moonOrbitMaterial = new THREE.MeshBasicMaterial({
            color: 0x444444,
            side: THREE.DoubleSide,
            transparent: true,
            opacity: 0.3
        });
        const moonOrbitLine = new THREE.Mesh(moonOrbitGeometry, moonOrbitMaterial);
        moonOrbitLine.rotation.x = Math.PI / 2; // 使轨道水平
        scene.add(moonOrbitLine);

        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        // 添加5.1度的倾角,模拟月球轨道倾角
        moonOrbit.rotation.x = THREE.MathUtils.degToRad(5.1);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222,
        });
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(moonOrbitRadius, 0, 0);
        moonOrbit.add(moon);

        // 创建月球表面纹理
        createMoonTexture(moon);

        // 函数:创建月球表面纹理
        function createMoonTexture(moonMesh) {
            // 创建一个画布
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const ctx = canvas.getContext('2d');
            
            // 填充灰色背景
            ctx.fillStyle = '#888';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            // 添加随机的暗色斑点
            for (let i = 0; i < 1000; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 0.5 + Math.random() * 3;
                const darkness = Math.random() * 0.4;
                
                ctx.fillStyle = `rgba(40, 40, 40, ${darkness})`;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
            }
            
            // 添加一些更大的环形山
            for (let i = 0; i < 50; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 3 + Math.random() * 10;
                
                ctx.fillStyle = 'rgba(70, 70, 70, 0.8)';
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
                
                ctx.strokeStyle = 'rgba(120, 120, 120, 0.6)';
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.arc(x, y, radius * 0.8, 0, Math.PI * 2);
                ctx.stroke();
            }
            
            // 应用纹理
            const texture = new THREE.CanvasTexture(canvas);
            moonMesh.material.map = texture;
            moonMesh.material.needsUpdate = true;
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 70;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 8; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 20 + Math.random() * 40;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 函数:创建云层的Alpha贴图
        function createCloudAlphaTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制随机的云
            context.fillStyle = 'rgba(255, 255, 255, 0.7)';
            
            // 创建许多小云团
            for (let i = 0; i < 100; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 5 + Math.random() * 20;
                
                for (let j = 0; j < 5; j++) {
                    const cloudX = x + (Math.random() - 0.5) * radius * 2;
                    const cloudY = y + (Math.random() - 0.5) * radius * 2;
                    const cloudSize = radius * (0.5 + Math.random() * 0.5);
                    
                    context.beginPath();
                    context.arc(cloudX, cloudY, cloudSize, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转 (一天自转一圈,但这里加快速度)
            earth.rotation.y += 0.01;
            land.rotation.y += 0.01;
            clouds.rotation.y += 0.012; // 云层稍快一点
            
            // 月球公转 (一个月公转一圈,但加快速度)
            moonOrbit.rotation.y += 0.002;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <script type="module">
        import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.module.js';
        import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/controls/OrbitControls.js';
        
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 10;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 20, 40);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建一个系统组
        const earthSystem = new THREE.Group();
        // 添加23.5度的倾斜角度,模拟地球倾斜
        earthSystem.rotation.z = THREE.MathUtils.degToRad(23.5);
        scene.add(earthSystem);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        earthSystem.add(earth);

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        earthSystem.add(land);

        // 添加云层
        const cloudGeometry = new THREE.SphereGeometry(5.1, 64, 64);
        const cloudMaterial = new THREE.MeshPhongMaterial({
            color: 0xffffff,
            transparent: true,
            opacity: 0.3,
            alphaMap: createCloudAlphaTexture()
        });
        const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
        earthSystem.add(clouds);

        // 月球轨道半径
        const moonOrbitRadius = 15;
        
        // 创建月球轨道线
        const moonOrbitGeometry = new THREE.RingGeometry(moonOrbitRadius - 0.1, moonOrbitRadius + 0.1, 64);
        const moonOrbitMaterial = new THREE.MeshBasicMaterial({
            color: 0x444444,
            side: THREE.DoubleSide,
            transparent: true,
            opacity: 0.3
        });
        const moonOrbitLine = new THREE.Mesh(moonOrbitGeometry, moonOrbitMaterial);
        moonOrbitLine.rotation.x = Math.PI / 2; // 使轨道水平
        scene.add(moonOrbitLine);

        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        // 添加5.1度的倾角,模拟月球轨道倾角
        moonOrbit.rotation.x = THREE.MathUtils.degToRad(5.1);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222,
        });
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(moonOrbitRadius, 0, 0);
        moonOrbit.add(moon);

        // 创建月球表面纹理
        createMoonTexture(moon);

        // 函数:创建月球表面纹理
        function createMoonTexture(moonMesh) {
            // 创建一个画布
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const ctx = canvas.getContext('2d');
            
            // 填充灰色背景
            ctx.fillStyle = '#888';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            // 添加随机的暗色斑点
            for (let i = 0; i < 1000; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 0.5 + Math.random() * 3;
                const darkness = Math.random() * 0.4;
                
                ctx.fillStyle = `rgba(40, 40, 40, ${darkness})`;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
            }
            
            // 添加一些更大的环形山
            for (let i = 0; i < 50; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 3 + Math.random() * 10;
                
                ctx.fillStyle = 'rgba(70, 70, 70, 0.8)';
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
                
                ctx.strokeStyle = 'rgba(120, 120, 120, 0.6)';
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.arc(x, y, radius * 0.8, 0, Math.PI * 2);
                ctx.stroke();
            }
            
            // 应用纹理
            const texture = new THREE.CanvasTexture(canvas);
            moonMesh.material.map = texture;
            moonMesh.material.needsUpdate = true;
        }

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 70;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 8; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 20 + Math.random() * 40;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 函数:创建云层的Alpha贴图
        function createCloudAlphaTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制随机的云
            context.fillStyle = 'rgba(255, 255, 255, 0.7)';
            
            // 创建许多小云团
            for (let i = 0; i < 100; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 5 + Math.random() * 20;
                
                for (let j = 0; j < 5; j++) {
                    const cloudX = x + (Math.random() - 0.5) * radius * 2;
                    const cloudY = y + (Math.random() - 0.5) * radius * 2;
                    const cloudSize = radius * (0.5 + Math.random() * 0.5);
                    
                    context.beginPath();
                    context.arc(cloudX, cloudY, cloudSize, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转 (一天自转一圈,但这里加快速度)
            earth.rotation.y += 0.01;
            land.rotation.y += 0.01;
            clouds.rotation.y += 0.012; // 云层稍快一点
            
            // 月球公转 (一个月公转一圈,但加快速度)
            moonOrbit.rotation.y += 0.002;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>

以上是 Claude 3.7 Sonnet 的第一次推理过程,生成的代码包含了一个错误: Uncaught SyntaxError: Unexpected end of input 


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        /* 样式代码 */
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <script type="module">
        // JavaScript 代码
    </script>
</body>
</html>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地月系统演示</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        canvas {
            display: block;
        }
        .info {
            position: absolute;
            top: 10px;
            left: 10px;
            color: white;
            font-family: Arial, sans-serif;
            font-size: 14px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="info">地月系统演示 - 使用鼠标拖动可旋转视角,滚轮可缩放</div>
    
    <script type="importmap">
      {
        "imports": {
          "three": "https://cdn.jsdelivr.net/npm/three@0.150.1/build/three.module.js",
          "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.150.1/examples/jsm/"
        }
      }
    </script>

    <script type="module">
        import * as THREE from 'three';
        import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
        
        // 初始化场景、相机和渲染器
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        renderer.setPixelRatio(window.devicePixelRatio);
        document.body.appendChild(renderer.domElement);

        // 创建轨道控制器
        const controls = new OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true; // 启用阻尼效果
        controls.dampingFactor = 0.05;
        controls.minDistance = 10;
        controls.maxDistance = 100;

        // 设置相机位置
        camera.position.set(0, 20, 40);
        controls.update();

        // 创建星空背景
        const starsGeometry = new THREE.BufferGeometry();
        const starsMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
        });

        const starsVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = THREE.MathUtils.randFloatSpread(2000);
            const y = THREE.MathUtils.randFloatSpread(2000);
            const z = THREE.MathUtils.randFloatSpread(2000);
            starsVertices.push(x, y, z);
        }

        starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
        const stars = new THREE.Points(starsGeometry, starsMaterial);
        scene.add(stars);

        // 添加光源(模拟太阳光)
        const sunLight = new THREE.DirectionalLight(0xFFFFFF, 1.5);
        sunLight.position.set(50, 0, 30); // 从一侧照射
        scene.add(sunLight);

        // 添加环境光
        const ambientLight = new THREE.AmbientLight(0x333333);
        scene.add(ambientLight);

        // 创建一个系统组
        const earthSystem = new THREE.Group();
        // 添加23.5度的倾斜角度,模拟地球倾斜
        earthSystem.rotation.z = THREE.MathUtils.degToRad(23.5);
        scene.add(earthSystem);

        // 创建地球
        const earthGeometry = new THREE.SphereGeometry(5, 64, 64);
        
        // 地球材质 - 使用简单的颜色
        const earthMaterial = new THREE.MeshPhongMaterial({
            color: 0x2233ff,  // 蓝色
            specular: 0x555555,
            shininess: 30
        });
        
        const earth = new THREE.Mesh(earthGeometry, earthMaterial);
        earthSystem.add(earth);

        // 函数:创建陆地的Alpha贴图(随机大陆形状)
        function createAlphaMapTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制几块随机的大陆
            context.fillStyle = 'white';
            for (let i = 0; i < 7; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 30 + Math.random() * 70;
                
                context.beginPath();
                context.arc(x, y, radius, 0, Math.PI * 2);
                context.fill();
                
                // 添加一些随机的"延伸"
                for (let j = 0; j < 8; j++) {
                    const angle = Math.random() * Math.PI * 2;
                    const distance = radius * 0.7;
                    const endX = x + Math.cos(angle) * distance;
                    const endY = y + Math.sin(angle) * distance;
                    const extensionRadius = 20 + Math.random() * 40;
                    
                    context.beginPath();
                    context.arc(endX, endY, extensionRadius, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 函数:创建云层的Alpha贴图
        function createCloudAlphaTexture() {
            const canvas = document.createElement('canvas');
            canvas.width = 1024;
            canvas.height = 512;
            const context = canvas.getContext('2d');
            
            // 填充透明背景
            context.fillStyle = 'black';
            context.fillRect(0, 0, canvas.width, canvas.height);
            
            // 绘制随机的云
            context.fillStyle = 'rgba(255, 255, 255, 0.7)';
            
            // 创建许多小云团
            for (let i = 0; i < 100; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 5 + Math.random() * 20;
                
                for (let j = 0; j < 5; j++) {
                    const cloudX = x + (Math.random() - 0.5) * radius * 2;
                    const cloudY = y + (Math.random() - 0.5) * radius * 2;
                    const cloudSize = radius * (0.5 + Math.random() * 0.5);
                    
                    context.beginPath();
                    context.arc(cloudX, cloudY, cloudSize, 0, Math.PI * 2);
                    context.fill();
                }
            }
            
            const texture = new THREE.CanvasTexture(canvas);
            return texture;
        }

        // 添加一些陆地(绿色区域)
        const landGeometry = new THREE.SphereGeometry(5.01, 64, 64);
        const landMaterial = new THREE.MeshPhongMaterial({
            color: 0x00aa00,  // 绿色
            transparent: true,
            opacity: 0.8,
            alphaMap: createAlphaMapTexture()
        });
        const land = new THREE.Mesh(landGeometry, landMaterial);
        earthSystem.add(land);

        // 添加云层
        const cloudGeometry = new THREE.SphereGeometry(5.1, 64, 64);
        const cloudMaterial = new THREE.MeshPhongMaterial({
            color: 0xffffff,
            transparent: true,
            opacity: 0.3,
            alphaMap: createCloudAlphaTexture()
        });
        const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
        earthSystem.add(clouds);

        // 月球轨道半径
        const moonOrbitRadius = 15;
        
        // 创建月球轨道线
        const moonOrbitGeometry = new THREE.RingGeometry(moonOrbitRadius - 0.1, moonOrbitRadius + 0.1, 64);
        const moonOrbitMaterial = new THREE.MeshBasicMaterial({
            color: 0x444444,
            side: THREE.DoubleSide,
            transparent: true,
            opacity: 0.3
        });
        const moonOrbitLine = new THREE.Mesh(moonOrbitGeometry, moonOrbitMaterial);
        moonOrbitLine.rotation.x = Math.PI / 2; // 使轨道水平
        scene.add(moonOrbitLine);

        // 创建月球轨道
        const moonOrbit = new THREE.Object3D();
        scene.add(moonOrbit);
        
        // 添加5.1度的倾角,模拟月球轨道倾角
        moonOrbit.rotation.x = THREE.MathUtils.degToRad(5.1);

        // 创建月球
        const moonGeometry = new THREE.SphereGeometry(1.3, 32, 32);
        const moonMaterial = new THREE.MeshPhongMaterial({
            color: 0xaaaaaa,  // 灰色
            emissive: 0x222222,
        });
        
        const moon = new THREE.Mesh(moonGeometry, moonMaterial);
        moon.position.set(moonOrbitRadius, 0, 0);
        moonOrbit.add(moon);

        // 函数:创建月球表面纹理
        function createMoonTexture(moonMesh) {
            // 创建一个画布
            const canvas = document.createElement('canvas');
            canvas.width = 512;
            canvas.height = 256;
            const ctx = canvas.getContext('2d');
            
            // 填充灰色背景
            ctx.fillStyle = '#888';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            // 添加随机的暗色斑点
            for (let i = 0; i < 1000; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 0.5 + Math.random() * 3;
                const darkness = Math.random() * 0.4;
                
                ctx.fillStyle = `rgba(40, 40, 40, ${darkness})`;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
            }
            
            // 添加一些更大的环形山
            for (let i = 0; i < 50; i++) {
                const x = Math.random() * canvas.width;
                const y = Math.random() * canvas.height;
                const radius = 3 + Math.random() * 10;
                
                ctx.fillStyle = 'rgba(70, 70, 70, 0.8)';
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
                
                ctx.strokeStyle = 'rgba(120, 120, 120, 0.6)';
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.arc(x, y, radius * 0.8, 0, Math.PI * 2);
                ctx.stroke();
            }
            
            // 应用纹理
            const texture = new THREE.CanvasTexture(canvas);
            moonMesh.material.map = texture;
            moonMesh.material.needsUpdate = true;
        }

        // 创建月球表面纹理
        createMoonTexture(moon);

        // 窗口大小调整处理
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        });

        // 动画循环
        const animate = function () {
            requestAnimationFrame(animate);
            
            // 地球自转 (一天自转一圈,但这里加快速度)
            earth.rotation.y += 0.01;
            land.rotation.y += 0.01;
            clouds.rotation.y += 0.012; // 云层稍快一点
            
            // 月球公转 (一个月公转一圈,但加快速度)
            moonOrbit.rotation.y += 0.002;
            
            // 更新控制器
            controls.update();
            
            // 渲染场景
            renderer.render(scene, camera);
        };

        animate();
    </script>
</body>
</html>