Skip to content

Commit

Permalink
better anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliusNmn committed Mar 3, 2024
1 parent a729b1e commit e2a2fa7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/demo/Demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export class Buddy {
angle: angle,
twistAngle: twistAngle,
})

const rightFootJoint = new CANNON.ConeTwistConstraint(rightFoot, lowerRightLeg, {
pivotA: new CANNON.Vec3(0, 0, heelRadius),
pivotB: new CANNON.Vec3(0, 0, -lowerLegLength / 2),
Expand Down Expand Up @@ -340,7 +339,8 @@ export class Buddy {
this.createMusclesFrontBack(lowerLeftLeg, leftFoot, 1, new CANNON.Vec3(0, lowerLegSize, 0), muscleParams)
this.createMusclesFrontBack(lowerRightLeg, rightFoot, 1, new CANNON.Vec3(0, lowerLegSize, 0), muscleParams)
// pitch
//this.createMusclesFrontBack(lowerLeftLeg, leftFoot, 1.1, new CANNON.Vec3(lowerLegSize, 0, 0), {stiffness: 20, damping: 5})
this.createMusclesFrontBack(lowerLeftLeg, leftFoot, 1, new CANNON.Vec3(lowerLegSize / 2, 0, 0), muscleParams)
this.createMusclesFrontBack(lowerRightLeg, rightFoot, 1, new CANNON.Vec3(lowerLegSize / 2, 0, 0), muscleParams)

// upper leg muscles
// quads
Expand Down Expand Up @@ -369,8 +369,8 @@ export class Buddy {
this.createMusclesFrontBack(upperBody, upperLeftArm, 1, new CANNON.Vec3(0, upperArmSize, 0), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 - upperArmSize))
this.createMusclesFrontBack(upperBody, upperRightArm, 1, new CANNON.Vec3(0, upperArmSize, 0), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 - upperArmSize))
// up / down
this.createMusclesFrontBack(upperBody, upperLeftArm, 1, new CANNON.Vec3(0, 0, upperArmSize), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 - upperArmSize))
this.createMusclesFrontBack(upperBody, upperRightArm, 1, new CANNON.Vec3(0, 0, upperArmSize), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 - upperArmSize))
this.createMusclesFrontBack(upperBody, upperLeftArm, 1, new CANNON.Vec3(0, 0, upperArmSize), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 + upperArmSize / 2))
this.createMusclesFrontBack(upperBody, upperRightArm, 1, new CANNON.Vec3(0, 0, upperArmSize), muscleParams, new CANNON.Vec3(0, 0, upperBodyLength / 2 + upperArmSize / 2))


// left = local x positive
Expand Down Expand Up @@ -466,7 +466,9 @@ export class Physics {
this.lastCallTime = now
if (this.buddy){
for (var i = 0; i < this.buddy.muscleInterface.muscles.length; i++) {
this.buddy.muscleInterface.setMuscleContraction(i, Math.sin(now * (3 + i / 3) * ((i % 2) * 2 - 1)) * 0.2 + 0.8)
//this.buddy.muscleInterface.setMuscleContraction(i, Math.sin(now * (3 + i / 3) * ((i % 2) * 2 - 1)) * 0.1 + 0.8)
this.buddy.muscleInterface.setMuscleContraction(i, 1)

}
}

Expand Down Expand Up @@ -497,7 +499,7 @@ export class Demo {
renderer: THREE.WebGLRenderer
camera: THREE.PerspectiveCamera
physics: Physics
gravity = 0
gravity = -9.81
constructor(canvas: HTMLCanvasElement) {
this.physics = new Physics()
this.scene = new THREE.Scene()
Expand Down

0 comments on commit e2a2fa7

Please sign in to comment.