|
@@ -23,16 +23,10 @@ import { Loci, EmptyLoci } from 'mol-model/loci';
|
|
import { SizeTheme } from '../../../theme';
|
|
import { SizeTheme } from '../../../theme';
|
|
import { createMeshValues, updateMeshValues, updateRenderableState, createRenderableState, DefaultMeshProps } from '../../util';
|
|
import { createMeshValues, updateMeshValues, updateRenderableState, createRenderableState, DefaultMeshProps } from '../../util';
|
|
import { MeshBuilder } from '../../../shape/mesh-builder';
|
|
import { MeshBuilder } from '../../../shape/mesh-builder';
|
|
-import { getPolymerElementCount, PolymerTraceIterator, interpolateNormals } from './util/polymer';
|
|
|
|
-import { Vec3, Mat4 } from 'mol-math/linear-algebra';
|
|
|
|
|
|
+import { getPolymerElementCount, PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment } from './util/polymer';
|
|
import { SecondaryStructureType, MoleculeType } from 'mol-model/structure/model/types';
|
|
import { SecondaryStructureType, MoleculeType } from 'mol-model/structure/model/types';
|
|
|
|
|
|
// TODO handle polymer ends properly
|
|
// TODO handle polymer ends properly
|
|
-// TODO avoid allocating Vec3, use global temp vars
|
|
|
|
-// TODO move more interpolation code into ./util/polymer/interpolate
|
|
|
|
-// TODO move direction wedges into separate visual
|
|
|
|
-
|
|
|
|
-const t = Mat4.identity()
|
|
|
|
|
|
|
|
async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Mesh) {
|
|
async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Mesh) {
|
|
const polymerElementCount = getPolymerElementCount(unit)
|
|
const polymerElementCount = getPolymerElementCount(unit)
|
|
@@ -44,17 +38,8 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
|
|
const linearSegments = 8
|
|
const linearSegments = 8
|
|
const radialSegments = 12
|
|
const radialSegments = 12
|
|
|
|
|
|
- const tanA = Vec3.zero()
|
|
|
|
- const tanB = Vec3.zero()
|
|
|
|
-
|
|
|
|
- const tB = Vec3.zero()
|
|
|
|
- const tangentVec = Vec3.zero()
|
|
|
|
-
|
|
|
|
- const pn = (linearSegments + 1) * 3
|
|
|
|
- const controlPoints = new Float32Array(pn)
|
|
|
|
- const tangentVectors = new Float32Array(pn)
|
|
|
|
- const normalVectors = new Float32Array(pn)
|
|
|
|
- const binormalVectors = new Float32Array(pn)
|
|
|
|
|
|
+ const state = createCurveSegmentState(linearSegments)
|
|
|
|
+ const { curvePoints, normalVectors, binormalVectors } = state
|
|
|
|
|
|
let i = 0
|
|
let i = 0
|
|
const polymerTraceIt = PolymerTraceIterator(unit)
|
|
const polymerTraceIt = PolymerTraceIterator(unit)
|
|
@@ -67,26 +52,8 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
|
|
const isHelix = SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Helix)
|
|
const isHelix = SecondaryStructureType.is(v.secStrucType, SecondaryStructureType.Flag.Helix)
|
|
const tension = (isNucleic || isSheet) ? 0.5 : 0.9
|
|
const tension = (isNucleic || isSheet) ? 0.5 : 0.9
|
|
|
|
|
|
- for (let j = 0; j <= linearSegments; ++j) {
|
|
|
|
- const t = j * 1.0 / linearSegments;
|
|
|
|
- // if ((v.last && t > 0.5) || (v.first && t < 0.5)) break
|
|
|
|
-
|
|
|
|
- if (t < 0.5) {
|
|
|
|
- Vec3.spline(tB, v.t0, v.t1, v.t2, v.t3, t + 0.5, tension)
|
|
|
|
- Vec3.spline(tanA, v.t0, v.t1, v.t2, v.t3, t + 0.5 + 0.01, tension)
|
|
|
|
- Vec3.spline(tanB, v.t0, v.t1, v.t2, v.t3, t + 0.5 - 0.01, tension)
|
|
|
|
- } else {
|
|
|
|
- Vec3.spline(tB, v.t1, v.t2, v.t3, v.t4, t - 0.5, tension)
|
|
|
|
- Vec3.spline(tanA, v.t1, v.t2, v.t3, v.t4, t - 0.5 + 0.01, tension)
|
|
|
|
- Vec3.spline(tanB, v.t1, v.t2, v.t3, v.t4, t - 0.5 - 0.01, tension)
|
|
|
|
- }
|
|
|
|
- Vec3.toArray(tB, controlPoints, j * 3)
|
|
|
|
- Vec3.normalize(tangentVec, Vec3.sub(tangentVec, tanA, tanB))
|
|
|
|
- Vec3.toArray(tangentVec, tangentVectors, j * 3)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// console.log('ELEMENT', i)
|
|
// console.log('ELEMENT', i)
|
|
- interpolateNormals(controlPoints, tangentVectors, normalVectors, binormalVectors, v.d12, v.d23)
|
|
|
|
|
|
+ interpolateCurveSegment(state, v, tension)
|
|
|
|
|
|
let width = 0.2, height = 0.2
|
|
let width = 0.2, height = 0.2
|
|
|
|
|
|
@@ -94,30 +61,14 @@ async function createPolymerTraceMesh(ctx: RuntimeContext, unit: Unit, mesh?: Me
|
|
if (isSheet) {
|
|
if (isSheet) {
|
|
width = 0.15; height = 1.0
|
|
width = 0.15; height = 1.0
|
|
const arrowHeight = v.secStrucChange ? 1.7 : 0
|
|
const arrowHeight = v.secStrucChange ? 1.7 : 0
|
|
- builder.addSheet(controlPoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, true, true)
|
|
|
|
|
|
+ builder.addSheet(curvePoints, normalVectors, binormalVectors, linearSegments, width, height, arrowHeight, true, true)
|
|
} else {
|
|
} else {
|
|
if (isHelix) {
|
|
if (isHelix) {
|
|
width = 0.2; height = 1.0
|
|
width = 0.2; height = 1.0
|
|
} else if (isNucleic) {
|
|
} else if (isNucleic) {
|
|
width = 1.5; height = 0.3
|
|
width = 1.5; height = 0.3
|
|
}
|
|
}
|
|
- builder.addTube(controlPoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, true, true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((isSheet && !v.secStrucChange) || !isSheet) {
|
|
|
|
- const upVec = Vec3.zero()
|
|
|
|
- let width = 0.5, height = 1.2, depth = 0.6
|
|
|
|
- if (isNucleic) {
|
|
|
|
- Vec3.fromArray(upVec, binormalVectors, Math.round(linearSegments / 2) * 3)
|
|
|
|
- depth = 0.9
|
|
|
|
- } else {
|
|
|
|
- Vec3.fromArray(upVec, normalVectors, Math.round(linearSegments / 2) * 3)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Mat4.targetTo(t, v.t3, v.t1, upVec)
|
|
|
|
- Mat4.mul(t, t, Mat4.rotXY90)
|
|
|
|
- Mat4.setTranslation(t, v.t2)
|
|
|
|
- builder.addWedge(t, { width, height, depth })
|
|
|
|
|
|
+ builder.addTube(curvePoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, true, true)
|
|
}
|
|
}
|
|
|
|
|
|
if (i % 10000 === 0 && ctx.shouldUpdate) {
|
|
if (i % 10000 === 0 && ctx.shouldUpdate) {
|