Commit 1fcc68a6 authored by rockyl's avatar rockyl

修改scilla-core为scilla

parent 2c70cf61
......@@ -12,7 +12,7 @@ export default {
output: {
file: 'dist/bundle.js',
format: 'umd',
name: 'scilla',
name: 'scilla-components',
//sourcemap: true,
},
plugins: [
......@@ -26,5 +26,6 @@ export default {
}),
commonjs(),
//uglify({}),
]
],
external: ['scilla']
};
......@@ -48,7 +48,7 @@ export default class Transform extends ScillaComponent {
*/
private _renderAlpha: number;
get renderAlpha(): number{
get renderAlpha(): number {
return this._renderAlpha;
}
......@@ -119,7 +119,7 @@ export default class Transform extends ScillaComponent {
/**
* 获取全局坐标
*/
get globalPosition(){
get globalPosition() {
this._globalPosition.setXY(this._globalMatrix.tx, this._globalMatrix.ty);
return this._globalPosition;
}
......@@ -127,7 +127,7 @@ export default class Transform extends ScillaComponent {
/**
* 获取全局角度
*/
get globalRotation(){
get globalRotation() {
return this._globalMatrix.rotation * 180 / Math.PI;
}
......@@ -203,11 +203,11 @@ export default class Transform extends ScillaComponent {
const parentTransform: Transform = entity.parent.getComponent(Transform);
if (parentTransform) {
this._renderAlpha = parentTransform._renderAlpha * this.alpha;
_globalMatrix.concat(parentTransform.getMatrix(true));
}else{
_globalMatrix.concat(parentTransform.getMatrix(false));
} else {
this._renderAlpha = this.alpha;
}
}else{
} else {
this._renderAlpha = this.alpha;
}
_globalPivotMatrix.copyFrom(_globalMatrix);
......@@ -222,7 +222,7 @@ export default class Transform extends ScillaComponent {
*/
getMatrix(withPivot: boolean = false, invert: boolean = false): Matrix {
let matrix = withPivot ? this._globalPivotMatrix : this._globalMatrix;
if(invert){
if (invert) {
const invertMatrix = this._globalInvertMatrix;
invertMatrix.copyFrom(matrix);
invertMatrix.invert();
......@@ -243,4 +243,8 @@ export default class Transform extends ScillaComponent {
super.onUpdate(t);
}
onEditorUpdate(t) {
this.onUpdate(t);
}
}
......@@ -13,36 +13,49 @@ export default class CameraController extends ScillaComponent {
viewportAnchor: Vector2D = createVector2D(0.5, 0.5);
target: Entity;
maxScale = 1.2;
once: boolean = true;
private targetPosition: Vector2D;
private followPosition: Vector2D;
private stageSize;
onCreate() {
super.onCreate();
}
private _stageSize;
onAwake() {
super.onAwake();
const {target,} = this;
this.stageSize = getStageSize();
if (target) {
this.targetPosition = target.getComponent(Transform).position;
}
this.followPosition = createVector2D();
if(this.once){
this.updateViewport();
}
}
get stageSize(){
if(!this._stageSize){
this._stageSize = getStageSize();
}
return this._stageSize;
}
onUpdate(t) {
super.onUpdate(t);
if(!this.once){
this.updateViewport();
}
this.followTarget();
}
onEditorUpdate(t){
this.updateViewport();
}
updateViewport() {
if (this.viewportAnchor) {
const {width, height} = this.stageSize;
......
......@@ -38,6 +38,10 @@ export default class RelativeLayout extends ScillaComponent {
}
}
onEditorUpdate(t){
this.adjust();
}
onSleep() {
super.onSleep();
}
......
......@@ -16,12 +16,12 @@ export default class GraphicRenderer extends Renderer {
borderWidth = 0;
//是否为mask
isUsedToMask = false;
isMask = false;
//是否显示mask
maskVisible = false;
protected getUseCacheMode(){
return this._useCacheMode && !this.isUsedToMask;
return this._useCacheMode && !this.isMask;
}
/**
......@@ -46,7 +46,7 @@ export default class GraphicRenderer extends Renderer {
protected draw() {
super.draw();
if (this.isUsedToMask) {
if (this.isMask) {
this._context.clip();
this.maskVisible && this.fillAndStoke()
} else {
......@@ -83,14 +83,18 @@ export default class GraphicRenderer extends Renderer {
* @inheritDoc
*/
protected drawClip() {
this.isUsedToMask && this.context.save();
this.isMask && this.context.save();
}
/**
* @inheritDoc
*/
afterUpdate() {
this.isUsedToMask && this.context.restore();
this.isMask && this.context.restore();
}
afterEditorUpdate(){
this.afterUpdate();
}
measureBounds() {
......
......@@ -115,9 +115,6 @@ export default class Renderer extends ScillaComponent {
*/
onUpdate(t) {
if (this.dirty) {
if(this.entity.name == 'label_status'){
console.log();
}
if (this.useCacheMode) {
this.readyCacheCanvas();
}
......@@ -143,6 +140,10 @@ export default class Renderer extends ScillaComponent {
}
}
onEditorUpdate(t){
this.onUpdate(t);
}
/**
* 准备缓存渲染上下文
*/
......
......@@ -14,7 +14,7 @@
],
"baseUrl": "./",
"paths": {
"scilla": ["node_modules/scilla-core/src"]
"scilla": ["node_modules/scilla/src"]
}
},
"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