@adatechnology/game-items-three 0.6.1 → 0.7.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/README.md +6 -0
- package/dist/chunk-WGFTVYO3.js +7999 -0
- package/dist/chunk-WGFTVYO3.js.map +1 -0
- package/dist/index.d.ts +41 -172
- package/dist/index.global.js +2909 -2556
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +85 -7919
- package/dist/index.js.map +1 -1
- package/dist/testing-CBYX7wTL.d.ts +196 -0
- package/dist/testing.d.ts +4 -0
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -0
- package/package.json +13 -9
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as THREE_NS from 'three';
|
|
2
|
+
import { Vec3, AreaPlacement, TestableModule } from '@adatechnology/game-contracts';
|
|
3
|
+
import { FindStack, ItemsCatalog, FindsProvider } from '@adatechnology/game-items';
|
|
4
|
+
|
|
5
|
+
type Three = typeof THREE_NS;
|
|
6
|
+
/** The material tags the team's showcase wears: what `setWear` turns toward its spoiled colour. */
|
|
7
|
+
declare const WEAR_TAGS: readonly ["metal", "wood", "cloth", "plastic", "paper", "food", "glass"];
|
|
8
|
+
type WearTag = (typeof WEAR_TAGS)[number];
|
|
9
|
+
/** What a material of the kit remembers so that `setWear` can go back to new: the colour it was made with (as three read it, and as sRGB floats), its tag and its roughness. */
|
|
10
|
+
interface ItemMaterialData {
|
|
11
|
+
base: THREE_NS.Color;
|
|
12
|
+
baseRgb: readonly [number, number, number];
|
|
13
|
+
tag: string;
|
|
14
|
+
rough: number;
|
|
15
|
+
}
|
|
16
|
+
type Vec3Tuple = readonly [number, number, number];
|
|
17
|
+
/**
|
|
18
|
+
* The helpers the showcase page defines before its models (`M`, `mesh`, `cyl`, `bx`, `lathe`, `torus`, `extrude`, `G` and the seven material makers), so that the
|
|
19
|
+
* builders ported from the page read the same as the originals. `T` is the three.js the kit was made with, with its box, cylinder, cone, sphere, plane, lathe, torus and
|
|
20
|
+
* (straight-edged) extrude geometries made by game-shapes (`shapeGeometries`: the same bytes, the same classes, a template cache); `materials` lists every material it made,
|
|
21
|
+
* in order.
|
|
22
|
+
*/
|
|
23
|
+
interface ItemKit {
|
|
24
|
+
readonly T: Three;
|
|
25
|
+
readonly materials: THREE_NS.MeshStandardMaterial[];
|
|
26
|
+
M(color: number, tag: string, options?: THREE_NS.MeshStandardMaterialParameters): THREE_NS.MeshStandardMaterial;
|
|
27
|
+
mesh(geometry: THREE_NS.BufferGeometry, material: THREE_NS.Material, position?: Vec3Tuple, rotation?: Vec3Tuple, scale?: Vec3Tuple): THREE_NS.Mesh;
|
|
28
|
+
cyl(radiusTop: number, radiusBottom: number, height: number, segments?: number): THREE_NS.CylinderGeometry;
|
|
29
|
+
bx(width: number, height: number, depth: number): THREE_NS.BoxGeometry;
|
|
30
|
+
lathe(points: ReadonlyArray<readonly [number, number]>, segments?: number): THREE_NS.LatheGeometry;
|
|
31
|
+
torus(radius: number, tube: number, arc?: number): THREE_NS.TorusGeometry;
|
|
32
|
+
extrude(points: ReadonlyArray<readonly [number, number]>, depth: number, bevel?: number): THREE_NS.ExtrudeGeometry;
|
|
33
|
+
G(...children: THREE_NS.Object3D[]): THREE_NS.Group;
|
|
34
|
+
metal(color: number): THREE_NS.MeshStandardMaterial;
|
|
35
|
+
wood(color: number): THREE_NS.MeshStandardMaterial;
|
|
36
|
+
cloth(color: number): THREE_NS.MeshStandardMaterial;
|
|
37
|
+
plastic(color: number): THREE_NS.MeshStandardMaterial;
|
|
38
|
+
paper(color: number): THREE_NS.MeshStandardMaterial;
|
|
39
|
+
food(color: number): THREE_NS.MeshStandardMaterial;
|
|
40
|
+
glass(color: number, opacity: number): THREE_NS.MeshStandardMaterial;
|
|
41
|
+
}
|
|
42
|
+
/** The helpers of the showcase page on a given three.js; every kit has its own list of materials. */
|
|
43
|
+
declare function createItemKit(three: Three): ItemKit;
|
|
44
|
+
|
|
45
|
+
/** One model of the showcase as `data/models.json` keeps it: the item it draws, the id the team gave it, the box it has in the units of the page and the scale to metres. */
|
|
46
|
+
interface ItemModelEntry {
|
|
47
|
+
/** Catalog id of the item (`canned_beans`). */
|
|
48
|
+
readonly id: string;
|
|
49
|
+
/** The id in the team's `MODELS` (`feijao_lata`). */
|
|
50
|
+
readonly teamId: string;
|
|
51
|
+
/** Box of the builder's group in the page's units (`Box3.setFromObject`), x y z. */
|
|
52
|
+
readonly teamBox: readonly [number, number, number];
|
|
53
|
+
/** Metres per unit of the page, from one real measure of the object. */
|
|
54
|
+
readonly scale: number;
|
|
55
|
+
}
|
|
56
|
+
/** A builder of the showcase, ported as it is: it draws in the page's units and returns the group. */
|
|
57
|
+
type ItemModelBuilder = (kit: ItemKit) => THREE_NS.Group;
|
|
58
|
+
/** The models of one registry: what `buildItem` reads through its `models` option. */
|
|
59
|
+
interface ItemModelRegistry {
|
|
60
|
+
has(id: string): boolean;
|
|
61
|
+
entry(id: string): ItemModelEntry | undefined;
|
|
62
|
+
builder(id: string): ItemModelBuilder | undefined;
|
|
63
|
+
/** The ids registered, in the order of registration (the order of the showcase for the ones the kit ships). */
|
|
64
|
+
list(): string[];
|
|
65
|
+
/** Adds (or replaces) the model of an item: `entry.id` is the catalog id the item's `model` field names. */
|
|
66
|
+
register(entry: ItemModelEntry, builder: ItemModelBuilder): void;
|
|
67
|
+
/** Takes a model out (a game that wants the simple shape instead). */
|
|
68
|
+
unregister(id: string): void;
|
|
69
|
+
}
|
|
70
|
+
/** The registry behind `registerItemModel`, `hasItemModel` and the rest of the global functions, created on first use. */
|
|
71
|
+
declare const defaultItemModels: () => ItemModelRegistry;
|
|
72
|
+
/**
|
|
73
|
+
* Adds (or replaces) the model of an item: `entry.id` is the catalog id the item's `model` field names.
|
|
74
|
+
* @deprecated use `createItemModels(...).register`.
|
|
75
|
+
*/
|
|
76
|
+
declare const registerItemModel: (entry: ItemModelEntry, builder: ItemModelBuilder) => void;
|
|
77
|
+
/** @deprecated use `createItemModels(...).unregister`. */
|
|
78
|
+
declare const unregisterItemModel: (id: string) => void;
|
|
79
|
+
/** @deprecated use `createItemModels(...).entry`. */
|
|
80
|
+
declare const itemModelEntry: (id: string) => ItemModelEntry | undefined;
|
|
81
|
+
/** @deprecated use `createItemModels(...).builder`. */
|
|
82
|
+
declare const itemModelBuilder: (id: string) => ItemModelBuilder | undefined;
|
|
83
|
+
/** @deprecated use `createItemModels(...).has`. */
|
|
84
|
+
declare const hasItemModel: (id: string) => boolean;
|
|
85
|
+
/** @deprecated use `createItemModels(...).list`. */
|
|
86
|
+
declare const listItemModels: () => string[];
|
|
87
|
+
|
|
88
|
+
/** What the layout needs of an item: its id, category and real size [width, height, depth] in metres. */
|
|
89
|
+
interface LayoutItem {
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly category: string;
|
|
92
|
+
readonly size: readonly [number, number, number];
|
|
93
|
+
}
|
|
94
|
+
/** Height of the top of a shelf, metres. */
|
|
95
|
+
declare const SHELF_HEIGHT = 0.9;
|
|
96
|
+
/** Longest row of items on a shelf, metres. */
|
|
97
|
+
declare const ROW_LIMIT = 5;
|
|
98
|
+
/** One shelf: a category's items laid out in rows at real size, the shelf's footprint and where its items sit on its top. */
|
|
99
|
+
interface ShelfPlan {
|
|
100
|
+
category: string;
|
|
101
|
+
/** Item id of the shelf in the module (`shelf_<category>`). */
|
|
102
|
+
id: string;
|
|
103
|
+
/** Footprint on the floor: length along x, depth along z. */
|
|
104
|
+
length: number;
|
|
105
|
+
depth: number;
|
|
106
|
+
position: Vec3;
|
|
107
|
+
/** Where each item sits, in world coordinates. */
|
|
108
|
+
items: AreaPlacement[];
|
|
109
|
+
}
|
|
110
|
+
declare const SHELF_PREFIX = "shelf_";
|
|
111
|
+
declare const ITEM_PREFIX = "item_";
|
|
112
|
+
declare const SHOWCASE_PREFIX = "showcase_";
|
|
113
|
+
/**
|
|
114
|
+
* The shelves of the area: one per category, in the order the categories come, with every item of the category side by side at real size, wrapped in rows of at most
|
|
115
|
+
* `ROW_LIMIT` metres. Shelves stand in a grid of four columns; an item that is longer than the row limit gets a row to itself. Pure: the same items always land in the same spots.
|
|
116
|
+
*/
|
|
117
|
+
declare function shelvesLayout(items: readonly LayoutItem[], categories: readonly string[]): ShelfPlan[];
|
|
118
|
+
|
|
119
|
+
interface ItemsTestModuleOptions {
|
|
120
|
+
/** The catalog to lay out (for example `createGoodsItems()` of `game-items-goods`). The module knows no content of its own. */
|
|
121
|
+
catalog: ItemsCatalog;
|
|
122
|
+
/** `en` or `pt-BR` (default). */
|
|
123
|
+
locale?: string;
|
|
124
|
+
/** Text of a key such as `item.canned_beans`, `place.house`, `category.food`, `container.fridge`, `recipe.stew` (the goods package has them in `goodsText`); without it the module falls back to the id. */
|
|
125
|
+
translate?: (key: string, locale: string) => string | undefined;
|
|
126
|
+
/** Seed of the finds roll (default 1). */
|
|
127
|
+
seed?: number;
|
|
128
|
+
/** Wear the items start with: `new` (default), `used` or `spoiled`. */
|
|
129
|
+
wear?: string;
|
|
130
|
+
/** The finds provider; default the one of `game-items` over `catalog`. A game gives its own (floorplan bindings, pools). */
|
|
131
|
+
provider?: FindsProvider;
|
|
132
|
+
/**
|
|
133
|
+
* Draws a person of the kit to judge the scale by (for example a survivor of `createPersonBuilder` of `game-characters-three`); the module brings it to 1.80 m. Without it
|
|
134
|
+
* the area shows the ruler alone.
|
|
135
|
+
*/
|
|
136
|
+
person?: (THREE: unknown) => THREE_NS.Object3D;
|
|
137
|
+
/** The models to show and draw with (`createItemModels(...)`); default the shared set behind `registerItemModel`. */
|
|
138
|
+
models?: ItemModelRegistry;
|
|
139
|
+
}
|
|
140
|
+
declare const SHOWCASE_STAND_ID = "stand_models";
|
|
141
|
+
declare const RULER_ID = "ruler_155";
|
|
142
|
+
declare const HUMAN_ID = "human_180";
|
|
143
|
+
declare const FINDS_TABLE_ID = "finds_table";
|
|
144
|
+
declare const RULER_HEIGHT = 1.55;
|
|
145
|
+
declare const HUMAN_HEIGHT = 1.8;
|
|
146
|
+
/** What the scenarios of the area ask of the module (and what a host or a test may read). */
|
|
147
|
+
interface ItemsAreaState {
|
|
148
|
+
readonly category: string;
|
|
149
|
+
readonly wear: string;
|
|
150
|
+
readonly ageDays: number;
|
|
151
|
+
readonly storage: string;
|
|
152
|
+
readonly powered: boolean;
|
|
153
|
+
readonly place: string;
|
|
154
|
+
readonly container: string;
|
|
155
|
+
readonly state: string;
|
|
156
|
+
readonly day: number;
|
|
157
|
+
readonly seed: number;
|
|
158
|
+
readonly recipe: string;
|
|
159
|
+
}
|
|
160
|
+
interface ItemsTestModule extends TestableModule {
|
|
161
|
+
/** Everything the module has put in the scene so far, with what was measured when it was drawn. */
|
|
162
|
+
placed(): ReadonlyArray<{
|
|
163
|
+
id: string;
|
|
164
|
+
itemId: string;
|
|
165
|
+
group: 'shelf' | 'showcase';
|
|
166
|
+
kind: 'model' | 'shape';
|
|
167
|
+
size: readonly [number, number, number];
|
|
168
|
+
root: THREE_NS.Object3D;
|
|
169
|
+
}>;
|
|
170
|
+
/** The stacks now on the finds table. */
|
|
171
|
+
finds(): readonly FindStack[];
|
|
172
|
+
/** The shelves of the layout. */
|
|
173
|
+
shelves(): readonly ShelfPlan[];
|
|
174
|
+
readonly state: ItemsAreaState;
|
|
175
|
+
/** The bench actions, callable without a host (what the buttons do). */
|
|
176
|
+
rollFinds(): readonly FindStack[];
|
|
177
|
+
craftSelected(): {
|
|
178
|
+
ok: boolean;
|
|
179
|
+
missing: readonly string[];
|
|
180
|
+
};
|
|
181
|
+
selectRecipe(id: string): void;
|
|
182
|
+
/** The box of a drawn object, metres [x, y, z] (needs the host's three.js namespace: null before the module is attached or an item built). */
|
|
183
|
+
measure(root: THREE_NS.Object3D): [number, number, number] | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The items test area as a `TestableModule` of @adatechnology/game-contracts: every item of a catalog on shelves by category at real size (the real model of the team where there is
|
|
187
|
+
* one, the simple shape of its category elsewhere), a stand where the 24 models turn, a ruler and a human figure to judge the scale, and a table where the finds of a container
|
|
188
|
+
* and the result of a recipe are laid. The bench sets wear, age and storage, the place, container, state, outbreak day and seed of the finds, and the recipe.
|
|
189
|
+
*/
|
|
190
|
+
declare function createItemsTestModule(options: ItemsTestModuleOptions): ItemsTestModule;
|
|
191
|
+
/** What the scenarios use of the context the test room passes (`ScenarioContext`). */
|
|
192
|
+
interface ScenarioLike {
|
|
193
|
+
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { unregisterItemModel as A, FINDS_TABLE_ID as F, HUMAN_HEIGHT as H, type ItemKit as I, type LayoutItem as L, ROW_LIMIT as R, SHELF_HEIGHT as S, type Vec3Tuple as V, WEAR_TAGS as W, type ItemModelRegistry as a, type ItemModelEntry as b, type ItemModelBuilder as c, HUMAN_ID as d, ITEM_PREFIX as e, type ItemMaterialData as f, type ItemsAreaState as g, type ItemsTestModule as h, type ItemsTestModuleOptions as i, RULER_HEIGHT as j, RULER_ID as k, SHELF_PREFIX as l, SHOWCASE_PREFIX as m, SHOWCASE_STAND_ID as n, type ScenarioLike as o, type ShelfPlan as p, type WearTag as q, createItemKit as r, createItemsTestModule as s, defaultItemModels as t, hasItemModel as u, itemModelBuilder as v, itemModelEntry as w, listItemModels as x, registerItemModel as y, shelvesLayout as z };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { F as FINDS_TABLE_ID, H as HUMAN_HEIGHT, d as HUMAN_ID, g as ItemsAreaState, h as ItemsTestModule, i as ItemsTestModuleOptions, j as RULER_HEIGHT, k as RULER_ID, n as SHOWCASE_STAND_ID, o as ScenarioLike, s as createItemsTestModule } from './testing-CBYX7wTL.js';
|
|
2
|
+
import 'three';
|
|
3
|
+
import '@adatechnology/game-contracts';
|
|
4
|
+
import '@adatechnology/game-items';
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FINDS_TABLE_ID,
|
|
3
|
+
HUMAN_HEIGHT,
|
|
4
|
+
HUMAN_ID,
|
|
5
|
+
RULER_HEIGHT,
|
|
6
|
+
RULER_ID,
|
|
7
|
+
SHOWCASE_STAND_ID,
|
|
8
|
+
createItemsTestModule
|
|
9
|
+
} from "./chunk-WGFTVYO3.js";
|
|
10
|
+
export {
|
|
11
|
+
FINDS_TABLE_ID,
|
|
12
|
+
HUMAN_HEIGHT,
|
|
13
|
+
HUMAN_ID,
|
|
14
|
+
RULER_HEIGHT,
|
|
15
|
+
RULER_ID,
|
|
16
|
+
SHOWCASE_STAND_ID,
|
|
17
|
+
createItemsTestModule
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adatechnology/game-items-three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "three.js presentation for @adatechnology/game-items: the 24 models of the Itens do Vale Cinzento showcase at real size, simple shapes at real size for every other item, wear (new, used, spoiled) on the materials, merge by material, LOD and the draw budgets of the team.",
|
|
6
6
|
"keywords": [
|
|
@@ -32,18 +32,22 @@
|
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js"
|
|
34
34
|
},
|
|
35
|
+
"./testing": {
|
|
36
|
+
"types": "./dist/testing.d.ts",
|
|
37
|
+
"import": "./dist/testing.js"
|
|
38
|
+
},
|
|
35
39
|
"./global": "./dist/index.global.js"
|
|
36
40
|
},
|
|
37
41
|
"files": [
|
|
38
42
|
"dist"
|
|
39
43
|
],
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@adatechnology/game-contracts": "^0.
|
|
42
|
-
"@adatechnology/game-floorplan-three": "^0.
|
|
43
|
-
"@adatechnology/game-fluids": "^0.4.
|
|
44
|
-
"@adatechnology/game-interactables": "^0.2.
|
|
45
|
-
"@adatechnology/game-items": "^0.2.
|
|
46
|
-
"@adatechnology/game-shapes-three": "^0.
|
|
45
|
+
"@adatechnology/game-contracts": "^0.22.0",
|
|
46
|
+
"@adatechnology/game-floorplan-three": "^0.9.0",
|
|
47
|
+
"@adatechnology/game-fluids": "^0.4.2",
|
|
48
|
+
"@adatechnology/game-interactables": "^0.2.14",
|
|
49
|
+
"@adatechnology/game-items": "^0.2.2",
|
|
50
|
+
"@adatechnology/game-shapes-three": "^0.3.0"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
49
53
|
"three": "^0.160.0"
|
|
@@ -56,8 +60,8 @@
|
|
|
56
60
|
"tsup": "^8.5.1",
|
|
57
61
|
"typescript": "^5.7.3",
|
|
58
62
|
"vitest": "^3.2.4",
|
|
59
|
-
"@adatechnology/game-items-goods": "^0.3.
|
|
60
|
-
"@adatechnology/game-test-room": "^0.
|
|
63
|
+
"@adatechnology/game-items-goods": "^0.3.2",
|
|
64
|
+
"@adatechnology/game-test-room": "^0.21.0",
|
|
61
65
|
"@adatechnology/golden-tool": "^0.0.0"
|
|
62
66
|
},
|
|
63
67
|
"scripts": {
|