sfml.js 1.0.0 → 1.2.1
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/README.ja.md +10 -9
- package/README.ko.md +10 -9
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +44 -51
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -144
- package/docs/development.ko.md +0 -144
- package/docs/development.md +0 -146
- package/docs/development.zh-CN.md +0 -146
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -107
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
|
@@ -37,8 +37,9 @@ class RenderWindow extends render_target_1.RenderTarget {
|
|
|
37
37
|
const initializeViews = () => {
|
|
38
38
|
super.initializeViews(window_1.Window.prototype.getSize.call(this));
|
|
39
39
|
};
|
|
40
|
-
if (native_1.native.isWindowOpen(this[graphics_state_1.graphicsNative]))
|
|
40
|
+
if (native_1.native.isWindowOpen(this[graphics_state_1.graphicsNative])) {
|
|
41
41
|
initializeViews();
|
|
42
|
+
}
|
|
42
43
|
(0, window_1.registerWindowHooks)(this, () => {
|
|
43
44
|
initializeViews();
|
|
44
45
|
this.onCreate();
|
|
@@ -93,8 +94,9 @@ class RenderWindow extends render_target_1.RenderTarget {
|
|
|
93
94
|
* @ko 클라이언트 영역의 최소 픽셀 크기를 설정합니다. undefined는 제한을 해제합니다.
|
|
94
95
|
*/
|
|
95
96
|
setMinimumSize(size) {
|
|
96
|
-
if (size !== undefined)
|
|
97
|
+
if (size !== undefined) {
|
|
97
98
|
(0, video_mode_1.windowSize)(size);
|
|
99
|
+
}
|
|
98
100
|
this.flush();
|
|
99
101
|
window_1.Window.prototype.setMinimumSize.call(this, size);
|
|
100
102
|
}
|
|
@@ -105,8 +107,9 @@ class RenderWindow extends render_target_1.RenderTarget {
|
|
|
105
107
|
* @ko 클라이언트 영역의 최대 픽셀 크기를 설정합니다. undefined는 제한을 해제합니다.
|
|
106
108
|
*/
|
|
107
109
|
setMaximumSize(size) {
|
|
108
|
-
if (size !== undefined)
|
|
110
|
+
if (size !== undefined) {
|
|
109
111
|
(0, video_mode_1.windowSize)(size);
|
|
112
|
+
}
|
|
110
113
|
this.flush();
|
|
111
114
|
window_1.Window.prototype.setMaximumSize.call(this, size);
|
|
112
115
|
}
|
package/dist/graphics/shader.js
CHANGED
|
@@ -45,32 +45,45 @@ function nameString(name) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function numeric(value) {
|
|
48
|
-
if (typeof value === 'number')
|
|
48
|
+
if (typeof value === 'number') {
|
|
49
49
|
return { type: 0, data: new Float32Array([value]) };
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'boolean') {
|
|
51
52
|
return { type: 2, data: new Int32Array([+value]) };
|
|
52
|
-
|
|
53
|
+
}
|
|
54
|
+
if (value instanceof Glsl.Vec2) {
|
|
53
55
|
return { type: 3, data: value[value_storage_1.vector2Storage] };
|
|
54
|
-
|
|
56
|
+
}
|
|
57
|
+
if (value instanceof Glsl.Vec3) {
|
|
55
58
|
return { type: 4, data: value[value_storage_1.vector3Storage] };
|
|
56
|
-
|
|
59
|
+
}
|
|
60
|
+
if (value instanceof Glsl.Vec4) {
|
|
57
61
|
return { type: 5, data: value[glsl_value_1.glslStorage] };
|
|
58
|
-
|
|
62
|
+
}
|
|
63
|
+
if (value instanceof Glsl.Ivec2) {
|
|
59
64
|
return { type: 6, data: value[value_storage_1.vector2Storage] };
|
|
60
|
-
|
|
65
|
+
}
|
|
66
|
+
if (value instanceof Glsl.Ivec3) {
|
|
61
67
|
return { type: 7, data: value[value_storage_1.vector3Storage] };
|
|
62
|
-
|
|
68
|
+
}
|
|
69
|
+
if (value instanceof Glsl.Ivec4) {
|
|
63
70
|
return { type: 8, data: value[glsl_value_1.glslStorage] };
|
|
64
|
-
|
|
71
|
+
}
|
|
72
|
+
if (value instanceof Glsl.Bvec2) {
|
|
65
73
|
return { type: 9, data: new Int32Array(value[glsl_value_1.glslStorage]) };
|
|
66
|
-
|
|
74
|
+
}
|
|
75
|
+
if (value instanceof Glsl.Bvec3) {
|
|
67
76
|
return { type: 10, data: new Int32Array(value[glsl_value_1.glslStorage]) };
|
|
68
|
-
|
|
77
|
+
}
|
|
78
|
+
if (value instanceof Glsl.Bvec4) {
|
|
69
79
|
return { type: 11, data: new Int32Array(value[glsl_value_1.glslStorage]) };
|
|
70
|
-
|
|
80
|
+
}
|
|
81
|
+
if (value instanceof Glsl.Mat3) {
|
|
71
82
|
return { type: 12, data: value[glsl_value_1.glslStorage] };
|
|
72
|
-
|
|
83
|
+
}
|
|
84
|
+
if (value instanceof Glsl.Mat4) {
|
|
73
85
|
return { type: 13, data: value[glsl_value_1.glslStorage] };
|
|
86
|
+
}
|
|
74
87
|
throw new TypeError('Expected a Shader uniform value');
|
|
75
88
|
}
|
|
76
89
|
/**
|
|
@@ -134,21 +147,26 @@ class Shader {
|
|
|
134
147
|
const code = [null, null, null];
|
|
135
148
|
for (let i = 0; i < 3; i++) {
|
|
136
149
|
const stream = stages[i];
|
|
137
|
-
if (stream === null)
|
|
150
|
+
if (stream === null) {
|
|
138
151
|
continue;
|
|
139
|
-
|
|
152
|
+
}
|
|
153
|
+
if (!(stream instanceof input_stream_1.InputStream)) {
|
|
140
154
|
throw new TypeError('Expected an InputStream');
|
|
155
|
+
}
|
|
141
156
|
const size = await stream.getSize();
|
|
142
|
-
if (size === undefined || size === 0n)
|
|
157
|
+
if (size === undefined || size === 0n) {
|
|
143
158
|
return false;
|
|
159
|
+
}
|
|
144
160
|
if (typeof size !== 'bigint' || size < 0n || size > 0x7fffffffn) {
|
|
145
161
|
throw new RangeError('Shader stream size exceeds the buffer limit');
|
|
146
162
|
}
|
|
147
|
-
if (await stream.seek(0n) === undefined)
|
|
163
|
+
if ((await stream.seek(0n)) === undefined) {
|
|
148
164
|
return false;
|
|
165
|
+
}
|
|
149
166
|
const bytes = new Uint8Array(Number(size));
|
|
150
|
-
if (await stream.read(bytes) !== size)
|
|
167
|
+
if ((await stream.read(bytes)) !== size) {
|
|
151
168
|
return false;
|
|
169
|
+
}
|
|
152
170
|
code[i] = Buffer.from(bytes.buffer).toString('utf8');
|
|
153
171
|
}
|
|
154
172
|
return this.compile(true, code);
|
|
@@ -168,7 +186,8 @@ class Shader {
|
|
|
168
186
|
return;
|
|
169
187
|
}
|
|
170
188
|
const { type, data } = scalarType === 'int'
|
|
171
|
-
? { type: 1, data: new Int32Array([value]) }
|
|
189
|
+
? { type: 1, data: new Int32Array([value]) }
|
|
190
|
+
: numeric(value);
|
|
172
191
|
(0, graphics_state_1.flushGraphics)();
|
|
173
192
|
native_1.native.setShaderUniform(this[graphics_state_1.graphicsNative], name, type, data, false);
|
|
174
193
|
}
|
|
@@ -183,14 +202,17 @@ class Shader {
|
|
|
183
202
|
nameString(name);
|
|
184
203
|
let type = 0;
|
|
185
204
|
let data;
|
|
186
|
-
if (values instanceof Float32Array)
|
|
205
|
+
if (values instanceof Float32Array) {
|
|
187
206
|
data = values;
|
|
207
|
+
}
|
|
188
208
|
else {
|
|
189
|
-
if (!Array.isArray(values))
|
|
209
|
+
if (!Array.isArray(values)) {
|
|
190
210
|
throw new TypeError('Expected a uniform array');
|
|
211
|
+
}
|
|
191
212
|
const parts = Array.from(values, value => numeric(value));
|
|
192
|
-
if (parts.length)
|
|
213
|
+
if (parts.length) {
|
|
193
214
|
type = parts[0].type;
|
|
215
|
+
}
|
|
194
216
|
if (![0, 3, 4, 5, 12, 13].includes(type) ||
|
|
195
217
|
parts.some(part => part.type !== type)) {
|
|
196
218
|
throw new TypeError('Expected a homogeneous float, vector or matrix array');
|
|
@@ -230,14 +252,18 @@ class Shader {
|
|
|
230
252
|
* @ja 現在の環境がシェーダーに対応しているかを返します。
|
|
231
253
|
* @ko 현재 환경의 셰이더 지원 여부를 반환합니다.
|
|
232
254
|
*/
|
|
233
|
-
static isAvailable() {
|
|
255
|
+
static isAvailable() {
|
|
256
|
+
return native_1.native.isShaderAvailable(false);
|
|
257
|
+
}
|
|
234
258
|
/**
|
|
235
259
|
* Returns whether the current environment supports geometry shaders.
|
|
236
260
|
* @zh 返回当前环境是否支持几何着色器。
|
|
237
261
|
* @ja 現在の環境がジオメトリシェーダーに対応しているかを返します。
|
|
238
262
|
* @ko 현재 환경의 기하 셰이더 지원 여부를 반환합니다.
|
|
239
263
|
*/
|
|
240
|
-
static isGeometryAvailable() {
|
|
264
|
+
static isGeometryAvailable() {
|
|
265
|
+
return native_1.native.isShaderAvailable(true);
|
|
266
|
+
}
|
|
241
267
|
/**
|
|
242
268
|
* Normalizes stage arguments into a [vertex, geometry, fragment] tuple.
|
|
243
269
|
* @zh 将阶段参数标准化为 [vertex, geometry, fragment] 三元组。
|
|
@@ -246,17 +272,21 @@ class Shader {
|
|
|
246
272
|
*/
|
|
247
273
|
stages(sources) {
|
|
248
274
|
if (sources.length === 2 && typeof sources[1] === 'number') {
|
|
249
|
-
if (!Number.isInteger(sources[1]) ||
|
|
275
|
+
if (!Number.isInteger(sources[1]) ||
|
|
276
|
+
sources[1] < 0 ||
|
|
277
|
+
sources[1] > 2) {
|
|
250
278
|
throw new RangeError('Invalid shader type');
|
|
251
279
|
}
|
|
252
280
|
const result = [null, null, null];
|
|
253
281
|
result[sources[1]] = sources[0];
|
|
254
282
|
return result;
|
|
255
283
|
}
|
|
256
|
-
if (sources.length === 2)
|
|
284
|
+
if (sources.length === 2) {
|
|
257
285
|
return [sources[0], null, sources[1]];
|
|
258
|
-
|
|
286
|
+
}
|
|
287
|
+
if (sources.length === 3) {
|
|
259
288
|
return sources;
|
|
289
|
+
}
|
|
260
290
|
throw new TypeError('Expected a shader source and type, or two/three sources');
|
|
261
291
|
}
|
|
262
292
|
/**
|
|
@@ -267,12 +297,15 @@ class Shader {
|
|
|
267
297
|
*/
|
|
268
298
|
async load(memory, sources) {
|
|
269
299
|
const stages = this.stages(sources).map(source => {
|
|
270
|
-
if (source === null)
|
|
300
|
+
if (source === null) {
|
|
271
301
|
return null;
|
|
272
|
-
|
|
302
|
+
}
|
|
303
|
+
if (typeof source !== 'string') {
|
|
273
304
|
throw new TypeError('Expected shader source strings');
|
|
274
|
-
|
|
305
|
+
}
|
|
306
|
+
if (!memory && source.includes('\0')) {
|
|
275
307
|
throw new TypeError('Invalid shader path');
|
|
308
|
+
}
|
|
276
309
|
return memory || !source ? source : (0, node_path_1.resolve)(source);
|
|
277
310
|
});
|
|
278
311
|
return this.compile(memory, stages);
|
|
@@ -286,10 +319,12 @@ class Shader {
|
|
|
286
319
|
compile(memory, sources) {
|
|
287
320
|
return new Promise((resolve, reject) => {
|
|
288
321
|
native_1.native.compileShader(memory, sources, (error, program) => {
|
|
289
|
-
if (error)
|
|
322
|
+
if (error) {
|
|
290
323
|
return reject(error);
|
|
291
|
-
|
|
324
|
+
}
|
|
325
|
+
if (!program) {
|
|
292
326
|
return resolve(false);
|
|
327
|
+
}
|
|
293
328
|
try {
|
|
294
329
|
(0, graphics_state_1.flushGraphics)();
|
|
295
330
|
native_1.native.commitShader(this[graphics_state_1.graphicsNative], program);
|
package/dist/graphics/shape.js
CHANGED
|
@@ -14,8 +14,9 @@ const drawable_1 = require("./drawable");
|
|
|
14
14
|
const rect_1 = require("./rect");
|
|
15
15
|
const texture_1 = require("./texture");
|
|
16
16
|
function shapeNumber(value) {
|
|
17
|
-
if (typeof value !== 'number')
|
|
17
|
+
if (typeof value !== 'number') {
|
|
18
18
|
throw new TypeError('Expected a number');
|
|
19
|
+
}
|
|
19
20
|
const result = Math.fround(value);
|
|
20
21
|
if (!Number.isFinite(result)) {
|
|
21
22
|
throw new RangeError('Expected a finite float32 value');
|
|
@@ -24,7 +25,8 @@ function shapeNumber(value) {
|
|
|
24
25
|
}
|
|
25
26
|
exports.shapeNumber = shapeNumber;
|
|
26
27
|
function shapeCount(value) {
|
|
27
|
-
if (!Number.isInteger(value) ||
|
|
28
|
+
if (!Number.isInteger(value) ||
|
|
29
|
+
value < 0 ||
|
|
28
30
|
value > Math.floor(0x7fffffff / (6 * 20)) - 2) {
|
|
29
31
|
throw new RangeError('Shape point count exceeds the buffer limit');
|
|
30
32
|
}
|
|
@@ -45,12 +47,14 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
45
47
|
const mapping = native_1.native.createShape((0, graphics_state_1.graphicsContext)(), init.kind, init.x ?? 0, init.y ?? 0, init.source?.[graphics_state_1.graphicsNative]);
|
|
46
48
|
this[graphics_state_1.graphicsNative] = mapping.handle;
|
|
47
49
|
this[graphics_state_1.shapeState] = {
|
|
48
|
-
id: mapping.id,
|
|
50
|
+
id: mapping.id,
|
|
51
|
+
words: new Uint32Array(mapping.appearance),
|
|
49
52
|
rectangle: new Int32Array(mapping.appearance, 12, 4),
|
|
50
53
|
texture: init.source?.[graphics_state_1.shapeState].texture ?? null,
|
|
51
54
|
};
|
|
52
55
|
this[transformable_1.transformableState] = {
|
|
53
|
-
handle: mapping.transformable,
|
|
56
|
+
handle: mapping.transformable,
|
|
57
|
+
values: new Float32Array(mapping.buffer),
|
|
54
58
|
};
|
|
55
59
|
this.shapeInfo = (0, struct_view_1.nativeStruct)(mapping.info);
|
|
56
60
|
}
|
|
@@ -65,11 +69,13 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
65
69
|
if (texture !== null && !(texture instanceof texture_1.Texture)) {
|
|
66
70
|
throw new TypeError('Expected a Texture or null');
|
|
67
71
|
}
|
|
68
|
-
if (typeof resetRect !== 'boolean')
|
|
72
|
+
if (typeof resetRect !== 'boolean') {
|
|
69
73
|
throw new TypeError('Expected a boolean');
|
|
74
|
+
}
|
|
70
75
|
const state = this[graphics_state_1.shapeState];
|
|
71
|
-
const reset = texture &&
|
|
72
|
-
(
|
|
76
|
+
const reset = texture &&
|
|
77
|
+
(resetRect ||
|
|
78
|
+
(!state.texture && state.rectangle.every(value => value === 0)));
|
|
73
79
|
if (texture !== state.texture) {
|
|
74
80
|
native_1.native.setShapeTexture(this[graphics_state_1.graphicsNative], texture?.[graphics_state_1.graphicsNative] ?? null, texture?.[graphics_state_1.textureId] ?? 0);
|
|
75
81
|
state.texture = texture;
|
|
@@ -96,8 +102,9 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
96
102
|
* @ko 사용할 텍스처 픽셀 영역을 복사합니다. 음수 크기로 텍스처를 반전할 수 있습니다.
|
|
97
103
|
*/
|
|
98
104
|
setTextureRect(rectangle) {
|
|
99
|
-
if (!(rectangle instanceof rect_1.IntRect))
|
|
105
|
+
if (!(rectangle instanceof rect_1.IntRect)) {
|
|
100
106
|
throw new TypeError('Expected an IntRect');
|
|
107
|
+
}
|
|
101
108
|
this[graphics_state_1.shapeState].rectangle.set(rectangle[value_storage_1.rectStorage]);
|
|
102
109
|
}
|
|
103
110
|
/**
|
|
@@ -120,8 +127,9 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
120
127
|
* @ko 채우기 색상을 설정합니다. 그릴 때 텍스처 색상과 곱해집니다.
|
|
121
128
|
*/
|
|
122
129
|
setFillColor(color) {
|
|
123
|
-
if (!(color instanceof color_1.Color))
|
|
130
|
+
if (!(color instanceof color_1.Color)) {
|
|
124
131
|
throw new TypeError('Expected a Color');
|
|
132
|
+
}
|
|
125
133
|
this[graphics_state_1.shapeState].words[1] = color.toInteger();
|
|
126
134
|
}
|
|
127
135
|
/**
|
|
@@ -140,8 +148,9 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
140
148
|
* @ko 윤곽선 색상을 복사합니다.
|
|
141
149
|
*/
|
|
142
150
|
setOutlineColor(color) {
|
|
143
|
-
if (!(color instanceof color_1.Color))
|
|
151
|
+
if (!(color instanceof color_1.Color)) {
|
|
144
152
|
throw new TypeError('Expected a Color');
|
|
153
|
+
}
|
|
145
154
|
this[graphics_state_1.shapeState].words[2] = color.toInteger();
|
|
146
155
|
}
|
|
147
156
|
/**
|
|
@@ -181,8 +190,9 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
181
190
|
*/
|
|
182
191
|
setMiterLimit(limit) {
|
|
183
192
|
limit = shapeNumber(limit);
|
|
184
|
-
if (limit < 1)
|
|
193
|
+
if (limit < 1) {
|
|
185
194
|
throw new RangeError('Miter limit must be at least 1');
|
|
195
|
+
}
|
|
186
196
|
this.changeGeometry(1, limit);
|
|
187
197
|
}
|
|
188
198
|
/**
|
|
@@ -224,10 +234,12 @@ class ShapeResource extends drawable_1.Drawable {
|
|
|
224
234
|
target[graphics_state_1.recordShape](this, states);
|
|
225
235
|
}
|
|
226
236
|
[(_a = value_storage_1.mutableValue, graphics_state_1.dispatchDrawable)](target, states) {
|
|
227
|
-
if (this.draw === ShapeResource.prototype.draw)
|
|
237
|
+
if (this.draw === ShapeResource.prototype.draw) {
|
|
228
238
|
this.draw(target, states);
|
|
229
|
-
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
230
241
|
super[graphics_state_1.dispatchDrawable](target, states);
|
|
242
|
+
}
|
|
231
243
|
}
|
|
232
244
|
}
|
|
233
245
|
/**
|
package/dist/graphics/sprite.js
CHANGED
|
@@ -17,9 +17,12 @@ class SpriteResource extends drawable_1.Drawable {
|
|
|
17
17
|
super();
|
|
18
18
|
this[_a] = true;
|
|
19
19
|
const copy = source instanceof SpriteResource ? source : undefined;
|
|
20
|
-
const texture = copy
|
|
21
|
-
|
|
20
|
+
const texture = copy
|
|
21
|
+
? copy[graphics_state_1.spriteState].texture
|
|
22
|
+
: source;
|
|
23
|
+
if (!(texture instanceof texture_1.Texture)) {
|
|
22
24
|
throw new TypeError('Expected a Texture');
|
|
25
|
+
}
|
|
23
26
|
if (rectangle !== undefined && !(rectangle instanceof rect_1.IntRect)) {
|
|
24
27
|
throw new TypeError('Expected an IntRect');
|
|
25
28
|
}
|
|
@@ -29,11 +32,14 @@ class SpriteResource extends drawable_1.Drawable {
|
|
|
29
32
|
const { handle, transformable, id, buffer, appearance } = native_1.native.createSprite((0, graphics_state_1.graphicsContext)(), texture[graphics_state_1.graphicsNative], texture[graphics_state_1.textureId]);
|
|
30
33
|
this[graphics_state_1.graphicsNative] = handle;
|
|
31
34
|
this[graphics_state_1.spriteState] = {
|
|
32
|
-
id,
|
|
33
|
-
|
|
35
|
+
id,
|
|
36
|
+
words: new Uint32Array(appearance),
|
|
37
|
+
rectangle: new Int32Array(appearance, 4, 4),
|
|
38
|
+
texture,
|
|
34
39
|
};
|
|
35
40
|
this[transformable_1.transformableState] = {
|
|
36
|
-
handle: transformable,
|
|
41
|
+
handle: transformable,
|
|
42
|
+
values: new Float32Array(buffer),
|
|
37
43
|
};
|
|
38
44
|
if (copy) {
|
|
39
45
|
this[graphics_state_1.spriteState].words.set(copy[graphics_state_1.spriteState].words);
|
|
@@ -51,10 +57,12 @@ class SpriteResource extends drawable_1.Drawable {
|
|
|
51
57
|
* @ko 텍스처 참조를 교체합니다. resetRect가 true이면 텍스처 영역을 전체 텍스처로 초기화합니다.
|
|
52
58
|
*/
|
|
53
59
|
setTexture(texture, resetRect = false) {
|
|
54
|
-
if (!(texture instanceof texture_1.Texture))
|
|
60
|
+
if (!(texture instanceof texture_1.Texture)) {
|
|
55
61
|
throw new TypeError('Expected a Texture');
|
|
56
|
-
|
|
62
|
+
}
|
|
63
|
+
if (typeof resetRect !== 'boolean') {
|
|
57
64
|
throw new TypeError('Expected a boolean');
|
|
65
|
+
}
|
|
58
66
|
const state = this[graphics_state_1.spriteState];
|
|
59
67
|
if (texture !== state.texture) {
|
|
60
68
|
native_1.native.setSpriteTexture(this[graphics_state_1.graphicsNative], texture[graphics_state_1.graphicsNative], texture[graphics_state_1.textureId]);
|
|
@@ -82,8 +90,9 @@ class SpriteResource extends drawable_1.Drawable {
|
|
|
82
90
|
* @ko 텍스처 픽셀 영역을 복사합니다. 너비와 높이는 스프라이트 로컬 크기를 결정하며 음수 값으로 텍스처를 반전할 수 있습니다.
|
|
83
91
|
*/
|
|
84
92
|
setTextureRect(rectangle) {
|
|
85
|
-
if (!(rectangle instanceof rect_1.IntRect))
|
|
93
|
+
if (!(rectangle instanceof rect_1.IntRect)) {
|
|
86
94
|
throw new TypeError('Expected an IntRect');
|
|
95
|
+
}
|
|
87
96
|
this[graphics_state_1.spriteState].rectangle.set(rectangle[value_storage_1.rectStorage]);
|
|
88
97
|
}
|
|
89
98
|
/**
|
|
@@ -107,8 +116,9 @@ class SpriteResource extends drawable_1.Drawable {
|
|
|
107
116
|
* @ko 텍스처와 채널별로 곱할 색상을 설정합니다. Alpha로 전체 불투명도를 제어할 수 있습니다.
|
|
108
117
|
*/
|
|
109
118
|
setColor(color) {
|
|
110
|
-
if (!(color instanceof color_1.Color))
|
|
119
|
+
if (!(color instanceof color_1.Color)) {
|
|
111
120
|
throw new TypeError('Expected a Color');
|
|
121
|
+
}
|
|
112
122
|
this[graphics_state_1.spriteState].words[5] = color.toInteger();
|
|
113
123
|
}
|
|
114
124
|
/**
|
|
@@ -134,8 +134,10 @@ class StencilValue {
|
|
|
134
134
|
*/
|
|
135
135
|
constructor(value) {
|
|
136
136
|
const input = value instanceof StencilValue ? value.value : value;
|
|
137
|
-
if (!Number.isInteger(input) ||
|
|
138
|
-
input
|
|
137
|
+
if (!Number.isInteger(input) ||
|
|
138
|
+
typeof input !== 'number' ||
|
|
139
|
+
input < -0x80000000 ||
|
|
140
|
+
input > 0xffffffff) {
|
|
139
141
|
throw new RangeError('Expected a 32-bit stencil value');
|
|
140
142
|
}
|
|
141
143
|
(0, numeric_properties_1.numericProperties)(this, {
|
|
@@ -160,11 +162,13 @@ class StencilMode {
|
|
|
160
162
|
constructor(source = {}) {
|
|
161
163
|
(0, numeric_properties_1.numericProperties)(this, {
|
|
162
164
|
stencilComparison: StencilComparison.Always,
|
|
163
|
-
stencilUpdateOperation: StencilUpdateOperation.Keep,
|
|
165
|
+
stencilUpdateOperation: StencilUpdateOperation.Keep,
|
|
166
|
+
stencilOnly: false,
|
|
164
167
|
});
|
|
165
|
-
this.stencilComparison =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
this.stencilComparison =
|
|
169
|
+
source.stencilComparison ?? StencilComparison.Always;
|
|
170
|
+
this.stencilUpdateOperation =
|
|
171
|
+
source.stencilUpdateOperation ?? StencilUpdateOperation.Keep;
|
|
168
172
|
this.stencilReference = new StencilValue(source.stencilReference ?? 0);
|
|
169
173
|
this.stencilMask = new StencilValue(source.stencilMask ?? 0xffffffff);
|
|
170
174
|
this.stencilOnly = source.stencilOnly ?? false;
|
package/dist/graphics/swap.js
CHANGED
|
@@ -4,8 +4,9 @@ exports.swap = void 0;
|
|
|
4
4
|
const texture_1 = require("./texture");
|
|
5
5
|
const vertex_buffer_1 = require("./vertex-buffer");
|
|
6
6
|
function swap(left, right) {
|
|
7
|
-
if (left instanceof texture_1.Texture && right instanceof texture_1.Texture)
|
|
7
|
+
if (left instanceof texture_1.Texture && right instanceof texture_1.Texture) {
|
|
8
8
|
left.swap(right);
|
|
9
|
+
}
|
|
9
10
|
else if (left instanceof vertex_buffer_1.VertexBuffer && right instanceof vertex_buffer_1.VertexBuffer) {
|
|
10
11
|
left.swap(right);
|
|
11
12
|
}
|