diff --git a/index.html b/index.html
index 43457e967..711e10a53 100644
--- a/index.html
+++ b/index.html
@@ -92,23 +92,27 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/paint-controls.js b/src/components/paint-controls.js
index 57429d9da..ffcf506bf 100644
--- a/src/components/paint-controls.js
+++ b/src/components/paint-controls.js
@@ -15,19 +15,20 @@ AFRAME.registerComponent('paint-controls', {
var self = this;
var highLightTextureUrl = 'assets/images/controller-pressed.png';
var tooltips = null;
+ const TRACKPAD_DOWN_POSITION = 1;
+ const TRACKPAD_UP_POSITION = -1;
+ const EPSILON = 0.3;
this.controller = null;
this.modelLoaded = false;
-
+ this.trackpadDown = false;
this.onModelLoaded = this.onModelLoaded.bind(this);
el.addEventListener('model-loaded', this.onModelLoaded);
var onAxisMove = function(evt) {
if (evt.detail.axis[0] === 0 && evt.detail.axis[1] === 0 || self.previousAxis === evt.detail.axis[1]) { return; }
-
var delta = evt.detail.axis[1] / 300;
var size = el.components.brush.schema.size;
var value = THREE.Math.clamp(self.el.getAttribute('brush').size - delta, size.min, size.max);
-
self.el.setAttribute('brush', 'size', value);
}
@@ -35,17 +36,31 @@ AFRAME.registerComponent('paint-controls', {
var controllerName = evt.detail.name;
tooltips = Utils.getTooltips(controllerName);
if (controllerName === 'windows-motion-controls') {
- el.setAttribute('teleport-controls', {button: 'trackpad'});
- el.addEventListener('axismove', function (evt) {
- onAxisMove(evt);
+ el.setAttribute('teleport-controls', {button: 'auto', axis: 'auto'});
+ el.addEventListener('trackpaddown', function (evt) {
+ self.trackpadDown = true;
});
- el.addEventListener('trackpadtouchstart', function () {
- self.touchStarted = true;
+ el.addEventListener('axismove', function (evt) {
+ var isUpDirection = undefined;
+ if (self.trackpadDown) {
+ if (Math.abs(evt.detail.axis[3] - TRACKPAD_DOWN_POSITION) < EPSILON) {
+ isUpDirection = false;
+ }
+ else if(Math.abs(evt.detail.axis[3] - TRACKPAD_UP_POSITION) < EPSILON) {
+ isUpDirection = true;
+ }
+
+ if (isUpDirection !== undefined) {
+ self.trackpadDown = false;
+ var delta = isUpDirection ? 0.01 : -0.01;
+ var size = el.components.brush.schema.size;
+ var value = THREE.Math.clamp(self.el.getAttribute('brush').size + delta, size.min, size.max);
+ self.el.setAttribute('brush', 'size', value);
+ }
+ }
});
- self.touchStarted = false;
-
} else if (controllerName === 'oculus-touch-controls') {
var hand = evt.detail.component.data.hand;
el.setAttribute('teleport-controls', {button: hand === 'left' ? 'ybutton' : 'bbutton'});
diff --git a/vendor/aframe-teleport-controls.min.js b/vendor/aframe-teleport-controls.min.js
index fa562d1cf..3d2611526 100644
--- a/vendor/aframe-teleport-controls.min.js
+++ b/vendor/aframe-teleport-controls.min.js
@@ -1 +1 @@
-!function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){function n(t){var e="line"===t.type?2:t.curveNumberPoints;return new l(e,t.curveLineWidth)}function r(t){var e,i,n;return i=document.createElement("a-entity"),i.className="hitEntity",n=document.createElement("a-entity"),n.setAttribute("geometry",{primitive:"torus",radius:t.hitCylinderRadius,radiusTubular:.01}),n.setAttribute("rotation",{x:90,y:0,z:0}),n.setAttribute("material",{shader:"flat",color:t.hitCylinderColor,side:"double",depthTest:!1}),i.appendChild(n),e=document.createElement("a-entity"),e.setAttribute("position",{x:0,y:t.hitCylinderHeight/2,z:0}),e.setAttribute("geometry",{primitive:"cylinder",segmentsHeight:1,radius:t.hitCylinderRadius,height:t.hitCylinderHeight,openEnded:!0}),e.setAttribute("material",{shader:"flat",color:t.hitCylinderColor,side:"double",src:s,transparent:!0,depthTest:!1}),i.appendChild(e),i}function o(t){var e,i;return e=new THREE.BoxBufferGeometry(t,.5,t),e.applyMatrix((new THREE.Matrix4).makeTranslation(0,-.25,0)),i=new THREE.MeshBasicMaterial({color:16776960}),new THREE.Mesh(e,i)}var s=i(3),a=i(1),l=i(2);if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),i=e.length;--i>=0&&e.item(i)!==this;);return i>-1}),AFRAME.registerComponent("teleport-controls",{schema:{type:{default:"parabolic",oneOf:["parabolic","line"]},button:{default:"trackpad",oneOf:["trackpad","trigger","grip","menu"]},collisionEntities:{default:""},hitEntity:{type:"selector"},cameraRig:{type:"selector"},hitCylinderColor:{type:"color",default:"#99ff99"},hitCylinderRadius:{default:.25,min:0},hitCylinderHeight:{default:.3,min:0},maxLength:{default:10,min:0,if:{type:["line"]}},curveNumberPoints:{default:30,min:2,if:{type:["parabolic"]}},curveLineWidth:{default:.025},curveHitColor:{type:"color",default:"#99ff99"},curveMissColor:{type:"color",default:"#ff0000"},curveShootingSpeed:{default:5,min:0,if:{type:["parabolic"]}},defaultPlaneSize:{default:100},landingNormal:{type:"vec3",default:"0 1 0"},landingMaxAngle:{default:"45",min:0,max:360}},init:function(){var t,e=this.data,i=this.el;this.active=!1,this.obj=i.object3D,this.hitPoint=new THREE.Vector3,this.hit=!1,this.prevHeightDiff=0,this.referenceNormal=new THREE.Vector3,this.curveMissColor=new THREE.Color,this.curveHitColor=new THREE.Color,this.raycaster=new THREE.Raycaster,this.defaultPlane=o(this.data.defaultPlaneSize),t=this.teleportEntity=document.createElement("a-entity"),t.classList.add("teleportRay"),t.setAttribute("visible",!1),i.sceneEl.appendChild(this.teleportEntity),i.addEventListener(e.button+"down",this.onButtonDown.bind(this)),i.addEventListener(e.button+"up",this.onButtonUp.bind(this)),this.queryCollisionEntities()},update:function(t){var e=this.data,i=AFRAME.utils.diff(e,t);this.referenceNormal.copy(e.landingNormal),this.curveMissColor.set(e.curveMissColor),this.curveHitColor.set(e.curveHitColor),(!this.line||"curveLineWidth"in i||"curveNumberPoints"in i||"type"in i)&&(this.line=n(e),this.teleportEntity.setObject3D("mesh",this.line.mesh)),e.hitEntity?this.hitEntity=e.hitEntity:(!this.hitEntity||"hitCylinderColor"in i||"hitCylinderHeight"in i||"hitCylinderRadius"in i)&&(this.hitEntity&&this.hitEntity.parentNode.removeChild(this.hitEntity),this.hitEntity=r(e),this.el.sceneEl.appendChild(this.hitEntity)),this.hitEntity.setAttribute("visible",!1),"collisionEntities"in i&&this.queryCollisionEntities()},remove:function(){var t=this.el,e=this.hitEntity,i=this.teleportEntity;e&&e.parentNode.removeChild(e),i&&i.parentNode.removeChild(i),t.sceneEl.removeEventListener("child-attached",this.childAttachHandler),t.sceneEl.removeEventListener("child-detached",this.childDetachHandler)},tick:function(){var t=new THREE.Vector3,e=new THREE.Quaternion,i=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3;return function(s,l){if(this.active){var h=this.obj.matrixWorld;h.decompose(i,e,n);var c=r.set(0,0,-1).applyQuaternion(e).normalize();this.line.setDirection(c.clone()),t.copy(this.obj.getWorldPosition());var d,u=t.clone();if(this.teleportEntity.setAttribute("visible",!0),this.line.material.color.set(this.curveMissColor),this.hitEntity.setAttribute("visible",!1),this.hit=!1,"parabolic"===this.data.type)for(var A=c.clone().multiplyScalar(this.data.curveShootingSpeed),E=-9.8,p=new THREE.Vector3(0,E,0),y=0;y0&&!this.hit&&this.isValidNormalsAngle(i[0].face.normal)){var r=i[0].point;this.line.material.color.set(this.curveHitColor),this.hitEntity.setAttribute("position",r),this.hitEntity.setAttribute("visible",!0),this.hit=!0,this.hitPoint.copy(i[0].point);for(var o=t;o=0&&e.item(i)!==this;);return i>-1}),AFRAME.registerComponent("teleport-controls",{schema:{type:{default:"parabolic",oneOf:["parabolic","line"]},axis:{default:"auto",oneOf:["left","right","up","down","auto","none"]},button:{default:"auto",oneOf:["trackpad","trigger","grip","menu","thumbstick","auto"]},collisionEntities:{default:""},hitEntity:{type:"selector"},cameraRig:{type:"selector"},hitCylinderColor:{type:"color",default:"#99ff99"},hitCylinderRadius:{default:.25,min:0},hitCylinderHeight:{default:.3,min:0},maxLength:{default:10,min:0,if:{type:["line"]}},curveNumberPoints:{default:30,min:2,if:{type:["parabolic"]}},curveLineWidth:{default:.025},curveHitColor:{type:"color",default:"#99ff99"},curveMissColor:{type:"color",default:"#ff0000"},curveShootingSpeed:{default:5,min:0,if:{type:["parabolic"]}},defaultPlaneSize:{default:100},landingNormal:{type:"vec3",default:"0 1 0"},landingMaxAngle:{default:"45",min:0,max:360}},init:function(){var t,e=this.el,i=this;this.active=!1,this.axisIndex=1,this.obj=e.object3D,this.hitPoint=new THREE.Vector3,this.hit=!1,this.prevHeightDiff=0,this.referenceNormal=new THREE.Vector3,this.curveMissColor=new THREE.Color,this.curveHitColor=new THREE.Color,this.raycaster=new THREE.Raycaster,this.controllerName=void 0,this.defaultPlane=s(this.data.defaultPlaneSize),t=this.teleportEntity=document.createElement("a-entity"),t.classList.add("teleportRay"),t.setAttribute("visible",!1),e.sceneEl.appendChild(this.teleportEntity),this.buttonDownHandler=this.onButtonDown.bind(this),this.buttonUpHandler=this.onButtonUp.bind(this),this.axisMoveHandler=this.onAxisMoved.bind(this),e.addEventListener("controllerconnected",function(t){i.controllerName=t.detail.name,i.updateAutoValues(i)}),this.queryCollisionEntities()},updateAutoValues:function(t,e){var i=e?e.button:t.button,n=e?e.axis:t.axis;"auto"===t.button&&(t.controllerName&&"windows-motion-controls"===t.controllerName?t.button="thumbstick":t.button="trackpad"),"auto"===t.axis&&(t.controllerName&&"windows-motion-controls"===t.controllerName?t.axis="up":t.axis="none"),"none"!==t.axis&&"trackpad"!==t.button&&"thumbstick"!==t.button&&(t.axis="none"),t.updateButtonHandlers(t,i,t.button),t.updateAxisHandler(t,n,t.axis),t.updateAxisIndex(t)},updateAxisHandler:function(t,e,i){e!==i&&("none"===i?t.el.removeEventListener("axismove",t.axisMoveHandler):t.el.addEventListener("axismove",t.axisMoveHandler))},updateButtonHandlers:function(t,e,i){e!=i&&(t.el.removeEventListener(e+"down",t.buttonDownHandler),t.el.removeEventListener(e+"up",t.buttonUpHandler),t.el.addEventListener(i+"down",t.buttonDownHandler),t.el.addEventListener(i+"up",t.buttonUpHandler))},updateAxisIndex:function(t){if("none"!==t.axis){var e=.4;t.axisDeadzone=e,"left"===t.axis&&(t.axisDeadzone=-e);var i={thumbstick:{left:0,right:0,up:1,down:1},trackpad:{left:2,right:2,up:3,down:3}},n={trackpad:{left:0,right:0,up:1,down:1}},o={thumbstick:{left:0,right:0,up:1,down:1}};"windows-motion-controls"===t.controllerName?("up"===t.axis&&(t.axisDeadzone=-e),foundButton=i[t.button]):"vive-controls"===t.controllerName?("down"===t.axis&&(t.axisDeadzone=-e),foundButton=n[t.button]):"oculus-touch-controls"===t.controllerName&&("up"===t.axis&&(t.axisDeadzone=-e),foundButton=o[t.button]),foundButton&&(t.axisIndex=foundButton[t.axis]),foundButton&&t.axis||console.log("Error finding "+t.button+" or "+t.axis+" in "+t.controllerName)}},update:function(t){var e=this.data,i=AFRAME.utils.diff(e,t);(!this.axis||!this.button||"axis"in i||"button"in i)&&(this.axis=e.axis,this.button=e.button,this.updateAutoValues(this,t)),this.referenceNormal.copy(e.landingNormal),this.curveMissColor.set(e.curveMissColor),this.curveHitColor.set(e.curveHitColor),(!this.line||"curveLineWidth"in i||"curveNumberPoints"in i||"type"in i)&&(this.line=n(e),this.teleportEntity.setObject3D("mesh",this.line.mesh)),e.hitEntity?this.hitEntity=e.hitEntity:(!this.hitEntity||"hitCylinderColor"in i||"hitCylinderHeight"in i||"hitCylinderRadius"in i)&&(this.hitEntity&&this.hitEntity.parentNode.removeChild(this.hitEntity),this.hitEntity=o(e),this.el.sceneEl.appendChild(this.hitEntity)),this.hitEntity.setAttribute("visible",!1),"collisionEntities"in i&&this.queryCollisionEntities()},remove:function(){var t=this.el,e=this.hitEntity,i=this.teleportEntity;e&&e.parentNode.removeChild(e),i&&i.parentNode.removeChild(i),t.sceneEl.removeEventListener("child-attached",this.childAttachHandler),t.sceneEl.removeEventListener("child-detached",this.childDetachHandler)},tick:function(){var t=new THREE.Vector3,e=new THREE.Quaternion,i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3,s=new THREE.Vector3;return function(r,l){if(this.active){var h=this.obj.matrixWorld;h.decompose(i,e,n);var c=o.set(0,0,-1).applyQuaternion(e).normalize();this.line.setDirection(c.clone()),t.copy(this.obj.getWorldPosition());var u,d=t.clone();if(this.teleportEntity.setAttribute("visible",!0),this.line.material.color.set(this.curveMissColor),this.hitEntity.setAttribute("visible",!1),this.hit=!1,"parabolic"===this.data.type)for(var A=c.clone().multiplyScalar(this.data.curveShootingSpeed),p=-9.8,E=new THREE.Vector3(0,p,0),m=0;m0,n=Math.abs(e)>=Math.abs(this.axisDeadzone)&&i;!this.active&&n?this.active=!0:this.active&&!n&&(this.active=!1,this.onTeleport())}},onButtonDown:function(){"none"===this.axis&&(this.active=!0)},onButtonUp:function(t){this.active&&(this.active=!1,this.onTeleport())},checkMeshCollisions:function(t,e){var i,n;if(n=this.collisionEntities.map(function(t){return t.getObject3D("mesh")}).filter(function(t){return t}),n=n.length?n:[this.defaultPlane],i=this.raycaster.intersectObjects(n,!0),i.length>0&&!this.hit&&this.isValidNormalsAngle(i[0].face.normal)){var o=i[0].point;this.line.material.color.set(this.curveHitColor),this.hitEntity.setAttribute("position",o),this.hitEntity.setAttribute("visible",!0),this.hit=!0,this.hitPoint.copy(i[0].point);for(var s=t;s