Skip to content

Commit 29a6ce1

Browse files
authored
TransformControls: Improved highlight colors (#22048)
* TransformControls: Improved highlight colors * TransformControls: Clean up * TransformControls: Bring back opacity
1 parent 7382532 commit 29a6ce1

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

examples/jsm/controls/TransformControls.js

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
BoxGeometry,
33
BufferGeometry,
4-
Color,
54
CylinderGeometry,
65
DoubleSide,
76
Euler,
@@ -787,49 +786,49 @@ class TransformControlsGizmo extends Object3D {
787786
matHelper.opacity = 0.33;
788787

789788
const matRed = gizmoMaterial.clone();
790-
matRed.color.set( 0xff0000 );
789+
matRed.color.setHex( 0xff0000 );
791790

792791
const matGreen = gizmoMaterial.clone();
793-
matGreen.color.set( 0x00ff00 );
792+
matGreen.color.setHex( 0x00ff00 );
794793

795794
const matBlue = gizmoMaterial.clone();
796-
matBlue.color.set( 0x0000ff );
795+
matBlue.color.setHex( 0x0000ff );
797796

798797
const matWhiteTransparent = gizmoMaterial.clone();
799798
matWhiteTransparent.opacity = 0.25;
800799

801800
const matYellowTransparent = matWhiteTransparent.clone();
802-
matYellowTransparent.color.set( 0xffff00 );
801+
matYellowTransparent.color.setHex( 0xffff00 );
803802

804803
const matCyanTransparent = matWhiteTransparent.clone();
805-
matCyanTransparent.color.set( 0x00ffff );
804+
matCyanTransparent.color.setHex( 0x00ffff );
806805

807806
const matMagentaTransparent = matWhiteTransparent.clone();
808-
matMagentaTransparent.color.set( 0xff00ff );
807+
matMagentaTransparent.color.setHex( 0xff00ff );
809808

810809
const matYellow = gizmoMaterial.clone();
811-
matYellow.color.set( 0xffff00 );
810+
matYellow.color.setHex( 0xffff00 );
812811

813812
const matLineRed = gizmoLineMaterial.clone();
814-
matLineRed.color.set( 0xff0000 );
813+
matLineRed.color.setHex( 0xff0000 );
815814

816815
const matLineGreen = gizmoLineMaterial.clone();
817-
matLineGreen.color.set( 0x00ff00 );
816+
matLineGreen.color.setHex( 0x00ff00 );
818817

819818
const matLineBlue = gizmoLineMaterial.clone();
820-
matLineBlue.color.set( 0x0000ff );
819+
matLineBlue.color.setHex( 0x0000ff );
821820

822821
const matLineCyan = gizmoLineMaterial.clone();
823-
matLineCyan.color.set( 0x00ffff );
822+
matLineCyan.color.setHex( 0x00ffff );
824823

825824
const matLineMagenta = gizmoLineMaterial.clone();
826-
matLineMagenta.color.set( 0xff00ff );
825+
matLineMagenta.color.setHex( 0xff00ff );
827826

828827
const matLineYellow = gizmoLineMaterial.clone();
829-
matLineYellow.color.set( 0xffff00 );
828+
matLineYellow.color.setHex( 0xffff00 );
830829

831830
const matLineGray = gizmoLineMaterial.clone();
832-
matLineGray.color.set( 0x787878 );
831+
matLineGray.color.setHex( 0x787878 );
833832

834833
const matLineYellowTransparent = matLineYellow.clone();
835834
matLineYellowTransparent.opacity = 0.25;
@@ -1522,37 +1521,27 @@ class TransformControlsGizmo extends Object3D {
15221521

15231522
// highlight selected axis
15241523

1525-
handle.material._opacity = handle.material._opacity || handle.material.opacity;
15261524
handle.material._color = handle.material._color || handle.material.color.clone();
1525+
handle.material._opacity = handle.material._opacity || handle.material.opacity;
15271526

15281527
handle.material.color.copy( handle.material._color );
15291528
handle.material.opacity = handle.material._opacity;
15301529

1531-
if ( ! this.enabled ) {
1532-
1533-
handle.material.opacity *= 0.5;
1534-
handle.material.color.lerp( new Color( 1, 1, 1 ), 0.5 );
1535-
1536-
} else if ( this.axis ) {
1530+
if ( this.enabled && this.axis ) {
15371531

15381532
if ( handle.name === this.axis ) {
15391533

1534+
handle.material.color.setHex( 0xffff00 );
15401535
handle.material.opacity = 1.0;
1541-
handle.material.color.lerp( new Color( 1, 1, 1 ), 0.5 );
15421536

15431537
} else if ( this.axis.split( '' ).some( function ( a ) {
15441538

15451539
return handle.name === a;
15461540

15471541
} ) ) {
15481542

1543+
handle.material.color.setHex( 0xffff00 );
15491544
handle.material.opacity = 1.0;
1550-
handle.material.color.lerp( new Color( 1, 1, 1 ), 0.5 );
1551-
1552-
} else {
1553-
1554-
handle.material.opacity *= 0.25;
1555-
handle.material.color.lerp( new Color( 1, 1, 1 ), 0.5 );
15561545

15571546
}
15581547

0 commit comments

Comments
 (0)