sfml.js 1.0.0-rc.2 → 1.1.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.
Files changed (314) hide show
  1. package/README.ja.md +16 -11
  2. package/README.ko.md +16 -11
  3. package/README.md +16 -11
  4. package/README.zh-CN.md +16 -11
  5. package/assets/breakout.png +0 -0
  6. package/binding.gyp +23 -16
  7. package/dist/audio/effect-processor.js +9 -3
  8. package/dist/audio/input-sound-file.js +41 -15
  9. package/dist/audio/listener.js +33 -11
  10. package/dist/audio/music.js +41 -18
  11. package/dist/audio/output-sound-file.js +4 -2
  12. package/dist/audio/playback-device.js +11 -3
  13. package/dist/audio/sound-buffer-recorder.js +8 -5
  14. package/dist/audio/sound-buffer.js +40 -17
  15. package/dist/audio/sound-file-factory.js +21 -9
  16. package/dist/audio/sound-file-reader.js +21 -7
  17. package/dist/audio/sound-recorder.js +36 -15
  18. package/dist/audio/sound-source.js +117 -40
  19. package/dist/audio/sound-stream.js +14 -5
  20. package/dist/audio/sound.js +9 -4
  21. package/dist/audio/value.js +42 -16
  22. package/dist/graphics/blend-mode.js +2 -1
  23. package/dist/graphics/boolean-vector.d.ts +1 -2
  24. package/dist/graphics/boolean-vector.js +19 -9
  25. package/dist/graphics/color.js +2 -1
  26. package/dist/graphics/convex-shape.js +7 -3
  27. package/dist/graphics/font.js +52 -23
  28. package/dist/graphics/glsl-matrix.js +8 -3
  29. package/dist/graphics/glsl.js +47 -16
  30. package/dist/graphics/glyph.js +27 -10
  31. package/dist/graphics/image.js +30 -14
  32. package/dist/graphics/rect.js +15 -8
  33. package/dist/graphics/render-states.js +18 -9
  34. package/dist/graphics/render-target.js +49 -23
  35. package/dist/graphics/render-texture.js +24 -12
  36. package/dist/graphics/render-window.js +6 -3
  37. package/dist/graphics/shader.js +67 -32
  38. package/dist/graphics/shape.js +25 -13
  39. package/dist/graphics/sprite.js +19 -9
  40. package/dist/graphics/stencil-mode.js +10 -6
  41. package/dist/graphics/swap.js +2 -1
  42. package/dist/graphics/text.js +123 -48
  43. package/dist/graphics/texture.js +48 -24
  44. package/dist/graphics/transform.js +29 -13
  45. package/dist/graphics/transformable.js +2 -1
  46. package/dist/graphics/vertex-array.js +40 -18
  47. package/dist/graphics/vertex-buffer.js +39 -19
  48. package/dist/graphics/vertex.js +6 -3
  49. package/dist/graphics/view.js +30 -14
  50. package/dist/index.d.ts +4 -4
  51. package/dist/internal/audio-codec-registry.js +12 -6
  52. package/dist/internal/audio-input-stream.js +2 -1
  53. package/dist/internal/audio-music-pump.js +58 -24
  54. package/dist/internal/audio-recorder-session.js +17 -7
  55. package/dist/internal/audio-worker-session.js +28 -10
  56. package/dist/internal/audio-worker.js +40 -21
  57. package/dist/internal/glsl-value.d.ts +3 -1
  58. package/dist/internal/glsl-value.js +18 -8
  59. package/dist/internal/graphics-state.js +29 -15
  60. package/dist/internal/input-stream.d.ts +3 -1
  61. package/dist/internal/input-stream.js +16 -7
  62. package/dist/internal/numeric-properties.js +2 -1
  63. package/dist/internal/render-states.js +2 -1
  64. package/dist/internal/scalar.js +22 -13
  65. package/dist/internal/shaped-glyph.d.ts +3 -1
  66. package/dist/internal/shaped-glyph.js +12 -4
  67. package/dist/internal/struct-view.d.ts +3 -1
  68. package/dist/internal/struct-view.js +3 -1
  69. package/dist/internal/transformable.js +2 -1
  70. package/dist/network/common.js +23 -11
  71. package/dist/network/dns.js +25 -17
  72. package/dist/network/ftp.js +43 -18
  73. package/dist/network/http.js +126 -56
  74. package/dist/network/ip-address.js +50 -25
  75. package/dist/network/packet.js +63 -25
  76. package/dist/network/sftp.js +175 -74
  77. package/dist/network/socket-selector.js +28 -14
  78. package/dist/network/socket.js +71 -30
  79. package/dist/network/tcp-listener.js +42 -19
  80. package/dist/network/tcp-socket.js +111 -53
  81. package/dist/network/tls-material.js +2 -1
  82. package/dist/network/udp-socket.js +68 -33
  83. package/dist/system/angle.js +2 -1
  84. package/dist/system/clock.js +4 -2
  85. package/dist/system/err.js +5 -2
  86. package/dist/system/file-input-stream.js +8 -4
  87. package/dist/system/input-stream.js +6 -3
  88. package/dist/system/operators.d.ts +1 -1
  89. package/dist/system/operators.js +90 -50
  90. package/dist/system/sleep.js +4 -2
  91. package/dist/system/time.js +12 -6
  92. package/dist/system/vector2.js +6 -7
  93. package/dist/system/vector3.js +11 -6
  94. package/dist/window/clipboard.js +2 -1
  95. package/dist/window/context.js +10 -5
  96. package/dist/window/cursor.js +2 -1
  97. package/dist/window/event.js +9 -5
  98. package/dist/window/mouse.js +4 -2
  99. package/dist/window/video-mode.js +2 -1
  100. package/dist/window/window.js +19 -12
  101. package/native/addon.cc +25 -12
  102. package/native/audio-binding.cc +266 -126
  103. package/native/audio-codec-binding.cc +147 -77
  104. package/native/audio-device-binding.cc +76 -49
  105. package/native/audio-file-binding.cc +116 -67
  106. package/native/audio-recorder-binding.cc +147 -98
  107. package/native/audio-recorder.h +1 -1
  108. package/native/audio-state.h +53 -30
  109. package/native/audio-stream-binding.cc +148 -94
  110. package/native/audio-stream.h +5 -4
  111. package/native/audio-worker-binding.cc +163 -81
  112. package/native/audio-worker.h +35 -19
  113. package/native/batch-drawable.cc +29 -16
  114. package/native/batch-drawable.h +11 -8
  115. package/native/context-binding.cc +40 -27
  116. package/native/context-settings.h +15 -8
  117. package/native/deferred-delete.cc +9 -6
  118. package/native/deferred-delete.h +7 -8
  119. package/native/error-stream-binding.cc +42 -28
  120. package/native/font-binding.cc +89 -48
  121. package/native/graphics-binding.cc +122 -72
  122. package/native/graphics-state.h +50 -36
  123. package/native/image-binding.cc +38 -24
  124. package/native/image-state.h +26 -18
  125. package/native/input-binding.cc +42 -27
  126. package/native/render-window-binding.cc +38 -23
  127. package/native/shader-binding.cc +115 -50
  128. package/native/shape-binding.cc +94 -49
  129. package/native/shape-state.h +18 -9
  130. package/native/shaped-glyph-storage.h +9 -5
  131. package/native/stream-binding.cc +143 -117
  132. package/native/system-binding.cc +17 -12
  133. package/native/text-binding.cc +68 -35
  134. package/native/text-state.h +25 -18
  135. package/native/texture-binding.cc +42 -33
  136. package/native/texture-resource.h +20 -12
  137. package/native/time-value.h +3 -1
  138. package/native/transformable-binding.cc +12 -6
  139. package/native/transformable-state.h +6 -6
  140. package/native/value-binding.h +46 -28
  141. package/native/value-layout.h +10 -10
  142. package/native/values-binding.cc +29 -23
  143. package/native/vertex-binding.cc +18 -12
  144. package/native/vertex-buffer-binding.cc +38 -24
  145. package/native/vertex-storage.h +2 -2
  146. package/native/view-data.h +4 -3
  147. package/native/window-binding.cc +75 -45
  148. package/native/window-event.h +20 -11
  149. package/native/window-owner.h +15 -12
  150. package/package.json +43 -50
  151. package/src/audio/effect-processor.ts +9 -3
  152. package/src/audio/input-sound-file.ts +108 -36
  153. package/src/audio/listener.ts +39 -13
  154. package/src/audio/music.ts +112 -47
  155. package/src/audio/output-sound-file.ts +40 -11
  156. package/src/audio/playback-device.ts +23 -8
  157. package/src/audio/sound-buffer-recorder.ts +35 -13
  158. package/src/audio/sound-buffer.ts +166 -58
  159. package/src/audio/sound-file-factory.ts +127 -49
  160. package/src/audio/sound-file-reader.ts +49 -15
  161. package/src/audio/sound-recorder.ts +100 -34
  162. package/src/audio/sound-source.ts +142 -45
  163. package/src/audio/sound-stream.ts +15 -5
  164. package/src/audio/sound.ts +12 -4
  165. package/src/audio/value.ts +89 -26
  166. package/src/graphics/blend-mode.ts +3 -1
  167. package/src/graphics/boolean-vector.ts +56 -26
  168. package/src/graphics/color.ts +3 -1
  169. package/src/graphics/convex-shape.ts +10 -3
  170. package/src/graphics/font.ts +171 -50
  171. package/src/graphics/glsl-matrix.ts +9 -3
  172. package/src/graphics/glsl.ts +81 -35
  173. package/src/graphics/glyph.ts +67 -26
  174. package/src/graphics/image.ts +119 -45
  175. package/src/graphics/rect.ts +56 -24
  176. package/src/graphics/render-states.ts +31 -14
  177. package/src/graphics/render-target.ts +197 -81
  178. package/src/graphics/render-texture.ts +36 -12
  179. package/src/graphics/render-window.ts +9 -3
  180. package/src/graphics/shader.ts +186 -61
  181. package/src/graphics/shape.ts +93 -35
  182. package/src/graphics/sprite.ts +64 -25
  183. package/src/graphics/stencil-mode.ts +12 -6
  184. package/src/graphics/swap.ts +3 -2
  185. package/src/graphics/text.ts +229 -74
  186. package/src/graphics/texture.ts +180 -61
  187. package/src/graphics/transform.ts +132 -47
  188. package/src/graphics/transformable.ts +3 -1
  189. package/src/graphics/vertex-array.ts +87 -35
  190. package/src/graphics/vertex-buffer.ts +97 -33
  191. package/src/graphics/vertex.ts +9 -3
  192. package/src/graphics/view.ts +59 -21
  193. package/src/index.ts +101 -23
  194. package/src/internal/audio-codec-registry.ts +18 -6
  195. package/src/internal/audio-input-stream.ts +6 -2
  196. package/src/internal/audio-music-pump.ts +116 -41
  197. package/src/internal/audio-native.ts +249 -96
  198. package/src/internal/audio-recorder-session.ts +68 -24
  199. package/src/internal/audio-worker-session.ts +65 -21
  200. package/src/internal/audio-worker.ts +85 -41
  201. package/src/internal/glsl-value.ts +26 -11
  202. package/src/internal/graphics-state.ts +57 -20
  203. package/src/internal/input-stream.ts +23 -10
  204. package/src/internal/native.ts +252 -99
  205. package/src/internal/numeric-properties.ts +2 -1
  206. package/src/internal/render-states.ts +3 -1
  207. package/src/internal/scalar.ts +33 -14
  208. package/src/internal/shaped-glyph.ts +25 -12
  209. package/src/internal/struct-view.ts +40 -13
  210. package/src/internal/transformable.ts +3 -1
  211. package/src/network/common.ts +35 -11
  212. package/src/network/dns.ts +95 -38
  213. package/src/network/ftp.ts +129 -47
  214. package/src/network/http.ts +232 -77
  215. package/src/network/ip-address.ts +118 -48
  216. package/src/network/packet.ts +161 -54
  217. package/src/network/sftp.ts +498 -168
  218. package/src/network/socket-selector.ts +66 -26
  219. package/src/network/socket.ts +133 -46
  220. package/src/network/tcp-listener.ts +78 -29
  221. package/src/network/tcp-socket.ts +240 -95
  222. package/src/network/tls-material.ts +6 -2
  223. package/src/network/udp-socket.ts +147 -53
  224. package/src/system/angle.ts +3 -1
  225. package/src/system/clock.ts +12 -4
  226. package/src/system/err.ts +5 -2
  227. package/src/system/file-input-stream.ts +12 -4
  228. package/src/system/input-stream.ts +9 -3
  229. package/src/system/operators.ts +290 -115
  230. package/src/system/sleep.ts +6 -2
  231. package/src/system/time.ts +18 -6
  232. package/src/system/timeout-with-predicate.ts +19 -8
  233. package/src/system/vector2.ts +101 -49
  234. package/src/system/vector3.ts +85 -36
  235. package/src/window/clipboard.ts +3 -1
  236. package/src/window/context.ts +15 -5
  237. package/src/window/cursor.ts +3 -1
  238. package/src/window/event.ts +26 -12
  239. package/src/window/mouse.ts +6 -2
  240. package/src/window/video-mode.ts +3 -1
  241. package/src/window/window.ts +119 -37
  242. package/test/native/audio-probes.cc +74 -36
  243. package/test/native/deferred-delete-probes.cc +17 -11
  244. package/test/native/drawable-probes.cc +70 -36
  245. package/test/native/exception-probes.cc +14 -9
  246. package/test/native/image-probes.cc +20 -10
  247. package/test/native/matrix-probes.cc +8 -4
  248. package/test/native/network-oracle.cc +17 -11
  249. package/test/native/render-texture-probes.cc +33 -24
  250. package/test/native/shader-probes.cc +9 -9
  251. package/test/native/shape-probes.cc +37 -23
  252. package/test/native/sprite-probes.cc +41 -25
  253. package/test/native/system-probes.cc +58 -35
  254. package/test/native/text-probes.cc +77 -44
  255. package/test/native/texture-probes.cc +43 -26
  256. package/test/native/time-probes.cc +18 -12
  257. package/test/native/transform-probes.cc +15 -10
  258. package/test/native/transformable-probes.cc +23 -17
  259. package/test/native/value-oracle.h +9 -4
  260. package/test/native/value-probes.cc +31 -23
  261. package/test/native/vertex-array-probes.cc +22 -14
  262. package/test/native/vertex-buffer-probes.cc +28 -17
  263. package/test/native/view-probes.cc +29 -17
  264. package/test/native/window-probes.cc +66 -33
  265. package/tools/ensure-sfml.cjs +9 -0
  266. package/tools/generate-network-constants.cjs +11 -6
  267. package/tools/generate-window-constants.cjs +31 -12
  268. package/docs/README.ja.md +0 -30
  269. package/docs/README.ko.md +0 -30
  270. package/docs/README.md +0 -30
  271. package/docs/README.zh-CN.md +0 -30
  272. package/docs/api.ja.md +0 -84
  273. package/docs/api.ko.md +0 -84
  274. package/docs/api.md +0 -81
  275. package/docs/api.zh-CN.md +0 -81
  276. package/docs/audio.ja.md +0 -249
  277. package/docs/audio.ko.md +0 -251
  278. package/docs/audio.md +0 -252
  279. package/docs/audio.zh-CN.md +0 -252
  280. package/docs/concepts.ja.md +0 -130
  281. package/docs/concepts.ko.md +0 -130
  282. package/docs/concepts.md +0 -131
  283. package/docs/concepts.zh-CN.md +0 -131
  284. package/docs/development.ja.md +0 -148
  285. package/docs/development.ko.md +0 -148
  286. package/docs/development.md +0 -150
  287. package/docs/development.zh-CN.md +0 -150
  288. package/docs/getting-started.ja.md +0 -154
  289. package/docs/getting-started.ko.md +0 -154
  290. package/docs/getting-started.md +0 -156
  291. package/docs/getting-started.zh-CN.md +0 -156
  292. package/docs/graphics.ja.md +0 -256
  293. package/docs/graphics.ko.md +0 -254
  294. package/docs/graphics.md +0 -255
  295. package/docs/graphics.zh-CN.md +0 -257
  296. package/docs/network.ja.md +0 -214
  297. package/docs/network.ko.md +0 -216
  298. package/docs/network.md +0 -218
  299. package/docs/network.zh-CN.md +0 -218
  300. package/docs/system.ja.md +0 -169
  301. package/docs/system.ko.md +0 -171
  302. package/docs/system.md +0 -173
  303. package/docs/system.zh-CN.md +0 -173
  304. package/docs/window.ja.md +0 -138
  305. package/docs/window.ko.md +0 -140
  306. package/docs/window.md +0 -141
  307. package/docs/window.zh-CN.md +0 -141
  308. package/native/exception-boundary.h +0 -97
  309. package/native/numeric-fields.h +0 -96
  310. package/native/shared-handle.h +0 -69
  311. package/test/tsconfig.json +0 -8
  312. package/tools/configure-lsp.cjs +0 -23
  313. package/tools/lib_downloader.cjs +0 -92
  314. package/tools/lib_downloader_urls.cjs +0 -23
@@ -1,5 +1,8 @@
1
1
  import {
2
- audioNative, audioHandle, type AudioHandle, type AudioSourceMapping,
2
+ audioNative,
3
+ audioHandle,
4
+ type AudioHandle,
5
+ type AudioSourceMapping,
3
6
  } from '../internal/audio-native';
4
7
  import { Vector3f } from '../system/vector3';
5
8
  import { radians } from '../system/angle';
@@ -7,7 +10,14 @@ import { Time } from '../system/time';
7
10
  import { EffectProcessor } from './effect-processor';
8
11
  import type { ReadonlyValue as R } from '../internal/value-storage';
9
12
  import {
10
- Cone, type ConeInput, SoundStatus, float, flag, vector, angle, duration,
13
+ Cone,
14
+ type ConeInput,
15
+ SoundStatus,
16
+ float,
17
+ flag,
18
+ vector,
19
+ angle,
20
+ duration,
11
21
  } from './value';
12
22
 
13
23
  /**
@@ -51,8 +61,14 @@ export abstract class SoundSource {
51
61
  if (!(source instanceof SoundSource)) {
52
62
  throw new TypeError('Expected a SoundSource');
53
63
  }
54
- if (source === this) return this;
55
- audioNative.assignAudioSource(this[audioHandle], source[audioHandle], false);
64
+ if (source === this) {
65
+ return this;
66
+ }
67
+ audioNative.assignAudioSource(
68
+ this[audioHandle],
69
+ source[audioHandle],
70
+ false,
71
+ );
56
72
  return this;
57
73
  }
58
74
  /**
@@ -61,84 +77,108 @@ export abstract class SoundSource {
61
77
  * @ja ピッチと再生速度の倍率を設定します。1 は元の速度です。
62
78
  * @ko 음높이와 재생 속도 배율을 설정합니다. 1은 원래 속도입니다.
63
79
  */
64
- setPitch(value: number): void { this.set(0, value); }
80
+ setPitch(value: number): void {
81
+ this.set(0, value);
82
+ }
65
83
  /**
66
84
  * Return the pitch multiplier.
67
85
  * @zh 返回音高倍率。
68
86
  * @ja ピッチの倍率を返します。
69
87
  * @ko 음높이 배율을 반환합니다.
70
88
  */
71
- getPitch(): number { return this.get(0); }
89
+ getPitch(): number {
90
+ return this.get(0);
91
+ }
72
92
  /**
73
93
  * Set stereo pan: -1 is left, 0 is center, and 1 is right.
74
94
  * @zh 设置立体声声像,-1 为左、0 为中、1 为右。
75
95
  * @ja ステレオパンを設定します。-1 は左、0 は中央、1 は右です。
76
96
  * @ko 스테레오 팬을 설정합니다. -1은 왼쪽, 0은 중앙, 1은 오른쪽입니다.
77
97
  */
78
- setPan(value: number): void { this.set(1, value); }
98
+ setPan(value: number): void {
99
+ this.set(1, value);
100
+ }
79
101
  /**
80
102
  * Return the stereo pan.
81
103
  * @zh 返回立体声声像。
82
104
  * @ja ステレオパンを返します。
83
105
  * @ko 스테레오 팬을 반환합니다.
84
106
  */
85
- getPan(): number { return this.get(1); }
107
+ getPan(): number {
108
+ return this.get(1);
109
+ }
86
110
  /**
87
111
  * Set volume as a percentage; 0 is silent and 100 is the original volume.
88
112
  * @zh 设置音量百分比,0 为静音,100 为原始音量。
89
113
  * @ja 音量を百分率で設定します。0 は無音、100 は元の音量です。
90
114
  * @ko 볼륨을 백분율로 설정합니다. 0은 무음, 100은 원래 볼륨입니다.
91
115
  */
92
- setVolume(value: number): void { this.set(2, value); }
116
+ setVolume(value: number): void {
117
+ this.set(2, value);
118
+ }
93
119
  /**
94
120
  * Return the volume percentage.
95
121
  * @zh 返回音量百分比。
96
122
  * @ja 音量の百分率を返します。
97
123
  * @ko 볼륨 백분율을 반환합니다.
98
124
  */
99
- getVolume(): number { return this.get(2); }
125
+ getVolume(): number {
126
+ return this.get(2);
127
+ }
100
128
  /**
101
129
  * Enable or disable spatial effects from position, distance, and direction.
102
130
  * @zh 设置是否启用位置、距离和方向引起的空间音效。
103
131
  * @ja 位置・距離・方向による空間音響効果の有効・無効を設定します。
104
132
  * @ko 위치, 거리, 방향에 따른 공간 음향 효과의 활성화 여부를 설정합니다.
105
133
  */
106
- setSpatializationEnabled(value: boolean): void { this.set(3, flag(value)); }
134
+ setSpatializationEnabled(value: boolean): void {
135
+ this.set(3, flag(value));
136
+ }
107
137
  /**
108
138
  * Return whether spatialization is enabled.
109
139
  * @zh 返回是否启用空间音效。
110
140
  * @ja 空間音響効果が有効かどうかを返します。
111
141
  * @ko 공간 음향 효과의 활성화 여부를 반환합니다.
112
142
  */
113
- isSpatializationEnabled(): boolean { return this.get(3) !== 0; }
143
+ isSpatializationEnabled(): boolean {
144
+ return this.get(3) !== 0;
145
+ }
114
146
  /**
115
147
  * Set the 3D position using the same units as the listener and distances.
116
148
  * @zh 设置三维位置,单位须与监听者位置及距离参数一致。
117
149
  * @ja 3D 位置を設定します。単位はリスナー位置と距離パラメーターに合わせます。
118
150
  * @ko 3차원 위치를 설정합니다. 리스너 위치 및 거리 매개변수와 단위가 같아야 합니다.
119
151
  */
120
- setPosition(value: R<Vector3f>): void { this.setVector(4, value); }
152
+ setPosition(value: R<Vector3f>): void {
153
+ this.setVector(4, value);
154
+ }
121
155
  /**
122
156
  * Return a copy of the 3D position.
123
157
  * @zh 返回三维位置副本。
124
158
  * @ja 3D 位置のコピーを返します。
125
159
  * @ko 3차원 위치의 복사본을 반환합니다.
126
160
  */
127
- getPosition(): Vector3f { return this.getVector(4); }
161
+ getPosition(): Vector3f {
162
+ return this.getVector(4);
163
+ }
128
164
  /**
129
165
  * Set the sound source's emission direction.
130
166
  * @zh 设置声源发声方向。
131
167
  * @ja 音源の発音方向を設定します。
132
168
  * @ko 음원의 소리 방출 방향을 설정합니다.
133
169
  */
134
- setDirection(value: R<Vector3f>): void { this.setVector(7, value); }
170
+ setDirection(value: R<Vector3f>): void {
171
+ this.setVector(7, value);
172
+ }
135
173
  /**
136
174
  * Return a copy of the emission direction.
137
175
  * @zh 返回发声方向副本。
138
176
  * @ja 発音方向のコピーを返します。
139
177
  * @ko 소리 방출 방향의 복사본을 반환합니다.
140
178
  */
141
- getDirection(): Vector3f { return this.getVector(7); }
179
+ getDirection(): Vector3f {
180
+ return this.getVector(7);
181
+ }
142
182
  /**
143
183
  * Set the inner and outer cone angles and outer gain, updating the native
144
184
  * audio engine.
@@ -162,8 +202,11 @@ export abstract class SoundSource {
162
202
  */
163
203
  getCone(): Cone {
164
204
  this.field(10, false);
165
- return new Cone({ innerAngle: radians(this.values[10]),
166
- outerAngle: radians(this.values[11]), outerGain: this.values[12] });
205
+ return new Cone({
206
+ innerAngle: radians(this.values[10]),
207
+ outerAngle: radians(this.values[11]),
208
+ outerGain: this.values[12],
209
+ });
167
210
  }
168
211
  /**
169
212
  * Set the 3D velocity for the Doppler effect, in position units per second.
@@ -171,42 +214,54 @@ export abstract class SoundSource {
171
214
  * @ja ドップラー効果用の 3D 速度を設定します。単位は位置単位/秒です。
172
215
  * @ko 도플러 효과에 사용할 3차원 속도를 설정합니다. 단위는 위치 단위/초입니다.
173
216
  */
174
- setVelocity(value: R<Vector3f>): void { this.setVector(13, value); }
217
+ setVelocity(value: R<Vector3f>): void {
218
+ this.setVector(13, value);
219
+ }
175
220
  /**
176
221
  * Return a copy of the velocity.
177
222
  * @zh 返回速度副本。
178
223
  * @ja 速度のコピーを返します。
179
224
  * @ko 속도의 복사본을 반환합니다.
180
225
  */
181
- getVelocity(): Vector3f { return this.getVector(13); }
226
+ getVelocity(): Vector3f {
227
+ return this.getVector(13);
228
+ }
182
229
  /**
183
230
  * Set the Doppler effect multiplier; 0 disables it.
184
231
  * @zh 设置多普勒效应倍率,0 禁用。
185
232
  * @ja ドップラー効果の倍率を設定します。0 で無効になります。
186
233
  * @ko 도플러 효과 배율을 설정합니다. 0은 비활성화합니다.
187
234
  */
188
- setDopplerFactor(value: number): void { this.set(16, value); }
235
+ setDopplerFactor(value: number): void {
236
+ this.set(16, value);
237
+ }
189
238
  /**
190
239
  * Return the Doppler effect multiplier.
191
240
  * @zh 返回多普勒效应倍率。
192
241
  * @ja ドップラー効果の倍率を返します。
193
242
  * @ko 도플러 효과 배율을 반환합니다.
194
243
  */
195
- getDopplerFactor(): number { return this.get(16); }
244
+ getDopplerFactor(): number {
245
+ return this.get(16);
246
+ }
196
247
  /**
197
248
  * Set the factor controlling the source direction's effect on attenuation.
198
249
  * @zh 设置声源方向对衰减的影响因子。
199
250
  * @ja 音源の方向が減衰に与える影響の係数を設定します。
200
251
  * @ko 음원 방향이 감쇠에 미치는 영향 계수를 설정합니다.
201
252
  */
202
- setDirectionalAttenuationFactor(value: number): void { this.set(17, value); }
253
+ setDirectionalAttenuationFactor(value: number): void {
254
+ this.set(17, value);
255
+ }
203
256
  /**
204
257
  * Return the directional attenuation factor.
205
258
  * @zh 返回方向衰减因子。
206
259
  * @ja 指向性減衰係数を返します。
207
260
  * @ko 지향성 감쇠 계수를 반환합니다.
208
261
  */
209
- getDirectionalAttenuationFactor(): number { return this.get(17); }
262
+ getDirectionalAttenuationFactor(): number {
263
+ return this.get(17);
264
+ }
210
265
  /**
211
266
  * Set whether the position is relative to the listener; false uses world
212
267
  * coordinates.
@@ -214,105 +269,135 @@ export abstract class SoundSource {
214
269
  * @ja 位置をリスナー相対にするか設定します。false はワールド座標を使います。
215
270
  * @ko 리스너 기준 상대 위치 여부를 설정합니다. false는 월드 좌표를 사용합니다.
216
271
  */
217
- setRelativeToListener(value: boolean): void { this.set(18, flag(value)); }
272
+ setRelativeToListener(value: boolean): void {
273
+ this.set(18, flag(value));
274
+ }
218
275
  /**
219
276
  * Return whether listener-relative coordinates are used.
220
277
  * @zh 返回是否使用监听者相对坐标。
221
278
  * @ja リスナー相対座標を使うかどうかを返します。
222
279
  * @ko 리스너 기준 상대 좌표 사용 여부를 반환합니다.
223
280
  */
224
- isRelativeToListener(): boolean { return this.get(18) !== 0; }
281
+ isRelativeToListener(): boolean {
282
+ return this.get(18) !== 0;
283
+ }
225
284
  /**
226
285
  * Set the minimum reference distance at which maximum volume is maintained.
227
286
  * @zh 设置保持最大音量的最小参考距离。
228
287
  * @ja 最大音量を維持する最小基準距離を設定します。
229
288
  * @ko 최대 볼륨을 유지하는 최소 기준 거리를 설정합니다.
230
289
  */
231
- setMinDistance(value: number): void { this.set(19, value); }
290
+ setMinDistance(value: number): void {
291
+ this.set(19, value);
292
+ }
232
293
  /**
233
294
  * Return the minimum reference distance.
234
295
  * @zh 返回最小参考距离。
235
296
  * @ja 最小基準距離を返します。
236
297
  * @ko 최소 기준 거리를 반환합니다.
237
298
  */
238
- getMinDistance(): number { return this.get(19); }
299
+ getMinDistance(): number {
300
+ return this.get(19);
301
+ }
239
302
  /**
240
303
  * Set the maximum distance used for distance attenuation.
241
304
  * @zh 设置距离衰减使用的最大距离。
242
305
  * @ja 距離減衰に使う最大距離を設定します。
243
306
  * @ko 거리 감쇠에 사용할 최대 거리를 설정합니다.
244
307
  */
245
- setMaxDistance(value: number): void { this.set(20, value); }
308
+ setMaxDistance(value: number): void {
309
+ this.set(20, value);
310
+ }
246
311
  /**
247
312
  * Return the maximum distance.
248
313
  * @zh 返回最大距离。
249
314
  * @ja 最大距離を返します。
250
315
  * @ko 최대 거리를 반환합니다.
251
316
  */
252
- getMaxDistance(): number { return this.get(20); }
317
+ getMaxDistance(): number {
318
+ return this.get(20);
319
+ }
253
320
  /**
254
321
  * Set the minimum gain after distance attenuation.
255
322
  * @zh 设置距离衰减后的最小增益。
256
323
  * @ja 距離減衰後の最小ゲインを設定します。
257
324
  * @ko 거리 감쇠 후의 최소 게인을 설정합니다.
258
325
  */
259
- setMinGain(value: number): void { this.set(21, value); }
326
+ setMinGain(value: number): void {
327
+ this.set(21, value);
328
+ }
260
329
  /**
261
330
  * Return the minimum gain.
262
331
  * @zh 返回最小增益。
263
332
  * @ja 最小ゲインを返します。
264
333
  * @ko 최소 게인을 반환합니다.
265
334
  */
266
- getMinGain(): number { return this.get(21); }
335
+ getMinGain(): number {
336
+ return this.get(21);
337
+ }
267
338
  /**
268
339
  * Set the maximum gain after distance attenuation.
269
340
  * @zh 设置距离衰减后的最大增益。
270
341
  * @ja 距離減衰後の最大ゲインを設定します。
271
342
  * @ko 거리 감쇠 후의 최대 게인을 설정합니다.
272
343
  */
273
- setMaxGain(value: number): void { this.set(22, value); }
344
+ setMaxGain(value: number): void {
345
+ this.set(22, value);
346
+ }
274
347
  /**
275
348
  * Return the maximum gain.
276
349
  * @zh 返回最大增益。
277
350
  * @ja 最大ゲインを返します。
278
351
  * @ko 최대 게인을 반환합니다.
279
352
  */
280
- getMaxGain(): number { return this.get(22); }
353
+ getMaxGain(): number {
354
+ return this.get(22);
355
+ }
281
356
  /**
282
357
  * Set the distance attenuation factor; 0 disables distance attenuation.
283
358
  * @zh 设置距离衰减因子,0 禁用距离衰减。
284
359
  * @ja 距離減衰係数を設定します。0 で距離減衰が無効になります。
285
360
  * @ko 거리 감쇠 계수를 설정합니다. 0은 거리 감쇠를 비활성화합니다.
286
361
  */
287
- setAttenuation(value: number): void { this.set(23, value); }
362
+ setAttenuation(value: number): void {
363
+ this.set(23, value);
364
+ }
288
365
  /**
289
366
  * Return the distance attenuation factor.
290
367
  * @zh 返回距离衰减因子。
291
368
  * @ja 距離減衰係数を返します。
292
369
  * @ko 거리 감쇠 계수를 반환합니다.
293
370
  */
294
- getAttenuation(): number { return this.get(23); }
371
+ getAttenuation(): number {
372
+ return this.get(23);
373
+ }
295
374
  /**
296
375
  * Set whether playback loops after reaching the end.
297
376
  * @zh 设置到达末尾后是否循环播放。
298
377
  * @ja 末尾に達した後にループ再生するか設定します。
299
378
  * @ko 끝에 도달한 후 반복 재생할지 설정합니다.
300
379
  */
301
- setLooping(value: boolean): void { this.set(24, flag(value)); }
380
+ setLooping(value: boolean): void {
381
+ this.set(24, flag(value));
382
+ }
302
383
  /**
303
384
  * Return whether playback loops.
304
385
  * @zh 返回是否循环播放。
305
386
  * @ja ループ再生するかどうかを返します。
306
387
  * @ko 반복 재생 여부를 반환합니다.
307
388
  */
308
- isLooping(): boolean { return this.get(24) !== 0; }
389
+ isLooping(): boolean {
390
+ return this.get(24) !== 0;
391
+ }
309
392
  /**
310
393
  * Query the native engine's current playback status.
311
394
  * @zh 查询原生引擎的当前播放状态。
312
395
  * @ja ネイティブエンジンの現在の再生状態を取得します。
313
396
  * @ko 네이티브 엔진의 현재 재생 상태를 조회합니다.
314
397
  */
315
- getStatus(): SoundStatus { return this.get(25); }
398
+ getStatus(): SoundStatus {
399
+ return this.get(25);
400
+ }
316
401
  /**
317
402
  * Bind and retain an effect processor reference; undefined removes it.
318
403
  * @zh 绑定并保留效果处理器引用;undefined 移除处理器。
@@ -320,7 +405,10 @@ export abstract class SoundSource {
320
405
  * @ko 효과 처리기를 연결하고 참조를 유지합니다. undefined는 처리기를 제거합니다.
321
406
  */
322
407
  setEffectProcessor(processor?: EffectProcessor): void {
323
- if (processor !== undefined && !(processor instanceof EffectProcessor)) {
408
+ if (
409
+ processor !== undefined &&
410
+ !(processor instanceof EffectProcessor)
411
+ ) {
324
412
  throw new TypeError('Expected an EffectProcessor');
325
413
  }
326
414
  audioNative.setAudioEffect(this[audioHandle], processor?.[audioHandle]);
@@ -332,21 +420,27 @@ export abstract class SoundSource {
332
420
  * @ja 再生を開始または再開します。再生中なら SFML の仕様に従い最初から再生します。
333
421
  * @ko 재생을 시작하거나 재개합니다. 이미 재생 중이면 SFML 동작에 따라 다시 시작합니다.
334
422
  */
335
- play(): void { this.command(0); }
423
+ play(): void {
424
+ this.command(0);
425
+ }
336
426
  /**
337
427
  * Pause and retain the playback position.
338
428
  * @zh 暂停并保留播放位置。
339
429
  * @ja 再生位置を保持して一時停止します。
340
430
  * @ko 재생 위치를 유지한 채 일시 정지합니다.
341
431
  */
342
- pause(): void { this.command(1); }
432
+ pause(): void {
433
+ this.command(1);
434
+ }
343
435
  /**
344
436
  * Stop and reset the playback position to zero.
345
437
  * @zh 停止并将播放位置归零。
346
438
  * @ja 停止して再生位置をゼロに戻します。
347
439
  * @ko 정지하고 재생 위치를 0으로 되돌립니다.
348
440
  */
349
- stop(): void { this.command(2); }
441
+ stop(): void {
442
+ this.command(2);
443
+ }
350
444
  /**
351
445
  * Set the playback time relative to the beginning of the sound.
352
446
  * @zh 设置相对于声音起点的播放时间。
@@ -390,7 +484,10 @@ export abstract class SoundSource {
390
484
  }
391
485
  private getVector(field: number): Vector3f {
392
486
  this.field(field, false);
393
- return new Vector3f(this.values[field], this.values[field + 1],
394
- this.values[field + 2]);
487
+ return new Vector3f(
488
+ this.values[field],
489
+ this.values[field + 1],
490
+ this.values[field + 2],
491
+ );
395
492
  }
396
493
  }
@@ -42,7 +42,9 @@ export class SoundStream extends SoundSource {
42
42
  const created = options ? audioNative.createAudioStream(frames,
43
43
  unsigned(options.channelCount), unsigned(options.sampleRate), slots, map)
44
44
  : undefined;
45
- if (!created && !mapping) throw new TypeError('Expected stream options');
45
+ if (!created && !mapping) {
46
+ throw new TypeError('Expected stream options');
47
+ }
46
48
  super(created ?? mapping!);
47
49
  this.streamChannels = new Int32Array(
48
50
  audioNative.audioSourceChannels(this[audioHandle]));
@@ -60,28 +62,36 @@ export class SoundStream extends SoundSource {
60
62
  * @ja チャンネルごとのサンプルレートを Hz で返します。
61
63
  * @ko 채널별 샘플 레이트를 Hz 단위로 반환합니다.
62
64
  */
63
- getSampleRate(): number { return this.get(26); }
65
+ getSampleRate(): number {
66
+ return this.get(26);
67
+ }
64
68
  /**
65
69
  * Return the number of channels.
66
70
  * @zh 返回声道数量。
67
71
  * @ja チャンネル数を返します。
68
72
  * @ko 채널 수를 반환합니다.
69
73
  */
70
- getChannelCount(): number { return this.get(27); }
74
+ getChannelCount(): number {
75
+ return this.get(27);
76
+ }
71
77
  /**
72
78
  * Return the speaker positions of the interleaved channels.
73
79
  * @zh 返回各交错声道的扬声器位置。
74
80
  * @ja 各インターリーブチャンネルのスピーカー位置を返します。
75
81
  * @ko 각 인터리브 채널의 스피커 위치를 반환합니다.
76
82
  */
77
- getChannelMap(): ChannelMap { return this.streamChannels; }
83
+ getChannelMap(): ChannelMap {
84
+ return this.streamChannels;
85
+ }
78
86
  /**
79
87
  * Return the Worker error, or undefined if no error has occurred.
80
88
  * @zh 返回 Worker 错误;尚无错误时为 undefined。
81
89
  * @ja Worker のエラーを返します。まだエラーがなければ undefined。
82
90
  * @ko Worker 오류를 반환합니다. 아직 오류가 없으면 undefined입니다.
83
91
  */
84
- getWorkerError(): Error | undefined { return this.session?.error; }
92
+ getWorkerError(): Error | undefined {
93
+ return this.session?.error;
94
+ }
85
95
  /**
86
96
  * Return audio queue statistics, or undefined if there is no Worker session.
87
97
  * @zh 返回音频队列统计;没有 Worker 会话时为 undefined。
@@ -36,8 +36,12 @@ export class Sound extends SoundSource {
36
36
  * @ko 속성과 버퍼 연결을 복사하고 현재 Sound를 정지하여 재생 위치를 처음으로 되돌립니다.
37
37
  */
38
38
  override assign(source: Sound): this {
39
- if (!(source instanceof Sound)) throw new TypeError('Expected a Sound');
40
- if (source === this) return this;
39
+ if (!(source instanceof Sound)) {
40
+ throw new TypeError('Expected a Sound');
41
+ }
42
+ if (source === this) {
43
+ return this;
44
+ }
41
45
  audioNative.assignAudioSource(this[audioHandle], source[audioHandle], true);
42
46
  this.buffer = source.buffer;
43
47
  return this;
@@ -49,7 +53,9 @@ export class Sound extends SoundSource {
49
53
  * @ko 오디오 버퍼 참조를 교체하여 유지하고 네이티브 재생 음원을 갱신합니다.
50
54
  */
51
55
  setBuffer(buffer: ReadonlySoundBuffer): void {
52
- if (!(buffer instanceof SoundBuffer)) throw new TypeError('Expected a SoundBuffer');
56
+ if (!(buffer instanceof SoundBuffer)) {
57
+ throw new TypeError('Expected a SoundBuffer');
58
+ }
53
59
  audioNative.setAudioBuffer(this[audioHandle], buffer[audioHandle]);
54
60
  this.buffer = buffer;
55
61
  }
@@ -59,5 +65,7 @@ export class Sound extends SoundSource {
59
65
  * @ja 現在関連付けられているバッファーの読み取り専用参照を返します。
60
66
  * @ko 현재 연결된 버퍼의 읽기 전용 참조를 반환합니다.
61
67
  */
62
- getBuffer(): ReadonlySoundBuffer { return this.buffer; }
68
+ getBuffer(): ReadonlySoundBuffer {
69
+ return this.buffer;
70
+ }
63
71
  }