New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@3ditles/glb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@3ditles/glb

A TypeScript library for parsing and processing GLB 3D model files

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

@3dtiles/glb

A TypeScript library for parsing and processing GLB 3D model files.

Features

  • Parse GLB files into structured data
  • Validate GLB file integrity and structure
  • Serialize GLB data back into binary format
  • Support for GLB version 2
  • Handle both JSON and binary chunks

Installation

npm install @3dtiles/glb

Usage

Parsing a GLB file

import { parseGLB, validateGLB } from '@3dtiles/glb';
import { readFileSync } from 'fs';

// Read GLB file as binary
const data = readFileSync('model.glb');
const glbFile = parseGLB(new Uint8Array(data.buffer));

// Validate the parsed file
if (validateGLB(glbFile)) {
  console.log('Valid GLB file');
  console.log('JSON content:', glbFile.jsonContent);
  console.log('Has binary chunk:', !!glbFile.binaryChunk);
} else {
  console.error('Invalid GLB file');
}

Serializing a GLB file

import { serializeGLB, GLBFile } from '@3dtiles/glb';
import { writeFileSync } from 'fs';

// Create or modify a GLBFile object
const glbFile: GLBFile = {
  header: {
    magic: 0x46546C67,
    version: 2,
    length: 0 // Will be calculated automatically
  },
  jsonContent: {
    scenes: [{ nodes: [] }],
    nodes: []
  },
  // ... add other chunks as needed
};

// Serialize to binary
const binaryData = serializeGLB(glbFile);

// Write to file
writeFileSync('new-model.glb', binaryData);

API

parseGLB(data: Uint8Array): GLBFile

Parses binary data into a GLBFile structure.

validateGLB(file: GLBFile): boolean

Validates the structure and integrity of a parsed GLBFile.

serializeGLB(file: GLBFile): Uint8Array

Serializes a GLBFile back into binary format.

GLBParser class

Provides the core functionality with methods:

  • parse(data: Uint8Array): GLBFile
  • validate(file: GLBFile): boolean
  • serialize(file: GLBFile): Uint8Array

License

MIT

Keywords

glb

FAQs

Package last updated on 10 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts