modern-canvas 0.7.14 → 0.7.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +51 -46
- package/dist/index.d.cts +13 -12
- package/dist/index.d.mts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +15 -15
- package/dist/index.mjs +51 -46
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1746,7 +1746,7 @@ class Matrix3 extends Matrix {
|
|
|
1746
1746
|
constructor(array) {
|
|
1747
1747
|
super(3, 3, array);
|
|
1748
1748
|
}
|
|
1749
|
-
|
|
1749
|
+
affineInvert() {
|
|
1750
1750
|
const [
|
|
1751
1751
|
n11,
|
|
1752
1752
|
n21,
|
|
@@ -2198,10 +2198,10 @@ class Transform2D extends Matrix3 {
|
|
|
2198
2198
|
newPos.y = b * x + d * y + ty;
|
|
2199
2199
|
return newPos;
|
|
2200
2200
|
}
|
|
2201
|
-
|
|
2202
|
-
return this.clone().
|
|
2201
|
+
affineInverse() {
|
|
2202
|
+
return this.clone().affineInvert();
|
|
2203
2203
|
}
|
|
2204
|
-
|
|
2204
|
+
applyAffineInverse(pos, newPos) {
|
|
2205
2205
|
newPos = newPos || new Vector2();
|
|
2206
2206
|
const { a, b, c, d, tx, ty } = this.toObject();
|
|
2207
2207
|
const id = 1 / (a * d + c * -b);
|
|
@@ -2580,7 +2580,7 @@ attribute vec4 aBackgroundColor;
|
|
|
2580
2580
|
attribute vec4 aDisableWrapMode;
|
|
2581
2581
|
|
|
2582
2582
|
uniform mat3 projectionMatrix;
|
|
2583
|
-
uniform mat3
|
|
2583
|
+
uniform mat3 viewMatrix;
|
|
2584
2584
|
uniform vec4 modulate;
|
|
2585
2585
|
|
|
2586
2586
|
varying float vTextureId;
|
|
@@ -2596,7 +2596,7 @@ void main(void) {
|
|
|
2596
2596
|
0.0, 0.0, 1.0
|
|
2597
2597
|
);
|
|
2598
2598
|
vTextureId = aTextureId;
|
|
2599
|
-
mat3 modelViewProjectionMatrix = projectionMatrix *
|
|
2599
|
+
mat3 modelViewProjectionMatrix = projectionMatrix * viewMatrix * modelMatrix;
|
|
2600
2600
|
gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
2601
2601
|
vUv = aUv;
|
|
2602
2602
|
vModulate = aModulate * modulate;
|
|
@@ -3327,7 +3327,7 @@ class WebGLProgramModule extends WebGLModule {
|
|
|
3327
3327
|
boundProgram = null;
|
|
3328
3328
|
uniforms = {
|
|
3329
3329
|
projectionMatrix: [1, 0, 0, 0, 1, 0, 0, 0, 1],
|
|
3330
|
-
|
|
3330
|
+
viewMatrix: [1, 0, 0, 0, 1, 0, 0, 0, 1]
|
|
3331
3331
|
};
|
|
3332
3332
|
create(options) {
|
|
3333
3333
|
const program = this.gl.createProgram();
|
|
@@ -3531,7 +3531,7 @@ ${gl.getShaderInfoLog(shader)}`);
|
|
|
3531
3531
|
this.boundProgram = null;
|
|
3532
3532
|
this.uniforms = {
|
|
3533
3533
|
projectionMatrix: [1, 0, 0, 0, 1, 0, 0, 0, 1],
|
|
3534
|
-
|
|
3534
|
+
viewMatrix: [1, 0, 0, 0, 1, 0, 0, 0, 1]
|
|
3535
3535
|
};
|
|
3536
3536
|
}
|
|
3537
3537
|
free() {
|
|
@@ -3625,8 +3625,8 @@ class WebGLScissorModule extends WebGLModule {
|
|
|
3625
3625
|
use() {
|
|
3626
3626
|
const renderer = this._renderer;
|
|
3627
3627
|
const { pixelRatio, mask, viewport, screen, gl, program } = renderer;
|
|
3628
|
-
const {
|
|
3629
|
-
const rect = transformRectToAABB(
|
|
3628
|
+
const { viewMatrix } = program.uniforms;
|
|
3629
|
+
const rect = transformRectToAABB(viewMatrix, mask.last.mask);
|
|
3630
3630
|
const { x, y, width, height } = rect;
|
|
3631
3631
|
let scissorY;
|
|
3632
3632
|
if (viewport.boundViewport) {
|
|
@@ -6565,7 +6565,7 @@ exports.Viewport = class Viewport extends exports.Node {
|
|
|
6565
6565
|
this.projection.flipY(flipY);
|
|
6566
6566
|
}
|
|
6567
6567
|
projection = new Projection2D();
|
|
6568
|
-
|
|
6568
|
+
canvasTransform = new Transform2D();
|
|
6569
6569
|
_framebufferIndex = 0;
|
|
6570
6570
|
_framebuffers = [
|
|
6571
6571
|
{ texture: new ViewportTexture(), needsUpload: false },
|
|
@@ -6680,7 +6680,7 @@ exports.Viewport = class Viewport extends exports.Node {
|
|
|
6680
6680
|
render(renderer, next) {
|
|
6681
6681
|
const oldViewport = this._tree?.getCurrentViewport();
|
|
6682
6682
|
renderer.program.uniforms.projectionMatrix = this.projection.toArray(true);
|
|
6683
|
-
renderer.program.uniforms.
|
|
6683
|
+
renderer.program.uniforms.viewMatrix = this.canvasTransform.toArray(true);
|
|
6684
6684
|
this.activate(renderer);
|
|
6685
6685
|
renderer.clear();
|
|
6686
6686
|
super.render(renderer, next);
|
|
@@ -6695,11 +6695,11 @@ exports.Viewport = class Viewport extends exports.Node {
|
|
|
6695
6695
|
getRect() {
|
|
6696
6696
|
return new Rect2(this.x, this.y, this.width, this.height);
|
|
6697
6697
|
}
|
|
6698
|
-
|
|
6699
|
-
return this.
|
|
6698
|
+
toCanvasGlobal(screenPos, newPos) {
|
|
6699
|
+
return this.canvasTransform.applyAffineInverse(screenPos, newPos);
|
|
6700
6700
|
}
|
|
6701
|
-
|
|
6702
|
-
return this.
|
|
6701
|
+
toCanvasScreen(globalPos, newPos) {
|
|
6702
|
+
return this.canvasTransform.apply(globalPos, newPos);
|
|
6703
6703
|
}
|
|
6704
6704
|
};
|
|
6705
6705
|
__decorateClass$P([
|
|
@@ -7237,35 +7237,28 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
|
|
|
7237
7237
|
getTransformOrigin() {
|
|
7238
7238
|
return new Vector2(0, 0);
|
|
7239
7239
|
}
|
|
7240
|
-
|
|
7240
|
+
updateTransform(cb) {
|
|
7241
7241
|
const origin = this.getTransformOrigin();
|
|
7242
|
-
const transform =
|
|
7243
|
-
transform.translate(-origin.x, -origin.y).scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).rotate(this.rotation);
|
|
7242
|
+
const transform = this.transform.identity().translate(-origin.x, -origin.y).scale(this.scale.x, this.scale.y).skew(this.skew.x, this.skew.y).rotate(this.rotation);
|
|
7244
7243
|
cb?.(transform);
|
|
7245
7244
|
transform.translate(this.position.x, this.position.y).translate(origin.x, origin.y);
|
|
7246
|
-
return transform;
|
|
7247
|
-
}
|
|
7248
|
-
updateTransform() {
|
|
7249
|
-
this.transform.copy(this.getTransform());
|
|
7250
7245
|
}
|
|
7251
7246
|
updateGlobalTransform() {
|
|
7252
7247
|
this.updateTransform();
|
|
7253
7248
|
const parent = this.getParent();
|
|
7254
7249
|
if (parent?.globalTransform) {
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
);
|
|
7264
|
-
this.
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
);
|
|
7268
|
-
this.globalRotation = parent.globalRotation + this.rotation;
|
|
7250
|
+
const {
|
|
7251
|
+
globalPosition,
|
|
7252
|
+
globalScale,
|
|
7253
|
+
globalSkew,
|
|
7254
|
+
globalTransform,
|
|
7255
|
+
globalRotation
|
|
7256
|
+
} = parent;
|
|
7257
|
+
this._parentTransformDirtyId = globalTransform.dirtyId;
|
|
7258
|
+
this.globalPosition.set(globalPosition.x + this.position.x, globalPosition.y + this.position.y);
|
|
7259
|
+
this.globalScale.set(globalScale.x * this.scale.x, globalScale.y * this.scale.y);
|
|
7260
|
+
this.globalSkew.set(globalSkew.x * this.skew.x, globalSkew.y * this.skew.y);
|
|
7261
|
+
this.globalRotation = globalRotation + this.rotation;
|
|
7269
7262
|
parent.globalTransform.multiply(this.transform, this.globalTransform);
|
|
7270
7263
|
} else {
|
|
7271
7264
|
this.globalPosition.copy(this.position);
|
|
@@ -7314,7 +7307,7 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
|
|
|
7314
7307
|
}
|
|
7315
7308
|
}
|
|
7316
7309
|
toLocal(globalPos, newPos) {
|
|
7317
|
-
return this.globalTransform.
|
|
7310
|
+
return this.globalTransform.applyAffineInverse(globalPos, newPos);
|
|
7318
7311
|
}
|
|
7319
7312
|
toGlobal(localPos, newPos) {
|
|
7320
7313
|
return this.globalTransform.apply(localPos, newPos);
|
|
@@ -7341,7 +7334,7 @@ var __decorateClass$I = (decorators, target, key, kind) => {
|
|
|
7341
7334
|
return result;
|
|
7342
7335
|
};
|
|
7343
7336
|
exports.Camera2D = class Camera2D extends exports.Node2D {
|
|
7344
|
-
zoom = new Vector2(1, 1).on("update", () => this.
|
|
7337
|
+
zoom = new Vector2(1, 1).on("update", () => this.updateCanvasTransform());
|
|
7345
7338
|
maxZoom = new Vector2(6, 6);
|
|
7346
7339
|
minZoom = new Vector2(0.1, 0.1);
|
|
7347
7340
|
_screenOffset = { x: 0, y: 0 };
|
|
@@ -7428,14 +7421,26 @@ exports.Camera2D = class Camera2D extends exports.Node2D {
|
|
|
7428
7421
|
}
|
|
7429
7422
|
updateTransform() {
|
|
7430
7423
|
super.updateTransform();
|
|
7431
|
-
this.
|
|
7424
|
+
this.updateCanvasTransform();
|
|
7432
7425
|
}
|
|
7433
|
-
|
|
7426
|
+
updateCanvasTransform() {
|
|
7434
7427
|
const viewport = this.getViewport();
|
|
7435
7428
|
if (!viewport)
|
|
7436
7429
|
return;
|
|
7437
|
-
viewport.
|
|
7438
|
-
this.emit("
|
|
7430
|
+
viewport.canvasTransform.identity().scale(this.zoom.x, this.zoom.y).translate(this.position.x, this.position.y);
|
|
7431
|
+
this.emit("updateCanvasTransform");
|
|
7432
|
+
}
|
|
7433
|
+
toGlobal(screenPos, newPos) {
|
|
7434
|
+
const viewport = this.getViewport();
|
|
7435
|
+
if (!viewport)
|
|
7436
|
+
throw new Error("Failed to toGlobal, viewport is empty");
|
|
7437
|
+
return viewport.toCanvasGlobal(screenPos, newPos);
|
|
7438
|
+
}
|
|
7439
|
+
toScreen(globalPos, newPos) {
|
|
7440
|
+
const viewport = this.getViewport();
|
|
7441
|
+
if (!viewport)
|
|
7442
|
+
throw new Error("Failed to toScreen, viewport is empty");
|
|
7443
|
+
return viewport.toCanvasScreen(globalPos, newPos);
|
|
7439
7444
|
}
|
|
7440
7445
|
};
|
|
7441
7446
|
__decorateClass$I([
|
|
@@ -10038,9 +10043,9 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
10038
10043
|
const [originX, originY] = parseCSSTransformOrigin(this.style.transformOrigin);
|
|
10039
10044
|
return new Vector2(originX * width, originY * height);
|
|
10040
10045
|
}
|
|
10041
|
-
|
|
10046
|
+
updateTransform(cb) {
|
|
10042
10047
|
const { width, height } = this.size;
|
|
10043
|
-
|
|
10048
|
+
super.updateTransform((transform) => {
|
|
10044
10049
|
parseCSSTransform(this.style.transform ?? "", width, height, transform);
|
|
10045
10050
|
cb?.(transform);
|
|
10046
10051
|
});
|
|
@@ -10229,7 +10234,7 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
10229
10234
|
const pos = new Vector2(screenX, screenY);
|
|
10230
10235
|
const viewport = this.getViewport();
|
|
10231
10236
|
if (viewport) {
|
|
10232
|
-
viewport.
|
|
10237
|
+
viewport.toCanvasGlobal(pos, pos);
|
|
10233
10238
|
}
|
|
10234
10239
|
this.toLocal(pos, pos);
|
|
10235
10240
|
if (this._positionInput(pos, key)) {
|
package/dist/index.d.cts
CHANGED
|
@@ -444,7 +444,7 @@ declare class Matrix2 extends Matrix {
|
|
|
444
444
|
*/
|
|
445
445
|
declare class Matrix3 extends Matrix {
|
|
446
446
|
constructor(array?: number[]);
|
|
447
|
-
|
|
447
|
+
affineInvert(): this;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
declare class Projection2D extends Matrix3 {
|
|
@@ -583,8 +583,8 @@ declare class Transform2D extends Matrix3 {
|
|
|
583
583
|
y: number;
|
|
584
584
|
}, output?: TransformableObject): TransformableObject;
|
|
585
585
|
apply<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
586
|
-
|
|
587
|
-
|
|
586
|
+
affineInverse(): this;
|
|
587
|
+
applyAffineInverse<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
588
588
|
isIdentity(): boolean;
|
|
589
589
|
toObject(): TransformObject;
|
|
590
590
|
}
|
|
@@ -1105,7 +1105,7 @@ declare class WebGLProgramModule extends WebGLModule {
|
|
|
1105
1105
|
boundProgram: WebGLProgram | null;
|
|
1106
1106
|
uniforms: {
|
|
1107
1107
|
projectionMatrix: number[];
|
|
1108
|
-
|
|
1108
|
+
viewMatrix: number[];
|
|
1109
1109
|
};
|
|
1110
1110
|
create(options?: WebGLProgramOptions): WebGLProgram;
|
|
1111
1111
|
getMeta(program: WebGLProgram): WebGLProgramMeta;
|
|
@@ -1532,7 +1532,7 @@ interface Viewport {
|
|
|
1532
1532
|
declare class Viewport extends Node implements Rectangulable {
|
|
1533
1533
|
flipY: boolean;
|
|
1534
1534
|
readonly projection: Projection2D;
|
|
1535
|
-
readonly
|
|
1535
|
+
readonly canvasTransform: Transform2D;
|
|
1536
1536
|
protected _framebufferIndex: number;
|
|
1537
1537
|
protected _framebuffers: ViewportFramebuffer[];
|
|
1538
1538
|
x: number;
|
|
@@ -1557,8 +1557,8 @@ declare class Viewport extends Node implements Rectangulable {
|
|
|
1557
1557
|
activateWithCopy(renderer: WebGLRenderer, target: Viewport): void;
|
|
1558
1558
|
render(renderer: WebGLRenderer, next?: () => void): void;
|
|
1559
1559
|
getRect(): Rect2;
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
toCanvasGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1561
|
+
toCanvasScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
1564
|
interface RenderCall {
|
|
@@ -1948,8 +1948,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1948
1948
|
constructor(properties?: Partial<Node2DProperties>, nodes?: Node[]);
|
|
1949
1949
|
protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1950
1950
|
getTransformOrigin(): Vector2;
|
|
1951
|
-
|
|
1952
|
-
updateTransform(): void;
|
|
1951
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
1953
1952
|
updateGlobalTransform(): void;
|
|
1954
1953
|
protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
|
|
1955
1954
|
protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
|
|
@@ -1961,7 +1960,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1961
1960
|
interface Camera2DProperties extends Node2DProperties {
|
|
1962
1961
|
}
|
|
1963
1962
|
interface Camera2DEventMap extends Node2DEventMap {
|
|
1964
|
-
|
|
1963
|
+
updateCanvasTransform: () => void;
|
|
1965
1964
|
}
|
|
1966
1965
|
interface Camera2D {
|
|
1967
1966
|
on: (<K extends keyof Camera2DEventMap>(type: K, listener: Camera2DEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
|
|
@@ -1985,7 +1984,9 @@ declare class Camera2D extends Node2D {
|
|
|
1985
1984
|
protected _input(event: InputEvent, key: InputEventKey): void;
|
|
1986
1985
|
protected _onWheel(e: WheelInputEvent): void;
|
|
1987
1986
|
updateTransform(): void;
|
|
1988
|
-
|
|
1987
|
+
updateCanvasTransform(): void;
|
|
1988
|
+
toGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1989
|
+
toScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1989
1990
|
}
|
|
1990
1991
|
|
|
1991
1992
|
interface BaseElement2DFill extends NormalizedFill {
|
|
@@ -2156,7 +2157,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2156
2157
|
protected _updateStyleProperty(key: string, value: any, _oldValue: any, _declaration?: PropertyDeclaration): void;
|
|
2157
2158
|
protected _updateMaskImage(): void;
|
|
2158
2159
|
getTransformOrigin(): Vector2;
|
|
2159
|
-
|
|
2160
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
2160
2161
|
updateGlobalTransform(): void;
|
|
2161
2162
|
getRect(): Rect2;
|
|
2162
2163
|
protected _getPointArray(): Vector2Data[];
|
package/dist/index.d.mts
CHANGED
|
@@ -444,7 +444,7 @@ declare class Matrix2 extends Matrix {
|
|
|
444
444
|
*/
|
|
445
445
|
declare class Matrix3 extends Matrix {
|
|
446
446
|
constructor(array?: number[]);
|
|
447
|
-
|
|
447
|
+
affineInvert(): this;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
declare class Projection2D extends Matrix3 {
|
|
@@ -583,8 +583,8 @@ declare class Transform2D extends Matrix3 {
|
|
|
583
583
|
y: number;
|
|
584
584
|
}, output?: TransformableObject): TransformableObject;
|
|
585
585
|
apply<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
586
|
-
|
|
587
|
-
|
|
586
|
+
affineInverse(): this;
|
|
587
|
+
applyAffineInverse<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
588
588
|
isIdentity(): boolean;
|
|
589
589
|
toObject(): TransformObject;
|
|
590
590
|
}
|
|
@@ -1105,7 +1105,7 @@ declare class WebGLProgramModule extends WebGLModule {
|
|
|
1105
1105
|
boundProgram: WebGLProgram | null;
|
|
1106
1106
|
uniforms: {
|
|
1107
1107
|
projectionMatrix: number[];
|
|
1108
|
-
|
|
1108
|
+
viewMatrix: number[];
|
|
1109
1109
|
};
|
|
1110
1110
|
create(options?: WebGLProgramOptions): WebGLProgram;
|
|
1111
1111
|
getMeta(program: WebGLProgram): WebGLProgramMeta;
|
|
@@ -1532,7 +1532,7 @@ interface Viewport {
|
|
|
1532
1532
|
declare class Viewport extends Node implements Rectangulable {
|
|
1533
1533
|
flipY: boolean;
|
|
1534
1534
|
readonly projection: Projection2D;
|
|
1535
|
-
readonly
|
|
1535
|
+
readonly canvasTransform: Transform2D;
|
|
1536
1536
|
protected _framebufferIndex: number;
|
|
1537
1537
|
protected _framebuffers: ViewportFramebuffer[];
|
|
1538
1538
|
x: number;
|
|
@@ -1557,8 +1557,8 @@ declare class Viewport extends Node implements Rectangulable {
|
|
|
1557
1557
|
activateWithCopy(renderer: WebGLRenderer, target: Viewport): void;
|
|
1558
1558
|
render(renderer: WebGLRenderer, next?: () => void): void;
|
|
1559
1559
|
getRect(): Rect2;
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
toCanvasGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1561
|
+
toCanvasScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
1564
|
interface RenderCall {
|
|
@@ -1948,8 +1948,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1948
1948
|
constructor(properties?: Partial<Node2DProperties>, nodes?: Node[]);
|
|
1949
1949
|
protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1950
1950
|
getTransformOrigin(): Vector2;
|
|
1951
|
-
|
|
1952
|
-
updateTransform(): void;
|
|
1951
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
1953
1952
|
updateGlobalTransform(): void;
|
|
1954
1953
|
protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
|
|
1955
1954
|
protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
|
|
@@ -1961,7 +1960,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1961
1960
|
interface Camera2DProperties extends Node2DProperties {
|
|
1962
1961
|
}
|
|
1963
1962
|
interface Camera2DEventMap extends Node2DEventMap {
|
|
1964
|
-
|
|
1963
|
+
updateCanvasTransform: () => void;
|
|
1965
1964
|
}
|
|
1966
1965
|
interface Camera2D {
|
|
1967
1966
|
on: (<K extends keyof Camera2DEventMap>(type: K, listener: Camera2DEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
|
|
@@ -1985,7 +1984,9 @@ declare class Camera2D extends Node2D {
|
|
|
1985
1984
|
protected _input(event: InputEvent, key: InputEventKey): void;
|
|
1986
1985
|
protected _onWheel(e: WheelInputEvent): void;
|
|
1987
1986
|
updateTransform(): void;
|
|
1988
|
-
|
|
1987
|
+
updateCanvasTransform(): void;
|
|
1988
|
+
toGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1989
|
+
toScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1989
1990
|
}
|
|
1990
1991
|
|
|
1991
1992
|
interface BaseElement2DFill extends NormalizedFill {
|
|
@@ -2156,7 +2157,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2156
2157
|
protected _updateStyleProperty(key: string, value: any, _oldValue: any, _declaration?: PropertyDeclaration): void;
|
|
2157
2158
|
protected _updateMaskImage(): void;
|
|
2158
2159
|
getTransformOrigin(): Vector2;
|
|
2159
|
-
|
|
2160
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
2160
2161
|
updateGlobalTransform(): void;
|
|
2161
2162
|
getRect(): Rect2;
|
|
2162
2163
|
protected _getPointArray(): Vector2Data[];
|
package/dist/index.d.ts
CHANGED
|
@@ -444,7 +444,7 @@ declare class Matrix2 extends Matrix {
|
|
|
444
444
|
*/
|
|
445
445
|
declare class Matrix3 extends Matrix {
|
|
446
446
|
constructor(array?: number[]);
|
|
447
|
-
|
|
447
|
+
affineInvert(): this;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
declare class Projection2D extends Matrix3 {
|
|
@@ -583,8 +583,8 @@ declare class Transform2D extends Matrix3 {
|
|
|
583
583
|
y: number;
|
|
584
584
|
}, output?: TransformableObject): TransformableObject;
|
|
585
585
|
apply<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
586
|
-
|
|
587
|
-
|
|
586
|
+
affineInverse(): this;
|
|
587
|
+
applyAffineInverse<P extends Vector2Data = Vector2>(pos: Vector2Data, newPos?: P): P;
|
|
588
588
|
isIdentity(): boolean;
|
|
589
589
|
toObject(): TransformObject;
|
|
590
590
|
}
|
|
@@ -1105,7 +1105,7 @@ declare class WebGLProgramModule extends WebGLModule {
|
|
|
1105
1105
|
boundProgram: WebGLProgram | null;
|
|
1106
1106
|
uniforms: {
|
|
1107
1107
|
projectionMatrix: number[];
|
|
1108
|
-
|
|
1108
|
+
viewMatrix: number[];
|
|
1109
1109
|
};
|
|
1110
1110
|
create(options?: WebGLProgramOptions): WebGLProgram;
|
|
1111
1111
|
getMeta(program: WebGLProgram): WebGLProgramMeta;
|
|
@@ -1532,7 +1532,7 @@ interface Viewport {
|
|
|
1532
1532
|
declare class Viewport extends Node implements Rectangulable {
|
|
1533
1533
|
flipY: boolean;
|
|
1534
1534
|
readonly projection: Projection2D;
|
|
1535
|
-
readonly
|
|
1535
|
+
readonly canvasTransform: Transform2D;
|
|
1536
1536
|
protected _framebufferIndex: number;
|
|
1537
1537
|
protected _framebuffers: ViewportFramebuffer[];
|
|
1538
1538
|
x: number;
|
|
@@ -1557,8 +1557,8 @@ declare class Viewport extends Node implements Rectangulable {
|
|
|
1557
1557
|
activateWithCopy(renderer: WebGLRenderer, target: Viewport): void;
|
|
1558
1558
|
render(renderer: WebGLRenderer, next?: () => void): void;
|
|
1559
1559
|
getRect(): Rect2;
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
toCanvasGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1561
|
+
toCanvasScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
1564
|
interface RenderCall {
|
|
@@ -1948,8 +1948,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1948
1948
|
constructor(properties?: Partial<Node2DProperties>, nodes?: Node[]);
|
|
1949
1949
|
protected _updateProperty(key: string, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
|
|
1950
1950
|
getTransformOrigin(): Vector2;
|
|
1951
|
-
|
|
1952
|
-
updateTransform(): void;
|
|
1951
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
1953
1952
|
updateGlobalTransform(): void;
|
|
1954
1953
|
protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
|
|
1955
1954
|
protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
|
|
@@ -1961,7 +1960,7 @@ declare class Node2D extends CanvasItem {
|
|
|
1961
1960
|
interface Camera2DProperties extends Node2DProperties {
|
|
1962
1961
|
}
|
|
1963
1962
|
interface Camera2DEventMap extends Node2DEventMap {
|
|
1964
|
-
|
|
1963
|
+
updateCanvasTransform: () => void;
|
|
1965
1964
|
}
|
|
1966
1965
|
interface Camera2D {
|
|
1967
1966
|
on: (<K extends keyof Camera2DEventMap>(type: K, listener: Camera2DEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
|
|
@@ -1985,7 +1984,9 @@ declare class Camera2D extends Node2D {
|
|
|
1985
1984
|
protected _input(event: InputEvent, key: InputEventKey): void;
|
|
1986
1985
|
protected _onWheel(e: WheelInputEvent): void;
|
|
1987
1986
|
updateTransform(): void;
|
|
1988
|
-
|
|
1987
|
+
updateCanvasTransform(): void;
|
|
1988
|
+
toGlobal<P extends Vector2Data = Vector2>(screenPos: Vector2Data, newPos?: P): P;
|
|
1989
|
+
toScreen<P extends Vector2Data = Vector2>(globalPos: Vector2Data, newPos?: P): P;
|
|
1989
1990
|
}
|
|
1990
1991
|
|
|
1991
1992
|
interface BaseElement2DFill extends NormalizedFill {
|
|
@@ -2156,7 +2157,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2156
2157
|
protected _updateStyleProperty(key: string, value: any, _oldValue: any, _declaration?: PropertyDeclaration): void;
|
|
2157
2158
|
protected _updateMaskImage(): void;
|
|
2158
2159
|
getTransformOrigin(): Vector2;
|
|
2159
|
-
|
|
2160
|
+
updateTransform(cb?: (transform: Transform2D) => void): void;
|
|
2160
2161
|
updateGlobalTransform(): void;
|
|
2161
2162
|
getRect(): Rect2;
|
|
2162
2163
|
protected _getPointArray(): Vector2Data[];
|