This repository was archived by the owner on Feb 10, 2023. It is now read-only.
Replies: 1 comment 1 reply
-
|
The following works. However, the 'object' in NgtObjectController isn't immediately available. Is there a ready event that can be hooked into? This way, I can initialize the mixer once, rather than on every click. @Directive({
selector: '[button]',
})
export class DirectiveButtonComponent {
constructor(
private object3dController: NgtObjectController,
private object3dInputsController: NgtObjectInputsController,
) {
this.object3dInputsController.click.subscribe(next => {
this.mixer = new AnimationMixer(this.object3dController.object);
this.action = this.mixer.clipAction(this.clip);
this.action.loop = LoopOnce;
this.startanimation();
});
this.object3dController.animateReady.subscribe(next => {
if (this.mixer)
this.tick(next.state);
})
}
@Output() clicked = new EventEmitter<boolean>();
private clicktime = 0.1;
private positionKF = new VectorKeyframeTrack('.position', [0, this.clicktime * 2 / 3, this.clicktime], [
0, 0, 0,
0, -0.05, 0,
0, 0, 0,
]);
private clip = new AnimationClip('Action', this.clicktime, [this.positionKF]);
private mixer!: AnimationMixer;
private action!: AnimationAction;
startanimation() {
this.action.reset();
this.action.play();
this.clicked.emit(true);
}
tick({ delta }: NgtRender) {
this.mixer.update(delta);
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've created a button directive that I can add to an ngt object. When the object is clicked, I want it to briefly animate the object, in this case, a mesh
I've discovered NgtObjectInputsController, but not sure if that's what I should be using to access the host element.
If I subscribe to click in the constructor, I see the console message logged. However, if I move this code into AfterViewInit, it doesn't fire anymore.
How do I hook into the host elements animateReady handler? The short animation needs to tick for a few 100 milliseconds.
Beta Was this translation helpful? Give feedback.
All reactions