46 lines
1.8 KiB
Markdown
46 lines
1.8 KiB
Markdown
# The Speckle Object Loader
|
|
|
|
[](https://twitter.com/SpeckleSystems) [](https://speckle.community) [](https://speckle.systems) [](https://speckle.guide/dev/)
|
|
|
|
## Documentation
|
|
|
|
Comprehensive developer and user documentation can be found in our:
|
|
|
|
#### 📚 [Speckle Docs website](https://speckle.guide/dev/)
|
|
|
|
## Getting started
|
|
|
|
This is a small utility class that helps you stream an object and all its sub-components from the Speckle Server API. It is inteded to be used in contexts where you want to "download" the whole object, or iteratively traverse its whole tree.
|
|
|
|
Here's a sample way on how to use it, pfilfered from the [3d viewer package](../viewer):
|
|
|
|
```js
|
|
|
|
|
|
async load( { serverUrl, token, streamId, objectId } ) {
|
|
|
|
const loader = new ObjectLoader( { serverUrl, token, streamId, objectId } )
|
|
|
|
let total = null
|
|
let count = 0
|
|
|
|
for await ( let obj of loader.getObjectIterator() ) {
|
|
|
|
if( !total ) total = obj.totalChildrenCount
|
|
|
|
console.log( obj, `Progress: ${count++}/${total}` )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
## Community
|
|
|
|
If in trouble, the Speckle Community hangs out on [the forum](https://speckle.community). Do join and introduce yourself! We're happy to help.
|
|
|
|
## License
|
|
|
|
Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. If you have any questions, don't hesitate to get in touch with us via [email](mailto:hello@speckle.systems).
|