Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fbx-parser

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fbx-parser

This parser will parse FBX text files and convert them into a JavaScript-Object structure.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
197
decreased by-49.87%
Maintainers
1
Weekly downloads
 
Created
Source

FBX Parser for JavaScript/TypeScript

npm npm bundle size GitHub Workflow Status

This parser will parse FBX text files and convert them into a JavaScript-Object structure.

Installation

npm install fbx-parser

Usage

import * as FBXParser from 'fbx-parser'

// when encoding is known
const fbx = parseText(fbxString)
const fbx = parseBinary(fbxUint8Array)

// when file encoding is unknown
import * as fs from 'fs'
const file = 'file.fbx'
let fbx: FBX
try {
  // try binary file encoding
  fbx = parse(await fs.readFileSync(file))
} catch (e) {
  // try text file encoding
  fbx = parse(await fs.readFileSync(file, 'utf-8'))
}

Calling the parser will return the same raw structure of the FBX file:

type FBX = FBXNode[]

interface FBXNode {
  name: string
  props: FBXProperty[]
  nodes: FBXNode[]
}

type FBXProperty = boolean | number | BigInt | boolean[] | number[] | BigInt[] | string
// Get Settings
const globalSettings = fbx.subnodes.find((v) => v.name === 'GlobalSettings')
const properties70 = globalSettings.subnodes.find((v) => v.name === 'Properties70')
const upAxis = properties70.subnodes.find((v) => v.name === 'P' && v.properties[0] === '"UpAxis"').properties[4]

const connections = fbx.subnodes.find((v) => v.name === 'Connections')
const connectionsOnRoot = connections.subnodes.filter((v) => v.properties[2] === '0')
for (const connection of connectionsOnRoot) {
  const objectId = connection.properties[1]
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Developer Documentation

FBX Documentation

Resources

Tools

Keywords

FAQs

Package last updated on 09 Feb 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc