@gamelearn/arcade-components 0.25.6 → 0.25.8
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.
|
@@ -40,10 +40,11 @@ var AnimateElement = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
40
40
|
animationUrl = _ref.animationUrl,
|
|
41
41
|
enableBounding = _ref.enableBounding,
|
|
42
42
|
layers = _ref.layers,
|
|
43
|
+
pauseAtStart = _ref.pauseAtStart,
|
|
43
44
|
onClick = _ref.onClick,
|
|
44
45
|
onPointerOver = _ref.onPointerOver,
|
|
45
46
|
onPointerOut = _ref.onPointerOut,
|
|
46
|
-
props = _objectWithoutProperties(_ref, ["model", "position", "rotation", "animationUrl", "enableBounding", "layers", "onClick", "onPointerOver", "onPointerOut"]);
|
|
47
|
+
props = _objectWithoutProperties(_ref, ["model", "position", "rotation", "animationUrl", "enableBounding", "layers", "pauseAtStart", "onClick", "onPointerOver", "onPointerOut"]);
|
|
47
48
|
|
|
48
49
|
var _useGLB = (0, _useGLB2.default)(animationUrl),
|
|
49
50
|
animations = _useGLB.animations;
|
|
@@ -55,7 +56,13 @@ var AnimateElement = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
55
56
|
var mouseEvents = {
|
|
56
57
|
onClick: onClick,
|
|
57
58
|
onPointerOver: onPointerOver,
|
|
58
|
-
onPointerOut: onPointerOut
|
|
59
|
+
onPointerOut: onPointerOut,
|
|
60
|
+
onPointerCancel: props.onPointerCancel,
|
|
61
|
+
onPointerDown: props.onPointerDown,
|
|
62
|
+
onPointerEnter: props.onPointerEnter,
|
|
63
|
+
onPointerLeave: props.onPointerLeave,
|
|
64
|
+
onPointerMove: props.onPointerMove,
|
|
65
|
+
onPointerUp: props.onPointerUp
|
|
59
66
|
};
|
|
60
67
|
|
|
61
68
|
var currentProps = _objectSpread(_objectSpread({}, enableBounding ? {} : mouseEvents), props);
|
|
@@ -82,23 +89,37 @@ var AnimateElement = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
|
82
89
|
if (clip) {
|
|
83
90
|
var action = mixer.clipAction(clip, animationRef.current);
|
|
84
91
|
action.play();
|
|
92
|
+
|
|
93
|
+
if (pauseAtStart) {
|
|
94
|
+
action.paused = true;
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
|
-
}, [mixer, animations, animationRef]);
|
|
98
|
+
}, [mixer, animations, pauseAtStart, animationRef]);
|
|
88
99
|
return /*#__PURE__*/_react.default.createElement("group", {
|
|
89
100
|
visible: props.visible
|
|
90
101
|
}, enableBounding ? /*#__PURE__*/_react.default.createElement(_BoundingBox.default, _extends({
|
|
91
102
|
model: model,
|
|
92
|
-
position: position,
|
|
93
|
-
rotation: rotation,
|
|
94
103
|
layers: layers
|
|
95
104
|
}, mouseEvents)) : null, /*#__PURE__*/_react.default.createElement("primitive", _extends({
|
|
96
105
|
ref: getRef,
|
|
97
106
|
object: model,
|
|
98
107
|
position: position,
|
|
99
|
-
rotation: rotation
|
|
108
|
+
rotation: rotation,
|
|
109
|
+
raycast: enableBounding ? null : _drei.meshBounds
|
|
100
110
|
}, currentProps)));
|
|
101
111
|
});
|
|
102
112
|
|
|
113
|
+
AnimateElement.defaultProps = {
|
|
114
|
+
onClick: function onClick() {},
|
|
115
|
+
onPointerOver: function onPointerOver() {},
|
|
116
|
+
onPointerOut: function onPointerOut() {},
|
|
117
|
+
onPointerCancel: function onPointerCancel() {},
|
|
118
|
+
onPointerDown: function onPointerDown() {},
|
|
119
|
+
onPointerEnter: function onPointerEnter() {},
|
|
120
|
+
onPointerLeave: function onPointerLeave() {},
|
|
121
|
+
onPointerMove: function onPointerMove() {},
|
|
122
|
+
onPointerUp: function onPointerUp() {}
|
|
123
|
+
};
|
|
103
124
|
var _default = AnimateElement;
|
|
104
125
|
exports.default = _default;
|
|
@@ -23,25 +23,29 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
23
23
|
|
|
24
24
|
var BoundingBox = function BoundingBox(_ref) {
|
|
25
25
|
var model = _ref.model,
|
|
26
|
-
rotation = _ref.rotation,
|
|
27
|
-
position = _ref.position,
|
|
28
26
|
visible = _ref.visible,
|
|
29
|
-
props = _objectWithoutProperties(_ref, ["model", "
|
|
27
|
+
props = _objectWithoutProperties(_ref, ["model", "visible"]);
|
|
30
28
|
|
|
31
29
|
var bounding = (0, _react.useRef)();
|
|
32
30
|
(0, _react.useEffect)(function () {
|
|
33
31
|
if (model && bounding.current) {
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
var updatePosition = function updatePosition() {
|
|
33
|
+
var box = new _three.Box3().setFromObject(model);
|
|
34
|
+
var size = box.getSize(new _three.Vector3());
|
|
35
|
+
bounding.current.position.copy(model.position);
|
|
36
|
+
bounding.current.rotation.copy(model.rotation);
|
|
37
|
+
bounding.current.scale.copy(size);
|
|
38
|
+
bounding.current.scale.x /= 2;
|
|
39
|
+
bounding.current.position.y += size.y / 2;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
updatePosition();
|
|
43
|
+
bounding.current.updatePosition = updatePosition;
|
|
44
|
+
model.brother = bounding.current;
|
|
39
45
|
}
|
|
40
|
-
}, [model
|
|
46
|
+
}, [model]);
|
|
41
47
|
return /*#__PURE__*/_react.default.createElement("mesh", _extends({
|
|
42
|
-
ref: bounding
|
|
43
|
-
position: position,
|
|
44
|
-
rotation: rotation
|
|
48
|
+
ref: bounding
|
|
45
49
|
}, props), /*#__PURE__*/_react.default.createElement("boxGeometry", {
|
|
46
50
|
args: [1, 1, 1]
|
|
47
51
|
}), /*#__PURE__*/_react.default.createElement("meshBasicMaterial", {
|