-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e36ec70
commit 833170c
Showing
7 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,51 @@ | ||
export function setupCameraGUI(gui, camera) { | ||
import * as THREE from "three"; | ||
|
||
export function setupCameraGUI(tjs, gui, camera) { | ||
// Create a folder for camera parameters | ||
const cameraFolder = gui.addFolder("Camera"); | ||
|
||
// Temp storage for position to use in onChange callbacks | ||
const position = { x: camera.position.x, y: camera.position.y, z: camera.position.z }; | ||
|
||
// Dropdown for selecting camera type | ||
const cameraType = { type: camera instanceof THREE.PerspectiveCamera ? "Perspective" : "Orthographic" }; | ||
cameraFolder | ||
.add(cameraType, "type", ["Perspective", "Orthographic"]) | ||
.name("Camera Type") | ||
.onChange((newType) => { | ||
tjs.cameraType = newType; | ||
tjs.updateCameraAndControls({}); | ||
}); | ||
|
||
function updateCameraPosition(x, y, z) { | ||
camera.position.set(x, y, z); | ||
position.x = x; | ||
position.y = y; | ||
position.z = z; | ||
} | ||
|
||
// Add GUI controllers for position | ||
cameraFolder | ||
.add(position, "x", -100, 100) | ||
.name("X Position") | ||
.onChange((newValue) => { | ||
camera.updatePosition(newValue, position.y, position.z); | ||
// Update the temp storage to ensure consistency | ||
position.x = newValue; | ||
}); | ||
.onChange((newValue) => updateCameraPosition(newValue, position.y, position.z)); | ||
cameraFolder | ||
.add(position, "y", -100, 100) | ||
.name("Y Position") | ||
.onChange((newValue) => { | ||
camera.updatePosition(position.x, newValue, position.z); | ||
// Update the temp storage to ensure consistency | ||
position.y = newValue; | ||
}); | ||
.onChange((newValue) => updateCameraPosition(position.x, newValue, position.z)); | ||
cameraFolder | ||
.add(position, "z", -100, 100) | ||
.name("Z Position") | ||
.onChange((newValue) => { | ||
camera.updatePosition(position.x, position.y, newValue); | ||
// Update the temp storage to ensure consistency | ||
position.z = newValue; | ||
}); | ||
.onChange((newValue) => updateCameraPosition(position.x, position.y, newValue)); | ||
|
||
function updateCameraType(type) { | ||
if (type === "Perspective") { | ||
camera.fov = camera.fov || 50; // Default fov if not set | ||
camera.updateProjectionMatrix(); | ||
} else if (type === "Orthographic") { | ||
// Specific adjustments for Orthographic camera can be made here | ||
// camera.left, camera.right, camera.top, camera.bottom, etc. | ||
camera.updateProjectionMatrix(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+38.5 KB
tests/e2e/gui.spec.js-snapshots/Camera-perspective-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.