mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
序列化场景和相机。
This commit is contained in:
parent
eae35a4aeb
commit
23d2ccd64c
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user