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

@nebula-spatial/cad-loader

v0.2.0

Published

Browser-side DXB3/DXBS CAD pack loader runtime

Readme

@nebula-spatial/cad-loader

浏览器侧 DXB3/DXBS CAD pack 加载运行时。负责解析文档、构建 Three.js 渲染资源,并 提供图层、INSERT、文本和外部资源的文档级访问能力。

有完整视图需求的应用通常通过 @nebula-spatial/viewerviewer.cad.open() 接入。 本包适用于需要自行管理 Three.js 场景或 CAD 文档生命周期的集成。

文档会话

createCadDocumentSession() 是推荐的文档级入口。会话提供 header、基础内容就绪状态、 视口需求和只读渲染资源;调用方负责场景挂载和相机/视口同步。

import {
  createCadDocumentSession,
  getCadDocumentRenderResource,
} from '@nebula-spatial/cad-loader';

const session = createCadDocumentSession('/api/files/demo/result', {
  filename: 'demo.dxf',
});
const renderNode = getCadDocumentRenderResource(session);

scene.add(renderNode.object);
const stopChanges = renderNode.onChange(() => requestRender());

const header = await session.headerReady;
fitCamera(header.bounds);

session.setDisplayContext(displayContext);
session.setViewportDemand(viewportDemand);
await session.initialContentReady;

stopChanges();
scene.remove(renderNode.object);
session.dispose();

headerReady 提供文档边界和图层元数据,initialContentReady 表示基础内容已可用。 通过 content-appendeddemand-progressphase-change 和错误事件可监听后续变化。

CadRenderNode 是只读渲染资源。选择状态、属性面板、编辑命令和历史记录由产品层维护。

其他入口

  • loadGeo():简单的 GeoNode 增量加载。适合不需要文档会话的 Three.js 集成。
  • createLoadSession():以异步事件流消费 CAD pack,适合自定义渲染器或流量控制。
  • @nebula-spatial/cad-loader/core:不依赖 Three.js、DOM 或 WebGL 的协议解析 API,可用于 Worker、Node.js 和 CLI。
import { loadGeo } from '@nebula-spatial/cad-loader';

const node = loadGeo('/api/files/demo/result');
scene.add(node);
node.setViewportSize(canvas.clientWidth, canvas.clientHeight);
await node.ready;

默认 Worker 使用包内 ESM 资源路径。使用非 Vite bundler 或自行托管 Worker 资源时,可通过 LoadGeoOptions.workerUrlworkerFactory 配置 Worker 创建方式。

边界

本包不处理上传、任务轮询、文件目录或原始 DXF/DWG 解析。运行时依赖为 three peer dependency,要求 Node.js 18 或更高版本。

开发

npm run typecheck --workspace @nebula-spatial/cad-loader
npm test --workspace @nebula-spatial/cad-loader
npm run build --workspace @nebula-spatial/cad-loader