diff --git a/cocos/3d/framework/particle/animator/color-overtime.js b/cocos/3d/framework/particle/animator/color-overtime.js index aba6e5a437..0076e83137 100644 --- a/cocos/3d/framework/particle/animator/color-overtime.js +++ b/cocos/3d/framework/particle/animator/color-overtime.js @@ -1,13 +1,20 @@ import { color4, pseudoRandom } from '../../../../core/vmath'; import { CCClass } from '../../../../core/data'; +import GradientRange from './gradient-range'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const COLOR_OVERTIME_RAND_OFFSET = 91041; +@ccclass('cc.ColorOvertimeModule') export default class ColorOvertimeModule { + @property enable = false; - color = null; + @property({ + type: GradientRange + }) + color = new GradientRange(); animate(particle) { if (this.enable) { @@ -16,7 +23,7 @@ export default class ColorOvertimeModule { } } -CCClass.fastDefine('cc.ColorOvertimeModule', ColorOvertimeModule, { - enable: false, - color: null -}); +// CCClass.fastDefine('cc.ColorOvertimeModule', ColorOvertimeModule, { +// enable: false, +// color: null +// }); diff --git a/cocos/3d/framework/particle/animator/curve-range.js b/cocos/3d/framework/particle/animator/curve-range.js index 4c51d6b9cc..3320823e81 100644 --- a/cocos/3d/framework/particle/animator/curve-range.js +++ b/cocos/3d/framework/particle/animator/curve-range.js @@ -2,6 +2,7 @@ import { lerp } from '../../../../core/vmath'; import { Enum } from '../../../../core/value-types'; import { AnimationCurve } from '../../../geom-utils'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const Mode = Enum({ Constant: 0, @@ -10,22 +11,37 @@ const Mode = Enum({ TwoConstants: 3 }); +@ccclass('cc.CurveRange') export default class CurveRange { + @property mode = Mode.Constant; - curve = null; + @property({ + type: AnimationCurve + }) + curve = new AnimationCurve(); - curveMin = null; + @property({ + type: AnimationCurve + }) + curveMin = new AnimationCurve(); - curveMax = null; + @property({ + type: AnimationCurve + }) + curveMax = new AnimationCurve(); + @property constant = 0; + @property constantMin = 0; + @property constantMax = 0; + @property multiplier = 1; constructor() { @@ -46,13 +62,13 @@ export default class CurveRange { } } -CCClass.fastDefine('cc.CurveRange', CurveRange, { - mode: Mode.Constant, - constant: 0, - constantMin: 0, - constantMax: 0, - curve: new AnimationCurve(), - curveMin: new AnimationCurve(), - curveMax: new AnimationCurve(), - multiplier: 1 -}); +// CCClass.fastDefine('cc.CurveRange', CurveRange, { +// mode: Mode.Constant, +// constant: 0, +// constantMin: 0, +// constantMax: 0, +// curve: new AnimationCurve(), +// curveMin: new AnimationCurve(), +// curveMax: new AnimationCurve(), +// multiplier: 1 +// }); diff --git a/cocos/3d/framework/particle/animator/force-overtime.js b/cocos/3d/framework/particle/animator/force-overtime.js index 1d33ce76b3..cd5cac5587 100644 --- a/cocos/3d/framework/particle/animator/force-overtime.js +++ b/cocos/3d/framework/particle/animator/force-overtime.js @@ -2,19 +2,32 @@ import { vec3, quat, pseudoRandom } from '../../../../core/vmath'; import { calculateTransform, Space } from '../particle-general-function'; import CurveRange from './curve-range'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const FORCE_OVERTIME_RAND_OFFSET = 212165; +@ccclass('cc.ForceOvertimeModule') export default class ForceOvertimeModule { + @property enable = false; - x = null; + @property({ + type: CurveRange + }) + x = new CurveRange(); - y = null; + @property({ + type: CurveRange + }) + y = new CurveRange(); - z = null; + @property({ + type: CurveRange + }) + z = new CurveRange(); + @property space = Space.Local; // TODO:currently not supported @@ -38,11 +51,11 @@ export default class ForceOvertimeModule { } } -CCClass.fastDefine('cc.ForceOvertimeModule',ForceOvertimeModule,{ - enable : false, - x : new CurveRange(), - y : new CurveRange(), - z : new CurveRange(), - space : Space.Local, - randomized : false -}); +// CCClass.fastDefine('cc.ForceOvertimeModule',ForceOvertimeModule,{ +// enable : false, +// x : new CurveRange(), +// y : new CurveRange(), +// z : new CurveRange(), +// space : Space.Local, +// randomized : false +// }); diff --git a/cocos/3d/framework/particle/animator/gradient-range.js b/cocos/3d/framework/particle/animator/gradient-range.js index 2e9343ef94..65fb3906a8 100644 --- a/cocos/3d/framework/particle/animator/gradient-range.js +++ b/cocos/3d/framework/particle/animator/gradient-range.js @@ -2,6 +2,7 @@ import { color4 } from '../../../../core/vmath'; import { Enum } from '../../../../core/value-types'; import Gradient from './gradient'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const GRADIENT_MODE_FIX = 0; const GRADIENT_MODE_BLEND = 1; @@ -20,21 +21,35 @@ const Mode = Enum({ RandomColor: 4 }); +@ccclass('cc.GradientRange') export default class GradientRange { + @property mode = Mode.Color; + @property color = cc.Color.WHITE; + @property colorMin = cc.Color.WHITE; + @property colorMax = cc.Color.WHITE; + @property({ + type: Gradient + }) gradient = new Gradient(); - gradientMin = null; + @property({ + type: Gradient + }) + gradientMin = new Gradient(); - gradientMax = null; + @property({ + type: Gradient + }) + gradientMax = new Gradient(); evaluate(time, rndRatio) { switch (this.mode) { @@ -56,15 +71,15 @@ export default class GradientRange { } } -CCClass.fastDefine('cc.GradientRange', GradientRange, { - mode: Mode.Color, - color: cc.Color.WHITE, - colorMin: cc.Color.WHITE, - colorMax: cc.Color.WHITE, - gradient: new Gradient(), - gradientMin: null, - gradientMax: null -}); +// CCClass.fastDefine('cc.GradientRange', GradientRange, { +// mode: Mode.Color, +// color: cc.Color.WHITE, +// colorMin: cc.Color.WHITE, +// colorMax: cc.Color.WHITE, +// gradient: new Gradient(), +// gradientMin: null, +// gradientMax: null +// }); export class GradientUniform { constructor(gr) { diff --git a/cocos/3d/framework/particle/animator/gradient.js b/cocos/3d/framework/particle/animator/gradient.js index 20d5f6f2cf..2061b768d2 100644 --- a/cocos/3d/framework/particle/animator/gradient.js +++ b/cocos/3d/framework/particle/animator/gradient.js @@ -1,46 +1,56 @@ import { repeat } from '../../../../core/vmath'; import { Enum, ValueType } from '../../../../core/value-types'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const Mode = Enum({ Blend: 0, Fixed: 1 }); +@ccclass('cc.ColorKey') export class ColorKey { + @property color = cc.Color.WHITE; + @property time = 0; } -CCClass.fastDefine('cc.ColorKey', ColorKey, { - color: cc.Color.WHITE, - time: 0 -}); +// CCClass.fastDefine('cc.ColorKey', ColorKey, { +// color: cc.Color.WHITE, +// time: 0 +// }); +@ccclass('cc.AlphaKey') export class AlphaKey { + @property alpha = 1; + @property time = 0; } -CCClass.fastDefine('cc.AlphaKey', AlphaKey, { - alpha: 1, - time: 0 -}); +// CCClass.fastDefine('cc.AlphaKey', AlphaKey, { +// alpha: 1, +// time: 0 +// }); -export default class Gradient extends ValueType { +@ccclass('cc.Gradient') +export default class Gradient { + @property colorKeys = []; + @property alphaKeys = [] + @property mode = Mode.Blend; constructor() { - super(); this._color = cc.Color.WHITE; } @@ -125,8 +135,8 @@ export default class Gradient extends ValueType { } } -CCClass.fastDefine('cc.Gradient', Gradient, { - mode: Mode.Blend, - colorKeys: [], - alphaKeys: [] -}); +// CCClass.fastDefine('cc.Gradient', Gradient, { +// mode: Mode.Blend, +// colorKeys: [], +// alphaKeys: [] +// }); diff --git a/cocos/3d/framework/particle/animator/limit-velocity-overtime.js b/cocos/3d/framework/particle/animator/limit-velocity-overtime.js index fd4919aac7..f7307cd5e5 100644 --- a/cocos/3d/framework/particle/animator/limit-velocity-overtime.js +++ b/cocos/3d/framework/particle/animator/limit-velocity-overtime.js @@ -1,25 +1,43 @@ import { vec3, lerp, pseudoRandom } from '../../../../core/vmath'; import { CCClass } from '../../../../core/data'; import { Space } from '../particle-general-function'; +import { property, ccclass } from '../../../../core/data/class-decorator'; +import CurveRange from './curve-range'; const LIMIT_VELOCITY_RAND_OFFSET = 23541; +@ccclass('cc.LimitVelocityOvertimeModule') export default class LimitVelocityOvertimeModule { enable = false; - limitX = null; + @property({ + type: CurveRange + }) + limitX = new CurveRange(); - limitY = null; + @property({ + type: CurveRange + }) + limitY = new CurveRange(); - limitZ = null; + @property({ + type: CurveRange + }) + limitZ = new CurveRange(); - limit = null; + @property({ + type: CurveRange + }) + limit = new CurveRange(); - dampen = null; + @property + dampen = 0; + @property separateAxes = false; + @property space = Space.Local; // TODO:functions related to drag are temporarily not supported @@ -59,17 +77,17 @@ function dampenBeyondLimit(vel, limit, dampen) { return abs * sgn; } -CCClass.fastDefine('cc.LimitVelocityOvertimeModule',LimitVelocityOvertimeModule,{ - enable : false, - limitX : null, - limitY : null, - limitZ : null, - limit : null, - dampen : null, - separateAxes : false, - space : Space.Local, - // TODO:functions related to drag are temporarily not supported - drag : null, - multiplyDragByParticleSize : false, - multiplyDragByParticleVelocity : false -}); +// CCClass.fastDefine('cc.LimitVelocityOvertimeModule', LimitVelocityOvertimeModule, { +// enable: false, +// limitX: null, +// limitY: null, +// limitZ: null, +// limit: null, +// dampen: null, +// separateAxes: false, +// space: Space.Local, +// // TODO:functions related to drag are temporarily not supported +// drag: null, +// multiplyDragByParticleSize: false, +// multiplyDragByParticleVelocity: false +// }); diff --git a/cocos/3d/framework/particle/animator/rotation-overtime.js b/cocos/3d/framework/particle/animator/rotation-overtime.js index f9608a2dbd..d015e9ceb5 100644 --- a/cocos/3d/framework/particle/animator/rotation-overtime.js +++ b/cocos/3d/framework/particle/animator/rotation-overtime.js @@ -1,13 +1,17 @@ import { pseudoRandom } from "../../../../core/vmath"; import { CCClass } from "../../../../core/data"; import CurveRange from "./curve-range"; +import { property, ccclass } from "../../../../core/data/class-decorator"; const ROTATION_OVERTIME_RAND_OFFSET = 125292; +@ccclass('cc.RotationOvertimeModule') export default class RotationOvertimeModule { + @property enable = false; + @property _separateAxes = false; get separateAxes() { @@ -23,11 +27,20 @@ export default class RotationOvertimeModule { } } - x = null; + @property({ + type: CurveRange + }) + x = new CurveRange(); - y = null; + @property({ + type: CurveRange + }) + y = new CurveRange(); - z = null; + @property({ + type: CurveRange + }) + z = new CurveRange(); constructor() { @@ -44,10 +57,10 @@ export default class RotationOvertimeModule { } } -CCClass.fastDefine('cc.RotationOvertimeModule',RotationOvertimeModule,{ - enable : false, - _separateAxes : false, - x : new CurveRange(), - y : new CurveRange(), - z : new CurveRange() -}); +// CCClass.fastDefine('cc.RotationOvertimeModule', RotationOvertimeModule, { +// enable: false, +// _separateAxes: false, +// x: new CurveRange(), +// y: new CurveRange(), +// z: new CurveRange() +// }); diff --git a/cocos/3d/framework/particle/animator/size-overtime.js b/cocos/3d/framework/particle/animator/size-overtime.js index f8498988d9..63f77d09aa 100644 --- a/cocos/3d/framework/particle/animator/size-overtime.js +++ b/cocos/3d/framework/particle/animator/size-overtime.js @@ -1,22 +1,38 @@ import { vec3, pseudoRandom } from '../../../../core/vmath'; import CurveRange from './curve-range'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const SIZE_OVERTIME_RAND_OFFSET = 39825; +@ccclass('cc.SizeOvertimeModule') export default class SizeOvertimeModule { + @property enable = false; + @property separateAxes = false; - size = null; + @property({ + type: CurveRange + }) + size = new CurveRange(); - x = null; + @property({ + type: CurveRange + }) + x = new CurveRange(); - y = null; + @property({ + type: CurveRange + }) + y = new CurveRange(); - z = null; + @property({ + type: CurveRange + }) + z = new CurveRange(); animate(particle) { if (!this.separateAxes) { @@ -25,11 +41,11 @@ export default class SizeOvertimeModule { } } -CCClass.fastDefine('cc.SizeOvertimeModule', SizeOvertimeModule, { - enable: false, - separateAxes: false, - size: new CurveRange(), - x: new CurveRange(), - y: new CurveRange(), - z: new CurveRange() -}); +// CCClass.fastDefine('cc.SizeOvertimeModule', SizeOvertimeModule, { +// enable: false, +// separateAxes: false, +// size: new CurveRange(), +// x: new CurveRange(), +// y: new CurveRange(), +// z: new CurveRange() +// }); diff --git a/cocos/3d/framework/particle/animator/texture-animation.js b/cocos/3d/framework/particle/animator/texture-animation.js index 65ab0b0fd2..6c04f88d3b 100644 --- a/cocos/3d/framework/particle/animator/texture-animation.js +++ b/cocos/3d/framework/particle/animator/texture-animation.js @@ -2,6 +2,7 @@ import { repeat, lerp, pseudoRandom } from "../../../../core/vmath"; import { Enum } from "../../../../core/value-types"; import CurveRange from "./curve-range"; import { CCClass } from "../../../../core/data"; +import { property, ccclass } from "../../../../core/data/class-decorator"; const TEXTURE_ANIMATION_RAND_OFFSET = 90794; @@ -15,8 +16,10 @@ const Animation = Enum({ SingleRow: 1 }); +@ccclass('cc.TextureAnimationModule') export default class TextureAnimationModule { + @property _enable = false; get enable() { @@ -28,6 +31,7 @@ export default class TextureAnimationModule { this.ps.renderer._updateMaterialParams(); } + @property _mode = Mode.Grid get mode() { @@ -41,18 +45,29 @@ export default class TextureAnimationModule { } } + @property numTilesX = 0; + @property numTilesY = 0; + @property animation = Animation.WholeSheet; - frameOverTime = null; + @property({ + type: CurveRange + }) + frameOverTime = new CurveRange(); - startFrame = null; + @property({ + type: CurveRange + }) + startFrame = new CurveRange(); + @property cycleCount = 0; + @property _flipU = 0; get flipU() { @@ -63,6 +78,7 @@ export default class TextureAnimationModule { console.error("particle texture animation's flipU is not supported!"); } + @property _flipV = 0; get flipV() { @@ -73,6 +89,7 @@ export default class TextureAnimationModule { console.error("particle texture animation's flipV is not supported!"); } + @property _uvChannelMask = -1 get uvChannelMask() { @@ -83,8 +100,10 @@ export default class TextureAnimationModule { console.error("particle texture animation's uvChannelMask is not supported!"); } + @property randomRow = false; + @property rowIndex = 0; onInit(ps) { @@ -115,18 +134,18 @@ export default class TextureAnimationModule { } } -CCClass.fastDefine('cc.TextureAnimationModule', TextureAnimationModule, { - _enable: false, - _mode: Mode.Grid, - numTilesX: 0, - numTilesY: 0, - animation: Animation.WholeSheet, - frameOverTime: new CurveRange(), - startFrame: new CurveRange(), - cycleCount: 0, - _flipU: 0, - _flipV: 0, - _uvChannelMask: -1, - randomRow: false, - rowIndex: 0 -}); +// CCClass.fastDefine('cc.TextureAnimationModule', TextureAnimationModule, { +// _enable: false, +// _mode: Mode.Grid, +// numTilesX: 0, +// numTilesY: 0, +// animation: Animation.WholeSheet, +// frameOverTime: new CurveRange(), +// startFrame: new CurveRange(), +// cycleCount: 0, +// _flipU: 0, +// _flipV: 0, +// _uvChannelMask: -1, +// randomRow: false, +// rowIndex: 0 +// }); diff --git a/cocos/3d/framework/particle/animator/velocity-overtime.js b/cocos/3d/framework/particle/animator/velocity-overtime.js index 1153f83e07..465aaecb84 100644 --- a/cocos/3d/framework/particle/animator/velocity-overtime.js +++ b/cocos/3d/framework/particle/animator/velocity-overtime.js @@ -2,21 +2,37 @@ import { vec3, quat, pseudoRandom } from '../../../../core/vmath'; import { calculateTransform, Space } from '../particle-general-function'; import CurveRange from './curve-range'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; const VELOCITY_OVERTIME_RAND_OFFSET = 197866; +@ccclass('cc.VelocityOvertimeModule') export default class VelocityOvertimeModule { + @property enable = false; - x = null; + @property({ + type: CurveRange + }) + x = new CurveRange(); - y = null; + @property({ + type: CurveRange + }) + y = new CurveRange(); - z = null; + @property({ + type: CurveRange + }) + z = new CurveRange(); - speedModifier = null; + @property({ + type: CurveRange + }) + speedModifier = new CurveRange(); + @property space = Space.Local; constructor() { @@ -40,11 +56,11 @@ export default class VelocityOvertimeModule { } -CCClass.fastDefine('cc.VelocityOvertimeModule', VelocityOvertimeModule, { - enable: false, - x: new CurveRange(), - y: new CurveRange(), - z: new CurveRange(), - speedModifier: new CurveRange(), - space: Space.Local -}); +// CCClass.fastDefine('cc.VelocityOvertimeModule', VelocityOvertimeModule, { +// enable: false, +// x: new CurveRange(), +// y: new CurveRange(), +// z: new CurveRange(), +// speedModifier: new CurveRange(), +// space: Space.Local +// }); diff --git a/cocos/3d/framework/particle/burst.js b/cocos/3d/framework/particle/burst.js index 634447ffc2..fb2e01570d 100644 --- a/cocos/3d/framework/particle/burst.js +++ b/cocos/3d/framework/particle/burst.js @@ -1,10 +1,12 @@ import { repeat } from "../../../core/vmath"; import CurveRange from "./animator/curve-range"; import { CCClass } from "../../../core/data"; +import { property, ccclass } from "../../../core/data/class-decorator"; - +@ccclass('cc.Burst') export default class Burst { + @property _time = 0; get time() { @@ -16,10 +18,13 @@ export default class Burst { this._curTime = val; } + @property minCount = 30; + @property maxCount = 30; + @property _repeatCount = 1; get repeatCount() { @@ -31,8 +36,12 @@ export default class Burst { this._remainingCount = val; } + @property repeatInterval = 1; + @property({ + type: CurveRange + }) count = null; constructor() { @@ -58,11 +67,11 @@ export default class Burst { } } -CCClass.fastDefine('cc.Burst', Burst, { - _time: 0, - minCount: 30, - maxCount: 30, - _repeatCount: 1, - repeatInterval: 1, - count: new CurveRange -}); +// CCClass.fastDefine('cc.Burst', Burst, { +// _time: 0, +// minCount: 30, +// maxCount: 30, +// _repeatCount: 1, +// repeatInterval: 1, +// count: new CurveRange +// }); diff --git a/cocos/3d/framework/particle/emitter/shape-module.js b/cocos/3d/framework/particle/emitter/shape-module.js index f8c6c9769c..2b7877a368 100644 --- a/cocos/3d/framework/particle/emitter/shape-module.js +++ b/cocos/3d/framework/particle/emitter/shape-module.js @@ -3,6 +3,7 @@ import { vec3, vec2, random, randomRange, mat4, quat, clamp, repeat, pingPong } import { Enum, Vec3 } from '../../../../core/value-types'; import CurveRange from '../animator/curve-range'; import { CCClass } from '../../../../core/data'; +import { property, ccclass } from '../../../../core/data/class-decorator'; let _intermediVec = vec3.create(0, 0, 0); let _intermediArr = new Array(); @@ -29,14 +30,19 @@ const ArcMode = Enum({ PingPong: 2 }); +@ccclass('cc.ShapeModule') export default class ShapeModule { + @property enable = false; + @property shapeType = ShapeType.Box; + @property emitFrom = EmitLocation.Base; + @property _position = new Vec3(0, 0, 0); get position() { @@ -47,7 +53,7 @@ export default class ShapeModule { this.constructMat(); } - + @property _rotation = new Vec3(0, 0, 0); get rotation() { @@ -58,7 +64,7 @@ export default class ShapeModule { this.constructMat(); } - + @property _scale = new Vec3(0, 0, 0); get scale() { @@ -69,30 +75,45 @@ export default class ShapeModule { this.constructMat(); } + @property alignToDirection = false; + @property randomDirectionAmount = 0; + @property sphericalDirectionAmount = 0; + @property randomPositionAmount = 0; + @property radius = 0; + @property radiusThickness = 1; + @property arc = 0; + @property arcMode = ArcMode.Random; + @property arcSpread = 0; + @property({ + type: CurveRange + }) arcSpeed = new CurveRange(); + @property angle = 0; + @property length = 0; + @property boxThickness = new Vec3(0, 0, 0); constructor() { @@ -284,24 +305,24 @@ function applyBoxThickness(pos, thickness) { } } -CCClass.fastDefine('cc.ShapeModule', ShapeModule, { - enable: false, - shapeType: ShapeType.Box, - emitFrom: EmitLocation.Base, - _position: new Vec3(0, 0, 0), - _rotation: new Vec3(0, 0, 0), - _scale: new Vec3(0, 0, 0), - alignToDirection: false, - randomDirectionAmount: 0, - sphericalDirectionAmount: 0, - randomPositionAmount: 0, - radius: 0, - radiusThickness: 1, - arc: 0, - arcMode: ArcMode.Random, - arcSpread: 0, - arcSpeed: null, - angle: 0, - length: 0, - boxThickness: new Vec3(0, 0, 0) -}); +// CCClass.fastDefine('cc.ShapeModule', ShapeModule, { +// enable: false, +// shapeType: ShapeType.Box, +// emitFrom: EmitLocation.Base, +// _position: new Vec3(0, 0, 0), +// _rotation: new Vec3(0, 0, 0), +// _scale: new Vec3(0, 0, 0), +// alignToDirection: false, +// randomDirectionAmount: 0, +// sphericalDirectionAmount: 0, +// randomPositionAmount: 0, +// radius: 0, +// radiusThickness: 1, +// arc: 0, +// arcMode: ArcMode.Random, +// arcSpread: 0, +// arcSpeed: null, +// angle: 0, +// length: 0, +// boxThickness: new Vec3(0, 0, 0) +// }); diff --git a/cocos/3d/framework/particle/particle-system-component.js b/cocos/3d/framework/particle/particle-system-component.js index e0cf121e42..91e3799e19 100644 --- a/cocos/3d/framework/particle/particle-system-component.js +++ b/cocos/3d/framework/particle/particle-system-component.js @@ -2,8 +2,6 @@ import Component from '../../../components/CCComponent'; import { vec3, vec2, mat4, quat, randomRangeInt, pseudoRandom } from '../../../core/vmath'; -import registry from '../../misc/registry'; -import Gradient, { ColorKey, AlphaKey } from './animator/gradient'; import CurveRange from './animator/curve-range'; import GradientRange from './animator/gradient-range'; import ParticleSystemRenderer from './renderer/particle-system-renderer'; @@ -18,29 +16,12 @@ import ShapeModule from './emitter/shape-module'; import Burst from './burst'; import { particleEmitZAxis, Space } from './particle-general-function'; import { INT_MAX } from '../../../core/vmath/bits'; -import ParticleSystemGpuRenderer from './renderer/particle-system-gpu-renderer'; -import { ccclass, executionOrder, executeInEditMode, property, requireComponent } from '../../../core/data/class-decorator'; - -registry.registerClass('Burst', Burst); -registry.registerClass('ColorKey', ColorKey); -registry.registerClass('AlphaKey', AlphaKey); -registry.registerClass('Gradient', Gradient); -registry.registerClass('GradientRange', GradientRange); -registry.registerClass('CurveRange', CurveRange); -registry.registerClass('SizeOvertimeModule', SizeOvertimeModule); -registry.registerClass('ColorOverLifetimeModule', ColorOverLifetimeModule); -registry.registerClass('ParticleSystemRenderer', ParticleSystemRenderer); -registry.registerClass('ParticleSystemGpuRenderer', ParticleSystemGpuRenderer); -registry.registerClass('VelocityOvertimeModule', VelocityOvertimeModule); -registry.registerClass('ForceOvertimeModule', ForceOvertimeModule); -registry.registerClass('LimitVelocityOvertimeModule', LimitVelocityOvertimeModule); -registry.registerClass('RotationOvertimeModule', RotationOvertimeModule); -registry.registerClass('TextureAnimationModule', TextureAnimationModule); -registry.registerClass('ShapeModule', ShapeModule); +import { ccclass, executionOrder, executeInEditMode, property, requireComponent, menu } from '../../../core/data/class-decorator'; let _world_mat = mat4.create(); @ccclass('cc.ParticleSystemComponent') +@menu('Components/ParticleSystemComponent') @requireComponent(ParticleSystemRenderer) @executionOrder(99) @executeInEditMode @@ -49,33 +30,35 @@ export default class ParticleSystemComponent extends Component { @property capacity = 2000; - @property - startColor = null; + @property({ + type:GradientRange + }) + startColor = new GradientRange(); @property({ type: CurveRange }) - startSize = null; + startSize = new CurveRange(); @property({ type: CurveRange }) - startSpeed = null; + startSpeed = new CurveRange(); @property({ type: CurveRange }) - startRotation = null; + startRotation = new CurveRange(); @property({ type: CurveRange }) - startDelay = null; + startDelay = new CurveRange(); @property({ type: CurveRange }) - startLifetime = null; + startLifetime = new CurveRange(); @property duration = 5.0; @@ -126,35 +109,35 @@ export default class ParticleSystemComponent extends Component { @property({ type: CurveRange }) - gravityModifier = null; + gravityModifier = new CurveRange(); // emission module @property({ type: CurveRange }) - rateOverTime = null; + rateOverTime = new CurveRange(); @property({ type: CurveRange }) - rateOverDistance = null; + rateOverDistance = new CurveRange(); @property({ type: [Burst] }) - bursts = null; + bursts = new Array(); // color over lifetime module @property({ type: ColorOverLifetimeModule }) - colorOverLifetimeModule = null; + colorOverLifetimeModule = new ColorOverLifetimeModule(); // shpae module @property({ type: ShapeModule }) - shapeModule = null; + shapeModule = new ShapeModule(); // particle system renderer @property({ @@ -166,32 +149,32 @@ export default class ParticleSystemComponent extends Component { @property({ type: SizeOvertimeModule }) - sizeOvertimeModule = null; + sizeOvertimeModule = new SizeOvertimeModule(); @property({ type: VelocityOvertimeModule }) - velocityOvertimeModule = null; + velocityOvertimeModule = new VelocityOvertimeModule(); @property({ type: ForceOvertimeModule }) - forceOvertimeModule = null; + forceOvertimeModule = new ForceOvertimeModule(); @property({ type: LimitVelocityOvertimeModule }) - limitVelocityOvertimeModule = null; + limitVelocityOvertimeModule = new LimitVelocityOvertimeModule(); @property({ type: RotationOvertimeModule }) - rotationOvertimeModule = null; + rotationOvertimeModule = new RotationOvertimeModule(); @property({ type: TextureAnimationModule }) - textureAnimationModule = null; + textureAnimationModule = new TextureAnimationModule(); constructor() { super(); @@ -216,6 +199,7 @@ export default class ParticleSystemComponent extends Component { onLoad() { // HACK, TODO + this.renderer = this.getComponent(ParticleSystemRenderer); this.renderer.onInit(); this.shapeModule.onInit(this); this.textureAnimationModule.onInit(this); diff --git a/cocos/3d/framework/particle/renderer/particle-system-renderer.js b/cocos/3d/framework/particle/renderer/particle-system-renderer.js index a7f36a6f20..d4ee9e6787 100644 --- a/cocos/3d/framework/particle/renderer/particle-system-renderer.js +++ b/cocos/3d/framework/particle/renderer/particle-system-renderer.js @@ -109,10 +109,12 @@ export default class ParticleSystemRenderer extends RenderableComponent { } this._updateMaterialParams(); this._updateModel(); + this.onEnable(); } onEnable() { - this._scene.addModel(this._model); + if (this._model != null) + this._scene.addModel(this._model); } onDisable() {