@galacean/effects-plugin-orientation-transformer 2.0.0-alpha.3 → 2.0.0-alpha.30

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.mjs CHANGED
@@ -3,160 +3,136 @@
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.3
6
+ * Version: v2.0.0-alpha.30
7
7
  */
8
8
 
9
- import { isObject, isArray, assertExist, AbstractPlugin, ItemBehaviour, VFXItem, registerPlugin, logger } from '@galacean/effects';
9
+ import * as EFFECTS from '@galacean/effects';
10
+ import { isArray, isIOSByUA, isMiniProgram, assertExist, AbstractPlugin, effectsClass, ItemBehaviour, registerPlugin, VFXItem, logger } from '@galacean/effects';
10
11
 
11
- /******************************************************************************
12
- Copyright (c) Microsoft Corporation.
13
-
14
- Permission to use, copy, modify, and/or distribute this software for any
15
- purpose with or without fee is hereby granted.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
- PERFORMANCE OF THIS SOFTWARE.
24
- ***************************************************************************** */
25
- /* global Reflect, Promise, SuppressedError, Symbol */
26
-
27
- var extendStatics = function(d, b) {
28
- extendStatics = Object.setPrototypeOf ||
29
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
31
- return extendStatics(d, b);
32
- };
33
-
34
- function __extends(d, b) {
35
- if (typeof b !== "function" && b !== null)
36
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
37
- extendStatics(d, b);
38
- function __() { this.constructor = d; }
39
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40
- }
41
-
42
- var __assign = function() {
43
- __assign = Object.assign || function __assign(t) {
44
- for (var s, i = 1, n = arguments.length; i < n; i++) {
45
- s = arguments[i];
46
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47
- }
48
- return t;
49
- };
50
- return __assign.apply(this, arguments);
51
- };
52
-
53
- function __read(o, n) {
54
- var m = typeof Symbol === "function" && o[Symbol.iterator];
55
- if (!m) return o;
56
- var i = m.call(o), r, ar = [], e;
57
- try {
58
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
59
- }
60
- catch (error) { e = { error: error }; }
61
- finally {
62
- try {
63
- if (r && !r.done && (m = i["return"])) m.call(i);
64
- }
65
- finally { if (e) throw e.error; }
66
- }
67
- return ar;
68
- }
69
-
70
- function __spreadArray(to, from, pack) {
71
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
72
- if (ar || !(i in from)) {
73
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
74
- ar[i] = from[i];
75
- }
76
- }
77
- return to.concat(ar || Array.prototype.slice.call(from));
78
- }
79
-
80
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
81
- var e = new Error(message);
82
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
83
- };
12
+ function _set_prototype_of(o, p) {
13
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
14
+ o.__proto__ = p;
15
+ return o;
16
+ };
17
+ return _set_prototype_of(o, p);
18
+ }
84
19
 
85
- var CompositionTransformerAcceler = /** @class */ (function () {
20
+ function _inherits(subClass, superClass) {
21
+ if (typeof superClass !== "function" && superClass !== null) {
22
+ throw new TypeError("Super expression must either be null or a function");
23
+ }
24
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
25
+ constructor: {
26
+ value: subClass,
27
+ writable: true,
28
+ configurable: true
29
+ }
30
+ });
31
+ if (superClass) _set_prototype_of(subClass, superClass);
32
+ }
33
+
34
+ var CompositionTransformerAcceler = /*#__PURE__*/ function() {
86
35
  function CompositionTransformerAcceler(composition) {
87
36
  this.composition = composition;
88
37
  this.targets = {};
89
38
  this.records = {};
90
- this.current = {};
91
- this.gammaRange = [-89, 89];
92
- this.betaRange = [-80, 80];
39
+ this.currentPos = {};
40
+ this.currentRot = {};
41
+ this.gammaRange = [
42
+ -89,
43
+ 89
44
+ ];
45
+ this.betaRange = [
46
+ -89,
47
+ 89
48
+ ];
93
49
  }
94
- CompositionTransformerAcceler.prototype.update = function (_a) {
95
- var x = _a.x, y = _a.y;
96
- this.currentEvent = { x: x, y: y };
50
+ var _proto = CompositionTransformerAcceler.prototype;
51
+ _proto.update = function update(param) {
52
+ var x = param.x, y = param.y, beta = param.beta, gamma = param.gamma;
53
+ this.currentEvent = {
54
+ x: x,
55
+ y: y,
56
+ beta: beta,
57
+ gamma: gamma
58
+ };
97
59
  };
98
- CompositionTransformerAcceler.prototype.updateOrientation = function () {
60
+ _proto.updateOrientation = function updateOrientation() {
99
61
  var _this = this;
100
62
  var event = this.currentEvent;
101
63
  if (event) {
102
- Object.getOwnPropertyNames(this.targets).forEach(function (name) {
64
+ Object.getOwnPropertyNames(this.targets).forEach(function(name) {
103
65
  _this.moveLayer(name, event);
104
66
  });
105
67
  }
106
68
  };
107
- CompositionTransformerAcceler.prototype.initComposition = function () {
69
+ _proto.initComposition = function initComposition() {
108
70
  var items = this.composition.items;
109
- for (var i = 0; i < items.length; i++) {
71
+ for(var i = 0; i < items.length; i++){
110
72
  var item = items[i];
111
73
  var target = this.targets[item.name];
112
74
  if (target) {
113
75
  var position = item.transform.position.toArray();
114
- var currentPosition = this.current[item.name];
76
+ var rotation = item.transform.rotation.toArray();
77
+ var currentPosition = this.currentPos[item.name];
78
+ var currentRot = this.currentRot[item.name];
115
79
  this.records[item.name] = {
116
80
  item: item,
117
81
  position: position,
82
+ rotation: rotation
118
83
  };
119
84
  if (currentPosition) {
120
- var _a = __read(currentPosition, 3), x = _a[0], y = _a[1], z = _a[2];
121
- item.transform.setPosition(x, y, z);
85
+ item.transform.setPosition(currentPosition[0], currentPosition[1], currentPosition[2]);
86
+ }
87
+ if (currentRot) {
88
+ item.transform.setRotation(currentRot[0], currentRot[1], currentRot[2]);
122
89
  }
123
90
  }
124
91
  }
125
92
  };
126
- CompositionTransformerAcceler.prototype.addTarget = function (target) {
93
+ _proto.addTarget = function addTarget(target) {
127
94
  this.targets[target.name] = target;
128
95
  };
129
- CompositionTransformerAcceler.prototype.removeTarget = function (name) {
96
+ _proto.removeTarget = function removeTarget(name) {
130
97
  delete this.targets[name];
131
98
  delete this.records[name];
132
99
  };
133
- CompositionTransformerAcceler.prototype.moveLayer = function (name, _a) {
134
- var _b;
135
- var _c;
136
- var x = _a.x, y = _a.y;
137
- var layer = (_c = this.records[name]) === null || _c === void 0 ? void 0 : _c.item;
100
+ _proto.moveLayer = function moveLayer(name, param) {
101
+ var x = param.x, y = param.y, b = param.beta, g = param.gamma;
102
+ var _this_records_name;
103
+ var layer = (_this_records_name = this.records[name]) == null ? void 0 : _this_records_name.item;
138
104
  if (layer) {
139
105
  var initPosition = this.records[name].position;
106
+ var initRotation = this.records[name].rotation;
140
107
  var target = this.targets[name];
141
108
  var beta = clamp(x, this.betaRange), gamma = clamp(y, this.gammaRange);
142
109
  if (target) {
110
+ var _layer_transform, _layer_transform1;
143
111
  var position = [
144
- initPosition[0] + 1.2 * mapRange((beta - this.gammaRange[0]) / (this.gammaRange[1] - this.gammaRange[0]), target.xMin, target.xMax),
145
- initPosition[1] + 1.2 * mapRange((gamma - this.betaRange[0]) / (this.betaRange[1] - this.betaRange[0]), target.yMin, target.yMax),
146
- initPosition[2],
112
+ initPosition[0] + 1.2 * mapRange(normalize(beta, this.gammaRange[0], this.gammaRange[1]), target.xMin, target.xMax),
113
+ initPosition[1] + 1.2 * mapRange(normalize(gamma, this.betaRange[0], this.betaRange[1]), target.yMin, target.yMax),
114
+ initPosition[2]
115
+ ];
116
+ var br = normalize(clamp(g * 0.8, this.gammaRange), this.gammaRange[0], this.gammaRange[1]);
117
+ var gr = normalize(clamp(b * 0.8, this.betaRange), this.betaRange[0], this.betaRange[1]);
118
+ var rotation = [
119
+ initRotation[0] + mapRange(gr, target.hMin, target.hMax),
120
+ initRotation[1] + mapRange(br, target.vMin, target.vMax),
121
+ initRotation[2]
147
122
  ];
148
- (_b = layer.transform).setPosition.apply(_b, __spreadArray([], __read(position), false));
149
- this.current[name] = position.slice();
123
+ (_layer_transform = layer.transform).setPosition.apply(_layer_transform, [].concat(position));
124
+ (_layer_transform1 = layer.transform).setRotation.apply(_layer_transform1, [].concat(rotation));
125
+ this.currentPos[name] = position.slice();
126
+ this.currentRot[name] = rotation.slice();
150
127
  }
151
128
  }
152
129
  };
153
130
  return CompositionTransformerAcceler;
154
- }());
131
+ }();
155
132
  function clamp(x, range) {
156
133
  if (x < range[0]) {
157
134
  return range[0];
158
- }
159
- else if (x > range[1]) {
135
+ } else if (x > range[1]) {
160
136
  return range[1];
161
137
  }
162
138
  return x;
@@ -164,9 +140,19 @@ function clamp(x, range) {
164
140
  function mapRange(t, min, max) {
165
141
  return min + (max - min) * t;
166
142
  }
143
+ function normalize(a, min, max) {
144
+ return (a - min) / (max - min);
145
+ }
167
146
 
168
- function getObjectType(obj) {
169
- return Object.prototype.toString.call(obj);
147
+ function _extends() {
148
+ _extends = Object.assign || function assign(target) {
149
+ for(var i = 1; i < arguments.length; i++){
150
+ var source = arguments[i];
151
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
152
+ }
153
+ return target;
154
+ };
155
+ return _extends.apply(this, arguments);
170
156
  }
171
157
 
172
158
  /**
@@ -174,117 +160,59 @@ function getObjectType(obj) {
174
160
  * @internal
175
161
  * @param angleObj 角度数值对象
176
162
  * @param validRange 角度限制值
177
- */
178
- function angleLimit(angleObj, validRange) {
163
+ */ function angleLimit(angleObj, validRange) {
179
164
  var flagAlpha = true;
180
165
  var flagBeta = true;
181
166
  var flagGamma = true;
182
- if (getObjectType(validRange.alpha) === '[object Array]' && validRange.alpha.length >= 2) {
167
+ if (isArray(validRange.alpha) && validRange.alpha.length >= 2) {
183
168
  var referAlphaA = angleObj.alpha + validRange.alpha[0];
184
169
  var referAlphaB = angleObj.alpha + validRange.alpha[1];
185
170
  referAlphaA = referAlphaA < 0 ? referAlphaA + 360 : referAlphaA;
186
171
  referAlphaB = referAlphaB > 360 ? referAlphaB - 360 : referAlphaB;
187
172
  if (referAlphaA < referAlphaB) {
188
173
  flagAlpha = angleObj.alpha > referAlphaA && angleObj.alpha < referAlphaB;
189
- }
190
- else {
174
+ } else {
191
175
  flagAlpha = angleObj.alpha > referAlphaA || angleObj.alpha < referAlphaB;
192
176
  }
193
177
  }
194
- if (getObjectType(validRange.beta) === '[object Array]' && validRange.beta.length >= 2) {
178
+ if (isArray(validRange.beta) && validRange.beta.length >= 2) {
195
179
  flagBeta = angleObj.beta >= validRange.beta[0] && angleObj.beta <= validRange.beta[1];
196
180
  }
197
- if (getObjectType(validRange.gamma) === '[object Array]' && validRange.gamma.length >= 2) {
181
+ if (isArray(validRange.gamma) && validRange.gamma.length >= 2) {
198
182
  flagGamma = angleObj.gamma >= validRange.gamma[0] && angleObj.gamma <= validRange.gamma[1];
199
183
  }
200
184
  return flagAlpha && flagBeta && flagGamma;
201
185
  }
202
186
 
203
- function deepMerge(target, args) {
204
- if (!isObject(target) && !isArray(target)) {
205
- return target;
206
- }
207
- var result = isArray(target) ? __spreadArray([], __read(target), false) : __assign({}, target);
208
- var length = arguments.length;
209
- for (var index = 1; index < length; index++) {
210
- var source = arguments[index] || {};
211
- if (isObject(source)) {
212
- var prop = void 0;
213
- for (prop in source) {
214
- if (source.hasOwnProperty(prop)) {
215
- if (isObject(result[prop]) && isObject(source[prop])) {
216
- result[prop] = deepMerge(result[prop], source[prop]);
217
- }
218
- else if (isObject(source[prop])) {
219
- result[prop] = deepMerge(source[prop]);
220
- }
221
- else if (isArray(source[prop])) {
222
- result[prop] = deepMerge(source[prop]);
223
- }
224
- else {
225
- result[prop] = source[prop];
226
- }
227
- }
228
- }
229
- for (prop in result) {
230
- if (isObject(result[prop]) &&
231
- result.hasOwnProperty(prop) &&
232
- !source.hasOwnProperty(prop)) {
233
- result[prop] = deepMerge(result[prop]);
234
- }
235
- }
236
- }
237
- }
238
- if (length === 1) {
239
- for (var prop in result) {
240
- if (isObject(result[prop]) && result.hasOwnProperty(prop)) {
241
- result[prop] = deepMerge(result[prop]);
242
- }
243
- }
244
- }
245
- return result;
246
- }
247
-
248
- function isIOS() {
249
- var str = navigator.userAgent.toLowerCase();
250
- var ver = str.match(/cpu (iphone )?os (.*?) like mac os/);
251
- return ver ? parseInt(ver[2], 10) : 0;
252
- }
253
-
254
187
  /**
255
188
  * 稳定区间
256
- */
257
- var STABLE_RANGE = 3;
189
+ */ var STABLE_RANGE = 3;
258
190
  /**
259
191
  * 每次增幅的最大值
260
- */
261
- var MAX_CHANGE = 5;
192
+ */ var MAX_CHANGE = 5;
262
193
  /**
263
194
  * 每次增幅的最小值
264
- */
265
- var MIN_CHANGE = 1;
195
+ */ var MIN_CHANGE = 1;
266
196
  /**
267
197
  * 数据缓存队列的长度
268
- */
269
- var VALUE_POOL_LENGTH = 5;
198
+ */ var VALUE_POOL_LENGTH = 5;
270
199
  /**
271
200
  * 滤波方法
272
- */
273
- var Filtering = /** @class */ (function () {
201
+ */ var Filtering = /*#__PURE__*/ function() {
274
202
  function Filtering(options) {
275
- if (options === void 0) { options = {}; }
203
+ if (options === void 0) options = {};
276
204
  this.options = options;
277
205
  this.lastValue = 0;
278
206
  this.valuePool = [];
279
207
  }
208
+ var _proto = Filtering.prototype;
280
209
  /**
281
- * 0deg 左右保持一定的稳定区间 STABLE_RANGE
282
- * - 小于 STABLE_RANGE 的算 0
283
- * - 大于 STABLE_RANGE 的减去 STABLE_RANGE
284
- * @param value - 输入值
285
- * @returns
286
- */
287
- Filtering.prototype.stableFix = function (value) {
210
+ * 0deg 左右保持一定的稳定区间 STABLE_RANGE
211
+ * - 小于 STABLE_RANGE 的算 0
212
+ * - 大于 STABLE_RANGE 的减去 STABLE_RANGE
213
+ * @param value - 输入值
214
+ * @returns
215
+ */ _proto.stableFix = function stableFix(value) {
288
216
  var stableRange = this.options.stableRange || STABLE_RANGE;
289
217
  if (Math.abs(value) < stableRange) {
290
218
  return 0;
@@ -292,13 +220,12 @@ var Filtering = /** @class */ (function () {
292
220
  return value > stableRange ? value - stableRange : value + stableRange;
293
221
  };
294
222
  /**
295
- * 变幅限制
296
- * - 最大变化 MAX_CHANGE
297
- * - 最小变化 MIN_CHANGE
298
- * @param value
299
- * @returns
300
- */
301
- Filtering.prototype.changeLimit = function (value) {
223
+ * 变幅限制
224
+ * - 最大变化 MAX_CHANGE
225
+ * - 最小变化 MIN_CHANGE
226
+ * @param value
227
+ * @returns
228
+ */ _proto.changeLimit = function changeLimit(value) {
302
229
  var lastValue = this.lastValue;
303
230
  var result = value;
304
231
  if (Math.abs(value - lastValue) > MAX_CHANGE) {
@@ -310,21 +237,20 @@ var Filtering = /** @class */ (function () {
310
237
  this.lastValue = result;
311
238
  return result;
312
239
  };
313
- Filtering.prototype.linearRegressionMedian = function (value) {
240
+ _proto.linearRegressionMedian = function linearRegressionMedian(value) {
314
241
  // 在队列中装载数据,达到队列阀值长度时开始计算
315
242
  this.valuePool.push(value);
316
243
  var result;
317
244
  if (this.valuePool.length >= VALUE_POOL_LENGTH) {
318
245
  result = getLinearRegressionFixedVal(this.valuePool);
319
246
  this.valuePool.shift();
320
- }
321
- else {
247
+ } else {
322
248
  result = this.lastValue;
323
249
  }
324
250
  return result;
325
251
  };
326
252
  return Filtering;
327
- }());
253
+ }();
328
254
  // 计算出线性回归参数
329
255
  function linearRegression(x, y) {
330
256
  var result = {};
@@ -334,30 +260,30 @@ function linearRegression(x, y) {
334
260
  var sumXY = 0;
335
261
  var sumXX = 0;
336
262
  var sumYY = 0;
337
- for (var i = 0; i < y.length; i++) {
263
+ for(var i = 0; i < y.length; i++){
338
264
  sumX += x[i];
339
265
  sumY += y[i];
340
- sumXY += (x[i] * y[i]);
341
- sumXX += (x[i] * x[i]);
342
- sumYY += (y[i] * y[i]);
266
+ sumXY += x[i] * y[i];
267
+ sumXX += x[i] * x[i];
268
+ sumYY += y[i] * y[i];
343
269
  }
344
270
  var avgX = sumX / n;
345
271
  var avgY = sumY / n;
346
- result['a'] = (sumXY - n * avgX * avgY) / (sumXX - n * avgX * avgX);
347
- result['b'] = avgY - result.a * avgX;
348
- result['miss'] = Math.pow((n * sumXY - sumX * sumY) / Math.sqrt((n * sumXX - sumX * sumX) * (n * sumYY - sumY * sumY)), 2);
272
+ result["a"] = (sumXY - n * avgX * avgY) / (sumXX - n * avgX * avgX);
273
+ result["b"] = avgY - result.a * avgX;
274
+ result["miss"] = Math.pow((n * sumXY - sumX * sumY) / Math.sqrt((n * sumXX - sumX * sumX) * (n * sumYY - sumY * sumY)), 2);
349
275
  return result;
350
276
  }
351
277
  // 生成线性回归函数 F(x) = ax + b
352
278
  function createLinearRegressionFx(values) {
353
279
  var x = [];
354
280
  var y = [];
355
- values.forEach(function (item, index) {
281
+ values.forEach(function(item, index) {
356
282
  x.push(index); // 数据是连续的,所以直接取数组下标为 x
357
283
  y.push(item);
358
284
  });
359
285
  var key = linearRegression(x, y);
360
- return function (x) {
286
+ return function(x) {
361
287
  return key.a * x + key.b;
362
288
  };
363
289
  }
@@ -365,14 +291,14 @@ function createLinearRegressionFx(values) {
365
291
  function getLinearRegressionFixedVal(valuePool) {
366
292
  var fx = createLinearRegressionFx(valuePool);
367
293
  // 这个迭代修正很重要
368
- valuePool = valuePool.map(function (item, index) {
294
+ valuePool = valuePool.map(function(item, index) {
369
295
  return fx(index);
370
296
  });
371
297
  return fx(valuePool.length / 2);
372
298
  }
373
299
 
374
- var useJSBridge = isIOS() && typeof window.AlipayJSBridge !== 'undefined';
375
- var useWindVane = typeof window.WindVane !== 'undefined';
300
+ var useJSBridge = isIOSByUA() && typeof window.AlipayJSBridge !== "undefined";
301
+ var useWindVane = typeof window.WindVane !== "undefined";
376
302
  // 默认参数
377
303
  var defaultOptions = {
378
304
  X: true,
@@ -382,31 +308,49 @@ var defaultOptions = {
382
308
  relativeBeta: false,
383
309
  relativeGamma: false,
384
310
  validRange: {
385
- alpha: [-60, 60],
386
- beta: [-60, 180],
387
- gamma: [-89, 89],
311
+ alpha: [
312
+ -60,
313
+ 60
314
+ ],
315
+ beta: [
316
+ -60,
317
+ 180
318
+ ],
319
+ gamma: [
320
+ -89,
321
+ 89
322
+ ]
388
323
  },
389
- stableRange: 3,
324
+ stableRange: 3
390
325
  };
391
- var DeviceOrientation = /** @class */ (function () {
326
+ var DeviceOrientation = /*#__PURE__*/ function() {
392
327
  function DeviceOrientation(options) {
393
- if (options === void 0) { options = {}; }
328
+ if (options === void 0) options = {};
394
329
  this.lastX = 0;
395
330
  this.lastY = 0;
396
331
  this.prevAcceler = {
397
332
  x: 0,
398
333
  y: 0,
399
- z: 0,
334
+ z: 0
400
335
  };
401
336
  this.stoped = false;
402
- this.options = deepMerge(defaultOptions, options);
337
+ // 模拟简单的 deep merge
338
+ var validRange = _extends({}, defaultOptions.validRange, options.validRange);
339
+ var mergeOptions = _extends({}, defaultOptions, options);
340
+ mergeOptions.validRange = validRange;
341
+ this.options = mergeOptions;
403
342
  var stableRange = this.options.stableRange;
404
- this.filterX = new Filtering({ stableRange: stableRange });
405
- this.filterY = new Filtering({ stableRange: stableRange });
343
+ this.filterX = new Filtering({
344
+ stableRange: stableRange
345
+ });
346
+ this.filterY = new Filtering({
347
+ stableRange: stableRange
348
+ });
406
349
  }
407
- DeviceOrientation.prototype.watch = function (callback) {
350
+ var _proto = DeviceOrientation.prototype;
351
+ _proto.watch = function watch(callback) {
408
352
  var _this = this;
409
- if (typeof callback !== 'function') {
353
+ if (typeof callback !== "function") {
410
354
  return;
411
355
  }
412
356
  // 目前只能绑定一个方法,此处可以扩展成一个方法队列
@@ -415,66 +359,67 @@ var DeviceOrientation = /** @class */ (function () {
415
359
  }
416
360
  var timefragment = 0; // 时间片计时
417
361
  var nowts = 0; // 当前时间
418
- var referGamma = 0; // 初始化角度,作为单独一个用户的空间旋转的参照
419
- var referBeta = 0;
362
+ // 初始化角度,作为单独一个用户的空间旋转的参照
363
+ var referGamma = NaN, referBeta = NaN;
420
364
  var alpha;
421
365
  var beta;
422
366
  var gamma;
423
- var gammaFixed;
424
- var betaFixed;
425
367
  var isInValidDegRange;
426
368
  var x; // 最终输出的 x
427
369
  var y; // 最终输出的 y
428
- var handleWatch = function (e) {
370
+ var handleWatch = function(e) {
429
371
  if (_this.stoped) {
430
372
  return;
431
373
  }
432
374
  alpha = e.alpha; // 垂直于屏幕的轴 0 ~ 360
433
375
  beta = e.beta; // 横向 X 轴 -180 ~ 180
434
376
  gamma = e.gamma; // 纵向 Y 轴 -90 ~ 90
435
- if (!referBeta) {
436
- referBeta = beta || 0;
437
- }
438
- if (!referGamma) {
439
- referGamma = gamma || 0;
440
- }
441
- //
442
377
  isInValidDegRange = angleLimit.call(_this, {
443
378
  alpha: alpha,
444
379
  beta: beta,
445
- gamma: gamma,
380
+ gamma: gamma
446
381
  }, _this.options.validRange);
382
+ if (isNaN(referGamma)) {
383
+ referGamma = gamma;
384
+ _this.filterX.lastValue = gamma;
385
+ }
386
+ if (isNaN(referBeta)) {
387
+ referBeta = beta;
388
+ _this.filterY.lastValue = beta;
389
+ }
447
390
  if (isInValidDegRange) {
448
391
  // 最终结果值
449
392
  if (_this.options.X) {
450
- gammaFixed = gamma - referGamma;
451
- x = _this.options.relativeGamma ? gammaFixed : gamma;
393
+ x = _this.options.relativeGamma ? gamma - referGamma : gamma;
452
394
  x = _this.filterX.stableFix(x);
453
395
  x = _this.filterX.changeLimit(x);
454
396
  x = _this.filterX.linearRegressionMedian(+x);
455
- }
456
- else {
397
+ } else {
457
398
  x = 0;
458
399
  }
459
400
  if (_this.options.Y) {
460
- // beta 相对 referBeta 的角度
461
- betaFixed = beta - referBeta;
462
- y = _this.options.relativeBeta ? betaFixed : beta;
401
+ y = _this.options.relativeBeta ? beta - referBeta : beta;
463
402
  y = _this.filterY.stableFix(y);
464
403
  y = _this.filterY.changeLimit(y);
465
404
  y = _this.filterY.linearRegressionMedian(+y);
466
- }
467
- else {
405
+ } else {
468
406
  y = 0;
469
407
  }
470
408
  if (_this.isValid(x, y)) {
471
409
  if (_this.options.useRequestAnimationFrame) {
472
- window.requestAnimationFrame(function () {
473
- callback(x, y, { alpha: alpha, beta: beta, gamma: gamma });
410
+ window.requestAnimationFrame(function() {
411
+ callback(x, y, {
412
+ alpha: alpha,
413
+ beta: y - referBeta,
414
+ gamma: x - referGamma
415
+ });
416
+ });
417
+ } else {
418
+ callback(x, y, {
419
+ alpha: alpha,
420
+ beta: y - referBeta,
421
+ gamma: x - referGamma
474
422
  });
475
- }
476
- else {
477
- callback(x, y, { alpha: alpha, beta: beta, gamma: gamma });
478
423
  }
479
424
  _this.lastX = x;
480
425
  _this.lastY = y;
@@ -485,51 +430,52 @@ var DeviceOrientation = /** @class */ (function () {
485
430
  this.stoped = false;
486
431
  if (useWindVane) {
487
432
  switchWindVane(true, this.options.interval);
488
- this.watchListener = function (e) {
489
- if ('param' in e) {
490
- var _a = e.param, x_1 = _a.x, y_1 = _a.y, z = _a.z;
433
+ this.watchListener = function(e) {
434
+ if ("param" in e) {
435
+ var _e_param = e.param, x = _e_param.x, y = _e_param.y, z = _e_param.z;
491
436
  // 即使手机没动,也会不停触发,所以这里加个判断,值相等则不调用回调
492
- if (x_1 === _this.prevAcceler.x && y_1 === _this.prevAcceler.y && z === _this.prevAcceler.z) {
437
+ if (x === _this.prevAcceler.x && y === _this.prevAcceler.y && z === _this.prevAcceler.z) {
493
438
  return;
494
439
  }
495
- _this.prevAcceler = { x: x_1, y: y_1, z: z };
440
+ _this.prevAcceler = {
441
+ x: x,
442
+ y: y,
443
+ z: z
444
+ };
496
445
  var evt = {
497
446
  alpha: +z * 180,
498
- beta: +y_1 * -90,
499
- gamma: +x_1 * 90,
447
+ beta: +y * -90,
448
+ gamma: +x * 90
500
449
  };
501
450
  handleWatch(evt);
502
451
  }
503
452
  };
504
- document.addEventListener('motion.gyro', this.watchListener, false);
505
- }
506
- else if (useJSBridge) {
453
+ document.addEventListener("motion.gyro", this.watchListener, false);
454
+ } else if (useJSBridge && !isMiniProgram()) {
507
455
  switchIOSEvent(true, this.options.interval / 1000);
508
- this.watchListener = function (e) {
509
- if (e && 'data' in e) {
456
+ this.watchListener = function(e) {
457
+ if (e && "data" in e) {
510
458
  /*
511
- data:
512
- {
513
- data: {
514
- x: 0.0, // gamma -1 ~ 1
515
- y: 0.0, // beta -1 ~ 1
516
- z: 0.0, // alpha
517
- }
518
- }
519
- */
520
- var _a = e.data, x_2 = _a.x, y_2 = _a.y, z = _a.z;
459
+ data:
460
+ {
461
+ data: {
462
+ x: 0.0, // gamma -1 ~ 1
463
+ y: 0.0, // beta -1 ~ 1
464
+ z: 0.0, // alpha
465
+ }
466
+ }
467
+ */ var _e_data = e.data, x = _e_data.x, y = _e_data.y, z = _e_data.z;
521
468
  var evt = {
522
469
  alpha: z * 180,
523
- beta: y_2 * -90,
524
- gamma: x_2 * 90,
470
+ beta: y * -90,
471
+ gamma: x * 90
525
472
  };
526
473
  handleWatch(evt);
527
474
  }
528
475
  };
529
- document.addEventListener('accelerometerChange', this.watchListener, false);
530
- }
531
- else {
532
- this.watchListener = function (e) {
476
+ document.addEventListener("accelerometerChange", this.watchListener, false);
477
+ } else {
478
+ this.watchListener = function(e) {
533
479
  nowts = new Date().getTime();
534
480
  // 控制时间片
535
481
  if (nowts - timefragment >= _this.options.interval) {
@@ -537,80 +483,87 @@ var DeviceOrientation = /** @class */ (function () {
537
483
  handleWatch(e);
538
484
  }
539
485
  };
540
- window.addEventListener('deviceorientation', this.watchListener, false);
486
+ window.addEventListener("deviceorientation", this.watchListener, false);
541
487
  }
542
488
  };
543
- DeviceOrientation.prototype.unWatch = function () {
489
+ _proto.unWatch = function unWatch() {
544
490
  assertExist(this.watchListener);
545
491
  if (useWindVane) {
546
492
  switchWindVane(false);
547
- document.removeEventListener('motion.gyro', this.watchListener);
548
- }
549
- else if (useJSBridge) {
493
+ document.removeEventListener("motion.gyro", this.watchListener);
494
+ } else if (useJSBridge) {
550
495
  switchIOSEvent(false);
551
- document.removeEventListener('accelerometerChange', this.watchListener);
552
- }
553
- else {
554
- window.removeEventListener('deviceorientation', this.watchListener);
496
+ document.removeEventListener("accelerometerChange", this.watchListener);
497
+ } else {
498
+ window.removeEventListener("deviceorientation", this.watchListener);
555
499
  }
556
500
  this.stoped = true;
557
501
  this.watchListener = undefined;
558
502
  };
559
- DeviceOrientation.prototype.pause = function () {
503
+ _proto.pause = function pause() {
560
504
  this.stoped = true;
561
505
  if (useJSBridge) {
562
506
  switchIOSEvent(false);
563
507
  }
564
508
  };
565
- DeviceOrientation.prototype.continue = function () {
509
+ _proto.continue = function _continue() {
566
510
  this.stoped = false;
567
511
  if (useJSBridge) {
568
512
  switchIOSEvent(true, this.options.interval / 1000);
569
513
  }
570
514
  };
571
- DeviceOrientation.prototype.isValid = function (x, y) {
515
+ _proto.isValid = function isValid(x, y) {
572
516
  // 判断是否和上次的值一样,检测有没有变
573
517
  return this.lastX !== x || this.lastY !== y;
574
518
  };
575
519
  return DeviceOrientation;
576
- }());
520
+ }();
577
521
  // 开启/关闭 iOS 的陀螺仪监听
578
522
  function switchIOSEvent(open, interval) {
579
- window.AlipayJSBridge.call('watchShake', {
523
+ window.AlipayJSBridge.call("watchShake", {
580
524
  monitorGyroscope: false,
581
525
  monitorAccelerometer: !!open,
582
- interval: !open ? 10 : parseFloat(interval.toFixed(3)),
583
- }, function () { });
526
+ interval: !open ? 10 : parseFloat(interval.toFixed(3))
527
+ }, function() {});
584
528
  }
585
529
  function switchWindVane(open, interval) {
586
530
  var params = {
587
531
  // 是开启还是关闭陀螺仪的监听
588
532
  on: open,
589
533
  // 陀螺仪事件的时间间隔
590
- frequency: interval,
534
+ frequency: interval
591
535
  };
592
- window.WindVane.call('WVMotion', 'listenGyro', params, function (e) {
593
- console.info('call WVMotion success');
594
- }, function (e) {
595
- console.error('call WVMotion failed:' + JSON.stringify(e));
536
+ window.WindVane.call("WVMotion", "listenGyro", params, function(e) {
537
+ console.info("Call WVMotion success.");
538
+ }, function(e) {
539
+ console.error("Call WVMotion failed: " + JSON.stringify(e) + ".");
596
540
  });
597
541
  }
598
542
 
599
543
  /**
600
544
  *
601
- */
602
- var OrientationAdapterAcceler = /** @class */ (function () {
545
+ */ var OrientationAdapterAcceler = /*#__PURE__*/ function() {
603
546
  function OrientationAdapterAcceler() {
604
547
  this.transformers = [];
605
548
  this.connected = false;
606
549
  this.accelerMotion = null;
607
550
  this.validRange = {
608
- alpha: [-60, 60],
609
- beta: [-80, 80],
610
- gamma: [-89, 89], // 左右翻转
551
+ alpha: [
552
+ -60,
553
+ 60
554
+ ],
555
+ beta: [
556
+ -80,
557
+ 80
558
+ ],
559
+ gamma: [
560
+ -89,
561
+ 89
562
+ ]
611
563
  };
612
564
  }
613
- OrientationAdapterAcceler.prototype.connect = function () {
565
+ var _proto = OrientationAdapterAcceler.prototype;
566
+ _proto.connect = function connect() {
614
567
  var _this = this;
615
568
  if (!this.connected) {
616
569
  this.accelerMotion = new DeviceOrientation({
@@ -621,37 +574,41 @@ var OrientationAdapterAcceler = /** @class */ (function () {
621
574
  relativeBeta: false,
622
575
  relativeGamma: false,
623
576
  validRange: this.validRange,
624
- stableRange: 3, // 稳定区间
577
+ stableRange: 3
625
578
  });
626
- this.accelerMotion.watch(function (x, y) {
579
+ this.accelerMotion.watch(function(x, y, param) {
580
+ var beta = param.beta, gamma = param.gamma;
627
581
  var motion = {
628
582
  x: x,
629
583
  y: y,
584
+ beta: beta,
585
+ gamma: gamma
630
586
  };
631
587
  _this.dispatchMotion(motion);
632
588
  });
633
589
  }
634
590
  this.connected = true;
635
591
  };
636
- OrientationAdapterAcceler.prototype.disconnect = function () {
592
+ _proto.disconnect = function disconnect() {
637
593
  if (this.accelerMotion) {
638
594
  this.accelerMotion.unWatch();
639
595
  }
640
596
  this.connected = false;
641
597
  };
642
598
  /**
643
- *
644
- * @param motion
645
- */
646
- OrientationAdapterAcceler.prototype.dispatchMotion = function (motion) {
647
- this.transformers.forEach(function (t) { return t.update(motion); });
648
- };
649
- OrientationAdapterAcceler.prototype.addTransformer = function (transformer) {
599
+ *
600
+ * @param motion
601
+ */ _proto.dispatchMotion = function dispatchMotion(motion) {
602
+ this.transformers.forEach(function(t) {
603
+ return t.update(motion);
604
+ });
605
+ };
606
+ _proto.addTransformer = function addTransformer(transformer) {
650
607
  if (!this.transformers.includes(transformer)) {
651
608
  this.transformers.push(transformer);
652
609
  }
653
610
  };
654
- OrientationAdapterAcceler.prototype.removeTransformer = function (transformer) {
611
+ _proto.removeTransformer = function removeTransformer(transformer) {
655
612
  var index = this.transformers.indexOf(transformer);
656
613
  if (index > -1) {
657
614
  this.transformers.splice(index, 1);
@@ -659,7 +616,7 @@ var OrientationAdapterAcceler = /** @class */ (function () {
659
616
  return this.transformers.length === 0;
660
617
  };
661
618
  return OrientationAdapterAcceler;
662
- }());
619
+ }();
663
620
  var adapter;
664
621
  function getAccelerAdapter() {
665
622
  if (!adapter) {
@@ -668,72 +625,74 @@ function getAccelerAdapter() {
668
625
  return adapter;
669
626
  }
670
627
 
671
- var OrientationPluginLoader = /** @class */ (function (_super) {
672
- __extends(OrientationPluginLoader, _super);
628
+ var OrientationPluginLoader = /*#__PURE__*/ function(AbstractPlugin) {
629
+ _inherits(OrientationPluginLoader, AbstractPlugin);
673
630
  function OrientationPluginLoader() {
674
- var _this = _super !== null && _super.apply(this, arguments) || this;
631
+ var _this;
632
+ _this = AbstractPlugin.apply(this, arguments) || this;
675
633
  _this.order = 90;
676
634
  _this.adapter = null;
677
- _this.handleConnect = function () {
678
- var _a;
635
+ _this.handleConnect = function() {
679
636
  if (!closeManually) {
680
- (_a = _this.adapter) === null || _a === void 0 ? void 0 : _a.connect();
637
+ var _this_adapter;
638
+ (_this_adapter = _this.adapter) == null ? void 0 : _this_adapter.connect();
681
639
  }
682
640
  };
683
- _this.handleDisconnect = function () {
684
- var _a;
685
- (_a = _this.adapter) === null || _a === void 0 ? void 0 : _a.disconnect();
641
+ _this.handleDisconnect = function() {
642
+ var _this_adapter;
643
+ (_this_adapter = _this.adapter) == null ? void 0 : _this_adapter.disconnect();
686
644
  };
687
645
  return _this;
688
646
  }
689
- OrientationPluginLoader.prototype.onCompositionConstructed = function () {
690
- var _a;
647
+ var _proto = OrientationPluginLoader.prototype;
648
+ _proto.onCompositionConstructed = function onCompositionConstructed() {
649
+ var _this_adapter;
691
650
  this.adapter = getAdapter();
692
- (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.connect();
651
+ (_this_adapter = this.adapter) == null ? void 0 : _this_adapter.connect();
693
652
  this.bindAccelerDocumentEvent();
694
653
  };
695
- OrientationPluginLoader.prototype.onCompositionReset = function (composition) {
696
- var _a;
654
+ _proto.onCompositionReset = function onCompositionReset(composition) {
655
+ var _this_adapter;
697
656
  var transformer = composition.loaderData.deviceTransformer = new CompositionTransformerAcceler(composition);
698
- (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.addTransformer(transformer);
657
+ (_this_adapter = this.adapter) == null ? void 0 : _this_adapter.addTransformer(transformer);
699
658
  };
700
- OrientationPluginLoader.prototype.onCompositionUpdate = function (composition) {
659
+ _proto.onCompositionUpdate = function onCompositionUpdate(composition) {
701
660
  var transformer = composition.loaderData.deviceTransformer;
702
661
  if (transformer) {
703
662
  transformer.updateOrientation();
704
663
  }
705
664
  };
706
- OrientationPluginLoader.prototype.onCompositionDestroyed = function (composition) {
707
- var _a, _b;
708
- var empty = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.removeTransformer(composition.loaderData.deviceTransformer);
665
+ _proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {
666
+ var _this_adapter;
667
+ var empty = (_this_adapter = this.adapter) == null ? void 0 : _this_adapter.removeTransformer(composition.loaderData.deviceTransformer);
709
668
  if (empty) {
710
- (_b = this.adapter) === null || _b === void 0 ? void 0 : _b.disconnect();
669
+ var _this_adapter1;
670
+ (_this_adapter1 = this.adapter) == null ? void 0 : _this_adapter1.disconnect();
711
671
  }
712
672
  };
713
- OrientationPluginLoader.prototype.bindAccelerDocumentEvent = function () {
673
+ _proto.bindAccelerDocumentEvent = function bindAccelerDocumentEvent() {
714
674
  this.unbindAccelerDocumentEvent(); // 保证全局只监听一份
715
- document.addEventListener('resume', this.handleConnect, false);
716
- document.addEventListener('pause', this.handleDisconnect, false);
717
- document.addEventListener('back', this.handleDisconnect, false);
675
+ document.addEventListener("resume", this.handleConnect, false);
676
+ document.addEventListener("pause", this.handleDisconnect, false);
677
+ document.addEventListener("back", this.handleDisconnect, false);
718
678
  };
719
- OrientationPluginLoader.prototype.unbindAccelerDocumentEvent = function () {
720
- document.removeEventListener('resume', this.handleConnect);
721
- document.removeEventListener('pause', this.handleDisconnect);
722
- document.removeEventListener('back', this.handleDisconnect);
679
+ _proto.unbindAccelerDocumentEvent = function unbindAccelerDocumentEvent() {
680
+ document.removeEventListener("resume", this.handleConnect);
681
+ document.removeEventListener("pause", this.handleDisconnect);
682
+ document.removeEventListener("back", this.handleDisconnect);
723
683
  };
724
- OrientationPluginLoader.prototype.dispose = function () {
684
+ _proto.dispose = function dispose() {
725
685
  getAdapter().disconnect();
726
686
  this.unbindAccelerDocumentEvent();
727
687
  };
728
688
  return OrientationPluginLoader;
729
- }(AbstractPlugin));
689
+ }(AbstractPlugin);
730
690
  // 是否是手动关闭,如果是,那么 resume 时不要恢复
731
691
  var closeManually = false;
732
692
  /**
733
693
  *
734
694
  * @returns
735
- */
736
- function getAdapter() {
695
+ */ function getAdapter() {
737
696
  // 运动感应类型(默认使用加速度,Native 环境使用陀螺仪)
738
697
  return getAccelerAdapter();
739
698
  }
@@ -746,61 +705,80 @@ function openDeviceMotion() {
746
705
  getAdapter().connect();
747
706
  }
748
707
 
749
- var OrientationComponent = /** @class */ (function (_super) {
750
- __extends(OrientationComponent, _super);
708
+ function __decorate(decorators, target, key, desc) {
709
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
710
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
711
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
712
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
713
+ }
714
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
715
+ var e = new Error(message);
716
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
717
+ };
718
+
719
+ var OrientationComponent = /*#__PURE__*/ function(ItemBehaviour) {
720
+ _inherits(OrientationComponent, ItemBehaviour);
751
721
  function OrientationComponent() {
752
- return _super !== null && _super.apply(this, arguments) || this;
722
+ return ItemBehaviour.apply(this, arguments);
753
723
  }
754
- OrientationComponent.prototype.fromData = function (data) {
755
- _super.prototype.fromData.call(this, data);
756
- var targets = data.content.options.targets;
724
+ var _proto = OrientationComponent.prototype;
725
+ _proto.fromData = function fromData(data) {
726
+ ItemBehaviour.prototype.fromData.call(this, data);
727
+ var targets = data.options.targets;
757
728
  if (targets) {
758
- this.targets = targets.map(function (t) { return ({
759
- name: t.name,
760
- xMin: +t.xMin || 0,
761
- yMin: +t.yMin || 0,
762
- xMax: +t.xMax || 0,
763
- yMax: +t.yMax || 0,
764
- }); });
729
+ this.targets = targets.map(function(t) {
730
+ return {
731
+ name: t.name,
732
+ xMin: +t.xMin || 0,
733
+ yMin: +t.yMin || 0,
734
+ xMax: +t.xMax || 0,
735
+ yMax: +t.yMax || 0,
736
+ vMin: +t.vMin || 0,
737
+ hMin: +t.hMin || 0,
738
+ vMax: +t.vMax || 0,
739
+ hMax: +t.hMax || 0
740
+ };
741
+ });
765
742
  }
766
743
  };
767
- OrientationComponent.prototype.start = function () {
768
- var _a, _b;
769
- var transformer = (_a = this.item.composition) === null || _a === void 0 ? void 0 : _a.loaderData.deviceTransformer;
744
+ _proto.start = function start() {
745
+ var _this_item_composition;
746
+ var transformer = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.loaderData.deviceTransformer;
770
747
  if (transformer) {
771
- (_b = this.targets) === null || _b === void 0 ? void 0 : _b.forEach(function (target) { return transformer.addTarget(target); });
748
+ var _this_targets;
749
+ (_this_targets = this.targets) == null ? void 0 : _this_targets.forEach(function(target) {
750
+ return transformer.addTarget(target);
751
+ });
772
752
  transformer.initComposition();
773
753
  }
774
754
  };
775
- OrientationComponent.prototype.update = function (dt) {
776
- var _a;
777
- var transformer = (_a = this.item.composition) === null || _a === void 0 ? void 0 : _a.loaderData.deviceTransformer;
755
+ _proto.update = function update(dt) {
756
+ var _this_item_composition;
757
+ var transformer = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.loaderData.deviceTransformer;
778
758
  if (transformer) {
779
759
  transformer.updateOrientation();
780
760
  }
781
761
  };
782
- OrientationComponent.prototype.onDestroy = function () {
762
+ _proto.onDestroy = function onDestroy() {
783
763
  var _this = this;
784
- var _a;
785
- (_a = this.targets) === null || _a === void 0 ? void 0 : _a.forEach(function (target) { var _a, _b; return (_b = (_a = _this.item.composition) === null || _a === void 0 ? void 0 : _a.loaderData.deviceTransformer) === null || _b === void 0 ? void 0 : _b.removeTarget(target.name); });
764
+ var _this_targets;
765
+ (_this_targets = this.targets) == null ? void 0 : _this_targets.forEach(function(target) {
766
+ var _this_item_composition_loaderData_deviceTransformer, _this_item_composition;
767
+ return (_this_item_composition = _this.item.composition) == null ? void 0 : (_this_item_composition_loaderData_deviceTransformer = _this_item_composition.loaderData.deviceTransformer) == null ? void 0 : _this_item_composition_loaderData_deviceTransformer.removeTarget(target.name);
768
+ });
786
769
  };
787
770
  return OrientationComponent;
788
- }(ItemBehaviour));
771
+ }(ItemBehaviour);
772
+ OrientationComponent = __decorate([
773
+ effectsClass("OrientationComponent")
774
+ ], OrientationComponent);
789
775
 
790
- var TransformVFXItem = /** @class */ (function (_super) {
791
- __extends(TransformVFXItem, _super);
792
- function TransformVFXItem(engine, props) {
793
- var _this = _super.call(this, engine, props) || this;
794
- var component = _this.addComponent(OrientationComponent);
795
- component.fromData(props);
796
- return _this;
797
- }
798
- return TransformVFXItem;
799
- }(VFXItem));
800
-
801
- registerPlugin('orientation-transformer', OrientationPluginLoader, TransformVFXItem);
802
- var version = "2.0.0-alpha.3";
803
- logger.info('plugin orientation transformer version: ' + version);
776
+ registerPlugin("orientation-transformer", OrientationPluginLoader, VFXItem);
777
+ var version = "2.0.0-alpha.30";
778
+ logger.info("Plugin orientation transformer version: " + version + ".");
779
+ if (version !== EFFECTS.version) {
780
+ 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!");
781
+ }
804
782
 
805
- export { OrientationAdapterAcceler, closeDeviceMotion, getAdapter, openDeviceMotion, version };
783
+ export { OrientationAdapterAcceler, OrientationComponent, OrientationPluginLoader, closeDeviceMotion, getAdapter, openDeviceMotion, version };
806
784
  //# sourceMappingURL=index.mjs.map