MCPcopy
hub / github.com/donmccurdy/glTF-Transform / createExtension

Method createExtension

packages/core/src/document.ts:196–202  ·  view source on GitHub ↗

* Creates a new Extension, for the extension type of the given constructor. If the * extension is already enabled for this Document, the previous Extension reference is reused.

(ctor: new (doc: Document) => T)

Source from the content-addressed store, hash-verified

194 * extension is already enabled for this Document, the previous Extension reference is reused.
195 */
196 createExtension<T extends Extension>(ctor: new (doc: Document) => T): T {
197 const extensionName = (ctor as unknown as { EXTENSION_NAME: 'string' }).EXTENSION_NAME;
198 const prevExtension = this.getRoot()
199 .listExtensionsUsed()
200 .find((ext) => ext.extensionName === extensionName);
201 return (prevExtension || new ctor(this)) as T;
202 }
203
204 /**
205 * Disables and removes an {@link Extension} from the Document. If no Extension exists with

Callers 15

readMethod · 0.80
extension.test.tsFile · 0.80
readMethod · 0.80
getParamsFunction · 0.80
ktxdecompressFunction · 0.80
toktxFunction · 0.80
xmpFunction · 0.80
createMaterialPaneFunction · 0.80

Calls 2

getRootMethod · 0.95
listExtensionsUsedMethod · 0.80

Tested by 3

readMethod · 0.64
getParamsFunction · 0.64
createSceneInstancedFunction · 0.64