gltf-parser-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/README.zh.md +47 -0
- package/dist/index.cjs +4027 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +26582 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# GLTF Parser Plugin
|
|
2
|
+
|
|
3
|
+
A high-performance GLTF/GLB loader plugin for `3d-tiles-renderer` that offloads parsing to Web Workers.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Web Worker Parsing**: Moves GLTF/GLB parsing and Draco decompression to a background thread to maintain high frame rates and UI responsiveness.
|
|
8
|
+
- **Metadata Support**: Full support for `EXT_mesh_features` and `EXT_structural_metadata` extensions, mapping metadata to Three.js objects.
|
|
9
|
+
- **Efficient Resource Management**: Uses a shared worker pool with reference counting to manage resources efficiently.
|
|
10
|
+
- **Draco Compression**: Built-in support for Draco-compressed meshes.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install gltf-parser-plugin
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Register the plugin with your `3d-tiles-renderer` instance:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { TilesRenderer } from "3d-tiles-renderer";
|
|
24
|
+
import { GLTFParserPlugin } from "gltf-parser-plugin";
|
|
25
|
+
|
|
26
|
+
const tilesRenderer = new TilesRenderer("path/to/tileset.json");
|
|
27
|
+
|
|
28
|
+
// Register the plugin
|
|
29
|
+
tilesRenderer.registerPlugin(
|
|
30
|
+
new GLTFParserPlugin({
|
|
31
|
+
metadata: true, // Enable metadata parsing (default: true)
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
### `GLTFParserPluginOptions`
|
|
39
|
+
|
|
40
|
+
| Option | Type | Default | Description |
|
|
41
|
+
| ---------- | --------- | ------- | ------------------------------------------------------------------------------ |
|
|
42
|
+
| `metadata` | `boolean` | `true` | Whether to parse `EXT_mesh_features` and `EXT_structural_metadata` extensions. |
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- `three`: >= 0.150.0
|
|
47
|
+
- `3d-tiles-renderer`: Compatible version
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# GLTF Parser Plugin
|
|
2
|
+
|
|
3
|
+
专为 `3d-tiles-renderer` 设计的高性能 GLTF/GLB 加载器插件,使用 Web Workers 进行异步解析。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **Web Worker 解析**: 将 GLTF/GLB 解析和 Draco 解码操作移至后台线程,确保主线程流畅,避免掉帧。
|
|
8
|
+
- **元数据支持**: 完整支持 `EXT_mesh_features` 和 `EXT_structural_metadata` 扩展,将元数据映射到 Three.js 对象中。
|
|
9
|
+
- **高效资源管理**: 使用带有引用计数的共享 Worker 池来高效管理资源。
|
|
10
|
+
- **Draco 压缩**: 内置支持 Draco 压缩的网格模型。
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install gltf-parser-plugin
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 使用方法
|
|
19
|
+
|
|
20
|
+
在 `3d-tiles-renderer` 实例中注册插件:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { TilesRenderer } from "3d-tiles-renderer";
|
|
24
|
+
import { GLTFParserPlugin } from "gltf-parser-plugin";
|
|
25
|
+
|
|
26
|
+
const tilesRenderer = new TilesRenderer("path/to/tileset.json");
|
|
27
|
+
|
|
28
|
+
// 注册插件
|
|
29
|
+
tilesRenderer.registerPlugin(
|
|
30
|
+
new GLTFParserPlugin({
|
|
31
|
+
metadata: true, // 启用元数据解析 (默认: true)
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 配置选项
|
|
37
|
+
|
|
38
|
+
### `GLTFParserPluginOptions`
|
|
39
|
+
|
|
40
|
+
| 选项 | 类型 | 默认值 | 描述 |
|
|
41
|
+
| ---------- | --------- | ------ | ---------------------------------------------------------------- |
|
|
42
|
+
| `metadata` | `boolean` | `true` | 是否解析 `EXT_mesh_features` 和 `EXT_structural_metadata` 扩展。 |
|
|
43
|
+
|
|
44
|
+
## 环境要求
|
|
45
|
+
|
|
46
|
+
- `three`: >= 0.150.0
|
|
47
|
+
- `3d-tiles-renderer`: 兼容版本
|