Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,27 @@
</a-entity>
</a-entity>
<a-entity class="windows-motion-tooltips" visible="false">
<a-entity tooltip="text: Trigger to paint!; width: 0.1; height: 0.04; targetPosition: 0 -.3 -.1; lineHorizontalAlign: center; lineVerticalAlign: bottom; src: assets/images/tooltip.png"
position="0 -.1 -.2"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Main menu; width: 0.07; height: 0.03; targetPosition: 0.01 0.0025 -.06; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.1 0.02 -.05"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Brush size\n(up/down); width: 0.11; height: 0.04; targetPosition: 0 -.09 -.1; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.14 0 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Press to undo; width: 0.11; height: 0.03; targetPosition: 0 0 0; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.11 0 0"
rotation="-90 0 0">
</a-entity>
</a-entity>
<a-entity tooltip="text: Trigger to paint!; width: 0.1; height: 0.04; targetPosition: 0 -.3 -.1; lineHorizontalAlign: center; lineVerticalAlign: bottom; src: assets/images/tooltip.png"
position="0 -.1 -.2"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Main menu; width: 0.07; height: 0.03; targetPosition: 0.01 0.0025 -.06; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.1 0.02 -.05"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Brush size\n(up/down); width: 0.07; height: 0.03; targetPosition: 0.01 -.04 -.13; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.1 0.02 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Teleport\n(up); width: 0.11; height: 0.04; targetPosition: 0 -.09 -.1; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.14 0 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Press to undo; width: 0.11; height: 0.03; targetPosition: 0 0 0; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.11 0 0"
rotation="-90 0 0">
</a-entity>
</a-entity>
</a-entity>
<a-entity id="right-hand"
brush
Expand Down Expand Up @@ -152,23 +156,27 @@
</a-entity>
</a-entity>
<a-entity class="windows-motion-tooltips" visible="false">
<a-entity tooltip="text: Trigger to paint!; width: 0.1; height: 0.04; targetPosition: 0 -.3 -.1; lineHorizontalAlign: center; lineVerticalAlign: bottom; src: assets/images/tooltip.png"
position="0 -.1 -.2"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Main menu; width: 0.07; height: 0.03; targetPosition: -.015 0.0025 -.06; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.1 0.02 -.05"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Brush size\n(up/down); width: 0.11; height: 0.04; targetPosition: 0 -.09 -.1; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.14 0 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Press to undo; width: 0.11; height: 0.03; targetPosition: 0 0 0; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.11 0 0"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Trigger to paint!; width: 0.1; height: 0.04; targetPosition: 0 -.3 -.1; lineHorizontalAlign: center; lineVerticalAlign: bottom; src: assets/images/tooltip.png"
position="0 -.1 -.2"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Main menu; width: 0.07; height: 0.03; targetPosition: -.015 0.0025 -.06; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.1 0.02 -.05"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Brush size\n(up/down); width: 0.07; height: 0.03; targetPosition: -.01 -.04 -.13; lineHorizontalAlign: left; src: assets/images/tooltip.png"
position="0.1 0.02 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Teleport\n(up); width: 0.11; height: 0.04; targetPosition: 0 -.09 -.1; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.14 0 -.1"
rotation="-90 0 0">
</a-entity>
<a-entity tooltip="text: Press to undo; width: 0.11; height: 0.03; targetPosition: 0 0 0; lineHorizontalAlign: right; src: assets/images/tooltip.png"
position="-0.11 0 0"
rotation="-90 0 0">
</a-entity>
</a-entity>
</a-entity>
</a-entity>
<a-entity id="sky" geometry="primitive:sphere; radius:30; phiLength:360; phiStart:0; thetaLength:90" material="shader:flat; side:back; height:2048; src:#skymap; width:2048"></a-entity>
Expand Down
35 changes: 25 additions & 10 deletions src/components/paint-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,52 @@ 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);
}

el.addEventListener('controllerconnected', function (evt) {
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'});
Expand Down
Loading