Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove objectColorSource config, replace with objectsColors #156

Closed
xeolabs opened this issue Sep 14, 2023 · 0 comments
Closed

Remove objectColorSource config, replace with objectsColors #156

xeolabs opened this issue Sep 14, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@xeolabs
Copy link
Member

xeolabs commented Sep 14, 2023

Remove objectColorSource config, replace with objectsColors

By default, BIMViewer loads whatever object colors and opacities are in the XKT model files, without changing them.
Sometimes, however, certain types of objects may have colors that make it hard for us to view the model.

For example, in some IFC models, IfcPlate types may be used to represent windows, and those types are often given opaque
colors. That results in the windows of our model being opaque. For this example, we can make the windows transparent
by configuring the BIMViewer, or just that model, with a custom color or opacity, for that IfcPlate type. That would make
all IfcPlate types transparent again. There are two ways we can do this - programmatically via BIMViewer.setConfigs, or
for each project individually, via the project's index.json file.

In the code below, we'll configure all IfcSpace, IfcWindow, IfcOpeningElement and IfcPlate types
to be transparent, and while we're at it, we'll make IfcWindow types to be always blue. Note that all values are in range [0..1].


Note that prior to v2.4, BIMViewer did change the colors and opacities of IfcOpening, IfcSpace, IfcWindow and IfcPlate by
default. We've removed that in v2.4, because it was confusing
and users wondered why those object types did not have the colors/opacities defined for them in the model.


// In case the model has opaque colors for IfcSpace, IfcWindow, IfcOpeningElement and IfcPlate 
// objects, let's make those objects always transparent. To make the model look extra nice,
// let's force IfcWindows to always be blue, while we're at it. This will apply to all models,
// except where we override the settings per-project, as shown next.

bimViewer.setConfigs({
      "objectColors": {
            "IfcSpace": {
                "opacity": 0.3
            },
            "IfcWindow": {
                "opacity": 0.4,
                "color": [0, 0, 1]
            },
            "IfcOpeningElement": {
                "opacity": 0.3
            },
            "IfcPlate": {
                "opacity": 0.3
            }
        }
});

The other way we can set these color/opacity customizations is per-project, within the viewerConfigs section of
a project's index.json file. If we've also set them via BIMViewer.setConFigs, then these will override
the ones set via that method.

As an example, we've done this for the OTCConferenceCenter demo model, which otherwise has its windows opaque, which would make it hard
for us to navigate around that model. Therefore, we provide a custom map of colors and opacities for certain IFC types via
the viewerConfigs in the project index.json for that model, as shown below.

{
    "id": "otcConferenceCenter",
    "name": "OTC Conference Center",
    "models": [
        {
            "id": "design",
            "name": "OTC Conference Center Design"
        }
    ],
    "viewerConfigs": {
        "backgroundColor": [
            0.95,
            0.95,
            1.0
        ],
        "objectColors": {
            "IfcSpace": {
                "opacity": 0.3
            },
            "IfcWindow": {
                "opacity": 0.4
            },
            "IfcOpeningElement": {
                "opacity": 0.3
            },
            "IfcPlate": {
                "opacity": 0.3
            }
        }
    },
    "viewerContent": {
        "modelsLoaded": [
            "design"
        ]
    },
    "viewerState": {
        "tabOpen": "objects",
        "expandObjectsTree": 3,
        "expandClassesTree": 1,
        "expandStoreysTree": 1
    }
}
@xeolabs xeolabs added the enhancement New feature or request label Sep 14, 2023
@xeolabs xeolabs added this to the 2.4.9 milestone Sep 14, 2023
@xeolabs xeolabs closed this as completed Sep 14, 2023
@xeolabs xeolabs self-assigned this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant