Skip to content

Commit

Permalink
Merge pull request #7 from noppefoxwolf/feature/AddColliderGroups
Browse files Browse the repository at this point in the history
Add colliderGroups
  • Loading branch information
tattn committed Dec 20, 2019
2 parents 0198707 + 864793b commit cd11a5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Sources/VRMKit/VRM/VRM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public extension VRM {

struct SecondaryAnimation: Codable {
public let boneGroups: [BoneGroup]
public let colliderGroups: [ColliderGroup]
public struct BoneGroup: Codable {
public let bones: [Int]
public let center: Int
Expand All @@ -173,6 +174,16 @@ public extension VRM {
stiffiness = try decodeDouble(key: .stiffiness, container: container)
}
}

public struct ColliderGroup: Codable {
public let node: Int
public let colliders: [Collider]

public struct Collider: Codable {
public let offset: Vector3
public let radius: Double
}
}
}

struct Vector3: Codable {
Expand Down
11 changes: 10 additions & 1 deletion Tests/VRMKit/VRMKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class VRMTests: XCTestCase {
XCTAssertEqual(vrm.firstPerson.meshAnnotations[0].mesh, 0)
}

func testSecondaryAnimation() {
func testSecondaryAnimationBoneGroups() {
let target = vrm.secondaryAnimation.boneGroups[0]
XCTAssertEqual(target.bones, [41, 49, 57, 59, 61])
XCTAssertEqual(target.center, -1)
Expand All @@ -95,4 +95,13 @@ class VRMTests: XCTestCase {
XCTAssertEqual(target.hitRadius, 0.01)
XCTAssertEqual(target.stiffiness, 0.65)
}

func testSecondaryAnimationColliderGroups() {
let target = vrm.secondaryAnimation.colliderGroups[0]
XCTAssertEqual(target.node, 34)
XCTAssertEqual(target.colliders[0].offset.x, 0.0)
XCTAssertEqual(target.colliders[0].offset.y, 0.05)
XCTAssertEqual(target.colliders[0].offset.z, 0.0)
XCTAssertEqual(target.colliders[0].radius, 0.09)
}
}

0 comments on commit cd11a5e

Please sign in to comment.