@adatechnology/game-floorplan-three 0.2.0 → 0.3.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 +25 -0
- package/dist/index.d.ts +100 -3
- package/dist/index.global.js +9281 -561
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +323 -28
- package/dist/index.js.map +1 -1
- package/package.json +18 -17
package/README.md
CHANGED
|
@@ -48,6 +48,23 @@ house.update(dt, performance.now(), camera.position) // doors, laundry, wind, di
|
|
|
48
48
|
|
|
49
49
|
`house.group` is the root. Everything is merged to one mesh per group and material (a draw call each); only what moves stays apart.
|
|
50
50
|
|
|
51
|
+
## Furniture as a destructible spec
|
|
52
|
+
|
|
53
|
+
`furnitureSpec(THREE, type, { w?, d?, h?, seed?, options? })` runs the team's builder of `type` (`bookcase`, `shelf_unit`, `dining_table`, `coffee_table`... the keys of `renderer.types`) unchanged, with a recording stand-in for the drawing api, and returns `{ spec, build(THREE), top, size }`: one part per drawn box or cylinder (`wood_0`, `plain_17`: builder material key and drawing order), with the colour the builder gave it. Sizes default to the catalogue entry (`residentialItems`; `catalog` overrides it), `seed` drives the builder's random (the books), so the same seed gives the same piece.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { furnitureSpec } from '@adatechnology/game-floorplan-three'
|
|
57
|
+
const shelf = furnitureSpec(THREE, 'bookcase') // 1.2 x 0.35 x 2 m: uprights, back, boards and books
|
|
58
|
+
world.add(shelf.spec, { id: 'shelf', position: [-3.5, 0, 0] })
|
|
59
|
+
scene.add(shelf.build(THREE)) // meshes named by part id
|
|
60
|
+
const table = furnitureSpec(THREE, 'dining_table', { w: 1.6, d: 0.8, h: 0.78, options: { chairs: false } })
|
|
61
|
+
table.top // { part: 'wood_0', y: 0.78 }: what loose things rest on
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`tapSpec(THREE, { kind: 'counter' | 'wall', reach? })` does the same for the team's tap (`counterTap` of the sink, `wallTap` of the laundry tub): the steel parts of the base, column, spout and lever, and `spout`, where the water thread starts (the thread itself is not drawn).
|
|
65
|
+
|
|
66
|
+
Materials: `wood` is `wood_hard` (`wood_soft` under 3.5 cm: boards, panels), `metal` is `steel`, `plain` is `plastic` (`paper` on shelves and racks: the books), `fabric`, `glass` and `plant` keep their name; `options.materials` overrides any key. Parts that touch the floor are anchored. Joints come from `inferJoints` (screws between wood...), except that paper rests on what it lies on with a weak `resting` joint, so books fall when their board breaks, and is not joined to its neighbours. `options.chairs: false` drops what the builder draws in a frame of its own (a table's chairs). Planes and leaves have no volume and are left out.
|
|
67
|
+
|
|
51
68
|
## Bound to the destruction
|
|
52
69
|
|
|
53
70
|
With `destruction` (a world of `game-destruction`) and `destructionRenderer` (`game-destruction-three`), the house registers itself in the world on first need
|
|
@@ -88,6 +105,14 @@ navigator.blocked(x, z, floor) // 1 blocked, 0 free, -1 use the ground grid
|
|
|
88
105
|
|
|
89
106
|
Everything the house says to the player (prompts, messages) is in `locales` (`en`, `pt-BR`).
|
|
90
107
|
|
|
108
|
+
## Geometry
|
|
109
|
+
|
|
110
|
+
The kernel's three is `shapeGeometries(THREE)` of `@adatechnology/game-shapes-three`: the primitive templates the accumulator copies (box,
|
|
111
|
+
cylinders of 12 and 6 sides, the open cone, sphere, plane), the breach units, the fragments, the mirrors and the test area's specimens are made
|
|
112
|
+
by game-shapes, bit-identical to three's (`tests/exact-golden.test.ts`) and cached by parameters across renderers. The accumulator itself (one
|
|
113
|
+
mesh per group and material) keeps its own arithmetic: its transform, normals and world-projected uvs are not three's matrix order, so moving
|
|
114
|
+
it onto the core bake would change bytes (see the T9 design, §7.3).
|
|
115
|
+
|
|
91
116
|
## Build
|
|
92
117
|
|
|
93
118
|
`dist/index.js` (ESM, three.js and the other packages external), `dist/index.d.ts`, and `dist/index.global.js` exposing `GameFloorplanThree` (three.js is the page's own `THREE`).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleScenario, TestableModule } from '@adatechnology/game-contracts';
|
|
1
|
+
import { ModuleScenario, TestableModule, DestructibleSpec } from '@adatechnology/game-contracts';
|
|
2
2
|
|
|
3
3
|
/** Texts the house shows to the player (interaction prompts, messages, outbuilding labels), by locale. */
|
|
4
4
|
type Messages = Record<string, string>;
|
|
@@ -435,11 +435,13 @@ interface FloorplanEngineLike {
|
|
|
435
435
|
generate(template: string, options?: {
|
|
436
436
|
seed?: number;
|
|
437
437
|
state?: string;
|
|
438
|
+
floors?: number;
|
|
438
439
|
}): any;
|
|
439
440
|
listTemplates(): Array<{
|
|
440
441
|
id: string;
|
|
441
442
|
name?: string;
|
|
442
443
|
floors?: number;
|
|
444
|
+
floorRange?: number[] | null;
|
|
443
445
|
}>;
|
|
444
446
|
listStates(): string[];
|
|
445
447
|
translate?(namespace: any, key: string, locale?: string, vars?: Record<string, string | number>): string;
|
|
@@ -460,6 +462,15 @@ interface SpecimenDef {
|
|
|
460
462
|
state?: string;
|
|
461
463
|
/** The bearing walls only close: a frame of pillars and beams carries the building. */
|
|
462
464
|
portico?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* How the structure is sized (`toDestructibleSpec`): `safety` is the share of its capacity a pillar uses at rest, `redundancy` the most it uses after one other pillar is lost.
|
|
467
|
+
* A slab on four pillars is held by the sum of the four: with `safety` 0.72 and `redundancy` 0.97 it holds one loss (0.96) and falls with two.
|
|
468
|
+
*/
|
|
469
|
+
sizing?: {
|
|
470
|
+
safety?: number;
|
|
471
|
+
redundancy?: number;
|
|
472
|
+
safetyOthers?: number;
|
|
473
|
+
};
|
|
463
474
|
/** Name by locale; the text of the area when absent. */
|
|
464
475
|
name?: Record<string, string>;
|
|
465
476
|
}
|
|
@@ -511,7 +522,9 @@ declare function createFloorplanTestModule(options?: FloorplanTestOptions): Test
|
|
|
511
522
|
|
|
512
523
|
/**
|
|
513
524
|
* The five items of the team's house area (sala-de-testes/area-casas): a frame house, a whole house, a wood-frame house, a log cabin and a tent. The team's frame house is its single-storey house A; here it is the
|
|
514
|
-
* two-storey townhouse, because the ceiling slab of the single-storey plan keeps standing on its bearing partitions when two pillars go (see evidence, T2.6).
|
|
525
|
+
* two-storey townhouse, because the ceiling slab of the single-storey plan keeps standing on its bearing partitions when two pillars go (see evidence, T2.6). The frame house is a reinforced concrete frame (T10 §12): the slabs
|
|
526
|
+
* are cut into panels on real beams, the pillars are sized (`sizing`) to carry the load of the ones lost, and the beams to carry the span the lost pillar leaves: one pillar lost and the slab stays,
|
|
527
|
+
* the two ends of a side lost and that side comes down (owner, 2026-10-24: "4 pilares e a sustentação é a soma dos 4"; 2026-10-25: the real structure of the houses).
|
|
515
528
|
*/
|
|
516
529
|
declare const DEFAULT_SPECIMENS: readonly SpecimenDef[];
|
|
517
530
|
/** What the area keeps of a built specimen: the structure spec the house draws (what the destruction world is given) and the plan it came from. */
|
|
@@ -530,4 +543,88 @@ declare function specimenSpec(THREE: any, engine: FloorplanEngineLike, def: Spec
|
|
|
530
543
|
*/
|
|
531
544
|
declare function buildSpecimenMeshes(THREE: any, spec: any): any;
|
|
532
545
|
|
|
533
|
-
|
|
546
|
+
/** What `furnitureSpec` reads of a catalogue entry (the items of `game-floorplan-residential` and the other packs have more). */
|
|
547
|
+
interface FurnitureCatalogEntry {
|
|
548
|
+
type: string;
|
|
549
|
+
w: number;
|
|
550
|
+
d: number;
|
|
551
|
+
h: number;
|
|
552
|
+
}
|
|
553
|
+
interface FurnitureSpecOptions {
|
|
554
|
+
/** Size in metres (default: the catalogue entry of the type). */
|
|
555
|
+
w?: number;
|
|
556
|
+
d?: number;
|
|
557
|
+
h?: number;
|
|
558
|
+
/** Seed of the builder's random (the books of a shelf, the crates): same seed, same piece (default 1). */
|
|
559
|
+
seed?: number;
|
|
560
|
+
/** Builder-level choices. */
|
|
561
|
+
options?: {
|
|
562
|
+
/** Material of the destruction world per builder material key (`wood`, `metal`, `plain`, `fabric`, `glass`...), overriding the defaults. */
|
|
563
|
+
materials?: Record<string, string>;
|
|
564
|
+
/** Keep the chairs a table draws (default true). Chairs are drawn by the builder in a frame of their own, so this drops everything drawn in another frame than the piece's. */
|
|
565
|
+
chairs?: boolean;
|
|
566
|
+
/** Colour roles of the builder (`wood`, `fabric_main`, `fabric_accent`, `metal`...) as `0xRRGGBB`. */
|
|
567
|
+
palette?: Record<string, number>;
|
|
568
|
+
};
|
|
569
|
+
/** Catalogue the default size is read from (default `residentialItems`). */
|
|
570
|
+
catalog?: readonly FurnitureCatalogEntry[];
|
|
571
|
+
/** The `document` the house renderer makes its textures with (default the global one). */
|
|
572
|
+
document?: unknown;
|
|
573
|
+
}
|
|
574
|
+
interface FurnitureSpecResult {
|
|
575
|
+
/** One part per box or cylinder the builder drew, origin at the centre of the footprint on the floor. */
|
|
576
|
+
spec: DestructibleSpec;
|
|
577
|
+
/** Draws the piece: one mesh per part, named by the part id, coloured as the builder coloured it. */
|
|
578
|
+
build(THREE: any): any;
|
|
579
|
+
/** The widest high horizontal part and the height of its upper face (what loose things rest on), or null when the piece has none. */
|
|
580
|
+
top: {
|
|
581
|
+
part: string;
|
|
582
|
+
y: number;
|
|
583
|
+
} | null;
|
|
584
|
+
/** Size the piece was drawn at. */
|
|
585
|
+
size: {
|
|
586
|
+
w: number;
|
|
587
|
+
d: number;
|
|
588
|
+
h: number;
|
|
589
|
+
};
|
|
590
|
+
/** Where the water leaves the taps the builder drew (a sink, a tub), in the space of the spec; empty for furniture without a tap. */
|
|
591
|
+
spouts: Array<[number, number, number]>;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* The team's furniture as a destructible spec. It runs the builder of `type` (`FURNITURE.shelf` for `bookcase`, `FURNITURE.table` for `dining_table`,
|
|
595
|
+
* mapped in `furniture/type-table.ts`) unchanged, with a recording stand-in for the drawing api instead of the house's accumulators: every box and
|
|
596
|
+
* cylinder it draws becomes a part, named `<material key>_<n>` in drawing order (`wood_0`, `plain_17`), with the colour the builder gave it.
|
|
597
|
+
* Planes and leaves (flat, no volume) and water are left out.
|
|
598
|
+
*
|
|
599
|
+
* Materials: `wood` is `wood_hard`, and `wood_soft` for thin boards and panels (under 3.5 cm); `metal` is `steel`; `fabric`, `glass` and `plant` keep
|
|
600
|
+
* their name; `plain` is `plastic`, or `paper` for shelves and racks (their books and boxes). Parts that touch the floor are anchored. Joints come from
|
|
601
|
+
* `inferJoints` (screws between wood, welds or bolts between metal...), except that paper rests on what it lies on with a `resting` joint (weak: it falls when
|
|
602
|
+
* the board breaks) and is not joined to its neighbours.
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* const { spec, build, top } = furnitureSpec(THREE, 'bookcase') // 1.2 x 0.35 x 2 m, boards and books
|
|
606
|
+
*/
|
|
607
|
+
declare function furnitureSpec(THREE: any, type: string, opts?: FurnitureSpecOptions): FurnitureSpecResult;
|
|
608
|
+
interface TapSpecOptions {
|
|
609
|
+
/** `counter` (default): the tap of a sink, standing on the counter; `wall`: the tap of a laundry tub or a garden, with its plate on the wall. */
|
|
610
|
+
kind?: 'counter' | 'wall';
|
|
611
|
+
/** How far the counter tap's spout reaches, metres (default 0.2: the kitchen sink's). */
|
|
612
|
+
reach?: number;
|
|
613
|
+
/** The `document` the house renderer makes its textures with (default the global one). */
|
|
614
|
+
document?: unknown;
|
|
615
|
+
}
|
|
616
|
+
interface TapSpecResult {
|
|
617
|
+
/** The tap as parts (base, column, spout, lever), origin on the counter under the column (`counter`) or on the wall plate's centre line at the floor (`wall`). */
|
|
618
|
+
spec: DestructibleSpec;
|
|
619
|
+
/** Draws the tap: one mesh per part, named by the part id. */
|
|
620
|
+
build(THREE: any): any;
|
|
621
|
+
/** Where the water leaves the spout, in the space of the spec. */
|
|
622
|
+
spout: [number, number, number];
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* The team's tap (`counterTap` of the sink, `wallTap` of the laundry tub: `furniture/taps.ts`) drawn by the same code into parts, with the lever at rest. `spout` is where its
|
|
626
|
+
* water thread starts, so a host can put a tap of the fluids world there; the water thread itself is not drawn.
|
|
627
|
+
*/
|
|
628
|
+
declare function tapSpec(THREE: any, opts?: TapSpecOptions): TapSpecResult;
|
|
629
|
+
|
|
630
|
+
export { type AreaContext, type BuildOptions, DEFAULT_SPECIMENS, type Damageable, type DestructibleHouse, FLOORPLAN_AREA_ID, type FloorNavigator, type FloorplanEngineLike, type FloorplanTestOptions, type FurnitureCatalogEntry, type FurnitureSpecOptions, type FurnitureSpecResult, type House, type HouseRenderer, type HouseRendererOptions, type Messages, type NavFlight, type NavFloor, type NavHouse, type NavHouseDef, type NavRect, type NavResult, type NavShape, type NavStair, type NavigableHouse, type NavigationDefOptions, type NavigatorBinding, OPEN_ROOM_TYPES, SPECIMEN_AT, type SpecimenDef, type TapSpecOptions, type TapSpecResult, type TemplateGroup, type Translate, VERSION, bindNavigator, buildSpecimenMeshes, create, createFloorNavigator, createFloorplanTestModule, create as createHouseRenderer, createHouseScenarios, createTranslator, en, furnitureSpec, isOpenArea, locales, navigationDefOf, planLod, ptBR, rectsOf, specimenSpec, tapSpec };
|