初始化多多畅职企业内推平台项目

功能特性:
- 3D地球动画与中国地图可视化
- 省份/城市/企业搜索功能
- 308家企业数据展示
- 响应式设计(PC端和移动端)
- 企业详情页面与业务板块展示
- 官网新闻轮播图

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
KQL
2025-11-22 19:38:14 +08:00
commit ab50931347
41 changed files with 56412 additions and 0 deletions

127
js/scene/EarthModel.js Normal file
View File

@@ -0,0 +1,127 @@
/* ===================================
地球模型 - 包含地球、云层、大气层
=================================== */
import { CONFIG } from '../config.js';
export class EarthModel {
constructor(scene) {
this.scene = scene;
this.earthGroup = new THREE.Group();
this.earth = null;
this.clouds = null;
this.atmosphere = null;
this.loader = new THREE.TextureLoader();
this.init();
}
// 初始化地球模型
init() {
const radius = CONFIG.scene.earth.radius;
const segments = CONFIG.scene.earth.segments;
// 创建地球
this.earth = new THREE.Mesh(
new THREE.SphereGeometry(radius, segments, segments),
new THREE.MeshPhongMaterial({
map: this.loader.load(CONFIG.textures.earthMap),
specularMap: this.loader.load(CONFIG.textures.earthSpecular),
normalMap: this.loader.load(CONFIG.textures.earthNormal),
specular: new THREE.Color(0x111111),
shininess: 5
})
);
this.earthGroup.add(this.earth);
// 创建云层
this.clouds = new THREE.Mesh(
new THREE.SphereGeometry(CONFIG.scene.earth.cloudRadius, segments, segments),
new THREE.MeshLambertMaterial({
map: this.loader.load(CONFIG.textures.earthClouds),
transparent: true,
opacity: 0.9,
blending: THREE.AdditiveBlending
})
);
this.earthGroup.add(this.clouds);
// 创建大气光晕
this.atmosphere = new THREE.Mesh(
new THREE.SphereGeometry(CONFIG.scene.earth.atmosphereRadius, segments, segments),
new THREE.ShaderMaterial({
vertexShader: `
varying vec3 vNormal;
void main() {
vNormal = normalize(normalMatrix * normal);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
varying vec3 vNormal;
void main() {
float intensity = pow(0.55 - dot(vNormal, vec3(0, 0, 1.0)), 4.5);
gl_FragColor = vec4(0.0, 0.6, 1.0, 1.0) * intensity;
}
`,
blending: THREE.AdditiveBlending,
side: THREE.BackSide,
transparent: true
})
);
// 大气层独立添加到场景不在earthGroup中避免被旋转
this.scene.add(this.atmosphere);
this.scene.add(this.earthGroup);
}
// 自动旋转地球和云层
rotate() {
if (this.earthGroup) {
this.earthGroup.rotation.y += 0.0008;
}
if (this.clouds) {
this.clouds.rotation.y += 0.0010;
}
}
// 获取可交互对象(用于射线检测)
getInteractiveObjects() {
return [this.earth, this.clouds];
}
// 获取地球组(用于转场旋转)
getGroup() {
return this.earthGroup;
}
// 获取大气层(用于悬停效果)
getAtmosphere() {
return this.atmosphere;
}
// 获取云层(用于转场淡出)
getClouds() {
return this.clouds;
}
// 销毁
dispose() {
if (this.earth) {
this.earth.geometry.dispose();
this.earth.material.dispose();
}
if (this.clouds) {
this.clouds.geometry.dispose();
this.clouds.material.dispose();
}
if (this.atmosphere) {
this.atmosphere.geometry.dispose();
this.atmosphere.material.dispose();
this.scene.remove(this.atmosphere);
}
if (this.earthGroup) {
this.scene.remove(this.earthGroup);
}
}
}

288
js/scene/SceneManager.js Normal file
View File

@@ -0,0 +1,288 @@
/* ===================================
3D场景管理器 - 主控制器
=================================== */
import { CONFIG } from '../config.js';
import { StarSystem } from './StarSystem.js';
import { EarthModel } from './EarthModel.js';
import { Transition } from './Transition.js';
export class SceneManager {
constructor(container, onTransitionComplete) {
this.container = container;
this.onTransitionComplete = onTransitionComplete;
// 状态标志
this.isIntro = true;
this.isHovering = false;
this.parallaxX = 0;
this.parallaxY = 0;
// Three.js核心对象
this.scene = null;
this.camera = null;
this.renderer = null;
this.raycaster = new THREE.Raycaster();
this.mouse = new THREE.Vector2();
// 子系统
this.starSystem = null;
this.earthModel = null;
this.transition = null;
this.init();
}
// 初始化场景
init() {
// 创建场景
this.scene = new THREE.Scene();
this.scene.fog = new THREE.FogExp2(CONFIG.scene.fog.color, CONFIG.scene.fog.density);
// 创建相机
const camConfig = CONFIG.scene.camera;
this.camera = new THREE.PerspectiveCamera(
camConfig.fov,
window.innerWidth / window.innerHeight,
camConfig.near,
camConfig.far
);
this.camera.position.z = camConfig.initialZ; // 开场动画:从深空开始
// 创建渲染器
this.renderer = new THREE.WebGLRenderer({ antialias: true });
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setClearColor(0x000000, 1); // 设置黑色背景
this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
this.renderer.outputEncoding = THREE.sRGBEncoding;
this.container.appendChild(this.renderer.domElement);
// 创建星空系统
this.starSystem = new StarSystem(this.scene);
// 创建地球模型
this.earthModel = new EarthModel(this.scene);
// 添加灯光
this.setupLights();
// 绑定事件
this.bindEvents();
// 启动动画循环
this.animate();
}
// 设置灯光
setupLights() {
const lights = CONFIG.scene.lights;
// 环境光
this.scene.add(new THREE.AmbientLight(lights.ambient));
// 太阳光
const sunLight = new THREE.DirectionalLight(lights.sun.color, lights.sun.intensity);
sunLight.position.set(...lights.sun.position);
this.scene.add(sunLight);
// 边缘光
const rimLight = new THREE.SpotLight(lights.rim.color, lights.rim.intensity);
rimLight.position.set(...lights.rim.position);
rimLight.lookAt(0, 0, 0);
this.scene.add(rimLight);
}
// 开场动画
startIntroSequence(uiElements) {
const animConfig = CONFIG.animation.intro;
const tl = gsap.timeline({
onComplete: () => {
this.isIntro = false; // 动画结束,允许交互
}
});
// A. 摄像机缓慢推进 (从 z=100 -> z=16)
tl.to(this.camera.position, {
z: CONFIG.scene.camera.defaultZ,
duration: animConfig.cameraDuration,
ease: "power2.out"
});
// B. UI 淡入 (标题和提示依次出现)
tl.to('.v1-title', {
opacity: 1,
duration: 1.5,
ease: "power2.out"
}, `-=${animConfig.titleDelay}`);
tl.to('.v1-subtitle', {
opacity: 1,
duration: 1.2,
ease: "power2.out"
}, `-=${animConfig.subtitleDelay}`);
tl.to('.instruction-hint', {
opacity: 1,
duration: 1.0,
ease: "power2.out"
}, `-=${animConfig.hintDelay}`);
}
// 初始化转场系统
initTransition(uiElements) {
this.transition = new Transition(
this.camera,
this.earthModel,
uiElements,
this.onTransitionComplete
);
}
// 绑定事件
bindEvents() {
// 鼠标移动
window.addEventListener('mousemove', (e) => this.onMouseMove(e));
// 鼠标点击
window.addEventListener('mousedown', () => this.onMouseDown());
// 触摸移动(移动端)
window.addEventListener('touchmove', (e) => this.onTouchMove(e), { passive: false });
// 触摸点击(移动端)
window.addEventListener('touchstart', (e) => this.onTouchStart(e));
// 窗口resize
window.addEventListener('resize', () => this.onWindowResize());
}
// 鼠标移动事件
onMouseMove(e) {
if (this.transition && this.transition.isActive()) return;
this.mouse.x = (e.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = -(e.clientY / window.innerHeight) * 2 + 1;
// 只有开场动画结束后才检测悬停
if (!this.isIntro) {
this.raycaster.setFromCamera(this.mouse, this.camera);
const intersects = this.raycaster.intersectObjects(
this.earthModel.getInteractiveObjects()
);
if (intersects.length > 0) {
if (!this.isHovering) {
this.isHovering = true;
this.container.classList.add('interactive');
gsap.to(this.earthModel.getAtmosphere().scale, {
x: 1.03,
y: 1.03,
z: 1.03,
duration: 0.3
});
}
} else {
if (this.isHovering) {
this.isHovering = false;
this.container.classList.remove('interactive');
gsap.to(this.earthModel.getAtmosphere().scale, {
x: 1,
y: 1,
z: 1,
duration: 0.3
});
}
}
}
// 视差效果
this.parallaxX = (e.clientX - window.innerWidth / 2) * 0.001;
this.parallaxY = (e.clientY - window.innerHeight / 2) * 0.001;
}
// 鼠标点击事件
onMouseDown() {
if (this.isIntro || !this.isHovering) return;
if (this.transition && this.transition.isActive()) return;
// 触发转场
if (this.transition) {
this.transition.trigger();
}
}
// 触摸移动事件(移动端)
onTouchMove(e) {
if (this.transition && this.transition.isActive()) return;
const touch = e.touches[0];
this.mouse.x = (touch.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = -(touch.clientY / window.innerHeight) * 2 + 1;
// 视差效果
this.parallaxX = (touch.clientX - window.innerWidth / 2) * 0.001;
this.parallaxY = (touch.clientY - window.innerHeight / 2) * 0.001;
}
// 触摸点击事件(移动端)
onTouchStart(e) {
if (this.isIntro) return;
if (this.transition && this.transition.isActive()) return;
const touch = e.touches[0];
this.mouse.x = (touch.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = -(touch.clientY / window.innerHeight) * 2 + 1;
// 检测是否点击地球
this.raycaster.setFromCamera(this.mouse, this.camera);
const intersects = this.raycaster.intersectObjects(
this.earthModel.getInteractiveObjects()
);
if (intersects.length > 0) {
// 触发转场
if (this.transition) {
this.transition.trigger();
}
}
}
// 窗口resize
onWindowResize() {
this.camera.aspect = window.innerWidth / window.innerHeight;
this.camera.updateProjectionMatrix();
this.renderer.setSize(window.innerWidth, window.innerHeight);
}
// 动画循环
animate() {
requestAnimationFrame(() => this.animate());
// 如果不在转场中
if (!this.transition || !this.transition.isActive()) {
// 地球和云层旋转
this.earthModel.rotate();
// 只有开场动画结束后才启用视差效果
if (!this.isIntro) {
this.camera.position.x += (this.parallaxX * 8 - this.camera.position.x) * 0.05;
this.camera.position.y += (-this.parallaxY * 8 - this.camera.position.y) * 0.05;
this.camera.lookAt(0, 0, 0);
}
}
this.renderer.render(this.scene, this.camera);
}
// 销毁场景
dispose() {
if (this.starSystem) this.starSystem.dispose();
if (this.earthModel) this.earthModel.dispose();
if (this.renderer) {
this.renderer.dispose();
this.container.removeChild(this.renderer.domElement);
}
}
}

100
js/scene/StarSystem.js Normal file
View File

@@ -0,0 +1,100 @@
/* ===================================
星空系统 - 彩色星星点缀
=================================== */
import { CONFIG } from '../config.js';
export class StarSystem {
constructor(scene) {
this.scene = scene;
this.stars = null;
this.init();
}
// 创建星星纹理
createStarTexture() {
const canvas = document.createElement('canvas');
canvas.width = 32;
canvas.height = 32;
const ctx = canvas.getContext('2d');
const grad = ctx.createRadialGradient(16, 16, 0, 16, 16, 16);
grad.addColorStop(0, 'rgba(255, 255, 255, 1)');
grad.addColorStop(0.4, 'rgba(255, 255, 255, 0.4)');
grad.addColorStop(1, 'rgba(255, 255, 255, 0)');
ctx.fillStyle = grad;
ctx.fillRect(0, 0, 32, 32);
return new THREE.Texture(canvas);
}
// 初始化星空
init() {
const starTexture = this.createStarTexture();
starTexture.needsUpdate = true;
const starGeo = new THREE.BufferGeometry();
const starCount = CONFIG.scene.stars.count;
const posArray = [];
const colorArray = [];
// 颜色调色板
const palette = CONFIG.scene.stars.colors.map(hex => new THREE.Color(hex));
// 生成星星位置和颜色
for (let i = 0; i < starCount; i++) {
posArray.push(
(Math.random() - 0.5) * 500,
(Math.random() - 0.5) * 500,
(Math.random() - 0.5) * 250 - 50
);
const c = palette[Math.floor(Math.random() * palette.length)];
colorArray.push(c.r, c.g, c.b);
}
starGeo.setAttribute('position', new THREE.Float32BufferAttribute(posArray, 3));
starGeo.setAttribute('color', new THREE.Float32BufferAttribute(colorArray, 3));
// 自定义着色器材质以支持彩色星星
const starMaterial = new THREE.ShaderMaterial({
uniforms: {
pointTexture: { value: starTexture }
},
vertexShader: `
attribute vec3 color;
varying vec3 vColor;
void main() {
vColor = color;
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = ${CONFIG.scene.stars.size} * (300.0 / -mvPosition.z);
gl_Position = projectionMatrix * mvPosition;
}
`,
fragmentShader: `
uniform sampler2D pointTexture;
varying vec3 vColor;
void main() {
gl_FragColor = vec4(vColor, 1.0) * texture2D(pointTexture, gl_PointCoord);
}
`,
blending: THREE.AdditiveBlending,
depthWrite: false,
transparent: true
});
this.stars = new THREE.Points(starGeo, starMaterial);
this.scene.add(this.stars);
}
// 更新(预留)
update() {
// 可以在这里添加星星的动态效果,比如闪烁
}
// 销毁
dispose() {
if (this.stars) {
this.stars.geometry.dispose();
this.stars.material.dispose();
this.scene.remove(this.stars);
}
}
}

104
js/scene/Transition.js Normal file
View File

@@ -0,0 +1,104 @@
/* ===================================
转场特效 - 从3D地球到2D地图的超空间跳跃
=================================== */
import { CONFIG } from '../config.js';
export class Transition {
constructor(camera, earthModel, uiElements, onComplete) {
this.camera = camera;
this.earthModel = earthModel;
this.uiElements = uiElements; // { uiLayer, hint, speedLines, cloudFog }
this.onComplete = onComplete;
this.isTransitioning = false;
}
// 触发超空间跳跃转场
trigger() {
if (this.isTransitioning) return;
this.isTransitioning = true;
// 获取UI元素
const { uiLayer, hint, speedLines, cloudFog } = this.uiElements;
// 0. UI 消失
uiLayer.style.opacity = 0;
hint.style.opacity = 0;
const earthGroup = this.earthModel.getGroup();
const clouds = this.earthModel.getClouds();
const atmosphere = this.earthModel.getAtmosphere();
// 创建GSAP时间线
const tl = gsap.timeline({
onComplete: () => {
this.isTransitioning = false;
if (this.onComplete) this.onComplete();
}
});
// 转场配置
const warpConfig = CONFIG.warp;
const transConfig = CONFIG.animation.transition;
// 1. 地球对齐 + 速度线出现
tl.to(earthGroup.rotation, {
y: warpConfig.targetRotationY,
x: warpConfig.targetRotationX,
duration: transConfig.earthRotation,
ease: "power2.inOut"
}, "start");
tl.to(speedLines, {
opacity: 1,
scale: 1.5,
duration: 1.0,
ease: "power1.in"
}, "start");
// 2. 镜头急速突进 (模拟穿过云层)
tl.to(this.camera.position, {
z: warpConfig.finalCameraZ,
x: 0,
y: 0,
duration: transConfig.cameraZoom,
ease: "expo.in",
onUpdate: () => {
// 镜头抖动效果 (Camera Shake) - 只在z<8时轻微抖动
const z = this.camera.position.z;
if (z < warpConfig.shakeThreshold.max && z > warpConfig.shakeThreshold.min) {
const intensity = warpConfig.shakeIntensity;
const shakeX = (Math.random() - 0.5) * intensity;
const shakeY = (Math.random() - 0.5) * intensity;
this.camera.position.x += shakeX;
this.camera.position.y += shakeY;
}
}
}, "start");
// 3. 材质变化:大气层和云层迅速变淡(为了不挡视线)
tl.to([clouds.material, atmosphere.material], {
opacity: 0,
duration: 0.5
}, "-=0.8");
// 4. "云雾吞噬"特效 (Backdrop Blur + Brightness)
tl.to(cloudFog, {
opacity: 1,
scale: 1.2,
backdropFilter: "blur(20px)",
duration: transConfig.fogFade,
ease: "power2.in"
}, "-=0.8");
}
// 重置转场状态
reset() {
this.isTransitioning = false;
}
// 检查是否正在转场
isActive() {
return this.isTransitioning;
}
}