Remove locktolocalrotation option

This commit is contained in:
Jess Telford 2016-11-05 15:55:23 +11:00
parent e0e8c23bea
commit f0902cedd1
2 changed files with 29 additions and 38 deletions

View file

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Support click and drag for children of entities and the camera
### Removed
- Removed `lockToLocalRotation` option. It is hard coded to `true` now.
## [1.3.3][] - 2016-11-05
### Fixed

View file

@ -301,7 +301,7 @@ const {selectItem} = (function selectItemFunction() {
};
}());
function dragItem(THREE, element, offset, camera, depth, mouseInfo, lockToLocalRotation) {
function dragItem(THREE, element, offset, camera, depth, mouseInfo) {
const threeCamera = camera.components.camera.camera;
@ -344,7 +344,6 @@ function dragItem(THREE, element, offset, camera, depth, mouseInfo, lockToLocalR
depth
);
if (lockToLocalRotation) {
let rotationDiff;
@ -370,8 +369,6 @@ function dragItem(THREE, element, offset, camera, depth, mouseInfo, lockToLocalR
nextRotation.y = THREE.Math.radToDeg(rotationEuler.y);
nextRotation.z = THREE.Math.radToDeg(rotationEuler.z);
}
const nextPosition = {x: x - offsetVector.x, y: y - offsetVector.y, z: z - offsetVector.z};
// When the element has parents, we need to convert its new world position
@ -393,10 +390,8 @@ function dragItem(THREE, element, offset, camera, depth, mouseInfo, lockToLocalR
element.setAttribute('position', nextPosition);
if (lockToLocalRotation) {
element.setAttribute('rotation', nextRotation);
}
}
function onTouchMove({changedTouches: [touchInfo]}) {
onMouseMove(touchInfo);
@ -430,7 +425,7 @@ const {didMount, didUnmount} = (function getDidMountAndUnmount() {
let removeDragListeners;
const cache = [];
function initialize(THREE, componentName, lockToLocalRotation) {
function initialize(THREE, componentName) {
// TODO: Based on a scene from the element passed in?
const scene = document.querySelector('a-scene');
@ -473,8 +468,7 @@ const {didMount, didUnmount} = (function getDidMountAndUnmount() {
{
clientX,
clientY,
},
lockToLocalRotation
}
);
draggedElement = element;
@ -603,10 +597,10 @@ const {didMount, didUnmount} = (function getDidMountAndUnmount() {
}
return {
didMount(element, THREE, componentName, lockToLocalRotation) {
didMount(element, THREE, componentName) {
if (cache.length === 0) {
initialize(THREE, componentName, lockToLocalRotation);
initialize(THREE, componentName);
}
if (cache.indexOf(element) === -1) {
@ -648,20 +642,13 @@ export default function aframeDraggableComponent(aframe, componentName = COMPONE
* Draggable component for A-Frame.
*/
aframe.registerComponent(componentName, {
schema: {
/*
* @param {bool} [lockToLocalRotation=true] - When dragging the component,
* should it be screen locked (true), or should its rotation be left alone
* (false).
*/
lockToLocalRotation: {default: true},
},
schema: {},
/**
* Called once when component is attached. Generally for initial setup.
*/
init() {
didMount(this, THREE, componentName, this.data.lockToLocalRotation);
didMount(this, THREE, componentName);
},
/**
@ -693,7 +680,7 @@ export default function aframeDraggableComponent(aframe, componentName = COMPONE
* Use to continue or add any dynamic or background behavior such as events.
*/
play() {
didMount(this, THREE, componentName, this.data.lockToLocalRotation);
didMount(this, THREE, componentName);
},
});
}