提交 e4a3720a 编写于 作者: R repsac

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
上级 46f47e58
...@@ -43,7 +43,6 @@ VERTICES = 'vertices' ...@@ -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'
......
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):
......
from bpy import data, types, context from bpy import data, types
from .. import constants, utilities, logger from .. import utilities, logger
def _lamp(func): def _lamp(func):
......
...@@ -3,7 +3,7 @@ import mathutils ...@@ -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): ...@@ -76,10 +76,7 @@ def bones(mesh):
bone_count += 1 bone_count += 1
return { return (bones, bone_map)
constants.BONES: bones,
constants.BONE_MAP: bone_map
}
@_mesh @_mesh
...@@ -172,7 +169,6 @@ def faces(mesh, options): ...@@ -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))
......
...@@ -2,7 +2,7 @@ import math ...@@ -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 ( ...@@ -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): ...@@ -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): ...@@ -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:
......
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
......
...@@ -230,8 +230,8 @@ class Geometry(base_classes.BaseNode): ...@@ -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.SKIN_WEIGHTS, constants.NAME,
constants.NAME, constants.INFLUENCES_PER_VERTEX) 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): ...@@ -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 #@TODO: considering making bones data implied when
# the object itself or only handled via a local # querying skinning data
# variable as it doesn't seem this data has
# other users outside of the immediate logic 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) bones, bone_map = api.mesh.bones(self.node)
self[constants.BONES] = bone_data[constants.BONES] self[constants.BONES] = bones
self[constants.BONE_MAP] = bone_data[constants.BONE_MAP]
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(
......
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):
......
...@@ -2,11 +2,9 @@ import os ...@@ -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): ...@@ -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():
......
...@@ -75,20 +75,33 @@ function loadObject( data ) { ...@@ -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();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册