I have a Three.JS application that colors the object based on a text file:
let color1 = 0x00ff00;
let color2 = 0xFF04F0;
In the Three.JS code:
var cubeGeometry = new THREE.BoxGeometry(15, 1, 5);
var cubeMaterial = new THREE.MeshLambertMaterial({color:color2});
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
var cubeGeometry1 = new THREE.BoxGeometry(15, 1, 5);
var cubeMaterial1 = new THREE.MeshLambertMaterial({color:color1});
var cube1 = new THREE.Mesh(cubeGeometry1, cubeMaterial1);
As the colors in the text file change, the Three.JS application displays them correctly. If I add <META HTTP-EQUIV="refresh" CONTENT="5">
on the <head>
of the html then it refreshes and grabs the color values, but the scene resets (notice that you can move the scene with the mouse). Is there a way to update the Javascript variables without reloading the page and keeping the Three.JS scene?
Full code is here: https://github.com/f0n/threeSocket
GitHub pages: https://f0n.github.io/threeSocket/