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

GLTFLoader: Add loadNode hook #25077

Merged
merged 1 commit into from
Dec 9, 2022
Merged

Conversation

takahirox
Copy link
Collaborator

Description

This PR adds loadNode hook to GLTFParser. /cc @donmccurdy

Use case:

This hook is needed for glTF LOD extensions (MSFT_lod or EXT_node_lod)

// LOD extension plugin
loadNode(nodeIndex) {
    // Some set up here
    ...
    //

    const lod = new LOD();
    const pending = [];
    pending.push(parser.loadNode(nodeIndex));
    for (let i = 0; i < extensionDef.lods.length; i++) {
        pending.push(parser.getDependency('node', extensionDef.lods[i].node));
    }
    return Promise.all(pending).then(nodes => {
        for (let i = 0; i < nodes.length; i++) {
            lod.addLevel(node, coverages[i]);
        }
        return lod;
    });
}

@takahirox takahirox force-pushed the GLTFLoaderLoadNodeHook branch from 945d884 to d7c76f7 Compare December 4, 2022 21:59
@mrdoob mrdoob requested a review from donmccurdy December 7, 2022 08:29
@mrdoob mrdoob added this to the r148 milestone Dec 7, 2022
takahirox added a commit to Hubs-Foundation/three.js that referenced this pull request Dec 7, 2022
[HUBS]
This change is needed for glTF LOD support.
This change is not merged into the official Three.js but
likely it can get in soon.
mrdoob#25077
We can remove this commit if the PR is merged to the
official Three.js and upgrading our Three.js fork to the
one including the change.
@mrdoob mrdoob merged commit 08497e9 into mrdoob:dev Dec 9, 2022
@takahirox takahirox deleted the GLTFLoaderLoadNodeHook branch December 9, 2022 05:59
@0b5vr 0b5vr mentioned this pull request Dec 23, 2022
10 tasks
0b5vr added a commit to three-types/three-ts-types that referenced this pull request Dec 27, 2022
joshuaellis added a commit to three-types/three-ts-types that referenced this pull request Jan 3, 2023
* docs: update constructor doc comment of geometries

See: mrdoob/three.js#25086

* docs: update doc comment of the constructor of BufferAttribute

See: mrdoob/three.js#25046

the `normalized` was already optional in the typedef

* feat: add TwoPassDoubleSide

See: mrdoob/three.js#25165

also add doc comment of Side

* feat: add `Mesh.getVertexPosition()`

- add `Mesh.getVertexPosition()`
- add doc comment of `SceneUtils.reduceVertices`

See: mrdoob/three.js#25049

* feat: add `Object3D.getObjectsByProperty()`

- add `Object3D.getObjectsByProperty()`
- add doc comment of `Object3D.getObjectByProperty()`

See: mrdoob/three.js#25006

* docs: add a doc comment of `PointLight.castShadow`

See: mrdoob/three.js#25136

* feat (GLTFLoader): add loadNode hook

See: mrdoob/three.js#25077

* feat (Nodes): New features and revisions

- add three new nodes: `CacheNode`, `StackNode`, and `SpecularMIPLevelNode`
- add `NodeCache`
- add `getDefaultUV()` to `CubeTextureNode` and `TextureNode`
- add `isGlobal()` to `Node`
- add `cache` and `globalCache` to `NodeBuilder`
- add missing `flowsData` to `NodeBuilder`
- add `hasDependencies` to `TempNode`
- add `maxMipLevel` and `cache` to `ShaderNodeBaseElements`
- replace `maxMipLevel` -> `specularMIPLevel` of `ShaderNodeElements`
- change constructor type and texture type of `MaxMipLevelNode`
- add `SpecularMIPLevelNode`

* feat (Nodes): add FogExp2 node

Co-authored-by: Josh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants