Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend STLLoaderPlugin to load via optional, custom data source object #578

Closed
xeolabs opened this issue Mar 3, 2021 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@xeolabs
Copy link
Member

xeolabs commented Mar 3, 2021

Solution

Example usage:

 class MyDataSource {
     getSTL(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 {
                     error(request.statusText);
                 }
             }
         };
         request.send(null);
    }
}

const stlLoader = new STLLoaderPlugin(viewer, {
    dataSource: new MyDataSource()
});

const model = stlLoader.load({
    id: "myModel",
    src: "./models/stl/binary/spurGear.stl",
    smoothNormals: true
});
@xeolabs xeolabs added the enhancement New feature or request label Mar 3, 2021
@xeolabs xeolabs self-assigned this Mar 3, 2021
@xeolabs xeolabs added this to the 1.7.0 milestone Mar 3, 2021
xeolabs added a commit that referenced this issue Mar 3, 2021
@xeolabs xeolabs closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant