mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-24 00:26:08 +08:00
Interactable camera path (#372)
* click to add cameras * buttons for translate, rotation, and world/local * gui layout mostly done * interpolation works * slider play works * camera code mostly working
This commit is contained in:
1 parent
ad4a6c4a6f
commit
adf249b3cd
11 files changed
+650
-48
No files matched your search
@@ -28,6 +28,10 @@ export function get_scene_tree() {
|
||||
sceneTree.delete(path);
|
||||
};
|
||||
|
||||
// Main camera
|
||||
const main_camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
|
||||
setObject(['Main Camera'], main_camera);
|
||||
|
||||
// Axes
|
||||
const axes = new THREE.AxesHelper(5);
|
||||
setObject(['Axes'], axes);
|
||||
|
||||
@@ -1,14 +1,310 @@
|
||||
import * as React from 'react';
|
||||
import * as THREE from 'three';
|
||||
|
||||
import { Button } from '@mui/material';
|
||||
import { Button, Slider } from '@mui/material';
|
||||
|
||||
import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew';
|
||||
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
|
||||
import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import FirstPageIcon from '@mui/icons-material/FirstPage';
|
||||
import LastPageIcon from '@mui/icons-material/LastPage';
|
||||
import PauseIcon from '@mui/icons-material/Pause';
|
||||
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
||||
import TextField from '@mui/material/TextField';
|
||||
import VisibilityIcon from '@mui/icons-material/Visibility';
|
||||
import { useEffect } from 'react';
|
||||
import { get_curve_object_from_cameras } from './curve';
|
||||
|
||||
function set_camera_position(camera, matrix) {
|
||||
const mat = new THREE.Matrix4();
|
||||
mat.fromArray(matrix.elements);
|
||||
mat.decompose(camera.position, camera.quaternion, camera.scale);
|
||||
}
|
||||
|
||||
function CameraList(props) {
|
||||
const sceneTree = props.sceneTree;
|
||||
const cameras = props.cameras;
|
||||
const camera_main = props.camera_main;
|
||||
const transform_controls = props.transform_controls;
|
||||
const setCameras = props.setCameras;
|
||||
|
||||
const set_transform_controls = (index) => {
|
||||
// camera helper object so grab the camera inside
|
||||
const camera = sceneTree.find([
|
||||
'Camera Path',
|
||||
'Cameras',
|
||||
index.toString(),
|
||||
'Camera',
|
||||
'<object>',
|
||||
]).object;
|
||||
transform_controls.attach(camera);
|
||||
};
|
||||
|
||||
const delete_camera = (index) => {
|
||||
console.log('TODO: deleting camera: ', index);
|
||||
setCameras([...cameras.slice(0, index), ...cameras.slice(index + 1)]);
|
||||
};
|
||||
|
||||
const cameraList = cameras.map((camera, index) => {
|
||||
return (
|
||||
<div className="CameraList-row" key={camera.uuid}>
|
||||
<Button onClick={() => set_transform_controls(index)}>
|
||||
Camera {index}
|
||||
</Button>
|
||||
<div className="CameraList-row-buttons">
|
||||
<Button
|
||||
onClick={() => set_camera_position(camera_main, camera.matrix)}
|
||||
>
|
||||
<VisibilityIcon />
|
||||
</Button>
|
||||
<Button onClick={() => delete_camera(index)}>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
return <div>{cameraList}</div>;
|
||||
}
|
||||
|
||||
export default function CameraPanel(props) {
|
||||
// unpack props
|
||||
const sceneTree = props.sceneTree;
|
||||
|
||||
// scene tree objects
|
||||
const camera_main = sceneTree.find_object(['Main Camera']);
|
||||
const transform_controls = sceneTree.find_object(['Transform Controls']);
|
||||
|
||||
// react state
|
||||
const [cameras, setCameras] = React.useState([]);
|
||||
const [slider_value, set_slider_value] = React.useState(0);
|
||||
const [is_playing, setIsPlaying] = React.useState(false);
|
||||
const [seconds, setSeconds] = React.useState(4);
|
||||
const [fps, setFps] = React.useState(24);
|
||||
const total_num_steps = seconds * fps;
|
||||
const step_size = (cameras.length - 1) / total_num_steps;
|
||||
const slider_min = 0;
|
||||
const slider_max = Math.max(0, cameras.length - 1);
|
||||
|
||||
const add_camera = () => {
|
||||
const camera_main_copy = camera_main.clone();
|
||||
camera_main_copy.far = camera_main_copy.near + 0.1;
|
||||
const new_camera_list = cameras.concat(camera_main_copy);
|
||||
setCameras(new_camera_list);
|
||||
};
|
||||
|
||||
// force a rerender if the cameras are dragged around
|
||||
let update_cameras_interval = null;
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
transform_controls.addEventListener('mouseDown', (event) => {
|
||||
// prevent multiple loops
|
||||
if (update_cameras_interval === null) {
|
||||
// hardcoded for 100 ms per udpate
|
||||
update_cameras_interval = setInterval(() => {
|
||||
setCameras(cameras);
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
transform_controls.addEventListener('mouseUp', (event) => {
|
||||
if (update_cameras_interval !== null) {
|
||||
clearInterval(update_cameras_interval);
|
||||
update_cameras_interval = null;
|
||||
}
|
||||
});
|
||||
|
||||
// draw cameras and curve to the scene
|
||||
useEffect(() => {
|
||||
// draw the cameras
|
||||
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 helper = new THREE.CameraHelper(camera);
|
||||
// camera
|
||||
sceneTree.set_object_from_path(
|
||||
['Camera Path', 'Cameras', i.toString(), 'Camera'],
|
||||
camera,
|
||||
);
|
||||
// camera helper
|
||||
sceneTree.set_object_from_path(
|
||||
['Camera Path', 'Cameras', i.toString(), 'Camera Helper'],
|
||||
helper,
|
||||
);
|
||||
}
|
||||
}, [cameras]);
|
||||
|
||||
// update the camera curve
|
||||
const curve_object = get_curve_object_from_cameras(cameras);
|
||||
if (cameras.length > 1) {
|
||||
const num_points = fps * seconds;
|
||||
const points = curve_object.curve_positions.getPoints(num_points);
|
||||
const geometry = new THREE.BufferGeometry().setFromPoints(points);
|
||||
const material = new THREE.LineBasicMaterial({ color: 0xff0000 });
|
||||
const threejs_object = new THREE.Line(geometry, material);
|
||||
sceneTree.set_object_from_path(['Camera Path', 'Curve'], threejs_object);
|
||||
}
|
||||
|
||||
const marks = [];
|
||||
for (let i = 0; i < cameras.length; i += 1) {
|
||||
marks.push({ value: i, label: i.toString() });
|
||||
}
|
||||
|
||||
// when the slider changes, update the main camera position
|
||||
useEffect(() => {
|
||||
if (cameras.length > 1) {
|
||||
// interpolate to get the points
|
||||
const position = curve_object.curve_positions.getPoint(
|
||||
slider_value / (cameras.length - 1.0),
|
||||
);
|
||||
const up = curve_object.curve_ups.getPoint(slider_value / cameras.length);
|
||||
const lookat = curve_object.curve_lookats.getPoint(
|
||||
slider_value / cameras.length,
|
||||
);
|
||||
|
||||
// create a copy of the vector up
|
||||
const up_copy = up.clone();
|
||||
const cross = up_copy.cross(lookat);
|
||||
|
||||
up.normalize();
|
||||
lookat.normalize();
|
||||
cross.normalize();
|
||||
|
||||
// create the camera transform matrix
|
||||
const mat = new THREE.Matrix4();
|
||||
mat.set(
|
||||
cross.x,
|
||||
up.x,
|
||||
lookat.x,
|
||||
position.x,
|
||||
cross.y,
|
||||
up.y,
|
||||
lookat.y,
|
||||
position.y,
|
||||
cross.z,
|
||||
up.z,
|
||||
lookat.z,
|
||||
position.z,
|
||||
);
|
||||
set_camera_position(camera_main, mat);
|
||||
}
|
||||
}, [slider_value]);
|
||||
|
||||
// call this function whenever slider state changes
|
||||
useEffect(() => {
|
||||
if (is_playing) {
|
||||
const interval = setInterval(() => {
|
||||
set_slider_value((prev) => prev + step_size);
|
||||
}, 1000 / fps);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
return () => {};
|
||||
}, [is_playing]);
|
||||
|
||||
// make sure to pause if the slider reaches the end
|
||||
useEffect(() => {
|
||||
if (slider_value >= slider_max) {
|
||||
set_slider_value(slider_max);
|
||||
setIsPlaying(false);
|
||||
}
|
||||
}, [slider_value]);
|
||||
|
||||
export default function CameraPanel() {
|
||||
return (
|
||||
<div className="CameraPanel">
|
||||
TODO: create a camera path panel list of cameras
|
||||
<Button id="CameraPanel-add-camera-button" variant="outlined">
|
||||
Add Camera
|
||||
</Button>
|
||||
<div className="CameraPanel-top-button">
|
||||
<Button variant="outlined" onClick={add_camera}>
|
||||
Add Camera
|
||||
</Button>
|
||||
</div>
|
||||
<div className="CameraPanel-top-button">
|
||||
<Button className="CameraPanel-top-button" variant="outlined">
|
||||
Export Path
|
||||
</Button>
|
||||
</div>
|
||||
<div className="CameraPanel-slider-container">
|
||||
<Slider
|
||||
value={slider_value}
|
||||
step={step_size}
|
||||
valueLabelDisplay="on"
|
||||
marks={marks}
|
||||
min={slider_min}
|
||||
max={slider_max}
|
||||
disabled={cameras.length < 2}
|
||||
onChange={(event, value) => {
|
||||
set_slider_value(value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="CameraPanel-slider-button-container">
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={() => {
|
||||
setIsPlaying(false);
|
||||
set_slider_value(slider_min);
|
||||
}}
|
||||
>
|
||||
<FirstPageIcon />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={() => set_slider_value(slider_value - step_size)}
|
||||
>
|
||||
<ArrowBackIosNewIcon />
|
||||
</Button>
|
||||
|
||||
{!is_playing ? (
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={() => {
|
||||
setIsPlaying(true);
|
||||
}}
|
||||
>
|
||||
<PlayArrowIcon />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={() => {
|
||||
setIsPlaying(false);
|
||||
}}
|
||||
>
|
||||
<PauseIcon />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={() => set_slider_value(slider_value + step_size)}
|
||||
>
|
||||
<ArrowForwardIosIcon />
|
||||
</Button>
|
||||
<Button variant="outlined" onClick={() => set_slider_value(slider_max)}>
|
||||
<LastPageIcon />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="CameraList-row-time-interval">
|
||||
<TextField
|
||||
id="outlined-number"
|
||||
label="Seconds"
|
||||
type="number"
|
||||
onChange={(e) => setSeconds(Math.max(1, e.target.value))}
|
||||
value={seconds}
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-number"
|
||||
label="FPS"
|
||||
type="number"
|
||||
onChange={(e) => setFps(Math.max(1, e.target.value))}
|
||||
value={fps}
|
||||
/>
|
||||
</div>
|
||||
<div className="CameraList-container">
|
||||
<CameraList
|
||||
sceneTree={sceneTree}
|
||||
transform_controls={transform_controls}
|
||||
camera_main={camera_main}
|
||||
cameras={cameras}
|
||||
setCameras={setCameras}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Code for creating a curve from a set of points
|
||||
|
||||
import * as THREE from 'three';
|
||||
|
||||
function get_curve(list_of_3d_vectors) {
|
||||
// TODO: add some hyperparameters to this function
|
||||
const curve = new THREE.CatmullRomCurve3(
|
||||
list_of_3d_vectors,
|
||||
false,
|
||||
'centripetal',
|
||||
);
|
||||
return curve;
|
||||
}
|
||||
|
||||
export function get_curve_object_from_cameras(cameras) {
|
||||
// interpolate positions, lookat directions, and ups
|
||||
// similar to
|
||||
// https://github.com/google-research/multinerf/blob/1c8b1c552133cdb2de1c1f3c871b2813f6662265/internal/camera_utils.py#L281
|
||||
|
||||
const positions = [];
|
||||
const lookats = [];
|
||||
const ups = [];
|
||||
|
||||
for (let i = 0; i < cameras.length; i += 1) {
|
||||
const camera = cameras[i];
|
||||
|
||||
const up = new THREE.Vector3(0, 1, 0); // y is up in local space
|
||||
const lookat = new THREE.Vector3(0, 0, -1); // -z is forward in local space
|
||||
up.applyQuaternion(camera.quaternion);
|
||||
lookat.applyQuaternion(camera.quaternion);
|
||||
|
||||
positions.push(camera.position);
|
||||
ups.push(up);
|
||||
lookats.push(lookat);
|
||||
}
|
||||
|
||||
let curve_positions = null;
|
||||
let curve_lookats = null;
|
||||
let curve_ups = null;
|
||||
|
||||
curve_positions = get_curve(positions);
|
||||
curve_lookats = get_curve(lookats);
|
||||
curve_ups = get_curve(ups);
|
||||
|
||||
const curve_object = {
|
||||
curve_positions,
|
||||
curve_lookats,
|
||||
curve_ups,
|
||||
};
|
||||
|
||||
return curve_object;
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import { Leva } from 'leva';
|
||||
import Tab from '@mui/material/Tab';
|
||||
import Tabs from '@mui/material/Tabs';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { useEffect } from 'react';
|
||||
import Divider from '@mui/material/Divider';
|
||||
import StatusPanel from './StatusPanel';
|
||||
import SceneNode from '../../SceneNode';
|
||||
@@ -40,11 +39,9 @@ function TabPanel(props: TabPanelProps) {
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...other}
|
||||
>
|
||||
{value === index && (
|
||||
<Box sx={{ p: 3, padding: 0 }}>
|
||||
<Typography component="div">{children}</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Box sx={{ p: 3, padding: 0 }}>
|
||||
<Typography component="div">{children}</Typography>
|
||||
</Box>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -121,18 +118,12 @@ interface BasicTabsProps {
|
||||
export function BasicTabs(props: BasicTabsProps) {
|
||||
const sceneTree = props.sceneTree;
|
||||
|
||||
const [value, setValue] = React.useState(0);
|
||||
const [value, setValue] = React.useState(2);
|
||||
|
||||
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
|
||||
setValue(newValue);
|
||||
};
|
||||
|
||||
// set the panel pane index
|
||||
useEffect(() => {
|
||||
const panel_index = 0;
|
||||
setValue(panel_index);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<StatusPanel sceneTree={sceneTree} />
|
||||
@@ -183,7 +174,7 @@ export function BasicTabs(props: BasicTabsProps) {
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel value={value} index={2}>
|
||||
<CameraPanel />
|
||||
<CameraPanel sceneTree={sceneTree} />
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel value={value} index={3}>
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
||||
import Stats from 'stats.js';
|
||||
import { useSelector } from 'react-redux';
|
||||
import React, { useContext, useEffect, useRef } from 'react';
|
||||
import { WebSocketContext } from '../WebSocket/WebSocket';
|
||||
|
||||
import { Button } from '@mui/material';
|
||||
import OpenWithIcon from '@mui/icons-material/OpenWith';
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
|
||||
import PublicOffSharpIcon from '@mui/icons-material/PublicOffSharp';
|
||||
import PublicSharpIcon from '@mui/icons-material/PublicSharp';
|
||||
import Stats from 'stats.js';
|
||||
import SyncOutlinedIcon from '@mui/icons-material/SyncOutlined';
|
||||
import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
||||
import { useSelector } from 'react-redux';
|
||||
import WebRtcWindow from '../WebRtcWindow/WebRtcWindow';
|
||||
import { WebSocketContext } from '../WebSocket/WebSocket';
|
||||
|
||||
const msgpack = require('msgpack-lite');
|
||||
|
||||
@@ -18,9 +25,54 @@ function createStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
function TransformIcons(props) {
|
||||
const sceneTree = props.sceneTree;
|
||||
const transform_controls = sceneTree.find_object(['Transform Controls']);
|
||||
// toggle back and forth between local and global transform
|
||||
const [world, setWorld] = React.useState(true);
|
||||
|
||||
const toggleLocal = () => {
|
||||
transform_controls.setSpace(world ? 'local' : 'world');
|
||||
setWorld(!world);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
className="ViewerWindow-iconbutton"
|
||||
onClick={() => {
|
||||
transform_controls.setMode('translate');
|
||||
}}
|
||||
variant="outlined"
|
||||
>
|
||||
{/* translate */}
|
||||
<OpenWithIcon />
|
||||
</Button>
|
||||
<Button
|
||||
className="ViewerWindow-iconbutton"
|
||||
onClick={() => {
|
||||
transform_controls.setMode('rotate');
|
||||
}}
|
||||
variant="outlined"
|
||||
>
|
||||
{/* rotate */}
|
||||
<SyncOutlinedIcon />
|
||||
</Button>
|
||||
<Button
|
||||
className="ViewerWindow-iconbutton"
|
||||
variant="outlined"
|
||||
onClick={toggleLocal}
|
||||
>
|
||||
{world ? <PublicSharpIcon /> : <PublicOffSharpIcon />}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// manages a camera and the web rtc stream...
|
||||
export default function ViewerWindow(props) {
|
||||
// eslint-disable-next-line react/prop-types
|
||||
const sceneTree = props.sceneTree;
|
||||
const scene = props.scene;
|
||||
|
||||
const myRef = useRef(null);
|
||||
@@ -30,13 +82,15 @@ export default function ViewerWindow(props) {
|
||||
);
|
||||
const field_of_view_ref = useRef(field_of_view);
|
||||
|
||||
const camera = useRef(null);
|
||||
let cameraControls = null;
|
||||
let transformsControls = null;
|
||||
let renderer = null;
|
||||
let viewportWidth = null;
|
||||
let viewportHeight = null;
|
||||
let stats = null;
|
||||
|
||||
const camera = sceneTree.find(['Main Camera', '<object>']).object;
|
||||
|
||||
const getViewportWidth = () => {
|
||||
const width = myRef.current.clientWidth;
|
||||
return width - (width % 2);
|
||||
@@ -49,8 +103,8 @@ export default function ViewerWindow(props) {
|
||||
const handleResize = () => {
|
||||
viewportWidth = getViewportWidth();
|
||||
viewportHeight = getViewportHeight();
|
||||
camera.current.aspect = viewportWidth / viewportHeight;
|
||||
camera.current.updateProjectionMatrix();
|
||||
camera.aspect = viewportWidth / viewportHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(viewportWidth, viewportHeight);
|
||||
};
|
||||
|
||||
@@ -62,7 +116,7 @@ export default function ViewerWindow(props) {
|
||||
const data = {
|
||||
type: cmd,
|
||||
path,
|
||||
data: camera.current.toJSON(),
|
||||
data: camera.toJSON(),
|
||||
};
|
||||
const message = msgpack.encode(data);
|
||||
websocket.send(message);
|
||||
@@ -71,7 +125,7 @@ export default function ViewerWindow(props) {
|
||||
|
||||
// keep sending the camera often
|
||||
useEffect(() => {
|
||||
const fps = 60;
|
||||
const fps = 24;
|
||||
const interval = 1000 / fps;
|
||||
const refreshIntervalId = setInterval(sendCamera, interval);
|
||||
return () => {
|
||||
@@ -82,10 +136,10 @@ export default function ViewerWindow(props) {
|
||||
const update = () => {
|
||||
requestAnimationFrame(update);
|
||||
handleResize();
|
||||
camera.current.fov = field_of_view_ref.current;
|
||||
camera.current.updateProjectionMatrix();
|
||||
camera.fov = field_of_view_ref.current;
|
||||
camera.updateProjectionMatrix();
|
||||
cameraControls.update();
|
||||
renderer.render(scene, camera.current);
|
||||
renderer.render(scene, camera);
|
||||
stats.update();
|
||||
};
|
||||
|
||||
@@ -97,16 +151,16 @@ export default function ViewerWindow(props) {
|
||||
stats = createStats();
|
||||
myRef.current.append(stats.domElement);
|
||||
|
||||
camera.current = new THREE.PerspectiveCamera(
|
||||
field_of_view_ref.current,
|
||||
viewportWidth / viewportHeight,
|
||||
0.01,
|
||||
100,
|
||||
);
|
||||
camera.current.position.x = 5;
|
||||
camera.current.position.y = -5;
|
||||
camera.current.position.z = 5;
|
||||
camera.current.up = new THREE.Vector3(0, 0, 1);
|
||||
// camera = new THREE.PerspectiveCamera(
|
||||
// field_of_view_ref.current,
|
||||
// viewportWidth / viewportHeight,
|
||||
// 0.01,
|
||||
// 100,
|
||||
// );
|
||||
camera.position.x = 5;
|
||||
camera.position.y = -5;
|
||||
camera.position.z = 5;
|
||||
camera.up = new THREE.Vector3(0, 0, 1);
|
||||
|
||||
renderer = new THREE.WebGLRenderer({
|
||||
antialias: true,
|
||||
@@ -117,7 +171,7 @@ export default function ViewerWindow(props) {
|
||||
|
||||
myRef.current.append(renderer.domElement);
|
||||
// add camera controls
|
||||
cameraControls = new OrbitControls(camera.current, renderer.domElement);
|
||||
cameraControls = new OrbitControls(camera, renderer.domElement);
|
||||
cameraControls.rotateSpeed = 2.0;
|
||||
cameraControls.zoomSpeed = 0.3;
|
||||
cameraControls.panSpeed = 0.2;
|
||||
@@ -126,7 +180,16 @@ export default function ViewerWindow(props) {
|
||||
cameraControls.enableDamping = true;
|
||||
cameraControls.dampingFactor = 1.0;
|
||||
cameraControls.update();
|
||||
|
||||
transformsControls = new TransformControls(camera, renderer.domElement);
|
||||
sceneTree.set_object_from_path(['Transform Controls'], transformsControls);
|
||||
|
||||
transformsControls.addEventListener('dragging-changed', (event) => {
|
||||
cameraControls.enabled = !event.value;
|
||||
});
|
||||
|
||||
update();
|
||||
// cameraControls.addEventListener('change', update);
|
||||
}, []);
|
||||
|
||||
// updates the field of view inside the ref to avoid rerendering so often
|
||||
@@ -139,6 +202,9 @@ export default function ViewerWindow(props) {
|
||||
{/* the webrtc viewer needs to know the camera pose */}
|
||||
<WebRtcWindow />
|
||||
<div className="canvas-container-main" ref={myRef} />
|
||||
<div className="ViewerWindow-buttons">
|
||||
<TransformIcons sceneTree={sceneTree} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user