donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.3k stars 145 forks source link

feat(functions): Add mergeDocuments, cloneDocument, copyToDocument, moveToDocument #1375

Closed donmccurdy closed 2 months ago

donmccurdy commented 2 months ago

Changes:

Example:

import { copyToDocument } from '@gltf-transform/functions';

// Copy materials from sourceDocument to targetDocument.
const map = copyToDocument(
  targetDocument,
  sourceDocument,
  [sourceMaterialA, sourceMaterialB]
);

// Find counterpart of sourceMaterialA in targetDocument.
const targetMaterialA = map.get(sourceMaterialA);

Related:

elalish commented 2 months ago

Excellent, thank you! I look forward to using these.

marwie commented 2 months ago

Oh great, thanks a lot!