Browse Source

initial static geometry tests (without textures) are working

repsac 10 years ago
parent
commit
2dccd13ee1
25 changed files with 216 additions and 93 deletions
  1. 147 0
      utils/exporters/blender/tests/scripts/js/review.js
  2. 0 1
      utils/exporters/blender/tests/scripts/setup_test_env.bash
  3. 3 4
      utils/exporters/blender/tests/scripts/test_buffer_geometry.bash
  4. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_animation.bash
  5. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_bump_spec_maps.bash
  6. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_diffuse_map.bash
  7. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_lambert_material.bash
  8. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_light_map.bash
  9. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_mix_colors.bash
  10. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_morph_targets.bash
  11. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_normal_map.bash
  12. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_normals.bash
  13. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_phong_material.bash
  14. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_vertex_colors.bash
  15. 3 4
      utils/exporters/blender/tests/scripts/test_geometry_wireframe.bash
  16. 3 4
      utils/exporters/blender/tests/scripts/test_scene_area_light.bash
  17. 3 4
      utils/exporters/blender/tests/scripts/test_scene_directional_light.bash
  18. 3 4
      utils/exporters/blender/tests/scripts/test_scene_hemi_light.bash
  19. 3 4
      utils/exporters/blender/tests/scripts/test_scene_instancing.bash
  20. 3 4
      utils/exporters/blender/tests/scripts/test_scene_maps.bash
  21. 3 4
      utils/exporters/blender/tests/scripts/test_scene_no_embed.bash
  22. 3 4
      utils/exporters/blender/tests/scripts/test_scene_orthographic.bash
  23. 3 4
      utils/exporters/blender/tests/scripts/test_scene_perspective.bash
  24. 3 4
      utils/exporters/blender/tests/scripts/test_scene_point_light.bash
  25. 3 4
      utils/exporters/blender/tests/scripts/test_scene_spot_light.bash

+ 147 - 0
utils/exporters/blender/tests/scripts/js/review.js

@@ -0,0 +1,147 @@
+var scene, renderer, camera, container, animation;
+
+var clock = new THREE.Clock();
+
+function render() {
+        
+    renderer.render( scene, camera );
+      
+}
+
+function animate() {
+
+    requestAnimationFrame( animate );
+
+    if ( animation != null ) {
+
+        var delta = clock.getDelta();
+        THREE.AnimationHandler.update( delta );
+
+    }
+
+    render();
+
+}
+
+function onWindowResize() {
+
+    camera.aspect = container.offsetWidth / container.offsetHeight;
+    camera.updateProjectionMatrix();
+
+    renderer.setSize( container.offsetWidth, container.offsetHeight );
+
+    render();
+
+}
+
+function setupScene( result, data ) {
+
+    scene = new THREE.Scene();
+    scene.add( new THREE.GridHelper( 10, 2.5 ) );
+
+}
+
+function setupLights() {
+
+    var directionalLight = new THREE.DirectionalLight( 0xb8b8b8 );
+    directionalLight.position.set(1, 1, 1).normalize();
+    directionalLight.intensity = 1.0;
+    scene.add( directionalLight );
+    
+    directionalLight = new THREE.DirectionalLight( 0xb8b8b8 );
+    directionalLight.position.set(-1, 0.6, 0.5).normalize();
+    directionalLight.intensity = 0.5;
+    scene.add(directionalLight);
+
+    directionalLight = new THREE.DirectionalLight();
+    directionalLight.position.set(-0.3, 0.6, -0.8).normalize( 0xb8b8b8 );
+    directionalLight.intensity = 0.45;
+    scene.add(directionalLight);
+
+}
+
+function loadGeometry( data, url ) {
+
+    var loader = new THREE.JSONLoader();
+    var texturePath = loader.extractUrlBase( url );
+    data = loader.parse( data, texturePath );
+    if ( data.materials === undefined ) {
+    
+        console.log('using default material');
+        data.materials = [new THREE.MeshLambertMaterial( { color: 0xb8b8b8 } )];
+    
+    }
+
+    var material = new THREE.MeshFaceMaterial( data.materials ); 
+    var mesh;
+
+    mesh = new THREE.Mesh( data.geometry, material );
+
+    setupScene();
+    setupLights();
+    scene.add( mesh );
+
+    render();
+
+}
+
+function loadData( data, url ) {
+
+    if ( data.metadata.type == 'Geometry' ) {
+        
+        loadGeometry( data, url );
+    
+    }
+
+}
+
+function init( url ) {
+
+    container = document.createElement( 'div' );
+    container.id = 'viewport';
+    document.body.appendChild( container );
+
+    renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true  } );
+    renderer.setSize( container.offsetWidth, container.offsetHeight );
+    renderer.setClearColor( 0x000000, 0 );
+    container.appendChild( renderer.domElement );
+    renderer.gammaInput = true;
+    renderer.gammaOutput = true;
+    
+    var aspect = container.offsetWidth / container.offsetHeight;
+    camera = new THREE.PerspectiveCamera( 50, aspect, 0.01, 50 );
+    orbit = new THREE.OrbitControls( camera, container );
+    orbit.addEventListener( 'change', render );
+    camera.position.z = 5;
+    camera.position.x = 5;
+    camera.position.y = 5;
+    var target = new THREE.Vector3( 0, 1, 0 );
+    camera.lookAt( target );
+    orbit.target = target;
+    camera.updateProjectionMatrix();
+
+    window.addEventListener( 'resize', onWindowResize, false );
+
+	var xhr = new XMLHttpRequest();
+    xhr.onreadystatechange = function ( x ) {
+    
+        if ( xhr.readyState === xhr.DONE ) {
+
+            if ( xhr.status === 200 || xhr.status === 0  ) {
+
+                loadData( JSON.parse( xhr.responseText ), url );
+
+            } else {
+
+                console.error( 'could not load json ' + xhr.status );
+
+            }
+
+        } 
+    
+    };
+    xhr.open( 'GET', url, true );
+    xhr.withCredentials = false;
+    xhr.send( null );
+
+}

+ 0 - 1
utils/exporters/blender/tests/scripts/setup_test_env.bash

@@ -3,7 +3,6 @@
 # you must have blender setup to run from the command line
 if [[ `which blender` == "" ]]; then
     echo "No 'blender' executable found on the command line"
-    exit 1
 fi
 
 export JSON=`python -c "import tempfile;print(tempfile.mktemp(prefix='$TAG.', suffix='.json'))"`

+ 3 - 4
utils/exporters/blender/tests/scripts/test_buffer_geometry.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --geometryType BufferGeometry
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --geometryType BufferGeometry
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_animation.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/anim.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --animation --bones --skinning \
+    $JSON --vertices --faces --animation --bones --skinning \
     --embedAnimation
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_bump_spec_maps.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/planeA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials --uvs --maps
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials --uvs --maps
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_diffuse_map.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials --uvs --maps
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials --uvs --maps
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_lambert_material.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_light_map.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/lightmap.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials --uvs --maps
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials --uvs --maps
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_mix_colors.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeB.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --colors --faceMaterials --mixColors
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --colors --faceMaterials --mixColors
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_morph_targets.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/anim.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --morphTargets
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --morphTargets
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_normal_map.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/planeB.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials --uvs --maps --normals
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials --uvs --maps --normals
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_normals.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/torusA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --normals
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --normals
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_phong_material.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/torusA.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --normals --faceMaterials
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --normals --faceMaterials
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_vertex_colors.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeB.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --colors --faceMaterials
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --colors --faceMaterials
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_geometry_wireframe.bash

@@ -1,9 +1,8 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/cubeC.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --faceMaterials
-testjson $@ --tag $(tagname)
+    $JSON --vertices --faces --faceMaterials
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_area_light.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_area_light.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --lights --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_directional_light.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_directional_light.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --lights --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_hemi_light.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_hemi_light.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --lights --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_instancing.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_instancing.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --scene --materials --roundOff \
+    $JSON --vertices --faces --scene --materials --roundOff \
     --roundValue 4 --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_maps.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_maps.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --scene --materials --maps \
+    $JSON --vertices --faces --scene --materials --maps \
     --uvs --embedGeometry --copyTextures
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_no_embed.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_instancing.blend --python $PYSCRIPT -- \
-    $TMP_JSON --vertices --faces --scene --materials --roundOff \
+    $JSON --vertices --faces --scene --materials --roundOff \
     --roundValue 4
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_orthographic.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_orthographic_camera.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --cameras --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_perspective.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_perspective_camera.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --cameras --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_point_light.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_point_light.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --lights --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)

+ 3 - 4
utils/exporters/blender/tests/scripts/test_scene_spot_light.bash

@@ -1,10 +1,9 @@
 #!/bin/bash
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $DIR
+source "$DIR/setup_test_env.bash"
 
-source setup_test_env.bash
 blender --background $BLEND/scene_spot_light.blend \
-    --python $PYSCRIPT -- $TMP_JSON --vertices --faces --scene \
+    --python $PYSCRIPT -- $JSON --vertices --faces --scene \
     --lights --materials --embedGeometry
-testjson $@ --tag $(tagname)
+makereview $@ --tag $(tagname)