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

Error creating box with a THREE.Audio in the tree #13

Open
mqp opened this issue Jul 26, 2018 · 1 comment
Open

Error creating box with a THREE.Audio in the tree #13

mqp opened this issue Jul 26, 2018 · 1 comment
Labels

Comments

@mqp
Copy link
Contributor

mqp commented Jul 26, 2018

Unfortunately, it doesn't seem to be safe to call clone on an arbitrary three.js Object3D. As a result, creating a box shape fails if you try to create it on an object hierarchy that includes somewhere in it an Audio or PositionalAudio Object3D. For example, in a browser:

const listener = new THREE.AudioListener();
const object = new THREE.Mesh(new THREE.BoxGeometry(10, 10, 10));
object.children.push(new THREE.Audio(listener));

// fails
const box = mesh2shape(object, { type: mesh2shape.Type.BOX });

will result in

TypeError: listener is undefined three.js:39118
	Audio three.js:39118
	clone three.js:8636
	copy three.js:8674
	clone three.js:8636
	createBoundingBoxShape index.js:104
	mesh2shape index.js:25

This regressed recently with this commit: 0c7bc98

I don't know enough about three.js conventions to say whether three or this library is the one that is "wrong". One possible fix would be to write the bounding box creation code in question directly in terms of the matrices involved instead of calling clone, but it looks like that would be mostly duplicating a lot of code from Box3.

@mqp mqp changed the title Error creating a box shape with a THREE.Audio in the tree Error creating box shape with a THREE.Audio in the tree Jul 26, 2018
@mqp mqp changed the title Error creating box shape with a THREE.Audio in the tree Error creating box with a THREE.Audio in the tree Jul 26, 2018
mqp added a commit to Hubs-Foundation/hubs that referenced this issue Jul 26, 2018
Future versions have a bug which is awkward to work around; for
now, make sure we don't accidentally upgrade.

See donmccurdy/three-to-cannon#13.
@mqp
Copy link
Contributor Author

mqp commented Jul 26, 2018

Ah, this is what my esteemed colleague @johnshaughnessy has made a PR to try to fix: #12

@donmccurdy donmccurdy added the bug label Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants