base/obb
회전된 바운딩 박스.
Rotated bounding box.
OBBextends Object
회전된 바운딩 박스.
Rotated bounding box.
import { OBB, Vector2 } from "./build/vanilla.js";
const box = new OBB();
box.setEdges([Vector2.create(0, 0), Vector2.create(10, 0), Vector2.create(10, 10), Vector2.create(0, 10)]);
const diamond = new OBB();
diamond.setEdges([Vector2.create(15, 5), Vector2.create(20, 10), Vector2.create(15, 15), Vector2.create(8, 10)]);
const point = Vector2.create(5, 5);
console.log(box.contains(point), box.overlaps(diamond));좌표와 충돌 검출.
Collision detection with a point.
- viewPositionVector2
- 검사할 점. (모서리와 같은 좌표계)Point to test. (in the same coordinate space as the corners)
반환Returnsboolean 점이 모서리들이 이루는 사각형 안에 있으면 참. (null 이거나 Vector2 가 아니면 거짓)True if the point is inside the quadrilateral formed by the corners. (false if null or not a Vector2)
짝Counterpart: vanilla-engine OBB.contains
분리축 정리(SAT)를 이용한 다각형(OBB) 간의 충돌 검출.
Collision detection between polygons (OBB) using the separating axis theorem (SAT).
- otherOBB
- 검사할 상자.Box to test.
반환Returnsboolean 겹치면 참. (변이 닿기만 해도 참)True if they overlap. (also true if the edges only touch)
짝Counterpart: vanilla-engine OBB.overlaps
모서리 목록 설정.
Sets the corner list.
- edgesVector2[]
- 모서리 4 개. (둘레를 따라 차례로, 벡터를 복사하지 않고 그대로 담는다, 4 개가 아니면 오류를 던진다)The 4 corners. (in order around the perimeter, stored as is without copying, throws an error if not 4)
반환ReturnsVector2[] 돌려주는 값 없음. (undefined)Returns nothing. (undefined)
짝Counterpart: vanilla-engine OBB.set_edges
모서리 목록 반환.
Returns the corner list.
반환ReturnsVector2[] 모서리 4 개. (내부 배열을 그대로 돌려준다)The 4 corners. (returns the internal array as is)
짝Counterpart: vanilla-engine OBB.get_edges