Skip to content

Merging models #691

Answered by donmccurdy
raducal asked this question in Q&A
Sep 26, 2022 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

Hi @raducostica! You'll need to merge(...) the Document instances, then write the Document to a file only once at the end. Merging N Documents results in a Document with N buffers and N scenes — in most cases you'll also want to consolidate to a single buffer and a single scene. See https://stackoverflow.com/a/68032114/1314762 if you choose to go this route.

However, it looks like you might be trying to create a scene containing N mesh primitives? In that case there's no point in generating N documents and scenes along the way. You can create one document, append N meshes or mesh primitives to it, and then write the result:

import { Document, NodeIO } from '@gltf-transform/core';

const doc 

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@raducal
Comment options

@donmccurdy
Comment options

@raducal

This comment was marked as off-topic.

@donmccurdy
Comment options

@raducal
Comment options

Answer selected by raducal
Comment options

You must be logged in to vote
1 reply
@donmccurdy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants