@@ -31,16 +31,18 @@ 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 DEFAULT_MESH_COLOR = new THREE . Color ( '#434442' ) ;
43
- const SELECTED_MESH_COLOR = new THREE . Color ( '#AB5118' ) ;
42
+ const DEFAULT_MESH_COLOR = ( ) => new THREE . Color ( getCSSVariableColor ( '--jp-inverse-layout-color4' ) ) ;
43
+ const DEFAULT_EDGE_COLOR = ( ) => new THREE . Color ( getCSSVariableColor ( '--jp-inverse-layout-color2' ) ) ;
44
+ const SELECTED_MESH_COLOR = ( ) => new THREE . Color ( getCSSVariableColor ( '--jp-brand-color0' ) ) ;
45
+
44
46
45
47
export type BasicMesh = THREE . Mesh <
46
48
THREE . BufferGeometry ,
@@ -491,7 +493,7 @@ export class MainView extends React.Component<IProps, IStates> {
491
493
if ( selection ) {
492
494
// Deselect old selection
493
495
if ( this . _selectedMesh ) {
494
- let originalColor = DEFAULT_MESH_COLOR ;
496
+ let originalColor = DEFAULT_MESH_COLOR ( ) ;
495
497
if (
496
498
guidata &&
497
499
guidata [ this . _selectedMesh . name ] &&
@@ -517,7 +519,7 @@ export class MainView extends React.Component<IProps, IStates> {
517
519
}
518
520
519
521
if ( this . _selectedMesh ) {
520
- this . _selectedMesh . material . color = SELECTED_MESH_COLOR ;
522
+ this . _selectedMesh . material . color = SELECTED_MESH_COLOR ( ) ;
521
523
this . _model . syncSelectedObject ( this . _selectedMesh . name , this . state . id ) ;
522
524
} else {
523
525
this . _model . syncSelectedObject ( undefined , this . state . id ) ;
@@ -568,7 +570,7 @@ export class MainView extends React.Component<IProps, IStates> {
568
570
569
571
const objdata = guidata ? guidata ?. [ objName ] : null ;
570
572
571
- let color = DEFAULT_MESH_COLOR ;
573
+ let color = DEFAULT_MESH_COLOR ( ) ;
572
574
let visible = true ;
573
575
if ( objdata ) {
574
576
if ( Object . prototype . hasOwnProperty . call ( objdata , 'color' ) ) {
@@ -618,12 +620,12 @@ export class MainView extends React.Component<IProps, IStates> {
618
620
619
621
if ( this . _selectedMesh ?. name === objName ) {
620
622
this . _selectedMesh = mesh ;
621
- mesh . material . color = SELECTED_MESH_COLOR ;
623
+ mesh . material . color = SELECTED_MESH_COLOR ( ) ;
622
624
}
623
625
624
626
const edgeMaterial = new THREE . LineBasicMaterial ( {
625
627
linewidth : 5 ,
626
- color : 'black'
628
+ color : DEFAULT_EDGE_COLOR ( )
627
629
} ) ;
628
630
edgeList . forEach ( edge => {
629
631
const edgeVertices = new THREE . Float32BufferAttribute (
@@ -732,7 +734,7 @@ export class MainView extends React.Component<IProps, IStates> {
732
734
733
735
if ( selected ) {
734
736
this . _selectedMesh = selected as BasicMesh ;
735
- this . _selectedMesh . material . color = SELECTED_MESH_COLOR ;
737
+ this . _selectedMesh . material . color = SELECTED_MESH_COLOR ( ) ;
736
738
}
737
739
}
738
740
@@ -741,7 +743,7 @@ export class MainView extends React.Component<IProps, IStates> {
741
743
return ;
742
744
}
743
745
744
- let originalColor = DEFAULT_MESH_COLOR ;
746
+ let originalColor = DEFAULT_MESH_COLOR ( ) ;
745
747
const guidata = this . _model . sharedModel . getOption ( 'guidata' ) ;
746
748
if (
747
749
guidata &&
@@ -986,7 +988,7 @@ export class MainView extends React.Component<IProps, IStates> {
986
988
987
989
// Draw lines
988
990
const material = new THREE . LineBasicMaterial ( {
989
- color : 'black' ,
991
+ color : DEFAULT_EDGE_COLOR ( ) ,
990
992
linewidth : 2
991
993
} ) ;
992
994
const geometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
0 commit comments