From f862030b1c966d703877f085d142831f95e9e393 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sat, 7 May 2022 08:12:52 +0200 Subject: [PATCH] Fixed voxel presets, added icon --- .../html/js/entityProperties.js | 87 ++++++++++++------ .../entityProperties/html/tabs/polyvox.png | Bin 0 -> 2068 bytes 2 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 scripts/system/create/entityProperties/html/tabs/polyvox.png diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 43db567f95..908ad7fe28 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1346,7 +1346,8 @@ const GROUPS = [ options: { 0 : "None", 1 : "Grass + ground", 2 : "Bricks", 3 : "Stone", 4: "Concrete", 5 : "Rock"}, propertyID: "polyVoxPreset", - onDropdownChange: polyVoxPresetChanged, + onDropdownChange: createPolyVoxPresetChangedFunction, + skipPropertyUpdate: true, }, /*{ label: "Surface Style", @@ -2344,7 +2345,6 @@ function updateMultiDiffProperties(propertiesMapToUpdate, onlyUpdateEntity) { function createEmitTextPropertyUpdateFunction(property) { return function() { - alert('event orig'); property.elInput.classList.remove('multi-diff'); updateProperty(property.name, this.value, property.isParticleProperty); }; @@ -2931,13 +2931,7 @@ function createDropdownProperty(property, propertyID, elProperty) { elInput.add(option); } - //elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property)); - elInput.addEventListener('change', createPolyVoxPresetChangedFunction(property)); - if (propertyData. - onDropdownChange !== undefined) { - alert("registered"); - //elInput.addEventListener('change', propertyData.onDropdownChange); - } + elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property)); elProperty.appendChild(elInput); @@ -3257,30 +3251,54 @@ function parentIDChanged() { function createPolyVoxPresetChangedFunction(property) { return function() { - alert('event'); property.elInput.classList.remove('multi-diff'); - updateProperty(property.name, this.value, property.isParticleProperty); + var xTextureURL = ""; + var yTextureURL = ""; + var zTextureURL = ""; + switch (parseInt(this.value)) { + // Clear texture entries + case 0: + xTextureURL = ""; + yTextureURL = ""; + zTextureURL = ""; + break; + // Grass + ground + case 1: + xTextureURL = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg"; + yTextureURL = "qrc:///serverless/Textures/ground_grass_gen_05.png"; + zTextureURL = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg"; + break; + // Bricks + case 2: + xTextureURL = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg"; + yTextureURL = "qrc:///serverless/Textures/2K-stone_floor_3-diffuse_l.jpg"; + zTextureURL = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg"; + break; + // Stone + case 3: + xTextureURL = "qrc:///serverless/Textures/wall_l.png"; + yTextureURL = "qrc:///serverless/Textures/floor_l.png"; + zTextureURL = "qrc:///serverless/Textures/wall_l.png"; + break; + // Concrete + case 4: + xTextureURL = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; + yTextureURL = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; + zTextureURL = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; + break; + // Rock + case 5: + xTextureURL = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; + yTextureURL = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; + zTextureURL = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; + break; + } + updateProperty("xTextureURL", xTextureURL, false); + updateProperty("yTextureURL", yTextureURL, false); + updateProperty("zTextureURL", zTextureURL, false); }; } - -/*function polyVoxPresetChanged(property) { - return function() { - property.elInput.classList.remove('multi-diff'); - alert('PolyVox preset 2 ' + JSON.stringify(property)); - updateProperty("xTextureURL", "test", false); - updateProperty("yTextureURL", "test", false); - updateProperty("zTextureURL", "test", false); - }; -}*/ - -function polyVoxPresetChanged() { - alert('PolyVox preset 2 '); - //updateProperty("xTextureURL", "test", false); - //updateProperty("yTextureURL", "test", false); - //updateProperty("zTextureURL", "test", false); -} - /** * BUTTON CALLBACKS */ @@ -4839,7 +4857,16 @@ function loaded() { let propertyID = elDropdown.getAttribute("propertyID"); let property = properties[propertyID]; property.elInput = dt; - dt.addEventListener('change', createEmitTextPropertyUpdateFunction(property)); + + if (property.data. + skipPropertyUpdate !== true) { + dt.addEventListener('change', createEmitTextPropertyUpdateFunction(property)); + } + + if (property.data. + onDropdownChange !== undefined) { + dt.addEventListener('change', property.data.onDropdownChange(property)); + } } document.addEventListener('click', function(ev) { closeAllDropdowns() }, true); diff --git a/scripts/system/create/entityProperties/html/tabs/polyvox.png b/scripts/system/create/entityProperties/html/tabs/polyvox.png new file mode 100644 index 0000000000000000000000000000000000000000..3875e76dc83305cc3bc9e2e7425953bde48de654 GIT binary patch literal 2068 zcmV+v2EX>4Tx04R}tkv&MmKpe$iQ%glEqIM8*$WWauNELC^DionYs1;guFuC*#nlvOS zE{=k0!NHHks)LKOt`4q(Aou~|=;Wm6A|?JWDYS_7;J6>}?mh0_0YbgZG^=X@&~)2O zCE{WxyDA1>5rBYx#4sQ;%b1g-Bsz|-d-(Wz7v))<&;2=i)ttoupGZ8*4AUmwAfDc| z4bJ<-VOEq?;&bA0lP*a7$aTfzH_io@1)do;)2VslFtJ!@W2KE*(bR~ih$E_|Q@)V# zSmnIMSu0mr^Pc>Lp`5<5%ypV0NMI35kRU=q6(y8mBTB1IiiH&I$2<6kUB5&wg(`8@D`M&FbL25*6$HLthkK29HiGxhUcX)SqdvE`qY4-O6RP}P3q#{Tb00006VoOIv0RI600RN!9r;`8x010qNS#tmY z53m3L53m90ew@7k000McNliru<^=}^1RBJBr8)or02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00rzxL_t(Y$E}rZOp{j>$M3z*)0UQ^qov@eZ4j6*Afl16 zir{2r!5|$CMM1>PMP$s#6iI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