Jelajahi Sumber

(partly) fixing validation tests

Raanan Weber 7 tahun lalu
induk
melakukan
2f8f5b5910

+ 2 - 1
Viewer/src/configuration/configuration.ts

@@ -99,7 +99,7 @@ export interface IModelConfiguration {
         center?: boolean;
         unitSize?: boolean;
         parentIndex?: number;
-    }; // shoud the model be scaled to unit-size
+    }; // should the model be scaled to unit-size
 
     title?: string;
     subtitle?: string;
@@ -326,6 +326,7 @@ export interface ICameraConfiguration {
     };
     disableCameraControl?: boolean;
     disableCtrlForPanning?: boolean;
+    disableAutoFocus?: boolean;
 
     [propName: string]: any;
 }

+ 1 - 1
Viewer/src/viewer/sceneManager.ts

@@ -381,7 +381,7 @@ export class SceneManager {
             let newTarget = this.camera.target.clone();
             extendClassWithConfig(newTarget, cameraConfig.target);
             this.camera.setTarget(newTarget);
-        } else if (model) {
+        } else if (model && !cameraConfig.disableAutoFocus) {
             const boundingInfo = model.rootMesh.getHierarchyBoundingVectors(true);
             const sizeVec = boundingInfo.max.subtract(boundingInfo.min);
             const halfSizeVec = sizeVec.scale(0.5);

TEMPAT SAMPAH
Viewer/tests/validation/ReferenceImages/BrainStem.png


TEMPAT SAMPAH
Viewer/tests/validation/ReferenceImages/BrainStemTransformation.png


TEMPAT SAMPAH
Viewer/tests/validation/ReferenceImages/Diffuse.png


TEMPAT SAMPAH
Viewer/tests/validation/ReferenceImages/basicHelmet.png


+ 3 - 0
Viewer/tests/validation/config.json

@@ -72,6 +72,9 @@
             "title": "BrainStem transformation",
             "configuration": {
                 "extends": "extended",
+                "camera": {
+                    "disableAutoFocus": true
+                },
                 "model": {
                     "position": {
                         "x": 0.2,

+ 28 - 14
Viewer/tests/validation/validation.js

@@ -186,10 +186,25 @@ function runTest(index, done) {
     configuration.engine.engineOptions.preserveDrawingBuffer = true;
 
     //cancel camera behvaviors for the tests
-    if (configuration.camera && configuration.camera.behaviors) {
-        delete configuration.camera.behaviors;
+    configuration.camera = configuration.camera || {};
+    configuration.camera.behaviors = null;
+
+    // make sure we use only local assets
+    configuration.skybox = {
+        cubeTexture: {
+            url: "/dist/assets/environment/DefaultSkybox_cube_radiance_256.dds"
+        }
     }
 
+    //envirnonment directory
+    configuration.lab = configuration.lab || {};
+    configuration.lab.environmentAssetsRootURL = "/dist/assets/environment/";
+
+    //model config
+    configuration.model = configuration.model || {};
+    configuration.model.castShadow = !test.createMesh
+
+
     // create a new viewer
     currentViewer && currentViewer.dispose();
     currentViewer = null;
@@ -202,24 +217,23 @@ function runTest(index, done) {
         var currentFrame = 0;
         var waitForFrame = test.waitForFrame || 1;
 
-        if (test.createMesh) {
+        if (test.model) {
+            currentViewer.initModel(test.model);
+        } else if (test.createMesh) {
             prepareMeshForViewer(currentViewer, configuration, test);
-            currentViewer.sceneManager.scene.executeWhenReady(() => {
-                currentViewer.onFrameRenderedObservable.add(() => {
-                    if (currentFrame === waitForFrame) {
-                        evaluate(test, resultCanvas, result, renderImage, index, waitRing, done);
-                    }
-                    currentFrame++;
-                });
-            });
-        } else {
+        }
+
+        currentViewer.onModelLoadedObservable.add(() => {
             currentViewer.onFrameRenderedObservable.add(() => {
                 if (currentFrame === waitForFrame) {
-                    evaluate(test, resultCanvas, result, renderImage, index, waitRing, done);
+                    currentViewer.sceneManager.scene.executeWhenReady(() => {
+                        evaluate(test, resultCanvas, result, renderImage, index, waitRing, done);
+                    });
                 }
                 currentFrame++;
             });
-        }
+
+        })
     });
 }