Assuming you set up a physics body for your entity in Reality Composer, you can actually directly get the mass of the physics body:
// Load the scene from your .rcproject.
let sceneAnchor = try! MyRealityComposerProject.loadScene()
// Get a reference to the entity that you configured a physics body for.
let box = sceneAnchor.box
// Get the physics body from the entity's component set.
guard let physicsBody = box?.components[PhysicsBodyComponent.self] as? PhysicsBodyComponent else {
fatalError("box has no PhysicsBodyComponent.")
}
// Access the mass properties of the physics body.
print(physicsBody.massProperties.mass)