We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The getObjectsByProperty method can be greatly improved by sharing the same array, instead of creating new ones and concatenating them.
I have created an example where performance can be checked.
If you want I can do PR.
I created a scene with 5000 children and called the getObjectsByProperty method to select them all.
Current function:
getObjectsByProperty( name, value ) { let result = []; if ( this[ name ] === value ) result.push( this ); for ( let i = 0, l = this.children.length; i < l; i ++ ) { const childResult = this.children[ i ].getObjectsByProperty( name, value ); if ( childResult.length > 0 ) { result = result.concat( childResult ); } } return result; }
Function with shared array reference:
function getObjectsByProperty2(name, value, result = []) { if (this[name] === value) result.push(this); for (let i = 0, l = this.children.length; i < l; i++) { this.children[i].getObjectsByProperty2(name, value, result); } return result; };
https://jsfiddle.net/agargaro/qyh6zxkg/4/
No response
r158
The text was updated successfully, but these errors were encountered:
I agree this is a good suggestion. We have similar result or target parameters in other methods as well.
That would be great!
Sorry, something went wrong.
getObjectsByProperty()
Successfully merging a pull request may close this issue.
Description
The getObjectsByProperty method can be greatly improved by sharing the same array, instead of creating new ones and concatenating them.
I have created an example where performance can be checked.
If you want I can do PR.
Reproduction steps
I created a scene with 5000 children and called the getObjectsByProperty method to select them all.
Code
Current function:
Function with shared array reference:
Live example
https://jsfiddle.net/agargaro/qyh6zxkg/4/
Screenshots
No response
Version
r158
Device
No response
Browser
No response
OS
No response
The text was updated successfully, but these errors were encountered: