-
Can you offer any guidance on using ngtPhysicHingeConstraint? I have the following code, but I just can seem to put the last piece of the puzzle in place. <!--static-->
<ngt-mesh ngtPhysicBox [getPhysicProps]="getStaticProps"
[position]="[0, y, 0]" [scale]="scale" [castShadow]="true">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
<!--hinge-->
<ng-container ngtPhysicHingeConstraint [options]="{pivotB:[0, -2.5, 0], axisB:[-1,0,0]}" #constraint="ngtCannonConstraint">
<ngt-mesh #hinge="ngtMesh" ngtPhysicBox [getPhysicProps]="getHingeProps" (ready)="ready(constraint, hinge.mesh)"
[position]="[0, 3, 0]" [scale]="scale" [castShadow]="true">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
</ng-container> where ready function looks like this ready(constraint: NgtCannonConstraintController, mesh: Mesh) {
constraint.setBodies(mesh);
} I'm trying to represent this const constraint = new CANNON.HingeConstraint(staticBody, hingedBody, {
pivotA: new CANNON.Vec3(0, -size * 0.5 - distance, 0),
axisA: new CANNON.Vec3(-1, 0, 0),
pivotB: new CANNON.Vec3(0, size * 0.5 + distance, 0),
axisB: new CANNON.Vec3(-1, 0, 0),
}) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I also tried this, but it doesn't work <ng-container ngtPhysicHingeConstraint [options]="options" #constraint="ngtCannonConstraint">
<!--static-->
<ngt-mesh #static="ngtMesh" [name]="'static'" ngtPhysicBox [getPhysicProps]="getStaticProps" (ready)="ready(constraint, static.mesh)"
[position]="[0, y, 0]" [scale]="scale" [castShadow]="true">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
<!--hinge-->
<ngt-mesh #hinge="ngtMesh" [name]="'hinge'" ngtPhysicBox [getPhysicProps]="getHingeProps" (ready)="ready(constraint, hinge.mesh)"
[position]="[0, 3, 0]" [scale]="scale" [castShadow]="true">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
</ng-container> options: Record<string, unknown> = {
pivotA: [0, -this.size * 0.5 - this.distance, 0],
axisA: [-1, 0, 0],
pivotB: [0, this.size * 0.5 + this.distance, 0],
axisB: [-1, 0, 0],
} |
Beta Was this translation helpful? Give feedback.
-
Hi @IRobot1, sorry I haven't been able to get back to your issues/discussions. I've been feeling a bit of a burn-out lately so I'm slow on getting back to Angular Three. In addition, there are quite a few changes to the THREE.js ecosystem (with r139 release). Not going to promise anything but I'll get back to Angular Three as soon as I feel better. PS: I've read everything. Just can't find the time or the will to respond, sorry for that :( |
Beta Was this translation helpful? Give feedback.
-
No problem. I understand. I go though periods of low motivation too. Take all the time you need. Good news! I was able to figure it out. Once I understand what the container was being used for, the solution was much simpler. <ng-container ngtPhysicHingeConstraint [options]="options">
<!--static-->
<ngt-mesh ngtPhysicBox [getPhysicProps]="getStaticProps"
[position]="[0, size, 0]" [scale]="scale" [castShadow]="true">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
<!--hinge-->
<ngt-mesh ngtPhysicBox [getPhysicProps]="getHingeProps"
[position]="[0, size/2-1, 0]" [scale]="scale" [castShadow]="true" [rotation]="[0, 0, 20 | radian]">
<ngt-box-geometry></ngt-box-geometry>
<ngt-mesh-standard-material></ngt-mesh-standard-material>
</ngt-mesh>
</ng-container> With a bit of luck, I should be able to finish the other constraint examples now. |
Beta Was this translation helpful? Give feedback.
No problem. I understand. I go though periods of low motivation too. Take all the time you need.
Good news! I was able to figure it out. Once I understand what the container was being used for, the solution was much simpler.