npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@luothink/three-gis-kit

v1.0.0

Published

A utility library for three.js GIS, including CSG operations, coordinate transformation, geometry calculations and pipe modeling.

Readme

@luothink/three-gis-kit

A utility library for three.js GIS calculations.

Installation

npm install @luothink/three-gis-kit

Usage

import { CSGUtils, GeometryUtils, GeoCoordUtils, GISUtils } from '@luothink/three-gis-kit';

API

CSGUtils

提供 CSG (three-bvh-csg) 布尔运算功能。

performCSG(THREE, CSG, meshA, meshB, operation)

执行 CSG 布尔运算。

| 参数 | 类型 | 说明 | |------|------|------| | THREE | Object | THREE.js 库对象 | | CSG | Object | CSG 库对象 (three-bvh-csg) | | meshA | Mesh | 待运算的 Mesh 对象 A | | meshB | Mesh | 待运算的 Mesh 对象 B | | operation | String | 运算操作 |

operation 可选值:

  • union - 并集 (A ∪ B)
  • subtract - 差集 (A - B)
  • intersect - 交集 (A ∩ B)
  • difference - 对称差集 (A ⊕ B)
  • reverse_subtraction - 反向差集 (B - A)
  • hollow_subtract - 空心差集
  • hollow_intersection - 空心交集
import { CSGUtils } from '@luothink/three-gis-kit';
import * as THREE from 'three';
import * as CSG from 'three-bvh-csg';

const resultMesh = CSGUtils.performCSG(THREE, CSG, meshA, meshB, 'subtract');

GeoCoordUtils

提供 GIS 坐标转换功能,包括经纬度、墨卡托、世界坐标的转换。

lonLatToMercator(lng, lat, alt?)

将经纬度转换为墨卡托投影坐标。

import { GeoCoordUtils } from '@luothink/three-gis-kit';

const mercator = GeoCoordUtils.lonLatToMercator(121.543793, 29.868336);
// { x: 13528332.56, y: 3503547.56, z: 0 }

mercatorToLonLat(x, y, z?)

将墨卡托投影坐标转换为经纬度。

const lnglat = GeoCoordUtils.mercatorToLonLat(13528332.56, 3503547.56);
// { x: 121.543793, y: 29.868336, z: 0 }

lonLatToWorld(lng, lat, alt?)

将经纬度转换为世界坐标 (Three.js 坐标系)。

const world = GeoCoordUtils.lonLatToWorld(121.543793, 29.868336, 100);
// { x: 13528332.56, y: 100, z: -3503547.56 }

worldToLonLat(x, y, z)

将世界坐标转换为经纬度。

const lnglat = GeoCoordUtils.worldToLonLat(13528332.56, 100, -3503547.56);
// { x: 121.543793, y: 29.868336, z: 100 }

mercatorToWorld(x, y, alt?)

将墨卡托投影坐标转换为世界坐标。

worldToMercator(x, y, z)

将世界坐标转换为墨卡托投影坐标。


GISUtils

提供 GIS 相关的实用工具函数。

calcDistance(start, end, ignoreAltitude?)

计算两点之间的距离(考虑海拔高度)。

| 参数 | 类型 | 说明 | |------|------|------| | start | {x, y, z} | 起点坐标 | | end | {x, y, z} | 终点坐标 | | ignoreAltitude | Boolean | 是否忽略海拔,默认 false |

import { GISUtils } from '@luothink/three-gis-kit';

const start = { x: 121.543793, y: 29.868336, z: 0 };
const end = { x: 121.553793, y: 29.878336, z: 50 };
const distance = GISUtils.calcDistance(start, end);
// 返回距离(米)

calcPipeLength_ar(start, end, THREE)

计算 3D 管长(圆柱体高度)。

const length = GISUtils.calcPipeLength_ar(start, end, THREE);

degreesToDMS(degrees, isLongitude?)

将十进制度数转换为度分秒 (DMS) 格式。

const result = GISUtils.degreesToDMS(121.543793, true);
console.log(result.toString()); // "121°32'37.6548\"E"

toRadian(degrees)

角度转弧度。

toDegree(radians)

弧度转角度。


GeometryUtils

提供几何计算功能。

lineToCylinder(THREE, startingPoint, endPoint, radiusStart, radiusEnd, material, radiusIncrement?, pipeLength_ar)

将两点之间的线段转换为圆柱体(管道)模型。

import { GeometryUtils } from '@luothink/three-gis-kit';
import * as THREE from 'three';

const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const start = { x: 0, y: 0, z: 0 };
const end = { x: 10, y: 10, z: 10 };
const pipeLength = 17.32;

const cylinder = GeometryUtils.lineToCylinder(
  THREE, start, end, 0.5, 0.5, material, 0, pipeLength
);

adjustLineLength(startPoint, endPoint, pipeLength, newLength, fixedPoint?)

调整管道长度(保持方向不变)。

| 参数 | 类型 | 说明 | |------|------|------| | startPoint | {x, y, z} | 起点坐标 | | endPoint | {x, y, z} | 终点坐标 | | pipeLength | Number | 当前管道长度 | | newLength | Number | 目标长度 | | fixedPoint | String | 固定点: "start" 或 "end" |

const result = GeometryUtils.adjustLineLength(
  { x: 0, y: 0, z: 0 },
  { x: 10, y: 0, z: 0 },
  10,
  20,
  'start'
);
// { start: {x:0, y:0, z:0}, end: {x:20, y:0, z:0} }

License

ISC# @luothink/three-gis-kit

A utility library for three.js GIS calculations.

Installation

npm install @luothink/three-gis-kit

Usage

import { /* your exports */ } from '@luothink/three-gis-kit';

// 使用示例

API

  • CSGUtils
  • GeometryUtils
  • GeoCoordUtils
  • GISUtils

License

ISC