new NURBS( [config] [, typeName])
Creates a new NURBS surface terrain representation.
Parameters:
| Name | Type | Argument | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
<optional> |
An optional configuration object. |
||||||||||||||||||||||||
Properties of
|
|||||||||||||||||||||||||||
| Name | Type | Argument | Description |
|---|---|---|---|
name |
string |
<optional> |
A human-readable name for this component. |
uuid |
string |
<optional> |
A universally unique identifier of this component. |
productRef |
string |
<optional> |
The product reference number or identifier.. |
description |
string |
<optional> |
A brief product or type description. |
supplier |
BIM.Supplier |
<optional> |
An optional supplier details data object. |
typeNameAn additional parameter typically used by subclasses to set the
component type name without modifying the config object.
Extends
Members
-
:boolean
applyGradient
-
Whether or not to grade the surface from zero to height, defaults to false.
Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
applyNoise
-
Whether or not to add random noise to surface, defaults to false.
Type
- boolean
- Inherited From:
- Overrides:
-
:string
className <readonly>
-
The name of the subclass for this object instance.
This name must match the name of this class within the
PD.Registry. Thus, the base implementation simply referencesthis.constructor.getClassName()to ensure that this is always the case even for subclasses. As a result, there is rarely any need to override this method.This property is used when copying, storing and exporting data for subclass instances to ensure that they are recreated as instances of the right class.
Type
- string
- Inherited From:
- Overrides:
-
:string
description
-
A brief product or type description, defaults to an empty string.
This description is typically used to provide additional information about the product to other team members, such as its reasons for selection. important features, specifications and/or intended use.
Type
- string
- Inherited From:
- Overrides:
-
:string
displayName <readonly>
-
The name to display for this class within the user interface.
Type
- string
- Inherited From:
- Overrides:
-
:number
gradientDirection
-
The direction of slope fall-off given CCW from the +X axis, defaults to 0deg (-X).
This is given as a mathematical angle rather than a cartesian angle as we don't want it to be confused in any way with the North offset angle, which is given CW from the +Y axis. Making it CCW from the +X axis allows it to use standard maths and makes it clear that it is a model-based angle.
Type
- number
- Inherited From:
- Overrides:
-
:number
gridDensity
-
The density of sample grid cells over the surface, defaults to 15.
Type
- number
- Inherited From:
- Overrides:
-
:number
gridPower
-
The power applied to the distance weighting process, defaults to 2.0.
Type
- number
- Inherited From:
- Overrides:
-
:number
gridRadius
-
The radius of influence of each point in the grid, defaults to 4.0.
Type
- number
- Inherited From:
- Overrides:
-
:number
gridVariance
-
The degree of uniformity in spacing of sample grid cells over the surface, defaults to 0.25.
Type
- number
- Inherited From:
- Overrides:
-
:string
iconName <readonly>
-
The name of the SVG icon to associate with this object instance.
This name should match the name of the icon associated with this class within the
PD.Registry. Thus, the default implementation simply referencesthis.constructor.getClassName()to ensure that this is always the case, even for subclasses. However, you can override this property if you want a different icon dependant on other properties of the class instance, as shown in the example below.Type
- string
- Inherited From:
- Overrides:
Example
// Overriding the icon name. MyElements.Table = class extends PD.Base { /// ... get iconName() { if (this.hasRoundTop) return 'MyElements.Table.Round'; return this.constructor.getClassName(); }; /// ... }; -
:boolean
interpolateSurface
-
Whether to spatially interpolate a surface grid from raw spot heights.
Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
isComponent <readonly>
-
A flag identifying this object as a shared BIM component.
Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
isLocked
-
Whether or not this component's parameters are fixed.
This property is used by the UI and framework to indicate that the component's parameters are fixed and therefore not editable. It is typically set by a 3rd-party manufacturer or supplier on products that they can only provide in one configuration.
For example, there is no point specifying a particular manufacturer's fridge and then adjusting its width to fit a hole in your cabinetry if that manufacturer cannot actually supply a fridge of that width.
Thus, when this property is
true, you will not be able to edit the parameters, but you can always duplicate the component (or its configuration), but without the supplier details if you really do want to modify it.Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
isNURBSTerrainType <readonly>
-
A flag identifying this object as a NURBS terrain type.
Type
- boolean
-
:boolean
isTerrainType <readonly>
-
A flag identifying this object as a terrain type.
Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
keepAspect
-
Whether to make the number of grid cells in the X and Y axis the same.
Type
- boolean
- Inherited From:
- Overrides:
-
:string
name
-
A human-readable name for this item instance.
Type
- string
- Inherited From:
- Overrides:
-
:THREE.Vector2
noiseOffset
-
The noise function 2D offset factor.
Type
- THREE.Vector2
- Overrides:
-
:THREE.Vector2
noiseScale
-
The noise function 2D scale factor.
Type
- THREE.Vector2
- Overrides:
-
:string
productRef
-
The product reference number or identifier, defaults to an empty string.
The product reference is typically used to store a serial number, model number, SKU or other identifier provided by the manufacturer or supplier to uniquely identify this product.
Type
- string
- Inherited From:
- Overrides:
-
:number
spotDensity
-
The density of the spot heights over surface, defaults to 8.
Type
- number
- Inherited From:
- Overrides:
-
:number
subType <readonly>
-
An element-specific subtype.
Type
- number
- Inherited From:
- Overrides:
-
:string
supplier
-
The product supplier/manufacturer, defaults to
null.This property contains details of the supplier or manufacturer of this product or component. Multiple components can share the same supplier instance to avoid unnecessary duplication of data.
Type
- string
- Inherited From:
- Overrides:
-
:string
uuid
-
A universally unique identifier for the item instance.
Type
- string
- Inherited From:
- Overrides:
Methods
-
clone()
-
Creates a copy of this instance with different name and uuid.
- Inherited From:
- Overrides:
Returns:
Returns a new instance with copied values.
- Type
- PD.Base | null
-
copySpotHeightsToSurfacePoints(terrain, spotHeights)
-
Copy spot heights to surface points with optional Perlin noise.
Parameters:
Name Type Description terrainBIM.Terrain The terrain element this component is controlling.
spotHeightsArray.<Array.<number>> An array of [x,y,z,u,v] spot height positions.
- Inherited From:
- Overrides:
-
generateSpotHeights(terrain)
-
Generate the base spot heights that govern the interpolated surface.
The aim is that spot heights can be generated in a variety of different ways, such as a grid of mathematically calculated points, a set of measured points heights, lines of imported contours, etc.
Once defined, a gridded surface can be interpolated from these spot heights using a range of different algorithms, such as a inverse distance, NURBS curve fitting, or even just triangulating the raw control nodes
Each subclass can offer a different set of options for generating spot heights. This default implementation generates a flat grid of control nodes that is either horizontal or sloping in a given direction.
The return value of this method must be an array of spot heights, where each spot height is an array of five (5) numbers where the first three (3) are the absolute X, Y and Z values of the point in model coordinates, and the last two (2) are its fractional U and V coordinates relative to the X and Y extents of the terrain footprint.
The U and V coordinates are used to apply spatial undulations to the resulting surface if it is not interpolated. As such, they are actually optional as they can be computed from the X and Y positions of each point, however it does give subclasses that use UV coordinates an opportunity to provide them in order to avoid their recalculation.
The following example shows how to obtain the terrain footprint extents and how the default U and V coordinates will be computed.
Parameters:
Name Type Description terrainBIM.Terrain The terrain element this component is controlling.
- Inherited From:
- Overrides:
Returns:
Returns an array of [x,y,z,u,v] control nodes.
- Type
- Array.<Array.<number>>
Example
let u, v; const extents = terrain.footprint.extents; const spot_heights = terrain.generateSpotHeights(); const dx = Math.max(1e-6, extents.max.x - extents.min.x); const dy = Math.max(1e-6, extents.max.y - extents.min.y); for (const pos of spot_heights) { u = (pos[0] - extents.min.x) / dx; v = (pos[1] - extents.min.y) / dy; /// Apply spatial noise... } -
generateSurfacePoints(terrain)
-
Generate spot heights using Perlin noise over the path.
Parameters:
Name Type Description terrainBIM.Terrain The terrain element this component is controlling.
- Overrides:
-
getNameAndSupplierParameters()
-
Provides a list of dynamic parameter groups for the component name, description and supplier.
See the
PD.Base#getDynamicParametersmethod for more details.- Inherited From:
- Overrides:
Returns:
Returns an array of
PD.ParamGroupobjects.- Type
- Array
-
hasMethod(component, methodName)
-
Determines if this component has a callable method with the given name.
This method is useful for checking if the component has a particular method before attempting to call it, thereby avoiding potential runtime errors. It is used within the framework to check for the presence of life-cycle methods in an element's type component before delegating them.
Parameters:
Name Type Description componentBIM.Component The component to check.
methodNamestring The case-sensitive name of the function/method to check for.
- Inherited From:
- Overrides:
Returns:
Returns true if the component is valid and has the function name as a method, otherwise false.
- Type
- boolean
-
interpolateSurfaceFromSpotHeights(terrain, spotHeights, density)
-
Interpolate a gridded surface over an array of spot heights.
The surface is interpolated over the extents of the terrain footprint and has optional Perlin noise applied.
Parameters:
Name Type Description terrainBIM.Terrain The terrain element this component is controlling.
spotHeightsArray.<Array.<number>> An array of [x,y,z,u,v] spot height positions.
densitynumber The density of the interpolate surface grid.
- Inherited From:
- Overrides:
-
isCompatibleWith(obj)
-
Determines if this component can be added to the given entity.
Whilst a small number of components may be compatible with multiple entity types, most components are designed to be used only by a specific entity type, and will not allow you to assign them to an incompatible entity.
Parameters:
Name Type Description objBIM.ENTITY | BIM.Entity The entity type or object instance to check for compatibility with.
- Inherited From:
- Overrides:
Returns:
Returns true if the component can be added to the object, otherwise false.
- Type
- boolean
-
updateDynamicParameters(param, group)
-
Sets the dynamic parameter value and returns true if it changed.
Most subclasses don't need to override this method as it automatically detects changes and rebuilds the element/component and model when required. However, if you do need to add your own custom logic or intercept the return value, please read the following examples carefully and use whichever best suits your needs.
NOTE: When overriding this method, you may not want to call
super.updateDynamicParameters(param, group)as the parent class may have added its own logic that may interfere with what you want to do. Instead, either use the staticPD.Base.updateDynamicParametersOnHostmethod to check if the value changed, or base it on the third example which replicates the code in that static method.Parameters:
Name Type Description paramPD.Parameter The dynamic parameter that changed.
groupPD.ParamGroup The group that the dynamic parameter belongs to.
- Inherited From:
- Overrides:
Returns:
Returns true if the value actually changed.
- Type
- boolean
Examples
updateDynamicParameters(param, group) { /// When you want parent class to use its logic. if (super.updateDynamicParameters(param, group)) { if (param.name == 'i_am_special') this.doSomethingSpecial(); return true; } return false; };updateDynamicParameters(param, group) { /// When you don't want parent to handle parameter updates. if (PD.Base.updateDynamicParametersOnHost(param, group, this)) { /// Invalidate geometry. if (this.typeComponent) { ++this.typeComponent.updateIndex; } /// Rebuild element. this.hasChanged = true; this.update(); /// Only update site mesh. if (this.onlyUsesSiteMesh) { const level = this.level; if (level) { // Don't trigger whole level update. level.rebuildSiteMesh(); PD.GlobalActions.redrawAndUpdateSelection(); return false; } } return true; } return false; };updateDynamicParameters(param, group) { /// The following three lines of code replicate /// `PD.Base.updateDynamicParametersOnHost()`, which you can /// use if you need to access `target` without having to call /// `group.getTarget() || this` twice. const target = group.getTarget() || this; target.checkDynamicParameter(param, group, this); if (param.setValueOnHostIfDifferent(target, group, this)) { /// You can now use `target`. if (target.myOwnMeshThatIsUpdatedDuringRebuild) { /// Rebuild element. this.hasChanged = true; this.update(); /// If no level meshes or other elements are affected, /// simply update the target locally and return false. this.myOwnMeshThatIsUpdatedDuringRebuild.update(); /// Update selection meshes if the /// element's highlight geometry changed. PD.GlobalActions.updateSelectionMeshes(); return false; } return true; } return false; }; -
getClassDescription() <static>
-
A brief description of this class to accompany its icon.
Returns:
Returns a brief description.
- Type
- string
-
getClassName() <static>
-
The name of this class within the
PD.Registry.See
PD.Base.getClassNamefor more details as this is required for use with thePD.Registry.Returns:
Returns the registered name of this class.
- Type
- string
-
getDisplayName() <static>
-
The name to display within the user interface.
Returns:
Returns the display name.
- Type
- string