@@ -6,6 +6,7 @@ import { WinNode } from "../WinNode";
66import { ThreeScene } from "../../ThreeScene" ;
77import { Script } from "../../export/Script" ;
88import { ComboBox } from "../../components/ComboBox" ;
9+ import { MeshBasicMaterial } from "three" ;
910
1011export class ScenePreviewNode extends WinNode {
1112
@@ -14,6 +15,7 @@ export class ScenePreviewNode extends WinNode {
1415 protected ambientLightSlider :DraggableValue ;
1516 protected rotationSpeedSlider :DraggableValue ;
1617 protected objTypeCombo :ComboBox ;
18+ protected errorMaterial :MeshBasicMaterial ;
1719
1820 constructor ( protected scene :ThreeScene ) {
1921
@@ -46,6 +48,8 @@ export class ScenePreviewNode extends WinNode {
4648 rotationSpeedSlider . value = this . scene . rotationSpeed ;
4749 objType . index = this . scene . currentObjectIndex ;
4850
51+ this . errorMaterial = new MeshBasicMaterial ( { color :0xff0000 } ) ;
52+
4953 }
5054
5155 protected onAmbientLightSlider ( intensity :number ) {
@@ -71,13 +75,20 @@ export class ScenePreviewNode extends WinNode {
7175
7276 const script = new Script ( ) ;
7377
74- const materialRef = slot . writeScript ( script ) ;
78+ try
79+ {
80+ const materialRef = slot . writeScript ( script ) ;
7581
76- console . log ( script . toString ( "" , false ) )
82+ console . log ( script . toString ( "" , false ) )
7783
78- const material = script . eval ( materialRef + "()" ) ;
84+ const material = script . eval ( materialRef + "()" ) ;
7985
80- this . scene . setMaterial ( materialIndex , material ) ;
86+ this . scene . setMaterial ( materialIndex , material ) ;
87+ }
88+ catch ( error )
89+ {
90+ this . scene . setMaterial ( materialIndex , this . errorMaterial ) ;
91+ }
8192 }
8293
8394 override serialize ( ) : Record < string , any > {
0 commit comments