@threekit-tools/treble 0.0.83 → 0.0.84
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/Treble/Treble.d.ts +9 -3
- package/dist/Treble/Treble.js +37 -7
- package/dist/Treble/index.d.ts +2 -2
- package/dist/Treble/index.js +2 -2
- package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
- package/dist/Treble/snapshots.js +247 -0
- package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
- package/dist/Treble/wishlist.js +135 -0
- package/dist/api/orders.d.ts +5 -7
- package/dist/components/AttributeValue/index.js +2 -2
- package/dist/components/Cards/index.d.ts +2 -1
- package/dist/components/Cards/index.js +3 -3
- package/dist/components/Dropdown/index.d.ts +2 -1
- package/dist/components/Dropdown/index.js +3 -3
- package/dist/components/FlatForm/index.js +5 -3
- package/dist/components/Player/index.d.ts +1 -1
- package/dist/components/Strips/index.d.ts +2 -1
- package/dist/components/Strips/index.js +3 -3
- package/dist/components/Swatch/index.d.ts +2 -1
- package/dist/components/Swatch/index.js +3 -3
- package/dist/components/Switch/index.d.ts +2 -1
- package/dist/components/Switch/index.js +2 -2
- package/dist/components/TextInput/index.d.ts +2 -1
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/Tiles/index.d.ts +2 -1
- package/dist/components/Tiles/index.js +3 -3
- package/dist/components/TilesGroup/index.d.ts +2 -1
- package/dist/components/TilesGroup/index.js +3 -3
- package/dist/components/Upload/index.d.ts +2 -1
- package/dist/components/Upload/index.js +2 -2
- package/dist/components/UploadArea/index.d.ts +2 -1
- package/dist/components/UploadArea/index.js +2 -2
- package/dist/components/formComponents.d.ts +12 -0
- package/dist/components/formComponents.js +5 -5
- package/dist/constants.d.ts +0 -22
- package/dist/constants.js +1 -23
- package/dist/hooks/useSingleAnimation/index.js +15 -14
- package/dist/http/orders.d.ts +6 -8
- package/dist/store/product.js +3 -1
- package/dist/types.d.ts +71 -24
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +5 -4
- package/package.json +1 -1
- package/dist/Treble/Snapshots.js +0 -250
- package/dist/Treble/Wishlist.js +0 -136
package/dist/types.d.ts
CHANGED
|
@@ -1,30 +1,67 @@
|
|
|
1
1
|
/// <reference types="webpack-env" />
|
|
2
2
|
import threekitAPI from './api';
|
|
3
3
|
import Treble from './Treble';
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
declare enum SCENE_PHASES {
|
|
5
|
+
LOADED = 0,
|
|
6
|
+
PRELOADED = 1,
|
|
7
|
+
RENDERED = 2
|
|
8
|
+
}
|
|
9
|
+
export declare enum PRIVATE_APIS {
|
|
10
|
+
SCENE = "scene",
|
|
11
|
+
PLAYER = "player"
|
|
12
|
+
}
|
|
13
|
+
export declare enum DISPLAY_OPTIONS {
|
|
14
|
+
WEBGL = "webgl",
|
|
15
|
+
IMAGE = "image"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ATTRIBUTE_TYPES {
|
|
18
|
+
STRING = "String",
|
|
19
|
+
ASSET = "Asset",
|
|
20
|
+
COLOR = "Color",
|
|
21
|
+
NUMBER = "Number",
|
|
22
|
+
BOOLEAN = "Boolean"
|
|
23
|
+
}
|
|
24
|
+
export declare enum ASSET_TYPES {
|
|
25
|
+
UPLOAD = "upload",
|
|
26
|
+
ITEM = "item"
|
|
27
|
+
}
|
|
28
|
+
export declare enum PLUG_TYPES {
|
|
29
|
+
PROXY = "Proxy",
|
|
30
|
+
TRANSFORM = "Transform"
|
|
31
|
+
}
|
|
32
|
+
export declare enum TRANSFORM_PROPERTY_TYPES {
|
|
33
|
+
ROTATION = "rotation",
|
|
34
|
+
TRANSLATION = "translation",
|
|
35
|
+
SCALE = "scale"
|
|
36
|
+
}
|
|
37
|
+
export declare enum SNAPSHOT_FORMATS {
|
|
38
|
+
JPG = "jpg",
|
|
39
|
+
PNG = "png"
|
|
40
|
+
}
|
|
41
|
+
export declare enum SNAPSHOT_OUTPUTS {
|
|
42
|
+
URL = "url",
|
|
43
|
+
DOWNLOAD = "download",
|
|
44
|
+
DATA_URL = "dataUrl",
|
|
45
|
+
BLOB = "blob",
|
|
46
|
+
FILE = "file"
|
|
47
|
+
}
|
|
9
48
|
export declare type IMetadata = Record<string, string | number | null>;
|
|
10
|
-
export interface
|
|
49
|
+
export interface ISceneQueryShared {
|
|
11
50
|
all?: boolean;
|
|
12
51
|
id?: string;
|
|
13
52
|
name?: string | RegExp;
|
|
14
53
|
type?: string | Array<string>;
|
|
15
54
|
names?: Array<RegExp>;
|
|
16
55
|
properties?: any;
|
|
17
|
-
property?: string;
|
|
18
56
|
child?: string;
|
|
19
57
|
parent?: boolean;
|
|
20
58
|
includeParent?: boolean;
|
|
21
|
-
from?: string |
|
|
59
|
+
from?: string | ISceneQueryShared | ISceneQueryNode;
|
|
22
60
|
hasPlug?: string;
|
|
23
61
|
operator?: any;
|
|
24
62
|
operatorIndex?: number;
|
|
25
63
|
evalNode?: boolean;
|
|
26
64
|
evalPlug?: string;
|
|
27
|
-
plug?: string;
|
|
28
65
|
shallow?: boolean;
|
|
29
66
|
skipModels?: boolean;
|
|
30
67
|
configurator?: boolean;
|
|
@@ -33,6 +70,15 @@ export interface ISceneQuery {
|
|
|
33
70
|
tags?: Array<RegExp>;
|
|
34
71
|
hierarchial?: boolean;
|
|
35
72
|
}
|
|
73
|
+
export interface ISceneQueryNode extends ISceneQueryShared {
|
|
74
|
+
plug?: PLUG_TYPES.PROXY;
|
|
75
|
+
property?: 'asset';
|
|
76
|
+
}
|
|
77
|
+
export interface ISceneQueryTransform extends ISceneQueryShared {
|
|
78
|
+
plug: PLUG_TYPES.TRANSFORM;
|
|
79
|
+
property: TRANSFORM_PROPERTY_TYPES;
|
|
80
|
+
}
|
|
81
|
+
export declare type ISceneQuery = ISceneQueryNode | ISceneQueryTransform | string;
|
|
36
82
|
export interface ISceneResult {
|
|
37
83
|
id: string;
|
|
38
84
|
name: string;
|
|
@@ -54,7 +100,7 @@ export declare type ISetConfiguration = Record<string, IConfigurationAttribute>;
|
|
|
54
100
|
interface IDisplayAttributeConfig {
|
|
55
101
|
includeHidden?: boolean;
|
|
56
102
|
}
|
|
57
|
-
interface IAttributeBase<T extends
|
|
103
|
+
interface IAttributeBase<T extends ATTRIBUTE_TYPES, V extends IConfigurationAttribute> {
|
|
58
104
|
type: T;
|
|
59
105
|
id: string;
|
|
60
106
|
name: string;
|
|
@@ -78,8 +124,8 @@ export interface IHydratedAttributeAssetValue extends IDisplayAttributeAssetValu
|
|
|
78
124
|
handleSelect: () => Promise<void>;
|
|
79
125
|
selected: boolean;
|
|
80
126
|
}
|
|
81
|
-
export interface IAttributeAssetBase<V> extends IAttributeBase<
|
|
82
|
-
assetType:
|
|
127
|
+
export interface IAttributeAssetBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.ASSET, IConfigurationAsset> {
|
|
128
|
+
assetType: ASSET_TYPES;
|
|
83
129
|
blacklist: [];
|
|
84
130
|
defaultValue: IConfigurationAsset;
|
|
85
131
|
hiddenValues?: Array<string>;
|
|
@@ -97,7 +143,7 @@ export interface IHydratedAttributeStringValue extends IDisplayAttributeStringVa
|
|
|
97
143
|
handleSelect: () => Promise<void>;
|
|
98
144
|
selected: boolean;
|
|
99
145
|
}
|
|
100
|
-
export interface IAttributeStringBase<V> extends IAttributeBase<
|
|
146
|
+
export interface IAttributeStringBase<V> extends IAttributeBase<ATTRIBUTE_TYPES.STRING, string> {
|
|
101
147
|
blacklist: [];
|
|
102
148
|
defaultValue: string;
|
|
103
149
|
hiddenValues?: Array<string>;
|
|
@@ -107,17 +153,17 @@ export interface IAttributeStringBase<V> extends IAttributeBase<'String', string
|
|
|
107
153
|
export declare type IDisplayAttributeString = IAttributeStringBase<IDisplayAttributeStringValue>;
|
|
108
154
|
export declare type IHydratedAttributeString = IAttributeStringBase<IHydratedAttributeStringValue>;
|
|
109
155
|
export declare type IAttributeString = IAttributeStringBase<string>;
|
|
110
|
-
export interface IAttributeColor extends IAttributeBase<
|
|
156
|
+
export interface IAttributeColor extends IAttributeBase<ATTRIBUTE_TYPES.COLOR, IConfigurationColor> {
|
|
111
157
|
defaultValue: IConfigurationColor;
|
|
112
158
|
}
|
|
113
|
-
export interface IAttributeNumber extends IAttributeBase<
|
|
159
|
+
export interface IAttributeNumber extends IAttributeBase<ATTRIBUTE_TYPES.NUMBER, number> {
|
|
114
160
|
defaultValue: number;
|
|
115
161
|
lockToStep: boolean;
|
|
116
162
|
max?: number;
|
|
117
163
|
min?: number;
|
|
118
164
|
step: number;
|
|
119
165
|
}
|
|
120
|
-
export interface IAttributeBoolean extends IAttributeBase<
|
|
166
|
+
export interface IAttributeBoolean extends IAttributeBase<ATTRIBUTE_TYPES.BOOLEAN, boolean> {
|
|
121
167
|
defaultValue: boolean;
|
|
122
168
|
}
|
|
123
169
|
export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
|
|
@@ -138,7 +184,6 @@ export interface ISnapshotConfig {
|
|
|
138
184
|
height: number;
|
|
139
185
|
};
|
|
140
186
|
}
|
|
141
|
-
export declare type SNAPSHOT_FORMAT_TYPES = 'jpg' | 'png';
|
|
142
187
|
export interface Node {
|
|
143
188
|
name: string;
|
|
144
189
|
nodeId: string;
|
|
@@ -203,13 +248,13 @@ export interface IThreekitConfigurator {
|
|
|
203
248
|
}
|
|
204
249
|
export interface IThreekitScene {
|
|
205
250
|
PHASES: {
|
|
206
|
-
LOADED:
|
|
207
|
-
PRELOADED:
|
|
208
|
-
RENDERED:
|
|
251
|
+
LOADED: SCENE_PHASES.LOADED;
|
|
252
|
+
PRELOADED: SCENE_PHASES.PRELOADED;
|
|
253
|
+
RENDERED: SCENE_PHASES.RENDERED;
|
|
209
254
|
};
|
|
210
|
-
get: (query:
|
|
211
|
-
find: (query: ISceneQuery
|
|
212
|
-
set: (query:
|
|
255
|
+
get: <T extends ISceneQuery>(query: T) => T extends ISceneQueryTransform ? ICoordinates : ISceneResult;
|
|
256
|
+
find: (query: ISceneQuery) => string;
|
|
257
|
+
set: (query: ISceneQueryTransform, transform: ICoordinates) => void;
|
|
213
258
|
}
|
|
214
259
|
export interface IThreekitCamera {
|
|
215
260
|
frameBoundingSphere: () => void;
|
|
@@ -231,12 +276,13 @@ export interface IThreekitPlayer {
|
|
|
231
276
|
on: (phase: SCENE_PHASES | string, callback: (args: any) => void) => void;
|
|
232
277
|
getConfigurator: () => Promise<IThreekitConfigurator>;
|
|
233
278
|
getStageConfigurator: () => Promise<IThreekitConfigurator>;
|
|
234
|
-
enableApi: (api:
|
|
279
|
+
enableApi: <T extends PRIVATE_APIS>(api: T) => T extends PRIVATE_APIS.PLAYER ? IThreekitPrivatePlayer : any;
|
|
235
280
|
snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
|
|
236
281
|
unload: () => Promise<string>;
|
|
237
282
|
}
|
|
238
283
|
export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
|
|
239
284
|
getAppliedConfiguration: (attributeName: string) => string;
|
|
285
|
+
getFullConfiguration: () => IConfiguration;
|
|
240
286
|
}
|
|
241
287
|
export interface IThreekitPrivatePlayer {
|
|
242
288
|
getConfigurator: () => IThreekitPrivateConfigurator;
|
|
@@ -244,6 +290,7 @@ export interface IThreekitPrivatePlayer {
|
|
|
244
290
|
getFullConfiguration: () => IConfiguration;
|
|
245
291
|
};
|
|
246
292
|
calculateLogs: () => Promise<Record<string, any>>;
|
|
293
|
+
getAssetInstance: (query: ISceneQueryNode | string) => Promise<string>;
|
|
247
294
|
}
|
|
248
295
|
export interface ThreekitInitConfig {
|
|
249
296
|
authToken: string;
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.TRANSFORM_PROPERTY_TYPES = exports.PLUG_TYPES = exports.ASSET_TYPES = exports.ATTRIBUTE_TYPES = exports.DISPLAY_OPTIONS = exports.PRIVATE_APIS = void 0;
|
|
4
|
+
var SCENE_PHASES;
|
|
5
|
+
(function (SCENE_PHASES) {
|
|
6
|
+
SCENE_PHASES[SCENE_PHASES["LOADED"] = 0] = "LOADED";
|
|
7
|
+
SCENE_PHASES[SCENE_PHASES["PRELOADED"] = 1] = "PRELOADED";
|
|
8
|
+
SCENE_PHASES[SCENE_PHASES["RENDERED"] = 2] = "RENDERED";
|
|
9
|
+
})(SCENE_PHASES || (SCENE_PHASES = {}));
|
|
10
|
+
var PRIVATE_APIS;
|
|
11
|
+
(function (PRIVATE_APIS) {
|
|
12
|
+
PRIVATE_APIS["SCENE"] = "scene";
|
|
13
|
+
PRIVATE_APIS["PLAYER"] = "player";
|
|
14
|
+
})(PRIVATE_APIS = exports.PRIVATE_APIS || (exports.PRIVATE_APIS = {}));
|
|
15
|
+
var DISPLAY_OPTIONS;
|
|
16
|
+
(function (DISPLAY_OPTIONS) {
|
|
17
|
+
DISPLAY_OPTIONS["WEBGL"] = "webgl";
|
|
18
|
+
DISPLAY_OPTIONS["IMAGE"] = "image";
|
|
19
|
+
})(DISPLAY_OPTIONS = exports.DISPLAY_OPTIONS || (exports.DISPLAY_OPTIONS = {}));
|
|
20
|
+
var ATTRIBUTE_TYPES;
|
|
21
|
+
(function (ATTRIBUTE_TYPES) {
|
|
22
|
+
ATTRIBUTE_TYPES["STRING"] = "String";
|
|
23
|
+
ATTRIBUTE_TYPES["ASSET"] = "Asset";
|
|
24
|
+
ATTRIBUTE_TYPES["COLOR"] = "Color";
|
|
25
|
+
ATTRIBUTE_TYPES["NUMBER"] = "Number";
|
|
26
|
+
ATTRIBUTE_TYPES["BOOLEAN"] = "Boolean";
|
|
27
|
+
})(ATTRIBUTE_TYPES = exports.ATTRIBUTE_TYPES || (exports.ATTRIBUTE_TYPES = {}));
|
|
28
|
+
var ASSET_TYPES;
|
|
29
|
+
(function (ASSET_TYPES) {
|
|
30
|
+
ASSET_TYPES["UPLOAD"] = "upload";
|
|
31
|
+
ASSET_TYPES["ITEM"] = "item";
|
|
32
|
+
})(ASSET_TYPES = exports.ASSET_TYPES || (exports.ASSET_TYPES = {}));
|
|
33
|
+
var PLUG_TYPES;
|
|
34
|
+
(function (PLUG_TYPES) {
|
|
35
|
+
PLUG_TYPES["PROXY"] = "Proxy";
|
|
36
|
+
PLUG_TYPES["TRANSFORM"] = "Transform";
|
|
37
|
+
})(PLUG_TYPES = exports.PLUG_TYPES || (exports.PLUG_TYPES = {}));
|
|
38
|
+
var TRANSFORM_PROPERTY_TYPES;
|
|
39
|
+
(function (TRANSFORM_PROPERTY_TYPES) {
|
|
40
|
+
TRANSFORM_PROPERTY_TYPES["ROTATION"] = "rotation";
|
|
41
|
+
TRANSFORM_PROPERTY_TYPES["TRANSLATION"] = "translation";
|
|
42
|
+
TRANSFORM_PROPERTY_TYPES["SCALE"] = "scale";
|
|
43
|
+
})(TRANSFORM_PROPERTY_TYPES = exports.TRANSFORM_PROPERTY_TYPES || (exports.TRANSFORM_PROPERTY_TYPES = {}));
|
|
44
|
+
var SNAPSHOT_FORMATS;
|
|
45
|
+
(function (SNAPSHOT_FORMATS) {
|
|
46
|
+
SNAPSHOT_FORMATS["JPG"] = "jpg";
|
|
47
|
+
SNAPSHOT_FORMATS["PNG"] = "png";
|
|
48
|
+
})(SNAPSHOT_FORMATS = exports.SNAPSHOT_FORMATS || (exports.SNAPSHOT_FORMATS = {}));
|
|
49
|
+
var SNAPSHOT_OUTPUTS;
|
|
50
|
+
(function (SNAPSHOT_OUTPUTS) {
|
|
51
|
+
SNAPSHOT_OUTPUTS["URL"] = "url";
|
|
52
|
+
SNAPSHOT_OUTPUTS["DOWNLOAD"] = "download";
|
|
53
|
+
SNAPSHOT_OUTPUTS["DATA_URL"] = "dataUrl";
|
|
54
|
+
SNAPSHOT_OUTPUTS["BLOB"] = "blob";
|
|
55
|
+
SNAPSHOT_OUTPUTS["FILE"] = "file";
|
|
56
|
+
})(SNAPSHOT_OUTPUTS = exports.SNAPSHOT_OUTPUTS || (exports.SNAPSHOT_OUTPUTS = {}));
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute } from './types';
|
|
2
|
-
import { ITrebleConfig,
|
|
2
|
+
import { ITrebleConfig, ATTRIBUTE_TYPES } from './types';
|
|
3
3
|
import { RawAttributeValue } from './hooks/useAttribute';
|
|
4
4
|
import { ITranslationMap } from './api/products';
|
|
5
5
|
interface ICameraPosition {
|
|
@@ -53,7 +53,7 @@ export declare const hydrateAttribute: (data: [
|
|
|
53
53
|
undefined | ITranslationMap,
|
|
54
54
|
undefined | string
|
|
55
55
|
], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>) => Record<string, IHydratedAttribute>;
|
|
56
|
-
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType:
|
|
56
|
+
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: ATTRIBUTE_TYPES) => string | number | boolean | File | IConfigurationColor | {
|
|
57
57
|
assetId: RawAttributeValue;
|
|
58
58
|
} | undefined;
|
|
59
59
|
export declare const filterFormAttributes: (attributes: Record<string, IThreekitDisplayAttribute>, attributeComponentProps: IAttributesComponentProps, includeReservedAttributes: boolean) => IThreekitDisplayAttribute[];
|
package/dist/utils.js
CHANGED
|
@@ -47,6 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.loadTrebleConfig = exports.runDebugger = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.isIOS = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
49
49
|
var constants_1 = require("./constants");
|
|
50
|
+
var types_1 = require("./types");
|
|
50
51
|
var generateClassName = function (baseClass) {
|
|
51
52
|
return function (component, customClassName, title) {
|
|
52
53
|
var result = "".concat(baseClass, "-").concat(component);
|
|
@@ -356,12 +357,12 @@ var hydrateAttribute = function (data, optionSelectionHandler) {
|
|
|
356
357
|
exports.hydrateAttribute = hydrateAttribute;
|
|
357
358
|
var selectionToConfiguration = function (value, attributeType) {
|
|
358
359
|
switch (attributeType) {
|
|
359
|
-
case
|
|
360
|
-
case
|
|
360
|
+
case types_1.ATTRIBUTE_TYPES.NUMBER:
|
|
361
|
+
case types_1.ATTRIBUTE_TYPES.STRING:
|
|
361
362
|
return value;
|
|
362
|
-
case
|
|
363
|
+
case types_1.ATTRIBUTE_TYPES.ASSET:
|
|
363
364
|
return { assetId: value };
|
|
364
|
-
case
|
|
365
|
+
case types_1.ATTRIBUTE_TYPES.COLOR:
|
|
365
366
|
return (0, exports.deflateRgb)(value);
|
|
366
367
|
default:
|
|
367
368
|
return value;
|
package/package.json
CHANGED
package/dist/Treble/Snapshots.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
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
|
-
var api_1 = __importDefault(require("../api"));
|
|
43
|
-
var constants_1 = require("../constants");
|
|
44
|
-
var utils_1 = require("../utils");
|
|
45
|
-
var DEFAULT_CAMERA_CONFIG = {
|
|
46
|
-
filename: "snapshot",
|
|
47
|
-
size: { width: 1920, height: 1080 },
|
|
48
|
-
format: constants_1.SNAPSHOT_FORMATS.png,
|
|
49
|
-
attributeName: constants_1.ATTRIBUTES_RESERVED.camera,
|
|
50
|
-
output: constants_1.SNAPSHOT_OUTPUTS.blob,
|
|
51
|
-
useStage: false,
|
|
52
|
-
};
|
|
53
|
-
var cameraValues;
|
|
54
|
-
var getCameraValue = function (configurator, cameraAttrName) {
|
|
55
|
-
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
56
|
-
var attribute = configurator
|
|
57
|
-
.getDisplayAttributes()
|
|
58
|
-
.find(function (el) { return el.name === cameraAttrName; });
|
|
59
|
-
if (!attribute)
|
|
60
|
-
return undefined;
|
|
61
|
-
return attribute.value;
|
|
62
|
-
};
|
|
63
|
-
var getCamerasMap = function (configurator, cameraAttrName) {
|
|
64
|
-
if (cameraAttrName === void 0) { cameraAttrName = constants_1.ATTRIBUTES_RESERVED.camera; }
|
|
65
|
-
if (cameraValues)
|
|
66
|
-
return cameraValues;
|
|
67
|
-
var attribute = configurator
|
|
68
|
-
.getDisplayAttributes()
|
|
69
|
-
.find(function (el) { return el.name === cameraAttrName; });
|
|
70
|
-
if (!attribute) {
|
|
71
|
-
cameraValues = {};
|
|
72
|
-
return cameraValues;
|
|
73
|
-
}
|
|
74
|
-
var cameraAttribute = attribute;
|
|
75
|
-
cameraAttribute.values.forEach(function (el) {
|
|
76
|
-
var _a;
|
|
77
|
-
var value = cameraAttribute.type === constants_1.ATTRIBUTE_TYPES.asset
|
|
78
|
-
? { assetId: el.assetId }
|
|
79
|
-
: el.value;
|
|
80
|
-
cameraValues = Object.assign(cameraValues || {}, (_a = {},
|
|
81
|
-
_a[el.label] = value,
|
|
82
|
-
_a));
|
|
83
|
-
}, {});
|
|
84
|
-
return cameraValues;
|
|
85
|
-
};
|
|
86
|
-
var getSnapshot = function (_a) {
|
|
87
|
-
var size = _a.size, format = _a.format;
|
|
88
|
-
return window.threekit.player.snapshotAsync({
|
|
89
|
-
size: size,
|
|
90
|
-
mimeType: "image/".concat(constants_1.SNAPSHOT_FORMATS[format]),
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
var getSnapshots = function (cameras, snapshotConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
-
var attributeName, size, format, configurator, _a, camerasMap, snapshots;
|
|
95
|
-
return __generator(this, function (_b) {
|
|
96
|
-
switch (_b.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
attributeName = snapshotConfig.attributeName || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
99
|
-
size = snapshotConfig.size || DEFAULT_CAMERA_CONFIG.size;
|
|
100
|
-
format = snapshotConfig.format || DEFAULT_CAMERA_CONFIG.format;
|
|
101
|
-
if (!(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.useStage)) return [3, 2];
|
|
102
|
-
return [4, window.threekit.player.getStageConfigurator()];
|
|
103
|
-
case 1:
|
|
104
|
-
_a = _b.sent();
|
|
105
|
-
return [3, 3];
|
|
106
|
-
case 2:
|
|
107
|
-
_a = window.threekit.configurator;
|
|
108
|
-
_b.label = 3;
|
|
109
|
-
case 3:
|
|
110
|
-
configurator = _a;
|
|
111
|
-
camerasMap = getCamerasMap(configurator, attributeName);
|
|
112
|
-
if (!camerasMap)
|
|
113
|
-
return [2, Promise.resolve([])];
|
|
114
|
-
snapshots = [];
|
|
115
|
-
return [2, cameras.reduce(function (snapshotPromise, camera) {
|
|
116
|
-
return snapshotPromise.then(function () {
|
|
117
|
-
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
-
var snapshotStr;
|
|
119
|
-
var _a;
|
|
120
|
-
return __generator(this, function (_b) {
|
|
121
|
-
switch (_b.label) {
|
|
122
|
-
case 0:
|
|
123
|
-
if (!camera) return [3, 2];
|
|
124
|
-
return [4, configurator.setConfiguration((_a = {},
|
|
125
|
-
_a[attributeName] = camerasMap[camera],
|
|
126
|
-
_a))];
|
|
127
|
-
case 1:
|
|
128
|
-
_b.sent();
|
|
129
|
-
_b.label = 2;
|
|
130
|
-
case 2: return [4, getSnapshot({ size: size, format: format })];
|
|
131
|
-
case 3:
|
|
132
|
-
snapshotStr = _b.sent();
|
|
133
|
-
snapshots.push(snapshotStr);
|
|
134
|
-
resolve(snapshots);
|
|
135
|
-
return [2];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}); });
|
|
139
|
-
});
|
|
140
|
-
}, Promise.resolve(snapshots))];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}); };
|
|
144
|
-
var Snapshots = (function () {
|
|
145
|
-
function Snapshots() {
|
|
146
|
-
var _this = this;
|
|
147
|
-
this.getSnapshot = getSnapshot;
|
|
148
|
-
this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
149
|
-
var filename, size, format, attributeName, output, configurator, _a, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response, urlsArray, snapshotBlobs, snapshotFiles;
|
|
150
|
-
var _c;
|
|
151
|
-
return __generator(this, function (_d) {
|
|
152
|
-
switch (_d.label) {
|
|
153
|
-
case 0:
|
|
154
|
-
filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
|
|
155
|
-
size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
|
|
156
|
-
format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
|
|
157
|
-
attributeName = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.attributeName) || DEFAULT_CAMERA_CONFIG.attributeName;
|
|
158
|
-
output = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.output) || DEFAULT_CAMERA_CONFIG.output;
|
|
159
|
-
if (!(snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.useStage)) return [3, 2];
|
|
160
|
-
return [4, window.threekit.player.getStageConfigurator()];
|
|
161
|
-
case 1:
|
|
162
|
-
_a = _d.sent();
|
|
163
|
-
return [3, 3];
|
|
164
|
-
case 2:
|
|
165
|
-
_a = window.threekit.configurator;
|
|
166
|
-
_d.label = 3;
|
|
167
|
-
case 3:
|
|
168
|
-
configurator = _a;
|
|
169
|
-
cameras = Array.isArray(camerasList) ? camerasList : [camerasList];
|
|
170
|
-
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3, 5];
|
|
171
|
-
return [4, this.getSnapshot({ size: size, format: format })];
|
|
172
|
-
case 4:
|
|
173
|
-
snapshotData = _d.sent();
|
|
174
|
-
snapshotsRaw = [snapshotData];
|
|
175
|
-
return [3, 8];
|
|
176
|
-
case 5:
|
|
177
|
-
camerasMap_1 = getCamerasMap(configurator, attributeName);
|
|
178
|
-
if (!camerasMap_1)
|
|
179
|
-
return [2, null];
|
|
180
|
-
cameras = cameras.filter(function (el) { return el === undefined || Object.keys(camerasMap_1).includes(el); });
|
|
181
|
-
currentCamera = getCameraValue(configurator, attributeName);
|
|
182
|
-
cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
|
|
183
|
-
return [4, getSnapshots(cameras, snapshotsConfig)];
|
|
184
|
-
case 6:
|
|
185
|
-
snapshotsRaw = _d.sent();
|
|
186
|
-
return [4, configurator.setConfiguration((_c = {},
|
|
187
|
-
_c[attributeName] = currentCamera,
|
|
188
|
-
_c))];
|
|
189
|
-
case 7:
|
|
190
|
-
_d.sent();
|
|
191
|
-
(0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
|
|
192
|
-
_d.label = 8;
|
|
193
|
-
case 8:
|
|
194
|
-
_b = output;
|
|
195
|
-
switch (_b) {
|
|
196
|
-
case constants_1.SNAPSHOT_OUTPUTS.url: return [3, 9];
|
|
197
|
-
case constants_1.SNAPSHOT_OUTPUTS.download: return [3, 11];
|
|
198
|
-
case constants_1.SNAPSHOT_OUTPUTS.blob: return [3, 12];
|
|
199
|
-
case constants_1.SNAPSHOT_OUTPUTS.file: return [3, 13];
|
|
200
|
-
case constants_1.SNAPSHOT_OUTPUTS.dataUrl: return [3, 14];
|
|
201
|
-
}
|
|
202
|
-
return [3, 14];
|
|
203
|
-
case 9:
|
|
204
|
-
attachments = snapshotsRaw.reduce(function (output, el, idx) {
|
|
205
|
-
var _a;
|
|
206
|
-
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
207
|
-
? (0, utils_1.regularToKebabCase)(camerasList[idx] || 'default')
|
|
208
|
-
: filename;
|
|
209
|
-
var preppedFilename = cameraName === filename
|
|
210
|
-
? "".concat(filename, ".").concat(format)
|
|
211
|
-
: "".concat(filename, "-").concat(cameraName, ".").concat(format);
|
|
212
|
-
var file = (0, utils_1.dataURItoFile)(el, preppedFilename);
|
|
213
|
-
return Object.assign(output, (_a = {}, _a[cameraName] = file, _a));
|
|
214
|
-
}, {});
|
|
215
|
-
return [4, api_1.default.configurations.save({
|
|
216
|
-
assetId: window.threekit.player.assetId,
|
|
217
|
-
configuration: window.threekit.configurator.getConfiguration(),
|
|
218
|
-
attachments: attachments,
|
|
219
|
-
})];
|
|
220
|
-
case 10:
|
|
221
|
-
response = _d.sent();
|
|
222
|
-
urlsArray = Object.values(response.data.attachments);
|
|
223
|
-
return [2, Promise.resolve(urlsArray)];
|
|
224
|
-
case 11:
|
|
225
|
-
snapshotsRaw.forEach(function (snapshotBlob, idx) {
|
|
226
|
-
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
227
|
-
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
228
|
-
: '';
|
|
229
|
-
(0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
230
|
-
});
|
|
231
|
-
return [2, Promise.resolve()];
|
|
232
|
-
case 12:
|
|
233
|
-
snapshotBlobs = snapshotsRaw.map(function (el) { return (0, utils_1.dataURItoBlob)(el); });
|
|
234
|
-
return [2, Promise.resolve(snapshotBlobs)];
|
|
235
|
-
case 13:
|
|
236
|
-
snapshotFiles = snapshotsRaw.map(function (el, idx) {
|
|
237
|
-
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
238
|
-
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
239
|
-
: '';
|
|
240
|
-
return (0, utils_1.dataURItoFile)(el, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
241
|
-
});
|
|
242
|
-
return [2, Promise.resolve(snapshotFiles)];
|
|
243
|
-
case 14: return [2, Promise.resolve(snapshotsRaw)];
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}); };
|
|
247
|
-
}
|
|
248
|
-
return Snapshots;
|
|
249
|
-
}());
|
|
250
|
-
exports.default = Snapshots;
|