提交 3e906bf6 编写于 作者: A alteredq

Fixed handling of hierarchies and custom properties for asynchronously loaded...

Fixed handling of hierarchies and custom properties for asynchronously loaded objects in SceneLoader.

Bah, this one was tricky, all sorts of shenanigans were going on. Hope this is it, I still don't fully understand how "object" variable was keeping value from other invocations of "handle_children" (instead of just being "undefined" after "var object;"), seems like closures keeping value in recursive function calls.
上级 d25bf1ed
此差异已折叠。
......@@ -17,7 +17,9 @@
"scale" : [ 1, 1, 1 ],
"visible" : true,
"properties" : {
"rotating" : true
"rotating" : true,
"rotateX" : true,
"rotateY" : true
}
},
......@@ -66,7 +68,6 @@
"visible" : true
},
"torus" : {
"geometry" : "torus",
"materials": [ "phong_orange" ],
......@@ -166,7 +167,11 @@
"position" : [ -28, -1, 29 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 12, 12, 12 ],
"visible" : true
"visible" : true,
"properties" : {
"rotating" : true,
"rotateY" : true
}
},
"ninja" : {
......
......@@ -461,8 +461,8 @@
var object = rotatingObjects[ i ];
object.rotation.x += 0.01;
object.rotation.y += 0.02;
if ( object.properties.rotateX ) object.rotation.x += 1 * delta;
if ( object.properties.rotateY ) object.rotation.y += 0.5 * delta;
}
......
......@@ -62,8 +62,8 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
var urlBase = THREE.Loader.prototype.extractUrlBase( url );
var dg, dm, dd, dl, dc, df, dt,
g, o, m, l, d, p, r, q, s, c, t, f, tt, pp, u,
var dg, dm, dl, dc, df, dt,
g, m, l, d, p, r, q, s, c, t, f, tt, pp, u,
geometry, material, camera, fog,
texture, images,
light,
......@@ -149,16 +149,16 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
function handle_children( parent, children ) {
var object;
for ( dd in children ) {
for ( var dd in children ) {
// check by id if child has already been handled,
// if not, create new object
if ( result.objects[ dd ] === undefined ) {
o = children[ dd ];
var o = children[ dd ];
var object = null;
if ( o.geometry !== undefined ) {
......@@ -320,19 +320,24 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
if ( o.properties !== undefined ) {
if ( object ) {
if ( o.properties !== undefined ) {
for ( var key in o.properties ) {
for ( var key in o.properties ) {
var value = o.properties[ key ];
object.properties[ key ] = value;
var value = o.properties[ key ];
object.properties[ key ] = value;
}
}
}
if ( o.children !== undefined ) {
if ( o.children !== undefined ) {
handle_children( object, o.children );
handle_children( object, o.children );
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册