Garden
This example shows how you can use a single form to control multiple systems. For example, you may create one form to control all main components in a home, such as heating, lighting and irrigation of the garden.
Solids
A garden light is created by a black cylinder and a small cylinder on top that emits a certain color of light. The color is defined as a parameter of the part.
An irrigation system includes a schematic representation of an underground water reservoir, a pump, some pipes and a sprinkler. The irrigation system has a parameter on
that specifies if the pump is on or off. If the parameter is 1
, a transparent blue water spray is created to simulate an active sprinkler.
Topics
The garden includes a tree with an associated photo and glTF model, the irrigation system and the garden lights. The display of irrigation system and garden lights is specified by a controller with status 'on', 'off' or 'auto'. The status of the controllers are used to set the '0' or '1' status of the irrigation system and the color of the garden lights. In this case the garden lights are set to black (off) if the controller for the lights does not have the value 'on'.
building.home.garden.tree.geometry = maple_tree.glb
building.home.garden.tree.translation = -3.5, 8, 0.3
building.home.garden.tree.scale = 2, 2, 2
building.home.garden.tree.photo = maple_tree.jpg
building.home.garden.irrigation.controller = on
building.home.garden.irrigation.geometry = Irrigation(building.home.garden.irrigation.controller === 'off' ? 0 : 1)
building.home.garden.lights.controller
building.home.garden.lights.geometry = H09.Garden lights(building.home.garden.lights.controller === 'on' ? 'yellow' : 'black')
Form
In the previous examples we have used forms that are associated to a single solid or glTF model, such as a heating system or solar panel. It can also be useful to define a form where you can display values of multiple items, for example, a form where you can control both the irrigation and lighting system. You can do this by specifying the subtopic as the key for a form field. This form is used to display information on the item building.home
and to include a display of the moisture
you specify the subtopic garden.irrigation.moisture
. The form also includes two topics that are used to control the irrigation and lighting systems.
Home
garden.irrigation.controller:Irrigation
["on","off","auto"]
garden.lights.controller:Lights
["on","off","auto"]
garden.irrigation.moisture:Moisture
[0|20:red,20|80:green,80|100:blue]
garden.irrigation.battery:Battery
[0|10:red,10|20:yellow,20|100:green]
Model
The model contains a list of all subtopics that should be displayed. The display of each subsystem can be controlled by the switch after the topic. If the user clicks on the tree, the form with information about the tree is displayed.
If you click on somewhere in the 3D viewer where there is no geometry, the default form defined in the model is displayed for the topic defined in the field 'item'. In this case the information about the topic building.home
is displayed.