GeOnDT GeOnDT for JS

Class: UCollisionManager

UCollisionManager

여러 Collider를 균일 격자에 등록하고 정밀 충돌 판정 전에 공간 후보를 줄이는 broad-phase 관리자입니다.

비교 대상이 하나이거나 이미 정해진 소수이면 Collider의 intersects()를 직접 호출하십시오. 이 경우에는 줄일 후보가 없으므로 등록, 위치 인덱스 갱신, 후보 배열 생성과 그룹 필터링 비용이 추가될 수 있습니다. 등록된 Collider가 많고 가능한 비교 쌍 중 상당수를 공간 인덱스로 제외할 수 있을 때 이 관리자를 사용하십시오. 유리해지는 고정 개수는 없으며 Collider 크기·분포·이동 빈도를 포함한 실제 장면에서 측정하여 선택해야 합니다.

new UCollisionManager(opt)

다수 Collider의 공간 후보와 충돌 쌍을 관리합니다.

Name Type Default Description
opt object {} optional
Name Type Default Description
cellSize number 400 optional
scheduled boolean false optional
interval number 20 optional

Methods

addCollider(collider)boolean

collider를 manager에 등록하고 grid index에 추가합니다.

Name Type Description
collider UCollider
Returns:
Type Description
boolean

clear()

등록된 모든 collider와 grid index 상태를 초기화합니다.

getCandidates(colliderOrId)Array.<UCollider>

특정 collider와 AABB가 겹칠 가능성이 있는 후보 collider를 조회합니다.

Name Type Description
colliderOrId UCollider | string
Returns:
Type Description
Array.<UCollider>

getColliderByName(name)undefined|UCollider

collider id 또는 target.name으로 collider를 조회합니다.

Name Type Description
name string
Returns:
Type Description
undefined | UCollider

getColliders()Array.<UCollider>

현재 등록된 모든 collider를 반환합니다.

Returns:
Type Description
Array.<UCollider>

getCollidersByTarget(target)Array.<UCollider>

같은 target에 붙은 collider를 모두 조회합니다. 한 객체에 여러 collider(본체·부속 등)를 붙인 경우에 사용합니다. target은 객체 참조(===) 또는 target.name 문자열로 지정할 수 있습니다.

Name Type Description
target unknown

대상 객체 참조 또는 target.name

Returns:
Type Description
Array.<UCollider> 등록 순서대로 정렬된 collider 목록. 없으면 빈 배열

getIntersections(colliderOrId, updateIndex)Array.<UCollider>

특정 collider 기준으로 실제 충돌 중인 collider 목록을 조회합니다.

Name Type Default Description
colliderOrId UCollider | string
updateIndex boolean true optional

true면 조회 전에 pending collider 위치 변경을 grid index에 반영합니다.

Returns:
Type Description
Array.<UCollider>

getIntersectionsByGroup(groupName, updateIndex)Array.<UCollisionManager~CollisionHitInfo>

특정 groupName의 collider들을 기준으로 실제 충돌 중인 collider 쌍을 조회합니다.

Name Type Default Description
groupName string
updateIndex boolean true optional

true면 조회 전에 pending collider 위치 변경을 grid index에 반영합니다.

Returns:
Type Description
Array.<UCollisionManager~CollisionHitInfo>

getIntersectionsForGroups(sourceGroupName, targetGroupName, updateIndex)Array.<UCollisionManager~CollisionHitInfo>

source group과 target group 사이의 실제 충돌 쌍을 조회합니다.

Name Type Default Description
sourceGroupName string
targetGroupName string
updateIndex boolean true optional

true면 조회 전에 pending collider 위치 변경을 grid index에 반영합니다.

Returns:
Type Description
Array.<UCollisionManager~CollisionHitInfo>

removeCollider(colliderOrId)boolean

collider를 manager와 grid index에서 제거합니다.

Name Type Description
colliderOrId UCollider | string
Returns:
Type Description
boolean

updateCollider(colliderOrId, position)boolean

등록된 collider의 위치 변경을 반영하고 grid index 갱신을 예약합니다.

Name Type Description
colliderOrId UCollider | string
position WorldPositionVector3 optional
Returns:
Type Description
boolean