@aethervtt/shard-scenes 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/parity.d.ts +40 -0
- package/dist/parity.js +356 -0
- package/package.json +41 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Patrick Dias
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aethervtt/shard-scenes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Part of [Shard](https://github.com/aethervtt/shard), a WebGPU-first 2D/3D game engine in TypeScript. See the repository for documentation.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PARITY_LAYERS, PARITY_TILES, type ParityAngle, type ParityOptions, type ParityScene, type ParityView, parityPlugins, poseParityCamera, showParityView, spawnParity, } from './parity.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PARITY_LAYERS,
|
|
3
|
+
PARITY_TILES,
|
|
4
|
+
parityPlugins,
|
|
5
|
+
poseParityCamera,
|
|
6
|
+
showParityView,
|
|
7
|
+
spawnParity
|
|
8
|
+
} from "./parity.js";
|
|
9
|
+
export {
|
|
10
|
+
PARITY_LAYERS,
|
|
11
|
+
PARITY_TILES,
|
|
12
|
+
parityPlugins,
|
|
13
|
+
poseParityCamera,
|
|
14
|
+
showParityView,
|
|
15
|
+
spawnParity
|
|
16
|
+
};
|
package/dist/parity.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AssetRef, type Entity, type Owner, type World } from '@aethervtt/shard-core';
|
|
2
|
+
import type { Plugin } from '@aethervtt/shard-runtime';
|
|
3
|
+
/** Render layers: 1 is shared; each view adds its own visuals' layer. */
|
|
4
|
+
export declare const PARITY_LAYERS: {
|
|
5
|
+
readonly shared: 1;
|
|
6
|
+
readonly map: 2;
|
|
7
|
+
readonly tabletop: 4;
|
|
8
|
+
};
|
|
9
|
+
/** What the fixture adds beyond the renderer (`renderPlugin`, `forwardPlugin`, `TransformPlugin`). */
|
|
10
|
+
export declare function parityPlugins(): Plugin[];
|
|
11
|
+
/**
|
|
12
|
+
* The tile map (0059), one row per line: its first row lies beyond the north wall, and the cells
|
|
13
|
+
* the tests probe are stone. Its top-left corner is at world (x −2, z −9.5); tiles are 1 m.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PARITY_TILES: {
|
|
16
|
+
origin: readonly [-2, -9.5];
|
|
17
|
+
rows: string[];
|
|
18
|
+
};
|
|
19
|
+
export interface ParityScene {
|
|
20
|
+
/** The orthographic Map camera: shared layer plus flat token discs. */
|
|
21
|
+
map: Entity;
|
|
22
|
+
/** The perspective Tabletop camera: shared layer plus standees. */
|
|
23
|
+
tabletop: Entity;
|
|
24
|
+
/** Token roots, each with a disc (Map) and a standee (Tabletop). */
|
|
25
|
+
tokens: Entity[];
|
|
26
|
+
}
|
|
27
|
+
export type ParityView = 'map' | 'tabletop';
|
|
28
|
+
export type ParityAngle = 'top' | 30 | 55;
|
|
29
|
+
export interface ParityOptions {
|
|
30
|
+
/** Where the cameras render. Omit for the window (a canvas). */
|
|
31
|
+
target?: AssetRef<'RenderTarget'>;
|
|
32
|
+
/** Who owns everything spawned (0061): releasing it removes the whole table. */
|
|
33
|
+
owner?: Owner;
|
|
34
|
+
}
|
|
35
|
+
/** Spawns the fixture into `world`. Both cameras start inactive: `showParityView` picks one. */
|
|
36
|
+
export declare function spawnParity(world: World, options?: ParityOptions): ParityScene;
|
|
37
|
+
/** Makes one view's camera the active one. */
|
|
38
|
+
export declare function showParityView(world: World, scene: ParityScene, view: ParityView): void;
|
|
39
|
+
/** Points a view's camera at the table's center from `angle` degrees above it (or straight down). */
|
|
40
|
+
export declare function poseParityCamera(world: World, scene: ParityScene, view: ParityView, angle: ParityAngle): void;
|
package/dist/parity.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChildOf
|
|
3
|
+
} from "@aethervtt/shard-core";
|
|
4
|
+
import { FogLayer, FogRegionsStore, fogPlugin } from "@aethervtt/shard-fog";
|
|
5
|
+
import { Grid, gridPlugin } from "@aethervtt/shard-grid";
|
|
6
|
+
import { box, cylinder } from "@aethervtt/shard-mesh";
|
|
7
|
+
import {
|
|
8
|
+
AmbientLight,
|
|
9
|
+
Camera3d,
|
|
10
|
+
DirectionalLight,
|
|
11
|
+
Exposure,
|
|
12
|
+
GroundLayer,
|
|
13
|
+
MaterialAsset,
|
|
14
|
+
Materials,
|
|
15
|
+
Mesh3d,
|
|
16
|
+
Meshes,
|
|
17
|
+
MeshMaterial,
|
|
18
|
+
NotShadowCaster,
|
|
19
|
+
PointLight,
|
|
20
|
+
RenderLayers,
|
|
21
|
+
Tonemapping
|
|
22
|
+
} from "@aethervtt/shard-render";
|
|
23
|
+
import {
|
|
24
|
+
spritePlugin,
|
|
25
|
+
TextureAtlas,
|
|
26
|
+
TextureAtlases,
|
|
27
|
+
Tilemap,
|
|
28
|
+
TilemapData,
|
|
29
|
+
TilemapDatas,
|
|
30
|
+
tilemapOnGround
|
|
31
|
+
} from "@aethervtt/shard-sprite";
|
|
32
|
+
import { Floor, Opening, structurePlugin, Wall } from "@aethervtt/shard-structure";
|
|
33
|
+
import { Texture, Textures } from "@aethervtt/shard-texture";
|
|
34
|
+
import { lookAt, Transform } from "@aethervtt/shard-transform";
|
|
35
|
+
import { VectorShape, vectorPlugin } from "@aethervtt/shard-vector";
|
|
36
|
+
const PARITY_LAYERS = { shared: 1, map: 2, tabletop: 4 };
|
|
37
|
+
function parityPlugins() {
|
|
38
|
+
return [structurePlugin, gridPlugin, vectorPlugin, fogPlugin, spritePlugin];
|
|
39
|
+
}
|
|
40
|
+
const PARITY_TILES = {
|
|
41
|
+
origin: [-2, -9.5],
|
|
42
|
+
rows: [
|
|
43
|
+
"moss moss dirt moss moss moss dirt moss moss",
|
|
44
|
+
"stone stone stone stone crack stone stone stone stone",
|
|
45
|
+
"stone moss stone stone stone stone stone stone dirt",
|
|
46
|
+
"stone stone crack stone stone moss stone stone stone",
|
|
47
|
+
"dirt stone stone stone stone stone stone crack stone",
|
|
48
|
+
"stone stone stone moss stone stone dirt stone stone",
|
|
49
|
+
"stone crack stone stone stone stone stone stone moss",
|
|
50
|
+
"stone stone stone stone dirt stone stone stone stone"
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
function tileAtlas(world) {
|
|
54
|
+
const names = ["stone", "crack", "moss", "dirt"];
|
|
55
|
+
const base = [
|
|
56
|
+
[150, 144, 132],
|
|
57
|
+
[150, 144, 132],
|
|
58
|
+
[78, 112, 60],
|
|
59
|
+
[124, 94, 66]
|
|
60
|
+
];
|
|
61
|
+
const pixels = new Uint8Array(32 * 8 * 4);
|
|
62
|
+
for (let r = 0; r < 4; r++)
|
|
63
|
+
for (let y = 0; y < 8; y++)
|
|
64
|
+
for (let x = 0; x < 8; x++) {
|
|
65
|
+
const n = (x * 73 + y * 151 + r * 37) % 17 - 8;
|
|
66
|
+
const edge = x === 0 || y === 0 ? 0.7 : 1;
|
|
67
|
+
const crack = r === 1 && (x === y || x === y + 1) ? 0.55 : 1;
|
|
68
|
+
const [cr, cg, cb] = base[r];
|
|
69
|
+
const f = edge * crack;
|
|
70
|
+
pixels.set(
|
|
71
|
+
[
|
|
72
|
+
Math.max(0, Math.min(255, cr * f + n)),
|
|
73
|
+
Math.max(0, Math.min(255, cg * f + n)),
|
|
74
|
+
Math.max(0, Math.min(255, cb * f + n)),
|
|
75
|
+
255
|
|
76
|
+
],
|
|
77
|
+
(y * 32 + r * 8 + x) * 4
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const texture = world.resource(Textures).add(Texture.create({ width: 32, height: 8, mips: [pixels] }));
|
|
81
|
+
return world.resource(TextureAtlases).add(
|
|
82
|
+
new TextureAtlas(
|
|
83
|
+
texture,
|
|
84
|
+
names.map((name, i) => ({ name, rect: [i * 8, 0, 8, 8] }))
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function spawnParity(world, options = {}) {
|
|
89
|
+
const owner = options.owner;
|
|
90
|
+
const plain = world.spawn.bind(world);
|
|
91
|
+
const spawn = (...inits) => owner ? world.owners.spawn(owner, ...inits) : plain(...inits);
|
|
92
|
+
const meshes = world.resource(Meshes);
|
|
93
|
+
const materials = world.resource(Materials);
|
|
94
|
+
const mat = (baseColor, roughness = 0.8) => materials.add(new MaterialAsset({ baseColor, roughness }));
|
|
95
|
+
world.resource(AmbientLight).brightness = 1500;
|
|
96
|
+
spawn(
|
|
97
|
+
[DirectionalLight, { illuminance: 2e4, shadows: true, shadowUpdate: "on-change" }],
|
|
98
|
+
[Transform, { rotation: lookAt([-4, 10, 3], [0, 0, 0]) }]
|
|
99
|
+
);
|
|
100
|
+
spawn([
|
|
101
|
+
Floor,
|
|
102
|
+
{
|
|
103
|
+
points: [
|
|
104
|
+
[-10, -8],
|
|
105
|
+
[10, -8],
|
|
106
|
+
[10, 8],
|
|
107
|
+
[-10, 8]
|
|
108
|
+
],
|
|
109
|
+
material: mat([0.22, 0.21, 0.2, 1])
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
|
+
const stone = mat([0.7, 0.68, 0.64, 1]);
|
|
113
|
+
const walls = [
|
|
114
|
+
[
|
|
115
|
+
[-10, -8],
|
|
116
|
+
[10, -8]
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
[10, -8],
|
|
120
|
+
[10, 8]
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
[-10, 8],
|
|
124
|
+
[-10, -8]
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
[-3, -8],
|
|
128
|
+
[-3, 2]
|
|
129
|
+
]
|
|
130
|
+
];
|
|
131
|
+
const wallEntities = walls.map(
|
|
132
|
+
([a, b]) => spawn([Wall, { a: [...a], b: [...b], height: 2.5, thickness: 0.25, material: stone }])
|
|
133
|
+
);
|
|
134
|
+
spawn([Opening, { wall: wallEntities[3], kind: "door", offset: 5, width: 1.2, state: "open" }]);
|
|
135
|
+
spawn([
|
|
136
|
+
Opening,
|
|
137
|
+
{ wall: wallEntities[1], kind: "window", offset: 6, width: 2, sill: 1, height: 1 }
|
|
138
|
+
]);
|
|
139
|
+
const data = TilemapData.create(9, PARITY_TILES.rows.length, ["floor"], []);
|
|
140
|
+
PARITY_TILES.rows.forEach((row, y) => {
|
|
141
|
+
row.split(" ").forEach((name, x) => {
|
|
142
|
+
data.layers[0].set(x, y, data.tileId(name));
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
const ground = tilemapOnGround();
|
|
146
|
+
spawn(
|
|
147
|
+
[
|
|
148
|
+
Tilemap,
|
|
149
|
+
{
|
|
150
|
+
atlas: tileAtlas(world),
|
|
151
|
+
data: world.resource(TilemapDatas).add(data),
|
|
152
|
+
lit: "3d"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
[GroundLayer, { band: 10 }],
|
|
156
|
+
[
|
|
157
|
+
Transform,
|
|
158
|
+
{
|
|
159
|
+
translation: [PARITY_TILES.origin[0], 0, PARITY_TILES.origin[1]],
|
|
160
|
+
rotation: ground.rotation
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
);
|
|
164
|
+
spawn(
|
|
165
|
+
[
|
|
166
|
+
PointLight,
|
|
167
|
+
{
|
|
168
|
+
color: [1, 0.8, 0.55, 1],
|
|
169
|
+
intensity: 6e5,
|
|
170
|
+
range: 3.5,
|
|
171
|
+
bright: 1.5,
|
|
172
|
+
falloff: "tabletop"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
[Transform, { translation: [5.5, 1.2, -7] }]
|
|
176
|
+
);
|
|
177
|
+
spawn(
|
|
178
|
+
[Grid, { size: 1.5, color: [1, 1, 1, 1], opacity: 0.35, lineWidth: 1, extent: [20, 16] }],
|
|
179
|
+
Transform
|
|
180
|
+
);
|
|
181
|
+
spawn(
|
|
182
|
+
[
|
|
183
|
+
VectorShape,
|
|
184
|
+
{
|
|
185
|
+
geometry: {
|
|
186
|
+
kind: "polygon",
|
|
187
|
+
outer: [
|
|
188
|
+
[0, 0],
|
|
189
|
+
[4, 0],
|
|
190
|
+
[5, 3],
|
|
191
|
+
[1, 4]
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
fill: [0.1, 0.3, 1, 1],
|
|
195
|
+
fillOpacity: 0.7,
|
|
196
|
+
stroke: [0.1, 0.3, 1, 1],
|
|
197
|
+
strokeWidth: 2,
|
|
198
|
+
strokeUnits: "css-px"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
[Transform, { translation: [2, 0, -6] }]
|
|
202
|
+
);
|
|
203
|
+
const pen = [];
|
|
204
|
+
for (let i = 0; i <= 40; i++) pen.push([i * 0.25, Math.sin(i * 0.4) * 1.2]);
|
|
205
|
+
spawn(
|
|
206
|
+
[
|
|
207
|
+
VectorShape,
|
|
208
|
+
{
|
|
209
|
+
geometry: { kind: "pen", points: pen },
|
|
210
|
+
stroke: [1, 0.15, 0.1, 1],
|
|
211
|
+
strokeWidth: 3,
|
|
212
|
+
strokeUnits: "css-px"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
[Transform, { translation: [-1, 0, 3] }]
|
|
216
|
+
);
|
|
217
|
+
spawn(
|
|
218
|
+
[
|
|
219
|
+
VectorShape,
|
|
220
|
+
{
|
|
221
|
+
geometry: { kind: "ellipse", rx: 2, ry: 1.2 },
|
|
222
|
+
stroke: [1, 0.9, 0.1, 1],
|
|
223
|
+
strokeWidth: 0.12
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
[Transform, { translation: [6, 0, 3] }]
|
|
227
|
+
);
|
|
228
|
+
const disc = meshes.add(cylinder({ radius: 0.5, height: 0.02 }));
|
|
229
|
+
const standee = meshes.add(box({ x: 0.15, y: 1.6, z: 0.9 }));
|
|
230
|
+
const tokenMat = mat([0.9, 0.35, 0.1, 1], 0.5);
|
|
231
|
+
const tokens = [];
|
|
232
|
+
for (const [x, z] of [
|
|
233
|
+
[3.5, -4.5],
|
|
234
|
+
[-1.5, 3],
|
|
235
|
+
[6, 2],
|
|
236
|
+
[-6, -2]
|
|
237
|
+
]) {
|
|
238
|
+
const root = spawn([Transform, { translation: [x, 0, z] }]);
|
|
239
|
+
spawn(
|
|
240
|
+
[Mesh3d, { mesh: disc }],
|
|
241
|
+
[MeshMaterial, { material: tokenMat }],
|
|
242
|
+
[RenderLayers, { mask: PARITY_LAYERS.map }],
|
|
243
|
+
[GroundLayer, { band: 40 }],
|
|
244
|
+
NotShadowCaster,
|
|
245
|
+
Transform,
|
|
246
|
+
[ChildOf, { parent: root }]
|
|
247
|
+
);
|
|
248
|
+
spawn(
|
|
249
|
+
[Mesh3d, { mesh: standee }],
|
|
250
|
+
[MeshMaterial, { material: tokenMat }],
|
|
251
|
+
[RenderLayers, { mask: PARITY_LAYERS.tabletop }],
|
|
252
|
+
[Transform, { translation: [0, 0.8, 0] }],
|
|
253
|
+
[ChildOf, { parent: root }]
|
|
254
|
+
);
|
|
255
|
+
tokens.push(root);
|
|
256
|
+
}
|
|
257
|
+
const fog = world.resource(FogRegionsStore).add({
|
|
258
|
+
rev: 1,
|
|
259
|
+
regions: [
|
|
260
|
+
{
|
|
261
|
+
op: "hide",
|
|
262
|
+
strength: 0.75,
|
|
263
|
+
feather: 0.3,
|
|
264
|
+
shape: {
|
|
265
|
+
kind: "polygon",
|
|
266
|
+
outer: [
|
|
267
|
+
[5.5, -3],
|
|
268
|
+
[9.5, -3],
|
|
269
|
+
[9.5, 3],
|
|
270
|
+
[5.5, 3]
|
|
271
|
+
],
|
|
272
|
+
holes: [
|
|
273
|
+
[
|
|
274
|
+
[6.5, -1],
|
|
275
|
+
[8.5, -1],
|
|
276
|
+
[8.5, 1],
|
|
277
|
+
[6.5, 1]
|
|
278
|
+
]
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
op: "hide",
|
|
284
|
+
strength: 0.75,
|
|
285
|
+
feather: 0.3,
|
|
286
|
+
shape: { kind: "rect", x: 7.5, y: 5.5, w: 2.2, h: 2 }
|
|
287
|
+
},
|
|
288
|
+
// Over the tiles' west end.
|
|
289
|
+
{
|
|
290
|
+
op: "hide",
|
|
291
|
+
strength: 0.75,
|
|
292
|
+
feather: 0.3,
|
|
293
|
+
shape: { kind: "rect", x: -2, y: -8, w: 2, h: 1.8 }
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
spawn([
|
|
298
|
+
FogLayer,
|
|
299
|
+
{ base: "revealed", extent: { min: [-10, -8], max: [10, 8] }, texelSize: 0.05, regions: fog }
|
|
300
|
+
]);
|
|
301
|
+
const propMat = mat([0.3, 0.5, 0.35, 1]);
|
|
302
|
+
for (const [x, z, s] of [
|
|
303
|
+
[-7, -5, 1],
|
|
304
|
+
[-6, 5, 0.8],
|
|
305
|
+
[8.5, 6.5, 1.2]
|
|
306
|
+
])
|
|
307
|
+
spawn(
|
|
308
|
+
[Mesh3d, { mesh: meshes.add(box({ x: s, y: s, z: s })) }],
|
|
309
|
+
[MeshMaterial, { material: propMat }],
|
|
310
|
+
[Transform, { translation: [x, s / 2, z] }]
|
|
311
|
+
);
|
|
312
|
+
spawn(
|
|
313
|
+
[Mesh3d, { mesh: meshes.add(cylinder({ radius: 0.3, height: 2.5 })) }],
|
|
314
|
+
[MeshMaterial, { material: propMat }],
|
|
315
|
+
[Transform, { translation: [1, 1.25, -6.6] }]
|
|
316
|
+
);
|
|
317
|
+
const camera = (layers, orthographic) => spawn(
|
|
318
|
+
[
|
|
319
|
+
Camera3d,
|
|
320
|
+
{
|
|
321
|
+
...options.target ? { target: options.target } : {},
|
|
322
|
+
fovY: 45,
|
|
323
|
+
layers,
|
|
324
|
+
active: false,
|
|
325
|
+
clearColor: [0.02, 0.02, 0.03, 1],
|
|
326
|
+
...orthographic ? { projection: "orthographic", orthoHeight: 18, far: 200 } : {}
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
[Exposure, { ev100: 12.5 }],
|
|
330
|
+
[Tonemapping, { dither: false }],
|
|
331
|
+
Transform
|
|
332
|
+
);
|
|
333
|
+
const map = camera(PARITY_LAYERS.shared | PARITY_LAYERS.map, true);
|
|
334
|
+
const tabletop = camera(PARITY_LAYERS.shared | PARITY_LAYERS.tabletop, false);
|
|
335
|
+
return { map, tabletop, tokens };
|
|
336
|
+
}
|
|
337
|
+
function showParityView(world, scene, view) {
|
|
338
|
+
world.set(scene.map, Camera3d, { active: view === "map" });
|
|
339
|
+
world.set(scene.tabletop, Camera3d, { active: view === "tabletop" });
|
|
340
|
+
}
|
|
341
|
+
function poseParityCamera(world, scene, view, angle) {
|
|
342
|
+
const cam = view === "map" ? scene.map : scene.tabletop;
|
|
343
|
+
const distance = view === "map" ? 30 : 22;
|
|
344
|
+
const pitch = angle === "top" ? 89.99 : angle;
|
|
345
|
+
const a = pitch * Math.PI / 180;
|
|
346
|
+
const eye = [0, Math.sin(a) * distance, Math.cos(a) * distance];
|
|
347
|
+
world.set(cam, Transform, { translation: eye, rotation: lookAt(eye, [0, 0, 0]) });
|
|
348
|
+
}
|
|
349
|
+
export {
|
|
350
|
+
PARITY_LAYERS,
|
|
351
|
+
PARITY_TILES,
|
|
352
|
+
parityPlugins,
|
|
353
|
+
poseParityCamera,
|
|
354
|
+
showParityView,
|
|
355
|
+
spawnParity
|
|
356
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aethervtt/shard-scenes",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@aethervtt/shard-core": "0.1.0",
|
|
20
|
+
"@aethervtt/shard-fog": "0.1.0",
|
|
21
|
+
"@aethervtt/shard-grid": "0.1.0",
|
|
22
|
+
"@aethervtt/shard-mesh": "0.1.0",
|
|
23
|
+
"@aethervtt/shard-render": "0.1.0",
|
|
24
|
+
"@aethervtt/shard-runtime": "0.1.0",
|
|
25
|
+
"@aethervtt/shard-sprite": "0.1.0",
|
|
26
|
+
"@aethervtt/shard-structure": "0.1.0",
|
|
27
|
+
"@aethervtt/shard-texture": "0.1.0",
|
|
28
|
+
"@aethervtt/shard-transform": "0.1.0",
|
|
29
|
+
"@aethervtt/shard-vector": "0.1.0"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/aethervtt/shard.git",
|
|
34
|
+
"directory": "packages/scenes"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"provenance": true
|
|
39
|
+
},
|
|
40
|
+
"shard": {
|
|
41
|
+
"buildSha": "8e14c9896f82a3554b156f1ffdd68f2cc3e7d78a"
|
|
42
|
+
}
|
|
43
|
+
}
|