We scan the room using the RoomPlan API, and after the scan, we obtain objects with a white color along with shadows and shading. However, upon updating the color of these objects, we experience a loss of shadows and shading.
RoomPlan scan
After Update
Thanks for including the two pictures. In the second one, the new colors look like they went onto materials that ignore lighting. The walls face different directions but are exactly the same blue-gray, and the furniture has no visible edges. UnlitMaterial is "A material that doesn't respond to lights in the scene." When I replaced the materials of a RoomPlan model of a meeting room with UnlitMaterial, I got the same look. That was on an iPhone 18 Pro Max with iOS 27.2.1. In SceneKit, the .constant lighting model gives "Uniform shading that incorporates ambient lighting only," and in my test on a Mac it rendered all four walls the same shade.
SceneKit is deprecated. The SceneKit documentation says "SceneKit is deprecated, use RealityKit instead," so the code below uses RealityKit.
When I loaded the USDZ file from RoomPlan, RealityKit gave each surface a PhysicallyBasedMaterial. Replacing only the base color of those materials keeps the shading. Shadows need a light that casts them, such as a DirectionalLightComponent with a DirectionalLightComponent.Shadow. RealityKit's light components don't have a setting for how soft a shadow is. These shadows have sharper edges than the ones in your first picture. In my test, adding GroundingShadowComponent to every part of the model didn't produce visible shadows.
In the file RoomPlan exported for my scan, the walls and windows are under an entity named Arch_grp, and the floor is under Floor_grp. This code colors them and adds a light:
import RealityKit
import UIKit
// Changes the color of every mesh in an entity's hierarchy and keeps it lit,
// by replacing only the base color of each existing material.
// A material of another type becomes a lit SimpleMaterial.
@MainActor func setColor(_ color: UIColor, on entity: Entity) {
if var model = entity.components[ModelComponent.self] {
model.materials = model.materials.map { material in
if var lit = material as? PhysicallyBasedMaterial {
lit.baseColor = .init(tint: color)
return lit
}
return SimpleMaterial(color: color, roughness: 0.8, isMetallic: false)
}
entity.components.set(model)
}
for child in entity.children {
setColor(color, on: child)
}
}
// A light from above and to one side that casts shadows.
@MainActor func makeShadowLight() -> Entity {
let light = Entity()
light.components.set([DirectionalLightComponent(color: .white, intensity: 1500),
DirectionalLightComponent.Shadow()])
light.look(at: .zero, from: [-2, 6, 3], relativeTo: nil)
return light
}
// For example, in a RealityView's make closure, after loading the RoomPlan file as `room`:
// if let walls = room.findEntity(named: "Arch_grp") { setColor(.systemTeal, on: walls) }
// if let floor = room.findEntity(named: "Floor_grp") { setColor(.systemPink, on: floor) }
// content.add(makeShadowLight())
On my iPhone, the walls and floor kept their shading in the new colors. The furniture cast shadows on the floor and the back wall.