-
Notifications
You must be signed in to change notification settings - Fork 149
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
why memory cost too much than three.js?and how to improve performance? #55
Comments
I read doc,you suggested that use obj.duplicate() when adding many identical objects. Performance considerations let i=1;
tb.loadObj(options, function (model) {
mdl = model.duplicate(); //use duplicate
console.log("loop begin");
origin.forEach((el) => {
mdl.setCoords(el).addTooltip("Boat", false);
console.log("clone times "+i, mdl);
tb.add(mdl);
i++;
});
console.log("loop end");
}); |
@jscastro76 var origin = new Array();
for (let index = 0; index < 100; index++) {
var coordinates = new Array(2);
coordinates[0] = Math.random() * (119.287 - 117.335) + 117.335;
coordinates[1] = Math.random() * (39.413 - 38.488) + 38.488;
origin.push(coordinates);
}
let i=1;
tb.loadObj(options, function (model) {
console.log("loop begin");
origin.forEach((el) => {
let mdl=model.duplicate().setCoords(el); //use this type is ok!
mdl.addTooltip("Boat", false);//.addLabel("<h1>Hello World!</h1>");// addTooltip("Boat", false);
console.log("clone times "+i, mdl.coordinates);
tb.add(mdl);
i++;
});
console.log("loop end");
});
}, |
Since a few days ago I see your issues reported, thanks for your interest in the project, but let me clarify some basic rules to have a healthy and structured interaction if you pretend to receive help. Having said so, first you mentioned you use three.js to add 5000 objects, please share the sample code you are using in comparison to the sample code of threebox, without that is impossible I can help you with it. Second, I see you found the right way to clone objects with |
…e 3D objects of a layer, apart from removing the layer itself with `map.removeLayer` - [**#56**](#56) Objects cache at `tb.loadObj` - `tb.loadObj` now is 100% async and in the first call to an object load by url, then caches the returned object for the sucessive calls to return a clone of the object through `obj.duplicate()` - Closes [**#51**](#51), [**#55**](#55) - [**#57**](#57) Add a new sample to measure performance - Added new example to demonstrate add thousands of objects and measure performance [Threebox Performance](https://github.com/jscastro76/threebox/blob/master/examples/15-performance.html). - [**#58**](#58) Refactor `tb.remove` - [**#59**](#59) Refactor `tb.clear` to add `layerId`. - [**#60**](#58) Refactor `tb.dispose` - All the examples reviewed and updated and added to the [Examples list](https://github.com/jscastro76/threebox/blob/master/examples/readme.md)
@luojiandan check out the new v.2.0.6 as it includes an important change in |
Hi @jscastro76 ,
Thank you for maintaining this plugin.
when I add the same model to the map for 100 times by threebox.js,the memory cost 2GB.and set the number to 500,the browser crash
but add the same model to the map for 5000 times by three.js,the memory cost 162M.
Why is the gap so large and how can I improve performance?
**model file format:**glb
**model size:**4M
three.js:
memory cost 162M
threebox.js:
way 1:
way 2(duplicate):
Am I in the right way or there another way?
thanks again:)
The text was updated successfully, but these errors were encountered: