Skip to content

Commit

Permalink
Fixed some remaining issues with exporting to SceneJS 2.0 and ensured…
Browse files Browse the repository at this point in the history
… that the renderer node is added to the camera correctly (as a single element list, not an object which was causing a bug)
  • Loading branch information
rehno-lindeque committed Aug 14, 2011
1 parent 65b0d68 commit aeb05c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
23 changes: 22 additions & 1 deletion stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,31 @@ def _pretty_print(self, node, indent):
indent
The indentation level
"""
# TODO: This function should also order the keys in a logical way...
# First output 'type', 'id' and 'coreId'
specialKeys = ['type', 'id', 'coreId', 'nodes']
specialValues = { 'type': None, 'id': None, 'coreId': None, 'nodes': None }
otherValues = []

for k,v in node.items():
if k in specialKeys:
specialValues[k] = v
else:
otherValues.append((k,v))

for k in specialKeys[:-1]:
if specialValues[k]:
yield " " * indent + k + ": " + self._pretty_print_value(specialValues[k], indent) + "\n"

# Output all other keys
for k,v in node.items():
if k in specialKeys:
continue
output = " " * indent + k + (":\n" if isinstance(v,dict) else ": ")
yield output + self._pretty_print_value(v, indent) + "\n"

# Output the 'nodes' key last
if specialValues['nodes']:
yield " " * indent + "nodes: " + self._pretty_print_value(specialValues['nodes'], indent) + "\n"

def write(self, node):
"""Create a Javascript output stream, where nodes are automatically created via SceneJS.createScene
Expand Down
16 changes: 2 additions & 14 deletions translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def translate_scene(scene):

#jscamera['nodes'][0]['nodes'] = _translate_scene_nodes(scene.nodes)
jsrenderer['nodes'] = _translate_scene_nodes(scene.nodes)
jscamera['nodes'][0]['nodes'] = jsrenderer
jscamera['nodes'][0]['nodes'] = [jsrenderer]

return {
'type': 'scene',
Expand All @@ -572,18 +572,6 @@ def translate_scene(scene):
'flags': {
'backfaces': False
},
'nodes': [
# {
# 'type': 'renderer',
# 'clear': {
# 'depth': True,
# 'color': True,
# 'stencil': False
# },
# 'clearColor': { 'r': 0.4, 'g': 0.4, 'b': 0.4 },
# 'nodes': [ jscamera ]
# }]
jscamera
]
'nodes': [jscamera]
}

0 comments on commit aeb05c1

Please sign in to comment.