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
package/src/audio/value.ts
CHANGED
|
@@ -190,18 +190,38 @@ export enum SoundStatus {
|
|
|
190
190
|
* @ko 16비트 인터리브 PCM의 읽기 전용 타입 뷰로,
|
|
191
191
|
* 기반 네이티브 저장소를 유지합니다.
|
|
192
192
|
*/
|
|
193
|
-
export type ReadonlySamples = Readonly<
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
export type ReadonlySamples = Readonly<
|
|
194
|
+
Pick<
|
|
195
|
+
Int16Array,
|
|
196
|
+
| number
|
|
197
|
+
| 'length'
|
|
198
|
+
| 'byteLength'
|
|
199
|
+
| 'byteOffset'
|
|
200
|
+
| typeof Symbol.iterator
|
|
201
|
+
| 'slice'
|
|
202
|
+
| 'entries'
|
|
203
|
+
| 'keys'
|
|
204
|
+
| 'values'
|
|
205
|
+
>
|
|
206
|
+
>;
|
|
196
207
|
/**
|
|
197
208
|
* Read-only view of channel positions in interleaved order.
|
|
198
209
|
* @zh 按交错顺序排列的声道位置只读视图。
|
|
199
210
|
* @ja インターリーブ順に並ぶチャンネル位置の読み取り専用ビュー。
|
|
200
211
|
* @ko 인터리브 순서로 나열된 채널 위치의 읽기 전용 뷰입니다.
|
|
201
212
|
*/
|
|
202
|
-
export type ChannelMap = Readonly<
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
export type ChannelMap = Readonly<
|
|
214
|
+
Pick<
|
|
215
|
+
Int32Array,
|
|
216
|
+
| number
|
|
217
|
+
| 'length'
|
|
218
|
+
| typeof Symbol.iterator
|
|
219
|
+
| 'slice'
|
|
220
|
+
| 'entries'
|
|
221
|
+
| 'keys'
|
|
222
|
+
| 'values'
|
|
223
|
+
>
|
|
224
|
+
>;
|
|
205
225
|
|
|
206
226
|
/**
|
|
207
227
|
* Directional cone parameters for a spatial sound source or listener.
|
|
@@ -241,7 +261,9 @@ export interface ConeInput {
|
|
|
241
261
|
* @ko 부동 소수점 필드로 노출되는 네이티브 sf::SoundSource::Cone입니다.
|
|
242
262
|
*/
|
|
243
263
|
export class Cone {
|
|
244
|
-
private readonly values = new Float32Array(
|
|
264
|
+
private readonly values = new Float32Array(
|
|
265
|
+
audioNative.createAudioValue(0),
|
|
266
|
+
);
|
|
245
267
|
/**
|
|
246
268
|
* Create a cone with zero angles and gain, or copy the given parameters.
|
|
247
269
|
* @zh 创建角度和增益均为零的方向锥,或复制给定参数。
|
|
@@ -261,42 +283,54 @@ export class Cone {
|
|
|
261
283
|
* @ja 内側コーンの全角のコピー。
|
|
262
284
|
* @ko 내부 원뿔 전체 각도의 복사본입니다.
|
|
263
285
|
*/
|
|
264
|
-
get innerAngle(): Angle {
|
|
286
|
+
get innerAngle(): Angle {
|
|
287
|
+
return radians(this.values[0]);
|
|
288
|
+
}
|
|
265
289
|
/**
|
|
266
290
|
* Copy the inner cone angle.
|
|
267
291
|
* @zh 复制内锥角度。
|
|
268
292
|
* @ja 内側コーンの角度をコピーします。
|
|
269
293
|
* @ko 내부 원뿔 각도를 복사합니다.
|
|
270
294
|
*/
|
|
271
|
-
set innerAngle(value: R<Angle>) {
|
|
295
|
+
set innerAngle(value: R<Angle>) {
|
|
296
|
+
this.values[0] = angle(value);
|
|
297
|
+
}
|
|
272
298
|
/**
|
|
273
299
|
* Copy of the full outer cone angle.
|
|
274
300
|
* @zh 外锥完整角度的副本。
|
|
275
301
|
* @ja 外側コーンの全角のコピー。
|
|
276
302
|
* @ko 외부 원뿔 전체 각도의 복사본입니다.
|
|
277
303
|
*/
|
|
278
|
-
get outerAngle(): Angle {
|
|
304
|
+
get outerAngle(): Angle {
|
|
305
|
+
return radians(this.values[1]);
|
|
306
|
+
}
|
|
279
307
|
/**
|
|
280
308
|
* Copy the outer cone angle.
|
|
281
309
|
* @zh 复制外锥角度。
|
|
282
310
|
* @ja 外側コーンの角度をコピーします。
|
|
283
311
|
* @ko 외부 원뿔 각도를 복사합니다.
|
|
284
312
|
*/
|
|
285
|
-
set outerAngle(value: R<Angle>) {
|
|
313
|
+
set outerAngle(value: R<Angle>) {
|
|
314
|
+
this.values[1] = angle(value);
|
|
315
|
+
}
|
|
286
316
|
/**
|
|
287
317
|
* Gain multiplier outside the outer cone.
|
|
288
318
|
* @zh 外锥之外的增益倍率。
|
|
289
319
|
* @ja 外側コーンの外でのゲイン倍率。
|
|
290
320
|
* @ko 외부 원뿔 바깥의 게인 배율입니다.
|
|
291
321
|
*/
|
|
292
|
-
get outerGain(): number {
|
|
322
|
+
get outerGain(): number {
|
|
323
|
+
return this.values[2];
|
|
324
|
+
}
|
|
293
325
|
/**
|
|
294
326
|
* Set the outer cone gain multiplier.
|
|
295
327
|
* @zh 设置外锥增益倍率。
|
|
296
328
|
* @ja 外側コーンのゲイン倍率を設定します。
|
|
297
329
|
* @ko 외부 원뿔의 게인 배율을 설정합니다.
|
|
298
330
|
*/
|
|
299
|
-
set outerGain(value: number) {
|
|
331
|
+
set outerGain(value: number) {
|
|
332
|
+
this.values[2] = float(value);
|
|
333
|
+
}
|
|
300
334
|
}
|
|
301
335
|
|
|
302
336
|
/**
|
|
@@ -328,7 +362,9 @@ export interface TimeSpanInput {
|
|
|
328
362
|
* @ko 정확한 마이크로초 단위로 저장되는 변경 가능한 오디오 시간 구간입니다.
|
|
329
363
|
*/
|
|
330
364
|
export class TimeSpan {
|
|
331
|
-
private readonly values = new BigInt64Array(
|
|
365
|
+
private readonly values = new BigInt64Array(
|
|
366
|
+
audioNative.createAudioValue(1),
|
|
367
|
+
);
|
|
332
368
|
/**
|
|
333
369
|
* Create a span with zero offset and length, or copy the given parameters.
|
|
334
370
|
* @zh 创建零偏移、零长度的时间段,或复制给定参数。
|
|
@@ -336,7 +372,10 @@ export class TimeSpan {
|
|
|
336
372
|
* @ko 오프셋과 길이가 0인 구간을 생성하거나 지정한 매개변수를 복사합니다.
|
|
337
373
|
*/
|
|
338
374
|
constructor(value?: Readonly<TimeSpanInput>) {
|
|
339
|
-
if (value) {
|
|
375
|
+
if (value) {
|
|
376
|
+
this.offset = value.offset;
|
|
377
|
+
this.length = value.length;
|
|
378
|
+
}
|
|
340
379
|
}
|
|
341
380
|
/**
|
|
342
381
|
* Copy of the starting offset.
|
|
@@ -344,36 +383,48 @@ export class TimeSpan {
|
|
|
344
383
|
* @ja 開始オフセットのコピー。
|
|
345
384
|
* @ko 시작 오프셋의 복사본입니다.
|
|
346
385
|
*/
|
|
347
|
-
get offset(): Time {
|
|
386
|
+
get offset(): Time {
|
|
387
|
+
return new Time(this.values[0]);
|
|
388
|
+
}
|
|
348
389
|
/**
|
|
349
390
|
* Copy the starting offset.
|
|
350
391
|
* @zh 复制起点偏移。
|
|
351
392
|
* @ja 開始オフセットをコピーします。
|
|
352
393
|
* @ko 시작 오프셋을 복사합니다.
|
|
353
394
|
*/
|
|
354
|
-
set offset(value: R<Time>) {
|
|
395
|
+
set offset(value: R<Time>) {
|
|
396
|
+
this.values[0] = duration(value);
|
|
397
|
+
}
|
|
355
398
|
/**
|
|
356
399
|
* Copy of the duration.
|
|
357
400
|
* @zh 时长的副本。
|
|
358
401
|
* @ja 長さのコピー。
|
|
359
402
|
* @ko 길이의 복사본입니다.
|
|
360
403
|
*/
|
|
361
|
-
get length(): Time {
|
|
404
|
+
get length(): Time {
|
|
405
|
+
return new Time(this.values[1]);
|
|
406
|
+
}
|
|
362
407
|
/**
|
|
363
408
|
* Copy the time span length.
|
|
364
409
|
* @zh 复制时间段长度。
|
|
365
410
|
* @ja 時間範囲の長さをコピーします。
|
|
366
411
|
* @ko 시간 구간의 길이를 복사합니다.
|
|
367
412
|
*/
|
|
368
|
-
set length(value: R<Time>) {
|
|
413
|
+
set length(value: R<Time>) {
|
|
414
|
+
this.values[1] = duration(value);
|
|
415
|
+
}
|
|
369
416
|
}
|
|
370
417
|
|
|
371
418
|
export function float(value: number): number {
|
|
372
|
-
if (typeof value !== 'number')
|
|
419
|
+
if (typeof value !== 'number') {
|
|
420
|
+
throw new TypeError('Expected a number');
|
|
421
|
+
}
|
|
373
422
|
return Math.fround(value);
|
|
374
423
|
}
|
|
375
424
|
export function flag(value: boolean): number {
|
|
376
|
-
if (typeof value !== 'boolean')
|
|
425
|
+
if (typeof value !== 'boolean') {
|
|
426
|
+
throw new TypeError('Expected a boolean');
|
|
427
|
+
}
|
|
377
428
|
return +value;
|
|
378
429
|
}
|
|
379
430
|
export function unsigned(value: number): number {
|
|
@@ -383,11 +434,15 @@ export function unsigned(value: number): number {
|
|
|
383
434
|
return value;
|
|
384
435
|
}
|
|
385
436
|
export function duration(value: R<Time>): bigint {
|
|
386
|
-
if (!(value instanceof Time))
|
|
437
|
+
if (!(value instanceof Time)) {
|
|
438
|
+
throw new TypeError('Expected a Time');
|
|
439
|
+
}
|
|
387
440
|
return value.asMicroseconds();
|
|
388
441
|
}
|
|
389
442
|
export function angle(value: R<Angle>): number {
|
|
390
|
-
if (!(value instanceof Angle))
|
|
443
|
+
if (!(value instanceof Angle)) {
|
|
444
|
+
throw new TypeError('Expected an Angle');
|
|
445
|
+
}
|
|
391
446
|
return value.asRadians();
|
|
392
447
|
}
|
|
393
448
|
export function vector(value: R<Vector3<'f32'>>): void {
|
|
@@ -397,12 +452,20 @@ export function vector(value: R<Vector3<'f32'>>): void {
|
|
|
397
452
|
}
|
|
398
453
|
export function channels(map: Iterable<SoundChannel>): Int32Array {
|
|
399
454
|
const values = Array.from(map);
|
|
400
|
-
if (
|
|
401
|
-
|
|
455
|
+
if (
|
|
456
|
+
values.some(
|
|
457
|
+
value =>
|
|
458
|
+
!Number.isInteger(value) ||
|
|
459
|
+
value < 0 ||
|
|
460
|
+
value > SoundChannel.TopBackCenter,
|
|
461
|
+
)
|
|
462
|
+
) {
|
|
402
463
|
throw new RangeError('Unknown sound channel');
|
|
403
464
|
}
|
|
404
465
|
return Int32Array.from(values);
|
|
405
466
|
}
|
|
406
467
|
export function samples(value: Int16Array): void {
|
|
407
|
-
if (!(value instanceof Int16Array))
|
|
468
|
+
if (!(value instanceof Int16Array)) {
|
|
469
|
+
throw new TypeError('Expected an Int16Array');
|
|
470
|
+
}
|
|
408
471
|
}
|
|
@@ -212,7 +212,9 @@ export class BlendMode {
|
|
|
212
212
|
alphaDstFactor: BlendFactor.OneMinusSrcAlpha,
|
|
213
213
|
alphaEquation: BlendEquation.Add,
|
|
214
214
|
});
|
|
215
|
-
if (args.length === 0)
|
|
215
|
+
if (args.length === 0) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
216
218
|
if (args.length === 1 && args[0] instanceof BlendMode) {
|
|
217
219
|
const source = args[0];
|
|
218
220
|
this.colorSrcFactor = source.colorSrcFactor;
|
|
@@ -11,12 +11,17 @@ import type { ScalarType } from '../internal/scalar';
|
|
|
11
11
|
* @ja ブールベクトル演算の基底クラス。数値結果の非ゼロを true に変換します。
|
|
12
12
|
* @ko 불리언 벡터 연산의 기반 클래스입니다. 숫자 결과가 0이 아니면 true로 변환합니다.
|
|
13
13
|
*/
|
|
14
|
-
export abstract class BooleanVector<
|
|
15
|
-
extends
|
|
14
|
+
export abstract class BooleanVector<
|
|
15
|
+
K extends 'vector2' | 'vector3',
|
|
16
|
+
> extends BooleanComponents<K> {
|
|
16
17
|
protected checkPair(rhs: R<BooleanVector<K>>): void {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
if (
|
|
19
|
+
!(rhs instanceof BooleanVector) ||
|
|
20
|
+
this[glslStorage].length !== rhs[glslStorage].length
|
|
21
|
+
) {
|
|
22
|
+
throw new TypeError(
|
|
23
|
+
'Boolean vector operands must have the same dimension',
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
@@ -32,7 +37,9 @@ export abstract class BooleanVector<K extends 'vector2' | 'vector3'>
|
|
|
32
37
|
const a = this[glslStorage];
|
|
33
38
|
const b = rhs[glslStorage];
|
|
34
39
|
let sum = 0;
|
|
35
|
-
for (let i = 0; i < a.length; i++)
|
|
40
|
+
for (let i = 0; i < a.length; i++) {
|
|
41
|
+
sum += a[i] * b[i];
|
|
42
|
+
}
|
|
36
43
|
return sum !== 0;
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -55,7 +62,7 @@ export abstract class BooleanVector<K extends 'vector2' | 'vector3'>
|
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
type Source2 = R<Bvec2> | R<Vector2<ScalarType>>;
|
|
58
|
-
type Arguments2 = [] | [
|
|
65
|
+
type Arguments2 = [] | [x: boolean, y: boolean] | [source: Source2];
|
|
59
66
|
|
|
60
67
|
/**
|
|
61
68
|
* sf::Vector2<bool>; each component occupies one canonical 0/1 byte.
|
|
@@ -73,16 +80,25 @@ export class Bvec2 extends BooleanVector<'vector2'> {
|
|
|
73
80
|
*/
|
|
74
81
|
constructor(...args: Arguments2) {
|
|
75
82
|
const source = args[0];
|
|
76
|
-
const components =
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
const components =
|
|
84
|
+
args.length === 0 ||
|
|
85
|
+
(args.length === 2 &&
|
|
86
|
+
typeof source === 'boolean' &&
|
|
87
|
+
typeof args[1] === 'boolean');
|
|
88
|
+
const copy =
|
|
89
|
+
args.length === 1 &&
|
|
79
90
|
(source instanceof Bvec2 || source instanceof Vector2);
|
|
80
91
|
if (!components && !copy) {
|
|
81
|
-
throw new TypeError(
|
|
92
|
+
throw new TypeError(
|
|
93
|
+
'Expected a boolean pair or a two-dimensional vector',
|
|
94
|
+
);
|
|
82
95
|
}
|
|
83
|
-
super(
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
super(
|
|
97
|
+
typeof source === 'object'
|
|
98
|
+
? [ source.x, source.y ]
|
|
99
|
+
: [ source ?? false, args[1] ?? false ],
|
|
100
|
+
buffer => native.wrapVector2('bool', buffer),
|
|
101
|
+
);
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
/**
|
|
@@ -136,7 +152,9 @@ export class Bvec2 extends BooleanVector<'vector2'> {
|
|
|
136
152
|
|
|
137
153
|
type Source3 = R<Bvec3> | R<Vector3<ScalarType>>;
|
|
138
154
|
type Arguments3 =
|
|
139
|
-
|
|
155
|
+
| []
|
|
156
|
+
| [x: boolean, y: boolean, z: boolean]
|
|
157
|
+
| [source: Source3];
|
|
140
158
|
|
|
141
159
|
/**
|
|
142
160
|
* sf::Vector3<bool>, sharing the same native family as numeric Vector3.
|
|
@@ -154,18 +172,26 @@ export class Bvec3 extends BooleanVector<'vector3'> {
|
|
|
154
172
|
*/
|
|
155
173
|
constructor(...args: Arguments3) {
|
|
156
174
|
const source = args[0];
|
|
157
|
-
const components =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
const components =
|
|
176
|
+
args.length === 0 ||
|
|
177
|
+
(args.length === 3 &&
|
|
178
|
+
typeof source === 'boolean' &&
|
|
179
|
+
typeof args[1] === 'boolean' &&
|
|
180
|
+
typeof args[2] === 'boolean');
|
|
181
|
+
const copy =
|
|
182
|
+
args.length === 1 &&
|
|
161
183
|
(source instanceof Bvec3 || source instanceof Vector3);
|
|
162
184
|
if (!components && !copy) {
|
|
163
|
-
throw new TypeError(
|
|
185
|
+
throw new TypeError(
|
|
186
|
+
'Expected a boolean triple or a three-dimensional vector',
|
|
187
|
+
);
|
|
164
188
|
}
|
|
165
|
-
super(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
189
|
+
super(
|
|
190
|
+
typeof source === 'object'
|
|
191
|
+
? [ source.x, source.y, source.z ]
|
|
192
|
+
: [ source ?? false, args[1] ?? false, args[2] ?? false ],
|
|
193
|
+
buffer => native.wrapVector3('bool', buffer),
|
|
194
|
+
);
|
|
169
195
|
}
|
|
170
196
|
|
|
171
197
|
/**
|
|
@@ -174,14 +200,18 @@ export class Bvec3 extends BooleanVector<'vector3'> {
|
|
|
174
200
|
* @ja Z ブール成分。
|
|
175
201
|
* @ko Z 불리언 성분입니다.
|
|
176
202
|
*/
|
|
177
|
-
get z(): boolean {
|
|
203
|
+
get z(): boolean {
|
|
204
|
+
return this[glslStorage][2] !== 0;
|
|
205
|
+
}
|
|
178
206
|
/**
|
|
179
207
|
* Sets the Z component, stored as a 0/1 byte.
|
|
180
208
|
* @zh 设置 Z 分量,按 0/1 字节存储。
|
|
181
209
|
* @ja Z 成分を設定し、0/1 のバイトで格納します。
|
|
182
210
|
* @ko Z 성분을 설정하며 0/1 바이트로 저장합니다.
|
|
183
211
|
*/
|
|
184
|
-
set z(value: boolean) {
|
|
212
|
+
set z(value: boolean) {
|
|
213
|
+
this[glslStorage][2] = value ? 1 : 0;
|
|
214
|
+
}
|
|
185
215
|
|
|
186
216
|
/**
|
|
187
217
|
* Computes the 3D cross product and converts each nonzero component to true.
|
package/src/graphics/color.ts
CHANGED
|
@@ -91,7 +91,9 @@ export class Color {
|
|
|
91
91
|
green?: number, blue?: number, alpha = 255,
|
|
92
92
|
) {
|
|
93
93
|
this.state.values[3] = 255;
|
|
94
|
-
if (redOrSource === undefined)
|
|
94
|
+
if (redOrSource === undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
95
97
|
if (redOrSource instanceof Color) {
|
|
96
98
|
this[colorStorage].set(redOrSource[colorStorage]);
|
|
97
99
|
} else if (typeof redOrSource === 'number') {
|
|
@@ -26,8 +26,11 @@ export class ConvexShape extends Shape {
|
|
|
26
26
|
*/
|
|
27
27
|
constructor(source: R<ConvexShape>);
|
|
28
28
|
constructor(source: number | R<ConvexShape> = 0) {
|
|
29
|
-
if (source instanceof ConvexShape)
|
|
30
|
-
|
|
29
|
+
if (source instanceof ConvexShape) {
|
|
30
|
+
super({ kind: 3, source });
|
|
31
|
+
} else {
|
|
32
|
+
super({ kind: 3, x: shapeCount(source as number) });
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
/**
|
|
@@ -58,7 +61,11 @@ export class ConvexShape extends Shape {
|
|
|
58
61
|
* @ko 로컬 꼭짓점 좌표를 복사합니다. 인덱스는 0부터 시작하며 꼭짓점은 윤곽 순서로 볼록 다각형을 구성해야 합니다.
|
|
59
62
|
*/
|
|
60
63
|
setPoint(this: ConvexShape, index: number, point: R<Vector2f>): void {
|
|
61
|
-
if (
|
|
64
|
+
if (
|
|
65
|
+
!Number.isInteger(index) ||
|
|
66
|
+
index < 0 ||
|
|
67
|
+
index >= this.getPointCount()
|
|
68
|
+
) {
|
|
62
69
|
throw new RangeError('Shape point index is out of bounds');
|
|
63
70
|
}
|
|
64
71
|
this.changeGeometry(5, index, ...shapeVector(point));
|