Przeglądaj źródła

update aframe extras

Nikolay Suslov 6 lat temu
rodzic
commit
38dd0032c4

Plik diff jest za duży
+ 392 - 16514
support/client/lib/vwf/model/aframe/addon/aframe-extras.controls.js


Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/addon/aframe-extras.controls.min.js


Plik diff jest za duży
+ 630 - 536
support/client/lib/vwf/model/aframe/addon/aframe-extras.loaders.js


Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/addon/aframe-extras.loaders.min.js


+ 39 - 10
support/client/lib/vwf/model/aframe/aframe-master.js

@@ -65372,7 +65372,8 @@ module.exports.Component = registerComponent('light', {
     shadowCameraLeft: {default: -5, if: {castShadow: true}},
     shadowCameraVisible: {default: false, if: {castShadow: true}},
     shadowMapHeight: {default: 512, if: {castShadow: true}},
-    shadowMapWidth: {default: 512, if: {castShadow: true}}
+    shadowMapWidth: {default: 512, if: {castShadow: true}},
+    shadowRadius: {default: 1, if: {castShadow: true}}
   },
 
   /**
@@ -65446,6 +65447,7 @@ module.exports.Component = registerComponent('light', {
           case 'shadowCameraVisible':
           case 'shadowMapHeight':
           case 'shadowMapWidth':
+          case 'shadowRadius':
             if (!shadowsLoaded) {
               self.updateShadow();
               shadowsLoaded = true;
@@ -65512,6 +65514,7 @@ module.exports.Component = registerComponent('light', {
 
     // Shadow appearance.
     light.shadow.bias = data.shadowBias;
+    light.shadow.radius = data.shadowRadius;
     light.shadow.mapSize.height = data.shadowMapHeight;
     light.shadow.mapSize.width = data.shadowMapWidth;
 
@@ -76370,7 +76373,7 @@ _dereq_('./core/a-mixin');
 _dereq_('./extras/components/');
 _dereq_('./extras/primitives/');
 
-console.log('A-Frame Version: 0.8.2 (Date 2018-05-07, Commit #050cbaf)');
+console.log('A-Frame Version: 0.8.2 (Date 2018-05-10, Commit #e4e40b0)');
 console.log('three Version:', pkg.dependencies['three']);
 console.log('WebVR Polyfill Version:', pkg.dependencies['webvr-polyfill']);
 
@@ -76979,7 +76982,6 @@ var css = ".a-html{bottom:0;left:0;position:fixed;right:0;top:0}.a-body{height:1
 },{"browserify-css":5}],159:[function(_dereq_,module,exports){
 var css = ".rs-base{background-color:#333;color:#fafafa;border-radius:0;font:10px monospace;left:5px;line-height:1em;opacity:.85;overflow:hidden;padding:10px;position:fixed;top:5px;width:300px;z-index:10000}.rs-base div.hidden{display:none}.rs-base h1{color:#fff;cursor:pointer;font-size:1.4em;font-weight:300;margin:0 0 5px;padding:0}.rs-group{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-direction:column-reverse;flex-direction:column-reverse;margin-bottom:5px}.rs-group:last-child{margin-bottom:0}.rs-counter-base{align-items:center;display:-webkit-box;display:-webkit-flex;display:flex;height:10px;-webkit-justify-content:space-between;justify-content:space-between;margin:2px 0}.rs-counter-base.alarm{color:#b70000;text-shadow:0 0 0 #b70000,0 0 1px #fff,0 0 1px #fff,0 0 2px #fff,0 0 2px #fff,0 0 3px #fff,0 0 3px #fff,0 0 4px #fff,0 0 4px #fff}.rs-counter-id{font-weight:300;-webkit-box-ordinal-group:0;-webkit-order:0;order:0;width:54px}.rs-counter-value{font-weight:300;-webkit-box-ordinal-group:1;-webkit-order:1;order:1;text-align:right;width:35px}.rs-canvas{-webkit-box-ordinal-group:2;-webkit-order:2;order:2}@media (min-width:480px){.rs-base{left:20px;top:20px}}"; (_dereq_("browserify-css").createStyle(css, { "href": "src/style/rStats.css"})); module.exports = css;
 },{"browserify-css":5}],160:[function(_dereq_,module,exports){
-var bind = _dereq_('../utils/bind');
 var constants = _dereq_('../constants/');
 var registerSystem = _dereq_('../core/system').registerSystem;
 
@@ -76993,10 +76995,18 @@ var DEFAULT_CAMERA_ATTR = 'data-aframe-default-camera';
 module.exports.System = registerSystem('camera', {
   init: function () {
     this.activeCameraEl = null;
+    this.bindMethods();
     // Wait for all entities to fully load before checking for existence of camera.
     // Since entities wait for <a-assets> to load, any cameras attaching to the scene
     // will do so asynchronously.
-    this.sceneEl.addEventListener('loaded', bind(this.setupDefaultCamera, this));
+    this.sceneEl.addEventListener('loaded', this.setupDefaultCamera);
+  },
+
+  bindMethods: function () {
+    this.setupDefaultCamera = this.setupDefaultCamera.bind(this);
+    this.wrapRender = this.wrapRender.bind(this);
+    this.unwrapRender = this.unwrapRender.bind(this);
+    this.render = this.render.bind(this);
   },
 
   /**
@@ -77026,8 +77036,6 @@ module.exports.System = registerSystem('camera', {
       z: 0
     });
     sceneEl.appendChild(defaultCameraEl);
-    sceneEl.addEventListener('enter-vr', this.removeDefaultOffset);
-    sceneEl.addEventListener('exit-vr', this.addDefaultOffset);
     sceneEl.emit('camera-ready', {cameraEl: defaultCameraEl});
   },
 
@@ -77112,6 +77120,10 @@ module.exports.System = registerSystem('camera', {
     }
 
     spectatorCameraEl = this.spectatorCameraEl = newCameraEl;
+
+    sceneEl.addEventListener('enter-vr', this.wrapRender);
+    sceneEl.addEventListener('exit-vr', this.unwrapRender);
+
     spectatorCameraEl.setAttribute('camera', 'active', false);
     spectatorCameraEl.play();
 
@@ -77125,14 +77137,31 @@ module.exports.System = registerSystem('camera', {
     this.spectatorCameraEl = undefined;
   },
 
-  tock: function () {
+  /**
+   * Wrap the render method of the renderer to render
+   * the spectator camera after vrDisplay.submitFrame.
+   */
+  wrapRender: function () {
+    if (!this.spectatorCameraEl) { return; }
+    this.originalRender = this.sceneEl.renderer.render;
+    this.sceneEl.renderer.render = this.render;
+  },
+
+  unwrapRender: function () {
+    if (!this.originalRender) { return; }
+    this.sceneEl.renderer.render = this.originalRender;
+    this.originalRender = undefined;
+  },
+
+  render: function (scene, camera, renderTarget) {
     var spectatorCamera;
     var sceneEl = this.sceneEl;
     var isVREnabled = sceneEl.renderer.vr.enabled;
-    if (!this.spectatorCameraEl || sceneEl.isMobile) { return; }
+    this.originalRender.call(sceneEl.renderer, scene, camera, renderTarget);
+    if (!this.spectatorCameraEl || sceneEl.isMobile || !isVREnabled) { return; }
     spectatorCamera = this.spectatorCameraEl.components.camera.camera;
     sceneEl.renderer.vr.enabled = false;
-    sceneEl.renderer.render(sceneEl.object3D, spectatorCamera);
+    this.originalRender.call(sceneEl.renderer, scene, spectatorCamera);
     sceneEl.renderer.vr.enabled = isVREnabled;
   }
 });
@@ -77153,7 +77182,7 @@ function removeDefaultCamera (sceneEl) {
   sceneEl.removeChild(defaultCamera);
 }
 
-},{"../constants/":94,"../core/system":113,"../utils/bind":167}],161:[function(_dereq_,module,exports){
+},{"../constants/":94,"../core/system":113}],161:[function(_dereq_,module,exports){
 var geometries = _dereq_('../core/geometry').geometries;
 var registerSystem = _dereq_('../core/system').registerSystem;
 var THREE = _dereq_('../lib/three');

Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/aframe-master.js.map


Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/aframe-master.min.js


Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/aframe-master.min.js.map


+ 48 - 29
support/client/lib/vwf/model/aframe/extras/aframe-extras.controls.js

@@ -842,7 +842,7 @@ module.exports = AFRAME.registerComponent('checkpoint-controls', {
       this.el.setAttribute('position', this.targetPosition);
       this.checkpoint = null;
       el.emit('navigation-end', { checkpoint: checkpoint });
-      el.components['movement-controls'].updateNavNode();
+      el.components['movement-controls'].updateNavLocation();
     }
   },
 
@@ -924,8 +924,8 @@ module.exports = AFRAME.registerComponent('gamepad-controls', {
     camera: { default: '[camera]', type: 'selector' },
 
     // Rotation sensitivity
-    rotationSensitivity: { default: 0.05 // radians/frame, ish
-    } },
+    rotationSensitivity: { default: 2.0 }
+  },
 
   /*******************************************************************
    * Core
@@ -1022,20 +1022,34 @@ module.exports = AFRAME.registerComponent('gamepad-controls', {
   updateRotation: function updateRotation(dt) {
     if (!this.isRotationActive()) return;
 
+    var data = this.data;
+    var yaw = this.yaw;
+    var pitch = this.pitch;
+    var lookControls = data.camera.components['look-controls'];
+    var hasLookControls = lookControls && lookControls.pitchObject && lookControls.yawObject;
+
+    // Sync with look-controls pitch/yaw if available.
+    if (hasLookControls) {
+      pitch.rotation.copy(lookControls.pitchObject.rotation);
+      yaw.rotation.copy(lookControls.yawObject.rotation);
+    }
+
     var lookVector = this.getJoystick(1);
 
     if (Math.abs(lookVector.x) <= JOYSTICK_EPS) lookVector.x = 0;
     if (Math.abs(lookVector.y) <= JOYSTICK_EPS) lookVector.y = 0;
 
-    var data = this.data;
-    var yaw = this.yaw;
-    var pitch = this.pitch;
-
     lookVector.multiplyScalar(data.rotationSensitivity * dt / 1000);
     yaw.rotation.y -= lookVector.x;
     pitch.rotation.x -= lookVector.y;
     pitch.rotation.x = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, pitch.rotation.x));
-    data.camera.object3D.rotation.set(THREE.Math.radToDeg(pitch.rotation.x), THREE.Math.radToDeg(yaw.rotation.y), 0);
+    data.camera.object3D.rotation.set(pitch.rotation.x, yaw.rotation.y, 0);
+
+    // Sync with look-controls pitch/yaw if available.
+    if (hasLookControls) {
+      lookControls.pitchObject.rotation.copy(pitch.rotation);
+      lookControls.yawObject.rotation.copy(yaw.rotation);
+    }
   },
 
   /*******************************************************************
@@ -1355,9 +1369,7 @@ module.exports = AFRAME.registerComponent('movement-controls', {
   schema: {
     enabled: { default: true },
     controls: { default: ['gamepad', 'trackpad', 'keyboard', 'touch'] },
-    easing: { default: 15 }, // m/s2
-    easingY: { default: 0 }, // m/s2
-    acceleration: { default: 80 }, // m/s2
+    speed: { default: 0.3, min: 0 },
     fly: { default: false },
     constrainToNavMesh: { default: false },
     camera: { default: '[camera]', type: 'selector' }
@@ -1386,10 +1398,16 @@ module.exports = AFRAME.registerComponent('movement-controls', {
     }
   },
 
-  update: function update() {
-    if (this.el.sceneEl.hasLoaded) {
+  update: function update(prevData) {
+    var el = this.el;
+    var data = this.data;
+    if (el.sceneEl.hasLoaded) {
       this.injectControls();
     }
+    if (data.constrainToNavMesh !== prevData.constrainToNavMesh) {
+      var nav = el.sceneEl.systems.nav;
+      data.constrainToNavMesh ? nav.addAgent(this) : nav.removeAgent(this);
+    }
   },
 
   injectControls: function injectControls() {
@@ -1404,7 +1422,8 @@ module.exports = AFRAME.registerComponent('movement-controls', {
     }
   },
 
-  updateNavNode: function updateNavNode() {
+  updateNavLocation: function updateNavLocation() {
+    this.navGroup = null;
     this.navNode = null;
   },
 
@@ -1446,7 +1465,7 @@ module.exports = AFRAME.registerComponent('movement-controls', {
         end.copy(velocity).multiplyScalar(dt / 1000).add(start);
 
         var nav = el.sceneEl.systems.nav;
-        this.navGroup = this.navGroup || nav.getGroup(start);
+        this.navGroup = this.navGroup === null ? nav.getGroup(start) : this.navGroup;
         this.navNode = this.navNode || nav.getNode(start, this.navGroup);
         this.navNode = nav.clampStep(start, end, this.navGroup, this.navNode, clampedEnd);
         el.object3D.position.copy(clampedEnd);
@@ -1479,6 +1498,7 @@ module.exports = AFRAME.registerComponent('movement-controls', {
   },
 
   updateVelocity: function () {
+    var vector2 = new THREE.Vector2();
     // var matrix = new THREE.Matrix4();
     // var matrix2 = new THREE.Matrix4();
     // var position = new THREE.Vector3();
@@ -1506,19 +1526,11 @@ module.exports = AFRAME.registerComponent('movement-controls', {
         }
       }
 
-      if (AFRAME.components.velocity && !data.constrainToNavMesh) velocity.copy(this.el.getAttribute('velocity'));
-      velocity.x -= velocity.x * data.easing * dt / 1000;
-      velocity.y -= velocity.y * data.easingY * dt / 1000;
-      velocity.z -= velocity.z * data.easing * dt / 1000;
+      if (el.hasAttribute('velocity') && !data.constrainToNavMesh) {
+        velocity.copy(this.el.getAttribute('velocity'));
+      }
 
       if (dVelocity && data.enabled) {
-        // Set acceleration
-        if (dVelocity.length() > 1) {
-          dVelocity.setLength(this.data.acceleration * dt / 1000);
-        } else {
-          dVelocity.multiplyScalar(this.data.acceleration * dt / 1000);
-        }
-
         // TODO: Handle rotated rig.
         var cameraEl = data.camera;
         // matrix.copy(cameraEl.object3D.matrixWorld);
@@ -1530,9 +1542,16 @@ module.exports = AFRAME.registerComponent('movement-controls', {
         // Rotate to heading
         dVelocity.applyQuaternion(cameraEl.object3D.quaternion);
 
-        if (!data.fly) dVelocity.y = 0;
-
-        velocity.add(dVelocity);
+        var factor = dVelocity.length();
+        if (data.fly) {
+          velocity.copy(dVelocity);
+          velocity.multiplyScalar(this.data.speed * dt);
+        } else {
+          vector2.set(dVelocity.x, dVelocity.z);
+          vector2.setLength(factor * this.data.speed * dt);
+          velocity.x = vector2.x;
+          velocity.z = vector2.y;
+        }
       }
     };
   }()

Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/extras/aframe-extras.controls.min.js


Plik diff jest za duży
+ 1379 - 1469
support/client/lib/vwf/model/aframe/extras/aframe-extras.js


Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/extras/aframe-extras.min.js


+ 1 - 1
support/client/lib/vwf/model/aframe/extras/aframe-extras.misc.js

@@ -397,7 +397,7 @@ module.exports = AFRAME.registerComponent('kinematic-body', {
         position = new CANNON.Vec3().copy(el.getAttribute('position'));
 
     this.body = new CANNON.Body({
-      material: this.system.material,
+      material: this.system.getMaterial('staticMaterial'),
       position: position,
       mass: data.mass,
       linearDamping: data.linearDamping,

Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/extras/aframe-extras.misc.min.js


+ 259 - 242
support/client/lib/vwf/model/aframe/extras/aframe-extras.pathfinding.js

@@ -3,7 +3,259 @@
 
 require('./src/pathfinding');
 
-},{"./src/pathfinding":8}],2:[function(require,module,exports){
+},{"./src/pathfinding":2}],2:[function(require,module,exports){
+'use strict';
+
+require('./nav-mesh');
+require('./nav-agent');
+require('./system');
+
+},{"./nav-agent":3,"./nav-mesh":4,"./system":5}],3:[function(require,module,exports){
+'use strict';
+
+module.exports = AFRAME.registerComponent('nav-agent', {
+  schema: {
+    destination: { type: 'vec3' },
+    active: { default: false },
+    speed: { default: 2 }
+  },
+  init: function init() {
+    this.system = this.el.sceneEl.systems.nav;
+    this.system.addAgent(this);
+    this.group = null;
+    this.path = [];
+    this.raycaster = new THREE.Raycaster();
+  },
+  remove: function remove() {
+    this.system.removeAgent(this);
+  },
+  update: function update() {
+    this.path.length = 0;
+  },
+  updateNavLocation: function updateNavLocation() {
+    this.group = null;
+    this.path = [];
+  },
+  tick: function () {
+    var vDest = new THREE.Vector3();
+    var vDelta = new THREE.Vector3();
+    var vNext = new THREE.Vector3();
+
+    return function (t, dt) {
+      var el = this.el;
+      var data = this.data;
+      var raycaster = this.raycaster;
+      var speed = data.speed * dt / 1000;
+
+      if (!data.active) return;
+
+      // Use PatrolJS pathfinding system to get shortest path to target.
+      if (!this.path.length) {
+        var position = this.el.object3D.position;
+        this.group = this.group || this.system.getGroup(position);
+        this.path = this.system.getPath(position, vDest.copy(data.destination), this.group) || [];
+        el.emit('nav-start');
+      }
+
+      // If no path is found, exit.
+      if (!this.path.length) {
+        console.warn('[nav] Unable to find path to %o.', data.destination);
+        this.el.setAttribute('nav-agent', { active: false });
+        el.emit('nav-end');
+        return;
+      }
+
+      // Current segment is a vector from current position to next waypoint.
+      var vCurrent = el.object3D.position;
+      var vWaypoint = this.path[0];
+      vDelta.subVectors(vWaypoint, vCurrent);
+
+      var distance = vDelta.length();
+      var gazeTarget = void 0;
+
+      if (distance < speed) {
+        // If <1 step from current waypoint, discard it and move toward next.
+        this.path.shift();
+
+        // After discarding the last waypoint, exit pathfinding.
+        if (!this.path.length) {
+          this.el.setAttribute('nav-agent', { active: false });
+          el.emit('nav-end');
+          return;
+        }
+
+        vNext.copy(vCurrent);
+        gazeTarget = this.path[0];
+      } else {
+        // If still far away from next waypoint, find next position for
+        // the current frame.
+        vNext.copy(vDelta.setLength(speed)).add(vCurrent);
+        gazeTarget = vWaypoint;
+      }
+
+      // Look at the next waypoint.
+      gazeTarget.y = vCurrent.y;
+      el.object3D.lookAt(gazeTarget);
+
+      // Raycast against the nav mesh, to keep the agent moving along the
+      // ground, not traveling in a straight line from higher to lower waypoints.
+      raycaster.ray.origin.copy(vNext);
+      raycaster.ray.origin.y += 1.5;
+      raycaster.ray.direction.y = -1;
+      var intersections = raycaster.intersectObject(this.system.getNavMesh());
+
+      if (!intersections.length) {
+        // Raycasting failed. Step toward the waypoint and hope for the best.
+        vCurrent.copy(vNext);
+      } else {
+        // Re-project next position onto nav mesh.
+        vDelta.subVectors(intersections[0].point, vCurrent);
+        vCurrent.add(vDelta.setLength(speed));
+      }
+    };
+  }()
+});
+
+},{}],4:[function(require,module,exports){
+'use strict';
+
+/**
+ * nav-mesh
+ *
+ * Waits for a mesh to be loaded on the current entity, then sets it as the
+ * nav mesh in the pathfinding system.
+ */
+
+module.exports = AFRAME.registerComponent('nav-mesh', {
+  init: function init() {
+    this.system = this.el.sceneEl.systems.nav;
+    this.hasLoadedNavMesh = false;
+    this.el.addEventListener('model-loaded', this.loadNavMesh.bind(this));
+  },
+
+  play: function play() {
+    if (!this.hasLoadedNavMesh) this.loadNavMesh();
+  },
+
+  loadNavMesh: function loadNavMesh() {
+    var object = this.el.getObject3D('mesh');
+    var scene = this.el.sceneEl.object3D;
+
+    if (!object) return;
+
+    var navMesh = void 0;
+    object.traverse(function (node) {
+      if (node.isMesh) navMesh = node;
+    });
+
+    if (!navMesh) return;
+
+    var navMeshGeometry = navMesh.geometry.isBufferGeometry ? new THREE.Geometry().fromBufferGeometry(navMesh.geometry) : navMesh.geometry.clone();
+
+    scene.updateMatrixWorld();
+    navMeshGeometry.applyMatrix(navMesh.matrixWorld);
+    this.system.setNavMeshGeometry(navMeshGeometry);
+
+    this.hasLoadedNavMesh = true;
+  }
+});
+
+},{}],5:[function(require,module,exports){
+'use strict';
+
+var Path = require('three-pathfinding');
+
+var pathfinder = new Path();
+var ZONE = 'level';
+
+/**
+ * nav
+ *
+ * Pathfinding system, using PatrolJS.
+ */
+module.exports = AFRAME.registerSystem('nav', {
+  init: function init() {
+    this.navMesh = null;
+    this.agents = new Set();
+  },
+
+  /**
+   * @param {THREE.Geometry} geometry
+   */
+  setNavMeshGeometry: function setNavMeshGeometry(geometry) {
+    this.navMesh = new THREE.Mesh(geometry);
+    pathfinder.setZoneData(ZONE, Path.createZone(geometry));
+    Array.from(this.agents).forEach(function (agent) {
+      return agent.updateNavLocation();
+    });
+  },
+
+  /**
+   * @return {THREE.Mesh}
+   */
+  getNavMesh: function getNavMesh() {
+    return this.navMesh;
+  },
+
+  /**
+   * @param {NavAgent} ctrl
+   */
+  addAgent: function addAgent(ctrl) {
+    this.agents.add(ctrl);
+  },
+
+  /**
+   * @param {NavAgent} ctrl
+   */
+  removeAgent: function removeAgent(ctrl) {
+    this.agents.delete(ctrl);
+  },
+
+  /**
+   * @param  {THREE.Vector3} start
+   * @param  {THREE.Vector3} end
+   * @param  {number} groupID
+   * @return {Array<THREE.Vector3>}
+   */
+  getPath: function getPath(start, end, groupID) {
+    return pathfinder.findPath(start, end, ZONE, groupID);
+  },
+
+  /**
+   * @param {THREE.Vector3} position
+   * @return {number}
+   */
+  getGroup: function getGroup(position) {
+    return pathfinder.getGroup(ZONE, position);
+  },
+
+  /**
+   * @param  {THREE.Vector3} position
+   * @param  {number} groupID
+   * @return {Node}
+   */
+  getNode: function getNode(position, groupID) {
+    return pathfinder.getClosestNode(position, ZONE, groupID, true);
+  },
+
+  /**
+   * @param  {THREE.Vector3} start Starting position.
+   * @param  {THREE.Vector3} end Desired ending position.
+   * @param  {number} groupID
+   * @param  {Node} node
+   * @param  {THREE.Vector3} endTarget (Output) Adjusted step end position.
+   * @return {Node} Current node, after step is taken.
+   */
+  clampStep: function clampStep(start, end, groupID, node, endTarget) {
+    if (!this.navMesh || !node) {
+      endTarget.copy(end);
+      return this.navMesh ? this.getNode(end, groupID) : null;
+    }
+    return pathfinder.clampStep(start, end, node, ZONE, groupID, endTarget);
+  }
+});
+
+},{"three-pathfinding":10}],6:[function(require,module,exports){
 'use strict';
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -148,7 +400,7 @@ var AStar = function () {
 
 module.exports = AStar;
 
-},{"./BinaryHeap":3,"./utils.js":7}],3:[function(require,module,exports){
+},{"./BinaryHeap":7,"./utils.js":11}],7:[function(require,module,exports){
 "use strict";
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -302,7 +554,7 @@ var BinaryHeap = function () {
 
 module.exports = BinaryHeap;
 
-},{}],4:[function(require,module,exports){
+},{}],8:[function(require,module,exports){
 'use strict';
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -528,7 +780,7 @@ var Builder = function () {
 
 module.exports = Builder;
 
-},{"./utils":7}],5:[function(require,module,exports){
+},{"./utils":11}],9:[function(require,module,exports){
 'use strict';
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -639,7 +891,7 @@ var Channel = function () {
 
 module.exports = Channel;
 
-},{"./utils":7}],6:[function(require,module,exports){
+},{"./utils":11}],10:[function(require,module,exports){
 'use strict';
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -944,7 +1196,7 @@ var Node = {}; // jshint ignore:line
 
 module.exports = Path;
 
-},{"./AStar":2,"./Builder":4,"./Channel":5,"./utils":7}],7:[function(require,module,exports){
+},{"./AStar":6,"./Builder":8,"./Channel":9,"./utils":11}],11:[function(require,module,exports){
 'use strict';
 
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -1278,239 +1530,4 @@ var Utils = function () {
 
 module.exports = Utils;
 
-},{}],8:[function(require,module,exports){
-'use strict';
-
-require('./nav-mesh');
-require('./nav-agent');
-require('./system');
-
-},{"./nav-agent":9,"./nav-mesh":10,"./system":11}],9:[function(require,module,exports){
-'use strict';
-
-module.exports = AFRAME.registerComponent('nav-agent', {
-  schema: {
-    destination: { type: 'vec3' },
-    active: { default: false },
-    speed: { default: 2 }
-  },
-  init: function init() {
-    this.system = this.el.sceneEl.systems.nav;
-    this.system.addAgent(this);
-    this.group = null;
-    this.path = [];
-    this.raycaster = new THREE.Raycaster();
-  },
-  remove: function remove() {
-    this.system.removeAgent(this);
-  },
-  update: function update() {
-    this.path.length = 0;
-  },
-  tick: function () {
-    var vDest = new THREE.Vector3();
-    var vDelta = new THREE.Vector3();
-    var vNext = new THREE.Vector3();
-
-    return function (t, dt) {
-      var el = this.el;
-      var data = this.data;
-      var raycaster = this.raycaster;
-      var speed = data.speed * dt / 1000;
-
-      if (!data.active) return;
-
-      // Use PatrolJS pathfinding system to get shortest path to target.
-      if (!this.path.length) {
-        var position = this.el.object3D.position;
-        this.group = this.group || this.system.getGroup(position);
-        this.path = this.system.getPath(position, vDest.copy(data.destination), this.group);
-        this.path = this.path || [];
-        el.emit('nav-start');
-      }
-
-      // If no path is found, exit.
-      if (!this.path.length) {
-        console.warn('[nav] Unable to find path to %o.', data.destination);
-        this.el.setAttribute('nav-agent', { active: false });
-        el.emit('nav-end');
-        return;
-      }
-
-      // Current segment is a vector from current position to next waypoint.
-      var vCurrent = el.object3D.position;
-      var vWaypoint = this.path[0];
-      vDelta.subVectors(vWaypoint, vCurrent);
-
-      var distance = vDelta.length();
-      var gazeTarget = void 0;
-
-      if (distance < speed) {
-        // If <1 step from current waypoint, discard it and move toward next.
-        this.path.shift();
-
-        // After discarding the last waypoint, exit pathfinding.
-        if (!this.path.length) {
-          this.el.setAttribute('nav-agent', { active: false });
-          el.emit('nav-end');
-          return;
-        } else {
-          gazeTarget = this.path[0];
-        }
-      } else {
-        // If still far away from next waypoint, find next position for
-        // the current frame.
-        vNext.copy(vDelta.setLength(speed)).add(vCurrent);
-        gazeTarget = vWaypoint;
-      }
-
-      // Look at the next waypoint.
-      gazeTarget.y = vCurrent.y;
-      el.object3D.lookAt(gazeTarget);
-
-      // Raycast against the nav mesh, to keep the agent moving along the
-      // ground, not traveling in a straight line from higher to lower waypoints.
-      raycaster.ray.origin.copy(vNext);
-      raycaster.ray.origin.y += 1.5;
-      raycaster.ray.direction.y = -1;
-      var intersections = raycaster.intersectObject(this.system.getNavMesh());
-
-      if (!intersections.length) {
-        // Raycasting failed. Step toward the waypoint and hope for the best.
-        vCurrent.copy(vNext);
-      } else {
-        // Re-project next position onto nav mesh.
-        vDelta.subVectors(intersections[0].point, vCurrent);
-        vCurrent.add(vDelta.setLength(speed));
-      }
-    };
-  }()
-});
-
-},{}],10:[function(require,module,exports){
-'use strict';
-
-/**
- * nav-mesh
- *
- * Waits for a mesh to be loaded on the current entity, then sets it as the
- * nav mesh in the pathfinding system.
- */
-
-module.exports = AFRAME.registerComponent('nav-mesh', {
-  init: function init() {
-    this.system = this.el.sceneEl.systems.nav;
-    this.loadNavMesh();
-    this.el.addEventListener('model-loaded', this.loadNavMesh.bind(this));
-  },
-
-  loadNavMesh: function loadNavMesh() {
-    var object = this.el.getObject3D('mesh');
-
-    if (!object) return;
-
-    var navMesh = void 0;
-    object.traverse(function (node) {
-      if (node.isMesh) navMesh = node;
-    });
-
-    if (!navMesh) return;
-
-    this.system.setNavMesh(navMesh);
-  }
-});
-
-},{}],11:[function(require,module,exports){
-'use strict';
-
-var Path = require('three-pathfinding');
-
-var pathfinder = new Path();
-var ZONE = 'level';
-
-/**
- * nav
- *
- * Pathfinding system, using PatrolJS.
- */
-module.exports = AFRAME.registerSystem('nav', {
-  init: function init() {
-    this.navMesh = null;
-    this.agents = new Set();
-  },
-
-  /**
-   * @param {THREE.Mesh} mesh
-   */
-  setNavMesh: function setNavMesh(mesh) {
-    var geometry = mesh.geometry.isBufferGeometry ? new THREE.Geometry().fromBufferGeometry(mesh.geometry) : mesh.geometry;
-    this.navMesh = new THREE.Mesh(geometry);
-    pathfinder.setZoneData(ZONE, Path.createZone(this.navMesh.geometry));
-  },
-
-  /**
-   * @return {THREE.Mesh}
-   */
-  getNavMesh: function getNavMesh() {
-    return this.navMesh;
-  },
-
-  /**
-   * @param {NavAgent} ctrl
-   */
-  addAgent: function addAgent(ctrl) {
-    this.agents.add(ctrl);
-  },
-
-  /**
-   * @param {NavAgent} ctrl
-   */
-  removeAgent: function removeAgent(ctrl) {
-    this.agents.remove(ctrl);
-  },
-
-  /**
-   * @param  {THREE.Vector3} start
-   * @param  {THREE.Vector3} end
-   * @param  {number} groupID
-   * @return {Array<THREE.Vector3>}
-   */
-  getPath: function getPath(start, end, groupID) {
-    return pathfinder.findPath(start, end, ZONE, groupID);
-  },
-
-  /**
-   * @param {THREE.Vector3} position
-   * @return {number}
-   */
-  getGroup: function getGroup(position) {
-    return pathfinder.getGroup(ZONE, position);
-  },
-
-  /**
-   * @param  {THREE.Vector3} position
-   * @param  {number} groupID
-   * @return {Node}
-   */
-  getNode: function getNode(position, groupID) {
-    return pathfinder.getClosestNode(position, ZONE, groupID, true);
-  },
-
-  /**
-   * @param  {THREE.Vector3} start Starting position.
-   * @param  {THREE.Vector3} end Desired ending position.
-   * @param  {number} groupID
-   * @param  {Node} node
-   * @param  {THREE.Vector3} endTarget (Output) Adjusted step end position.
-   * @return {Node} Current node, after step is taken.
-   */
-  clampStep: function clampStep(start, end, groupID, node, endTarget) {
-    if (!this.navMesh || !node) {
-      endTarget.copy(end);
-      return this.navMesh ? this.getNode(end, groupID) : null;
-    }
-    return pathfinder.clampStep(start, end, node, ZONE, groupID, endTarget);
-  }
-});
-
-},{"three-pathfinding":6}]},{},[1]);
+},{}]},{},[1]);

Plik diff jest za duży
+ 0 - 0
support/client/lib/vwf/model/aframe/extras/aframe-extras.pathfinding.min.js


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików