Demand
- Open the local STL file
- An independent WebGL-based viewer that will be reused by other sites
- Data transfer of the open file to the viewer, and the progress bar is displayed when the file is loaded
Solution Solutions
#1可以使用传统的html5 API to open,
#2来说, an IFRAME can be used to provide a separate viewer,
#3来说需要用web worker to implement.
Implementation Details
The flow of data is the main page-of the Web site, the main page-of the viewer in the iframe "Web worker-" iframe, which is the home page
The data type you just opened is the buffer array, which can be passed directly to the main page of the IFRAME Viewer via post message and then to the Web worker of the viewer via post message, which is parsed by the worker. During parsing, the worker is sent a message to the viewer main page to update the progress bar
Attention
When using post message, because data copy is easy to get out of memory when the file is large, the solution is to use transferable parameters to avoid copy of the big data being transferred.
Results
The file opened in 300MB is approximately 6 seconds in length.
Open the local STL file and create the geometry used by WebGL