Преглед на файлове

geo and repr tweaks & fixes

Alexander Rose преди 6 години
родител
ревизия
488d852529

+ 1 - 1
src/mol-geo/geometry/geometry.ts

@@ -72,7 +72,7 @@ export namespace Geometry {
             case 'spheres':
             case 'text':
             case 'lines':
-                return arrayMax(geometry.groupBuffer.ref.value) + 1
+                return getDrawCount(geometry) === 0 ? 0 : (arrayMax(geometry.groupBuffer.ref.value) + 1)
             case 'direct-volume':
                 return 1
         }

+ 1 - 1
src/mol-geo/geometry/text/font-atlas.ts

@@ -80,7 +80,7 @@ export class FontAtlas {
         this.lineHeight = Math.round(fontSize + 2 * this.buffer + this.radius)
         this.maxWidth = Math.round(this.lineHeight * 0.75)
 
-        // create texture
+        // create texture (for ~350 characters)
         this.texture = createTextureImage(350 * this.lineHeight * this.maxWidth, 1)
 
         // prepare scratch canvas

+ 14 - 0
src/mol-geo/geometry/text/text.ts

@@ -162,6 +162,20 @@ export namespace Text {
     function updateValues(values: TextValues, props: PD.Values<Params>) {
         BaseGeometry.updateValues(values, props)
         ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor)
+
+        ValueCell.updateIfChanged(values.uBorderWidth, props.borderWidth)
+        if (Color.fromNormalizedArray(values.uBorderColor.ref.value, 0) !== props.borderColor) {
+            Color.toArrayNormalized(props.borderColor, values.uBorderColor.ref.value, 0)
+            ValueCell.update(values.uBorderColor, values.uBorderColor.ref.value)
+        }
+        ValueCell.updateIfChanged(values.uOffsetX, props.offsetX)
+        ValueCell.updateIfChanged(values.uOffsetY, props.offsetY)
+        ValueCell.updateIfChanged(values.uOffsetZ, props.offsetZ)
+        if (Color.fromNormalizedArray(values.uBackgroundColor.ref.value, 0) !== props.backgroundColor) {
+            Color.toArrayNormalized(props.backgroundColor, values.uBackgroundColor.ref.value, 0)
+            ValueCell.update(values.uBackgroundColor, values.uBackgroundColor.ref.value)
+        }
+        ValueCell.updateIfChanged(values.uBackgroundOpacity, props.backgroundOpacity)
     }
 
     function updateBoundingSphere(values: TextValues, text: Text) {

+ 1 - 1
src/mol-gl/shader/text.vert

@@ -45,7 +45,7 @@ void main(void){
     float offsetY = uOffsetY * scale;
     float offsetZ = uOffsetZ * scale;
     if (vTexCoord.x == 10.0) {
-        offsetZ -= 0.001;
+        offsetZ -= 0.01;
     }
 
     vec4 mvPosition = uModelView * aTransform * vec4(aPosition, 1.0);

+ 8 - 6
src/mol-repr/shape/representation.ts

@@ -49,22 +49,22 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa
         VisualUpdateState.reset(updateState)
 
         if (!shape && !_shape) {
-            console.error('no shape given')
+            // console.error('no shape given')
             return
         } else if (shape && !_shape) {
-            console.log('first shape')
+            // console.log('first shape')
             updateState.createNew = true
         } else if (shape && _shape && shape.id === _shape.id) {
-            console.log('same shape')
+            // console.log('same shape')
             // trigger color update when shape has not changed
             updateState.updateColor = true
             updateState.updateTransform = true
         } else if (shape && _shape && shape.id !== _shape.id) {
-            console.log('new shape')
+            // console.log('new shape')
             updateState.updateTransform = true
             updateState.createGeometry = true
         } else if (!shape) {
-            console.log('only props')
+            // console.log('only props')
             // nothing to set
         } else {
             console.warn('unexpected state')
@@ -72,10 +72,12 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa
 
         if (updateState.updateTransform) {
             updateState.updateColor = true
+            updateState.updateSize = true
         }
 
         if (updateState.createGeometry) {
             updateState.updateColor = true
+            updateState.updateSize = true
         }
     }
 
@@ -132,7 +134,7 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa
                 if (updateState.updateSize) {
                     // not all geometries have size data, so check here
                     if ('uSize' in _renderObject.values) {
-                        console.log('update size')
+                        // console.log('update size')
                         createSizes(locationIt, _theme.size, _renderObject.values)
                     }
                 }

+ 2 - 0
src/mol-repr/structure/units-visual.ts

@@ -125,11 +125,13 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry
 
         if (updateState.updateTransform) {
             updateState.updateColor = true
+            updateState.updateSize = true
             updateState.updateMatrix = true
         }
 
         if (updateState.createGeometry) {
             updateState.updateColor = true
+            updateState.updateSize = true
         }
     }