@adatechnology/game-items-three 0.1.6 → 0.2.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/dist/index.d.ts +82 -2
- package/dist/index.global.js +6616 -89
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6004 -89
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE_NS from 'three';
|
|
2
|
-
import { Thumbnail, Vec3, AreaPlacement, TestableModule } from '@adatechnology/game-contracts';
|
|
2
|
+
import { ContainerSpec, Thumbnail, Vec3, AreaPlacement, TestableModule } from '@adatechnology/game-contracts';
|
|
3
3
|
import { FindStack, ItemsCatalog, FindsProvider } from '@adatechnology/game-items';
|
|
4
4
|
|
|
5
5
|
type Three = typeof THREE_NS;
|
|
@@ -103,6 +103,8 @@ interface DrawableItem extends ShapeSubject {
|
|
|
103
103
|
size: Vec3Tuple;
|
|
104
104
|
/** Key of a showcase model; without one (or when the model is not registered) the simple shape is drawn. */
|
|
105
105
|
model?: string;
|
|
106
|
+
/** Real weight in kg; with `destructible` it becomes the mass of the destruction body. */
|
|
107
|
+
weight?: number;
|
|
106
108
|
}
|
|
107
109
|
interface BuildItemOptions {
|
|
108
110
|
/** Wear of the materials, 0 new (default), 1 used, 2 spoiled. */
|
|
@@ -111,6 +113,8 @@ interface BuildItemOptions {
|
|
|
111
113
|
simple?: boolean;
|
|
112
114
|
/** Level of detail of the simple shape, 1 (default) or 0.5 for half the segments. */
|
|
113
115
|
detail?: number;
|
|
116
|
+
/** Write the `userData` that `game-destruction-three`'s `specFromObject3D` reads (material of each mesh, hollow shells, welded parts, skins; see `tagForDestruction`). Default off. */
|
|
117
|
+
destructible?: boolean;
|
|
114
118
|
/** A kit to draw with (and to collect the materials in); default a new one. */
|
|
115
119
|
kit?: ItemKit;
|
|
116
120
|
}
|
|
@@ -133,6 +137,82 @@ interface ItemModel {
|
|
|
133
137
|
*/
|
|
134
138
|
declare function buildItem(T: typeof THREE_NS, item: DrawableItem, options?: BuildItemOptions): ItemModel;
|
|
135
139
|
|
|
140
|
+
/** The destruction material (`game-destruction` id) of each material tag of the kit, for a mesh whose model says nothing else. */
|
|
141
|
+
declare const DESTRUCTION_MATERIAL_BY_TAG: Readonly<Record<string, string>>;
|
|
142
|
+
/** How a model behaves under `game-destruction-three`'s `specFromObject3D`, as `data/destruction.json` keeps it. */
|
|
143
|
+
interface ItemDestruction {
|
|
144
|
+
/** The meshes are thin shells, not solid blocks. */
|
|
145
|
+
readonly hollow?: boolean;
|
|
146
|
+
/** The parts of the model are welded to its largest mesh, so a hit dents and holes them instead of tearing them off. */
|
|
147
|
+
readonly welded?: boolean;
|
|
148
|
+
/** Meshes made of these material tags are skins (labels, coats): drawn on a part, never a part of their own. */
|
|
149
|
+
readonly skinTags?: readonly string[];
|
|
150
|
+
/** Material tag to destruction material id, over `DESTRUCTION_MATERIAL_BY_TAG`. */
|
|
151
|
+
readonly materials?: Readonly<Record<string, string>>;
|
|
152
|
+
/** Segments the cylinder and box meshes of the model are rebuilt with, so a bullet dent (a few millimetres wide) finds vertices to push in. */
|
|
153
|
+
readonly tessellate?: {
|
|
154
|
+
readonly cylinder?: {
|
|
155
|
+
readonly heightSegments: number;
|
|
156
|
+
readonly radialSegments: number;
|
|
157
|
+
};
|
|
158
|
+
readonly box?: {
|
|
159
|
+
readonly widthSegments: number;
|
|
160
|
+
readonly heightSegments: number;
|
|
161
|
+
readonly depthSegments: number;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** A family of models that behave alike: one rule for all of them, so adding a model is one id and changing the rule changes them all. */
|
|
166
|
+
interface ItemFamily {
|
|
167
|
+
readonly models: readonly string[];
|
|
168
|
+
readonly rule: ItemDestruction;
|
|
169
|
+
}
|
|
170
|
+
/** What a model holds inside its shell: a liquid (`game-fluids` id) filling `fill` of the inner volume. */
|
|
171
|
+
interface ItemContents {
|
|
172
|
+
readonly liquid: string;
|
|
173
|
+
readonly fill: number;
|
|
174
|
+
/** The shell is a box (a flat tin) and not a cylinder. */
|
|
175
|
+
readonly box?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/** Id of the family a model belongs to (`drink_can`), if any. */
|
|
178
|
+
declare const itemFamily: (modelId: string) => string | undefined;
|
|
179
|
+
declare const itemDestruction: (modelId: string) => ItemDestruction | undefined;
|
|
180
|
+
/** The family ids and their models, as the data gives them. */
|
|
181
|
+
declare const ITEM_FAMILIES: Readonly<Record<string, ItemFamily>>;
|
|
182
|
+
/** The subject of `itemContents`: what `buildItem` draws. */
|
|
183
|
+
interface ContentsSubject {
|
|
184
|
+
readonly model?: string;
|
|
185
|
+
/** Metres. */
|
|
186
|
+
readonly size: readonly [number, number, number];
|
|
187
|
+
/** Kg, shell included. */
|
|
188
|
+
readonly weight?: number;
|
|
189
|
+
}
|
|
190
|
+
/** Id of the welded part that is the whole shell of a container. */
|
|
191
|
+
declare const SHELL_PART_ID = "shell";
|
|
192
|
+
/**
|
|
193
|
+
* The container the model holds (`TestableItem.fluid` of the test room and `PartSpec.contains` of the shell), sized from the item: the inner volume of its
|
|
194
|
+
* box times the fill of the model, never more than the item weighs in that liquid. Undefined for a model that holds nothing.
|
|
195
|
+
*/
|
|
196
|
+
declare function itemContents(subject: ContentsSubject): {
|
|
197
|
+
readonly container: ContainerSpec;
|
|
198
|
+
readonly liquid: string;
|
|
199
|
+
readonly liters: number;
|
|
200
|
+
} | undefined;
|
|
201
|
+
/** What `tagForDestruction` needs to know about the item beside its meshes. */
|
|
202
|
+
interface DestructionTagOptions {
|
|
203
|
+
readonly modelId?: string;
|
|
204
|
+
/** Real weight in kg. */
|
|
205
|
+
readonly weight?: number;
|
|
206
|
+
/** Size in metres, for the contents of the shell. */
|
|
207
|
+
readonly size?: readonly [number, number, number];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Writes the `userData` that `specFromObject3D` reads onto the meshes of a drawn item: the destruction material of each mesh from its kit material tag,
|
|
211
|
+
* the item's real weight in kg (`destructionMass`, so the world weighs what the thing weighs) and what the model's family in `data/destruction.json` asks for (hollow shells, welded parts, skins),
|
|
212
|
+
* with the liquid the model holds on its shell (`destructionContains`).
|
|
213
|
+
*/
|
|
214
|
+
declare function tagForDestruction(root: THREE_NS.Object3D, options?: DestructionTagOptions): void;
|
|
215
|
+
|
|
136
216
|
/**
|
|
137
217
|
* The same item with its meshes joined by material: one mesh and one draw call per material instead of one per part (the "one material for all the items" of the page's
|
|
138
218
|
* budget, as far as the materials of the kit allow). The materials are the same objects, so `setWear` still reaches them. The model's scale stays on the root.
|
|
@@ -380,4 +460,4 @@ interface ScenarioLike {
|
|
|
380
460
|
expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
|
|
381
461
|
}
|
|
382
462
|
|
|
383
|
-
export { type BudgetReport, type BuildItemOptions, type DrawableItem, FINDS_TABLE_ID, HUMAN_HEIGHT, HUMAN_ID, ITEM_BUDGETS, ITEM_PREFIX, type ItemBudgets, type ItemKit, type ItemLod, type ItemLodOptions, type ItemMaterialData, type ItemModel, type ItemModelBuilder, type ItemModelEntry, type ItemSizeClass, type ItemsAreaState, type ItemsTestModule, type ItemsTestModuleOptions, type LayoutItem, MODEL_BUDGET_DEVIATIONS, ROW_LIMIT, RULER_HEIGHT, RULER_ID, SHAPES, SHELF_HEIGHT, SHELF_PREFIX, SHIPPED_MODELS, SHOWCASE_PREFIX, SHOWCASE_STAND_ID, type ScenarioLike, type ShapeContext, type ShapeId, type ShapeSubject, type ShelfPlan, type ThumbnailRenderOptions, type ThumbnailRenderer, type ThumbnailScene, type Vec3Like, type Vec3Tuple, WEAR_AMOUNT, WEAR_TAGS, WEAR_TARGET, type WearStage, type WearTag, buildItem, buildItemLod, canonicalFrame, checkBudget, composeThumbnailScene, countDrawCalls, countTriangles, createItemKit, createItemsTestModule, cullDistanceOf, drawShape, hasItemModel, isShape, itemModelBuilder, itemModelEntry, itemThumbnail, itemThumbnailSvg, listItemModels, mergeItem, registerItemModel, renderItemThumbnail, setWear, shade, shapeOf, shapeThumbnailSvg, shelvesLayout, sizeClassOf, thumbnailPatch, triangleBudgetOf, unregisterItemModel, wearableMaterials };
|
|
463
|
+
export { type BudgetReport, type BuildItemOptions, type ContentsSubject, DESTRUCTION_MATERIAL_BY_TAG, type DestructionTagOptions, type DrawableItem, FINDS_TABLE_ID, HUMAN_HEIGHT, HUMAN_ID, ITEM_BUDGETS, ITEM_FAMILIES, ITEM_PREFIX, type ItemBudgets, type ItemContents, type ItemDestruction, type ItemFamily, type ItemKit, type ItemLod, type ItemLodOptions, type ItemMaterialData, type ItemModel, type ItemModelBuilder, type ItemModelEntry, type ItemSizeClass, type ItemsAreaState, type ItemsTestModule, type ItemsTestModuleOptions, type LayoutItem, MODEL_BUDGET_DEVIATIONS, ROW_LIMIT, RULER_HEIGHT, RULER_ID, SHAPES, SHELF_HEIGHT, SHELF_PREFIX, SHELL_PART_ID, SHIPPED_MODELS, SHOWCASE_PREFIX, SHOWCASE_STAND_ID, type ScenarioLike, type ShapeContext, type ShapeId, type ShapeSubject, type ShelfPlan, type ThumbnailRenderOptions, type ThumbnailRenderer, type ThumbnailScene, type Vec3Like, type Vec3Tuple, WEAR_AMOUNT, WEAR_TAGS, WEAR_TARGET, type WearStage, type WearTag, buildItem, buildItemLod, canonicalFrame, checkBudget, composeThumbnailScene, countDrawCalls, countTriangles, createItemKit, createItemsTestModule, cullDistanceOf, drawShape, hasItemModel, isShape, itemContents, itemDestruction, itemFamily, itemModelBuilder, itemModelEntry, itemThumbnail, itemThumbnailSvg, listItemModels, mergeItem, registerItemModel, renderItemThumbnail, setWear, shade, shapeOf, shapeThumbnailSvg, shelvesLayout, sizeClassOf, tagForDestruction, thumbnailPatch, triangleBudgetOf, unregisterItemModel, wearableMaterials };
|