Closed sefirosweb closed 1 year ago
@sefirosweb thank you for opening an issue, will have to give it more thought
I suppose rbush which is used for box collision would not be enought for it, but mayme somehow...
Personally, I think it is better to keep 2D and 3D collisions in separate libraries. If all your objects are extremely simple (like cubes and spheres, but not polygons), you could try having three CollisionSystems (one for xy, one for yz, and one for xz). That is extremely hacky though and probably sucks performance-wise, so I wouldn't necessarily recommend it.
thanks for clarify guys,
I'm making it detect 3 solutions for a raycast (XY / XZ / ZY) but as you indicate the adaptation is a bit stinky
Personally, I think it is better to keep 2D and 3D collisions in separate libraries. If all your objects are extremely simple (like cubes and spheres, but not polygons), you could try having three CollisionSystems (one for xy, one for yz, and one for xz). That is extremely hacky though and probably sucks performance-wise, so I wouldn't necessarily recommend it.
to build up from @Codezilluh answer
@sefirosweb I believe you'd need 2 collision systems each body would have to have bboxXY and bboxXZ
if you're talking only about the bbox collision it could be fairly easy with a fork of this library
thing is, any SAT for 3d would have to be more complex with angles, scale, offsets, and 3D on top of that
I agree that it would have to be another library, and I don't currently have plans for it
on a side note - it's not always necessary to have 3d detection in a 3d game, example: https://games.pietal.dev/space/ (use WSAD to move, space to shoot)
maybe start with something like
class XY extends RBush {}
class XZ extends RBush {
compareMinY(a, b) { return a.minZ - b.minZ }
}
class BodyXYZ {
bbox = {
minX: number;
maxX: number;
minY: number;
maxY: number;
minZ: number;
maxZ: number;
}
updateBody(xy: XY, xz: XZ) {
xy.remove(this.bbox);
xz.remove(this.bbox);
// update bbox here somehow
xy.insert(this.bbox);
xz.insert(this.bbox);
}
}
RBush from https://github.com/mourner/rbush
@sefirosweb actually maybe use this https://github.com/Eronana/rbush-3d
Thanks Prozi, i cheeck that but seems they don't support box rotatio, I was also looking at three js which is very powerful with 3D but I think I can't use the isolated collision system
yes box rotation is part of separaring axes theorem checking collision between 2 bodies. the rbushes are for broad phase search optimisations and always use boxes (or cubes in 3d)
Hi guys, one question this package can calculate the collision boxes of 3D objects? Ex raycast x cube or cube x cube
Sorry if my question is stupid i dont know if one dimension extra is huge more hard
Best!