Skip to content

Commit c4d1dd1

Browse files
evil159github-actions[bot]
authored andcommitted
Fix 3d puck switching (#11873)
This fixes an issue introduced in mapbox/mapbox-sdk#9292 when old 3d puck model will remain on the screen after changing 3D puck model to another one. https://mapbox.atlassian.net/browse/MAPSIOS-2150 cc @mapbox/maps-ios cc @mapbox/sdk-platform GitOrigin-RevId: 46fd028ca5c16befe2bf12ab14c1f5818a73851e
1 parent 828db50 commit c4d1dd1

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Mapbox welcomes participation and contributions from everyone.
44

55
## main
66

7+
* Fix old 3D puck model remaining after updating the puck model.
8+
79
## 11.21.0 - 02 April, 2026
810

911
## 11.21.0-rc.1 - 23 March, 2026

Sources/MapboxMaps/Location/Puck/Puck3DRenderer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ final class Puck3DRenderer: PuckRenderer {
3232

3333
private func updateSourceModel(newState: PuckRendererState<Puck3DConfiguration>, oldState: PuckRendererState<Puck3DConfiguration>?) {
3434
var model = newState.configuration.model
35+
model.id = "puck-model"
3536
model.position = [newState.coordinate.longitude, newState.coordinate.latitude]
3637

3738
model.orientation = model.orientation

Tests/MapboxMapsTests/Location/Puck/Puck3DRendererTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class Puck3DRendererTests: XCTestCase {
1818
}
1919

2020
func test_SetNewState_With3DPuck_StartsRendering() throws {
21-
let configuration = Puck3DConfiguration(model: Model())
21+
let configuration = Puck3DConfiguration(model: Model(id: "puck-model"))
2222
let newState: PuckRendererState = .fixture(configuration: configuration)
2323
var expectedModel = configuration.model
2424
expectedModel.position = [newState.coordinate.longitude, newState.coordinate.latitude]
@@ -31,7 +31,7 @@ final class Puck3DRendererTests: XCTestCase {
3131
}
3232

3333
func test_SetNewDuplicatedState_With3DPuck_DoNothing() throws {
34-
let configuration = Puck3DConfiguration(model: Model(id: "test"))
34+
let configuration = Puck3DConfiguration(model: Model(id: "puck-model"))
3535
let newState: PuckRendererState = .fixture()
3636
var expectedModel = configuration.model
3737
expectedModel.position = [newState.coordinate.longitude, newState.coordinate.latitude]
@@ -45,7 +45,7 @@ final class Puck3DRendererTests: XCTestCase {
4545
}
4646

4747
func test_SetNewState_WithNil_RemovesLayerAndSource() throws {
48-
let configuration = Puck3DConfiguration(model: Model())
48+
let configuration = Puck3DConfiguration(model: Model(id: "puck-model"))
4949
let newState: PuckRendererState = .fixture(configuration: configuration)
5050
var expectedModel = configuration.model
5151
expectedModel.position = [newState.coordinate.longitude, newState.coordinate.latitude]
@@ -59,7 +59,7 @@ final class Puck3DRendererTests: XCTestCase {
5959
}
6060

6161
func test_SetNewState_WithSameConfiguration_UpdatesOnlySources() throws {
62-
let configuration = Puck3DConfiguration(model: Model())
62+
let configuration = Puck3DConfiguration(model: Model(id: "puck-model"))
6363
let firstState: PuckRendererState = .fixture(
6464
accuracyAuthorization: .reducedAccuracy,
6565
configuration: configuration
@@ -88,13 +88,13 @@ final class Puck3DRendererTests: XCTestCase {
8888

8989
}
9090
func test_SetNewState_WithNewConfiguration_UpdatesSourcesAndLayer() throws {
91-
let firstConfiguration = Puck3DConfiguration(model: Model(id: "first"))
91+
let firstConfiguration = Puck3DConfiguration(model: Model(id: "puck-model"))
9292
let firstState: PuckRendererState = .fixture(configuration: firstConfiguration)
9393
var firstModel = firstConfiguration.model
9494
firstModel.position = [firstState.coordinate.longitude, firstState.coordinate.latitude]
9595
firstModel.orientation = [0, 0, 0]
9696

97-
let secondConfiguration = Puck3DConfiguration(model: Model(id: "second"), modelScale: .constant([3]))
97+
let secondConfiguration = Puck3DConfiguration(model: Model(id: "puck-model"), modelScale: .constant([3]))
9898
let secondState: PuckRendererState = .fixture(configuration: secondConfiguration)
9999
var secondModel = secondConfiguration.model
100100
secondModel.position = [secondState.coordinate.longitude, secondState.coordinate.latitude]

0 commit comments

Comments
 (0)