Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MANYFOLD_mesh_progressive extension support #99

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project provides you Three.js glTF loader/extension plugins even for such e
* [EXT_texture_video](https://github.com/takahirox/EXT_texture_video) (Loader only)
* [MSFT_lod](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod) (Loader only, in progress)
* [MSFT_texture_dds](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds) (Loader only)
* [MANYFOLD_mesh_progressive](https://github.com/manyfold3d/glTF/tree/MANYFOLD_mesh_progressive/extensions/2.0/Vendor/MANYFOLD_mesh_progressive#readme) (Loader only)

## Compatible Three.js revision

Expand Down
Binary file added examples/assets/gltf/Progressive/progressive.glb
Binary file not shown.
19 changes: 19 additions & 0 deletions loaders/MANYFOLD_mesh_progressive/MANYFOLD_mesh_progressive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
FileLoader,
LoaderUtils
} from 'three';

export default class GLTFManyfoldMeshProgressiveExtension {
constructor(parser, url, binChunkOffset) {
this.name = 'MANYFOLD_mesh_progressive';
this.parser = parser;
this.url = url;
this.binChunkOffset = binChunkOffset;
console.log(`${this.name} loader created`)
}

static load(url, loader, onLoad, onProgress, onError, fileLoader = null) {
console.log(`${this.name} falling back to original loader`)
loader.load(url, onLoad, onProgress, onError);
}
}
5 changes: 5 additions & 0 deletions loaders/MANYFOLD_mesh_progressive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Three.js](https://threejs.org) [GLTFLoader](https://threejs.org/docs/#examples/en/loaders/GLTFLoader) [EXT_texture_video](https://github.com/manyfold3d/glTF/tree/MANYFOLD_mesh_progressive/extensions/2.0/Vendor/MANYFOLD_mesh_progressive#readme) extension

This extension implements a loader for [MANYFOLD_mesh_progressive](https://github.com/manyfold3d/glTF/tree/MANYFOLD_mesh_progressive/extensions/2.0/Vendor/MANYFOLD_mesh_progressive#readme) streams.

Such streams load an initial base mesh in the usual way, then provide a stream of refinements which can be displayed incrementally.
43 changes: 43 additions & 0 deletions test/MANYFOLD_mesh_progressive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* global QUnit */

import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import GLTFManyfoldMeshProgressiveExtension from '../loaders/MANYFOLD_mesh_progressive/MANYFOLD_mesh_progressive.js';

export default QUnit.module('MANYFOLD_mesh_progressive', () => {
QUnit.module('GLTFManyfoldMeshProgressiveExtension', () => {
QUnit.test('register', assert => {
const done = assert.async();
new GLTFLoader()
.register(parser => new GLTFManyfoldMeshProgressiveExtension(parser))
.parse('{"asset": {"version": "2.0"}}', null, result => {
assert.ok(true, 'can register');
done();
}, error => {
assert.ok(false, 'can register');
done();
});
});
});

QUnit.module('GLTFManyfoldMeshProgressiveExtension-webonly', () => {
QUnit.test('parse', assert => {
const done = assert.async();
const assetPath = '../examples/assets/gltf/Progressive/progressive.glb';
new GLTFLoader()
.register(parser => new GLTFManyfoldMeshProgressiveExtension(parser))
.load(assetPath, gltf => {
let hasBaseMesh = false;
gltf.scene.traverse(object => {
if (object.isMesh) {
hasBaseMesh = true;
}
});
assert.ok(hasBaseMesh, 'can parse base mesh');
done();
}, undefined, error => {
assert.ok(false, 'can load base mesh');
done();
});
});
});
});
Loading