Skip to content

Commit

Permalink
Chore: Remove autobind from 3d controls (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinHoldstock authored and tonyjin committed Nov 22, 2017
1 parent 4fd7eda commit 5aa3bc8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/lib/viewers/box3d/Box3DControls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EventEmitter from 'events';
import autobind from 'autobind-decorator';
import Controls from '../../Controls';
import { EVENT_RESET, EVENT_SCENE_LOADED, EVENT_TOGGLE_FULLSCREEN, EVENT_TOGGLE_VR } from './box3DConstants';
import { ICON_FULLSCREEN_IN, ICON_FULLSCREEN_OUT, ICON_3D_VR } from '../../icons/icons';
Expand All @@ -8,7 +7,6 @@ import './Box3DControls.scss';
import { CLASS_HIDDEN } from '../../constants';
import { UIRegistry } from './Box3DUIUtils';

@autobind
class Box3DControls extends EventEmitter {
/** @property {HTMLElement} - Reference to the parent container to nest UI in */
el;
Expand Down Expand Up @@ -41,6 +39,10 @@ class Box3DControls extends EventEmitter {
this.controls = new Controls(this.el);

this.uiRegistry = new UIRegistry();

this.handleToggleFullscreen = this.handleToggleFullscreen.bind(this);
this.handleToggleVr = this.handleToggleVr.bind(this);
this.handleReset = this.handleReset.bind(this);
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/lib/viewers/box3d/model3d/Model3DControls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import autobind from 'autobind-decorator';
import Box3DControls from '../Box3DControls';
import Model3DAnimationClipsPullup from './Model3DAnimationClipsPullup';
import Model3DSettingsPullup from './Model3DSettingsPullup';
Expand All @@ -25,7 +24,6 @@ import { ICON_3D_RESET, ICON_ANIMATION, ICON_GEAR, ICON_PAUSE, ICON_PLAY } from
* This class handles the UI for 3d preview controls. This includes Reset,
* Render Mode selection, VR and fullscreen buttons.
*/
@autobind
class Model3DControls extends Box3DControls {
/** @property {Model3DAnimationClipsPullup} - UI Component for listing and interacting with animation clips */
animationClipsPullup;
Expand Down Expand Up @@ -57,8 +55,21 @@ class Model3DControls extends Box3DControls {
*/
constructor(containerEl) {
super(containerEl);

this.animationClipsPullup = new Model3DAnimationClipsPullup(containerEl);
this.settingsPullup = new Model3DSettingsPullup();

this.handleSelectAnimationClip = this.handleSelectAnimationClip.bind(this);
this.handleToggleAnimation = this.handleToggleAnimation.bind(this);
this.handleToggleAnimationClips = this.handleToggleAnimationClips.bind(this);
this.handleToggleSettings = this.handleToggleSettings.bind(this);

this.handleSetRenderMode = this.handleSetRenderMode.bind(this);
this.handleSetSkeletonsVisible = this.handleSetSkeletonsVisible.bind(this);
this.handleSetWireframesVisible = this.handleSetWireframesVisible.bind(this);
this.handleSetGridVisible = this.handleSetGridVisible.bind(this);
this.handleSetCameraProjection = this.handleSetCameraProjection.bind(this);
this.handleAxisRotation = this.handleAxisRotation.bind(this);
}

/** @inheritdoc */
Expand Down
11 changes: 7 additions & 4 deletions src/lib/viewers/box3d/model3d/Model3DVrControls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* global THREE */
import autobind from 'autobind-decorator';

/** The various object manipulation modes supported. */
const controlType = {
Expand Down Expand Up @@ -52,10 +51,15 @@ class Model3DVrControls {
constructor(vrGamepads, box3dEngine) {
this.vrGamepads = vrGamepads;
this.box3d = box3dEngine;

this.onScaleUpdate = this.onScaleUpdate.bind(this);
this.onGamepadButtonDown = this.onGamepadButtonDown.bind(this);
this.onGamepadButtonUp = this.onGamepadButtonUp.bind(this);

// Listen for gamepad button events to trigger actions.
this.vrGamepads.forEach((gamepad) => {
gamepad.listenTo(gamepad, 'gamepadButtonDown', this.onGamepadButtonDown.bind(this));
gamepad.listenTo(gamepad, 'gamepadButtonUp', this.onGamepadButtonUp.bind(this));
gamepad.listenTo(gamepad, 'gamepadButtonDown', this.onGamepadButtonDown);
gamepad.listenTo(gamepad, 'gamepadButtonUp', this.onGamepadButtonUp);
});
this.controllerState = {
initiatingController: null,
Expand Down Expand Up @@ -125,7 +129,6 @@ class Model3DVrControls {
*
* @return {void}
*/
@autobind
onScaleUpdate() {
this.vrGamepads[0].getPosition(this.vrWorkVector1);
this.vrGamepads[1].getPosition(this.vrWorkVector2);
Expand Down

0 comments on commit 5aa3bc8

Please sign in to comment.