Closed MaxGeldner closed 3 years ago
If we already have our STL file in memory (perhaps pre-loaded, or even generated in-client), then we can just pass that
file data straight to the STLLoaderPlugin#load
method. In the example below, we'll show how it's done by pre-loading
our STL file data, before passing it to that method.
loadSTL("./models/stl/binary/spurGear.stl", (stlData) =>{
const model = stlLoader.load({
id: "myModel",
stl: stlData,
smoothNormals: true
});
})
function loadSTL(src, ok, error) {
const request = new XMLHttpRequest();
request.overrideMimeType("application/json");
request.open('GET', src, true);
request.responseType = 'arraybuffer';
request.onreadystatechange = function () {
if (request.readyState === 4) {
if (request.status === 200) {
ok(request.response);
} else if (error) {
error(request.statusText);
}
}
};
request.send(null);
}
/ping @MaxGeldner - I just released this fix in 1.7.0-alpha.4
See all changes in that pre-release here: https://github.com/xeokit/xeokit-sdk/blob/master/CHANGE_LOG.md
Everything under the "1.7.0" heading in that change log is pre-released in 1.7.0-alpha.4.
The other issue that (if I understand correctly) is important for our project is https://github.com/xeokit/xeokit-sdk/issues/579, which allows us to load STL models with double-precision global coordinates, so they properly render align with double-precision map coordinates without rounding errors.
/ping @MaxGeldner - I just released this fix in 1.7.0-alpha.4
See all changes in that pre-release here: https://github.com/xeokit/xeokit-sdk/blob/master/CHANGE_LOG.md
Everything under the "1.7.0" heading in that change log is pre-released in 1.7.0-alpha.4.
The other issue that (if I understand correctly) is important for our project is #579, which allows us to load STL models with double-precision global coordinates, so they properly render align with double-precision map coordinates without rounding errors.
@xeolabs Thank you very much :) I hope to integrate the new version before our meeting next monday and get back to you with questions on that appointment, if I have any.
Until then have a nice weekend!
Is this feature critical for your commercial enterprise? Yes, it is critical for the DBI project (we are in talks over a license agreement atm I think).
Is your feature request related to a problem? Please describe. I'd like to plug data directly into the STL loader and not go the extra way of having to write my data into a file, to use the STL loaders load() function. Assuming a part of my code generates a STL string, it would be better to have a method in the STL loader that can handle this STL string directly.
Describe the solution you'd like At the moment the STL loader uses the parse() function to actually load the STL string, taken from a file via the load() function, into Xeokit. Solutions would be: