Commit 1fcc68a6 authored by rockyl's avatar rockyl

修改scilla-core为scilla

parent 2c70cf61
...@@ -8,6 +8,12 @@ ...@@ -8,6 +8,12 @@
}, },
"devDependencies": { "devDependencies": {
"glob": "^7.1.3" "glob": "^7.1.3",
"rollup-plugin-commonjs": "^9.2.2",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-typescript2": "^0.20.1",
"rollup-plugin-uglify": "^6.0.2",
"tslib": "^1.9.3",
"typescript": "^3.3.4000"
} }
} }
...@@ -12,7 +12,7 @@ export default { ...@@ -12,7 +12,7 @@ export default {
output: { output: {
file: 'dist/bundle.js', file: 'dist/bundle.js',
format: 'umd', format: 'umd',
name: 'scilla', name: 'scilla-components',
//sourcemap: true, //sourcemap: true,
}, },
plugins: [ plugins: [
...@@ -26,5 +26,6 @@ export default { ...@@ -26,5 +26,6 @@ export default {
}), }),
commonjs(), commonjs(),
//uglify({}), //uglify({}),
] ],
external: ['scilla']
}; };
...@@ -48,7 +48,7 @@ export default class Transform extends ScillaComponent { ...@@ -48,7 +48,7 @@ export default class Transform extends ScillaComponent {
*/ */
private _renderAlpha: number; private _renderAlpha: number;
get renderAlpha(): number{ get renderAlpha(): number {
return this._renderAlpha; return this._renderAlpha;
} }
...@@ -119,7 +119,7 @@ export default class Transform extends ScillaComponent { ...@@ -119,7 +119,7 @@ export default class Transform extends ScillaComponent {
/** /**
* 获取全局坐标 * 获取全局坐标
*/ */
get globalPosition(){ get globalPosition() {
this._globalPosition.setXY(this._globalMatrix.tx, this._globalMatrix.ty); this._globalPosition.setXY(this._globalMatrix.tx, this._globalMatrix.ty);
return this._globalPosition; return this._globalPosition;
} }
...@@ -127,7 +127,7 @@ export default class Transform extends ScillaComponent { ...@@ -127,7 +127,7 @@ export default class Transform extends ScillaComponent {
/** /**
* 获取全局角度 * 获取全局角度
*/ */
get globalRotation(){ get globalRotation() {
return this._globalMatrix.rotation * 180 / Math.PI; return this._globalMatrix.rotation * 180 / Math.PI;
} }
...@@ -203,11 +203,11 @@ export default class Transform extends ScillaComponent { ...@@ -203,11 +203,11 @@ export default class Transform extends ScillaComponent {
const parentTransform: Transform = entity.parent.getComponent(Transform); const parentTransform: Transform = entity.parent.getComponent(Transform);
if (parentTransform) { if (parentTransform) {
this._renderAlpha = parentTransform._renderAlpha * this.alpha; this._renderAlpha = parentTransform._renderAlpha * this.alpha;
_globalMatrix.concat(parentTransform.getMatrix(true)); _globalMatrix.concat(parentTransform.getMatrix(false));
}else{ } else {
this._renderAlpha = this.alpha; this._renderAlpha = this.alpha;
} }
}else{ } else {
this._renderAlpha = this.alpha; this._renderAlpha = this.alpha;
} }
_globalPivotMatrix.copyFrom(_globalMatrix); _globalPivotMatrix.copyFrom(_globalMatrix);
...@@ -222,7 +222,7 @@ export default class Transform extends ScillaComponent { ...@@ -222,7 +222,7 @@ export default class Transform extends ScillaComponent {
*/ */
getMatrix(withPivot: boolean = false, invert: boolean = false): Matrix { getMatrix(withPivot: boolean = false, invert: boolean = false): Matrix {
let matrix = withPivot ? this._globalPivotMatrix : this._globalMatrix; let matrix = withPivot ? this._globalPivotMatrix : this._globalMatrix;
if(invert){ if (invert) {
const invertMatrix = this._globalInvertMatrix; const invertMatrix = this._globalInvertMatrix;
invertMatrix.copyFrom(matrix); invertMatrix.copyFrom(matrix);
invertMatrix.invert(); invertMatrix.invert();
...@@ -243,4 +243,8 @@ export default class Transform extends ScillaComponent { ...@@ -243,4 +243,8 @@ export default class Transform extends ScillaComponent {
super.onUpdate(t); super.onUpdate(t);
} }
onEditorUpdate(t) {
this.onUpdate(t);
}
} }
...@@ -13,36 +13,49 @@ export default class CameraController extends ScillaComponent { ...@@ -13,36 +13,49 @@ export default class CameraController extends ScillaComponent {
viewportAnchor: Vector2D = createVector2D(0.5, 0.5); viewportAnchor: Vector2D = createVector2D(0.5, 0.5);
target: Entity; target: Entity;
maxScale = 1.2; maxScale = 1.2;
once: boolean = true;
private targetPosition: Vector2D; private targetPosition: Vector2D;
private followPosition: Vector2D; private followPosition: Vector2D;
private stageSize; private _stageSize;
onCreate() {
super.onCreate();
}
onAwake() { onAwake() {
super.onAwake(); super.onAwake();
const {target,} = this; const {target,} = this;
this.stageSize = getStageSize();
if (target) { if (target) {
this.targetPosition = target.getComponent(Transform).position; this.targetPosition = target.getComponent(Transform).position;
} }
this.followPosition = createVector2D(); this.followPosition = createVector2D();
this.updateViewport(); if(this.once){
this.updateViewport();
}
}
get stageSize(){
if(!this._stageSize){
this._stageSize = getStageSize();
}
return this._stageSize;
} }
onUpdate(t) { onUpdate(t) {
super.onUpdate(t); super.onUpdate(t);
if(!this.once){
this.updateViewport();
}
this.followTarget(); this.followTarget();
} }
onEditorUpdate(t){
this.updateViewport();
}
updateViewport() { updateViewport() {
if (this.viewportAnchor) { if (this.viewportAnchor) {
const {width, height} = this.stageSize; const {width, height} = this.stageSize;
......
...@@ -38,6 +38,10 @@ export default class RelativeLayout extends ScillaComponent { ...@@ -38,6 +38,10 @@ export default class RelativeLayout extends ScillaComponent {
} }
} }
onEditorUpdate(t){
this.adjust();
}
onSleep() { onSleep() {
super.onSleep(); super.onSleep();
} }
......
...@@ -16,12 +16,12 @@ export default class GraphicRenderer extends Renderer { ...@@ -16,12 +16,12 @@ export default class GraphicRenderer extends Renderer {
borderWidth = 0; borderWidth = 0;
//是否为mask //是否为mask
isUsedToMask = false; isMask = false;
//是否显示mask //是否显示mask
maskVisible = false; maskVisible = false;
protected getUseCacheMode(){ protected getUseCacheMode(){
return this._useCacheMode && !this.isUsedToMask; return this._useCacheMode && !this.isMask;
} }
/** /**
...@@ -46,7 +46,7 @@ export default class GraphicRenderer extends Renderer { ...@@ -46,7 +46,7 @@ export default class GraphicRenderer extends Renderer {
protected draw() { protected draw() {
super.draw(); super.draw();
if (this.isUsedToMask) { if (this.isMask) {
this._context.clip(); this._context.clip();
this.maskVisible && this.fillAndStoke() this.maskVisible && this.fillAndStoke()
} else { } else {
...@@ -83,14 +83,18 @@ export default class GraphicRenderer extends Renderer { ...@@ -83,14 +83,18 @@ export default class GraphicRenderer extends Renderer {
* @inheritDoc * @inheritDoc
*/ */
protected drawClip() { protected drawClip() {
this.isUsedToMask && this.context.save(); this.isMask && this.context.save();
} }
/** /**
* @inheritDoc * @inheritDoc
*/ */
afterUpdate() { afterUpdate() {
this.isUsedToMask && this.context.restore(); this.isMask && this.context.restore();
}
afterEditorUpdate(){
this.afterUpdate();
} }
measureBounds() { measureBounds() {
......
...@@ -115,9 +115,6 @@ export default class Renderer extends ScillaComponent { ...@@ -115,9 +115,6 @@ export default class Renderer extends ScillaComponent {
*/ */
onUpdate(t) { onUpdate(t) {
if (this.dirty) { if (this.dirty) {
if(this.entity.name == 'label_status'){
console.log();
}
if (this.useCacheMode) { if (this.useCacheMode) {
this.readyCacheCanvas(); this.readyCacheCanvas();
} }
...@@ -143,6 +140,10 @@ export default class Renderer extends ScillaComponent { ...@@ -143,6 +140,10 @@ export default class Renderer extends ScillaComponent {
} }
} }
onEditorUpdate(t){
this.onUpdate(t);
}
/** /**
* 准备缓存渲染上下文 * 准备缓存渲染上下文
*/ */
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
], ],
"baseUrl": "./", "baseUrl": "./",
"paths": { "paths": {
"scilla": ["node_modules/scilla-core/src"] "scilla": ["node_modules/scilla/src"]
} }
}, },
"include": [ "include": [
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment