From 13a6bf6c67c0e39cd2eea21bf32726bf3e46fb20 Mon Sep 17 00:00:00 2001 From: Phillip Hohenester Date: Fri, 22 Jan 2021 15:15:58 +0100 Subject: [PATCH 1/3] turned scene change into multicasts --- app_web/src/logic/uimodel.js | 7 ++++--- app_web/src/main.js | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app_web/src/logic/uimodel.js b/app_web/src/logic/uimodel.js index da9e77d7..f29a9ff9 100644 --- a/app_web/src/logic/uimodel.js +++ b/app_web/src/logic/uimodel.js @@ -1,5 +1,5 @@ -import { bindCallback, fromEvent, merge } from 'rxjs'; -import { map, filter, startWith, pluck } from 'rxjs/operators'; +import { Subject, fromEvent, merge } from 'rxjs'; +import { map, filter, startWith, pluck, multicast } from 'rxjs/operators'; import { glTF, ToneMaps, DebugOutput } from 'gltf-sample-viewer'; import { gltfInput } from '../input.js'; @@ -26,7 +26,8 @@ class UIModel map( value => ({mainFile: value, additionalFiles: undefined})), ); this.flavour = app.flavourChanged$.pipe(pluck("event", "msg")); // TODO gltfModelPathProvider needs to be changed to accept flavours explicitely - this.scene = app.sceneChanged$.pipe(pluck("event", "msg")); + const sceneSubject = new Subject(); + this.scene = app.sceneChanged$.pipe(pluck("event", "msg"), multicast(sceneSubject)); this.camera = app.cameraChanged$.pipe(pluck("event", "msg")); this.environment = app.environmentChanged$.pipe(pluck("event", "msg")); this.environmentRotation = app.environmentRotationChanged$.pipe(pluck("event", "msg")); diff --git a/app_web/src/main.js b/app_web/src/main.js index ad3a5b8f..cfc8b233 100644 --- a/app_web/src/main.js +++ b/app_web/src/main.js @@ -29,7 +29,7 @@ async function main() // whenever a new model is selected, load it and when complete pass the loaded gltf // into a stream back into the UI - const subject = new Subject(); + const gltfLoadedSubject = new Subject(); const gltfLoadedMulticast = uiModel.model.pipe( mergeMap( (model) => { @@ -50,10 +50,10 @@ async function main() ); }), // transform gltf loaded observable to multicast observable to avoid multiple execution with multiple subscriptions - multicast(subject) + multicast(gltfLoadedSubject) ); - + const sceneChangedSubject = new Subject(); const sceneChangedObservable = uiModel.scene.pipe(map( newSceneIndex => { state.sceneIndex = newSceneIndex; state.cameraIndex = undefined; @@ -61,7 +61,9 @@ async function main() scene.applyTransformHierarchy(state.gltf); computePrimitiveCentroids(state.gltf); state.userCamera.fitViewToScene(state.gltf, state.sceneIndex); - })); + }), + multicast(sceneChangedSubject) + ); const statisticsUpdateObservableTemp = merge( gltfLoadedMulticast, From 15c5d9f407319597c1d5ae43caa7b033bbd33141 Mon Sep 17 00:00:00 2001 From: Phillip Hohenester Date: Mon, 25 Jan 2021 12:46:51 +0100 Subject: [PATCH 2/3] removed multicast from scene --- app_web/src/logic/uimodel.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app_web/src/logic/uimodel.js b/app_web/src/logic/uimodel.js index f29a9ff9..ef9ada20 100644 --- a/app_web/src/logic/uimodel.js +++ b/app_web/src/logic/uimodel.js @@ -26,8 +26,7 @@ class UIModel map( value => ({mainFile: value, additionalFiles: undefined})), ); this.flavour = app.flavourChanged$.pipe(pluck("event", "msg")); // TODO gltfModelPathProvider needs to be changed to accept flavours explicitely - const sceneSubject = new Subject(); - this.scene = app.sceneChanged$.pipe(pluck("event", "msg"), multicast(sceneSubject)); + this.scene = app.sceneChanged$.pipe(pluck("event", "msg")); this.camera = app.cameraChanged$.pipe(pluck("event", "msg")); this.environment = app.environmentChanged$.pipe(pluck("event", "msg")); this.environmentRotation = app.environmentRotationChanged$.pipe(pluck("event", "msg")); From c859938627ef8b3f683d5a450e8181a45be5ed7d Mon Sep 17 00:00:00 2001 From: Phillip Hohenester Date: Mon, 25 Jan 2021 12:51:07 +0100 Subject: [PATCH 3/3] removed unnecessary imports --- app_web/src/logic/uimodel.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app_web/src/logic/uimodel.js b/app_web/src/logic/uimodel.js index ef9ada20..69949a54 100644 --- a/app_web/src/logic/uimodel.js +++ b/app_web/src/logic/uimodel.js @@ -1,7 +1,6 @@ -import { Subject, fromEvent, merge } from 'rxjs'; -import { map, filter, startWith, pluck, multicast } from 'rxjs/operators'; +import { fromEvent, merge } from 'rxjs'; +import { map, filter, startWith, pluck } from 'rxjs/operators'; import { glTF, ToneMaps, DebugOutput } from 'gltf-sample-viewer'; -import { gltfInput } from '../input.js'; import { getIsGltf, getIsGlb, getIsHdr } from 'gltf-sample-viewer';