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

Fixes issue with removing objects from scene that don't have materials (... #126

Merged
merged 1 commit into from
Sep 9, 2013

Conversation

saebyn
Copy link
Contributor

@saebyn saebyn commented Sep 8, 2013

...e.g. cameras).

@saebyn
Copy link
Contributor Author

saebyn commented Sep 8, 2013

Not quite, since if object.material is undefined, this will throw an error.
My pull request adds an additional check before dereferencing on
object.material to prevent the TypeError when removing things, like cameras
that don't have materials, from the scene.

On Sun, Sep 8, 2013 at 2:32 PM, Yousef Amar notifications@github.comwrote:

Beat you to it, buddy. :) -> 20fe58420fe584


Reply to this email directly or view it on GitHubhttps://github.com//pull/126#issuecomment-24029991
.

@yousefamar
Copy link
Contributor

Yeah, realized a second after posting and it made sense. That's why I deleted my comment. My bad!

@saebyn
Copy link
Contributor Author

saebyn commented Sep 8, 2013

No problem :) I was confused why I didn't see your comment on github, but I
guess that explains it.

On Sun, Sep 8, 2013 at 2:42 PM, Yousef Amar notifications@github.comwrote:

Yeah, realized a second after posting and it made sense. That's why I
deleted my comment. My bad!


Reply to this email directly or view it on GitHubhttps://github.com//pull/126#issuecomment-24030184
.

chandlerprall added a commit that referenced this pull request Sep 9, 2013
Fixes issue with removing objects from scene that don't have materials (...
@chandlerprall chandlerprall merged commit 7e3837b into chandlerprall:master Sep 9, 2013
@juanpscotto
Copy link

Hi, I have the same error when removing a arrowHelper from the scene: Here is my code:

var arrow = new THREE.ArrowHelper( new THREE.Vector3( 0, -1, 0 ), new THREE.Vector3( 0, 0, 0 ), 5 , 0x0D6759);
arrow .is_arrow = true;
arrow.position.set(0, 0, 0);
scene.add( vectorComponenteVelocidadY );

This is my function to remove all the arrows from the scene;
function removeArrow()
{
var obj, i;
for ( i = scene.children.length - 1; i >= 0 ; i -- ) {
obj = scene.children[ i ];
if ( obj.is_arrow) {
scene.remove(obj);
}
}
}

But it only remove one, and it gives me the following error:
TypeError: object.material is undefined

...material._physijs && this._materials_ref_counts.hasOwnProperty( object.material._p...

What Can I do to delete them all? Thanks.

@chandlerprall
Copy link
Owner

Try using the most recent versions of physi.js and physijs_worker.js, the error you're seeing should be fixed.

@juanpscotto
Copy link

Thank you very much, I just applied the patch you did me lasta time, now I downloaded all the files again and it works perfect!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants