2017-10-25 1 views
0

Ich p5.js und WebGL weitere Informationen mit Informationen hereWürfel Algorithmus nicht generatin Würfel p5.js

Ich brauche einen Würfel mit den Koordinaten (x, y, z)

Die Funktion zeichnen dass zieht es:

function drawCube(x,y,z,L) { 
    A = new ThreeDpoint(x, y, z ); 
    B = new ThreeDpoint(x, y+L, z ); 
    C = new ThreeDpoint(x+L, y+L, z ); 
    D = new ThreeDpoint(x+L, y, z ); 
    E = new ThreeDpoint(x, y, z-L); 
    F = new ThreeDpoint(x, y+L, z-L); 
    G = new ThreeDpoint(x+L, y+L, z-L); 
    H = new ThreeDpoint(x, y, z-L); 

    line(A.x,A.y,A.z, B.x,B.y,B.z); 
    line(A.x,A.y,A.z, D.x,D.y,D.z); 
    line(A.x,A.y,A.z, E.x,E.y,E.z); 
    line(B.x,B.y,B.z, F.x,F.y,F.z); 
    line(B.x,B.y,B.z, C.x,C.y,C.z); 
    line(C.x,C.y,C.z, G.x,G.y,G.z); 
    line(C.x,C.y,C.z, D.x,D.y,D.z); 
    line(D.x,D.y,D.z, H.x,H.y,H.z); 
    line(E.x,E.y,E.z, F.x,F.y,F.z); 
    line(E.x,E.y,E.z, H.x,H.y,H.z); 
    line(F.x,F.y,F.z, G.x,G.y,G.z); 
    line(G.x,G.y,E.z, H.x,H.y,H.z); 
} 

Aber das ist te Ergebnis ich erhalte:

Image

Danke.

Antwort

0

nur raten, aber E und H sind die gleichen Punkt

E = new ThreeDpoint(x, y, z-L); 
H = new ThreeDpoint(x, y, z-L); 

Ich glaube, Sie H sein wollen

H = new ThreeDpoint(x+L, y, z-L);