初次提交

This commit is contained in:
blitheli 2024-08-13 18:56:27 +08:00
parent 7fb3956745
commit ac8482aa44
391 changed files with 846881 additions and 0 deletions

18
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,18 @@
// 使module
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}

227
CatalogSkybox.js Normal file
View File

@ -0,0 +1,227 @@
const CatalogSkybox = {
};
/**
* 由立方体盒子上的坐标(单位长度为2)转换为对应盒子面上的图片的坐标
*
* @param {number} x 立方盒子的x坐标,[-1,1]
* @param {number} y 立方盒子的y坐标,[-1,1]
* @param {number} z 立方盒子的z坐标,[-1,1]
* @returns {i,j,faceId} i为图片的x坐标(向右),[0,1],j为图片的y坐标(向下),[0,0]为图片的左上角
* faceId为图片的面id,[0,5]
*/
CatalogSkybox.cubeXyzToImgUV = function(x, y, z) {
let faceId, i, j;
if (x === -1) { // back
j = (1.0 - y) / 2.0;
i = (1.0 + z) / 2.0;
faceId = 0;
} else if (y === -1) { // left
i = (1.0 + x) / 2.0;
j = (1.0 - z) / 2.0;
faceId = 1;
} else if (x === 1) { // front
j = (1.0 - y) / 2.0;
i = (1.0 - z) / 2.0;
faceId = 2;
} else if (y === 1) { // right
i = (1.0 + x) / 2.0;
j = (1.0 + z) / 2.0;
faceId = 3;
} else if (z === 1) { // top
i = (1.0 + x) / 2.0;
j = (1.0 - y) / 2.0;
faceId = 4;
} else if (z === -1) { // bottom
i = (1.0 - x) / 2.0;
j = (1.0 - y) / 2.0;
faceId = 5;
}
else {
throw new Error("x,y,z其中一个必须为1或-1");
}
if (i > 1) {
i = 1;
}
if (i < 0) {
i = 0;
}
if (j > 1) {
j = 1;
}
if (j < 0) {
j = 0;
}
return { i, j, faceId };
}
const Pi1_4 = Math.PI / 4.0;
const Pi3_4 = 3 * Math.PI / 4.0;
/**
* 天球坐标系坐标(赤经,赤纬)转换为立方体盒子(单位为2上的坐标
*
* @param {number} theta 赤经,弧度,[-PI,PI]
* @param {number} phi 赤纬,弧度,[-PI/2,PI/2]
*/
CatalogSkybox.sphere2CubeXyz = function (theta, phi) {
// 计算笛卡尔坐标单位长度为1的球表面
let x = Math.cos(theta) * Math.cos(phi);
let y = Math.sin(theta) * Math.cos(phi);
let z = Math.sin(phi);
const tanPhi = Math.tan(phi);
let cosThe;
// 将笛卡尔坐标映射到立方体盒子(单位为2)上
// x = 1,或 z = 1,-1
if (theta >= -Pi1_4 && theta < Pi1_4) {
cosThe = Math.cos(theta);
if (tanPhi > cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = 1;
}
else if (tanPhi < -cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = -1;
}
else {
y = y / Math.abs(x);
z = z / Math.abs(x);
x = 1;
}
}
// y = 1,或 z = 1,-1
else if (theta >= Pi1_4 && theta < Pi3_4) {
cosThe = Math.cos(theta - Math.PI / 2);
if (tanPhi > cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = 1;
}
else if (tanPhi < -cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = -1;
}
else {
x = x / Math.abs(y);
z = z / Math.abs(y);
y = 1;
}
}
// x = -1,或 z = 1,-1
else if (theta >= Pi3_4 || theta < -Pi3_4) {
cosThe = Math.cos(theta - Math.PI);
if (tanPhi > cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = 1;
}
else if (tanPhi < -cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = -1;
}
else {
y = y / Math.abs(x);
z = z / Math.abs(x);
x = -1;
}
}
// y = -1,或 z = 1,-1
else if (theta >= -Pi3_4 && theta < -Pi1_4) {
cosThe = Math.cos(theta + Math.PI / 2);
if (tanPhi > cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = 1;
}
else if (tanPhi < -cosThe) {
x = x / Math.abs(z);
y = y / Math.abs(z);
z = -1;
}
else {
x = x / Math.abs(y);
z = z / Math.abs(y);
y = -1;
}
}
return { x, y, z };
}
/**
* 由立方体盒子某个面的图片坐标转换为对应立方盒子面的坐标
*
* @param {number} i 图片的x坐标(向右),[0,1]
* @param {number} j 图片的y坐标(向下),[0,0]为图片的左上角
* @param {number} faceId 立方盒子的面id,[0,5]
* @returns {x,y,z} 立方盒子的坐标,[-1,1]
*/
CatalogSkybox.imgUvToCubeXyz = function(i, j, faceId) {
/*
* 此函数被修改以适应cesium skybox的贴图
*/
let a = 2.0 * i ;
let b = 2.0 * j;
let x, y, z;
if (faceId === 0) { // back
// (x,y,z) = (-1.0, 1.0 - a, 1.0 - b);
x = -1.0;
y = 1.0 - b;
z = a - 1.0;
} else if (faceId === 1) { // left
x = a - 1.0;
y = -1.0;
z = 1.0 - b;
} else if (faceId === 2) { // front
// (x,y,z) = (1.0, a - 1.0, 1.0 - b);
x = 1.0;
y = 1.0 - b;
z = 1.0 - a;
} else if (faceId === 3) { // right
// (x,y,z) = (1.0 - a, 1.0, 1.0 - b);
x = a - 1.0;
y = 1.0;
z = b - 1.0;
} else if (faceId === 4) { // top
// (x,y,z) = (b - 1.0, a - 1.0, 1.0);
x = a - 1.0;
y = 1.0 - b;
z = 1.0;
} else if (faceId === 5) { // bottom
// (x,y,z) = (1.0 - b, a - 1.0, -1.0);
x = 1.0 - a;
y = 1.0 - b;
z = -1.0;
}
return { x, y, z };
}
/**
* 由立方体盒子上的坐标(单位长度为2)转换为赤经赤纬坐标
*
* @param {number} x 立方盒子的x坐标,[-1,1]
* @param {number} y 立方盒子的y坐标,[-1,1]
* @param {number} z 立方盒子的z坐标,[-1,1]
* @returns {theta, phi} theta为赤经,弧度,[-PI,PI],phi为赤纬,弧度,[-PI/2,PI/2]
*/
CatalogSkybox.cubeXyz2Sphere = function (x, y, z) {
let theta = Math.atan2(y, x);
let r = Math.sqrt(x * x + y * y);
let phi = Math.atan2(z, r);
return { theta, phi };
}
export default CatalogSkybox;

29
CatalogSkybox.test.js Normal file
View File

@ -0,0 +1,29 @@
import CatalogSkybox from "./CatalogSkybox.js";
// 测试CatalogSkybox相关函数的正向和反向转换
// 这个文件单独运行使用node方式运行
// 20240812 blitheli
// theta从-Pi到Piphi从-Pi/2到Pi/2
// theta取100个点phi取50个点
for (let ii = 0; ii < 100; ii++) {
let theta = -Math.PI + ii * Math.PI / 50.0;
for (let jj = 0; jj < 50; jj++) {
let phi = -Math.PI / 2.0 + jj * Math.PI / 50.0;
let { x, y, z } = CatalogSkybox.sphere2CubeXyz(theta, phi);
let { i, j, faceId } = CatalogSkybox.cubeXyzToImgUV(x, y, z);
// 反向转换
let { x1, y1, z1 } = CatalogSkybox.imgUvToCubeXyz(i, j, faceId);
let { thetap, phip } = CatalogSkybox.cubeXyz2Sphere(x1, y1, z1);
if (Math.abs(theta - thetap) > 0.0001 || Math.abs(phi - phip) > 0.0001) {
console.log("error", theta, phi, thetap, phip);
}
}
}
console.log("如果没有输出其它信息,那么表明测试成功了!!");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
<Title>NE2_HR_LC_SR_W_DR_recolored.tif</Title>
<Abstract></Abstract>
<SRS>EPSG:4326</SRS>
<BoundingBox miny="-90.00000000000000" minx="-180.00000000000000" maxy="90.00000000000000" maxx="180.00000000000000"/>
<Origin y="-90.00000000000000" x="-180.00000000000000"/>
<TileFormat width="256" height="256" mime-type="image/jpg" extension="jpg"/>
<TileSets profile="geodetic">
<TileSet href="0" units-per-pixel="0.70312500000000" order="0"/>
<TileSet href="1" units-per-pixel="0.35156250000000" order="1"/>
<TileSet href="2" units-per-pixel="0.17578125000000" order="2"/>
</TileSets>
</TileMap>

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Some files were not shown because too many files have changed in this diff Show More