javascript - ThreeJS collisions with SAT missaligned collision boxes -
i'm working on simple game school, have encountered problem making collisions. collision boxes seems miss aligned.
here game: http://ggeasy.herokuapp.com/game
those little boxes drawn this:
for(var x = 0; x < colliderpolygon.points.length; x++){ var test = new three.mesh(new three.cubegeometry(8,8,8),material) test.position.x = colliderpolygon.pos.x + colliderpolygon.calcpoints[x].x test.position.z = colliderpolygon.pos.y + colliderpolygon.calcpoints[x].y this.mesh.add(test) }
i translated collision, because in theory threejs position bound bottom center of box , in sat it's bound left top corner of box.
whole program's code available here: https://github.com/hajtosek/ggeasy
any ideas, have did wrong?
ok, key understand position binding points.
three.js has ind middle of mesh, sat has in top left corner. var collider = new sat.box(new sat.vector(cubemesh.position.x - halfwidth, cubemesh.position.z - halfheight), width, height);
Comments
Post a Comment