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

@hhtrong/threelayer

v1.0.0

Published

Thư viện hiển thị và tương tác mô hình 3D trên [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/).

Readme

Mapbox3DLayer

Thư viện hiển thị và tương tác mô hình 3D trên Mapbox GL JS.

Cài đặt

npm install @hhtrong/threelayer mapbox-gl

Sử dụng

import mapboxgl from "mapbox-gl";
import "mapbox-gl/dist/mapbox-gl.css";

import { Mapbox3DLayer } from "@hhtrong/threelayer";

mapboxgl.accessToken = "YOUR_MAPBOX_ACCESS_TOKEN";

const map = new mapboxgl.Map({
  container: "map",
  style: "mapbox://styles/mapbox/streets-v12",
  center: [107.59939, 16.459356],
  zoom: 16,
  pitch: 60,
  bearing: 0,
  antialias: true,
});

const threelayer = new Mapbox3DLayer(undefined, {
  defaultLights: true,
  customLights: [],
  realSunlight: false,
  realSunlightHelper: false,
  passiveRendering: false,
  preserveDrawingBuffer: false,
  enableSelectingFeatures: false,
  enableSelectingObjects: true,
  enableDraggingObjects: false,
  enableRotatingObjects: false,
  enableTooltips: false,
  enableHelpTooltips: false,
  enableClippingPlanes: true,
  clippingPlane: false,
  clippingGround: 0,
  multiLayer: false,
  orthographic: false,
  fov: 45,
  sky: false,
  terrain: false,
  slot: "middle",
});

threelayer.addLayerTo(map);

await threelayer.ready();

threelayer.addModelToLayer({
  type: "ifc",
  obj: "../models/onecad.ifc",
  units: "meters",
  scale: 20,
  rotation: { x: 90, y: 0, z: 0 },
  position: [107.59939, 16.459356, 0],
  anchor: "bottom-center",
  bbox: true,
  groupId: "building",
  enableSelectFragment: true,
  enableHighlightFragment: true,
});

Constructor

new Mapbox3DLayer(layerId?, options)

| Tham số | Kiểu | Mô tả | | --------- | --------------------- | --------------------------------------------------------------------------- | | layerId | string \| undefined | ID của Mapbox layer. Không truyền hoặc truyền undefined sẽ tự động tạo ID | | options | DefaultThreeOptions | Cấu hình cho 3D layer |

Ví dụ:

const layer = new Mapbox3DLayer("building-layer", options);

Hoặc để thư viện tự tạo ID:

const layer = new Mapbox3DLayer(undefined, options);

Options

| Option | Kiểu | Mô tả | | ------------------------- | ----------------------------- | ------------------------------------- | | defaultLights | boolean | Sử dụng ánh sáng mặc định | | customLights | Array<{ color, intensity }> | Cấu hình ánh sáng tùy chỉnh | | realSunlight | boolean | Sử dụng ánh sáng mặt trời thực | | realSunlightHelper | boolean | Hiển thị helper của ánh sáng mặt trời | | passiveRendering | boolean | Bật passive rendering | | preserveDrawingBuffer | boolean | Giữ lại WebGL drawing buffer | | enableSelectingFeatures | boolean | Cho phép chọn feature trên bản đồ | | enableSelectingObjects | boolean | Cho phép chọn model 3D | | enableDraggingObjects | boolean | Cho phép di chuyển model 3D | | enableRotatingObjects | boolean | Cho phép xoay model 3D | | enableTooltips | boolean | Bật tooltip | | enableHelpTooltips | boolean | Bật tooltip label | | enableClippingPlanes | boolean | Bật clipping planes | | clippingPlane | boolean | Ẩn phần mô hình dưới giá trị mặt đất | | clippingGround | number | Giá trị mặt đất dùng cho clipping | | multiLayer | boolean | Bật chế độ multi-layer | | orthographic | boolean | Sử dụng orthographic camera | | fov | number | Field of View của camera | | sky | boolean | Bật Sky | | terrain | boolean | Bật Terrain | | slot | LayerSlot | Slot của Mapbox layer | | wasmPath | string | Đường dẫn tới WASM, không bắt buộc |

API

addLayerTo(map)

Thêm Mapbox3DLayer vào Mapbox:

threelayer.addLayerTo(map);

ready()

Chờ 3D layer khởi tạo hoàn tất:

await threelayer.ready();

Nên gọi trước khi thêm model.

addListener(event, callback)

Đăng ký event:

threelayer.addListener("added", () => {
  console.log("layer added");
});

addModelToLayer(options)

Thêm model vào 3D layer:

threelayer.addModelToLayer({
  type: "ifc",
  obj: "../models/onecad.ifc",
  units: "meters",
  scale: 20,
  rotation: { x: 90, y: 0, z: 0 },
  position: [107.59939, 16.459356, 0],
  anchor: "bottom-center",
  bbox: true,
  groupId: "building",
  enableSelectFragment: true,
  enableHighlightFragment: true,
});

Model options

| Option | Mô tả | | ------------------------- | ---------------------------------------- | | type | Loại model | | obj | Đường dẫn tới model | | units | Đơn vị của model | | scale | Tỷ lệ model | | rotation | Xoay theo x, y, z | | position | Vị trí [longitude, latitude, altitude] | | anchor | Điểm neo của model | | bbox | Hiển thị bounding box | | groupId | ID của group | | enableSelectFragment | Cho phép chọn Fragment IFC | | enableHighlightFragment | Cho phép highlight Fragment IFC |