Skip to content

Commit

Permalink
Update: Adjust default camera distance for model3d viewer (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiiBond committed Mar 22, 2017
1 parent 0668a1c commit 307e124
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit 307e124

Please sign in to comment.