@soonspacejs/plugin-patrol-controls 2.4.9 → 2.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -2
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return n};var n={},i=Object.prototype,o=i.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function h(t,e,n,i){var o=e&&e.prototype instanceof f?e:f,r=Object.create(o.prototype),a=new E(i||[]);return r._invoke=function(t,e,n){var i="suspendedStart";return function(o,r){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===o)throw r;return k()}for(n.method=o,n.arg=r;;){var a=n.delegate;if(a){var s=S(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var u=p(t,e,n);if("normal"===u.type){if(i=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),r}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}n.wrap=h;var l={};function f(){}function d(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(T([])));w&&w!==i&&o.call(w,a)&&(y=w);var g=v.prototype=f.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function b(e,n){function i(r,a,s,u){var c=p(e[r],e,a);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==t(l)&&o.call(l,"__await")?n.resolve(l.__await).then((function(t){i("next",t,s,u)}),(function(t){i("throw",t,s,u)})):n.resolve(l).then((function(t){h.value=t,s(h)}),(function(t){return i("throw",t,s,u)}))}u(c.arg)}var r;this._invoke=function(t,e){function o(){return new n((function(n,o){i(t,e,n,o)}))}return r=r?r.then(o,o):o()}}function S(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,S(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var i=p(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,l;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function T(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(o.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return d.prototype=v,c(g,"constructor",v),c(v,"constructor",d),d.displayName=c(v,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},n.awrap=function(t){return{__await:t}},x(b.prototype),c(b.prototype,s,(function(){return this})),n.AsyncIterator=b,n.async=function(t,e,i,o,r){void 0===r&&(r=Promise);var a=new b(h(t,e,i,o),r);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},n.values=T,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return a.type="throw",a.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i],a=r.completion;if("root"===r.tryLoc)return n("end");if(r.tryLoc<=this.prev){var s=o.call(r,"catchLoc"),u=o.call(r,"finallyLoc");if(s&&u){if(this.prev<r.catchLoc)return n(r.catchLoc,!0);if(this.prev<r.finallyLoc)return n(r.finallyLoc)}else if(s){if(this.prev<r.catchLoc)return n(r.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return n(r.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var a=r?r.completion:{};return a.type=t,a.arg=e,r?(this.method="next",this.next=r.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var o=i.arg;P(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},n}function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}
|
|
2
1
|
/*! *****************************************************************************
|
|
3
2
|
Copyright (c) Microsoft Corporation.
|
|
4
3
|
|
|
@@ -13,4 +12,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
14
|
***************************************************************************** */
|
|
16
|
-
function
|
|
15
|
+
function t(t,i,s,e){return new(s||(s=Promise))((function(o,n){function a(t){try{h(e.next(t))}catch(t){n(t)}}function r(t){try{h(e.throw(t))}catch(t){n(t)}}function h(t){var i;t.done?o(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(a,r)}h((e=e.apply(t,i||[])).next())}))}class i{constructor(t){this._mainCameraViewpointData=null,this.ssp=t,this.camera=t.viewport.camera,this.options={naviSpeed:1,rotateSpeed:1,eyeHeight:150,flyToStartPoint:!0,onUpdate:()=>{},onEnd:()=>{}},this.states={moveDuration:0,rotateDuration:0},this.points=[],this.nextPointIndex=0,this.isPaused=!1,this.isStoped=!1,this._positionTween=null,this._rotationTween=null,this._cameraViewpointData=null}start(t,i){this.initOptions(i),this.init(t),this.patrolStart()}setOptions(t){if(this.isStoped)return;const{naviSpeed:i,rotateSpeed:s}=t;if(i&&this._positionTween){const t=this.states.moveDuration*this.options.naviSpeed/i;this._positionTween.duration(t),this.states.moveDuration=t}if(s&&this._rotationTween){const t=this.states.rotateDuration*this.options.rotateSpeed/s;this._rotationTween.duration(t),this.states.rotateDuration=t}this.initOptions(t)}pause(){var t,i;if(this.isPaused)return;this._cameraViewpointData=this.ssp.getCameraViewpoint();const{cameraManager:s}=this.ssp.viewport,e=s.getMainCamera();s.setCurrentCamera(e),this.ssp.setCameraViewpoint(this._cameraViewpointData),this.ssp.setControlsOptions({enabled:!1}),this.isPaused=!0,null===(t=this._positionTween)||void 0===t||t.pause(),null===(i=this._rotationTween)||void 0===i||i.pause()}resume(){var t,i;if(this.isPaused){if(this._cameraViewpointData){const{cameraManager:t}=this.ssp.viewport;t.setCurrentCamera(this.camera),this.ssp.setCameraViewpoint(this._cameraViewpointData)}this.isPaused=!1,null===(t=this._positionTween)||void 0===t||t.resume(),null===(i=this._rotationTween)||void 0===i||i.resume()}}stop(){this.patrolStop();const{cameraManager:t}=this.ssp.viewport,i=t.getMainCamera();t.setCurrentCamera(i),this._mainCameraViewpointData&&this.ssp.setCameraViewpoint(this._mainCameraViewpointData),this.ssp.setControlsOptions({enabled:!0})}init(t){const{cameraManager:i}=this.ssp.viewport;this.isPaused=!1,this.isStoped=!1,this._mainCameraViewpointData=i.getCameraViewpoint(),this.camera=i.createCamera("patrolControls"),i.setCurrentCamera(this.camera),t.nodes.forEach((t=>{this.points.push(t.getWorldPosition(new this.ssp.THREE.Vector3))}))}initOptions(t){const{eyeHeight:i,naviSpeed:s,rotateSpeed:e,flyToStartPoint:o=!0,onUpdate:n,onEnd:a}=t;i&&(this.options.eyeHeight=i),s&&(this.options.naviSpeed=s),e&&(this.options.rotateSpeed=e),this.options.flyToStartPoint=o,n&&(this.options.onUpdate=n),a&&(this.options.onEnd=a)}computedRotation(t,i){const s=new this.ssp.THREE.Matrix4;s.lookAt(t,i,this.camera.up);const e=(new this.ssp.THREE.Euler).setFromRotationMatrix(s,"YXZ");return e.copy(this.ssp.utils.rotationAFix(this.camera.rotation,e.clone())),0===e.y&&(0===e.z?e.x=0:0===e.x&&(e.z=0)),e}computedNextRotation(){const t=this.points[this.nextPointIndex],i=this.points[this.nextPointIndex+1];return this.computedRotation(t,i)}patrolStart(){return t(this,void 0,void 0,(function*(){return new Promise((i=>t(this,void 0,void 0,(function*(){const{onUpdate:t,onEnd:s}=this.options;if(this.nextPointIndex===this.points.length)null==s||s(this.camera.position.clone()),i(!0),this.isStoped=!0;else{const i=this.camera.position.clone(),s=this.points[this.nextPointIndex].clone().setY(this.points[this.nextPointIndex].y+this.options.eyeHeight),e=i.distanceTo(s);if(this.states.moveDuration=0===this.nextPointIndex?1e3:e/this.options.naviSpeed/.6,0!==this.nextPointIndex||this.options.flyToStartPoint?yield this.ssp.animation(this.camera.position,s,{duration:this.states.moveDuration},((i,s)=>{null==t||t(i),this.ssp.signals.cameraChange.dispatch()}),(t=>{this._positionTween=t})):this.camera.position.copy(s),this.nextPointIndex<this.points.length-1){const t=this.camera.rotation.clone(),i=this.computedNextRotation(),s=Math.abs(t.x-i.x)+Math.abs(t.y-i.y)+Math.abs(t.y-i.y);this.states.rotateDuration=0===this.nextPointIndex?1e3:100*s/this.options.rotateSpeed,0!==this.nextPointIndex||this.options.flyToStartPoint?yield this.ssp.animation(this.camera.rotation,i,{duration:this.states.rotateDuration},((t,i)=>{}),(t=>{this._rotationTween=t})):this.camera.rotation.copy(i)}this.nextPointIndex++,yield this.patrolStart()}}))))}))}patrolStop(){var t,i;this.options={naviSpeed:1,rotateSpeed:1,eyeHeight:150,flyToStartPoint:!0,onUpdate:()=>{},onEnd:()=>{}},this.points=[],this.nextPointIndex=0,this.isPaused=!1,this.isStoped=!0,null===(t=this._positionTween)||void 0===t||t.stop(),null===(i=this._rotationTween)||void 0===i||i.stop(),this._positionTween=null,this._rotationTween=null}}export{i as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-patrol-controls",
|
|
3
3
|
"pluginName": "PatrolControlsPlugin",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.12",
|
|
5
5
|
"description": "Patrol-controls plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xuek",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "1c14eab2badba701ba58d6c8df1a6e1798ca4ec5"
|
|
17
17
|
}
|