diff --git a/ShadowEditor.Web/src/serialization/Converter.js b/ShadowEditor.Web/src/serialization/Converter.js index 80b08df0..54b57e4e 100644 --- a/ShadowEditor.Web/src/serialization/Converter.js +++ b/ShadowEditor.Web/src/serialization/Converter.js @@ -14,9 +14,11 @@ import OrthographicCameraSerializer from './camera/OrthographicCameraSerializer' import PerspectiveCameraSerializer from './camera/PerspectiveCameraSerializer'; // light +import AmbientLightSerializer from './light/AmbientLightSerializer'; +import DirectionalLightSerializer from './light/DirectionalLightSerializer'; +import HemisphereLightSerializer from './light/HemisphereLightSerializer'; import PointLightSerializer from './light/PointLightSerializer'; import SpotLightSerializer from './light/SpotLightSerializer'; -import HemisphereLightSerializer from './light/HemisphereLightSerializer'; import RectAreaLightSerializer from './light/RectAreaLightSerializer'; /** @@ -78,19 +80,24 @@ Converter.prototype.toJSON = function (app) { break; // case 'Sprite': // break; - // case 'PointLight': - // json = (new PointLightSerializer()).toJSON(obj); - // break; - // case 'SpotLight': - // json = (new SpotLightSerializer()).toJSON(obj); - // break; - // case 'DirectionalLight': - // break; - // case 'HemisphereLight': - // json = (new HemisphereLightSerializer()).toJSON(obj); - // break; - // case 'AmbientLight': - // break; + case 'AmbientLight': + json = (new AmbientLightSerializer()).toJSON(obj); + break; + case 'DirectionalLight': + json = (new DirectionalLightSerializer()).toJSON(obj); + break; + case 'HemisphereLight': + json = (new HemisphereLightSerializer()).toJSON(obj); + break; + case 'PointLight': + json = (new PointLightSerializer()).toJSON(obj); + break; + case 'RectAreaLight': + json = (new RectAreaLightSerializer()).toJSON(obj); + break; + case 'SpotLight': + json = (new SpotLightSerializer()).toJSON(obj); + break; } if (json) { list.push(json); diff --git a/ShadowEditor.Web/src/serialization/light/AmbientLightSerializer.js b/ShadowEditor.Web/src/serialization/light/AmbientLightSerializer.js new file mode 100644 index 00000000..ce35962c --- /dev/null +++ b/ShadowEditor.Web/src/serialization/light/AmbientLightSerializer.js @@ -0,0 +1,27 @@ +import BaseSerializer from '../BaseSerializer'; +import LightSerializer from './LightSerializer'; + +/** + * AmbientLightSerializer + */ +function AmbientLightSerializer() { + BaseSerializer.call(this); +} + +AmbientLightSerializer.prototype = Object.create(BaseSerializer.prototype); +AmbientLightSerializer.prototype.constructor = AmbientLightSerializer; + +AmbientLightSerializer.prototype.toJSON = function (obj) { + var json = LightSerializer.prototype.toJSON.call(this, obj); + + json.color = obj.color; + json.intensity = obj.intensity; + + return json; +}; + +AmbientLightSerializer.prototype.fromJSON = function (json) { + +}; + +export default AmbientLightSerializer; \ No newline at end of file diff --git a/ShadowEditor.Web/src/serialization/light/DirectionalLightSerializer.js b/ShadowEditor.Web/src/serialization/light/DirectionalLightSerializer.js new file mode 100644 index 00000000..86dd7a8f --- /dev/null +++ b/ShadowEditor.Web/src/serialization/light/DirectionalLightSerializer.js @@ -0,0 +1,27 @@ +import BaseSerializer from '../BaseSerializer'; +import LightSerializer from './LightSerializer'; + +/** + * DirectionalLightSerializer + */ +function DirectionalLightSerializer() { + BaseSerializer.call(this); +} + +DirectionalLightSerializer.prototype = Object.create(BaseSerializer.prototype); +DirectionalLightSerializer.prototype.constructor = DirectionalLightSerializer; + +DirectionalLightSerializer.prototype.toJSON = function (obj) { + var json = LightSerializer.prototype.toJSON.call(this, obj); + + json.color = obj.color; + json.intensity = obj.intensity; + + return json; +}; + +DirectionalLightSerializer.prototype.fromJSON = function (json) { + +}; + +export default DirectionalLightSerializer; \ No newline at end of file diff --git a/ShadowEditor.Web/src/serialization/light/HemisphereLightSerializer.js b/ShadowEditor.Web/src/serialization/light/HemisphereLightSerializer.js index 4a0c1f80..d7368573 100644 --- a/ShadowEditor.Web/src/serialization/light/HemisphereLightSerializer.js +++ b/ShadowEditor.Web/src/serialization/light/HemisphereLightSerializer.js @@ -14,8 +14,8 @@ HemisphereLightSerializer.prototype.constructor = HemisphereLightSerializer; HemisphereLightSerializer.prototype.toJSON = function (obj) { var json = LightSerializer.prototype.toJSON.call(this, obj); - json.skyColor = item.skyColor; - json.groundColor = item.groundColor; + json.skyColor = obj.skyColor; + json.groundColor = obj.groundColor; return json; }; diff --git a/ShadowEditor.Web/src/serialization/light/LightSerializer.js b/ShadowEditor.Web/src/serialization/light/LightSerializer.js index 5e417989..568d4edd 100644 --- a/ShadowEditor.Web/src/serialization/light/LightSerializer.js +++ b/ShadowEditor.Web/src/serialization/light/LightSerializer.js @@ -14,8 +14,8 @@ LightSerializer.prototype.constructor = LightSerializer; LightSerializer.prototype.toJSON = function (obj) { var json = Object3DSerializer.prototype.toJSON.call(this, obj); - json.color = item.color; - json.intensity = item.intensity; + json.color = obj.color; + json.intensity = obj.intensity; return json; }; diff --git a/ShadowEditor.Web/src/serialization/light/PointLightSerializer.js b/ShadowEditor.Web/src/serialization/light/PointLightSerializer.js index 33a1c77d..adff7e68 100644 --- a/ShadowEditor.Web/src/serialization/light/PointLightSerializer.js +++ b/ShadowEditor.Web/src/serialization/light/PointLightSerializer.js @@ -14,8 +14,8 @@ PointLightSerializer.prototype.constructor = PointLightSerializer; PointLightSerializer.prototype.toJSON = function (obj) { var json = LightSerializer.prototype.toJSON.call(this, obj); - json.distance = item.distance; - json.decay = item.decay; + json.distance = obj.distance; + json.decay = obj.decay; return json; }; diff --git a/ShadowEditor.Web/src/serialization/light/RectAreaLightSerializer.js b/ShadowEditor.Web/src/serialization/light/RectAreaLightSerializer.js index 486b7ab5..a7550cbd 100644 --- a/ShadowEditor.Web/src/serialization/light/RectAreaLightSerializer.js +++ b/ShadowEditor.Web/src/serialization/light/RectAreaLightSerializer.js @@ -14,8 +14,8 @@ RectAreaLightSerializer.prototype.constructor = RectAreaLightSerializer; RectAreaLightSerializer.prototype.toJSON = function (obj) { var json = LightSerializer.prototype.toJSON.call(this, obj); - json.width = item.width; - json.height = item.height; + json.width = obj.width; + json.height = obj.height; return json; }; diff --git a/ShadowEditor.Web/src/serialization/light/SpotLightSerializer.js b/ShadowEditor.Web/src/serialization/light/SpotLightSerializer.js index f8c954bf..475042cf 100644 --- a/ShadowEditor.Web/src/serialization/light/SpotLightSerializer.js +++ b/ShadowEditor.Web/src/serialization/light/SpotLightSerializer.js @@ -14,10 +14,10 @@ SpotLightSerializer.prototype.constructor = SpotLightSerializer; SpotLightSerializer.prototype.toJSON = function (obj) { var json = LightSerializer.prototype.toJSON.call(this, obj); - json.distance = item.distance; - json.angle = item.angle; - json.penumbra = item.penumbra; - json.decay = item.decay; + json.distance = obj.distance; + json.angle = obj.angle; + json.penumbra = obj.penumbra; + json.decay = obj.decay; return json; };