@galacean/effects-plugin-orientation-transformer 2.0.0-alpha.21 → 2.0.0-alpha.23

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/alipay.js CHANGED
@@ -810,7 +810,7 @@ exports.OrientationComponent = __decorate([
810
810
  ], exports.OrientationComponent);
811
811
 
812
812
  EFFECTS.registerPlugin("orientation-transformer", OrientationPluginLoader, EFFECTS.VFXItem);
813
- var version = "2.0.0-alpha.21";
813
+ var version = "2.0.0-alpha.23";
814
814
  EFFECTS.logger.info("Plugin orientation transformer version: " + version + ".");
815
815
  if (version !== EFFECTS__namespace.version) {
816
816
  console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
package/dist/alipay.mjs CHANGED
@@ -787,7 +787,7 @@ OrientationComponent = __decorate([
787
787
  ], OrientationComponent);
788
788
 
789
789
  registerPlugin("orientation-transformer", OrientationPluginLoader, VFXItem);
790
- var version = "2.0.0-alpha.21";
790
+ var version = "2.0.0-alpha.23";
791
791
  logger.info("Plugin orientation transformer version: " + version + ".");
792
792
  if (version !== EFFECTS.version) {
793
793
  console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects player orientation transformer plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,意绮
6
- * Version: v2.0.0-alpha.21
6
+ * Version: v2.0.0-alpha.23
7
7
  */
8
8
 
9
9
  'use strict';
@@ -817,7 +817,7 @@ exports.OrientationComponent = __decorate([
817
817
  ], exports.OrientationComponent);
818
818
 
819
819
  EFFECTS.registerPlugin("orientation-transformer", OrientationPluginLoader, EFFECTS.VFXItem);
820
- var version = "2.0.0-alpha.21";
820
+ var version = "2.0.0-alpha.23";
821
821
  EFFECTS.logger.info("Plugin orientation transformer version: " + version + ".");
822
822
  if (version !== EFFECTS__namespace.version) {
823
823
  console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
package/dist/index.min.js CHANGED
@@ -3,6 +3,6 @@
3
3
  * Description: Galacean Effects player orientation transformer plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,意绮
6
- * Version: v2.0.0-alpha.21
7
- */function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.orientationTransformerPlugin={}),t.ge)}(this,function(t,e){"use strict";var n,a,i=function(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}(e);function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}var s=function(){function t(t){this.composition=t,this.targets={},this.records={},this.currentPos={},this.currentRot={},this.gammaRange=[-89,89],this.betaRange=[-89,89]}var e=t.prototype;return e.update=function(t){var e=t.x,n=t.y,a=t.beta,i=t.gamma;this.currentEvent={x:e,y:n,beta:a,gamma:i}},e.updateOrientation=function(){var t=this,e=this.currentEvent;e&&Object.getOwnPropertyNames(this.targets).forEach(function(n){t.moveLayer(n,e)})},e.initComposition=function(){for(var t=this.composition.items,e=0;e<t.length;e++){var n=t[e];if(this.targets[n.name]){var a=n.transform.position.toArray(),i=n.transform.rotation.toArray(),r=this.currentPos[n.name],o=this.currentRot[n.name];this.records[n.name]={item:n,position:a,rotation:i},r&&n.transform.setPosition(r[0],r[1],r[2]),o&&n.transform.setRotation(o[0],o[1],o[2])}}},e.addTarget=function(t){this.targets[t.name]=t},e.removeTarget=function(t){delete this.targets[t],delete this.records[t]},e.moveLayer=function(t,e){var n=e.x,a=e.y,i=e.beta,r=e.gamma,o=null==(L=this.records[t])?void 0:L.item;if(o){var s=this.records[t].position,l=this.records[t].rotation,u=this.targets[t],h=c(n,this.betaRange),f=c(a,this.gammaRange);if(u){var m,d,p,v,g,b,y,M,w,R,x,O,L,E,A,P=[s[0]+1.2*(d=(h-(m=this.gammaRange[0]))/(this.gammaRange[1]-m),(p=u.xMin)+(u.xMax-p)*d),s[1]+1.2*(g=(f-(v=this.betaRange[0]))/(this.betaRange[1]-v),(b=u.yMin)+(u.yMax-b)*g),s[2]],D=(y=c(.8*r,this.gammaRange),(y-(M=this.gammaRange[0]))/(this.gammaRange[1]-M)),T=(w=c(.8*i,this.betaRange),(w-(R=this.betaRange[0]))/(this.betaRange[1]-R)),j=[l[0]+((x=u.hMin)+(u.hMax-x)*T),l[1]+((O=u.vMin)+(u.vMax-O)*D),l[2]];(E=o.transform).setPosition.apply(E,[].concat(P)),(A=o.transform).setRotation.apply(A,[].concat(j)),this.currentPos[t]=P.slice(),this.currentRot[t]=j.slice()}}},t}();function c(t,e){return t<e[0]?e[0]:t>e[1]?e[1]:t}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t}).apply(this,arguments)}function u(t){return Object.prototype.toString.call(t)}function h(t,e){var n=!0,a=!0,i=!0;if("[object Array]"===u(e.alpha)&&e.alpha.length>=2){var r=t.alpha+e.alpha[0],o=t.alpha+e.alpha[1];n=(r=r<0?r+360:r)<(o=o>360?o-360:o)?t.alpha>r&&t.alpha<o:t.alpha>r||t.alpha<o}return"[object Array]"===u(e.beta)&&e.beta.length>=2&&(a=t.beta>=e.beta[0]&&t.beta<=e.beta[1]),"[object Array]"===u(e.gamma)&&e.gamma.length>=2&&(i=t.gamma>=e.gamma[0]&&t.gamma<=e.gamma[1]),n&&a&&i}var f=function(){function t(t){void 0===t&&(t={}),this.options=t,this.lastValue=0,this.valuePool=[]}var e=t.prototype;return e.stableFix=function(t){var e=this.options.stableRange||3;return Math.abs(t)<e?0:t>e?t-e:t+e},e.changeLimit=function(t){var e=this.lastValue,n=t;return Math.abs(t-e)>5&&(n=e<t?e+5:e-5),1>Math.abs(t-e)&&(n=e),this.lastValue=n,n},e.linearRegressionMedian=function(t){var e,n,a;return this.valuePool.push(t),this.valuePool.length>=5?(a=function(t){var e=[],n=[];t.forEach(function(t,a){e.push(a),n.push(t)});var a=function(t,e){for(var n={},a=e.length,i=0,r=0,o=0,s=0,c=0,l=0;l<e.length;l++)i+=t[l],r+=e[l],o+=t[l]*e[l],s+=t[l]*t[l],c+=e[l]*e[l];var u=i/a,h=r/a;return n.a=(o-a*u*h)/(s-a*u*u),n.b=h-n.a*u,n.miss=Math.pow((a*o-i*r)/Math.sqrt((a*s-i*i)*(a*c-r*r)),2),n}(e,n);return function(t){return a.a*t+a.b}}(n=this.valuePool),n=n.map(function(t,e){return a(e)}),e=a(n.length/2),this.valuePool.shift()):e=this.lastValue,e},t}(),m=((n=navigator.userAgent.toLowerCase().match(/cpu (iphone )?os (.*?) like mac os/))?parseInt(n[2],10):0)&&void 0!==window.AlipayJSBridge,d=void 0!==window.WindVane,p={X:!0,Y:!0,interval:Math.floor(1e3/30),useRequestAnimationFrame:!0,relativeBeta:!1,relativeGamma:!1,validRange:{alpha:[-60,60],beta:[-60,180],gamma:[-89,89]},stableRange:3},v=function(){function t(t){void 0===t&&(t={}),this.lastX=0,this.lastY=0,this.prevAcceler={x:0,y:0,z:0},this.stoped=!1;var e=l({},p.validRange,t.validRange),n=l({},p,t);n.validRange=e,this.options=n;var a=this.options.stableRange;this.filterX=new f({stableRange:a}),this.filterY=new f({stableRange:a})}var n=t.prototype;return n.watch=function(t){var e,n,a,i,r,o,s=this;if("function"==typeof t&&!this.watchListener){var c,l=0,u=0,f=NaN,p=NaN,v=function(c){!s.stoped&&(e=c.alpha,n=c.beta,a=c.gamma,i=h.call(s,{alpha:e,beta:n,gamma:a},s.options.validRange),isNaN(f)&&(f=a,s.filterX.lastValue=a),isNaN(p)&&(p=n,s.filterY.lastValue=n),i&&(s.options.X?(r=s.options.relativeGamma?a-f:a,r=s.filterX.stableFix(r),r=s.filterX.changeLimit(r),r=s.filterX.linearRegressionMedian(+r)):r=0,s.options.Y?(o=s.options.relativeBeta?n-p:n,o=s.filterY.stableFix(o),o=s.filterY.changeLimit(o),o=s.filterY.linearRegressionMedian(+o)):o=0,s.isValid(r,o)&&(s.options.useRequestAnimationFrame?window.requestAnimationFrame(function(){t(r,o,{alpha:e,beta:o-p,gamma:r-f})}):t(r,o,{alpha:e,beta:o-p,gamma:r-f}),s.lastX=r,s.lastY=o)))};this.stoped=!1,d?(b(!0,this.options.interval),this.watchListener=function(t){if("param"in t){var e=t.param,n=e.x,a=e.y,i=e.z;(n!==s.prevAcceler.x||a!==s.prevAcceler.y||i!==s.prevAcceler.z)&&(s.prevAcceler={x:n,y:a,z:i},v({alpha:180*+i,beta:-90*+a,gamma:90*+n}))}},document.addEventListener("motion.gyro",this.watchListener,!1)):m&&!("undefined"!=typeof my&&(null==(c=my)?void 0:c.renderTarget)==="web"||"miniprogram"===window.__wxjs_environment)?(g(!0,this.options.interval/1e3),this.watchListener=function(t){if(t&&"data"in t){var e=t.data,n=e.x,a=e.y;v({alpha:180*e.z,beta:-90*a,gamma:90*n})}},document.addEventListener("accelerometerChange",this.watchListener,!1)):(this.watchListener=function(t){(u=new Date().getTime())-l>=s.options.interval&&(l=u,v(t))},window.addEventListener("deviceorientation",this.watchListener,!1))}},n.unWatch=function(){e.assertExist(this.watchListener),d?(b(!1),document.removeEventListener("motion.gyro",this.watchListener)):m?(g(!1),document.removeEventListener("accelerometerChange",this.watchListener)):window.removeEventListener("deviceorientation",this.watchListener),this.stoped=!0,this.watchListener=void 0},n.pause=function(){this.stoped=!0,m&&g(!1)},n.continue=function(){this.stoped=!1,m&&g(!0,this.options.interval/1e3)},n.isValid=function(t,e){return this.lastX!==t||this.lastY!==e},t}();function g(t,e){window.AlipayJSBridge.call("watchShake",{monitorGyroscope:!1,monitorAccelerometer:!!t,interval:t?parseFloat(e.toFixed(3)):10},function(){})}function b(t,e){window.WindVane.call("WVMotion","listenGyro",{on:t,frequency:e},function(t){console.info("Call WVMotion success.")},function(t){console.error("Call WVMotion failed: "+JSON.stringify(t)+".")})}var y=function(){function t(){this.transformers=[],this.connected=!1,this.accelerMotion=null,this.validRange={alpha:[-60,60],beta:[-80,80],gamma:[-89,89]}}var e=t.prototype;return e.connect=function(){var t=this;this.connected||(this.accelerMotion=new v({X:!0,Y:!0,interval:Math.floor(1e3/60),useRequestAnimationFrame:!0,relativeBeta:!1,relativeGamma:!1,validRange:this.validRange,stableRange:3}),this.accelerMotion.watch(function(e,n,a){var i=a.beta,r=a.gamma;t.dispatchMotion({x:e,y:n,beta:i,gamma:r})})),this.connected=!0},e.disconnect=function(){this.accelerMotion&&this.accelerMotion.unWatch(),this.connected=!1},e.dispatchMotion=function(t){this.transformers.forEach(function(e){return e.update(t)})},e.addTransformer=function(t){this.transformers.includes(t)||this.transformers.push(t)},e.removeTransformer=function(t){var e=this.transformers.indexOf(t);return e>-1&&this.transformers.splice(e,1),0===this.transformers.length},t}(),M=function(t){function e(){var e;return e=t.apply(this,arguments)||this,e.order=90,e.adapter=null,e.handleConnect=function(){if(!w){var t;null==(t=e.adapter)||t.connect()}},e.handleDisconnect=function(){var t;null==(t=e.adapter)||t.disconnect()},e}o(e,t);var n=e.prototype;return n.onCompositionConstructed=function(){var t;this.adapter=R(),null==(t=this.adapter)||t.connect(),this.bindAccelerDocumentEvent()},n.onCompositionReset=function(t){var e,n=t.loaderData.deviceTransformer=new s(t);null==(e=this.adapter)||e.addTransformer(n)},n.onCompositionUpdate=function(t){var e=t.loaderData.deviceTransformer;e&&e.updateOrientation()},n.onCompositionDestroyed=function(t){var e,n;(null==(e=this.adapter)?void 0:e.removeTransformer(t.loaderData.deviceTransformer))&&(null==(n=this.adapter)||n.disconnect())},n.bindAccelerDocumentEvent=function(){this.unbindAccelerDocumentEvent(),document.addEventListener("resume",this.handleConnect,!1),document.addEventListener("pause",this.handleDisconnect,!1),document.addEventListener("back",this.handleDisconnect,!1)},n.unbindAccelerDocumentEvent=function(){document.removeEventListener("resume",this.handleConnect),document.removeEventListener("pause",this.handleDisconnect),document.removeEventListener("back",this.handleDisconnect)},n.dispose=function(){R().disconnect(),this.unbindAccelerDocumentEvent()},e}(e.AbstractPlugin),w=!1;function R(){return a||(a=new y),a}"function"==typeof SuppressedError&&SuppressedError,t.OrientationComponent=function(t){function e(){return t.apply(this,arguments)}o(e,t);var n=e.prototype;return n.fromData=function(e){t.prototype.fromData.call(this,e);var n=e.options.targets;n&&(this.targets=n.map(function(t){return{name:t.name,xMin:+t.xMin||0,yMin:+t.yMin||0,xMax:+t.xMax||0,yMax:+t.yMax||0,vMin:+t.vMin||0,hMin:+t.hMin||0,vMax:+t.vMax||0,hMax:+t.hMax||0}}))},n.start=function(){var t,e,n=null==(t=this.item.composition)?void 0:t.loaderData.deviceTransformer;n&&(null==(e=this.targets)||e.forEach(function(t){return n.addTarget(t)}),n.initComposition())},n.update=function(t){var e,n=null==(e=this.item.composition)?void 0:e.loaderData.deviceTransformer;n&&n.updateOrientation()},n.onDestroy=function(){var t,e=this;null==(t=this.targets)||t.forEach(function(t){var n,a;return null==(a=e.item.composition)?void 0:null==(n=a.loaderData.deviceTransformer)?void 0:n.removeTarget(t.name)})},e}(e.ItemBehaviour),t.OrientationComponent=function(t,e,n,a){var i,r=arguments.length,o=r<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,a);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(o=(r<3?i(o):r>3?i(e,n,o):i(e,n))||o);return r>3&&o&&Object.defineProperty(e,n,o),o}([e.effectsClass("OrientationComponent")],t.OrientationComponent),e.registerPlugin("orientation-transformer",M,e.VFXItem);var x="2.0.0-alpha.21";e.logger.info("Plugin orientation transformer version: "+x+"."),x!==i.version&&console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),t.OrientationAdapterAcceler=y,t.OrientationPluginLoader=M,t.closeDeviceMotion=function(){w=!0,R().disconnect()},t.getAdapter=R,t.openDeviceMotion=function(){w=!1,R().connect()},t.version=x,Object.defineProperty(t,"__esModule",{value:!0})});
6
+ * Version: v2.0.0-alpha.23
7
+ */function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.orientationTransformerPlugin={}),t.ge)}(this,function(t,e){"use strict";var n,a,i=function(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}(e);function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}var s=function(){function t(t){this.composition=t,this.targets={},this.records={},this.currentPos={},this.currentRot={},this.gammaRange=[-89,89],this.betaRange=[-89,89]}var e=t.prototype;return e.update=function(t){var e=t.x,n=t.y,a=t.beta,i=t.gamma;this.currentEvent={x:e,y:n,beta:a,gamma:i}},e.updateOrientation=function(){var t=this,e=this.currentEvent;e&&Object.getOwnPropertyNames(this.targets).forEach(function(n){t.moveLayer(n,e)})},e.initComposition=function(){for(var t=this.composition.items,e=0;e<t.length;e++){var n=t[e];if(this.targets[n.name]){var a=n.transform.position.toArray(),i=n.transform.rotation.toArray(),r=this.currentPos[n.name],o=this.currentRot[n.name];this.records[n.name]={item:n,position:a,rotation:i},r&&n.transform.setPosition(r[0],r[1],r[2]),o&&n.transform.setRotation(o[0],o[1],o[2])}}},e.addTarget=function(t){this.targets[t.name]=t},e.removeTarget=function(t){delete this.targets[t],delete this.records[t]},e.moveLayer=function(t,e){var n=e.x,a=e.y,i=e.beta,r=e.gamma,o=null==(L=this.records[t])?void 0:L.item;if(o){var s=this.records[t].position,l=this.records[t].rotation,u=this.targets[t],h=c(n,this.betaRange),f=c(a,this.gammaRange);if(u){var m,d,p,v,g,b,y,M,w,R,x,O,L,E,A,P=[s[0]+1.2*(d=(h-(m=this.gammaRange[0]))/(this.gammaRange[1]-m),(p=u.xMin)+(u.xMax-p)*d),s[1]+1.2*(g=(f-(v=this.betaRange[0]))/(this.betaRange[1]-v),(b=u.yMin)+(u.yMax-b)*g),s[2]],D=(y=c(.8*r,this.gammaRange),(y-(M=this.gammaRange[0]))/(this.gammaRange[1]-M)),T=(w=c(.8*i,this.betaRange),(w-(R=this.betaRange[0]))/(this.betaRange[1]-R)),j=[l[0]+((x=u.hMin)+(u.hMax-x)*T),l[1]+((O=u.vMin)+(u.vMax-O)*D),l[2]];(E=o.transform).setPosition.apply(E,[].concat(P)),(A=o.transform).setRotation.apply(A,[].concat(j)),this.currentPos[t]=P.slice(),this.currentRot[t]=j.slice()}}},t}();function c(t,e){return t<e[0]?e[0]:t>e[1]?e[1]:t}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t}).apply(this,arguments)}function u(t){return Object.prototype.toString.call(t)}function h(t,e){var n=!0,a=!0,i=!0;if("[object Array]"===u(e.alpha)&&e.alpha.length>=2){var r=t.alpha+e.alpha[0],o=t.alpha+e.alpha[1];n=(r=r<0?r+360:r)<(o=o>360?o-360:o)?t.alpha>r&&t.alpha<o:t.alpha>r||t.alpha<o}return"[object Array]"===u(e.beta)&&e.beta.length>=2&&(a=t.beta>=e.beta[0]&&t.beta<=e.beta[1]),"[object Array]"===u(e.gamma)&&e.gamma.length>=2&&(i=t.gamma>=e.gamma[0]&&t.gamma<=e.gamma[1]),n&&a&&i}var f=function(){function t(t){void 0===t&&(t={}),this.options=t,this.lastValue=0,this.valuePool=[]}var e=t.prototype;return e.stableFix=function(t){var e=this.options.stableRange||3;return Math.abs(t)<e?0:t>e?t-e:t+e},e.changeLimit=function(t){var e=this.lastValue,n=t;return Math.abs(t-e)>5&&(n=e<t?e+5:e-5),1>Math.abs(t-e)&&(n=e),this.lastValue=n,n},e.linearRegressionMedian=function(t){var e,n,a;return this.valuePool.push(t),this.valuePool.length>=5?(a=function(t){var e=[],n=[];t.forEach(function(t,a){e.push(a),n.push(t)});var a=function(t,e){for(var n={},a=e.length,i=0,r=0,o=0,s=0,c=0,l=0;l<e.length;l++)i+=t[l],r+=e[l],o+=t[l]*e[l],s+=t[l]*t[l],c+=e[l]*e[l];var u=i/a,h=r/a;return n.a=(o-a*u*h)/(s-a*u*u),n.b=h-n.a*u,n.miss=Math.pow((a*o-i*r)/Math.sqrt((a*s-i*i)*(a*c-r*r)),2),n}(e,n);return function(t){return a.a*t+a.b}}(n=this.valuePool),n=n.map(function(t,e){return a(e)}),e=a(n.length/2),this.valuePool.shift()):e=this.lastValue,e},t}(),m=((n=navigator.userAgent.toLowerCase().match(/cpu (iphone )?os (.*?) like mac os/))?parseInt(n[2],10):0)&&void 0!==window.AlipayJSBridge,d=void 0!==window.WindVane,p={X:!0,Y:!0,interval:Math.floor(1e3/30),useRequestAnimationFrame:!0,relativeBeta:!1,relativeGamma:!1,validRange:{alpha:[-60,60],beta:[-60,180],gamma:[-89,89]},stableRange:3},v=function(){function t(t){void 0===t&&(t={}),this.lastX=0,this.lastY=0,this.prevAcceler={x:0,y:0,z:0},this.stoped=!1;var e=l({},p.validRange,t.validRange),n=l({},p,t);n.validRange=e,this.options=n;var a=this.options.stableRange;this.filterX=new f({stableRange:a}),this.filterY=new f({stableRange:a})}var n=t.prototype;return n.watch=function(t){var e,n,a,i,r,o,s=this;if("function"==typeof t&&!this.watchListener){var c,l=0,u=0,f=NaN,p=NaN,v=function(c){!s.stoped&&(e=c.alpha,n=c.beta,a=c.gamma,i=h.call(s,{alpha:e,beta:n,gamma:a},s.options.validRange),isNaN(f)&&(f=a,s.filterX.lastValue=a),isNaN(p)&&(p=n,s.filterY.lastValue=n),i&&(s.options.X?(r=s.options.relativeGamma?a-f:a,r=s.filterX.stableFix(r),r=s.filterX.changeLimit(r),r=s.filterX.linearRegressionMedian(+r)):r=0,s.options.Y?(o=s.options.relativeBeta?n-p:n,o=s.filterY.stableFix(o),o=s.filterY.changeLimit(o),o=s.filterY.linearRegressionMedian(+o)):o=0,s.isValid(r,o)&&(s.options.useRequestAnimationFrame?window.requestAnimationFrame(function(){t(r,o,{alpha:e,beta:o-p,gamma:r-f})}):t(r,o,{alpha:e,beta:o-p,gamma:r-f}),s.lastX=r,s.lastY=o)))};this.stoped=!1,d?(b(!0,this.options.interval),this.watchListener=function(t){if("param"in t){var e=t.param,n=e.x,a=e.y,i=e.z;(n!==s.prevAcceler.x||a!==s.prevAcceler.y||i!==s.prevAcceler.z)&&(s.prevAcceler={x:n,y:a,z:i},v({alpha:180*+i,beta:-90*+a,gamma:90*+n}))}},document.addEventListener("motion.gyro",this.watchListener,!1)):m&&!("undefined"!=typeof my&&(null==(c=my)?void 0:c.renderTarget)==="web"||"miniprogram"===window.__wxjs_environment)?(g(!0,this.options.interval/1e3),this.watchListener=function(t){if(t&&"data"in t){var e=t.data,n=e.x,a=e.y;v({alpha:180*e.z,beta:-90*a,gamma:90*n})}},document.addEventListener("accelerometerChange",this.watchListener,!1)):(this.watchListener=function(t){(u=new Date().getTime())-l>=s.options.interval&&(l=u,v(t))},window.addEventListener("deviceorientation",this.watchListener,!1))}},n.unWatch=function(){e.assertExist(this.watchListener),d?(b(!1),document.removeEventListener("motion.gyro",this.watchListener)):m?(g(!1),document.removeEventListener("accelerometerChange",this.watchListener)):window.removeEventListener("deviceorientation",this.watchListener),this.stoped=!0,this.watchListener=void 0},n.pause=function(){this.stoped=!0,m&&g(!1)},n.continue=function(){this.stoped=!1,m&&g(!0,this.options.interval/1e3)},n.isValid=function(t,e){return this.lastX!==t||this.lastY!==e},t}();function g(t,e){window.AlipayJSBridge.call("watchShake",{monitorGyroscope:!1,monitorAccelerometer:!!t,interval:t?parseFloat(e.toFixed(3)):10},function(){})}function b(t,e){window.WindVane.call("WVMotion","listenGyro",{on:t,frequency:e},function(t){console.info("Call WVMotion success.")},function(t){console.error("Call WVMotion failed: "+JSON.stringify(t)+".")})}var y=function(){function t(){this.transformers=[],this.connected=!1,this.accelerMotion=null,this.validRange={alpha:[-60,60],beta:[-80,80],gamma:[-89,89]}}var e=t.prototype;return e.connect=function(){var t=this;this.connected||(this.accelerMotion=new v({X:!0,Y:!0,interval:Math.floor(1e3/60),useRequestAnimationFrame:!0,relativeBeta:!1,relativeGamma:!1,validRange:this.validRange,stableRange:3}),this.accelerMotion.watch(function(e,n,a){var i=a.beta,r=a.gamma;t.dispatchMotion({x:e,y:n,beta:i,gamma:r})})),this.connected=!0},e.disconnect=function(){this.accelerMotion&&this.accelerMotion.unWatch(),this.connected=!1},e.dispatchMotion=function(t){this.transformers.forEach(function(e){return e.update(t)})},e.addTransformer=function(t){this.transformers.includes(t)||this.transformers.push(t)},e.removeTransformer=function(t){var e=this.transformers.indexOf(t);return e>-1&&this.transformers.splice(e,1),0===this.transformers.length},t}(),M=function(t){function e(){var e;return e=t.apply(this,arguments)||this,e.order=90,e.adapter=null,e.handleConnect=function(){if(!w){var t;null==(t=e.adapter)||t.connect()}},e.handleDisconnect=function(){var t;null==(t=e.adapter)||t.disconnect()},e}o(e,t);var n=e.prototype;return n.onCompositionConstructed=function(){var t;this.adapter=R(),null==(t=this.adapter)||t.connect(),this.bindAccelerDocumentEvent()},n.onCompositionReset=function(t){var e,n=t.loaderData.deviceTransformer=new s(t);null==(e=this.adapter)||e.addTransformer(n)},n.onCompositionUpdate=function(t){var e=t.loaderData.deviceTransformer;e&&e.updateOrientation()},n.onCompositionDestroyed=function(t){var e,n;(null==(e=this.adapter)?void 0:e.removeTransformer(t.loaderData.deviceTransformer))&&(null==(n=this.adapter)||n.disconnect())},n.bindAccelerDocumentEvent=function(){this.unbindAccelerDocumentEvent(),document.addEventListener("resume",this.handleConnect,!1),document.addEventListener("pause",this.handleDisconnect,!1),document.addEventListener("back",this.handleDisconnect,!1)},n.unbindAccelerDocumentEvent=function(){document.removeEventListener("resume",this.handleConnect),document.removeEventListener("pause",this.handleDisconnect),document.removeEventListener("back",this.handleDisconnect)},n.dispose=function(){R().disconnect(),this.unbindAccelerDocumentEvent()},e}(e.AbstractPlugin),w=!1;function R(){return a||(a=new y),a}"function"==typeof SuppressedError&&SuppressedError,t.OrientationComponent=function(t){function e(){return t.apply(this,arguments)}o(e,t);var n=e.prototype;return n.fromData=function(e){t.prototype.fromData.call(this,e);var n=e.options.targets;n&&(this.targets=n.map(function(t){return{name:t.name,xMin:+t.xMin||0,yMin:+t.yMin||0,xMax:+t.xMax||0,yMax:+t.yMax||0,vMin:+t.vMin||0,hMin:+t.hMin||0,vMax:+t.vMax||0,hMax:+t.hMax||0}}))},n.start=function(){var t,e,n=null==(t=this.item.composition)?void 0:t.loaderData.deviceTransformer;n&&(null==(e=this.targets)||e.forEach(function(t){return n.addTarget(t)}),n.initComposition())},n.update=function(t){var e,n=null==(e=this.item.composition)?void 0:e.loaderData.deviceTransformer;n&&n.updateOrientation()},n.onDestroy=function(){var t,e=this;null==(t=this.targets)||t.forEach(function(t){var n,a;return null==(a=e.item.composition)?void 0:null==(n=a.loaderData.deviceTransformer)?void 0:n.removeTarget(t.name)})},e}(e.ItemBehaviour),t.OrientationComponent=function(t,e,n,a){var i,r=arguments.length,o=r<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,a);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(o=(r<3?i(o):r>3?i(e,n,o):i(e,n))||o);return r>3&&o&&Object.defineProperty(e,n,o),o}([e.effectsClass("OrientationComponent")],t.OrientationComponent),e.registerPlugin("orientation-transformer",M,e.VFXItem);var x="2.0.0-alpha.23";e.logger.info("Plugin orientation transformer version: "+x+"."),x!==i.version&&console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),t.OrientationAdapterAcceler=y,t.OrientationPluginLoader=M,t.closeDeviceMotion=function(){w=!0,R().disconnect()},t.getAdapter=R,t.openDeviceMotion=function(){w=!1,R().connect()},t.version=x,Object.defineProperty(t,"__esModule",{value:!0})});
8
8
  //# sourceMappingURL=index.min.js.map
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects player orientation transformer plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,意绮
6
- * Version: v2.0.0-alpha.21
6
+ * Version: v2.0.0-alpha.23
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
@@ -794,7 +794,7 @@ OrientationComponent = __decorate([
794
794
  ], OrientationComponent);
795
795
 
796
796
  registerPlugin("orientation-transformer", OrientationPluginLoader, VFXItem);
797
- var version = "2.0.0-alpha.21";
797
+ var version = "2.0.0-alpha.23";
798
798
  logger.info("Plugin orientation transformer version: " + version + ".");
799
799
  if (version !== EFFECTS.version) {
800
800
  console.error("注意:请统一 Orientation Transformer 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Orientation Transformer plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-plugin-orientation-transformer",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.23",
4
4
  "description": "Galacean Effects player orientation transformer plugin",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "registry": "https://registry.npmjs.org"
44
44
  },
45
45
  "devDependencies": {
46
- "@galacean/effects": "2.0.0-alpha.21"
46
+ "@galacean/effects": "2.0.0-alpha.23"
47
47
  },
48
48
  "scripts": {
49
49
  "dev": "vite",