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

Refactor GridHelper to support different size and divisions #29601

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Makio64
Copy link
Contributor

@Makio64 Makio64 commented Oct 9, 2024

Description

GridHelper can now receive a width/height and different division. The previous signature still work ( synthax inspired by animejs )

new GridHelper( size , divisions, color1 , color2 )
new GridHelper( 10 , 10, 0xff0000 , 0x00ff00 ) create a grid of 10x10 divide 10 times.
new GridHelper( [5,10] , [5,2], 0xff0000 , 0x00ff00 ) create a grid of 5x10 divide 5 time on x axis and 2 times on z axis

Can also mix the int / array for size/divisions

Copy link

github-actions bot commented Oct 9, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 689.92
170.93
690.05
170.98
+133 B
+46 B
WebGPU 813.52
219.09
813.65
219.13
+133 B
+40 B
WebGPU Nodes 813.03
218.94
813.16
218.98
+133 B
+44 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 462.94
111.81
462.94
111.81
+0 B
+0 B
WebGPU 537.35
145
537.35
145
+0 B
+0 B
WebGPU Nodes 493.46
134.72
493.46
134.72
+0 B
+0 B

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 10, 2024

I'm not sure about this, tbh. It seems having grids like that is a quite specific thing. In order to keep the helper straightforward, I currently tend to leave this bit out.

@Makio64
Copy link
Contributor Author

Makio64 commented Oct 10, 2024

@Mugen87 I often found myself needing it while doing editor or prototyping so I though it might be profitable to others.

Here some use cases not squared :

  • "Infinite runner" level editor : long tiles of 3 x 100 to put obstacles on it
  • Rooms editor prototype : placing items on a grid based on a wall / floor in a not cubic room
  • Dungeon game prototype : the fight in each rooms are on a grid based but the battlefield is not always squared

But I think the code added is too big for the usage, I will try to make it more small and elegant

@Makio64
Copy link
Contributor Author

Makio64 commented Oct 11, 2024

@Mugen87 i reduced the code, its 67lines in total but if you think its too much, maybe in addons or in a Gist

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 11, 2024

The new approach is indeed cleaner. Let's see what @mrdoob thinks about this feature.

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.

2 participants