@adatechnology/game-items-three 0.2.0 → 0.3.1
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 +5 -0
- package/dist/index.global.js +19229 -527
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +35 -58
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -337,6 +337,9 @@ function drawShape(k, shape, size, options = {}) {
|
|
|
337
337
|
return DRAWERS[shape]({ k, w, h, d, color: options.color ?? DEFAULT_COLOR, detail: options.detail ?? 1 });
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
// src/build-item.ts
|
|
341
|
+
import { markKitOrigin } from "@adatechnology/game-contracts";
|
|
342
|
+
|
|
340
343
|
// src/destruction.ts
|
|
341
344
|
import { LIQUIDS } from "@adatechnology/game-fluids";
|
|
342
345
|
|
|
@@ -6672,6 +6675,7 @@ function buildItem(T, item, options = {}) {
|
|
|
6672
6675
|
if (options.wear) setWear(materials, options.wear);
|
|
6673
6676
|
root.userData.wear = options.wear ?? 0;
|
|
6674
6677
|
if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size });
|
|
6678
|
+
markKitOrigin(root, { owner: "game-items-three", kind: "item", id: item.id, ...kind === "shape" ? { standIn: true } : {} });
|
|
6675
6679
|
return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
|
|
6676
6680
|
}
|
|
6677
6681
|
|
|
@@ -6836,6 +6840,8 @@ function renderItemThumbnail(T, renderer, item, options = {}) {
|
|
|
6836
6840
|
}
|
|
6837
6841
|
|
|
6838
6842
|
// src/area.ts
|
|
6843
|
+
import { markKitOrigin as markKitOrigin2 } from "@adatechnology/game-contracts";
|
|
6844
|
+
import { furnitureSpec } from "@adatechnology/game-floorplan-three";
|
|
6839
6845
|
import { rng } from "@adatechnology/game-interactables";
|
|
6840
6846
|
import { canCraft, craft, createFindsProvider, freshness, ITEM_CATEGORIES } from "@adatechnology/game-items";
|
|
6841
6847
|
|
|
@@ -6912,6 +6918,8 @@ var STAND = { at: [0, 0, 9.5], radius: 2.1, height: 0.8, ring: 1.35 };
|
|
|
6912
6918
|
var RULER_AT = [-6.5, 0, 9];
|
|
6913
6919
|
var HUMAN_AT = [-5.4, 0, 9];
|
|
6914
6920
|
var TABLE = { at: [7, 0, 9.5], length: 3.2, depth: 1, height: 0.8 };
|
|
6921
|
+
var SHELF_FURNITURE = "workbench";
|
|
6922
|
+
var TABLE_FURNITURE = "meeting_table";
|
|
6915
6923
|
var WEARS = ["new", "used", "spoiled"];
|
|
6916
6924
|
var WEAR_STAGE = { new: 0, used: 1, spoiled: 2 };
|
|
6917
6925
|
var SPIN = 0.6;
|
|
@@ -7077,28 +7085,23 @@ function createItemsTestModule(options) {
|
|
|
7077
7085
|
const register = (entry) => {
|
|
7078
7086
|
entries2.push({ ...entry, triangles: countTriangles(entry.root), drawCalls: countDrawCalls(entry.root) });
|
|
7079
7087
|
};
|
|
7080
|
-
const
|
|
7081
|
-
id
|
|
7082
|
-
name
|
|
7088
|
+
const furnitureItem = (id, name, type, size, decorate) => ({
|
|
7089
|
+
id,
|
|
7090
|
+
name,
|
|
7083
7091
|
movable: false,
|
|
7084
7092
|
build: (THREE) => {
|
|
7085
|
-
const
|
|
7086
|
-
const
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
group.userData.category = plan.category;
|
|
7098
|
-
group.userData.shelf = true;
|
|
7099
|
-
shelfRoots.push(group);
|
|
7100
|
-
return group;
|
|
7101
|
-
}
|
|
7093
|
+
const piece = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
|
|
7094
|
+
const root = piece.build(THREE);
|
|
7095
|
+
root.userData.furnitureSpec = { ...piece.spec, name };
|
|
7096
|
+
decorate?.(root);
|
|
7097
|
+
return root;
|
|
7098
|
+
},
|
|
7099
|
+
spec: (root) => root.userData.furnitureSpec
|
|
7100
|
+
});
|
|
7101
|
+
const shelfItem = (plan) => furnitureItem(plan.id, fill(text.shelf, { category: categoryName(plan.category) }), SHELF_FURNITURE, { w: plan.length, d: plan.depth, h: SHELF_HEIGHT }, (root) => {
|
|
7102
|
+
root.userData.category = plan.category;
|
|
7103
|
+
root.userData.shelf = true;
|
|
7104
|
+
shelfRoots.push(root);
|
|
7102
7105
|
});
|
|
7103
7106
|
const shelfRoots = [];
|
|
7104
7107
|
const fluidOf = (subject) => {
|
|
@@ -7138,7 +7141,7 @@ function createItemsTestModule(options) {
|
|
|
7138
7141
|
movable: false,
|
|
7139
7142
|
build: (THREE) => {
|
|
7140
7143
|
const T = THREE;
|
|
7141
|
-
const group = new T.Group();
|
|
7144
|
+
const group = markKitOrigin2(new T.Group(), { owner: "game-items-three", kind: "aid" });
|
|
7142
7145
|
const base = new T.Mesh(new T.CylinderGeometry(STAND.radius, STAND.radius + 0.1, STAND.height - 0.04, 40), new T.MeshStandardMaterial({ color: 3816772, roughness: 0.8 }));
|
|
7143
7146
|
base.position.y = (STAND.height - 0.04) / 2;
|
|
7144
7147
|
const top = new T.Mesh(new T.CylinderGeometry(STAND.radius, STAND.radius, 0.04, 40), new T.MeshStandardMaterial({ color: 13617848, roughness: 0.6 }));
|
|
@@ -7153,7 +7156,7 @@ function createItemsTestModule(options) {
|
|
|
7153
7156
|
movable: false,
|
|
7154
7157
|
build: (THREE) => {
|
|
7155
7158
|
const T = THREE;
|
|
7156
|
-
const group = new T.Group();
|
|
7159
|
+
const group = markKitOrigin2(new T.Group(), { owner: "game-items-three", kind: "aid" });
|
|
7157
7160
|
const post = new T.Mesh(new T.BoxGeometry(0.06, RULER_HEIGHT, 0.02), new T.MeshStandardMaterial({ color: 15262408, roughness: 0.7 }));
|
|
7158
7161
|
post.position.y = RULER_HEIGHT / 2;
|
|
7159
7162
|
group.add(post);
|
|
@@ -7171,47 +7174,20 @@ function createItemsTestModule(options) {
|
|
|
7171
7174
|
return group;
|
|
7172
7175
|
}
|
|
7173
7176
|
});
|
|
7174
|
-
const humanItem = () => ({
|
|
7177
|
+
const humanItem = (person) => ({
|
|
7175
7178
|
id: HUMAN_ID,
|
|
7176
7179
|
name: text.human,
|
|
7177
7180
|
movable: false,
|
|
7178
7181
|
build: (THREE) => {
|
|
7179
7182
|
const T = THREE;
|
|
7180
|
-
const
|
|
7181
|
-
const
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
group.add(mesh);
|
|
7186
|
-
};
|
|
7187
|
-
for (const x of [-0.09, 0.09]) part(new T.CylinderGeometry(0.075, 0.06, 0.88, 10), x, 0.44);
|
|
7188
|
-
part(new T.BoxGeometry(0.4, 0.62, 0.22), 0, 0.88 + 0.31);
|
|
7189
|
-
for (const x of [-0.26, 0.26]) part(new T.CylinderGeometry(0.045, 0.04, 0.6, 8), x, 1.2);
|
|
7190
|
-
part(new T.CylinderGeometry(0.05, 0.055, 0.07, 8), 0, 1.535);
|
|
7191
|
-
part(new T.SphereGeometry(0.115, 14, 10), 0, 1.685);
|
|
7192
|
-
group.userData.height = HUMAN_HEIGHT;
|
|
7193
|
-
return group;
|
|
7194
|
-
}
|
|
7195
|
-
});
|
|
7196
|
-
const tableItem = () => ({
|
|
7197
|
-
id: FINDS_TABLE_ID,
|
|
7198
|
-
name: text.table,
|
|
7199
|
-
movable: false,
|
|
7200
|
-
build: (THREE) => {
|
|
7201
|
-
const T = THREE;
|
|
7202
|
-
const group = new T.Group();
|
|
7203
|
-
const top = new T.Mesh(new T.BoxGeometry(TABLE.length, 0.05, TABLE.depth), new T.MeshStandardMaterial({ color: 8022613, roughness: 0.8 }));
|
|
7204
|
-
top.position.y = TABLE.height - 0.025;
|
|
7205
|
-
group.add(top);
|
|
7206
|
-
const frame = new T.MeshStandardMaterial({ color: 4013892 });
|
|
7207
|
-
for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
|
|
7208
|
-
const leg = new T.Mesh(new T.BoxGeometry(0.06, TABLE.height - 0.05, 0.06), frame);
|
|
7209
|
-
leg.position.set(sx * (TABLE.length - 0.12) / 2, (TABLE.height - 0.05) / 2, sz * (TABLE.depth - 0.12) / 2);
|
|
7210
|
-
group.add(leg);
|
|
7211
|
-
}
|
|
7212
|
-
return group;
|
|
7183
|
+
const root = person(THREE);
|
|
7184
|
+
const height = new T.Box3().setFromObject(root).getSize(new T.Vector3()).y;
|
|
7185
|
+
if (height > 0) root.scale.multiplyScalar(HUMAN_HEIGHT / height);
|
|
7186
|
+
root.userData.height = HUMAN_HEIGHT;
|
|
7187
|
+
return root;
|
|
7213
7188
|
}
|
|
7214
7189
|
});
|
|
7190
|
+
const tableItem = () => furnitureItem(FINDS_TABLE_ID, text.table, TABLE_FURNITURE, { w: TABLE.length, d: TABLE.depth, h: TABLE.height });
|
|
7215
7191
|
const liveEntries = () => entries2.filter((entry) => entry.root.parent !== null);
|
|
7216
7192
|
const visibleEntries = () => liveEntries().filter((entry) => entry.root.visible);
|
|
7217
7193
|
const applyCategory = () => {
|
|
@@ -7376,7 +7352,8 @@ function createItemsTestModule(options) {
|
|
|
7376
7352
|
const angle = index / showcase.length * Math.PI * 2;
|
|
7377
7353
|
placements.push({ item: `${SHOWCASE_PREFIX}${model.id}`, position: [STAND.at[0] + Math.cos(angle) * STAND.ring, STAND.height + 0.01, STAND.at[2] + Math.sin(angle) * STAND.ring], asleep: true });
|
|
7378
7354
|
});
|
|
7379
|
-
placements.push({ item: RULER_ID, position: RULER_AT }
|
|
7355
|
+
placements.push({ item: RULER_ID, position: RULER_AT });
|
|
7356
|
+
if (options.person) placements.push({ item: HUMAN_ID, position: HUMAN_AT });
|
|
7380
7357
|
placements.push({ item: FINDS_TABLE_ID, position: TABLE.at, surface: { halfSize: [TABLE.length / 2, TABLE.depth / 2], height: TABLE.height } });
|
|
7381
7358
|
return placements;
|
|
7382
7359
|
};
|
|
@@ -7467,7 +7444,7 @@ function createItemsTestModule(options) {
|
|
|
7467
7444
|
standItem(),
|
|
7468
7445
|
...showcase.map(showcaseItem),
|
|
7469
7446
|
rulerItem(),
|
|
7470
|
-
humanItem(),
|
|
7447
|
+
...options.person ? [humanItem(options.person)] : [],
|
|
7471
7448
|
tableItem()
|
|
7472
7449
|
],
|
|
7473
7450
|
area: () => ({ placements: areaPlacements(), view: { eye: [0, 5.5, 16], target: [0, 0.8, 0] } }),
|