@next2d/render-queue 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Next2D
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ @next2d/render-queue
2
+ =============
3
+
4
+ ## Installation
5
+
6
+ ```
7
+ npm install @next2d/render-queue
8
+ ```
9
+
10
+ ## License
11
+ This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@next2d/render-queue",
3
+ "version": "2.0.0",
4
+ "description": "Next2D Renderer Queue Package",
5
+ "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
+ "license": "MIT",
7
+ "homepage": "https://next2d.app",
8
+ "bugs": "https://github.com/Next2D/Player/issues",
9
+ "main": "src/index.js",
10
+ "types": "src/index.d.ts",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./src/index.js",
15
+ "require": "./src/index.js"
16
+ }
17
+ },
18
+ "keywords": [
19
+ "Next2D",
20
+ "Next2D Renderer Queue"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Next2D/Player.git"
25
+ }
26
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @description レンダーキューの管理クラス
3
+ * Management class of the render queue
4
+ *
5
+ * @class
6
+ * @public
7
+ */
8
+ declare class RenderQueue {
9
+ /**
10
+ * @description バッファ
11
+ * Buffer
12
+ *
13
+ * @type {Float32Array}
14
+ * @public
15
+ */
16
+ buffer: Float32Array;
17
+ /**
18
+ * @description オフセット
19
+ * Offset
20
+ *
21
+ * @type {number}
22
+ * @public
23
+ */
24
+ offset: number;
25
+ /**
26
+ * @constructor
27
+ * @public
28
+ */
29
+ constructor();
30
+ /**
31
+ * @description バッファにデータを追加
32
+ * Add data to the buffer
33
+ *
34
+ * @param {...number} args
35
+ * @return {void}
36
+ * @method
37
+ * @public
38
+ */
39
+ push(...args: number[]): void;
40
+ /**
41
+ * @description バッファをセット
42
+ * Set the buffer
43
+ *
44
+ * @param {Float32Array | Uint8Array} args
45
+ * @return {void}
46
+ * @method
47
+ * @public
48
+ */
49
+ set(array: Float32Array | Uint8Array): void;
50
+ /**
51
+ * @description バッファをリサイズ
52
+ * Resize the buffer
53
+ *
54
+ * @param {number} length
55
+ * @return {void}
56
+ * @method
57
+ * @public
58
+ */
59
+ resize(length: number): void;
60
+ }
61
+ export declare const renderQueue: RenderQueue;
62
+ export {};
@@ -0,0 +1,94 @@
1
+ import { $upperPowerOfTwo } from "./RenderQueueUtil";
2
+ /**
3
+ * @description レンダーキューの管理クラス
4
+ * Management class of the render queue
5
+ *
6
+ * @class
7
+ * @public
8
+ */
9
+ class RenderQueue {
10
+ /**
11
+ * @constructor
12
+ * @public
13
+ */
14
+ constructor() {
15
+ /**
16
+ * @description バッファ
17
+ * Buffer
18
+ *
19
+ * @type {Float32Array}
20
+ * @public
21
+ */
22
+ Object.defineProperty(this, "buffer", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ /**
29
+ * @description オフセット
30
+ * Offset
31
+ *
32
+ * @type {number}
33
+ * @public
34
+ */
35
+ Object.defineProperty(this, "offset", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ this.buffer = new Float32Array(256);
42
+ this.offset = 0;
43
+ }
44
+ /**
45
+ * @description バッファにデータを追加
46
+ * Add data to the buffer
47
+ *
48
+ * @param {...number} args
49
+ * @return {void}
50
+ * @method
51
+ * @public
52
+ */
53
+ push(...args) {
54
+ if (this.buffer.length < this.offset + args.length) {
55
+ this.resize(args.length);
56
+ }
57
+ for (let idx = 0; idx < args.length; idx++) {
58
+ this.buffer[this.offset++] = args[idx];
59
+ }
60
+ }
61
+ /**
62
+ * @description バッファをセット
63
+ * Set the buffer
64
+ *
65
+ * @param {Float32Array | Uint8Array} args
66
+ * @return {void}
67
+ * @method
68
+ * @public
69
+ */
70
+ set(array) {
71
+ if (this.buffer.length < this.offset + array.length) {
72
+ this.resize(array.length);
73
+ }
74
+ this.buffer.set(array, this.offset);
75
+ this.offset += array.length;
76
+ }
77
+ /**
78
+ * @description バッファをリサイズ
79
+ * Resize the buffer
80
+ *
81
+ * @param {number} length
82
+ * @return {void}
83
+ * @method
84
+ * @public
85
+ */
86
+ resize(length) {
87
+ const newBuffer = new Float32Array($upperPowerOfTwo(this.offset + length));
88
+ if (this.buffer.length) {
89
+ newBuffer.set(this.buffer);
90
+ }
91
+ this.buffer = newBuffer;
92
+ }
93
+ }
94
+ export const renderQueue = new RenderQueue();
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @description 指定された値を2の累乗に切り上げます。
3
+ * Rounds the specified value up to a power of two.
4
+ *
5
+ * @param {number} v
6
+ * @return {number}
7
+ * @method
8
+ * @protected
9
+ */
10
+ export declare const $upperPowerOfTwo: (v: number) => number;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @description 指定された値を2の累乗に切り上げます。
3
+ * Rounds the specified value up to a power of two.
4
+ *
5
+ * @param {number} v
6
+ * @return {number}
7
+ * @method
8
+ * @protected
9
+ */
10
+ export const $upperPowerOfTwo = (v) => {
11
+ v--;
12
+ v |= v >> 1;
13
+ v |= v >> 2;
14
+ v |= v >> 4;
15
+ v |= v >> 8;
16
+ v |= v >> 16;
17
+ v++;
18
+ return v;
19
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./RenderQueue";
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./RenderQueue";