mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Merge pull request #15352 from dback2/materialTargetMasterFollowup
Case 22082, 22101: PR 15325 follow up and PR 15351 RC82 > Master
This commit is contained in:
commit
13fb3148a5
2 changed files with 52 additions and 25 deletions
|
@ -2523,18 +2523,24 @@ var PropertiesTool = function (opts) {
|
||||||
propertyRanges: propertyRanges,
|
propertyRanges: propertyRanges,
|
||||||
});
|
});
|
||||||
} else if (data.type === "materialTargetRequest") {
|
} else if (data.type === "materialTargetRequest") {
|
||||||
var properties = Entities.getEntityProperties(data.entityID, ["type", "parentID"]);
|
var parentModelData;
|
||||||
var parentModel = properties.parentID !== Uuid.NULL &&
|
var properties = Entities.getEntityProperties(data.entityID, ["type", "parentID"]);
|
||||||
Entities.getEntityProperties(properties.parentID, ["type"]).type === "Model";
|
if (properties.type === "Material" && properties.parentID !== Uuid.NULL) {
|
||||||
var parentModelData;
|
var parentType = Entities.getEntityProperties(properties.parentID, ["type"]).type;
|
||||||
if (properties.type === "Material" && parentModel) {
|
if (parentType === "Model" || Entities.getNestableType(properties.parentID) === "avatar") {
|
||||||
parentModelData = Graphics.getModel(properties.parentID);
|
parentModelData = Graphics.getModel(properties.parentID);
|
||||||
}
|
} else if (parentType === "Shape" || parentType === "Box" || parentType === "Sphere") {
|
||||||
emitScriptEvent({
|
parentModelData = {};
|
||||||
type: 'materialTargetReply',
|
parentModelData.numMeshes = 1;
|
||||||
materialTargetData: parentModelData,
|
parentModelData.materialNames = [];
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
emitScriptEvent({
|
||||||
|
type: 'materialTargetReply',
|
||||||
|
entityID: data.entityID,
|
||||||
|
materialTargetData: parentModelData,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HMD.displayModeChanged.connect(function() {
|
HMD.displayModeChanged.connect(function() {
|
||||||
|
|
|
@ -55,6 +55,7 @@ const GROUPS = [
|
||||||
label: "Parent",
|
label: "Parent",
|
||||||
type: "string",
|
type: "string",
|
||||||
propertyID: "parentID",
|
propertyID: "parentID",
|
||||||
|
onChange: parentIDChanged,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Parent Joint Index",
|
label: "Parent Joint Index",
|
||||||
|
@ -2009,6 +2010,9 @@ function createStringProperty(property, elProperty) {
|
||||||
|
|
||||||
|
|
||||||
elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property));
|
elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property));
|
||||||
|
if (propertyData.onChange !== undefined) {
|
||||||
|
elInput.addEventListener('change', propertyData.onChange);
|
||||||
|
}
|
||||||
|
|
||||||
elProperty.appendChild(elInput);
|
elProperty.appendChild(elInput);
|
||||||
|
|
||||||
|
@ -2478,7 +2482,7 @@ function resetDynamicMultiselectProperty(elDivOptions) {
|
||||||
let elDivOption = elInputs[0].parentNode;
|
let elDivOption = elInputs[0].parentNode;
|
||||||
elDivOption.parentNode.removeChild(elDivOption);
|
elDivOption.parentNode.removeChild(elDivOption);
|
||||||
}
|
}
|
||||||
elDivOptions.firstChild.style.display = "block"; // show "No Options" text
|
elDivOptions.firstChild.style.display = null; // show "No Options" text
|
||||||
elDivOptions.parentNode.lastChild.style.display = "none"; // hide Select/Clear all buttons
|
elDivOptions.parentNode.lastChild.style.display = "none"; // hide Select/Clear all buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2624,6 +2628,17 @@ function createProperty(propertyData, propertyElementID, propertyName, propertyI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROPERTY-SPECIFIC CALLBACKS
|
||||||
|
*/
|
||||||
|
|
||||||
|
function parentIDChanged() {
|
||||||
|
if (selectedEntityProperties.type === "Material") {
|
||||||
|
requestMaterialTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BUTTON CALLBACKS
|
* BUTTON CALLBACKS
|
||||||
*/
|
*/
|
||||||
|
@ -3158,6 +3173,10 @@ function setTextareaScrolling(element) {
|
||||||
* MATERIAL TARGET FUNCTIONS
|
* MATERIAL TARGET FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function requestMaterialTarget() {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'materialTargetRequest', entityID: selectedEntityProperties.id }));
|
||||||
|
}
|
||||||
|
|
||||||
function setMaterialTargetData(materialTargetData) {
|
function setMaterialTargetData(materialTargetData) {
|
||||||
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
||||||
resetDynamicMultiselectProperty(elDivOptions);
|
resetDynamicMultiselectProperty(elDivOptions);
|
||||||
|
@ -3167,7 +3186,7 @@ function setMaterialTargetData(materialTargetData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
elDivOptions.firstChild.style.display = "none"; // hide "No Options" text
|
elDivOptions.firstChild.style.display = "none"; // hide "No Options" text
|
||||||
elDivOptions.parentNode.lastChild.style.display = "block"; // show Select/Clear all buttons
|
elDivOptions.parentNode.lastChild.style.display = null; // show Select/Clear all buttons
|
||||||
|
|
||||||
let numMeshes = materialTargetData.numMeshes;
|
let numMeshes = materialTargetData.numMeshes;
|
||||||
for (let i = 0; i < numMeshes; ++i) {
|
for (let i = 0; i < numMeshes; ++i) {
|
||||||
|
@ -3243,35 +3262,35 @@ function sendMaterialTargetProperty() {
|
||||||
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
||||||
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
|
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
|
||||||
|
|
||||||
let materialTargetList = "";
|
let materialTargetList = [];
|
||||||
for (let i = 0; i < elInputs.length; ++i) {
|
for (let i = 0; i < elInputs.length; ++i) {
|
||||||
let elInput = elInputs[i];
|
let elInput = elInputs[i];
|
||||||
if (elInput.checked) {
|
if (elInput.checked) {
|
||||||
let targetID = elInput.getAttribute("targetID");
|
let targetID = elInput.getAttribute("targetID");
|
||||||
if (elInput.getAttribute("isMaterialName") === "true") {
|
if (elInput.getAttribute("isMaterialName") === "true") {
|
||||||
materialTargetList += "mat::" + targetID + ",";
|
materialTargetList.push("mat::" + targetID);
|
||||||
} else {
|
} else {
|
||||||
materialTargetList += targetID + ",";
|
materialTargetList.push(targetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materialTargetList !== "") {
|
let propertyValue = materialTargetList.join(",");
|
||||||
materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1);
|
if (propertyValue.length > 1) {
|
||||||
materialTargetList = "[" + materialTargetList + "]";
|
propertyValue = "[" + propertyValue + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProperty("parentMaterialName", materialTargetList, false);
|
updateProperty("parentMaterialName", propertyValue, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function materialTargetPropertyUpdate(propertyValue) {
|
function materialTargetPropertyUpdate(propertyValue) {
|
||||||
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
let elDivOptions = getPropertyInputElement("parentMaterialName");
|
||||||
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
|
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
|
||||||
|
|
||||||
if (propertyValue.charAt(0) === '[') {
|
if (propertyValue.startsWith('[')) {
|
||||||
propertyValue = propertyValue.substring(1, propertyValue.length);
|
propertyValue = propertyValue.substring(1, propertyValue.length);
|
||||||
}
|
}
|
||||||
if (propertyValue.charAt(propertyValue.length - 1) === ']') {
|
if (propertyValue.endsWith(']')) {
|
||||||
propertyValue = propertyValue.substring(0, propertyValue.length - 1);
|
propertyValue = propertyValue.substring(0, propertyValue.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3782,7 +3801,7 @@ function loaded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasSelectedEntityChanged && selectedEntityProperties.type === "Material") {
|
if (hasSelectedEntityChanged && selectedEntityProperties.type === "Material") {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'materialTargetRequest', entityID: selectedEntityProperties.id }));
|
requestMaterialTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
let activeElement = document.activeElement;
|
let activeElement = document.activeElement;
|
||||||
|
@ -3835,7 +3854,9 @@ function loaded() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (data.type === 'materialTargetReply') {
|
} else if (data.type === 'materialTargetReply') {
|
||||||
setMaterialTargetData(data.materialTargetData);
|
if (data.entityID === selectedEntityProperties.id) {
|
||||||
|
setMaterialTargetData(data.materialTargetData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue