Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Camera view updates #32

Merged
merged 4 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions dist/3dstreet-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35981,7 +35981,13 @@ var Events = __webpack_require__(6);
var classNames = __webpack_require__(14);


var options = [{ value: 'perspective', event: 'cameraperspectivetoggle', payload: null, label: 'Perspective' }, { value: 'ortholeft', event: 'cameraorthographictoggle', payload: 'left', label: 'Left View' }, { value: 'orthoright', event: 'cameraorthographictoggle', payload: 'right', label: 'Right View' }, { value: 'orthotop', event: 'cameraorthographictoggle', payload: 'top', label: 'Top View' }, { value: 'orthobottom', event: 'cameraorthographictoggle', payload: 'bottom', label: 'Bottom View' }, { value: 'orthoback', event: 'cameraorthographictoggle', payload: 'back', label: 'Back View' }, { value: 'orthofront', event: 'cameraorthographictoggle', payload: 'front', label: 'Front View' }];
var options = [{ value: 'perspective', event: 'cameraperspectivetoggle', payload: null, label: '3D View' },
// { value: 'ortholeft', event: 'cameraorthographictoggle', payload: 'left', label: 'Left View' },
// { value: 'orthoright', event: 'cameraorthographictoggle', payload: 'right', label: 'Right View' },
{ value: 'orthotop', event: 'cameraorthographictoggle', payload: 'top', label: 'Plan View' },
// { value: 'orthobottom', event: 'cameraorthographictoggle', payload: 'bottom', label: 'Bottom View' },
// { value: 'orthoback', event: 'cameraorthographictoggle', payload: 'back', label: 'Back View' },
{ value: 'orthofront', event: 'cameraorthographictoggle', payload: 'front', label: 'Cross Section' }];

function getOption(value) {
return options.filter(function (opt) {
Expand Down Expand Up @@ -36251,14 +36257,14 @@ function initCameras(inspector) {
var perspectiveCamera = inspector.camera = new THREE.PerspectiveCamera();
perspectiveCamera.far = 10000;
perspectiveCamera.near = 0.01;
perspectiveCamera.position.set(0, 1.6, 2);
perspectiveCamera.position.set(0, 15, 30);
perspectiveCamera.lookAt(new THREE.Vector3(0, 1.6, -1));
perspectiveCamera.updateMatrixWorld();
sceneEl.object3D.add(perspectiveCamera);
sceneEl.camera = perspectiveCamera;

var ratio = sceneEl.canvas.width / sceneEl.canvas.height;
var orthoCamera = new THREE.OrthographicCamera(-10 * ratio, 10 * ratio, 10, -10);
var orthoCamera = new THREE.OrthographicCamera(-40 * ratio, 40 * ratio, 40, -40);
sceneEl.object3D.add(orthoCamera);

var cameras = inspector.cameras = {
Expand Down Expand Up @@ -36306,10 +36312,10 @@ function saveOrthoCamera(camera, dir) {

function setOrthoCamera(camera, dir, ratio) {
var info = orthoCameraMemory[dir];
camera.left = info.left || -10 * ratio;
camera.right = info.right || 10 * ratio;
camera.top = info.top || 10;
camera.bottom = info.bottom || -10;
camera.left = info.left || -40 * ratio;
camera.right = info.right || 40 * ratio;
camera.top = info.top || 40;
camera.bottom = info.bottom || -40;
camera.position.copy(info.position);
camera.rotation.copy(info.rotation);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/3dstreet-editor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3dstreet-editor.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/components/viewport/CameraToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var classNames = require('classnames');
import Select from 'react-select';

const options = [
{ value: 'perspective', event: 'cameraperspectivetoggle', payload: null, label: 'Perspective' },
{ value: 'ortholeft', event: 'cameraorthographictoggle', payload: 'left', label: 'Left View' },
{ value: 'orthoright', event: 'cameraorthographictoggle', payload: 'right', label: 'Right View' },
{ value: 'orthotop', event: 'cameraorthographictoggle', payload: 'top', label: 'Top View' },
{ value: 'orthobottom', event: 'cameraorthographictoggle', payload: 'bottom', label: 'Bottom View' },
{ value: 'orthoback', event: 'cameraorthographictoggle', payload: 'back', label: 'Back View' },
{ value: 'orthofront', event: 'cameraorthographictoggle', payload: 'front', label: 'Front View' },
{ value: 'perspective', event: 'cameraperspectivetoggle', payload: null, label: '3D View' },
// { value: 'ortholeft', event: 'cameraorthographictoggle', payload: 'left', label: 'Left View' },
// { value: 'orthoright', event: 'cameraorthographictoggle', payload: 'right', label: 'Right View' },
{ value: 'orthotop', event: 'cameraorthographictoggle', payload: 'top', label: 'Plan View' },
// { value: 'orthobottom', event: 'cameraorthographictoggle', payload: 'bottom', label: 'Bottom View' },
// { value: 'orthoback', event: 'cameraorthographictoggle', payload: 'back', label: 'Back View' },
{ value: 'orthofront', event: 'cameraorthographictoggle', payload: 'front', label: 'Cross Section' },
];

function getOption (value) {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/cameras.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export function initCameras (inspector) {
const perspectiveCamera = inspector.camera = new THREE.PerspectiveCamera();
perspectiveCamera.far = 10000;
perspectiveCamera.near = 0.01;
perspectiveCamera.position.set(0, 1.6, 2);
perspectiveCamera.position.set(0, 15, 30);
perspectiveCamera.lookAt(new THREE.Vector3(0, 1.6, -1));
perspectiveCamera.updateMatrixWorld();
sceneEl.object3D.add(perspectiveCamera);
sceneEl.camera = perspectiveCamera;

const ratio = sceneEl.canvas.width / sceneEl.canvas.height;
const orthoCamera = new THREE.OrthographicCamera(-10 * ratio, 10 * ratio, 10, -10);
const orthoCamera = new THREE.OrthographicCamera(-40 * ratio, 40 * ratio, 40, -40);
sceneEl.object3D.add(orthoCamera);

const cameras = inspector.cameras = {
Expand Down Expand Up @@ -93,10 +93,10 @@ function saveOrthoCamera (camera, dir) {

function setOrthoCamera (camera, dir, ratio) {
const info = orthoCameraMemory[dir];
camera.left = info.left || (-10 * ratio);
camera.right = info.right || (10 * ratio);
camera.top = info.top || 10;
camera.bottom = info.bottom || -10;
camera.left = info.left || (-40 * ratio);
camera.right = info.right || (40 * ratio);
camera.top = info.top || 40;
camera.bottom = info.bottom || -40;
camera.position.copy(info.position);
camera.rotation.copy(info.rotation);
}
Expand Down