lecodes-sdk 0.19.2 → 0.20.2
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/dist/global.d.ts +62 -0
- package/dist/host.d.ts +3 -0
- package/dist/types/audio/Bus.d.ts +45 -0
- package/dist/types/audio/Sound.d.ts +28 -0
- package/dist/types/audio/Voice.d.ts +27 -0
- package/dist/types/audio/audio.d.ts +83 -0
- package/dist/types/audio/support.d.ts +1 -0
- package/dist/types/gl/AudioSource.d.ts +60 -0
- package/dist/types/gl/AudioZone.d.ts +32 -0
- package/dist/types/gl/DecalSet.d.ts +103 -0
- package/dist/types/gl/Geometry.d.ts +5 -0
- package/dist/types/gl/Light.d.ts +7 -0
- package/dist/types/gl/Locomotion.d.ts +3 -1
- package/dist/types/gl/Material.d.ts +86 -2
- package/dist/types/gl/Mesh.d.ts +11 -0
- package/dist/types/gl/Scene.d.ts +23 -0
- package/dist/types/gl/SceneAudio.d.ts +11 -0
- package/dist/types/gl/Texture.d.ts +29 -1
- package/dist/types/gl/animation/AnimationClip.d.ts +25 -12
- package/dist/types/gl/animation/Animator.d.ts +51 -183
- package/dist/types/gl/animation/Feet.d.ts +85 -0
- package/dist/types/gl/animation/Warp.d.ts +53 -0
- package/dist/types/gl/animation/core.d.ts +61 -17
- package/dist/types/gl/state.d.ts +0 -1
- package/dist/types/inject.d.ts +17 -2
- package/dist/types/plugins/map.d.ts +174 -0
- package/dist/types/runtime/input.d.ts +11 -0
- package/dist/types/ui/UIImage.d.ts +15 -5
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/src/audio/Bus.ts +102 -0
- package/src/audio/Sound.ts +96 -0
- package/src/audio/Voice.ts +102 -0
- package/src/audio/audio.ts +161 -0
- package/src/audio/support.ts +6 -0
- package/src/bridges.d.ts +1481 -1345
- package/src/compile/__tests__/compile.test.ts +12 -0
- package/src/compile/compileProject.ts +35 -15
- package/src/compile/index.ts +3 -0
- package/src/core/Aspect.ts +34 -9
- package/src/g2/Scene2D.ts +7 -0
- package/src/gl/AudioSource.ts +113 -0
- package/src/gl/AudioZone.ts +75 -0
- package/src/gl/DecalSet.ts +233 -0
- package/src/gl/Geometry.ts +5 -0
- package/src/gl/Light.ts +16 -0
- package/src/gl/Lightmap.ts +3 -2
- package/src/gl/Locomotion.ts +7 -5
- package/src/gl/Material.ts +152 -4
- package/src/gl/Mesh.ts +20 -1
- package/src/gl/Particles.ts +3 -3
- package/src/gl/Scene.ts +42 -8
- package/src/gl/SceneAudio.ts +26 -0
- package/src/gl/Texture.ts +43 -3
- package/src/gl/Vehicle.ts +5 -5
- package/src/gl/animation/AnimationClip.ts +43 -20
- package/src/gl/animation/Animator.ts +138 -329
- package/src/gl/animation/Feet.ts +134 -0
- package/src/gl/animation/Loop.ts +3 -1
- package/src/gl/animation/Warp.ts +96 -0
- package/src/gl/animation/core.ts +741 -670
- package/src/gl/state.ts +6 -6
- package/src/host.d.ts +3 -0
- package/src/inject.ts +23 -2
- package/src/plugins/map.ts +396 -0
- package/src/runtime/input.ts +6 -1
- package/src/ui/UIImage.ts +21 -7
package/dist/global.d.ts
CHANGED
|
@@ -11,8 +11,11 @@ declare global {
|
|
|
11
11
|
const Animator: typeof SDK.Animator
|
|
12
12
|
const Aspect: typeof SDK.Aspect
|
|
13
13
|
const AudioPlayer: typeof SDK.AudioPlayer
|
|
14
|
+
const AudioSource: typeof SDK.AudioSource
|
|
15
|
+
const AudioZone: typeof SDK.AudioZone
|
|
14
16
|
const Autotile2D: typeof SDK.Autotile2D
|
|
15
17
|
const Bitmap: typeof SDK.Bitmap
|
|
18
|
+
const Bus: typeof SDK.Bus
|
|
16
19
|
const Camera: typeof SDK.Camera
|
|
17
20
|
const Camera2D: typeof SDK.Camera2D
|
|
18
21
|
const CameraFollow: typeof SDK.CameraFollow
|
|
@@ -24,6 +27,8 @@ declare global {
|
|
|
24
27
|
const ClickEvent: typeof SDK.ClickEvent
|
|
25
28
|
const Color: typeof SDK.Color
|
|
26
29
|
const DateValue: typeof SDK.DateValue
|
|
30
|
+
const DecalSet: typeof SDK.DecalSet
|
|
31
|
+
const Feet: typeof SDK.Feet
|
|
27
32
|
const File: typeof SDK.File
|
|
28
33
|
const FollowPath: typeof SDK.FollowPath
|
|
29
34
|
const FormData: typeof SDK.FormData
|
|
@@ -44,6 +49,7 @@ declare global {
|
|
|
44
49
|
const LongPressEvent: typeof SDK.LongPressEvent
|
|
45
50
|
const LookAt: typeof SDK.LookAt
|
|
46
51
|
const Loop: typeof SDK.Loop
|
|
52
|
+
const MapView: typeof SDK.MapView
|
|
47
53
|
const Mat4: typeof SDK.Mat4
|
|
48
54
|
const Material: typeof SDK.Material
|
|
49
55
|
const MaterialHandle: typeof SDK.MaterialHandle
|
|
@@ -74,6 +80,7 @@ declare global {
|
|
|
74
80
|
const Push: typeof SDK.Push
|
|
75
81
|
const QRScanner: typeof SDK.QRScanner
|
|
76
82
|
const Quat: typeof SDK.Quat
|
|
83
|
+
const REVERB_PRESETS: typeof SDK.REVERB_PRESETS
|
|
77
84
|
const Ragdoll: typeof SDK.Ragdoll
|
|
78
85
|
const Ray: typeof SDK.Ray
|
|
79
86
|
const Replicated: typeof SDK.Replicated
|
|
@@ -82,10 +89,12 @@ declare global {
|
|
|
82
89
|
const Scene: typeof SDK.Scene
|
|
83
90
|
const Scene2D: typeof SDK.Scene2D
|
|
84
91
|
const Scene2dHandle: typeof SDK.Scene2dHandle
|
|
92
|
+
const SceneAudio: typeof SDK.SceneAudio
|
|
85
93
|
const SceneHandle: typeof SDK.SceneHandle
|
|
86
94
|
const Service: typeof SDK.Service
|
|
87
95
|
const Shape: typeof SDK.Shape
|
|
88
96
|
const Shape2D: typeof SDK.Shape2D
|
|
97
|
+
const Sound: typeof SDK.Sound
|
|
89
98
|
const Spin: typeof SDK.Spin
|
|
90
99
|
const Sprite: typeof SDK.Sprite
|
|
91
100
|
const SpriteAnimation: typeof SDK.SpriteAnimation
|
|
@@ -127,6 +136,8 @@ declare global {
|
|
|
127
136
|
const Vec3: typeof SDK.Vec3
|
|
128
137
|
const Vehicle: typeof SDK.Vehicle
|
|
129
138
|
const VideoPlayer: typeof SDK.VideoPlayer
|
|
139
|
+
const Voice: typeof SDK.Voice
|
|
140
|
+
const Warp: typeof SDK.Warp
|
|
130
141
|
const WebSocket: typeof SDK.WebSocket
|
|
131
142
|
const Wheel: typeof SDK.Wheel
|
|
132
143
|
const __GizmoBuffer: typeof SDK.__GizmoBuffer
|
|
@@ -151,6 +162,7 @@ declare global {
|
|
|
151
162
|
const animate: typeof SDK.animate
|
|
152
163
|
const animateMat4: typeof SDK.animateMat4
|
|
153
164
|
const app: typeof SDK.app
|
|
165
|
+
const audio: typeof SDK.audio
|
|
154
166
|
const cells: typeof SDK.cells
|
|
155
167
|
const clipboard: typeof SDK.clipboard
|
|
156
168
|
const colorCurve: typeof SDK.colorCurve
|
|
@@ -210,17 +222,24 @@ declare global {
|
|
|
210
222
|
type AppState = SDK.AppState
|
|
211
223
|
type Aspect<K extends string, P = Node, E extends EventMap = {}> = SDK.Aspect<K, P, E>
|
|
212
224
|
type AspectEntry<A extends Aspect<any, any> = Aspect<any, any>> = SDK.AspectEntry<A>
|
|
225
|
+
type AudioCone = SDK.AudioCone
|
|
213
226
|
type AudioPlayer = SDK.AudioPlayer
|
|
227
|
+
type AudioSource = SDK.AudioSource
|
|
228
|
+
type AudioStats = SDK.AudioStats
|
|
229
|
+
type AudioZone = SDK.AudioZone
|
|
214
230
|
type AutoPaintRules = SDK.AutoPaintRules
|
|
215
231
|
type Autotile2D = SDK.Autotile2D
|
|
216
232
|
type Bitmap = SDK.Bitmap
|
|
233
|
+
type BlendMember = SDK.BlendMember
|
|
217
234
|
type BlendPosition = SDK.BlendPosition
|
|
218
235
|
type BlockEntry = SDK.BlockEntry
|
|
236
|
+
type Bus = SDK.Bus
|
|
219
237
|
type Camera = SDK.Camera
|
|
220
238
|
type Camera2D = SDK.Camera2D
|
|
221
239
|
type Camera2dNodeDef = SDK.Camera2dNodeDef
|
|
222
240
|
type CameraFacing = SDK.CameraFacing
|
|
223
241
|
type CameraFollow = SDK.CameraFollow
|
|
242
|
+
type CameraMove = SDK.CameraMove
|
|
224
243
|
type CameraNodeDef = SDK.CameraNodeDef
|
|
225
244
|
type CameraPlace = SDK.CameraPlace
|
|
226
245
|
type CameraView = SDK.CameraView
|
|
@@ -230,7 +249,11 @@ declare global {
|
|
|
230
249
|
type CharacterController2D = SDK.CharacterController2D
|
|
231
250
|
type ClickEvent<T = any> = SDK.ClickEvent<T>
|
|
232
251
|
type ClientChannel<E extends Record<string, unknown> = Record<string, unknown>> = SDK.ClientChannel<E>
|
|
252
|
+
type ClipAlign = SDK.ClipAlign
|
|
253
|
+
type ClipCycle = SDK.ClipCycle
|
|
233
254
|
type ClipDef = SDK.ClipDef
|
|
255
|
+
type ClipEventHandler = SDK.ClipEventHandler
|
|
256
|
+
type ClipInfo = SDK.ClipInfo
|
|
234
257
|
type ClipKey<V> = SDK.ClipKey<V>
|
|
235
258
|
type ClipTrackDef = SDK.ClipTrackDef
|
|
236
259
|
type CompAxis = SDK.CompAxis
|
|
@@ -239,9 +262,15 @@ declare global {
|
|
|
239
262
|
type ConformOptions = SDK.ConformOptions
|
|
240
263
|
type DateInput = SDK.DateInput
|
|
241
264
|
type DateValue = SDK.DateValue
|
|
265
|
+
type DecalOptions = SDK.DecalOptions
|
|
266
|
+
type DecalPlacement = SDK.DecalPlacement
|
|
267
|
+
type DecalSet = SDK.DecalSet
|
|
268
|
+
type DecalSetOptions = SDK.DecalSetOptions
|
|
269
|
+
type DecalSpawnOptions = SDK.DecalSpawnOptions
|
|
242
270
|
type DifferentialMode = SDK.DifferentialMode
|
|
243
271
|
type Displacement = SDK.Displacement
|
|
244
272
|
type DriveLayout = SDK.DriveLayout
|
|
273
|
+
type EchoParams = SDK.EchoParams
|
|
245
274
|
type EdgeSlot = SDK.EdgeSlot
|
|
246
275
|
type EditorApi = SDK.EditorApi
|
|
247
276
|
type EditorRayHit = SDK.EditorRayHit
|
|
@@ -249,12 +278,14 @@ declare global {
|
|
|
249
278
|
type EditorWindowFn = SDK.EditorWindowFn
|
|
250
279
|
type EngineConfig = SDK.EngineConfig
|
|
251
280
|
type EventMap = SDK.EventMap
|
|
281
|
+
type Feet = SDK.Feet
|
|
252
282
|
type FeetOptions = SDK.FeetOptions
|
|
253
283
|
type FetchResponse = SDK.FetchResponse
|
|
254
284
|
type FieldMeta<T = unknown> = SDK.FieldMeta<T>
|
|
255
285
|
type File = SDK.File
|
|
256
286
|
type FileData = SDK.FileData
|
|
257
287
|
type FillBlock = SDK.FillBlock
|
|
288
|
+
type FitOptions = SDK.FitOptions
|
|
258
289
|
type FollowPath = SDK.FollowPath
|
|
259
290
|
type FootState = SDK.FootState
|
|
260
291
|
type FormData = SDK.FormData
|
|
@@ -277,6 +308,7 @@ declare global {
|
|
|
277
308
|
type InspectorUI = SDK.InspectorUI
|
|
278
309
|
type InstanceTransform = SDK.InstanceTransform
|
|
279
310
|
type InstancedMesh = SDK.InstancedMesh
|
|
311
|
+
type KneeAxisReport = SDK.KneeAxisReport
|
|
280
312
|
type Layer = SDK.Layer
|
|
281
313
|
type LayerOptions = SDK.LayerOptions
|
|
282
314
|
type LevelBuild = SDK.LevelBuild
|
|
@@ -290,7 +322,10 @@ declare global {
|
|
|
290
322
|
type Light = SDK.Light
|
|
291
323
|
type LightDef = SDK.LightDef
|
|
292
324
|
type Lightmap = SDK.Lightmap
|
|
325
|
+
type LineLayer = SDK.LineLayer
|
|
326
|
+
type LineLayerOptions = SDK.LineLayerOptions
|
|
293
327
|
type LitMaterialDef = SDK.LitMaterialDef
|
|
328
|
+
type LngLat = SDK.LngLat
|
|
294
329
|
type LoadedScene<D extends SceneDef> = SDK.LoadedScene<D>
|
|
295
330
|
type LoadedScene2d<D extends Scene2dDef> = SDK.LoadedScene2d<D>
|
|
296
331
|
type Locale = SDK.Locale
|
|
@@ -300,12 +335,24 @@ declare global {
|
|
|
300
335
|
type LocomotionSet = SDK.LocomotionSet
|
|
301
336
|
type LocomotionState = SDK.LocomotionState
|
|
302
337
|
type LocomotionTuning = SDK.LocomotionTuning
|
|
338
|
+
type LodMode = SDK.LodMode
|
|
303
339
|
type LongPressEvent<T = any> = SDK.LongPressEvent<T>
|
|
304
340
|
type LookAt = SDK.LookAt
|
|
305
341
|
type Loop = SDK.Loop
|
|
306
342
|
type LoopDef = SDK.LoopDef
|
|
307
343
|
type LoopOptions = SDK.LoopOptions
|
|
308
344
|
type MakeEntry<A extends Record<string, unknown> = Record<string, unknown>> = SDK.MakeEntry<A>
|
|
345
|
+
type MapCamera = SDK.MapCamera
|
|
346
|
+
type MapOptions = SDK.MapOptions
|
|
347
|
+
type MapPaddingValues = SDK.MapPaddingValues
|
|
348
|
+
type MapStyle = SDK.MapStyle
|
|
349
|
+
type MapStyleName = SDK.MapStyleName
|
|
350
|
+
type MapTap = SDK.MapTap
|
|
351
|
+
type MapView = SDK.MapView
|
|
352
|
+
type MarkerItem = SDK.MarkerItem
|
|
353
|
+
type MarkerLayer = SDK.MarkerLayer
|
|
354
|
+
type MarkerLayerOptions = SDK.MarkerLayerOptions
|
|
355
|
+
type MarkerTap = SDK.MarkerTap
|
|
309
356
|
type Mat4 = SDK.Mat4
|
|
310
357
|
type Material = SDK.Material
|
|
311
358
|
type MaterialData = SDK.MaterialData
|
|
@@ -358,6 +405,7 @@ declare global {
|
|
|
358
405
|
type Plane = SDK.Plane
|
|
359
406
|
type PlayAnimation = SDK.PlayAnimation
|
|
360
407
|
type PlayOptions = SDK.PlayOptions
|
|
408
|
+
type PlaySoundOptions = SDK.PlaySoundOptions
|
|
361
409
|
type Playback = SDK.Playback
|
|
362
410
|
type PresentOptions = SDK.PresentOptions
|
|
363
411
|
type Presentable = SDK.Presentable
|
|
@@ -372,7 +420,10 @@ declare global {
|
|
|
372
420
|
type RagdollPart = SDK.RagdollPart
|
|
373
421
|
type Ray = SDK.Ray
|
|
374
422
|
type Replicated = SDK.Replicated
|
|
423
|
+
type ReverbParams = SDK.ReverbParams
|
|
424
|
+
type ReverbPreset = SDK.ReverbPreset
|
|
375
425
|
type RibbonOptions = SDK.RibbonOptions
|
|
426
|
+
type Rolloff = SDK.Rolloff
|
|
376
427
|
type RpcError = SDK.RpcError
|
|
377
428
|
type Scene = SDK.Scene
|
|
378
429
|
type Scene2D = SDK.Scene2D
|
|
@@ -380,6 +431,7 @@ declare global {
|
|
|
380
431
|
type Scene2dEnv = SDK.Scene2dEnv
|
|
381
432
|
type Scene2dHandle<D extends Scene2dDef = Scene2dDef> = SDK.Scene2dHandle<D>
|
|
382
433
|
type Scene2dNodeDef = SDK.Scene2dNodeDef
|
|
434
|
+
type SceneAudio = SDK.SceneAudio
|
|
383
435
|
type SceneDef = SDK.SceneDef
|
|
384
436
|
type SceneHandle<D extends SceneDef = SceneDef> = SDK.SceneHandle<D>
|
|
385
437
|
type SceneInstance<D extends SceneDef> = SDK.SceneInstance<D>
|
|
@@ -391,6 +443,9 @@ declare global {
|
|
|
391
443
|
type Shape2D = SDK.Shape2D
|
|
392
444
|
type SheetSprite = SDK.SheetSprite
|
|
393
445
|
type Signal<T> = SDK.Signal<T>
|
|
446
|
+
type Sound = SDK.Sound
|
|
447
|
+
type SoundOptions = SDK.SoundOptions
|
|
448
|
+
type SpatialOptions = SDK.SpatialOptions
|
|
394
449
|
type Spin = SDK.Spin
|
|
395
450
|
type Sprite = SDK.Sprite
|
|
396
451
|
type SpriteAnimation = SDK.SpriteAnimation
|
|
@@ -405,6 +460,8 @@ declare global {
|
|
|
405
460
|
type StateMachineEvents = SDK.StateMachineEvents
|
|
406
461
|
type StatesDef<C> = SDK.StatesDef<C>
|
|
407
462
|
type SteeringConfig = SDK.SteeringConfig
|
|
463
|
+
type StepHandler = SDK.StepHandler
|
|
464
|
+
type StepWarpOptions = SDK.StepWarpOptions
|
|
408
465
|
type StopOptions = SDK.StopOptions
|
|
409
466
|
type System<K extends string, S extends SystemHost = Scene, E extends EventMap = {}> = SDK.System<K, S, E>
|
|
410
467
|
type SystemHost = SDK.SystemHost
|
|
@@ -418,6 +475,7 @@ declare global {
|
|
|
418
475
|
type TerrainSnapshot = SDK.TerrainSnapshot
|
|
419
476
|
type Texture = SDK.Texture
|
|
420
477
|
type Texture2D = SDK.Texture2D
|
|
478
|
+
type TextureLoadOptions = SDK.TextureLoadOptions
|
|
421
479
|
type ThemeAccessors<T> = SDK.ThemeAccessors<T>
|
|
422
480
|
type ThemeValues = SDK.ThemeValues
|
|
423
481
|
type TileBlock = SDK.TileBlock
|
|
@@ -475,11 +533,15 @@ declare global {
|
|
|
475
533
|
type UIWidgetStyle = SDK.UIWidgetStyle
|
|
476
534
|
type Unit = SDK.Unit
|
|
477
535
|
type UnlitMaterialDef = SDK.UnlitMaterialDef
|
|
536
|
+
type UserLocationOptions = SDK.UserLocationOptions
|
|
478
537
|
type VRScene = SDK.VRScene
|
|
479
538
|
type Vec2 = SDK.Vec2
|
|
480
539
|
type Vec3 = SDK.Vec3
|
|
481
540
|
type Vehicle = SDK.Vehicle
|
|
482
541
|
type VideoPlayer = SDK.VideoPlayer
|
|
542
|
+
type Voice = SDK.Voice
|
|
543
|
+
type VoiceEvents = SDK.VoiceEvents
|
|
544
|
+
type Warp = SDK.Warp
|
|
483
545
|
type WarpOptions = SDK.WarpOptions
|
|
484
546
|
type WebSocket = SDK.WebSocket
|
|
485
547
|
type Wheel = SDK.Wheel
|
package/dist/host.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ declare global {
|
|
|
29
29
|
error(...data: any[]): void
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/** Compile-time macro: `asset('./data.json')` yields the file's PARSED data (a .json file is
|
|
33
|
+
* data, not code — it ships inside the bundle). See the `string` overload for everything else. */
|
|
34
|
+
function asset(path: `${string}.json`): any
|
|
32
35
|
/** Compile-time macro: `asset('./hero.png')` is desugared by the bundler into the module import
|
|
33
36
|
* for that resource. The file must exist — a path that resolves to nothing fails the compile
|
|
34
37
|
* (`asset not found: ./hero.png (main.ts:3)`); there is no runtime fallback. Calls inside
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type ReverbPreset = "room" | "hall" | "cave" | "arena" | "bathroom" | "outdoor";
|
|
2
|
+
export type ReverbParams = {
|
|
3
|
+
/** 0 (a closet) … 1 (a cathedral). */
|
|
4
|
+
roomSize?: number;
|
|
5
|
+
/** High-frequency loss per reflection, 0 … 1. */
|
|
6
|
+
damping?: number;
|
|
7
|
+
/** Stereo width of the tail, 0 … 1. */
|
|
8
|
+
width?: number;
|
|
9
|
+
/** Wet amount, 0 … 1. */
|
|
10
|
+
mix?: number;
|
|
11
|
+
/** Seconds before the tail starts (a big hall: 0.02 … 0.05). */
|
|
12
|
+
preDelay?: number;
|
|
13
|
+
};
|
|
14
|
+
export type EchoParams = {
|
|
15
|
+
/** Seconds between repeats (up to 2). */
|
|
16
|
+
delay?: number;
|
|
17
|
+
/** Feedback, 0 … 0.95 — how many repeats survive. */
|
|
18
|
+
decay?: number;
|
|
19
|
+
/** Wet amount, 0 … 1. */
|
|
20
|
+
mix?: number;
|
|
21
|
+
};
|
|
22
|
+
export declare const REVERB_PRESETS: Record<ReverbPreset, Required<ReverbParams>>;
|
|
23
|
+
export declare class Bus {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
private _volume;
|
|
26
|
+
private _muted;
|
|
27
|
+
private _reverb;
|
|
28
|
+
private _echo;
|
|
29
|
+
private _lowpass;
|
|
30
|
+
private get _live();
|
|
31
|
+
get volume(): number;
|
|
32
|
+
set volume(v: number);
|
|
33
|
+
get muted(): boolean;
|
|
34
|
+
set muted(v: boolean);
|
|
35
|
+
/** A preset name, explicit params, or null (off). */
|
|
36
|
+
get reverb(): ReverbPreset | ReverbParams | null;
|
|
37
|
+
set reverb(v: ReverbPreset | ReverbParams | null);
|
|
38
|
+
get echo(): EchoParams | null;
|
|
39
|
+
set echo(v: EchoParams | null);
|
|
40
|
+
/** Low-pass cutoff in Hz (20 … 20000), null = off. */
|
|
41
|
+
get lowpass(): number | null;
|
|
42
|
+
set lowpass(v: number | null);
|
|
43
|
+
/** Stop every voice on this bus (fade in seconds). */
|
|
44
|
+
stopAll(fade?: number): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type SoundOptions = {
|
|
2
|
+
/** Keep two channels (2D playback of stereo material — music beds, ambiences). Default: the clip
|
|
3
|
+
* is decoded MONO, which is what 3D spatialization needs and what SFX are anyway. */
|
|
4
|
+
stereo?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare class Sound {
|
|
7
|
+
/** The urls this clip was loaded from (one per variant). */
|
|
8
|
+
readonly urls: readonly string[];
|
|
9
|
+
private readonly _durations;
|
|
10
|
+
private _channels;
|
|
11
|
+
private _disposed;
|
|
12
|
+
private _last;
|
|
13
|
+
private constructor();
|
|
14
|
+
/** Fetch + decode. An array = variants: `play` picks a random one (never the same twice in a row
|
|
15
|
+
* when there are 3 or more). Rejects with the failing url when a file cannot be decoded. */
|
|
16
|
+
static load(src: string | string[], options?: SoundOptions): Promise<Sound>;
|
|
17
|
+
/** Seconds (the first variant's). 0 for a silent clip. */
|
|
18
|
+
get duration(): number;
|
|
19
|
+
/** Decoded channel count: 1, or 2 with `{ stereo: true }`. */
|
|
20
|
+
get channels(): number;
|
|
21
|
+
/** How many variants this clip carries. */
|
|
22
|
+
get variants(): number;
|
|
23
|
+
/** True when the engine has this clip (false on hosts without audio, or after dispose). */
|
|
24
|
+
get ready(): boolean;
|
|
25
|
+
get disposed(): boolean;
|
|
26
|
+
/** Free the engine's PCM. Voices playing it stop at once. Idempotent. */
|
|
27
|
+
dispose(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Emitter } from "../core/events";
|
|
2
|
+
export type VoiceEvents = {
|
|
3
|
+
/** The voice is over: the clip ended, `stop` completed, or the pool reused the slot. */
|
|
4
|
+
ended: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare class Voice extends Emitter<VoiceEvents> {
|
|
7
|
+
private _volume;
|
|
8
|
+
private _pitch;
|
|
9
|
+
private _pan;
|
|
10
|
+
private _over;
|
|
11
|
+
addEventListener<K extends keyof VoiceEvents>(channel: K, callback: VoiceEvents[K]): void;
|
|
12
|
+
/** True while the engine plays this voice. */
|
|
13
|
+
get playing(): boolean;
|
|
14
|
+
/** Seconds into the clip. */
|
|
15
|
+
get time(): number;
|
|
16
|
+
get volume(): number;
|
|
17
|
+
set volume(v: number);
|
|
18
|
+
get pitch(): number;
|
|
19
|
+
set pitch(v: number);
|
|
20
|
+
/** 2D voices only: -1 left … 1 right. */
|
|
21
|
+
get pan(): number;
|
|
22
|
+
set pan(v: number);
|
|
23
|
+
/** Stop now, or fade out over `fade` seconds. `ended` fires from the engine afterwards. */
|
|
24
|
+
stop(options?: {
|
|
25
|
+
fade?: number;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type Vec3Like } from "../math/vec";
|
|
2
|
+
import { Bus } from "./Bus";
|
|
3
|
+
import type { Sound } from "./Sound";
|
|
4
|
+
import { Voice } from "./Voice";
|
|
5
|
+
export type PlaySoundOptions = {
|
|
6
|
+
/** 0 … 1 (and above, at your own risk). Default 1. */
|
|
7
|
+
volume?: number;
|
|
8
|
+
/** Playback rate, 1 = unchanged. Default 1. */
|
|
9
|
+
pitch?: number;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
/** Bus name; default: the source's bus, `sfx` for 2D. */
|
|
12
|
+
bus?: string;
|
|
13
|
+
/** Higher survives voice stealing when the pool is full. Default 0. */
|
|
14
|
+
priority?: number;
|
|
15
|
+
/** Fade-in seconds. Default 0. */
|
|
16
|
+
fade?: number;
|
|
17
|
+
/** Seconds into the clip to start from. */
|
|
18
|
+
startAt?: number;
|
|
19
|
+
/** 2D only: -1 left … 1 right. */
|
|
20
|
+
pan?: number;
|
|
21
|
+
};
|
|
22
|
+
export type Rolloff = "none" | "inverse" | "linear" | "exponential";
|
|
23
|
+
/** Distance model of an AudioSource / playAt. */
|
|
24
|
+
export type SpatialOptions = {
|
|
25
|
+
/** Metres of full volume around the source. Default 1. */
|
|
26
|
+
minDistance?: number;
|
|
27
|
+
/** Metres beyond which the source no longer gets quieter. Default 50. */
|
|
28
|
+
maxDistance?: number;
|
|
29
|
+
/** How volume falls between the two: `inverse` (default, physical), `linear`, `exponential`, `none`. */
|
|
30
|
+
rolloff?: Rolloff;
|
|
31
|
+
};
|
|
32
|
+
export declare const ROLLOFF: Record<Rolloff, number>;
|
|
33
|
+
export type AudioStats = {
|
|
34
|
+
voicesPlaying: number;
|
|
35
|
+
voicesMono: number;
|
|
36
|
+
voicesStereo: number;
|
|
37
|
+
/** Voices displaced (or dropped) by a fuller pool since start. */
|
|
38
|
+
stolen: number;
|
|
39
|
+
clips: number;
|
|
40
|
+
clipBytes: number;
|
|
41
|
+
/** Master peak since the previous read, linear (1 = full scale). */
|
|
42
|
+
peak: number;
|
|
43
|
+
sampleRate: number;
|
|
44
|
+
/** The reverb zone the listener is in (0 = none) and how far inside (0 … 1). */
|
|
45
|
+
listenerZone: number;
|
|
46
|
+
zoneBlend: number;
|
|
47
|
+
/** Voices rendered binaurally right now (see `audio.hrtf`). */
|
|
48
|
+
hrtfVoices: number;
|
|
49
|
+
};
|
|
50
|
+
declare class AudioSystem {
|
|
51
|
+
private readonly _buses;
|
|
52
|
+
private _hrtf;
|
|
53
|
+
private _hrtfVoices;
|
|
54
|
+
private _timeScalePitch;
|
|
55
|
+
/** True when this host mixes sound. Everything below is a silent no-op otherwise. */
|
|
56
|
+
get supported(): boolean;
|
|
57
|
+
/** HRTF binaural rendering (MIT KEMAR filters on the CPU): sounds get a real up / down / behind in
|
|
58
|
+
* HEADPHONES. Off by default — on speakers it only smears the image. Applies to the `hrtfVoices`
|
|
59
|
+
* nearest 3D voices; the rest keep plain panning. */
|
|
60
|
+
get hrtf(): boolean;
|
|
61
|
+
set hrtf(v: boolean);
|
|
62
|
+
/** `Time.scale` also pitches the sfx bus: slow motion drops every effect's tone, like a film. Default
|
|
63
|
+
* false — a pause only mutes sfx, the menu click keeps its pitch. */
|
|
64
|
+
get timeScalePitch(): boolean;
|
|
65
|
+
set timeScalePitch(v: boolean);
|
|
66
|
+
/** How many voices get the (CPU-heavier) binaural path. Default 16. */
|
|
67
|
+
get hrtfVoices(): number;
|
|
68
|
+
set hrtfVoices(n: number);
|
|
69
|
+
/** A bus by name — the five built-ins, or an app-defined one created on first use. */
|
|
70
|
+
bus(name: string): Bus;
|
|
71
|
+
get master(): Bus;
|
|
72
|
+
/** 2D playback (UI, stingers, music one-shots). */
|
|
73
|
+
play(sound: Sound, options?: PlaySoundOptions): Voice;
|
|
74
|
+
/** A one-shot at a world position with its own transient source — impacts, ricochets, debris.
|
|
75
|
+
* The source is freed when the voice ends. */
|
|
76
|
+
playAt(sound: Sound, position: Vec3Like, options?: PlaySoundOptions & SpatialOptions): Voice;
|
|
77
|
+
/** Stop every voice on every bus (fade in seconds). */
|
|
78
|
+
stopAll(fade?: number): void;
|
|
79
|
+
/** Engine counters for a debug overlay or a perf log. */
|
|
80
|
+
get stats(): AudioStats;
|
|
81
|
+
}
|
|
82
|
+
export declare const audio: AudioSystem;
|
|
83
|
+
export type { AudioSystem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const audioSupported: boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Aspect } from "../core/Aspect";
|
|
2
|
+
import type { FieldMeta } from "../core/fields";
|
|
3
|
+
import { type PlaySoundOptions, type Rolloff } from "../audio/audio";
|
|
4
|
+
import type { Sound } from "../audio/Sound";
|
|
5
|
+
import type { Voice } from "../audio/Voice";
|
|
6
|
+
import type { Node } from "./Node";
|
|
7
|
+
export type AudioCone = {
|
|
8
|
+
/** Degrees of full volume around the node's −Z. */
|
|
9
|
+
inner: number;
|
|
10
|
+
/** Degrees where the volume has fallen to `outerGain`. */
|
|
11
|
+
outer: number;
|
|
12
|
+
/** Volume behind the source, 0 … 1. */
|
|
13
|
+
outerGain?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare class AudioSource extends Aspect<"audio", Node> {
|
|
16
|
+
static readonly aspect = "audio";
|
|
17
|
+
static fields: FieldMeta<AudioSource>;
|
|
18
|
+
private _minDistance;
|
|
19
|
+
private _maxDistance;
|
|
20
|
+
private _rolloff;
|
|
21
|
+
private _cone;
|
|
22
|
+
private _doppler;
|
|
23
|
+
private _spread;
|
|
24
|
+
private _occlusion;
|
|
25
|
+
private _bus;
|
|
26
|
+
/** Metres of full volume around the node. Default 1. */
|
|
27
|
+
get minDistance(): number;
|
|
28
|
+
set minDistance(v: number);
|
|
29
|
+
/** Metres beyond which the source no longer gets quieter. Default 50. */
|
|
30
|
+
get maxDistance(): number;
|
|
31
|
+
set maxDistance(v: number);
|
|
32
|
+
/** `inverse` (default), `linear`, `exponential`, `none`. */
|
|
33
|
+
get rolloff(): Rolloff;
|
|
34
|
+
set rolloff(v: Rolloff);
|
|
35
|
+
/** Directional source along the node's −Z; null = omnidirectional (default). */
|
|
36
|
+
get cone(): AudioCone | null;
|
|
37
|
+
set cone(v: AudioCone | null);
|
|
38
|
+
/** Doppler amount 0 … 1 (0 = off, the default) — needs the node to actually move. */
|
|
39
|
+
get doppler(): number;
|
|
40
|
+
set doppler(v: number);
|
|
41
|
+
/** 0 = pin-point panning (default) … 1 = the same on every speaker (a big, close source). */
|
|
42
|
+
get spread(): number;
|
|
43
|
+
set spread(v: number);
|
|
44
|
+
/** The engine raycasts listener → source (against solid bodies) and muffles the voices when
|
|
45
|
+
* something is in the way. Default false. */
|
|
46
|
+
get occlusion(): boolean;
|
|
47
|
+
set occlusion(v: boolean);
|
|
48
|
+
/** Default bus for voices on this source. Default `sfx`. */
|
|
49
|
+
get bus(): string;
|
|
50
|
+
set bus(v: string);
|
|
51
|
+
/** Live voices on this source. */
|
|
52
|
+
get voices(): number;
|
|
53
|
+
onAttach(): void;
|
|
54
|
+
onDetach(): void;
|
|
55
|
+
/** Play a clip from this node. */
|
|
56
|
+
play(sound: Sound, options?: PlaySoundOptions): Voice;
|
|
57
|
+
/** Stop every voice on this source (fade in seconds). */
|
|
58
|
+
stopAll(fade?: number): void;
|
|
59
|
+
private _push;
|
|
60
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Aspect } from "../core/Aspect";
|
|
2
|
+
import { type ReverbParams, type ReverbPreset } from "../audio/Bus";
|
|
3
|
+
import { type Vec3Like } from "../math/vec";
|
|
4
|
+
import type { Node } from "./Node";
|
|
5
|
+
export declare class AudioZone extends Aspect<"audioZone", Node> {
|
|
6
|
+
static readonly aspect = "audioZone";
|
|
7
|
+
private _box;
|
|
8
|
+
private _sphere;
|
|
9
|
+
private _reverb;
|
|
10
|
+
private _blend;
|
|
11
|
+
private _bus;
|
|
12
|
+
/** The engine's zone id — what `audio.stats.listenerZone` reports while the listener is inside. */
|
|
13
|
+
get id(): number;
|
|
14
|
+
/** Half-extents [hx, hy, hz]; falls back to the node's Shape box, then a 1 m cube. */
|
|
15
|
+
get box(): Vec3Like | null;
|
|
16
|
+
set box(v: Vec3Like | null);
|
|
17
|
+
/** Radius; falls back to the node's Shape sphere. */
|
|
18
|
+
get sphere(): number | null;
|
|
19
|
+
set sphere(v: number | null);
|
|
20
|
+
/** A preset name or explicit params (see Bus.reverb). */
|
|
21
|
+
get reverb(): ReverbPreset | ReverbParams;
|
|
22
|
+
set reverb(v: ReverbPreset | ReverbParams);
|
|
23
|
+
/** Crossfade depth in metres inside the border (0 = a hard edge). Default 1. */
|
|
24
|
+
get blend(): number;
|
|
25
|
+
set blend(v: number);
|
|
26
|
+
/** The bus the zone's reverb rides on. Default `sfx`. */
|
|
27
|
+
get bus(): string;
|
|
28
|
+
set bus(v: string);
|
|
29
|
+
onAttach(): void;
|
|
30
|
+
onDetach(): void;
|
|
31
|
+
private _push;
|
|
32
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
import { Material } from "./Material";
|
|
3
|
+
import type { Texture } from "./Texture";
|
|
4
|
+
import { type Vec3Like } from "../math/vec";
|
|
5
|
+
import { type QuatLike } from "../math/quat";
|
|
6
|
+
import { type ColorInput } from "../core/color";
|
|
7
|
+
/** Per-decal look and life — defaults come from the set's options. */
|
|
8
|
+
export type DecalOptions = {
|
|
9
|
+
/** Image width and height on the surface (world units); a number = square. Default 0.2. */
|
|
10
|
+
size?: number | [number, number];
|
|
11
|
+
/** Projection depth (world units): how far in front of and behind the hit point the decal still
|
|
12
|
+
* lands. Default = the smaller of width / height. */
|
|
13
|
+
depth?: number;
|
|
14
|
+
/** Atlas cell (row-major from the top-left) for a set with a `sheet`; `"random"` picks one.
|
|
15
|
+
* Default 0. */
|
|
16
|
+
frame?: number | "random";
|
|
17
|
+
/** Tint multiplied into the image. Default white. */
|
|
18
|
+
tint?: ColorInput;
|
|
19
|
+
/** 0..1 on top of the tint's alpha. Default 1. */
|
|
20
|
+
opacity?: number;
|
|
21
|
+
/** Seconds until the decal is gone; 0 = stays until recycled. Default 0. */
|
|
22
|
+
life?: number;
|
|
23
|
+
/** Seconds to fade in after spawning. Default 0. */
|
|
24
|
+
fadeIn?: number;
|
|
25
|
+
/** Seconds of fade at the end of `life` (ignored with life 0). Default 0. */
|
|
26
|
+
fadeOut?: number;
|
|
27
|
+
};
|
|
28
|
+
export type DecalSetOptions = DecalOptions & {
|
|
29
|
+
/** The material — `Material.decal({ map })` by default (`map` below is its shortcut). A custom
|
|
30
|
+
* material must keep decal.mat's vertex contract. */
|
|
31
|
+
material?: Material;
|
|
32
|
+
/** Atlas texture for the default material. */
|
|
33
|
+
map?: Texture;
|
|
34
|
+
/** Tangent-space normal atlas (same cell grid) → a RELIEF decal that bends the surface's
|
|
35
|
+
* lighting instead of painting a colour (`Material.decal` `normalMap`). Footprints and dents
|
|
36
|
+
* need only this; a bullet hole gives `map` too and its colour multiplies in. */
|
|
37
|
+
normalMap?: Texture;
|
|
38
|
+
/** Relief strength for `normalMap`. Default 1. Default material only. */
|
|
39
|
+
bump?: number;
|
|
40
|
+
/** Atlas grid of the map: columns, or [columns, rows]. Default 1 (the whole texture). */
|
|
41
|
+
sheet?: number | [number, number];
|
|
42
|
+
/** Slot budget — the most decals alive at once. Default 256. */
|
|
43
|
+
max?: number;
|
|
44
|
+
/** Soft fraction (0..1) of the box's half depth at both ends, so an oblique surface leaves the
|
|
45
|
+
* box gently. Default 0.3. Default material only. */
|
|
46
|
+
edge?: number;
|
|
47
|
+
/** Surfaces turned more than this away from the projection axis fade out — the cosine of the
|
|
48
|
+
* angle (0.3 ≈ 72°) keeps a floor hit off the wall it meets; 0 = project onto anything.
|
|
49
|
+
* Default 0.3. Default material only. */
|
|
50
|
+
angleFade?: number;
|
|
51
|
+
/** HDR boost of the image (0 = none). Default material only. */
|
|
52
|
+
emissive?: number;
|
|
53
|
+
name?: string;
|
|
54
|
+
/** Coarse draw order, 0 (first) … 7 (last); default 4 — see `Mesh.renderPriority`. Decals are
|
|
55
|
+
* blended and sort with the other blended draws of their priority. */
|
|
56
|
+
renderPriority?: number;
|
|
57
|
+
};
|
|
58
|
+
/** `spawn` placement: where the image sits on the surface. */
|
|
59
|
+
export type DecalSpawnOptions = DecalOptions & {
|
|
60
|
+
/** World direction the image's top points along the surface (projected onto it) — a footprint's
|
|
61
|
+
* travel direction. Default: a random spin. */
|
|
62
|
+
up?: Vec3Like;
|
|
63
|
+
/** Extra spin around the normal, radians. Default: random when `up` is not given, else 0. */
|
|
64
|
+
rotation?: number;
|
|
65
|
+
};
|
|
66
|
+
/** `place` / `update` placement: a full frame, like a node looking INTO the surface (its −Z is the
|
|
67
|
+
* projection direction, +Y the image's top). */
|
|
68
|
+
export type DecalPlacement = DecalOptions & {
|
|
69
|
+
position: Vec3Like;
|
|
70
|
+
/** A quaternion, or Euler degrees (YXZ) like `Node.eulerAngles`. Default identity = projecting
|
|
71
|
+
* down −Z. */
|
|
72
|
+
rotation?: QuatLike | Vec3Like;
|
|
73
|
+
};
|
|
74
|
+
export declare class DecalSet extends Node {
|
|
75
|
+
private _material;
|
|
76
|
+
private readonly _max;
|
|
77
|
+
private readonly _cols;
|
|
78
|
+
private readonly _rows;
|
|
79
|
+
private readonly _defaults;
|
|
80
|
+
private readonly _rec;
|
|
81
|
+
private readonly _slots;
|
|
82
|
+
private static _warned;
|
|
83
|
+
constructor(options?: DecalSetOptions);
|
|
84
|
+
get material(): Material;
|
|
85
|
+
/** Decals alive right now. */
|
|
86
|
+
get count(): number;
|
|
87
|
+
/** The slot budget the set was created with. */
|
|
88
|
+
get max(): number;
|
|
89
|
+
/** Coarse draw order, 0 … 7 — see `Mesh.renderPriority`. Write-only. */
|
|
90
|
+
set renderPriority(v: number);
|
|
91
|
+
/** Stamp a decal on a surface: `point` on it, `normal` out of it (a raycast hit, a foot plant
|
|
92
|
+
* with `Vec3.up`). Returns the slot for `update` / `remove` (−1 when the host draws none). */
|
|
93
|
+
spawn(point: Vec3Like, normal: Vec3Like, options?: DecalSpawnOptions): number;
|
|
94
|
+
/** Place a decal by a full frame (an editor-placed stain, a moving marker). Returns the slot. */
|
|
95
|
+
place(placement: DecalPlacement): number;
|
|
96
|
+
/** Move / restyle a placed decal; fields left out keep the values it was placed with. Its birth
|
|
97
|
+
* time (the life clock) is kept. */
|
|
98
|
+
update(slot: number, placement: Partial<DecalPlacement>): this;
|
|
99
|
+
remove(slot: number): this;
|
|
100
|
+
clear(): this;
|
|
101
|
+
private _writePlacement;
|
|
102
|
+
private _write;
|
|
103
|
+
}
|
|
@@ -10,6 +10,11 @@ export declare class Geometry {
|
|
|
10
10
|
* tiles per face, which would fold every face onto the same texels); absent = the host reuses
|
|
11
11
|
* `uv`, which is right for a plane. */
|
|
12
12
|
uv1?: Float32Array;
|
|
13
|
+
/** Per-vertex COLOURS: 4 bytes (r, g, b, a) per vertex, 0..255. A material that declares
|
|
14
|
+
* `requires: [color]` reads them through `getColor()` — one mesh, many colours, no material per
|
|
15
|
+
* shade (a debug drawer, a gradient along a curve). Absent = every vertex white, which is what
|
|
16
|
+
* the built-in materials expect. */
|
|
17
|
+
colors?: Uint8Array;
|
|
13
18
|
constructor(vertices: Float32Array, normals: Float32Array, indices: Uint16Array, uv: Float32Array);
|
|
14
19
|
translate(x: number, y: number, z: number): this;
|
|
15
20
|
scale(x: number, y: number, z: number): this;
|
package/dist/types/gl/Light.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare class Light extends Node {
|
|
|
53
53
|
private _intensity;
|
|
54
54
|
/** The most recently created sun — what `Lightmap.load` uses unless told otherwise. */
|
|
55
55
|
static lastSun: Light | null;
|
|
56
|
+
_shadowDistance: number;
|
|
56
57
|
/** A directional sun light. */
|
|
57
58
|
static sun(options?: SunOptions): Light;
|
|
58
59
|
/**
|
|
@@ -70,4 +71,10 @@ export declare class Light extends Node {
|
|
|
70
71
|
set intensity(value: number);
|
|
71
72
|
destroy(): void;
|
|
72
73
|
set color(value: ColorInput);
|
|
74
|
+
get color(): ColorInput;
|
|
75
|
+
/** Sun direction as created (the engine keeps it; a settings menu rebuilds a sun from it). */
|
|
76
|
+
get direction(): [number, number, number];
|
|
77
|
+
/** Sun shadow options as created — creation-time in the engine, so a change means a new sun. */
|
|
78
|
+
get shadowsQuality(): number;
|
|
79
|
+
get shadowDistance(): number;
|
|
73
80
|
}
|