@xviewer.js/debug 1.0.0-beta.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -3,6 +3,11 @@
3
3
  var three = require('three');
4
4
  var core = require('@xviewer.js/core');
5
5
 
6
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
7
+
8
+ var css = "@charset \"UTF-8\";\n.lil-gui {\n font-family: var(--font-family);\n font-size: var(--font-size);\n line-height: 1;\n font-weight: normal;\n font-style: normal;\n text-align: left;\n background-color: var(--background-color);\n color: var(--text-color);\n user-select: none;\n -webkit-user-select: none;\n touch-action: manipulation;\n --background-color: #1f1f1f;\n --text-color: #ebebeb;\n --title-background-color: #111111;\n --title-text-color: #ebebeb;\n --widget-color: #424242;\n --hover-color: #4f4f4f;\n --focus-color: #595959;\n --number-color: #2cc9ff;\n --string-color: #a2db3c;\n --font-size: 11px;\n --input-font-size: 11px;\n --font-family: -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n Arial,\n sans-serif;\n --font-family-mono: Menlo,\n Monaco,\n Consolas,\n \"Droid Sans Mono\",\n monospace;\n --padding: 4px;\n --spacing: 4px;\n --widget-height: 20px;\n --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);\n --name-width: 40%;\n --slider-knob-width: 2px;\n --slider-input-width: 27%;\n --color-input-width: 27%;\n --slider-input-min-width: 45px;\n --color-input-min-width: 45px;\n --folder-indent: 7px;\n --widget-padding: 0 0 0 3px;\n --widget-border-radius: 2px;\n --checkbox-size: calc(0.75 * var(--widget-height));\n --scrollbar-width: 5px;\n}\n.lil-gui, .lil-gui * {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n.lil-gui.root {\n width: var(--width, 245px);\n display: flex;\n flex-direction: column;\n}\n.lil-gui.root > .title {\n background: var(--title-background-color);\n color: var(--title-text-color);\n}\n.lil-gui.root > .children {\n overflow-x: hidden;\n overflow-y: auto;\n}\n.lil-gui.root > .children::-webkit-scrollbar {\n width: var(--scrollbar-width);\n height: var(--scrollbar-width);\n background: var(--background-color);\n}\n.lil-gui.root > .children::-webkit-scrollbar-thumb {\n border-radius: var(--scrollbar-width);\n background: var(--focus-color);\n}\n@media (pointer: coarse) {\n .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {\n --widget-height: 28px;\n --padding: 6px;\n --spacing: 6px;\n --font-size: 13px;\n --input-font-size: 16px;\n --folder-indent: 10px;\n --scrollbar-width: 7px;\n --slider-input-min-width: 50px;\n --color-input-min-width: 65px;\n }\n}\n.lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {\n --widget-height: 28px;\n --padding: 6px;\n --spacing: 6px;\n --font-size: 13px;\n --input-font-size: 16px;\n --folder-indent: 10px;\n --scrollbar-width: 7px;\n --slider-input-min-width: 50px;\n --color-input-min-width: 65px;\n}\n.lil-gui.autoPlace {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 1001;\n}\n\n.lil-gui .controller {\n display: flex;\n align-items: center;\n padding: 0 var(--padding);\n margin: var(--spacing) 0;\n}\n.lil-gui .controller.disabled {\n opacity: 0.5;\n}\n.lil-gui .controller.disabled, .lil-gui .controller.disabled * {\n pointer-events: none !important;\n}\n.lil-gui .controller > .name {\n min-width: var(--name-width);\n flex-shrink: 0;\n white-space: pre;\n padding-right: var(--spacing);\n line-height: var(--widget-height);\n}\n.lil-gui .controller .widget {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n min-height: var(--widget-height);\n}\n.lil-gui .controller.string input {\n color: var(--string-color);\n}\n.lil-gui .controller.boolean .widget {\n cursor: pointer;\n}\n.lil-gui .controller.color .display {\n width: 100%;\n height: var(--widget-height);\n border-radius: var(--widget-border-radius);\n position: relative;\n}\n@media (hover: hover) {\n .lil-gui .controller.color .display:hover:before {\n content: \" \";\n display: block;\n position: absolute;\n border-radius: var(--widget-border-radius);\n border: 1px solid rgba(255, 255, 255, 0.6);\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n}\n.lil-gui .controller.color input[type=color] {\n opacity: 0;\n width: 100%;\n height: 100%;\n cursor: pointer;\n}\n.lil-gui .controller.color input[type=text] {\n margin-left: var(--spacing);\n font-family: var(--font-family-mono);\n min-width: var(--color-input-min-width);\n width: var(--color-input-width);\n flex-shrink: 0;\n}\n.lil-gui .controller.option select {\n opacity: 0;\n position: absolute;\n width: 100%;\n max-width: 100%;\n}\n.lil-gui .controller.option .display {\n position: relative;\n pointer-events: none;\n border-radius: var(--widget-border-radius);\n height: var(--widget-height);\n line-height: var(--widget-height);\n max-width: 100%;\n overflow: hidden;\n word-break: break-all;\n padding-left: 0.55em;\n padding-right: 1.75em;\n background: var(--widget-color);\n}\n@media (hover: hover) {\n .lil-gui .controller.option .display.focus {\n background: var(--focus-color);\n }\n}\n.lil-gui .controller.option .display.active {\n background: var(--focus-color);\n}\n.lil-gui .controller.option .display:after {\n font-family: \"lil-gui\";\n content: \"↕\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n padding-right: 0.375em;\n}\n.lil-gui .controller.option .widget,\n.lil-gui .controller.option select {\n cursor: pointer;\n}\n@media (hover: hover) {\n .lil-gui .controller.option .widget:hover .display {\n background: var(--hover-color);\n }\n}\n.lil-gui .controller.number input {\n color: var(--number-color);\n}\n.lil-gui .controller.number.hasSlider input {\n margin-left: var(--spacing);\n width: var(--slider-input-width);\n min-width: var(--slider-input-min-width);\n flex-shrink: 0;\n}\n.lil-gui .controller.number .slider {\n width: 100%;\n height: var(--widget-height);\n background-color: var(--widget-color);\n border-radius: var(--widget-border-radius);\n padding-right: var(--slider-knob-width);\n overflow: hidden;\n cursor: ew-resize;\n touch-action: pan-y;\n}\n@media (hover: hover) {\n .lil-gui .controller.number .slider:hover {\n background-color: var(--hover-color);\n }\n}\n.lil-gui .controller.number .slider.active {\n background-color: var(--focus-color);\n}\n.lil-gui .controller.number .slider.active .fill {\n opacity: 0.95;\n}\n.lil-gui .controller.number .fill {\n height: 100%;\n border-right: var(--slider-knob-width) solid var(--number-color);\n box-sizing: content-box;\n}\n.lil-gui .controller.texture canvas {\n width: 100%;\n border-radius: var(--widget-border-radius);\n}\n.lil-gui .controller.texture .group {\n display: flex;\n position: relative;\n width: 100%;\n}\n.lil-gui .controller.texture .info {\n position: absolute;\n display: flex;\n gap: 11px;\n}\n.lil-gui .controller.texture .label {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.6745098039);\n display: \"flex\";\n padding: 2px;\n border-radius: var(--widget-border-radius);\n}\n.lil-gui .controller.texture .block {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n margin-top: 2px;\n width: var(--font-size);\n height: var(--font-size);\n border-radius: var(--font-size);\n background-color: white;\n cursor: pointer;\n}\n.lil-gui .controller.texture .block.select {\n background-color: var(--string-color);\n}\n.lil-gui .controller.image img {\n width: 100%;\n}\n.lil-gui .controller.image canvas {\n width: 100%;\n}\n.lil-gui .controller.vector input {\n color: var(--number-color);\n}\n.lil-gui .controller.vector .fill {\n height: 100%;\n margin-left: var(--spacing);\n box-sizing: content-box;\n}\n\n.lil-gui-dragging .lil-gui {\n --hover-color: var(--widget-color);\n}\n.lil-gui-dragging * {\n cursor: ew-resize !important;\n}\n\n.lil-gui-dragging.lil-gui-vertical * {\n cursor: ns-resize !important;\n}\n\n.lil-gui .title {\n height: var(--title-height);\n line-height: calc(var(--title-height) - 4px);\n font-weight: 600;\n padding: 0 var(--padding);\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n outline: none;\n text-decoration-skip: objects;\n}\n.lil-gui .title:before {\n font-family: \"lil-gui\";\n content: \"▾\";\n padding-right: 2px;\n display: inline-block;\n}\n.lil-gui .title:active {\n background: var(--title-background-color);\n opacity: 0.75;\n}\n@media (hover: hover) {\n body:not(.lil-gui-dragging) .lil-gui .title:hover {\n background: var(--title-background-color);\n opacity: 0.85;\n }\n .lil-gui .title:focus {\n text-decoration: underline var(--focus-color);\n }\n}\n.lil-gui.root > .title:focus {\n text-decoration: none !important;\n}\n.lil-gui.closed > .title:before {\n content: \"▸\";\n}\n.lil-gui.closed > .children {\n transform: translateY(-7px);\n opacity: 0;\n}\n.lil-gui.closed:not(.transition) > .children {\n display: none;\n}\n.lil-gui.transition > .children {\n transition-duration: 300ms;\n transition-property: height, opacity, transform;\n transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);\n overflow: hidden;\n pointer-events: none;\n}\n.lil-gui .children:empty:before {\n content: \"Empty\";\n padding: 0 var(--padding);\n margin: var(--spacing) 0;\n display: block;\n height: var(--widget-height);\n font-style: italic;\n line-height: var(--widget-height);\n opacity: 0.5;\n}\n.lil-gui.root > .children > .lil-gui > .title {\n border: 0 solid var(--widget-color);\n border-width: 1px 0;\n transition: border-color 300ms;\n}\n.lil-gui.root > .children > .lil-gui.closed > .title {\n border-bottom-color: transparent;\n}\n.lil-gui + .controller {\n border-top: 1px solid var(--widget-color);\n margin-top: 0;\n padding-top: var(--spacing);\n}\n.lil-gui .lil-gui .lil-gui > .title {\n border: none;\n}\n.lil-gui .lil-gui .lil-gui > .children {\n border: none;\n margin-left: var(--folder-indent);\n border-left: 2px solid var(--widget-color);\n}\n.lil-gui .lil-gui .controller {\n border: none;\n}\n\n.lil-gui input {\n -webkit-tap-highlight-color: transparent;\n border: 0;\n outline: none;\n font-family: var(--font-family);\n font-size: var(--input-font-size);\n border-radius: var(--widget-border-radius);\n height: var(--widget-height);\n background: var(--widget-color);\n color: var(--text-color);\n width: 100%;\n}\n@media (hover: hover) {\n .lil-gui input:hover {\n background: var(--hover-color);\n }\n .lil-gui input:active {\n background: var(--focus-color);\n }\n}\n.lil-gui input:disabled {\n opacity: 1;\n}\n.lil-gui input[type=text],\n.lil-gui input[type=number] {\n padding: var(--widget-padding);\n}\n.lil-gui input[type=text]:focus,\n.lil-gui input[type=number]:focus {\n background: var(--focus-color);\n}\n.lil-gui input::-webkit-outer-spin-button,\n.lil-gui input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n.lil-gui input[type=number] {\n -moz-appearance: textfield;\n}\n.lil-gui input[type=checkbox] {\n appearance: none;\n -webkit-appearance: none;\n height: var(--checkbox-size);\n width: var(--checkbox-size);\n border-radius: var(--widget-border-radius);\n text-align: center;\n cursor: pointer;\n}\n.lil-gui input[type=checkbox]:checked:before {\n font-family: \"lil-gui\";\n content: \"✓\";\n font-size: var(--checkbox-size);\n line-height: var(--checkbox-size);\n}\n@media (hover: hover) {\n .lil-gui input[type=checkbox]:focus {\n box-shadow: inset 0 0 0 1px var(--focus-color);\n }\n}\n.lil-gui button {\n -webkit-tap-highlight-color: transparent;\n outline: none;\n cursor: pointer;\n font-family: var(--font-family);\n font-size: var(--font-size);\n color: var(--text-color);\n width: 100%;\n height: var(--widget-height);\n text-transform: none;\n background: var(--widget-color);\n border-radius: var(--widget-border-radius);\n border: 1px solid var(--widget-color);\n text-align: center;\n line-height: calc(var(--widget-height) - 4px);\n}\n@media (hover: hover) {\n .lil-gui button:hover {\n background: var(--hover-color);\n border-color: var(--hover-color);\n }\n .lil-gui button:focus {\n border-color: var(--focus-color);\n }\n}\n.lil-gui button:active {\n background: var(--focus-color);\n}\n\n@font-face {\n font-family: \"lil-gui\";\n src: url(\"data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==\") format(\"woff\");\n}\n.curve-editor {\n display: flex;\n flex-direction: column;\n gap: 5px;\n background-color: #303030;\n outline: 1px solid #000000;\n padding: 5px;\n width: 100%;\n}\n.curve-editor .button-medium {\n background-color: #545454;\n min-width: var(--widget-height);\n min-height: var(--widget-height);\n height: 100%;\n outline: 1px solid #3c3c3c;\n display: flex;\n justify-content: center;\n align-items: center;\n color: #fff;\n font-size: var(--input-font-size, 11px);\n}\n.curve-editor .button-medium.selected {\n background-color: #4772b3;\n pointer-events: none;\n}\n.curve-editor .button-medium:hover {\n background-color: #656565;\n cursor: default;\n}\n.curve-editor .curve-top {\n display: flex;\n width: 100%;\n}\n.curve-editor .curve-panel {\n width: 100%;\n height: 90px;\n outline: 1px solid #646464;\n}\n.curve-editor .curve-point-panel {\n display: flex;\n align-items: center;\n width: 100%;\n height: var(--widget-height);\n}\n.curve-editor .curve-point-panel input {\n background-color: #545454;\n height: 100%;\n width: 100%;\n color: #fff;\n border: 0;\n outline: 1px solid #3c3c3c;\n text-align: center;\n font-size: var(--input-font-size, 11px);\n}";
9
+ n(css,{});
10
+
6
11
  class Controller {
7
12
  /**
8
13
  * Sets the name of the controller and its label in the GUI.
@@ -175,7 +180,7 @@ class Controller {
175
180
  }
176
181
  return this;
177
182
  }
178
- needsUpdateDisplay() {
183
+ checkDisplay() {
179
184
  if (this.parent._closed) {
180
185
  return false;
181
186
  }
@@ -191,7 +196,7 @@ class Controller {
191
196
  // To prevent framerate loss, make sure the value has changed before updating the display.
192
197
  // Note: save() is used here instead of getValue() only because of ColorController. The !== operator
193
198
  // won't work for color objects or arrays, but ColorController.save() always returns a string.
194
- if (this.needsUpdateDisplay()) {
199
+ if (this.checkDisplay()) {
195
200
  this.updateDisplay();
196
201
  }
197
202
  }
@@ -213,7 +218,7 @@ class Controller {
213
218
  return this;
214
219
  }
215
220
  update() {
216
- if (this.needsUpdateDisplay()) {
221
+ if (this.checkDisplay()) {
217
222
  this.updateDisplay();
218
223
  }
219
224
  }
@@ -446,14 +451,14 @@ class NumberController extends Controller {
446
451
  return false;
447
452
  }
448
453
  updateDisplay() {
449
- const value = this.getValue();
454
+ const value = this._snap(this.getValue());
450
455
  if (this._hasSlider) {
451
456
  let percent = (value - this._min) / (this._max - this._min);
452
457
  percent = Math.max(0, Math.min(percent, 1));
453
458
  this.$fill.style.width = percent * 100 + '%';
454
459
  }
455
460
  if (!this._inputFocused) {
456
- this.$input.value = value;
461
+ this.$input.value = "" + value;
457
462
  }
458
463
  return this;
459
464
  }
@@ -858,8 +863,7 @@ class ColorController extends Controller {
858
863
  this.setValue(newValue);
859
864
  } else {
860
865
  this._format.fromHexString(value, this.getValue(), this._rgbScale);
861
- this._callOnChange();
862
- this.updateDisplay();
866
+ this.setValue(this.getValue());
863
867
  }
864
868
  }
865
869
  save() {
@@ -926,49 +930,6 @@ class ColorController extends Controller {
926
930
  }
927
931
  }
928
932
 
929
- class ImageController extends Controller {
930
- static async toDataURL(img) {
931
- if (img instanceof HTMLImageElement) {
932
- return img.src;
933
- } else {
934
- if (img) {
935
- let url = ImageController._imageMap.get(img);
936
- if (url) return url;
937
- const w = Math.min(img.width, 256);
938
- const h = Math.min(img.height, 256);
939
- if (ImageController._context == null) {
940
- ImageController._context = document.createElement('canvas').getContext("2d");
941
- }
942
- ImageController._context.canvas.width = w;
943
- ImageController._context.canvas.height = h;
944
- if (img.data) {
945
- let imageData = ImageController._context.createImageData(img.width, img.height);
946
- imageData.data.set(img.data);
947
- img = await createImageBitmap(imageData);
948
- }
949
- if (img instanceof ImageBitmap) {
950
- ImageController._context.drawImage(img, 0, 0, img.width, img.height, 0, 0, w, h);
951
- ImageController._imageMap.set(img, url = ImageController._context.canvas.toDataURL());
952
- return url;
953
- }
954
- }
955
- return "";
956
- }
957
- }
958
- updateDisplay() {
959
- ImageController.toDataURL(this.getValue()).then((url)=>this.$img.src = url);
960
- return this;
961
- }
962
- constructor(parent, object, property){
963
- super(parent, object, property, "image");
964
- this.$img = document.createElement("img");
965
- this.$widget.appendChild(this.$img);
966
- this.updateDisplay();
967
- }
968
- }
969
- ImageController._context = null;
970
- ImageController._imageMap = new WeakMap();
971
-
972
933
  class UIElement {
973
934
  add(...args) {
974
935
  for(let i = 0; i < args.length; i++){
@@ -1056,8 +1017,8 @@ class UINumber extends UIElement {
1056
1017
  return this;
1057
1018
  }
1058
1019
  updateDisplay() {
1059
- let value = this.getValue();
1060
- this.dom.value = "" + this._snap(value);
1020
+ let value = this._snap(this.getValue());
1021
+ this.dom.value = "" + value;
1061
1022
  if (this.unit !== '') this.dom.value += ' ' + this.unit;
1062
1023
  }
1063
1024
  _getImplicitStep(value) {
@@ -1232,7 +1193,7 @@ class VectorController extends Controller {
1232
1193
  this._callOnChange();
1233
1194
  return this;
1234
1195
  }
1235
- needsUpdateDisplay() {
1196
+ checkDisplay() {
1236
1197
  return !this.parent._closed;
1237
1198
  }
1238
1199
  updateDisplay() {
@@ -1731,56 +1692,48 @@ class CurveController extends Controller {
1731
1692
  }
1732
1693
 
1733
1694
  class TextureController extends Controller {
1734
- needsUpdateDisplay() {
1735
- if (this.parent._closed) {
1736
- return false;
1737
- }
1738
- let texture = this.getValue();
1739
- if (texture && this._version !== texture.version) {
1740
- this._version = texture.version;
1741
- return true;
1742
- }
1743
- return false;
1695
+ checkDisplay() {
1696
+ return this._autoRefresh || super.checkDisplay();
1744
1697
  }
1745
1698
  updateDisplay() {
1746
1699
  const canvas = this.$canvas;
1747
1700
  const context = canvas.getContext("2d");
1748
- const texture = this.getValue();
1749
- const image = texture.image;
1750
- // Seems like context can be null if the canvas is not visible
1751
- if (context) {
1752
- // Always clear the context before set new texture, because new texture may has transparency
1753
- context.clearRect(0, 0, canvas.width, canvas.height);
1754
- }
1755
- if (image && image.width > 0) {
1756
- const scale = canvas.width / image.width;
1757
- canvas.height = Math.max(2, image.height / image.width * canvas.width);
1758
- const width = Math.max(image.width * scale, 2);
1759
- const height = Math.max(image.height * scale, 2);
1760
- if (texture.__getImage) {
1761
- context.drawImage(texture.__getImage(), 0, 0, width, height);
1701
+ let texture = this.getValue();
1702
+ if (texture) {
1703
+ let image = texture.image;
1704
+ if (image && image.width > 0) {
1705
+ this.$label.textContent = `${image.width}x${image.height}`;
1706
+ canvas.title = texture.sourceFile || "";
1707
+ canvas.height = canvas.width / image.width * image.height;
1708
+ if (this.getImage) {
1709
+ const w = 256, h = 256 / image.width * image.height;
1710
+ context.drawImage(this.getImage(texture, w, h), 0, 0, w * 1.5, h * 1.5, 0, 0, canvas.width, canvas.height); //why 1.5 ?
1711
+ }
1762
1712
  } else {
1763
- context.drawImage(image, 0, 0, width, height);
1713
+ canvas.title = texture.sourceFile + ' (error)';
1764
1714
  }
1715
+ } else {
1716
+ canvas.title = 'empty';
1765
1717
  }
1766
1718
  return this;
1767
1719
  }
1768
1720
  constructor(parent, object, property){
1769
- super(parent, object, property, "image");
1770
- this._version = 0;
1771
- let group = document.createElement("div");
1772
- group.style.display = "flex";
1773
- group.style.flexDirection = "column";
1774
- group.style.width = "100%";
1775
- this.$widget.appendChild(group);
1776
- this.$canvas = document.createElement("canvas");
1777
- group.appendChild(this.$canvas);
1778
- const texture = this.getValue();
1779
- if (texture.isRenderTargetTexture) {
1780
- let button = document.createElement("button");
1781
- button.textContent = "capture";
1782
- button.onclick = ()=>this.updateDisplay();
1783
- group.appendChild(button);
1721
+ super(parent, object, property, "texture");
1722
+ this._autoRefresh = false;
1723
+ const group = this.$widget.appendChild(document.createElement("div"));
1724
+ group.classList.add("group");
1725
+ this.$canvas = group.appendChild(document.createElement("canvas"));
1726
+ const label = this.$label = group.appendChild(document.createElement("div"));
1727
+ label.classList.add("label");
1728
+ let texture = this.getValue();
1729
+ if (texture && texture.image && texture.image.depth) {
1730
+ const block = group.appendChild(document.createElement("div"));
1731
+ block.classList.add("block");
1732
+ block.onclick = ()=>{
1733
+ this._autoRefresh = !this._autoRefresh;
1734
+ if (this._autoRefresh) block.classList.add("select");
1735
+ else block.classList.remove("select");
1736
+ };
1784
1737
  }
1785
1738
  }
1786
1739
  }
@@ -1842,14 +1795,6 @@ class GUI {
1842
1795
  */ addColor(object, property, rgbScale = 1) {
1843
1796
  return new ColorController(this, object, property, rgbScale);
1844
1797
  }
1845
- /**
1846
- *
1847
- * @param {object} object
1848
- * @param {string} property Name of the property to control.
1849
- * @returns {Controller}
1850
- */ addImage(object, property) {
1851
- return new ImageController(this, object, property);
1852
- }
1853
1798
  addTexture(object, property) {
1854
1799
  return new TextureController(this, object, property);
1855
1800
  }
@@ -2193,7 +2138,9 @@ class GUI {
2193
2138
  this.$title.setAttribute('role', 'button');
2194
2139
  this.$title.setAttribute('aria-expanded', "true");
2195
2140
  this.$title.setAttribute('tabindex', "0");
2196
- this.$title.addEventListener('click', ()=>this.openAnimated(this._closed));
2141
+ this.$title.addEventListener('click', ()=>{
2142
+ this.openAnimated(this._closed);
2143
+ });
2197
2144
  this.$title.addEventListener('keydown', (e)=>{
2198
2145
  if (e.code === 'Enter' || e.code === 'Space') {
2199
2146
  e.preventDefault();
@@ -2236,61 +2183,269 @@ class GUI {
2236
2183
  }
2237
2184
  }
2238
2185
 
2239
- function _ts_decorate(decorators, target, key, desc) {
2240
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2241
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2242
- 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;
2243
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2186
+ /******************************************************************************
2187
+ Copyright (c) Microsoft Corporation.
2188
+
2189
+ Permission to use, copy, modify, and/or distribute this software for any
2190
+ purpose with or without fee is hereby granted.
2191
+
2192
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2193
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2194
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2195
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2196
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2197
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2198
+ PERFORMANCE OF THIS SOFTWARE.
2199
+ ***************************************************************************** */
2200
+ /* global Reflect, Promise, SuppressedError, Symbol */
2201
+
2202
+
2203
+ function __decorate(decorators, target, key, desc) {
2204
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2205
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2206
+ 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;
2207
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2244
2208
  }
2245
- class InspectorPlugin extends core.Plugin {
2246
- static _getTargetName(target) {
2247
- return target.name || target.constructor.name || target.type;
2209
+
2210
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2211
+ var e = new Error(message);
2212
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2213
+ };
2214
+
2215
+ class ViewerHelper extends core.ObjectInstance {
2216
+ get outputColorSpace() {
2217
+ return this._renderer.outputColorSpace;
2218
+ }
2219
+ set outputColorSpace(v) {
2220
+ this._renderer.outputColorSpace = v;
2221
+ }
2222
+ get toneMapping() {
2223
+ return this._renderer.toneMapping;
2224
+ }
2225
+ set toneMapping(v) {
2226
+ this._renderer.toneMapping = v;
2227
+ }
2228
+ get toneMappingExposure() {
2229
+ return this._renderer.toneMappingExposure;
2230
+ }
2231
+ set toneMappingExposure(v) {
2232
+ this._renderer.toneMappingExposure = v;
2233
+ }
2234
+ get shadows() {
2235
+ return this._renderer.shadowMap.enabled;
2236
+ }
2237
+ set shadows(v) {
2238
+ this._renderer.shadowMap.enabled = v;
2239
+ }
2240
+ get backgroundBlurriness() {
2241
+ return this._scene.backgroundBlurriness;
2242
+ }
2243
+ set backgroundBlurriness(v) {
2244
+ this._scene.backgroundBlurriness = v;
2245
+ }
2246
+ get environment() {
2247
+ return this._scene.environment;
2248
+ }
2249
+ set environment(v) {
2250
+ this._scene.environment = v;
2251
+ }
2252
+ get environmentIntensity() {
2253
+ return this._scene.environmentIntensity;
2254
+ }
2255
+ set environmentIntensity(v) {
2256
+ this._scene.environmentIntensity = v;
2257
+ }
2258
+ get environmentRotation() {
2259
+ return this._scene.environmentRotation;
2260
+ }
2261
+ set environmentRotation(v) {
2262
+ this._scene.environmentRotation.copy(v);
2263
+ }
2264
+ get background() {
2265
+ return this._scene.background;
2266
+ }
2267
+ set background(v) {
2268
+ this._scene.background = v;
2269
+ }
2270
+ get backgroundRotation() {
2271
+ return this._scene.backgroundRotation;
2248
2272
  }
2249
- onUpdate(dt) {
2273
+ set backgroundRotation(v) {
2274
+ this._scene.backgroundRotation.copy(v);
2275
+ }
2276
+ get targetFrameRate() {
2277
+ return this._viewer.targetFrameRate;
2278
+ }
2279
+ set targetFrameRate(v) {
2280
+ this._viewer.targetFrameRate = v;
2281
+ }
2282
+ constructor(viewer){
2283
+ super();
2284
+ this._viewer = viewer;
2285
+ this._scene = viewer.scene;
2286
+ this._renderer = viewer.renderer;
2287
+ }
2288
+ }
2289
+ __decorate([
2290
+ core.property({
2291
+ value: {
2292
+ SRGBColorSpace: "srgb",
2293
+ LinearSRGBColorSpace: "srgb-linear",
2294
+ DisplayP3ColorSpace: "display-p3",
2295
+ LinearDisplayP3ColorSpace: "display-p3-linear"
2296
+ }
2297
+ })
2298
+ ], ViewerHelper.prototype, "outputColorSpace", null);
2299
+ __decorate([
2300
+ core.property({
2301
+ value: {
2302
+ NoToneMapping: 0,
2303
+ LinearToneMapping: 1,
2304
+ ReinhardToneMapping: 2,
2305
+ CineonToneMapping: 3,
2306
+ ACESFilmicToneMapping: 4
2307
+ }
2308
+ })
2309
+ ], ViewerHelper.prototype, "toneMapping", null);
2310
+ __decorate([
2311
+ core.property({
2312
+ min: 0,
2313
+ max: 10,
2314
+ step: 0.01
2315
+ })
2316
+ ], ViewerHelper.prototype, "toneMappingExposure", null);
2317
+ __decorate([
2318
+ core.property
2319
+ ], ViewerHelper.prototype, "shadows", null);
2320
+ __decorate([
2321
+ core.property({
2322
+ min: 0,
2323
+ max: 1,
2324
+ step: 0.01
2325
+ })
2326
+ ], ViewerHelper.prototype, "backgroundBlurriness", null);
2327
+ __decorate([
2328
+ core.property({
2329
+ value: new three.Texture()
2330
+ })
2331
+ ], ViewerHelper.prototype, "environment", null);
2332
+ __decorate([
2333
+ core.property({
2334
+ min: 0,
2335
+ max: 1,
2336
+ step: 0.01
2337
+ })
2338
+ ], ViewerHelper.prototype, "environmentIntensity", null);
2339
+ __decorate([
2340
+ core.property({
2341
+ step: 0.01
2342
+ })
2343
+ ], ViewerHelper.prototype, "environmentRotation", null);
2344
+ __decorate([
2345
+ core.property
2346
+ ], ViewerHelper.prototype, "background", null);
2347
+ __decorate([
2348
+ core.property({
2349
+ step: 0.01
2350
+ })
2351
+ ], ViewerHelper.prototype, "backgroundRotation", null);
2352
+ __decorate([
2353
+ core.property
2354
+ ], ViewerHelper.prototype, "targetFrameRate", null);
2355
+
2356
+ class Inspector extends core.Mount {
2357
+ onLoad() {
2358
+ const { width, height } = this.viewer;
2359
+ this._scene = new three.Scene();
2360
+ this._camera = new three.OrthographicCamera(0, width, height, 0, -1, 1);
2361
+ this._gui = new GUI({
2362
+ width: 310,
2363
+ title: "Inspector"
2364
+ }).close();
2365
+ this._gui.addFolder("Viewer").close().hide();
2366
+ this._gui.addFolder("Component").close().hide();
2367
+ this._gui.addFolder("Material").close().hide();
2368
+ this._gui.addFolder("Other").close().hide();
2369
+ this._inspect(new ViewerHelper(this.viewer));
2370
+ this._addSprite();
2371
+ }
2372
+ onDestroy() {
2373
+ this._gui.destroy();
2374
+ this._refCntMap.clear();
2375
+ this._targetMap.clear();
2376
+ }
2377
+ update(dt) {
2250
2378
  this._gui.update();
2251
2379
  this._updateFolders();
2252
2380
  }
2253
- _initFolders() {
2254
- const gui = this._gui;
2255
- gui.addFolder("Viewer").close().hide();
2256
- gui.addFolder("Plugin").close().hide();
2257
- gui.addFolder("Component").close().hide();
2258
- gui.addFolder("Material").close().hide();
2259
- gui.addFolder("Other").close().hide();
2381
+ resize(width, height) {
2382
+ this._camera.left = 0;
2383
+ this._camera.right = width;
2384
+ this._camera.top = height;
2385
+ this._camera.bottom = 0;
2386
+ this._camera.updateProjectionMatrix();
2387
+ }
2388
+ _addSprite() {
2389
+ const viewer = this.viewer;
2390
+ this._sprite = viewer.add(three.Sprite, {
2391
+ parent: this._scene,
2392
+ scale: new three.Vector3(256, 256, 1),
2393
+ position: new three.Vector3(viewer.width / 2, viewer.height / 2),
2394
+ visible: false
2395
+ });
2260
2396
  }
2261
- _initViewer() {
2262
- this.inspect(new ViewerExtension(this.viewer));
2397
+ _renderScene() {
2398
+ const { renderer } = this.viewer;
2399
+ const autoClearDepth = renderer.autoClearDepth;
2400
+ const autoClearColor = renderer.autoClearColor;
2401
+ renderer.autoClearDepth = true;
2402
+ renderer.autoClearColor = false;
2403
+ renderer.render(this._scene, this._camera);
2404
+ renderer.autoClearDepth = autoClearDepth;
2405
+ renderer.autoClearColor = autoClearColor;
2406
+ return renderer.domElement;
2407
+ }
2408
+ _renderSprite(texture, w, h) {
2409
+ this._sprite.visible = true;
2410
+ this._sprite.scale.set(w, h, 1);
2411
+ this._sprite.position.set(w / 2, this._camera.top - h / 2, 0);
2412
+ this._sprite.material.map = texture;
2413
+ this._sprite.material.needsUpdate = true;
2414
+ const dom = this._renderScene();
2415
+ this._sprite.visible = false;
2416
+ return dom;
2263
2417
  }
2264
2418
  _updateFolders() {
2265
- const statesMap = this._statesMap;
2266
- const setState = (v)=>statesMap.set(v, statesMap.has(v) ? 0 : 1);
2267
- statesMap.forEach((_, k, map)=>map.set(k, -1));
2268
- this.viewer.traversePlugins(setState);
2419
+ const refCntMap = this._refCntMap;
2420
+ const setState = (v)=>{
2421
+ if (refCntMap.get(v) === -1) refCntMap.set(v, 0);
2422
+ if (refCntMap.get(v) === undefined) refCntMap.set(v, 1);
2423
+ };
2424
+ refCntMap.forEach((_, k, map)=>map.set(k, -1));
2269
2425
  this.viewer.traverseComponents(setState);
2270
2426
  this.viewer.traverseMaterials(setState);
2271
- statesMap.forEach((v, k, map)=>{
2427
+ refCntMap.forEach((v, k, map)=>{
2272
2428
  if (v === 1) {
2273
- this.inspect(k);
2429
+ this._inspect(k);
2274
2430
  }
2275
2431
  if (v === -1) {
2276
- this.uninspect(k);
2432
+ this._uninspect(k);
2277
2433
  map.delete(k);
2278
2434
  }
2279
2435
  });
2280
2436
  }
2281
2437
  _getPropertiesList(target) {
2282
2438
  const list = [];
2283
- let props = core.PropertyManager._getMergedProperties(target);
2439
+ let props = core.PropertyManager._getMergedProperties(target.constructor);
2284
2440
  if (props) {
2285
- list.push(props);
2286
- this._targetMap.set(props, target);
2441
+ const values = propsSort(props);
2442
+ this._targetMap.set(values, target);
2443
+ list.push(values);
2287
2444
  }
2288
2445
  if (target instanceof three.ShaderMaterial) {
2289
2446
  props = Object.create(null);
2290
2447
  const uniforms = Object.create(null);
2291
- this._targetMap.set(props, uniforms);
2292
- const entries = Object.entries(target.uniforms);
2293
- entries.forEach(([name])=>{
2448
+ Object.keys(target.uniforms).forEach((name)=>{
2294
2449
  Object.defineProperty(uniforms, name, {
2295
2450
  get: ()=>target.uniforms[name].value,
2296
2451
  set: (v)=>target.uniforms[name].value = v
@@ -2299,18 +2454,18 @@ class InspectorPlugin extends core.Plugin {
2299
2454
  dir: "uniforms"
2300
2455
  };
2301
2456
  });
2302
- list.push(props);
2457
+ const values = propsSort(props);
2458
+ this._targetMap.set(values, uniforms);
2459
+ list.push(values);
2303
2460
  }
2304
2461
  return list;
2305
2462
  }
2306
- inspect(target) {
2463
+ _inspect(target) {
2307
2464
  let propsList = this._getPropertiesList(target);
2308
2465
  if (propsList.length === 0) return;
2309
2466
  let gui = this._gui;
2310
- if (target instanceof ViewerExtension) {
2467
+ if (target instanceof ViewerHelper) {
2311
2468
  gui = gui.getFolder("Viewer").show();
2312
- } else if (target instanceof core.Plugin) {
2313
- gui = gui.getFolder("Plugin").show();
2314
2469
  } else if (target instanceof core.Component) {
2315
2470
  gui = gui.getFolder("Component").show();
2316
2471
  } else if (target instanceof three.Material) {
@@ -2319,51 +2474,62 @@ class InspectorPlugin extends core.Plugin {
2319
2474
  gui = gui.getFolder("Other").show();
2320
2475
  }
2321
2476
  if (gui._title !== "Viewer") {
2322
- gui = gui.getFolder(target.uuid) || gui.addFolder(InspectorPlugin._getTargetName(target), target.uuid).close();
2477
+ gui = gui.getFolder(target.uuid) || gui.addFolder(targetName(target), target.uuid).close();
2323
2478
  }
2324
- this._addPropsListGUI(gui, propsList, target);
2479
+ this._addGUI(gui, propsList, target);
2325
2480
  return target;
2326
2481
  }
2327
- _addPropsListGUI(gui, list, target, dir = "") {
2328
- let source = target;
2329
- for (let props of list){
2330
- if (dir) {
2331
- gui = gui.getFolder(dir) || gui.addFolder(dir).close();
2332
- }
2482
+ _addGUI(gui, list, target, dir = "") {
2483
+ if (dir) {
2484
+ gui = gui.getFolder(dir) || gui.addFolder(dir).close();
2485
+ }
2486
+ const source = target;
2487
+ for (const props of list){
2333
2488
  target = this._targetMap.get(props) || source;
2334
- for(let k in props){
2335
- let value = target[k];
2336
- if (value == null) continue;
2337
- const prop = props[k];
2489
+ for (const [k, prop] of props){
2490
+ let value = target[k] == null ? prop.value : target[k];
2491
+ if (value == null || prop.parent && target[prop.parent] == null) {
2492
+ continue;
2493
+ }
2338
2494
  let folder = gui;
2339
2495
  if (prop.dir) {
2340
2496
  folder = folder.getFolder(prop.dir) || folder.addFolder(prop.dir).close();
2341
2497
  }
2342
- if (core.PropertyManager._hasProperties(value)) {
2343
- this._addPropsListGUI(folder, this._getPropertiesList(value), target, k);
2498
+ if (core.PropertyManager._hasProperties(value.constructor)) {
2499
+ this._addGUI(folder, this._getPropertiesList(value), target, k);
2344
2500
  }
2345
- const type = typeof value;
2346
- let ins = null;
2347
- if (value.isColor) {
2348
- ins = folder.addColor(target, k);
2349
- } else if (value.isAnimationCurve) {
2350
- ins = folder.addCurve(target, k);
2351
- } else if (value.isVector2 || value.isVector3 || value.isVector4 || value.isEuler) {
2352
- ins = folder.addVector(target, k, prop.min, prop.max, prop.step);
2353
- } else if (value.isTexture) ; else if (type === "number" || type === "boolean" || type === "string" || type === "function") {
2354
- ins = folder.add(target, k, prop.value || prop.min, prop.max, prop.step);
2355
- } else ;
2356
- if (ins && prop.name) {
2357
- ins.name(prop.name);
2501
+ if (Array.isArray(value)) {
2502
+ this._addGUI(folder, [
2503
+ value.map((_, i)=>[
2504
+ i.toString(),
2505
+ {}
2506
+ ])
2507
+ ], value, k);
2508
+ } else {
2509
+ const type = typeof value;
2510
+ let ins = null;
2511
+ if (value.isColor) {
2512
+ ins = folder.addColor(target, k);
2513
+ } else if (value.isAnimationCurve) {
2514
+ ins = folder.addCurve(target, k);
2515
+ } else if (value.isVector2 || value.isVector3 || value.isVector4 || value.isEuler) {
2516
+ ins = folder.addVector(target, k, prop.min, prop.max, prop.step);
2517
+ } else if (value.isTexture) {
2518
+ ins = folder.addTexture(target, k);
2519
+ ins.getImage = (texture, w, h)=>this._renderSprite(texture, w, h);
2520
+ } else if (type === "number" || type === "boolean" || type === "string" || type === "function") {
2521
+ ins = folder.add(target, k, prop.value || prop.min, prop.max, prop.step);
2522
+ } else ;
2523
+ if (ins && prop.name) {
2524
+ ins.name(prop.name);
2525
+ }
2358
2526
  }
2359
2527
  }
2360
2528
  }
2361
2529
  }
2362
- uninspect(target) {
2530
+ _uninspect(target) {
2363
2531
  let gui = this._gui;
2364
- if (target instanceof core.Plugin) {
2365
- gui = gui.getFolder("Plugin");
2366
- } else if (target instanceof core.Component) {
2532
+ if (target instanceof core.Component) {
2367
2533
  gui = gui.getFolder("Component");
2368
2534
  } else if (target instanceof three.Material) {
2369
2535
  gui = gui.getFolder("Material");
@@ -2375,100 +2541,52 @@ class InspectorPlugin extends core.Plugin {
2375
2541
  gui.hide();
2376
2542
  }
2377
2543
  }
2378
- constructor(){
2379
- super();
2380
- this._statesMap = new Map();
2544
+ constructor(...args){
2545
+ super(...args);
2546
+ this._refCntMap = new Map();
2381
2547
  this._targetMap = new Map();
2382
- this.install = ()=>{
2383
- this._gui = new GUI({
2384
- width: 310,
2385
- title: "Inspector"
2386
- }).close();
2387
- this._initFolders();
2388
- this._initViewer();
2389
- };
2390
- this.uninstall = ()=>{
2391
- this._gui.destroy();
2392
- this._statesMap.clear();
2393
- this._targetMap.clear();
2394
- };
2395
2548
  }
2396
2549
  }
2397
- class ViewerExtension extends core.ObjectInstance {
2398
- get outputColorSpace() {
2399
- return this._renderer.outputColorSpace;
2400
- }
2401
- set outputColorSpace(v) {
2402
- this._renderer.outputColorSpace = v;
2403
- }
2404
- get toneMapping() {
2405
- return this._renderer.toneMapping;
2406
- }
2407
- set toneMapping(v) {
2408
- this._renderer.toneMapping = v;
2409
- }
2410
- get toneMappingExposure() {
2411
- return this._renderer.toneMappingExposure;
2412
- }
2413
- set toneMappingExposure(v) {
2414
- this._renderer.toneMappingExposure = v;
2415
- }
2416
- get shadows() {
2417
- return this._renderer.shadowMap.enabled;
2418
- }
2419
- set shadows(v) {
2420
- this._renderer.shadowMap.enabled = v;
2421
- }
2422
- get backgroundBlurriness() {
2423
- return this._scene.backgroundBlurriness;
2424
- }
2425
- set backgroundBlurriness(v) {
2426
- this._scene.backgroundBlurriness = v;
2427
- }
2428
- constructor(viewer){
2429
- super();
2430
- this._scene = viewer.scene;
2431
- this._renderer = viewer.renderer;
2432
- }
2550
+ function targetName(target) {
2551
+ return target.name || target.constructor.name || target.type;
2433
2552
  }
2434
- _ts_decorate([
2435
- core.property({
2436
- value: {
2437
- SRGBColorSpace: "srgb",
2438
- LinearSRGBColorSpace: "srgb-linear",
2439
- DisplayP3ColorSpace: "display-p3",
2440
- LinearDisplayP3ColorSpace: "display-p3-linear"
2441
- }
2442
- })
2443
- ], ViewerExtension.prototype, "outputColorSpace", null);
2444
- _ts_decorate([
2445
- core.property({
2553
+ function propsSort(props) {
2554
+ const order = (v)=>v.order || 10000;
2555
+ const values = Object.entries(props);
2556
+ const array0 = values.filter((v)=>!v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
2557
+ const array1 = values.filter((v)=>v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
2558
+ return array0.concat(array1);
2559
+ }
2560
+ const materialProperties = {
2561
+ visible: {
2562
+ order: 1
2563
+ },
2564
+ transparent: {
2565
+ order: 2
2566
+ },
2567
+ side: {
2568
+ order: 3,
2446
2569
  value: {
2447
- NoToneMapping: 0,
2448
- LinearToneMapping: 1,
2449
- ReinhardToneMapping: 2,
2450
- CineonToneMapping: 3,
2451
- ACESFilmicToneMapping: 4
2570
+ FrontSide: 0,
2571
+ BackSide: 1,
2572
+ DoubleSide: 2
2452
2573
  }
2453
- })
2454
- ], ViewerExtension.prototype, "toneMapping", null);
2455
- _ts_decorate([
2456
- core.property({
2457
- min: 0,
2458
- max: 10,
2459
- step: 0.01
2460
- })
2461
- ], ViewerExtension.prototype, "toneMappingExposure", null);
2462
- _ts_decorate([
2463
- core.property
2464
- ], ViewerExtension.prototype, "shadows", null);
2465
- _ts_decorate([
2466
- core.property({
2574
+ },
2575
+ color: {
2576
+ order: 4,
2577
+ dir: "diffuse"
2578
+ },
2579
+ opacity: {
2580
+ order: 5,
2581
+ dir: "diffuse",
2467
2582
  min: 0,
2468
2583
  max: 1,
2469
2584
  step: 0.01
2470
- })
2471
- ], ViewerExtension.prototype, "backgroundBlurriness", null);
2585
+ }
2586
+ };
2587
+ for(let k in materialProperties){
2588
+ core.property(materialProperties[k])(three.Material.prototype, k);
2589
+ }
2472
2590
  const meshBasicMaterislProperties = {
2473
2591
  map: {
2474
2592
  dir: "diffuse"
@@ -2501,24 +2619,6 @@ for(let k in meshBasicMaterislProperties){
2501
2619
  core.property(meshBasicMaterislProperties[k])(three.MeshBasicMaterial.prototype, k);
2502
2620
  }
2503
2621
  const meshStandardMaterialProperties = {
2504
- visible: {},
2505
- transparent: {},
2506
- side: {
2507
- value: {
2508
- FrontSide: 0,
2509
- BackSide: 1,
2510
- DoubleSide: 2
2511
- }
2512
- },
2513
- color: {
2514
- dir: "diffuse"
2515
- },
2516
- opacity: {
2517
- dir: "diffuse",
2518
- min: 0,
2519
- max: 1,
2520
- step: 0.01
2521
- },
2522
2622
  map: {
2523
2623
  dir: "diffuse"
2524
2624
  },
@@ -2568,7 +2668,8 @@ const meshStandardMaterialProperties = {
2568
2668
  },
2569
2669
  normalScale: {
2570
2670
  dir: "normal",
2571
- parent: "normalMap"
2671
+ step: 0.01,
2672
+ parent: "normalMap "
2572
2673
  },
2573
2674
  displacementScale: {
2574
2675
  dir: "displacement",
@@ -2588,7 +2689,8 @@ const meshStandardMaterialProperties = {
2588
2689
  dir: "envMap",
2589
2690
  min: 0,
2590
2691
  max: 1,
2591
- step: 0.01
2692
+ step: 0.01,
2693
+ parent: "envMap"
2592
2694
  },
2593
2695
  lightMap: {
2594
2696
  dir: "lightMap"
@@ -2604,6 +2706,116 @@ const meshStandardMaterialProperties = {
2604
2706
  for(let k in meshStandardMaterialProperties){
2605
2707
  core.property(meshStandardMaterialProperties[k])(three.MeshStandardMaterial.prototype, k);
2606
2708
  }
2709
+ const meshPhysicalMaterialProperties = {
2710
+ ior: {
2711
+ min: 0,
2712
+ max: 10,
2713
+ step: 0.01
2714
+ },
2715
+ anisotropy: {
2716
+ min: 0,
2717
+ max: 10,
2718
+ step: 0.01
2719
+ },
2720
+ clearcoat: {
2721
+ dir: "clearcoat"
2722
+ },
2723
+ clearcoatMap: {
2724
+ dir: "clearcoat",
2725
+ min: 0,
2726
+ max: 1,
2727
+ step: 0.01
2728
+ },
2729
+ clearcoatRoughness: {
2730
+ dir: "clearcoat",
2731
+ min: 0,
2732
+ max: 1,
2733
+ step: 0.01
2734
+ },
2735
+ clearcoatNormalScale: {
2736
+ dir: "clearcoat",
2737
+ step: 0.01
2738
+ },
2739
+ clearcoatNormalMap: {
2740
+ dir: "clearcoat"
2741
+ },
2742
+ iridescence: {
2743
+ dir: "iridescence",
2744
+ min: 0,
2745
+ max: 1,
2746
+ step: 0.01
2747
+ },
2748
+ iridescenceMap: {
2749
+ dir: "iridescence"
2750
+ },
2751
+ iridescenceIOR: {
2752
+ dir: "iridescence",
2753
+ step: 0.01
2754
+ },
2755
+ iridescenceThicknessRange: {
2756
+ dir: "iridescence"
2757
+ },
2758
+ iridescenceThicknessMap: {
2759
+ dir: "iridescence"
2760
+ },
2761
+ sheen: {
2762
+ dir: "sheen"
2763
+ },
2764
+ sheenColor: {
2765
+ dir: "sheen"
2766
+ },
2767
+ sheenColorMap: {
2768
+ dir: "sheen"
2769
+ },
2770
+ sheenRoughness: {
2771
+ dir: "sheen",
2772
+ min: 0,
2773
+ max: 1,
2774
+ step: 0.01
2775
+ },
2776
+ sheenRoughnessMap: {
2777
+ dir: "sheen"
2778
+ },
2779
+ transmission: {
2780
+ dir: "transmission"
2781
+ },
2782
+ transmissionMap: {
2783
+ dir: "transmission"
2784
+ },
2785
+ thickness: {
2786
+ dir: "thickness",
2787
+ min: 0,
2788
+ max: 1,
2789
+ step: 0.01
2790
+ },
2791
+ thicknessMap: {
2792
+ dir: "thickness"
2793
+ },
2794
+ attenuationDistance: {
2795
+ dir: "attenuation"
2796
+ },
2797
+ attenuationColor: {
2798
+ dir: "attenuation"
2799
+ },
2800
+ specularIntensity: {
2801
+ dir: "specular",
2802
+ min: 0,
2803
+ max: 1,
2804
+ step: 0.01
2805
+ },
2806
+ specularIntensityMap: {
2807
+ dir: "specular"
2808
+ },
2809
+ specularColor: {
2810
+ dir: "specular"
2811
+ },
2812
+ specularColorMap: {
2813
+ dir: "specular"
2814
+ }
2815
+ };
2816
+ for(let k in meshPhysicalMaterialProperties){
2817
+ core.property(meshPhysicalMaterialProperties[k])(three.MeshPhysicalMaterial.prototype, k);
2818
+ }
2607
2819
 
2608
2820
  /**
2609
2821
  * @author mrdoob / http://mrdoob.com/
@@ -2653,7 +2865,7 @@ var Panel = function(name, fg, bg) {
2653
2865
  }
2654
2866
  };
2655
2867
  };
2656
- var Stats = function() {
2868
+ var Stats$1 = function() {
2657
2869
  var mode = 0;
2658
2870
  var container = document.createElement('div');
2659
2871
  container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
@@ -2712,8 +2924,19 @@ var Stats = function() {
2712
2924
  };
2713
2925
  };
2714
2926
 
2715
- class StatsPlugin extends core.Plugin {
2716
- onUpdate(dt) {
2927
+ class Stats extends core.Mount {
2928
+ onLoad() {
2929
+ this._stats.addPanel(this._dcPanel);
2930
+ this._stats.addPanel(this._texPanel);
2931
+ this._stats.addPanel(this._triPanel);
2932
+ this._stats.addPanel(this._prgPanel);
2933
+ this._stats.showPanel(0);
2934
+ document.body.appendChild(this._stats.dom);
2935
+ }
2936
+ onDestroy() {
2937
+ document.body.removeChild(this._stats.dom);
2938
+ }
2939
+ update(dt) {
2717
2940
  const info = this.viewer.renderer.info;
2718
2941
  this._dcPanel.update(info.render.calls, 300);
2719
2942
  this._triPanel.update(info.render.triangles, 500000);
@@ -2721,28 +2944,38 @@ class StatsPlugin extends core.Plugin {
2721
2944
  this._prgPanel.update(info.programs.length, 50);
2722
2945
  this._stats.update();
2723
2946
  }
2724
- constructor(){
2725
- super();
2726
- this._stats = new Stats();
2947
+ constructor(...args){
2948
+ super(...args);
2949
+ this._stats = new Stats$1();
2727
2950
  this._dcPanel = new Panel('DC', '#ff8', '#221');
2728
2951
  this._triPanel = new Panel("TRI", '#ff8', '#221');
2729
2952
  this._texPanel = new Panel('TEX', '#ff8', '#221');
2730
2953
  this._prgPanel = new Panel('PRG', '#ff8', '#221');
2731
- this.install = ()=>{
2732
- this._stats.addPanel(this._dcPanel);
2733
- this._stats.addPanel(this._texPanel);
2734
- this._stats.addPanel(this._triPanel);
2735
- this._stats.addPanel(this._prgPanel);
2736
- this._stats.showPanel(0);
2737
- document.body.appendChild(this._stats.dom);
2738
- };
2739
- this.uninstall = ()=>{
2740
- document.body.removeChild(this._stats.dom);
2741
- };
2742
2954
  }
2743
2955
  }
2744
2956
 
2957
+ class BoxProjectionHelper extends core.Mount {
2958
+ onLoad() {
2959
+ this._box3 = new three.Box3();
2960
+ this._target = this.viewer.mount(core.BoxProjection);
2961
+ this._helper = this.viewer.add(new three.Box3Helper(this._box3));
2962
+ }
2963
+ onEnable() {
2964
+ this._helper.visible = true;
2965
+ }
2966
+ onDisable() {
2967
+ this._helper.visible = false;
2968
+ }
2969
+ update(dt) {
2970
+ const { center, boxMin, boxMax } = this._target;
2971
+ this._box3.min.copy(center).add(boxMin);
2972
+ this._box3.max.copy(center).add(boxMax);
2973
+ this._helper.updateMatrixWorld();
2974
+ }
2975
+ }
2976
+
2977
+ exports.BoxProjectionHelper = BoxProjectionHelper;
2745
2978
  exports.GUI = GUI;
2746
- exports.InspectorPlugin = InspectorPlugin;
2747
- exports.StatsPlugin = StatsPlugin;
2979
+ exports.Inspector = Inspector;
2980
+ exports.Stats = Stats;
2748
2981
  //# sourceMappingURL=main.js.map