@next2d/display 1.14.20
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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/BitmapData.d.ts +142 -0
- package/dist/BitmapData.js +386 -0
- package/dist/BlendMode.d.ts +204 -0
- package/dist/BlendMode.js +240 -0
- package/dist/DisplayObject.d.ts +556 -0
- package/dist/DisplayObject.js +1671 -0
- package/dist/DisplayObjectContainer.d.ts +346 -0
- package/dist/DisplayObjectContainer.js +1775 -0
- package/dist/FrameLabel.d.ts +98 -0
- package/dist/FrameLabel.js +120 -0
- package/dist/Graphics.d.ts +571 -0
- package/dist/Graphics.js +2164 -0
- package/dist/GraphicsBitmapFill.d.ts +49 -0
- package/dist/GraphicsBitmapFill.js +86 -0
- package/dist/GraphicsGradientFill.d.ts +65 -0
- package/dist/GraphicsGradientFill.js +157 -0
- package/dist/InteractiveObject.d.ts +32 -0
- package/dist/InteractiveObject.js +43 -0
- package/dist/Loader.d.ts +130 -0
- package/dist/Loader.js +318 -0
- package/dist/LoaderInfo.d.ts +120 -0
- package/dist/LoaderInfo.js +184 -0
- package/dist/LoopConfig.d.ts +108 -0
- package/dist/LoopConfig.js +156 -0
- package/dist/LoopType.d.ts +104 -0
- package/dist/LoopType.js +122 -0
- package/dist/MovieClip.d.ts +310 -0
- package/dist/MovieClip.js +940 -0
- package/dist/Shape.d.ts +164 -0
- package/dist/Shape.js +509 -0
- package/dist/Sprite.d.ts +170 -0
- package/dist/Sprite.js +280 -0
- package/dist/Stage.d.ts +164 -0
- package/dist/Stage.js +251 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/package.json +45 -0
package/dist/Shape.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { LoaderInfo } from "./LoaderInfo";
|
|
2
|
+
import { DisplayObject } from "./DisplayObject";
|
|
3
|
+
import { Graphics } from "./Graphics";
|
|
4
|
+
import { CanvasToWebGLContext } from "@next2d/webgl";
|
|
5
|
+
import { BoundsImpl, ShapeCharacterImpl, ParentImpl, DictionaryTagImpl, PlayerHitObjectImpl, Character } from "@next2d/interface";
|
|
6
|
+
/**
|
|
7
|
+
* Shape クラスには、Graphics クラスからメソッドにアクセスできる graphics プロパティがあります。
|
|
8
|
+
*
|
|
9
|
+
* The Shape class includes a graphics property,
|
|
10
|
+
* which lets you access methods from the Graphics class.
|
|
11
|
+
*
|
|
12
|
+
* @class
|
|
13
|
+
* @memberOf next2d.display
|
|
14
|
+
* @extends DisplayObject
|
|
15
|
+
*/
|
|
16
|
+
export declare class Shape extends DisplayObject {
|
|
17
|
+
private _$graphics;
|
|
18
|
+
private _$bounds;
|
|
19
|
+
private _$bitmapId;
|
|
20
|
+
private _$src;
|
|
21
|
+
/**
|
|
22
|
+
* @constructor
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
constructor();
|
|
26
|
+
/**
|
|
27
|
+
* @description 指定されたクラスのストリングを返します。
|
|
28
|
+
* Returns the string representation of the specified class.
|
|
29
|
+
*
|
|
30
|
+
* @return {string}
|
|
31
|
+
* @default [class Shape]
|
|
32
|
+
* @method
|
|
33
|
+
* @static
|
|
34
|
+
*/
|
|
35
|
+
static toString(): string;
|
|
36
|
+
/**
|
|
37
|
+
* @description 指定されたクラスの空間名を返します。
|
|
38
|
+
* Returns the space name of the specified class.
|
|
39
|
+
*
|
|
40
|
+
* @return {string}
|
|
41
|
+
* @default next2d.display.Shape
|
|
42
|
+
* @const
|
|
43
|
+
* @static
|
|
44
|
+
*/
|
|
45
|
+
static get namespace(): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description 指定されたオブジェクトのストリングを返します。
|
|
48
|
+
* Returns the string representation of the specified object.
|
|
49
|
+
*
|
|
50
|
+
* @return {string}
|
|
51
|
+
* @default [object Shape]
|
|
52
|
+
* @method
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
toString(): string;
|
|
56
|
+
/**
|
|
57
|
+
* @description 指定されたオブジェクトの空間名を返します。
|
|
58
|
+
* Returns the space name of the specified object.
|
|
59
|
+
*
|
|
60
|
+
* @return {string}
|
|
61
|
+
* @default next2d.display.Shape
|
|
62
|
+
* @const
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
get namespace(): string;
|
|
66
|
+
/**
|
|
67
|
+
* @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
|
|
68
|
+
* Specifies the Graphics object that belongs to this sprite
|
|
69
|
+
* where vector drawing commands can occur.
|
|
70
|
+
*
|
|
71
|
+
* @member {Graphics}
|
|
72
|
+
* @readonly
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
get graphics(): Graphics;
|
|
76
|
+
/**
|
|
77
|
+
* @description 指定されたパスから画像を読み込み、Graphicsを生成します
|
|
78
|
+
* Reads images from the specified path and generates Graphics.
|
|
79
|
+
*
|
|
80
|
+
* @member {string}
|
|
81
|
+
* @readonly
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
get src(): string;
|
|
85
|
+
set src(src: string);
|
|
86
|
+
/**
|
|
87
|
+
* @param {object} character
|
|
88
|
+
* @param {LoaderInfo} loaderInfo
|
|
89
|
+
* @return {void}
|
|
90
|
+
* @method
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
_$buildCharacter(character: Character<ShapeCharacterImpl>, loaderInfo: LoaderInfo): void;
|
|
94
|
+
/**
|
|
95
|
+
* @return {void}
|
|
96
|
+
* @method
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
_$createWorkerInstance(): void;
|
|
100
|
+
/**
|
|
101
|
+
* @param {object} character
|
|
102
|
+
* @return {void}
|
|
103
|
+
* @method
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
106
|
+
_$sync(character: ShapeCharacterImpl): void;
|
|
107
|
+
/**
|
|
108
|
+
* @param {object} tag
|
|
109
|
+
* @param {DisplayObjectContainer} parent
|
|
110
|
+
* @return {object}
|
|
111
|
+
* @method
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
_$build(tag: DictionaryTagImpl, parent: ParentImpl<any>): ShapeCharacterImpl;
|
|
115
|
+
/**
|
|
116
|
+
* @param {Float32Array} [matrix=null]
|
|
117
|
+
* @returns {object}
|
|
118
|
+
* @method
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
_$getBounds(matrix?: Float32Array | null): BoundsImpl;
|
|
122
|
+
/**
|
|
123
|
+
* @param {CanvasToWebGLContext} context
|
|
124
|
+
* @param {Float32Array} matrix
|
|
125
|
+
* @param {Float32Array} color_transform
|
|
126
|
+
* @return {void}
|
|
127
|
+
* @method
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
_$draw(context: CanvasToWebGLContext, matrix: Float32Array, color_transform: Float32Array): void;
|
|
131
|
+
/**
|
|
132
|
+
* @param {CanvasToWebGLContext} context
|
|
133
|
+
* @param {Float32Array} matrix
|
|
134
|
+
* @returns {void}
|
|
135
|
+
* @method
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
_$clip(context: CanvasToWebGLContext, matrix: Float32Array): void;
|
|
139
|
+
/**
|
|
140
|
+
* @param {CanvasRenderingContext2D} context
|
|
141
|
+
* @param {Float32Array} matrix
|
|
142
|
+
* @param {object} options
|
|
143
|
+
* @return {boolean}
|
|
144
|
+
* @method
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
_$mouseHit(context: CanvasRenderingContext2D, matrix: Float32Array, options: PlayerHitObjectImpl): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* @param {CanvasRenderingContext2D} context
|
|
150
|
+
* @param {Float32Array} matrix
|
|
151
|
+
* @param {object} options
|
|
152
|
+
* @param {boolean} [is_clip=false]
|
|
153
|
+
* @return {boolean}
|
|
154
|
+
* @method
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
_$hit(context: CanvasRenderingContext2D, matrix: Float32Array, options: PlayerHitObjectImpl, is_clip?: boolean): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* @return {void}
|
|
160
|
+
* @method
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
_$postProperty(): void;
|
|
164
|
+
}
|
package/dist/Shape.js
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { DisplayObject } from "./DisplayObject";
|
|
2
|
+
import { Graphics } from "./Graphics";
|
|
3
|
+
import { BitmapData } from "./BitmapData";
|
|
4
|
+
import { Rectangle } from "@next2d/geom";
|
|
5
|
+
import { Event } from "@next2d/events";
|
|
6
|
+
import { $MATRIX_HIT_ARRAY_IDENTITY, $rendererWorker } from "@next2d/util";
|
|
7
|
+
import { $getArray, $poolArray, $getFloat32Array6, $getBoundsObject, $poolBoundsObject, $multiplicationMatrix, $boundsMatrix, $poolFloat32Array6, $multiplicationColor, $clamp, $poolFloat32Array8, $Math, $COLOR_ARRAY_IDENTITY } from "@next2d/share";
|
|
8
|
+
/**
|
|
9
|
+
* Shape クラスには、Graphics クラスからメソッドにアクセスできる graphics プロパティがあります。
|
|
10
|
+
*
|
|
11
|
+
* The Shape class includes a graphics property,
|
|
12
|
+
* which lets you access methods from the Graphics class.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @memberOf next2d.display
|
|
16
|
+
* @extends DisplayObject
|
|
17
|
+
*/
|
|
18
|
+
export class Shape extends DisplayObject {
|
|
19
|
+
/**
|
|
20
|
+
* @constructor
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
/**
|
|
26
|
+
* @type {Graphics}
|
|
27
|
+
* @default null
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
this._$graphics = null;
|
|
31
|
+
/**
|
|
32
|
+
* @type {object}
|
|
33
|
+
* @default null
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
this._$bounds = null;
|
|
37
|
+
/**
|
|
38
|
+
* @type {number}
|
|
39
|
+
* @default 0
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
this._$bitmapId = 0;
|
|
43
|
+
/**
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @default ""
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
this._$src = "";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @description 指定されたクラスのストリングを返します。
|
|
52
|
+
* Returns the string representation of the specified class.
|
|
53
|
+
*
|
|
54
|
+
* @return {string}
|
|
55
|
+
* @default [class Shape]
|
|
56
|
+
* @method
|
|
57
|
+
* @static
|
|
58
|
+
*/
|
|
59
|
+
static toString() {
|
|
60
|
+
return "[class Shape]";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @description 指定されたクラスの空間名を返します。
|
|
64
|
+
* Returns the space name of the specified class.
|
|
65
|
+
*
|
|
66
|
+
* @return {string}
|
|
67
|
+
* @default next2d.display.Shape
|
|
68
|
+
* @const
|
|
69
|
+
* @static
|
|
70
|
+
*/
|
|
71
|
+
static get namespace() {
|
|
72
|
+
return "next2d.display.Shape";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @description 指定されたオブジェクトのストリングを返します。
|
|
76
|
+
* Returns the string representation of the specified object.
|
|
77
|
+
*
|
|
78
|
+
* @return {string}
|
|
79
|
+
* @default [object Shape]
|
|
80
|
+
* @method
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
toString() {
|
|
84
|
+
return "[object Shape]";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @description 指定されたオブジェクトの空間名を返します。
|
|
88
|
+
* Returns the space name of the specified object.
|
|
89
|
+
*
|
|
90
|
+
* @return {string}
|
|
91
|
+
* @default next2d.display.Shape
|
|
92
|
+
* @const
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
get namespace() {
|
|
96
|
+
return "next2d.display.Shape";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @description ベクターの描画コマンドが発生するこのスプライトに属する Graphics オブジェクトを指定します。
|
|
100
|
+
* Specifies the Graphics object that belongs to this sprite
|
|
101
|
+
* where vector drawing commands can occur.
|
|
102
|
+
*
|
|
103
|
+
* @member {Graphics}
|
|
104
|
+
* @readonly
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
get graphics() {
|
|
108
|
+
if (!this._$graphics) {
|
|
109
|
+
this._$graphics = new Graphics(this);
|
|
110
|
+
}
|
|
111
|
+
return this._$graphics;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @description 指定されたパスから画像を読み込み、Graphicsを生成します
|
|
115
|
+
* Reads images from the specified path and generates Graphics.
|
|
116
|
+
*
|
|
117
|
+
* @member {string}
|
|
118
|
+
* @readonly
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
get src() {
|
|
122
|
+
return this._$src;
|
|
123
|
+
}
|
|
124
|
+
set src(src) {
|
|
125
|
+
const image = new Image();
|
|
126
|
+
image.addEventListener("load", () => {
|
|
127
|
+
const width = image.width;
|
|
128
|
+
const height = image.height;
|
|
129
|
+
const bitmapData = new BitmapData(width, height);
|
|
130
|
+
bitmapData.image = image;
|
|
131
|
+
this
|
|
132
|
+
.graphics
|
|
133
|
+
.beginBitmapFill(bitmapData)
|
|
134
|
+
.drawRect(0, 0, width, height);
|
|
135
|
+
if (this.hasEventListener(Event.LOAD)) {
|
|
136
|
+
this.dispatchEvent(new Event(Event.LOAD));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
this._$src = image.src = src;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @param {object} character
|
|
143
|
+
* @param {LoaderInfo} loaderInfo
|
|
144
|
+
* @return {void}
|
|
145
|
+
* @method
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
_$buildCharacter(character, loaderInfo) {
|
|
149
|
+
const graphics = this.graphics;
|
|
150
|
+
if (!loaderInfo._$data) {
|
|
151
|
+
throw new Error("the loaderInfo data is null.");
|
|
152
|
+
}
|
|
153
|
+
if (character.recodes) {
|
|
154
|
+
switch (true) {
|
|
155
|
+
case character.bitmapId > 0:
|
|
156
|
+
{
|
|
157
|
+
this._$bitmapId = character.bitmapId;
|
|
158
|
+
const bitmap = loaderInfo
|
|
159
|
+
._$data
|
|
160
|
+
.characters[character.bitmapId];
|
|
161
|
+
if (!bitmap.buffer) {
|
|
162
|
+
throw new Error("the bitmap buffer is null.");
|
|
163
|
+
}
|
|
164
|
+
const width = $Math.abs(bitmap.bounds.xMax - bitmap.bounds.xMin);
|
|
165
|
+
const height = $Math.abs(bitmap.bounds.yMax - bitmap.bounds.yMin);
|
|
166
|
+
const bitmapData = new BitmapData(width, height);
|
|
167
|
+
if (!bitmap._$buffer) {
|
|
168
|
+
bitmap._$buffer = new Uint8Array(bitmap.buffer);
|
|
169
|
+
$poolArray(bitmap.buffer);
|
|
170
|
+
bitmap.buffer = null;
|
|
171
|
+
}
|
|
172
|
+
bitmapData.buffer = bitmap._$buffer.slice();
|
|
173
|
+
// setup
|
|
174
|
+
graphics._$recode = $getArray();
|
|
175
|
+
// clone
|
|
176
|
+
const recodes = character.recodes;
|
|
177
|
+
if (recodes[recodes.length - 1] === Graphics.END_FILL) {
|
|
178
|
+
const length = recodes.length - 6;
|
|
179
|
+
for (let idx = 0; idx < length; ++idx) {
|
|
180
|
+
graphics._$recode.push(recodes[idx]);
|
|
181
|
+
}
|
|
182
|
+
// add Bitmap Fill
|
|
183
|
+
graphics._$recode.push(Graphics.BITMAP_FILL, bitmapData, null, "repeat", false);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const width = recodes[recodes.length - 9];
|
|
187
|
+
const caps = recodes[recodes.length - 8];
|
|
188
|
+
const joints = recodes[recodes.length - 7];
|
|
189
|
+
const miterLimit = recodes[recodes.length - 6];
|
|
190
|
+
const length = recodes.length - 10;
|
|
191
|
+
for (let idx = 0; idx < length; ++idx) {
|
|
192
|
+
graphics._$recode.push(recodes[idx]);
|
|
193
|
+
}
|
|
194
|
+
graphics._$recode.push(Graphics.BITMAP_STROKE, width, caps, joints, miterLimit, bitmapData, $getFloat32Array6(1, 0, 0, 1, character.bounds.xMin, character.bounds.yMin), "repeat", false);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
case character.inBitmap:
|
|
199
|
+
{
|
|
200
|
+
// setup
|
|
201
|
+
graphics._$recode = $getArray();
|
|
202
|
+
const recodes = character.recodes;
|
|
203
|
+
for (let idx = 0; idx < recodes.length; ++idx) {
|
|
204
|
+
const value = recodes[idx];
|
|
205
|
+
graphics._$recode[idx] = value;
|
|
206
|
+
if (typeof value !== "object") {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (!value.buffer) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const bitmapData = new BitmapData(value.width, value.height);
|
|
213
|
+
bitmapData.buffer = new Uint8Array(value.buffer);
|
|
214
|
+
graphics._$recode[idx++] = bitmapData;
|
|
215
|
+
const matrix = recodes[idx];
|
|
216
|
+
graphics._$recode[idx] = $getFloat32Array6(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
default:
|
|
221
|
+
graphics._$recode = character.recodes.slice(0);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const width = $Math.abs(character.bounds.xMax - character.bounds.xMin);
|
|
227
|
+
const height = $Math.abs(character.bounds.yMax - character.bounds.yMin);
|
|
228
|
+
const bitmapData = new BitmapData(width, height);
|
|
229
|
+
if (!character._$buffer) {
|
|
230
|
+
if (!character.buffer) {
|
|
231
|
+
throw new Error("the bitmap buffer is null.");
|
|
232
|
+
}
|
|
233
|
+
character._$buffer = new Uint8Array(character.buffer);
|
|
234
|
+
$poolArray(character.buffer);
|
|
235
|
+
character.buffer = null;
|
|
236
|
+
}
|
|
237
|
+
bitmapData.buffer = character._$buffer.slice(0);
|
|
238
|
+
graphics
|
|
239
|
+
.beginBitmapFill(bitmapData, null, false)
|
|
240
|
+
.drawRect(0, 0, width, height);
|
|
241
|
+
}
|
|
242
|
+
graphics._$maxAlpha = 1;
|
|
243
|
+
graphics._$canDraw = true;
|
|
244
|
+
graphics._$xMin = character.bounds.xMin;
|
|
245
|
+
graphics._$xMax = character.bounds.xMax;
|
|
246
|
+
graphics._$yMin = character.bounds.yMin;
|
|
247
|
+
graphics._$yMax = character.bounds.yMax;
|
|
248
|
+
// 9-scale
|
|
249
|
+
if (character.grid) {
|
|
250
|
+
this._$scale9Grid = new Rectangle(character.grid.x, character.grid.y, character.grid.w, character.grid.h);
|
|
251
|
+
}
|
|
252
|
+
if ($rendererWorker && this._$stage) {
|
|
253
|
+
this._$createWorkerInstance();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @return {void}
|
|
258
|
+
* @method
|
|
259
|
+
* @private
|
|
260
|
+
*/
|
|
261
|
+
_$createWorkerInstance() {
|
|
262
|
+
if (this._$created || !$rendererWorker) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this._$created = true;
|
|
266
|
+
const options = $getArray();
|
|
267
|
+
const bounds = this._$getBounds();
|
|
268
|
+
const message = {
|
|
269
|
+
"command": "createShape",
|
|
270
|
+
"instanceId": this._$instanceId,
|
|
271
|
+
"parentId": this._$parent ? this._$parent._$instanceId : -1,
|
|
272
|
+
"maxAlpha": 0,
|
|
273
|
+
"canDraw": false,
|
|
274
|
+
"xMin": bounds.xMin,
|
|
275
|
+
"yMin": bounds.yMin,
|
|
276
|
+
"xMax": bounds.xMax,
|
|
277
|
+
"yMax": bounds.yMax
|
|
278
|
+
};
|
|
279
|
+
const graphics = this._$graphics;
|
|
280
|
+
if (graphics) {
|
|
281
|
+
const recodes = graphics._$getRecodes();
|
|
282
|
+
if (recodes.length
|
|
283
|
+
&& graphics._$maxAlpha > 0
|
|
284
|
+
&& graphics._$canDraw) {
|
|
285
|
+
message.maxAlpha = graphics._$maxAlpha;
|
|
286
|
+
message.canDraw = graphics._$canDraw;
|
|
287
|
+
message.recodes = recodes;
|
|
288
|
+
options.push(recodes.buffer);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (this._$characterId > -1) {
|
|
292
|
+
message.characterId = this._$characterId;
|
|
293
|
+
}
|
|
294
|
+
if (this._$loaderInfo) {
|
|
295
|
+
message.loaderInfoId = this._$loaderInfo._$id;
|
|
296
|
+
}
|
|
297
|
+
if (this._$scale9Grid) {
|
|
298
|
+
message.grid = {
|
|
299
|
+
"x": this._$scale9Grid.x,
|
|
300
|
+
"y": this._$scale9Grid.y,
|
|
301
|
+
"w": this._$scale9Grid.width,
|
|
302
|
+
"h": this._$scale9Grid.height
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
$rendererWorker.postMessage(message, options);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @param {object} character
|
|
309
|
+
* @return {void}
|
|
310
|
+
* @method
|
|
311
|
+
* @protected
|
|
312
|
+
*/
|
|
313
|
+
_$sync(character) {
|
|
314
|
+
if (this._$loaderInfo) {
|
|
315
|
+
this._$buildCharacter(character, this._$loaderInfo);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @param {object} tag
|
|
320
|
+
* @param {DisplayObjectContainer} parent
|
|
321
|
+
* @return {object}
|
|
322
|
+
* @method
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
_$build(tag, parent) {
|
|
326
|
+
const character = this
|
|
327
|
+
._$baseBuild(tag, parent);
|
|
328
|
+
this._$buildCharacter(character, parent._$loaderInfo);
|
|
329
|
+
return character;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @param {Float32Array} [matrix=null]
|
|
333
|
+
* @returns {object}
|
|
334
|
+
* @method
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
_$getBounds(matrix = null) {
|
|
338
|
+
if (!this._$graphics) {
|
|
339
|
+
return $getBoundsObject(0, 0, 0, 0);
|
|
340
|
+
}
|
|
341
|
+
const baseBounds = this._$graphics._$getBounds();
|
|
342
|
+
if (!matrix) {
|
|
343
|
+
return baseBounds;
|
|
344
|
+
}
|
|
345
|
+
let multiMatrix = matrix;
|
|
346
|
+
const rawMatrix = this._$transform._$rawMatrix();
|
|
347
|
+
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
348
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
349
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
350
|
+
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
351
|
+
}
|
|
352
|
+
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
353
|
+
$poolBoundsObject(baseBounds);
|
|
354
|
+
if (multiMatrix !== matrix) {
|
|
355
|
+
$poolFloat32Array6(multiMatrix);
|
|
356
|
+
}
|
|
357
|
+
return bounds;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* @param {CanvasToWebGLContext} context
|
|
361
|
+
* @param {Float32Array} matrix
|
|
362
|
+
* @param {Float32Array} color_transform
|
|
363
|
+
* @return {void}
|
|
364
|
+
* @method
|
|
365
|
+
* @private
|
|
366
|
+
*/
|
|
367
|
+
_$draw(context, matrix, color_transform) {
|
|
368
|
+
if (!this._$visible) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (!this._$graphics || !this._$graphics._$canDraw) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
let multiColor = color_transform;
|
|
375
|
+
const rawColor = this._$transform._$rawColorTransform();
|
|
376
|
+
if (rawColor !== $COLOR_ARRAY_IDENTITY
|
|
377
|
+
&& rawColor[0] !== 1 || rawColor[1] !== 1
|
|
378
|
+
|| rawColor[2] !== 1 || rawColor[3] !== 1
|
|
379
|
+
|| rawColor[4] !== 0 || rawColor[5] !== 0
|
|
380
|
+
|| rawColor[6] !== 0 || rawColor[7] !== 0) {
|
|
381
|
+
multiColor = $multiplicationColor(color_transform, rawColor);
|
|
382
|
+
}
|
|
383
|
+
const alpha = $clamp(multiColor[3] + multiColor[7] / 255, 0, 1, 0);
|
|
384
|
+
if (!alpha) {
|
|
385
|
+
if (multiColor !== color_transform) {
|
|
386
|
+
$poolFloat32Array8(multiColor);
|
|
387
|
+
}
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const filters = this._$filters || this.filters;
|
|
391
|
+
const blendMode = this._$blendMode || this.blendMode;
|
|
392
|
+
let multiMatrix = matrix;
|
|
393
|
+
const rawMatrix = this._$transform._$rawMatrix();
|
|
394
|
+
if (rawMatrix !== $MATRIX_HIT_ARRAY_IDENTITY
|
|
395
|
+
&& rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
396
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
397
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
398
|
+
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
399
|
+
}
|
|
400
|
+
this
|
|
401
|
+
._$graphics
|
|
402
|
+
._$draw(context, multiMatrix, multiColor, blendMode, filters);
|
|
403
|
+
if (multiMatrix !== matrix) {
|
|
404
|
+
$poolFloat32Array6(multiMatrix);
|
|
405
|
+
}
|
|
406
|
+
if (multiColor !== color_transform) {
|
|
407
|
+
$poolFloat32Array8(multiColor);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* @param {CanvasToWebGLContext} context
|
|
412
|
+
* @param {Float32Array} matrix
|
|
413
|
+
* @returns {void}
|
|
414
|
+
* @method
|
|
415
|
+
* @private
|
|
416
|
+
*/
|
|
417
|
+
_$clip(context, matrix) {
|
|
418
|
+
if (!this._$graphics) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
let multiMatrix = matrix;
|
|
422
|
+
const rawMatrix = this._$transform._$rawMatrix();
|
|
423
|
+
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
424
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
425
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
426
|
+
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
427
|
+
}
|
|
428
|
+
this._$graphics._$clip(context, multiMatrix);
|
|
429
|
+
if (multiMatrix !== matrix) {
|
|
430
|
+
$poolFloat32Array6(multiMatrix);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @param {CanvasRenderingContext2D} context
|
|
435
|
+
* @param {Float32Array} matrix
|
|
436
|
+
* @param {object} options
|
|
437
|
+
* @return {boolean}
|
|
438
|
+
* @method
|
|
439
|
+
* @private
|
|
440
|
+
*/
|
|
441
|
+
_$mouseHit(context, matrix, options) {
|
|
442
|
+
if (!this._$visible) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
return this._$hit(context, matrix, options);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* @param {CanvasRenderingContext2D} context
|
|
449
|
+
* @param {Float32Array} matrix
|
|
450
|
+
* @param {object} options
|
|
451
|
+
* @param {boolean} [is_clip=false]
|
|
452
|
+
* @return {boolean}
|
|
453
|
+
* @method
|
|
454
|
+
* @private
|
|
455
|
+
*/
|
|
456
|
+
_$hit(context, matrix, options, is_clip = false) {
|
|
457
|
+
let hit = false;
|
|
458
|
+
const graphics = this._$graphics;
|
|
459
|
+
if (graphics
|
|
460
|
+
&& graphics._$canDraw
|
|
461
|
+
&& graphics._$getBounds()) {
|
|
462
|
+
let multiMatrix = matrix;
|
|
463
|
+
const rawMatrix = this._$transform._$rawMatrix();
|
|
464
|
+
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
465
|
+
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
466
|
+
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
467
|
+
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
468
|
+
}
|
|
469
|
+
hit = graphics._$hit(context, multiMatrix, options, is_clip);
|
|
470
|
+
if (multiMatrix !== matrix) {
|
|
471
|
+
$poolFloat32Array6(multiMatrix);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return hit;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* @return {void}
|
|
478
|
+
* @method
|
|
479
|
+
* @private
|
|
480
|
+
*/
|
|
481
|
+
_$postProperty() {
|
|
482
|
+
if (!$rendererWorker) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const message = this._$createMessage();
|
|
486
|
+
const graphics = this._$graphics;
|
|
487
|
+
if (graphics && !graphics._$buffer) {
|
|
488
|
+
message.maxAlpha = graphics._$maxAlpha;
|
|
489
|
+
message.canDraw = graphics._$canDraw;
|
|
490
|
+
const recodes = graphics._$getRecodes();
|
|
491
|
+
message.recodes = recodes;
|
|
492
|
+
const options = $getArray(recodes.buffer);
|
|
493
|
+
const bounds = this._$getBounds();
|
|
494
|
+
message.xMin = bounds.xMin;
|
|
495
|
+
message.yMin = bounds.yMin;
|
|
496
|
+
message.xMax = bounds.xMax;
|
|
497
|
+
message.yMax = bounds.yMax;
|
|
498
|
+
$rendererWorker
|
|
499
|
+
.postMessage(message, options);
|
|
500
|
+
$poolArray(options);
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
$rendererWorker
|
|
504
|
+
.postMessage(message);
|
|
505
|
+
}
|
|
506
|
+
this._$posted = true;
|
|
507
|
+
this._$updated = false;
|
|
508
|
+
}
|
|
509
|
+
}
|