Skip to content
Snippets Groups Projects
Commit 5d36a925 authored by Alexander Rose's avatar Alexander Rose
Browse files

wip, carbohydrate visual

parent ffb7824b
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ export function polygon(sideCount: number, shift: boolean) { ...@@ -12,7 +12,7 @@ export function polygon(sideCount: number, shift: boolean) {
const points = new Float32Array(sideCount * 2) const points = new Float32Array(sideCount * 2)
const radius = sideCount <= 4 ? Math.sqrt(2) / 2 : 0.6 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) { for (let i = 0, il = 2 * sideCount; i < il; i += 2) {
const c = (i + offset) / sideCount * Math.PI const c = (i + offset) / sideCount * Math.PI
......
...@@ -78,7 +78,7 @@ export function Wedge() { ...@@ -78,7 +78,7 @@ export function Wedge() {
let box: Primitive let box: Primitive
export function Box() { export function Box() {
if (!box) box = Prism(polygon(4, false)) if (!box) box = Prism(polygon(4, true))
return box return box
} }
...@@ -88,14 +88,14 @@ export function DiamondPrism() { ...@@ -88,14 +88,14 @@ export function DiamondPrism() {
return diamond return diamond
} }
let hexagonalPrism: Primitive
export function HexagonalPrism() {
if (!hexagonalPrism) hexagonalPrism = Prism(polygon(5, false))
return hexagonalPrism
}
let pentagonalPrism: Primitive let pentagonalPrism: Primitive
export function PentagonalPrism() { export function PentagonalPrism() {
if (!pentagonalPrism) pentagonalPrism = Prism(polygon(6, true)) if (!pentagonalPrism) pentagonalPrism = Prism(polygon(5, false))
return pentagonalPrism return pentagonalPrism
} }
let hexagonalPrism: Primitive
export function HexagonalPrism() {
if (!hexagonalPrism) hexagonalPrism = Prism(polygon(6, true))
return hexagonalPrism
}
\ No newline at end of file
...@@ -83,44 +83,45 @@ async function createCarbohydrateSymbolMesh(ctx: RuntimeContext, structure: Stru ...@@ -83,44 +83,45 @@ async function createCarbohydrateSymbolMesh(ctx: RuntimeContext, structure: Stru
break break
case SaccharideShapes.FlatBox: case SaccharideShapes.FlatBox:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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)) Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2))
builder.addBox(t) builder.addBox(t)
break break
case SaccharideShapes.FilledStar: case SaccharideShapes.FilledStar:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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 }) builder.addStar(t, { outerRadius: side, innerRadius: side / 2, thickness: side / 2, pointCount: 5 })
break break
case SaccharideShapes.FilledDiamond: case SaccharideShapes.FilledDiamond:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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)) Mat4.scale(t, t, Vec3.set(sVec, side * 1.4, side * 1.4, side * 1.4))
builder.addOctahedron(t) builder.addOctahedron(t)
break break
case SaccharideShapes.DividedDiamond: case SaccharideShapes.DividedDiamond:
// TODO split // TODO split
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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)) Mat4.scale(t, t, Vec3.set(sVec, side * 1.4, side * 1.4, side * 1.4))
builder.addOctahedron(t) builder.addOctahedron(t)
break break
case SaccharideShapes.FlatDiamond: case SaccharideShapes.FlatDiamond:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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)) Mat4.scale(t, t, Vec3.set(sVec, side, side / 2, side / 2))
builder.addDiamondPrism(t) builder.addDiamondPrism(t)
break
case SaccharideShapes.Pentagon: case SaccharideShapes.Pentagon:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) 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)) Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2))
builder.addPentagonalPrism(t) builder.addPentagonalPrism(t)
break break
case SaccharideShapes.FlatHexagon: case SaccharideShapes.FlatHexagon:
default: default:
centerAlign(cGeo.center, cGeo.normal, cGeo.direction) centerAlign(cGeo.center, cGeo.normal, cGeo.direction)
Mat4.mul(t, t, Mat4.rotY90) Mat4.mul(t, t, Mat4.rotZYZ90)
Mat4.scale(t, t, Vec3.set(sVec, side, side, side / 2)) Mat4.scale(t, t, Vec3.set(sVec, side / 1.5, side , side / 2))
builder.addHexagonalPrism(t) builder.addHexagonalPrism(t)
break break
} }
......
...@@ -877,8 +877,14 @@ namespace Mat4 { ...@@ -877,8 +877,14 @@ namespace Mat4 {
export const rotX90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(1, 0, 0)) export const rotX90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(1, 0, 0))
/** Rotation matrix for 90deg rotation around y-axis */ /** Rotation matrix for 90deg rotation around y-axis */
export const rotY90: ReadonlyMat4 = Mat4.fromRotation(Mat4.identity(), degToRad(90), Vec3.create(0, 1, 0)) 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 */ /** Rotation matrix for 90deg rotation around first x-axis and then y-axis */
export const rotXY90: ReadonlyMat4 = Mat4.mul(Mat4.identity(), rotX90, rotY90) 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 export default Mat4
\ No newline at end of file
...@@ -98,14 +98,14 @@ export class Stage { ...@@ -98,14 +98,14 @@ export class Stage {
// this.loadPdbid('3sn6') // discontinuous chains // this.loadPdbid('3sn6') // discontinuous chains
// this.loadPdbid('2zex') // contains carbohydrate polymer // this.loadPdbid('2zex') // contains carbohydrate polymer
// this.loadPdbid('3sgj') // 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('1umz') // contains Xyl (Xyloglucan)
// this.loadPdbid('1mfb') // contains Abe // this.loadPdbid('1mfb') // contains Abe
// this.loadPdbid('2gdu') // contains sucrose // this.loadPdbid('2gdu') // contains sucrose
// this.loadPdbid('2fnc') // contains maltotriose // this.loadPdbid('2fnc') // contains maltotriose
// this.loadPdbid('4zs9') // contains raffinose // this.loadPdbid('4zs9') // contains raffinose
// this.loadPdbid('2yft') // contains kestose // 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_full.bcif`)
// this.loadMmcifUrl(`../../examples/1cbs_updated.cif`) // this.loadMmcifUrl(`../../examples/1cbs_updated.cif`)
// this.loadMmcifUrl(`../../examples/1crn.cif`) // this.loadMmcifUrl(`../../examples/1crn.cif`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment