Преглед на файлове

fixed wrong winding order in primitives

Alexander Rose преди 6 години
родител
ревизия
c53c5cc3c5
променени са 5 файла, в които са добавени 13 реда и са изтрити 13 реда
  1. 2 2
      src/mol-geo/primitive/box.ts
  2. 3 3
      src/mol-geo/primitive/prism.ts
  3. 4 4
      src/mol-geo/primitive/pyramid.ts
  4. 2 2
      src/mol-geo/primitive/star.ts
  5. 2 2
      src/mol-geo/primitive/wedge.ts

+ 2 - 2
src/mol-geo/primitive/box.ts

@@ -33,8 +33,8 @@ function createBox(perforated: boolean): Primitive {
     Vec3.set(b, points[2], points[3], -0.5)
     Vec3.set(b, points[2], points[3], -0.5)
     Vec3.set(c, points[4], points[5], -0.5)
     Vec3.set(c, points[4], points[5], -0.5)
     Vec3.set(d, points[6], points[7], -0.5)
     Vec3.set(d, points[6], points[7], -0.5)
-    builder.add(a, b, c)
-    if (!perforated) builder.add(c, d, a)
+    builder.add(c, b, a)
+    if (!perforated) builder.add(a, d, c)
     Vec3.set(a, points[0], points[1], 0.5)
     Vec3.set(a, points[0], points[1], 0.5)
     Vec3.set(b, points[2], points[3], 0.5)
     Vec3.set(b, points[2], points[3], 0.5)
     Vec3.set(c, points[4], points[5], 0.5)
     Vec3.set(c, points[4], points[5], 0.5)

+ 3 - 3
src/mol-geo/primitive/prism.ts

@@ -16,7 +16,7 @@ const a = Vec3.zero(), b = Vec3.zero(), c = Vec3.zero(), d = Vec3.zero()
  */
  */
 export function Prism(points: ArrayLike<number>): Primitive {
 export function Prism(points: ArrayLike<number>): Primitive {
     const sideCount = points.length / 2
     const sideCount = points.length / 2
-    if (sideCount < 5) throw new Error('need at least 5 points to build a prism')
+    if (sideCount < 4) throw new Error('need at least 5 points to build a prism')
 
 
     const count = 4 * sideCount
     const count = 4 * sideCount
     const builder = PrimitiveBuilder(count)
     const builder = PrimitiveBuilder(count)
@@ -37,10 +37,10 @@ export function Prism(points: ArrayLike<number>): Primitive {
         const ni = (i + 1) % sideCount
         const ni = (i + 1) % sideCount
         Vec3.set(a, points[i * 2], points[i * 2 + 1], -0.5)
         Vec3.set(a, points[i * 2], points[i * 2 + 1], -0.5)
         Vec3.set(b, points[ni * 2], points[ni * 2 + 1], -0.5)
         Vec3.set(b, points[ni * 2], points[ni * 2 + 1], -0.5)
-        builder.add(a, b, on)
+        builder.add(on, b, a)
         Vec3.set(a, points[i * 2], points[i * 2 + 1], 0.5)
         Vec3.set(a, points[i * 2], points[i * 2 + 1], 0.5)
         Vec3.set(b, points[ni * 2], points[ni * 2 + 1], 0.5)
         Vec3.set(b, points[ni * 2], points[ni * 2 + 1], 0.5)
-        builder.add(op, b, a)
+        builder.add(a, b, op)
     }
     }
 
 
     return builder.getPrimitive()
     return builder.getPrimitive()

+ 4 - 4
src/mol-geo/primitive/pyramid.ts

@@ -33,20 +33,20 @@ export function Pyramide(points: ArrayLike<number>): Primitive {
         Vec3.set(a, points[0], points[1], -0.5)
         Vec3.set(a, points[0], points[1], -0.5)
         Vec3.set(b, points[2], points[3], -0.5)
         Vec3.set(b, points[2], points[3], -0.5)
         Vec3.set(c, points[4], points[5], -0.5)
         Vec3.set(c, points[4], points[5], -0.5)
-        builder.add(a, b, c)
+        builder.add(c, b, a)
     } else if (sideCount === 4) {
     } else if (sideCount === 4) {
         Vec3.set(a, points[0], points[1], -0.5)
         Vec3.set(a, points[0], points[1], -0.5)
         Vec3.set(b, points[2], points[3], -0.5)
         Vec3.set(b, points[2], points[3], -0.5)
         Vec3.set(c, points[4], points[5], -0.5)
         Vec3.set(c, points[4], points[5], -0.5)
         Vec3.set(d, points[6], points[7], -0.5)
         Vec3.set(d, points[6], points[7], -0.5)
-        builder.add(a, b, c)
-        builder.add(c, d, a)
+        builder.add(c, b, a)
+        builder.add(a, d, c)
     } else {
     } else {
         for (let i = 0; i < sideCount; ++i) {
         for (let i = 0; i < sideCount; ++i) {
             const ni = (i + 1) % sideCount
             const ni = (i + 1) % sideCount
             Vec3.set(a, points[i * 2], points[i * 2 + 1], -0.5)
             Vec3.set(a, points[i * 2], points[i * 2 + 1], -0.5)
             Vec3.set(b, points[ni * 2], points[ni * 2 + 1], -0.5)
             Vec3.set(b, points[ni * 2], points[ni * 2 + 1], -0.5)
-            builder.add(a, b, on)
+            builder.add(on, b, a)
         }
         }
     }
     }
 
 

+ 2 - 2
src/mol-geo/primitive/star.ts

@@ -46,9 +46,9 @@ export function Star(props?: StarProps): Primitive {
         Vec3.set(c, outerPoints[ni * 2], outerPoints[ni * 2 + 1], 0)
         Vec3.set(c, outerPoints[ni * 2], outerPoints[ni * 2 + 1], 0)
 
 
         builder.add(op, a, b)
         builder.add(op, a, b)
-        builder.add(on, a, b)
+        builder.add(b, a, on)
         builder.add(op, b, c)
         builder.add(op, b, c)
-        builder.add(on, b, c)
+        builder.add(c, b, on)
     }
     }
 
 
     return builder.getPrimitive()
     return builder.getPrimitive()

+ 2 - 2
src/mol-geo/primitive/wedge.ts

@@ -32,11 +32,11 @@ export function createWedge(): Primitive {
     Vec3.set(a, points[0], points[1], -0.5)
     Vec3.set(a, points[0], points[1], -0.5)
     Vec3.set(b, points[2], points[3], -0.5)
     Vec3.set(b, points[2], points[3], -0.5)
     Vec3.set(c, points[4], points[5], -0.5)
     Vec3.set(c, points[4], points[5], -0.5)
-    builder.add(a, b, c)
+    builder.add(c, b, a)
     Vec3.set(a, points[0], points[1], 0.5)
     Vec3.set(a, points[0], points[1], 0.5)
     Vec3.set(b, points[2], points[3], 0.5)
     Vec3.set(b, points[2], points[3], 0.5)
     Vec3.set(c, points[4], points[5], 0.5)
     Vec3.set(c, points[4], points[5], 0.5)
-    builder.add(c, b, a)
+    builder.add(a, b, c)
 
 
     return builder.getPrimitive()
     return builder.getPrimitive()
 }
 }