提交 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'
FACES = 'faces'
NORMALS = 'normals'
BONES = 'bones'
BONE_MAP = 'boneMap'
UVS = 'uvs'
COLORS = 'colors'
MIX_COLORS = 'mixColors'
......
import math
from bpy import data, types, context
from .. import constants, logger
from .. import logger
def _camera(func):
......
from bpy import data, types, context
from .. import constants, utilities, logger
from bpy import data, types
from .. import utilities, logger
def _lamp(func):
......
......@@ -3,7 +3,7 @@ import mathutils
from bpy import data, types, context
from . import material, texture
from . import object as object_
from .. import constants, utilities, logger
from .. import constants, utilities, logger, exceptions
def _mesh(func):
......@@ -76,10 +76,7 @@ def bones(mesh):
bone_count += 1
return {
constants.BONES: bones,
constants.BONE_MAP: bone_map
}
return (bones, bone_map)
@_mesh
......@@ -172,7 +169,6 @@ def faces(mesh, options):
vertex_normals = _normals(mesh, options) if opt_normals else None
vertex_colours = vertex_colors(mesh) if opt_colours else None
MASK = constants.MASK
face_data = []
logger.info('Parsing %d faces', len(mesh.tessfaces))
......
......@@ -2,7 +2,7 @@ import math
import mathutils
import bpy
from bpy import data, context, types
from .. import constants, logger, utilities
from .. import constants, logger, utilities, exceptions
from .constants import (
MESH,
EMPTY,
......@@ -13,8 +13,6 @@ from .constants import (
POINT,
HEMI,
AREA,
PERSP,
ORTHO,
CAMERA,
PERSP,
ORTHO,
......@@ -50,7 +48,6 @@ def _object(func):
def assemblies(valid_types):
logger.debug('object.assemblies(%s)', valid_types)
nodes = []
for obj in data.objects:
if not obj.parent and obj.type in valid_types:
yield obj.name
......@@ -390,7 +387,6 @@ def _matrix(obj):
def _on_visible_layer(obj, visible_layers):
obj_layers = []
visible = True
for index, layer in enumerate(obj.layers):
if layer and index not in visible_layers:
......
import bpy
from bpy import data, types
from .. import constants, logger
from .constants import IMAGE, MAG_FILTER, MIN_FILTER, MAPPING
......
......@@ -230,8 +230,8 @@ class Geometry(base_classes.BaseNode):
def __geometry_metadata(self, metadata):
skip = (constants.TYPE, constants.FACES, constants.UUID,
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)
for key in self.keys():
......@@ -332,28 +332,27 @@ class Geometry(base_classes.BaseNode):
if self.options.get(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):
logger.info('Parsing %s', constants.ANIMATION)
self[constants.ANIMATION] = api.mesh.animation(
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):
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):
logger.info('Parsing %s', constants.SKINNING)
influences = self.options.get(
constants.INFLUENCES_PER_VERTEX, 2)
bone_map = self.get(constants.BONE_MAP) or {}
self[constants.INFLUENCES_PER_VERTEX] = influences
self[constants.SKIN_INDICES] = api.mesh.skin_indices(
......
import shutil
from .. import constants
from . import _json, logger, exceptions
from . import _json, logger
def copy_registered_textures(dest, registration):
......
......@@ -2,11 +2,9 @@ import os
from .. import constants
from . import (
base_classes,
image,
texture,
material,
geometry,
exceptions,
object,
logger,
io,
......@@ -83,7 +81,6 @@ class Scene(base_classes.BaseScene):
extension = constants.EXTENSIONS.get(compression,
constants.EXTENSIONS[constants.JSON])
#@TODO: test this new logic
export_dir = os.path.dirname(self.filepath)
for key, value in self.items():
......
......@@ -75,20 +75,33 @@ function loadObject( data ) {
var loader = new THREE.ObjectLoader();
scene = loader.parse( data );
var hasLights = false;
var lights = ['AmbientLight', 'DirectionalLight', 'AreaLight',
'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;
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.
先完成此消息的编辑!
想要评论请 注册