@vpmedia/phaser 1.105.0 → 1.107.0
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.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +238 -244
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +2 -2
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +2 -2
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +6 -6
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +2 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +3 -3
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +8 -8
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +8 -8
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +6 -6
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +3 -3
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +7 -7
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +16 -6
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +5 -5
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -3
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +7 -7
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +1 -1
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +3 -3
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +1 -1
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +5 -5
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +1 -1
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +1 -1
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -3
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +12 -11
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +2 -2
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +1 -1
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +12 -21
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +1 -1
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +3 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +8 -8
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +8 -7
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +5 -5
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +3 -2
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +4 -3
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +2 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +2 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +8 -4
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +1 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +3 -3
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +3 -3
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +2 -2
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +3 -3
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +3 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +1 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +15 -15
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +1 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +5 -5
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/index.ts +8 -0
- package/src/phaser/core/animation.ts +16 -8
- package/src/phaser/core/animation_manager.ts +11 -5
- package/src/phaser/core/cache.ts +9 -8
- package/src/phaser/core/device.ts +24 -24
- package/src/phaser/core/device_util.ts +4 -2
- package/src/phaser/core/dom.ts +2 -2
- package/src/phaser/core/factory.ts +3 -5
- package/src/phaser/core/game.ts +21 -34
- package/src/phaser/core/input.ts +9 -5
- package/src/phaser/core/input_handler.ts +22 -7
- package/src/phaser/core/input_mouse.ts +8 -84
- package/src/phaser/core/input_mspointer.ts +22 -18
- package/src/phaser/core/input_pointer.ts +48 -48
- package/src/phaser/core/input_touch.ts +7 -7
- package/src/phaser/core/loader.ts +46 -31
- package/src/phaser/core/loader_parser.ts +34 -8
- package/src/phaser/core/scale_manager.ts +5 -5
- package/src/phaser/core/scene.ts +5 -5
- package/src/phaser/core/signal.ts +15 -9
- package/src/phaser/core/signal_binding.ts +8 -1
- package/src/phaser/core/sound.ts +18 -21
- package/src/phaser/core/sound_manager.ts +3 -3
- package/src/phaser/core/sound_sprite.ts +7 -7
- package/src/phaser/core/stage.ts +6 -6
- package/src/phaser/core/time.ts +28 -28
- package/src/phaser/core/timer.ts +4 -4
- package/src/phaser/core/tween.ts +31 -9
- package/src/phaser/core/tween_data.ts +2 -2
- package/src/phaser/core/tween_manager.ts +7 -7
- package/src/phaser/display/bitmap_text.ts +6 -6
- package/src/phaser/display/button.ts +38 -19
- package/src/phaser/display/canvas/buffer.ts +4 -4
- package/src/phaser/display/canvas/renderer.ts +2 -2
- package/src/phaser/display/canvas/util.ts +21 -13
- package/src/phaser/display/display_object.ts +17 -31
- package/src/phaser/display/graphics.ts +9 -9
- package/src/phaser/display/graphics_data.ts +19 -11
- package/src/phaser/display/group.ts +8 -8
- package/src/phaser/display/image.ts +26 -20
- package/src/phaser/display/sprite_util.ts +16 -4
- package/src/phaser/display/text.ts +9 -9
- package/src/phaser/display/webgl/blend_manager.ts +2 -2
- package/src/phaser/display/webgl/earcut.ts +31 -6
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -17
- package/src/phaser/display/webgl/filter_manager.ts +3 -3
- package/src/phaser/display/webgl/filter_texture.ts +4 -4
- package/src/phaser/display/webgl/graphics.ts +11 -3
- package/src/phaser/display/webgl/graphics_data.ts +9 -9
- package/src/phaser/display/webgl/render_texture.ts +9 -3
- package/src/phaser/display/webgl/shader/complex.ts +5 -5
- package/src/phaser/display/webgl/shader/fast.ts +6 -6
- package/src/phaser/display/webgl/shader/normal.ts +11 -11
- package/src/phaser/display/webgl/shader/primitive.ts +5 -5
- package/src/phaser/display/webgl/shader/strip.ts +5 -5
- package/src/phaser/display/webgl/shader_manager.ts +12 -11
- package/src/phaser/display/webgl/sprite_batch.ts +18 -17
- package/src/phaser/display/webgl/stencil_manager.ts +18 -6
- package/src/phaser/display/webgl/texture.ts +6 -1
- package/src/phaser/display/webgl/util.ts +17 -4
- package/src/phaser/geom/circle.ts +1 -1
- package/src/phaser/geom/ellipse.ts +1 -1
- package/src/phaser/geom/line.ts +2 -2
- package/src/phaser/geom/matrix.ts +3 -3
- package/src/phaser/geom/polygon.ts +1 -1
- package/src/phaser/geom/rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +8 -3
- package/src/phaser/geom/util/line.ts +9 -2
- package/src/phaser/geom/util/matrix.ts +1 -1
- package/src/phaser/geom/util/point.ts +23 -16
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +13 -6
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
|
@@ -25,21 +25,21 @@ const defaultVertexSrc = [
|
|
|
25
25
|
|
|
26
26
|
export class NormalShader {
|
|
27
27
|
[key: string]: any;
|
|
28
|
-
gl!: any;
|
|
29
|
-
_UID!: any;
|
|
30
|
-
program!: any;
|
|
31
|
-
fragmentSrc!: any;
|
|
32
|
-
vertexSrc!: any;
|
|
33
|
-
textureCount!: any;
|
|
34
|
-
firstRun!: any;
|
|
35
|
-
dirty!: any;
|
|
36
|
-
uniforms!: any;
|
|
37
|
-
attributes!: any;
|
|
28
|
+
gl!: any;
|
|
29
|
+
_UID!: any;
|
|
30
|
+
program!: any;
|
|
31
|
+
fragmentSrc!: any;
|
|
32
|
+
vertexSrc!: any;
|
|
33
|
+
textureCount!: any;
|
|
34
|
+
firstRun!: any;
|
|
35
|
+
dirty!: any;
|
|
36
|
+
uniforms!: any;
|
|
37
|
+
attributes!: any;
|
|
38
38
|
/**
|
|
39
39
|
* Creates a new NormalShader instance.
|
|
40
40
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
41
41
|
*/
|
|
42
|
-
constructor(gl) {
|
|
42
|
+
constructor(gl: WebGLRenderingContext) {
|
|
43
43
|
this.gl = gl;
|
|
44
44
|
this._UID = uuidv4();
|
|
45
45
|
/** @type {WebGLProgram} */
|
|
@@ -5,11 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class PrimitiveShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
fragmentSrc!: any;
|
|
12
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new PrimitiveShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -5,11 +5,11 @@ import { compileProgram } from '../util.js';
|
|
|
5
5
|
|
|
6
6
|
export class StripShader {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
gl!: any;
|
|
9
|
-
_UID!: any;
|
|
10
|
-
program!: any;
|
|
11
|
-
fragmentSrc!: any;
|
|
12
|
-
vertexSrc!: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new StripShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
@@ -3,19 +3,20 @@ import { FastShader } from './shader/fast.js';
|
|
|
3
3
|
import { NormalShader } from './shader/normal.js';
|
|
4
4
|
import { PrimitiveShader } from './shader/primitive.js';
|
|
5
5
|
import { StripShader } from './shader/strip.js';
|
|
6
|
+
import type { IdentifiedWebGLRenderingContext } from './util.js';
|
|
6
7
|
|
|
7
8
|
export class WebGLShaderManager {
|
|
8
9
|
[key: string]: any;
|
|
9
|
-
gl!: any;
|
|
10
|
-
primitiveShader!: any;
|
|
11
|
-
complexPrimitiveShader!: any;
|
|
12
|
-
defaultShader!: any;
|
|
13
|
-
fastShader!: any;
|
|
14
|
-
stripShader!: any;
|
|
15
|
-
maxAttibs!: any;
|
|
16
|
-
attribState!: any;
|
|
17
|
-
tempAttribState!: any;
|
|
18
|
-
stack!: any;
|
|
10
|
+
gl!: any;
|
|
11
|
+
primitiveShader!: any;
|
|
12
|
+
complexPrimitiveShader!: any;
|
|
13
|
+
defaultShader!: any;
|
|
14
|
+
fastShader!: any;
|
|
15
|
+
stripShader!: any;
|
|
16
|
+
maxAttibs!: any;
|
|
17
|
+
attribState!: any;
|
|
18
|
+
tempAttribState!: any;
|
|
19
|
+
stack!: any;
|
|
19
20
|
/**
|
|
20
21
|
* Initializes the shader manager with a WebGL context.
|
|
21
22
|
*/
|
|
@@ -39,7 +40,7 @@ stack!: any;
|
|
|
39
40
|
* Initializes the shader manager with a WebGL context.
|
|
40
41
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
41
42
|
*/
|
|
42
|
-
setContext(gl) {
|
|
43
|
+
setContext(gl: IdentifiedWebGLRenderingContext) {
|
|
43
44
|
this.gl = gl;
|
|
44
45
|
this.primitiveShader = new PrimitiveShader(gl);
|
|
45
46
|
this.complexPrimitiveShader = new ComplexPrimitiveShader(gl);
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { AbstractFilter } from './abstract_filter.js';
|
|
2
2
|
import { NormalShader } from './shader/normal.js';
|
|
3
|
+
import type { IdentifiedWebGLRenderingContext } from './util.js';
|
|
3
4
|
|
|
4
5
|
export class WebGLSpriteBatch {
|
|
5
6
|
[key: string]: any;
|
|
6
|
-
vertSize!: any;
|
|
7
|
-
size!: any;
|
|
8
|
-
vertices!: any;
|
|
9
|
-
positions!: any;
|
|
10
|
-
colors!: any;
|
|
11
|
-
indices!: any;
|
|
12
|
-
lastIndexCount!: any;
|
|
13
|
-
drawing!: any;
|
|
14
|
-
currentBatchSize!: any;
|
|
15
|
-
currentBaseTexture!: any;
|
|
16
|
-
dirty!: any;
|
|
17
|
-
textures!: any;
|
|
18
|
-
blendModes!: any;
|
|
19
|
-
shaders!: any;
|
|
20
|
-
sprites!: any;
|
|
21
|
-
defaultShader!: any;
|
|
7
|
+
vertSize!: any;
|
|
8
|
+
size!: any;
|
|
9
|
+
vertices!: any;
|
|
10
|
+
positions!: any;
|
|
11
|
+
colors!: any;
|
|
12
|
+
indices!: any;
|
|
13
|
+
lastIndexCount!: any;
|
|
14
|
+
drawing!: any;
|
|
15
|
+
currentBatchSize!: any;
|
|
16
|
+
currentBaseTexture!: any;
|
|
17
|
+
dirty!: any;
|
|
18
|
+
textures!: any;
|
|
19
|
+
blendModes!: any;
|
|
20
|
+
shaders!: any;
|
|
21
|
+
sprites!: any;
|
|
22
|
+
defaultShader!: any;
|
|
22
23
|
/**
|
|
23
24
|
* Creates a new SpriteBatch instance.
|
|
24
25
|
*/
|
|
@@ -65,7 +66,7 @@ defaultShader!: any;
|
|
|
65
66
|
* Renders a sprite using WebGL.
|
|
66
67
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
67
68
|
*/
|
|
68
|
-
setContext(gl) {
|
|
69
|
+
setContext(gl: IdentifiedWebGLRenderingContext) {
|
|
69
70
|
this.gl = gl;
|
|
70
71
|
// create a couple of buffers
|
|
71
72
|
this.vertexBuffer = gl.createBuffer();
|
|
@@ -2,9 +2,9 @@ import { hex2rgb } from '../../util/math.js';
|
|
|
2
2
|
|
|
3
3
|
export class WebGLStencilManager {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
stencilStack!: any;
|
|
6
|
-
reverse!: any;
|
|
7
|
-
count!: any;
|
|
5
|
+
stencilStack!: any;
|
|
6
|
+
reverse!: any;
|
|
7
|
+
count!: any;
|
|
8
8
|
/**
|
|
9
9
|
* Initializes the stencil manager.
|
|
10
10
|
*/
|
|
@@ -36,7 +36,11 @@ count!: any;
|
|
|
36
36
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
37
37
|
* @param {object} renderSession - The rendering session.
|
|
38
38
|
*/
|
|
39
|
-
pushStencil(
|
|
39
|
+
pushStencil(
|
|
40
|
+
graphics: import('../graphics.js').Graphics,
|
|
41
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
42
|
+
renderSession: any
|
|
43
|
+
) {
|
|
40
44
|
const gl = renderSession.gl;
|
|
41
45
|
this.bindGraphics(graphics, webGLData, renderSession);
|
|
42
46
|
if (this.stencilStack.length === 0) {
|
|
@@ -94,7 +98,11 @@ count!: any;
|
|
|
94
98
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
95
99
|
* @param {object} renderSession - The rendering session.
|
|
96
100
|
*/
|
|
97
|
-
bindGraphics(
|
|
101
|
+
bindGraphics(
|
|
102
|
+
graphics: import('../graphics.js').Graphics,
|
|
103
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
104
|
+
renderSession: any
|
|
105
|
+
) {
|
|
98
106
|
// if(this._currentGraphics === graphics)return;
|
|
99
107
|
// this._currentGraphics = graphics;
|
|
100
108
|
const gl = renderSession.gl;
|
|
@@ -141,7 +149,11 @@ count!: any;
|
|
|
141
149
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
142
150
|
* @param {object} renderSession - The rendering session.
|
|
143
151
|
*/
|
|
144
|
-
popStencil(
|
|
152
|
+
popStencil(
|
|
153
|
+
graphics: import('../graphics.js').Graphics,
|
|
154
|
+
webGLData: import('./graphics_data.js').GraphicsData,
|
|
155
|
+
renderSession: any
|
|
156
|
+
) {
|
|
145
157
|
const gl = renderSession.gl;
|
|
146
158
|
this.stencilStack.pop();
|
|
147
159
|
this.count -= 1;
|
|
@@ -56,7 +56,12 @@ export class Texture {
|
|
|
56
56
|
* @param {Rectangle | null | undefined} crop - The crop rectangle.
|
|
57
57
|
* @param {Rectangle | null | undefined} trim - The trim rectangle.
|
|
58
58
|
*/
|
|
59
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
baseTexture: import('./base_texture.js').BaseTexture,
|
|
61
|
+
frame: Rectangle | null | undefined = null,
|
|
62
|
+
crop: Rectangle | null | undefined = null,
|
|
63
|
+
trim: Rectangle | null | undefined = null
|
|
64
|
+
) {
|
|
60
65
|
this.noFrame = false;
|
|
61
66
|
if (!frame) {
|
|
62
67
|
this.noFrame = true;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** WebGL context tagged with the per-context id the renderer assigns, used to key shader caches. */
|
|
2
|
+
export type IdentifiedWebGLRenderingContext = WebGLRenderingContext & { id: number };
|
|
3
|
+
|
|
1
4
|
// No error has been recorded. The value of this constant is 0.
|
|
2
5
|
export const NO_ERROR = 0;
|
|
3
6
|
// An unacceptable value has been specified for an enumerated argument. The command is ignored and the error flag is set.
|
|
@@ -60,9 +63,12 @@ export const initDefaultShaders = () => {};
|
|
|
60
63
|
* @param {object} shaderType - The type of shader to compile.
|
|
61
64
|
* @returns {WebGLShader} The compiled WebGL shader or null if compilation failed.
|
|
62
65
|
*/
|
|
63
|
-
export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string, shaderType: any) => {
|
|
66
|
+
export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string, shaderType: any) => {
|
|
64
67
|
const src = Array.isArray(shaderSrc) ? shaderSrc.join('\n') : shaderSrc;
|
|
65
68
|
const shader = gl.createShader(shaderType);
|
|
69
|
+
if (!shader) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
66
72
|
gl.shaderSource(shader, src);
|
|
67
73
|
gl.compileShader(shader);
|
|
68
74
|
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
@@ -81,7 +87,7 @@ export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[]|str
|
|
|
81
87
|
* @param {string[]|string} shaderSrc - The vertex shader source code.
|
|
82
88
|
* @returns {WebGLShader} The compiled WebGL vertex shader or null if compilation failed.
|
|
83
89
|
*/
|
|
84
|
-
export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
90
|
+
export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
|
|
85
91
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
86
92
|
};
|
|
87
93
|
|
|
@@ -91,7 +97,7 @@ export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string
|
|
|
91
97
|
* @param {string[]|string} shaderSrc - The fragment shader source code.
|
|
92
98
|
* @returns {WebGLShader} The compiled WebGL fragment shader or null if compilation failed.
|
|
93
99
|
*/
|
|
94
|
-
export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
100
|
+
export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[] | string) => {
|
|
95
101
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
96
102
|
};
|
|
97
103
|
|
|
@@ -102,12 +108,19 @@ export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: stri
|
|
|
102
108
|
* @param {string[]|string} fragmentSrc - The fragment shader source code.
|
|
103
109
|
* @returns {WebGLProgram} The compiled WebGL shader program or null if compilation failed.
|
|
104
110
|
*/
|
|
105
|
-
export const compileProgram = (
|
|
111
|
+
export const compileProgram = (
|
|
112
|
+
gl: WebGLRenderingContext,
|
|
113
|
+
vertexSrc: string[] | string,
|
|
114
|
+
fragmentSrc: string[] | string
|
|
115
|
+
) => {
|
|
106
116
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|
|
107
117
|
const vertexShader = compileVertexShader(gl, vertexSrc);
|
|
108
118
|
|
|
109
119
|
const shaderProgram = gl.createProgram();
|
|
110
120
|
|
|
121
|
+
if (!shaderProgram || !vertexShader || !fragmentShader) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
111
124
|
gl.attachShader(shaderProgram, vertexShader);
|
|
112
125
|
gl.attachShader(shaderProgram, fragmentShader);
|
|
113
126
|
gl.linkProgram(shaderProgram);
|
|
@@ -46,7 +46,7 @@ export class Circle {
|
|
|
46
46
|
* @param {Point} output - The point to store the result in (optional).
|
|
47
47
|
* @returns {Point} A random point within this circle.
|
|
48
48
|
*/
|
|
49
|
-
random(output: Point = null) {
|
|
49
|
+
random(output: Point | null = null) {
|
|
50
50
|
const result = output || new Point();
|
|
51
51
|
const t = 2 * Math.PI * Math.random();
|
|
52
52
|
const u = Math.random() + Math.random();
|
|
@@ -91,7 +91,7 @@ export class Ellipse {
|
|
|
91
91
|
* @param {Point} output - The point to store the result in (optional).
|
|
92
92
|
* @returns {Point} A random point within this ellipse.
|
|
93
93
|
*/
|
|
94
|
-
random(output: Point = null) {
|
|
94
|
+
random(output: Point | null = null) {
|
|
95
95
|
const result = output || new Point();
|
|
96
96
|
const p = Math.random() * Math.PI * 2;
|
|
97
97
|
const r = Math.random();
|
package/src/phaser/geom/line.ts
CHANGED
|
@@ -119,7 +119,7 @@ export class Line {
|
|
|
119
119
|
* @param {Point} output - The point to store the result in (optional).
|
|
120
120
|
* @returns {Point} The midpoint of this line.
|
|
121
121
|
*/
|
|
122
|
-
midPoint(output: Point = null) {
|
|
122
|
+
midPoint(output: Point | null = null) {
|
|
123
123
|
const result = output || new Point();
|
|
124
124
|
result.x = (this.start.x + this.end.x) / 2;
|
|
125
125
|
result.y = (this.start.y + this.end.y) / 2;
|
|
@@ -169,7 +169,7 @@ export class Line {
|
|
|
169
169
|
* @param {Point} output - The point to store the result in (optional).
|
|
170
170
|
* @returns {Point} A random point on this line.
|
|
171
171
|
*/
|
|
172
|
-
random(output: Point = null) {
|
|
172
|
+
random(output: Point | null = null) {
|
|
173
173
|
const result = output || new Point();
|
|
174
174
|
const t = Math.random();
|
|
175
175
|
result.x = this.start.x + t * (this.end.x - this.start.x);
|
|
@@ -105,7 +105,7 @@ export class Matrix {
|
|
|
105
105
|
* @param {Float32Array} output - The array to store the result in (optional).
|
|
106
106
|
* @returns {Float32Array} A Float32Array containing the matrix elements.
|
|
107
107
|
*/
|
|
108
|
-
toArray(transpose: boolean = false, output: Float32Array = null) {
|
|
108
|
+
toArray(transpose: boolean = false, output: Float32Array | null = null) {
|
|
109
109
|
const result = output || new Float32Array(9);
|
|
110
110
|
if (transpose) {
|
|
111
111
|
result[0] = this.a;
|
|
@@ -137,7 +137,7 @@ export class Matrix {
|
|
|
137
137
|
* @param {Point} output - The point to store the result in (optional).
|
|
138
138
|
* @returns {Point} The transformed point.
|
|
139
139
|
*/
|
|
140
|
-
apply(pos: Point, output: Point = null) {
|
|
140
|
+
apply(pos: Point, output: Point | null = null) {
|
|
141
141
|
const result = output || new Point();
|
|
142
142
|
result.x = this.a * pos.x + this.c * pos.y + this.tx;
|
|
143
143
|
result.y = this.b * pos.x + this.d * pos.y + this.ty;
|
|
@@ -150,7 +150,7 @@ export class Matrix {
|
|
|
150
150
|
* @param {Point} output - The point to store the result in (optional).
|
|
151
151
|
* @returns {Point} The transformed point.
|
|
152
152
|
*/
|
|
153
|
-
applyInverse(pos: Point, output: Point = null) {
|
|
153
|
+
applyInverse(pos: Point, output: Point | null = null) {
|
|
154
154
|
const result = output || new Point();
|
|
155
155
|
const id = 1 / (this.a * this.d + this.c * -this.b);
|
|
156
156
|
const x = pos.x;
|
|
@@ -13,7 +13,7 @@ export class Polygon {
|
|
|
13
13
|
* Creates a new Polygon instance.
|
|
14
14
|
* @param {object[]} points - The array of points to define the polygon (optional).
|
|
15
15
|
*/
|
|
16
|
-
constructor(points: any[] = null) {
|
|
16
|
+
constructor(points: any[] | null = null) {
|
|
17
17
|
/** @type {number} */
|
|
18
18
|
this.area = 0;
|
|
19
19
|
/** @type {Point[]} */
|
|
@@ -288,7 +288,7 @@ export class Rectangle {
|
|
|
288
288
|
* @param {Point} output - The point to store the result in (optional).
|
|
289
289
|
* @returns {Point} A random point within this rectangle.
|
|
290
290
|
*/
|
|
291
|
-
random(output: Point = null) {
|
|
291
|
+
random(output: Point | null = null) {
|
|
292
292
|
const result = output || new Point();
|
|
293
293
|
result.x = this.randomX;
|
|
294
294
|
result.y = this.randomY;
|
|
@@ -301,7 +301,7 @@ export class Rectangle {
|
|
|
301
301
|
* @param {Point} output - The point to store the result in (optional).
|
|
302
302
|
* @returns {Point} A point at the specified position on the rectangle.
|
|
303
303
|
*/
|
|
304
|
-
getPoint(position: number, output: Point = null) {
|
|
304
|
+
getPoint(position: number, output: Point | null = null) {
|
|
305
305
|
const result = output || new Point();
|
|
306
306
|
switch (position) {
|
|
307
307
|
case TOP_LEFT:
|
|
@@ -8,7 +8,7 @@ import { Point } from '../point.js';
|
|
|
8
8
|
* @param {Circle} output - Optional circle to store the result in.
|
|
9
9
|
* @returns {Circle} The cloned circle.
|
|
10
10
|
*/
|
|
11
|
-
export const clone = (input: Circle, output: Circle = null) => {
|
|
11
|
+
export const clone = (input: Circle, output: Circle | null = null) => {
|
|
12
12
|
const result = output || new Circle();
|
|
13
13
|
result.x = input.x;
|
|
14
14
|
result.y = input.y;
|
|
@@ -60,7 +60,12 @@ export const intersects = (a: Circle, b: Circle) => {
|
|
|
60
60
|
* @param {Point} output - Optional point to store the result in.
|
|
61
61
|
* @returns {Point} The point on the circumference of the circle.
|
|
62
62
|
*/
|
|
63
|
-
export const circumferencePoint = (
|
|
63
|
+
export const circumferencePoint = (
|
|
64
|
+
a: Circle,
|
|
65
|
+
angle: number,
|
|
66
|
+
asDegrees: boolean = false,
|
|
67
|
+
output: Point | null = null
|
|
68
|
+
) => {
|
|
64
69
|
const result = output || new Point();
|
|
65
70
|
if (asDegrees === true) {
|
|
66
71
|
angle = degToRad(angle);
|
|
@@ -78,7 +83,7 @@ export const circumferencePoint = (a: Circle, angle: number, asDegrees: boolean
|
|
|
78
83
|
* @param {Point} output - Optional point to store the result in.
|
|
79
84
|
* @returns {Point} The point on the circumference of the circle.
|
|
80
85
|
*/
|
|
81
|
-
export const intersectsPoint = (a: Circle, angle: number, asDegrees: boolean = false, output: Point = null) => {
|
|
86
|
+
export const intersectsPoint = (a: Circle, angle: number, asDegrees: boolean = false, output: Point | null = null) => {
|
|
82
87
|
const result = output || new Point();
|
|
83
88
|
if (asDegrees === true) {
|
|
84
89
|
angle = degToRad(angle);
|
|
@@ -8,7 +8,7 @@ import { intersects as intersectsRect } from './rectangle.js';
|
|
|
8
8
|
* @param {Line} output - Optional line to store the result in.
|
|
9
9
|
* @returns {Line} The cloned line.
|
|
10
10
|
*/
|
|
11
|
-
export const clone = (input: Line, output: Line = null) => {
|
|
11
|
+
export const clone = (input: Line, output: Line | null = null) => {
|
|
12
12
|
const result = output || new Line();
|
|
13
13
|
result.start.x = input.start.x;
|
|
14
14
|
result.start.y = input.start.y;
|
|
@@ -27,7 +27,14 @@ export const clone = (input: Line, output: Line = null) => {
|
|
|
27
27
|
* @param {Point} output - Optional point to store the result in.
|
|
28
28
|
* @returns {Point} The intersection point, or null if there is no intersection.
|
|
29
29
|
*/
|
|
30
|
-
export const intersectsPoints = (
|
|
30
|
+
export const intersectsPoints = (
|
|
31
|
+
a: any,
|
|
32
|
+
b: any,
|
|
33
|
+
e: any,
|
|
34
|
+
f: any,
|
|
35
|
+
asSegment: boolean = true,
|
|
36
|
+
output: Point | null = null
|
|
37
|
+
) => {
|
|
31
38
|
const result = output || new Point();
|
|
32
39
|
const a1 = b.y - a.y;
|
|
33
40
|
const a2 = f.y - e.y;
|
|
@@ -6,7 +6,7 @@ import { Matrix } from '../matrix.js';
|
|
|
6
6
|
* @param {Matrix} output - Optional matrix to store the result in.
|
|
7
7
|
* @returns {Matrix} The cloned matrix.
|
|
8
8
|
*/
|
|
9
|
-
export const clone = (input: Matrix, output: Matrix = null) => {
|
|
9
|
+
export const clone = (input: Matrix, output: Matrix | null = null) => {
|
|
10
10
|
const result = output || new Matrix();
|
|
11
11
|
result.a = input.a;
|
|
12
12
|
result.b = input.b;
|
|
@@ -7,7 +7,7 @@ import { Point } from '../point.js';
|
|
|
7
7
|
* @param {Point} output - The point to store the result in (optional).
|
|
8
8
|
* @returns {Point} A new point containing the sum of the two points.
|
|
9
9
|
*/
|
|
10
|
-
export const add = (a: Point, b: Point, output: Point = null) => {
|
|
10
|
+
export const add = (a: Point, b: Point, output: Point | null = null) => {
|
|
11
11
|
const result = output || new Point();
|
|
12
12
|
result.x = a.x + b.x;
|
|
13
13
|
result.y = a.y + b.y;
|
|
@@ -21,7 +21,7 @@ export const add = (a: Point, b: Point, output: Point = null) => {
|
|
|
21
21
|
* @param {Point} output - The point to store the result in (optional).
|
|
22
22
|
* @returns {Point} A new point containing the difference of the two points.
|
|
23
23
|
*/
|
|
24
|
-
export const subtract = (a: Point, b: Point, output: Point = null) => {
|
|
24
|
+
export const subtract = (a: Point, b: Point, output: Point | null = null) => {
|
|
25
25
|
const result = output || new Point();
|
|
26
26
|
result.x = a.x - b.x;
|
|
27
27
|
result.y = a.y - b.y;
|
|
@@ -35,7 +35,7 @@ export const subtract = (a: Point, b: Point, output: Point = null) => {
|
|
|
35
35
|
* @param {Point} output - The point to store the result in (optional).
|
|
36
36
|
* @returns {Point} A new point containing the product of the two points.
|
|
37
37
|
*/
|
|
38
|
-
export const multiply = (a: Point, b: Point, output: Point = null) => {
|
|
38
|
+
export const multiply = (a: Point, b: Point, output: Point | null = null) => {
|
|
39
39
|
const result = output || new Point();
|
|
40
40
|
result.x = a.x * b.x;
|
|
41
41
|
result.y = a.y * b.y;
|
|
@@ -49,7 +49,7 @@ export const multiply = (a: Point, b: Point, output: Point = null) => {
|
|
|
49
49
|
* @param {Point} output - The point to store the result in (optional).
|
|
50
50
|
* @returns {Point} A new point containing the quotient of the two points.
|
|
51
51
|
*/
|
|
52
|
-
export const divide = (a: Point, b: Point, output: Point = null) => {
|
|
52
|
+
export const divide = (a: Point, b: Point, output: Point | null = null) => {
|
|
53
53
|
const result = output || new Point();
|
|
54
54
|
result.x = a.x / b.x;
|
|
55
55
|
result.y = a.y / b.y;
|
|
@@ -82,7 +82,7 @@ export const angle = (a: Point, b: Point) => {
|
|
|
82
82
|
* @param {Point} output - The point to store the result in (optional).
|
|
83
83
|
* @returns {Point} A new point with negated coordinates.
|
|
84
84
|
*/
|
|
85
|
-
export const negative = (a: Point, output: Point = null) => {
|
|
85
|
+
export const negative = (a: Point, output: Point | null = null) => {
|
|
86
86
|
const result = output || new Point();
|
|
87
87
|
return result.setTo(-a.x, -a.y);
|
|
88
88
|
};
|
|
@@ -95,7 +95,7 @@ export const negative = (a: Point, output: Point = null) => {
|
|
|
95
95
|
* @param {Point} output - The point to store the result in (optional).
|
|
96
96
|
* @returns {Point} A new point with the result of the operation.
|
|
97
97
|
*/
|
|
98
|
-
export const multiplyAdd = (a: Point, b: Point, s: number, output: Point = null) => {
|
|
98
|
+
export const multiplyAdd = (a: Point, b: Point, s: number, output: Point | null = null) => {
|
|
99
99
|
const result = output || new Point();
|
|
100
100
|
return result.setTo(a.x + b.x * s, a.y + b.y * s);
|
|
101
101
|
};
|
|
@@ -108,7 +108,7 @@ export const multiplyAdd = (a: Point, b: Point, s: number, output: Point = null)
|
|
|
108
108
|
* @param {Point} output - The point to store the result in (optional).
|
|
109
109
|
* @returns {Point} A new point interpolated between the two points.
|
|
110
110
|
*/
|
|
111
|
-
export const interpolate = (a: Point, b: Point, f: number, output: Point = null) => {
|
|
111
|
+
export const interpolate = (a: Point, b: Point, f: number, output: Point | null = null) => {
|
|
112
112
|
const result = output || new Point();
|
|
113
113
|
return result.setTo(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);
|
|
114
114
|
};
|
|
@@ -119,7 +119,7 @@ export const interpolate = (a: Point, b: Point, f: number, output: Point = null)
|
|
|
119
119
|
* @param {Point} output - The point to store the result in (optional).
|
|
120
120
|
* @returns {Point} A new point that is perpendicular to the input point.
|
|
121
121
|
*/
|
|
122
|
-
export const perp = (a: Point, output: Point = null) => {
|
|
122
|
+
export const perp = (a: Point, output: Point | null = null) => {
|
|
123
123
|
const result = output || new Point();
|
|
124
124
|
return result.setTo(-a.y, a.x);
|
|
125
125
|
};
|
|
@@ -130,7 +130,7 @@ export const perp = (a: Point, output: Point = null) => {
|
|
|
130
130
|
* @param {Point} output - The point to store the result in (optional).
|
|
131
131
|
* @returns {Point} A new point that is perpendicular to the input point (rotated clockwise).
|
|
132
132
|
*/
|
|
133
|
-
export const rperp = (a: Point, output: Point = null) => {
|
|
133
|
+
export const rperp = (a: Point, output: Point | null = null) => {
|
|
134
134
|
const result = output || new Point();
|
|
135
135
|
return result.setTo(a.y, -a.x);
|
|
136
136
|
};
|
|
@@ -156,7 +156,7 @@ export const distance = (a: Point, b: Point, round: boolean = false) => {
|
|
|
156
156
|
* @param {Point} output - The point to store the result in (optional).
|
|
157
157
|
* @returns {Point} A new point with the projected result.
|
|
158
158
|
*/
|
|
159
|
-
export const project = (a: Point, b: Point, output: Point = null) => {
|
|
159
|
+
export const project = (a: Point, b: Point, output: Point | null = null) => {
|
|
160
160
|
const result = output || new Point();
|
|
161
161
|
const amt = a.dot(b) / b.getMagnitudeSq();
|
|
162
162
|
if (amt !== 0) {
|
|
@@ -172,7 +172,7 @@ export const project = (a: Point, b: Point, output: Point = null) => {
|
|
|
172
172
|
* @param {Point} output - The point to store the result in (optional).
|
|
173
173
|
* @returns {Point} A new point with the projected result.
|
|
174
174
|
*/
|
|
175
|
-
export const projectUnit = (a: Point, b: Point, output: Point = null) => {
|
|
175
|
+
export const projectUnit = (a: Point, b: Point, output: Point | null = null) => {
|
|
176
176
|
const result = output || new Point();
|
|
177
177
|
const amt = a.dot(b);
|
|
178
178
|
if (amt !== 0) {
|
|
@@ -187,7 +187,7 @@ export const projectUnit = (a: Point, b: Point, output: Point = null) => {
|
|
|
187
187
|
* @param {Point} output - The point to store the result in (optional).
|
|
188
188
|
* @returns {Point} A new point with the same x coordinate but negated y coordinate.
|
|
189
189
|
*/
|
|
190
|
-
export const normalRightHand = (a: Point, output: Point = null) => {
|
|
190
|
+
export const normalRightHand = (a: Point, output: Point | null = null) => {
|
|
191
191
|
const result = output || new Point();
|
|
192
192
|
return result.setTo(a.y * -1, a.x);
|
|
193
193
|
};
|
|
@@ -198,7 +198,7 @@ export const normalRightHand = (a: Point, output: Point = null) => {
|
|
|
198
198
|
* @param {Point} output - The point to store the result in (optional).
|
|
199
199
|
* @returns {Point} A new normalized point.
|
|
200
200
|
*/
|
|
201
|
-
export const normalize = (a: Point, output: Point = null) => {
|
|
201
|
+
export const normalize = (a: Point, output: Point | null = null) => {
|
|
202
202
|
const result = output || new Point();
|
|
203
203
|
const m = a.getMagnitude();
|
|
204
204
|
if (m !== 0) {
|
|
@@ -217,7 +217,14 @@ export const normalize = (a: Point, output: Point = null) => {
|
|
|
217
217
|
* @param {number | null | undefined} dist - The distance to rotate from (default: null).
|
|
218
218
|
* @returns {Point} The rotated point instance for chaining.
|
|
219
219
|
*/
|
|
220
|
-
export const rotate = (
|
|
220
|
+
export const rotate = (
|
|
221
|
+
a: Point,
|
|
222
|
+
x: number,
|
|
223
|
+
y: number,
|
|
224
|
+
ang: number,
|
|
225
|
+
asDegrees: boolean,
|
|
226
|
+
dist: number | null | undefined
|
|
227
|
+
) => {
|
|
221
228
|
if (asDegrees) {
|
|
222
229
|
ang *= Math.PI / 180;
|
|
223
230
|
}
|
|
@@ -244,7 +251,7 @@ export const rotate = (a: Point, x: number, y: number, ang: number, asDegrees: b
|
|
|
244
251
|
* @returns {Point} A new point representing the centroid of the input points.
|
|
245
252
|
* @throws {Error} If the points array is empty.
|
|
246
253
|
*/
|
|
247
|
-
export const centroid = (points: Point[], output: Point = null) => {
|
|
254
|
+
export const centroid = (points: Point[], output: Point | null = null) => {
|
|
248
255
|
const result = output || new Point();
|
|
249
256
|
const pointsLen = points.length;
|
|
250
257
|
if (pointsLen < 1) {
|
|
@@ -285,7 +292,7 @@ export const parse = (obj: any, xProp: string = 'x', yProp: string = 'y') => {
|
|
|
285
292
|
* @param {Point} output - The point to store the result in (optional).
|
|
286
293
|
* @returns {Point} A new point with the same coordinates as the input.
|
|
287
294
|
*/
|
|
288
|
-
export const clone = (input: Point, output: Point = null) => {
|
|
295
|
+
export const clone = (input: Point, output: Point | null = null) => {
|
|
289
296
|
const result = output || new Point();
|
|
290
297
|
result.setTo(input.x, input.y);
|
|
291
298
|
return result;
|
|
@@ -6,7 +6,7 @@ import { Polygon } from '../polygon.js';
|
|
|
6
6
|
* @param {Polygon} output - Optional polygon to store the result in.
|
|
7
7
|
* @returns {Polygon} The cloned polygon.
|
|
8
8
|
*/
|
|
9
|
-
export const clone = (input: Polygon, output: Polygon = null) => {
|
|
9
|
+
export const clone = (input: Polygon, output: Polygon | null = null) => {
|
|
10
10
|
const result = output || new Polygon();
|
|
11
11
|
result.setTo(input._points.slice());
|
|
12
12
|
return result;
|