Skip to content

Commit

Permalink
Merge pull request #5795 from mozilla/LODProgressiveLoadingBehindFlag
Browse files Browse the repository at this point in the history
Hide LOD progressive loading mode behind the flag
  • Loading branch information
takahirox authored Nov 28, 2022
2 parents 8d33372 + 3d37c0f commit 1fc6826
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"semver": "^7.3.2",
"three": "github:mozillareality/three.js#56e7c46d991cc16bff82bdbb03c7bfba4620567f",
"three-ammo": "github:mozillareality/three-ammo",
"three-gltf-extensions": "^0.0.13",
"three-gltf-extensions": "^0.0.14",
"three-mesh-bvh": "^0.3.7",
"three-pathfinding": "^1.1.0",
"three-to-ammo": "github:infinitelee/three-to-ammo",
Expand Down
10 changes: 8 additions & 2 deletions src/components/gltf-model-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ export async function loadGLTF(src, contentType, onProgress, jsonPreprocessor) {
gltfUrl = fileMap["scene.gtlf"];
}

const useRangeRequests = qsTruthy("rangerequests");
const loadingManager = new THREE.LoadingManager();
loadingManager.setURLModifier(getCustomGLTFParserURLResolver(gltfUrl));
const gltfLoader = new GLTFLoader(loadingManager);
Expand All @@ -676,8 +677,13 @@ export async function loadGLTF(src, contentType, onProgress, jsonPreprocessor) {
.register(
parser =>
new GLTFLodExtension(parser, {
loadingMode: "progressive",
loadingMode: useRangeRequests ? "progressive" : "all",
onLoadMesh: (lod, mesh, level, lowestLevel) => {
// Nothing to do for "all" mode
if (!useRangeRequests) {
return mesh;
}

// Higher levels are progressively loaded on demand.
// So some post-loading processings done in gltf-model-plus and media-loader
// need to be done here now.
Expand Down Expand Up @@ -787,7 +793,7 @@ export async function loadGLTF(src, contentType, onProgress, jsonPreprocessor) {

resolve(gltf);
};
if (qsTruthy("rangerequests")) {
if (useRangeRequests) {
GLBRangeRequests.load(gltfUrl, gltfLoader, onLoad, onProgress, reject);
} else {
gltfLoader.load(gltfUrl, onLoad, onProgress, reject);
Expand Down

0 comments on commit 1fc6826

Please sign in to comment.