@next2d/core 1.15.0 → 1.17.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/Display.js +3 -2
- package/dist/Next2D.js +27 -16
- package/dist/Player.d.ts +24 -28
- package/dist/Player.js +106 -105
- package/dist/Text.js +1 -2
- package/package.json +12 -12
package/dist/Display.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayObject, InteractiveObject, DisplayObjectContainer, Sprite, MovieClip, BitmapData, BlendMode, FrameLabel, Graphics, Loader, LoaderInfo, Shape, Stage } from "@next2d/display";
|
|
1
|
+
import { DisplayObject, InteractiveObject, DisplayObjectContainer, Sprite, MovieClip, BitmapData, BlendMode, FrameLabel, Graphics, Loader, LoaderInfo, Shape, Stage, TextField } from "@next2d/display";
|
|
2
2
|
const display = {
|
|
3
3
|
DisplayObject,
|
|
4
4
|
InteractiveObject,
|
|
@@ -12,7 +12,8 @@ const display = {
|
|
|
12
12
|
Loader,
|
|
13
13
|
LoaderInfo,
|
|
14
14
|
Shape,
|
|
15
|
-
Stage
|
|
15
|
+
Stage,
|
|
16
|
+
TextField
|
|
16
17
|
};
|
|
17
18
|
Object.entries(display).forEach(([key, DisplayClass]) => {
|
|
18
19
|
Object.defineProperty(display, key, {
|
package/dist/Next2D.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { events } from "./Events";
|
|
2
11
|
import { display } from "./Display";
|
|
3
12
|
import { filters } from "./Filters";
|
|
@@ -169,22 +178,24 @@ export class Next2D {
|
|
|
169
178
|
* @public
|
|
170
179
|
*/
|
|
171
180
|
createRootMovieClip(width = 240, height = 240, fps = 24, options = null) {
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
return Promise
|
|
183
|
+
.all(this._$promises)
|
|
184
|
+
.then(() => {
|
|
185
|
+
$poolArray(this._$promises);
|
|
186
|
+
const player = this._$player;
|
|
187
|
+
// setup
|
|
188
|
+
player.width = width | 0;
|
|
189
|
+
player.height = height | 0;
|
|
190
|
+
player.mode = "create";
|
|
191
|
+
player.stage._$frameRate = fps | 0;
|
|
192
|
+
player.setOptions(options);
|
|
193
|
+
player._$initialize();
|
|
194
|
+
const root = player.stage.addChild(new Sprite());
|
|
195
|
+
player._$loadStatus = Player.LOAD_END;
|
|
196
|
+
player.play();
|
|
197
|
+
return root;
|
|
198
|
+
});
|
|
188
199
|
});
|
|
189
200
|
}
|
|
190
201
|
}
|
package/dist/Player.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CacheStore } from "@next2d/share";
|
|
2
1
|
import { Stage, MovieClip } from "@next2d/display";
|
|
3
2
|
import { Event as Next2DEvent } from "@next2d/events";
|
|
4
3
|
import { Video, Sound } from "@next2d/media";
|
|
5
4
|
import { CanvasToWebGLContext } from "@next2d/webgl";
|
|
6
5
|
import { PlayerOptionsImpl, PlayerModeImpl, AttachmentImpl, EventListenerImpl, EventDispatcherImpl } from "@next2d/interface";
|
|
6
|
+
import { CacheStore } from "@next2d/share";
|
|
7
7
|
/**
|
|
8
8
|
* 描画のイベントや設定やコントロールの管理クラス
|
|
9
9
|
* Management classes for drawing events, settings and controls
|
|
@@ -11,55 +11,52 @@ import { PlayerOptionsImpl, PlayerModeImpl, AttachmentImpl, EventListenerImpl, E
|
|
|
11
11
|
* @class
|
|
12
12
|
*/
|
|
13
13
|
export declare class Player {
|
|
14
|
-
|
|
15
|
-
private readonly _$cacheStore;
|
|
16
|
-
private _$mode;
|
|
14
|
+
_$stopFlag: boolean;
|
|
17
15
|
_$actionOffset: number;
|
|
18
16
|
_$actions: MovieClip[];
|
|
19
17
|
_$loaders: EventDispatcherImpl<any>[];
|
|
20
18
|
_$sounds: Map<any, MovieClip>;
|
|
19
|
+
_$loadStatus: number;
|
|
20
|
+
_$width: number;
|
|
21
|
+
_$height: number;
|
|
22
|
+
_$scale: number;
|
|
23
|
+
_$state: "up" | "down";
|
|
24
|
+
_$attachment: AttachmentImpl | null;
|
|
25
|
+
readonly _$videos: Video[];
|
|
26
|
+
readonly _$sources: Sound[];
|
|
27
|
+
private _$mode;
|
|
21
28
|
private _$context;
|
|
22
|
-
private readonly _$hitObject;
|
|
23
29
|
private _$rollOverObject;
|
|
24
30
|
private _$mouseOverTarget;
|
|
25
|
-
private readonly _$ratio;
|
|
26
|
-
_$stopFlag: boolean;
|
|
27
31
|
private _$startTime;
|
|
28
32
|
private _$fps;
|
|
29
|
-
private _$isLoad;
|
|
30
|
-
_$loadStatus: number;
|
|
31
|
-
_$width: number;
|
|
32
|
-
_$height: number;
|
|
33
33
|
private _$baseWidth;
|
|
34
34
|
private _$baseHeight;
|
|
35
|
-
_$scale: number;
|
|
36
|
-
private readonly _$matrix;
|
|
37
35
|
private _$tx;
|
|
38
36
|
private _$ty;
|
|
39
|
-
_$state: "up" | "down";
|
|
40
37
|
private _$hitTestStart;
|
|
41
38
|
private _$stageX;
|
|
42
39
|
private _$stageY;
|
|
43
|
-
private readonly _$broadcastEvents;
|
|
44
40
|
private _$optionWidth;
|
|
45
41
|
private _$optionHeight;
|
|
46
42
|
private _$tagId;
|
|
47
43
|
private _$bgColor;
|
|
48
44
|
private _$base;
|
|
49
|
-
readonly _$videos: Video[];
|
|
50
|
-
readonly _$sources: Sound[];
|
|
51
45
|
private _$fullScreen;
|
|
52
|
-
private readonly _$quality;
|
|
53
46
|
private _$textField;
|
|
54
|
-
private _$touchY;
|
|
55
47
|
private _$timerId;
|
|
56
48
|
private _$loadId;
|
|
57
|
-
_$attachment: AttachmentImpl | null;
|
|
58
|
-
private readonly _$canvas;
|
|
59
49
|
private _$deltaX;
|
|
60
50
|
private _$deltaY;
|
|
61
51
|
private _$clickTarget;
|
|
62
52
|
private _$actionProcess;
|
|
53
|
+
private readonly _$stage;
|
|
54
|
+
private readonly _$hitObject;
|
|
55
|
+
private readonly _$ratio;
|
|
56
|
+
private readonly _$matrix;
|
|
57
|
+
private readonly _$broadcastEvents;
|
|
58
|
+
private readonly _$quality;
|
|
59
|
+
private readonly _$canvas;
|
|
63
60
|
/**
|
|
64
61
|
* @constructor
|
|
65
62
|
* @public
|
|
@@ -80,24 +77,23 @@ export declare class Player {
|
|
|
80
77
|
*/
|
|
81
78
|
static get LOAD_END(): number;
|
|
82
79
|
/**
|
|
83
|
-
* @
|
|
80
|
+
* @return {CacheStore}
|
|
84
81
|
* @readonly
|
|
85
82
|
* @public
|
|
86
83
|
*/
|
|
87
|
-
get
|
|
84
|
+
get cacheStore(): CacheStore;
|
|
88
85
|
/**
|
|
89
|
-
* @
|
|
86
|
+
* @type {HTMLCanvasElement}
|
|
90
87
|
* @readonly
|
|
91
88
|
* @public
|
|
92
89
|
*/
|
|
93
|
-
get
|
|
90
|
+
get canvas(): HTMLCanvasElement;
|
|
94
91
|
/**
|
|
95
|
-
* @
|
|
96
|
-
* @return {CacheStore}
|
|
92
|
+
* @return {Map}
|
|
97
93
|
* @readonly
|
|
98
94
|
* @public
|
|
99
95
|
*/
|
|
100
|
-
get
|
|
96
|
+
get broadcastEvents(): Map<string, EventListenerImpl[]>;
|
|
101
97
|
/**
|
|
102
98
|
* @member {CanvasToWebGLContext|null}
|
|
103
99
|
* @default null
|
package/dist/Player.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CacheStore } from "@next2d/share";
|
|
2
1
|
import { Stage } from "@next2d/display";
|
|
3
2
|
import { Event as Next2DEvent, MouseEvent as Next2DMouseEvent, EventPhase } from "@next2d/events";
|
|
4
3
|
import { SoundMixer } from "@next2d/media";
|
|
5
4
|
import { CanvasToWebGLContext } from "@next2d/webgl";
|
|
6
|
-
import { $
|
|
7
|
-
import { $Math, $performance, $COLOR_ARRAY_IDENTITY, $doUpdated, $isUpdated, $getArray, $getFloat32Array6, $getMap, $uintToRGBA, $toColorInt, $requestAnimationFrame, $cancelAnimationFrame, $poolArray, $clamp } from "@next2d/share";
|
|
5
|
+
import { $document, $window, $rendererWorker, $PREFIX, $audioContext, $TOUCH_START, $TOUCH_MOVE, $TOUCH_END, $MOUSE_DOWN, $MOUSE_MOVE, $MOUSE_UP, $MOUSE_WHEEL, $DOUBLE_CLICK, $MOUSE_LEAVE, $loadAudioData, $MATRIX_HIT_ARRAY_IDENTITY, $hitContext, $isTouch, $dropTarget, $dragRules, $isSafari, $getEvent, $setEvent, $setEventType, $setCurrentLoaderInfo, $getEventType, $getRenderBufferArray, $getRenderMessageObject, $poolRenderMessageObject } from "@next2d/util";
|
|
6
|
+
import { $Math, $performance, $COLOR_ARRAY_IDENTITY, $doUpdated, $isUpdated, $getArray, $getFloat32Array6, $getMap, $uintToRGBA, $toColorInt, $requestAnimationFrame, $cancelAnimationFrame, $poolArray, $clamp, $devicePixelRatio, $setDevicePixelRatio, $cacheStore } from "@next2d/share";
|
|
8
7
|
/**
|
|
9
8
|
* 描画のイベントや設定やコントロールの管理クラス
|
|
10
9
|
* Management classes for drawing events, settings and controls
|
|
@@ -17,17 +16,14 @@ export class Player {
|
|
|
17
16
|
* @public
|
|
18
17
|
*/
|
|
19
18
|
constructor() {
|
|
19
|
+
// init
|
|
20
|
+
$setDevicePixelRatio(window.devicePixelRatio);
|
|
20
21
|
/**
|
|
21
22
|
* @type {Stage}
|
|
22
23
|
* @private
|
|
23
24
|
*/
|
|
24
25
|
this._$stage = new Stage();
|
|
25
26
|
this._$stage._$player = this;
|
|
26
|
-
/**
|
|
27
|
-
* @type {CacheStore}
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
this._$cacheStore = new CacheStore();
|
|
31
27
|
/**
|
|
32
28
|
* @type {string}
|
|
33
29
|
* @private
|
|
@@ -98,12 +94,6 @@ export class Player {
|
|
|
98
94
|
* @private
|
|
99
95
|
*/
|
|
100
96
|
this._$fps = 16;
|
|
101
|
-
/**
|
|
102
|
-
* @type {boolean}
|
|
103
|
-
* @default false
|
|
104
|
-
* @private
|
|
105
|
-
*/
|
|
106
|
-
this._$isLoad = false;
|
|
107
97
|
/**
|
|
108
98
|
* @type {number}
|
|
109
99
|
* @default 0
|
|
@@ -256,12 +246,6 @@ export class Player {
|
|
|
256
246
|
* @private
|
|
257
247
|
*/
|
|
258
248
|
this._$textField = null;
|
|
259
|
-
/**
|
|
260
|
-
* @type {number}
|
|
261
|
-
* @default 0
|
|
262
|
-
* @private
|
|
263
|
-
*/
|
|
264
|
-
this._$touchY = 0;
|
|
265
249
|
/**
|
|
266
250
|
* @type {number}
|
|
267
251
|
* @default -1
|
|
@@ -322,6 +306,14 @@ export class Player {
|
|
|
322
306
|
static get LOAD_END() {
|
|
323
307
|
return 2;
|
|
324
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* @return {CacheStore}
|
|
311
|
+
* @readonly
|
|
312
|
+
* @public
|
|
313
|
+
*/
|
|
314
|
+
get cacheStore() {
|
|
315
|
+
return $cacheStore;
|
|
316
|
+
}
|
|
325
317
|
/**
|
|
326
318
|
* @type {HTMLCanvasElement}
|
|
327
319
|
* @readonly
|
|
@@ -338,15 +330,6 @@ export class Player {
|
|
|
338
330
|
get broadcastEvents() {
|
|
339
331
|
return this._$broadcastEvents;
|
|
340
332
|
}
|
|
341
|
-
/**
|
|
342
|
-
* @member {CacheStore}
|
|
343
|
-
* @return {CacheStore}
|
|
344
|
-
* @readonly
|
|
345
|
-
* @public
|
|
346
|
-
*/
|
|
347
|
-
get cacheStore() {
|
|
348
|
-
return this._$cacheStore;
|
|
349
|
-
}
|
|
350
333
|
/**
|
|
351
334
|
* @member {CanvasToWebGLContext|null}
|
|
352
335
|
* @default null
|
|
@@ -507,7 +490,7 @@ export class Player {
|
|
|
507
490
|
this._$stopFlag = true;
|
|
508
491
|
this._$timerId = -1;
|
|
509
492
|
SoundMixer.stopAll();
|
|
510
|
-
|
|
493
|
+
$cacheStore.reset();
|
|
511
494
|
if ($rendererWorker) {
|
|
512
495
|
$rendererWorker.postMessage({
|
|
513
496
|
"command": "stop"
|
|
@@ -521,7 +504,7 @@ export class Player {
|
|
|
521
504
|
* @public
|
|
522
505
|
*/
|
|
523
506
|
removeCache(id) {
|
|
524
|
-
|
|
507
|
+
$cacheStore.removeCache(id);
|
|
525
508
|
if ($rendererWorker) {
|
|
526
509
|
$rendererWorker.postMessage({
|
|
527
510
|
"command": "removeCache",
|
|
@@ -638,12 +621,6 @@ export class Player {
|
|
|
638
621
|
* @private
|
|
639
622
|
*/
|
|
640
623
|
_$initialize() {
|
|
641
|
-
if ($document.readyState === "loading") {
|
|
642
|
-
$window.addEventListener("DOMContentLoaded", () => {
|
|
643
|
-
this._$initialize();
|
|
644
|
-
});
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
624
|
const contentElementId = this.contentElementId;
|
|
648
625
|
if (!this._$tagId) {
|
|
649
626
|
$document
|
|
@@ -793,20 +770,22 @@ export class Player {
|
|
|
793
770
|
this._$canvas.width = 1;
|
|
794
771
|
this._$canvas.height = 1;
|
|
795
772
|
if ($rendererWorker) {
|
|
796
|
-
$rendererWorker.postMessage({
|
|
797
|
-
"command": "setStage",
|
|
798
|
-
"instanceId": this._$stage._$instanceId
|
|
799
|
-
});
|
|
800
773
|
const offscreenCanvas = this
|
|
801
774
|
._$canvas
|
|
802
775
|
.transferControlToOffscreen();
|
|
776
|
+
const buffer = $getRenderBufferArray();
|
|
777
|
+
let index = 0;
|
|
778
|
+
buffer[index++] = this._$stage._$instanceId;
|
|
779
|
+
buffer[index++] = +$isSafari;
|
|
780
|
+
buffer[index++] = $devicePixelRatio;
|
|
781
|
+
buffer[index++] = this._$getSamples();
|
|
782
|
+
const options = $getArray(offscreenCanvas, buffer.buffer);
|
|
803
783
|
$rendererWorker.postMessage({
|
|
804
784
|
"command": "initialize",
|
|
805
785
|
"canvas": offscreenCanvas,
|
|
806
|
-
"
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}, [offscreenCanvas]);
|
|
786
|
+
"buffer": buffer
|
|
787
|
+
}, options);
|
|
788
|
+
$poolArray(options);
|
|
810
789
|
}
|
|
811
790
|
else {
|
|
812
791
|
// create gl context
|
|
@@ -819,7 +798,7 @@ export class Player {
|
|
|
819
798
|
});
|
|
820
799
|
if (gl) {
|
|
821
800
|
this._$context = new CanvasToWebGLContext(gl, this._$getSamples());
|
|
822
|
-
|
|
801
|
+
$cacheStore.context = this._$context;
|
|
823
802
|
}
|
|
824
803
|
else {
|
|
825
804
|
alert("WebGL setting is off. Please turn the setting on.");
|
|
@@ -853,7 +832,6 @@ export class Player {
|
|
|
853
832
|
$setEvent(event);
|
|
854
833
|
$setEventType($TOUCH_START);
|
|
855
834
|
// start position
|
|
856
|
-
this._$touchY = event.changedTouches[0].pageY;
|
|
857
835
|
this._$hitTest();
|
|
858
836
|
});
|
|
859
837
|
this._$canvas.addEventListener($TOUCH_MOVE, (event) => {
|
|
@@ -868,10 +846,6 @@ export class Player {
|
|
|
868
846
|
});
|
|
869
847
|
// mouse wheel
|
|
870
848
|
this._$canvas.addEventListener($TOUCH_MOVE, (event) => {
|
|
871
|
-
// update
|
|
872
|
-
const pageY = event.changedTouches[0].pageY;
|
|
873
|
-
this._$deltaY = this._$touchY - pageY;
|
|
874
|
-
this._$touchY = pageY;
|
|
875
849
|
$setEvent(event);
|
|
876
850
|
$setEventType($TOUCH_MOVE);
|
|
877
851
|
this._$hitTest();
|
|
@@ -941,9 +915,6 @@ export class Player {
|
|
|
941
915
|
const div = $document
|
|
942
916
|
.getElementById(this.contentElementId);
|
|
943
917
|
if (div) {
|
|
944
|
-
// cache reset
|
|
945
|
-
this._$stage._$doChanged();
|
|
946
|
-
this._$cacheStore.reset();
|
|
947
918
|
const parent = div.parentElement;
|
|
948
919
|
if (!parent) {
|
|
949
920
|
throw new Error("the parentElement is null.");
|
|
@@ -982,6 +953,13 @@ export class Player {
|
|
|
982
953
|
: `${screenWidth / 2 - width / 2}px`;
|
|
983
954
|
width *= $devicePixelRatio;
|
|
984
955
|
height *= $devicePixelRatio;
|
|
956
|
+
// no resize
|
|
957
|
+
if (this._$width === width && this._$height === height) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
// cache reset
|
|
961
|
+
this._$stage._$doChanged();
|
|
962
|
+
$cacheStore.reset();
|
|
985
963
|
// params
|
|
986
964
|
this._$scale = scale;
|
|
987
965
|
this._$width = width;
|
|
@@ -1022,10 +1000,17 @@ export class Player {
|
|
|
1022
1000
|
*/
|
|
1023
1001
|
_$setBackgroundColor(background_color = "transparent") {
|
|
1024
1002
|
if ($rendererWorker) {
|
|
1025
|
-
$
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1003
|
+
const buffer = $getRenderBufferArray();
|
|
1004
|
+
buffer[0] = background_color === "transparent"
|
|
1005
|
+
? -1
|
|
1006
|
+
: $toColorInt(background_color);
|
|
1007
|
+
const message = $getRenderMessageObject();
|
|
1008
|
+
message.command = "setBackgroundColor";
|
|
1009
|
+
message.buffer = buffer;
|
|
1010
|
+
const options = $getArray(buffer.buffer);
|
|
1011
|
+
$rendererWorker.postMessage(message, options);
|
|
1012
|
+
$poolRenderMessageObject(message);
|
|
1013
|
+
$poolArray(options);
|
|
1029
1014
|
}
|
|
1030
1015
|
else {
|
|
1031
1016
|
const context = this._$context;
|
|
@@ -1053,20 +1038,28 @@ export class Player {
|
|
|
1053
1038
|
*/
|
|
1054
1039
|
_$resizeCanvas(width, height, scale, tx = 0, ty = 0) {
|
|
1055
1040
|
if ($rendererWorker) {
|
|
1056
|
-
$
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1041
|
+
const buffer = $getRenderBufferArray();
|
|
1042
|
+
let index = 0;
|
|
1043
|
+
buffer[index++] = width;
|
|
1044
|
+
buffer[index++] = height;
|
|
1045
|
+
buffer[index++] = scale;
|
|
1046
|
+
buffer[index++] = tx;
|
|
1047
|
+
buffer[index++] = ty;
|
|
1048
|
+
const message = $getRenderMessageObject();
|
|
1049
|
+
const options = $getArray(buffer.buffer);
|
|
1050
|
+
message.command = "resize";
|
|
1051
|
+
message.buffer = buffer;
|
|
1052
|
+
$rendererWorker.postMessage(message, options);
|
|
1053
|
+
// reset
|
|
1054
|
+
$poolRenderMessageObject(message);
|
|
1055
|
+
$poolArray(options);
|
|
1064
1056
|
}
|
|
1065
1057
|
else {
|
|
1066
1058
|
const context = this._$context;
|
|
1067
1059
|
if (!context) { // unit test
|
|
1068
1060
|
return;
|
|
1069
1061
|
}
|
|
1062
|
+
context.clearInstacedArray();
|
|
1070
1063
|
this._$canvas.width = width;
|
|
1071
1064
|
this._$canvas.height = height;
|
|
1072
1065
|
context._$gl.viewport(0, 0, width, height);
|
|
@@ -1076,9 +1069,10 @@ export class Player {
|
|
|
1076
1069
|
manager.releaseAttachment(this._$attachment, true);
|
|
1077
1070
|
}
|
|
1078
1071
|
this._$attachment = manager
|
|
1079
|
-
.createCacheAttachment(width, height,
|
|
1072
|
+
.createCacheAttachment(width, height, true);
|
|
1080
1073
|
// update cache max size
|
|
1081
1074
|
context.setMaxSize(width, height);
|
|
1075
|
+
context._$bind(this._$attachment);
|
|
1082
1076
|
}
|
|
1083
1077
|
}
|
|
1084
1078
|
/**
|
|
@@ -1412,19 +1406,18 @@ export class Player {
|
|
|
1412
1406
|
if (!this._$width || !this._$height) {
|
|
1413
1407
|
return;
|
|
1414
1408
|
}
|
|
1409
|
+
if (!this._$stage._$isUpdated()) {
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1415
1412
|
if ($rendererWorker) {
|
|
1416
1413
|
$rendererWorker.postMessage({
|
|
1417
1414
|
"command": "draw"
|
|
1418
1415
|
});
|
|
1419
1416
|
}
|
|
1420
|
-
if (!this._$stage._$isUpdated()) {
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
1417
|
const context = this._$context;
|
|
1424
1418
|
if (!context) {
|
|
1425
1419
|
return;
|
|
1426
1420
|
}
|
|
1427
|
-
context._$bind(this._$attachment);
|
|
1428
1421
|
// reset
|
|
1429
1422
|
context.reset();
|
|
1430
1423
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
@@ -1433,17 +1426,10 @@ export class Player {
|
|
|
1433
1426
|
this._$stage._$draw(context, this._$matrix, $COLOR_ARRAY_IDENTITY);
|
|
1434
1427
|
// stage end
|
|
1435
1428
|
this._$stage._$updated = false;
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
.
|
|
1439
|
-
|
|
1440
|
-
// reset and draw to main canvas
|
|
1441
|
-
context.reset();
|
|
1442
|
-
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
1443
|
-
context.clearRect(0, 0, this._$width, this._$height);
|
|
1444
|
-
context.drawImage(texture, 0, 0, this._$width, this._$height);
|
|
1445
|
-
// re bind
|
|
1446
|
-
context._$bind(this._$attachment);
|
|
1429
|
+
context.drawInstacedArray();
|
|
1430
|
+
context
|
|
1431
|
+
.frameBuffer
|
|
1432
|
+
.transferToMainTexture();
|
|
1447
1433
|
}
|
|
1448
1434
|
/**
|
|
1449
1435
|
* @return {void}
|
|
@@ -1516,20 +1502,20 @@ export class Player {
|
|
|
1516
1502
|
x += rect.left;
|
|
1517
1503
|
y += rect.top;
|
|
1518
1504
|
}
|
|
1519
|
-
let
|
|
1520
|
-
let
|
|
1505
|
+
let pageX = 0;
|
|
1506
|
+
let pageY = 0;
|
|
1521
1507
|
if ("changedTouches" in event) {
|
|
1522
1508
|
const changedTouche = event.changedTouches[0];
|
|
1523
|
-
|
|
1524
|
-
|
|
1509
|
+
pageX = changedTouche.pageX;
|
|
1510
|
+
pageY = changedTouche.pageY;
|
|
1525
1511
|
}
|
|
1526
1512
|
else if ("pageX" in event) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1513
|
+
pageX = event.pageX;
|
|
1514
|
+
pageY = event.pageY;
|
|
1529
1515
|
}
|
|
1530
1516
|
// drop point
|
|
1531
|
-
stageX = (
|
|
1532
|
-
stageY = (
|
|
1517
|
+
const stageX = (pageX - x) / this._$scale;
|
|
1518
|
+
const stageY = (pageY - y) / this._$scale;
|
|
1533
1519
|
// update
|
|
1534
1520
|
this._$stageX = stageX;
|
|
1535
1521
|
this._$stageY = stageY;
|
|
@@ -1574,9 +1560,23 @@ export class Player {
|
|
|
1574
1560
|
$dropTarget.x = dragX;
|
|
1575
1561
|
$dropTarget.y = dragY;
|
|
1576
1562
|
}
|
|
1563
|
+
if (this._$clickTarget
|
|
1564
|
+
&& "_$text" in this._$clickTarget
|
|
1565
|
+
&& this._$clickTarget.scrollEnabled) {
|
|
1566
|
+
const deltaX = this._$deltaX - pageX;
|
|
1567
|
+
const deltaY = this._$deltaY - pageY;
|
|
1568
|
+
// @ts-ignore
|
|
1569
|
+
this._$clickTarget.scrollX += deltaX / (this._$clickTarget.textWidth / this._$clickTarget.width);
|
|
1570
|
+
// @ts-ignore
|
|
1571
|
+
this._$clickTarget.scrollY += deltaY / (this._$clickTarget.textHeight / this._$clickTarget.height);
|
|
1572
|
+
}
|
|
1573
|
+
this._$deltaX = pageX;
|
|
1574
|
+
this._$deltaY = pageY;
|
|
1577
1575
|
break;
|
|
1578
1576
|
case $TOUCH_START:
|
|
1579
1577
|
case $MOUSE_DOWN:
|
|
1578
|
+
this._$deltaX = pageX;
|
|
1579
|
+
this._$deltaY = pageY;
|
|
1580
1580
|
this._$state = "down";
|
|
1581
1581
|
canPointer = this._$canvas.style.cursor === "pointer";
|
|
1582
1582
|
staticPointer = true;
|
|
@@ -1584,6 +1584,8 @@ export class Player {
|
|
|
1584
1584
|
case $TOUCH_END:
|
|
1585
1585
|
case $MOUSE_UP:
|
|
1586
1586
|
case $DOUBLE_CLICK:
|
|
1587
|
+
this._$deltaX = 0;
|
|
1588
|
+
this._$deltaY = 0;
|
|
1587
1589
|
this._$state = "up";
|
|
1588
1590
|
break;
|
|
1589
1591
|
}
|
|
@@ -1749,18 +1751,6 @@ export class Player {
|
|
|
1749
1751
|
// down event
|
|
1750
1752
|
case $TOUCH_START:
|
|
1751
1753
|
case $MOUSE_DOWN:
|
|
1752
|
-
// TextField focus out
|
|
1753
|
-
if (this._$textField
|
|
1754
|
-
&& instance !== this._$textField
|
|
1755
|
-
&& "_$text" in this._$textField) {
|
|
1756
|
-
this._$textField.focus = false;
|
|
1757
|
-
this._$textField = null;
|
|
1758
|
-
}
|
|
1759
|
-
// TextField focus out
|
|
1760
|
-
if ("_$text" in instance) {
|
|
1761
|
-
instance.focus = true;
|
|
1762
|
-
this._$textField = instance;
|
|
1763
|
-
}
|
|
1764
1754
|
// (3) mouseDown
|
|
1765
1755
|
if (instance.willTrigger(Next2DMouseEvent.MOUSE_DOWN)) {
|
|
1766
1756
|
instance.dispatchEvent(new Next2DMouseEvent(Next2DMouseEvent.MOUSE_DOWN, true, false));
|
|
@@ -1778,6 +1768,11 @@ export class Player {
|
|
|
1778
1768
|
this._$textField.focus = false;
|
|
1779
1769
|
this._$textField = null;
|
|
1780
1770
|
}
|
|
1771
|
+
// TextField focus out
|
|
1772
|
+
if ("_$text" in instance) {
|
|
1773
|
+
instance.focus = true;
|
|
1774
|
+
this._$textField = instance;
|
|
1775
|
+
}
|
|
1781
1776
|
// (1) mouseUp
|
|
1782
1777
|
if (instance.willTrigger(Next2DMouseEvent.MOUSE_UP)) {
|
|
1783
1778
|
instance.dispatchEvent(new Next2DMouseEvent(Next2DMouseEvent.MOUSE_UP, true, false));
|
|
@@ -1795,9 +1790,15 @@ export class Player {
|
|
|
1795
1790
|
if (instance.willTrigger(Next2DMouseEvent.MOUSE_WHEEL)) {
|
|
1796
1791
|
instance.dispatchEvent(new Next2DMouseEvent(Next2DMouseEvent.MOUSE_WHEEL));
|
|
1797
1792
|
}
|
|
1798
|
-
if (
|
|
1799
|
-
|
|
1800
|
-
|
|
1793
|
+
if (instance.scrollEnabled) {
|
|
1794
|
+
if ("deltaX" in event) {
|
|
1795
|
+
// @ts-ignore
|
|
1796
|
+
instance.scrollX += event.deltaX / (instance.textWidth / instance.width);
|
|
1797
|
+
}
|
|
1798
|
+
if ("deltaY" in event) {
|
|
1799
|
+
// @ts-ignore
|
|
1800
|
+
instance.scrollY += event.deltaY / (instance.textHeight / instance.height);
|
|
1801
|
+
}
|
|
1801
1802
|
}
|
|
1802
1803
|
break;
|
|
1803
1804
|
case $DOUBLE_CLICK:
|
package/dist/Text.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Next2D Core Packages",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@tvon.jp> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@next2d/interface": "1.
|
|
36
|
-
"@next2d/webgl": "1.
|
|
37
|
-
"@next2d/display": "1.
|
|
38
|
-
"@next2d/core": "1.
|
|
39
|
-
"@next2d/net": "1.
|
|
40
|
-
"@next2d/share": "1.
|
|
41
|
-
"@next2d/events": "1.
|
|
42
|
-
"@next2d/media": "1.
|
|
43
|
-
"@next2d/text": "1.
|
|
44
|
-
"@next2d/geom": "1.
|
|
45
|
-
"@next2d/util": "1.
|
|
35
|
+
"@next2d/interface": "1.17.0",
|
|
36
|
+
"@next2d/webgl": "1.17.0",
|
|
37
|
+
"@next2d/display": "1.17.0",
|
|
38
|
+
"@next2d/core": "1.17.0",
|
|
39
|
+
"@next2d/net": "1.17.0",
|
|
40
|
+
"@next2d/share": "1.17.0",
|
|
41
|
+
"@next2d/events": "1.17.0",
|
|
42
|
+
"@next2d/media": "1.17.0",
|
|
43
|
+
"@next2d/text": "1.17.0",
|
|
44
|
+
"@next2d/geom": "1.17.0",
|
|
45
|
+
"@next2d/util": "1.17.0"
|
|
46
46
|
}
|
|
47
47
|
}
|