architwin 1.0.27 → 1.0.29
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/README.md +25 -23
- package/lib/architwin.d.ts +10 -2
- package/lib/architwin.min.js +1 -1
- package/lib/types.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ ArchiTwin Library
|
|
|
8
8
|
- [Installation](#installation)
|
|
9
9
|
- [Install Using NPM](#install-using-npm)
|
|
10
10
|
- [Getting Started](#getting-started)
|
|
11
|
+
- [Prerequisites](#prerequisites)
|
|
11
12
|
- [Define an iFrame as target for the Showcase](#define-an-iframe-as-target-for-the-showcase)
|
|
12
13
|
- [Import the library](#import-the-library)
|
|
13
14
|
- [Setup your proxy](#setup-your-proxy)
|
|
@@ -36,9 +37,19 @@ npm i architwin
|
|
|
36
37
|
````
|
|
37
38
|
## Getting Started
|
|
38
39
|
------------------------
|
|
40
|
+
|
|
41
|
+
#### Prerequisites
|
|
42
|
+
|
|
43
|
+
Before you start coding your architwin powered app, there are a few things you need to have ready to ensure that you are able to run the app properly without interruptions. For a seamless development experience, make sure to have the following ready:
|
|
44
|
+
|
|
45
|
+
- **appKey:** your appKey is used to authenticate your connection when loading the 3D showcase. For security purposes, the appKey can only be used by a domain (e.g. awesomesite.com) it is associated with. This key is important especially when you launch your app in production and utilize your own site domain. Please contact us to request your appKey
|
|
46
|
+
- **apiKey:** not to be confused with the appKey, the apiKey is used to authenticate all API requests sent to our servers including user authentication and fetching object data connected to a showcase. Please contact us to request your apiKey
|
|
47
|
+
- **apiURL:** an optional key in the [auth object](#connection-parameters) which if set, will point all internal API calls to the api endpoint or base URL you assign. If this is not set, all api calls will be directed to the proxy address set in the `vite.config.ts` file during **local development**. Example: `apiURL: "apps.awesomesite.com/api"` will resolve internally to `apps.awesomesite.com/api/cas/tickets?someparams` or `apps.awesomesite.com/api/v1/showcase/id/1`. It is important to add `/api` to the base url of your custom apiURL to ensure the api requests are properly sent. There is no need to add a forward slash at the end of our custom apiURL. Please take note that you *may* have to setup a proxy server to bypass CORS issues when you deploy your application on your production servers
|
|
48
|
+
- **Username and password:** User credentials used to authenticate the user. Please contact us to request your username and password
|
|
49
|
+
|
|
39
50
|
#### Define an iFrame as target for the Showcase
|
|
40
51
|
|
|
41
|
-
This example uses Vue's ref attribute to reference the target iFrame. Please consult the official documentation of your preferred framework of choice on how to
|
|
52
|
+
This example uses Vue's ref attribute to reference the target iFrame. Please consult the official documentation of your preferred framework of choice on how to reference a target component.
|
|
42
53
|
|
|
43
54
|
````html
|
|
44
55
|
<template>
|
|
@@ -164,13 +175,15 @@ export default defineConfig(({ command, mode }) => {
|
|
|
164
175
|
// ex: const spaceUrl = "https://my.matterport.com/show/?m=qSGGhhjTYbN";
|
|
165
176
|
|
|
166
177
|
const auth = {
|
|
178
|
+
apiURL: 'YOUR-API-URL'
|
|
167
179
|
apiKey: apiKey,
|
|
168
180
|
user: authUser
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
const config: IMPConfig = {
|
|
172
184
|
iframeId: 'mp-showcase',
|
|
173
|
-
bundlePath: "path/to/bundle/", // optional. Iframe src should be something like this: <bundlePath>/
|
|
185
|
+
bundlePath: "path/to/bundle/", // optional. Iframe src should be something like this: <bundlePath>/showcase.html?
|
|
186
|
+
appKey: 'YOUR-APP-KEY'
|
|
174
187
|
play: 1,
|
|
175
188
|
}
|
|
176
189
|
|
|
@@ -196,7 +209,7 @@ Or programmatically using methods defined in this library.
|
|
|
196
209
|
|
|
197
210
|
Vue is the framework we use in the code snippets provided above. If your team intends to use other frameworks like Svelte or React.
|
|
198
211
|
|
|
199
|
-
**
|
|
212
|
+
**Svelte**: Setup your svelte project with Architwin
|
|
200
213
|
|
|
201
214
|
````javascript
|
|
202
215
|
<script>
|
|
@@ -215,6 +228,7 @@ Vue is the framework we use in the code snippets provided above. If your team in
|
|
|
215
228
|
const spaceUrl = "https://basic-dev.rev-kitten.com/showcase/model3d_public/1?token=e707880f-0fc5-48a6-b3f6-643a19f81464";
|
|
216
229
|
|
|
217
230
|
const auth = {
|
|
231
|
+
apiURL: 'YOUR-API-URL',
|
|
218
232
|
apiKey: apiKey,
|
|
219
233
|
user: authUser
|
|
220
234
|
}
|
|
@@ -222,6 +236,7 @@ Vue is the framework we use in the code snippets provided above. If your team in
|
|
|
222
236
|
const config = {
|
|
223
237
|
iframeId: 'mp-showcase',
|
|
224
238
|
play: 1,
|
|
239
|
+
appKey: 'YOUR-APP-KEY'
|
|
225
240
|
} as IMPConfig
|
|
226
241
|
|
|
227
242
|
// more config options as explain later
|
|
@@ -269,12 +284,14 @@ export function App(props) {
|
|
|
269
284
|
const spaceUrl = "https://basic-dev.rev-kitten.com/showcase/model3d_public/1?token=e707880f-0fc5-48a6-b3f6-643a19f81464";
|
|
270
285
|
|
|
271
286
|
const auth = {
|
|
287
|
+
apiURL: 'YOUR-API-URL',
|
|
272
288
|
apiKey: apiKey,
|
|
273
289
|
user: authUser
|
|
274
290
|
};
|
|
275
291
|
|
|
276
292
|
const config = {
|
|
277
293
|
iframeId: 'mp-showcase',
|
|
294
|
+
appKey: 'YOUR-APP-KEY'
|
|
278
295
|
play: 1
|
|
279
296
|
};
|
|
280
297
|
|
|
@@ -327,8 +344,9 @@ connectSpace(spaceUrl, auth, config)
|
|
|
327
344
|
|
|
328
345
|
```typescript
|
|
329
346
|
export interface IMPConfig{
|
|
330
|
-
iframeId: string,
|
|
331
|
-
|
|
347
|
+
iframeId: string, // required
|
|
348
|
+
appKey?: string,
|
|
349
|
+
bundlePath?: string,
|
|
332
350
|
play?: 0 | 1,
|
|
333
351
|
qs?: 0 | 1,
|
|
334
352
|
tour?: 0 | 1 | 2 | 3,
|
|
@@ -338,6 +356,8 @@ export interface IMPConfig{
|
|
|
338
356
|
|
|
339
357
|
**iframeId:** string: The `id` of the target iframe where the 3D space will be loaded into.
|
|
340
358
|
|
|
359
|
+
**appKey:** your appKey is used to authenticate your connection when loading the 3D showcase. For security purposes, the appKey can only be used by a domain (e.g. awesomesite.com) it is associated with. This key is important especially when you launch your app in production and utilize your own site domain. Please contact us to request your appKey
|
|
360
|
+
|
|
341
361
|
**bundlePath?:** string: bundlePath is an optional key that can be set for projects whose project structure requires a custom path to the bundle SDK provided by matterport. If not set, the package will by default set the bundle path to the bundle SDK found inside the architwin package in node_modules.
|
|
342
362
|
|
|
343
363
|
*Example:*
|
|
@@ -346,7 +366,6 @@ export interface IMPConfig{
|
|
|
346
366
|
|
|
347
367
|
This will resolve internally to `"assets/customBundleName/showcase.html?someparams"`
|
|
348
368
|
|
|
349
|
-
|
|
350
369
|
**play?:** 0 | 1, default = 0
|
|
351
370
|
|
|
352
371
|
- 0 Shows a Play button ▶️️ on the iframe. The user must press the Play button ▶️️ to open the Matterport model.
|
|
@@ -407,9 +426,6 @@ This will move the user to the nearest Sweep marker in the indicated direction.
|
|
|
407
426
|
````typescript
|
|
408
427
|
<script lang="ts">
|
|
409
428
|
import * as atwin from 'architwin';
|
|
410
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
411
|
-
import { onMounted, ref } from 'vue';
|
|
412
|
-
|
|
413
429
|
...
|
|
414
430
|
await atwin.moveInDirection("FORWARD")
|
|
415
431
|
await atwin.moveInDirection("FORWARD")
|
|
@@ -438,8 +454,6 @@ Note, cameraPan will work only in *Dollhouse* mode.
|
|
|
438
454
|
````typescript
|
|
439
455
|
<script lang="ts">
|
|
440
456
|
import * as atwin from 'architwin';
|
|
441
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
442
|
-
import { onMounted, ref } from 'vue';
|
|
443
457
|
|
|
444
458
|
...
|
|
445
459
|
// rotate around X axis, last parameter is the Speed of rotation in seconds
|
|
@@ -514,8 +528,6 @@ moveToSweep(sweepId) - // to move to a specific Sweep
|
|
|
514
528
|
````typescript
|
|
515
529
|
<script lang="ts">
|
|
516
530
|
import * as atwin from 'architwin';
|
|
517
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
518
|
-
import { onMounted, ref } from 'vue';
|
|
519
531
|
|
|
520
532
|
...
|
|
521
533
|
// get current sweep data
|
|
@@ -566,8 +578,6 @@ getSweepPosition(): {x: number, y: number, z: number} - // returns the position
|
|
|
566
578
|
````typescript
|
|
567
579
|
<script lang="ts">
|
|
568
580
|
import * as atwin from 'architwin';
|
|
569
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
570
|
-
import { onMounted, ref } from 'vue';
|
|
571
581
|
|
|
572
582
|
...
|
|
573
583
|
// get all Sweeps in loaded Space
|
|
@@ -605,8 +615,6 @@ pauseVideo(videoId: number) - // pause a video screen
|
|
|
605
615
|
````typescript
|
|
606
616
|
<script lang="ts">
|
|
607
617
|
import * as atwin from 'architwin';
|
|
608
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
609
|
-
import { onMounted, ref } from 'vue';
|
|
610
618
|
|
|
611
619
|
...
|
|
612
620
|
// play a video
|
|
@@ -652,9 +660,6 @@ cameraRotate(x: number, y: number, speed: number) - // rotates the camera view,
|
|
|
652
660
|
````typescript
|
|
653
661
|
<script lang="ts">
|
|
654
662
|
import * as atwin from 'architwin';
|
|
655
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
656
|
-
import { onMounted, ref } from 'vue';
|
|
657
|
-
|
|
658
663
|
...
|
|
659
664
|
|
|
660
665
|
// get current Camera Pose
|
|
@@ -717,9 +722,6 @@ getNearbyObjects(type?: '3DX' | 'SLIDESHOW' | 'VIDEO', distance?: number = 2)
|
|
|
717
722
|
````typescript
|
|
718
723
|
<script lang="ts">
|
|
719
724
|
import * as atwin from 'architwin';
|
|
720
|
-
import type { IMPConfig, IUser } from 'architwin/lib/types';
|
|
721
|
-
import { onMounted, ref } from 'vue';
|
|
722
|
-
|
|
723
725
|
...
|
|
724
726
|
|
|
725
727
|
// get all nearby objects
|
package/lib/architwin.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { MpSdk } from "../bundle/sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type IUser, type IMPConfig, type ISweep, type ITagPublic, type NearbyPayload, type NearbyObjects, type IObjectData } from "./types";
|
|
3
3
|
declare let tags: ITagPublic[];
|
|
4
4
|
declare let sweeps: any;
|
|
5
|
+
declare let selectedObject: IObjectData;
|
|
6
|
+
/**
|
|
7
|
+
* initialization: loginUser, iframe, space, tags, objects
|
|
8
|
+
* @constructor
|
|
9
|
+
* @param url - the URL of the space you wish to connect to.
|
|
10
|
+
* @param auth - an authentication object with the apiKey and user credentials.
|
|
11
|
+
* @param config - a config object to set some default space behavior.
|
|
12
|
+
*/
|
|
5
13
|
declare function connectSpace(url: string, auth: {
|
|
6
14
|
apiURL?: string;
|
|
7
15
|
apiKey: string;
|
|
@@ -60,4 +68,4 @@ declare const atwin: {
|
|
|
60
68
|
setViewMode: typeof setViewMode;
|
|
61
69
|
getNearbyObjects: typeof getNearbyObjects;
|
|
62
70
|
};
|
|
63
|
-
export { atwin as default, tags, sweeps, connectSpace, disconnectSpace, gotoTag, getCurrentSweep, getCurrentSweepPosition, moveToSweep, getNearbySweeps, pauseVideo, playVideo, getCurrentCameraPose, getCameraPosition, moveInDirection, cameraLookAt, cameraPan, cameraRotate, getViewMode, setViewMode, getNearbyObjects, };
|
|
71
|
+
export { atwin as default, tags, sweeps, selectedObject, connectSpace, disconnectSpace, gotoTag, getCurrentSweep, getCurrentSweepPosition, moveToSweep, getNearbySweeps, pauseVideo, playVideo, getCurrentCameraPose, getCameraPosition, moveInDirection, cameraLookAt, cameraPan, cameraRotate, getViewMode, setViewMode, getNearbyObjects, };
|
package/lib/architwin.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P((function(resolve){resolve(value)}))}return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{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;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};import axios from"axios";import{distance}from"mathjs";import JSZip from"jszip";import JSZipUtils from"jszip-utils";var _config={aws:{region:"ap-northeast-1",accessKeyId:"AKIAVVUXZ66KW7GBSW7A",secretAccessKey:"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'"},mp:{sdkKey:"a3ae8341bd8f44899eba16df86307d7d",urlParams:["help","play","nt","qs","brand","dh","tour","gt","hr","mls","mt","tagNav","pin","portal","f","fp","lang","kb","lp","st","title","tourcta","wts","ts","hl","vr","nozoom","search","wh"]}};var _apiURL="http://localhost:5173/api";var sdkKey=_config.mp.sdkKey;var urlParams=_config.mp.urlParams;var _iframe={};var _api={};var _space={};var _atwin={};var _tags=[];var tags=[];var sweeps=[];var _allSlideShow=[];var _slideShowImage=[];var _currentSlideShowID=0;var _currentSlideIndex=0;var _currentSlideShow=null;var _timer=null;var _videos=[];var _currentViewMode="";var _3DXObject=[];var _unrenderedObjects=[];var _transformControlNode;var _inputControlComponent=null;var _selectedObject={};var _previousTimeStamp=0;var _renderDistance=null;var _autoDetectNearbyObj=false;var _currentSweep={};var _currentCameraPose={};var _sweeps=[];var _isInitialLoad=true;function connectSpace(url,auth,config){return __awaiter(this,void 0,void 0,(function(){var lastString,api,showcase;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("connectSpace()");console.log("__config",config);if("apiURL"in auth){lastString=auth.apiURL.slice(-1);if(lastString!=="/"){auth.apiURL+="/"}_apiURL=auth.apiURL}console.log("_apiURL",_apiURL);api=axios.create({baseURL:_apiURL,headers:{"Access-Control-Allow-Origin":"*","Content-Type":"application/json",Authorization:auth.apiKey}});_api=api;showcase=document.getElementById(config.iframeId);_iframe=showcase;if(!url.includes("https://my.matterport.com/show/"))return[3,2];console.log("URL IS MATTERPORT");return[4,loadDefaultMpSpace(url,config,showcase)];case 1:_a.sent();return[3,4];case 2:console.log("URL IS REV-KITTEN");return[4,loadAtwinSpace(url,auth,config,showcase)];case 3:_a.sent();_a.label=4;case 4:return[2]}}))}))}function loadDefaultMpSpace(url,config,showcase){return __awaiter(this,void 0,void 0,(function(){var iframeSrc,showcaseWindow,_setTags;var _this=this;return __generator(this,(function(_a){console.log("loadDefaultMpSpace(url: string, showcase: HTMLIFrameElement)",url,showcase);iframeSrc=getIframeSrc(config,url);console.log("__iframeSrc",iframeSrc);showcase.src=iframeSrc;showcaseWindow=showcase.contentWindow;showcase.addEventListener("load",(function(){return __awaiter(_this,void 0,void 0,(function(){var e_1;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log('iframe.addEventListener("load")');console.log("showcaseWindow",showcaseWindow);_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,showcaseWindow.MP_SDK.connect(showcaseWindow)];case 2:_atwin=_a.sent();console.log("Hello Bundle SDK",_atwin);_atwin.App.state.subscribe((function(appState){return __awaiter(_this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("appState",appState);if(!(appState.phase===_atwin.App.Phase.LOADING))return[3,2];console.log("App is loading...");return[4,_setTags()];case 1:_a.sent();return[3,3];case 2:if(appState.phase===_atwin.App.Phase.STARTING){console.log("App is starting...")}else if(appState.phase===_atwin.App.Phase.PLAYING){console.log("App is playing...")}_a.label=3;case 3:return[2]}}))}))}));return[3,4];case 3:e_1=_a.sent();console.error(e_1);return[3,4];case 4:return[2]}}))}))}));_setTags=function(){return __awaiter(_this,void 0,void 0,(function(){var mpTags,filteredMpTags;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("_setTags()");return[4,_atwin.Mattertag.getData()];case 1:mpTags=_a.sent();if(mpTags){filteredMpTags=mpTags.map((function(i){var x={};x.id=i.sid;x.name=i.label;return x}));tags=filteredMpTags;console.log("tags",tags)}return[2]}}))}))};return[2]}))}))}function loadAtwinSpace(url,auth,config,showcase){var _a;return __awaiter(this,void 0,void 0,(function(){var spaceId,space,iframeSrc,tags,objects,showcaseWindow;var _this=this;return __generator(this,(function(_b){switch(_b.label){case 0:console.log("loadAtwinSpace(url: string, auth: { apiKey: string; user: IUser },config: IMPConfig, showcase: HTMLIFrameElement)");spaceId=getSpaceId(url);if(!spaceId){console.error("spaceId is undefined");return[2]}if(!_isInitialLoad)return[3,2];return[4,loginUser(auth.user)];case 1:_b.sent();_b.label=2;case 2:return[4,getSpace(spaceId)];case 3:space=_b.sent();if(!space){console.error("space is undefined");return[2]}setSpace(space);iframeSrc=getIframeSrc(config,space.space_url);console.log("__iframeSrc",iframeSrc);showcase.src=iframeSrc;return[4,getTags(space)];case 4:tags=_b.sent();if(!tags){console.log("tags is undefined");return[2]}setTags(tags);return[4,get3DObjects(spaceId)];case 5:objects=_b.sent();if(!objects){console.log("objects is undefined");return[2]}if(_isInitialLoad){(_a=showcase.contentWindow)===null||_a===void 0?void 0:_a.location.reload()}_isInitialLoad=false;showcaseWindow=showcase.contentWindow;showcase.addEventListener("load",(function(){return __awaiter(_this,void 0,void 0,(function(){var e_2;return __generator(this,(function(_a){switch(_a.label){case 0:console.log('iframe.addEventListener("load")');console.log("showcaseWindow",showcaseWindow);if(!showcaseWindow.MP_SDK)return[3,5];_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,showcaseWindow.MP_SDK.connect(showcaseWindow)];case 2:_atwin=_a.sent();console.log("Hello Bundle SDK",_atwin);onShowcaseConnect();return[3,4];case 3:e_2=_a.sent();console.error(e_2);return[3,4];case 4:return[3,6];case 5:console.log("No showcaseWindow.MP_SDK found");_a.label=6;case 6:return[2]}}))}))}));return[2]}}))}))}function onShowcaseConnect(){return __awaiter(this,void 0,void 0,(function(){var modelData,e_3;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("onShowcaseConnect()");_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_atwin.Model.getData()];case 2:modelData=_a.sent();console.log("Model sid:"+modelData.sid);_atwin.App.state.subscribe((function(appState){return __awaiter(_this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("appState",appState);if(!(appState.phase===_atwin.App.Phase.LOADING))return[3,1];console.log("App is loading...");return[3,7];case 1:if(!(appState.phase===_atwin.App.Phase.STARTING))return[3,3];console.log("App is starting...");return[4,hideTags()];case 2:_a.sent();return[3,7];case 3:if(!(appState.phase===_atwin.App.Phase.PLAYING))return[3,7];console.log("App is playing...");return[4,showTags(_tags)];case 4:_a.sent();return[4,getSweeps()];case 5:_a.sent();return[4,setLighting()];case 6:_a.sent();_atwin.Sweep.current.subscribe((function(currentSweep){if(currentSweep.sid===""){console.log("Not currently stationed at a sweep position")}else{_currentSweep=currentSweep;console.log("Currently at sweep",_currentSweep.id);videoAutoPlay()}}));_atwin.Camera.pose.subscribe((function(pose){return __awaiter(this,void 0,void 0,(function(){var hasElapsed;return __generator(this,(function(_a){switch(_a.label){case 0:_currentCameraPose=pose;console.log("Current Camera Pose",_currentCameraPose);hasElapsed=hasTimeElapsed(300);if(!hasElapsed)return[3,2];console.log("_unrenderedObjects "+_unrenderedObjects.length);return[4,renderOnDemand()];case 1:_a.sent();_a.label=2;case 2:if(hasTimeElapsed(1e3)&&_autoDetectNearbyObj){getNearbyObjects({type:"ALL",distance:2})}return[2]}}))}))}));_atwin.Mode.current.subscribe((function(mode){_currentViewMode=mode}));_a.label=7;case 7:return[2]}}))}))}));return[3,4];case 3:e_3=_a.sent();console.error(e_3);return[3,4];case 4:return[2]}}))}))}function hasTimeElapsed(maxTime){var currentTimestamp=Date.now();var differenceInMilliseconds=(currentTimestamp-_previousTimeStamp)%1e3;_previousTimeStamp=currentTimestamp;if(differenceInMilliseconds>=maxTime){console.log("Elapsed more than ".concat(maxTime));return true}else{console.log("Elapsed less than ".concat(maxTime));return false}}function getNearbyUnrenderedObjects(payload){var toBeRendered=[];var currentPose={x:_currentCameraPose.position.x,y:_currentCameraPose.position.y};toBeRendered=_unrenderedObjects.filter((function(obj){var obj_pos={x:obj.object_position.x,y:obj.object_position.y};var distance=calculateDistance(currentPose,obj_pos);return distance<payload.distance}));var filtered=_unrenderedObjects.filter((function(obj){return toBeRendered.indexOf(obj)===-1}));_unrenderedObjects=filtered;console.log("render toBeRendered "+toBeRendered.length);return toBeRendered}function getNearbyObjects(payload){if(payload.type===undefined||payload.type===""){payload.type="ALL"}if(payload.distance===undefined){payload.distance=2}var pos1={x:_currentCameraPose.position.x,y:_currentCameraPose.position.y};var three_d=[];var videos=[];var slideshows=[];if(payload.type==="ALL"||"3DX"){three_d=_3DXObject.filter((function(obj){var pos2={x:obj.position.x,y:obj.position.y};var distance=calculateDistance(pos1,pos2);console.log("3DX Distance: "+distance);return distance<payload.distance}))}if(payload.type==="ALL"||"VIDEO"){videos=_videos.filter((function(vid){var pos2={x:vid.node.position.x,y:vid.node.position.y};var distance=calculateDistance(pos1,pos2);console.log("Video Distance: "+distance);return distance<payload.distance}))}if(payload.type==="ALL"||"SLIDESHOW"){slideshows=_allSlideShow.filter((function(slide){var pos2={x:slide.node.position.x,y:slide.node.position.y};var distance=calculateDistance(pos1,pos2);console.log("Slideshow Distance: "+distance);return distance<payload.distance}))}console.log("nearby3DXObjects "+three_d.length);console.log("nearbyVideos "+videos.length);console.log("nearbySlideshows "+slideshows.length);return{x3d:three_d,videos:videos,slideshows:slideshows}}function show3DObjects(object){var _a;return __awaiter(this,void 0,void 0,(function(){var sceneObject,id,modelNode,component;return __generator(this,(function(_b){switch(_b.label){case 0:return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_b.sent()[0];id=Math.floor(Math.random()*20);modelNode=sceneObject.addNode(id.toString());component=modelNode.addComponent(getComponentLoader(object),{url:(_a=object.object_data)===null||_a===void 0?void 0:_a.amazon_uri});if(!component.inputs){console.error("component.inputs is undefined");return[2]}component.inputs.localScale={x:object.object_scale.x,y:object.object_scale.y,z:object.object_scale.z};modelNode.obj3D.position.set(object.object_position.x,object.object_position.y,object.object_position.z);modelNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);_3DXObject.push(modelNode);console.log("_3DXObject "+_3DXObject.length);modelNode.start();component.spyOnEvent(new ClickSpy(object,modelNode,component));return[2]}}))}))}function renderOnDemand(){return __awaiter(this,void 0,void 0,(function(){var objects;var _this=this;return __generator(this,(function(_a){if(_unrenderedObjects.length!==0){console.log("renderOnDemand()");objects=getNearbyUnrenderedObjects({type:"",distance:2});objects.forEach((function(obj){return __awaiter(_this,void 0,void 0,(function(){var _a,_b,_c,_d;return __generator(this,(function(_e){switch(_e.label){case 0:if(!(((_a=obj.object_data)===null||_a===void 0?void 0:_a.object_type)==="FBX"||((_b=obj.object_data)===null||_b===void 0?void 0:_b.object_type)==="GLB"))return[3,2];return[4,show3DObjects(obj)];case 1:_e.sent();return[3,6];case 2:if(!(((_c=obj.object_data)===null||_c===void 0?void 0:_c.object_type)==="MP4"))return[3,4];return[4,showVideoObjects(obj)];case 3:_e.sent();return[3,6];case 4:if(!(((_d=obj.object_data)===null||_d===void 0?void 0:_d.object_type)==="ZIP"))return[3,6];return[4,showSlideScreenModel(obj)];case 5:_e.sent();_e.label=6;case 6:return[2]}}))}))}))}return[2]}))}))}function getIframeSrc(config,url){console.log("getIframeSrc()",config,url);var modelId=url.split("?m=")[1];if(!modelId){console.error("modelId is undefined");return""}var src="";if("bundlePath"in config){var lastString=config.bundlePath.slice(-1);if(lastString!=="/"){config.bundlePath+="/"}src+="".concat(config.bundlePath,"showcase.html?m=").concat(modelId,"&applicationKey=").concat(sdkKey,"&newtags=1")}else{if(config.prod===undefined||config.prod===null){config.prod=true}if(config.prod){src+="node_modules/architwin/bundle/showcase.html?m=".concat(modelId,"&applicationKey=").concat(sdkKey,"&newtags=1")}else{src+="architwin/bundle/showcase.html?m=".concat(modelId,"&applicationKey=").concat(sdkKey,"&newtags=1")}}console.log("__src",src);for(var _i=0,urlParams_1=urlParams;_i<urlParams_1.length;_i++){var param=urlParams_1[_i];if(param in config){src+="&".concat(param,"=").concat(config[param])}}return src}function loginUser(user){return __awaiter(this,void 0,void 0,(function(){var response;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("loginUser(user)",user);return[4,_api.post("/cas/tickets?email="+user.email+"&password="+user.password)];case 1:response=_a.sent();console.log("loginUser, response",response.status,response.data);if(response.status==200){return[2,response.data]}else{return[2,response]}return[2]}}))}))}function getSpace(spaceId){return __awaiter(this,void 0,void 0,(function(){var response;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("getShowcase(spaceId: string)",spaceId);return[4,_api.get("/v1/showcases/id/".concat(spaceId))];case 1:response=_a.sent();console.log("response",response);if(response.status===200){if(response.data.data.length===0){console.error("No data")}return[2,response.data.data[0]]}else{console.error("Error in fetchShowcase()"+response)}return[2,null]}}))}))}function getSpaceId(url){var urlArray=url.split(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/);var path=urlArray[5];var spaceId=path.split("/")[3];console.log("urlArray",urlArray);console.log("path",path);if(!spaceId){console.error("spaceId is undefined");return}return spaceId}function setSpace(space){console.log("setSpace(space: ISpace)",space);_space=space}function getTags(space){return __awaiter(this,void 0,void 0,(function(){var response,tags_1,error_1;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("getTags()");_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_api.get("/v1/tags/showcase-id/".concat(space.id))];case 2:response=_a.sent();console.log("response",response);if(response.status===200){tags_1=response.data.data;if(!tags_1){console.error("tags is undefined")}return[2,tags_1]}else{console.error("Custom Error: Unable to fetch tags")}return[3,4];case 3:error_1=_a.sent();console.error(error_1);return[3,4];case 4:return[2,null]}}))}))}function setTags(tags){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){console.log("setTags()",tags);_tags=tags.map((function(tag){tag.json_data=JSON.parse(tag.json_data);tag.json_data.id=tag.json_data.sid;return tag}));mapTags(_tags);return[2]}))}))}function get3DObjects(showcase_id){return __awaiter(this,void 0,void 0,(function(){var id,response,showcase_objects,getRequests,response_1,object_data_1,threed_objects,error_2,error_3;return __generator(this,(function(_a){switch(_a.label){case 0:if(!showcase_id)return[3,8];_a.label=1;case 1:_a.trys.push([1,7,,8]);id=parseInt(showcase_id);console.log("showcase_id "+id);return[4,_api.get("/v1/showcase-objects/showcase-id/".concat(id))];case 2:response=_a.sent();showcase_objects=response.data.data;console.log("showcase_objects "+JSON.stringify(showcase_objects));getRequests=showcase_objects.map((function(obj){return _api.get("/v1/objects/id/".concat(obj.object_id))}));_a.label=3;case 3:_a.trys.push([3,5,,6]);return[4,axios.all(getRequests)];case 4:response_1=_a.sent();object_data_1=response_1.map((function(res){return res.data.data[0]}));console.log("object_data"+JSON.stringify(object_data_1));threed_objects=showcase_objects.map((function(showcase){var target=object_data_1.find((function(obj){return obj.id===showcase.object_id}));if(target){showcase.object_data=target}if(showcase.object_position){showcase.object_position=typeof showcase.object_position==="string"?JSON.parse(showcase.object_position):showcase.object_position}if(showcase.object_rotation){showcase.object_rotation=typeof showcase.object_rotation==="string"?JSON.parse(showcase.object_rotation):showcase.object_rotation}if(showcase.object_scale){showcase.object_scale=typeof showcase.object_scale==="string"?JSON.parse(showcase.object_scale):showcase.object_scale}return showcase}));console.log("get3DObjectsByShowcaseId "+JSON.stringify(threed_objects));_unrenderedObjects=threed_objects;return[2,threed_objects];case 5:error_2=_a.sent();console.error("threed_objects "+error_2);return[3,6];case 6:return[3,8];case 7:error_3=_a.sent();console.error("get3DObjectsByShowcaseId "+error_3);return[3,8];case 8:return[2,[]]}}))}))}function gotoTag(tag_id){return __awaiter(this,void 0,void 0,(function(){var error_4;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("gotoTag(tag: tag_id)",tag_id);if(!tag_id){console.error("tag is undefined");return[2]}_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_atwin.Mattertag.navigateToTag(tag_id,_atwin.Mattertag.Transition.FLY)];case 2:_a.sent();return[3,4];case 3:error_4=_a.sent();console.error(error_4);return[3,4];case 4:return[2]}}))}))}function showTags(tags){return __awaiter(this,void 0,void 0,(function(){var _this=this;return __generator(this,(function(_a){tags.forEach((function(tag,indx){return __awaiter(_this,void 0,void 0,(function(){var mpData,tagIds,attachmentId1,error_5;return __generator(this,(function(_a){switch(_a.label){case 0:mpData=tag.json_data;if(!mpData){console.error("tag.json_data/mpData is undefined");return[2]}return[4,_atwin.Tag.add({anchorPosition:mpData.anchorPosition,color:mpData.color,description:mpData.description,id:mpData.sid,label:mpData.label,stemVector:mpData.stemVector,stemVisible:mpData.stemVisible})];case 1:tagIds=_a.sent();if(!tagIds)return[3,6];tag.json_data.id=tagIds[0];if(!(tag.json_data.media&&tag.json_data.media.src.trim()!==""))return[3,6];_a.label=2;case 2:_a.trys.push([2,5,,6]);console.log("Attaching media...");return[4,_atwin.Tag.registerAttachment(tag.json_data.media.src)];case 3:attachmentId1=_a.sent()[0];tag.json_data["attachments"]=[attachmentId1];return[4,_atwin.Tag.attach(tag.json_data.sid,attachmentId1)];case 4:_a.sent();console.log("Media successfully attached");return[3,6];case 5:error_5=_a.sent();console.warn("Custom warn: Media not attached: Invalid media src link: "+error_5);console.warn("mediaSrc: ".concat(tag.json_data.media.src," | tag index: ").concat(indx));return[3,6];case 6:return[2]}}))}))}));console.log("tags",_tags);return[2]}))}))}function hideTags(){return __awaiter(this,void 0,void 0,(function(){var tags,tagIds;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("hideTags()");return[4,_atwin.Mattertag.getData()];case 1:tags=_a.sent();if(!tags)return[3,3];tagIds=tags.map((function(i){return i.sid}));return[4,_atwin.Mattertag.remove(tagIds)];case 2:_a.sent();console.log("Tags removed in space: ",tagIds);_a.label=3;case 3:return[2]}}))}))}function mapTags($tags){console.log("mapTags()",$tags);tags=$tags.map((function(i){var x={};x.id=i.json_data.id;x.name=i.json_data.label;return x}));console.log("tags",tags)}function getCurrentSweep(){return _currentSweep}function getCurrentCameraPose(){return _currentCameraPose}function getCameraPosition(){return _currentCameraPose.position}function getCurrentSweepPosition(){return _currentSweep.position}function getSweeps(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){console.log("Getting Sweeps in Space");_atwin.Sweep.data.subscribe({onCollectionUpdated:function(collection){console.log("Sweeps In Space",collection);if(!collection){console.log("No Sweeps in loaded Space")}_sweeps=collection;var sw=Object.values(_sweeps);sweeps=sw.map((function(item){return{id:item.uuid,position:item.position,neighbors:item.neighbors}}))}});return[2,null]}))}))}function moveToSweep(sweepId){return __awaiter(this,void 0,void 0,(function(){var transition,transitionTime;return __generator(this,(function(_a){transition=_atwin.Sweep.Transition.FLY;transitionTime=2e3;console.log("Sweep Move",sweepId);_atwin.Sweep.moveTo(sweepId,{transition:transition,transitionTime:transitionTime}).then((function(){console.log("Sweep Arrived at sweep "+sweepId)})).catch((function(error){console.log("Sweep Error on Arriving",error)}));return[2]}))}))}function getNearbySweeps(sweepId){return __awaiter(this,void 0,void 0,(function(){var nearby;return __generator(this,(function(_a){switch(_a.label){case 0:if(!sweepId)return[3,2];return[4,sweeps.find((function(item){return item.id==sweepId})).neighbors];case 1:nearby=_a.sent();console.log("Nearby Sweeps",nearby);return[2,nearby];case 2:console.log("No Nearby Sweeps");_a.label=3;case 3:return[2]}}))}))}function getComponentLoader(object){if(object&&object.object_data){var index=object.object_data.object_type;var component={FBX:_atwin.Scene.Component.FBX_LOADER,GLB:_atwin.Scene.Component.GLTF_LOADER,MP4:"liveVideo",ZIP:"slideScreenModel"};return component[index]||""}return""}function setSelectedObject(data,node,component){_selectedObject={object:data,component:component,node:node};console.log("setSelectedObject()")}function setLighting(){return __awaiter(this,void 0,void 0,(function(){var sceneObject,lights;return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];lights=sceneObject.addNode();lights.addComponent("mp.directionalLight",{intensity:.6,color:{r:1,g:1,b:1}});lights.addComponent("mp.ambientLight",{intensity:.6,color:{r:1,g:1,b:1}});lights.start();return[2]}}))}))}function clearTransformControls(){if(!_transformControlNode){console.error("_transformControlNode is undefined");return}if(_inputControlComponent==null||!_inputControlComponent){console.error("_inputControlComponent is undefined");return}_transformControlNode.stop();console.log("clearTransformControls()")}function setTransformControls(selectedObject,mode){if(mode===void 0){mode="translate"}return __awaiter(this,void 0,void 0,(function(){var sceneObject,transformNode,transformComponent,inputComponent;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("Object to be transformed "+selectedObject.object.object_data.name);clearTransformControls();return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];transformNode=sceneObject.addNode();transformComponent=transformNode.addComponent("mp.transformControls");_transformControlNode=transformNode;inputComponent=transformNode.addComponent("mp.input",{eventsEnabled:true,userNavigationEnabled:true});_inputControlComponent=inputComponent.spyOnEvent(new ClickSpy(selectedObject.object,selectedObject.node,selectedObject.component));transformNode.start();transformComponent.inputs.selection=selectedObject.node;transformComponent.inputs.mode=mode;return[2]}}))}))}function calculateDistance(pos1,pos2){var dx=pos2.x-pos1.x;var dy=pos2.y-pos1.y;return Math.sqrt(dx*dx+dy*dy)}function showVideoObjects(object){var _a,_b;return __awaiter(this,void 0,void 0,(function(){var sceneObject,liveStreamNode,liveStreamComponent;return __generator(this,(function(_c){switch(_c.label){case 0:return[4,createVideoComponent()];case 1:_c.sent();return[4,_atwin.Scene.createObjects(1)];case 2:sceneObject=_c.sent()[0];liveStreamNode=sceneObject.addNode();return[4,liveStreamNode.addComponent(getComponentLoader(object),{url:(_a=object.object_data)===null||_a===void 0?void 0:_a.amazon_uri})];case 3:liveStreamComponent=_c.sent();liveStreamNode.position.set(object.object_position.x,object.object_position.y,object.object_position.z);liveStreamNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);liveStreamNode.scale.set(object.object_scale.x,object.object_scale.y,object.object_scale.z);if(liveStreamComponent.outputs.loadingState!="Error"){liveStreamNode.start()}liveStreamComponent.inputs.src=(_b=object.object_data)===null||_b===void 0?void 0:_b.amazon_uri;_videos.push({data:object,component:liveStreamComponent,node:liveStreamNode,type:"VIDEO"});return[2]}}))}))}function playVideo(videoId){var videoObject=_videos.find((function(object){return object.data.id==videoId}));if(videoObject){videoObject.component.video.play()}else{console.error("Unable to find video object using that id")}}function pauseVideo(videoId){var videoObject=_videos.find((function(object){return object.data.id==videoId}));if(videoObject){videoObject.component.video.pause()}else{console.error("Unable to find video object using that id")}}function videoAutoPlay(){function nearestVideo(videoObject){return __awaiter(this,void 0,void 0,(function(){var videoPosition,cameraPosition,computedDistance;return __generator(this,(function(_a){videoPosition=videoObject.data.object_position;cameraPosition=getCurrentSweepPosition();computedDistance=distance([cameraPosition.x,cameraPosition.y,cameraPosition.z],[videoPosition.x,videoPosition.y,videoPosition.z]);try{if(videoObject.data.autoplay&&videoObject.data.autoplay_distance&&computedDistance<videoObject.data.autoplay_distance){videoObject.component.video.play()}else{videoObject.component.video.pause()}}catch(e){console.error("Unable to play or stop video")}return[2]}))}))}_videos.forEach((function(videoObject){return nearestVideo(videoObject)}))}function createVideoComponent(){function videoRenderer(){this.inputs={visible:true,userNavigationEnabled:true,eventsEnabled:true,colliderEnabled:true,src:null};this.outputs={texture:null,video:null,aspect:720/480};this.onInit=function(){this.video;this.texture};this.onEvent=function(eventType,eventData){};this.onInputsUpdated=function(previous){this.releaseTexture();var THREE=this.context.three;if(!this.inputs.src){this.video.src="";return}if(this.inputs.src instanceof HTMLVideoElement){this.video=this.inputs.src}else{this.video=this.createVideoElement();if(typeof this.inputs.src==="string"){this.video.src=this.inputs.src}else{this.video.srcObject=this.inputs.src}this.video.load()}this.texture=new THREE.VideoTexture(this.video);this.texture.minFilter=THREE.LinearFilter;this.texture.magFilter=THREE.LinearFilter;this.texture.format=THREE.RGBFormat;var geometry=new THREE.PlaneGeometry(1,1);geometry.scale(1,480/720,1);geometry.translate(0,.33,0);this.material=new THREE.MeshBasicMaterial({map:this.texture,side:THREE.DoubleSide});var mesh=new THREE.Mesh(geometry,this.material);this.outputs.objectRoot=mesh;this.outputs.collider=mesh;mesh.visible=this.inputs.visible;this.outputs.texture=this.texture;this.outputs.video=this.video};this.releaseTexture=function(){if(this.texture){this.outputs.texture=null;this.texture.dispose()}};this.createVideoElement=function(){var video=document.createElement("video");video.setAttribute("id","htmlLivestreamVideo");video.crossOrigin="anonymous";video.setAttribute("height","480");video.setAttribute("width","720");video.setAttribute("webkit-playsinline","webkit-playsinline");video.setAttribute("controls","controls");video.muted=false;video.loop=true;video.volume=1;return video};this.onTick=function(tickDelta){};this.onDestroy=function(){this.material.dispose()};this.spyOnEvent=function(payload){console.log("payload",payload)}}function makeVideoRender(){return new videoRenderer}_atwin.Scene.register("liveVideo",makeVideoRender)}function createSlideScreenModel(){function SlideScreenModelRenderer(){this.inputs={src:null,userNavigationEnabled:true,eventsEnabled:true,colliderEnabled:true,visible:true};this.outputs={texture:null,t_image:null};this.onInit=function(){this.texture;this.t_image;this.material;this.mesh};this.events={"INTERACTION.CLICK":true};this.onEvent=function(eventType,eventData){return __awaiter(this,void 0,void 0,(function(){var slideshow_1,mousePosition,planePosition;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("onEventSlideShow",eventType,eventData);if(!(eventType=="INTERACTION.CLICK"))return[3,2];if(!(_allSlideShow.length>0))return[3,2];slideshow_1=_allSlideShow.filter((function(l){var _a,_b,_c,_d;return(_d=((_b=(_a=l.collider)===null||_a===void 0?void 0:_a.collider)===null||_b===void 0?void 0:_b.uuid)==((_c=eventData.collider)===null||_c===void 0?void 0:_c.uuid))!==null&&_d!==void 0?_d:false}))[0];console.log("slideShow eventData",slideshow_1);if(!(slideshow_1!=null))return[3,2];console.log("slideShow eventData",slideshow_1);return[4,getMousePosition()];case 1:mousePosition=_a.sent();planePosition=slideshow_1.node.obj3D.position;console.log("MOUSE POSITION",mousePosition);console.log("PLANE POSITION",planePosition);if(slideshow_1.object.object_type=="ZIP"){if(slideshow_1.id!=_currentSlideShowID){_currentSlideIndex=_slideShowImage.find((function(elem){return elem.id===slideshow_1.id})).idx;console.log("CURRENT INDEX",_currentSlideIndex);_currentSlideShow=_slideShowImage.find((function(elem){return elem.id===slideshow_1.id})).images;console.log("CURRENT SLIDE",_currentSlideShow)}if(slideshow_1.id==_currentSlideShowID){console.log("ChangeImage",slideshow_1,_currentSlideShowID);if(planePosition.x<mousePosition.x){console.log("LEFT SIDE");clearInterval(_timer);this.inputs.src=imageStream("prev")}else if(planePosition.y<mousePosition.y){console.log("RIGHT SIDE");clearInterval(_timer);this.inputs.src=imageStream("next")}else if(planePosition.y>mousePosition.y){console.log("AUTOPLAY");_timer=setInterval((function(){_currentSlideIndex=(_currentSlideIndex+1)%_currentSlideShow.length;console.log("CURRENT INDEX",_currentSlideIndex);_this.inputs.src=imageStream("next")}),2e3)}}else{_currentSlideShowID=slideshow_1.id}}_a.label=2;case 2:return[2]}}))}))};this.onInputsUpdated=function(previous){var _this=this;this.releaseTexture();var three=this.context.three;this.t_image=document.createElement("IMG");this.t_image.src=this.inputs.src;this.t_image.setAttribute("width","auto");this.t_image.setAttribute("height","auto");this.t_image.crossOrigin="anonymous";var planeGeo=new three.PlaneGeometry(1.5,1.5);planeGeo.translate(0,.33,0);if(previous.src!=this.inputs.src){console.log("this.inputs.src",this.inputs.src);this.texture=(new three.TextureLoader).load(this.t_image.src,(function(tex){if(tex===void 0){tex=_this.texture}tex.minFilter=three.LinearFilter;tex.magFilter=three.LinearFilter;tex.format=three.RGBAFormat;tex.needsUpdate=true;tex.onUpdate=_this.textureUpdated;_this.material=new three.MeshBasicMaterial({map:_this.texture,side:three.DoubleSide,transparent:true,alphaTest:.5});_this.mesh=new three.Mesh(planeGeo,_this.material);_this.mesh.scale.set(1,_this.texture.image.height/_this.texture.image.width,1);_this.outputs.objectRoot=_this.mesh;_this.outputs.collider=_this.mesh;_this.outputs.texture=_this.texture;_this.outputs.t_image=_this.t_image}))}if(this.mesh!=null){this.mesh.visible=this.inputs.visible}};this.textureUpdated=function(params){console.log("Update Callback",params)};this.releaseTexture=function(){if(this.texture){this.outputs.texture=null}};this.onTick=function(tickDelta){};this.onDestroy=function(){this.material.dispose();this.texture.dispose()}}function makeSlideScreenModelRenderer(){return new SlideScreenModelRenderer}_atwin.Scene.register("slideScreenModel",makeSlideScreenModelRenderer)}function showSlideScreenModel(object){return __awaiter(this,void 0,void 0,(function(){var sceneObject,modelNode,component,slideShow;return __generator(this,(function(_a){switch(_a.label){case 0:createSlideScreenModel();return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];modelNode=sceneObject.addNode();component=modelNode.addComponent("slideScreenModel");console.log("COMPONENT",component);modelNode.scale.set={x:object.object_scale.x,y:object.object_scale.y,z:object.object_scale.z};modelNode.obj3D.position.set(object.object_position.x,object.object_position.y,object.object_position.z);modelNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);modelNode.start();return[4,addImageToSlideShow(object.object_data,component,object.id)];case 2:_a.sent();console.log("SLIDE OUTPUT",component.outputs);slideShow={id:object.id,collider:component.outputs,object:object.object_data,node:modelNode,component:component,type:"ZIP"};_allSlideShow.push(slideShow);console.log("ALL SLIDESHOW",_allSlideShow);return[2]}}))}))}function addImageToSlideShow(data,component,objectID){return __awaiter(this,void 0,void 0,(function(){var dataList;return __generator(this,(function(_a){switch(_a.label){case 0:dataList=[];return[4,new JSZip.external.Promise((function(resolve,reject){JSZipUtils.getBinaryContent(data.amazon_uri,(function(err,data){if(err){console.log("getBI error",err);reject(err)}else{console.log("getBI success",data);resolve(data)}}))})).then((function(data){console.log("data from getBI",data);return JSZip.loadAsync(data)})).then((function(data){console.log("data from loadAsync",data);var _loop_1=function(key){if(key.includes("__MACOSX"))return"continue";if(key.includes(".DS_Store"))return"continue";if(data.files[key].dir)return"continue";var base=data.file(data.files[key].name).async("base64");base.then((function(res){dataList.push({name:data.files[key].name,path:"data:image/png;base64,".concat(res)});if(dataList.length==1){component.inputs.src="data:image/png;base64,".concat(res)}}))};for(var key in data.files){_loop_1(key)}_slideShowImage.push({id:objectID,images:dataList,idx:0,playID:null,play:false,comp:component})}))];case 1:_a.sent();return[2]}}))}))}function getMousePosition(){return __awaiter(this,void 0,void 0,(function(){var planePosition;return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Pointer.intersection.subscribe((function(intersection){planePosition=intersection.position}))];case 1:_a.sent();return[2,planePosition]}}))}))}function imageStream(direction){var diff=direction==="prev"?-1:1;var length=_currentSlideShow.length;var index=_currentSlideIndex+diff;if(index===-1){index=length-1}if(index===length){index=0}_currentSlideIndex=index;_slideShowImage.find((function(elem){return elem.id===_currentSlideShowID})).idx=index;return _currentSlideShow[_currentSlideIndex].path}function cameraRotate(x,y,speed){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Camera.rotate(x,y,{speed:speed}).then((function(){console.log("camera rotate success.",x,y)})).catch((function(error){console.log("camera rotate error.",error)}))];case 1:_a.sent();return[2]}}))}))}function cameraPan(x,z){return __awaiter(this,void 0,void 0,(function(){var mode;return __generator(this,(function(_a){switch(_a.label){case 0:mode=getViewMode();if(!(mode==_atwin.Mode.Mode.FLOORPLAN||mode==_atwin.Mode.Mode.DOLLHOUSE))return[3,2];return[4,_atwin.Camera.pan({x:x,z:z}).then((function(){console.log("camera pan success.")})).catch((function(error){console.log("camera rotate error:",error)}))];case 1:_a.sent();return[3,3];case 2:console.error("Incorrect view mode.");_a.label=3;case 3:return[2]}}))}))}function cameraLookAt(x,y){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Camera.lookAtScreenCoords(x,y).then((function(){console.log("camera looking at...",x,y)})).catch((function(error){console.log("camera looking at error:",error)}))];case 1:_a.sent();return[2]}}))}))}function moveInDirection(direction){return __awaiter(this,void 0,void 0,(function(){var nextDirection;return __generator(this,(function(_a){switch(_a.label){case 0:nextDirection=_atwin.Camera.Direction.LEFT;switch(direction.toUpperCase()){case"LEFT":nextDirection=_atwin.Camera.Direction.LEFT;break;case"RIGHT":nextDirection=_atwin.Camera.Direction.RIGHT;break;case"UP":nextDirection=_atwin.Camera.Direction.UP;break;case"DOWN":nextDirection=_atwin.Camera.Direction.DOWN;break;case"BACK":nextDirection=_atwin.Camera.Direction.BACK;break;case"FORWARD":nextDirection=_atwin.Camera.Direction.FORWARD;break;default:nextDirection=_atwin.Camera.Direction.LEFT;break}return[4,_atwin.Camera.moveInDirection(nextDirection).then((function(){console.log("Move to...",nextDirection)})).catch((function(){console.warn("An error occured while moving in that direction.",nextDirection)}))];case 1:_a.sent();return[2]}}))}))}function dispose3dObjects(){console.log("dispose3dObjects");_3DXObject.forEach((function(obj){console.log("_3DXObject stop",obj);obj.stop()}));_videos.forEach((function(vid){console.log("_videos pause and node stop",vid);vid.component.video.pause();vid.node.stop()}));_allSlideShow.forEach((function(slide){console.log("_allSlideShow stop",slide);slide.node.stop()}))}function getViewMode(){return _currentViewMode}function setViewMode(mode){return __awaiter(this,void 0,void 0,(function(){var modeType;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("=== get Mode Type ===",_getModeType(mode));modeType=_getModeType(mode);return[4,_atwin.Mode.moveTo(modeType).then((function(nextMode){console.log("Arrived at new view mode "+nextMode)})).catch((function(error){console.error("Error occur on:",error)}))];case 1:_a.sent();return[2]}}))}))}function _getModeType(mode){var modes={DOLLHOUSE:"mode.dollhouse",FLOORPLAN:"mode.floorplan",INSIDE:"mode.inside",OUTSIDE:"mode.outside",TRANSITIONING:"mode.transitioning"};return modes[mode.toUpperCase()]||""}function disconnectSpace(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("disconnectSpace()");return[4,hideTags()];case 1:_a.sent();dispose3dObjects();_atwin.disconnect();_iframe.src="";_api={};_space={};_atwin={};_tags=[];tags=[];sweeps=[];_allSlideShow=[];_slideShowImage=[];_currentSlideShowID=0;_currentSlideIndex=0;_currentSlideShow=null;_timer=null;_videos=[];_currentViewMode="";_3DXObject=[];_unrenderedObjects=[];_previousTimeStamp=0;_currentSweep={};_currentCameraPose={};_sweeps=[];return[2]}}))}))}var ClickSpy=function(){function ClickSpy(data,node,component){this.eventType="INTERACTION.CLICK";this.object_data=data;this.node=node;this.component=component}ClickSpy.prototype.onEvent=function(payload){return __awaiter(this,void 0,void 0,(function(){var selectedObj;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("INTERACTION.CLICK",payload);selectedObj={object:this.object_data,node:this.node,component:this.component};setSelectedObject(this.object_data,this.node,this.component);return[4,setTransformControls(selectedObj)];case 1:_a.sent();return[2]}}))}))};return ClickSpy}();var atwin={tags:tags,sweeps:sweeps,connectSpace:connectSpace,disconnectSpace:disconnectSpace,gotoTag:gotoTag,getCurrentSweep:getCurrentSweep,getCurrentSweepPosition:getCurrentSweepPosition,moveToSweep:moveToSweep,getNearbySweeps:getNearbySweeps,pauseVideo:pauseVideo,playVideo:playVideo,getCurrentCameraPose:getCurrentCameraPose,getCameraPosition:getCameraPosition,moveInDirection:moveInDirection,cameraLookAt:cameraLookAt,cameraPan:cameraPan,cameraRotate:cameraRotate,getViewMode:getViewMode,setViewMode:setViewMode,getNearbyObjects:getNearbyObjects};export{atwin as default,tags,sweeps,connectSpace,disconnectSpace,gotoTag,getCurrentSweep,getCurrentSweepPosition,moveToSweep,getNearbySweeps,pauseVideo,playVideo,getCurrentCameraPose,getCameraPosition,moveInDirection,cameraLookAt,cameraPan,cameraRotate,getViewMode,setViewMode,getNearbyObjects};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P((function(resolve){resolve(value)}))}return new(P||(P=Promise))((function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())}))};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{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;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};import axios from"axios";import{distance}from"mathjs";import JSZip from"jszip";import JSZipUtils from"jszip-utils";var _config={aws:{region:"ap-northeast-1",accessKeyId:"AKIAVVUXZ66KW7GBSW7A",secretAccessKey:"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'"},mp:{appKey:"a3ae8341bd8f44899eba16df86307d7d",urlParams:["help","play","nt","qs","brand","dh","tour","gt","hr","mls","mt","tagNav","pin","portal","f","fp","lang","kb","lp","st","title","tourcta","wts","ts","hl","vr","nozoom","search","wh"]}};var _apiURL="http://localhost:5173/api";var _appKey=_config.mp.appKey;var urlParams=_config.mp.urlParams;var _iframe={};var _api={};var _space={};var _atwin={};var _tags=[];var tags=[];var sweeps=[];var _allSlideShow=[];var _slideShowImage=[];var _currentSlideShowID=0;var _currentSlideIndex=0;var _currentSlideShow=null;var _timer=null;var _videos=[];var _currentViewMode="";var _3DXObject=[];var _unrenderedObjects=[];var _transformControlNode;var _inputControlComponent=null;var selectedObject={};var _previousTimeStamp=0;var _renderDistance=null;var _autoDetectNearbyObj=false;var _viewMode="public";var _currentSweep={};var _currentCameraPose={};var _sweeps=[];var _isInitialLoad=true;function connectSpace(url,auth,config){return __awaiter(this,void 0,void 0,(function(){var lastString,api,showcase;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("connectSpace()");console.log("__config",config);if("apiURL"in auth){console.log("'apiURL' in auth");lastString=auth.apiURL.slice(-1);if(lastString!=="/"){auth.apiURL+="/"}_apiURL=auth.apiURL}if("appKey"in config){console.log("'appKey' in config");_appKey=config.appKey}console.log("_apiURL",_apiURL);api=axios.create({baseURL:_apiURL,headers:{"Access-Control-Allow-Origin":"*","Content-Type":"application/json",Authorization:auth.apiKey}});_api=api;if(config.viewMode==="interactive"){_viewMode="interactive"}showcase=document.getElementById(config.iframeId);_iframe=showcase;if(!url.includes("https://my.matterport.com/show/"))return[3,2];console.log("URL IS MATTERPORT");return[4,loadDefaultMpSpace(url,config,showcase)];case 1:_a.sent();return[3,4];case 2:console.log("URL IS REV-KITTEN");return[4,loadAtwinSpace(url,auth,config,showcase)];case 3:_a.sent();_a.label=4;case 4:return[2]}}))}))}function loadDefaultMpSpace(url,config,showcase){return __awaiter(this,void 0,void 0,(function(){var iframeSrc,showcaseWindow,_setTags;var _this=this;return __generator(this,(function(_a){console.log("loadDefaultMpSpace(url: string, showcase: HTMLIFrameElement)",url,showcase);iframeSrc=getIframeSrc(config,url);console.log("__iframeSrc",iframeSrc);showcase.src=iframeSrc;showcaseWindow=showcase.contentWindow;showcase.addEventListener("load",(function(){return __awaiter(_this,void 0,void 0,(function(){var e_1;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log('iframe.addEventListener("load")');console.log("showcaseWindow",showcaseWindow);_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,showcaseWindow.MP_SDK.connect(showcaseWindow)];case 2:_atwin=_a.sent();console.log("Hello Bundle SDK",_atwin);_atwin.App.state.subscribe((function(appState){return __awaiter(_this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("appState",appState);if(!(appState.phase===_atwin.App.Phase.LOADING))return[3,2];console.log("App is loading...");return[4,_setTags()];case 1:_a.sent();return[3,3];case 2:if(appState.phase===_atwin.App.Phase.STARTING){console.log("App is starting...")}else if(appState.phase===_atwin.App.Phase.PLAYING){console.log("App is playing...")}_a.label=3;case 3:return[2]}}))}))}));return[3,4];case 3:e_1=_a.sent();console.error(e_1);return[3,4];case 4:return[2]}}))}))}));_setTags=function(){return __awaiter(_this,void 0,void 0,(function(){var mpTags,filteredMpTags;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("_setTags()");return[4,_atwin.Mattertag.getData()];case 1:mpTags=_a.sent();if(mpTags){filteredMpTags=mpTags.map((function(i){var x={};x.id=i.sid;x.name=i.label;return x}));tags=filteredMpTags;console.log("tags",tags)}return[2]}}))}))};return[2]}))}))}function loadAtwinSpace(url,auth,config,showcase){var _a;return __awaiter(this,void 0,void 0,(function(){var spaceId,space,iframeSrc,tags,objects,showcaseWindow;var _this=this;return __generator(this,(function(_b){switch(_b.label){case 0:console.log("loadAtwinSpace(url: string, auth: { apiKey: string; user: IUser },config: IMPConfig, showcase: HTMLIFrameElement)");spaceId=getSpaceId(url);if(!spaceId){console.error("spaceId is undefined");return[2]}if(!_isInitialLoad)return[3,2];return[4,loginUser(auth.user)];case 1:_b.sent();_b.label=2;case 2:return[4,getSpace(spaceId)];case 3:space=_b.sent();if(!space){console.error("space is undefined");return[2]}setSpace(space);iframeSrc=getIframeSrc(config,space.space_url);console.log("__iframeSrc",iframeSrc);showcase.src=iframeSrc;return[4,getTags(space)];case 4:tags=_b.sent();if(!tags){console.log("tags is undefined");return[2]}setTags(tags);return[4,get3DObjects(spaceId)];case 5:objects=_b.sent();if(!objects){console.log("objects is undefined");return[2]}if(_isInitialLoad){(_a=showcase.contentWindow)===null||_a===void 0?void 0:_a.location.reload()}_isInitialLoad=false;showcaseWindow=showcase.contentWindow;showcase.addEventListener("load",(function(){return __awaiter(_this,void 0,void 0,(function(){var e_2;return __generator(this,(function(_a){switch(_a.label){case 0:console.log('iframe.addEventListener("load")');console.log("showcaseWindow",showcaseWindow);if(!showcaseWindow.MP_SDK)return[3,5];_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,showcaseWindow.MP_SDK.connect(showcaseWindow)];case 2:_atwin=_a.sent();console.log("Hello Bundle SDK",_atwin);onShowcaseConnect();return[3,4];case 3:e_2=_a.sent();console.error(e_2);return[3,4];case 4:return[3,6];case 5:console.log("No showcaseWindow.MP_SDK found");_a.label=6;case 6:return[2]}}))}))}));return[2]}}))}))}function onShowcaseConnect(){return __awaiter(this,void 0,void 0,(function(){var modelData,e_3;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("onShowcaseConnect()");_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_atwin.Model.getData()];case 2:modelData=_a.sent();console.log("Model sid:"+modelData.sid);_atwin.App.state.subscribe((function(appState){return __awaiter(_this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("appState",appState);if(!(appState.phase===_atwin.App.Phase.LOADING))return[3,1];console.log("App is loading...");return[3,7];case 1:if(!(appState.phase===_atwin.App.Phase.STARTING))return[3,3];console.log("App is starting...");return[4,hideTags()];case 2:_a.sent();return[3,7];case 3:if(!(appState.phase===_atwin.App.Phase.PLAYING))return[3,7];console.log("App is playing...");return[4,showTags(_tags)];case 4:_a.sent();return[4,getSweeps()];case 5:_a.sent();return[4,setLighting()];case 6:_a.sent();_atwin.Sweep.current.subscribe((function(currentSweep){if(currentSweep.sid===""){console.log("Not currently stationed at a sweep position")}else{_currentSweep=currentSweep;console.log("Currently at sweep",_currentSweep.id);videoAutoPlay()}}));_atwin.Camera.pose.subscribe((function(pose){return __awaiter(this,void 0,void 0,(function(){var hasElapsed;return __generator(this,(function(_a){switch(_a.label){case 0:_currentCameraPose=pose;console.log("Current Camera Pose",_currentCameraPose);hasElapsed=hasTimeElapsed(300);if(!hasElapsed)return[3,2];console.log("_unrenderedObjects "+_unrenderedObjects.length);return[4,renderOnDemand()];case 1:_a.sent();_a.label=2;case 2:if(hasTimeElapsed(1e3)&&_autoDetectNearbyObj){getNearbyObjects({type:"ALL",distance:2})}return[2]}}))}))}));_atwin.Mode.current.subscribe((function(mode){_currentViewMode=mode}));_a.label=7;case 7:return[2]}}))}))}));return[3,4];case 3:e_3=_a.sent();console.error(e_3);return[3,4];case 4:return[2]}}))}))}function hasTimeElapsed(maxTime){var currentTimestamp=Date.now();var differenceInMilliseconds=(currentTimestamp-_previousTimeStamp)%1e3;_previousTimeStamp=currentTimestamp;if(differenceInMilliseconds>=maxTime){console.log("Elapsed more than ".concat(maxTime));return true}else{console.log("Elapsed less than ".concat(maxTime));return false}}function getNearbyUnrenderedObjects(payload){var toBeRendered=[];var currentPose={x:_currentCameraPose.position.x,y:_currentCameraPose.position.y};toBeRendered=_unrenderedObjects.filter((function(obj){var obj_pos={x:obj.object_position.x,y:obj.object_position.y};var distance=calculateDistance(currentPose,obj_pos);return distance<payload.distance}));var filtered=_unrenderedObjects.filter((function(obj){return toBeRendered.indexOf(obj)===-1}));_unrenderedObjects=filtered;console.log("render toBeRendered "+toBeRendered.length);return toBeRendered}function getNearbyObjects(payload){if(payload.type===undefined||payload.type===""){payload.type="ALL"}if(payload.distance===undefined){payload.distance=2}var pos1={x:_currentCameraPose.position.x,y:_currentCameraPose.position.y};var three_d=[];var videos=[];var slideshows=[];if(payload.type==="ALL"||"3DX"){three_d=_3DXObject.filter((function(obj){var pos2={x:obj.position.x,y:obj.position.y};var distance=calculateDistance(pos1,pos2);console.log("3DX Distance: "+distance);return distance<payload.distance}))}if(payload.type==="ALL"||"VIDEO"){videos=_videos.filter((function(vid){var pos2={x:vid.node.position.x,y:vid.node.position.y};var distance=calculateDistance(pos1,pos2);console.log("Video Distance: "+distance);return distance<payload.distance}))}if(payload.type==="ALL"||"SLIDESHOW"){slideshows=_allSlideShow.filter((function(slide){var pos2={x:slide.node.position.x,y:slide.node.position.y};var distance=calculateDistance(pos1,pos2);console.log("Slideshow Distance: "+distance);return distance<payload.distance}))}console.log("nearby3DXObjects "+three_d.length);console.log("nearbyVideos "+videos.length);console.log("nearbySlideshows "+slideshows.length);return{x3d:three_d,videos:videos,slideshows:slideshows}}function show3DObjects(object){var _a;return __awaiter(this,void 0,void 0,(function(){var sceneObject,id,modelNode,component;return __generator(this,(function(_b){switch(_b.label){case 0:return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_b.sent()[0];id=Math.floor(Math.random()*20);modelNode=sceneObject.addNode(id.toString());component=modelNode.addComponent(getComponentLoader(object),{url:(_a=object.object_data)===null||_a===void 0?void 0:_a.amazon_uri});if(!component.inputs){console.error("component.inputs is undefined");return[2]}component.inputs.localScale={x:object.object_scale.x,y:object.object_scale.y,z:object.object_scale.z};modelNode.obj3D.position.set(object.object_position.x,object.object_position.y,object.object_position.z);modelNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);_3DXObject.push(modelNode);console.log("_3DXObject "+_3DXObject.length);modelNode.start();if(_viewMode==="interactive"){component.spyOnEvent(new ClickSpy(object,modelNode,component))}return[2]}}))}))}function renderOnDemand(){return __awaiter(this,void 0,void 0,(function(){var objects;var _this=this;return __generator(this,(function(_a){if(_unrenderedObjects.length!==0){console.log("renderOnDemand()");objects=getNearbyUnrenderedObjects({type:"",distance:2});objects.forEach((function(obj){return __awaiter(_this,void 0,void 0,(function(){var _a,_b,_c,_d;return __generator(this,(function(_e){switch(_e.label){case 0:if(!(((_a=obj.object_data)===null||_a===void 0?void 0:_a.object_type)==="FBX"||((_b=obj.object_data)===null||_b===void 0?void 0:_b.object_type)==="GLB"))return[3,2];return[4,show3DObjects(obj)];case 1:_e.sent();return[3,6];case 2:if(!(((_c=obj.object_data)===null||_c===void 0?void 0:_c.object_type)==="MP4"))return[3,4];return[4,showVideoObjects(obj)];case 3:_e.sent();return[3,6];case 4:if(!(((_d=obj.object_data)===null||_d===void 0?void 0:_d.object_type)==="ZIP"))return[3,6];return[4,showSlideScreenModel(obj)];case 5:_e.sent();_e.label=6;case 6:return[2]}}))}))}))}return[2]}))}))}function getIframeSrc(config,url){console.log("getIframeSrc()",config,url);var modelId=url.split("?m=")[1];if(!modelId){console.error("modelId is undefined");return""}var src="";if("bundlePath"in config){var lastString=config.bundlePath.slice(-1);if(lastString!=="/"){config.bundlePath+="/"}src+="".concat(config.bundlePath,"showcase.html?m=").concat(modelId,"&applicationKey=").concat(_appKey,"&newtags=1")}else{if(config.prod===undefined||config.prod===null){config.prod=true}if(config.prod){src+="node_modules/architwin/bundle/showcase.html?m=".concat(modelId,"&applicationKey=").concat(_appKey,"&newtags=1")}else{src+="architwin/bundle/showcase.html?m=".concat(modelId,"&applicationKey=").concat(_appKey,"&newtags=1")}}console.log("__src",src);for(var _i=0,urlParams_1=urlParams;_i<urlParams_1.length;_i++){var param=urlParams_1[_i];if(param in config){src+="&".concat(param,"=").concat(config[param])}}return src}function loginUser(user){return __awaiter(this,void 0,void 0,(function(){var response;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("loginUser(user)",user);return[4,_api.post("/cas/tickets?email="+user.email+"&password="+user.password)];case 1:response=_a.sent();console.log("loginUser, response",response.status,response.data);if(response.status==200){return[2,response.data]}else{return[2,response]}return[2]}}))}))}function getSpace(spaceId){return __awaiter(this,void 0,void 0,(function(){var response;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("getShowcase(spaceId: string)",spaceId);return[4,_api.get("/v1/showcases/id/".concat(spaceId))];case 1:response=_a.sent();console.log("response",response);if(response.status===200){if(response.data.data.length===0){console.error("No data")}return[2,response.data.data[0]]}else{console.error("Error in fetchShowcase()"+response)}return[2,null]}}))}))}function getSpaceId(url){var urlArray=url.split(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/);var path=urlArray[5];var spaceId=path.split("/")[3];console.log("urlArray",urlArray);console.log("path",path);if(!spaceId){console.error("spaceId is undefined");return}return spaceId}function setSpace(space){console.log("setSpace(space: ISpace)",space);_space=space}function getTags(space){return __awaiter(this,void 0,void 0,(function(){var response,tags_1,error_1;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("getTags()");_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_api.get("/v1/tags/showcase-id/".concat(space.id))];case 2:response=_a.sent();console.log("response",response);if(response.status===200){tags_1=response.data.data;if(!tags_1){console.error("tags is undefined")}return[2,tags_1]}else{console.error("Custom Error: Unable to fetch tags")}return[3,4];case 3:error_1=_a.sent();console.error(error_1);return[3,4];case 4:return[2,null]}}))}))}function setTags(tags){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){console.log("setTags()",tags);_tags=tags.map((function(tag){tag.json_data=JSON.parse(tag.json_data);tag.json_data.id=tag.json_data.sid;return tag}));mapTags(_tags);return[2]}))}))}function get3DObjects(showcase_id){return __awaiter(this,void 0,void 0,(function(){var id,response,showcase_objects,getRequests,response_1,object_data_1,threed_objects,error_2,error_3;return __generator(this,(function(_a){switch(_a.label){case 0:if(!showcase_id)return[3,8];_a.label=1;case 1:_a.trys.push([1,7,,8]);id=parseInt(showcase_id);console.log("showcase_id "+id);return[4,_api.get("/v1/showcase-objects/showcase-id/".concat(id))];case 2:response=_a.sent();showcase_objects=response.data.data;console.log("showcase_objects "+JSON.stringify(showcase_objects));getRequests=showcase_objects.map((function(obj){return _api.get("/v1/objects/id/".concat(obj.object_id))}));_a.label=3;case 3:_a.trys.push([3,5,,6]);return[4,axios.all(getRequests)];case 4:response_1=_a.sent();object_data_1=response_1.map((function(res){return res.data.data[0]}));console.log("object_data"+JSON.stringify(object_data_1));threed_objects=showcase_objects.map((function(showcase){var target=object_data_1.find((function(obj){return obj.id===showcase.object_id}));if(target){showcase.object_data=target}if(showcase.object_position){showcase.object_position=typeof showcase.object_position==="string"?JSON.parse(showcase.object_position):showcase.object_position}if(showcase.object_rotation){showcase.object_rotation=typeof showcase.object_rotation==="string"?JSON.parse(showcase.object_rotation):showcase.object_rotation}if(showcase.object_scale){showcase.object_scale=typeof showcase.object_scale==="string"?JSON.parse(showcase.object_scale):showcase.object_scale}return showcase}));console.log("get3DObjectsByShowcaseId "+JSON.stringify(threed_objects));_unrenderedObjects=threed_objects;return[2,threed_objects];case 5:error_2=_a.sent();console.error("threed_objects "+error_2);return[3,6];case 6:return[3,8];case 7:error_3=_a.sent();console.error("get3DObjectsByShowcaseId "+error_3);return[3,8];case 8:return[2,[]]}}))}))}function gotoTag(tag_id){return __awaiter(this,void 0,void 0,(function(){var error_4;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("gotoTag(tag: tag_id)",tag_id);if(!tag_id){console.error("tag is undefined");return[2]}_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,_atwin.Mattertag.navigateToTag(tag_id,_atwin.Mattertag.Transition.FLY)];case 2:_a.sent();return[3,4];case 3:error_4=_a.sent();console.error(error_4);return[3,4];case 4:return[2]}}))}))}function showTags(tags){return __awaiter(this,void 0,void 0,(function(){var _this=this;return __generator(this,(function(_a){tags.forEach((function(tag,indx){return __awaiter(_this,void 0,void 0,(function(){var mpData,tagIds,attachmentId1,error_5;return __generator(this,(function(_a){switch(_a.label){case 0:mpData=tag.json_data;if(!mpData){console.error("tag.json_data/mpData is undefined");return[2]}return[4,_atwin.Tag.add({anchorPosition:mpData.anchorPosition,color:mpData.color,description:mpData.description,id:mpData.sid,label:mpData.label,stemVector:mpData.stemVector,stemVisible:mpData.stemVisible})];case 1:tagIds=_a.sent();if(!tagIds)return[3,6];tag.json_data.id=tagIds[0];if(!(tag.json_data.media&&tag.json_data.media.src.trim()!==""))return[3,6];_a.label=2;case 2:_a.trys.push([2,5,,6]);console.log("Attaching media...");return[4,_atwin.Tag.registerAttachment(tag.json_data.media.src)];case 3:attachmentId1=_a.sent()[0];tag.json_data["attachments"]=[attachmentId1];return[4,_atwin.Tag.attach(tag.json_data.sid,attachmentId1)];case 4:_a.sent();console.log("Media successfully attached");return[3,6];case 5:error_5=_a.sent();console.warn("Custom warn: Media not attached: Invalid media src link: "+error_5);console.warn("mediaSrc: ".concat(tag.json_data.media.src," | tag index: ").concat(indx));return[3,6];case 6:return[2]}}))}))}));console.log("tags",_tags);return[2]}))}))}function hideTags(){return __awaiter(this,void 0,void 0,(function(){var tags,tagIds;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("hideTags()");return[4,_atwin.Mattertag.getData()];case 1:tags=_a.sent();if(!tags)return[3,3];tagIds=tags.map((function(i){return i.sid}));return[4,_atwin.Mattertag.remove(tagIds)];case 2:_a.sent();console.log("Tags removed in space: ",tagIds);_a.label=3;case 3:return[2]}}))}))}function mapTags($tags){console.log("mapTags()",$tags);tags=$tags.map((function(i){var x={};x.id=i.json_data.id;x.name=i.json_data.label;return x}));console.log("tags",tags)}function getCurrentSweep(){return _currentSweep}function getCurrentCameraPose(){return _currentCameraPose}function getCameraPosition(){return _currentCameraPose.position}function getCurrentSweepPosition(){return _currentSweep.position}function getSweeps(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){console.log("Getting Sweeps in Space");_atwin.Sweep.data.subscribe({onCollectionUpdated:function(collection){console.log("Sweeps In Space",collection);if(!collection){console.log("No Sweeps in loaded Space")}_sweeps=collection;var sw=Object.values(_sweeps);sweeps=sw.map((function(item){return{id:item.uuid,position:item.position,neighbors:item.neighbors}}))}});return[2,null]}))}))}function moveToSweep(sweepId){return __awaiter(this,void 0,void 0,(function(){var transition,transitionTime;return __generator(this,(function(_a){transition=_atwin.Sweep.Transition.FLY;transitionTime=2e3;console.log("Sweep Move",sweepId);_atwin.Sweep.moveTo(sweepId,{transition:transition,transitionTime:transitionTime}).then((function(){console.log("Sweep Arrived at sweep "+sweepId)})).catch((function(error){console.log("Sweep Error on Arriving",error)}));return[2]}))}))}function getNearbySweeps(sweepId){return __awaiter(this,void 0,void 0,(function(){var nearby;return __generator(this,(function(_a){switch(_a.label){case 0:if(!sweepId)return[3,2];return[4,sweeps.find((function(item){return item.id==sweepId})).neighbors];case 1:nearby=_a.sent();console.log("Nearby Sweeps",nearby);return[2,nearby];case 2:console.log("No Nearby Sweeps");_a.label=3;case 3:return[2]}}))}))}function getComponentLoader(object){if(object&&object.object_data){var index=object.object_data.object_type;var component={FBX:_atwin.Scene.Component.FBX_LOADER,GLB:_atwin.Scene.Component.GLTF_LOADER,MP4:"liveVideo",ZIP:"slideScreenModel"};return component[index]||""}return""}function setSelectedObject(data,node,component){selectedObject={object:data,component:component,node:node};console.log("setSelectedObject()")}function setLighting(){return __awaiter(this,void 0,void 0,(function(){var sceneObject,lights;return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];lights=sceneObject.addNode();lights.addComponent("mp.directionalLight",{intensity:.6,color:{r:1,g:1,b:1}});lights.addComponent("mp.ambientLight",{intensity:.6,color:{r:1,g:1,b:1}});lights.start();return[2]}}))}))}function clearTransformControls(){if(!_transformControlNode){console.error("_transformControlNode is undefined");return}if(_inputControlComponent==null||!_inputControlComponent){console.error("_inputControlComponent is undefined");return}_transformControlNode.stop();console.log("clearTransformControls()")}function setTransformControls(selectedObject,mode){if(mode===void 0){mode="translate"}return __awaiter(this,void 0,void 0,(function(){var sceneObject,transformNode,transformComponent,inputComponent;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("Object to be transformed "+selectedObject.object.object_data.name);clearTransformControls();return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];transformNode=sceneObject.addNode();transformComponent=transformNode.addComponent("mp.transformControls");_transformControlNode=transformNode;inputComponent=transformNode.addComponent("mp.input",{eventsEnabled:true,userNavigationEnabled:true});_inputControlComponent=inputComponent.spyOnEvent(new ClickSpy(selectedObject.object,selectedObject.node,selectedObject.component));transformNode.start();transformComponent.inputs.selection=selectedObject.node;transformComponent.inputs.mode=mode;return[2]}}))}))}function calculateDistance(pos1,pos2){var dx=pos2.x-pos1.x;var dy=pos2.y-pos1.y;return Math.sqrt(dx*dx+dy*dy)}function showVideoObjects(object){var _a,_b;return __awaiter(this,void 0,void 0,(function(){var sceneObject,liveStreamNode,liveStreamComponent;return __generator(this,(function(_c){switch(_c.label){case 0:return[4,createVideoComponent()];case 1:_c.sent();return[4,_atwin.Scene.createObjects(1)];case 2:sceneObject=_c.sent()[0];liveStreamNode=sceneObject.addNode();return[4,liveStreamNode.addComponent(getComponentLoader(object),{url:(_a=object.object_data)===null||_a===void 0?void 0:_a.amazon_uri})];case 3:liveStreamComponent=_c.sent();liveStreamNode.position.set(object.object_position.x,object.object_position.y,object.object_position.z);liveStreamNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);liveStreamNode.scale.set(object.object_scale.x,object.object_scale.y,object.object_scale.z);if(liveStreamComponent.outputs.loadingState!="Error"){liveStreamNode.start()}liveStreamComponent.inputs.src=(_b=object.object_data)===null||_b===void 0?void 0:_b.amazon_uri;_videos.push({data:object,component:liveStreamComponent,node:liveStreamNode,type:"VIDEO"});return[2]}}))}))}function playVideo(videoId){var videoObject=_videos.find((function(object){return object.data.id==videoId}));if(videoObject){videoObject.component.video.play()}else{console.error("Unable to find video object using that id")}}function pauseVideo(videoId){var videoObject=_videos.find((function(object){return object.data.id==videoId}));if(videoObject){videoObject.component.video.pause()}else{console.error("Unable to find video object using that id")}}function videoAutoPlay(){function nearestVideo(videoObject){return __awaiter(this,void 0,void 0,(function(){var videoPosition,cameraPosition,computedDistance;return __generator(this,(function(_a){videoPosition=videoObject.data.object_position;cameraPosition=getCurrentSweepPosition();computedDistance=distance([cameraPosition.x,cameraPosition.y,cameraPosition.z],[videoPosition.x,videoPosition.y,videoPosition.z]);try{if(videoObject.data.autoplay&&videoObject.data.autoplay_distance&&computedDistance<videoObject.data.autoplay_distance){videoObject.component.video.play()}else{videoObject.component.video.pause()}}catch(e){console.error("Unable to play or stop video")}return[2]}))}))}_videos.forEach((function(videoObject){return nearestVideo(videoObject)}))}function createVideoComponent(){function videoRenderer(){this.inputs={visible:true,userNavigationEnabled:true,eventsEnabled:true,colliderEnabled:true,src:null};this.outputs={texture:null,video:null,aspect:720/480};this.onInit=function(){this.video;this.texture};this.onEvent=function(eventType,eventData){};this.onInputsUpdated=function(previous){this.releaseTexture();var THREE=this.context.three;if(!this.inputs.src){this.video.src="";return}if(this.inputs.src instanceof HTMLVideoElement){this.video=this.inputs.src}else{this.video=this.createVideoElement();if(typeof this.inputs.src==="string"){this.video.src=this.inputs.src}else{this.video.srcObject=this.inputs.src}this.video.load()}this.texture=new THREE.VideoTexture(this.video);this.texture.minFilter=THREE.LinearFilter;this.texture.magFilter=THREE.LinearFilter;this.texture.format=THREE.RGBFormat;var geometry=new THREE.PlaneGeometry(1,1);geometry.scale(1,480/720,1);geometry.translate(0,.33,0);this.material=new THREE.MeshBasicMaterial({map:this.texture,side:THREE.DoubleSide});var mesh=new THREE.Mesh(geometry,this.material);this.outputs.objectRoot=mesh;this.outputs.collider=mesh;mesh.visible=this.inputs.visible;this.outputs.texture=this.texture;this.outputs.video=this.video};this.releaseTexture=function(){if(this.texture){this.outputs.texture=null;this.texture.dispose()}};this.createVideoElement=function(){var video=document.createElement("video");video.setAttribute("id","htmlLivestreamVideo");video.crossOrigin="anonymous";video.setAttribute("height","480");video.setAttribute("width","720");video.setAttribute("webkit-playsinline","webkit-playsinline");video.setAttribute("controls","controls");video.muted=false;video.loop=true;video.volume=1;return video};this.onTick=function(tickDelta){};this.onDestroy=function(){this.material.dispose()};this.spyOnEvent=function(payload){console.log("payload",payload)}}function makeVideoRender(){return new videoRenderer}_atwin.Scene.register("liveVideo",makeVideoRender)}function createSlideScreenModel(){function SlideScreenModelRenderer(){this.inputs={src:null,userNavigationEnabled:true,eventsEnabled:true,colliderEnabled:true,visible:true};this.outputs={texture:null,t_image:null};this.onInit=function(){this.texture;this.t_image;this.material;this.mesh};this.events={"INTERACTION.CLICK":true};this.onEvent=function(eventType,eventData){return __awaiter(this,void 0,void 0,(function(){var slideshow_1,mousePosition,planePosition;var _this=this;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("onEventSlideShow",eventType,eventData);if(!(eventType=="INTERACTION.CLICK"))return[3,2];if(!(_allSlideShow.length>0))return[3,2];slideshow_1=_allSlideShow.filter((function(l){var _a,_b,_c,_d;return(_d=((_b=(_a=l.collider)===null||_a===void 0?void 0:_a.collider)===null||_b===void 0?void 0:_b.uuid)==((_c=eventData.collider)===null||_c===void 0?void 0:_c.uuid))!==null&&_d!==void 0?_d:false}))[0];console.log("slideShow eventData",slideshow_1);if(!(slideshow_1!=null))return[3,2];console.log("slideShow eventData",slideshow_1);return[4,getMousePosition()];case 1:mousePosition=_a.sent();planePosition=slideshow_1.node.obj3D.position;console.log("MOUSE POSITION",mousePosition);console.log("PLANE POSITION",planePosition);if(slideshow_1.object.object_type=="ZIP"){if(slideshow_1.id!=_currentSlideShowID){_currentSlideIndex=_slideShowImage.find((function(elem){return elem.id===slideshow_1.id})).idx;console.log("CURRENT INDEX",_currentSlideIndex);_currentSlideShow=_slideShowImage.find((function(elem){return elem.id===slideshow_1.id})).images;console.log("CURRENT SLIDE",_currentSlideShow)}if(slideshow_1.id==_currentSlideShowID){console.log("ChangeImage",slideshow_1,_currentSlideShowID);if(planePosition.x<mousePosition.x){console.log("LEFT SIDE");clearInterval(_timer);this.inputs.src=imageStream("prev")}else if(planePosition.y<mousePosition.y){console.log("RIGHT SIDE");clearInterval(_timer);this.inputs.src=imageStream("next")}else if(planePosition.y>mousePosition.y){console.log("AUTOPLAY");_timer=setInterval((function(){_currentSlideIndex=(_currentSlideIndex+1)%_currentSlideShow.length;console.log("CURRENT INDEX",_currentSlideIndex);_this.inputs.src=imageStream("next")}),2e3)}}else{_currentSlideShowID=slideshow_1.id}}_a.label=2;case 2:return[2]}}))}))};this.onInputsUpdated=function(previous){var _this=this;this.releaseTexture();var three=this.context.three;this.t_image=document.createElement("IMG");this.t_image.src=this.inputs.src;this.t_image.setAttribute("width","auto");this.t_image.setAttribute("height","auto");this.t_image.crossOrigin="anonymous";var planeGeo=new three.PlaneGeometry(1.5,1.5);planeGeo.translate(0,.33,0);if(previous.src!=this.inputs.src){console.log("this.inputs.src",this.inputs.src);this.texture=(new three.TextureLoader).load(this.t_image.src,(function(tex){if(tex===void 0){tex=_this.texture}tex.minFilter=three.LinearFilter;tex.magFilter=three.LinearFilter;tex.format=three.RGBAFormat;tex.needsUpdate=true;tex.onUpdate=_this.textureUpdated;_this.material=new three.MeshBasicMaterial({map:_this.texture,side:three.DoubleSide,transparent:true,alphaTest:.5});_this.mesh=new three.Mesh(planeGeo,_this.material);_this.mesh.scale.set(1,_this.texture.image.height/_this.texture.image.width,1);_this.outputs.objectRoot=_this.mesh;_this.outputs.collider=_this.mesh;_this.outputs.texture=_this.texture;_this.outputs.t_image=_this.t_image}))}if(this.mesh!=null){this.mesh.visible=this.inputs.visible}};this.textureUpdated=function(params){console.log("Update Callback",params)};this.releaseTexture=function(){if(this.texture){this.outputs.texture=null}};this.onTick=function(tickDelta){};this.onDestroy=function(){this.material.dispose();this.texture.dispose()}}function makeSlideScreenModelRenderer(){return new SlideScreenModelRenderer}_atwin.Scene.register("slideScreenModel",makeSlideScreenModelRenderer)}function showSlideScreenModel(object){return __awaiter(this,void 0,void 0,(function(){var sceneObject,modelNode,component,slideShow;return __generator(this,(function(_a){switch(_a.label){case 0:createSlideScreenModel();return[4,_atwin.Scene.createObjects(1)];case 1:sceneObject=_a.sent()[0];modelNode=sceneObject.addNode();component=modelNode.addComponent("slideScreenModel");console.log("COMPONENT",component);modelNode.scale.set={x:object.object_scale.x,y:object.object_scale.y,z:object.object_scale.z};modelNode.obj3D.position.set(object.object_position.x,object.object_position.y,object.object_position.z);modelNode.obj3D.rotation.set(object.object_rotation.x,object.object_rotation.y,object.object_rotation.z);modelNode.start();return[4,addImageToSlideShow(object.object_data,component,object.id)];case 2:_a.sent();console.log("SLIDE OUTPUT",component.outputs);slideShow={id:object.id,collider:component.outputs,object:object.object_data,node:modelNode,component:component,type:"ZIP"};_allSlideShow.push(slideShow);console.log("ALL SLIDESHOW",_allSlideShow);return[2]}}))}))}function addImageToSlideShow(data,component,objectID){return __awaiter(this,void 0,void 0,(function(){var dataList;return __generator(this,(function(_a){switch(_a.label){case 0:dataList=[];return[4,new JSZip.external.Promise((function(resolve,reject){JSZipUtils.getBinaryContent(data.amazon_uri,(function(err,data){if(err){console.log("getBI error",err);reject(err)}else{console.log("getBI success",data);resolve(data)}}))})).then((function(data){console.log("data from getBI",data);return JSZip.loadAsync(data)})).then((function(data){console.log("data from loadAsync",data);var _loop_1=function(key){if(key.includes("__MACOSX"))return"continue";if(key.includes(".DS_Store"))return"continue";if(data.files[key].dir)return"continue";var base=data.file(data.files[key].name).async("base64");base.then((function(res){dataList.push({name:data.files[key].name,path:"data:image/png;base64,".concat(res)});if(dataList.length==1){component.inputs.src="data:image/png;base64,".concat(res)}}))};for(var key in data.files){_loop_1(key)}_slideShowImage.push({id:objectID,images:dataList,idx:0,playID:null,play:false,comp:component})}))];case 1:_a.sent();return[2]}}))}))}function getMousePosition(){return __awaiter(this,void 0,void 0,(function(){var planePosition;return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Pointer.intersection.subscribe((function(intersection){planePosition=intersection.position}))];case 1:_a.sent();return[2,planePosition]}}))}))}function imageStream(direction){var diff=direction==="prev"?-1:1;var length=_currentSlideShow.length;var index=_currentSlideIndex+diff;if(index===-1){index=length-1}if(index===length){index=0}_currentSlideIndex=index;_slideShowImage.find((function(elem){return elem.id===_currentSlideShowID})).idx=index;return _currentSlideShow[_currentSlideIndex].path}function cameraRotate(x,y,speed){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Camera.rotate(x,y,{speed:speed}).then((function(){console.log("camera rotate success.",x,y)})).catch((function(error){console.log("camera rotate error.",error)}))];case 1:_a.sent();return[2]}}))}))}function cameraPan(x,z){return __awaiter(this,void 0,void 0,(function(){var mode;return __generator(this,(function(_a){switch(_a.label){case 0:mode=getViewMode();if(!(mode==_atwin.Mode.Mode.FLOORPLAN||mode==_atwin.Mode.Mode.DOLLHOUSE))return[3,2];return[4,_atwin.Camera.pan({x:x,z:z}).then((function(){console.log("camera pan success.")})).catch((function(error){console.log("camera rotate error:",error)}))];case 1:_a.sent();return[3,3];case 2:console.error("Incorrect view mode.");_a.label=3;case 3:return[2]}}))}))}function cameraLookAt(x,y){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:return[4,_atwin.Camera.lookAtScreenCoords(x,y).then((function(){console.log("camera looking at...",x,y)})).catch((function(error){console.log("camera looking at error:",error)}))];case 1:_a.sent();return[2]}}))}))}function moveInDirection(direction){return __awaiter(this,void 0,void 0,(function(){var nextDirection;return __generator(this,(function(_a){switch(_a.label){case 0:nextDirection=_atwin.Camera.Direction.LEFT;switch(direction.toUpperCase()){case"LEFT":nextDirection=_atwin.Camera.Direction.LEFT;break;case"RIGHT":nextDirection=_atwin.Camera.Direction.RIGHT;break;case"UP":nextDirection=_atwin.Camera.Direction.UP;break;case"DOWN":nextDirection=_atwin.Camera.Direction.DOWN;break;case"BACK":nextDirection=_atwin.Camera.Direction.BACK;break;case"FORWARD":nextDirection=_atwin.Camera.Direction.FORWARD;break;default:nextDirection=_atwin.Camera.Direction.LEFT;break}return[4,_atwin.Camera.moveInDirection(nextDirection).then((function(){console.log("Move to...",nextDirection)})).catch((function(){console.warn("An error occured while moving in that direction.",nextDirection)}))];case 1:_a.sent();return[2]}}))}))}function dispose3dObjects(){console.log("dispose3dObjects");_3DXObject.forEach((function(obj){console.log("_3DXObject stop",obj);obj.stop()}));_videos.forEach((function(vid){console.log("_videos pause and node stop",vid);vid.component.video.pause();vid.node.stop()}));_allSlideShow.forEach((function(slide){console.log("_allSlideShow stop",slide);slide.node.stop()}))}function getViewMode(){return _currentViewMode}function setViewMode(mode){return __awaiter(this,void 0,void 0,(function(){var modeType;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("=== get Mode Type ===",_getModeType(mode));modeType=_getModeType(mode);return[4,_atwin.Mode.moveTo(modeType).then((function(nextMode){console.log("Arrived at new view mode "+nextMode)})).catch((function(error){console.error("Error occur on:",error)}))];case 1:_a.sent();return[2]}}))}))}function _getModeType(mode){var modes={DOLLHOUSE:"mode.dollhouse",FLOORPLAN:"mode.floorplan",INSIDE:"mode.inside",OUTSIDE:"mode.outside",TRANSITIONING:"mode.transitioning"};return modes[mode.toUpperCase()]||""}function disconnectSpace(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(_a){switch(_a.label){case 0:console.log("disconnectSpace()");return[4,hideTags()];case 1:_a.sent();dispose3dObjects();_atwin.disconnect();_iframe.src="";_api={};_space={};_atwin={};_tags=[];tags=[];sweeps=[];_allSlideShow=[];_slideShowImage=[];_currentSlideShowID=0;_currentSlideIndex=0;_currentSlideShow=null;_timer=null;_videos=[];_currentViewMode="";_3DXObject=[];_unrenderedObjects=[];_previousTimeStamp=0;_currentSweep={};_currentCameraPose={};_sweeps=[];return[2]}}))}))}var ClickSpy=function(){function ClickSpy(data,node,component){this.eventType="INTERACTION.CLICK";this.object_data=data;this.node=node;this.component=component}ClickSpy.prototype.onEvent=function(payload){return __awaiter(this,void 0,void 0,(function(){var selectedObj;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("INTERACTION.CLICK",payload);selectedObj={object:this.object_data,node:this.node,component:this.component};setSelectedObject(this.object_data,this.node,this.component);return[4,setTransformControls(selectedObj)];case 1:_a.sent();return[2]}}))}))};return ClickSpy}();var DragSpy=function(){function DragSpy(data,node,component){this.eventType="INTERACTION.DRAG_END";this.object_data=data;this.node=node;this.component=component}DragSpy.prototype.onEvent=function(payload){return __awaiter(this,void 0,void 0,(function(){var selectedObj;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("INTERACTION.DRAG_END",payload);selectedObj={object:this.object_data,node:this.node,component:this.component};return[4,setTransformControls(selectedObj)];case 1:_a.sent();return[2]}}))}))};return DragSpy}();var atwin={tags:tags,sweeps:sweeps,connectSpace:connectSpace,disconnectSpace:disconnectSpace,gotoTag:gotoTag,getCurrentSweep:getCurrentSweep,getCurrentSweepPosition:getCurrentSweepPosition,moveToSweep:moveToSweep,getNearbySweeps:getNearbySweeps,pauseVideo:pauseVideo,playVideo:playVideo,getCurrentCameraPose:getCurrentCameraPose,getCameraPosition:getCameraPosition,moveInDirection:moveInDirection,cameraLookAt:cameraLookAt,cameraPan:cameraPan,cameraRotate:cameraRotate,getViewMode:getViewMode,setViewMode:setViewMode,getNearbyObjects:getNearbyObjects};export{atwin as default,tags,sweeps,selectedObject,connectSpace,disconnectSpace,gotoTag,getCurrentSweep,getCurrentSweepPosition,moveToSweep,getNearbySweeps,pauseVideo,playVideo,getCurrentCameraPose,getCameraPosition,moveInDirection,cameraLookAt,cameraPan,cameraRotate,getViewMode,setViewMode,getNearbyObjects};
|
package/lib/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface IUser {
|
|
|
19
19
|
}
|
|
20
20
|
export interface IMPConfig {
|
|
21
21
|
iframeId: string;
|
|
22
|
+
appKey?: string;
|
|
22
23
|
bundlePath?: string;
|
|
23
24
|
help?: 0 | 1 | 2;
|
|
24
25
|
nt?: 0 | 1;
|
|
@@ -50,6 +51,7 @@ export interface IMPConfig {
|
|
|
50
51
|
search?: 0 | 1;
|
|
51
52
|
wh?: 0 | 1;
|
|
52
53
|
prod?: boolean;
|
|
54
|
+
viewMode?: VIEW_MODE | string;
|
|
53
55
|
}
|
|
54
56
|
export interface ISweep {
|
|
55
57
|
alignmentType: MpSdk.Sweep.Alignment;
|
|
@@ -154,3 +156,7 @@ export declare const enum MP_LANG {
|
|
|
154
156
|
IT = "it",
|
|
155
157
|
PT = "pt"
|
|
156
158
|
}
|
|
159
|
+
export declare const enum VIEW_MODE {
|
|
160
|
+
PUBLIC = "public",
|
|
161
|
+
INTERACTIVE = "interactive"
|
|
162
|
+
}
|