This example is a complete 3D showcase solution. An overview of an energy hub (oil field, refinery, tank farm, onshore and offshore wind, solar plant, fuel station and marine terminal) opens three detailed 3D screens: a wind turbine with a cutaway nacelle, a crude distillation unit the operator runs by clicking valves and pumps, and a marine terminal loading a tanker. Each 3D object is a custom control built with the Portable API, so the same solution runs in the RichClient, the SmartClient and the HTML5 client.
Every value in the 3D comes from tags, the 3D writes values back to tags, and a server script task simulates the process with cause and effect. A guided tour in the header walks through all four screens for presentations.
Download Energy Hub 3D Demo 10.1.6.zip. It has everything needed to run the example:
the solution,
Energy Hub 3D Demo.dbsln;the four compiled controls and the 3D scenes, in the folders they go into under
fx-10;Install-Controls.cmd, a double-click installer that copies and checks them;README.mdwith the install and run steps;the source code: the C# controls, the 3D engine and scenes, and the generator that writes the controls.
Validated with FrameworX 10.1.6 (build 3053) in the RichClient and the HTML5 client. No devices or databases are needed: a script task simulates the plant. For other versions, see Other FrameworX versions below.
The Overview in the RichClient. Areas marked "3D detail" open their own 3D screen when clicked. The panel on the right writes the tags the 3D reads and shows the production the 3D writes back.
What the example shows
Four portable controls, one per screen:
PlantOverview3DView,WindTurbine3DView,Refinery3DViewandMarineTerminal3DView. Each is listed in the Components panel like a built-in control and configured in its own panel in the Designer.One 3D engine for every client. The scenes are written once in JavaScript with three.js. The HTML5 client runs them in the browser; the RichClient and SmartClient run the same files in Microsoft Edge WebView2.
Tags in and out. Every input of a scene is a link (a constant, a tag or an expression). Scenes write values back to tags, and write the id of the component the operator clicks.
Interaction in the 3D. Hover a component for its live values, click it to select it or fly the camera to it, click a refinery valve or pump to operate it. Camera views and modes (X-ray, Thermal, Exploded, Flow) are buttons in the 3D and can also be driven by tags.
Cause and effect. The
Simulationtask links the screens: wind drives the turbines, valves and pumps drive the refinery flows and tank levels, naphtha leaves to the tanker while it loads.Day and night from one tag on every screen, and a guided tour of 14 steps for presentations.
Standard controls around the 3D: each screen has a panel of Slider, ToggleSwitch, TextBlock and Button controls bound to the same tags.
Install the controls
The controls are not part of the product, so they go into the installation before the solution opens. Do this once per computer that runs the Designer, the RichClient or the runtime server.
Unblock the download before you unzip it. Windows marks files downloaded from the internet as blocked, and the DLLs extracted from a blocked zip are blocked too. FrameworX does not load a blocked control DLL: the control is missing from the Components panel or the display does not show it.
Right-click Energy Hub 3D Demo 10.1.6.zip, select Properties, tick Unblock and click OK, then extract it. The installer also unblocks the files it copies.
Unblock the zip as described above.
Right-click the zip, select Extract All, then Extract.
Close the Designer and every FrameworX client.
In the extracted files, open the Energy Hub 3D Demo folder (the one with
README.md) and double-click Install-Controls.cmd. Click Yes when Windows asks to allow changes: the files go under Program Files.A window lists the 20 files it copied and ends with
20 of 20 files installed. Press any key to close it.Open the Designer. The four controls are listed in the Components panel under Viewer.
If FrameworX is not installed in C:\Program Files\Tatsoft\FrameworX, open PowerShell as administrator, go to the extracted Energy Hub 3D Demo folder with cd, and run the script with your own fx-10 folder:
cd "$env:USERPROFILE\Downloads\Energy Hub 3D Demo 10.1.6\Energy Hub 3D Demo" powershell -ExecutionPolicy Bypass -File .\Install-Controls.ps1 -FxPath "D:\Tatsoft\FrameworX\fx-10"
The first line is where Extract All puts the files when the zip is in Downloads; change it if you extracted elsewhere.
To copy by hand instead, copy the contents of Controls for FrameworX 10.1.6\fx-10\ into your installation's fx-10 folder, keeping the folders, then unblock each copied DLL:
Folder under fx-10 | Files | Used by |
|---|---|---|
| 4 DLLs, | Designer, RichClient, SmartClient |
| 4 DLLs with the same names | HTML5 client |
| three.js, the 3D engine | All clients |
Run the solution
Copy
Energy Hub 3D Demo.dbslnto any folder (for exampleDocuments\FrameworX\Solutions) and open it in the Solution Center.In the Designer, go to Runtime > Startup and click Run Startup (see Runtime Startup Reference). The RichClient opens maximized on the Overview.
For the browser, click Web in the header, or open
http://<server>:3201/html5/.
The first time a 3D screen opens it shows its preview image with Loading 3D for about two seconds while the scene starts. Opening it again is instant.
Try it yourself
Overview
Hover an area to see its live values. Click an area marked 3D detail (wind farm, offshore wind, refinery, cracking unit, tank farm, LPG spheres or the marine terminal) to open its 3D screen. The Turbine, Refinery and Terminal buttons in the panel, and the header buttons, do the same.
Move Wind speed or turn Gusty wind off. The turbines start at 3 m/s and reach rated power at 12 m/s; Wind under Production is computed by the 3D and written to a tag.
Use Overview, Energy, Oil and Port at the top of the 3D to fly the camera. Drag to rotate, right-drag to pan, use the wheel to zoom.
Wind Turbine
Nacelle view with X-ray and Thermal on, after Simulate gearbox damage: the gearbox turns orange as its oil heats up, and vibration rises to 7.8 mm/s.
Click Nacelle or Drivetrain at the top of the 3D. With X-ray on, the drivetrain shows through the nacelle cover: main bearing, gearbox, brake and generator, each with its temperature.
Turn Thermal on, then Simulate gearbox damage in the panel. The gearbox heats up over a few seconds and its vibration passes the 7.1 mm/s alarm level.
Turn Exploded on to pull the drivetrain apart. Click any component: its id is written to
Turbine/Selectedand shown as Last clicked.Move Wind direction: the nacelle yaws to face the wind. Turn Turbine running off: the brake applies and the blades feather.
Refinery
Reflux valve FV-102 closed: the column top reached 141 °C and 2.0 bar g, and flare FL-101 burns the excess.
With Flow on, the pipes show product moving wherever a pump runs and the valves on its path are open.
Click a valve or a pump in the 3D to open or close it, or start or stop it. The click writes the same tag as the switch in the panel, so both stay in step. Close FV-101 feed valve and the feed, the product flows and the heater temperature fall.
Close FV-102 reflux valve. The column top heats up and the pressure climbs; above 1.8 bar g the flare lights. Open it again and the column recovers.
Click Column and turn X-ray on to see the trays inside the column, coloured by temperature.
Column view in X-ray: trays, liquid and vapor from the hot bottom (345 °C) to the overhead.
Marine Terminal
The tanker loads naphtha at the jetty while three trucks drive the loop road. Each truck is drawn where its route-progress tag says.
Watch the cycle: the tanker loads, the loading arms disconnect when it is full, a new empty tanker berths and the arms connect again. Turn Automatic ship and truck cycle off to hold it.
Click Ship and turn X-ray cargo tanks on to see the load in each cargo tank. The ship's draft follows the load.
Click Trucks and turn Truck routes on. The positions come from
Terminal/Truck1PostoTruck3Pos, the way an AMR fleet manager or a GPS feed would supply them; the 3D writes each truck's X and Z back to tags.Move Sea state, turn Tugs standing by or Loading arms connected off.
Ship view with the cargo tanks in X-ray and the tugs standing by.
Day, night and the guided tour
Drag Hour of day on the Overview, or turn Day cycle on in the header (15 minutes of plant time per second). Every screen follows the same clock: street lamps, lit windows, floodlights, ship navigation lights and red aviation lights come on at night, and solar power drops to zero.
Turn Tour on in the header. The tour visits the four screens in 14 steps (about two and a half minutes, then it loops), sets each camera view and mode, and stages two events: the gearbox fault and the closed reflux valve. A caption beside the switch explains each step. Click an area on the Overview, or turn Tour off, to stop it.
Theme switches the client between dark and light, Info opens this page.
The Overview at 20:30, with a full tanker leaving and an empty one arriving.
Tags
The solution has 82 tags under EnergyHub. Each 3D control links to them in its configuration panel (double-click the control in the Designer).
Folder | Tags | Written by |
|---|---|---|
|
| Panels, header, |
|
|
|
| Inputs: | Inputs: the Overview panel switches; the others keep their start values. Outputs: the Overview 3D |
| Inputs: | Temperatures and vibration: |
|
| Valves and pumps: panel or a click in the 3D. Flows, levels, temperatures, pressure, flare: |
| Inputs: | Ship cycle and truck positions: |
|
| The 3D (clicked component) and the tour. These are Client-domain tags, so each client navigates and tours on its own |
How it is built
Four controls, one 3D engine
Each control class (for example T.Portable.Controls.TRefinery3DView) implements IPortableControl and is compiled twice: for the WPF clients and, with OpenSilver, for the HTML5 client. The 3D itself is JavaScript in HTML5\Libraries\Demo3D: a shared engine, fx3d-core.js (renderer, camera, picking, tooltips, value labels, day and night, views, modes), and one scene file per control.
In the HTML5 client, the control declares the scripts through
IHTML5ControlDependenciesand the browser runs the scene directly.In the RichClient and SmartClient, the control hosts a WebView2 that maps
HTML5\Libraries\Demo3Dto a local address and openshost.html?scene=<name>. WebView2 ships with FrameworX. The WebView2 stays alive while the display is cached, so reopening a screen is instant.In the Designer, the control shows a still preview of its scene.
Tag links
Every property in a control's configuration panel is a link: a constant, a tag or an expression. When the display opens, StartRuntime() turns each link into an ObjectReference and pushes a value to the scene only when it changes. The scene answers with messages the control turns into tag writes:
Outputs, such as
Poweror the truck positions, are written twice a second, only when they changed.Selected receives the id of the component the operator clicked.
Commands: clicking a valve or pump writes the tag linked to that input, so the 3D and the panel switch control the same tag.
View and Modes are inputs too: writing
columntoRefinery/Viewflies the camera, writingxray,flowtoRefinery/Modesswitches those modes on and the others off. The tour uses them.
Opening a screen from the 3D
The Overview control writes the clicked zone to Navigation/SelectedZone, and the MainPage code-behind opens the matching screen:
public async Task DisplayIsOpen()
{
string zone = @Tag.EnergyHub/Navigation/SelectedZone;
if (string.IsNullOrEmpty(zone))
return;
@Tag.EnergyHub/Navigation/SelectedZone = "";
string target = "";
if (zone == "WindFarm" || zone == "OffshoreWind")
target = "WindTurbine";
else if (zone == "Refinery" || zone == "CrackingUnit" || zone == "TankFarm" || zone == "LpgSpheres")
target = "Refinery";
else if (zone == "MarineTerminal")
target = "Terminal";
if (target == "")
return;
if (@Tag.EnergyHub/Settings/Tour == 1)
@Tag.EnergyHub/Settings/Tour = 0;
@Client.OpenDisplay(target);
}
Simulation
The server script task Simulation runs every second. Values move toward targets with first-order lags, so they change smoothly, and the areas affect one another. The refinery part shows the pattern:
// Flows follow the valves and pumps. double feed = (p1 && v1 && t1 > 2) ? setpoint : 0; double naphtha = (feed > 0 && p2 && v3) ? feed * 0.35 : 0; double residue = (feed > 0 && v4) ? feed * 0.45 : 0; // Without reflux the column top heats up and the pressure climbs until the flare lights. @Tag.EnergyHub/Refinery/ColumnTopTemp = Math.Round(cT + ((on ? (v2 ? 118 : 152) : 70) - cT) * 0.05, 1); double pTarget = (on ? (v2 ? 1.4 : 2.1) : 1.0) + (rnd.NextDouble() - 0.5) * 0.04; cP = cP + (pTarget - cP) * 0.08; @Tag.EnergyHub/Refinery/ColumnPressure = Math.Round(cP, 3); @Tag.EnergyHub/Refinery/Flare = cP > 1.8 ? 1 : 0;
The same task advances the clock, makes the wind gust, heats the gearbox when GearboxFault is set, lets naphtha leave to the tanker while it loads, runs the ship cycle and moves the trucks along their route.
Guided tour
The Header display's code-behind runs the tour every 500 ms while Settings/Tour is 1. Each step opens a display, writes the scene's View and Modes tags, sets the caption in Settings/TourText, and waits a fixed number of seconds. Turning the tour off restores the staged process tags.
Known limits
Nothing can be drawn over the 3D area in the RichClient and SmartClient: WebView2 is a native window. The panels sit beside the 3D.
Each open client runs its own copy of each scene, so outputs computed by the 3D (Overview production, turbine power) are written by every client that shows them, with small differences between clients.
A graphics card is recommended. Without one the 3D runs in software and the frame rate is low.
Other FrameworX versions
The HTML5 build of a portable control must use the same OpenSilver version as the FrameworX web client, so the compiled controls in the download are for FrameworX 10.1.6 (build 3053). For another version, rebuild them from the Source folder of the download:
Find the commit at the end of the ProductVersion of
fx-10\HTML5\_framework\OpenSilver.dllin your installation, and set the OpenSilver package whose name ends with that commit in eachT<Name>3DView.HTML5.csproj.Build the WPF projects (.NET Framework 4.8) and the HTML5 projects in Release, then copy the DLLs and the
web\Demo3Dfiles as described in Install the controls (Source\deploy.ps1does it).
The JavaScript scenes do not depend on the FrameworX version. The build steps and rules are in Portable API Reference.
Related
Portable API Reference: build a control that runs in the WPF clients and in the browser.
Custom Control API Reference: choose between WPF, Blazor and Portable controls.
3D Visualization Reference: 3D scenes in WPF displays with the built-in 3D host.
three.min.js is three.js r128, MIT license; the license file is in the download.
In this section...






