diff --git a/src/mol-geo/geometry/lines/lines.ts b/src/mol-geo/geometry/lines/lines.ts index bcee14f2cfa561a3f30cd1c5d530749a8357a3cc..9c1e5e359c83c604ca78e1504f43b26a51683624 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -177,8 +177,8 @@ export namespace Lines { } function getBoundingSphere(lineStart: Float32Array, lineEnd: Float32Array, lineCount: number, transform: Float32Array, transformCount: number) { - const start = calculateBoundingSphere(lineStart, lineCount * 4, transform, transformCount) - const end = calculateBoundingSphere(lineEnd, lineCount * 4, transform, transformCount) + const start = calculateBoundingSphere(lineStart, lineCount * 4, transform, transformCount, 0, 4) + const end = calculateBoundingSphere(lineEnd, lineCount * 4, transform, transformCount, 0, 4) return { boundingSphere: Sphere3D.expandBySphere(start.boundingSphere, end.boundingSphere), invariantBoundingSphere: Sphere3D.expandBySphere(start.invariantBoundingSphere, end.invariantBoundingSphere) diff --git a/src/mol-geo/geometry/spheres/spheres.ts b/src/mol-geo/geometry/spheres/spheres.ts index 3129cd54a452e493af2aebd22a825092db86fc39..30aa207e32c84ae6fab089ca9f804b8ec7f3e2e4 100644 --- a/src/mol-geo/geometry/spheres/spheres.ts +++ b/src/mol-geo/geometry/spheres/spheres.ts @@ -89,7 +89,7 @@ export namespace Spheres { const padding = getMaxSize(size) const { boundingSphere, invariantBoundingSphere } = calculateBoundingSphere( spheres.centerBuffer.ref.value, spheres.sphereCount * 4, - transform.aTransform.ref.value, instanceCount, padding + transform.aTransform.ref.value, instanceCount, padding, 4 ) return { @@ -130,7 +130,7 @@ export namespace Spheres { const padding = getMaxSize(values) const { boundingSphere, invariantBoundingSphere } = calculateBoundingSphere( values.aPosition.ref.value, spheres.sphereCount * 4, - values.aTransform.ref.value, values.instanceCount.ref.value, padding + values.aTransform.ref.value, values.instanceCount.ref.value, padding, 4 ) if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { ValueCell.update(values.boundingSphere, boundingSphere) diff --git a/src/mol-gl/renderable/util.ts b/src/mol-gl/renderable/util.ts index e33d096228f88b37a3d3b2b03d18da2d1f70a29e..928d80e3091939dee556310bd8327063eea35ebe 100644 --- a/src/mol-gl/renderable/util.ts +++ b/src/mol-gl/renderable/util.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -80,14 +80,15 @@ export function printImageData(imageData: ImageData, scale = 1, pixelated = fals const v = Vec3.zero() const boundaryHelper = new BoundaryHelper() -export function calculateInvariantBoundingSphere(position: Float32Array, positionCount: number): Sphere3D { +export function calculateInvariantBoundingSphere(position: Float32Array, positionCount: number, stepFactor: number): Sphere3D { + const step = stepFactor * 3 boundaryHelper.reset(0) - for (let i = 0, _i = positionCount * 3; i < _i; i += 3) { + for (let i = 0, _i = positionCount * 3; i < _i; i += step) { Vec3.fromArray(v, position, i) boundaryHelper.boundaryStep(v, 0) } boundaryHelper.finishBoundaryStep() - for (let i = 0, _i = positionCount * 3; i < _i; i += 3) { + for (let i = 0, _i = positionCount * 3; i < _i; i += step) { Vec3.fromArray(v, position, i) boundaryHelper.extendStep(v, 0) } @@ -109,8 +110,8 @@ export function calculateTransformBoundingSphere(invariantBoundingSphere: Sphere return boundaryHelper.getSphere() } -export function calculateBoundingSphere(position: Float32Array, positionCount: number, transform: Float32Array, transformCount: number, padding = 0): { boundingSphere: Sphere3D, invariantBoundingSphere: Sphere3D } { - const invariantBoundingSphere = calculateInvariantBoundingSphere(position, positionCount) +export function calculateBoundingSphere(position: Float32Array, positionCount: number, transform: Float32Array, transformCount: number, padding = 0, stepFactor = 1): { boundingSphere: Sphere3D, invariantBoundingSphere: Sphere3D } { + const invariantBoundingSphere = calculateInvariantBoundingSphere(position, positionCount, stepFactor) const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform, transformCount) Sphere3D.expand(boundingSphere, boundingSphere, padding) Sphere3D.expand(invariantBoundingSphere, invariantBoundingSphere, padding)