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

#136 - fixes left/right/top/bottom pan - thanks goes to @thejmazz #187

Merged
merged 1 commit into from
Mar 12, 2017

Conversation

hirako2000
Copy link
Collaborator

No description provided.

@hirako2000 hirako2000 requested a review from sasha240100 March 12, 2017 06:20
@sasha240100
Copy link
Member

@hirako2000 @thejmazz So it errored because of scope (arrow function) ?

@sasha240100 sasha240100 merged commit 16c66b9 into beta Mar 12, 2017
Copy link
Member

@sasha240100 sasha240100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

@hirako2000
Copy link
Collaborator Author

looks like incorrect javascript to me. it doesn't error but doesn't execute a function. its invalid code. no idea how it got there. seems like auto generated by some tool.

@sasha240100 sasha240100 deleted the #136 branch March 12, 2017 06:23
@coveralls
Copy link

Coverage Status

Coverage increased ( 0.4%) to 50.088% when pulling f132aa3 on #136 into cb9cfeb on beta.

@sasha240100
Copy link
Member

@hirako2000 That was my rewriting of it to es6 😄

@hirako2000
Copy link
Collaborator Author

should I use this issue to reformat the code as well? it's not following whs code style at all.

@sasha240100
Copy link
Member

@hirako2000 If you have a time - sure

@thejmazz
Copy link
Contributor

@sasha240100

It is not an issue of this scope from arrow functions; the functions were doing this:

const panLeft = () => {
  const v = new Vector3();

  return function panLeft(distance, objectMatrix) {
    v.setFromMatrixColumn(objectMatrix, 0); // get X column of objectMatrix
    v.multiplyScalar(-distance);
    panOffset.add(v);
  };
};

instead of

const panLeft = (() => {
  return (distance, objectMatrix) => {
  
  }
})()

which is an IIFE (immediately invoked function expression) for a function that returns another function.

Its very similar to a decorator, a decorator is basically the same thing but only for classes.

Without decorator:

class MyClass extends Component {
  ...
}

export default myDecorator(...params)(MyClass)

with decorator:

@myDecorator(...params)
export default class MyClass extends Component {
  ...
}

In the case with orbit controls, the "decorator" is an anonymous function and has no params, but uses v from within a closure.

The spec for decorator is still young (stage 2) and might change (or never get accepted). See proposal-decorators.

@sasha240100
Copy link
Member

@thejmazz Thanks for the explanation!

@sasha240100 sasha240100 added this to the v2.0.0-beta.8 milestone Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants