@yaks/stage 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +73 -2
- package/_dist/aim.d.ts +14 -0
- package/_dist/aim.d.ts.map +1 -0
- package/_dist/air.d.ts +23 -0
- package/_dist/air.d.ts.map +1 -0
- package/_dist/bus.d.ts +8 -0
- package/_dist/bus.d.ts.map +1 -0
- package/_dist/cam.d.ts +75 -0
- package/_dist/cam.d.ts.map +1 -0
- package/_dist/ears.d.ts +71 -0
- package/_dist/ears.d.ts.map +1 -0
- package/_dist/flames.d.ts +10 -0
- package/_dist/flames.d.ts.map +1 -0
- package/_dist/fx.d.ts +27 -0
- package/_dist/fx.d.ts.map +1 -0
- package/_dist/halo.d.ts +4 -0
- package/_dist/halo.d.ts.map +1 -0
- package/_dist/instances.d.ts +24 -0
- package/_dist/instances.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/pace.d.ts +19 -0
- package/_dist/pace.d.ts.map +1 -0
- package/_dist/render.d.ts +7 -0
- package/_dist/render.d.ts.map +1 -0
- package/_dist/samples.d.ts +27 -0
- package/_dist/samples.d.ts.map +1 -0
- package/_dist/scene.d.ts +28 -0
- package/_dist/scene.d.ts.map +1 -0
- package/_dist/sound.d.ts +13 -0
- package/_dist/sound.d.ts.map +1 -0
- package/aim.js +63 -0
- package/aim.js.map +1 -0
- package/aim.ts +71 -0
- package/air.js +40 -0
- package/air.js.map +1 -0
- package/air.ts +66 -0
- package/bus.js +36 -0
- package/bus.js.map +1 -0
- package/bus.ts +51 -0
- package/cam.js +110 -0
- package/cam.js.map +1 -0
- package/cam.ts +181 -0
- package/deno.json +1 -0
- package/ears.js +123 -0
- package/ears.js.map +1 -0
- package/ears.ts +131 -0
- package/flames.js +61 -0
- package/flames.js.map +1 -0
- package/flames.ts +69 -0
- package/fx.js +235 -0
- package/fx.js.map +1 -0
- package/fx.ts +330 -0
- package/halo.js +22 -0
- package/halo.js.map +1 -0
- package/halo.ts +23 -0
- package/instances.js +131 -0
- package/instances.js.map +1 -0
- package/instances.ts +166 -0
- package/mod.js +5 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/pace.js +63 -0
- package/pace.js.map +1 -0
- package/pace.ts +86 -0
- package/package.json +73 -4
- package/render.js +50 -0
- package/render.js.map +1 -0
- package/render.ts +68 -0
- package/samples.js +162 -0
- package/samples.js.map +1 -0
- package/samples.ts +204 -0
- package/scene.js +80 -0
- package/scene.js.map +1 -0
- package/scene.ts +112 -0
- package/sound.js +117 -0
- package/sound.js.map +1 -0
- package/sound.ts +175 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jeff Peterson
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/stage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Three.js presentation primitives over values: draw ordinary geometry, orbit a
|
|
4
|
+
camera, pick ground and objects, and play positional sound. A stage knows
|
|
5
|
+
neither a graph nor a game's world. The app reads its graph and hands it
|
|
6
|
+
geometry, animation, collision callbacks, clip URLs and volume values.
|
|
7
|
+
|
|
8
|
+
## A frame and a camera
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { pace } from '@yaks/stage'
|
|
12
|
+
import { groundRay } from '@yaks/stage/aim'
|
|
13
|
+
|
|
14
|
+
let draw = pace()
|
|
15
|
+
console.log([0, 8, 17, 25, 34].filter((t) => draw(t, 60))) // [0, 17, 34]
|
|
16
|
+
let point = groundRay(
|
|
17
|
+
{ x: 0, y: 4, z: 0 },
|
|
18
|
+
{ x: 0, y: -0.5, z: 0.5 },
|
|
19
|
+
() => 0,
|
|
20
|
+
)
|
|
21
|
+
console.log(point) // { x: 0, y: 0, z: 4 }
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`/render` creates a WebGL renderer. `frameLoop` (in `/pace`, which imports no
|
|
25
|
+
Three.js) schedules the next frame and supplies both elapsed seconds and a
|
|
26
|
+
simulation step capped at 50 ms; the page decides when to start it.
|
|
27
|
+
`pageLoop(frame, dispose)` starts it for a page: it rests while the page is
|
|
28
|
+
hidden, so the first frame back is not one long frame, and runs `dispose` once
|
|
29
|
+
when the page is left for good. `keepUp(quality(renderer, sun, scene, density))`
|
|
30
|
+
lowers pixel density and then shadows over successive slow windows. Call it only
|
|
31
|
+
while the app wants frame performance measured.
|
|
32
|
+
|
|
33
|
+
`/scene` is a lit scene with a camera that follows the player:
|
|
34
|
+
`followScene(canvas, world, actor, {blocked, sky})` adds the caller's world and
|
|
35
|
+
actor meshes under a sky and a sun. `draw(pose, intent, dt, elapsed)` places the
|
|
36
|
+
actor at a `{x, y, z, yaw}` pose, steers the camera by a camera intent, and
|
|
37
|
+
lowers quality on slow frames. `pick(x, y)` answers the ground point under a
|
|
38
|
+
screen position, for tapping where to go. `dispose()` frees every mesh it holds
|
|
39
|
+
and the renderer.
|
|
40
|
+
|
|
41
|
+
`/cam` takes a camera state and a small camera intent, not an input controller.
|
|
42
|
+
`aim` takes a `blocked(point)` callback and an optional minimum pitch. The app
|
|
43
|
+
owns terrain, walls and indoor policy. `/aim` intersects a ray with a supplied
|
|
44
|
+
heightfield or a collection of bounding spheres.
|
|
45
|
+
|
|
46
|
+
## Geometry and animation
|
|
47
|
+
|
|
48
|
+
- `/instances`: batches of repeated ordinary `THREE.BufferGeometry`, keyed by a
|
|
49
|
+
model-key function the caller supplies. Templates return a promise of owned
|
|
50
|
+
geometry; stage retains it while prepared or drawn placements need it,
|
|
51
|
+
disposes it after the last placement leaves. Attribute arrays and upload
|
|
52
|
+
callbacks remain the caller’s policy. A template finishing after disposal is
|
|
53
|
+
disposed too.
|
|
54
|
+
- `/fx`, `/air`, `/halo`, `/flames`: particles, projected labels, glow,
|
|
55
|
+
instanced air and flames. The app supplies colors, textures and motion.
|
|
56
|
+
|
|
57
|
+
## Sound
|
|
58
|
+
|
|
59
|
+
`/ears` spatializes audio relative to a camera. `/sound` manages sources that
|
|
60
|
+
follow their emitters. `/samples` loads clips by URL, plays one-shots and loops,
|
|
61
|
+
and falls back to a supplied voice when a clip is unavailable. `/bus` controls
|
|
62
|
+
volume by kind from supplied settings and an optional change callback; it never
|
|
63
|
+
chooses where settings are persisted.
|
|
64
|
+
|
|
65
|
+
Three.js is an ordinary npm dependency shared by the page and stage. Stage has
|
|
66
|
+
no voxel, graph or application dependencies. Points are plain `[x, y, z]`
|
|
67
|
+
values. Voxel materials, packed-quad geometry, box rigs and puppets live in
|
|
68
|
+
`@yaks/voxel/three`, and baked lamp light in `@yaks/voxel/light`. The platform
|
|
69
|
+
compiler serves the exports declared for the browser in `package.json`. An app
|
|
70
|
+
opts in with `"@yaks/stage": "platform"` in its `package.json` dependencies.
|
|
71
|
+
|
|
72
|
+
Mossvale (`apps/vale`) is a consumer. Its vocabulary, saved heroes, world,
|
|
73
|
+
procedural voices and design subscriptions remain in the app. The larger
|
|
74
|
+
world/sky/chunk-streaming shell is a separate extraction (T-125028).
|
package/_dist/aim.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Point = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
z: number;
|
|
5
|
+
};
|
|
6
|
+
export declare let cursor: (x: number, y: number, width: number, height: number, locked: boolean) => [number, number];
|
|
7
|
+
export declare let groundRay: (from: Point, ray: Point, height: (x: number, z: number) => number, far?: number) => Point;
|
|
8
|
+
export declare let landing: (from: Point, to: Point, reach: number) => Point;
|
|
9
|
+
/** First entity under a ray, before the terrain; independent of array order. */ export declare let pickRay: <M extends {
|
|
10
|
+
eid: string;
|
|
11
|
+
body: Point;
|
|
12
|
+
radius: number;
|
|
13
|
+
}>(marks: M[], from: Point, ray: Point, far: number) => M | null;
|
|
14
|
+
//# sourceMappingURL=aim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aim.d.ts","sources":["../aim.ts"],"names":[],"mappings":"AAEA,YAAY;EAAU,GAAG,MAAM;EAAE,GAAG,MAAM;EAAE,GAAG,MAAM;;AACrD,OAAO,YAAI,SACT,GAAG,MAAM,EACT,GAAG,MAAM,EACT,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,QAAQ,OAAO,MACb,MAAM,EAAE,MAAM,EAA8D;AAEhF,OAAO,YAAI,YACT,MAAM,OACN,KAAK,OACL,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,KAAK,MAAM,EACxC,iBACC,MAuBF;AAED,OAAO,YAAI,UAAW,MAAM,OAAO,IAAI,OAAO,OAAO,MAAM,KAAG,MAQ7D;AAED,8EAA8E,GAC9E,OAAO,YAAI,UAAW;EAAY,KAAK,MAAM;EAAE,MAAM;EAAO,QAAQ,MAAM;GACxE,OAAO,KACP,MAAM,OACN,KAAK,OACL,gBACC,IAAI,IAAI,CAaV"}
|
package/_dist/air.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
export type Air = {
|
|
4
|
+
color: number;
|
|
5
|
+
glow?: boolean;
|
|
6
|
+
rate: number;
|
|
7
|
+
spread: number;
|
|
8
|
+
low: number;
|
|
9
|
+
high: number;
|
|
10
|
+
speed: number;
|
|
11
|
+
up: number;
|
|
12
|
+
fall: number;
|
|
13
|
+
life: number;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
export type AirView = {
|
|
17
|
+
tick: (at: THREE.Vector3, dt: number, name?: string) => void;
|
|
18
|
+
};
|
|
19
|
+
/** The air over `scene`: `tick` sends what drifts in the air named, if
|
|
20
|
+
* any, round `at`, and lets what drifts in any other it sent settle, so a
|
|
21
|
+
* focus moving between emitter kinds sees the one air give way to the
|
|
22
|
+
* other. */ export declare let airOf: (scene: THREE.Scene, airs: Readonly<Record<string, Air>>) => AirView;
|
|
23
|
+
//# sourceMappingURL=air.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"air.d.ts","sources":["../air.ts"],"names":[],"mappings":"AACA,wCAAwC;AACxC,YAAY,0BAA+B;AAG3C,YAAY;EACV,OAAO,MAAM;EACb,OAAO,OAAO;EACd,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,MAAM;;AAGd,YAAY;EACV,OAAO,IAAI,MAAM,SAAS,IAAI,MAAM,EAAE,OAAO,MAAM,KAAK,IAAI;;AAG9D;;;UAGU,GACV,OAAO,YAAI,QACT,OAAO,MAAM,OACb,MAAM,SAAS,OAAO,MAAM,EAAE,UAC7B,QAmCF"}
|
package/_dist/bus.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** One volume control and its audio-graph gain. */ export interface Bus {
|
|
2
|
+
readonly level: number;
|
|
3
|
+
set(value: number): void;
|
|
4
|
+
into(ctx: AudioContext, out: AudioNode): GainNode;
|
|
5
|
+
}
|
|
6
|
+
export declare let bus: (fallback: number, _dts_1: never) => Bus;
|
|
7
|
+
/** A relative level while a higher-priority channel is active. */ export declare let duckLevel: (active: boolean, level?: number) => number;
|
|
8
|
+
//# sourceMappingURL=bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bus.d.ts","sources":["../bus.ts"],"names":[],"mappings":"AAKA,iDAAiD,GACjD,iBAAiB;WACN,OAAO,MAAM;EACtB,IAAI,OAAO,MAAM,GAAG,IAAI;EACxB,KAAK,KAAK,cAAc,KAAK,YAAY;;AAG3C,OAAO,YAAI,MACT,UAAU,MAAM,EAChB,kBAIC,IA4BF;AAED,gEAAgE,GAChE,OAAO,YAAI,YAAa,QAAQ,OAAO,EAAE,mBAAe,MAAM,CAC1C"}
|
package/_dist/cam.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
export type CameraIntent = {
|
|
4
|
+
orbit: [number, number];
|
|
5
|
+
turn: number;
|
|
6
|
+
zoom: number;
|
|
7
|
+
look: boolean;
|
|
8
|
+
snap: boolean;
|
|
9
|
+
faceMove: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type Cam = {
|
|
12
|
+
/** which way it looks from, round the hero: 0 looks from +z */ yaw: number;
|
|
13
|
+
pitch: number;
|
|
14
|
+
/** how far back it stands, and how far it can stand this frame */ dist: number;
|
|
15
|
+
reach: number;
|
|
16
|
+
/** the point it follows, eased after the hero */ x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
z: number;
|
|
19
|
+
shake: number;
|
|
20
|
+
/** it is swinging round behind the hero */ snap: boolean;
|
|
21
|
+
/** a free look keeps movement relative to the hero until steering or snap */ orbiting: boolean;
|
|
22
|
+
/** the least it looks down, raised while the hero is in a building */ lift: number;
|
|
23
|
+
};
|
|
24
|
+
/** How near the camera comes to the hero, in metres, when the level is in
|
|
25
|
+
* the way. */ export declare let CLOSEST: number;
|
|
26
|
+
/** How near the camera sees, in metres: as far out as the hero's nearest side
|
|
27
|
+
* ever comes, at its closest, so the depth buffer is as fine as it can be
|
|
28
|
+
* Nearer surfaces are clipped by the camera. */ export declare let NEAR: number;
|
|
29
|
+
/** Fit `camera`'s depth to what it can see: from NEAR out to the far edge of
|
|
30
|
+
* the level's fog, past which nothing shows. */ export declare let depth: (camera: THREE.PerspectiveCamera, fog: THREE.Fog) => void;
|
|
31
|
+
/** Turn the camera for a frame: as the hands turned and pulled it, or round
|
|
32
|
+
* behind a hero facing `yaw` when asked. Holding the stick sideways cannot
|
|
33
|
+
* make the view spin.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { assertAlmostEquals, assertEquals } from '@std/assert'
|
|
37
|
+
* let hands = (move: [number, number], more = {}) => ({
|
|
38
|
+
* move, turn: 0, faceMove: false, jump: false, strike: false, ability: 0,
|
|
39
|
+
* dodge: false, talk: false, gather: false, drink: false, snap: false,
|
|
40
|
+
* mic: false,
|
|
41
|
+
* orbit: [0, 0] as [number, number], look: false, zoom: 0, ...more,
|
|
42
|
+
* })
|
|
43
|
+
* let cam = () => ({
|
|
44
|
+
* yaw: 0, pitch: 0.4, dist: 9, reach: 9, x: 0, y: 0, z: 0, shake: 0,
|
|
45
|
+
* snap: false, orbiting: false, lift: 0,
|
|
46
|
+
* })
|
|
47
|
+
* // A hero facing +x has the camera behind them at -x, which is yaw -π/2.
|
|
48
|
+
* let run = (c: ReturnType<typeof cam>, i: ReturnType<typeof hands>) => {
|
|
49
|
+
* for (let f = 0; f < 60; f++) steer(c, f ? { ...i, snap: false } : i, Math.PI / 2, 1 / 60)
|
|
50
|
+
* return c.yaw
|
|
51
|
+
* }
|
|
52
|
+
* assertAlmostEquals(run(cam(), hands([0, 0], { snap: true })), -Math.PI / 2, 1e-9)
|
|
53
|
+
* assertEquals(run(cam(), hands([1, 0])), 0)
|
|
54
|
+
* assertEquals(run(cam(), hands([1, 0], { faceMove: true })), 0)
|
|
55
|
+
* assertEquals(run(cam(), hands([0, 1], { look: true })), 0)
|
|
56
|
+
* let turned = cam()
|
|
57
|
+
* steer(turned, hands([0, 0], { turn: -6 }), Math.PI, 0.1)
|
|
58
|
+
* assertAlmostEquals(turned.yaw, 0.6)
|
|
59
|
+
* ```
|
|
60
|
+
*/ export declare let steer: (cam: Cam, i: CameraIntent, yaw: number, dt: number) => void;
|
|
61
|
+
/** Free orbit changes the view, not where the keys say forward is. A turning
|
|
62
|
+
* key changes both the camera and the hero's heading this frame. The stick
|
|
63
|
+
* keeps moving in screen space so its direction remains direct on touch. */ export declare let moveLook: <I extends CameraIntent>(cam: Cam, i: I, yaw: number, dt: number) => any;
|
|
64
|
+
/** Which way the camera looks, in whole degrees clockwise from north (-z).
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { assertEquals } from '@std/assert'
|
|
68
|
+
* assertEquals(bearing(0), 0) // from the south, looking north
|
|
69
|
+
* assertEquals(bearing(-Math.PI / 2), 90) // from the west, looking east
|
|
70
|
+
* assertEquals(bearing(Math.PI / 2 + 4 * Math.PI), 270)
|
|
71
|
+
* ```
|
|
72
|
+
*/ export declare let bearing: (yaw: number) => number;
|
|
73
|
+
/** Orbit around target, shortening the arm immediately when blocked and
|
|
74
|
+
* easing it back out. The caller supplies collision and the minimum pitch. */ export declare let aim: (cam: Cam, camera: THREE.Camera, target: THREE.Vector3, blocked: (point: THREE.Vector3) => boolean, dt: number, lift?: number) => void;
|
|
75
|
+
//# sourceMappingURL=cam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cam.d.ts","sources":["../cam.ts"],"names":[],"mappings":"AASA,wCAAwC;AACxC,YAAY,0BAA+B;AAC3C,YAAY;EACV,QAAQ,MAAM,EAAE,MAAM;EACtB,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,OAAO;EACb,MAAM,OAAO;EACb,UAAU,OAAO;;AAInB,YAAY;EACV,6DAA6D,GAC7D,KAAK,MAAM;EACX,OAAO,MAAM;EACb,gEAAgE,GAChE,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,+CAA+C,GAC/C,GAAG,MAAM;EACT,GAAG,MAAM;EACT,GAAG,MAAM;EACT,OAAO,MAAM;EACb,yCAAyC,GACzC,MAAM,OAAO;EACb,2EAA2E,GAC3E,UAAU,OAAO;EACjB,oEAAoE,GACpE,MAAM,MAAM;;AAGd;YACY,GACZ,OAAO,YAAI,gBAAa;AAExB;;8CAE8C,GAC9C,OAAO,YAAI,aAAU;AAErB;8CAC8C,GAC9C,OAAO,YAAI,QAAS,QAAQ,MAAM,mBAAmB,KAAK,MAAM,QAAM,IAAI,CAKzE;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,YAAI,QACT,KAAK,KACL,GAAG,cACH,KAAK,MAAM,EACX,IAAI,MAAM,KACT,IAAI,CAqBN;AAED;;0EAE0E,GAC1E,OAAO,YAAI,WAAY,UAAU,cAC/B,KAAK,KACL,GAAG,GACH,KAAK,MAAM,EACX,IAAI,MAAM,SAC4D;AAExE;;;;;;;;CAQC,GACD,OAAO,YAAI,UAAW,KAAK,MAAM,KAAG,MAAM,CACY;AAEtD;4EAC4E,GAC5E,OAAO,YAAI,MACT,KAAK,KACL,QAAQ,MAAM,QACd,QAAQ,MAAM,SACd,UAAU,OAAO,MAAM,YAAY,OAAO,EAC1C,IAAI,MAAM,EACV,kBACC,IAAI,CA6BN"}
|
package/_dist/ears.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import type * as THREE from "@types/three";
|
|
3
|
+
export type Vec3 = [number, number, number];
|
|
4
|
+
/** Where the ears are, which way they face, and which way is up for them:
|
|
5
|
+
* what Web Audio's `AudioListener` is told each frame. */ export type Ear = {
|
|
6
|
+
at: Vec3;
|
|
7
|
+
forward: Vec3;
|
|
8
|
+
up: Vec3;
|
|
9
|
+
};
|
|
10
|
+
/** How a source is heard: `pan` places it round the head and fades it with
|
|
11
|
+
* distance (Web Audio's PannerNode), and out to the panner's `refDistance` it
|
|
12
|
+
* is at `near` of its own loudness. */ export type Falloff = {
|
|
13
|
+
pan: PannerOptions;
|
|
14
|
+
near: number;
|
|
15
|
+
};
|
|
16
|
+
/** How positional sounds are heard. Inside 5 m they peak at 0.6;
|
|
17
|
+
* beyond 5 m this is the old 3 m inverse curve (3 / distance). */ export declare let FALLOFF: Falloff;
|
|
18
|
+
/** How water is heard: at its own loudness out to `refDistance`, but beyond
|
|
19
|
+
* that falling away with the square of the distance, so a lake is heard at
|
|
20
|
+
* its edge and gone some twenty metres off. */ export declare let NEAR: Falloff;
|
|
21
|
+
/** Below this loudness at the ears a sound is not made at all: a sound
|
|
22
|
+
* dies away within some 25 m, a louder sound carries further. */ export declare let QUIET: number;
|
|
23
|
+
/** The ears for a camera: at `at`, the listener, or where the camera stands when
|
|
24
|
+
* there is no target; turned the way the camera looks down its own -z, held
|
|
25
|
+
* level, so the ground about the listener is at the height of the ears. */ export declare let ear: (eye: THREE.Object3D, at?: Vec3) => Ear;
|
|
26
|
+
/** The source's normalized direction and distance-attenuated gain. */ export interface Hearing {
|
|
27
|
+
side: number;
|
|
28
|
+
ahead: number;
|
|
29
|
+
gain: number;
|
|
30
|
+
}
|
|
31
|
+
/** What the ears make of a sound at `at`: how far to their right it is, from
|
|
32
|
+
* -1 hard left to 1 hard right; how far ahead, from -1 behind to 1 before
|
|
33
|
+
* them; and how loud, as `FALLOFF` hears it: `near` at `refDistance` or
|
|
34
|
+
* nearer. Right is forward × up, as Web Audio has it.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { assert, assertAlmostEquals, assertEquals } from '@std/assert'
|
|
38
|
+
* import * as THREE from 'three'
|
|
39
|
+
* // The camera behind and above a listener at (20, 6, 20), looking down at them,
|
|
40
|
+
* // and the ears at the listener.
|
|
41
|
+
* let eye = new THREE.PerspectiveCamera()
|
|
42
|
+
* eye.position.set(26, 10, 28)
|
|
43
|
+
* eye.lookAt(20, 6, 20)
|
|
44
|
+
* let target = new THREE.Vector3(20, 6, 20)
|
|
45
|
+
* let e = ear(eye, [20, 6, 20])
|
|
46
|
+
* // The camera's right as it draws it, and the way it looks, level.
|
|
47
|
+
* let right = new THREE.Vector3(1, 0, 0).applyQuaternion(eye.quaternion)
|
|
48
|
+
* let ahead = new THREE.Vector3(-6, 0, -8).normalize()
|
|
49
|
+
* let from = (dir: THREE.Vector3, d: number) => {
|
|
50
|
+
* let p = target.clone().addScaledVector(dir, d)
|
|
51
|
+
* return hear(e, [p.x, p.y, p.z])
|
|
52
|
+
* }
|
|
53
|
+
* // A sound to the listener's right on the screen is heard on the right, and to
|
|
54
|
+
* // their left on the left, whichever way the camera is turned.
|
|
55
|
+
* assertAlmostEquals(from(right, 5).side, 1, 1e-9)
|
|
56
|
+
* assertAlmostEquals(from(right, -5).side, -1, 1e-9)
|
|
57
|
+
* // On along the camera's view is ahead of the listener; the camera is behind.
|
|
58
|
+
* assertAlmostEquals(from(ahead, 5).ahead, 1, 1e-9)
|
|
59
|
+
* assert(hear(e, [26, 10, 28]).ahead < -0.8)
|
|
60
|
+
* // Beside the listener a sound is as loud as it is up close; further off it
|
|
61
|
+
* // fades.
|
|
62
|
+
* assertEquals(from(right, 2).gain, FALLOFF.near)
|
|
63
|
+
* assert(from(right, 12).gain < from(right, 8).gain)
|
|
64
|
+
* assertAlmostEquals(from(right, 5).gain, 3 / 5, 1e-9)
|
|
65
|
+
* assertAlmostEquals(from(right, 8).gain, 3 / 8, 1e-9)
|
|
66
|
+
* assertAlmostEquals(from(ahead, 40).gain, 3 / 40, 1e-9)
|
|
67
|
+
* // With no target, the ears are where the camera is.
|
|
68
|
+
* assertEquals(ear(eye).at, [26, 10, 28])
|
|
69
|
+
* ```
|
|
70
|
+
*/ export declare let hear: (e: Ear, at: Vec3) => Hearing;
|
|
71
|
+
//# sourceMappingURL=ears.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ears.d.ts","sources":["../ears.ts"],"names":[],"mappings":"AAOA,wCAAwC;AACxC,iBAAiB,0BAA+B;AAChD,YAAY,QAAQ,MAAM,EAAE,MAAM,EAAE,MAAM;AAE1C;wDACwD,GACxD,YAAY;EAAQ,IAAI;EAAM,SAAS;EAAM,IAAI;;AAEjD;;qCAEqC,GACrC,YAAY;EAAY,KAAK;EAAe,MAAM,MAAM;;AAExD;gEACgE,GAChE,OAAO,YAAI,SAAS,QAQnB;AAED;;6CAE6C,GAC7C,OAAO,YAAI,MAAM,QAQhB;AAED;+DAC+D,GAC/D,OAAO,YAAI,cAAa;AAcxB;;yEAEyE,GACzE,OAAO,YAAI,MAAO,KAAK,MAAM,UAAU,KAAK,SAAO,IAQlD;AAED,oEAAoE,GACpE,iBAAiB;EACf,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,MAAM,MAAM;;AAGd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,YAAI,OAAQ,GAAG,KAAK,IAAI,SAAO,QASrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
export type Fire = {
|
|
4
|
+
at: [number, number, number];
|
|
5
|
+
size: number;
|
|
6
|
+
};
|
|
7
|
+
/** Hang a flame mesh in `scene`, sized as fires come into sight, and return
|
|
8
|
+
* its motion for each frame. */ export type Flames = (t: number, focus: THREE.Vector3, fires: Fire[]) => void;
|
|
9
|
+
export declare let flames: (scene: THREE.Scene) => Flames;
|
|
10
|
+
//# sourceMappingURL=flames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flames.d.ts","sources":["../flames.ts"],"names":[],"mappings":"AAEA,wCAAwC;AACxC,YAAY,0BAA+B;AAE3C,YAAY;EAAS,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM;EAAG,MAAM,MAAM;;AAE/D;8BAC8B,GAC9B,YAAY,UAAU,GAAG,MAAM,EAAE,OAAO,MAAM,SAAS,OAAO,WAAW,IAAI;AAE7E,OAAO,YAAI,SAAU,OAAO,MAAM,UAAQ,OAyDzC"}
|
package/_dist/fx.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
/** Emission values for a burst of particles. */ export type Emission = {
|
|
4
|
+
speed?: number;
|
|
5
|
+
up?: number;
|
|
6
|
+
life?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
fall?: number;
|
|
9
|
+
halo?: boolean;
|
|
10
|
+
flame?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type Bits = {
|
|
13
|
+
emit: (at: THREE.Vector3, color: THREE.ColorRepresentation, n: number, options?: Emission) => void;
|
|
14
|
+
tick: (dt: number, camera?: THREE.Camera) => void;
|
|
15
|
+
};
|
|
16
|
+
/** A pool of little cubes: `lit` ones are shaded like the world, the others
|
|
17
|
+
* glow. */ export declare let bits: (scene: THREE.Scene, lit: boolean, most?: number) => Bits;
|
|
18
|
+
/** Whether a box on the screen, `w` by `h` from its top left at `x`, `y`,
|
|
19
|
+
* lies under the glass, where the scene's labels do not show. */ export type Under = (x: number, y: number, w: number, h: number) => boolean;
|
|
20
|
+
export type Overlay = {
|
|
21
|
+
float: (text: string, p: THREE.Vector3, kind: string) => void;
|
|
22
|
+
plate: (key: string, p: THREE.Vector3, html: string, cls?: string) => void;
|
|
23
|
+
tick: () => void;
|
|
24
|
+
};
|
|
25
|
+
/** The labels over the scene: plates that follow someone, and numbers that
|
|
26
|
+
* float up and fade. A label that would be `under` the glass is not shown. */ export declare let overlay: (layer: HTMLElement, camera: THREE.Camera, under?: Under) => Overlay;
|
|
27
|
+
//# sourceMappingURL=fx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx.d.ts","sources":["../fx.ts"],"names":[],"mappings":"AAKA,wCAAwC;AACxC,YAAY,0BAA+B;AAe3C,8CAA8C,GAC9C,YAAY;EACV,QAAQ,MAAM;EACd,KAAK,MAAM;EACX,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,OAAO;EACd,QAAQ,OAAO;;AAGjB,YAAY;EACV,OACE,IAAI,MAAM,SACV,OAAO,MAAM,qBACb,GAAG,MAAM,EACT,UAAU,aACP,IAAI;EACT,OAAO,IAAI,MAAM,EAAE,SAAS,MAAM,WAAW,IAAI;;AAGnD;SACS,GACT,OAAO,YAAI,OAAQ,OAAO,MAAM,OAAO,KAAK,OAAO,EAAE,kBAAa,KAqKjE;AAED;+DAC+D,GAC/D,YAAY,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAK,OAAO;AAE3E,YAAY;EACV,QAAQ,MAAM,MAAM,EAAE,GAAG,MAAM,SAAS,MAAM,MAAM,KAAK,IAAI;EAC7D,QAAQ,KAAK,MAAM,EAAE,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,IAAI;EAC1E,YAAY,IAAI;;AAGlB;4EAC4E,GAC5E,OAAO,YAAI,UACT,OAAO,aACP,QAAQ,MAAM,QACd,QAAO,UACN,QAsGF"}
|
package/_dist/halo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halo.d.ts","sources":["../halo.ts"],"names":[],"mappings":"AACA,wCAAwC;AACxC,YAAY,0BAA+B;AAI3C,OAAO,YAAI,YAAW,MAAM,YAgB3B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
type Point = [number, number, number];
|
|
4
|
+
export type Place = {
|
|
5
|
+
kind: string;
|
|
6
|
+
seed: number;
|
|
7
|
+
turn: number;
|
|
8
|
+
at: Point;
|
|
9
|
+
};
|
|
10
|
+
export type Template = (kind: string, seed: number, turn: number, near: boolean) => Promise<THREE.BufferGeometry>;
|
|
11
|
+
/** A prepared placement set retains its geometry until released, even before drawing. */ export type Prepared = {
|
|
12
|
+
ready: Promise<void[]>;
|
|
13
|
+
draw: (key: string) => void;
|
|
14
|
+
release: () => void;
|
|
15
|
+
};
|
|
16
|
+
/** The repeated geometry currently held by chunks in a scene. */ export type Instances = {
|
|
17
|
+
prepare: (placed: Place[], near: boolean) => Prepared;
|
|
18
|
+
drop: (key: string) => void;
|
|
19
|
+
invalidate: (kinds: Set<string>) => void;
|
|
20
|
+
dispose: () => void;
|
|
21
|
+
};
|
|
22
|
+
/** Templates transfer geometry ownership to the cache, which disposes it when
|
|
23
|
+
* no prepared or drawn set retains it. Attribute and upload policy stay with callers. */ export declare let instances: (scene: THREE.Scene, material: THREE.Material, template: Template, modelKey: (kind: string, seed: number, turn: number, near: boolean) => string, family: (kind: string) => string) => Instances;
|
|
24
|
+
//# sourceMappingURL=instances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instances.d.ts","sources":["../instances.ts"],"names":[],"mappings":"AAGA,wCAAwC;AACxC,YAAY,0BAA+B;KAEtC,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM;AAEpC,YAAY;EAAU,MAAM,MAAM;EAAE,MAAM,MAAM;EAAE,MAAM,MAAM;EAAE,IAAI;;AACpE,YAAY,YACV,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,MAAM,OAAO,KACV,QAAQ,MAAM;AAEnB,uFAAuF,GACvF,YAAY;EACV,OAAO,QAAQ,IAAI;EACnB,OAAO,KAAK,MAAM,KAAK,IAAI;EAC3B,eAAe,IAAI;;AAGrB,+DAA+D,GAC/D,YAAY;EACV,UAAU,QAAQ,SAAS,MAAM,OAAO,KAAK;EAC7C,OAAO,KAAK,MAAM,KAAK,IAAI;EAC3B,aAAa,OAAO,IAAI,MAAM,MAAM,IAAI;EACxC,eAAe,IAAI;;AAYrB;uFACuF,GACvF,OAAO,YAAI,YACT,OAAO,MAAM,OACb,UAAU,MAAM,UAChB,UAAU,UACV,WAAW,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,KAAK,MAAM,EAC7E,SAAS,MAAM,MAAM,KAAK,MAAM,KAC/B,UAqHF"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Three.js presentation primitives. World and graph policy belong to callers. */ export { keepUp, quality, renderer } from "./render.js";
|
|
2
|
+
export { frameLoop, pace, pageLoop } from "./pace.js";
|
|
3
|
+
export { aim, bearing, depth, moveLook, steer } from "./cam.js";
|
|
4
|
+
export type { Cam, CameraIntent } from "./cam.js";
|
|
5
|
+
export { cursor, groundRay, landing, pickRay } from "./aim.js";
|
|
6
|
+
export type { Point } from "./aim.js";
|
|
7
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA,gFAAgF,GAChF,SAAS,MAAM,EAAE,OAAO,EAAE,QAAQ,sBAAqB;AACvD,SAAS,SAAS,EAAE,IAAI,EAAE,QAAQ,oBAAmB;AACrD,SAAS,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,mBAAkB;AAC/D,cAAc,GAAG,EAAE,YAAY,mBAAkB;AACjD,SAAS,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,mBAAkB;AAC9D,cAAc,KAAK,mBAAkB"}
|
package/_dist/pace.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Draw at most `rate` frames each second, without drifting behind the screen.
|
|
2
|
+
*
|
|
3
|
+
* ```ts
|
|
4
|
+
* import { assertEquals } from '@std/assert'
|
|
5
|
+
* let draw = pace()
|
|
6
|
+
* assertEquals([0, 8, 17, 25, 34].filter((t) => draw(t, 60)), [0, 17, 34])
|
|
7
|
+
* let slower = pace()
|
|
8
|
+
* assertEquals([0, 17, 34, 50, 67].filter((t) => slower(t, 30)), [0, 34, 67])
|
|
9
|
+
* ```
|
|
10
|
+
*/ export declare let pace: () => (now: number, rate: number) => boolean;
|
|
11
|
+
/** An animation callback with elapsed time and a bounded simulation step.
|
|
12
|
+
* Scheduling is handed in, so the page owns starting and stopping it. */ export declare let frameLoop: (frame: (now: number, dt: number, elapsed: number) => void, then: number, schedule?: (frame: FrameRequestCallback) => unknown) => FrameRequestCallback;
|
|
13
|
+
type Page = Pick<typeof globalThis, 'requestAnimationFrame' | 'cancelAnimationFrame' | 'addEventListener' | 'removeEventListener' | 'document' | 'performance'>;
|
|
14
|
+
/** Run `frame` through {@link frameLoop} while the page is shown. The loop
|
|
15
|
+
* rests while the page is hidden, so its first frame back is not timed as one
|
|
16
|
+
* long frame, and `dispose` runs once when the page is left for good (a
|
|
17
|
+
* `pagehide` not kept in the back/forward cache). Answers a function that
|
|
18
|
+
* stops the loop and disposes now. */ export declare let pageLoop: (frame: (now: number, dt: number, elapsed: number) => void, dispose: () => void, win?: Page) => () => void;
|
|
19
|
+
//# sourceMappingURL=pace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pace.d.ts","sources":["../pace.ts"],"names":[],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,YAAI,aAAY,KAAK,MAAM,EAAE,MAAM,MAAM,KAAK,OAAO,CAQ3D;AAED;uEACuE,GACvE,OAAO,YAAI,YACT,QAAQ,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,SAAS,MAAM,KAAK,IAAI,EACzD,MAAM,MAAM,EACZ,YAAW,OAAO,yBAAyB,OAAO,KACjD,qBAQF;KAEI,OAAO,YACH,YACL,0BACA,yBACA,qBACA,wBACA,aACA;AAGJ;;;;oCAIoC,GACpC,OAAO,YAAI,WACT,QAAQ,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,SAAS,MAAM,KAAK,IAAI,EACzD,eAAe,IAAI,EACnB,MAAK,eACE,IAAI,CA4BZ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @ts-types="npm:@types/three@^0.186.0"
|
|
2
|
+
import * as THREE from "@types/three";
|
|
3
|
+
/** The shared WebGL renderer. Sizing and density are values supplied by the page. */ export declare let renderer: (canvas: HTMLCanvasElement, width: number, height: number, density: number) => THREE.WebGLRenderer;
|
|
4
|
+
/** Lower quality once per slow sampling window; no game or loading policy. */ export declare let keepUp: (ease: (() => void)[], window?: number, rate?: number) => (spent: number) => void;
|
|
5
|
+
/** Ordered reductions keep simulation on the display clock before looks. */ export declare let quality: (renderer: THREE.WebGLRenderer, sun: THREE.DirectionalLight, scene: THREE.Scene, density: number) => (() => void)[];
|
|
6
|
+
export { frameLoop } from "./pace.js";
|
|
7
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sources":["../render.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,YAAY,0BAA+B;AAE3C,mFAAmF,GACnF,OAAO,YAAI,WACT,QAAQ,mBACR,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,SAAS,MAAM,KACd,MAAM,cAYR;AAED,4EAA4E,GAC5E,OAAO,YAAI,SACT,aAAa,IAAI,KACjB,iBACA,mBACE,OAAO,MAAM,KAAK,IAAI,CASzB;AAED,0EAA0E,GAC1E,OAAO,YAAI,UACT,UAAU,MAAM,eAChB,KAAK,MAAM,kBACX,OAAO,MAAM,OACb,SAAS,MAAM,YACP,IAAI,IAoBb;AAED,SAAS,SAAS,oBAAmB"}
|