Browse Source

updated review.js to support cameras defined in a scene
updated the bone mapping logic to instead record the maps locally within the parsing method and not store to the Geometry() instance
included package modules missing from import
cleanup of unused imports and variables

repsac 10 years ago
parent
commit
e4a3720a37

+ 0 - 1
utils/exporters/blender/addons/io_three/constants.py

@@ -43,7 +43,6 @@ VERTICES = 'vertices'
 FACES = 'faces'
 FACES = 'faces'
 NORMALS = 'normals'
 NORMALS = 'normals'
 BONES = 'bones'
 BONES = 'bones'
-BONE_MAP = 'boneMap'
 UVS = 'uvs'
 UVS = 'uvs'
 COLORS = 'colors'
 COLORS = 'colors'
 MIX_COLORS = 'mixColors'
 MIX_COLORS = 'mixColors'

+ 1 - 2
utils/exporters/blender/addons/io_three/exporter/api/camera.py

@@ -1,6 +1,5 @@
-import math
 from bpy import data, types, context
 from bpy import data, types, context
-from .. import constants, logger
+from .. import logger
 
 
 
 
 def _camera(func):
 def _camera(func):

+ 2 - 2
utils/exporters/blender/addons/io_three/exporter/api/light.py

@@ -1,5 +1,5 @@
-from bpy import data, types, context
-from .. import constants, utilities, logger
+from bpy import data, types 
+from .. import utilities, logger
 
 
 
 
 def _lamp(func):
 def _lamp(func):

+ 2 - 6
utils/exporters/blender/addons/io_three/exporter/api/mesh.py

@@ -3,7 +3,7 @@ import mathutils
 from bpy import data, types, context
 from bpy import data, types, context
 from . import material, texture
 from . import material, texture
 from . import object as object_
 from . import object as object_
-from .. import constants, utilities, logger
+from .. import constants, utilities, logger, exceptions
 
 
 
 
 def _mesh(func):
 def _mesh(func):
@@ -76,10 +76,7 @@ def bones(mesh):
 
 
         bone_count += 1
         bone_count += 1
 
 
-    return {
-        constants.BONES: bones,
-        constants.BONE_MAP: bone_map
-    }
+    return (bones, bone_map)
 
 
 
 
 @_mesh
 @_mesh
@@ -172,7 +169,6 @@ def faces(mesh, options):
     vertex_normals = _normals(mesh, options) if opt_normals else None
     vertex_normals = _normals(mesh, options) if opt_normals else None
     vertex_colours = vertex_colors(mesh) if opt_colours else None
     vertex_colours = vertex_colors(mesh) if opt_colours else None
 
 
-    MASK = constants.MASK
     face_data = []
     face_data = []
 
 
     logger.info('Parsing %d faces', len(mesh.tessfaces))
     logger.info('Parsing %d faces', len(mesh.tessfaces))

+ 1 - 5
utils/exporters/blender/addons/io_three/exporter/api/object.py

@@ -2,7 +2,7 @@ import math
 import mathutils
 import mathutils
 import bpy
 import bpy
 from bpy import data, context, types
 from bpy import data, context, types
-from .. import constants, logger, utilities
+from .. import constants, logger, utilities, exceptions
 from .constants import (
 from .constants import (
     MESH,
     MESH,
     EMPTY,
     EMPTY,
@@ -13,8 +13,6 @@ from .constants import (
     POINT,
     POINT,
     HEMI,
     HEMI,
     AREA,
     AREA,
-    PERSP,
-    ORTHO,
     CAMERA,
     CAMERA,
     PERSP,
     PERSP,
     ORTHO,
     ORTHO,
@@ -50,7 +48,6 @@ def _object(func):
 
 
 def assemblies(valid_types):
 def assemblies(valid_types):
     logger.debug('object.assemblies(%s)', valid_types)
     logger.debug('object.assemblies(%s)', valid_types)
-    nodes = []
     for obj in data.objects:
     for obj in data.objects:
         if not obj.parent and obj.type in valid_types:
         if not obj.parent and obj.type in valid_types:
             yield obj.name
             yield obj.name
@@ -390,7 +387,6 @@ def _matrix(obj):
 
 
 
 
 def _on_visible_layer(obj, visible_layers):
 def _on_visible_layer(obj, visible_layers):
-    obj_layers = []
     visible = True
     visible = True
     for index, layer in enumerate(obj.layers):
     for index, layer in enumerate(obj.layers):
         if layer and index not in visible_layers:
         if layer and index not in visible_layers:

+ 0 - 1
utils/exporters/blender/addons/io_three/exporter/api/texture.py

@@ -1,4 +1,3 @@
-import bpy
 from bpy import data, types
 from bpy import data, types
 from .. import constants, logger
 from .. import constants, logger
 from .constants import IMAGE, MAG_FILTER, MIN_FILTER, MAPPING
 from .constants import IMAGE, MAG_FILTER, MIN_FILTER, MAPPING

+ 10 - 11
utils/exporters/blender/addons/io_three/exporter/geometry.py

@@ -230,8 +230,8 @@ class Geometry(base_classes.BaseNode):
     def __geometry_metadata(self, metadata): 
     def __geometry_metadata(self, metadata): 
         skip = (constants.TYPE, constants.FACES, constants.UUID,
         skip = (constants.TYPE, constants.FACES, constants.UUID,
             constants.ANIMATION, constants.SKIN_INDICES,
             constants.ANIMATION, constants.SKIN_INDICES,
-            constants.BONE_MAP, constants.SKIN_WEIGHTS, 
-            constants.NAME, constants.INFLUENCES_PER_VERTEX)
+            constants.SKIN_WEIGHTS, constants.NAME, 
+            constants.INFLUENCES_PER_VERTEX)
         vectors = (constants.VERTICES, constants.NORMALS)
         vectors = (constants.VERTICES, constants.NORMALS)
 
 
         for key in self.keys():
         for key in self.keys():
@@ -332,28 +332,27 @@ class Geometry(base_classes.BaseNode):
 
 
         if self.options.get(constants.UVS):
         if self.options.get(constants.UVS):
             logger.info('Parsing %s', constants.UVS)
             logger.info('Parsing %s', constants.UVS)
-            self[constants.UVS] = api.mesh.uvs(self.node, self.options)
+            self[constants.UVS] = api.mesh.uvs(
+                self.node, self.options)
 
 
         if self.options.get(constants.ANIMATION):
         if self.options.get(constants.ANIMATION):
             logger.info('Parsing %s', constants.ANIMATION)
             logger.info('Parsing %s', constants.ANIMATION)
             self[constants.ANIMATION] = api.mesh.animation(
             self[constants.ANIMATION] = api.mesh.animation(
                 self.node, self.options)
                 self.node, self.options)
 
 
-        #@TODO: wondering if bone maps should be stored with
-        #       the object itself or only handled via a local
-        #       variable as it doesn't seem this data has 
-        #       other users outside of the immediate logic
+        #@TODO: considering making bones data implied when
+        #       querying skinning data
+
+        bone_map = {}
         if self.options.get(constants.BONES):
         if self.options.get(constants.BONES):
             logger.info('Parsing %s', constants.BONES)
             logger.info('Parsing %s', constants.BONES)
-            bone_data = api.mesh.bones(self.node)
-            self[constants.BONES] = bone_data[constants.BONES]
-            self[constants.BONE_MAP] = bone_data[constants.BONE_MAP]
+            bones, bone_map = api.mesh.bones(self.node)
+            self[constants.BONES] = bones
 
 
         if self.options.get(constants.SKINNING):
         if self.options.get(constants.SKINNING):
             logger.info('Parsing %s', constants.SKINNING)
             logger.info('Parsing %s', constants.SKINNING)
             influences = self.options.get(
             influences = self.options.get(
                 constants.INFLUENCES_PER_VERTEX, 2)
                 constants.INFLUENCES_PER_VERTEX, 2)
-            bone_map = self.get(constants.BONE_MAP) or {}
 
 
             self[constants.INFLUENCES_PER_VERTEX] = influences
             self[constants.INFLUENCES_PER_VERTEX] = influences
             self[constants.SKIN_INDICES] = api.mesh.skin_indices(
             self[constants.SKIN_INDICES] = api.mesh.skin_indices(

+ 1 - 1
utils/exporters/blender/addons/io_three/exporter/io.py

@@ -1,6 +1,6 @@
 import shutil
 import shutil
 from .. import constants
 from .. import constants
-from . import _json, logger, exceptions 
+from . import _json, logger
 
 
 
 
 def copy_registered_textures(dest, registration):
 def copy_registered_textures(dest, registration):

+ 0 - 3
utils/exporters/blender/addons/io_three/exporter/scene.py

@@ -2,11 +2,9 @@ import os
 from .. import constants
 from .. import constants
 from . import (
 from . import (
     base_classes,
     base_classes,
-    image,
     texture,
     texture,
     material,
     material,
     geometry, 
     geometry, 
-    exceptions,
     object,
     object,
     logger,
     logger,
     io,
     io,
@@ -83,7 +81,6 @@ class Scene(base_classes.BaseScene):
         extension = constants.EXTENSIONS.get(compression, 
         extension = constants.EXTENSIONS.get(compression, 
             constants.EXTENSIONS[constants.JSON])
             constants.EXTENSIONS[constants.JSON])
 
 
-        #@TODO: test this new logic
         export_dir = os.path.dirname(self.filepath)
         export_dir = os.path.dirname(self.filepath)
         for key, value in self.items():
         for key, value in self.items():
             
             

+ 18 - 5
utils/exporters/blender/tests/scripts/js/review.js

@@ -75,20 +75,33 @@ function loadObject( data ) {
     var loader = new THREE.ObjectLoader();
     var loader = new THREE.ObjectLoader();
     scene = loader.parse( data );
     scene = loader.parse( data );
 
 
-
     var hasLights = false;
     var hasLights = false;
 
 
     var lights = ['AmbientLight', 'DirectionalLight', 'AreaLight',
     var lights = ['AmbientLight', 'DirectionalLight', 'AreaLight',
         'PointLight', 'SpotLight', 'HemisphereLight']
         'PointLight', 'SpotLight', 'HemisphereLight']
 
 
-    for ( i = 0; i < data.object.children.length; i ++ ) {
+    var cameras = ['OrthographicCamera', 'PerspectiveCamera'];
+
+    for ( i = 0; i < scene.children.length; i ++ ) {
 
 
-        var index = lights.indexOf( data.object.children[ i ].type );
+        var lightIndex = lights.indexOf( scene.children[ i ].type );
 
 
-        if ( index > -1 ) {
+        if ( lightIndex > -1 ) {
 
 
             hasLights = true;
             hasLights = true;
-            break;
+            continue;
+
+        }
+
+        var cameraIndex = cameras.indexOf( scene.children[ i ].type );
+
+        if ( cameraIndex > -1 ) {
+
+            camera = scene.children[ i ];
+            var container = document.getElementById( 'viewport' );
+            var aspect = container.offsetWidth / container.offsetHeight;
+            camera.aspect = aspect;
+            camera.updateProjectionMatrix();
 
 
         }
         }