@eva/plugin-renderer-graphics 2.1.0-beta.1 → 2.1.0-beta.3
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/package.json +3 -3
- package/dist/EVA.plugin.renderer.graphics.js +0 -86
- package/dist/EVA.plugin.renderer.graphics.min.js +0 -1
- package/dist/plugin-renderer-graphics.cjs.js +0 -129
- package/dist/plugin-renderer-graphics.cjs.prod.js +0 -1
- package/dist/plugin-renderer-graphics.d.ts +0 -60
- package/dist/plugin-renderer-graphics.esm.js +0 -124
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-graphics",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.3",
|
|
4
4
|
"description": "@eva/plugin-renderer-graphics",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-graphics.esm.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/plugin-renderer": "2.1.0-beta.
|
|
22
|
-
"@eva/eva.js": "2.1.0-beta.
|
|
21
|
+
"@eva/plugin-renderer": "2.1.0-beta.3",
|
|
22
|
+
"@eva/eva.js": "2.1.0-beta.3"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
globalThis.EVA = globalThis.EVA || {};
|
|
2
|
-
globalThis.EVA.plugin = globalThis.EVA.plugin || {};
|
|
3
|
-
globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
|
|
4
|
-
var _EVA_IIFE_graphics = function (exports, eva_js, pixi_js, pluginRenderer) {
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
class Graphics$3 extends pixi_js.Graphics {}
|
|
8
|
-
class Graphics$2 extends eva_js.Component {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.graphics = null;
|
|
12
|
-
}
|
|
13
|
-
init() {
|
|
14
|
-
this.graphics = new Graphics$3();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
Graphics$2.componentName = 'Graphics';
|
|
18
|
-
function __decorate(decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length,
|
|
20
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
21
|
-
d;
|
|
22
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);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;
|
|
23
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
-
}
|
|
25
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) {
|
|
27
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
28
|
-
resolve(value);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
-
function fulfilled(value) {
|
|
33
|
-
try {
|
|
34
|
-
step(generator.next(value));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject(e);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function rejected(value) {
|
|
40
|
-
try {
|
|
41
|
-
step(generator["throw"](value));
|
|
42
|
-
} catch (e) {
|
|
43
|
-
reject(e);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function step(result) {
|
|
47
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
48
|
-
}
|
|
49
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
let Graphics = class Graphics extends pluginRenderer.Renderer {
|
|
53
|
-
constructor() {
|
|
54
|
-
super(...arguments);
|
|
55
|
-
this.name = 'Graphics';
|
|
56
|
-
}
|
|
57
|
-
init() {
|
|
58
|
-
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
59
|
-
this.renderSystem.rendererManager.register(this);
|
|
60
|
-
}
|
|
61
|
-
componentChanged(changed) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
64
|
-
this.containerManager.getContainer(changed.gameObject.id).addChildAt(changed.component.graphics, 0);
|
|
65
|
-
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
66
|
-
this.containerManager.getContainer(changed.gameObject.id).removeChild(changed.component.graphics);
|
|
67
|
-
changed.component.graphics.destroy({
|
|
68
|
-
children: true
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
Graphics.systemName = 'Graphics';
|
|
75
|
-
Graphics = __decorate([eva_js.decorators.componentObserver({
|
|
76
|
-
Graphics: ['graphics']
|
|
77
|
-
})], Graphics);
|
|
78
|
-
var Graphics$1 = Graphics;
|
|
79
|
-
exports.Graphics = Graphics$2;
|
|
80
|
-
exports.GraphicsSystem = Graphics$1;
|
|
81
|
-
Object.defineProperty(exports, '__esModule', {
|
|
82
|
-
value: true
|
|
83
|
-
});
|
|
84
|
-
return exports;
|
|
85
|
-
}({}, EVA, PIXI, EVA.plugin.renderer);
|
|
86
|
-
globalThis.EVA.plugin.renderer.graphics = globalThis.EVA.plugin.renderer.graphics || _EVA_IIFE_graphics;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_graphics=function(e,r,n,t){"use strict";class i extends n.Graphics{}class s extends r.Component{constructor(){super(...arguments),this.graphics=null}init(){this.graphics=new i}}function c(e,r,n,t){return new(n||(n=Promise))(function(i,s){function c(e){try{o(t.next(e))}catch(e){s(e)}}function a(e){try{o(t.throw(e))}catch(e){s(e)}}function o(e){var r;e.done?i(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(c,a)}o((t=t.apply(e,r||[])).next())})}s.componentName="Graphics";let a=class extends t.Renderer{constructor(){super(...arguments),this.name="Graphics"}init(){this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return c(this,void 0,void 0,function*(){e.type===r.OBSERVER_TYPE.ADD?this.containerManager.getContainer(e.gameObject.id).addChildAt(e.component.graphics,0):e.type===r.OBSERVER_TYPE.REMOVE&&(this.containerManager.getContainer(e.gameObject.id).removeChild(e.component.graphics),e.component.graphics.destroy({children:!0}))})}};a.systemName="Graphics",a=function(e,r,n,t){var i,s=arguments.length,c=s<3?r:null===t?t=Object.getOwnPropertyDescriptor(r,n):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,r,n,t);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(s<3?i(c):s>3?i(r,n,c):i(r,n))||c);return s>3&&c&&Object.defineProperty(r,n,c),c}([r.decorators.componentObserver({Graphics:["graphics"]})],a);var o=a;return e.Graphics=s,e.GraphicsSystem=o,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,PIXI,EVA.plugin.renderer);globalThis.EVA.plugin.renderer.graphics=globalThis.EVA.plugin.renderer.graphics||_EVA_IIFE_graphics;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var eva_js = require('@eva/eva.js');
|
|
6
|
-
var pixi_js = require('pixi.js');
|
|
7
|
-
var pluginRenderer = require('@eva/plugin-renderer');
|
|
8
|
-
|
|
9
|
-
class Graphics$3 extends pixi_js.Graphics {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 图形绘制组件
|
|
14
|
-
*
|
|
15
|
-
* Graphics 组件提供矢量图形绘制能力,可以动态绘制各种几何图形。
|
|
16
|
-
* 它基于 PixiJS Graphics,支持绘制线条、矩形、圆形、多边形等,
|
|
17
|
-
* 适用于调试可视化、动态UI、简单特效等场景。
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const shape = new GameObject('shape');
|
|
22
|
-
* const graphics = new Graphics();
|
|
23
|
-
* shape.addComponent(graphics);
|
|
24
|
-
*
|
|
25
|
-
* // 在组件初始化后使用 graphics 对象绘制
|
|
26
|
-
* graphics.graphics.clear();
|
|
27
|
-
* graphics.graphics.beginFill(0xff0000);
|
|
28
|
-
* graphics.graphics.drawCircle(100, 100, 50); // 绘制圆形
|
|
29
|
-
* graphics.graphics.endFill();
|
|
30
|
-
*
|
|
31
|
-
* // 绘制矩形
|
|
32
|
-
* graphics.graphics.lineStyle(2, 0x0000ff);
|
|
33
|
-
* graphics.graphics.drawRect(0, 0, 100, 100);
|
|
34
|
-
*
|
|
35
|
-
* // 绘制多边形
|
|
36
|
-
* graphics.graphics.beginFill(0x00ff00);
|
|
37
|
-
* graphics.graphics.drawPolygon([0,0, 100,0, 100,100, 0,100]);
|
|
38
|
-
* graphics.graphics.endFill();
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
class Graphics$2 extends eva_js.Component {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
/** PixiJS Graphics 实例,用于绘制矢量图形 */
|
|
45
|
-
this.graphics = null;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* 初始化组件
|
|
49
|
-
* 创建 Graphics 绘图对象实例
|
|
50
|
-
*/
|
|
51
|
-
init() {
|
|
52
|
-
this.graphics = new Graphics$3();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/** 组件名称 */
|
|
56
|
-
Graphics$2.componentName = 'Graphics';
|
|
57
|
-
|
|
58
|
-
/******************************************************************************
|
|
59
|
-
Copyright (c) Microsoft Corporation.
|
|
60
|
-
|
|
61
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
62
|
-
purpose with or without fee is hereby granted.
|
|
63
|
-
|
|
64
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
65
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
66
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
67
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
68
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
69
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
70
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
71
|
-
***************************************************************************** */
|
|
72
|
-
|
|
73
|
-
function __decorate(decorators, target, key, desc) {
|
|
74
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
75
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
76
|
-
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;
|
|
77
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
81
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
82
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
83
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
84
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
85
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
86
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
91
|
-
var e = new Error(message);
|
|
92
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
let Graphics = class Graphics extends pluginRenderer.Renderer {
|
|
96
|
-
constructor() {
|
|
97
|
-
super(...arguments);
|
|
98
|
-
this.name = 'Graphics';
|
|
99
|
-
}
|
|
100
|
-
init() {
|
|
101
|
-
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
102
|
-
this.renderSystem.rendererManager.register(this);
|
|
103
|
-
}
|
|
104
|
-
componentChanged(changed) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
107
|
-
this.containerManager
|
|
108
|
-
.getContainer(changed.gameObject.id)
|
|
109
|
-
.addChildAt(changed.component.graphics, 0);
|
|
110
|
-
}
|
|
111
|
-
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
112
|
-
this.containerManager
|
|
113
|
-
.getContainer(changed.gameObject.id)
|
|
114
|
-
.removeChild(changed.component.graphics);
|
|
115
|
-
changed.component.graphics.destroy({ children: true });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
Graphics.systemName = 'Graphics';
|
|
121
|
-
Graphics = __decorate([
|
|
122
|
-
eva_js.decorators.componentObserver({
|
|
123
|
-
Graphics: ['graphics'],
|
|
124
|
-
})
|
|
125
|
-
], Graphics);
|
|
126
|
-
var Graphics$1 = Graphics;
|
|
127
|
-
|
|
128
|
-
exports.Graphics = Graphics$2;
|
|
129
|
-
exports.GraphicsSystem = Graphics$1;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("pixi.js"),r=require("@eva/plugin-renderer");class n extends t.Graphics{}class s extends e.Component{constructor(){super(...arguments),this.graphics=null}init(){this.graphics=new n}}function i(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,c)}a((n=n.apply(e,t||[])).next())})}s.componentName="Graphics","function"==typeof SuppressedError&&SuppressedError;let o=class extends r.Renderer{constructor(){super(...arguments),this.name="Graphics"}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return i(this,void 0,void 0,function*(){t.type===e.OBSERVER_TYPE.ADD?this.containerManager.getContainer(t.gameObject.id).addChildAt(t.component.graphics,0):t.type===e.OBSERVER_TYPE.REMOVE&&(this.containerManager.getContainer(t.gameObject.id).removeChild(t.component.graphics),t.component.graphics.destroy({children:!0}))})}};o.systemName="Graphics",o=function(e,t,r,n){var s,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(o=(i<3?s(o):i>3?s(t,r,o):s(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}([e.decorators.componentObserver({Graphics:["graphics"]})],o);var c=o;exports.Graphics=s,exports.GraphicsSystem=c;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Component } from '@eva/eva.js';
|
|
2
|
-
import { ComponentChanged } from '@eva/eva.js';
|
|
3
|
-
import { ContainerManager } from '@eva/plugin-renderer';
|
|
4
|
-
import { Graphics as Graphics_2 } from '@eva/renderer-adapter';
|
|
5
|
-
import { Renderer } from '@eva/plugin-renderer';
|
|
6
|
-
import { RendererManager } from '@eva/plugin-renderer';
|
|
7
|
-
import { RendererSystem } from '@eva/plugin-renderer';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 图形绘制组件
|
|
11
|
-
*
|
|
12
|
-
* Graphics 组件提供矢量图形绘制能力,可以动态绘制各种几何图形。
|
|
13
|
-
* 它基于 PixiJS Graphics,支持绘制线条、矩形、圆形、多边形等,
|
|
14
|
-
* 适用于调试可视化、动态UI、简单特效等场景。
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const shape = new GameObject('shape');
|
|
19
|
-
* const graphics = new Graphics();
|
|
20
|
-
* shape.addComponent(graphics);
|
|
21
|
-
*
|
|
22
|
-
* // 在组件初始化后使用 graphics 对象绘制
|
|
23
|
-
* graphics.graphics.clear();
|
|
24
|
-
* graphics.graphics.beginFill(0xff0000);
|
|
25
|
-
* graphics.graphics.drawCircle(100, 100, 50); // 绘制圆形
|
|
26
|
-
* graphics.graphics.endFill();
|
|
27
|
-
*
|
|
28
|
-
* // 绘制矩形
|
|
29
|
-
* graphics.graphics.lineStyle(2, 0x0000ff);
|
|
30
|
-
* graphics.graphics.drawRect(0, 0, 100, 100);
|
|
31
|
-
*
|
|
32
|
-
* // 绘制多边形
|
|
33
|
-
* graphics.graphics.beginFill(0x00ff00);
|
|
34
|
-
* graphics.graphics.drawPolygon([0,0, 100,0, 100,100, 0,100]);
|
|
35
|
-
* graphics.graphics.endFill();
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare class Graphics extends Component {
|
|
39
|
-
/** 组件名称 */
|
|
40
|
-
static componentName: string;
|
|
41
|
-
/** PixiJS Graphics 实例,用于绘制矢量图形 */
|
|
42
|
-
graphics: Graphics_2;
|
|
43
|
-
/**
|
|
44
|
-
* 初始化组件
|
|
45
|
-
* 创建 Graphics 绘图对象实例
|
|
46
|
-
*/
|
|
47
|
-
init(): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export declare class GraphicsSystem extends Renderer {
|
|
51
|
-
static systemName: string;
|
|
52
|
-
name: string;
|
|
53
|
-
renderSystem: RendererSystem;
|
|
54
|
-
rendererManager: RendererManager;
|
|
55
|
-
containerManager: ContainerManager;
|
|
56
|
-
init(): void;
|
|
57
|
-
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { }
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Component, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
|
-
import { Graphics as Graphics$4 } from 'pixi.js';
|
|
3
|
-
import { Renderer, RendererSystem } from '@eva/plugin-renderer';
|
|
4
|
-
|
|
5
|
-
class Graphics$3 extends Graphics$4 {
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 图形绘制组件
|
|
10
|
-
*
|
|
11
|
-
* Graphics 组件提供矢量图形绘制能力,可以动态绘制各种几何图形。
|
|
12
|
-
* 它基于 PixiJS Graphics,支持绘制线条、矩形、圆形、多边形等,
|
|
13
|
-
* 适用于调试可视化、动态UI、简单特效等场景。
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const shape = new GameObject('shape');
|
|
18
|
-
* const graphics = new Graphics();
|
|
19
|
-
* shape.addComponent(graphics);
|
|
20
|
-
*
|
|
21
|
-
* // 在组件初始化后使用 graphics 对象绘制
|
|
22
|
-
* graphics.graphics.clear();
|
|
23
|
-
* graphics.graphics.beginFill(0xff0000);
|
|
24
|
-
* graphics.graphics.drawCircle(100, 100, 50); // 绘制圆形
|
|
25
|
-
* graphics.graphics.endFill();
|
|
26
|
-
*
|
|
27
|
-
* // 绘制矩形
|
|
28
|
-
* graphics.graphics.lineStyle(2, 0x0000ff);
|
|
29
|
-
* graphics.graphics.drawRect(0, 0, 100, 100);
|
|
30
|
-
*
|
|
31
|
-
* // 绘制多边形
|
|
32
|
-
* graphics.graphics.beginFill(0x00ff00);
|
|
33
|
-
* graphics.graphics.drawPolygon([0,0, 100,0, 100,100, 0,100]);
|
|
34
|
-
* graphics.graphics.endFill();
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
class Graphics$2 extends Component {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(...arguments);
|
|
40
|
-
/** PixiJS Graphics 实例,用于绘制矢量图形 */
|
|
41
|
-
this.graphics = null;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 初始化组件
|
|
45
|
-
* 创建 Graphics 绘图对象实例
|
|
46
|
-
*/
|
|
47
|
-
init() {
|
|
48
|
-
this.graphics = new Graphics$3();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/** 组件名称 */
|
|
52
|
-
Graphics$2.componentName = 'Graphics';
|
|
53
|
-
|
|
54
|
-
/******************************************************************************
|
|
55
|
-
Copyright (c) Microsoft Corporation.
|
|
56
|
-
|
|
57
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
58
|
-
purpose with or without fee is hereby granted.
|
|
59
|
-
|
|
60
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
61
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
62
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
63
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
64
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
65
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
66
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
67
|
-
***************************************************************************** */
|
|
68
|
-
|
|
69
|
-
function __decorate(decorators, target, key, desc) {
|
|
70
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
71
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
72
|
-
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;
|
|
73
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
77
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
78
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
79
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
80
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
81
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
82
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
87
|
-
var e = new Error(message);
|
|
88
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
let Graphics = class Graphics extends Renderer {
|
|
92
|
-
constructor() {
|
|
93
|
-
super(...arguments);
|
|
94
|
-
this.name = 'Graphics';
|
|
95
|
-
}
|
|
96
|
-
init() {
|
|
97
|
-
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
98
|
-
this.renderSystem.rendererManager.register(this);
|
|
99
|
-
}
|
|
100
|
-
componentChanged(changed) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
103
|
-
this.containerManager
|
|
104
|
-
.getContainer(changed.gameObject.id)
|
|
105
|
-
.addChildAt(changed.component.graphics, 0);
|
|
106
|
-
}
|
|
107
|
-
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
108
|
-
this.containerManager
|
|
109
|
-
.getContainer(changed.gameObject.id)
|
|
110
|
-
.removeChild(changed.component.graphics);
|
|
111
|
-
changed.component.graphics.destroy({ children: true });
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
Graphics.systemName = 'Graphics';
|
|
117
|
-
Graphics = __decorate([
|
|
118
|
-
decorators.componentObserver({
|
|
119
|
-
Graphics: ['graphics'],
|
|
120
|
-
})
|
|
121
|
-
], Graphics);
|
|
122
|
-
var Graphics$1 = Graphics;
|
|
123
|
-
|
|
124
|
-
export { Graphics$2 as Graphics, Graphics$1 as GraphicsSystem };
|