File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -14,21 +14,16 @@ async function loop() {
1414 new Vector3 ( - 0.5 , 0.5 , 0 ) ,
1515 new Vector3 ( - 0.5 , - 0.5 , 0 ) ,
1616 new Vector3 ( 0.5 , 0.5 , 0 ) ,
17- new Vector3 ( 0.5 , 0.5 , 0 ) ,
18- new Vector3 ( - 0.5 , - 0.5 , 0 ) ,
1917 new Vector3 ( 0.5 , - 0.5 , 0 ) ,
2018 ] , [
2119 new Color ( 1 , 0 , 0 ) ,
2220 new Color ( 0 , 1 , 0 ) ,
2321 new Color ( 0 , 0 , 1 ) ,
24- new Color ( 0 , 0 , 1 ) ,
25- new Color ( 0 , 1 , 0 ) ,
2622 new Color ( 0 , 0 , 0 ) ,
2723 ] , [
28-
24+ 0 , 1 , 2 , 2 , 1 , 3
2925 ] )
3026
31- Shader . transformationMatrix = new Matrix4 ( ) ;
3227 Shader . projectionMatrix = Matrix4 . createProjectionMatrix (
3328 canvas . width / canvas . height ,
3429 70 ,
Original file line number Diff line number Diff line change @@ -54,10 +54,11 @@ class Renderer {
5454 static draw ( model ) {
5555 let positions = model . positions ;
5656 let colors = model . colors ;
57- for ( let i = 0 ; i < positions . length ; i += 3 ) {
58- let v1 = Shader . vertex ( positions [ i ] , colors [ i ] ) ;
59- let v2 = Shader . vertex ( positions [ i + 1 ] , colors [ i + 1 ] ) ;
60- let v3 = Shader . vertex ( positions [ i + 2 ] , colors [ i + 2 ] ) ;
57+ let indices = model . indices ;
58+ for ( let i = 0 ; i < indices . length ; i += 3 ) {
59+ let v1 = Shader . vertex ( positions [ indices [ i ] ] , colors [ indices [ i ] ] ) ;
60+ let v2 = Shader . vertex ( positions [ indices [ i + 1 ] ] , colors [ indices [ i + 1 ] ] ) ;
61+ let v3 = Shader . vertex ( positions [ indices [ i + 2 ] ] , colors [ indices [ i + 2 ] ] ) ;
6162 this . drawTriangle ( [ v1 , v2 , v3 ] ) ;
6263 }
6364 }
You can’t perform that action at this time.
0 commit comments