@mark1russell7/room-view 0.2.4 → 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 +36 -34
- package/build/{anchors-Ba3OUmhF.js → check-DI_B57qy.js} +10 -233
- package/build/check-DI_B57qy.js.map +1 -0
- package/build/index.d.ts +4 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -5
- package/build/index.js.map +1 -1
- package/build/{layers-B5nL_lVW.js → layers-CDNFVXds.js} +161 -5
- package/build/layers-CDNFVXds.js.map +1 -0
- package/build/{layers-BO_MMtQJ.d.ts → layers-CYZwt1bH.d.ts} +34 -9
- package/build/layers-CYZwt1bH.d.ts.map +1 -0
- package/build/{level-CXCIX08K.js → level-BERjgyrT.js} +11 -37
- package/build/level-BERjgyrT.js.map +1 -0
- package/build/{level-Cjcf3u20.d.ts → level-m-mJ_3Ok.d.ts} +11 -19
- package/build/level-m-mJ_3Ok.d.ts.map +1 -0
- package/build/marks.d.ts +2 -2
- package/build/marks.js +1 -2
- package/build/marks.js.map +1 -1
- package/build/sample.d.ts +4 -4
- package/build/sample.d.ts.map +1 -1
- package/build/sample.js +21 -217
- package/build/sample.js.map +1 -1
- package/build/schema.d.ts +59 -9
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +250 -91
- package/build/schema.js.map +1 -1
- package/build/{solids-S_j17vFJ.d.ts → solids-OiTlb_Pm.d.ts} +9 -54
- package/build/solids-OiTlb_Pm.d.ts.map +1 -0
- package/build/three.d.ts +8 -16
- package/build/three.d.ts.map +1 -1
- package/build/three.js +12 -106
- package/build/three.js.map +1 -1
- package/package.json +1 -1
- package/build/anchors-Ba3OUmhF.js.map +0 -1
- package/build/layers-B5nL_lVW.js.map +0 -1
- package/build/layers-BO_MMtQJ.d.ts.map +0 -1
- package/build/level-CXCIX08K.js.map +0 -1
- package/build/level-Cjcf3u20.d.ts.map +0 -1
- package/build/loads-CtHa4EHo.js +0 -103
- package/build/loads-CtHa4EHo.js.map +0 -1
- package/build/loads-Diy6-Ekz.d.ts +0 -73
- package/build/loads-Diy6-Ekz.d.ts.map +0 -1
- package/build/solids-S_j17vFJ.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loads-CtHa4EHo.js","names":[],"sources":["../src/loads.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\nimport type { Scene } from \"./room.ts\";\n\n/** These are the levels of the load of a circuit. */\nexport const LOAD_LEVELS: readonly [\"unknown\", \"ok\", \"near\", \"over\"] = [\"unknown\", \"ok\", \"near\", \"over\"];\n\n/** A level of the load of a circuit. A viewer gives each level a color. */\nexport type LoadLevel = (typeof LOAD_LEVELS)[number];\n\n/** The state of one circuit of a scene. */\nexport interface CircuitState {\n /** The `id` of the circuit. */\n readonly circuit: string;\n /** The sum of the loads of the circuit, in watts. */\n readonly watts: number;\n /** The limit of the circuit, in watts. */\n readonly limit: number;\n /** The load as a part of the limit. It is 0 for a limit that is not above 0. */\n readonly ratio: number;\n readonly level: LoadLevel;\n /** The `id` of each outlet of the circuit. */\n readonly outlets: readonly string[];\n /** The `id` of each placed object with an outlet of the circuit. */\n readonly objects: readonly string[];\n}\n\n/** The options of the levels. */\nexport interface LoadOptions {\n /** A circuit with this part of its limit, or more, has the level `near`. The default is 0.8. */\n readonly near?: number | undefined;\n}\n\n/** The default part of the limit at which a circuit has the level `near`. */\nexport const NEAR_LIMIT = 0.8;\n\n/**\n * This function gives the state of each circuit of a scene, in the sequence of the circuits.\n *\n * The loads are input data: a calculation or a meter gives them. A circuit that no load record names has the level `unknown`,\n * and so has a circuit with a limit that is not above 0. A load above the limit has the level `over`.\n */\nexport function circuitStates(scene: Scene, options: LoadOptions = {}): readonly CircuitState[] {\n const near = options.near ?? NEAR_LIMIT;\n const outlets = scene.room.outlets ?? [];\n return (scene.room.circuits ?? []).map((circuit): CircuitState => {\n const loads = (scene.loads ?? []).filter((load) => load.circuit === circuit.id);\n const watts = loads.reduce((sum, load) => sum + load.watts, 0);\n const known = loads.length > 0 && circuit.limit > 0 && Number.isFinite(watts);\n const ratio = known ? watts / circuit.limit : 0;\n const mine = outlets.filter((outlet) => outlet.circuit === circuit.id).map((outlet) => outlet.id);\n return {\n circuit: circuit.id,\n watts,\n limit: circuit.limit,\n ratio,\n level: !known ? \"unknown\" : ratio > 1 ? \"over\" : ratio >= near ? \"near\" : \"ok\",\n outlets: mine,\n objects: (scene.objects ?? []).filter((object) => object.outlet !== undefined && mine.includes(object.outlet)).map((object) => object.id),\n };\n });\n}\n\n/**\n * This function gives the level of each outlet of a scene: the level of its circuit. The key is the `id` of the outlet.\n * An outlet with no circuit of the room has no level, and the map does not have it.\n */\nexport function outletLevels(scene: Scene, options: LoadOptions = {}): ReadonlyMap<string, LoadLevel> {\n const levels = new Map<string, LoadLevel>();\n for (const state of circuitStates(scene, options)) {\n for (const outlet of state.outlets) levels.set(outlet, state.level);\n }\n return levels;\n}\n\n/** These are the shapes of the sign of a level. */\nexport const LEVEL_SHAPES: readonly [\"ring\", \"disc\", \"triangle\", \"square\"] = [\"ring\", \"disc\", \"triangle\", \"square\"];\n\n/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */\nexport type LevelShape = (typeof LEVEL_SHAPES)[number];\n\n/**\n * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.\n * The level `unknown` has a ring, and so has an outlet with no level.\n */\nexport function levelShape(level: LoadLevel | undefined): LevelShape {\n return level === \"ok\" ? \"disc\" : level === \"near\" ? \"triangle\" : level === \"over\" ? \"square\" : \"ring\";\n}\n\n/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */\nexport interface ShapeOutline {\n /** The radius of the circle through the corners, for a disc with the radius 1. */\n readonly radius: number;\n /** The number of the sides. */\n readonly sides: number;\n /** The angle of the first corner, in radians, counter-clockwise from the x axis. */\n readonly start: number;\n /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */\n readonly hole: number;\n}\n\n/**\n * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.\n * A triangle and a square with the radius of the disc look small, so they are larger.\n */\nexport const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>> = {\n ring: { radius: 1, sides: 40, start: 0, hole: 0.52 },\n disc: { radius: 1, sides: 40, start: 0, hole: 0 },\n triangle: { radius: 1.3, sides: 3, start: Math.PI / 2, hole: 0 },\n square: { radius: 1.25, sides: 4, start: Math.PI / 4, hole: 0 },\n};\n\n/**\n * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.\n * The center of the sign is the origin, and `radius` is the radius of a disc.\n */\nexport function shapeRing(shape: LevelShape, radius: number = 1): Ring {\n const outline = SHAPE_OUTLINES[shape];\n return Array.from({ length: outline.sides }, (_, index): readonly [number, number] => {\n const angle = outline.start + (index * 2 * Math.PI) / outline.sides;\n return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];\n });\n}\n"],"mappings":";;AAIA,MAAa,cAA0D;CAAC;CAAW;CAAM;CAAQ;AAAM;;AA6BvG,MAAa,aAAa;;;;;;;AAQ1B,SAAgB,cAAc,OAAc,UAAuB,CAAC,GAA4B;CAC9F,MAAM,OAAO,QAAQ,QAAA;CACrB,MAAM,UAAU,MAAM,KAAK,WAAW,CAAC;CACvC,QAAQ,MAAM,KAAK,YAAY,CAAC,EAAA,CAAG,KAAK,YAA0B;EAChE,MAAM,SAAS,MAAM,SAAS,CAAC,EAAA,CAAG,QAAQ,SAAS,KAAK,YAAY,QAAQ,EAAE;EAC9E,MAAM,QAAQ,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,OAAO,CAAC;EAC7D,MAAM,QAAQ,MAAM,SAAS,KAAK,QAAQ,QAAQ,KAAK,OAAO,SAAS,KAAK;EAC5E,MAAM,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ;EAC9C,MAAM,OAAO,QAAQ,QAAQ,WAAW,OAAO,YAAY,QAAQ,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,KAAK,KAAM,QAAQ;EAC9D,OAAO,CAAC,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,GAAG,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,CAAC;CAC9F,CAAC;AACH"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { B as Scene } from "./solids-S_j17vFJ.js";
|
|
2
|
-
import { Ring } from "@mark1russell7/layout-contract";
|
|
3
|
-
/** These are the levels of the load of a circuit. */
|
|
4
|
-
declare const LOAD_LEVELS: readonly ["unknown", "ok", "near", "over"];
|
|
5
|
-
/** A level of the load of a circuit. A viewer gives each level a color. */
|
|
6
|
-
type LoadLevel = (typeof LOAD_LEVELS)[number];
|
|
7
|
-
/** The state of one circuit of a scene. */
|
|
8
|
-
interface CircuitState {
|
|
9
|
-
/** The `id` of the circuit. */
|
|
10
|
-
readonly circuit: string;
|
|
11
|
-
/** The sum of the loads of the circuit, in watts. */
|
|
12
|
-
readonly watts: number;
|
|
13
|
-
/** The limit of the circuit, in watts. */
|
|
14
|
-
readonly limit: number;
|
|
15
|
-
/** The load as a part of the limit. It is 0 for a limit that is not above 0. */
|
|
16
|
-
readonly ratio: number;
|
|
17
|
-
readonly level: LoadLevel;
|
|
18
|
-
/** The `id` of each outlet of the circuit. */
|
|
19
|
-
readonly outlets: readonly string[];
|
|
20
|
-
/** The `id` of each placed object with an outlet of the circuit. */
|
|
21
|
-
readonly objects: readonly string[];
|
|
22
|
-
}
|
|
23
|
-
/** The options of the levels. */
|
|
24
|
-
interface LoadOptions {
|
|
25
|
-
/** A circuit with this part of its limit, or more, has the level `near`. The default is 0.8. */
|
|
26
|
-
readonly near?: number | undefined;
|
|
27
|
-
}
|
|
28
|
-
/** The default part of the limit at which a circuit has the level `near`. */
|
|
29
|
-
declare const NEAR_LIMIT = .8;
|
|
30
|
-
/**
|
|
31
|
-
* This function gives the state of each circuit of a scene, in the sequence of the circuits.
|
|
32
|
-
*
|
|
33
|
-
* The loads are input data: a calculation or a meter gives them. A circuit that no load record names has the level `unknown`,
|
|
34
|
-
* and so has a circuit with a limit that is not above 0. A load above the limit has the level `over`.
|
|
35
|
-
*/
|
|
36
|
-
declare function circuitStates(scene: Scene, options?: LoadOptions): readonly CircuitState[];
|
|
37
|
-
/**
|
|
38
|
-
* This function gives the level of each outlet of a scene: the level of its circuit. The key is the `id` of the outlet.
|
|
39
|
-
* An outlet with no circuit of the room has no level, and the map does not have it.
|
|
40
|
-
*/
|
|
41
|
-
declare function outletLevels(scene: Scene, options?: LoadOptions): ReadonlyMap<string, LoadLevel>;
|
|
42
|
-
/** These are the shapes of the sign of a level. */
|
|
43
|
-
declare const LEVEL_SHAPES: readonly ["ring", "disc", "triangle", "square"];
|
|
44
|
-
/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */
|
|
45
|
-
type LevelShape = (typeof LEVEL_SHAPES)[number];
|
|
46
|
-
/**
|
|
47
|
-
* This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
|
|
48
|
-
* The level `unknown` has a ring, and so has an outlet with no level.
|
|
49
|
-
*/
|
|
50
|
-
declare function levelShape(level: LoadLevel | undefined): LevelShape;
|
|
51
|
-
/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */
|
|
52
|
-
interface ShapeOutline {
|
|
53
|
-
/** The radius of the circle through the corners, for a disc with the radius 1. */
|
|
54
|
-
readonly radius: number;
|
|
55
|
-
/** The number of the sides. */
|
|
56
|
-
readonly sides: number;
|
|
57
|
-
/** The angle of the first corner, in radians, counter-clockwise from the x axis. */
|
|
58
|
-
readonly start: number;
|
|
59
|
-
/** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */
|
|
60
|
-
readonly hole: number;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
|
|
64
|
-
* A triangle and a square with the radius of the disc look small, so they are larger.
|
|
65
|
-
*/
|
|
66
|
-
declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
|
|
67
|
-
/**
|
|
68
|
-
* This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
|
|
69
|
-
* The center of the sign is the origin, and `radius` is the radius of a disc.
|
|
70
|
-
*/
|
|
71
|
-
declare function shapeRing(shape: LevelShape, radius?: number): Ring;
|
|
72
|
-
export { LoadLevel as a, SHAPE_OUTLINES as c, levelShape as d, outletLevels as f, LevelShape as i, ShapeOutline as l, LEVEL_SHAPES as n, LoadOptions as o, shapeRing as p, LOAD_LEVELS as r, NEAR_LIMIT as s, CircuitState as t, circuitStates as u };
|
|
73
|
-
//# sourceMappingURL=loads-Diy6-Ekz.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loads-Diy6-Ekz.d.ts","names":[],"sources":["../src/loads.ts"],"mappings":";;;cAIa;;KAGD,oBAAoB;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,OAAO;;WAEP;;WAEA;;;UAIM;;WAEN;;;cAIE;;;;;;;iBAQG,cAAc,OAAO,OAAO,UAAS,uBAA4B;;;;;iBAyBjE,aAAa,OAAO,OAAO,UAAS,cAAmB,oBAAoB;;cAS9E;;KAGD,qBAAqB;;;;;iBAMjB,WAAW,OAAO,wBAAwB;;UAKzC;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;cAOE,gBAAgB,SAAS,OAAO,YAAY;;;;;iBAWzC,UAAU,OAAO,YAAY,kBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solids-S_j17vFJ.d.ts","names":[],"sources":["../src/units.ts","../src/room.ts","../src/frames.ts","../src/joins.ts","../src/solids.ts"],"mappings":";;cAGa;;KAGD,qBAAqB;;iBAGjB,UAAU,MAAM;;iBAKhB,SAAS,MAAM,YAAY,OAAO;;;;;cAQrC;;iBAGG,kBAAkB;;KCrBtB;;cAGC;;cAGA;;;;;iBAMG,YAAY;;cAKf;;;;;KAMD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