open-index/open-npm huggingface dataset:
npm package: @keupoz/mson-core
Description: Core package of TypeScript MSON port
Latest version: 1.3.0

# `mson-core`

This the core package of [Mson](https://github.com/MineLittlePony/Mson) TypeScript port used to load and parse Mson files.

## Installation

```sh
npm install @keupoz/mson-core
```

## Usage

```typescript
import { ModelLoader } from '@keupoz/mson-core'

/**
 * Get actual model url. See `src/demo/modelLoader.ts` for example from demo
 */
function getModelUrl(modelId: string) {
  const [namespace, path] = modelId.split(':')

  return `path/to/${namespace}/models/${path}`
}

const modelLoader = new ModelLoader(async (modelId) => {
  const url = getModelUrl(modelId)

  const r = await fetch(url)
  const json = await r.json()

  return json
})

const parsedModel = await modelLoader.load('mson:steve')

console.log(parsedModel)
```
npm package: @keupoz/mson-three
Description: MSON port integration with Three.js
Latest version: 1.2.0

# `mson-three`

This package is used to load [Mson](https://github.com/MineLittlePony/Mson) models and create [Three.js](https://threejs.org/) objects from them.

## Installation

```sh
npm install three @keupoz/mson-three
```

## Usage

```typescript
import { ThreeMsonLoader } from '@keupoz/mson-three'
import { LoadingManager, Scene } from 'three'

const loadingManager = new LoadingManager()

loadingManager.setURLModifier((modelId) => {
  const [namespace, path] = modelId.split(':')

  return `path/to/${namespace}/models/${path}`
})

const msonLoader = new ThreeMsonLoader(loadingManager)
const model = await msonLoader.loadAsync('mson:steve')
const scene = new Scene()

scene.add(model)
```