@galacean/effects-plugin-orientation-transformer 2.0.0-alpha.8 → 2.0.0-beta.0
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 +805 -0
- package/dist/alipay.js.map +1 -0
- package/dist/alipay.mjs +777 -0
- package/dist/alipay.mjs.map +1 -0
- package/dist/composition-transformer-acceler.d.ts +2 -6
- package/dist/device-orientation.d.ts +2 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +156 -175
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +135 -174
- package/dist/index.mjs.map +1 -1
- package/dist/orientation-adapter-acceler.d.ts +2 -0
- package/dist/orientation-component.d.ts +2 -2
- package/dist/utils/filtering.d.ts +1 -1
- package/package.json +16 -4
- package/dist/transform-vfx-item.d.ts +0 -10
- package/dist/utils/deep-merge.d.ts +0 -1
- package/dist/utils/device.d.ts +0 -1
- package/dist/utils/object-type.d.ts +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Description: Galacean Effects player orientation transformer plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,意绮
|
|
6
|
-
* Version: v2.0.0-
|
|
6
|
+
* Version: v2.0.0-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import * as EFFECTS from '@galacean/effects';
|
|
10
|
+
import { isArray, isIOSByUA, isMiniProgram, assertExist, AbstractPlugin, effectsClass, Behaviour, registerPlugin, VFXItem, logger } from '@galacean/effects';
|
|
10
11
|
|
|
11
12
|
function _set_prototype_of(o, p) {
|
|
12
13
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
@@ -30,75 +31,6 @@ function _inherits(subClass, superClass) {
|
|
|
30
31
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
var OrientationComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
34
|
-
_inherits(OrientationComponent, ItemBehaviour);
|
|
35
|
-
function OrientationComponent() {
|
|
36
|
-
return ItemBehaviour.apply(this, arguments);
|
|
37
|
-
}
|
|
38
|
-
var _proto = OrientationComponent.prototype;
|
|
39
|
-
_proto.fromData = function fromData(data) {
|
|
40
|
-
ItemBehaviour.prototype.fromData.call(this, data);
|
|
41
|
-
var targets = data.content.options.targets;
|
|
42
|
-
if (targets) {
|
|
43
|
-
this.targets = targets.map(function(t) {
|
|
44
|
-
return {
|
|
45
|
-
name: t.name,
|
|
46
|
-
xMin: +t.xMin || 0,
|
|
47
|
-
yMin: +t.yMin || 0,
|
|
48
|
-
xMax: +t.xMax || 0,
|
|
49
|
-
yMax: +t.yMax || 0,
|
|
50
|
-
vMin: +t.vMin || 0,
|
|
51
|
-
hMin: +t.hMin || 0,
|
|
52
|
-
vMax: +t.vMax || 0,
|
|
53
|
-
hMax: +t.hMax || 0
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
_proto.start = function start() {
|
|
59
|
-
var _this_item_composition;
|
|
60
|
-
var transformer = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.loaderData.deviceTransformer;
|
|
61
|
-
if (transformer) {
|
|
62
|
-
var _this_targets;
|
|
63
|
-
(_this_targets = this.targets) == null ? void 0 : _this_targets.forEach(function(target) {
|
|
64
|
-
return transformer.addTarget(target);
|
|
65
|
-
});
|
|
66
|
-
transformer.initComposition();
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
_proto.update = function update(dt) {
|
|
70
|
-
var _this_item_composition;
|
|
71
|
-
var transformer = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.loaderData.deviceTransformer;
|
|
72
|
-
if (transformer) {
|
|
73
|
-
transformer.updateOrientation();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
_proto.onDestroy = function onDestroy() {
|
|
77
|
-
var _this = this;
|
|
78
|
-
var _this_targets;
|
|
79
|
-
(_this_targets = this.targets) == null ? void 0 : _this_targets.forEach(function(target) {
|
|
80
|
-
var _this_item_composition_loaderData_deviceTransformer, _this_item_composition;
|
|
81
|
-
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);
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return OrientationComponent;
|
|
85
|
-
}(ItemBehaviour);
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 水平旋转变化起始角(手机处于改角度时无变化)
|
|
89
|
-
*/ var VERTICAL_INIT_DEGREE = 45;
|
|
90
|
-
var TransformVFXItem = /*#__PURE__*/ function(VFXItem) {
|
|
91
|
-
_inherits(TransformVFXItem, VFXItem);
|
|
92
|
-
function TransformVFXItem(engine, props) {
|
|
93
|
-
var _this;
|
|
94
|
-
_this = VFXItem.call(this, engine, props) || this;
|
|
95
|
-
var component = _this.addComponent(OrientationComponent);
|
|
96
|
-
component.fromData(props);
|
|
97
|
-
return _this;
|
|
98
|
-
}
|
|
99
|
-
return TransformVFXItem;
|
|
100
|
-
}(VFXItem);
|
|
101
|
-
|
|
102
34
|
var CompositionTransformerAcceler = /*#__PURE__*/ function() {
|
|
103
35
|
function CompositionTransformerAcceler(composition) {
|
|
104
36
|
this.composition = composition;
|
|
@@ -117,10 +49,12 @@ var CompositionTransformerAcceler = /*#__PURE__*/ function() {
|
|
|
117
49
|
}
|
|
118
50
|
var _proto = CompositionTransformerAcceler.prototype;
|
|
119
51
|
_proto.update = function update(param) {
|
|
120
|
-
var x = param.x, y = param.y;
|
|
52
|
+
var x = param.x, y = param.y, beta = param.beta, gamma = param.gamma;
|
|
121
53
|
this.currentEvent = {
|
|
122
54
|
x: x,
|
|
123
|
-
y: y
|
|
55
|
+
y: y,
|
|
56
|
+
beta: beta,
|
|
57
|
+
gamma: gamma
|
|
124
58
|
};
|
|
125
59
|
};
|
|
126
60
|
_proto.updateOrientation = function updateOrientation() {
|
|
@@ -164,7 +98,7 @@ var CompositionTransformerAcceler = /*#__PURE__*/ function() {
|
|
|
164
98
|
delete this.records[name];
|
|
165
99
|
};
|
|
166
100
|
_proto.moveLayer = function moveLayer(name, param) {
|
|
167
|
-
var x = param.x, y = param.y;
|
|
101
|
+
var x = param.x, y = param.y, b = param.beta, g = param.gamma;
|
|
168
102
|
var _this_records_name;
|
|
169
103
|
var layer = (_this_records_name = this.records[name]) == null ? void 0 : _this_records_name.item;
|
|
170
104
|
if (layer) {
|
|
@@ -175,12 +109,12 @@ var CompositionTransformerAcceler = /*#__PURE__*/ function() {
|
|
|
175
109
|
if (target) {
|
|
176
110
|
var _layer_transform, _layer_transform1;
|
|
177
111
|
var position = [
|
|
178
|
-
initPosition[0] + 1.2 * mapRange((beta
|
|
179
|
-
initPosition[1] + 1.2 * mapRange((gamma
|
|
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),
|
|
180
114
|
initPosition[2]
|
|
181
115
|
];
|
|
182
|
-
var br = (clamp(
|
|
183
|
-
var gr = (clamp(
|
|
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]);
|
|
184
118
|
var rotation = [
|
|
185
119
|
initRotation[0] + mapRange(gr, target.hMin, target.hMax),
|
|
186
120
|
initRotation[1] + mapRange(br, target.vMin, target.vMax),
|
|
@@ -206,9 +140,19 @@ function clamp(x, range) {
|
|
|
206
140
|
function mapRange(t, min, max) {
|
|
207
141
|
return min + (max - min) * t;
|
|
208
142
|
}
|
|
143
|
+
function normalize(a, min, max) {
|
|
144
|
+
return (a - min) / (max - min);
|
|
145
|
+
}
|
|
209
146
|
|
|
210
|
-
function
|
|
211
|
-
|
|
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);
|
|
212
156
|
}
|
|
213
157
|
|
|
214
158
|
/**
|
|
@@ -220,7 +164,7 @@ function getObjectType(obj) {
|
|
|
220
164
|
var flagAlpha = true;
|
|
221
165
|
var flagBeta = true;
|
|
222
166
|
var flagGamma = true;
|
|
223
|
-
if (
|
|
167
|
+
if (isArray(validRange.alpha) && validRange.alpha.length >= 2) {
|
|
224
168
|
var referAlphaA = angleObj.alpha + validRange.alpha[0];
|
|
225
169
|
var referAlphaB = angleObj.alpha + validRange.alpha[1];
|
|
226
170
|
referAlphaA = referAlphaA < 0 ? referAlphaA + 360 : referAlphaA;
|
|
@@ -231,72 +175,15 @@ function getObjectType(obj) {
|
|
|
231
175
|
flagAlpha = angleObj.alpha > referAlphaA || angleObj.alpha < referAlphaB;
|
|
232
176
|
}
|
|
233
177
|
}
|
|
234
|
-
if (
|
|
178
|
+
if (isArray(validRange.beta) && validRange.beta.length >= 2) {
|
|
235
179
|
flagBeta = angleObj.beta >= validRange.beta[0] && angleObj.beta <= validRange.beta[1];
|
|
236
180
|
}
|
|
237
|
-
if (
|
|
181
|
+
if (isArray(validRange.gamma) && validRange.gamma.length >= 2) {
|
|
238
182
|
flagGamma = angleObj.gamma >= validRange.gamma[0] && angleObj.gamma <= validRange.gamma[1];
|
|
239
183
|
}
|
|
240
184
|
return flagAlpha && flagBeta && flagGamma;
|
|
241
185
|
}
|
|
242
186
|
|
|
243
|
-
function _extends() {
|
|
244
|
-
_extends = Object.assign || function assign(target) {
|
|
245
|
-
for(var i = 1; i < arguments.length; i++){
|
|
246
|
-
var source = arguments[i];
|
|
247
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
248
|
-
}
|
|
249
|
-
return target;
|
|
250
|
-
};
|
|
251
|
-
return _extends.apply(this, arguments);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function deepMerge(target, args) {
|
|
255
|
-
if (!isObject(target) && !isArray(target)) {
|
|
256
|
-
return target;
|
|
257
|
-
}
|
|
258
|
-
var result = isArray(target) ? [].concat(target) : _extends({}, target);
|
|
259
|
-
var length = arguments.length;
|
|
260
|
-
for(var index = 1; index < length; index++){
|
|
261
|
-
var source = arguments[index] || {};
|
|
262
|
-
if (isObject(source)) {
|
|
263
|
-
var prop = void 0;
|
|
264
|
-
for(prop in source){
|
|
265
|
-
if (source.hasOwnProperty(prop)) {
|
|
266
|
-
if (isObject(result[prop]) && isObject(source[prop])) {
|
|
267
|
-
result[prop] = deepMerge(result[prop], source[prop]);
|
|
268
|
-
} else if (isObject(source[prop])) {
|
|
269
|
-
result[prop] = deepMerge(source[prop]);
|
|
270
|
-
} else if (isArray(source[prop])) {
|
|
271
|
-
result[prop] = deepMerge(source[prop]);
|
|
272
|
-
} else {
|
|
273
|
-
result[prop] = source[prop];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
for(prop in result){
|
|
278
|
-
if (isObject(result[prop]) && result.hasOwnProperty(prop) && !source.hasOwnProperty(prop)) {
|
|
279
|
-
result[prop] = deepMerge(result[prop]);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (length === 1) {
|
|
285
|
-
for(var prop1 in result){
|
|
286
|
-
if (isObject(result[prop1]) && result.hasOwnProperty(prop1)) {
|
|
287
|
-
result[prop1] = deepMerge(result[prop1]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return result;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function isIOS() {
|
|
295
|
-
var str = navigator.userAgent.toLowerCase();
|
|
296
|
-
var ver = str.match(/cpu (iphone )?os (.*?) like mac os/);
|
|
297
|
-
return ver ? parseInt(ver[2], 10) : 0;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
187
|
/**
|
|
301
188
|
* 稳定区间
|
|
302
189
|
*/ var STABLE_RANGE = 3;
|
|
@@ -410,7 +297,7 @@ function getLinearRegressionFixedVal(valuePool) {
|
|
|
410
297
|
return fx(valuePool.length / 2);
|
|
411
298
|
}
|
|
412
299
|
|
|
413
|
-
var useJSBridge =
|
|
300
|
+
var useJSBridge = isIOSByUA() && typeof window.AlipayJSBridge !== "undefined";
|
|
414
301
|
var useWindVane = typeof window.WindVane !== "undefined";
|
|
415
302
|
// 默认参数
|
|
416
303
|
var defaultOptions = {
|
|
@@ -447,7 +334,11 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
447
334
|
z: 0
|
|
448
335
|
};
|
|
449
336
|
this.stoped = false;
|
|
450
|
-
|
|
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;
|
|
451
342
|
var stableRange = this.options.stableRange;
|
|
452
343
|
this.filterX = new Filtering({
|
|
453
344
|
stableRange: stableRange
|
|
@@ -468,13 +359,11 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
468
359
|
}
|
|
469
360
|
var timefragment = 0; // 时间片计时
|
|
470
361
|
var nowts = 0; // 当前时间
|
|
471
|
-
|
|
472
|
-
var referBeta =
|
|
362
|
+
// 初始化角度,作为单独一个用户的空间旋转的参照
|
|
363
|
+
var referGamma = NaN, referBeta = NaN;
|
|
473
364
|
var alpha;
|
|
474
365
|
var beta;
|
|
475
366
|
var gamma;
|
|
476
|
-
var gammaFixed;
|
|
477
|
-
var betaFixed;
|
|
478
367
|
var isInValidDegRange;
|
|
479
368
|
var x; // 最终输出的 x
|
|
480
369
|
var y; // 最终输出的 y
|
|
@@ -482,26 +371,26 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
482
371
|
if (_this.stoped) {
|
|
483
372
|
return;
|
|
484
373
|
}
|
|
485
|
-
alpha = e.alpha; // 垂直于屏幕的轴 0 ~ 360
|
|
486
|
-
beta = e.beta; // 横向 X 轴 -180 ~ 180
|
|
487
|
-
gamma = e.gamma; // 纵向 Y 轴 -90 ~ 90
|
|
488
|
-
if (!referBeta) {
|
|
489
|
-
referBeta = beta || 0;
|
|
490
|
-
}
|
|
491
|
-
if (!referGamma) {
|
|
492
|
-
referGamma = gamma || 0;
|
|
493
|
-
}
|
|
494
|
-
//
|
|
374
|
+
alpha = e.alpha || 0; // 垂直于屏幕的轴 0 ~ 360
|
|
375
|
+
beta = e.beta || 0; // 横向 X 轴 -180 ~ 180
|
|
376
|
+
gamma = e.gamma || 0; // 纵向 Y 轴 -90 ~ 90
|
|
495
377
|
isInValidDegRange = angleLimit.call(_this, {
|
|
496
378
|
alpha: alpha,
|
|
497
379
|
beta: beta,
|
|
498
380
|
gamma: gamma
|
|
499
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
|
+
}
|
|
500
390
|
if (isInValidDegRange) {
|
|
501
391
|
// 最终结果值
|
|
502
392
|
if (_this.options.X) {
|
|
503
|
-
|
|
504
|
-
x = _this.options.relativeGamma ? gammaFixed : gamma;
|
|
393
|
+
x = _this.options.relativeGamma ? gamma - referGamma : gamma;
|
|
505
394
|
x = _this.filterX.stableFix(x);
|
|
506
395
|
x = _this.filterX.changeLimit(x);
|
|
507
396
|
x = _this.filterX.linearRegressionMedian(+x);
|
|
@@ -509,9 +398,7 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
509
398
|
x = 0;
|
|
510
399
|
}
|
|
511
400
|
if (_this.options.Y) {
|
|
512
|
-
|
|
513
|
-
betaFixed = beta - referBeta;
|
|
514
|
-
y = _this.options.relativeBeta ? betaFixed : beta;
|
|
401
|
+
y = _this.options.relativeBeta ? beta - referBeta : beta;
|
|
515
402
|
y = _this.filterY.stableFix(y);
|
|
516
403
|
y = _this.filterY.changeLimit(y);
|
|
517
404
|
y = _this.filterY.linearRegressionMedian(+y);
|
|
@@ -523,15 +410,15 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
523
410
|
window.requestAnimationFrame(function() {
|
|
524
411
|
callback(x, y, {
|
|
525
412
|
alpha: alpha,
|
|
526
|
-
beta:
|
|
527
|
-
gamma:
|
|
413
|
+
beta: y - referBeta,
|
|
414
|
+
gamma: x - referGamma
|
|
528
415
|
});
|
|
529
416
|
});
|
|
530
417
|
} else {
|
|
531
418
|
callback(x, y, {
|
|
532
419
|
alpha: alpha,
|
|
533
|
-
beta:
|
|
534
|
-
gamma:
|
|
420
|
+
beta: y - referBeta,
|
|
421
|
+
gamma: x - referGamma
|
|
535
422
|
});
|
|
536
423
|
}
|
|
537
424
|
_this.lastX = x;
|
|
@@ -564,7 +451,7 @@ var DeviceOrientation = /*#__PURE__*/ function() {
|
|
|
564
451
|
}
|
|
565
452
|
};
|
|
566
453
|
document.addEventListener("motion.gyro", this.watchListener, false);
|
|
567
|
-
} else if (useJSBridge) {
|
|
454
|
+
} else if (useJSBridge && !isMiniProgram()) {
|
|
568
455
|
switchIOSEvent(true, this.options.interval / 1000);
|
|
569
456
|
this.watchListener = function(e) {
|
|
570
457
|
if (e && "data" in e) {
|
|
@@ -647,9 +534,9 @@ function switchWindVane(open, interval) {
|
|
|
647
534
|
frequency: interval
|
|
648
535
|
};
|
|
649
536
|
window.WindVane.call("WVMotion", "listenGyro", params, function(e) {
|
|
650
|
-
console.info("
|
|
537
|
+
console.info("Call WVMotion success.");
|
|
651
538
|
}, function(e) {
|
|
652
|
-
console.error("
|
|
539
|
+
console.error("Call WVMotion failed: " + JSON.stringify(e) + ".");
|
|
653
540
|
});
|
|
654
541
|
}
|
|
655
542
|
|
|
@@ -689,10 +576,13 @@ function switchWindVane(open, interval) {
|
|
|
689
576
|
validRange: this.validRange,
|
|
690
577
|
stableRange: 3
|
|
691
578
|
});
|
|
692
|
-
this.accelerMotion.watch(function(x, y) {
|
|
579
|
+
this.accelerMotion.watch(function(x, y, param) {
|
|
580
|
+
var beta = param.beta, gamma = param.gamma;
|
|
693
581
|
var motion = {
|
|
694
582
|
x: x,
|
|
695
|
-
y: y
|
|
583
|
+
y: y,
|
|
584
|
+
beta: beta,
|
|
585
|
+
gamma: gamma
|
|
696
586
|
};
|
|
697
587
|
_this.dispatchMotion(motion);
|
|
698
588
|
});
|
|
@@ -815,9 +705,80 @@ function openDeviceMotion() {
|
|
|
815
705
|
getAdapter().connect();
|
|
816
706
|
}
|
|
817
707
|
|
|
818
|
-
|
|
819
|
-
var
|
|
820
|
-
|
|
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(Behaviour) {
|
|
720
|
+
_inherits(OrientationComponent, Behaviour);
|
|
721
|
+
function OrientationComponent() {
|
|
722
|
+
return Behaviour.apply(this, arguments);
|
|
723
|
+
}
|
|
724
|
+
var _proto = OrientationComponent.prototype;
|
|
725
|
+
_proto.fromData = function fromData(data) {
|
|
726
|
+
Behaviour.prototype.fromData.call(this, data);
|
|
727
|
+
var targets = data.options.targets;
|
|
728
|
+
if (targets) {
|
|
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
|
+
});
|
|
742
|
+
}
|
|
743
|
+
};
|
|
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;
|
|
747
|
+
if (transformer) {
|
|
748
|
+
var _this_targets;
|
|
749
|
+
(_this_targets = this.targets) == null ? void 0 : _this_targets.forEach(function(target) {
|
|
750
|
+
return transformer.addTarget(target);
|
|
751
|
+
});
|
|
752
|
+
transformer.initComposition();
|
|
753
|
+
}
|
|
754
|
+
};
|
|
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;
|
|
758
|
+
if (transformer) {
|
|
759
|
+
transformer.updateOrientation();
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
_proto.onDestroy = function onDestroy() {
|
|
763
|
+
var _this = this;
|
|
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
|
+
});
|
|
769
|
+
};
|
|
770
|
+
return OrientationComponent;
|
|
771
|
+
}(Behaviour);
|
|
772
|
+
OrientationComponent = __decorate([
|
|
773
|
+
effectsClass("OrientationComponent")
|
|
774
|
+
], OrientationComponent);
|
|
775
|
+
|
|
776
|
+
registerPlugin("orientation-transformer", OrientationPluginLoader, VFXItem);
|
|
777
|
+
var version = "2.0.0-beta.0";
|
|
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
|
+
}
|
|
821
782
|
|
|
822
|
-
export { OrientationAdapterAcceler, closeDeviceMotion, getAdapter, openDeviceMotion, version };
|
|
783
|
+
export { OrientationAdapterAcceler, OrientationComponent, OrientationPluginLoader, closeDeviceMotion, getAdapter, openDeviceMotion, version };
|
|
823
784
|
//# sourceMappingURL=index.mjs.map
|