Class: Renderable

BIM. Renderable

Defines a container entity for storing and rendering BIM elements.

This is a virtual class that serves as the basis for subclasses such as BIM.Level and BIM.DrawingView that need to store, manage and render child elements.

It basically manages a list of elements, a set of renderable meshes and an optional background image that can be underlaid within a scene.


new Renderable( [config] [, typeName] [, index])

Creates a new virtual renderable container.

NOTE: Subclasses of this class must add any elements at the end of their own constructor to ensure that they are fully created before child elements access any of their properties. Also, subclasses must also set the id property to something unique.

Parameters:
Name Type Argument Description
config object <optional>

A configuration object.

Properties of config:
Name Type Argument Description
id number <optional>

A unique integer identifier.

name string <optional>

A human-readable name for this entity.

uuid string <optional>

A universally unique identifier of this entity.

visible boolean <optional>

Whether or not the container is visible within the model.

ghosted boolean <optional>

Whether or not the container is shown in transparent outline only.

elementList Array.<BIM.Element> <optional>

A list fo elements to add to the container.

typeName string <optional>

An additional parameter typically used by subclasses to set the instance name without modifying the config object.

index number <optional>

An optional index number to append to the type name.

Author:
  • drajmarsh

Extends

Members


:Map

attributes

Stores any arbitrary attributes associated with this entity.

This is a simple key/value map that can be used to store any additional information about the entity that may be required by the application such as reference ids, material types, fire ratings, costings, etc.

Type
  • Map
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 references this.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:

:THREE.Box3

displayExtents

Stores the 3D extents of the displayed meshes.

Internally, all levels and the elements within them are generated relative to a base floor level of zero (Z=0). The generated display meshes are then positioned within the model offset vertically by their actual floor level.

In order to center the current level within the view, the entire model is offset/animated up and down such that the floor plane of the currently selected level is always at absolute zero in the Z axis.

The extents property stores the bounding box of just the contents of the level. The displayExtents property stores the bounding box of the level as it is displayed within the model.

Type
  • THREE.Box3

:string

displayName <readonly>

The name to display for this class within the user interface.

Type
  • string
Inherited From:
Overrides:

:THREE.Vector3

displayOffset

Stores the current absolute display offset.

Internally, all levels and the elements within them are generated relative to a base floor level of zero (Z=0) and a local origin. The generated display meshes are then positioned within the model offset vertically by their actual floor level.

In order to center the current level within the view, the entire model is offset/animated up and down such that the floor plane of the currently selected level is always at absolute zero in the Z axis.

This vector stores the display offset position of the level meshes within the current editable view. Whilst levels are most ofter just displaced vertically, specific display modes may also move levels laterally. This vector stores the absolute offset of the level within the editable view and is used to adjust rays and frustums for selection.

Type
  • THREE.Vector3

:Array

elementList

The list of elements in the container.

Type
  • Array

:BIM.ENTITY

entityType <readonly>

Defines the type of BIM entity this class represents.

This value is used by the PD.Registry for grouping elements and matching components. The base implementation simply references this.constructor.getEntityType() so that only a static method needs to be added to subclasses.

Type
Inherited From:
Overrides:

:THREE.Box3

extents

The 3D extents of the element as a bounding box.

Type
  • THREE.Box3
Inherited From:
Overrides:

:boolean

ghosted

Whether or not the container is shown in transparent outline only.

Type
  • boolean

:boolean

hasChanged

Whether or not the entity has recently changed and needs to update.

This property is typically set by the user interface or other parts of the framework when the entity's properties have changed and any visual representations need to be updated.

Type
  • boolean
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 references this.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();
    };
    /// ...
 };

:number

id

A unique integer identifier for fast discovery and/or equality checking.

This identifier is unique within the current project data and is primarily intended to facilitate fast lookup and equality checking. It is assigned automatically when the renderable is created and should not change. It is much simpler than the uuid property, being a numeric integer rather than a long string of characters, and is the preferred way of comparing renderable entities to see if they are the same.

Type
  • number

:boolean

isEntity <readonly>

A flag identifying this object as an entity.

Type
  • boolean
Inherited From:
Overrides:

:boolean

isRenderable <readonly>

A flag identifying this object as a renderable container for elements.

Type
  • boolean

:BIM.Meshes

meshes

A collection of meshes required to render elements.

Type

:string

name

A human-readable name for this item instance.

Type
  • string
Inherited From:
Overrides:

:boolean

selected

Whether or not the entity is in the current selection set.

This property is typically set by the user interface when the user selects or deselects entities within the model view. The PD.SelectionManager uses this property to keep track of which entities are currently selected.

Type
  • boolean
Inherited From:
Overrides:

:BIM.TraceImage

traceImage

Stores information about the underlay trace image.

Each renderable can store an image to show as an underlay or for tracing over to create model geometry. This property stores the metadata, size and position of that image.

Type

:string

uuid

A universally unique identifier for the item instance.

Type
  • string
Inherited From:
Overrides:

:boolean

visible

Whether or not the entity is visible within the model.

The framework tries its best to avoid rendering invisible entities, but depending on the type of entity and how it is represented, this may not always be possible. For example, not rendering a chair is

Type
  • boolean
Inherited From:
Overrides:

Methods


addElement(element [, index])

Add an element to this container.

Parameters:
Name Type Argument Description
element BIM.Element

The element to add.

index number <optional>

An optional ordinal index at which to insert it.

Returns:

Returns true if the element was successfully added, otherwise false.

Type
boolean

afterRebuild()

Finalises meshes after container has been rebuilt.


beforeRebuild()

Initialise meshes prior to rebuilding the container.


checkDynamicParameter(param, group [, host])

Provides an opportunity to dynamically limit the value and/or range of each parameter.

This method is called whenever a dynamic parameter is interactively changed. The param argument gives access to the parameter being changed whilst the group argument gives access to other parameters within the same parameter group.

NOTE: Range validation in this method is not absolutely required, but doing so can prevent unnecessary model rebuilds due to out-of-range parameters being different from their previous values, even though the object's geometry will not actually change due to range constraints within the subclasses rebuild() method. Thus, it is usually best to do them here so that someone's future airport model is not entirely rebuilt each time they try to set a too-large length in your custom door handle component.

Parameters:
Name Type Argument Description
param PD.Parameter

The parameter that is being interactively changed.

group PD.ParamGroup

The group that the dynamic parameter belongs to.

host object <optional>

For components only, the parent or host object that called this method.

Inherited From:
Overrides:
Example
checkDynamicParameter(param, group, host) {

     switch (param.name) {

         case 'height':
             if (param.value < 1.0) param.value = 1.0;
             break;

         case 'width':
         case 'length':
             if (param.value < 100.0) param.value = 100.0;
             if (this.standardBedSize > 0) { // If not custom.
                 group.setParameterValue('standardBedSize', 0);
                 this.standardBedSize = 0; // Make it custom.
             }
             break;

         case 'standardBedSize': {
                 const std_bed = this.getStandardBedSize(Math.round(param.value));
                 if (std_bed != null) {
                     const [ width, length ] = (PD.DIMENSION.useImperial) ? std_bed.sizeImperial : std_bed.sizeMetric;
                     this.width = PD.Utils.toNumber(width, this.width);
                     group.setParameterValue('width', this.width);
                     this.length = PD.Utils.toNumber(length, this.length);
                     group.setParameterValue('length', this.length);
                 }
             } break;

       }

 };

clear()

Clears everything from this container so it can be reused.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

clearTraceImage()

Removes the texture and image mesh, and releases them from the GPU.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

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

computeDisplayOffset()

Calculates and returns the relative display offset vector.

This method updates the displayOffset property by adding the model display position to the level meshes position.

In order to center the current level within the view, the entire model is offset/animated up and down such that the floor plane of the currently selected level is always at absolute zero in the Z axis.

This means that the display offset changes each time a new level is selected, and dynamically when the model is animated up/down. Thus, this method should be called before any interactive selection to update the value.

Returns:

Returns the relative display offset vector.

Type
THREE.Vector3

computeExtents( [all])

Calculates the extents of the container from all its (visible) elements.

Internally, all levels and the elements within them are generated relative to a base floor level of zero (Z=0). The generated display meshes are then positioned within the model offset vertically by their actual floor level.

In order to center the current level within the view, the entire model is offset/animated up and down such that the floor plane of the currently selected level is always at absolute zero in the Z axis.

The extents property stores the bounding box of just the contents of the level, whilst the displayExtents property stores the bounding box the level as it is displayed within the model. This method calculates and updates both.

Parameters:
Name Type Argument Description
all boolean <optional>

When true, all elements are included rather than only visible ones.

Returns:

Returns the newly computed extents bounding box.

Type
THREE.Box3

containsElement(element)

Checks if the container contains the given element.

Parameters:
Name Type Description
element BIM.Element

The element to check.

Returns:

Returns true if this container contains the element.

Type
boolean

deleteAttribute(name)

Removes an attribute from this entity.

Parameters:
Name Type Description
name string

The name of the attribute to remove.

Inherited From:
Overrides:
Returns:

Returns this entity to support method chaining.

Type
PD.Base

fadeIn( [speed])

Fades the container from zero to full opacity.

Parameters:
Name Type Argument Description
speed number <optional>

An optional animation speed in ms, defaults to global animation speed.


fadeOut( [speed])

Fades the container to zero from its current opacity.

Parameters:
Name Type Argument Description
speed number <optional>

An optional animation speed in ms, defaults to global animation speed.


findClosestElementByRay(selection, event [, selectedElement])

Finds the closest element in the element list.

This method fills out the selection object with information on the closest element.

NOTE: This method does not check that the PD.GlobalState.selectElements flag is true before testing and adding elements to the selection as it may be used by simulation and analysis classes for purposes unrelated to interactive selection. If used for interactive selection, however, the calling function must first check that PD.GlobalState.selectElements is true before calling this method.

This method is typically called only on the currently selected level, on which the local model origin is based. Thus the given selection ray is not modified by the level's display offset. To use this method on a non-current level, you will need to modify the selection ray manually before calling it, as shown below.

Parameters:
Name Type Argument Description
selection PD.Selection

The interactive selection accumulator.

event Event

The DOM event that triggered this selection.

selectedElement BIM.Element <optional>

The element currently selected within the model.

Returns:

Returns true if something in the model was selected and the selection updated, otherwise false.

Type
boolean
Example
function findClosestElementByRay(selection, event, selectedElement) {

    let found = false;

    for (const level of myLevelContainer.levelList);

        /// ### -> Accommodate display position.
        selection.ray.origin.sub(level.computeDisplayOffset());

        if (level.findClosestElementByRay(selection, event, selectedElement)) {
            /// Act on `selection.closestElement`...
            found = true;
        }

        /// ### -> Reset ray position.
        selection.ray.origin.add(level.displayOffset);

    }

    return found;

}

findClosestFeatureByRay(selection, event [, selectedElement] [, selectedType])

Finds the closest feature in the element list.

This method fills out the selection object with information on the closest junction, path segment, aperture or element. If the selection.currentElement value is not null, then priority for selection is given to this element.

This method is typically called only on the currently selected level, on which the local model origin is based. Thus the given selection ray is not modified by the level's display offset. To use this method on a non-current level, you will need to modify the selection ray manually before calling it, as shown below.

Parameters:
Name Type Argument Description
selection PD.Selection

The interactive selection accumulator.

event Event

The DOM event that triggered this selection.

selectedElement BIM.Element <optional>

The element currently selected within the model.

selectedType PD.SELECTED <optional>

The current model selection type, defaults to PD.SELECTED.NONE.

Returns:

Returns true if something in the model was selected and the selection updated, otherwise false.

Type
boolean
Example
function findClosestFeatureByRay(selection, event, selectedElement, selectedType) {

    let found = false;

    for (const level of myLevelContainer.levelList);

        /// ### -> Accommodate display position.
        selection.ray.origin.sub(level.computeDisplayOffset());

        if (level.findClosestFeatureByRay(selection, event, selectedElement, selectedType)) {

            switch (selection.selectedType) {

                case PD.SELECTED.ELEMENT:
                    /// Act on `selection.closestElement`...
                    found = true;
                    break;

                case PD.SELECTED.SEGMENT:
                case PD.SELECTED.JUNCTION:
                    /// Act on `selection.closestJunction`...
                    found = true;
                    break;

                case PD.SELECTED.APERTURE:
                    /// Act on `selection.closestAperture`...
                    found = true;
                    break;

            }

        }

        /// ### -> Reset ray position.
        selection.ray.origin.add(level.displayOffset);

    }

    return found;

}

getAttribute(name)

Retrieve an attribute stored on this entity, if it exists.

Parameters:
Name Type Description
name string

The name of the attribute to retrieve.

Inherited From:
Overrides:
Returns:

Returns the attribute value, or undefined if it does not exist.

Type
any | undefined

getDynamicParameters( [host])

Provides a list of dynamic parameter groups to the UI.

This list is typically requested by the front-end framework whenever something is selected in the model and used to generate DOM components that allow the user to interactively edit each parameter.

Override this method in any derived classes to specify your own custom parameters and parameter groups. The array must only contain PD.ParamGroup objects for it to display the parameters it contains, as shown in the example below.

When the user modifies any a parameters, the updateDynamicParameters() method on the owner is called. As long as the name property of each parameter corresponds exactly to a property on the custom element, the default implementation of the update method can be used. This simply does some type and tolerance checking to see if the value has changed, before assigning the new value and calling the rebuild() method on the element. If you need to use names other than property names, or need to do your own type and/or tolerance checking, then you will need to also override the PD.Base#updateDynamicParameters` method.

Parameters:
Name Type Argument Description
host object <optional>

For components only, the parent or host object that called this method.

Inherited From:
Overrides:
Returns:

Returns an array of zero or more PD.ParamGroup objects.

Type
Array
Example
getDynamicParameters(host) {
     return [
         new PD.ParamGroup({
             name: 'mainParams',
             title: 'Table Parameters',
             target: this,
             params: [
                 new PD.Parameter({ name: 'height', title: 'Table Height', value: this.height, paramType: PD.ParamType.SmallDistance, description: 'The height from floor level to the top of the table.' }),
                 new PD.Parameter({ name: 'size', title: 'Table Top Size/Diameter', value: this.size, paramType: PD.ParamType.Distance, description: 'The size of the table top when not defined by a closed path.' }),
                 new PD.Parameter({ name: 'thickness', title: 'Table Top Thickness', value: this.thickness, paramType: PD.ParamType.SmallDistance, description: 'The thickness of the table top surface.' }),
                 new PD.Parameter({ name: 'offset', title: 'Offset From Path', value: this.offset, paramType: PD.ParamType.SmallDistance, description: 'The offset distance from the table path.' }),
                 new PD.Parameter({ name: 'swapSides', title: 'Swap Sides', value: this.swapSides, paramType: PD.ParamType.Boolean, description: 'Reverse the direction of the table relative to its path.' }),
                 new PD.Parameter({ name: 'isRound', title: 'Round Table', value: this.isRound, paramType: PD.ParamType.Boolean, description: 'Whether or not the table surface is round.'  }),
             ]
         }),
         new PD.ParamGroup({
             name: 'legParams',
             title: 'Leg Parameters',
             target: this,
             params: [
                 new PD.Parameter({ name: 'legCount', title: 'Number of Legs', value: this.legCount, paramType: PD.ParamType.Integer, description: 'The number of legs on the table.' }),
                 new PD.Parameter({ name: 'legSize', title: 'Leg Size', value: this.legSize, paramType: PD.ParamType.SmallDistance, description: 'The thickness of each leg of the table.' }),
                 new PD.Parameter({ name: 'legInset', title: 'Leg Edge Inset', value: this.legInset, paramType: PD.ParamType.SmallDistance, description: 'The inset distance of each leg from the table edge.' }),
                 new PD.Parameter({ name: 'legOffset', title: 'Leg Edge Offset', value: this.legOffset, paramType: PD.ParamType.Fraction, description: 'The relative distance of the leg along each edge span.' }),
                 new PD.Parameter({ name: 'legSpan', title: 'Max. Distance Between Legs', value: this.legSpan, paramType: PD.ParamType.Distance, description: 'The maximum distance between legs along each edge span.' })
             ]
         })
     ];
 };

getElements(filterFn)

Retrieves a list of elements in the container filtered down to just those that pass the test implemented in the provided callback function.

The callback function takes an element from the container as an argument and should apply a test that returns true to add the element to the returned list or false to skip it.

Parameters:
Name Type Description
filterFn function

A callback function suitable for use with Array.filter().

Returns:

Returns an array of elements that passed the callback test.

Type
Array
Example
const my_space = ...
const other_spaces = my_space.level.getElements((element, index, array) => {
    return element.isSpace && (element.uuid != myspace.uuid);
});

getMeshPosHeight()

Retrieves the current model height at which this level's rendered meshes are displayed.

Returns:

Returns the model height of the level's meshes.

Type
number

getOpacity()

Retrieves the container's current mesh opacities.

Returns:

Returns the container mesh opacity (0 to 1).

Type
number

getRefPos()

Retrieves the drawable's reference position.

The reference position stores the drawable's original starting position at the beginning of a dynamic animation.

As this is not always required or used, this is actually a getter for a vector object that is dynamically created as an attribute when first accessed.

Returns:

Returns the reference position.

Type
THREE.Vector3

getTargetPos()

Retrieves the drawable's target display position.

The display position stores the drawable's target position during a dynamic animation.

As this is not always required or used, this is actually a getter for a vector object that is dynamically created as an attribute when first accessed.

Returns:

Returns the display position.

Type
THREE.Vector3

hasContent()

Checks if the container has any elements.

Returns:

Returns true if the container has content.

Type
boolean

intersectExtents(ray, intersection)

Determines if the given ray intersects the entity extents.

Parameters:
Name Type Description
ray THREE.Ray

The ray to find the intersection for.

intersection THREE.Vector3

The vector to store the intersection point, if any.

Inherited From:
Overrides:
Returns:

Returns the intersection point, or null if no intersection.

Type
THREE.Vector3 | null

loadTraceImage(image_url, callback)

Loads in and displays a floor plan image for tracing.

Parameters:
Name Type Description
image_url string

The url of the image to load.

callback function

The callback function once loaded.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

moveLevelToTargetPos(fraction)

Interpolates the container towards its target display position.

Parameters:
Name Type Description
fraction number

The interpolation fraction (0 to 1), defaults to 1.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

needsRebuild()

Checks whether the container needs to be rebuilt.

Returns:

Returns true if a rebuild is required.

Type
boolean

rebuild( [forceUpdate] [, refView])

Rebuilds the container based on recent changes to the model.

Parameters:
Name Type Argument Default Description
forceUpdate boolean <optional>
false

Whether or not to rebuild level even if unchanged, defaults to false.

refView PD.View <optional>

An optional reference view data object to copy, defaults to the global view.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

rebuildElementWithOwnMeshes(element)

Rebuilds and re-renders the given elements that uses it's own mesh(es).

This method can be used by elements who use their own mesh and don't need the entire container to update when they change.

Parameters:
Name Type Description
element BIM.Element

The element to update and re-render.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

rebuildSiteMesh()

Rebuilds and re-renders only those elements that use the site mesh.

This method can be used by those elements whose BIM.Element#onlyUsesSiteMesh property is true instead of BIM.Level#rebuild to bypass a full container rebuild and only update the site mesh.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

removeElement(element)

Removes an element from this container.

Parameters:
Name Type Description
element BIM.Element

The building element to remove.

Returns:

Returns the ordinal index of the removed element, or -1 if not found on this container.

Type
number

renderElementPaths(mesh)

Renders the paths of visible elements to the scene.

This is used primarily during interactive drag actions as a visual indicator for snapping.

Parameters:
Name Type Description
mesh PD.PolyMesh

the mesh to render paths to.


setAttribute(name, value)

Stores an attribute on this entity, or replaces it's existing value.

Parameters:
Name Type Description
name string

The name of the attribute to store.

value string

The attribute value to store.

Inherited From:
Overrides:
Returns:

Returns this entity to support method chaining.

Type
PD.Base

setDefaultOpacity(show3d)

Sets the container's mesh opacities to default values.

Parameters:
Name Type Description
show3d boolean

Whether the model is rendered in 3D rather than plan.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

setExtents(bbox)

Set the 3D extents of the element as a bounding box.

Override this method in bounding box driven building elements such as equipment, imported or parametric meshes to rescale or regenerate their underlying geometry whenever it changes.

Parameters:
Name Type Description
bbox THREE.Box3

The new bounding box extents to set.

Inherited From:
Overrides:
Returns:

Returns this entity to support method chaining.

Type
PD.Base

setMeshPosHeight(z)

Sets the display height of this level.

Internally, all levels and the elements within them are generated relative to a base floor level of zero (Z=0). The generated display meshes are then positioned within the model offset vertically by their actual floor level.

In order to center the current level within the view, the entire model is offset/animated up and down such that the floor plane of the currently selected level is always at absolute zero in the Z axis.

This method sets the Z axis value of the level's meshes and updates the absolute display offset and extents to match.

Parameters:
Name Type Description
z number

The height to display the level at, in model units.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

setRefPos( [pos])

Sets the reference position to the given or current position.

As this is not always required or used, this is actually a setter for a vector object that is dynamically created as an attribute when first accessed.

Parameters:
Name Type Argument Description
pos THREE.Vector3 <optional>

An optional point to set, defaults to current mesh position.

Returns:

Returns this renderable to support method chaining.

Type
BIM.Renderable

setTargetPos( [pos])

Updates the reference position to the given or current position.

As this is not always required or used, this is actually a setter for a vector object that is dynamically created as an attribute when first accessed.

Parameters:
Name Type Argument Description
pos THREE.Vector3 <optional>

An optional point to set, defaults to the current mesh position.

Returns:

Returns this renderable to support method chaining.

Type
BIM.Renderable

setVerticalScale(scale)

Sets the vertical scale factor of the container.

This is primarily used in 2D to 3D animated transitions.

Parameters:
Name Type Description
scale number

A new vertical scale (0.01 to 1.0).

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

showShadows(state)

Sets the display of shadows within this container.

Parameters:
Name Type Description
state boolean

Whether or not to show shadows.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

update( [forceUpdate])

Updates all elements and checks to rebuild their geometry.

Parameters:
Name Type Argument Description
forceUpdate boolean <optional>

Whether or not to rebuild elements even if unchanged, defaults to false.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

updateDisplayOffset()

Recalculates the relative display offset and updates the displayed extents.

This method updates both the displayOffset property and the displayExtents bounding box. This method is called each time the display position or height of the level is set.

Returns:

Returns this container to support method chaining.

Type
BIM.Renderable

updateDynamicOpacity( [surface_fade] [, outline_fade])

Updates the container's mesh opacities based on dynamic PD.GlobalState values.

Parameters:
Name Type Argument Description
surface_fade number <optional>

The relative opacity of the container's surface meshes (0 to 1), defaults to 1.

outline_fade number <optional>

The relative opacity of the container's outline meshes (0 to 1), defaults to surface_fade.

Returns:

Returns this container object to support method chaining.

Type
BIM.Renderable

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 static PD.Base.updateDynamicParametersOnHost method 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
param PD.Parameter

The dynamic parameter that changed.

group PD.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;

 };

setDefaultGlassColor(mesh) <static>

Sets the mesh color to dark gray or light blue, depending on PD.GlobalState darkmode.

Parameters:
Name Type Description
mesh PD.PolyMesh

the mesh to set the color for.


setDefaultSectionColor(mesh) <static>

Sets the mesh color to dark gray or light-gray, depending on darkmode.

Parameters:
Name Type Description
mesh PD.PolyMesh

the mesh to set the color for.


setDefaultSurfaceColor(mesh) <static>

Sets the mesh color to dark gray or white, depending on PD.GlobalState darkmode.

Parameters:
Name Type Description
mesh PD.PolyMesh

the mesh to set the color for.


updateOutlineColorFromGlobalState() <static>

Updates the shared outline color based on PD.GlobalState values.