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

@x-viewer/core

v0.21.21

Published

WebGL-based 2D/3D viewer engine built on Three.js. View DWG/DXF/PDF files in the browser with no server required. Supports glTF, OBJ, FBX, IFC, STL and BimTiles formats.

Readme

@x-viewer/core

npm version npm downloads License

WebGL-based 2D/3D viewer engine built on Three.js. View DWG, DXF, glTF, OBJ, FBX, IFC, STL and PDF files directly in the browser — no server required.

Built with @x-viewer/core

| Application | Description | |---|---| | cad.thingraph.site | CAD viewer — View 2D(DWG, DXF) & 3D CAD models(glTF, GLB, OBJ, FBX, STL) directly in your browser | | drive.thingraph.site | DWG viewer - View DWG/DXF files directly in Google Drive | | dwg.thingraph.site | Live SDK examples and demos |

Features

  • High-performance 2D rendering: WebGL-based rendering engine built on Three.js
  • DWG/DXF support: Parse and render DWG/DXF files entirely in the browser via WebAssembly (libredwg), no backend needed
  • Paper space & layouts: Renders AutoCAD paper space layouts, viewports, and layer freeze
  • Hatch patterns: GPU-rendered AutoCAD hatch patterns (ANSI, ISO, AR-* series)
  • 3D formats: glTF/GLB, OBJ, FBX, IFC, STL, DAE, BimTiles
  • PDF viewer: Render PDF files in the browser
  • CAD comparison: Diff two DWG/DXF files with color-coded changes
  • Measurements & markup: Distance, area, angle tools with snapping; freehand and geometric annotations
  • Modular architecture: Designed for extensibility and seamless integration
  • TypeScript: Full TypeScript support with comprehensive type definitions

Installation

npm install @x-viewer/core
# or
pnpm add @x-viewer/core
# or
yarn add @x-viewer/core

Quick Start

Viewer2d — DWG/DXF Viewer

import { Viewer2d } from "@x-viewer/core";

const viewer = new Viewer2d({
    containerId: "myCanvas",
    enableSpinner: true,
    enableLayoutBar: true,
});

await viewer.loadModel({
    modelId: "id_0",
    name: "sample",
    src: "https://example.com/sample.dwg",
});

viewer.goToHomeView();

Viewer3d — 3D Model Viewer

import { Viewer3d, THREE } from "@x-viewer/core";

const viewer = new Viewer3d({ containerId: "myCanvas" });

await viewer.loadModel({
    modelId: "model_1",
    src: "./models/building.gltf",
    fileFormat: "gltf",
});

viewer.cameraManager.flyToViewpoint({
    eye: new THREE.Vector3(100, 50, 100),
    look: new THREE.Vector3(0, 0, 0),
});

Supported File Formats

2D Formats

| Format | Description | |---|---| | DWG | AutoCAD Drawing (all versions, via libredwg/WebAssembly) | | DXF | AutoCAD Drawing Exchange Format (ASCII and Binary) | | PDF | PDF files with vector graphics |

3D Formats

| Format | Description | |---|---| | glTF / GLB | glTF 2.0 | | OBJ | Wavefront OBJ (with MTL materials) | | FBX | Autodesk FBX | | STL | Stereolithography | | DAE | COLLADA | | IFC | Industry Foundation Classes (BIM; load via @x-viewer/plugins) | | 3DM | Rhinoceros 3DM (OpenNURBS; load via @x-viewer/plugins) |

API Examples

Loading with Progress

await viewer.loadModel(
    { modelId: "m1", src: "./drawing.dwg" },
    (event) => {
        const pct = (event.loaded / event.total) * 100;
        console.log(`${pct.toFixed(0)}%`);
    }
);

Layer Management (Viewer2d)

const layers = viewer.getLayers();
viewer.setLayerVisible("Layer1", false);
viewer.setLayerColor("Layer1", new THREE.Color(1, 0, 0));

CAD Comparison

import { DxfCompareHelper } from "@x-viewer/core";

const helper = new DxfCompareHelper(viewer);
await helper.compare(
    { modelId: "v1", src: "./rev1.dxf" },
    { modelId: "v2", src: "./rev2.dxf" },
    {
        addedColor: new THREE.Color(0, 1, 0),   // green = added
        removedColor: new THREE.Color(1, 0, 0), // red = removed
    }
);

Camera Control

viewer.cameraManager.setProjection(CameraProjection.Perspective);
viewer.cameraManager.flyToViewpoint({ eye, look });
viewer.zoomToBBox(new THREE.Box3(min, max));

Using Three.js

Import Three.js from this package to avoid version conflicts:

import { THREE, THREEAddons } from "@x-viewer/core";

const vector = new THREE.Vector3(0, 0, 0);
viewer.zoomToBBox(new THREE.Box3(min, max));

Coordinate System & Units

  • Coordinate system: Right-handed, Y-up (consistent with Three.js and glTF)
    • +X: right | -X: left
    • +Y: up | -Y: down
    • +Z: front (out of screen) | -Z: back (into screen)
  • Length: Meter | Area: m² | Angle: Degrees, CCW | Time: Milliseconds

Performance

  • Geometry batching to minimize draw calls
  • Instanced rendering for repeated elements
  • Material caching across entities
  • Custom GLSL shaders for GPU-accelerated hatch patterns
  • Spatial indexing for fast picking and culling

Known Limitations

  • DWG table entities are not fully supported (LibreDWG limitation)
  • External references (XRefs) are not supported
  • Some DWG files may fail to open due to LibreDWG limitations

Links

Related Packages

  • @x-viewer/plugins — Measurement, markup, toolbar, layer panel and more
  • @x-viewer/ui — Reusable UI components

License

UNLICENSED — contact [email protected] for licensing inquiries.