@@ -31,19 +31,27 @@ import {
31
31
WorkerAction
32
32
} from './types' ;
33
33
import { FloatingAnnotation } from './annotation/view' ;
34
- import { throttle } from './tools' ;
34
+ import { getCSSVariableColor , throttle } from './tools' ;
35
35
import { Vector2 } from 'three' ;
36
36
37
37
// Apply the BVH extension
38
38
THREE . BufferGeometry . prototype . computeBoundsTree = computeBoundsTree ;
39
39
THREE . BufferGeometry . prototype . disposeBoundsTree = disposeBoundsTree ;
40
40
THREE . Mesh . prototype . raycast = acceleratedRaycast ;
41
41
42
- const DARK_BG_COLOR = 'linear-gradient(rgb(0, 0, 42), rgb(82, 87, 110))' ;
43
- const LIGHT_BG_COLOR = 'radial-gradient(#efeded, #8f9091)' ;
42
+ const DEFAULT_MESH_COLOR_CSS = '--jp-inverse-layout-color4' ;
43
+ const DEFAULT_EDGE_COLOR_CSS = '--jp-inverse-layout-color2' ;
44
+ const SELECTED_MESH_COLOR_CSS = '--jp-brand-color0' ;
44
45
45
- const DEFAULT_MESH_COLOR = new THREE . Color ( '#434442' ) ;
46
- const SELECTED_MESH_COLOR = new THREE . Color ( '#AB5118' ) ;
46
+ const DEFAULT_MESH_COLOR = new THREE . Color (
47
+ getCSSVariableColor ( DEFAULT_MESH_COLOR_CSS )
48
+ ) ;
49
+ const DEFAULT_EDGE_COLOR = new THREE . Color (
50
+ getCSSVariableColor ( DEFAULT_EDGE_COLOR_CSS )
51
+ ) ;
52
+ const SELECTED_MESH_COLOR = new THREE . Color (
53
+ getCSSVariableColor ( SELECTED_MESH_COLOR_CSS )
54
+ ) ;
47
55
48
56
export type BasicMesh = THREE . Mesh <
49
57
THREE . BufferGeometry ,
@@ -218,6 +226,10 @@ export class MainView extends React.Component<IProps, IStates> {
218
226
219
227
sceneSetup = ( ) : void => {
220
228
if ( this . divRef . current !== null ) {
229
+ DEFAULT_MESH_COLOR . set ( getCSSVariableColor ( DEFAULT_MESH_COLOR_CSS ) ) ;
230
+ DEFAULT_EDGE_COLOR . set ( getCSSVariableColor ( DEFAULT_EDGE_COLOR_CSS ) ) ;
231
+ SELECTED_MESH_COLOR . set ( getCSSVariableColor ( SELECTED_MESH_COLOR_CSS ) ) ;
232
+
221
233
this . _camera = new THREE . PerspectiveCamera ( 90 , 2 , 0.1 , 1000 ) ;
222
234
this . _camera . position . set ( 8 , 8 , 8 ) ;
223
235
this . _camera . up . set ( 0 , 0 , 1 ) ;
@@ -626,7 +638,7 @@ export class MainView extends React.Component<IProps, IStates> {
626
638
627
639
const edgeMaterial = new THREE . LineBasicMaterial ( {
628
640
linewidth : 5 ,
629
- color : 'black'
641
+ color : DEFAULT_EDGE_COLOR
630
642
} ) ;
631
643
edgeList . forEach ( edge => {
632
644
const edgeVertices = new THREE . Float32BufferAttribute (
@@ -989,7 +1001,7 @@ export class MainView extends React.Component<IProps, IStates> {
989
1001
990
1002
// Draw lines
991
1003
const material = new THREE . LineBasicMaterial ( {
992
- color : 'black' ,
1004
+ color : DEFAULT_EDGE_COLOR ,
993
1005
linewidth : 2
994
1006
} ) ;
995
1007
const geometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
@@ -1046,6 +1058,11 @@ export class MainView extends React.Component<IProps, IStates> {
1046
1058
private _handleThemeChange = ( ) : void => {
1047
1059
const lightTheme =
1048
1060
document . body . getAttribute ( 'data-jp-theme-light' ) === 'true' ;
1061
+
1062
+ DEFAULT_MESH_COLOR . set ( getCSSVariableColor ( DEFAULT_MESH_COLOR_CSS ) ) ;
1063
+ DEFAULT_EDGE_COLOR . set ( getCSSVariableColor ( DEFAULT_EDGE_COLOR_CSS ) ) ;
1064
+ SELECTED_MESH_COLOR . set ( getCSSVariableColor ( SELECTED_MESH_COLOR_CSS ) ) ;
1065
+
1049
1066
this . setState ( old => ( { ...old , lightTheme } ) ) ;
1050
1067
} ;
1051
1068
@@ -1132,8 +1149,7 @@ export class MainView extends React.Component<IProps, IStates> {
1132
1149
ref = { this . divRef }
1133
1150
style = { {
1134
1151
width : '100%' ,
1135
- height : 'calc(100%)' ,
1136
- background : this . state . lightTheme ? LIGHT_BG_COLOR : DARK_BG_COLOR
1152
+ height : 'calc(100%)'
1137
1153
} }
1138
1154
/>
1139
1155
</ div >
0 commit comments