FAQ: As part of the “quick start” menu, there is the example call “Multiple Instance”. When I change the model to landinggear (instead of microengine), colors of the created instance are NOT identical to the original. How do I get the same colors?

Language: JavaScript

The multiple_instance example is using the function (getNodesEffectiveFaceColor()):

https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.Model.html?highlight=getnodeseffectivefacecolor#Communicator.Communicator.Model.getNodesEffectiveFaceColor

…which does not have the granularity to retrieve the individual face colors of an instance. As an alternative, there is a function called getNodeEffectiveFaceColor():

https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.Model.html?highlight=getnodeseffectivefacecolor#Communicator.Communicator.Model.getNodeEffectiveFaceColor

As proof of concept, attached is a brief video (with audio narration) walking through an example:

Below is the JavaScript used in the video:

  1. Time stamp [0:10]:
var hwv = multipleInstance._viewer;

function mySelectionFunc(selectionEvent) {
        var selection = selectionEvent.getSelection();
        if (selection && selection.getSelectionType() != Communicator.SelectionType.None) {
            console.log("Selected Node: " + selection.getNodeId());
			console.log("Face ID: " + selection.getFaceEntity().getCadFaceIndex());
        }
        else {
            console.log("Selected: None");
        }
    }

hwv.setCallbacks({
	selection: mySelectionFunc
});
  1. Time stamp [0:38]
    hwv.model.getNodeEffectiveFaceColor(10, 755);

  2. Time stamp [1:20]
    var color = new Communicator.Color(0, 128, 255);
    hwv.model.setNodeFaceColor(-64, 755, color);