diff --git a/ShadowEditor.Web/src/component/SmokeComponent.js b/ShadowEditor.Web/src/component/SmokeComponent.js index 79dde380..92761537 100644 --- a/ShadowEditor.Web/src/component/SmokeComponent.js +++ b/ShadowEditor.Web/src/component/SmokeComponent.js @@ -34,6 +34,44 @@ SmokeComponent.prototype.render = function () { fontWeight: 'bold' }, text: L_SMOKE_COMPONENT + }, + // { + // xtype: 'row', + // children: [{ + // xtype: 'label', + // text: '数量' + // }, { + // xtype: 'int', + // id: 'particleCount', + // scope: this.id, + // range: [0, Infinity], + // onChange: this.onChange.bind(this) + // }] + // }, + { + xtype: 'row', + children: [{ + xtype: 'label', + text: '尺寸' + }, { + xtype: 'int', + id: 'size', + scope: this.id, + range: [0, Infinity], + onChange: this.onChange.bind(this) + }] + }, { + xtype: 'row', + children: [{ + xtype: 'label', + text: '时长' + }, { + xtype: 'int', + id: 'lifetime', + scope: this.id, + range: [0, Infinity], + onChange: this.onChange.bind(this) + }] }, { xtype: 'row', children: [{ @@ -75,8 +113,15 @@ SmokeComponent.prototype.updateUI = function () { this.selected = editor.selected; + // var particleCount = UI.get('particleCount', this.id); + var size = UI.get('size', this.id); + var lifetime = UI.get('lifetime', this.id); var btnPreview = UI.get('btnPreview', this.id); + // particleCount.setValue(this.selected.userData.particleCount); + size.setValue(this.selected.userData.size); + lifetime.setValue(this.selected.userData.lifetime); + if (this.isPlaying) { btnPreview.setText(L_CANCEL); } else { @@ -84,6 +129,19 @@ SmokeComponent.prototype.updateUI = function () { } }; +SmokeComponent.prototype.onChange = function () { + // var particleCount = UI.get('particleCount', this.id); + var size = UI.get('size', this.id); + var lifetime = UI.get('lifetime', this.id); + + // this.selected.userData.particleCount = particleCount.getValue(); + this.selected.userData.size = size.getValue(); + this.selected.userData.lifetime = lifetime.getValue(); + + this.selected.material.uniforms.size.value = size.getValue(); + this.selected.material.uniforms.lifetime.value = lifetime.getValue(); +}; + SmokeComponent.prototype.onPreview = function () { if (this.isPlaying) { this.stopPreview(); diff --git a/ShadowEditor.Web/src/serialization/objects/SmokeSerializer.js b/ShadowEditor.Web/src/serialization/objects/SmokeSerializer.js index f8f49f51..cc8216f4 100644 --- a/ShadowEditor.Web/src/serialization/objects/SmokeSerializer.js +++ b/ShadowEditor.Web/src/serialization/objects/SmokeSerializer.js @@ -20,7 +20,7 @@ SmokeSerializer.prototype.toJSON = function (obj) { }; SmokeSerializer.prototype.fromJSON = function (json, parent, camera, renderer) { - var obj = parent || new Smoke(camera, renderer); + var obj = parent || new Smoke(camera, renderer, json.userData); MeshSerializer.prototype.fromJSON.call(this, json, obj);