fix tsc error (#4026)

This commit is contained in:
zxg0622
2019-03-13 18:24:57 +08:00
committed by Weiliang Wang
parent a2416ba312
commit efdbc65240
9 changed files with 37 additions and 35 deletions
@@ -4,7 +4,7 @@ import { AnimationCurve } from '../../../geom-utils';
import { CCClass } from '../../../../core/data';
import { property, ccclass } from '../../../../core/data/class-decorator';
const Mode = Enum({
export const Mode = Enum({
Constant: 0,
Curve: 1,
TwoCurves: 2,
@@ -1,6 +1,6 @@
import { OptimizedKey, evalOptCurve, AnimationCurve } from "../../../geom-utils/curve";
import { repeat } from "../../../../core/vmath";
import CurveRange from "./curve-range";
import CurveRange, { Mode } from "./curve-range";
// tslint:disable: max-line-length
@@ -291,16 +291,16 @@ export class CurveUniform {
public uploadUniform (device: any, name: number) {
switch (this.mode) {
case 'constant':
case Mode.Constant:
device.setUniform('u_' + name + '_curveMode', CURVE_MODE_CONSTANT);
device.setUniform('u_' + name + '_minConstant', this.minConstant);
break;
case 'twoConstants':
case Mode.TwoConstants:
device.setUniform('u_' + name + '_curveMode', CURVE_MODE_RANDOM_CONSTANT);
device.setUniform('u_' + name + '_minConstant', this.minConstant);
device.setUniform('u_' + name + '_maxConstant', this.maxConstant);
break;
case 'curve':
case Mode.Curve:
if (this.minCurve != null) {
device.setUniform('u_' + name + '_curveMode', CURVE_MODE_CURVE);
device.setUniform('u_' + name + '_minKeyTime', this.minCurve.timeUniform);
@@ -310,7 +310,7 @@ export class CurveUniform {
}
}
break;
case 'twoCurves':
case Mode.TwoCurves:
if (this.minCurve != null && this.maxCurve != null) {
device.setUniform('u_' + name + '_curveMode', CURVE_MODE_RANDOM_CURVE);
device.setUniform('u_' + name + '_minKeyTime', this.minCurve.timeUniform);
@@ -32,7 +32,7 @@ export default class TextureAnimationModule {
set enable (val) {
this._enable = val;
this.ps!.renderer!._updateMaterialParams();
(this.ps!.getComponent(cc.ParticleSystemRenderer) as any)._updateMaterialParams();
}
@property({
@@ -147,7 +147,7 @@ export default class ShapeModule {
private mat: mat4;
private quat: quat;
private particleSystem: ParticleSystemComponent | null;
private particleSystem: any;
private lastTime: number;
private totalAngle: number;
@@ -162,7 +162,7 @@ export default class ShapeModule {
public onInit (ps: ParticleSystemComponent) {
this.constructMat();
this.particleSystem = ps;
this.lastTime = ps._time;
this.lastTime = this.particleSystem._time;
this.totalAngle = 0;
}
@@ -96,7 +96,7 @@ export class ParticleSystemComponent extends Component {
set simulationSpace (val) {
if (val !== this._simulationSpace) {
this._simulationSpace = val;
this.renderer!._updateMaterialParams();
(this.renderer as any)._updateMaterialParams();
}
}
@@ -99,7 +99,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
private attrs: any[];
private _vertAttrs: IGFXInputAttribute[];
private particleSystem: any;
private _particles: RecyclePool;
private _particles: RecyclePool | null = null;
private _defaultMat: Material | null = null;
constructor () {
@@ -155,14 +155,14 @@ export default class ParticleSystemRenderer extends RenderableComponent {
}
public clear () {
this._particles.reset();
this._particles!.reset();
}
public _getFreeParticle (): Particle | null {
if (this._particles.length >= this.particleSystem.capacity) {
if (this._particles!.length >= this.particleSystem.capacity) {
return null;
}
return this._particles.add();
return this._particles!.add();
}
public _setNewParticle (p: Particle) {
@@ -177,13 +177,13 @@ export default class ParticleSystemRenderer extends RenderableComponent {
if (this.particleSystem.forceOvertimeModule.enable) {
this.particleSystem.forceOvertimeModule.update(this.particleSystem._simulationSpace, _tempWorldTrans);
}
for (let i = 0; i < this._particles.length; ++i) {
const p = this._particles.data[i];
for (let i = 0; i < this._particles!.length; ++i) {
const p = this._particles!.data[i];
p.remainingLifetime -= dt;
vec3.set(p.animatedVelocity, 0, 0, 0);
if (p.remainingLifetime < 0.0) {
this._particles.removeAt(i);
this._particles!.removeAt(i);
--i;
continue;
}
@@ -221,8 +221,8 @@ export default class ParticleSystemRenderer extends RenderableComponent {
// update vertex buffer
let idx = 0;
const uploadVel = this._renderMode === RenderMode.StrecthedBillboard;
for (let i = 0; i < this._particles.length; ++i) {
const p = this._particles.data[i];
for (let i = 0; i < this._particles!.length; ++i) {
const p = this._particles!.data[i];
let fi = 0;
if (this.particleSystem.textureAnimationModule.enable) {
fi = p.frameIndex;
@@ -250,7 +250,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
}
// because we use index buffer, per particle index count = 6.
this._model!.updateIA(this._particles.length * 6);
this._model!.updateIA(this._particles!.length * 6);
}
public updateShaderUniform () {
@@ -258,7 +258,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
}
public getParticleCount (): number {
return this._particles.length;
return this._particles!.length;
}
public _onMaterialModified (index: number, material: Material) {
+1 -1
View File
@@ -37,7 +37,7 @@ export default class Pool<T> {
}
const ret = this._frees[this._idx];
this._frees[this._idx] = null;
this._frees.splice(this._idx);
--this._idx;
return ret;
@@ -23,7 +23,7 @@ export default class ParticleBatchModel extends Model {
private _iaInfoBuffer: GFXBuffer;
private _subMeshData: IRenderingSubmesh | null;
constructor (scene: RenderScene, node: Node) {
constructor (scene: RenderScene, node: Node | null) {
super(scene, node);
this._type = 'particle-batch';
+14 -12
View File
@@ -258,7 +258,7 @@ export class Model {
this.allocatePSO(mat);
}
}
this._subModels[idx]._psos = mat ? this._matPSORecord.get(mat)! : null;
(this._subModels[idx] as any)._psos = mat ? this._matPSORecord.get(mat)! : null;
this._subModels[idx].material = mat;
}
@@ -304,17 +304,19 @@ export class Model {
}
}
protected initLocalBindings (mat: Material) {
if (this._localBindings.size === 0) {
this.onSetLocalBindings(mat);
}
for (const localBinding of this._localBindings.values()) {
if (!localBinding.buffer) {
localBinding.buffer = this._device.createBuffer({
usage: GFXBufferUsageBit.UNIFORM | GFXBufferUsageBit.TRANSFER_DST,
memUsage: GFXMemoryUsageBit.HOST | GFXMemoryUsageBit.DEVICE,
size: getUniformBlockSize(localBinding.blockInfo!),
});
protected initLocalBindings (mat: Material|null) {
if (mat) {
if (this._localBindings.size === 0) {
this.onSetLocalBindings(mat);
}
for (const localBinding of this._localBindings.values()) {
if (!localBinding.buffer) {
localBinding.buffer = this._device.createBuffer({
usage: GFXBufferUsageBit.UNIFORM | GFXBufferUsageBit.TRANSFER_DST,
memUsage: GFXMemoryUsageBit.HOST | GFXMemoryUsageBit.DEVICE,
size: getUniformBlockSize(localBinding.blockInfo!),
});
}
}
}
}