bard-legends-framework 0.4.3 → 0.4.5
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/physics/entity-types/physics-entity.d.ts +4 -1
- package/dist/physics/entity-types/physics-entity.js +6 -0
- package/dist/physics/entity-types/physics-entity.js.map +1 -1
- package/dist/physics/libs/p2js.helper.d.ts +4 -1
- package/dist/physics/libs/p2js.helper.js +20 -0
- package/dist/physics/libs/p2js.helper.js.map +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +6 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +9 -6
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js.map +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +13 -8
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +22 -11
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js.map +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +5 -0
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +2 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +4 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js.map +1 -1
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +10 -0
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +106 -0
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +13 -0
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +83 -0
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +5 -0
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +42 -0
- package/dist/physics/module//360/237/223/220services/creation/border.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +15 -0
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +120 -0
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +21 -0
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +109 -0
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +9 -0
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +97 -0
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts +14 -0
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js +102 -0
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.d.ts +14 -0
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js +87 -0
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.d.ts +9 -0
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js +73 -0
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +12 -0
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +63 -0
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +15 -0
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +92 -0
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +9 -0
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +25 -0
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +9 -0
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +92 -0
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js.map +1 -0
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +22 -0
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +135 -0
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js.map +1 -0
- package/dist/pixi/display-object/components/glow-filter.d.ts +2 -3
- package/dist/pixi/display-object/components/glow-filter.js +3 -5
- package/dist/pixi/display-object/components/glow-filter.js.map +1 -1
- package/dist/pixi/helpers/glow-sprite-generator.js +10 -16
- package/dist/pixi/helpers/glow-sprite-generator.js.map +1 -1
- package/dist/pixi/index.d.ts +6 -3
- package/package.json +1 -1
- package/package.json.bak +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TestVisualsService = void 0;
|
|
13
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
14
|
+
const game_entities_1 = require("../../../../game-entities");
|
|
15
|
+
const availability_grid_service_1 = require("../path-finding/availability-grid.service");
|
|
16
|
+
const physics_world_entity_1 = require("../../\uD83E\uDDCAentities/physics-world.entity");
|
|
17
|
+
const path_finder_service_1 = require("../path-finding/path-finder.service");
|
|
18
|
+
const position_to_grid_position_converter_1 = require("../../../libs/position-to-grid-position-converter");
|
|
19
|
+
const pixi_1 = require("../../../../pixi");
|
|
20
|
+
const utilities_1 = require("../../../../utilities");
|
|
21
|
+
const p2js_helper_1 = require("../../../libs/p2js.helper");
|
|
22
|
+
let TestVisualsService = class TestVisualsService {
|
|
23
|
+
constructor(availabilityGridService, pathFinderService) {
|
|
24
|
+
this.availabilityGridService = availabilityGridService;
|
|
25
|
+
this.pathFinderService = pathFinderService;
|
|
26
|
+
}
|
|
27
|
+
printPathfindingTestGrid(physicsWorldId, testLayerId, target, physicsBodyGroup, area, gridCellSize) {
|
|
28
|
+
let physicsWorld = physics_world_entity_1.PhysicsWorldEntity.getInstanceByIdOrFail(physicsWorldId);
|
|
29
|
+
let availabilityGrid = this.availabilityGridService.getAvilabilityGrid(physicsWorld, gridCellSize, physicsBodyGroup);
|
|
30
|
+
availabilityGrid
|
|
31
|
+
.map((value, position) => ({
|
|
32
|
+
position: position_to_grid_position_converter_1.PositionToGridPositionConverter.gridPositionToPosition(position, gridCellSize),
|
|
33
|
+
availability: value
|
|
34
|
+
}))
|
|
35
|
+
.forEach(value => {
|
|
36
|
+
if (value.position.isInsideRectangle(area)) {
|
|
37
|
+
let direction = this.pathFinderService.findPathDirection(physicsWorldId, value.position, target, physicsBodyGroup);
|
|
38
|
+
let graphics;
|
|
39
|
+
if (direction === undefined) {
|
|
40
|
+
graphics = pixi_1.Graphics.createRectangle(new helpers_lib_1.Vector(8, 8), 2, helpers_lib_1.ColorHelper.red)
|
|
41
|
+
.parent(testLayerId)
|
|
42
|
+
.setPosition(value.position)
|
|
43
|
+
.attach(physicsWorldId);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
graphics = pixi_1.Graphics.createArrow(25, value.availability ? helpers_lib_1.ColorHelper.green : helpers_lib_1.ColorHelper.red)
|
|
47
|
+
.parent(testLayerId)
|
|
48
|
+
.setPosition(value.position)
|
|
49
|
+
.setRotation(direction)
|
|
50
|
+
.attach(physicsWorldId);
|
|
51
|
+
}
|
|
52
|
+
let animator = new utilities_1.Animator(graphics, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() });
|
|
53
|
+
animator.animate({ alpha: 0 }).then(() => {
|
|
54
|
+
graphics.destroy();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
createExplosionDebugVisual(physicsWorld, testLayerId, rayCasts, explosionCenter, radius, duration = 300) {
|
|
60
|
+
let lineContainer = pixi_1.Container.create().parent(testLayerId).setAlpha(0.5).attach(physicsWorld);
|
|
61
|
+
pixi_1.Graphics.createCircle(radius, helpers_lib_1.ColorHelper.blue)
|
|
62
|
+
.parent(lineContainer)
|
|
63
|
+
.setPosition(explosionCenter)
|
|
64
|
+
.setAlpha(0.5)
|
|
65
|
+
.attach(physicsWorld);
|
|
66
|
+
rayCasts.forEach(ray => {
|
|
67
|
+
let color = ray.hits.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
|
|
68
|
+
pixi_1.Graphics.createVector(explosionCenter, ray.line.to, color).parent(lineContainer).attach(physicsWorld);
|
|
69
|
+
});
|
|
70
|
+
new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).animate({ alpha: 0 }).then(() => {
|
|
71
|
+
lineContainer.destroy();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
createElipticExplosionDebugVisual(physicsWorld, testLayerId, rayCasts, explosionCenter, rotation, size, duration = 300) {
|
|
75
|
+
let lineContainer = pixi_1.Container.create().parent(testLayerId).setAlpha(0.5).attach(physicsWorld);
|
|
76
|
+
pixi_1.Graphics.createElipse(size, helpers_lib_1.ColorHelper.blue)
|
|
77
|
+
.parent(lineContainer)
|
|
78
|
+
.setPosition(explosionCenter)
|
|
79
|
+
.setRotation(rotation)
|
|
80
|
+
.setAlpha(0.5)
|
|
81
|
+
.attach(physicsWorld);
|
|
82
|
+
rayCasts.forEach(ray => {
|
|
83
|
+
let color = ray.hits.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
|
|
84
|
+
pixi_1.Graphics.createVector(ray.line.from, ray.line.to, color).parent(lineContainer).attach(physicsWorld);
|
|
85
|
+
});
|
|
86
|
+
new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).animate({ alpha: 0 }).then(() => {
|
|
87
|
+
lineContainer.destroy();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
createPhysicsEntityShapeVisual(p2Body, testLayerId, options) {
|
|
91
|
+
let position = options?.overridePosition ?? p2js_helper_1.P2JSHelper.arrayToVector(p2Body.position);
|
|
92
|
+
let rotation = options?.overrideRotation ?? p2Body.angle;
|
|
93
|
+
let color = options?.color ?? helpers_lib_1.ColorHelper.blue;
|
|
94
|
+
let container = pixi_1.Container.create()
|
|
95
|
+
.parent(testLayerId)
|
|
96
|
+
.setPosition(position)
|
|
97
|
+
.setRotation(rotation)
|
|
98
|
+
.setAlpha(0.5)
|
|
99
|
+
.skipAttachCheck();
|
|
100
|
+
p2Body.shapes.forEach(shape => {
|
|
101
|
+
let displayObject = this.drawShape(shape, color);
|
|
102
|
+
displayObject.parent(container).skipAttachCheck();
|
|
103
|
+
});
|
|
104
|
+
let animator = new utilities_1.Animator(container, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() });
|
|
105
|
+
animator.animate({ alpha: 0 }).then(() => {
|
|
106
|
+
container.destroy();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
drawShape(shape, color) {
|
|
110
|
+
switch (shape.constructor.name) {
|
|
111
|
+
case 'Circle':
|
|
112
|
+
throw new Error('Not implemented');
|
|
113
|
+
case 'Plane':
|
|
114
|
+
throw new Error('Not implemented');
|
|
115
|
+
case 'Capsule':
|
|
116
|
+
throw new Error('Not implemented');
|
|
117
|
+
case 'Rectangle':
|
|
118
|
+
throw new Error('Not implemented');
|
|
119
|
+
case 'Convex':
|
|
120
|
+
return this.drawConvexShape(shape, color);
|
|
121
|
+
default:
|
|
122
|
+
throw new Error('Not implemented');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
drawConvexShape(shape, color) {
|
|
126
|
+
let polygon = [shape.vertices.map(vertex => ({ x: vertex[0], y: vertex[1] }))];
|
|
127
|
+
return pixi_1.Graphics.createPolygon(helpers_lib_1.Vector.zero, helpers_lib_1.Vector.zero, polygon, color);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.TestVisualsService = TestVisualsService;
|
|
131
|
+
exports.TestVisualsService = TestVisualsService = __decorate([
|
|
132
|
+
(0, game_entities_1.ServiceDecorator)(),
|
|
133
|
+
__metadata("design:paramtypes", [availability_grid_service_1.AvailabilityGridService, path_finder_service_1.PathFinderService])
|
|
134
|
+
], TestVisualsService);
|
|
135
|
+
//# sourceMappingURL=test-visuals.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-visuals.service.js","sourceRoot":"","sources":["../../../../../src/physics/module/📐services/test-visuals/test-visuals.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA6E;AAG7E,6DAA6D;AAC7D,yFAAoF;AACpF,0FAA2E;AAE3E,6EAAwE;AACxE,2GAAoG;AAEpG,2CAAsE;AACtE,qDAAkE;AAClE,2DAAuD;AAGhD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAAoB,uBAAgD,EAAU,iBAAoC;QAA9F,4BAAuB,GAA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9B"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { RGBColor } from 'helpers-lib';
|
|
2
1
|
import * as PIXI from 'pixi.js';
|
|
3
|
-
import {
|
|
2
|
+
import { GlowFilterOptions } from '../..';
|
|
4
3
|
export declare class GlowFilter {
|
|
5
4
|
private pixiSprite;
|
|
6
5
|
private glowSprite;
|
|
7
6
|
constructor(pixiSprite: PIXI.Sprite);
|
|
8
|
-
add(
|
|
7
|
+
add(options: GlowFilterOptions): void;
|
|
9
8
|
setAlpha(alpha: number): this;
|
|
10
9
|
get alpha(): number;
|
|
11
10
|
set alpha(value: number);
|
|
@@ -6,12 +6,10 @@ class GlowFilter {
|
|
|
6
6
|
constructor(pixiSprite) {
|
|
7
7
|
this.pixiSprite = pixiSprite;
|
|
8
8
|
}
|
|
9
|
-
add(
|
|
10
|
-
if (!options) {
|
|
11
|
-
options = {};
|
|
12
|
-
}
|
|
9
|
+
add(options) {
|
|
13
10
|
this.remove();
|
|
14
|
-
|
|
11
|
+
let { color, ...glowOptions } = options;
|
|
12
|
+
this.glowSprite = glow_sprite_generator_1.GlowSpriteGenerator.createGlowSprite(this.pixiSprite, color, glowOptions);
|
|
15
13
|
this.pixiSprite.addChild(this.glowSprite);
|
|
16
14
|
}
|
|
17
15
|
setAlpha(alpha) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glow-filter.js","sourceRoot":"","sources":["../../../../src/pixi/display-object/components/glow-filter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"glow-filter.js","sourceRoot":"","sources":["../../../../src/pixi/display-object/components/glow-filter.ts"],"names":[],"mappings":";;;AAEA,+EAA0E;AAG1E,MAAa,UAAU;IAGrB,YAAoB,UAAuB;QAAvB,eAAU,GAAV,UAAU,CAAa;IAAG,CAAC;IAE/C,GAAG,CAAC,OAA0B;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;QACxC,IAAI,CAAC,UAAU,GAAG,2CAAmB,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5F,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AArCD,gCAqCC"}
|
|
@@ -32,30 +32,24 @@ const update_cycle_1 = require("../../game-entities/update-cycle");
|
|
|
32
32
|
class GlowSpriteGenerator {
|
|
33
33
|
static { this.glowTextureCache = new Map(); }
|
|
34
34
|
static createGlowSprite(pixiSprite, color, options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
options.blurRadius = 5;
|
|
40
|
-
}
|
|
41
|
-
if (options.blendMode === undefined) {
|
|
42
|
-
options.blendMode = __1.BlendMode.add;
|
|
43
|
-
}
|
|
44
|
-
if (options.blurRadius > 40) {
|
|
35
|
+
let glowingPower = options.glowingPower ?? 0.5;
|
|
36
|
+
let blurRadius = options.blurRadius ?? 5;
|
|
37
|
+
let blendMode = options.blendMode ?? __1.BlendMode.add;
|
|
38
|
+
if (blurRadius > 40) {
|
|
45
39
|
throw new Error('GlowSpriteGenerator: blurRadius should be less than 40');
|
|
46
40
|
}
|
|
47
|
-
else if (
|
|
41
|
+
else if (blurRadius < 0) {
|
|
48
42
|
throw new Error('GlowSpriteGenerator: blurRadius should be greater than 0');
|
|
49
43
|
}
|
|
50
|
-
else if (!helpers_lib_1.Comparator.isInteger(
|
|
44
|
+
else if (!helpers_lib_1.Comparator.isInteger(blurRadius)) {
|
|
51
45
|
throw new Error('GlowSpriteGenerator: blurRadius should be an integer');
|
|
52
46
|
}
|
|
53
|
-
let glowBaseTexture = this.getGlowTexture(pixiSprite.texture,
|
|
47
|
+
let glowBaseTexture = this.getGlowTexture(pixiSprite.texture, blurRadius);
|
|
54
48
|
let glowSprite = new PIXI.Sprite(glowBaseTexture);
|
|
55
49
|
let anchor = new helpers_lib_1.Vector(pixiSprite.anchor.x, pixiSprite.anchor.y);
|
|
56
|
-
this.setEquavelentAnchorByExtendedBounds(glowSprite, anchor,
|
|
57
|
-
glowSprite.blendMode =
|
|
58
|
-
glowSprite.alpha =
|
|
50
|
+
this.setEquavelentAnchorByExtendedBounds(glowSprite, anchor, blurRadius);
|
|
51
|
+
glowSprite.blendMode = blendMode;
|
|
52
|
+
glowSprite.alpha = glowingPower;
|
|
59
53
|
glowSprite.tint = color;
|
|
60
54
|
return glowSprite;
|
|
61
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glow-sprite-generator.js","sourceRoot":"","sources":["../../../src/pixi/helpers/glow-sprite-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,+CAA2C;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AkB,CAAC,CAAC,KAAK,EAAE,CAAC;AAClD,CAAC,CAAC,CAAC"}
|
package/dist/pixi/index.d.ts
CHANGED
|
@@ -37,7 +37,10 @@ export interface SpriteWithGlowingShapesDefinition extends SpriteDefinition {
|
|
|
37
37
|
}
|
|
38
38
|
export type PolygonDefinition = ReadonlyArray<ReadonlyArray<Vec2>> | Vec2[][];
|
|
39
39
|
export interface GlowOptions {
|
|
40
|
-
glowingPower?: number;
|
|
41
|
-
blurRadius?: number;
|
|
42
|
-
blendMode?: BlendMode;
|
|
40
|
+
readonly glowingPower?: number;
|
|
41
|
+
readonly blurRadius?: number;
|
|
42
|
+
readonly blendMode?: BlendMode;
|
|
43
|
+
}
|
|
44
|
+
export interface GlowFilterOptions extends GlowOptions {
|
|
45
|
+
readonly color: RGBColor;
|
|
43
46
|
}
|
package/package.json
CHANGED