New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@babylonjs/loaders

Package Overview
Dependencies
Maintainers
1
Versions
582
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babylonjs/loaders - npm Package Compare versions

Comparing version

to
7.51.2

glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts

7

glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts
import type { IObjectInfo, IPathToObjectConverter } from "@babylonjs/core/ObjectModel/objectModelInterfaces.js";
import type { IGLTF } from "../glTFLoaderInterfaces";
import type { IObjectAccessor } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
/**

@@ -9,3 +10,3 @@ * A converter that takes a glTF Object Model JSON Pointer

*/
export declare class GLTFPathToObjectConverter<T> implements IPathToObjectConverter<T> {
export declare class GLTFPathToObjectConverter<T, BabylonType, BabylonValue> implements IPathToObjectConverter<IObjectAccessor<T, BabylonType, BabylonValue>> {
private _gltf;

@@ -16,2 +17,3 @@ private _infoTree;

* The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).
* See also https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/ObjectModel.adoc#core-pointers
* <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>

@@ -28,2 +30,3 @@ * <rootNode> := "nodes" | "materials" | "meshes" | "cameras" | "extensions"

* - "/nodes/0/rotation"
* - "/nodes.length"
* - "/materials/2/emissiveFactor"

@@ -36,3 +39,3 @@ * - "/materials/2/pbrMetallicRoughness/baseColorFactor"

*/
convert(path: string): IObjectInfo<T>;
convert(path: string): IObjectInfo<IObjectAccessor<T, BabylonType, BabylonValue>>;
}

@@ -14,2 +14,3 @@ /**

* The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901).
* See also https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/ObjectModel.adoc#core-pointers
* <animationPointer> := /<rootNode>/<assetIndex>/<propertyPath>

@@ -26,2 +27,3 @@ * <rootNode> := "nodes" | "materials" | "meshes" | "cameras" | "extensions"

* - "/nodes/0/rotation"
* - "/nodes.length"
* - "/materials/2/emissiveFactor"

@@ -43,4 +45,19 @@ * - "/materials/2/pbrMetallicRoughness/baseColorFactor"

parts.shift();
//if the last part has ".length" in it, separate that as an extra part
if (parts[parts.length - 1].includes(".length")) {
const lastPart = parts[parts.length - 1];
const split = lastPart.split(".");
parts.pop();
parts.push(...split);
}
let ignoreObjectTree = false;
for (const part of parts) {
if (infoTree.__array__) {
const isLength = part === "length";
if (isLength && !infoTree.__array__) {
throw new Error(`Path ${path} is invalid`);
}
if (infoTree.__ignoreObjectTree__) {
ignoreObjectTree = true;
}
if (infoTree.__array__ && !isLength) {
infoTree = infoTree.__array__;

@@ -54,7 +71,11 @@ }

}
if (objectTree === undefined) {
throw new Error(`Path ${path} is invalid`);
if (!ignoreObjectTree) {
if (objectTree === undefined) {
throw new Error(`Path ${path} is invalid`);
}
if (!isLength) {
objectTree = objectTree?.[part];
}
}
objectTree = objectTree[part];
if (infoTree.__target__) {
if (infoTree.__target__ || isLength) {
target = objectTree;

@@ -61,0 +82,0 @@ }

@@ -0,1 +1,2 @@

export * from "./objectModelMapping";
export * from "./EXT_lights_image_based";

@@ -34,2 +35,5 @@ export * from "./EXT_mesh_gpu_instancing";

export * from "./KHR_node_visibility";
export * from "./KHR_node_selectability";
export * from "./KHR_node_hoverability";
export * from "./ExtrasAsMetadata";
export * from "./KHR_interactivity/index";

@@ -0,1 +1,2 @@

export * from "./objectModelMapping.js";
export * from "./EXT_lights_image_based.js";

@@ -34,3 +35,7 @@ export * from "./EXT_mesh_gpu_instancing.js";

export * from "./KHR_node_visibility.js";
export * from "./KHR_node_selectability.js";
export * from "./KHR_node_hoverability.js";
export * from "./ExtrasAsMetadata.js";
// eslint-disable-next-line import/no-internal-modules
export * from "./KHR_interactivity/index.js";
//# sourceMappingURL=index.js.map

@@ -7,2 +7,3 @@ import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";

import type { IAnimation, IAnimationChannel } from "../glTFLoaderInterfaces";
import "./KHR_animation_pointer.data";
declare module "../../glTFFileLoader" {

@@ -9,0 +10,0 @@ interface GLTFLoaderExtensionOptions {

@@ -1,300 +0,1 @@

import { Animation } from "@babylonjs/core/Animations/animation.js";
import type { ICamera, IKHRLightsPunctual_Light, IMaterial } from "../glTFLoaderInterfaces";
import type { IAnimatable } from "@babylonjs/core/Animations/animatable.interface.js";
import { AnimationPropertyInfo } from "../glTFLoaderAnimation";
declare class CameraAnimationPropertyInfo extends AnimationPropertyInfo {
/** @internal */
buildAnimations(target: ICamera, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
}
declare class MaterialAnimationPropertyInfo extends AnimationPropertyInfo {
/** @internal */
buildAnimations(target: IMaterial, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
}
declare class LightAnimationPropertyInfo extends AnimationPropertyInfo {
/** @internal */
buildAnimations(target: IKHRLightsPunctual_Light, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
}
/** @internal */
export declare const animationPointerTree: {
nodes: {
__array__: {
translation: import("../glTFLoaderAnimation").TransformNodeAnimationPropertyInfo[];
rotation: import("../glTFLoaderAnimation").TransformNodeAnimationPropertyInfo[];
scale: import("../glTFLoaderAnimation").TransformNodeAnimationPropertyInfo[];
weights: import("../glTFLoaderAnimation").WeightAnimationPropertyInfo[];
__target__: boolean;
};
};
materials: {
__array__: {
__target__: boolean;
pbrMetallicRoughness: {
baseColorFactor: MaterialAnimationPropertyInfo[];
metallicFactor: MaterialAnimationPropertyInfo[];
roughnessFactor: MaterialAnimationPropertyInfo[];
baseColorTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
metallicRoughnessTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
emissiveFactor: MaterialAnimationPropertyInfo[];
normalTexture: {
scale: MaterialAnimationPropertyInfo[];
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
occlusionTexture: {
strength: MaterialAnimationPropertyInfo[];
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
emissiveTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
extensions: {
KHR_materials_anisotropy: {
anisotropyStrength: MaterialAnimationPropertyInfo[];
anisotropyRotation: MaterialAnimationPropertyInfo[];
anisotropyTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_clearcoat: {
clearcoatFactor: MaterialAnimationPropertyInfo[];
clearcoatRoughnessFactor: MaterialAnimationPropertyInfo[];
clearcoatTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
clearcoatNormalTexture: {
scale: MaterialAnimationPropertyInfo[];
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
clearcoatRoughnessTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_dispersion: {
dispersion: MaterialAnimationPropertyInfo[];
};
KHR_materials_emissive_strength: {
emissiveStrength: MaterialAnimationPropertyInfo[];
};
KHR_materials_ior: {
ior: MaterialAnimationPropertyInfo[];
};
KHR_materials_iridescence: {
iridescenceFactor: MaterialAnimationPropertyInfo[];
iridescenceIor: MaterialAnimationPropertyInfo[];
iridescenceThicknessMinimum: MaterialAnimationPropertyInfo[];
iridescenceThicknessMaximum: MaterialAnimationPropertyInfo[];
iridescenceTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
iridescenceThicknessTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_sheen: {
sheenColorFactor: MaterialAnimationPropertyInfo[];
sheenRoughnessFactor: MaterialAnimationPropertyInfo[];
sheenColorTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
sheenRoughnessTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_specular: {
specularFactor: MaterialAnimationPropertyInfo[];
specularColorFactor: MaterialAnimationPropertyInfo[];
specularTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
specularColorTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_transmission: {
transmissionFactor: MaterialAnimationPropertyInfo[];
transmissionTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_volume: {
attenuationColor: MaterialAnimationPropertyInfo[];
attenuationDistance: MaterialAnimationPropertyInfo[];
thicknessFactor: MaterialAnimationPropertyInfo[];
thicknessTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
KHR_materials_diffuse_transmission: {
diffuseTransmissionFactor: MaterialAnimationPropertyInfo[];
diffuseTransmissionTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
diffuseTransmissionColorFactor: MaterialAnimationPropertyInfo[];
diffuseTransmissionColorTexture: {
extensions: {
KHR_texture_transform: {
scale: MaterialAnimationPropertyInfo[];
offset: MaterialAnimationPropertyInfo[];
rotation: MaterialAnimationPropertyInfo[];
};
};
};
};
};
};
};
cameras: {
__array__: {
__target__: boolean;
orthographic: {
xmag: CameraAnimationPropertyInfo[];
ymag: CameraAnimationPropertyInfo[];
zfar: CameraAnimationPropertyInfo[];
znear: CameraAnimationPropertyInfo[];
};
perspective: {
yfov: CameraAnimationPropertyInfo[];
zfar: CameraAnimationPropertyInfo[];
znear: CameraAnimationPropertyInfo[];
};
};
};
extensions: {
KHR_lights_punctual: {
lights: {
__array__: {
__target__: boolean;
color: LightAnimationPropertyInfo[];
intensity: LightAnimationPropertyInfo[];
range: LightAnimationPropertyInfo[];
spot: {
innerConeAngle: LightAnimationPropertyInfo[];
outerConeAngle: LightAnimationPropertyInfo[];
};
};
};
};
EXT_lights_ies: {
lights: {
__array__: {
__target__: boolean;
color: LightAnimationPropertyInfo[];
multiplier: LightAnimationPropertyInfo[];
};
};
};
};
};
export {};
/* eslint-disable @typescript-eslint/naming-convention */
import { Animation } from "@babylonjs/core/Animations/animation.js";
import { AnimationPropertyInfo, nodeAnimationData } from "../glTFLoaderAnimation.js";
import { AnimationPropertyInfo } from "../glTFLoaderAnimation.js";
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
import { SetInterpolationForKey } from "./objectModelMapping.js";
function getColor3(_target, source, offset, scale) {

@@ -38,4 +39,4 @@ return Color3.FromArray(source, offset).scale(scale);

/** @internal */
buildAnimations(target, name, fps, keys, callback) {
callback(target._babylonCamera, this._buildAnimation(name, fps, keys));
buildAnimations(target, name, fps, keys) {
return [{ babylonAnimatable: target._babylonCamera, babylonAnimation: this._buildAnimation(name, fps, keys) }];
}

@@ -45,6 +46,11 @@ }

/** @internal */
buildAnimations(target, name, fps, keys, callback) {
buildAnimations(target, name, fps, keys) {
const babylonAnimations = [];
for (const fillMode in target._data) {
callback(target._data[fillMode].babylonMaterial, this._buildAnimation(name, fps, keys));
babylonAnimations.push({
babylonAnimatable: target._data[fillMode].babylonMaterial,
babylonAnimation: this._buildAnimation(name, fps, keys),
});
}
return babylonAnimations;
}

@@ -54,223 +60,183 @@ }

/** @internal */
buildAnimations(target, name, fps, keys, callback) {
callback(target._babylonLight, this._buildAnimation(name, fps, keys));
buildAnimations(target, name, fps, keys) {
return [{ babylonAnimatable: target._babylonLight, babylonAnimation: this._buildAnimation(name, fps, keys) }];
}
}
const nodesTree = {
__array__: {
__target__: true,
...nodeAnimationData,
},
};
const camerasTree = {
__array__: {
__target__: true,
orthographic: {
xmag: [
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, () => 1),
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, () => 1),
],
ymag: [
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, () => 1),
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, () => 1),
],
zfar: [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, () => 1)],
znear: [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, () => 1)],
},
perspective: {
yfov: [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, () => 1)],
zfar: [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, () => 1)],
znear: [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, () => 1)],
},
},
};
const materialsTree = {
__array__: {
__target__: true,
pbrMetallicRoughness: {
baseColorFactor: [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, () => 4),
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, () => 4),
],
metallicFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, () => 1)],
roughnessFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, () => 1)],
baseColorTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("albedoTexture"),
},
},
metallicRoughnessTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("metallicTexture"),
},
},
},
emissiveFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, () => 3)],
normalTexture: {
scale: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, () => 1)],
extensions: {
KHR_texture_transform: getTextureTransformTree("bumpTexture"),
},
},
occlusionTexture: {
strength: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, () => 1)],
extensions: {
KHR_texture_transform: getTextureTransformTree("ambientTexture"),
},
},
emissiveTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("emissiveTexture"),
},
},
extensions: {
KHR_materials_anisotropy: {
anisotropyStrength: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, () => 1)],
anisotropyRotation: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, () => 1)],
anisotropyTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("anisotropy.texture"),
},
},
},
KHR_materials_clearcoat: {
clearcoatFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, () => 1)],
clearcoatRoughnessFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, () => 1)],
clearcoatTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("clearCoat.texture"),
},
},
clearcoatNormalTexture: {
scale: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.bumpTexture.level", getFloat, () => 1)],
extensions: {
KHR_texture_transform: getTextureTransformTree("clearCoat.bumpTexture"),
},
},
clearcoatRoughnessTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("clearCoat.textureRoughness"),
},
},
},
KHR_materials_dispersion: {
dispersion: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.dispersion", getFloat, () => 1)],
},
KHR_materials_emissive_strength: {
emissiveStrength: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, () => 1)],
},
KHR_materials_ior: {
ior: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, () => 1)],
},
KHR_materials_iridescence: {
iridescenceFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, () => 1)],
iridescenceIor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, () => 1)],
iridescenceThicknessMinimum: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, () => 1)],
iridescenceThicknessMaximum: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, () => 1)],
iridescenceTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("iridescence.texture"),
},
},
iridescenceThicknessTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("iridescence.thicknessTexture"),
},
},
},
KHR_materials_sheen: {
sheenColorFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, () => 3)],
sheenRoughnessFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, () => 1)],
sheenColorTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("sheen.texture"),
},
},
sheenRoughnessTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("sheen.textureRoughness"),
},
},
},
KHR_materials_specular: {
specularFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, () => 1)],
specularColorFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, () => 3)],
specularTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("metallicReflectanceTexture"),
},
},
specularColorTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("reflectanceTexture"),
},
},
},
KHR_materials_transmission: {
transmissionFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, () => 1)],
transmissionTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("subSurface.refractionIntensityTexture"),
},
},
},
KHR_materials_volume: {
attenuationColor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, () => 3)],
attenuationDistance: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, () => 1)],
thicknessFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, () => 1)],
thicknessTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("subSurface.thicknessTexture"),
},
},
},
KHR_materials_diffuse_transmission: {
diffuseTransmissionFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.translucencyIntensity", getFloat, () => 1)],
diffuseTransmissionTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("subSurface.translucencyIntensityTexture"),
},
},
diffuseTransmissionColorFactor: [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "subSurface.translucencyColor", getColor3, () => 3)],
diffuseTransmissionColorTexture: {
extensions: {
KHR_texture_transform: getTextureTransformTree("subSurface.translucencyColorTexture"),
},
},
},
},
},
};
const extensionsTree = {
KHR_lights_punctual: {
lights: {
__array__: {
__target__: true,
color: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, () => 3)],
intensity: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, () => 1)],
range: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, () => 1)],
spot: {
innerConeAngle: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, () => 1)],
outerConeAngle: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, () => 1)],
},
},
},
},
EXT_lights_ies: {
lights: {
__array__: {
__target__: true,
color: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, () => 3)],
multiplier: [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, () => 1)],
},
},
},
};
/** @internal */
export const animationPointerTree = {
nodes: nodesTree,
materials: materialsTree,
cameras: camerasTree,
extensions: extensionsTree,
};
SetInterpolationForKey("/cameras/{}/orthographic/xmag", [
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, () => 1),
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, () => 1),
]);
SetInterpolationForKey("/cameras/{}/orthographic/ymag", [
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, () => 1),
new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, () => 1),
]);
SetInterpolationForKey("/cameras/{}/orthographic/zfar", [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, () => 1)]);
SetInterpolationForKey("/cameras/{}/orthographic/znear", [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, () => 1)]);
SetInterpolationForKey("/cameras/{}/perspective/yfov", [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, () => 1)]);
SetInterpolationForKey("/cameras/{}/perspective/zfar", [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, () => 1)]);
SetInterpolationForKey("/cameras/{}/perspective/znear", [new CameraAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, () => 1)]);
// add interpolation to the materials mapping
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/baseColorFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, () => 4),
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, () => 4),
]);
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/metallicFactor", [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, () => 1)]);
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/metallicFactor", [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, () => 1)]);
const baseColorTextureInterpolation = getTextureTransformTree("albedoTexture");
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale", baseColorTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset", baseColorTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation", baseColorTextureInterpolation.rotation);
const metallicRoughnessTextureInterpolation = getTextureTransformTree("metallicTexture");
SetInterpolationForKey("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale", metallicRoughnessTextureInterpolation.scale);
SetInterpolationForKey("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset", metallicRoughnessTextureInterpolation.offset);
SetInterpolationForKey("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation", metallicRoughnessTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/emissiveFactor", [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, () => 3)]);
const normalTextureInterpolation = getTextureTransformTree("bumpTexture");
SetInterpolationForKey("/materials/{}/normalTexture/scale", [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, () => 1)]);
SetInterpolationForKey("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale", normalTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset", normalTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation", normalTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/occlusionTexture/strength", [new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, () => 1)]);
const occlusionTextureInterpolation = getTextureTransformTree("ambientTexture");
SetInterpolationForKey("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale", occlusionTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset", occlusionTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation", occlusionTextureInterpolation.rotation);
const emissiveTextureInterpolation = getTextureTransformTree("emissiveTexture");
SetInterpolationForKey("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale", emissiveTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset", emissiveTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation", emissiveTextureInterpolation.rotation);
// materials extensions
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, () => 1),
]);
const anisotropyTextureInterpolation = getTextureTransformTree("anisotropy.texture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale", anisotropyTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset", anisotropyTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation", anisotropyTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, () => 1),
]);
const clearcoatTextureInterpolation = getTextureTransformTree("clearCoat.texture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale", clearcoatTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset", clearcoatTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation", clearcoatTextureInterpolation.rotation);
const clearcoatNormalTextureInterpolation = getTextureTransformTree("clearCoat.bumpTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "clearCoat.bumpTexture.level", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale", clearcoatNormalTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset", clearcoatNormalTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation", clearcoatNormalTextureInterpolation.rotation);
const clearcoatRoughnessTextureInterpolation = getTextureTransformTree("clearCoat.textureRoughness");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale", clearcoatRoughnessTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset", clearcoatRoughnessTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation", clearcoatRoughnessTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.dispersion", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_ior/ior", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, () => 1),
]);
const iridescenceTextureInterpolation = getTextureTransformTree("iridescence.texture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale", iridescenceTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset", iridescenceTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation", iridescenceTextureInterpolation.rotation);
const iridescenceThicknessTextureInterpolation = getTextureTransformTree("iridescence.thicknessTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale", iridescenceThicknessTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset", iridescenceThicknessTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation", iridescenceThicknessTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, () => 3),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, () => 1),
]);
const sheenTextureInterpolation = getTextureTransformTree("sheen.texture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale", sheenTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset", sheenTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation", sheenTextureInterpolation.rotation);
const sheenRoughnessTextureInterpolation = getTextureTransformTree("sheen.textureRoughness");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale", sheenRoughnessTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset", sheenRoughnessTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation", sheenRoughnessTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularColorFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, () => 3),
]);
const specularTextureInterpolation = getTextureTransformTree("metallicReflectanceTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale", specularTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset", specularTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation", specularTextureInterpolation.rotation);
const specularColorTextureInterpolation = getTextureTransformTree("reflectanceTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale", specularColorTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset", specularColorTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation", specularColorTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, () => 1),
]);
const transmissionTextureInterpolation = getTextureTransformTree("subSurface.refractionIntensityTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale", transmissionTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset", transmissionTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation", transmissionTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/attenuationColor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, () => 3),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/attenuationDistance", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, () => 1),
]);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/thicknessFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, () => 1),
]);
const thicknessTextureInterpolation = getTextureTransformTree("subSurface.thicknessTexture");
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale", thicknessTextureInterpolation.scale);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset", thicknessTextureInterpolation.offset);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation", thicknessTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "subSurface.translucencyIntensity", getFloat, () => 1),
]);
const diffuseTransmissionTextureInterpolation = getTextureTransformTree("subSurface.translucencyIntensityTexture");
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale", diffuseTransmissionTextureInterpolation.scale);
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset", diffuseTransmissionTextureInterpolation.offset);
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation", diffuseTransmissionTextureInterpolation.rotation);
SetInterpolationForKey("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor", [
new MaterialAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "subSurface.translucencyColor", getColor3, () => 3),
]);
const diffuseTransmissionColorTextureInterpolation = getTextureTransformTree("subSurface.translucencyColorTexture");
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale", diffuseTransmissionColorTextureInterpolation.scale);
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset", diffuseTransmissionColorTextureInterpolation.offset);
SetInterpolationForKey("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation", diffuseTransmissionColorTextureInterpolation.rotation);
SetInterpolationForKey("/extensions/KHR_lights_punctual/lights/{}/color", [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, () => 3)]);
SetInterpolationForKey("/extensions/KHR_lights_punctual/lights/{}/intensity", [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, () => 1)]);
SetInterpolationForKey("/extensions/KHR_lights_punctual/lights/{}/range", [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, () => 1)]);
SetInterpolationForKey("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle", [
new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, () => 1),
]);
SetInterpolationForKey("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle", [
new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, () => 1),
]);
SetInterpolationForKey("/nodes/{}/extensions/EXT_lights_ies/color", [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, () => 3)]);
SetInterpolationForKey("/nodes/{}/extensions/EXT_lights_ies/multiplier", [new LightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, () => 1)]);
//# sourceMappingURL=KHR_animation_pointer.data.js.map
import { Logger } from "@babylonjs/core/Misc/logger.js";
import { animationPointerTree } from "./KHR_animation_pointer.data.js";
import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
import { GetPathToObjectConverter } from "./objectModelMapping.js";
import "./KHR_animation_pointer.data.js";
const NAME = "KHR_animation_pointer";
/**
* Class to convert an animation pointer path to a smart object that
* gets data from the animation buffer and creates animations.
*/
class AnimationPointerPathToObjectConverter extends GLTFPathToObjectConverter {
constructor(gltf) {
super(gltf, animationPointerTree);
}
}
/**
* [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147)

@@ -30,3 +21,3 @@ * !!! Experimental Extension Subject to Changes !!!

this._loader = loader;
this._pathToObjectConverter = new AnimationPointerPathToObjectConverter(this._loader.gltf);
this._pathToObjectConverter = GetPathToObjectConverter(this._loader.gltf);
}

@@ -70,4 +61,10 @@ /**

try {
const targetInfo = this._pathToObjectConverter.convert(pointer);
return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad);
const obj = this._pathToObjectConverter.convert(pointer);
if (!obj.info.interpolation) {
throw new Error(`${extensionContext}/pointer: Interpolation is missing`);
}
return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, {
object: obj.object,
info: obj.info.interpolation,
}, onLoad);
}

@@ -74,0 +71,0 @@ catch (e) {

import type { GLTFLoader } from "../glTFLoader";
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
import type { Scene } from "@babylonjs/core/scene.js";
declare module "../../glTFFileLoader" {

@@ -31,3 +32,8 @@ interface GLTFLoaderExtensionOptions {

dispose(): void;
onReady(): void;
onReady(): Promise<void>;
}
/**
* @internal
* populates the object model with the interactivity extension
*/
export declare function _AddInteractivityObjectModel(scene: Scene): void;
import { FlowGraphCoordinator } from "@babylonjs/core/FlowGraph/flowGraphCoordinator.js";
import { FlowGraph } from "@babylonjs/core/FlowGraph/flowGraph.js";
import { convertGLTFToSerializedFlowGraph } from "./interactivityFunctions.js";
import { InteractivityPathToObjectConverter } from "./interactivityPathToObjectConverter.js";
import { ParseFlowGraphAsync } from "@babylonjs/core/FlowGraph/flowGraphParser.js";
import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
import { AddObjectAccessorToKey, GetPathToObjectConverter } from "./objectModelMapping.js";
import { InteractivityGraphToFlowGraphParser } from "./KHR_interactivity/interactivityGraphParser.js";
import { addToBlockFactory } from "@babylonjs/core/FlowGraph/Blocks/flowGraphBlockFactory.js";
import { Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
const NAME = "KHR_interactivity";

@@ -22,3 +24,10 @@ /**

this.enabled = this._loader.isExtensionUsed(NAME);
this._pathConverter = new InteractivityPathToObjectConverter(this._loader.gltf);
this._pathConverter = GetPathToObjectConverter(this._loader.gltf);
// avoid starting animations automatically.
_loader._skipStartAnimationStep = true;
// Update object model with new pointers
const scene = _loader.babylonScene;
if (scene) {
_AddInteractivityObjectModel(scene);
}
}

@@ -29,3 +38,3 @@ dispose() {

}
onReady() {
async onReady() {
if (!this._loader.babylonScene || !this._pathConverter) {

@@ -36,10 +45,99 @@ return;

const interactivityDefinition = this._loader.gltf.extensions?.KHR_interactivity;
const json = convertGLTFToSerializedFlowGraph(interactivityDefinition);
if (!interactivityDefinition) {
// This can technically throw, but it's not a critical error
return;
}
const coordinator = new FlowGraphCoordinator({ scene });
FlowGraph.Parse(json, { coordinator, pathConverter: this._pathConverter });
const graphs = interactivityDefinition.graphs.map((graph) => {
const parser = new InteractivityGraphToFlowGraphParser(graph, this._loader.gltf, this._loader);
return parser.serializeToFlowGraph();
});
// parse each graph async
await Promise.all(graphs.map((graph) => ParseFlowGraphAsync(graph, { coordinator, pathConverter: this._pathConverter })));
coordinator.start();
}
}
/**
* @internal
* populates the object model with the interactivity extension
*/
export function _AddInteractivityObjectModel(scene) {
// Note - all of those are read-only, as per the specs!
// active camera rotation
AddObjectAccessorToKey("/extensions/KHR_interactivity/?/activeCamera/rotation", {
get: () => {
if (!scene.activeCamera) {
return new Quaternion(NaN, NaN, NaN, NaN);
}
return Quaternion.FromRotationMatrix(scene.activeCamera.getWorldMatrix()).normalize();
},
type: "Quaternion",
getTarget: () => scene.activeCamera,
});
// activeCamera position
AddObjectAccessorToKey("/extensions/KHR_interactivity/?/activeCamera/position", {
get: () => {
if (!scene.activeCamera) {
return new Vector3(NaN, NaN, NaN);
}
return scene.activeCamera.position; // not global position
},
type: "Vector3",
getTarget: () => scene.activeCamera,
});
// /animations/{} pointers:
AddObjectAccessorToKey("/animations/{}/extensions/KHR_interactivity/isPlaying", {
get: (animation) => {
return animation._babylonAnimationGroup?.isPlaying ?? false;
},
type: "boolean",
getTarget: (animation) => {
return animation._babylonAnimationGroup;
},
});
AddObjectAccessorToKey("/animations/{}/extensions/KHR_interactivity/minTime", {
get: (animation) => {
return (animation._babylonAnimationGroup?.from ?? 0) / 60; // fixed factor for duration-to-frames conversion
},
type: "number",
getTarget: (animation) => {
return animation._babylonAnimationGroup;
},
});
AddObjectAccessorToKey("/animations/{}/extensions/KHR_interactivity/maxTime", {
get: (animation) => {
return (animation._babylonAnimationGroup?.to ?? 0) / 60; // fixed factor for duration-to-frames conversion
},
type: "number",
getTarget: (animation) => {
return animation._babylonAnimationGroup;
},
});
// playhead
AddObjectAccessorToKey("/animations/{}/extensions/KHR_interactivity/playhead", {
get: (animation) => {
return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion
},
type: "number",
getTarget: (animation) => {
return animation._babylonAnimationGroup;
},
});
//virtualPlayhead - TODO, do we support this property in our animations? getCurrentFrame is the only method we have for this.
AddObjectAccessorToKey("/animations/{}/extensions/KHR_interactivity/virtualPlayhead", {
get: (animation) => {
return (animation._babylonAnimationGroup?.getCurrentFrame() ?? 0) / 60; // fixed factor for duration-to-frames conversion
},
type: "number",
getTarget: (animation) => {
return animation._babylonAnimationGroup;
},
});
}
// Register flow graph blocks. Do it here so they are available when the extension is enabled.
addToBlockFactory(NAME, "FlowGraphGLTFDataProvider", async () => {
return (await import("./KHR_interactivity/flowGraphGLTFDataProvider.js")).FlowGraphGLTFDataProvider;
});
unregisterGLTFExtension(NAME);
registerGLTFExtension(NAME, true, (loader) => new KHR_interactivity(loader));
//# sourceMappingURL=KHR_interactivity.js.map
import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
import { addNewInteractivityFlowGraphMapping } from "./KHR_interactivity/declarationMapper.js";
import { AddObjectAccessorToKey } from "./objectModelMapping.js";
const NAME = "KHR_node_hoverability";
// interactivity
const meshPointerOverPrefix = "targetMeshPointerOver_";
addNewInteractivityFlowGraphMapping("event/onHoverIn", NAME, {
// using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)
blocks: ["FlowGraphPointerOverEventBlock" /* FlowGraphBlockNames.PointerOverEvent */, "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */, "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */, "KHR_interactivity/FlowGraphGLTFDataProvider"],
configuration: {
stopPropagation: { name: "stopPropagation" },
nodeIndex: {
name: "variable",
toBlock: "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
dataTransformer(data) {
return [meshPointerOverPrefix + data[0]];
},
},
},
outputs: {
values: {
hoverNodeIndex: { name: "index", toBlock: "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */ },
controllerIndex: { name: "pointerId" },
},
flows: {
out: { name: "done" },
},
},
interBlockConnectors: [
{
input: "targetMesh",
output: "value",
inputBlockIndex: 0,
outputBlockIndex: 1,
isVariable: true,
},
{
input: "array",
output: "nodes",
inputBlockIndex: 2,
outputBlockIndex: 3,
isVariable: true,
},
{
input: "object",
output: "meshUnderPointer",
inputBlockIndex: 2,
outputBlockIndex: 0,
isVariable: true,
},
],
extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
// add the glTF to the configuration of the last serialized object
const serializedObject = serializedObjects[serializedObjects.length - 1];
serializedObject.config = serializedObject.config || {};
serializedObject.config.glTF = globalGLTF;
// find the listener nodeIndex value
const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value[0];
if (nodeIndex === undefined || typeof nodeIndex !== "number") {
throw new Error("nodeIndex not found in configuration");
}
const variableName = meshPointerOverPrefix + nodeIndex;
// find the nodeIndex value
serializedObjects[1].config.variable = variableName;
context._userVariables[variableName] = {
className: "Mesh",
id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
};
return serializedObjects;
},
});
const meshPointerOutPrefix = "targetMeshPointerOut_";
addNewInteractivityFlowGraphMapping("event/onHoverOut", NAME, {
// using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)
blocks: ["FlowGraphPointerOutEventBlock" /* FlowGraphBlockNames.PointerOutEvent */, "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */, "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */, "KHR_interactivity/FlowGraphGLTFDataProvider"],
configuration: {
stopPropagation: { name: "stopPropagation" },
nodeIndex: {
name: "variable",
toBlock: "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
dataTransformer(data) {
return [meshPointerOutPrefix + data[0]];
},
},
},
outputs: {
values: {
hoverNodeIndex: { name: "index", toBlock: "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */ },
controllerIndex: { name: "pointerId" },
},
flows: {
out: { name: "done" },
},
},
interBlockConnectors: [
{
input: "targetMesh",
output: "value",
inputBlockIndex: 0,
outputBlockIndex: 1,
isVariable: true,
},
{
input: "array",
output: "nodes",
inputBlockIndex: 2,
outputBlockIndex: 3,
isVariable: true,
},
{
input: "object",
output: "meshOutOfPointer",
inputBlockIndex: 2,
outputBlockIndex: 0,
isVariable: true,
},
],
extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
// add the glTF to the configuration of the last serialized object
const serializedObject = serializedObjects[serializedObjects.length - 1];
serializedObject.config = serializedObject.config || {};
serializedObject.config.glTF = globalGLTF;
const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value[0];
if (nodeIndex === undefined || typeof nodeIndex !== "number") {
throw new Error("nodeIndex not found in configuration");
}
const variableName = meshPointerOutPrefix + nodeIndex;
// find the nodeIndex value
serializedObjects[1].config.variable = variableName;
context._userVariables[variableName] = {
className: "Mesh",
id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
};
return serializedObjects;
},
});
AddObjectAccessorToKey("/nodes/{}/extensions/KHR_node_hoverability/hoverable", {
get: (node) => {
const tn = node._babylonTransformNode;
if (tn && tn.pointerOverDisableMeshTesting !== undefined) {
return tn.pointerOverDisableMeshTesting;
}
return true;
},
set: (value, node) => {
node._primitiveBabylonMeshes?.forEach((mesh) => {
mesh.pointerOverDisableMeshTesting = !value;
});
},
getTarget: (node) => node._babylonTransformNode,
getPropertyName: [() => "pointerOverDisableMeshTesting"],
type: "boolean",
});
/**

@@ -4,0 +157,0 @@ * Loader extension for KHR_node_hoverability

import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
import { AddObjectAccessorToKey } from "./objectModelMapping.js";
const NAME = "KHR_node_visibility";
// object model extension for visibility
AddObjectAccessorToKey("/nodes/{}/extensions/KHR_node_visibility/visible", {
get: (node) => {
const tn = node._babylonTransformNode;
if (tn && tn.isVisible !== undefined) {
return tn.isVisible;
}
return true;
},
set: (value, node) => {
node._primitiveBabylonMeshes?.forEach((mesh) => {
mesh.inheritVisibility = true;
});
if (node._babylonTransformNode) {
node._babylonTransformNode.isVisible = value;
}
node._primitiveBabylonMeshes?.forEach((mesh) => {
mesh.isVisible = value;
});
},
getTarget: (node) => node._babylonTransformNode,
getPropertyName: [() => "isVisible"],
type: "boolean",
});
/**

@@ -4,0 +29,0 @@ * Loader extension for KHR_node_visibility

@@ -25,2 +25,3 @@ import type { IndicesArray, Nullable } from "@babylonjs/core/types.js";

import type { GLTFExtensionFactory } from "./glTFLoaderExtensionRegistry";
import type { IInterpolationPropertyInfo } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
export { GLTFFileLoader };

@@ -79,2 +80,4 @@ interface IWithMetadata {

_allMaterialsDirtyRequired: boolean;
/** @internal */
_skipStartAnimationStep: boolean;
private readonly _parent;

@@ -237,3 +240,3 @@ private readonly _extensions;

*/
_loadAnimationChannelFromTargetInfoAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, targetInfo: IObjectInfo<AnimationPropertyInfo[]>, onLoad: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): Promise<void>;
_loadAnimationChannelFromTargetInfoAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, targetInfo: IObjectInfo<IInterpolationPropertyInfo[]>, onLoad: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): Promise<void>;
private _loadAnimationSamplerAsync;

@@ -240,0 +243,0 @@ /**

@@ -23,3 +23,6 @@ import { Animation } from "@babylonjs/core/Animations/animation.js";

/** @internal */
abstract buildAnimations(target: any, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
abstract buildAnimations(target: any, name: string, fps: number, keys: any[]): {
babylonAnimatable: IAnimatable;
babylonAnimation: Animation;
}[];
}

@@ -29,14 +32,13 @@ /** @internal */

/** @internal */
buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
buildAnimations(target: INode, name: string, fps: number, keys: any[]): {
babylonAnimatable: IAnimatable;
babylonAnimation: Animation;
}[];
}
/** @internal */
export declare class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
buildAnimations(target: INode, name: string, fps: number, keys: any[], callback: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): void;
buildAnimations(target: INode, name: string, fps: number, keys: any[]): {
babylonAnimatable: IAnimatable;
babylonAnimation: Animation;
}[];
}
/** @internal */
export declare const nodeAnimationData: {
translation: TransformNodeAnimationPropertyInfo[];
rotation: TransformNodeAnimationPropertyInfo[];
scale: TransformNodeAnimationPropertyInfo[];
weights: WeightAnimationPropertyInfo[];
};
import { Animation } from "@babylonjs/core/Animations/animation.js";
import { Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
import { SetInterpolationForKey } from "./Extensions/objectModelMapping.js";
/** @internal */

@@ -37,4 +38,6 @@ export function getVector3(_target, source, offset, scale) {

/** @internal */
buildAnimations(target, name, fps, keys, callback) {
callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys));
buildAnimations(target, name, fps, keys) {
const babylonAnimations = [];
babylonAnimations.push({ babylonAnimatable: target._babylonTransformNode, babylonAnimation: this._buildAnimation(name, fps, keys) });
return babylonAnimations;
}

@@ -44,3 +47,4 @@ }

export class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
buildAnimations(target, name, fps, keys, callback) {
buildAnimations(target, name, fps, keys) {
const babylonAnimations = [];
if (target._numMorphTargets) {

@@ -62,3 +66,3 @@ for (let targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) {

morphTarget.animations.push(babylonAnimationClone);
callback(morphTarget, babylonAnimationClone);
babylonAnimations.push({ babylonAnimatable: morphTarget, babylonAnimation: babylonAnimationClone });
}

@@ -69,11 +73,9 @@ }

}
return babylonAnimations;
}
}
/** @internal */
export const nodeAnimationData = {
translation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, () => 3)],
rotation: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, () => 4)],
scale: [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, () => 3)],
weights: [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, (target) => target._numMorphTargets)],
};
SetInterpolationForKey("/nodes/{}/translation", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, () => 3)]);
SetInterpolationForKey("/nodes/{}/rotation", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, () => 4)]);
SetInterpolationForKey("/nodes/{}/scale", [new TransformNodeAnimationPropertyInfo(Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, () => 3)]);
SetInterpolationForKey("/nodes/{}/weights", [new WeightAnimationPropertyInfo(Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, (target) => target._numMorphTargets)]);
//# sourceMappingURL=glTFLoaderAnimation.js.map

@@ -5,2 +5,3 @@ export * from "./glTFLoader";

export * from "./glTFLoaderInterfaces";
export * from "./glTFLoaderAnimation";
export * from "./Extensions/index";

@@ -6,3 +6,4 @@ /* eslint-disable import/no-internal-modules */

export * from "./glTFLoaderInterfaces.js";
export * from "./glTFLoaderAnimation.js";
export * from "./Extensions/index.js";
//# sourceMappingURL=index.js.map
{
"name": "@babylonjs/loaders",
"version": "7.51.1",
"version": "7.51.2",
"main": "index.js",

@@ -21,6 +21,6 @@ "module": "index.js",

"devDependencies": {
"@babylonjs/core": "^7.51.1",
"@babylonjs/core": "^7.51.2",
"@dev/build-tools": "^1.0.0",
"@lts/loaders": "^1.0.0",
"babylonjs-gltf2interface": "^7.51.1"
"babylonjs-gltf2interface": "^7.51.2"
},

@@ -27,0 +27,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet