@next2d/webgl 3.17.1 → 3.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/webgl",
3
- "version": "3.17.1",
3
+ "version": "3.19.0",
4
4
  "description": "Next2D Webgl Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/texture-packer": "3.17.1",
28
- "@next2d/render-queue": "3.17.1"
27
+ "@next2d/texture-packer": "3.19.0",
28
+ "@next2d/render-queue": "3.19.0"
29
29
  }
30
30
  }
@@ -1,5 +1,17 @@
1
1
  import type { IAttachmentObject } from "../../interface/IAttachmentObject";
2
2
  import type { Context } from "../../Context";
3
+ /**
4
+ * @description GL のフレームバッファを attachment_object に切り替える
5
+ * Switch the GL framebuffer to attachment_object
6
+ *
7
+ * @param {Context} context
8
+ * @param {IAttachmentObject} attachment_object
9
+ * @param {IAttachmentObject | null} previous 直前まで GL に付いていたアタッチメントオブジェクト
10
+ * @return {void}
11
+ * @method
12
+ * @protected
13
+ */
14
+ export declare const $bindPhysical: (context: Context, attachment_object: IAttachmentObject, previous: IAttachmentObject | null) => void;
3
15
  /**
4
16
  * @description アタッチメントオブジェクトのサイズに変更・初期化し、フレームバッファにアタッチメントオブジェクトをバインドする
5
17
  * Change and initialize to the size of the attachment object and bind the attachment object to the frame buffer
@@ -1,30 +1,26 @@
1
- import { $currentAttachment } from "../../FrameBufferManager";
1
+ import { $currentAttachment, $setCurrentAttachment, $physicalAttachment, $attachmentDeferred, $setAttachmentDeferred, $isFramebufferBound } from "../../FrameBufferManager";
2
2
  import { execute as frameBufferManagerBindAttachmentObjectService } from "../../FrameBufferManager/service/FrameBufferManagerBindAttachmentObjectService";
3
3
  import { execute as maskBindUseCase } from "../../Mask/usecase/MaskBindUseCase";
4
4
  import { $gl, $setViewportSize } from "../../WebGLUtil";
5
5
  /**
6
- * @description アタッチメントオブジェクトのサイズに変更・初期化し、フレームバッファにアタッチメントオブジェクトをバインドする
7
- * Change and initialize to the size of the attachment object and bind the attachment object to the frame buffer
6
+ * @description GL のフレームバッファを attachment_object に切り替える
7
+ * Switch the GL framebuffer to attachment_object
8
8
  *
9
9
  * @param {Context} context
10
10
  * @param {IAttachmentObject} attachment_object
11
+ * @param {IAttachmentObject | null} previous 直前まで GL に付いていたアタッチメントオブジェクト
11
12
  * @return {void}
12
13
  * @method
13
14
  * @protected
14
15
  */
15
- export const execute = (context, attachment_object) => {
16
- // fixed logic
17
- const currentAttachment = $currentAttachment;
18
- if (currentAttachment
19
- && attachment_object.id === currentAttachment.id) {
20
- return;
21
- }
16
+ export const $bindPhysical = (context, attachment_object, previous) => {
22
17
  // フレームバッファにアタッチメントオブジェクトをバインドする
23
18
  frameBufferManagerBindAttachmentObjectService(attachment_object);
24
- if (!currentAttachment
25
- || currentAttachment.width !== attachment_object.width
26
- || currentAttachment.height !== attachment_object.height) {
27
- $setViewportSize(attachment_object.width, attachment_object.height);
19
+ // ビューポートの大きさは、切り替えを保留している間に書き換わっていることがあるので必ず合わせる
20
+ $setViewportSize(attachment_object.width, attachment_object.height);
21
+ if (!previous
22
+ || previous.width !== attachment_object.width
23
+ || previous.height !== attachment_object.height) {
28
24
  $gl.viewport(0, 0, attachment_object.width, attachment_object.height);
29
25
  }
30
26
  // カラーバッファorステンシルバッファが、未初期化の場合はクリアする
@@ -45,3 +41,37 @@ export const execute = (context, attachment_object) => {
45
41
  // mask bind
46
42
  maskBindUseCase(attachment_object.mask);
47
43
  };
44
+ /**
45
+ * @description アタッチメントオブジェクトのサイズに変更・初期化し、フレームバッファにアタッチメントオブジェクトをバインドする
46
+ * Change and initialize to the size of the attachment object and bind the attachment object to the frame buffer
47
+ *
48
+ * @param {Context} context
49
+ * @param {IAttachmentObject} attachment_object
50
+ * @return {void}
51
+ * @method
52
+ * @protected
53
+ */
54
+ export const execute = (context, attachment_object) => {
55
+ // 描画先の切り替えを保留している間 (ContextDeferBindUseCase): GL にはまだ前の描画先が付いている
56
+ if ($attachmentDeferred) {
57
+ $setAttachmentDeferred(false);
58
+ const physical = $physicalAttachment;
59
+ if (physical
60
+ && physical.id === attachment_object.id
61
+ && $isFramebufferBound) {
62
+ // GL に付いたままの描画先へ戻るだけ: 何も切り替えずに済む
63
+ $setCurrentAttachment(attachment_object);
64
+ $setViewportSize(attachment_object.width, attachment_object.height);
65
+ return;
66
+ }
67
+ $bindPhysical(context, attachment_object, physical);
68
+ return;
69
+ }
70
+ // fixed logic
71
+ const currentAttachment = $currentAttachment;
72
+ if (currentAttachment
73
+ && attachment_object.id === currentAttachment.id) {
74
+ return;
75
+ }
76
+ $bindPhysical(context, attachment_object, currentAttachment);
77
+ };
@@ -1,7 +1,6 @@
1
- import { $getVertices } from "../../PathCommand";
2
- import { execute as meshFillGenerateUseCase } from "../../Mesh/usecase/MeshFillGenerateUseCase";
1
+ import { execute as meshFillCurrentPathUseCase } from "../../Mesh/usecase/MeshFillCurrentPathUseCase";
3
2
  import { $bitmapData } from "../../Bitmap";
4
- import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
3
+ import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
5
4
  /**
6
5
  * @description パスコマンドのビットマップ塗り実行します。
7
6
  * Execute bitmap painting of path commands.
@@ -17,15 +16,14 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
17
16
  * @protected
18
17
  */
19
18
  export const execute = (pixels, matrix, width, height, repeat, smooth) => {
20
- const vertices = $getVertices();
21
- if (!vertices.length) {
19
+ // いまの経路を塗りのメッシュにして、塗りのバッファへ追加する
20
+ const indexCount = meshFillCurrentPathUseCase();
21
+ if (indexCount < 0) {
22
22
  return;
23
23
  }
24
24
  // 塗りの種類を追加
25
25
  $fillTypes.push("bitmap");
26
- const fillMesh = meshFillGenerateUseCase(vertices);
27
- $addFillBuffer(fillMesh.buffer);
28
26
  // 塗りのインデックスを追加
29
- $fillBufferIndexes.push(fillMesh.indexCount);
27
+ $fillBufferIndexes.push(indexCount);
30
28
  $bitmapData.push(pixels, matrix, width, height, repeat, smooth);
31
29
  };
@@ -0,0 +1,18 @@
1
+ import type { IAttachmentObject } from "../../interface/IAttachmentObject";
2
+ /**
3
+ * @description 描画先を attachment_object に切り替えるが、GL のフレームバッファの切り替えは、実際に GL で
4
+ * 描く時点まで保留する。アトラスへ図形を描いた後に元の描画先へ戻す処理で使う: 未キャッシュの
5
+ * 図形が続くと、次の図形がすぐにアトラスへ切り替え直すので、戻す切り替えは無駄になる。
6
+ * 現在の描画先とビューポートの大きさ (どちらも JavaScript の値) は、ここで切り替え後の値にする。
7
+ * Switch the render target to attachment_object, but postpone switching the GL framebuffer
8
+ * until something is actually drawn with GL. Used to go back to the previous target after
9
+ * drawing a shape into the atlas: when uncached shapes follow one another, the next one
10
+ * switches straight back to the atlas, so switching back in between is wasted. The current
11
+ * attachment and the viewport size (both JavaScript values) take their new values here.
12
+ *
13
+ * @param {IAttachmentObject} attachment_object
14
+ * @return {void}
15
+ * @method
16
+ * @protected
17
+ */
18
+ export declare const execute: (attachment_object: IAttachmentObject) => void;
@@ -0,0 +1,28 @@
1
+ import { $currentAttachment, $setCurrentAttachment, $setAttachmentDeferred } from "../../FrameBufferManager";
2
+ import { $setViewportSize } from "../../WebGLUtil";
3
+ /**
4
+ * @description 描画先を attachment_object に切り替えるが、GL のフレームバッファの切り替えは、実際に GL で
5
+ * 描く時点まで保留する。アトラスへ図形を描いた後に元の描画先へ戻す処理で使う: 未キャッシュの
6
+ * 図形が続くと、次の図形がすぐにアトラスへ切り替え直すので、戻す切り替えは無駄になる。
7
+ * 現在の描画先とビューポートの大きさ (どちらも JavaScript の値) は、ここで切り替え後の値にする。
8
+ * Switch the render target to attachment_object, but postpone switching the GL framebuffer
9
+ * until something is actually drawn with GL. Used to go back to the previous target after
10
+ * drawing a shape into the atlas: when uncached shapes follow one another, the next one
11
+ * switches straight back to the atlas, so switching back in between is wasted. The current
12
+ * attachment and the viewport size (both JavaScript values) take their new values here.
13
+ *
14
+ * @param {IAttachmentObject} attachment_object
15
+ * @return {void}
16
+ * @method
17
+ * @protected
18
+ */
19
+ export const execute = (attachment_object) => {
20
+ const currentAttachment = $currentAttachment;
21
+ if (currentAttachment
22
+ && attachment_object.id === currentAttachment.id) {
23
+ return;
24
+ }
25
+ $setCurrentAttachment(attachment_object);
26
+ $setViewportSize(attachment_object.width, attachment_object.height);
27
+ $setAttachmentDeferred(true);
28
+ };
@@ -1,6 +1,5 @@
1
- import { $getVertices } from "../../PathCommand";
2
- import { execute as meshFillGenerateUseCase } from "../../Mesh/usecase/MeshFillGenerateUseCase";
3
- import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
1
+ import { execute as meshFillCurrentPathUseCase } from "../../Mesh/usecase/MeshFillCurrentPathUseCase";
2
+ import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
4
3
  /**
5
4
  * @description Contextのパスコマンドの塗り実行します。
6
5
  * Execute Context path command painting.
@@ -10,14 +9,13 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
10
9
  * @protected
11
10
  */
12
11
  export const execute = (type) => {
13
- const vertices = $getVertices();
14
- if (!vertices.length) {
12
+ // いまの経路を塗りのメッシュにして、塗りのバッファへ追加する
13
+ const indexCount = meshFillCurrentPathUseCase();
14
+ if (indexCount < 0) {
15
15
  return;
16
16
  }
17
17
  // 塗りの種類を追加
18
18
  $fillTypes.push(type);
19
- const mesh = meshFillGenerateUseCase(vertices);
20
- $addFillBuffer(mesh.buffer);
21
19
  // 塗りのインデックスを追加
22
- $fillBufferIndexes.push(mesh.indexCount);
20
+ $fillBufferIndexes.push(indexCount);
23
21
  };
@@ -1,7 +1,6 @@
1
- import { $getVertices } from "../../PathCommand";
2
- import { execute as meshFillGenerateUseCase } from "../../Mesh/usecase/MeshFillGenerateUseCase";
1
+ import { execute as meshFillCurrentPathUseCase } from "../../Mesh/usecase/MeshFillCurrentPathUseCase";
3
2
  import { $gradientData } from "../../Gradient";
4
- import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
3
+ import { $fillTypes, $fillBufferIndexes } from "../../Mesh";
5
4
  /**
6
5
  * @description グラデーション塗りを描画
7
6
  * Draw a gradient fill
@@ -17,16 +16,15 @@ import { $addFillBuffer, $fillTypes, $fillBufferIndexes } from "../../Mesh";
17
16
  * @protected
18
17
  */
19
18
  export const execute = (type, stops, matrix, spread, interpolation, focal) => {
20
- const vertices = $getVertices();
21
- if (!vertices.length) {
19
+ // いまの経路を塗りのメッシュにして、塗りのバッファへ追加する
20
+ const indexCount = meshFillCurrentPathUseCase();
21
+ if (indexCount < 0) {
22
22
  return;
23
23
  }
24
24
  // 塗りの種類を追加
25
25
  $fillTypes.push(type === 0 ? "linear" : "radial");
26
- const fillMesh = meshFillGenerateUseCase(vertices);
27
- $addFillBuffer(fillMesh.buffer);
28
26
  // 塗りのインデックスを追加
29
- $fillBufferIndexes.push(fillMesh.indexCount);
27
+ $fillBufferIndexes.push(indexCount);
30
28
  $gradientData.push(stops, matrix, spread, interpolation);
31
29
  if (type === 1) {
32
30
  $gradientData.push(focal);
@@ -0,0 +1,13 @@
1
+ import type { Context } from "../../Context";
2
+ /**
3
+ * @description 保留していた描画先の切り替え (ContextDeferBindUseCase) を、GL のフレームバッファに反映する。
4
+ * GL で描く処理の先頭で、$attachmentDeferred が true のときに呼ぶ。
5
+ * Apply the postponed render target switch (ContextDeferBindUseCase) to the GL framebuffer.
6
+ * Called at the start of anything that draws with GL, when $attachmentDeferred is true.
7
+ *
8
+ * @param {Context} context
9
+ * @return {void}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export declare const execute: (context: Context) => void;
@@ -0,0 +1,21 @@
1
+ import { $currentAttachment, $physicalAttachment, $setAttachmentDeferred } from "../../FrameBufferManager";
2
+ import { $bindPhysical } from "./ContextBindUseCase";
3
+ /**
4
+ * @description 保留していた描画先の切り替え (ContextDeferBindUseCase) を、GL のフレームバッファに反映する。
5
+ * GL で描く処理の先頭で、$attachmentDeferred が true のときに呼ぶ。
6
+ * Apply the postponed render target switch (ContextDeferBindUseCase) to the GL framebuffer.
7
+ * Called at the start of anything that draws with GL, when $attachmentDeferred is true.
8
+ *
9
+ * @param {Context} context
10
+ * @return {void}
11
+ * @method
12
+ * @protected
13
+ */
14
+ export const execute = (context) => {
15
+ $setAttachmentDeferred(false);
16
+ const attachment = $currentAttachment;
17
+ if (!attachment) {
18
+ return;
19
+ }
20
+ $bindPhysical(context, attachment, $physicalAttachment);
21
+ };
package/src/Context.d.ts CHANGED
@@ -31,12 +31,28 @@ export declare class Context {
31
31
  resize(width: number, height: number, cache_clear?: boolean): void;
32
32
  clearRect(x: number, y: number, w: number, h: number): void;
33
33
  bind(attachment_object: IAttachmentObject): void;
34
+ /**
35
+ * @description 描画先を attachment_object に戻す。GL のフレームバッファの切り替えは、次に GL で描く時点まで
36
+ * 保留する (すぐ次の処理が同じ描画先へ切り替え直す場合、切り替えそのものを省ける)。
37
+ * アトラスへ描いた後に、元の描画先へ戻すときに使う。
38
+ * Go back to attachment_object as the render target. Switching the GL framebuffer is
39
+ * postponed until the next GL draw (and skipped altogether when the next operation
40
+ * switches straight back). Use it to return to the previous target after drawing
41
+ * into the atlas.
42
+ *
43
+ * @param {IAttachmentObject} attachment_object
44
+ * @return {void}
45
+ * @method
46
+ * @public
47
+ */
48
+ deferBind(attachment_object: IAttachmentObject): void;
34
49
  queueTextElement(node: Node, canvas: OffscreenCanvas): boolean;
35
50
  save(): void;
36
51
  restore(): void;
37
52
  setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
38
53
  transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
39
54
  reset(): void;
55
+ pathCommands(commands: Float32Array, index: number): number;
40
56
  beginPath(): void;
41
57
  moveTo(x: number, y: number): void;
42
58
  lineTo(x: number, y: number): void;
package/src/Context.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { $nativeShape, $nativePathActive, $setNativePathActive } from "./NativeShape";
2
+ import { $currentPath, $vertices } from "./PathCommand";
1
3
  import { queueTextUpload, flushTextUploads, flushTextUploadsForNode, disposeTextUploads } from "./TextUploadBatch";
2
4
  import { execute as contextGetRenderCompletionService } from "./Context/service/ContextGetRenderCompletionService";
3
5
  import { execute as beginPath } from "./PathCommand/service/PathCommandBeginPathService";
@@ -12,6 +14,8 @@ import { execute as contextFillBackgroundColorService } from "./Context/service/
12
14
  import { execute as contextResizeUseCase } from "./Context/usecase/ContextResizeUseCase";
13
15
  import { execute as contextClearRectUseCase } from "./Context/usecase/ContextClearRectUseCase";
14
16
  import { execute as contextBindUseCase } from "./Context/usecase/ContextBindUseCase";
17
+ import { execute as contextDeferBindUseCase } from "./Context/usecase/ContextDeferBindUseCase";
18
+ import { execute as contextSyncAttachmentUseCase } from "./Context/usecase/ContextSyncAttachmentUseCase";
15
19
  import { execute as contextSaveService } from "./Context/service/ContextSaveService";
16
20
  import { execute as contextRestoreService } from "./Context/service/ContextRestoreService";
17
21
  import { execute as contextSetTransformService } from "./Context/service/ContextSetTransformService";
@@ -53,7 +57,7 @@ import { execute as contextDrawFillUseCase } from "./Context/usecase/ContextDraw
53
57
  import { execute as contextCreateImageBitmapService } from "./Context/service/ContextCreateImageBitmapService";
54
58
  import { $setGradientLUTGeneratorMaxLength } from "./Shader/GradientLUTGenerator";
55
59
  import { $getAtlasAttachmentObject, $clearTransferBounds, $getAtlasTextureObject, $setAtlasPageDirty, $rootNodes, $setActiveAtlasIndex } from "./AtlasManager";
56
- import { $setReadFrameBuffer, $setDrawFrameBuffer, $currentAttachment, $setAtlasFrameBuffer, $setBitmapFrameBuffer } from "./FrameBufferManager";
60
+ import { $setReadFrameBuffer, $setDrawFrameBuffer, $currentAttachment, $attachmentDeferred, $setAtlasFrameBuffer, $setBitmapFrameBuffer } from "./FrameBufferManager";
57
61
  import { $setRenderMaxSize, $setWebGL2RenderingContext, $setSamples, $getFloat32Array9, $getArray, $setContext, $setDevicePixelRatio } from "./WebGLUtil";
58
62
  export class Context {
59
63
  constructor(gl, samples, device_pixel_ratio = 1) {
@@ -122,14 +126,23 @@ export class Context {
122
126
  contextUpdateBackgroundColorService(this, red, green, blue, alpha);
123
127
  }
124
128
  fillBackgroundColor() {
129
+ if ($attachmentDeferred) {
130
+ contextSyncAttachmentUseCase(this);
131
+ }
125
132
  flushTextUploads();
126
133
  contextFillBackgroundColorService(this.$clearColorR, this.$clearColorG, this.$clearColorB, this.$clearColorA);
127
134
  }
128
135
  resize(width, height, cache_clear = true) {
136
+ if ($attachmentDeferred) {
137
+ contextSyncAttachmentUseCase(this);
138
+ }
129
139
  disposeTextUploads();
130
140
  contextResizeUseCase(this, width, height, cache_clear);
131
141
  }
132
142
  clearRect(x, y, w, h) {
143
+ if ($attachmentDeferred) {
144
+ contextSyncAttachmentUseCase(this);
145
+ }
133
146
  flushTextUploads();
134
147
  contextClearRectUseCase(x, y, w, h);
135
148
  }
@@ -137,6 +150,23 @@ export class Context {
137
150
  flushTextUploads();
138
151
  contextBindUseCase(this, attachment_object);
139
152
  }
153
+ /**
154
+ * @description 描画先を attachment_object に戻す。GL のフレームバッファの切り替えは、次に GL で描く時点まで
155
+ * 保留する (すぐ次の処理が同じ描画先へ切り替え直す場合、切り替えそのものを省ける)。
156
+ * アトラスへ描いた後に、元の描画先へ戻すときに使う。
157
+ * Go back to attachment_object as the render target. Switching the GL framebuffer is
158
+ * postponed until the next GL draw (and skipped altogether when the next operation
159
+ * switches straight back). Use it to return to the previous target after drawing
160
+ * into the atlas.
161
+ *
162
+ * @param {IAttachmentObject} attachment_object
163
+ * @return {void}
164
+ * @method
165
+ * @public
166
+ */
167
+ deferBind(attachment_object) {
168
+ contextDeferBindUseCase(attachment_object);
169
+ }
140
170
  queueTextElement(node, canvas) {
141
171
  return queueTextUpload(node, canvas);
142
172
  }
@@ -153,9 +183,36 @@ export class Context {
153
183
  contextTransformService(this, a, b, c, d, e, f);
154
184
  }
155
185
  reset() {
186
+ if ($attachmentDeferred) {
187
+ contextSyncAttachmentUseCase(this);
188
+ }
156
189
  flushTextUploads();
157
190
  contextResetService(this);
158
191
  }
192
+ // 描画命令の並びのうち、index から続く経路の命令をまとめて処理する。実行環境が経路の実装を
193
+ // 提供していればそれを使い、次に処理する命令の位置を返す。使えないときは -1 を返すので、
194
+ // 呼び出し側が moveTo などを 1 つずつ呼ぶ。
195
+ pathCommands(commands, index) {
196
+ if (!$nativeShape) {
197
+ return -1;
198
+ }
199
+ // 3 次ベジェ曲線の分割数は画面上の拡大率で決まる (PathCommandBezierCurveToUseCase と同じ計算)
200
+ const matrix = this.$matrix;
201
+ const scaleX = matrix[0] * matrix[0] + matrix[1] * matrix[1];
202
+ const scaleY = matrix[3] * matrix[3] + matrix[4] * matrix[4];
203
+ const scaleSquared = scaleX > scaleY ? scaleX : scaleY;
204
+ if (!(scaleSquared > 0)) {
205
+ return -1;
206
+ }
207
+ if (!$nativePathActive) {
208
+ // JavaScript 側で経路を作り始めていたら、混ぜない
209
+ if ($currentPath.length || $vertices.length) {
210
+ return -1;
211
+ }
212
+ $setNativePathActive(true);
213
+ }
214
+ return $nativeShape.path(commands, index, scaleSquared);
215
+ }
159
216
  beginPath() {
160
217
  // reset color style
161
218
  contextResetStyleService(this);
@@ -193,30 +250,51 @@ export class Context {
193
250
  bezierCurveTo(cx1, cy1, cx2, cy2, x, y);
194
251
  }
195
252
  fill() {
253
+ if ($attachmentDeferred) {
254
+ contextSyncAttachmentUseCase(this);
255
+ }
196
256
  flushTextUploads();
197
257
  contextFillUseCase("fill");
198
258
  }
199
259
  gradientFill(type, stops, matrix, spread, interpolation, focal) {
260
+ if ($attachmentDeferred) {
261
+ contextSyncAttachmentUseCase(this);
262
+ }
200
263
  flushTextUploads();
201
264
  contextGradientFillUseCase(type, stops, matrix, spread, interpolation, focal);
202
265
  }
203
266
  bitmapFill(pixels, matrix, width, height, repeat, smooth) {
267
+ if ($attachmentDeferred) {
268
+ contextSyncAttachmentUseCase(this);
269
+ }
204
270
  flushTextUploads();
205
271
  contextBitmapFillUseCase(pixels, matrix, width, height, repeat, smooth);
206
272
  }
207
273
  stroke() {
274
+ if ($attachmentDeferred) {
275
+ contextSyncAttachmentUseCase(this);
276
+ }
208
277
  flushTextUploads();
209
278
  contextStrokeUseCase();
210
279
  }
211
280
  gradientStroke(type, stops, matrix, spread, interpolation, focal) {
281
+ if ($attachmentDeferred) {
282
+ contextSyncAttachmentUseCase(this);
283
+ }
212
284
  flushTextUploads();
213
285
  contextGradientStrokeUseCase(type, stops, matrix, spread, interpolation, focal);
214
286
  }
215
287
  bitmapStroke(pixels, matrix, width, height, repeat, smooth) {
288
+ if ($attachmentDeferred) {
289
+ contextSyncAttachmentUseCase(this);
290
+ }
216
291
  flushTextUploads();
217
292
  contextBitmapStrokeUseCase(pixels, matrix, width, height, repeat, smooth);
218
293
  }
219
294
  clip() {
295
+ if ($attachmentDeferred) {
296
+ contextSyncAttachmentUseCase(this);
297
+ }
220
298
  flushTextUploads();
221
299
  contextClipUseCase();
222
300
  }
@@ -272,6 +350,9 @@ export class Context {
272
350
  }
273
351
  }
274
352
  beginNodeRendering(node) {
353
+ if ($attachmentDeferred) {
354
+ contextSyncAttachmentUseCase(this);
355
+ }
275
356
  flushTextUploads();
276
357
  this.newDrawState = true;
277
358
  // このページには未解決の描き込みがある(次回の解決対象)
@@ -280,10 +361,16 @@ export class Context {
280
361
  contextBeginNodeRenderingService(node.x, node.y, node.w, node.h);
281
362
  }
282
363
  endNodeRendering() {
364
+ if ($attachmentDeferred) {
365
+ contextSyncAttachmentUseCase(this);
366
+ }
283
367
  flushTextUploads();
284
368
  contextEndNodeRenderingService();
285
369
  }
286
370
  drawFill() {
371
+ if ($attachmentDeferred) {
372
+ contextSyncAttachmentUseCase(this);
373
+ }
287
374
  flushTextUploads();
288
375
  contextDrawFillUseCase();
289
376
  }
@@ -292,6 +379,9 @@ export class Context {
292
379
  blnedDrawDisplayObjectUseCase(node, x_min, y_min, x_max, y_max, color_transform, color_transform_offset);
293
380
  }
294
381
  drawArraysInstanced() {
382
+ if ($attachmentDeferred) {
383
+ contextSyncAttachmentUseCase(this);
384
+ }
295
385
  flushTextUploads();
296
386
  blnedDrawArraysInstancedUseCase();
297
387
  }
@@ -299,26 +389,44 @@ export class Context {
299
389
  blnedClearArraysInstancedUseCase();
300
390
  }
301
391
  transferMainCanvas() {
392
+ if ($attachmentDeferred) {
393
+ contextSyncAttachmentUseCase(this);
394
+ }
302
395
  flushTextUploads();
303
396
  frameBufferManagerTransferMainCanvasService();
304
397
  }
305
398
  drawPixels(node, pixels) {
399
+ if ($attachmentDeferred) {
400
+ contextSyncAttachmentUseCase(this);
401
+ }
306
402
  flushTextUploads();
307
403
  contextDrawPixelsUseCase(node, pixels);
308
404
  }
309
405
  drawElement(node, element, _flipY = false) {
406
+ if ($attachmentDeferred) {
407
+ contextSyncAttachmentUseCase(this);
408
+ }
310
409
  flushTextUploads();
311
410
  contextDrawElementUseCase(node, element);
312
411
  }
313
412
  beginMask() {
413
+ if ($attachmentDeferred) {
414
+ contextSyncAttachmentUseCase(this);
415
+ }
314
416
  flushTextUploads();
315
417
  maskBeginMaskService();
316
418
  }
317
419
  setMaskBounds(x_min, y_min, x_max, y_max) {
420
+ if ($attachmentDeferred) {
421
+ contextSyncAttachmentUseCase(this);
422
+ }
318
423
  flushTextUploads();
319
424
  maskSetMaskBoundsService(x_min, y_min, x_max, y_max);
320
425
  }
321
426
  endMask() {
427
+ if ($attachmentDeferred) {
428
+ contextSyncAttachmentUseCase(this);
429
+ }
322
430
  flushTextUploads();
323
431
  maskEndMaskService();
324
432
  }
@@ -338,6 +446,9 @@ export class Context {
338
446
  contextContainerBeginLayerUseCase(width, height);
339
447
  }
340
448
  containerEndLayer(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x = 1, layer_scale_y = 1) {
449
+ if ($attachmentDeferred) {
450
+ contextSyncAttachmentUseCase(this);
451
+ }
341
452
  contextContainerEndLayerUseCase(blend_mode, matrix, color_transform, use_filter, filter_bounds, filter_params, unique_key, filter_key, layer_scale_x, layer_scale_y);
342
453
  }
343
454
  containerBeginAtlasNode(width, height) {
@@ -350,17 +461,29 @@ export class Context {
350
461
  return node;
351
462
  }
352
463
  containerEndAtlasNode() {
464
+ if ($attachmentDeferred) {
465
+ contextSyncAttachmentUseCase(this);
466
+ }
353
467
  const node = this._pendingAtlasNodes.pop();
354
468
  contextContainerEndAtlasNodeUseCase(node);
355
469
  }
356
470
  containerDrawCachedFilter(blend_mode, matrix, color_transform, filter_bounds, unique_key, filter_key) {
471
+ if ($attachmentDeferred) {
472
+ contextSyncAttachmentUseCase(this);
473
+ }
357
474
  contextContainerDrawCachedFilterUseCase(blend_mode, matrix, color_transform, filter_bounds, unique_key, filter_key);
358
475
  }
359
476
  async createImageBitmap(width, height) {
477
+ if ($attachmentDeferred) {
478
+ contextSyncAttachmentUseCase(this);
479
+ }
360
480
  flushTextUploads();
361
481
  return await contextCreateImageBitmapService(width, height);
362
482
  }
363
483
  getRenderCompletion() {
484
+ if ($attachmentDeferred) {
485
+ contextSyncAttachmentUseCase(this);
486
+ }
364
487
  flushTextUploads();
365
488
  return contextGetRenderCompletionService();
366
489
  }
@@ -1,7 +1,7 @@
1
1
  import { $gl } from "../../WebGLUtil";
2
2
  import { execute as textureManagerBind0UseCase } from "../../TextureManager/usecase/TextureManagerBind0UseCase";
3
3
  import { execute as textureManagerBindService } from "../../TextureManager/service/TextureManagerBindService";
4
- import { $setFramebufferBound, $setCurrentAttachment, $readFrameBuffer, $isFramebufferBound, $attachedColor, $setAttachedColor, $attachedStencil, $setAttachedStencil } from "../../FrameBufferManager";
4
+ import { $setFramebufferBound, $setCurrentAttachment, $setPhysicalAttachment, $setAttachmentDeferred, $readFrameBuffer, $isFramebufferBound, $attachedColor, $setAttachedColor, $attachedStencil, $setAttachedStencil } from "../../FrameBufferManager";
5
5
  /**
6
6
  * @description フレームバッファにアタッチメントオブジェクトをバインドする
7
7
  * Bind the attachment object to the frame buffer
@@ -13,6 +13,8 @@ import { $setFramebufferBound, $setCurrentAttachment, $readFrameBuffer, $isFrame
13
13
  */
14
14
  export const execute = (attachment_object) => {
15
15
  $setCurrentAttachment(attachment_object);
16
+ $setPhysicalAttachment(attachment_object);
17
+ $setAttachmentDeferred(false);
16
18
  if (!$isFramebufferBound) {
17
19
  $setFramebufferBound(true);
18
20
  $gl.bindFramebuffer($gl.FRAMEBUFFER, $readFrameBuffer);
@@ -1,5 +1,5 @@
1
1
  import { $gl } from "../../WebGLUtil";
2
- import { $setCurrentAttachment, $isFramebufferBound, $setFramebufferBound } from "../../FrameBufferManager";
2
+ import { $setCurrentAttachment, $setPhysicalAttachment, $setAttachmentDeferred, $isFramebufferBound, $setFramebufferBound } from "../../FrameBufferManager";
3
3
  /**
4
4
  * @description 現在アタッチされているFramebufferのバインド解除
5
5
  * Unbind the currently attached Framebuffer
@@ -10,6 +10,8 @@ import { $setCurrentAttachment, $isFramebufferBound, $setFramebufferBound } from
10
10
  */
11
11
  export const execute = () => {
12
12
  $setCurrentAttachment(null);
13
+ $setPhysicalAttachment(null);
14
+ $setAttachmentDeferred(false);
13
15
  if ($isFramebufferBound) {
14
16
  $setFramebufferBound(false);
15
17
  $gl.bindFramebuffer($gl.FRAMEBUFFER, null);
@@ -48,6 +48,43 @@ export declare let $atlasFrameBuffer: WebGLFramebuffer | null;
48
48
  export declare const $setAtlasFrameBuffer: (gl: WebGL2RenderingContext) => void;
49
49
  export declare let $currentAttachment: IAttachmentObject | null;
50
50
  export declare const $setCurrentAttachment: (attachment_object: IAttachmentObject | null) => void;
51
+ /**
52
+ * @description GL のフレームバッファに実際に付いているアタッチメントオブジェクト。
53
+ * 通常は $currentAttachment と同じ。$attachmentDeferred が true の間だけ違う。
54
+ * The attachment object actually attached to the GL framebuffer. Normally the same as
55
+ * $currentAttachment; they differ only while $attachmentDeferred is true.
56
+ *
57
+ * @type {IAttachmentObject | null}
58
+ * @public
59
+ */
60
+ export declare let $physicalAttachment: IAttachmentObject | null;
61
+ /**
62
+ * @param {IAttachmentObject | null} attachment_object
63
+ * @return {void}
64
+ * @method
65
+ * @public
66
+ */
67
+ export declare const $setPhysicalAttachment: (attachment_object: IAttachmentObject | null) => void;
68
+ /**
69
+ * @description 描画先の切り替えを保留しているかどうか。true の間、$currentAttachment (とビューポートの
70
+ * 大きさ) は切り替え後の値だが、GL のフレームバッファは $physicalAttachment のまま。
71
+ * GL で描く前に ContextSyncAttachmentUseCase で実際に切り替える。
72
+ * Whether a render target switch is pending. While true, $currentAttachment (and the
73
+ * viewport size) already hold the new target but the GL framebuffer still has
74
+ * $physicalAttachment. ContextSyncAttachmentUseCase performs the switch before
75
+ * anything is drawn with GL.
76
+ *
77
+ * @type {boolean}
78
+ * @public
79
+ */
80
+ export declare let $attachmentDeferred: boolean;
81
+ /**
82
+ * @param {boolean} state
83
+ * @return {void}
84
+ * @method
85
+ * @public
86
+ */
87
+ export declare const $setAttachmentDeferred: (state: boolean) => void;
51
88
  export declare let $isFramebufferBound: boolean;
52
89
  export declare const $setFramebufferBound: (state: boolean) => void;
53
90
  export declare let $readBitmapFramebuffer: WebGLFramebuffer | null;
@@ -64,6 +64,47 @@ export let $currentAttachment = null;
64
64
  export const $setCurrentAttachment = (attachment_object) => {
65
65
  $currentAttachment = attachment_object;
66
66
  };
67
+ /**
68
+ * @description GL のフレームバッファに実際に付いているアタッチメントオブジェクト。
69
+ * 通常は $currentAttachment と同じ。$attachmentDeferred が true の間だけ違う。
70
+ * The attachment object actually attached to the GL framebuffer. Normally the same as
71
+ * $currentAttachment; they differ only while $attachmentDeferred is true.
72
+ *
73
+ * @type {IAttachmentObject | null}
74
+ * @public
75
+ */
76
+ export let $physicalAttachment = null;
77
+ /**
78
+ * @param {IAttachmentObject | null} attachment_object
79
+ * @return {void}
80
+ * @method
81
+ * @public
82
+ */
83
+ export const $setPhysicalAttachment = (attachment_object) => {
84
+ $physicalAttachment = attachment_object;
85
+ };
86
+ /**
87
+ * @description 描画先の切り替えを保留しているかどうか。true の間、$currentAttachment (とビューポートの
88
+ * 大きさ) は切り替え後の値だが、GL のフレームバッファは $physicalAttachment のまま。
89
+ * GL で描く前に ContextSyncAttachmentUseCase で実際に切り替える。
90
+ * Whether a render target switch is pending. While true, $currentAttachment (and the
91
+ * viewport size) already hold the new target but the GL framebuffer still has
92
+ * $physicalAttachment. ContextSyncAttachmentUseCase performs the switch before
93
+ * anything is drawn with GL.
94
+ *
95
+ * @type {boolean}
96
+ * @public
97
+ */
98
+ export let $attachmentDeferred = false;
99
+ /**
100
+ * @param {boolean} state
101
+ * @return {void}
102
+ * @method
103
+ * @public
104
+ */
105
+ export const $setAttachmentDeferred = (state) => {
106
+ $attachmentDeferred = state;
107
+ };
67
108
  export let $isFramebufferBound = false;
68
109
  export const $setFramebufferBound = (state) => {
69
110
  $isFramebufferBound = state;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @description いまの経路を塗りのメッシュにして、塗りのバッファへ追加する。
3
+ * 経路を実行環境の側で組み立てていれば、メッシュもそちらで作る。
4
+ * Turns the current path into a fill mesh and appends it to the fill buffer.
5
+ * If the path was built on the runtime side, the mesh is generated there too.
6
+ *
7
+ * @return {number} 追加した頂点数。塗る経路が無ければ -1
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: () => number;
@@ -0,0 +1,41 @@
1
+ import { $getVertices } from "../../PathCommand";
2
+ import { execute as meshFillGenerateUseCase } from "./MeshFillGenerateUseCase";
3
+ import { $addFillBuffer, $reserveFillBuffer, $advanceFillBuffer, $getFillBuffer, $getFillBufferOffset } from "../../Mesh";
4
+ import { $nativeShape, $nativePathActive, $setNativePathActive } from "../../NativeShape";
5
+ import { $context, $viewportWidth, $viewportHeight } from "../../WebGLUtil";
6
+ /**
7
+ * @description いまの経路を塗りのメッシュにして、塗りのバッファへ追加する。
8
+ * 経路を実行環境の側で組み立てていれば、メッシュもそちらで作る。
9
+ * Turns the current path into a fill mesh and appends it to the fill buffer.
10
+ * If the path was built on the runtime side, the mesh is generated there too.
11
+ *
12
+ * @return {number} 追加した頂点数。塗る経路が無ければ -1
13
+ * @method
14
+ * @protected
15
+ */
16
+ export const execute = () => {
17
+ if ($nativePathActive && $nativeShape) {
18
+ $setNativePathActive(false);
19
+ const size = $nativeShape.fillSize();
20
+ if (!size) {
21
+ $nativeShape.reset();
22
+ return -1;
23
+ }
24
+ // MeshFillGenerateUseCase と同じ値を渡す
25
+ const colorStyle = $context.$fillStyle;
26
+ const matrix = $context.$matrix;
27
+ const width = $viewportWidth;
28
+ const height = $viewportHeight;
29
+ $reserveFillBuffer(size);
30
+ const indexCount = $nativeShape.fill($getFillBuffer(), $getFillBufferOffset(), matrix[0] / width, matrix[1] / height, matrix[3] / width, matrix[4] / height, matrix[6] / width, matrix[7] / height, colorStyle[0], colorStyle[1], colorStyle[2], colorStyle[3]);
31
+ $advanceFillBuffer(size);
32
+ return indexCount;
33
+ }
34
+ const vertices = $getVertices();
35
+ if (!vertices.length) {
36
+ return -1;
37
+ }
38
+ const mesh = meshFillGenerateUseCase(vertices);
39
+ $addFillBuffer(mesh.buffer);
40
+ return mesh.indexCount;
41
+ };
package/src/Mesh.d.ts CHANGED
@@ -37,6 +37,30 @@ export declare const $getFillBufferOffset: () => number;
37
37
  * @protected
38
38
  */
39
39
  export declare const $addFillBuffer: (buffer: Float32Array) => void;
40
+ /**
41
+ * @description 塗りのバッファに、あと size 要素を書けるだけの領域を確保する (内容は保つ)。
42
+ * 確保した後、$getFillBuffer() の $getFillBufferOffset() の位置から直接書き、
43
+ * $advanceFillBuffer(size) で位置を進める。
44
+ * Reserves room for `size` more elements in the fill buffer, keeping its content.
45
+ * Then write directly from $getFillBufferOffset() of $getFillBuffer() and advance
46
+ * the position with $advanceFillBuffer(size).
47
+ *
48
+ * @param {number} size
49
+ * @return {void}
50
+ * @method
51
+ * @protected
52
+ */
53
+ export declare const $reserveFillBuffer: (size: number) => void;
54
+ /**
55
+ * @description 塗りのバッファの書き込み位置を size 要素だけ進める
56
+ * Advances the write position of the fill buffer by `size` elements
57
+ *
58
+ * @param {number} size
59
+ * @return {void}
60
+ * @method
61
+ * @protected
62
+ */
63
+ export declare const $advanceFillBuffer: (size: number) => void;
40
64
  /**
41
65
  * @description バッファを頂点数の配列
42
66
  * Array of the number of vertices in the buffer
package/src/Mesh.js CHANGED
@@ -73,6 +73,41 @@ export const $addFillBuffer = (buffer) => {
73
73
  }
74
74
  $fillBufferOffset += buffer.length;
75
75
  };
76
+ /**
77
+ * @description 塗りのバッファに、あと size 要素を書けるだけの領域を確保する (内容は保つ)。
78
+ * 確保した後、$getFillBuffer() の $getFillBufferOffset() の位置から直接書き、
79
+ * $advanceFillBuffer(size) で位置を進める。
80
+ * Reserves room for `size` more elements in the fill buffer, keeping its content.
81
+ * Then write directly from $getFillBufferOffset() of $getFillBuffer() and advance
82
+ * the position with $advanceFillBuffer(size).
83
+ *
84
+ * @param {number} size
85
+ * @return {void}
86
+ * @method
87
+ * @protected
88
+ */
89
+ export const $reserveFillBuffer = (size) => {
90
+ const length = size + $fillBufferOffset;
91
+ if (length > $fillBuffer.length) {
92
+ const newBuffer = new Float32Array($upperPowerOfTwo(length));
93
+ if ($fillBufferOffset > 0) {
94
+ newBuffer.set($fillBuffer.subarray(0, $fillBufferOffset));
95
+ }
96
+ $fillBuffer = newBuffer;
97
+ }
98
+ };
99
+ /**
100
+ * @description 塗りのバッファの書き込み位置を size 要素だけ進める
101
+ * Advances the write position of the fill buffer by `size` elements
102
+ *
103
+ * @param {number} size
104
+ * @return {void}
105
+ * @method
106
+ * @protected
107
+ */
108
+ export const $advanceFillBuffer = (size) => {
109
+ $fillBufferOffset += size;
110
+ };
76
111
  /**
77
112
  * @description バッファを頂点数の配列
78
113
  * Array of the number of vertices in the buffer
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @description 実行環境が提供する、図形の「経路の組み立て」と「塗りのメッシュの生成」の実装。
3
+ * JIT が使えない実行環境 (ゲーム機向けのホスト) が、グローバルの __next2dShape に置く。
4
+ * 無い環境 (ブラウザ) では null で、すべて JavaScript で処理する。結果はどちらも同じ。
5
+ *
6
+ * The implementation of path building and fill mesh generation provided by the runtime.
7
+ * Runtimes without a JIT (hosts for game consoles) put it on the global as
8
+ * __next2dShape. Where it is absent (browsers) this is null and everything runs in
9
+ * JavaScript. Both produce the same result.
10
+ */
11
+ export interface INativeShape {
12
+ path(commands: Float32Array, index: number, scale_squared: number): number;
13
+ fillSize(): number;
14
+ fill(target: Float32Array, offset: number, a: number, b: number, c: number, d: number, tx: number, ty: number, red: number, green: number, blue: number, alpha: number): number;
15
+ exportPath(stroke: boolean): Float64Array;
16
+ reset(): void;
17
+ }
18
+ /**
19
+ * @type {INativeShape | null}
20
+ * @public
21
+ */
22
+ export declare const $nativeShape: INativeShape | null;
23
+ /**
24
+ * @description 経路を実行環境の側で組み立てている最中かどうか。
25
+ * true の間、JavaScript 側の経路 ($currentPath / $vertices) は空。
26
+ * Whether the path is currently being built on the runtime side. While true, the
27
+ * JavaScript-side path ($currentPath / $vertices) is empty.
28
+ *
29
+ * @type {boolean}
30
+ * @public
31
+ */
32
+ export declare let $nativePathActive: boolean;
33
+ /**
34
+ * @param {boolean} active
35
+ * @return {void}
36
+ * @method
37
+ * @public
38
+ */
39
+ export declare const $setNativePathActive: (active: boolean) => void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @type {INativeShape | null}
3
+ * @public
4
+ */
5
+ export const $nativeShape = globalThis.__next2dShape || null;
6
+ /**
7
+ * @description 経路を実行環境の側で組み立てている最中かどうか。
8
+ * true の間、JavaScript 側の経路 ($currentPath / $vertices) は空。
9
+ * Whether the path is currently being built on the runtime side. While true, the
10
+ * JavaScript-side path ($currentPath / $vertices) is empty.
11
+ *
12
+ * @type {boolean}
13
+ * @public
14
+ */
15
+ export let $nativePathActive = false;
16
+ /**
17
+ * @param {boolean} active
18
+ * @return {void}
19
+ * @method
20
+ * @public
21
+ */
22
+ export const $setNativePathActive = (active) => {
23
+ $nativePathActive = active;
24
+ };
@@ -1,4 +1,5 @@
1
1
  import { $poolArray } from "../../WebGLUtil";
2
+ import { $nativeShape, $nativePathActive, $setNativePathActive } from "../../NativeShape";
2
3
  import { $currentPath, $vertices } from "../../PathCommand";
3
4
  /**
4
5
  * @description 現在操作中のパス配列を全てクリアします。
@@ -9,6 +10,11 @@ import { $currentPath, $vertices } from "../../PathCommand";
9
10
  * @protected
10
11
  */
11
12
  export const execute = () => {
13
+ // 経路を実行環境の側で組み立てていた場合は、そちらを空にする
14
+ if ($nativePathActive && $nativeShape) {
15
+ $setNativePathActive(false);
16
+ $nativeShape.reset();
17
+ }
12
18
  $currentPath.length = 0;
13
19
  while ($vertices.length) {
14
20
  $poolArray($vertices.pop());
@@ -1,4 +1,5 @@
1
1
  import { $getArray } from "./WebGLUtil";
2
+ import { $nativeShape, $nativePathActive, $setNativePathActive } from "./NativeShape";
2
3
  /**
3
4
  * @description 現在操作中のパス配列
4
5
  * Current path array being operated
@@ -26,6 +27,25 @@ export const $vertices = $getArray();
26
27
  */
27
28
  export const $getVertices = (stroke = false) => {
28
29
  // stroke: 最低2頂点(6要素)が必要、fill: 最低3頂点(9要素)が必要
30
+ // 経路を実行環境の側で組み立てていた場合は、そこから取り出す
31
+ // (線の生成など、実行環境の側に実装が無い処理が経路を必要としたとき)
32
+ if ($nativePathActive && $nativeShape) {
33
+ $setNativePathActive(false);
34
+ const data = $nativeShape.exportPath(stroke);
35
+ const paths = [];
36
+ const count = data[0];
37
+ let offset = 1;
38
+ for (let idx = 0; idx < count; ++idx) {
39
+ const size = data[offset++];
40
+ const path = [];
41
+ for (let position = 0; position < size; position += 3) {
42
+ path.push(data[offset + position], data[offset + position + 1], data[offset + position + 2] !== 0);
43
+ }
44
+ offset += size;
45
+ paths.push(path);
46
+ }
47
+ return paths;
48
+ }
29
49
  const minVertices = stroke ? 6 : 9;
30
50
  // 現在のパスをverticesに追加
31
51
  if ($currentPath.length >= minVertices) {