Skip to content

Commit

Permalink
Fixed #642: Can mapLayers on SUF
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 26, 2023
1 parent d733e57 commit a3f6bcd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ final case class SceneUpdateFragment(
def withLayers(layers: Layer*): SceneUpdateFragment =
withLayers(layers.toBatch)

def mapLayers(f: Layer => Layer): SceneUpdateFragment =
this.copy(layers = layers.map(f))

def noLights: SceneUpdateFragment =
this.copy(lights = Batch.empty)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,18 @@ class SceneUpdateFragmentTests extends munit.FunSuite {
fail("match failed")
}

test("Map over layers") {
val scene =
SceneUpdateFragment.empty
.addLayer(Layer(BindingKey("key A")).withMagnification(1))
.addLayer(Layer(BindingKey("key B")).withMagnification(1))

val actual =
scene.mapLayers(l => l.withKey(BindingKey(l.key.map(_.toString).getOrElse("!") + "?")).withMagnification(2))

assert(actual.layers.length == 2)
assertEquals(actual.layers.map(_.key.get).toList, List(BindingKey("key A?"), BindingKey("key B?")))
assertEquals(actual.layers.map(_.magnification.get).toList, List(2, 2))
}

}

0 comments on commit a3f6bcd

Please sign in to comment.