@@ -478,6 +478,17 @@ export default class RoadKit {
478478 // Create the tile mesh
479479 this . selectedTile . mesh = this . selectedTile . tile . mesh . clone ( ) ;
480480 this . selectedTile . mesh . position . set ( this . selectedTile . position . x , this . selectedTile . position . y , this . selectedTile . position . z ) ;
481+
482+ // Make new tile green
483+ this . selectedTile . mesh . children . forEach ( ( child ) => {
484+ // Store the original material to restore later
485+ this . originalMaterials . push ( child . material ) ;
486+ // Create new red material and assign it
487+ const newMaterial = child . material . clone ( ) ;
488+ newMaterial . emissive = new THREE . Color ( 0x00ff00 ) ;
489+ newMaterial . emissiveIntensity = 0.1 ;
490+ child . material = newMaterial ;
491+ } ) ;
481492 this . scene . add ( this . selectedTile . mesh ) ;
482493
483494 // Add a physics body for specific tile types if needed
@@ -614,7 +625,7 @@ export default class RoadKit {
614625 }
615626
616627 /**
617- * Roatate the selected tile
628+ * Rotate the selected tile
618629 * @param e
619630 * @param {Object } target The tile to rotate
620631 * @param {Number } rotateAmount The amount to rotate the tile
@@ -654,6 +665,19 @@ export default class RoadKit {
654665 // Update the tile's mesh position
655666 this . selectedTile . mesh . position . set ( finalPosition . x , this . selectedTile . mesh . position . y , finalPosition . z ) ;
656667
668+ // Ensure any overlay is removed
669+ if ( this . originalMaterials !== [ ] ) {
670+ this . selectedTile . mesh . children . forEach ( ( child , i ) => {
671+ // For each child, remove its new material and restore the original
672+ destroyMaterial ( child . material ) ;
673+ child . material = this . originalMaterials [ i ] ;
674+ } ) ;
675+
676+ // Now there is no hovered tile
677+ this . hoveredTile = null ;
678+ this . originalMaterials = [ ] ;
679+ }
680+
657681 // Place the physics body and remove any applied forces
658682 if ( this . selectedTile . body ) {
659683 this . selectedTile . body . position . set ( finalPosition . x , this . selectedTile . body . position . y , finalPosition . z ) ;
0 commit comments