architwin 1.0.24 → 1.0.25

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 CHANGED
@@ -10,6 +10,7 @@ ArchiTwin Library
10
10
  - [Getting Started](#getting-started)
11
11
  - [Define an iFrame as target for the Showcase](#define-an-iframe-as-target-for-the-showcase)
12
12
  - [Import the library](#import-the-library)
13
+ - [Setup your proxy](#setup-your-proxy)
13
14
  - [Connect to a Space](#connect-to-a-space)
14
15
  - [Connection Parameters](#connection-parameters)
15
16
  - [Config Options](#config-options)
@@ -58,13 +59,13 @@ This example uses Vue's ref attribute to reference the target iFrame. Please con
58
59
  ````typescript
59
60
  <script lang="ts">
60
61
  import atwin from 'architwin';
61
- import type { IMPConfig, IUser } from 'architwin';
62
+ import type { IMPConfig, IUser } from 'architwin/lib/types'; //for typescript projects
62
63
  import { onMounted, ref } from 'vue';
63
64
 
64
65
  const mpIframe = ref<HTMLIFrameElement>()
65
66
 
66
67
  // replace with your api key and user
67
- const apiKey = "585876be-339f-4e52-a6a0-0bc816ccb95a"
68
+ const apiKey = "YOUR-API-KEY"
68
69
  const authUser = {
69
70
  email: "su@email.com",
70
71
  password: "su123"
@@ -74,6 +75,71 @@ const authUser = {
74
75
  </script>
75
76
  ````
76
77
 
78
+ #### Setup your proxy
79
+
80
+ In your `vite.config.ts`, add the followig block of code. This will allow your app in your development environment to send API request to our servers and circumvent CORS issues. If you are not using vite as your build tool, please refer on the official documentation of your build tool of choice on how to setup the proxy.
81
+
82
+ You may have to change the VITE_PROXY value if you intend to direct your api requests on another server during development.
83
+
84
+ During production deployment you may need to setup proxy settings using your web or proxy server (ie: nginx, apache).
85
+
86
+ ````typescript
87
+ import { fileURLToPath, URL } from "node:url";
88
+
89
+ import { defineConfig, loadEnv } from "vite";
90
+ import vue from "@vitejs/plugin-vue";
91
+ import dotenv from "dotenv";
92
+
93
+ // https://vitejs.dev/config/
94
+ export default defineConfig(({ command, mode }) => {
95
+ const env = loadEnv(mode, process.cwd(), "");
96
+ console.log("=== env ===", mode, JSON.stringify(env));
97
+
98
+ const VITE_PROXY = "https://basic-dev.rev-kitten.com";
99
+
100
+ return {
101
+ env: env,
102
+ plugins: [vue()],
103
+ server: {
104
+ host: true,
105
+ port: 5173,
106
+ proxy: {
107
+ "/api": {
108
+ target: VITE_PROXY,
109
+ secure: false,
110
+ changeOrigin: true,
111
+ },
112
+ "/admin": { target: VITE_PROXY, secure: false, changeOrigin: true },
113
+ "/default": { target: VITE_PROXY, secure: false, changeOrigin: true },
114
+
115
+
116
+ },
117
+ },
118
+ devServer: {
119
+ host: true,
120
+ port: 5173,
121
+ proxy: {
122
+ "/api": { target: VITE_PROXY, secure: false, changeOrigin: true},
123
+ "/admin": { target: VITE_PROXY, secure: false,
124
+ changeOrigin: true },
125
+ "/default": { target: VITE_PROXY, true: false, changeOrigin: true },
126
+ },
127
+ },
128
+
129
+ resolve: {
130
+ alias: {
131
+ "@": fileURLToPath(new URL("./src", import.meta.url)),
132
+ },
133
+ },
134
+ //@ts-ignore
135
+ test: {
136
+ globals: true,
137
+ environment: "jsdom",
138
+ }
139
+ };
140
+ });
141
+ ````
142
+
77
143
  #### Connect to a Space
78
144
 
79
145
  ````typescript
@@ -85,6 +151,9 @@ const authUser = {
85
151
  // set spaceUrl
86
152
  const spaceUrl = "https://basic-dev.rev-kitten.com/showcase/model3d_public/1?token=e707880f-0fc5-48a6-b3f6-643a19f81464";
87
153
 
154
+ // space url can also be a matterport url
155
+ // ex: const spaceUrl = "https://my.matterport.com/show/?m=qSGGhhjTYbN";
156
+
88
157
  const auth = {
89
158
  apiKey: apiKey,
90
159
  user: authUser
@@ -92,6 +161,7 @@ const authUser = {
92
161
 
93
162
  const config: IMPConfig = {
94
163
  iframeId: 'mp-showcase',
164
+ bundlePath: "path/to/bundle", // optional. Iframe src should be something like this: <bundlePath>/bundle/showcase.html?
95
165
  play: 1,
96
166
  }
97
167
 
@@ -152,6 +222,7 @@ await atwin.connectSpace(url, auth, config)
152
222
  ```typescript
153
223
  export interface IMPConfig{
154
224
  iframeId: string,
225
+ bundlePath: string,
155
226
  play?: 0 | 1,
156
227
  qs?: 0 | 1,
157
228
  tour?: 0 | 1 | 2 | 3,
@@ -160,6 +231,16 @@ export interface IMPConfig{
160
231
  ```
161
232
 
162
233
  **iframeId:** string,
234
+
235
+ **bundlePath?:** string, bundlePath is an optional key that can be set for projects whose project structure require 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 find inside the architwin package in node_modules. The path should end with a /
236
+
237
+ *Example:*
238
+
239
+ `bundlePath: "assets/"`
240
+
241
+ This will resolve internally to `"assets/bundle/showcase.html?someparams"`
242
+
243
+
163
244
  **play?:** 0 | 1, default = 0
164
245
 
165
246
  - 0 Shows a Play button ▶️️ on the iframe. The user must press the Play button ▶️️ to open the Matterport model.
@@ -196,7 +277,7 @@ This will move the user to the nearest Sweep marker in the indicated direction.
196
277
  ````typescript
197
278
  <script lang="ts">
198
279
  import atwin from 'architwin';
199
- import type { IMPConfig, IUser } from 'types';
280
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
200
281
  import { onMounted, ref } from 'vue';
201
282
 
202
283
  ...
@@ -227,7 +308,7 @@ Note, cameraPan will work only in *Dollhouse* mode.
227
308
  ````typescript
228
309
  <script lang="ts">
229
310
  import atwin from 'architwin';
230
- import type { IMPConfig, IUser } from 'types';
311
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
231
312
  import { onMounted, ref } from 'vue';
232
313
 
233
314
  ...
@@ -303,7 +384,7 @@ moveToSweep(sweepId) - // to move to a specific Sweep
303
384
  ````typescript
304
385
  <script lang="ts">
305
386
  import atwin from 'architwin';
306
- import type { IMPConfig, IUser } from 'types';
387
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
307
388
  import { onMounted, ref } from 'vue';
308
389
 
309
390
  ...
@@ -328,6 +409,10 @@ moveToSweep(sweepId) - // to move to a specific Sweep
328
409
 
329
410
  ## Function Reference
330
411
  --------------------------
412
+ ```typescript
413
+ disconnectSpace() // disconnects and clear currently displayed Space
414
+ ```
415
+
331
416
  #### Tags
332
417
  ````typescript
333
418
  getTags() - // returns an array of tag objects found in the Space
@@ -351,7 +436,7 @@ getSweepPosition(): {x: number, y: number, z: number} - // returns the position
351
436
  ````typescript
352
437
  <script lang="ts">
353
438
  import atwin from 'architwin';
354
- import type { IMPConfig, IUser } from 'types';
439
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
355
440
  import { onMounted, ref } from 'vue';
356
441
 
357
442
  ...
@@ -390,7 +475,7 @@ pauseVideo(videoId: number) - // pause a video screen
390
475
  ````typescript
391
476
  <script lang="ts">
392
477
  import atwin from 'architwin';
393
- import type { IMPConfig, IUser } from 'types';
478
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
394
479
  import { onMounted, ref } from 'vue';
395
480
 
396
481
  ...
@@ -437,7 +522,7 @@ cameraRotate(x: number, y: number, speed: number) - // rotates the camera view,
437
522
  ````typescript
438
523
  <script lang="ts">
439
524
  import atwin from 'architwin';
440
- import type { IMPConfig, IUser } from 'types';
525
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
441
526
  import { onMounted, ref } from 'vue';
442
527
 
443
528
  ...
@@ -502,7 +587,7 @@ getNearbyObjects(type?: '3DX' | 'SLIDESHOW' | 'VIDEO', distance?: number = 2)
502
587
  ````typescript
503
588
  <script lang="ts">
504
589
  import atwin from 'architwin';
505
- import type { IMPConfig, IUser } from 'types';
590
+ import type { IMPConfig, IUser } from 'architwin/lib/types';
506
591
  import { onMounted, ref } from 'vue';
507
592
 
508
593
  ...
@@ -98,6 +98,7 @@
98
98
 
99
99
  <script src='vendors/three/0.146.0/three.min.js'></script>
100
100
  <script src='js/browser-check.js'></script>
101
+ <!-- <script src='js/showcase.js'></script> -->
101
102
  <script src='https://cdn.jsdelivr.net/npm/architwin@1.0.13/bundle/js/showcase.js'></script>
102
103
  <script>
103
104
  var detailObject = {
@@ -1,10 +1,12 @@
1
1
  import type { MpSdk } from "../bundle/sdk";
2
2
  import type { IUser, IMPConfig, ISweep, ITagPublic } from "./types";
3
+ declare let tags: ITagPublic[];
4
+ declare let sweeps: any;
3
5
  declare function connectSpace(url: string, auth: {
4
6
  apiKey: string;
5
7
  user: IUser;
6
8
  }, config: IMPConfig): Promise<void>;
7
- declare function gotoTag(tag_id: number): Promise<void>;
9
+ declare function gotoTag(tag_id: string): Promise<void>;
8
10
  declare function getCurrentSweep(): ISweep;
9
11
  declare function getCurrentCameraPose(): any;
10
12
  declare function getCameraPosition(): any;
@@ -25,10 +27,12 @@ declare function cameraLookAt(x: number, y: number): Promise<void>;
25
27
  declare function moveInDirection(direction: string): Promise<void>;
26
28
  declare function getViewMode(): MpSdk.Mode.Mode;
27
29
  declare function setViewMode(mode: string): Promise<void>;
28
- declare const _default: {
30
+ declare function disconnectSpace(): void;
31
+ declare const atwin: {
29
32
  tags: ITagPublic[];
30
33
  sweeps: any;
31
34
  connectSpace: typeof connectSpace;
35
+ disconnectSpace: typeof disconnectSpace;
32
36
  gotoTag: typeof gotoTag;
33
37
  getCurrentSweep: typeof getCurrentSweep;
34
38
  getCurrentSweepPosition: typeof getCurrentSweepPosition;
@@ -45,4 +49,4 @@ declare const _default: {
45
49
  getViewMode: typeof getViewMode;
46
50
  setViewMode: typeof setViewMode;
47
51
  };
48
- export default _default;
52
+ export { atwin as default, tags, sweeps, connectSpace, disconnectSpace, gotoTag, getCurrentSweep, getCurrentSweepPosition, moveToSweep, getNearbySweeps, pauseVideo, playVideo, getCurrentCameraPose, getCameraPosition, moveInDirection, cameraLookAt, cameraPan, cameraRotate, getViewMode, setViewMode, };
@@ -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","play","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/v1/";var sdkKey=_config.mp.sdkKey;var urlParams=_config.mp.urlParams;console.log("apiURL...",apiURL);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 _currentSweep={};var _currentCameraPose={};var _sweeps=[];var _atwinSrc="/bundle/showcase.html?m=''&applicationKey=".concat(sdkKey,"&newtags=1");function connectSpace(url,auth,config){var _a;return __awaiter(this,void 0,void 0,(function(){var api,showcase,spaceId,space,tags,objects,showcaseWindow;var _this=this;return __generator(this,(function(_b){switch(_b.label){case 0:console.log("connectSpace()");console.log("__config",config);api=axios.create({baseURL:apiURL,headers:{"Access-Control-Allow-Origin":"*","Content-Type":"application/json",Authorization:auth.apiKey}});_api=api;showcase=document.getElementById(config.iframeId);spaceId=getSpaceId(url);if(!spaceId){console.error("spaceId is undefined");return[2]}return[4,loginUser(auth.user)];case 1:_b.sent();return[4,getSpace(spaceId)];case 2:space=_b.sent();if(!space){console.error("space is undefined");return[2]}setSpace(space);_atwinSrc=getIframeSrc(config);console.log("__atwinSrc",_atwinSrc);showcase.src=_atwinSrc;return[4,getTags(space)];case 3:tags=_b.sent();if(!tags){console.log("tags is undefined");return[2]}setTags(tags);return[4,get3DObjects(spaceId)];case 4:objects=_b.sent();if(!objects){console.log("objects is undefined");return[2]}(_a=showcase.contentWindow)===null||_a===void 0?void 0:_a.location.reload();showcaseWindow=showcase.contentWindow;showcase.addEventListener("load",(function(){return __awaiter(_this,void 0,void 0,(function(){var e_1;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);onShowcaseConnect();return[3,4];case 3:e_1=_a.sent();console.error(e_1);return[3,4];case 4:return[2]}}))}))}));return[2]}}))}))}function onShowcaseConnect(){return __awaiter(this,void 0,void 0,(function(){var modelData,e_2;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,2];console.log("App is loading...");return[4,hideTags()];case 1:_a.sent();return[3,7];case 2:if(!(appState.phase===_atwin.App.Phase.STARTING))return[3,4];console.log("App is starting...");return[4,showTags(_tags)];case 3:_a.sent();return[3,7];case 4:if(!(appState.phase===_atwin.App.Phase.PLAYING))return[3,7];console.log("App is playing...");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)){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_2=_a.sent();console.error(e_2);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){console.log("getIframeSrc()",config);var modelId=_space.space_url.split("?m=")[1];if(!modelId){console.error("modelId is undefined");return""}var src="";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+="rchitwin/bundle/showcase.html?m=".concat(modelId,"&applicationKey=").concat(sdkKey,"&newtags=1")}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("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("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("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("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 tag,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]);tag=_tags.find((function(i){return i.id===tag_id}));if(!tag){console.error("tag is not found");return[2]}return[4,_atwin.Mattertag.navigateToTag(tag.json_data.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.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 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()]||""}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}();export default{tags:tags,sweeps:sweeps,connectSpace:connectSpace,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};
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/v1/";var sdkKey=_config.mp.sdkKey;var urlParams=_config.mp.urlParams;console.log("apiURL...",apiURL);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 _currentSweep={};var _currentCameraPose={};var _sweeps=[];var _isInitialLoad=true;function connectSpace(url,auth,config){return __awaiter(this,void 0,void 0,(function(){var api,showcase;return __generator(this,(function(_a){switch(_a.label){case 0:console.log("connectSpace()");console.log("__config",config);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);_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[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)){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){src+="".concat(config.bundlePath,"bundle/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("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("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("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("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 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(){console.log("disconnectSpace()");_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=[]}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};export{atwin as default,tags,sweeps,connectSpace,disconnectSpace,gotoTag,getCurrentSweep,getCurrentSweepPosition,moveToSweep,getNearbySweeps,pauseVideo,playVideo,getCurrentCameraPose,getCameraPosition,moveInDirection,cameraLookAt,cameraPan,cameraRotate,getViewMode,setViewMode};
package/lib/types.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface ITag {
10
10
  json_data: MpSdk.Tag.TagData;
11
11
  }
12
12
  export interface ITagPublic {
13
- id: number;
13
+ id: string;
14
14
  name: string;
15
15
  }
16
16
  export interface IUser {
@@ -19,6 +19,7 @@ export interface IUser {
19
19
  }
20
20
  export interface IMPConfig {
21
21
  iframeId: string;
22
+ bundlePath?: string;
22
23
  help?: 0 | 1 | 2;
23
24
  nt?: 0 | 1;
24
25
  play?: 0 | 1;
@@ -49,19 +50,7 @@ export interface IMPConfig {
49
50
  search?: 0 | 1;
50
51
  wh?: 0 | 1;
51
52
  prod?: boolean;
52
- }
53
- export declare const enum MP_LANG {
54
- EN = "en",
55
- ES = "es",
56
- FR = "fr",
57
- DE = "de",
58
- RU = "ru",
59
- ZH = "zh",
60
- JA = "ja",
61
- KO = "ko",
62
- NL = "nl",
63
- IT = "it",
64
- PT = "pt"
53
+ domain: string;
65
54
  }
66
55
  export interface ISweep {
67
56
  alignmentType: MpSdk.Sweep.Alignment;
@@ -153,8 +142,16 @@ export declare const enum OBJECT_TYPE {
153
142
  VIDEO = "VIDEO",
154
143
  SLIDESHOW = "SLIDESHOW"
155
144
  }
156
- export declare const enum TRANSFORM_TYPE {
157
- TRANSLATE = "translate",
158
- ROTATE = "rotate",
159
- SCALE = "scale"
145
+ export declare const enum MP_LANG {
146
+ EN = "en",
147
+ ES = "es",
148
+ FR = "fr",
149
+ DE = "de",
150
+ RU = "ru",
151
+ ZH = "zh",
152
+ JA = "ja",
153
+ KO = "ko",
154
+ NL = "nl",
155
+ IT = "it",
156
+ PT = "pt"
160
157
  }
package/lib/types.js CHANGED
@@ -1 +1,5 @@
1
1
  export {};
2
+ // export const enum URL_TYPE {
3
+ // ROK = 'ROK',
4
+ // MP = 'MP',
5
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.min.js",
6
6
  "types": "./lib/architwin.d.ts",
@@ -15,9 +15,9 @@
15
15
  "default": {
16
16
  "default": "./lib/architwin.min.js"
17
17
  }
18
- }
18
+ },
19
+ "./lib/types": "./types.d.ts"
19
20
  },
20
-
21
21
  "scripts": {
22
22
  "test": "echo \"Error: no test specified\" && exit 1",
23
23
  "build": "tsc && terser lib/architwin.js -o lib/architwin.min.js"
@@ -30,12 +30,14 @@
30
30
  "jszip": "^3.10.1",
31
31
  "jszip-utils": "^0.1.0",
32
32
  "mathjs": "^11.8.0",
33
+ "terser": "^5.17.7",
33
34
  "three": "^0.152.2",
34
35
  "ts-loader": "^9.4.3"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@tsconfig/node18": "^2.0.1",
38
39
  "@types/node": "^18.16.15",
40
+ "@types/validator": "^13.7.17",
39
41
  "javascript-obfuscator": "^4.0.2",
40
42
  "terser-webpack-plugin": "^5.3.9",
41
43
  "typescript": "5.0.4",
package/tsconfig.json CHANGED
@@ -10,4 +10,4 @@
10
10
  },
11
11
  "include": ["src"],
12
12
  "exclude": ["node_modules", "**/__tests__/*"],
13
- }
13
+ }