This commit is contained in:
jerrywwl
2019-02-27 14:42:53 +08:00
5 changed files with 19 additions and 15 deletions
+3 -3
View File
@@ -145,9 +145,9 @@ class BuiltinResMgr {
// default particle material
const defaultParticleMtl = new cc.Material();
defaultParticleMtl._uuid = 'default-particle-material';
defaultParticleMtl.initialize({ effectName: 'builtin-particle-add' });
resources[defaultParticleMtl._uuid] = defaultParticleMtl;
defaultParticleMtl._uuid = null;
defaultParticleMtl.initialize({ effectName: 'builtin-effect-particle' });
resources['default-particle-material'] = defaultParticleMtl;
}
public get<T extends Asset> (uuid: string): T {
@@ -1,5 +1,5 @@
import { ccclass, executeInEditMode, property } from '../../../../core/data/class-decorator';
import { Enum, Vec2 } from '../../../../core/value-types';
import { Enum, Vec2, Vec4 } from '../../../../core/value-types';
import { mat4, vec2, vec3, vec4 } from '../../../../core/vmath';
import { GFXAttributeName, GFXFormat } from '../../../../gfx/define';
import { IGFXInputAttribute } from '../../../../gfx/input-assembler';
@@ -96,7 +96,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
private _defines: { [index: string]: boolean };
private _model: ParticleBatchModel | null;
private frameTile: Vec2;
private frameTile_velLenScale: Vec4;
private attrs: any[];
private _vertAttrs: IGFXInputAttribute[];
private particleSystem: any;
@@ -106,7 +106,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
super();
this._model = null;
this.frameTile = cc.v2(1, 1);
this.frameTile_velLenScale = cc.v4(1, 1, 0, 0);
this.attrs = new Array(5);
this._vertAttrs = [
{ name: GFXAttributeName.ATTR_POSITION, format: GFXFormat.RGB32F },
@@ -296,8 +296,8 @@ export default class ParticleSystemRenderer extends RenderableComponent {
this._defines[USE_STRETCHED_BILLBOARD] = true;
this._defines[USE_HORIZONTAL_BILLBOARD] = false;
this._defines[USE_VERTICAL_BILLBOARD] = false;
this.sharedMaterial!.setProperty('velocityScale', this._velocityScale);
this.sharedMaterial!.setProperty('lengthScale', this._lengthScale);
this.frameTile_velLenScale.z = this._velocityScale;
this.frameTile_velLenScale.w = this._lengthScale;
} else if (this._renderMode === RenderMode.HorizontalBillboard) {
this._defines[USE_BILLBOARD] = false;
this._defines[USE_STRETCHED_BILLBOARD] = false;
@@ -316,9 +316,9 @@ export default class ParticleSystemRenderer extends RenderableComponent {
mat.initialize({ defines: this._defines });
if (this.particleSystem.textureAnimationModule.enable) {
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile', vec2.set(this.frameTile, this.particleSystem.textureAnimationModule.numTilesX, this.particleSystem.textureAnimationModule.numTilesY));
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile_velLenScale', vec2.set(this.frameTile_velLenScale, this.particleSystem.textureAnimationModule.numTilesX, this.particleSystem.textureAnimationModule.numTilesY));
} else {
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile', this.frameTile);
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile_velLenScale', this.frameTile_velLenScale);
}
}
+2 -2
View File
@@ -221,7 +221,7 @@ export class CanvasComponent extends Component {
// cc.view.on('canvas-resize', this._thisOnResized);
// }
}
cc.view.on('canvas-size-update', this._thisOnResized);
cc.view.on('canvas-resize', this._thisOnResized);
this.applySettings();
this.alignWithScreen();
@@ -247,7 +247,7 @@ export class CanvasComponent extends Component {
// cc.view.off('canvas-resize', this._thisOnResized);
// }
// }
cc.view.off('canvas-size-update', this._thisOnResized);
cc.view.off('canvas-resize', this._thisOnResized);
// cc.view.off('design-resolution-changed', this._thisOnResized);
if (CanvasComponent.instance === this) {
+1 -2
View File
@@ -557,8 +557,6 @@ class View extends EventTarget {
const w = width * this._devicePixelRatio;
const h = height * this._devicePixelRatio;
cc.director.root.resize(w, h);
this.emit('canvas-size-update');
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
@@ -1087,6 +1085,7 @@ class ContainerStrategy {
// Setup canvas
locCanvas.width = w * devicePixelRatio;
locCanvas.height = h * devicePixelRatio;
view.emit('canvas-resize');
}
_fixContainer () {
+6 -1
View File
@@ -109,6 +109,10 @@ export class Root {
return false;
}
cc.view.on('canvas-resize', function () {
this.resize(cc.game.canvas.width, cc.game.canvas.height);
}, this);
return true;
}
@@ -151,7 +155,7 @@ export class Root {
}
for (const view of this._views) {
if (view.camera.isWindowSize) {
if (view.camera.isWindowSize && view.priority < 1 << 30) {
view.camera.resize(width, height);
}
}
@@ -230,6 +234,7 @@ export class Root {
public createView (info: IRenderViewInfo): RenderView {
const view: RenderView = this._createViewFun(this, info.camera);
view.initialize(info);
view.camera.resize(cc.game.canvas.width, cc.game.canvas.height);
this._views.push(view);
this._views.sort((a: RenderView, b: RenderView) => {