three-earth-3d 1.0.0
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/LICENSE +21 -0
- package/README.en.md +303 -0
- package/README.md +303 -0
- package/bin/copy-assets.mjs +61 -0
- package/dist/three-earth-3d.es.js +8076 -0
- package/dist/three-earth-3d.umd.js +72 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/ts/Utils/Sizes.d.ts +33 -0
- package/dist/types/ts/Utils/arc.d.ts +11 -0
- package/dist/types/ts/Utils/common.d.ts +34 -0
- package/dist/types/ts/index.d.ts +1 -0
- package/dist/types/ts/interfaces/IEvents.d.ts +3 -0
- package/dist/types/ts/interfaces/IWord.d.ts +62 -0
- package/dist/types/ts/world/Assets.d.ts +16 -0
- package/dist/types/ts/world/Basic.d.ts +15 -0
- package/dist/types/ts/world/Data.d.ts +13 -0
- package/dist/types/ts/world/Earth.d.ts +100 -0
- package/dist/types/ts/world/Resources.d.ts +13 -0
- package/dist/types/ts/world/Word.d.ts +29 -0
- package/package.json +56 -0
- package/static/images/earth/aircraft.png +0 -0
- package/static/images/earth/aperture.png +0 -0
- package/static/images/earth/earth.jpg +0 -0
- package/static/images/earth/glow.png +0 -0
- package/static/images/earth/gradient.png +0 -0
- package/static/images/earth/label-old.png +0 -0
- package/static/images/earth/label.png +0 -0
- package/static/images/earth/light_column.png +0 -0
- package/static/images/earth/redCircle.png +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 屏幕尺寸
|
|
3
|
+
*/
|
|
4
|
+
import { EventEmitter } from 'pietile-eventemitter';
|
|
5
|
+
import { IEvents } from '../interfaces/IEvents';
|
|
6
|
+
type options = {
|
|
7
|
+
dom: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
export default class Sizes {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
viewport: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
$sizeViewport: HTMLElement;
|
|
17
|
+
emitter: EventEmitter<IEvents>;
|
|
18
|
+
/**
|
|
19
|
+
* Constructor
|
|
20
|
+
*/
|
|
21
|
+
constructor(options: options);
|
|
22
|
+
/**
|
|
23
|
+
* 目前用于监听历史记录执行 historyChange
|
|
24
|
+
* @param event 事件
|
|
25
|
+
* @param fun 执行
|
|
26
|
+
*/
|
|
27
|
+
$on<T extends keyof IEvents>(event: T, fun: () => void): void;
|
|
28
|
+
/**
|
|
29
|
+
* Resize
|
|
30
|
+
*/
|
|
31
|
+
resize(): void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BufferGeometry, Line, LineBasicMaterial } from 'three';
|
|
2
|
+
/**输入地球上任意两点的经纬度坐标,通过函数flyArc可以绘制一个飞线圆弧轨迹
|
|
3
|
+
* lon1,lat1:轨迹线起点经纬度坐标
|
|
4
|
+
* lon2,lat2:轨迹线结束点经纬度坐标
|
|
5
|
+
*/
|
|
6
|
+
declare function flyArc(radius: any, lon1: any, lat1: any, lon2: any, lat2: any, options: any): Line<BufferGeometry, LineBasicMaterial>;
|
|
7
|
+
/**通过函数arcXOY()可以在XOY平面上绘制一个关于y轴对称的圆弧曲线
|
|
8
|
+
* startPoint, endPoint:表示圆弧曲线的起点和结束点坐标值,起点和结束点关于y轴对称
|
|
9
|
+
* 同时在圆弧轨迹的基础上绘制一段飞线*/
|
|
10
|
+
declare function arcXOY(radius: any, startPoint: any, endPoint: any, options: any): Line<BufferGeometry, LineBasicMaterial>;
|
|
11
|
+
export { arcXOY, flyArc };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Group, Mesh, MeshBasicMaterial, PlaneBufferGeometry, Texture, TubeGeometry, Vector3 } from "three";
|
|
2
|
+
import { punctuation } from "../world/Earth";
|
|
3
|
+
/**
|
|
4
|
+
* 经纬度坐标转球面坐标
|
|
5
|
+
* @param {地球半径} R
|
|
6
|
+
* @param {经度(角度值)} longitude
|
|
7
|
+
* @param {维度(角度值)} latitude
|
|
8
|
+
*/
|
|
9
|
+
export declare const lon2xyz: (R: number, longitude: number, latitude: number) => Vector3;
|
|
10
|
+
export declare const createWaveMesh: (options: {
|
|
11
|
+
radius;
|
|
12
|
+
lon;
|
|
13
|
+
lat;
|
|
14
|
+
textures;
|
|
15
|
+
}) => Mesh<PlaneBufferGeometry, MeshBasicMaterial>;
|
|
16
|
+
export declare const createLightPillar: (options: {
|
|
17
|
+
radius: number;
|
|
18
|
+
lon: number;
|
|
19
|
+
lat: number;
|
|
20
|
+
index: number;
|
|
21
|
+
textures: Record<string, Texture>;
|
|
22
|
+
punctuation: punctuation;
|
|
23
|
+
}) => Group;
|
|
24
|
+
export declare const createPointMesh: (options: {
|
|
25
|
+
radius: number;
|
|
26
|
+
lon: number;
|
|
27
|
+
lat: number;
|
|
28
|
+
material: MeshBasicMaterial;
|
|
29
|
+
}) => Mesh<PlaneBufferGeometry, MeshBasicMaterial>;
|
|
30
|
+
export declare const getCirclePoints: (option: any) => any[];
|
|
31
|
+
/**
|
|
32
|
+
* 创建动态的线
|
|
33
|
+
*/
|
|
34
|
+
export declare const createAnimateLine: (option: any) => Mesh<TubeGeometry, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface EarthCityPoint {
|
|
2
|
+
name: string;
|
|
3
|
+
/** 经度 */
|
|
4
|
+
E: number;
|
|
5
|
+
/** 纬度 */
|
|
6
|
+
N: number;
|
|
7
|
+
}
|
|
8
|
+
export interface EarthRouteData {
|
|
9
|
+
startArray: EarthCityPoint;
|
|
10
|
+
endArray: EarthCityPoint[];
|
|
11
|
+
}
|
|
12
|
+
export interface IWord {
|
|
13
|
+
/** 挂载目标 DOM 元素 */
|
|
14
|
+
dom: HTMLElement;
|
|
15
|
+
/** 地球创建完成、入场动画开始后触发 */
|
|
16
|
+
onReady?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* 静态资源基础路径,末尾不需要斜杠
|
|
19
|
+
* 包内默认图片放在 static/images/earth/ 下
|
|
20
|
+
* 消费方可以把图片复制到自己的 public 目录,然后传入对应前缀
|
|
21
|
+
* @default ''
|
|
22
|
+
*/
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
/** 自定义路线数据,不传则使用内置示例数据 */
|
|
25
|
+
data?: EarthRouteData[];
|
|
26
|
+
earth?: {
|
|
27
|
+
/** 地球半径,默认 50 */
|
|
28
|
+
radius?: number;
|
|
29
|
+
/** 自转速度,默认 0.002 */
|
|
30
|
+
rotateSpeed?: number;
|
|
31
|
+
/** 是否自转,默认 true */
|
|
32
|
+
isRotation?: boolean;
|
|
33
|
+
};
|
|
34
|
+
satellite?: {
|
|
35
|
+
/** 是否显示卫星,默认 true */
|
|
36
|
+
show?: boolean;
|
|
37
|
+
/** 卫星轨道旋转速度,默认 -0.01 */
|
|
38
|
+
rotateSpeed?: number;
|
|
39
|
+
/** 卫星球体大小,默认 1 */
|
|
40
|
+
size?: number;
|
|
41
|
+
/** 每条轨道几颗卫星,默认 2 */
|
|
42
|
+
number?: number;
|
|
43
|
+
};
|
|
44
|
+
punctuation?: {
|
|
45
|
+
/** 光柱底座圆圈颜色,默认 0x3892ff */
|
|
46
|
+
circleColor?: number;
|
|
47
|
+
lightColumn?: {
|
|
48
|
+
/** 起点光柱颜色,默认 0xffffff */
|
|
49
|
+
startColor?: number;
|
|
50
|
+
/** 终点光柱颜色,默认 0xff0000 */
|
|
51
|
+
endColor?: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
flyLine?: {
|
|
55
|
+
/** 轨迹线颜色,默认 0xd18547 */
|
|
56
|
+
color?: number;
|
|
57
|
+
/** 飞线拖尾速度,默认 0.004 */
|
|
58
|
+
speed?: number;
|
|
59
|
+
/** 飞线颜色,默认 0xff7714 */
|
|
60
|
+
flyLineColor?: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资源文件列表
|
|
3
|
+
*/
|
|
4
|
+
interface ITextures {
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IResources {
|
|
9
|
+
textures?: ITextures[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 根据 baseUrl 生成资源列表
|
|
13
|
+
* @param baseUrl 静态资源根路径,例如 '' 或 'https://cdn.example.com'
|
|
14
|
+
*/
|
|
15
|
+
export declare function getResources(baseUrl?: string): IResources;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建 Three.js 四大件:场景、相机、渲染器、控制器
|
|
3
|
+
*/
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
6
|
+
export declare class Basic {
|
|
7
|
+
scene: THREE.Scene;
|
|
8
|
+
camera: THREE.PerspectiveCamera;
|
|
9
|
+
renderer: THREE.WebGLRenderer;
|
|
10
|
+
controls: OrbitControls;
|
|
11
|
+
dom: HTMLElement;
|
|
12
|
+
constructor(dom: HTMLElement);
|
|
13
|
+
private initScenes;
|
|
14
|
+
private setControls;
|
|
15
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { BufferGeometry, Color, Group, Mesh, MeshBasicMaterial, Object3D, Points, PointsMaterial, ShaderMaterial, SphereBufferGeometry, Texture } from "three";
|
|
2
|
+
export type punctuation = {
|
|
3
|
+
circleColor: number;
|
|
4
|
+
lightColumn: {
|
|
5
|
+
startColor: number;
|
|
6
|
+
endColor: number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type options = {
|
|
10
|
+
data: {
|
|
11
|
+
startArray: {
|
|
12
|
+
name: string;
|
|
13
|
+
E: number;
|
|
14
|
+
N: number;
|
|
15
|
+
};
|
|
16
|
+
endArray: {
|
|
17
|
+
name: string;
|
|
18
|
+
E: number;
|
|
19
|
+
N: number;
|
|
20
|
+
}[];
|
|
21
|
+
}[];
|
|
22
|
+
dom: HTMLElement;
|
|
23
|
+
textures: Record<string, Texture>;
|
|
24
|
+
earth: {
|
|
25
|
+
radius: number;
|
|
26
|
+
rotateSpeed: number;
|
|
27
|
+
isRotation: boolean;
|
|
28
|
+
};
|
|
29
|
+
satellite: {
|
|
30
|
+
show: boolean;
|
|
31
|
+
rotateSpeed: number;
|
|
32
|
+
size: number;
|
|
33
|
+
number: number;
|
|
34
|
+
};
|
|
35
|
+
punctuation: punctuation;
|
|
36
|
+
flyLine: {
|
|
37
|
+
color: number;
|
|
38
|
+
speed: number;
|
|
39
|
+
flyLineColor: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type uniforms = {
|
|
43
|
+
glowColor: {
|
|
44
|
+
value: Color;
|
|
45
|
+
};
|
|
46
|
+
scale: {
|
|
47
|
+
type: string;
|
|
48
|
+
value: number;
|
|
49
|
+
};
|
|
50
|
+
bias: {
|
|
51
|
+
type: string;
|
|
52
|
+
value: number;
|
|
53
|
+
};
|
|
54
|
+
power: {
|
|
55
|
+
type: string;
|
|
56
|
+
value: number;
|
|
57
|
+
};
|
|
58
|
+
time: {
|
|
59
|
+
type: string;
|
|
60
|
+
value: any;
|
|
61
|
+
};
|
|
62
|
+
isHover: {
|
|
63
|
+
value: boolean;
|
|
64
|
+
};
|
|
65
|
+
map: {
|
|
66
|
+
value: Texture;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export default class earth {
|
|
70
|
+
group: Group;
|
|
71
|
+
earthGroup: Group;
|
|
72
|
+
around: BufferGeometry;
|
|
73
|
+
aroundPoints: Points<BufferGeometry, PointsMaterial>;
|
|
74
|
+
options: options;
|
|
75
|
+
uniforms: uniforms;
|
|
76
|
+
timeValue: number;
|
|
77
|
+
earth: Mesh<SphereBufferGeometry, ShaderMaterial>;
|
|
78
|
+
punctuationMaterial: MeshBasicMaterial;
|
|
79
|
+
markupPoint: Group;
|
|
80
|
+
waveMeshArr: Object3D[];
|
|
81
|
+
circleLineList: any[];
|
|
82
|
+
circleList: any[];
|
|
83
|
+
x: number;
|
|
84
|
+
n: number;
|
|
85
|
+
isRotation: boolean;
|
|
86
|
+
flyLineArcGroup: Group;
|
|
87
|
+
constructor(options: options);
|
|
88
|
+
init(): Promise<void>;
|
|
89
|
+
createEarth(): void;
|
|
90
|
+
createStars(): void;
|
|
91
|
+
createEarthGlow(): void;
|
|
92
|
+
createEarthAperture(): void;
|
|
93
|
+
createMarkupPoint(): Promise<void>;
|
|
94
|
+
createSpriteLabel(): Promise<void>;
|
|
95
|
+
createAnimateCircle(): void;
|
|
96
|
+
createFlyLine(): void;
|
|
97
|
+
show(): void;
|
|
98
|
+
render(): void;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资源管理和加载
|
|
3
|
+
*/
|
|
4
|
+
import { Texture } from 'three';
|
|
5
|
+
export declare class Resources {
|
|
6
|
+
private manager;
|
|
7
|
+
private callback;
|
|
8
|
+
private textureLoader;
|
|
9
|
+
textures: Record<string, Texture>;
|
|
10
|
+
constructor(callback: () => void, baseUrl?: string);
|
|
11
|
+
private setLoadingManager;
|
|
12
|
+
private loadResources;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MeshBasicMaterial, PerspectiveCamera, Scene, ShaderMaterial, WebGLRenderer } from 'three';
|
|
2
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
|
3
|
+
import { IWord } from '../interfaces/IWord';
|
|
4
|
+
import { Basic } from './Basic';
|
|
5
|
+
import Sizes from '../Utils/Sizes';
|
|
6
|
+
import { Resources } from './Resources';
|
|
7
|
+
import Earth from './Earth';
|
|
8
|
+
export default class World {
|
|
9
|
+
basic: Basic;
|
|
10
|
+
scene: Scene;
|
|
11
|
+
camera: PerspectiveCamera;
|
|
12
|
+
renderer: WebGLRenderer;
|
|
13
|
+
controls: OrbitControls;
|
|
14
|
+
sizes: Sizes;
|
|
15
|
+
material: ShaderMaterial | MeshBasicMaterial;
|
|
16
|
+
resources: Resources;
|
|
17
|
+
option: IWord;
|
|
18
|
+
earth: Earth;
|
|
19
|
+
/** html2canvas 需要一个隐藏容器,由库自动创建并在 dispose 时清理 */
|
|
20
|
+
private _html2canvasEl;
|
|
21
|
+
private _animFrameId;
|
|
22
|
+
constructor(option: IWord);
|
|
23
|
+
/** 自动在 body 上注入 html2canvas 所需的隐藏容器 */
|
|
24
|
+
private _createHtml2CanvasEl;
|
|
25
|
+
createEarth(): Promise<void>;
|
|
26
|
+
render(): void;
|
|
27
|
+
/** 销毁实例,释放所有资源和事件监听 */
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "three-earth-3d",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "3D Earth visualization component built with Three.js — mount to any DOM element",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"threejs",
|
|
7
|
+
"3d",
|
|
8
|
+
"earth",
|
|
9
|
+
"typescript",
|
|
10
|
+
"visualization",
|
|
11
|
+
"globe"
|
|
12
|
+
],
|
|
13
|
+
"author": "GhostCat",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/three-earth-3d.umd.js",
|
|
17
|
+
"module": "dist/three-earth-3d.es.js",
|
|
18
|
+
"types": "dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/three-earth-3d.es.js",
|
|
22
|
+
"require": "./dist/three-earth-3d.umd.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"three-earth-3d": "bin/copy-assets.mjs"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"static",
|
|
31
|
+
"bin"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "vite",
|
|
35
|
+
"build": "vite build && pnpm build:types",
|
|
36
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
37
|
+
"build:demo": "vite build --config vite.demo.config.ts",
|
|
38
|
+
"preview": "vite build --config vite.demo.config.ts && vite preview --config vite.demo.config.ts"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"three": ">=0.130.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@rollup/pluginutils": "^5.3.0",
|
|
45
|
+
"@types/three": "^0.143.0",
|
|
46
|
+
"typescript": "^4.1.3",
|
|
47
|
+
"vite": "^5.0.0",
|
|
48
|
+
"vite-plugin-glsl": "^1.3.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"gsap": "^3.7.1",
|
|
52
|
+
"html2canvas": "^1.4.1",
|
|
53
|
+
"pietile-eventemitter": "^1.0.1",
|
|
54
|
+
"three": "^0.143"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|