mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-25 18:39:55 +08:00
added transform controls back (#424)
This commit is contained in:
1 parent
0a86c56a8a
commit
7fd8470429
7 files changed
+27
-60
No files matched your search
@@ -25,11 +25,11 @@ function setPoint(point, pointMap, geometry, camera, x, y, z) {
|
||||
*/
|
||||
|
||||
class CameraHelper extends THREE.Mesh {
|
||||
constructor(camera) {
|
||||
constructor(camera, color = 0x000000) {
|
||||
const line_geometry = new THREE.BufferGeometry();
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
const material = new MeshLineMaterial({
|
||||
color: 0x000000,
|
||||
color,
|
||||
lineWidth: 0.01,
|
||||
});
|
||||
|
||||
@@ -101,13 +101,11 @@ class CameraHelper extends THREE.Mesh {
|
||||
|
||||
const w = 1;
|
||||
const h = 1;
|
||||
const z = 2;
|
||||
const z = 0.1;
|
||||
|
||||
// we need just camera projection matrix inverse
|
||||
// world matrix must be identity
|
||||
|
||||
console.log(_camera.projectionMatrixInverse);
|
||||
|
||||
_camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);
|
||||
|
||||
// near
|
||||
|
||||
@@ -40,13 +40,12 @@ function CameraList(props) {
|
||||
|
||||
const set_transform_controls = (index) => {
|
||||
// camera helper object so grab the camera inside
|
||||
const camera = sceneTree.find([
|
||||
const camera = sceneTree.find_object([
|
||||
'Camera Path',
|
||||
'Cameras',
|
||||
index.toString(),
|
||||
'Camera',
|
||||
'<object>',
|
||||
]).object;
|
||||
]);
|
||||
transform_controls.attach(camera);
|
||||
};
|
||||
|
||||
@@ -138,6 +137,7 @@ export default function CameraPanel(props) {
|
||||
|
||||
const add_camera = () => {
|
||||
const camera_main_copy = camera_main.clone();
|
||||
camera_main_copy.aspect = 1.0;
|
||||
const new_camera_list = cameras.concat(camera_main_copy);
|
||||
setCameras(new_camera_list);
|
||||
set_camera_position(camera_render, camera_main_copy.matrix);
|
||||
@@ -169,7 +169,8 @@ export default function CameraPanel(props) {
|
||||
sceneTree.delete(['Camera Path', 'Cameras']); // delete old cameras, which is important
|
||||
for (let i = 0; i < cameras.length; i += 1) {
|
||||
const camera = cameras[i];
|
||||
const camera_helper = new CameraHelper(camera);
|
||||
// camera.aspect = render_width / render_height;
|
||||
const camera_helper = new CameraHelper(camera, 0xfc0303);
|
||||
// camera
|
||||
sceneTree.set_object_from_path(
|
||||
['Camera Path', 'Cameras', i.toString(), 'Camera'],
|
||||
@@ -181,7 +182,7 @@ export default function CameraPanel(props) {
|
||||
camera_helper,
|
||||
);
|
||||
}
|
||||
}, [cameras]);
|
||||
}, [cameras, render_width, render_height]);
|
||||
|
||||
// update the camera curve
|
||||
const curve_object = get_curve_object_from_cameras(cameras);
|
||||
@@ -191,7 +192,7 @@ export default function CameraPanel(props) {
|
||||
const geometry = new THREE.BufferGeometry().setFromPoints(points);
|
||||
const spline = new MeshLine();
|
||||
spline.setGeometry(geometry);
|
||||
const material = new MeshLineMaterial({ lineWidth: 0.05, color: 0xff5024 });
|
||||
const material = new MeshLineMaterial({ lineWidth: 0.01, color: 0xff5024 });
|
||||
const spline_mesh = new THREE.Mesh(spline.geometry, material);
|
||||
sceneTree.set_object_from_path(['Camera Path', 'Curve'], spline_mesh);
|
||||
}
|
||||
@@ -214,11 +215,10 @@ export default function CameraPanel(props) {
|
||||
const up = curve_object.curve_ups.getPoint(
|
||||
slider_value / (cameras.length - 1.0),
|
||||
);
|
||||
|
||||
const mat = get_transform_matrix(position, lookat, up);
|
||||
set_camera_position(camera_render, mat);
|
||||
}
|
||||
}, [slider_value]);
|
||||
}, [slider_value, render_height, render_width]);
|
||||
|
||||
// call this function whenever slider state changes
|
||||
useEffect(() => {
|
||||
|
||||
@@ -7,7 +7,8 @@ function get_curve(list_of_3d_vectors) {
|
||||
const curve = new THREE.CatmullRomCurve3(
|
||||
list_of_3d_vectors,
|
||||
false,
|
||||
'catmullrom',
|
||||
// 'centripetal'
|
||||
'chordal'
|
||||
);
|
||||
return curve;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user