Dealing with exporting data from a three.js mesh to a string inside a web worker has been challenging for me. The issue arises when prototype information is lost, not due to three.js itself but because of the web workers. Essentially, my goal is to send objects to the web worker and utilize them in an imported script.
This snippet shows my web worker code:
importScripts('../editor/three.js', '../exporter.js');
onmessage = function(event) {
postMessage(event.data);
export(event.data);
};
The event.data object contains faces and vertices, and postMessage successfully sends the correct information. For example, the normal vector retains its clone() function.
The problem surfaces when I attempt to access the data in the export() function. While the values are accurate, all prototype information is lost. This means that the normal vector has properties x, y, z, but no longer recognizes the clone() function.
The export() function is defined in exporter.js with the definitions of three.js objects residing in three.js file.
Any suggestions or ideas on how to solve this?
Thank you.