Replies: 0
So i tried to add a Color-Picker to Vrm 360 3D Model Viewer, so the user (client) can change the color of the model any time. Although the developer says, that its not included right now.
So i thought why can’t i just change the HEX-Color Code (#dd3377) with a form and PHP. Is it possible? And the answer is YES !!!
So here is the workaround:
1. You need a plugin to use PHP-Shortcode (Snippets) in WordPress.
I used the plugin “Insert PHP Code Snippet”
https://de.wordpress.org/plugins/insert-php-code-snippet/
2. Create a new PHP-Snippet and give it a name.
In my example i named the snippet “PHP-Color-Picker-Snippet”.
3. Copy the following code into that snippet
————————————————
<?php
if(empty($_POST["color-picker"]))
{
$_POST["color-picker"] = "#adadad";
}
echo "<form method='post' action=''>";
echo "HEX-COLOR<br>";
echo "<input type='color' name='color-picker' value='".$_POST["color-picker"]."' onchange='this.form.submit()'>";
echo do_shortcode( "[vrm360 canvas_name=s1 model_url=http://wptestrotaform.aricon.de/wp-content/uploads/2021/11/Kuehlbox-Kopie-1.stl aspect_ratio=1.33333 hide_cmds=zoom,fit,run initial_offset=2 grid=false back_image_url=http://wptestrotaform.aricon.de/wp-content/uploads/2021/11/istockphoto-155013511-1024x1024-1.jpg mesh_color=".$_POST['color-picker']."]" );
echo "</form>";
?>
————————————————
4. Change model_url, hide_cmds, aspect_ratio, back_image_url, e.t.c
5. Add the shortcode of the PHP-Snippet to any page you want
In my example the shortcode looks like this
[xyz-ips snippet=”PHP-Color-Picker-Snippet”]
6. You can change the style of the color-picker via CSS to match your page.
7. ???
8. Profit
9. Enjoy
Here is the Demo-Page iam working on right now:
DEMO
If you have questions feel free to ask and i try to help, if i have the time 😉