From 5d36a9253eaa0f4553a5c6e8b89b6dcc717b4aec Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Tue, 31 Jul 2018 20:34:40 -0700 Subject: [PATCH] wip, carbohydrate visual --- src/mol-geo/primitive/polygon.ts | 2 +- src/mol-geo/primitive/prism.ts | 16 ++++++++-------- .../visual/carbohydrate-symbol-mesh.ts | 17 +++++++++-------- src/mol-math/linear-algebra/3d/mat4.ts | 6 ++++++ src/mol-view/stage.ts | 4 ++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/mol-geo/primitive/polygon.ts b/src/mol-geo/primitive/polygon.ts index 83ff7c8c0..b7db9972e 100644 --- a/src/mol-geo/primitive/polygon.ts +++ b/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 diff --git a/src/mol-geo/primitive/prism.ts b/src/mol-geo/primitive/prism.ts index 445ceed90..728d18404 100644 --- a/src/mol-geo/primitive/prism.ts +++ b/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 } \ No newline at end of file diff --git a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts index 265e32e78..70f363b02 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts +++ b/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 } diff --git a/src/mol-math/linear-algebra/3d/mat4.ts b/src/mol-math/linear-algebra/3d/mat4.ts index dd56c80e6..ddd7eaafd 100644 --- a/src/mol-math/linear-algebra/3d/mat4.ts +++ b/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 \ No newline at end of file diff --git a/src/mol-view/stage.ts b/src/mol-view/stage.ts index b806d5407..5ebbbb2db 100644 --- a/src/mol-view/stage.ts +++ b/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`) -- GitLab