序列化场景和相机。

This commit is contained in:
liteng 2018-08-04 12:34:21 +08:00
parent eae35a4aeb
commit 23d2ccd64c
13 changed files with 15 additions and 13 deletions

View File

@ -25,8 +25,9 @@ BaseSerializer.prototype.filter = function (obj) {
* @param {*} obj 对象
*/
BaseSerializer.prototype.toJSON = function (obj) {
var json = {};
Object.assign(json, this.metadata);
var json = {
metadata: this.metadata
};
return json;
};

View File

@ -58,6 +58,7 @@ Converter.prototype.toJSON = function (app) {
} else {
camera = (new PerspectiveCameraSerializer()).toJSON(app.editor.camera);
}
list.push(camera);
// 脚本
Object.keys(app.editor.scripts).forEach(function (id) {

View File

@ -25,7 +25,7 @@ ConfigSerializer.prototype.filter = function (obj) {
};
ConfigSerializer.prototype.toJSON = function (app) {
var json = BaseSerializer.prototype.toJSON(app);
var json = BaseSerializer.prototype.toJSON.call(this, app);
Object.assign(json, app.editor.config.toJSON());
return json;
};

View File

@ -29,7 +29,7 @@ ScriptSerializer.prototype.toJSON = function (app) {
var list = [];
Object.keys(app.editor.scripts).forEach(id => {
var json = BaseSerializer.prototype.toJSON(app);
var json = BaseSerializer.prototype.toJSON.call(this, app);
var name = app.editor.scripts[id].name;
var source = app.editor.scripts[id].source;

View File

@ -22,7 +22,7 @@ CameraSerializer.prototype.filter = function (obj) {
};
CameraSerializer.prototype.toJSON = function (obj) {
var json = Object3DSerializer.prototype.toJSON(obj);
var json = Object3DSerializer.prototype.toJSON.call(this, obj);
json.matrixWorldInverse = obj.matrixWorldInverse;
json.projectionMatrix = obj.projectionMatrix;

View File

@ -22,7 +22,7 @@ OrthographicCameraSerializer.prototype.filter = function (obj) {
};
OrthographicCameraSerializer.prototype.toJSON = function (obj) {
var json = CameraSerializer.prototype.toJSON(obj);
var json = CameraSerializer.prototype.toJSON.call(this, obj);
json.bottom = obj.bottom;
json.far = obj.far;

View File

@ -22,7 +22,7 @@ PerspectiveCameraSerializer.prototype.filter = function (obj) {
};
PerspectiveCameraSerializer.prototype.toJSON = function (obj) {
var json = CameraSerializer.prototype.toJSON(obj);
var json = CameraSerializer.prototype.toJSON.call(this, obj);
json.aspect = obj.aspect;
json.far = obj.far;

View File

@ -21,7 +21,7 @@ Object3DSerializer.prototype.filter = function (obj) {
};
Object3DSerializer.prototype.toJSON = function (obj) {
var json = BaseSerializer.prototype.toJSON(obj);
var json = BaseSerializer.prototype.toJSON.call(this, obj);
json.type = obj.type;
json.uuid = obj.uuid;

View File

@ -12,7 +12,7 @@ HemisphereLightSerializer.prototype = Object.create(BaseSerializer.prototype);
HemisphereLightSerializer.prototype.constructor = HemisphereLightSerializer;
HemisphereLightSerializer.prototype.toJSON = function (obj) {
var json = LightSerializer.prototype.toJSON(obj);
var json = LightSerializer.prototype.toJSON.call(this, obj);
json.skyColor = item.skyColor;
json.groundColor = item.groundColor;

View File

@ -12,7 +12,7 @@ LightSerializer.prototype = Object.create(BaseSerializer.prototype);
LightSerializer.prototype.constructor = LightSerializer;
LightSerializer.prototype.toJSON = function (obj) {
var json = Object3DSerializer.prototype.toJSON(obj);
var json = Object3DSerializer.prototype.toJSON.call(this, obj);
json.color = item.color;
json.intensity = item.intensity;

View File

@ -12,7 +12,7 @@ PointLightSerializer.prototype = Object.create(BaseSerializer.prototype);
PointLightSerializer.prototype.constructor = PointLightSerializer;
PointLightSerializer.prototype.toJSON = function (obj) {
var json = LightSerializer.prototype.toJSON(obj);
var json = LightSerializer.prototype.toJSON.call(this, obj);
json.distance = item.distance;
json.decay = item.decay;

View File

@ -12,7 +12,7 @@ RectAreaLightSerializer.prototype = Object.create(BaseSerializer.prototype);
RectAreaLightSerializer.prototype.constructor = RectAreaLightSerializer;
RectAreaLightSerializer.prototype.toJSON = function (obj) {
var json = LightSerializer.prototype.toJSON(obj);
var json = LightSerializer.prototype.toJSON.call(this, obj);
json.width = item.width;
json.height = item.height;

View File

@ -12,7 +12,7 @@ SpotLightSerializer.prototype = Object.create(BaseSerializer.prototype);
SpotLightSerializer.prototype.constructor = SpotLightSerializer;
SpotLightSerializer.prototype.toJSON = function (obj) {
var json = LightSerializer.prototype.toJSON(obj);
var json = LightSerializer.prototype.toJSON.call(this, obj);
json.distance = item.distance;
json.angle = item.angle;