From 0739a5e6326053a866f91e192873ba7ef6f537f1 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Mon, 11 Jun 2018 07:20:38 +0200
Subject: [PATCH] fixed scene update

---
 src/mol-gl/renderer.ts |  2 --
 src/mol-gl/scene.ts    | 10 +++++++---
 src/mol-view/viewer.ts |  7 ++-----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts
index cbc4ffffa..22e64a844 100644
--- a/src/mol-gl/renderer.ts
+++ b/src/mol-gl/renderer.ts
@@ -121,8 +121,6 @@ namespace Renderer {
             ValueCell.update(globalUniforms.uFogNear, camera.fogNear)
 
             currentProgramId = -1
-            // scene.unsetBoundingSphere()
-            // console.log('scene.boundingSphere', scene.boundingSphere)
 
             gl.depthMask(true)
             gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
diff --git a/src/mol-gl/scene.ts b/src/mol-gl/scene.ts
index 0cd225b7b..57764dd71 100644
--- a/src/mol-gl/scene.ts
+++ b/src/mol-gl/scene.ts
@@ -45,7 +45,6 @@ interface Scene extends Object3D {
     forEach: (callbackFn: (value: Renderable<any>, key: RenderObject) => void) => void
     eachOpaque: (callbackFn: (value: Renderable<any>, key: RenderObject) => void) => void
     eachTransparent: (callbackFn: (value: Renderable<any>, key: RenderObject) => void) => void
-    unsetBoundingSphere: () => void
 }
 
 namespace Scene {
@@ -57,7 +56,13 @@ namespace Scene {
 
         return {
             // ...createObject3D(), // TODO does not work in conjunction with getter
-            view, position, up, direction, update,
+            view, position, up, direction,
+
+            update: () => {
+                update()
+                renderableMap.forEach((o, r) => o.update())
+                boundingSphere = undefined
+            },
             
             add: (o: RenderObject) => {
                 if (!renderableMap.has(o)) {
@@ -93,7 +98,6 @@ namespace Scene {
                     if (o.values.uAlpha.ref.value < 1) callbackFn(r, o)
                 })
             },
-            unsetBoundingSphere: () => boundingSphere = undefined,
             get count() {
                 return renderableMap.size
             },
diff --git a/src/mol-view/viewer.ts b/src/mol-view/viewer.ts
index e8696d4b1..6be2f3607 100644
--- a/src/mol-view/viewer.ts
+++ b/src/mol-view/viewer.ts
@@ -269,7 +269,7 @@ namespace Viewer {
                 if (oldRO) {
                     SetUtils.difference(newRO, oldRO).forEach(o => scene.add(o))
                     SetUtils.difference(oldRO, newRO).forEach(o => scene.remove(o))
-                    // scene.update()
+                    scene.update()
                 } else {
                     repr.renderObjects.forEach(o => scene.add(o))
                 }
@@ -284,10 +284,7 @@ namespace Viewer {
                     reprCount.next(reprMap.size)
                 }
             },
-            update: () => {
-                scene.forEach((r, o) => r.update())
-                scene.unsetBoundingSphere()
-            },
+            update: () => scene.update(),
             clear: () => {
                 reprMap.clear()
                 scene.clear()
-- 
GitLab