提交 4b7da0fd 编写于 作者: M Mr.doob

Merge pull request #6753 from qwertzui11/dev

implemented serialization for THREE.LOD
......@@ -556,6 +556,12 @@ THREE.ObjectLoader.prototype = {
break;
case 'LOD':
object = new THREE.LOD();
break;
case 'Line':
object = new THREE.Line( getGeometry( data.geometry ), getMaterial( data.material ), data.mode );
......@@ -618,6 +624,31 @@ THREE.ObjectLoader.prototype = {
}
if ( data.type === 'LOD' ) {
for ( var l = 0; l < data.levels.length; l ++ ) {
var level = data.levels[l];
for ( var c = 0; c < object.children.length; c ++ ) {
var child = object.children[c];
if ( child.uuid === level.object ) {
object.levels.push({
distance: level.distance,
object: child
});
}
}
}
}
return object;
}
......
......@@ -8,6 +8,8 @@ THREE.LOD = function () {
THREE.Object3D.call( this );
this.type = 'LOD';
Object.defineProperties( this, {
levels: {
enumerable: true,
......@@ -149,3 +151,26 @@ THREE.LOD.prototype.copy = function ( source ) {
return this;
};
THREE.LOD.prototype.toJSON = function ( meta ) {
var data = THREE.Object3D.prototype.toJSON.call( this, meta );
data.object.levels = [];
var levels = this.levels;
for ( var i = 0, l = levels.length; i < l; i ++ ) {
var level = levels[ i ];
data.object.levels.push({
distance: level.distance,
object: level.object.uuid
});
}
return data;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册