-
I have a simple mesh who's position I'm changing in animateReady <ngt-mesh ngtPhysicBox [getPhysicProps]="getCubeProps"
[position]="position" (animateReady)="animateGroup($event.state)">
<ngt-sphere-geometry [args]="[ radius, 16, 16]"></ngt-sphere-geometry>
<ngt-mesh-standard-material [parameters]="{ wireframe: true, color: 'black' }"></ngt-mesh-standard-material>
</ngt-mesh> The position is being changed to match the position of the XR motion controller is world space. animateReady(event: NgtRender) {
if (this.controller) {
const position = this.controller.position;
this.position = [position.x, position.y, position.z] as NgtVector3;
}
} However, the mesh only seems to update twice a second and is slow to track the position of the controller. I've confirmed animateReady function is being called 60 times a second. Any thoughts? If you have a VR headset, you can try the project here. Set vr=true in app.component.ts first. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Can you replicate this issue without vr mode? I have a hunch of what's going on but it'd be easier with a sample that I can run :) |
Beta Was this translation helpful? Give feedback.
-
I was able to fix by adding change detection constructor(
private cd: ChangeDetectorRef,
) { }
animateGroup(event: NgtRender) {
if (this.controller) {
this.position = this.controller.position.toArray();
this.rotation = this.controller.rotation;
this.cd.detectChanges();
}
} |
Beta Was this translation helpful? Give feedback.
I was able to fix by adding change detection