donmccurdy / glTF-Transform

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

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

Closed donmccurdy closed 7 months ago

donmccurdy commented 7 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 7 months ago

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

marwie commented 7 months ago

Oh great, thanks a lot!