mixed-reality-extension-sdk
mixed-reality-extension-sdk copied to clipboard
Resetting a transform is ignored after animating
Editing a transform doesn't work after an animation has completed and a new parent is set
Repros:
- Animate app transform
- When done, change parent
- Set local transform
Please define "doesn't work". Is the new transform ignored, or does the actor appear in the wrong place?
Here's a min repro (with v0.18):
private started() {
this.assets = new MRE.AssetContainer(this.context);
const boxMesh = this.assets.createBoxMesh("box", 1, 1, 1);
const child = Actor.Create(this.context, {
actor: {
name: "Child",
appearance: {
meshId: boxMesh.id
},
transform: {
local: { scale: Vector3.One().scale(0.3) }
}
}
});
const parent = Actor.Create(this.context, {
actor: {
name: "Parent",
transform: {
local: {
position: { x: 0.1 }
}
}
}
});
console.log("Starting timer");
setTimeout(() => {
const promise = child.animateTo(
{ transform: { local: {
position: parent.transform.local.position
}}},
5.0,
AnimationEaseCurves.EaseInQuintic);
promise.then(() => {
child.transform.local.position = Vector3.Zero(); // <--- Doesn't work
child.parent = parent; // <--- Works
child.transform.local.position = Vector3.Zero(); // <--- Doesn't work
});
}, 5000);
}
The change to the local position is ignored. It is ignored because the value being set (0,0,0) is the same as the value that was set before the animation ran. The MRE server has no subscription and is unaware that the local position has changed since then, and so it ignores what looks like a no-op.
The parent stuff does not appear to be relevant, here is a reduced repro:
import * as MRE from '@microsoft/mixed-reality-extension-sdk';
export default class Repro {
constructor(private context: MRE.Context, private baseUrl: string) {
context.onStarted(() => {
const assets = new MRE.AssetContainer(this.context);
const box = MRE.Actor.CreatePrimitive(assets, {
definition: {
shape: MRE.PrimitiveShape.Box
},
actor: {
name: "Box",
}
});
const promise = box.animateTo({
transform: {
local: {
position: { x: 1 }
}
}
}, 5.0, MRE.AnimationEaseCurves.Linear);
promise.then(() => {
console.log("Transform is " + box.transform.local.position.x); // prints "Transform is 0"
box.transform.local.position.x = 0; // Has no effect. On the client, transform's X value remains 1.
});
});
}
}