初始化适配信息
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -13,3 +13,6 @@
|
|||||||
[submodule "engine_support/egret"]
|
[submodule "engine_support/egret"]
|
||||||
path = engine_support/egret
|
path = engine_support/egret
|
||||||
url = https://github.com/esengine/egret-ecs-ext.git
|
url = https://github.com/esengine/egret-ecs-ext.git
|
||||||
|
[submodule "extensions/ecs-tween"]
|
||||||
|
path = extensions/ecs-tween
|
||||||
|
url = https://github.com/esengine/ecs-tween
|
||||||
|
|||||||
Submodule engine_support/egret updated: 05ab4bfb0d...56a668a551
319
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.d.ts
vendored
Normal file
319
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.d.ts
vendored
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
declare module es {
|
||||||
|
abstract class AbstractTweenable implements ITweenable {
|
||||||
|
protected _isPaused: boolean;
|
||||||
|
protected _isCurrentlyManagedByTweenManager: boolean;
|
||||||
|
abstract tick(): boolean;
|
||||||
|
recycleSelf(): void;
|
||||||
|
isRunning(): boolean;
|
||||||
|
start(): void;
|
||||||
|
pause(): void;
|
||||||
|
resume(): void;
|
||||||
|
stop(bringToCompletion?: boolean): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
class PropertyTweens {
|
||||||
|
static NumberPropertyTo(self: any, memberName: string, to: number, duration: number): ITween<number>;
|
||||||
|
static Vector2PropertyTo(self: any, memeberName: string, to: Vector2, duration: number): ITween<Vector2>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
class TransformSpringTween extends AbstractTweenable {
|
||||||
|
readonly targetType: TransformTargetType;
|
||||||
|
private _transform;
|
||||||
|
private _targetType;
|
||||||
|
private _targetValue;
|
||||||
|
private _velocity;
|
||||||
|
dampingRatio: number;
|
||||||
|
angularFrequency: number;
|
||||||
|
constructor(transform: Transform, targetType: TransformTargetType, targetValue: Vector2);
|
||||||
|
setTargetValue(targetValue: Vector2): void;
|
||||||
|
updateDampingRatioWithHalfLife(lambda: number): void;
|
||||||
|
tick(): boolean;
|
||||||
|
private setTweenedValue;
|
||||||
|
private getCurrentValueOfTweenedTargetType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
enum LoopType {
|
||||||
|
none = 0,
|
||||||
|
restartFromBeginning = 1,
|
||||||
|
pingpong = 2
|
||||||
|
}
|
||||||
|
enum TweenState {
|
||||||
|
running = 0,
|
||||||
|
paused = 1,
|
||||||
|
complete = 2
|
||||||
|
}
|
||||||
|
abstract class Tween<T> implements ITweenable, ITween<T> {
|
||||||
|
protected _target: ITweenTarget<T>;
|
||||||
|
protected _isFromValueOverridden: boolean;
|
||||||
|
protected _fromValue: T;
|
||||||
|
protected _toValue: T;
|
||||||
|
protected _easeType: EaseType;
|
||||||
|
protected _shouldRecycleTween: boolean;
|
||||||
|
protected _isRelative: boolean;
|
||||||
|
protected _completionHandler: (tween: ITween<T>) => void;
|
||||||
|
protected _loopCompleteHandler: (tween: ITween<T>) => void;
|
||||||
|
protected _nextTween: ITweenable;
|
||||||
|
protected _tweenState: TweenState;
|
||||||
|
private _isTimeScaleIndependent;
|
||||||
|
protected _delay: number;
|
||||||
|
protected _duration: number;
|
||||||
|
protected _timeScale: number;
|
||||||
|
protected _elapsedTime: number;
|
||||||
|
protected _loopType: LoopType;
|
||||||
|
protected _loops: number;
|
||||||
|
protected _delayBetweenLoops: number;
|
||||||
|
private _isRunningInReverse;
|
||||||
|
context: any;
|
||||||
|
setEaseType(easeType: EaseType): ITween<T>;
|
||||||
|
setDelay(delay: number): ITween<T>;
|
||||||
|
setDuration(duration: number): ITween<T>;
|
||||||
|
setTimeScale(timeSclae: number): ITween<T>;
|
||||||
|
setIsTimeScaleIndependent(): ITween<T>;
|
||||||
|
setCompletionHandler(completeHandler: (tween: ITween<T>) => void): ITween<T>;
|
||||||
|
setLoops(loopType: LoopType, loops?: number, delayBetweenLoops?: number): ITween<T>;
|
||||||
|
setLoopCompletionHanlder(loopCompleteHandler: (tween: ITween<T>) => void): ITween<T>;
|
||||||
|
setFrom(from: T): ITween<T>;
|
||||||
|
prepareForReuse(from: T, to: T, duration: number): ITween<T>;
|
||||||
|
setRecycleTween(shouldRecycleTween: boolean): ITween<T>;
|
||||||
|
abstract setIsRelative(): ITween<T>;
|
||||||
|
setContext(context: any): ITween<T>;
|
||||||
|
setNextTween(nextTween: ITweenable): ITween<T>;
|
||||||
|
tick(): boolean;
|
||||||
|
recycleSelf(): void;
|
||||||
|
isRunning(): boolean;
|
||||||
|
start(): void;
|
||||||
|
pause(): void;
|
||||||
|
resume(): void;
|
||||||
|
stop(bringToCompletion?: boolean): void;
|
||||||
|
jumpToElapsedTime(elapsedTime: any): void;
|
||||||
|
reverseTween(): void;
|
||||||
|
waitForCompletion(): IterableIterator<any>;
|
||||||
|
getTargetObject(): any;
|
||||||
|
private resetState;
|
||||||
|
initialize(target: ITweenTarget<T>, to: T, duration: number): void;
|
||||||
|
private handleLooping;
|
||||||
|
protected abstract updateValue(): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
class NumberTween extends Tween<number> {
|
||||||
|
static create(): NumberTween;
|
||||||
|
constructor(target?: ITweenTarget<number>, to?: number, duration?: number);
|
||||||
|
setIsRelative(): ITween<number>;
|
||||||
|
protected updateValue(): void;
|
||||||
|
recycleSelf(): void;
|
||||||
|
}
|
||||||
|
class Vector2Tween extends Tween<Vector2> {
|
||||||
|
static create(): Vector2Tween;
|
||||||
|
constructor(target?: ITweenTarget<Vector2>, to?: Vector2, duration?: number);
|
||||||
|
setIsRelative(): ITween<Vector2>;
|
||||||
|
protected updateValue(): void;
|
||||||
|
recycleSelf(): void;
|
||||||
|
}
|
||||||
|
class RectangleTween extends Tween<Rectangle> {
|
||||||
|
static create(): RectangleTween;
|
||||||
|
constructor(target?: ITweenTarget<Rectangle>, to?: Rectangle, duration?: number);
|
||||||
|
setIsRelative(): ITween<Rectangle>;
|
||||||
|
protected updateValue(): void;
|
||||||
|
recycleSelf(): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
enum TransformTargetType {
|
||||||
|
position = 0,
|
||||||
|
localPosition = 1,
|
||||||
|
scale = 2,
|
||||||
|
localScale = 3,
|
||||||
|
rotationDegrees = 4,
|
||||||
|
localRotationDegrees = 5
|
||||||
|
}
|
||||||
|
class TransformVector2Tween extends Vector2Tween implements ITweenTarget<Vector2> {
|
||||||
|
private _transform;
|
||||||
|
private _targetType;
|
||||||
|
setTweenedValue(value: Vector2): void;
|
||||||
|
getTweenedValue(): Vector2;
|
||||||
|
getTargetObject(): Transform;
|
||||||
|
setTargetAndType(transform: Transform, targetType: TransformTargetType): void;
|
||||||
|
protected updateValue(): void;
|
||||||
|
recycleSelf(): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
enum EaseType {
|
||||||
|
linear = 0,
|
||||||
|
sineIn = 1,
|
||||||
|
sineOut = 2,
|
||||||
|
sineInOut = 3,
|
||||||
|
quadIn = 4,
|
||||||
|
quadOut = 5,
|
||||||
|
quadInOut = 6,
|
||||||
|
quintIn = 7,
|
||||||
|
quintOut = 8,
|
||||||
|
quintInOut = 9,
|
||||||
|
cubicIn = 10,
|
||||||
|
cubicOut = 11,
|
||||||
|
cubicInOut = 12,
|
||||||
|
quartIn = 13,
|
||||||
|
quartOut = 14,
|
||||||
|
quartInOut = 15,
|
||||||
|
expoIn = 16,
|
||||||
|
expoOut = 17,
|
||||||
|
expoInOut = 18,
|
||||||
|
circleIn = 19,
|
||||||
|
circleOut = 20,
|
||||||
|
circleInOut = 21,
|
||||||
|
elasticIn = 22,
|
||||||
|
elasticOut = 23,
|
||||||
|
elasticInOut = 24,
|
||||||
|
punch = 25,
|
||||||
|
backIn = 26,
|
||||||
|
backOut = 27,
|
||||||
|
backInOut = 28,
|
||||||
|
bounceIn = 29,
|
||||||
|
bounceOut = 30,
|
||||||
|
bounceInOut = 31
|
||||||
|
}
|
||||||
|
class EaseHelper {
|
||||||
|
static oppositeEaseType(easeType: EaseType): EaseType.linear | EaseType.sineIn | EaseType.sineOut | EaseType.sineInOut | EaseType.quadIn | EaseType.quadOut | EaseType.quadInOut | EaseType.quintIn | EaseType.quintOut | EaseType.quintInOut | EaseType.cubicIn | EaseType.cubicOut | EaseType.cubicInOut | EaseType.quartIn | EaseType.quartInOut | EaseType.expoIn | EaseType.expoOut | EaseType.expoInOut | EaseType.circleIn | EaseType.circleOut | EaseType.circleInOut | EaseType.elasticIn | EaseType.elasticOut | EaseType.elasticInOut | EaseType.punch | EaseType.backIn | EaseType.backOut | EaseType.backInOut | EaseType.bounceIn | EaseType.bounceOut | EaseType.bounceInOut;
|
||||||
|
static ease(easeType: EaseType, t: number, duration: number): number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
class TweenManager extends GlobalManager {
|
||||||
|
static defaultEaseType: EaseType;
|
||||||
|
static removeAllTweensOnLevelLoad: boolean;
|
||||||
|
static cacheNumberTweens: boolean;
|
||||||
|
static cacheVector2Tweens: boolean;
|
||||||
|
static cacheRectTweens: boolean;
|
||||||
|
private _activeTweens;
|
||||||
|
private _tempTweens;
|
||||||
|
private _isUpdating;
|
||||||
|
private static _instance;
|
||||||
|
constructor();
|
||||||
|
update(): void;
|
||||||
|
static addTween(tween: ITweenable): void;
|
||||||
|
static removeTween(tween: ITweenable): void;
|
||||||
|
static stopAllTweens(bringToCompletion?: boolean): void;
|
||||||
|
static allTweensWithContext(context: any): ITweenable[];
|
||||||
|
static stopAllTweensWithContext(context: any, bringToCompletion?: boolean): void;
|
||||||
|
static allTweenWithTarget(target: any): ITweenable[];
|
||||||
|
static stopAllTweensWithTarget(target: any, bringToCompletion?: boolean): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
module Easing {
|
||||||
|
class Linear {
|
||||||
|
static easeNone(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Quadratic {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Back {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Bounce {
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Circular {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Cubic {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Elastic {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
static punch(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Exponential {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Quartic {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Quintic {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
class Sinusoidal {
|
||||||
|
static easeIn(t: number, d: number): number;
|
||||||
|
static easeOut(t: number, d: number): number;
|
||||||
|
static easeInOut(t: number, d: number): number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
class Lerps {
|
||||||
|
static lerp(from: number, to: number, t: number): number;
|
||||||
|
static lerpVector2(from: Vector2, to: Vector2, t: number): Vector2;
|
||||||
|
static lerpRectangle(from: Rectangle, to: Rectangle, t: number): Rectangle;
|
||||||
|
static angleLerp(from: Vector2, to: Vector2, t: number): Vector2;
|
||||||
|
static ease(easeType: EaseType, from: number, to: number, t: number, duration: number): number;
|
||||||
|
static easeVector2(easeType: EaseType, from: Vector2, to: Vector2, t: number, duration: number): Vector2;
|
||||||
|
static easeRectangle(easeType: EaseType, from: Rectangle, to: Rectangle, t: number, duration: number): Rectangle;
|
||||||
|
static easeAngle(easeType: EaseType, from: Vector2, to: Vector2, t: number, duration: number): Vector2;
|
||||||
|
static fastSpring(currentValue: Vector2, targetValue: Vector2, velocity: Vector2, dampingRatio: number, angularFrequency: number): Vector2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
interface ITween<T> extends ITweenControl {
|
||||||
|
setEaseType(easeType: EaseType): ITween<T>;
|
||||||
|
setDelay(delay: number): ITween<T>;
|
||||||
|
setDuration(duration: number): ITween<T>;
|
||||||
|
setTimeScale(timeScale: number): ITween<T>;
|
||||||
|
setIsTimeScaleIndependent(): ITween<T>;
|
||||||
|
setCompletionHandler(completionHandler: (tween: ITween<T>) => void): ITween<T>;
|
||||||
|
setLoops(loopType: LoopType, loops: number, delayBetweenLoops: number): ITween<T>;
|
||||||
|
setFrom(from: T): ITween<T>;
|
||||||
|
prepareForReuse(from: T, to: T, duration: number): ITween<T>;
|
||||||
|
setRecycleTween(shouldRecycleTween: boolean): ITween<T>;
|
||||||
|
setIsRelative(): ITween<T>;
|
||||||
|
setContext(context: any): ITween<T>;
|
||||||
|
setNextTween(nextTween: ITweenable): ITween<T>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
interface ITweenControl extends ITweenable {
|
||||||
|
context: any;
|
||||||
|
jumpToElapsedTime(elapsedTime: number): any;
|
||||||
|
waitForCompletion(): any;
|
||||||
|
getTargetObject(): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
interface ITweenTarget<T> {
|
||||||
|
setTweenedValue(value: T): any;
|
||||||
|
getTweenedValue(): T;
|
||||||
|
getTargetObject(): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare module es {
|
||||||
|
interface ITweenable {
|
||||||
|
tick(): boolean;
|
||||||
|
recycleSelf(): any;
|
||||||
|
isRunning(): boolean;
|
||||||
|
start(): any;
|
||||||
|
pause(): any;
|
||||||
|
resume(): any;
|
||||||
|
stop(bringToCompletion: boolean): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
1110
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.js
Normal file
1110
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.js
Normal file
File diff suppressed because it is too large
Load Diff
1
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.min.js
vendored
Normal file
1
extensions/demo/demo_egret/libs/ecs-tween/ecs-tween.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
299
source/bin/framework.d.ts
vendored
299
source/bin/framework.d.ts
vendored
@@ -166,7 +166,8 @@ declare module es {
|
|||||||
disposeRenderTarget = 7,
|
disposeRenderTarget = 7,
|
||||||
resolutionScale = 8,
|
resolutionScale = 8,
|
||||||
resolutionOffset = 9,
|
resolutionOffset = 9,
|
||||||
createRenderTarget = 10
|
createRenderTarget = 10,
|
||||||
|
createCamera = 11
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -354,6 +355,154 @@ declare module es {
|
|||||||
toString(): string;
|
toString(): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare module es {
|
||||||
|
/** 2d 向量 */
|
||||||
|
class Vector2 implements IEquatable<Vector2> {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
/**
|
||||||
|
* 从两个值构造一个带有X和Y的二维向量。
|
||||||
|
* @param x 二维空间中的x坐标
|
||||||
|
* @param y 二维空间的y坐标
|
||||||
|
*/
|
||||||
|
constructor(x?: number, y?: number);
|
||||||
|
static readonly zero: Vector2;
|
||||||
|
static readonly one: Vector2;
|
||||||
|
static readonly unitX: Vector2;
|
||||||
|
static readonly unitY: Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static add(value1: Vector2, value2: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static divide(value1: Vector2, value2: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static multiply(value1: Vector2, value2: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static subtract(value1: Vector2, value2: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2
|
||||||
|
* 它包含来自另一个向量的标准化值。
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
static normalize(value: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
* 返回两个向量的点积
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static dot(value1: Vector2, value2: Vector2): number;
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间距离的平方
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
static distanceSquared(value1: Vector2, value2: Vector2): number;
|
||||||
|
/**
|
||||||
|
* 将指定的值限制在一个范围内
|
||||||
|
* @param value1
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
*/
|
||||||
|
static clamp(value1: Vector2, min: Vector2, max: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2,其中包含指定向量的线性插值
|
||||||
|
* @param value1 第一个向量
|
||||||
|
* @param value2 第二个向量
|
||||||
|
* @param amount 加权值(0.0-1.0之间)
|
||||||
|
* @returns 指定向量的线性插值结果
|
||||||
|
*/
|
||||||
|
static lerp(value1: Vector2, value2: Vector2, amount: number): Vector2;
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2,该Vector2包含了通过指定的Matrix进行的二维向量变换。
|
||||||
|
* @param position
|
||||||
|
* @param matrix
|
||||||
|
*/
|
||||||
|
static transform(position: Vector2, matrix: Matrix2D): Vector2;
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间的距离
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
* @returns 两个向量之间的距离
|
||||||
|
*/
|
||||||
|
static distance(value1: Vector2, value2: Vector2): number;
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间的角度,单位是度数
|
||||||
|
* @param from
|
||||||
|
* @param to
|
||||||
|
*/
|
||||||
|
static angle(from: Vector2, to: Vector2): number;
|
||||||
|
/**
|
||||||
|
* 创建一个包含指定向量反转的新Vector2
|
||||||
|
* @param value
|
||||||
|
* @returns 矢量反演的结果
|
||||||
|
*/
|
||||||
|
static negate(value: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
add(value: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
divide(value: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
multiply(value: Vector2): Vector2;
|
||||||
|
/**
|
||||||
|
* 从当前Vector2减去一个Vector2
|
||||||
|
* @param value 要减去的Vector2
|
||||||
|
* @returns 当前Vector2
|
||||||
|
*/
|
||||||
|
subtract(value: Vector2): this;
|
||||||
|
/**
|
||||||
|
* 将这个Vector2变成一个方向相同的单位向量
|
||||||
|
*/
|
||||||
|
normalize(): void;
|
||||||
|
/** 返回它的长度 */
|
||||||
|
length(): number;
|
||||||
|
/**
|
||||||
|
* 返回该Vector2的平方长度
|
||||||
|
* @returns 这个Vector2的平方长度
|
||||||
|
*/
|
||||||
|
lengthSquared(): number;
|
||||||
|
/**
|
||||||
|
* 四舍五入X和Y值
|
||||||
|
*/
|
||||||
|
round(): Vector2;
|
||||||
|
/**
|
||||||
|
* 返回以自己为中心点的左右角,单位为度
|
||||||
|
* @param left
|
||||||
|
* @param right
|
||||||
|
*/
|
||||||
|
angleBetween(left: Vector2, right: Vector2): number;
|
||||||
|
/**
|
||||||
|
* 比较当前实例是否等于指定的对象
|
||||||
|
* @param other 要比较的对象
|
||||||
|
* @returns 如果实例相同true 否则false
|
||||||
|
*/
|
||||||
|
equals(other: Vector2 | object): boolean;
|
||||||
|
clone(): Vector2;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
enum SceneResolutionPolicy {
|
enum SceneResolutionPolicy {
|
||||||
/**
|
/**
|
||||||
@@ -2635,154 +2784,6 @@ declare module es {
|
|||||||
reset(): void;
|
reset(): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
|
||||||
/** 2d 向量 */
|
|
||||||
class Vector2 implements IEquatable<Vector2> {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
/**
|
|
||||||
* 从两个值构造一个带有X和Y的二维向量。
|
|
||||||
* @param x 二维空间中的x坐标
|
|
||||||
* @param y 二维空间的y坐标
|
|
||||||
*/
|
|
||||||
constructor(x?: number, y?: number);
|
|
||||||
static readonly zero: Vector2;
|
|
||||||
static readonly one: Vector2;
|
|
||||||
static readonly unitX: Vector2;
|
|
||||||
static readonly unitY: Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static add(value1: Vector2, value2: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static divide(value1: Vector2, value2: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static multiply(value1: Vector2, value2: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static subtract(value1: Vector2, value2: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2
|
|
||||||
* 它包含来自另一个向量的标准化值。
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
static normalize(value: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
* 返回两个向量的点积
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static dot(value1: Vector2, value2: Vector2): number;
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间距离的平方
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
static distanceSquared(value1: Vector2, value2: Vector2): number;
|
|
||||||
/**
|
|
||||||
* 将指定的值限制在一个范围内
|
|
||||||
* @param value1
|
|
||||||
* @param min
|
|
||||||
* @param max
|
|
||||||
*/
|
|
||||||
static clamp(value1: Vector2, min: Vector2, max: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2,其中包含指定向量的线性插值
|
|
||||||
* @param value1 第一个向量
|
|
||||||
* @param value2 第二个向量
|
|
||||||
* @param amount 加权值(0.0-1.0之间)
|
|
||||||
* @returns 指定向量的线性插值结果
|
|
||||||
*/
|
|
||||||
static lerp(value1: Vector2, value2: Vector2, amount: number): Vector2;
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2,该Vector2包含了通过指定的Matrix进行的二维向量变换。
|
|
||||||
* @param position
|
|
||||||
* @param matrix
|
|
||||||
*/
|
|
||||||
static transform(position: Vector2, matrix: Matrix2D): Vector2;
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间的距离
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
* @returns 两个向量之间的距离
|
|
||||||
*/
|
|
||||||
static distance(value1: Vector2, value2: Vector2): number;
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间的角度,单位是度数
|
|
||||||
* @param from
|
|
||||||
* @param to
|
|
||||||
*/
|
|
||||||
static angle(from: Vector2, to: Vector2): number;
|
|
||||||
/**
|
|
||||||
* 创建一个包含指定向量反转的新Vector2
|
|
||||||
* @param value
|
|
||||||
* @returns 矢量反演的结果
|
|
||||||
*/
|
|
||||||
static negate(value: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
add(value: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
divide(value: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
multiply(value: Vector2): Vector2;
|
|
||||||
/**
|
|
||||||
* 从当前Vector2减去一个Vector2
|
|
||||||
* @param value 要减去的Vector2
|
|
||||||
* @returns 当前Vector2
|
|
||||||
*/
|
|
||||||
subtract(value: Vector2): this;
|
|
||||||
/**
|
|
||||||
* 将这个Vector2变成一个方向相同的单位向量
|
|
||||||
*/
|
|
||||||
normalize(): void;
|
|
||||||
/** 返回它的长度 */
|
|
||||||
length(): number;
|
|
||||||
/**
|
|
||||||
* 返回该Vector2的平方长度
|
|
||||||
* @returns 这个Vector2的平方长度
|
|
||||||
*/
|
|
||||||
lengthSquared(): number;
|
|
||||||
/**
|
|
||||||
* 四舍五入X和Y值
|
|
||||||
*/
|
|
||||||
round(): Vector2;
|
|
||||||
/**
|
|
||||||
* 返回以自己为中心点的左右角,单位为度
|
|
||||||
* @param left
|
|
||||||
* @param right
|
|
||||||
*/
|
|
||||||
angleBetween(left: Vector2, right: Vector2): number;
|
|
||||||
/**
|
|
||||||
* 比较当前实例是否等于指定的对象
|
|
||||||
* @param other 要比较的对象
|
|
||||||
* @returns 如果实例相同true 否则false
|
|
||||||
*/
|
|
||||||
equals(other: Vector2 | object): boolean;
|
|
||||||
clone(): Vector2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module es {
|
declare module es {
|
||||||
/**
|
/**
|
||||||
* 移动器使用的帮助器类,用于管理触发器碰撞器交互并调用itriggerlistener
|
* 移动器使用的帮助器类,用于管理触发器碰撞器交互并调用itriggerlistener
|
||||||
|
|||||||
@@ -1,24 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __extends = (this && this.__extends) || (function () {
|
|
||||||
var extendStatics = Object.setPrototypeOf ||
|
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
||||||
return function (d, b) {
|
|
||||||
extendStatics(d, b);
|
|
||||||
function __() { this.constructor = d; }
|
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
var __values = (this && this.__values) || function (o) {
|
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
||||||
if (m) return m.call(o);
|
|
||||||
return {
|
|
||||||
next: function () {
|
|
||||||
if (o && i >= o.length) o = void 0;
|
|
||||||
return { value: o && o[i++], done: !o };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
var __read = (this && this.__read) || function (o, n) {
|
var __read = (this && this.__read) || function (o, n) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||||
if (!m) return o;
|
if (!m) return o;
|
||||||
@@ -39,6 +19,26 @@ var __spread = (this && this.__spread) || function () {
|
|||||||
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
||||||
return ar;
|
return ar;
|
||||||
};
|
};
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
var __values = (this && this.__values) || function (o) {
|
||||||
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
if (m) return m.call(o);
|
||||||
|
return {
|
||||||
|
next: function () {
|
||||||
|
if (o && i >= o.length) o = void 0;
|
||||||
|
return { value: o && o[i++], done: !o };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
var es;
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
/**
|
/**
|
||||||
@@ -96,10 +96,11 @@ var es;
|
|||||||
for (var _i = 1; _i < arguments.length; _i++) {
|
for (var _i = 1; _i < arguments.length; _i++) {
|
||||||
data[_i - 1] = arguments[_i];
|
data[_i - 1] = arguments[_i];
|
||||||
}
|
}
|
||||||
|
var _a;
|
||||||
var list = this._messageTable.get(eventType);
|
var list = this._messageTable.get(eventType);
|
||||||
if (list) {
|
if (list) {
|
||||||
for (var i = list.length - 1; i >= 0; i--)
|
for (var i = list.length - 1; i >= 0; i--)
|
||||||
list[i].func.call(list[i].context, data);
|
(_a = list[i].func).call.apply(_a, __spread([list[i].context], data));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Emitter;
|
return Emitter;
|
||||||
@@ -379,6 +380,7 @@ var es;
|
|||||||
CoreEvents[CoreEvents["resolutionScale"] = 8] = "resolutionScale";
|
CoreEvents[CoreEvents["resolutionScale"] = 8] = "resolutionScale";
|
||||||
CoreEvents[CoreEvents["resolutionOffset"] = 9] = "resolutionOffset";
|
CoreEvents[CoreEvents["resolutionOffset"] = 9] = "resolutionOffset";
|
||||||
CoreEvents[CoreEvents["createRenderTarget"] = 10] = "createRenderTarget";
|
CoreEvents[CoreEvents["createRenderTarget"] = 10] = "createRenderTarget";
|
||||||
|
CoreEvents[CoreEvents["createCamera"] = 11] = "createCamera";
|
||||||
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
@@ -839,6 +841,271 @@ var es;
|
|||||||
es.Entity = Entity;
|
es.Entity = Entity;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
|
(function (es) {
|
||||||
|
/** 2d 向量 */
|
||||||
|
var Vector2 = /** @class */ (function () {
|
||||||
|
/**
|
||||||
|
* 从两个值构造一个带有X和Y的二维向量。
|
||||||
|
* @param x 二维空间中的x坐标
|
||||||
|
* @param y 二维空间的y坐标
|
||||||
|
*/
|
||||||
|
function Vector2(x, y) {
|
||||||
|
this.x = 0;
|
||||||
|
this.y = 0;
|
||||||
|
this.x = x ? x : 0;
|
||||||
|
this.y = y != undefined ? y : this.x;
|
||||||
|
}
|
||||||
|
Object.defineProperty(Vector2, "zero", {
|
||||||
|
get: function () {
|
||||||
|
return new Vector2(0, 0);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Vector2, "one", {
|
||||||
|
get: function () {
|
||||||
|
return new Vector2(1, 1);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Vector2, "unitX", {
|
||||||
|
get: function () {
|
||||||
|
return new Vector2(1, 0);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Vector2, "unitY", {
|
||||||
|
get: function () {
|
||||||
|
return new Vector2(0, 1);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.add = function (value1, value2) {
|
||||||
|
var result = Vector2.zero;
|
||||||
|
result.x = value1.x + value2.x;
|
||||||
|
result.y = value1.y + value2.y;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.divide = function (value1, value2) {
|
||||||
|
var result = Vector2.zero;
|
||||||
|
result.x = value1.x / value2.x;
|
||||||
|
result.y = value1.y / value2.y;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.multiply = function (value1, value2) {
|
||||||
|
var result = new Vector2(0, 0);
|
||||||
|
result.x = value1.x * value2.x;
|
||||||
|
result.y = value1.y * value2.y;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.subtract = function (value1, value2) {
|
||||||
|
var result = new Vector2(0, 0);
|
||||||
|
result.x = value1.x - value2.x;
|
||||||
|
result.y = value1.y - value2.y;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2
|
||||||
|
* 它包含来自另一个向量的标准化值。
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
Vector2.normalize = function (value) {
|
||||||
|
var nValue = new Vector2(value.x, value.y);
|
||||||
|
var val = 1 / Math.sqrt((nValue.x * nValue.x) + (nValue.y * nValue.y));
|
||||||
|
nValue.x *= val;
|
||||||
|
nValue.y *= val;
|
||||||
|
return nValue;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回两个向量的点积
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.dot = function (value1, value2) {
|
||||||
|
return (value1.x * value2.x) + (value1.y * value2.y);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间距离的平方
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
*/
|
||||||
|
Vector2.distanceSquared = function (value1, value2) {
|
||||||
|
var v1 = value1.x - value2.x, v2 = value1.y - value2.y;
|
||||||
|
return (v1 * v1) + (v2 * v2);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 将指定的值限制在一个范围内
|
||||||
|
* @param value1
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
*/
|
||||||
|
Vector2.clamp = function (value1, min, max) {
|
||||||
|
return new Vector2(es.MathHelper.clamp(value1.x, min.x, max.x), es.MathHelper.clamp(value1.y, min.y, max.y));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2,其中包含指定向量的线性插值
|
||||||
|
* @param value1 第一个向量
|
||||||
|
* @param value2 第二个向量
|
||||||
|
* @param amount 加权值(0.0-1.0之间)
|
||||||
|
* @returns 指定向量的线性插值结果
|
||||||
|
*/
|
||||||
|
Vector2.lerp = function (value1, value2, amount) {
|
||||||
|
return new Vector2(es.MathHelper.lerp(value1.x, value2.x, amount), es.MathHelper.lerp(value1.y, value2.y, amount));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 创建一个新的Vector2,该Vector2包含了通过指定的Matrix进行的二维向量变换。
|
||||||
|
* @param position
|
||||||
|
* @param matrix
|
||||||
|
*/
|
||||||
|
Vector2.transform = function (position, matrix) {
|
||||||
|
return new Vector2((position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31, (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间的距离
|
||||||
|
* @param value1
|
||||||
|
* @param value2
|
||||||
|
* @returns 两个向量之间的距离
|
||||||
|
*/
|
||||||
|
Vector2.distance = function (value1, value2) {
|
||||||
|
var v1 = value1.x - value2.x, v2 = value1.y - value2.y;
|
||||||
|
return Math.sqrt((v1 * v1) + (v2 * v2));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回两个向量之间的角度,单位是度数
|
||||||
|
* @param from
|
||||||
|
* @param to
|
||||||
|
*/
|
||||||
|
Vector2.angle = function (from, to) {
|
||||||
|
from = Vector2.normalize(from);
|
||||||
|
to = Vector2.normalize(to);
|
||||||
|
return Math.acos(es.MathHelper.clamp(Vector2.dot(from, to), -1, 1)) * es.MathHelper.Rad2Deg;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 创建一个包含指定向量反转的新Vector2
|
||||||
|
* @param value
|
||||||
|
* @returns 矢量反演的结果
|
||||||
|
*/
|
||||||
|
Vector2.negate = function (value) {
|
||||||
|
value.x = -value.x;
|
||||||
|
value.y = -value.y;
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
Vector2.prototype.add = function (value) {
|
||||||
|
this.x += value.x;
|
||||||
|
this.y += value.y;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
Vector2.prototype.divide = function (value) {
|
||||||
|
this.x /= value.x;
|
||||||
|
this.y /= value.y;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
Vector2.prototype.multiply = function (value) {
|
||||||
|
this.x *= value.x;
|
||||||
|
this.y *= value.y;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 从当前Vector2减去一个Vector2
|
||||||
|
* @param value 要减去的Vector2
|
||||||
|
* @returns 当前Vector2
|
||||||
|
*/
|
||||||
|
Vector2.prototype.subtract = function (value) {
|
||||||
|
this.x -= value.x;
|
||||||
|
this.y -= value.y;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 将这个Vector2变成一个方向相同的单位向量
|
||||||
|
*/
|
||||||
|
Vector2.prototype.normalize = function () {
|
||||||
|
var val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||||
|
this.x *= val;
|
||||||
|
this.y *= val;
|
||||||
|
};
|
||||||
|
/** 返回它的长度 */
|
||||||
|
Vector2.prototype.length = function () {
|
||||||
|
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回该Vector2的平方长度
|
||||||
|
* @returns 这个Vector2的平方长度
|
||||||
|
*/
|
||||||
|
Vector2.prototype.lengthSquared = function () {
|
||||||
|
return (this.x * this.x) + (this.y * this.y);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 四舍五入X和Y值
|
||||||
|
*/
|
||||||
|
Vector2.prototype.round = function () {
|
||||||
|
return new Vector2(Math.round(this.x), Math.round(this.y));
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 返回以自己为中心点的左右角,单位为度
|
||||||
|
* @param left
|
||||||
|
* @param right
|
||||||
|
*/
|
||||||
|
Vector2.prototype.angleBetween = function (left, right) {
|
||||||
|
var one = Vector2.subtract(left, this);
|
||||||
|
var two = Vector2.subtract(right, this);
|
||||||
|
return es.Vector2Ext.angle(one, two);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 比较当前实例是否等于指定的对象
|
||||||
|
* @param other 要比较的对象
|
||||||
|
* @returns 如果实例相同true 否则false
|
||||||
|
*/
|
||||||
|
Vector2.prototype.equals = function (other) {
|
||||||
|
if (other instanceof Vector2) {
|
||||||
|
return other.x == this.x && other.y == this.y;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
Vector2.prototype.clone = function () {
|
||||||
|
return new Vector2(this.x, this.y);
|
||||||
|
};
|
||||||
|
return Vector2;
|
||||||
|
}());
|
||||||
|
es.Vector2 = Vector2;
|
||||||
|
})(es || (es = {}));
|
||||||
|
///<reference path="../Math/Vector2.ts" />
|
||||||
|
var es;
|
||||||
|
///<reference path="../Math/Vector2.ts" />
|
||||||
(function (es) {
|
(function (es) {
|
||||||
var SceneResolutionPolicy;
|
var SceneResolutionPolicy;
|
||||||
(function (SceneResolutionPolicy) {
|
(function (SceneResolutionPolicy) {
|
||||||
@@ -858,12 +1125,24 @@ var es;
|
|||||||
* 如果ResolutionPolicy是完美的像素,这将被设置为为它计算的比例
|
* 如果ResolutionPolicy是完美的像素,这将被设置为为它计算的比例
|
||||||
*/
|
*/
|
||||||
this.pixelPerfectScale = 1;
|
this.pixelPerfectScale = 1;
|
||||||
|
/**
|
||||||
|
* 场景使用的设计分辨率大小
|
||||||
|
*/
|
||||||
|
this._designResolutionSize = es.Vector2.zero;
|
||||||
|
this._designBleedSize = es.Vector2.zero;
|
||||||
|
/**
|
||||||
|
* 这将根据分辨率策略进行设置,并用于RenderTarget的最终输出
|
||||||
|
*/
|
||||||
|
this._finalRenderDestinationRect = es.Rectangle.empty;
|
||||||
|
this._sceneRenderTarget = new es.Ref(null);
|
||||||
|
this._destinationRenderTarget = new es.Ref(null);
|
||||||
this._sceneComponents = [];
|
this._sceneComponents = [];
|
||||||
this._renderers = [];
|
this._renderers = [];
|
||||||
this._afterPostProcessorRenderers = [];
|
this._afterPostProcessorRenderers = [];
|
||||||
this.entities = new es.EntityList(this);
|
this.entities = new es.EntityList(this);
|
||||||
this.renderableComponents = new es.RenderableComponentList();
|
this.renderableComponents = new es.RenderableComponentList();
|
||||||
this.entityProcessors = new es.EntityProcessorList();
|
this.entityProcessors = new es.EntityProcessorList();
|
||||||
|
es.Framework.emitter.emit(es.CoreEvents.createCamera, this);
|
||||||
this._resolutionPolicy = Scene._defaultSceneResolutionPolicy;
|
this._resolutionPolicy = Scene._defaultSceneResolutionPolicy;
|
||||||
this._designResolutionSize = Scene._defaultDesignResolutionSize;
|
this._designResolutionSize = Scene._defaultDesignResolutionSize;
|
||||||
this._designBleedSize = Scene._defaultDesignBleedSize;
|
this._designBleedSize = Scene._defaultDesignBleedSize;
|
||||||
@@ -1289,6 +1568,11 @@ var es;
|
|||||||
Scene.prototype.getEntityProcessor = function () {
|
Scene.prototype.getEntityProcessor = function () {
|
||||||
return this.entityProcessors.getProcessor();
|
return this.entityProcessors.getProcessor();
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 所有场景的默认分辨率大小
|
||||||
|
*/
|
||||||
|
Scene._defaultDesignResolutionSize = es.Vector2.zero;
|
||||||
|
Scene._defaultDesignBleedSize = es.Vector2.zero;
|
||||||
/**
|
/**
|
||||||
* 用于所有场景的默认分辨率策略
|
* 用于所有场景的默认分辨率策略
|
||||||
*/
|
*/
|
||||||
@@ -6075,269 +6359,6 @@ var es;
|
|||||||
es.SubpixelVector2 = SubpixelVector2;
|
es.SubpixelVector2 = SubpixelVector2;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
(function (es) {
|
|
||||||
/** 2d 向量 */
|
|
||||||
var Vector2 = /** @class */ (function () {
|
|
||||||
/**
|
|
||||||
* 从两个值构造一个带有X和Y的二维向量。
|
|
||||||
* @param x 二维空间中的x坐标
|
|
||||||
* @param y 二维空间的y坐标
|
|
||||||
*/
|
|
||||||
function Vector2(x, y) {
|
|
||||||
this.x = 0;
|
|
||||||
this.y = 0;
|
|
||||||
this.x = x ? x : 0;
|
|
||||||
this.y = y != undefined ? y : this.x;
|
|
||||||
}
|
|
||||||
Object.defineProperty(Vector2, "zero", {
|
|
||||||
get: function () {
|
|
||||||
return new Vector2(0, 0);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Vector2, "one", {
|
|
||||||
get: function () {
|
|
||||||
return new Vector2(1, 1);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Vector2, "unitX", {
|
|
||||||
get: function () {
|
|
||||||
return new Vector2(1, 0);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(Vector2, "unitY", {
|
|
||||||
get: function () {
|
|
||||||
return new Vector2(0, 1);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.add = function (value1, value2) {
|
|
||||||
var result = Vector2.zero;
|
|
||||||
result.x = value1.x + value2.x;
|
|
||||||
result.y = value1.y + value2.y;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.divide = function (value1, value2) {
|
|
||||||
var result = Vector2.zero;
|
|
||||||
result.x = value1.x / value2.x;
|
|
||||||
result.y = value1.y / value2.y;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.multiply = function (value1, value2) {
|
|
||||||
var result = new Vector2(0, 0);
|
|
||||||
result.x = value1.x * value2.x;
|
|
||||||
result.y = value1.y * value2.y;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.subtract = function (value1, value2) {
|
|
||||||
var result = new Vector2(0, 0);
|
|
||||||
result.x = value1.x - value2.x;
|
|
||||||
result.y = value1.y - value2.y;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2
|
|
||||||
* 它包含来自另一个向量的标准化值。
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
Vector2.normalize = function (value) {
|
|
||||||
var nValue = new Vector2(value.x, value.y);
|
|
||||||
var val = 1 / Math.sqrt((nValue.x * nValue.x) + (nValue.y * nValue.y));
|
|
||||||
nValue.x *= val;
|
|
||||||
nValue.y *= val;
|
|
||||||
return nValue;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回两个向量的点积
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.dot = function (value1, value2) {
|
|
||||||
return (value1.x * value2.x) + (value1.y * value2.y);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间距离的平方
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
*/
|
|
||||||
Vector2.distanceSquared = function (value1, value2) {
|
|
||||||
var v1 = value1.x - value2.x, v2 = value1.y - value2.y;
|
|
||||||
return (v1 * v1) + (v2 * v2);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 将指定的值限制在一个范围内
|
|
||||||
* @param value1
|
|
||||||
* @param min
|
|
||||||
* @param max
|
|
||||||
*/
|
|
||||||
Vector2.clamp = function (value1, min, max) {
|
|
||||||
return new Vector2(es.MathHelper.clamp(value1.x, min.x, max.x), es.MathHelper.clamp(value1.y, min.y, max.y));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2,其中包含指定向量的线性插值
|
|
||||||
* @param value1 第一个向量
|
|
||||||
* @param value2 第二个向量
|
|
||||||
* @param amount 加权值(0.0-1.0之间)
|
|
||||||
* @returns 指定向量的线性插值结果
|
|
||||||
*/
|
|
||||||
Vector2.lerp = function (value1, value2, amount) {
|
|
||||||
return new Vector2(es.MathHelper.lerp(value1.x, value2.x, amount), es.MathHelper.lerp(value1.y, value2.y, amount));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 创建一个新的Vector2,该Vector2包含了通过指定的Matrix进行的二维向量变换。
|
|
||||||
* @param position
|
|
||||||
* @param matrix
|
|
||||||
*/
|
|
||||||
Vector2.transform = function (position, matrix) {
|
|
||||||
return new Vector2((position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31, (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间的距离
|
|
||||||
* @param value1
|
|
||||||
* @param value2
|
|
||||||
* @returns 两个向量之间的距离
|
|
||||||
*/
|
|
||||||
Vector2.distance = function (value1, value2) {
|
|
||||||
var v1 = value1.x - value2.x, v2 = value1.y - value2.y;
|
|
||||||
return Math.sqrt((v1 * v1) + (v2 * v2));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回两个向量之间的角度,单位是度数
|
|
||||||
* @param from
|
|
||||||
* @param to
|
|
||||||
*/
|
|
||||||
Vector2.angle = function (from, to) {
|
|
||||||
from = Vector2.normalize(from);
|
|
||||||
to = Vector2.normalize(to);
|
|
||||||
return Math.acos(es.MathHelper.clamp(Vector2.dot(from, to), -1, 1)) * es.MathHelper.Rad2Deg;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 创建一个包含指定向量反转的新Vector2
|
|
||||||
* @param value
|
|
||||||
* @returns 矢量反演的结果
|
|
||||||
*/
|
|
||||||
Vector2.negate = function (value) {
|
|
||||||
value.x = -value.x;
|
|
||||||
value.y = -value.y;
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
Vector2.prototype.add = function (value) {
|
|
||||||
this.x += value.x;
|
|
||||||
this.y += value.y;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
Vector2.prototype.divide = function (value) {
|
|
||||||
this.x /= value.x;
|
|
||||||
this.y /= value.y;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
Vector2.prototype.multiply = function (value) {
|
|
||||||
this.x *= value.x;
|
|
||||||
this.y *= value.y;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 从当前Vector2减去一个Vector2
|
|
||||||
* @param value 要减去的Vector2
|
|
||||||
* @returns 当前Vector2
|
|
||||||
*/
|
|
||||||
Vector2.prototype.subtract = function (value) {
|
|
||||||
this.x -= value.x;
|
|
||||||
this.y -= value.y;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 将这个Vector2变成一个方向相同的单位向量
|
|
||||||
*/
|
|
||||||
Vector2.prototype.normalize = function () {
|
|
||||||
var val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y));
|
|
||||||
this.x *= val;
|
|
||||||
this.y *= val;
|
|
||||||
};
|
|
||||||
/** 返回它的长度 */
|
|
||||||
Vector2.prototype.length = function () {
|
|
||||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回该Vector2的平方长度
|
|
||||||
* @returns 这个Vector2的平方长度
|
|
||||||
*/
|
|
||||||
Vector2.prototype.lengthSquared = function () {
|
|
||||||
return (this.x * this.x) + (this.y * this.y);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 四舍五入X和Y值
|
|
||||||
*/
|
|
||||||
Vector2.prototype.round = function () {
|
|
||||||
return new Vector2(Math.round(this.x), Math.round(this.y));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 返回以自己为中心点的左右角,单位为度
|
|
||||||
* @param left
|
|
||||||
* @param right
|
|
||||||
*/
|
|
||||||
Vector2.prototype.angleBetween = function (left, right) {
|
|
||||||
var one = Vector2.subtract(left, this);
|
|
||||||
var two = Vector2.subtract(right, this);
|
|
||||||
return es.Vector2Ext.angle(one, two);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 比较当前实例是否等于指定的对象
|
|
||||||
* @param other 要比较的对象
|
|
||||||
* @returns 如果实例相同true 否则false
|
|
||||||
*/
|
|
||||||
Vector2.prototype.equals = function (other) {
|
|
||||||
if (other instanceof Vector2) {
|
|
||||||
return other.x == this.x && other.y == this.y;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
Vector2.prototype.clone = function () {
|
|
||||||
return new Vector2(this.x, this.y);
|
|
||||||
};
|
|
||||||
return Vector2;
|
|
||||||
}());
|
|
||||||
es.Vector2 = Vector2;
|
|
||||||
})(es || (es = {}));
|
|
||||||
var es;
|
|
||||||
(function (es) {
|
(function (es) {
|
||||||
/**
|
/**
|
||||||
* 移动器使用的帮助器类,用于管理触发器碰撞器交互并调用itriggerlistener
|
* 移动器使用的帮助器类,用于管理触发器碰撞器交互并调用itriggerlistener
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -23,5 +23,6 @@ module es {
|
|||||||
resolutionScale,
|
resolutionScale,
|
||||||
resolutionOffset,
|
resolutionOffset,
|
||||||
createRenderTarget,
|
createRenderTarget,
|
||||||
|
createCamera,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
///<reference path="../Math/Vector2.ts" />
|
||||||
module es {
|
module es {
|
||||||
export enum SceneResolutionPolicy {
|
export enum SceneResolutionPolicy {
|
||||||
/**
|
/**
|
||||||
@@ -52,8 +53,8 @@ module es {
|
|||||||
/**
|
/**
|
||||||
* 所有场景的默认分辨率大小
|
* 所有场景的默认分辨率大小
|
||||||
*/
|
*/
|
||||||
private static _defaultDesignResolutionSize: Vector2;
|
private static _defaultDesignResolutionSize: Vector2 = Vector2.zero;
|
||||||
private static _defaultDesignBleedSize: Vector2;
|
private static _defaultDesignBleedSize: Vector2 = Vector2.zero;
|
||||||
/**
|
/**
|
||||||
* 用于所有场景的默认分辨率策略
|
* 用于所有场景的默认分辨率策略
|
||||||
*/
|
*/
|
||||||
@@ -65,15 +66,15 @@ module es {
|
|||||||
/**
|
/**
|
||||||
* 场景使用的设计分辨率大小
|
* 场景使用的设计分辨率大小
|
||||||
*/
|
*/
|
||||||
private _designResolutionSize: Vector2;
|
private _designResolutionSize: Vector2 = Vector2.zero;
|
||||||
private _designBleedSize: Vector2;
|
private _designBleedSize: Vector2 = Vector2.zero;
|
||||||
/**
|
/**
|
||||||
* 这将根据分辨率策略进行设置,并用于RenderTarget的最终输出
|
* 这将根据分辨率策略进行设置,并用于RenderTarget的最终输出
|
||||||
*/
|
*/
|
||||||
private _finalRenderDestinationRect: Rectangle;
|
private _finalRenderDestinationRect: Rectangle = Rectangle.empty;
|
||||||
|
|
||||||
private _sceneRenderTarget: Ref<any>;
|
private _sceneRenderTarget: Ref<any> = new Ref(null);
|
||||||
private _destinationRenderTarget: Ref<any>;
|
private _destinationRenderTarget: Ref<any> = new Ref(null);
|
||||||
private _screenshotRequestCallback: (texture) => void;
|
private _screenshotRequestCallback: (texture) => void;
|
||||||
|
|
||||||
public readonly _sceneComponents: SceneComponent[] = [];
|
public readonly _sceneComponents: SceneComponent[] = [];
|
||||||
@@ -103,6 +104,8 @@ module es {
|
|||||||
this.renderableComponents = new RenderableComponentList();
|
this.renderableComponents = new RenderableComponentList();
|
||||||
this.entityProcessors = new EntityProcessorList();
|
this.entityProcessors = new EntityProcessorList();
|
||||||
|
|
||||||
|
Framework.emitter.emit(CoreEvents.createCamera, this);
|
||||||
|
|
||||||
this._resolutionPolicy = Scene._defaultSceneResolutionPolicy;
|
this._resolutionPolicy = Scene._defaultSceneResolutionPolicy;
|
||||||
this._designResolutionSize = Scene._defaultDesignResolutionSize;
|
this._designResolutionSize = Scene._defaultDesignResolutionSize;
|
||||||
this._designBleedSize = Scene._defaultDesignBleedSize;
|
this._designBleedSize = Scene._defaultDesignBleedSize;
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ module transform {
|
|||||||
|
|
||||||
module es {
|
module es {
|
||||||
export enum DirtyType {
|
export enum DirtyType {
|
||||||
clean,
|
clean = 0,
|
||||||
positionDirty,
|
positionDirty = 1,
|
||||||
scaleDirty,
|
scaleDirty = 2,
|
||||||
rotationDirty,
|
rotationDirty = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Transform {
|
export class Transform {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ module es {
|
|||||||
let list: FuncPack[] = this._messageTable.get(eventType);
|
let list: FuncPack[] = this._messageTable.get(eventType);
|
||||||
if (list) {
|
if (list) {
|
||||||
for (let i = list.length - 1; i >= 0; i--)
|
for (let i = list.length - 1; i >= 0; i--)
|
||||||
list[i].func.call(list[i].context, data);
|
list[i].func.call(list[i].context, ...data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user