Bugfix: update sketch mode colors on theme change (#3849)
* Update client-side scene mesh base colors properly * Add E2E test * Remove use of `as`
This commit is contained in:
@ -102,7 +102,7 @@ import {
|
||||
getRectangleCallExpressions,
|
||||
updateRectangleSketch,
|
||||
} from 'lib/rectangleTool'
|
||||
import { getThemeColorForThreeJs } from 'lib/theme'
|
||||
import { getThemeColorForThreeJs, Themes } from 'lib/theme'
|
||||
import { err, reportRejection, trap } from 'lib/trap'
|
||||
import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer'
|
||||
import { Point3d } from 'wasm-lib/kcl/bindings/Point3d'
|
||||
@ -1473,6 +1473,25 @@ export class SceneEntities {
|
||||
to,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* Update the base color of each of the THREEjs meshes
|
||||
* that represent each of the sketch segments, to get the
|
||||
* latest value from `sceneInfra._theme`
|
||||
*/
|
||||
updateSegmentBaseColor(newColor: Themes.Light | Themes.Dark) {
|
||||
const newColorThreeJs = getThemeColorForThreeJs(newColor)
|
||||
Object.values(this.activeSegments).forEach((group) => {
|
||||
group.userData.baseColor = newColorThreeJs
|
||||
group.traverse((child) => {
|
||||
if (
|
||||
child instanceof Mesh &&
|
||||
child.material instanceof MeshBasicMaterial
|
||||
) {
|
||||
child.material.color.set(newColorThreeJs)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
removeSketchGrid() {
|
||||
if (this.axisGroup) this.scene.remove(this.axisGroup)
|
||||
}
|
||||
|
Reference in New Issue
Block a user