architwin 1.3.0 → 1.3.2

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.
@@ -7,3 +7,4 @@ export declare function setTransformType(type: string): void;
7
7
  export declare function getCoordinateValues(): Object3DPosition;
8
8
  export declare function clearCoordinateInputs(): void;
9
9
  export declare function showCurrentCoordinateValue(): void;
10
+ export declare function handleModelControlInputs(): void;
@@ -1,6 +1,7 @@
1
1
  import { useCapitalizeFirstLetter } from "../../../utils";
2
2
  import { getSelectedObject } from "../../../architwin";
3
3
  import { Notyf } from 'notyf';
4
+ import log from 'loglevel';
4
5
  let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500 });
5
6
  export let activeModelControlPane = false;
6
7
  export let modelControlPane;
@@ -8,6 +9,7 @@ let transformType = 'translate';
8
9
  let inputX;
9
10
  let inputY;
10
11
  let inputZ;
12
+ let isInputEventListenerSet = false;
11
13
  export function renderModelControlPane(type = 'Translate') {
12
14
  const element = document.createElement('div');
13
15
  element.classList.add('at_container');
@@ -24,17 +26,17 @@ export function renderModelControlPane(type = 'Translate') {
24
26
  <div class="at_number_field">
25
27
  <span class="at_bolder">X</span>
26
28
  <input type="number" id="at-input-x" class="at_rounded_input"/>
27
- <span class="at_bolder">m</span>
29
+ <span class="at_bolder at_model_unit">m</span>
28
30
  </div>
29
31
  <div class="at_number_field">
30
32
  <span class="at_bolder">Y</span>
31
33
  <input type="number" id="at-input-y" class="at_rounded_input"/>
32
- <span class="at_bolder">m</span>
34
+ <span class="at_bolder at_model_unit">m</span>
33
35
  </div>
34
36
  <div class="at_number_field">
35
37
  <span class="at_bolder">Z</span>
36
38
  <input type="number" id="at-input-z" class="at_rounded_input"/>
37
- <span class="at_bolder">m</span>
39
+ <span class="at_bolder at_model_unit">m</span>
38
40
  </div>
39
41
  <button class="at_button at_primary_azusa" id="at-confirm-transform">Confirm</button>
40
42
  </div>
@@ -67,6 +69,7 @@ export function setTransformType(type) {
67
69
  transformType = type.toLowerCase();
68
70
  return;
69
71
  }
72
+ setModelInputUnit(type);
70
73
  console.error("transformTypeTitle is undefined");
71
74
  return;
72
75
  }
@@ -154,3 +157,58 @@ export function showCurrentCoordinateValue() {
154
157
  inputZ.value = currentScale.z.toFixed(3).toString();
155
158
  }
156
159
  }
160
+ function setModelInputUnit(type) {
161
+ log.info("setModelInputUnit()");
162
+ if (!type) {
163
+ console.error("Type is undefined");
164
+ return;
165
+ }
166
+ const elements = document.querySelectorAll(`at_model_unit`);
167
+ if (elements && elements.length > 0) {
168
+ elements.forEach((element) => {
169
+ if (type === 'translate') {
170
+ element.textContent = 'm';
171
+ }
172
+ else if (type === 'rotate') {
173
+ element.textContent = '°';
174
+ }
175
+ else if (type === 'scale') {
176
+ element.textContent = '%';
177
+ }
178
+ });
179
+ }
180
+ }
181
+ function onModelControlInput(event) {
182
+ //@ts-expect-error
183
+ const value = event.target.value;
184
+ if (!value) {
185
+ return;
186
+ }
187
+ const decimalIndex = value.indexOf('.');
188
+ if (decimalIndex !== -1) {
189
+ const decimalPlaces = value.substring(decimalIndex + 1).length;
190
+ if (decimalPlaces >= 4) {
191
+ // Prevent additional input if there are already 3 or more decimal places
192
+ //@ts-expect-error
193
+ event.target.value = value.slice(0, -1);
194
+ }
195
+ }
196
+ }
197
+ export function handleModelControlInputs() {
198
+ log.info("handleModelControlInputs()");
199
+ if (!inputX) {
200
+ inputX = document.getElementById('at-input-x');
201
+ }
202
+ if (!inputY) {
203
+ inputY = document.getElementById('at-input-y');
204
+ }
205
+ if (!inputZ) {
206
+ inputZ = document.getElementById('at-input-z');
207
+ }
208
+ if (isInputEventListenerSet) {
209
+ return;
210
+ }
211
+ inputX.addEventListener('input', onModelControlInput);
212
+ inputY.addEventListener('input', onModelControlInput);
213
+ inputZ.addEventListener('input', onModelControlInput);
214
+ }
@@ -16,7 +16,7 @@ import { initFormData } from "./components/toolbar/tagFormPane";
16
16
  import { renderObjectList } from "./components/toolbar/objectListPane";
17
17
  import { renderLibraryList } from "./components/toolbar/libraryPane";
18
18
  import { renderObjectCard } from "./components/toolbar/card";
19
- import { toggleModelControl, getCoordinateValues, showCurrentCoordinateValue } from "./components/toolbar/modelControlsPane";
19
+ import { toggleModelControl, getCoordinateValues, showCurrentCoordinateValue, handleModelControlInputs } from "./components/toolbar/modelControlsPane";
20
20
  import { attachTagMedia } from "../tag";
21
21
  import i18n from './components/toolbar/i18n';
22
22
  import { isValidUrl } from "../utils";
@@ -191,6 +191,7 @@ function setupIndividualEventListeners() {
191
191
  // handleToggleDropdown()
192
192
  handleCloseModelControls();
193
193
  handleConfirmTransform();
194
+ handleModelControlInputs();
194
195
  }
195
196
  //================ OBJECT EVENT HANDLERS ===============//
196
197
  function handleTranslateObject() {
package/lib/convert.d.ts CHANGED
@@ -1,11 +1,6 @@
1
- export declare let generatedIds: Array<number>;
2
1
  export declare function meterToMillimeter(meter: number, decimal?: number): number;
3
2
  export declare function generateRandomUniqueNumber(currentIds: Array<number>): number;
4
- export declare function generateUUID(config?: {
5
- length?: number;
6
- separator?: string;
7
- }): string;
8
- export declare function generateRandomUsername(): string;
3
+ export declare function generateUUID(): string;
9
4
  export declare function useHexToRgb(hexcode: string): {
10
5
  r: number;
11
6
  g: number;
@@ -16,11 +11,3 @@ export declare function useRgbToHex(color: {
16
11
  g: number;
17
12
  b: number;
18
13
  }): string;
19
- export declare function convertToCssRgb(values: {
20
- r: number;
21
- g: number;
22
- b: number;
23
- }): string;
24
- export declare function arrayBufferToBase64(buffer: any): string;
25
- export declare function isUrlValid(userInput: string): boolean;
26
- export declare function dateTimeFormat(d: any): string;
package/lib/convert.js CHANGED
@@ -1,6 +1,3 @@
1
- import { format, toDate } from 'date-fns';
2
- import { ja } from 'date-fns/locale';
3
- export let generatedIds = [];
4
1
  export function meterToMillimeter(meter, decimal = 2) {
5
2
  const mm = meter * 1000;
6
3
  return parseFloat(mm.toFixed(decimal));
@@ -16,7 +13,7 @@ export function generateRandomUniqueNumber(currentIds) {
16
13
  } while (currentIds.indexOf(randomNumber) !== -1);
17
14
  return randomNumber;
18
15
  }
19
- export function generateUUID(config) {
16
+ export function generateUUID() {
20
17
  const cryptoObj = window.crypto;
21
18
  if (!cryptoObj) {
22
19
  console.error('crypto.getRandomValues() is not supported in this browser.');
@@ -32,42 +29,16 @@ export function generateUUID(config) {
32
29
  }
33
30
  hex.push(val);
34
31
  }
35
- let randUUID = `${hex[0]}${hex[1]}-${hex[2]}-${hex[3]}-${hex[4]}-${hex[5]}${hex[6]}${hex[7]}`;
36
- if (config && config.length) {
37
- console.log('Length set');
38
- randUUID = randUUID.slice(0, config.length);
39
- }
40
- if (config && config.separator) {
41
- console.log('Separator set');
42
- if (config.separator === 'none') {
43
- randUUID = randUUID.replace(/-/g, config.separator);
44
- }
45
- }
46
- return randUUID;
47
- }
48
- export function generateRandomUsername() {
49
- // Helper function to generate a random word
50
- function getRandomWord(length) {
51
- let result = '';
52
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
53
- const charactersLength = characters.length;
54
- for (let i = 0; i < length; i++) {
55
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
56
- }
57
- return result;
58
- }
59
- const randomWord = getRandomWord(Math.floor(Math.random() * 5) + 4);
60
- const randomNumber = Math.floor(Math.random() * 10000);
61
- const username = `${randomWord}${randomNumber}`;
62
- return username;
32
+ // The UUID string format is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
33
+ return `${hex[0]}${hex[1]}-${hex[2]}-${hex[3]}-${hex[4]}-${hex[5]}${hex[6]}${hex[7]}`;
63
34
  }
64
35
  export function useHexToRgb(hexcode) {
65
36
  // Remove '#' symbol if it exists
66
37
  hexcode = hexcode.replace("#", "");
67
38
  // Parse hex values for red, green, and blue
68
- const r = parseInt(hexcode.substring(0, 2), 16) / 255;
69
- const g = parseInt(hexcode.substring(2, 4), 16) / 255;
70
- const b = parseInt(hexcode.substring(4, 6), 16) / 255;
39
+ const r = parseInt(hexcode.substring(0, 2), 16);
40
+ const g = parseInt(hexcode.substring(2, 4), 16);
41
+ const b = parseInt(hexcode.substring(4, 6), 16);
71
42
  return { r, g, b };
72
43
  }
73
44
  export function useRgbToHex(color) {
@@ -81,31 +52,3 @@ export function useRgbToHex(color) {
81
52
  const hexB = color.b.toString(16).padStart(2, "0");
82
53
  return `${hexR}${hexG}${hexB}`;
83
54
  }
84
- export function convertToCssRgb(values) {
85
- // console.log('convertToCssRgb()', values)
86
- if (!values) {
87
- console.log('values is undefined');
88
- return;
89
- }
90
- let r = Math.round(values.r * 255);
91
- let g = Math.round(values.g * 255);
92
- let b = Math.round(values.b * 255);
93
- return `rgb(${r},${g},${b})`;
94
- }
95
- export function arrayBufferToBase64(buffer) {
96
- let binary = '';
97
- const bytes = new Uint8Array(buffer);
98
- const len = bytes.byteLength;
99
- for (let i = 0; i < len; i++) {
100
- binary += String.fromCharCode(bytes[i]);
101
- }
102
- return btoa(binary);
103
- }
104
- export function isUrlValid(userInput) {
105
- const urlPattern = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
106
- return urlPattern.test(userInput);
107
- }
108
- export function dateTimeFormat(d) {
109
- const local = format(toDate(d), 'yyyy年M月d日 HH:mm:ss', { locale: ja });
110
- return local;
111
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",
@@ -1,4 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class Menubar extends LitElement {
3
- render(): import("lit-html").TemplateResult<1>;
4
- }
@@ -1,35 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html, LitElement } from 'lit';
8
- import { customElement } from 'lit/decorators.js';
9
- let Menubar = class Menubar extends LitElement {
10
- render() {
11
- return html `
12
- <div class="at_toolbar_container" id="at-menu-bar">
13
- <div class="at_sidebar_button_icon">
14
- <span class="mdi mdi-bullseye" id="at-expand-btn"></span>
15
- </div>
16
- <div class="at_sidebar_button_icon">
17
- <span class="mdi mdi-cube-outline" id="at-object-list-btn"></span>
18
- </div>
19
- <div class="at_sidebar_button_icon">
20
- <span class="mdi mdi-map" id="at-minimap-btn" target-pane="at-map"></span>
21
- </div>
22
- <div class="at_sidebar_button_icon">
23
- <span class="mdi mdi-message-video" id="at-videocall-btn"></span>
24
- </div>
25
- <div class="at_sidebar_button_icon">
26
- <span class="mdi mdi-monitor-screenshot" id="at-screenshot-btn"></span>
27
- </div>
28
- </div>
29
- `;
30
- }
31
- };
32
- Menubar = __decorate([
33
- customElement('at-menubar')
34
- ], Menubar);
35
- export { Menubar };
@@ -1,5 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class SidebarContainer extends LitElement {
3
- checked: boolean;
4
- render(): import("lit-html").TemplateResult<1>;
5
- }
@@ -1,27 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html, LitElement } from 'lit';
8
- import { customElement, property } from 'lit/decorators.js';
9
- let SidebarContainer = class SidebarContainer extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- this.checked = false;
13
- }
14
- render() {
15
- return html `
16
- <div class="at_sidebar_container at_topRight" id="at-sidebar-container">
17
- </div>
18
- `;
19
- }
20
- };
21
- __decorate([
22
- property()
23
- ], SidebarContainer.prototype, "checked", void 0);
24
- SidebarContainer = __decorate([
25
- customElement('at-sidebar-container')
26
- ], SidebarContainer);
27
- export { SidebarContainer };
package/pre_deploy.sh DELETED
@@ -1,48 +0,0 @@
1
- #!/bin/bash
2
-
3
- # -o option
4
- # This option is supported if the system supports the User Portability Utilities op‐
5
- # tion. It shall set various options, many of which shall be equivalent to the single
6
- # option letters. The following values of option shall be supported:
7
-
8
- # allexport Equivalent to -a.
9
-
10
- # === to support environment files ===
11
-
12
- # Load nvm
13
- export NVM_DIR="$HOME/.nvm"
14
- # This loads nvm
15
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
16
- # This loads nvm bash_completion
17
- [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
18
-
19
- set -a
20
- . .env.local
21
- set +a
22
-
23
- export ROOT=`pwd`
24
- export HOME=/home/$USER
25
-
26
- # latest TAG
27
- export TAG_LATEST=$(git tag | tail -n1 | cut -f1)
28
- # use export TAG=<v#.#.#_rc###> to set TAG, otherwise use latest
29
- if [ -z "$TAG" ]; then
30
- export TAG=$TAG_LATEST
31
- fi
32
-
33
- echo "\n=> TAG to publish...$TAG"
34
- # Pause the script
35
- # read -p "Press Enter to continue..."
36
-
37
- echo "\n=> Force PUSH TAGS to Origin..."
38
- git push -f --tags -v
39
-
40
- echo "\n=> Locally, checkout deployment TAG and build..."
41
- git checkout $TAG
42
-
43
- echo "\n=> Building..."
44
- npm run build
45
-
46
- # We must clear temp TAG!!!
47
- echo "\n Cleaning up environment..."
48
- export TAG=