Browse Source

wip, carbohydrate visual

Alexander Rose 6 years ago
parent
commit
5d36a9253e

+ 1 - 1
src/mol-geo/primitive/polygon.ts

@@ -12,7 +12,7 @@ export function polygon(sideCount: number, shift: boolean) {
     const points = new Float32Array(sideCount * 2)
     const radius = sideCount <= 4 ? Math.sqrt(2) / 2 : 0.6
 
-    const offset = shift ? 0 : 1
+    const offset = shift ? 1 : 0
 
     for (let i = 0, il = 2 * sideCount; i < il; i += 2) {
         const c = (i + offset) / sideCount * Math.PI

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

@@ -78,7 +78,7 @@ export function Wedge() {
 
 let box: Primitive
 export function Box() {
-    if (!box) box = Prism(polygon(4, false))
+    if (!box) box = Prism(polygon(4, true))
     return box
 }
 
@@ -88,14 +88,14 @@ export function DiamondPrism() {
     return diamond
 }
 
-let hexagonalPrism: Primitive
-export function HexagonalPrism() {
-    if (!hexagonalPrism) hexagonalPrism = Prism(polygon(5, false))
-    return hexagonalPrism
-}
-
 let pentagonalPrism: Primitive
 export function PentagonalPrism() {
-    if (!pentagonalPrism) pentagonalPrism = Prism(polygon(6, true))
+    if (!pentagonalPrism) pentagonalPrism = Prism(polygon(5, false))
     return pentagonalPrism
+}
+
+let hexagonalPrism: Primitive
+export function HexagonalPrism() {
+    if (!hexagonalPrism) hexagonalPrism = Prism(polygon(6, true))
+    return hexagonalPrism
 }

+ 9 - 8
src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts

@@ -83,44 +83,45 @@ async function createCarbohydrateSymbolMesh(ctx: RuntimeContext, structure: Stru
                 break
             case SaccharideShapes.FlatBox:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2))
                 builder.addBox(t)
                 break
             case SaccharideShapes.FilledStar:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 builder.addStar(t, { outerRadius: side, innerRadius: side / 2, thickness: side / 2, pointCount: 5 })
                 break
             case SaccharideShapes.FilledDiamond:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 Mat4.scale(t, t, Vec3.set(sVec, side * 1.4, side * 1.4, side * 1.4))
                 builder.addOctahedron(t)
                 break
             case SaccharideShapes.DividedDiamond:
                 // TODO split
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 Mat4.scale(t, t, Vec3.set(sVec, side * 1.4, side * 1.4, side * 1.4))
                 builder.addOctahedron(t)
                 break
             case SaccharideShapes.FlatDiamond:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 Mat4.scale(t, t, Vec3.set(sVec, side, side / 2, side / 2))
                 builder.addDiamondPrism(t)
+                break
             case SaccharideShapes.Pentagon:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
+                Mat4.mul(t, t, Mat4.rotZY90)
                 Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2))
                 builder.addPentagonalPrism(t)
                 break
             case SaccharideShapes.FlatHexagon:
             default:
                 centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
-                Mat4.mul(t, t, Mat4.rotY90)
-                Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2))
+                Mat4.mul(t, t, Mat4.rotZYZ90)
+                Mat4.scale(t, t, Vec3.set(sVec, side / 1.5, side , side / 2))
                 builder.addHexagonalPrism(t)
                 break
         }

+ 6 - 0
src/mol-math/linear-algebra/3d/mat4.ts

@@ -877,8 +877,14 @@ namespace Mat4 {
     export const rotX90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(1, 0, 0))
     /** Rotation matrix for 90deg rotation around y-axis */
     export const rotY90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(0, 1, 0))
+    /** Rotation matrix for 90deg rotation around z-axis */
+    export const rotZ90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(0, 0, 1))
     /** Rotation matrix for 90deg rotation around first x-axis and then y-axis */
     export const rotXY90: ReadonlyMat4 = Mat4.mul(Mat4.identity(), rotX90, rotY90)
+    /** Rotation matrix for 90deg rotation around first z-axis and then y-axis */
+    export const rotZY90: ReadonlyMat4 = Mat4.mul(Mat4.identity(), rotZ90, rotY90)
+    /** Rotation matrix for 90deg rotation around first z-axis and then y-axis and then z-axis */
+    export const rotZYZ90: ReadonlyMat4 = Mat4.mul(Mat4.identity(), rotZY90, rotZ90)
 }
 
 export default Mat4

+ 2 - 2
src/mol-view/stage.ts

@@ -98,14 +98,14 @@ export class Stage {
         // this.loadPdbid('3sn6') // discontinuous chains
         // this.loadPdbid('2zex') // contains carbohydrate polymer
         // this.loadPdbid('3sgj') // contains carbohydrate polymer
-        this.loadPdbid('3ina') // contains GlcN and IdoA
+        // this.loadPdbid('3ina') // contains GlcN and IdoA
         // this.loadPdbid('1umz') // contains Xyl (Xyloglucan)
         // this.loadPdbid('1mfb') // contains Abe
         // this.loadPdbid('2gdu') // contains sucrose
         // this.loadPdbid('2fnc') // contains maltotriose
         // this.loadPdbid('4zs9') // contains raffinose
         // this.loadPdbid('2yft') // contains kestose
-        // this.loadPdbid('2b5t') // contains large carbohydrate polymer
+        this.loadPdbid('2b5t') // contains large carbohydrate polymer
         // this.loadMmcifUrl(`../../examples/1cbs_full.bcif`)
         // this.loadMmcifUrl(`../../examples/1cbs_updated.cif`)
         // this.loadMmcifUrl(`../../examples/1crn.cif`)