Skip to content

Commit

Permalink
refactor duplicated checks for user camera
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Schmithüsen committed Jan 16, 2019
1 parent b11c7d9 commit 61946f7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,28 @@ class gltfViewer
const self = this;
input.onRotate = (deltaX, deltaY) =>
{
if (self.renderingParameters.cameraIndex === "orbit camera")
if (this.userCameraActive())
{
this.userCamera.rotate(deltaX, deltaY);
}
};
input.onPan = (deltaX, deltaY) =>
{
if (self.renderingParameters.cameraIndex === "orbit camera")
if (this.userCameraActive())
{
this.userCamera.pan(deltaX, deltaY);
}
};
input.onZoom = (delta) =>
{
if (self.renderingParameters.cameraIndex === "orbit camera")
if (this.userCameraActive())
{
this.userCamera.zoomIn(delta);
}
};
input.onResetCamera = () =>
{
if (self.renderingParameters.cameraIndex === "orbit camera")
if (this.userCameraActive())
{
self.userCamera.reset(self.gltf, self.renderingParameters.sceneIndex);
}
Expand Down Expand Up @@ -309,7 +309,7 @@ class gltfViewer
scene.applyTransformHierarchy(gltf);

const transform = mat4.create();
if (this.renderingParameters.cameraIndex === "orbit camera")
if (this.userCameraActive())
{
const scaleFactor = getScaleFactor(gltf, this.renderingParameters.sceneIndex);
mat4.scale(transform, transform, vec3.fromValues(scaleFactor, scaleFactor, scaleFactor));
Expand Down Expand Up @@ -371,6 +371,11 @@ class gltfViewer
spinner.style.display = "none";
}
}

userCameraActive()
{
return this.userCameraActive();
}
}

export { gltfViewer };

0 comments on commit 61946f7

Please sign in to comment.