threejs-inspector
v0.0.69
Published
## Running the project
Downloads
182
Readme
ThreeJS Inspector
Running the project
- The app is running live at https://catalin-enache.github.io/threejs-inspector/.
- To run the app locally, clone the repository and run
npm installfollowed bynpm run dev. - The project will be available at
http://localhost:5173/.
Project status
This project is currently an application that will be later extracted into a library.
It uses
R3F(React Three Fiber) andTweakpaneunder the hood.Dreiutilities will join soon.Using
R3Fshould not prevent using this editor with a nativeThreeJsapplication which could be instantiated in aReactcomponent insideuseEffecthook (at least in the current project state).
Objective
- The main goal of this project is to provide a simple way to interact with a given ThreeJS application (without interfering),
easing the process of finding the right configurations for different objects before adjusting them in code.
This goal will be finalised when the project will be extracted into a library.
For now, it is a standalone application, and it is decoupled enough. - Another goal is to be able to quickly prototype mini experiments to help in learning ThreeJS, Shaders and Math.
Quick Guide
The cPanel can be moved around by dragging the top bar and can be toggled by pressing Ctrl+Alt+Shift+P.
Helperscan be toggled by pressing Ctrl+Alt+Shift+H. Whenhelpersare off only thepickersare visible.Gizmos(which includehelpersandpickers) can be toggled by pressing Ctrl+Alt+Shift+G.Play/Stop mode can be toggled by pressing Space (when
cPanelorGizmosare visible - which meanseditor mode)
or by pressing Ctrl+Alt+Shift+Space (whencPanelandGizmosare hidden - which meansnon editor mode).The shortcuts will very likely change in the future to ensure we're not interfering at all with the main app.
Objects that are not visible (e.g. lights, cameras) are injected with a picker such that they can be selected in the scene view.
Objects that are visible (e.g. meshes) are not inspectable by default. They can be made inspectable by setting
isInspectable: trueinuserData(in application code).This design choice was made in order to avoid looping through a very large list of objects when
Raycasterlooks for hits.To inspect an object
double clickon it in the scene view.All shortcuts are mentioned in cPanel labels which are constrained to a limited width to not consume space, but are revealed on mouse hover.
The cPanel has 3 main tabs.
Selectedtab is used to interact with the selected object.Customtab is used to interact with custom controls (added in code).Globaltab is used to config cPanel itself and interact with other global objects.
OrbitandFlycamera controls are available in the scene view. InFlymode, the camera can be moved withWASDQEwhile right mouse button is pressed (like inUnrealandUnity). InOrbitmode, the camera can be rotated around with left mouse button and panned with right mouse button. In both modes, the camera can be focused on selected object (or center of the stage) by pressingF.In play mode by default the current camera is reused. If a new camera is added to the scene, and it has
userData.useOnPlay = truethat one will be used instead in play mode.
Note: Only one camera havinguseOnPlay = truewill be considered (the last one added). The providedOrbitandFlycamera controls are opt-in in play mode (in cPanel checkbox and via]shortcut).
This allows us to create fully functional mini apps as well as preventing interfering with the main app.
It goes without saying that the main app should have its own camera controls when the default ones are not attached to the playing camera.To change a texture image, click on the texture image in the cPanel and select a new image (or 6 images for cube texture) from the opened file explorer.
Allowed extensions are.jpg,.jpeg,.png,.gif,.tif,.tiff,.webp,.tga,.exr,.hdr,.hdr.jpg(see: HDR-JPG).
For scene background/environment- if the texture is equirectangular (ratio 2:1 - see examples in
textures/background/equirectangular) it can be used withEquirectanguarReflectionMappingandEquirectangularRefractionMapping. - if the texture is cube (6 images allowed to be uploaded simultaneously) it can be used with
CubeReflectionMappingandCubeRefractionMapping. The 6 images must have their name ending withpx,nx,py,ny,pz,nz(e.g.skybox_px.jpg,skybox_nx.jpg, etc. or justpx.jpg,py.jpgetc.).
or ending withposx,negx,posy,negy,posz,negz(e.g.skybox_posx.jpg,skybox_negx.jpg, etc. or justposx.jpg,negx.jpgetc.). - if the texture is a simple image (for 2d background) it can be used with
UVMapping.
- if the texture is equirectangular (ratio 2:1 - see examples in
Any change to a texture will update the texture and if the texture is inside a material it will recompile the material
to accommodate (custom) shaders that would be looking for a specific thing in a texture. Any change in a material will recompile the material.
That is because some material changes (e.g.magFilter/minFilter) are not visible until the material is recompiled. Because of this, when adjusting some values in a texture or material (especially when using sliders) the cPanel controls might not be very responsive.Pressing
CtrlorShiftwhile dragging a cPanel slider will make the slider move faster or slower, respectively. Numbers in cPanel can also be adjusted using arrow keys.
While pressingAlt/OptionorShiftthe increment will be slower or faster, respectively.
