Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Adjust default camera distance for model3d viewer #5

Merged
merged 1 commit into from
Mar 22, 2017
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
4 changes: 2 additions & 2 deletions src/lib/viewers/box3d/Box3dAssets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const STATIC_URI = 'third-party/model3d/';
const BOX3D = [
`${STATIC_URI}boxsdk.js`,
`${STATIC_URI}boxsdk.min.js`,
`${STATIC_URI}three.min.js`,
`${STATIC_URI}box3d-runtime.js`,
`${STATIC_URI}box3d-runtime.min.js`,
`${STATIC_URI}webvr-polyfill.js`,
`${STATIC_URI}WebVR/VRConfig.js`
];
Expand Down
4 changes: 3 additions & 1 deletion src/lib/viewers/box3d/model3d/Model3dRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ORIGIN_VECTOR = { x: 0, y: 0, z: 0 };
const FLOOR_VECTOR = { x: 0, y: -1, z: 0 };
const IDENTITY_QUATERNION = { x: 0, y: 0, z: 0, w: 1 };

const PREVIEW_CAMERA_ORBIT_DISTANCE_FACTOR = 1.5;
const PREVIEW_CAMERA_POSITION = {
x: -0.559,
y: 0.197,
Expand Down Expand Up @@ -311,7 +312,8 @@ class Model3dRenderer extends Box3DRenderer {
// Set the origin point (so that we always point at the center of the model when the camera reloads)
orbitController.originPoint.copy(center);
orbitController.setPivotPosition(center);
orbitController.setOrbitDistance(Math.max(Math.max(maxDimension.x, maxDimension.y), maxDimension.z));
const distance = PREVIEW_CAMERA_ORBIT_DISTANCE_FACTOR * Math.max(Math.max(maxDimension.x, maxDimension.y), maxDimension.z);
orbitController.setOrbitDistance(distance);
}

/** @inheritdoc */
Expand Down