Smithsonian / dpo-voyager

DPO Voyager - 3D Explorer and Tool Suite
Apache License 2.0
164 stars 28 forks source link

Empties transform doesn't get saved in tours #255

Open sdumetz opened 4 months ago

sdumetz commented 4 months ago

Empties (nodes with no "content" but that might have children; eg. the "Lights" node).

I think the relevant code is in CVSnaphots.ts:66,114: Only models and lights gets added. It's more or less a feature given that the features doesn't specify transform as a save target but the more specific lightsand models. However it would be practical to be able to move a bunch of nodes together in a tour.

Regarding a possible fix, aside from finding a way to map this back to the features array, I couldn't get a sense of how to filter the CVNode instances accordingly.

sdumetz commented 4 months ago

After digging in a bit, I came with a prototype:

@@ -79,16 +86,24 @@ export default class CVSnapshots extends CTweenMachine

         const models = this.getGraphComponents(CVModel2);
         models.forEach(model => {
-            this.updateComponentTarget(model.transform, !!features["models"]);
             this.updateComponentTarget(model, !!features["models"]);
         });

         const lights = this.getGraphComponents(CLight);
         lights.forEach(light => {
-            this.updateComponentTarget(light.transform, !!features["lights"]);
             this.updateComponentTarget(light, !!features["lights"])
         });

+
+        const transforms = this.getGraphComponents(CVNode);
+        for(let transform of transforms){
+            let node = transform.node
+            if(!isNVNode(node)) continue;
+            if(node.camera) continue;
+
+            this.updateComponentTarget(transform, !!features["transforms"]);
+        }
+

The downside is: this introduces another tour "feature" users have to keep in mind, which I very much dislike. Especially since the concept of "transform" being a thing of its own, more or less separated from the underlying data object, while sound from a technical perspective (everybody does it internally) is not intuitive at all for non-technical users.

Leaving this here for later reference but I think I might be able to propose something better in the near future : I'm trying to optimize how the states array gets stored because it gets stupidly large on scenes with multiple objects, a large features set and many tour steps, which is very much the types of scenes I am working on.