From 32e0e40967423b887133343ad96ceb370070feb7 Mon Sep 17 00:00:00 2001 From: QwiglyDee Date: Thu, 9 Oct 2025 11:19:04 +0700 Subject: [PATCH 1/2] metadata import for animations --- .../glTF/2.0/Extensions/ExtrasAsMetadata.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts b/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts index e74c9a3e518..d343db27573 100644 --- a/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts +++ b/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts @@ -1,13 +1,14 @@ -import type { Nullable } from "core/types"; -import type { TransformNode } from "core/Meshes/transformNode"; +import type { IProperty } from "babylonjs-gltf2interface"; +import { AnimationGroup } from "core/Animations/animationGroup"; import type { Camera } from "core/Cameras/camera"; +import type { Material } from "core/Materials/material"; +import type { TransformNode } from "core/Meshes/transformNode"; +import type { Nullable } from "core/types"; -import type { IProperty } from "babylonjs-gltf2interface"; -import type { INode, ICamera, IMaterial } from "../glTFLoaderInterfaces"; -import type { IGLTFLoaderExtension } from "../glTFLoaderExtension"; import type { GLTFLoader } from "../glTFLoader"; -import type { Material } from "core/Materials/material"; +import type { IGLTFLoaderExtension } from "../glTFLoaderExtension"; import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry"; +import type { IAnimation, ICamera, IMaterial, INode } from "../glTFLoaderInterfaces"; const NAME = "ExtrasAsMetadata"; @@ -92,6 +93,16 @@ export class ExtrasAsMetadata implements IGLTFLoaderExtension { this._assignExtras(babylonMaterial, material); return babylonMaterial; } + + /** + * @internal + */ + public loadAnimationAsync(context: string, animation: IAnimation): Nullable> { + return this._loader.loadAnimationAsync(context, animation).then((babylonAnimation: AnimationGroup) => { + this._assignExtras(babylonAnimation, animation); + return babylonAnimation; + }) + } } unregisterGLTFExtension(NAME); From c8e6b98c8a45084f811e996f01d7f910c178a159 Mon Sep 17 00:00:00 2001 From: QwiglyDee Date: Thu, 9 Oct 2025 11:28:58 +0700 Subject: [PATCH 2/2] cleanup --- .../glTF/2.0/Extensions/ExtrasAsMetadata.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts b/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts index d343db27573..825fe54a714 100644 --- a/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts +++ b/packages/dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts @@ -1,14 +1,14 @@ -import type { IProperty } from "babylonjs-gltf2interface"; -import { AnimationGroup } from "core/Animations/animationGroup"; -import type { Camera } from "core/Cameras/camera"; -import type { Material } from "core/Materials/material"; -import type { TransformNode } from "core/Meshes/transformNode"; import type { Nullable } from "core/types"; +import type { TransformNode } from "core/Meshes/transformNode"; +import type { Camera } from "core/Cameras/camera"; +import type { AnimationGroup } from "core/Animations/animationGroup"; -import type { GLTFLoader } from "../glTFLoader"; +import type { IProperty } from "babylonjs-gltf2interface"; +import type { INode, ICamera, IMaterial, IAnimation } from "../glTFLoaderInterfaces"; import type { IGLTFLoaderExtension } from "../glTFLoaderExtension"; +import type { GLTFLoader } from "../glTFLoader"; +import type { Material } from "core/Materials/material"; import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry"; -import type { IAnimation, ICamera, IMaterial, INode } from "../glTFLoaderInterfaces"; const NAME = "ExtrasAsMetadata"; @@ -97,11 +97,13 @@ export class ExtrasAsMetadata implements IGLTFLoaderExtension { /** * @internal */ + // eslint-disable-next-line no-restricted-syntax public loadAnimationAsync(context: string, animation: IAnimation): Nullable> { + // eslint-disable-next-line github/no-then return this._loader.loadAnimationAsync(context, animation).then((babylonAnimation: AnimationGroup) => { this._assignExtras(babylonAnimation, animation); - return babylonAnimation; - }) + return babylonAnimation; + }); } }