|
@@ -331,7 +331,8 @@ define(["module", "vwf/view"], function (module, view) {
|
|
"remoteUrl": '',
|
|
"remoteUrl": '',
|
|
"displayName": 'Avatar '+ randId(),
|
|
"displayName": 'Avatar '+ randId(),
|
|
"sharing": { audio: true, video: true },
|
|
"sharing": { audio: true, video: true },
|
|
- "selectMode": false
|
|
|
|
|
|
+ "selectMode": false,
|
|
|
|
+ "position": "0 1.6 0"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -436,13 +437,26 @@ define(["module", "vwf/view"], function (module, view) {
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
- function compareCoordinates(a, b) {
|
|
|
|
- return a.x !== b.x || a.y !== b.y || a.z !== b.z
|
|
|
|
|
|
+ function compareCoordinates(a, b, delta) {
|
|
|
|
+ return Math.abs(a.x - b.x) > delta || Math.abs(a.y - b.y) > delta || Math.abs(a.z - b.z) > delta
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function getWorldRotation(el) {
|
|
|
|
+
|
|
|
|
+ let worldQuat = el.object3D.getWorldQuaternion();
|
|
|
|
+ //console.log(worldQuat);
|
|
|
|
+ let angle = (new THREE.Euler()).setFromQuaternion(worldQuat, 'YXZ');
|
|
|
|
+ let rotation = (new THREE.Vector3(THREE.Math.radToDeg(angle.x),
|
|
|
|
+ THREE.Math.radToDeg(angle.y), THREE.Math.radToDeg(angle.z) ));
|
|
|
|
+
|
|
|
|
+ return rotation
|
|
|
|
+ }
|
|
|
|
+
|
|
function updateAvatarPosition() {
|
|
function updateAvatarPosition() {
|
|
|
|
|
|
|
|
+ let delta = 0.0001;
|
|
|
|
+
|
|
let avatarName = 'avatar-' + self.kernel.moniker();
|
|
let avatarName = 'avatar-' + self.kernel.moniker();
|
|
var node = self.state.nodes[avatarName];
|
|
var node = self.state.nodes[avatarName];
|
|
if (!node) return;
|
|
if (!node) return;
|
|
@@ -450,21 +464,26 @@ define(["module", "vwf/view"], function (module, view) {
|
|
|
|
|
|
let el = document.querySelector('#avatarControl');
|
|
let el = document.querySelector('#avatarControl');
|
|
if (el) {
|
|
if (el) {
|
|
- let position = el.getAttribute('position');//el.object3D.getWorldPosition()//
|
|
|
|
- let rotation = el.getAttribute('rotation');
|
|
|
|
|
|
+ let position = el.object3D.getWorldPosition(); //el.getAttribute('position');
|
|
|
|
+ let rotation = getWorldRotation(el);
|
|
|
|
+
|
|
|
|
+ // console.log(rotation);
|
|
|
|
+ //let rotation = el.getAttribute('rotation');
|
|
|
|
|
|
let lastRotation = self.nodes[avatarName].selfTickRotation;
|
|
let lastRotation = self.nodes[avatarName].selfTickRotation;
|
|
|
|
+ let lastPosition = self.nodes[avatarName].selfTickPosition;
|
|
|
|
|
|
- let currentPosition = node.aframeObj.getAttribute('position');
|
|
|
|
- let currentRotation = node.aframeObj.getAttribute('rotation');
|
|
|
|
|
|
+ // let currentPosition = node.aframeObj.getAttribute('position');
|
|
|
|
+ // let currentRotation = node.aframeObj.getAttribute('rotation');
|
|
|
|
|
|
- if (position && rotation && currentPosition && currentRotation && lastRotation) {
|
|
|
|
- if (compareCoordinates(position, currentPosition) || rotation.y !== lastRotation.y) {
|
|
|
|
|
|
+ if (position && rotation && lastPosition && lastRotation) {
|
|
|
|
+ if (compareCoordinates(position, lastPosition, delta) || Math.abs(rotation.y - lastRotation.y) > delta) {
|
|
console.log("not equal!!")
|
|
console.log("not equal!!")
|
|
vwf_view.kernel.callMethod(avatarName, "followAvatarControl", [position, rotation]);
|
|
vwf_view.kernel.callMethod(avatarName, "followAvatarControl", [position, rotation]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- self.nodes[avatarName].selfTickRotation = Object.assign({}, el.getAttribute('rotation'));
|
|
|
|
|
|
+ self.nodes[avatarName].selfTickRotation = Object.assign({}, rotation);
|
|
|
|
+ self.nodes[avatarName].selfTickPosition = Object.assign({}, position);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -472,6 +491,9 @@ define(["module", "vwf/view"], function (module, view) {
|
|
|
|
|
|
function updateHandControllerVR(aName, aSelector) {
|
|
function updateHandControllerVR(aName, aSelector) {
|
|
//let avatarName = 'avatar-' + self.kernel.moniker();
|
|
//let avatarName = 'avatar-' + self.kernel.moniker();
|
|
|
|
+
|
|
|
|
+ let delta = 0.0001
|
|
|
|
+
|
|
let avatarName = aName + self.kernel.moniker();
|
|
let avatarName = aName + self.kernel.moniker();
|
|
var node = self.state.nodes[avatarName];
|
|
var node = self.state.nodes[avatarName];
|
|
if (!node) return;
|
|
if (!node) return;
|
|
@@ -480,7 +502,9 @@ define(["module", "vwf/view"], function (module, view) {
|
|
let el = document.querySelector(aSelector);
|
|
let el = document.querySelector(aSelector);
|
|
if (el) {
|
|
if (el) {
|
|
let position = el.object3D.getWorldPosition() //el.getAttribute('position');
|
|
let position = el.object3D.getWorldPosition() //el.getAttribute('position');
|
|
- let rotation = el.getAttribute('rotation');
|
|
|
|
|
|
+ let rotation = getWorldRotation(el);
|
|
|
|
+
|
|
|
|
+ //let rotation = el.getAttribute('rotation');
|
|
|
|
|
|
let lastRotation = self.nodes[avatarName].selfTickRotation;
|
|
let lastRotation = self.nodes[avatarName].selfTickRotation;
|
|
let lastPosition = self.nodes[avatarName].selfTickPosition;
|
|
let lastPosition = self.nodes[avatarName].selfTickPosition;
|
|
@@ -489,14 +513,17 @@ define(["module", "vwf/view"], function (module, view) {
|
|
//let currentRotation = node.aframeObj.getAttribute('rotation');
|
|
//let currentRotation = node.aframeObj.getAttribute('rotation');
|
|
|
|
|
|
if (position && rotation && lastRotation && lastPosition) {
|
|
if (position && rotation && lastRotation && lastPosition) {
|
|
- if (compareCoordinates(position, lastPosition) || compareCoordinates(rotation, lastRotation)) {
|
|
|
|
|
|
+ if (compareCoordinates(position, lastPosition, delta) || compareCoordinates(rotation, lastRotation, delta)) {
|
|
console.log("not equal!!");
|
|
console.log("not equal!!");
|
|
vwf_view.kernel.callMethod(avatarName, "updateVRControl", [position, rotation]);
|
|
vwf_view.kernel.callMethod(avatarName, "updateVRControl", [position, rotation]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- self.nodes[avatarName].selfTickRotation = Object.assign({}, el.getAttribute('rotation'));
|
|
|
|
- self.nodes[avatarName].selfTickPosition = Object.assign({}, el.getAttribute('position'));
|
|
|
|
|
|
+
|
|
|
|
+ //vwf_view.kernel.callMethod(avatarName, "updateVRControl", [position, rotation]);
|
|
|
|
+
|
|
|
|
+ self.nodes[avatarName].selfTickPosition = Object.assign({}, position);
|
|
|
|
+ self.nodes[avatarName].selfTickRotation = Object.assign({}, rotation);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -508,23 +535,30 @@ define(["module", "vwf/view"], function (module, view) {
|
|
|
|
|
|
let avatarEl = document.createElement('a-entity');
|
|
let avatarEl = document.createElement('a-entity');
|
|
avatarEl.setAttribute('id', 'avatarControlParent');
|
|
avatarEl.setAttribute('id', 'avatarControlParent');
|
|
- avatarEl.setAttribute('position', '0 1.6 0');
|
|
|
|
|
|
+
|
|
|
|
|
|
if (AFRAME.utils.device.isGearVR()) {
|
|
if (AFRAME.utils.device.isGearVR()) {
|
|
- avatarEl.setAttribute('position', '0 0 0');
|
|
|
|
|
|
+ avatarEl.setAttribute('movement-controls', {});//{'controls': 'gamepad'});
|
|
|
|
+ //avatarEl.setAttribute('position', '0 0 0');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
let controlEl = document.createElement('a-camera');
|
|
let controlEl = document.createElement('a-camera');
|
|
|
|
|
|
controlEl.setAttribute('id', 'avatarControl');
|
|
controlEl.setAttribute('id', 'avatarControl');
|
|
- controlEl.setAttribute('wasd-controls', {});
|
|
|
|
|
|
+ //controlEl.setAttribute('wasd-controls', {});
|
|
controlEl.setAttribute('look-controls', {pointerLockEnabled: false});
|
|
controlEl.setAttribute('look-controls', {pointerLockEnabled: false});
|
|
- controlEl.setAttribute('gamepad-controls', {'controller': 0});
|
|
|
|
|
|
+ //controlEl.setAttribute('gamepad-controls', {'controller': 0});
|
|
|
|
|
|
|
|
+
|
|
//controlEl.setAttribute('gearvr-controls',{});
|
|
//controlEl.setAttribute('gearvr-controls',{});
|
|
- controlEl.setAttribute('camera', 'active', true);
|
|
|
|
|
|
+
|
|
// controlEl.setAttribute('camera', 'near', 0.51);
|
|
// controlEl.setAttribute('camera', 'near', 0.51);
|
|
|
|
|
|
|
|
+
|
|
|
|
+ //controlEl.setAttribute('position', '0 0 0');
|
|
|
|
+ controlEl.setAttribute('camera', 'active', true);
|
|
|
|
+
|
|
let cursorEl = document.createElement('a-cursor');
|
|
let cursorEl = document.createElement('a-cursor');
|
|
cursorEl.setAttribute('id', 'cursor-' + avatarName);
|
|
cursorEl.setAttribute('id', 'cursor-' + avatarName);
|
|
cursorEl.setAttribute('raycaster', {});
|
|
cursorEl.setAttribute('raycaster', {});
|
|
@@ -625,26 +659,32 @@ define(["module", "vwf/view"], function (module, view) {
|
|
|
|
|
|
let sceneEl = document.querySelector('a-scene');
|
|
let sceneEl = document.querySelector('a-scene');
|
|
|
|
|
|
- //let avatarControl = document.querySelector('#avatarControlParent');
|
|
|
|
|
|
+ let avatarControl = document.querySelector('#avatarControlParent');
|
|
|
|
|
|
let gearvr = document.createElement('a-entity');
|
|
let gearvr = document.createElement('a-entity');
|
|
gearvr.setAttribute('id', 'gearvrcontrol');
|
|
gearvr.setAttribute('id', 'gearvrcontrol');
|
|
- gearvr.setAttribute('gearvr-controls', '');
|
|
|
|
- gearvr.setAttribute('gearvr-controls', 'hand', 'right');
|
|
|
|
- gearvr.setAttribute('gearvrcontrol', '');
|
|
|
|
- sceneEl.appendChild(gearvr);
|
|
|
|
|
|
+ gearvr.setAttribute('gearvr-controls', {
|
|
|
|
+ 'hand': 'right',
|
|
|
|
+ 'model': true });
|
|
|
|
+ // gearvr.setAttribute('gearvr-controls', 'hand', 'right');
|
|
|
|
+
|
|
|
|
+ gearvr.setAttribute('gearvrcontrol', {});
|
|
|
|
+ avatarControl.appendChild(gearvr);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function createWMRVRControls(hand) {
|
|
function createWMRVRControls(hand) {
|
|
|
|
|
|
let sceneEl = document.querySelector('a-scene');
|
|
let sceneEl = document.querySelector('a-scene');
|
|
|
|
+
|
|
|
|
+ let avatarControl = document.querySelector('#avatarControlParent');
|
|
|
|
+
|
|
let wmrvr = document.createElement('a-entity');
|
|
let wmrvr = document.createElement('a-entity');
|
|
wmrvr.setAttribute('id', 'wmrvrcontrol' + hand);
|
|
wmrvr.setAttribute('id', 'wmrvrcontrol' + hand);
|
|
wmrvr.setAttribute('windows-motion-controls', '');
|
|
wmrvr.setAttribute('windows-motion-controls', '');
|
|
wmrvr.setAttribute('windows-motion-controls', 'hand', hand);
|
|
wmrvr.setAttribute('windows-motion-controls', 'hand', hand);
|
|
wmrvr.setAttribute('wmrvrcontrol', {'hand': hand});
|
|
wmrvr.setAttribute('wmrvrcontrol', {'hand': hand});
|
|
- sceneEl.appendChild(wmrvr);
|
|
|
|
|
|
+ avatarControl.appendChild(wmrvr);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|