OpenAFPM CAD Visualization
Module for visualizing openafpm-cad-core 3D wind turbine model created in FreeCAD via a web browser.
- Create the 3D model in FreeCAD.
- Export the 3D model to Wavefront OBJ (
.obj
) format. - Load the 3D model (
.obj
file) with three.js.
Prerequisites
Install Node.js.
How to Run
-
Install dependencies.
npm install
-
(OPTIONAL) Build bundle if you want to make changes to files in
src/
.npm run watch
-
Start server.
npm run serve
-
Navigate to http://127.0.0.1:8080/ in your web browser of choice. Currently tested in Chrome.
Additionally, on UNIX-like operating systems, you can run npm start
; which runs npm run watch
and npm run serve
in parallel.
Wind Turbine Object Names
A list of object names that MUST be present in the .obj
file for the Wind Turbine.
In the Wavefront .obj format, object names start with o
and are delimited with a space on their own line (e.g. o Coils
).
- Stator_Coils
- Stator_ResinCast
- Rotor_Disk_Front
- Rotor_ResinCast_Front
- Rotor_Magnets_Front
- Rotor_Disk_Back
- Rotor_ResinCast_Back
- Rotor_Magnets_Back
- Hub_Flange
- Hub_Flange_Cover_Front
- Hub_Flange_Cover_Back
- Hub_StubAxleShaft
- Studs_Hub
- Frame
- YawBearing
- Tail_Hinge_Inner
- Tail_Hinge_Outer
- Tail_Boom_Pipe
- Tail_Boom_Support
- Tail_Stop_HighEnd
- Vane_Bracket_Top
- Vane_Bracket_Bottom
- Tail_Vane
- Studs_Frame
- Bolts (used by Tools)
- Nuts (used by Tools)
- *Screws (used by Tools)
- LocatingWashers (used by Stator Mold)
- LocatingBolts (used by Stator Mold)
- Washers (used by Rotor Mold)
- Rotor_MagnetJig (used by Magnet Jig)
- Rotor_MagnetJig_Disk (used by Magnet Jig)
- Rotor_Magnets (used by Magnet Jig)
- Rods (used by Coil Winder)
* Denotes and "ends with" match is performed.
API
OpenAfpmCadVisualization
Constructor
Construct a new OpenAFPM CAD visualization instance.
Behind the scenes constructs a WebGLRenderer, and a single instance is intended to be used throughout the lifetime of various visualizations (i.e. Wind Turbine and tools).
It also appends style
elements to the head
of the document.
Arguments
Name | Type | Required | Description |
---|---|---|---|
options |
Object |
true |
See below rows documenting properties. |
options.rootDomElement |
Element |
true |
DOM element to mount visualization elements to. |
options.width |
number |
true |
Width of visualization. |
options.height |
number |
true |
Height of visualization. |
visualize(loadObj, assembly, furlTransformPromise)
Arguments
Name | Type | Required | Description |
---|---|---|---|
loadObj |
function(): Promise.<string> |
true |
Zero-argument function returning a Promise that resolves to Wavefront OBJ file contents. |
assembly |
[string ] |
true |
Assembly of visualization. Must be one of "WindTurbine" , "StatorMold" , "RotorMold" , "MagnetJig" , or "CoilWinder" . |
furlTransformPromise |
Promise.<FurlTransform> |
true when type === "WindTurbine" , false otherwise. |
When assembly === "WindTurbine" , the Promise must resolve to a FurlTransform object. See below table for details. |
FurlTransform
Name | Type | Required | Description |
---|---|---|---|
furlTransform |
Object |
true |
An object representing how to furl the tail. |
maximum_angle |
number |
true |
Maximum angle (in degrees) to furl the tail before high end stop hits the yaw bearing pipe. |
transforms |
Array.<Transform> |
true |
Three element array of Transform objects needed to furl the tail. See below table for details. |
Transform
Name | Type | Required | Description |
---|---|---|---|
transform |
Object |
true |
An object representing a 3D transformation in Axis–angle representation. |
transform.name |
string |
false |
Name of transformation for descriptive purposes. (optional). |
transform.position |
Array.<number> |
true |
Three element array for x, y, and z coordinates. |
transform.axis |
Array.<number> |
true |
Axis of rotation, three element array for x, y, and z axes. |
transform.angle |
number |
true |
Angle of rotation (in radians). |
resize(width, height)
Resize visualization to specified width
and height
.
Arguments
Name | Type | Required | Description |
---|---|---|---|
width |
number |
true |
Width to resize visualization to. |
height |
number |
true |
Height to resize visualization to. |
Returns: undefined
handleMouseMove(event)
Display tooltip if cursor hovers over part and update internal mouse coordinates.
This method is debounced with a 10 millisecond wait time.
Arguments
Name | Type | Required | Description |
---|---|---|---|
event |
MouseEvent |
true |
mousemove event. |
Returns: undefined
cleanUp()
Performs various clean-up such as disposing geometries and materials.
Returns: undefined
Themeing
Basic themeing support is available via the data-theme
attribute on the rootDomElement
.
Supported values include "light"
(the default) and "dark"
.