@threekit-tools/treble 0.0.85-next-4 → 0.0.85-next-5
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.
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.BreatheAnimation = void 0;
|
|
43
|
+
var react_1 = require("react");
|
|
44
|
+
var useAnimationStart_1 = __importDefault(require("../../hooks/useAnimationStart"));
|
|
45
|
+
var types_1 = require("../../types");
|
|
46
|
+
var BreatheAnimation = function (props) {
|
|
47
|
+
var readyToAnimate = (0, useAnimationStart_1.default)();
|
|
48
|
+
var initialTranslation = (0, react_1.useRef)(null);
|
|
49
|
+
var initialRotation = (0, react_1.useRef)(null);
|
|
50
|
+
var animationInProgress = (0, react_1.useRef)(false);
|
|
51
|
+
var animationNodeId = (0, react_1.useRef)(undefined);
|
|
52
|
+
var startTime = (0, react_1.useRef)(null);
|
|
53
|
+
var timeoutId = (0, react_1.useRef)(null);
|
|
54
|
+
var _a = Object.assign({
|
|
55
|
+
speed: 4,
|
|
56
|
+
magnifier: 2,
|
|
57
|
+
resumeDelay: undefined,
|
|
58
|
+
nodeName: undefined,
|
|
59
|
+
}, props), speed = _a.speed, magnifier = _a.magnifier, resumeDelay = _a.resumeDelay, nodeName = _a.nodeName;
|
|
60
|
+
(0, react_1.useEffect)(function () {
|
|
61
|
+
if (!readyToAnimate)
|
|
62
|
+
return;
|
|
63
|
+
if (!nodeName)
|
|
64
|
+
return;
|
|
65
|
+
var ruleName = "wobble-animation";
|
|
66
|
+
var animateFrame = function (timestamp) {
|
|
67
|
+
if (!initialTranslation.current ||
|
|
68
|
+
!initialRotation.current ||
|
|
69
|
+
!animationNodeId.current)
|
|
70
|
+
return;
|
|
71
|
+
if (startTime.current === null)
|
|
72
|
+
startTime.current = timestamp;
|
|
73
|
+
var elapsed = (timestamp - startTime.current) / 1000;
|
|
74
|
+
var rotationDelta = {
|
|
75
|
+
x: 6 * magnifier * Math.cos(elapsed / (2.25 * speed)),
|
|
76
|
+
y: 3 * magnifier * Math.sin(elapsed / (2 * speed)),
|
|
77
|
+
z: 2 * magnifier * Math.sin(elapsed / (2 * speed)),
|
|
78
|
+
};
|
|
79
|
+
var translationDelta = {
|
|
80
|
+
x: 0,
|
|
81
|
+
y: (magnifier * Math.sin(elapsed / speed)) / 100,
|
|
82
|
+
z: 0,
|
|
83
|
+
};
|
|
84
|
+
window.threekit.player.scene.set({
|
|
85
|
+
id: animationNodeId.current,
|
|
86
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
87
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.ROTATION,
|
|
88
|
+
}, {
|
|
89
|
+
x: initialRotation.current.x + rotationDelta.x,
|
|
90
|
+
y: initialRotation.current.y + rotationDelta.y,
|
|
91
|
+
z: initialRotation.current.z + rotationDelta.z,
|
|
92
|
+
});
|
|
93
|
+
window.threekit.player.scene.set({
|
|
94
|
+
id: animationNodeId.current,
|
|
95
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
96
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.TRANSLATION,
|
|
97
|
+
}, {
|
|
98
|
+
x: initialTranslation.current.x + translationDelta.x,
|
|
99
|
+
y: initialTranslation.current.y + translationDelta.y,
|
|
100
|
+
z: initialTranslation.current.z + translationDelta.z,
|
|
101
|
+
});
|
|
102
|
+
if (animationInProgress.current)
|
|
103
|
+
window.requestAnimationFrame(animateFrame);
|
|
104
|
+
};
|
|
105
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var player, assetInstance;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
111
|
+
return [4, player.getAssetInstance(window.threekit.player.scene.find({
|
|
112
|
+
id: window.threekit.player.instanceId,
|
|
113
|
+
plug: types_1.PLUG_TYPES.PROXY,
|
|
114
|
+
property: 'asset',
|
|
115
|
+
}))];
|
|
116
|
+
case 1:
|
|
117
|
+
assetInstance = _a.sent();
|
|
118
|
+
animationNodeId.current = window.threekit.player.scene.get({
|
|
119
|
+
from: assetInstance,
|
|
120
|
+
name: nodeName,
|
|
121
|
+
}).id;
|
|
122
|
+
initialRotation.current = window.threekit.player.scene.get({
|
|
123
|
+
id: animationNodeId.current,
|
|
124
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
125
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.ROTATION,
|
|
126
|
+
});
|
|
127
|
+
initialTranslation.current = window.threekit.player.scene.get({
|
|
128
|
+
id: animationNodeId.current,
|
|
129
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
130
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.TRANSLATION,
|
|
131
|
+
});
|
|
132
|
+
animationInProgress.current = true;
|
|
133
|
+
window.threekit.player.tools.addTool({
|
|
134
|
+
key: ruleName,
|
|
135
|
+
label: 'wobble-animation',
|
|
136
|
+
active: true,
|
|
137
|
+
enabled: true,
|
|
138
|
+
handlers: {
|
|
139
|
+
mousedown: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
animationInProgress.current = false;
|
|
142
|
+
if (resumeDelay === undefined)
|
|
143
|
+
window.threekit.player.tools.removeTool(ruleName);
|
|
144
|
+
return [2];
|
|
145
|
+
});
|
|
146
|
+
}); },
|
|
147
|
+
mouseup: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
if (resumeDelay === undefined)
|
|
150
|
+
return [2];
|
|
151
|
+
if (timeoutId.current) {
|
|
152
|
+
clearTimeout(timeoutId.current);
|
|
153
|
+
timeoutId.current = null;
|
|
154
|
+
}
|
|
155
|
+
timeoutId.current = setTimeout(function () {
|
|
156
|
+
initialRotation.current = window.threekit.player.scene.get({
|
|
157
|
+
id: animationNodeId.current,
|
|
158
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
159
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.ROTATION,
|
|
160
|
+
});
|
|
161
|
+
initialTranslation.current = window.threekit.player.scene.get({
|
|
162
|
+
id: animationNodeId.current,
|
|
163
|
+
plug: types_1.PLUG_TYPES.TRANSFORM,
|
|
164
|
+
property: types_1.TRANSFORM_PROPERTY_TYPES.TRANSLATION,
|
|
165
|
+
});
|
|
166
|
+
startTime.current = null;
|
|
167
|
+
animationInProgress.current = true;
|
|
168
|
+
window.requestAnimationFrame(animateFrame);
|
|
169
|
+
}, resumeDelay * 1000);
|
|
170
|
+
return [2];
|
|
171
|
+
});
|
|
172
|
+
}); },
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
window.requestAnimationFrame(animateFrame);
|
|
176
|
+
return [2];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}); })();
|
|
180
|
+
}, [readyToAnimate]);
|
|
181
|
+
return null;
|
|
182
|
+
};
|
|
183
|
+
exports.BreatheAnimation = BreatheAnimation;
|
|
184
|
+
exports.default = exports.BreatheAnimation;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ import PlayerLoadingCircular from './components/PlayerLoadingCircular';
|
|
|
52
52
|
import PlayerLoadingSpinner from './components/PlayerLoadingSpinner';
|
|
53
53
|
import DraggableHint from './components/DraggableHint';
|
|
54
54
|
import TurntableAnimation from './components/TurntableAnimation';
|
|
55
|
+
import BreatheAnimation from './components/BreatheAnimation';
|
|
55
56
|
import AddIcon from './icons/Add';
|
|
56
57
|
import ArrowLeftIcon from './icons/ArrowLeft';
|
|
57
58
|
import ArrowRightIcon from './icons/ArrowRight';
|
|
@@ -94,4 +95,4 @@ import WishlistIcon from './icons/Wishlist';
|
|
|
94
95
|
import ZoomInIcon from './icons/ZoomIn';
|
|
95
96
|
import ZoomOutIcon from './icons/ZoomOut';
|
|
96
97
|
import SpinnerIcon from './icons/Spinner';
|
|
97
|
-
export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, };
|
|
98
|
+
export { useAttribute, useConfigurator, useConfigurationLoader, useFirstPlayerInteraction, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, useLoadingProgress, usePlayer, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, Skeleton, message, Modal, Drawer, Accordion, Tabs, PortalToArOverlay, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, TrebleApp, ProductLayout, PlayerLoadingCircular, PlayerLoadingSpinner, DraggableHint, TurntableAnimation, BreatheAnimation, AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DraggableIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ProductLayout = exports.TrebleApp = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.PortalToArOverlay = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.Skeleton = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayer = exports.useLoadingProgress = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useFirstPlayerInteraction = exports.useConfigurationLoader = exports.useConfigurator = exports.useAttribute = void 0;
|
|
7
|
-
exports.SpinnerIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DraggableIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = exports.TurntableAnimation = exports.DraggableHint = exports.PlayerLoadingSpinner = exports.PlayerLoadingCircular = void 0;
|
|
7
|
+
exports.SpinnerIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DraggableIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = exports.BreatheAnimation = exports.TurntableAnimation = exports.DraggableHint = exports.PlayerLoadingSpinner = exports.PlayerLoadingCircular = void 0;
|
|
8
8
|
var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
|
|
9
9
|
exports.useAttribute = useAttribute_1.default;
|
|
10
10
|
var useConfigurator_1 = __importDefault(require("./hooks/useConfigurator"));
|
|
@@ -113,6 +113,8 @@ var DraggableHint_1 = __importDefault(require("./components/DraggableHint"));
|
|
|
113
113
|
exports.DraggableHint = DraggableHint_1.default;
|
|
114
114
|
var TurntableAnimation_1 = __importDefault(require("./components/TurntableAnimation"));
|
|
115
115
|
exports.TurntableAnimation = TurntableAnimation_1.default;
|
|
116
|
+
var BreatheAnimation_1 = __importDefault(require("./components/BreatheAnimation"));
|
|
117
|
+
exports.BreatheAnimation = BreatheAnimation_1.default;
|
|
116
118
|
var Add_1 = __importDefault(require("./icons/Add"));
|
|
117
119
|
exports.AddIcon = Add_1.default;
|
|
118
120
|
var ArrowLeft_1 = __importDefault(require("./icons/ArrowLeft"));
|