Scene Setup

30 views
Skip to first unread message

Scott Haynes

unread,
Dec 21, 2011, 2:23:46 PM12/21/11
to SceneJS
I'm working with a model-view architecture for a webGL framework that
is renderer agnostic. I currently have scene definition specified in
a yaml file which is very similar to the JSON specification for
SceneJS. For the most part I specify nodes and then point those nodes
to collada(.dae) files. In some cases I specify the child node
hierarchy of the collada file when I need to setup properties for sub
nodes of the collada file. All of this should work fairly well with
the way SceneJS works, but there's a couple of issues that I'm not
exactly sure how to do. Or, I'm not exactly what the best way to
accomplish my tasks is probably a better way of putting it, and I
thought I'd see if anyone had any suggestions before I start hacking
away. ;) ( I've included a sample of the yaml below)

Here are some of the things that I have questions about:
1. Creating an empty scene. I'm assuming I should define a empty
scene in JSON as a string and pass that into the SceneJS.createScene?
2. Creating group nodes that aren't specified in any collada file.
I'll know the parent that this new node should be attached to, so I'll
need the ability to attach a new 'node' to any other node.
3. Do the nodes currently have names? Are the names unique? I
generally load a collada file and then recursively traverse the scene
graph and create my yaml to define the sub nodes of the file.
4. Is the collada loading(JSON evaling) done on a separate thread or
is it done on the stack?

---
extends: http://vwf.example.com/types/appscene
properties:
ambientColor: [ 183, 183, 183 ]
backgroundColor: [ 255, 255, 255 ]
activeCamera: "http-vwf-example-com-types-camera-maincamera"
loadDone: false
scripts:
- text:
this.initialize = function() {
console.info( "================ duck and plane
================" );
&nb sp; this.activeCamera = "http-vwf-example-com-types-camera-
maincamera";
this.loadDone = true;
}
type: application/javascript
children:
seymourplane_triangulate.dae:
extends: http://vwf.example.com/types/node3
source: seymourplane_triangulate.dae
type: model/vnd.collada+xml
properties:
angle: 0
scale: [ 1, 1, 1 ]
position: [ -1, 0, 3 ]
rotation: [ 1.57, 1.57, 0 ]

children:
bone1:
extends: http://vwf.example.com/types/node3
scripts:
- |
this.pointerClick = function() {
this.parent.prop.playing = !this.parent.prop.playing;
}
prop:
extends: http://vwf.example.co m/types/node3
properties:
playing: true
looping: true
maincamera:
extends: http://vwf.example.com/types/camera
properties:
walkMode: "walk"
cameraType: "perspective"
orbitPoint: [ 0, 0, 0 ]
position: [ 1, 20, 8 ]
eulers: [ 90, 180, 0 ]
< p class=MsoNormal> rotation: [ 1.56, 3.14, 0 ]
far: 1000.0
near: 0.1
fovy: 35
aspect: 1.0
orthoscale: 5
speed: 2.0
wallobject:
extends: "http://vwf.example.com/types/node3"
source: "cube"
type: "text/xml"
properties:
scale: [ 10, 10, 10 ]
material: "wallmaterial"

duck.dae:
extends: http://vwf.example.com/types/node3
source: duck.dae
type: model/vnd.collada+xml
properties:
spinning:
set: |
if ( value && !this.spinning ) {
this.future( 0.1 ).spin();
}
&nb sp; this.spinning = value;
value: false
scale: [ 0.05, 0.05, 0.05 ]
position: [ 0, -15, 0 ]
rotation: [ 1.57, 0, 0 ]
eulers: [ 90, 0, 0 ]
scripts:
- text: |
this.pointerClick = function() {
this.spinning = !this.spinning;
}
type: application/javascript
methods:

spin: |
var e = this.eulers;
e[1] += 2;
this.eulers = e;
if ( this.spinning ) {
this.future( 0.1 ).spin();
}
dir_duck_1:
extends: http://vwf.example.com/types/light
properties:
lightType: "directional"
& nbsp; constantAttenuation: 1
rotation: [ -0.79, -3.34, -0.22 ]
dir_plane_1:
extends: http://vwf.example.com/types/light
properties:
lightType: "directional"
constantAttenuation: 1
rotation: [ 0.279, 0.9539, -0.08268 ]

Scott Haynes

unread,
Jan 9, 2012, 2:46:16 PM1/9/12
to SceneJS
I've gotten to a point where I'm creating the scene and loading
collada files separately. I guess the biggest issue that I'm seeing
from the standpoint of the scene hierarchy are the lookAt, translate
and rotate nodes. The implementation in SceneJS is different enough
from the other renderers that I've support that I'm kind of stuck
trying to figure out how to get the scene correctly loaded. I'll want
to expose a position, and rotation property on a majority of the nodes
in the hierarchy. I'm going to need to insert the translate and
rotate nodes into the scene hierarchy for all of the nodes that I want
to expose the position and rotation properties. For instance, if I
want the propeller of the seymour plane to spin, then I would need to
find that node in the plane hierarchy and insert a rotate node as a
parent to the propeller node, right? Is there another way to access
the models/meshes transform with the use of the translate and rotate
nodes?

Thanks,
Scott
Reply all
Reply to author
Forward
0 new messages