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

Simple collision example #20836

Merged
merged 1 commit into from Dec 22, 2020
Merged

Simple collision example #20836

merged 1 commit into from Dec 22, 2020

Conversation

supereggbert
Copy link
Contributor

Related issue: --

Description

This is a simple example of doing some collisions within three.js, using its maths functions, without having to resort to the bloat and overhead of a full physics engine.

There are basic octree and capsule implementations, that are by no means complete. I've tried to keep things simple so It will hopefully serve as a good starting point for three.js projects.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 5, 2020

There are basic octree

Notice that there is already a k-d tree implementation in three.js.

In general I'm not feeling so well with adding space-partitioning structures at all to this repo. I've planned to suggest to remove TypedArrayUtils and webgl_nearestneighbour and implement such entities in third party repos.

The Capsule class looks more appropriate although you only need to add the jsm version.

@gkjohnson
Copy link
Collaborator

Here's the live example link:

http://raw.githack.com/supereggbert/three.js/octree-collision/examples/misc_octree_collisions.html

Really nice demo!

@supereggbert
Copy link
Contributor Author

@Mugen87 Apologies, maybe my naming the class “octree” is inappropriate. It's intended to be a collider for generic triangle meshes. So perhaps, a rename to TrimeshCollider may be better?

It's primary purpose isn’t to be a spacial index, it simply makes use of one. It adds the ability to do collision tests against a trimesh that aren't just ray queries, i.e. sphere intersections and capsule intersections, something not currently supported directly in three.js. If the use of a spatial index is an issue, I can remove it and both the class and example should still work fine. However, it would limit its use to trimeshes consisting of 1000s of triangles; it currently scales to 100,000s with the inclusion of a little extra code to build an index.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 6, 2020

The final decision is up to @mrdoob but I have in general problems to expand the repository with logic that normally belongs to a game engine. three.js should focus on rendering.

Besides, the problem is that all code in the repository needs to be maintained. And I have the feeling we are already spending too much of our limited time in maintaining and support code in examples. This distracts us from doing development tasks in the core. There are many core-related issues and PRs waiting to be fixed or reviewed. And I'm not convinced that we can make noticeable progress in the future if the repo gets bigger and bigger.

Sorry, I know this issue should be discussed separately but this PR was some sort of opportunity for me to write it down. Your code is definitely great but I think it belongs to an own repository.

@supereggbert
Copy link
Contributor Author

@Mugen87 I totally understand, and I'm 100% happy either way. Maybe, hosting externally and instead adding to the "Useful links" in the docs is more appropriate?

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 6, 2020

Maybe, hosting externally and instead adding to the "Useful links" in the docs is more appropriate?

Yeah this sounds good to me. Besides, I recommend to make a post in the forum's Resources category about the code. This would also allow you to explain the code, the motivation behind it and receive feedback of curious community members.

@mrdoob mrdoob added this to the r124 milestone Dec 22, 2020
@mrdoob
Copy link
Owner

mrdoob commented Dec 22, 2020

This is fantastic @supereggbert!

@mrdoob
Copy link
Owner

mrdoob commented Dec 22, 2020

@Mugen87

The final decision is up to @mrdoob but I have in general problems to expand the repository with logic that normally belongs to a game engine. three.js should focus on rendering.

Lately I've been thinking of doing basic game examples that people can use as a base. Mainly because it's pretty hard to put all the available web apis together and make something work on desktop and mobile. I think this is perfect for game_fps.

Besides, the problem is that all code in the repository needs to be maintained. And I have the feeling we are already spending too much of our limited time in maintaining and support code in examples. This distracts us from doing development tasks in the core. There are many core-related issues and PRs waiting to be fixed or reviewed. And I'm not convinced that we can make noticeable progress in the future if the repo gets bigger and bigger.

Yes, I completely understand. I think in 2021 we could focus on dong some clean up and merge and/or remove examples.

@mrdoob mrdoob merged commit 22d07c8 into mrdoob:dev Dec 22, 2020
@mrdoob
Copy link
Owner

mrdoob commented Dec 22, 2020

Thanks!

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 23, 2020

I think in 2021 we could focus on dong some clean up and merge and/or remove examples.

Sounds good! 👍

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 14, 2021

@supereggbert Do you mind having a look at this question about the new code in the forum?

https://discourse.threejs.org/t/large-model-collision-follow-games-fps-example/22424

@supereggbert
Copy link
Contributor Author

@Mugen87 Apologies for the delay, I've only just seen. I'll take a look now.

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.

None yet

4 participants