@adatechnology/game-items-three 0.11.8 → 0.13.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.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ CUP_FLOOR_SHARE,
2
3
  DESTRUCTION_MATERIAL_BY_TAG,
3
4
  FINDS_TABLE_ID,
4
5
  HUMAN_HEIGHT,
@@ -18,6 +19,7 @@ import {
18
19
  SHIPPED_MODELS,
19
20
  SHOWCASE_PREFIX,
20
21
  SHOWCASE_STAND_ID,
22
+ WASH_NAME,
21
23
  WEAR_AMOUNT,
22
24
  WEAR_TAGS,
23
25
  WEAR_TARGET,
@@ -44,12 +46,15 @@ import {
44
46
  itemOpening,
45
47
  itemThumbnail,
46
48
  itemThumbnailSvg,
49
+ itemVessel,
47
50
  listItemModels,
48
51
  makeupSpec,
49
52
  openItem,
50
53
  registerItemModel,
51
54
  registryOver,
52
55
  renderItemThumbnail,
56
+ setItemDirt,
57
+ setItemFoam,
53
58
  setOpeningContents,
54
59
  setWear,
55
60
  shade,
@@ -65,7 +70,7 @@ import {
65
70
  turnItem,
66
71
  unregisterItemModel,
67
72
  wearableMaterials
68
- } from "./chunk-64JEKMFT.js";
73
+ } from "./chunk-FCEKW7F6.js";
69
74
 
70
75
  // src/contained.ts
71
76
  function createContainedItemModel(items, options = {}) {
@@ -76,6 +81,8 @@ function createContainedItemModel(items, options = {}) {
76
81
  if (!item) return null;
77
82
  const model = buildItem(T, item, options);
78
83
  model.root.userData.item = { id: item.id, kind: model.kind };
84
+ const dirt = stack.data?.["dirt"];
85
+ if (typeof dirt === "number" && dirt > 0) setItemDirt(T, model.root, dirt);
79
86
  return model.root;
80
87
  };
81
88
  }
@@ -130,6 +137,7 @@ function createItemModels(options = {}) {
130
137
  return models;
131
138
  }
132
139
  export {
140
+ CUP_FLOOR_SHARE,
133
141
  DESTRUCTION_MATERIAL_BY_TAG,
134
142
  FINDS_TABLE_ID,
135
143
  HUMAN_HEIGHT,
@@ -149,6 +157,7 @@ export {
149
157
  SHIPPED_MODELS,
150
158
  SHOWCASE_PREFIX,
151
159
  SHOWCASE_STAND_ID,
160
+ WASH_NAME,
152
161
  WEAR_AMOUNT,
153
162
  WEAR_TAGS,
154
163
  WEAR_TARGET,
@@ -179,12 +188,15 @@ export {
179
188
  itemOpening,
180
189
  itemThumbnail,
181
190
  itemThumbnailSvg,
191
+ itemVessel,
182
192
  listItemModels,
183
193
  makeupSpec,
184
194
  mergeItem,
185
195
  openItem,
186
196
  registerItemModel,
187
197
  renderItemThumbnail,
198
+ setItemDirt,
199
+ setItemFoam,
188
200
  setOpeningContents,
189
201
  setWear,
190
202
  shade,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contained.ts","../src/item-models.ts","../src/merge.ts","../src/lod.ts","../src/models/instance.ts"],"sourcesContent":["import type * as THREE_NS from 'three'\n\nimport { buildItem } from './build-item'\nimport type { BuildItemOptions, DrawableItem } from './build-item'\n\n/** A stack held in a container (`ItemStack` of game-interactables): the item id and its free data. */\nexport interface ContainedStack {\n readonly type: string\n}\n\n/** What `createContainedItemModel` returns: the real model of a stack drawn with the caller's `THREE`, or null for an id the catalogue does not have. */\nexport type ContainedItemModel = (stack: ContainedStack, T: typeof THREE_NS) => THREE_NS.Object3D | null\n\n/**\n * The model of the items inside furniture, for `createContentsView` of game-interactables-three and `interactives.itemModel` of game-floorplan-three: each\n * stack is drawn by `buildItem` from the catalogue (the team's model where there is one, the item's own shape otherwise), never a stand-in. Every item gets its\n * own materials, so the view can discard it alone when it is taken. `root.userData.item` says what was drawn (`{ id, kind }`).\n */\nexport function createContainedItemModel(items: Iterable<DrawableItem>, options: Omit<BuildItemOptions, 'kit'> = {}): ContainedItemModel {\n const byId = new Map<string, DrawableItem>()\n for (const item of items) byId.set(item.id, item)\n return (stack, T) => {\n const item = byId.get(stack.type)\n if (!item) return null\n const model = buildItem(T, item, options)\n model.root.userData.item = { id: item.id, kind: model.kind }\n return model.root\n }\n}\n","import { buildItem } from './build-item'\nimport { hasItemModel } from './models/registry'\n\n/** The item models as a source a weapon or an explosive can draw with (`ItemModels` of game-weapons-three): a host lends it as `items`. */\nexport const itemModels = { has: hasItemModel, build: buildItem } as const\n","import { mergeByMaterial } from '@adatechnology/game-shapes-three'\nimport type * as THREE_NS from 'three'\n\nimport type { ItemModel } from './build-item'\n\n/**\n * 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\n * 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.\n */\nexport function mergeItem(T: typeof THREE_NS, model: ItemModel): ItemModel {\n model.root.updateMatrixWorld(true)\n const merged = new T.Group()\n merged.name = model.root.name\n merged.scale.copy(model.root.scale)\n merged.userData = { ...model.root.userData }\n // baked into the space of the root, which leaves the root's own scale out of the geometry\n merged.add(...mergeByMaterial(T, model.root, model.root))\n return { ...model, root: merged }\n}\n","import type * as THREE_NS from 'three'\n\nimport { ITEM_BUDGETS, cullDistanceOf } from './budgets'\nimport type { ItemBudgets } from './budgets'\nimport { buildItem } from './build-item'\nimport type { BuildItemOptions, DrawableItem, ItemModel } from './build-item'\nimport { createItemKit } from './kit'\nimport { mergeItem } from './merge'\n\nexport interface ItemLodOptions extends Omit<BuildItemOptions, 'simple' | 'detail' | 'kit'> {\n budgets?: ItemBudgets\n /** Join the meshes of each level by material (default true). */\n merge?: boolean\n /** Distance of the second level in metres; default a third of the distance at which the item disappears. */\n lod1Distance?: number\n}\n\nexport interface ItemLod {\n /** Add this to the scene and call `update(camera)` (or let the renderer do it). */\n readonly root: THREE_NS.LOD\n /** Full detail: the showcase model, or the shape at full segments. */\n readonly near: ItemModel\n /** The simple shape at half the segments. */\n readonly far: ItemModel\n /** Metres from the camera at which the item is no longer drawn. */\n readonly cullDistance: number\n readonly lod1Distance: number\n}\n\n/**\n * Three levels of an item: the model (or the shape) up close, the simple shape at half the segments from `lod1Distance`, and nothing from the distance of its class\n * (a small item goes at 30 m, a large one at 60 m).\n */\nexport function buildItemLod(T: typeof THREE_NS, item: DrawableItem, options: ItemLodOptions = {}): ItemLod {\n const budgets = options.budgets ?? ITEM_BUDGETS\n const cullDistance = cullDistanceOf(item.size, budgets)\n const lod1Distance = options.lod1Distance ?? cullDistance / 3\n const joined = (model: ItemModel): ItemModel => (options.merge === false ? model : mergeItem(T, model))\n const wear = { ...(options.wear === undefined ? {} : { wear: options.wear }), ...(options.models === undefined ? {} : { models: options.models }) }\n const near = joined(buildItem(T, item, { ...wear, kit: createItemKit(T) }))\n const far = joined(buildItem(T, item, { ...wear, simple: true, detail: budgets.lod1Ratio, kit: createItemKit(T) }))\n const root = new T.LOD()\n root.name = item.id\n root.addLevel(near.root, 0)\n root.addLevel(far.root, lod1Distance)\n root.addLevel(new T.Group(), cullDistance)\n root.userData.wear = options.wear ?? 0\n return { root, near, far, cullDistance, lod1Distance }\n}\n","import { applyPatches, mergeById, removeIds } from '@adatechnology/game-contracts'\nimport type { DeepPartial, Thumbnail } from '@adatechnology/game-contracts'\nimport type * as THREE_NS from 'three'\n\nimport { buildItem } from '../build-item'\nimport { buildItemLod } from '../lod'\nimport type { ItemLod, ItemLodOptions } from '../lod'\nimport { itemThumbnail } from '../thumbnails'\nimport type { BuildItemOptions, DrawableItem, ItemModel } from '../build-item'\nimport { registryOver } from './registry'\nimport type { ItemModelBuilder, ItemModelEntry, ItemModelRegistry } from './registry'\nimport { SHIPPED_MODELS } from './shipped'\n\nexport interface ItemModelRecord {\n readonly entry: ItemModelEntry\n readonly builder: ItemModelBuilder\n}\n\nexport interface ItemModelsOptions {\n /** Models added to the shipped ones; one with the id of a shipped model replaces it. */\n readonly packs?: readonly (readonly ItemModelRecord[])[]\n /** Changes to an entry by item id (`scale`, `teamBox`), merged field by field. */\n readonly patch?: Readonly<Record<string, DeepPartial<ItemModelEntry>>>\n /** Item ids whose model is taken out (the item then gets its simple shape). */\n readonly remove?: readonly string[]\n}\n\nexport interface ItemModels extends ItemModelRegistry {\n /** `buildItem` that reads this set of models. */\n build(T: typeof THREE_NS, item: DrawableItem, options?: Omit<BuildItemOptions, 'models'>): ItemModel\n /** `buildItemLod` that reads this set of models. */\n buildLod(T: typeof THREE_NS, item: DrawableItem, options?: Omit<ItemLodOptions, 'models'>): ItemLod\n /** `itemThumbnail` that asks this set whether the item has a model. */\n thumbnail(item: DrawableItem): Thumbnail\n}\n\ntype Keyed = ItemModelRecord & { readonly id: string }\n\n/** A set of item models of its own: the shipped ones plus `packs`, `patch` and `remove`. Nothing is shared with any other set on the page. */\nexport function createItemModels(options: ItemModelsOptions = {}): ItemModels {\n const keyed = (record: ItemModelRecord): Keyed => ({ ...record, id: record.entry.id })\n const records = mergeById(SHIPPED_MODELS.map(keyed), (options.packs ?? []).flat().map(keyed))\n applyPatches(records, Object.fromEntries(Object.entries(options.patch ?? {}).map(([id, entry]) => [id, { entry }])) as Readonly<Record<string, DeepPartial<Keyed>>>)\n removeIds(records, options.remove)\n const registry = registryOver(new Map([...records].map(([id, record]) => [id, record.entry])), new Map([...records].map(([id, record]) => [id, record.builder])))\n const models: ItemModels = {\n ...registry,\n build: (T, item, buildOptions = {}) => buildItem(T, item, { ...buildOptions, models: registry }),\n buildLod: (T, item, lodOptions = {}) => buildItemLod(T, item, { ...lodOptions, models: registry }),\n thumbnail: (item) => itemThumbnail(item, registry),\n }\n return models\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,yBAAyB,OAA+B,UAAyC,CAAC,GAAuB;AACvI,QAAM,OAAO,oBAAI,IAA0B;AAC3C,aAAW,QAAQ,MAAO,MAAK,IAAI,KAAK,IAAI,IAAI;AAChD,SAAO,CAAC,OAAO,MAAM;AACnB,UAAM,OAAO,KAAK,IAAI,MAAM,IAAI;AAChC,QAAI,CAAC,KAAM,QAAO;AAClB,UAAM,QAAQ,U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;AAAA,EACnD;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/contained.ts","../src/item-models.ts","../src/merge.ts","../src/lod.ts","../src/models/instance.ts"],"sourcesContent":["import type * as THREE_NS from 'three'\n\nimport { buildItem } from './build-item'\nimport type { BuildItemOptions, DrawableItem } from './build-item'\nimport { setItemDirt } from './wash'\n\n/** A stack held in a container (`ItemStack` of game-interactables): the item id and its free data. */\nexport interface ContainedStack {\n readonly type: string\n /** The stack's free data: `dirt` (0 clean to 1 caked) draws the food left on it (a plate left dirty in a sink). */\n readonly data?: Readonly<Record<string, unknown>>\n}\n\n/** What `createContainedItemModel` returns: the real model of a stack drawn with the caller's `THREE`, or null for an id the catalogue does not have. */\nexport type ContainedItemModel = (stack: ContainedStack, T: typeof THREE_NS) => THREE_NS.Object3D | null\n\n/**\n * The model of the items inside furniture, for `createContentsView` of game-interactables-three and `interactives.itemModel` of game-floorplan-three: each\n * stack is drawn by `buildItem` from the catalogue (the team's model where there is one, the item's own shape otherwise), never a stand-in. Every item gets its\n * own materials, so the view can discard it alone when it is taken. `root.userData.item` says what was drawn (`{ id, kind }`); a stack with `data.dirt` is drawn\n * dirty (`setItemDirt`), the same as the item once it is in the world.\n */\nexport function createContainedItemModel(items: Iterable<DrawableItem>, options: Omit<BuildItemOptions, 'kit'> = {}): ContainedItemModel {\n const byId = new Map<string, DrawableItem>()\n for (const item of items) byId.set(item.id, item)\n return (stack, T) => {\n const item = byId.get(stack.type)\n if (!item) return null\n const model = buildItem(T, item, options)\n model.root.userData.item = { id: item.id, kind: model.kind }\n const dirt = stack.data?.['dirt']\n if (typeof dirt === 'number' && dirt > 0) setItemDirt(T, model.root, dirt)\n return model.root\n }\n}\n","import { buildItem } from './build-item'\nimport { hasItemModel } from './models/registry'\n\n/** The item models as a source a weapon or an explosive can draw with (`ItemModels` of game-weapons-three): a host lends it as `items`. */\nexport const itemModels = { has: hasItemModel, build: buildItem } as const\n","import { mergeByMaterial } from '@adatechnology/game-shapes-three'\nimport type * as THREE_NS from 'three'\n\nimport type { ItemModel } from './build-item'\n\n/**\n * 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\n * 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.\n */\nexport function mergeItem(T: typeof THREE_NS, model: ItemModel): ItemModel {\n model.root.updateMatrixWorld(true)\n const merged = new T.Group()\n merged.name = model.root.name\n merged.scale.copy(model.root.scale)\n merged.userData = { ...model.root.userData }\n // baked into the space of the root, which leaves the root's own scale out of the geometry\n merged.add(...mergeByMaterial(T, model.root, model.root))\n return { ...model, root: merged }\n}\n","import type * as THREE_NS from 'three'\n\nimport { ITEM_BUDGETS, cullDistanceOf } from './budgets'\nimport type { ItemBudgets } from './budgets'\nimport { buildItem } from './build-item'\nimport type { BuildItemOptions, DrawableItem, ItemModel } from './build-item'\nimport { createItemKit } from './kit'\nimport { mergeItem } from './merge'\n\nexport interface ItemLodOptions extends Omit<BuildItemOptions, 'simple' | 'detail' | 'kit'> {\n budgets?: ItemBudgets\n /** Join the meshes of each level by material (default true). */\n merge?: boolean\n /** Distance of the second level in metres; default a third of the distance at which the item disappears. */\n lod1Distance?: number\n}\n\nexport interface ItemLod {\n /** Add this to the scene and call `update(camera)` (or let the renderer do it). */\n readonly root: THREE_NS.LOD\n /** Full detail: the showcase model, or the shape at full segments. */\n readonly near: ItemModel\n /** The simple shape at half the segments. */\n readonly far: ItemModel\n /** Metres from the camera at which the item is no longer drawn. */\n readonly cullDistance: number\n readonly lod1Distance: number\n}\n\n/**\n * Three levels of an item: the model (or the shape) up close, the simple shape at half the segments from `lod1Distance`, and nothing from the distance of its class\n * (a small item goes at 30 m, a large one at 60 m).\n */\nexport function buildItemLod(T: typeof THREE_NS, item: DrawableItem, options: ItemLodOptions = {}): ItemLod {\n const budgets = options.budgets ?? ITEM_BUDGETS\n const cullDistance = cullDistanceOf(item.size, budgets)\n const lod1Distance = options.lod1Distance ?? cullDistance / 3\n const joined = (model: ItemModel): ItemModel => (options.merge === false ? model : mergeItem(T, model))\n const wear = { ...(options.wear === undefined ? {} : { wear: options.wear }), ...(options.models === undefined ? {} : { models: options.models }) }\n const near = joined(buildItem(T, item, { ...wear, kit: createItemKit(T) }))\n const far = joined(buildItem(T, item, { ...wear, simple: true, detail: budgets.lod1Ratio, kit: createItemKit(T) }))\n const root = new T.LOD()\n root.name = item.id\n root.addLevel(near.root, 0)\n root.addLevel(far.root, lod1Distance)\n root.addLevel(new T.Group(), cullDistance)\n root.userData.wear = options.wear ?? 0\n return { root, near, far, cullDistance, lod1Distance }\n}\n","import { applyPatches, mergeById, removeIds } from '@adatechnology/game-contracts'\nimport type { DeepPartial, Thumbnail } from '@adatechnology/game-contracts'\nimport type * as THREE_NS from 'three'\n\nimport { buildItem } from '../build-item'\nimport { buildItemLod } from '../lod'\nimport type { ItemLod, ItemLodOptions } from '../lod'\nimport { itemThumbnail } from '../thumbnails'\nimport type { BuildItemOptions, DrawableItem, ItemModel } from '../build-item'\nimport { registryOver } from './registry'\nimport type { ItemModelBuilder, ItemModelEntry, ItemModelRegistry } from './registry'\nimport { SHIPPED_MODELS } from './shipped'\n\nexport interface ItemModelRecord {\n readonly entry: ItemModelEntry\n readonly builder: ItemModelBuilder\n}\n\nexport interface ItemModelsOptions {\n /** Models added to the shipped ones; one with the id of a shipped model replaces it. */\n readonly packs?: readonly (readonly ItemModelRecord[])[]\n /** Changes to an entry by item id (`scale`, `teamBox`), merged field by field. */\n readonly patch?: Readonly<Record<string, DeepPartial<ItemModelEntry>>>\n /** Item ids whose model is taken out (the item then gets its simple shape). */\n readonly remove?: readonly string[]\n}\n\nexport interface ItemModels extends ItemModelRegistry {\n /** `buildItem` that reads this set of models. */\n build(T: typeof THREE_NS, item: DrawableItem, options?: Omit<BuildItemOptions, 'models'>): ItemModel\n /** `buildItemLod` that reads this set of models. */\n buildLod(T: typeof THREE_NS, item: DrawableItem, options?: Omit<ItemLodOptions, 'models'>): ItemLod\n /** `itemThumbnail` that asks this set whether the item has a model. */\n thumbnail(item: DrawableItem): Thumbnail\n}\n\ntype Keyed = ItemModelRecord & { readonly id: string }\n\n/** A set of item models of its own: the shipped ones plus `packs`, `patch` and `remove`. Nothing is shared with any other set on the page. */\nexport function createItemModels(options: ItemModelsOptions = {}): ItemModels {\n const keyed = (record: ItemModelRecord): Keyed => ({ ...record, id: record.entry.id })\n const records = mergeById(SHIPPED_MODELS.map(keyed), (options.packs ?? []).flat().map(keyed))\n applyPatches(records, Object.fromEntries(Object.entries(options.patch ?? {}).map(([id, entry]) => [id, { entry }])) as Readonly<Record<string, DeepPartial<Keyed>>>)\n removeIds(records, options.remove)\n const registry = registryOver(new Map([...records].map(([id, record]) => [id, record.entry])), new Map([...records].map(([id, record]) => [id, record.builder])))\n const models: ItemModels = {\n ...registry,\n build: (T, item, buildOptions = {}) => buildItem(T, item, { ...buildOptions, models: registry }),\n buildLod: (T, item, lodOptions = {}) => buildItemLod(T, item, { ...lodOptions, models: registry }),\n thumbnail: (item) => itemThumbnail(item, registry),\n }\n return models\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,SAAS,yBAAyB,OAA+B,UAAyC,CAAC,GAAuB;AACvI,QAAM,OAAO,oBAAI,IAA0B;AAC3C,aAAW,QAAQ,MAAO,MAAK,IAAI,KAAK,IAAI,IAAI;AAChD,SAAO,CAAC,OAAO,MAAM;AACnB,UAAM,OAAO,KAAK,IAAI,MAAM,IAAI;AAChC,QAAI,CAAC,KAAM,QAAO;AAClB,UAAM,QAAQ,UAAU,GAAG,MAAM,OAAO;AACxC,UAAM,KAAK,SAAS,OAAO,EAAE,IAAI,KAAK,IAAI,MAAM,MAAM,KAAK;AAC3D,UAAM,OAAO,MAAM,OAAO,MAAM;AAChC,QAAI,OAAO,SAAS,YAAY,OAAO,EAAG,aAAY,GAAG,MAAM,MAAM,IA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eshStandardMaterial;
39
39
  food(color: number): THREE_NS.MeshStandardMaterial;
40
40
  glass(color: number, opacity: number): THREE_NS.MeshStandardMaterial;
41
+ /** Marks a part as the thing's carry handle (`CARRY_HANDLE_TAG` of game-contracts): a hand takes the thing there and carries it hanging. */
42
+ carryHandle<TObject extends THREE_NS.Object3D>(part: TObject): TObject;
41
43
  }
42
44
  /** The helpers of the showcase page on a given three.js; every kit has its own list of materials. */
43
45
  declare function createItemKit(three: Three): ItemKit;
44
46
 
47
+ /** A builder of the showcase, ported as it is: it draws in the page's units and returns the group. Kept apart from the registry so a model can name its type without reaching the list of shipped models. */
48
+ type ItemModelBuilder = (kit: ItemKit) => THREE_NS.Group;
49
+
45
50
  /** 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
51
  interface ItemModelEntry {
47
52
  /** Catalog id of the item (`canned_beans`). */
@@ -53,8 +58,7 @@ interface ItemModelEntry {
53
58
  /** Metres per unit of the page, from one real measure of the object. */
54
59
  readonly scale: number;
55
60
  }
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;
61
+
58
62
  /** The models of one registry: what `buildItem` reads through its `models` option. */
59
63
  interface ItemModelRegistry {
60
64
  has(id: string): boolean;
@@ -138,6 +142,8 @@ interface ItemsTestModuleOptions {
138
142
  models?: ItemModelRegistry;
139
143
  /** What an item does in the hand (eaten, taken, applied: `goodsItemUse` of game-items-goods); without it the items have only the uses of their liquid. */
140
144
  itemUse?: (item: ItemDef) => ModuleItemUse | undefined;
145
+ /** Items that get dirty and are washed at a sink (they draw food left on them and foam); default the `kitchen` items that are not food. */
146
+ washable?: (item: ItemDef) => boolean;
141
147
  }
142
148
  declare const SHOWCASE_STAND_ID = "stand_models";
143
149
  declare const RULER_ID = "ruler_155";
package/dist/testing.d.ts CHANGED
@@ -1,4 +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-D2tqWTG4.js';
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-DbKHUIwv.js';
2
2
  import 'three';
3
3
  import '@adatechnology/game-contracts';
4
4
  import '@adatechnology/game-items';
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  RULER_ID,
7
7
  SHOWCASE_STAND_ID,
8
8
  createItemsTestModule
9
- } from "./chunk-64JEKMFT.js";
9
+ } from "./chunk-FCEKW7F6.js";
10
10
  export {
11
11
  FINDS_TABLE_ID,
12
12
  HUMAN_HEIGHT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/game-items-three",
3
- "version": "0.11.8",
3
+ "version": "0.13.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": [
@@ -42,12 +42,12 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@adatechnology/game-contracts": "^0.48.0",
46
- "@adatechnology/game-interactables": "^0.11.0",
47
- "@adatechnology/game-fluids": "^0.7.2",
48
- "@adatechnology/game-items": "^0.7.0",
49
- "@adatechnology/game-floorplan-three": "^9.0.0",
50
- "@adatechnology/game-shapes-three": "^0.4.2"
45
+ "@adatechnology/game-contracts": "^0.50.0",
46
+ "@adatechnology/game-floorplan-three": "^11.0.0",
47
+ "@adatechnology/game-fluids": "^0.7.4",
48
+ "@adatechnology/game-interactables": "^0.13.0",
49
+ "@adatechnology/game-items": "^0.8.0",
50
+ "@adatechnology/game-shapes-three": "^0.5.1"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "three": "^0.160.0"
@@ -60,15 +60,15 @@
60
60
  "tsup": "^8.5.1",
61
61
  "typescript": "^5.7.3",
62
62
  "vitest": "^3.2.4",
63
- "@adatechnology/game-destruction": "^0.35.0",
64
- "@adatechnology/game-interactables-household": "^0.8.6",
65
- "@adatechnology/game-interactables-three": "^0.6.2",
66
- "@adatechnology/game-destruction-three": "^1.8.1",
67
- "@adatechnology/game-items-goods": "^0.7.1",
68
- "@adatechnology/game-physics": "^0.11.1",
69
- "@adatechnology/game-test-room": "^1.10.2",
70
- "@adatechnology/golden-tool": "^0.0.0",
71
- "@adatechnology/game-physics-jolt": "^0.7.6"
63
+ "@adatechnology/game-destruction": "^0.38.0",
64
+ "@adatechnology/game-destruction-three": "^1.10.1",
65
+ "@adatechnology/game-interactables-household": "^0.9.0",
66
+ "@adatechnology/game-interactables-three": "^0.7.0",
67
+ "@adatechnology/game-items-goods": "^0.8.0",
68
+ "@adatechnology/game-physics": "^0.11.2",
69
+ "@adatechnology/game-physics-jolt": "^0.7.8",
70
+ "@adatechnology/game-test-room": "^1.12.0",
71
+ "@adatechnology/golden-tool": "^0.0.0"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup",