We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Save Configuration for RGB Color

Home Forums Programming Save Configuration for RGB Color

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #19567
    hoody
    Participant

    Hey Guys. I learned from ypur “Custom Image Example” how to save an uploaded Texture (by User) into a shareable FB-Link.

    Heres my Code and it works:

    registerOnClick(‘Schnalle Rechts’, function() {
    openFile(function() {
    replaceTexture(‘mat_schnalle_rechts’, ‘hodz schriftyug weiss rechts.png.001’, _pGlob.openedFile, function() {});
    sendData(_pGlob.openedFile, ‘http://brudastan.de/wp-json/verge3d/v1/upload_file/’, function() {
    saved_conf_url = setUrlParam(getUrlData(‘URL’), ‘image_url’, dictGet(_pGlob.loadedFile, ‘link’));
    openWebPage(saved_conf_url, ‘NO_RELOAD’);
    });
    });
    }, function() {});

    But how does this work for (RGB) Colors?

    Here is my code for changing the RGB Color:

    eventHTMLElem(‘change’, ‘picker’, true, function(event) {

    let rbg = changeToRBG(event.target.value)
    console.log(rbg)

    var vals = rbg.substring(rbg.indexOf(‘(‘) +1, rbg.length -1).split(‘,’)
    console.log(vals[0]+” “+vals[1]+” “+vals[2])

    setMaterialColor(‘mat_sohlenrand’, ‘RGB’, (vals[0]/255), (vals[1]/255), (vals[2]/255));

    });

    How do i integrate the sendData puzzle into this code, so that the values of the RGB Colors will be saved on the server?

    Thanks

    #19579

    Hi,

    Unlike with textures which are uploaded to server, there is no need to use the server with colors. You can just serialize RGB values to a text line and save to application URL as it is done with image id.

    Chief 3D Verger | LinkedIn | Twitter

    #19581
    hoody
    Participant

    Hi Yuri!

    Thank you very much for your quick answer!

    Can you explain what you mean by “serialize RGB values to a text line”. Coud you post an example of code?

    I also dont quite understand to what “image id” you are reffering – you mean “image_url”?

    #19629

    I was thinking you can create a line of text with color information, say, “1,0.5,0.5”, and use it instead of “image_url”.

    Chief 3D Verger | LinkedIn | Twitter

    #19768
    hoody
    Participant

    Hey Yuri, thanks for your support.

    I came up with this:

    eventHTMLElem(‘change’, ‘picker2’, true, function(event) {

    let rbg = changeToRBG(event.target.value)
    console.log(rbg)

    var vals = rbg.substring(rbg.indexOf(‘(‘) +1, rbg.length -1).split(‘,’)
    console.log(vals[0]+” “+vals[1]+” “+vals[2])

    setMaterialColor(‘mat_schnalle_rechts’, ‘RGB’, (vals[0]/255), (vals[1]/255), (vals[2]/255));

    let serial = “”
    serial+=vals[0]/255+”,”+vals[1]/255+”,”+vals[2]/255
    console.log(“serial: “+serial+” Typeof: “+ typeof serial)

    saved_conf_url = setUrlParam(getUrlData(‘URL’), ‘mat.color’, serial);
    openWebPage(saved_conf_url, ‘NO_RELOAD’);
    });

    The parameters are saved to the url – but when i share it on FB the configuration of the color is not saved.

    What im i doing wrong?

    #19769

    so it works if you use this URL in the address bar of the browser, but not on FB? May be they limit URL to only contain certain characters? You can try using “&” symbols that should be allowed.

    Chief 3D Verger | LinkedIn | Twitter

    #19770
    hoody
    Participant

    No what i mean is that i can see that parameters are saved to the url. But the configuration / the changes are not visible in the browser.

    Link looks like this: http://brudastan.de/wp-content/uploads/verge3d/2507/Brudi.html?mat.color=0%2C1%2C0

    Im not sure if mat.color is right?

    #19789

    Hi,

    you probably need to do something simple like:

    http://brudastan.de/wp-content/uploads/verge3d/2507/Brudi.html?R=0&G=0.5&B=0.5

    Set colors from URL

    P.S: You might also need to reduce the size of the default normal map and disable SSAO (it works really slow on thye low-end and middle-end hardware).

    Attachments:
    You must be logged in to view attached files.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #19839
    hoody
    Participant

    Hey Guys thanks for taking your time.

    I managed to save the R,G,B values to the url parameters.

    But the colors are not changing in the “customized scene” under the custom link.
    -> Url paremeters have no influence

    What am i missing?

    Heres my code:

    if (dictGet(getUrlData(‘PARAMS’), ‘R’) && dictGet(getUrlData(‘PARAMS’), ‘G’) && dictGet(getUrlData(‘PARAMS’), ‘B’)) {
    loadFiledictGet(getUrlData(‘PARAMS’), ‘R’) && dictGet(getUrlData(‘PARAMS’), ‘G’) && dictGet(getUrlData(‘PARAMS’), ‘B’), function() {
    let r_val = dictGet(getUrlData(‘PARAMS’), ‘R’); let g_val = dictGet(getUrlData(‘PARAMS’), ‘G’); let b_val = dictGet(getUrlData(‘PARAMS’), ‘B’); setMaterialColor(‘mat_schnalle_links’, ‘RGB’, r_val, g_val, b_val);
    setMaterialColor(‘mat_schnalle_rechts’, ‘RGB’, r_val, g_val, b_val);
    };
    }

    eventHTMLElem(‘change’, ‘picker2’, true, function(event) {

    let rbg = changeToRBG(event.target.value)

    var vals = rbg.substring(rbg.indexOf(‘(‘) +1, rbg.length -1).split(‘,’)

    let r_val = (vals[0]/255)
    let g_val = (vals[1]/255)
    let b_val = (vals[2]/255)

    setMaterialColor(‘mat_schnalle_links’, ‘RGB’, r_val, g_val, b_val);
    setMaterialColor(‘mat_schnalle_rechts’, ‘RGB’, r_val, g_val, b_val);
    saved_conf_url = setUrlParam(getUrlData(‘URL’), ‘R’, r_val);
    saved_conf_url += ‘&G=’+g_val
    saved_conf_url += ‘&B=’+b_val

    openWebPage(saved_conf_url, ‘NO_RELOAD’);
    });

    I think i´m close to get this solved with a hint in the right direction from you guys.

    Thanks

    #19846
    hoody
    Participant

    Never mind! I got it! :)

    #19850

    Awesome :good:

    Soft8Soft Tech Chief
    X | FB | LinkedIn

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.