@@ -623,22 +623,64 @@ <h4>决策结果说明</h4>
623623
624624 // 创建网格 - 三个坐标面的方格参考线
625625 function createGrid ( size ) {
626- // XY平面网格(底面)
627- const xyGridHelper = new THREE . GridHelper ( size , size , colors . grid , colors . grid ) ;
628- xyGridHelper . position . y = 0 ;
629- scene . add ( xyGridHelper ) ;
630-
631- // YZ平面网格(侧面)
632- const yzGridHelper = new THREE . GridHelper ( size , size , colors . grid , colors . grid ) ;
633- yzGridHelper . rotation . x = Math . PI / 2 ;
634- yzGridHelper . position . z = 0 ;
635- scene . add ( yzGridHelper ) ;
636-
637- // XZ平面网格(后面)
638- const xzGridHelper = new THREE . GridHelper ( size , size , colors . grid , colors . grid ) ;
639- xzGridHelper . rotation . z = Math . PI / 2 ;
640- xzGridHelper . position . y = 0 ;
641- scene . add ( xzGridHelper ) ;
626+ const gridMaterial = new THREE . LineBasicMaterial ( { color : colors . grid } ) ;
627+
628+ // XY平面网格(底面)- 从(0,0)到(10,10)
629+ for ( let i = 0 ; i <= size ; i ++ ) {
630+ // 平行于X轴的线
631+ const xLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
632+ new THREE . Vector3 ( 0 , 0 , i ) ,
633+ new THREE . Vector3 ( size , 0 , i )
634+ ] ) ;
635+ const xLine = new THREE . Line ( xLineGeometry , gridMaterial ) ;
636+ scene . add ( xLine ) ;
637+
638+ // 平行于Y轴的线
639+ const yLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
640+ new THREE . Vector3 ( i , 0 , 0 ) ,
641+ new THREE . Vector3 ( i , 0 , size )
642+ ] ) ;
643+ const yLine = new THREE . Line ( yLineGeometry , gridMaterial ) ;
644+ scene . add ( yLine ) ;
645+ }
646+
647+ // YZ平面网格(侧面)- 从(0,0)到(10,10)
648+ for ( let i = 0 ; i <= size ; i ++ ) {
649+ // 平行于Y轴的线
650+ const yLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
651+ new THREE . Vector3 ( 0 , 0 , i ) ,
652+ new THREE . Vector3 ( 0 , size , i )
653+ ] ) ;
654+ const yLine = new THREE . Line ( yLineGeometry , gridMaterial ) ;
655+ scene . add ( yLine ) ;
656+
657+ // 平行于Z轴的线
658+ const zLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
659+ new THREE . Vector3 ( 0 , i , 0 ) ,
660+ new THREE . Vector3 ( 0 , i , size )
661+ ] ) ;
662+ const zLine = new THREE . Line ( zLineGeometry , gridMaterial ) ;
663+ scene . add ( zLine ) ;
664+ }
665+
666+ // XZ平面网格(后面)- 从(0,0)到(10,10)
667+ for ( let i = 0 ; i <= size ; i ++ ) {
668+ // 平行于X轴的线
669+ const xLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
670+ new THREE . Vector3 ( 0 , i , 0 ) ,
671+ new THREE . Vector3 ( size , i , 0 )
672+ ] ) ;
673+ const xLine = new THREE . Line ( xLineGeometry , gridMaterial ) ;
674+ scene . add ( xLine ) ;
675+
676+ // 平行于Z轴的线
677+ const zLineGeometry = new THREE . BufferGeometry ( ) . setFromPoints ( [
678+ new THREE . Vector3 ( i , 0 , 0 ) ,
679+ new THREE . Vector3 ( i , size , 0 )
680+ ] ) ;
681+ const zLine = new THREE . Line ( zLineGeometry , gridMaterial ) ;
682+ scene . add ( zLine ) ;
683+ }
642684 }
643685
644686 // 创建坐标轴刻度
0 commit comments