Skip to content

Support morph target weights in glTF animation pointer and interactivity #16778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphA
}

public override _doOperation(context: FlowGraphContext): P {
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
const value = accessorContainer.info.get(accessorContainer.object) as P;
const object = accessorContainer.info.getTarget?.(accessorContainer.object);
const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);
const accessor = this.templateComponent.getAccessor(this.config.pathConverter, context);
const value = accessor.info.get(accessor.object, accessor.index) as P;
const object = accessor.info.getTarget?.(accessor.object, accessor.index);
const propertyName = accessor.info.getPropertyName?.[0](accessor.object);
if (!object) {
throw new Error("Object is undefined");
} else {
Expand All @@ -101,18 +101,18 @@ export class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphA
}

private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
const type = accessorContainer.info.type;
const accessor = this.templateComponent.getAccessor(this.config.pathConverter, context);
const type = accessor.info.type;
if (type.startsWith("Color")) {
value = ToColor(value as Vector4, type) as unknown as P;
}
accessorContainer.info.set?.(value, accessorContainer.object);
accessor.info.set?.(value, accessor.object, accessor.index);
}

private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
const type = accessorContainer.info.type;
const value = accessorContainer.info.get(accessorContainer.object);
const accessor = this.templateComponent.getAccessor(this.config.pathConverter, context);
const type = accessor.info.type;
const value = accessor.info.get(accessor.object, accessor.index);
if (type.startsWith("Color")) {
return FromColor(value as Color3 | Color4) as unknown as P;
}
Expand All @@ -124,11 +124,11 @@ export class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphA
_propertyName: string,
context: FlowGraphContext
): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
const accessor = this.templateComponent.getAccessor(this.config.pathConverter, context);
return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {
const animations: Animation[] = [];
// make sure keys are of the right type (in case of float3 color/vector)
const type = accessorContainer.info.type;
const type = accessor.info.type;
if (type.startsWith("Color")) {
keys = keys.map((key) => {
return {
Expand All @@ -137,8 +137,8 @@ export class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphA
};
});
}
accessorContainer.info.interpolation?.forEach((info, index) => {
const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || "Animation-interpolation-" + index;
accessor.info.interpolation?.forEach((info, index) => {
const name = accessor.info.getPropertyName?.[index](accessor.object) || "Animation-interpolation-" + index;
// generate the keys based on interpolation info
let newKeys: any[] = keys;
if (animationType !== info.type) {
Expand All @@ -150,7 +150,7 @@ export class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphA
};
});
}
const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);
const animationData = info.buildAnimations(accessor.object, name, 60, newKeys);
for (const animation of animationData) {
if (easingFunction) {
animation.babylonAnimation.setEasingFunction(easingFunction);
Expand Down
5 changes: 4 additions & 1 deletion packages/dev/core/src/ObjectModel/objectModelInterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/**
* A container with an original object and information about that object.
* on some other object.
*/
export interface IObjectInfo<T, O = any> {
/**
* The original object.
*/
object: O;
/**
* The index of the array in question when applicable.
*/
index?: number;
/**
* Information about the object.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ export class EXT_lights_image_based implements IGLTFLoaderExtension {
}
}

/**
* @internal
*/
/** @internal */
// eslint-disable-next-line no-restricted-syntax
public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {
return GLTFLoader.LoadExtensionAsync<IEXTLightsImageBased_LightReferenceImageBased>(context, scene, this.name, async (extensionContext, extension) => {
Expand Down
Loading
Loading