@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/module.js CHANGED
@@ -1,5 +1,10 @@
1
- import { MeshBasicMaterial, MeshStandardMaterial, ShaderMaterial, Material } from 'three';
2
- import { property, Plugin, PropertyManager, Component, ObjectInstance } from '@xviewer.js/core';
1
+ import { Texture, Material, MeshBasicMaterial, MeshStandardMaterial, MeshPhysicalMaterial, Scene, OrthographicCamera, Sprite, Vector3, ShaderMaterial, Box3, Box3Helper } from 'three';
2
+ import { property, ObjectInstance, Mount, PropertyManager, Component, BoxProjection } from '@xviewer.js/core';
3
+
4
+ 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}}
5
+
6
+ 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}";
7
+ n(css,{});
3
8
 
4
9
  class Controller {
5
10
  /**
@@ -173,7 +178,7 @@ class Controller {
173
178
  }
174
179
  return this;
175
180
  }
176
- needsUpdateDisplay() {
181
+ checkDisplay() {
177
182
  if (this.parent._closed) {
178
183
  return false;
179
184
  }
@@ -189,7 +194,7 @@ class Controller {
189
194
  // To prevent framerate loss, make sure the value has changed before updating the display.
190
195
  // Note: save() is used here instead of getValue() only because of ColorController. The !== operator
191
196
  // won't work for color objects or arrays, but ColorController.save() always returns a string.
192
- if (this.needsUpdateDisplay()) {
197
+ if (this.checkDisplay()) {
193
198
  this.updateDisplay();
194
199
  }
195
200
  }
@@ -211,7 +216,7 @@ class Controller {
211
216
  return this;
212
217
  }
213
218
  update() {
214
- if (this.needsUpdateDisplay()) {
219
+ if (this.checkDisplay()) {
215
220
  this.updateDisplay();
216
221
  }
217
222
  }
@@ -444,14 +449,14 @@ class NumberController extends Controller {
444
449
  return false;
445
450
  }
446
451
  updateDisplay() {
447
- const value = this.getValue();
452
+ const value = this._snap(this.getValue());
448
453
  if (this._hasSlider) {
449
454
  let percent = (value - this._min) / (this._max - this._min);
450
455
  percent = Math.max(0, Math.min(percent, 1));
451
456
  this.$fill.style.width = percent * 100 + '%';
452
457
  }
453
458
  if (!this._inputFocused) {
454
- this.$input.value = value;
459
+ this.$input.value = "" + value;
455
460
  }
456
461
  return this;
457
462
  }
@@ -856,8 +861,7 @@ class ColorController extends Controller {
856
861
  this.setValue(newValue);
857
862
  } else {
858
863
  this._format.fromHexString(value, this.getValue(), this._rgbScale);
859
- this._callOnChange();
860
- this.updateDisplay();
864
+ this.setValue(this.getValue());
861
865
  }
862
866
  }
863
867
  save() {
@@ -924,49 +928,6 @@ class ColorController extends Controller {
924
928
  }
925
929
  }
926
930
 
927
- class ImageController extends Controller {
928
- static async toDataURL(img) {
929
- if (img instanceof HTMLImageElement) {
930
- return img.src;
931
- } else {
932
- if (img) {
933
- let url = ImageController._imageMap.get(img);
934
- if (url) return url;
935
- const w = Math.min(img.width, 256);
936
- const h = Math.min(img.height, 256);
937
- if (ImageController._context == null) {
938
- ImageController._context = document.createElement('canvas').getContext("2d");
939
- }
940
- ImageController._context.canvas.width = w;
941
- ImageController._context.canvas.height = h;
942
- if (img.data) {
943
- let imageData = ImageController._context.createImageData(img.width, img.height);
944
- imageData.data.set(img.data);
945
- img = await createImageBitmap(imageData);
946
- }
947
- if (img instanceof ImageBitmap) {
948
- ImageController._context.drawImage(img, 0, 0, img.width, img.height, 0, 0, w, h);
949
- ImageController._imageMap.set(img, url = ImageController._context.canvas.toDataURL());
950
- return url;
951
- }
952
- }
953
- return "";
954
- }
955
- }
956
- updateDisplay() {
957
- ImageController.toDataURL(this.getValue()).then((url)=>this.$img.src = url);
958
- return this;
959
- }
960
- constructor(parent, object, property){
961
- super(parent, object, property, "image");
962
- this.$img = document.createElement("img");
963
- this.$widget.appendChild(this.$img);
964
- this.updateDisplay();
965
- }
966
- }
967
- ImageController._context = null;
968
- ImageController._imageMap = new WeakMap();
969
-
970
931
  class UIElement {
971
932
  add(...args) {
972
933
  for(let i = 0; i < args.length; i++){
@@ -1054,8 +1015,8 @@ class UINumber extends UIElement {
1054
1015
  return this;
1055
1016
  }
1056
1017
  updateDisplay() {
1057
- let value = this.getValue();
1058
- this.dom.value = "" + this._snap(value);
1018
+ let value = this._snap(this.getValue());
1019
+ this.dom.value = "" + value;
1059
1020
  if (this.unit !== '') this.dom.value += ' ' + this.unit;
1060
1021
  }
1061
1022
  _getImplicitStep(value) {
@@ -1230,7 +1191,7 @@ class VectorController extends Controller {
1230
1191
  this._callOnChange();
1231
1192
  return this;
1232
1193
  }
1233
- needsUpdateDisplay() {
1194
+ checkDisplay() {
1234
1195
  return !this.parent._closed;
1235
1196
  }
1236
1197
  updateDisplay() {
@@ -1729,56 +1690,48 @@ class CurveController extends Controller {
1729
1690
  }
1730
1691
 
1731
1692
  class TextureController extends Controller {
1732
- needsUpdateDisplay() {
1733
- if (this.parent._closed) {
1734
- return false;
1735
- }
1736
- let texture = this.getValue();
1737
- if (texture && this._version !== texture.version) {
1738
- this._version = texture.version;
1739
- return true;
1740
- }
1741
- return false;
1693
+ checkDisplay() {
1694
+ return this._autoRefresh || super.checkDisplay();
1742
1695
  }
1743
1696
  updateDisplay() {
1744
1697
  const canvas = this.$canvas;
1745
1698
  const context = canvas.getContext("2d");
1746
- const texture = this.getValue();
1747
- const image = texture.image;
1748
- // Seems like context can be null if the canvas is not visible
1749
- if (context) {
1750
- // Always clear the context before set new texture, because new texture may has transparency
1751
- context.clearRect(0, 0, canvas.width, canvas.height);
1752
- }
1753
- if (image && image.width > 0) {
1754
- const scale = canvas.width / image.width;
1755
- canvas.height = Math.max(2, image.height / image.width * canvas.width);
1756
- const width = Math.max(image.width * scale, 2);
1757
- const height = Math.max(image.height * scale, 2);
1758
- if (texture.__getImage) {
1759
- context.drawImage(texture.__getImage(), 0, 0, width, height);
1699
+ let texture = this.getValue();
1700
+ if (texture) {
1701
+ let image = texture.image;
1702
+ if (image && image.width > 0) {
1703
+ this.$label.textContent = `${image.width}x${image.height}`;
1704
+ canvas.title = texture.sourceFile || "";
1705
+ canvas.height = canvas.width / image.width * image.height;
1706
+ if (this.getImage) {
1707
+ const w = 256, h = 256 / image.width * image.height;
1708
+ context.drawImage(this.getImage(texture, w, h), 0, 0, w * 1.5, h * 1.5, 0, 0, canvas.width, canvas.height); //why 1.5 ?
1709
+ }
1760
1710
  } else {
1761
- context.drawImage(image, 0, 0, width, height);
1711
+ canvas.title = texture.sourceFile + ' (error)';
1762
1712
  }
1713
+ } else {
1714
+ canvas.title = 'empty';
1763
1715
  }
1764
1716
  return this;
1765
1717
  }
1766
1718
  constructor(parent, object, property){
1767
- super(parent, object, property, "image");
1768
- this._version = 0;
1769
- let group = document.createElement("div");
1770
- group.style.display = "flex";
1771
- group.style.flexDirection = "column";
1772
- group.style.width = "100%";
1773
- this.$widget.appendChild(group);
1774
- this.$canvas = document.createElement("canvas");
1775
- group.appendChild(this.$canvas);
1776
- const texture = this.getValue();
1777
- if (texture.isRenderTargetTexture) {
1778
- let button = document.createElement("button");
1779
- button.textContent = "capture";
1780
- button.onclick = ()=>this.updateDisplay();
1781
- group.appendChild(button);
1719
+ super(parent, object, property, "texture");
1720
+ this._autoRefresh = false;
1721
+ const group = this.$widget.appendChild(document.createElement("div"));
1722
+ group.classList.add("group");
1723
+ this.$canvas = group.appendChild(document.createElement("canvas"));
1724
+ const label = this.$label = group.appendChild(document.createElement("div"));
1725
+ label.classList.add("label");
1726
+ let texture = this.getValue();
1727
+ if (texture && texture.image && texture.image.depth) {
1728
+ const block = group.appendChild(document.createElement("div"));
1729
+ block.classList.add("block");
1730
+ block.onclick = ()=>{
1731
+ this._autoRefresh = !this._autoRefresh;
1732
+ if (this._autoRefresh) block.classList.add("select");
1733
+ else block.classList.remove("select");
1734
+ };
1782
1735
  }
1783
1736
  }
1784
1737
  }
@@ -1840,14 +1793,6 @@ class GUI {
1840
1793
  */ addColor(object, property, rgbScale = 1) {
1841
1794
  return new ColorController(this, object, property, rgbScale);
1842
1795
  }
1843
- /**
1844
- *
1845
- * @param {object} object
1846
- * @param {string} property Name of the property to control.
1847
- * @returns {Controller}
1848
- */ addImage(object, property) {
1849
- return new ImageController(this, object, property);
1850
- }
1851
1796
  addTexture(object, property) {
1852
1797
  return new TextureController(this, object, property);
1853
1798
  }
@@ -2191,7 +2136,9 @@ class GUI {
2191
2136
  this.$title.setAttribute('role', 'button');
2192
2137
  this.$title.setAttribute('aria-expanded', "true");
2193
2138
  this.$title.setAttribute('tabindex', "0");
2194
- this.$title.addEventListener('click', ()=>this.openAnimated(this._closed));
2139
+ this.$title.addEventListener('click', ()=>{
2140
+ this.openAnimated(this._closed);
2141
+ });
2195
2142
  this.$title.addEventListener('keydown', (e)=>{
2196
2143
  if (e.code === 'Enter' || e.code === 'Space') {
2197
2144
  e.preventDefault();
@@ -2234,61 +2181,269 @@ class GUI {
2234
2181
  }
2235
2182
  }
2236
2183
 
2237
- function _ts_decorate(decorators, target, key, desc) {
2238
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2239
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2240
- 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;
2241
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2184
+ /******************************************************************************
2185
+ Copyright (c) Microsoft Corporation.
2186
+
2187
+ Permission to use, copy, modify, and/or distribute this software for any
2188
+ purpose with or without fee is hereby granted.
2189
+
2190
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2191
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2192
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2193
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2194
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2195
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2196
+ PERFORMANCE OF THIS SOFTWARE.
2197
+ ***************************************************************************** */
2198
+ /* global Reflect, Promise, SuppressedError, Symbol */
2199
+
2200
+
2201
+ function __decorate(decorators, target, key, desc) {
2202
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2203
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2204
+ 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;
2205
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2242
2206
  }
2243
- class InspectorPlugin extends Plugin {
2244
- static _getTargetName(target) {
2245
- return target.name || target.constructor.name || target.type;
2207
+
2208
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2209
+ var e = new Error(message);
2210
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2211
+ };
2212
+
2213
+ class ViewerHelper extends ObjectInstance {
2214
+ get outputColorSpace() {
2215
+ return this._renderer.outputColorSpace;
2216
+ }
2217
+ set outputColorSpace(v) {
2218
+ this._renderer.outputColorSpace = v;
2219
+ }
2220
+ get toneMapping() {
2221
+ return this._renderer.toneMapping;
2222
+ }
2223
+ set toneMapping(v) {
2224
+ this._renderer.toneMapping = v;
2225
+ }
2226
+ get toneMappingExposure() {
2227
+ return this._renderer.toneMappingExposure;
2228
+ }
2229
+ set toneMappingExposure(v) {
2230
+ this._renderer.toneMappingExposure = v;
2231
+ }
2232
+ get shadows() {
2233
+ return this._renderer.shadowMap.enabled;
2234
+ }
2235
+ set shadows(v) {
2236
+ this._renderer.shadowMap.enabled = v;
2237
+ }
2238
+ get backgroundBlurriness() {
2239
+ return this._scene.backgroundBlurriness;
2240
+ }
2241
+ set backgroundBlurriness(v) {
2242
+ this._scene.backgroundBlurriness = v;
2243
+ }
2244
+ get environment() {
2245
+ return this._scene.environment;
2246
+ }
2247
+ set environment(v) {
2248
+ this._scene.environment = v;
2249
+ }
2250
+ get environmentIntensity() {
2251
+ return this._scene.environmentIntensity;
2252
+ }
2253
+ set environmentIntensity(v) {
2254
+ this._scene.environmentIntensity = v;
2255
+ }
2256
+ get environmentRotation() {
2257
+ return this._scene.environmentRotation;
2258
+ }
2259
+ set environmentRotation(v) {
2260
+ this._scene.environmentRotation.copy(v);
2261
+ }
2262
+ get background() {
2263
+ return this._scene.background;
2264
+ }
2265
+ set background(v) {
2266
+ this._scene.background = v;
2267
+ }
2268
+ get backgroundRotation() {
2269
+ return this._scene.backgroundRotation;
2246
2270
  }
2247
- onUpdate(dt) {
2271
+ set backgroundRotation(v) {
2272
+ this._scene.backgroundRotation.copy(v);
2273
+ }
2274
+ get targetFrameRate() {
2275
+ return this._viewer.targetFrameRate;
2276
+ }
2277
+ set targetFrameRate(v) {
2278
+ this._viewer.targetFrameRate = v;
2279
+ }
2280
+ constructor(viewer){
2281
+ super();
2282
+ this._viewer = viewer;
2283
+ this._scene = viewer.scene;
2284
+ this._renderer = viewer.renderer;
2285
+ }
2286
+ }
2287
+ __decorate([
2288
+ property({
2289
+ value: {
2290
+ SRGBColorSpace: "srgb",
2291
+ LinearSRGBColorSpace: "srgb-linear",
2292
+ DisplayP3ColorSpace: "display-p3",
2293
+ LinearDisplayP3ColorSpace: "display-p3-linear"
2294
+ }
2295
+ })
2296
+ ], ViewerHelper.prototype, "outputColorSpace", null);
2297
+ __decorate([
2298
+ property({
2299
+ value: {
2300
+ NoToneMapping: 0,
2301
+ LinearToneMapping: 1,
2302
+ ReinhardToneMapping: 2,
2303
+ CineonToneMapping: 3,
2304
+ ACESFilmicToneMapping: 4
2305
+ }
2306
+ })
2307
+ ], ViewerHelper.prototype, "toneMapping", null);
2308
+ __decorate([
2309
+ property({
2310
+ min: 0,
2311
+ max: 10,
2312
+ step: 0.01
2313
+ })
2314
+ ], ViewerHelper.prototype, "toneMappingExposure", null);
2315
+ __decorate([
2316
+ property
2317
+ ], ViewerHelper.prototype, "shadows", null);
2318
+ __decorate([
2319
+ property({
2320
+ min: 0,
2321
+ max: 1,
2322
+ step: 0.01
2323
+ })
2324
+ ], ViewerHelper.prototype, "backgroundBlurriness", null);
2325
+ __decorate([
2326
+ property({
2327
+ value: new Texture()
2328
+ })
2329
+ ], ViewerHelper.prototype, "environment", null);
2330
+ __decorate([
2331
+ property({
2332
+ min: 0,
2333
+ max: 1,
2334
+ step: 0.01
2335
+ })
2336
+ ], ViewerHelper.prototype, "environmentIntensity", null);
2337
+ __decorate([
2338
+ property({
2339
+ step: 0.01
2340
+ })
2341
+ ], ViewerHelper.prototype, "environmentRotation", null);
2342
+ __decorate([
2343
+ property
2344
+ ], ViewerHelper.prototype, "background", null);
2345
+ __decorate([
2346
+ property({
2347
+ step: 0.01
2348
+ })
2349
+ ], ViewerHelper.prototype, "backgroundRotation", null);
2350
+ __decorate([
2351
+ property
2352
+ ], ViewerHelper.prototype, "targetFrameRate", null);
2353
+
2354
+ class Inspector extends Mount {
2355
+ onLoad() {
2356
+ const { width, height } = this.viewer;
2357
+ this._scene = new Scene();
2358
+ this._camera = new OrthographicCamera(0, width, height, 0, -1, 1);
2359
+ this._gui = new GUI({
2360
+ width: 310,
2361
+ title: "Inspector"
2362
+ }).close();
2363
+ this._gui.addFolder("Viewer").close().hide();
2364
+ this._gui.addFolder("Component").close().hide();
2365
+ this._gui.addFolder("Material").close().hide();
2366
+ this._gui.addFolder("Other").close().hide();
2367
+ this._inspect(new ViewerHelper(this.viewer));
2368
+ this._addSprite();
2369
+ }
2370
+ onDestroy() {
2371
+ this._gui.destroy();
2372
+ this._refCntMap.clear();
2373
+ this._targetMap.clear();
2374
+ }
2375
+ update(dt) {
2248
2376
  this._gui.update();
2249
2377
  this._updateFolders();
2250
2378
  }
2251
- _initFolders() {
2252
- const gui = this._gui;
2253
- gui.addFolder("Viewer").close().hide();
2254
- gui.addFolder("Plugin").close().hide();
2255
- gui.addFolder("Component").close().hide();
2256
- gui.addFolder("Material").close().hide();
2257
- gui.addFolder("Other").close().hide();
2379
+ resize(width, height) {
2380
+ this._camera.left = 0;
2381
+ this._camera.right = width;
2382
+ this._camera.top = height;
2383
+ this._camera.bottom = 0;
2384
+ this._camera.updateProjectionMatrix();
2385
+ }
2386
+ _addSprite() {
2387
+ const viewer = this.viewer;
2388
+ this._sprite = viewer.add(Sprite, {
2389
+ parent: this._scene,
2390
+ scale: new Vector3(256, 256, 1),
2391
+ position: new Vector3(viewer.width / 2, viewer.height / 2),
2392
+ visible: false
2393
+ });
2258
2394
  }
2259
- _initViewer() {
2260
- this.inspect(new ViewerExtension(this.viewer));
2395
+ _renderScene() {
2396
+ const { renderer } = this.viewer;
2397
+ const autoClearDepth = renderer.autoClearDepth;
2398
+ const autoClearColor = renderer.autoClearColor;
2399
+ renderer.autoClearDepth = true;
2400
+ renderer.autoClearColor = false;
2401
+ renderer.render(this._scene, this._camera);
2402
+ renderer.autoClearDepth = autoClearDepth;
2403
+ renderer.autoClearColor = autoClearColor;
2404
+ return renderer.domElement;
2405
+ }
2406
+ _renderSprite(texture, w, h) {
2407
+ this._sprite.visible = true;
2408
+ this._sprite.scale.set(w, h, 1);
2409
+ this._sprite.position.set(w / 2, this._camera.top - h / 2, 0);
2410
+ this._sprite.material.map = texture;
2411
+ this._sprite.material.needsUpdate = true;
2412
+ const dom = this._renderScene();
2413
+ this._sprite.visible = false;
2414
+ return dom;
2261
2415
  }
2262
2416
  _updateFolders() {
2263
- const statesMap = this._statesMap;
2264
- const setState = (v)=>statesMap.set(v, statesMap.has(v) ? 0 : 1);
2265
- statesMap.forEach((_, k, map)=>map.set(k, -1));
2266
- this.viewer.traversePlugins(setState);
2417
+ const refCntMap = this._refCntMap;
2418
+ const setState = (v)=>{
2419
+ if (refCntMap.get(v) === -1) refCntMap.set(v, 0);
2420
+ if (refCntMap.get(v) === undefined) refCntMap.set(v, 1);
2421
+ };
2422
+ refCntMap.forEach((_, k, map)=>map.set(k, -1));
2267
2423
  this.viewer.traverseComponents(setState);
2268
2424
  this.viewer.traverseMaterials(setState);
2269
- statesMap.forEach((v, k, map)=>{
2425
+ refCntMap.forEach((v, k, map)=>{
2270
2426
  if (v === 1) {
2271
- this.inspect(k);
2427
+ this._inspect(k);
2272
2428
  }
2273
2429
  if (v === -1) {
2274
- this.uninspect(k);
2430
+ this._uninspect(k);
2275
2431
  map.delete(k);
2276
2432
  }
2277
2433
  });
2278
2434
  }
2279
2435
  _getPropertiesList(target) {
2280
2436
  const list = [];
2281
- let props = PropertyManager._getMergedProperties(target);
2437
+ let props = PropertyManager._getMergedProperties(target.constructor);
2282
2438
  if (props) {
2283
- list.push(props);
2284
- this._targetMap.set(props, target);
2439
+ const values = propsSort(props);
2440
+ this._targetMap.set(values, target);
2441
+ list.push(values);
2285
2442
  }
2286
2443
  if (target instanceof ShaderMaterial) {
2287
2444
  props = Object.create(null);
2288
2445
  const uniforms = Object.create(null);
2289
- this._targetMap.set(props, uniforms);
2290
- const entries = Object.entries(target.uniforms);
2291
- entries.forEach(([name])=>{
2446
+ Object.keys(target.uniforms).forEach((name)=>{
2292
2447
  Object.defineProperty(uniforms, name, {
2293
2448
  get: ()=>target.uniforms[name].value,
2294
2449
  set: (v)=>target.uniforms[name].value = v
@@ -2297,18 +2452,18 @@ class InspectorPlugin extends Plugin {
2297
2452
  dir: "uniforms"
2298
2453
  };
2299
2454
  });
2300
- list.push(props);
2455
+ const values = propsSort(props);
2456
+ this._targetMap.set(values, uniforms);
2457
+ list.push(values);
2301
2458
  }
2302
2459
  return list;
2303
2460
  }
2304
- inspect(target) {
2461
+ _inspect(target) {
2305
2462
  let propsList = this._getPropertiesList(target);
2306
2463
  if (propsList.length === 0) return;
2307
2464
  let gui = this._gui;
2308
- if (target instanceof ViewerExtension) {
2465
+ if (target instanceof ViewerHelper) {
2309
2466
  gui = gui.getFolder("Viewer").show();
2310
- } else if (target instanceof Plugin) {
2311
- gui = gui.getFolder("Plugin").show();
2312
2467
  } else if (target instanceof Component) {
2313
2468
  gui = gui.getFolder("Component").show();
2314
2469
  } else if (target instanceof Material) {
@@ -2317,51 +2472,62 @@ class InspectorPlugin extends Plugin {
2317
2472
  gui = gui.getFolder("Other").show();
2318
2473
  }
2319
2474
  if (gui._title !== "Viewer") {
2320
- gui = gui.getFolder(target.uuid) || gui.addFolder(InspectorPlugin._getTargetName(target), target.uuid).close();
2475
+ gui = gui.getFolder(target.uuid) || gui.addFolder(targetName(target), target.uuid).close();
2321
2476
  }
2322
- this._addPropsListGUI(gui, propsList, target);
2477
+ this._addGUI(gui, propsList, target);
2323
2478
  return target;
2324
2479
  }
2325
- _addPropsListGUI(gui, list, target, dir = "") {
2326
- let source = target;
2327
- for (let props of list){
2328
- if (dir) {
2329
- gui = gui.getFolder(dir) || gui.addFolder(dir).close();
2330
- }
2480
+ _addGUI(gui, list, target, dir = "") {
2481
+ if (dir) {
2482
+ gui = gui.getFolder(dir) || gui.addFolder(dir).close();
2483
+ }
2484
+ const source = target;
2485
+ for (const props of list){
2331
2486
  target = this._targetMap.get(props) || source;
2332
- for(let k in props){
2333
- let value = target[k];
2334
- if (value == null) continue;
2335
- const prop = props[k];
2487
+ for (const [k, prop] of props){
2488
+ let value = target[k] == null ? prop.value : target[k];
2489
+ if (value == null || prop.parent && target[prop.parent] == null) {
2490
+ continue;
2491
+ }
2336
2492
  let folder = gui;
2337
2493
  if (prop.dir) {
2338
2494
  folder = folder.getFolder(prop.dir) || folder.addFolder(prop.dir).close();
2339
2495
  }
2340
- if (PropertyManager._hasProperties(value)) {
2341
- this._addPropsListGUI(folder, this._getPropertiesList(value), target, k);
2496
+ if (PropertyManager._hasProperties(value.constructor)) {
2497
+ this._addGUI(folder, this._getPropertiesList(value), target, k);
2342
2498
  }
2343
- const type = typeof value;
2344
- let ins = null;
2345
- if (value.isColor) {
2346
- ins = folder.addColor(target, k);
2347
- } else if (value.isAnimationCurve) {
2348
- ins = folder.addCurve(target, k);
2349
- } else if (value.isVector2 || value.isVector3 || value.isVector4 || value.isEuler) {
2350
- ins = folder.addVector(target, k, prop.min, prop.max, prop.step);
2351
- } else if (value.isTexture) ; else if (type === "number" || type === "boolean" || type === "string" || type === "function") {
2352
- ins = folder.add(target, k, prop.value || prop.min, prop.max, prop.step);
2353
- } else ;
2354
- if (ins && prop.name) {
2355
- ins.name(prop.name);
2499
+ if (Array.isArray(value)) {
2500
+ this._addGUI(folder, [
2501
+ value.map((_, i)=>[
2502
+ i.toString(),
2503
+ {}
2504
+ ])
2505
+ ], value, k);
2506
+ } else {
2507
+ const type = typeof value;
2508
+ let ins = null;
2509
+ if (value.isColor) {
2510
+ ins = folder.addColor(target, k);
2511
+ } else if (value.isAnimationCurve) {
2512
+ ins = folder.addCurve(target, k);
2513
+ } else if (value.isVector2 || value.isVector3 || value.isVector4 || value.isEuler) {
2514
+ ins = folder.addVector(target, k, prop.min, prop.max, prop.step);
2515
+ } else if (value.isTexture) {
2516
+ ins = folder.addTexture(target, k);
2517
+ ins.getImage = (texture, w, h)=>this._renderSprite(texture, w, h);
2518
+ } else if (type === "number" || type === "boolean" || type === "string" || type === "function") {
2519
+ ins = folder.add(target, k, prop.value || prop.min, prop.max, prop.step);
2520
+ } else ;
2521
+ if (ins && prop.name) {
2522
+ ins.name(prop.name);
2523
+ }
2356
2524
  }
2357
2525
  }
2358
2526
  }
2359
2527
  }
2360
- uninspect(target) {
2528
+ _uninspect(target) {
2361
2529
  let gui = this._gui;
2362
- if (target instanceof Plugin) {
2363
- gui = gui.getFolder("Plugin");
2364
- } else if (target instanceof Component) {
2530
+ if (target instanceof Component) {
2365
2531
  gui = gui.getFolder("Component");
2366
2532
  } else if (target instanceof Material) {
2367
2533
  gui = gui.getFolder("Material");
@@ -2373,100 +2539,52 @@ class InspectorPlugin extends Plugin {
2373
2539
  gui.hide();
2374
2540
  }
2375
2541
  }
2376
- constructor(){
2377
- super();
2378
- this._statesMap = new Map();
2542
+ constructor(...args){
2543
+ super(...args);
2544
+ this._refCntMap = new Map();
2379
2545
  this._targetMap = new Map();
2380
- this.install = ()=>{
2381
- this._gui = new GUI({
2382
- width: 310,
2383
- title: "Inspector"
2384
- }).close();
2385
- this._initFolders();
2386
- this._initViewer();
2387
- };
2388
- this.uninstall = ()=>{
2389
- this._gui.destroy();
2390
- this._statesMap.clear();
2391
- this._targetMap.clear();
2392
- };
2393
2546
  }
2394
2547
  }
2395
- class ViewerExtension extends ObjectInstance {
2396
- get outputColorSpace() {
2397
- return this._renderer.outputColorSpace;
2398
- }
2399
- set outputColorSpace(v) {
2400
- this._renderer.outputColorSpace = v;
2401
- }
2402
- get toneMapping() {
2403
- return this._renderer.toneMapping;
2404
- }
2405
- set toneMapping(v) {
2406
- this._renderer.toneMapping = v;
2407
- }
2408
- get toneMappingExposure() {
2409
- return this._renderer.toneMappingExposure;
2410
- }
2411
- set toneMappingExposure(v) {
2412
- this._renderer.toneMappingExposure = v;
2413
- }
2414
- get shadows() {
2415
- return this._renderer.shadowMap.enabled;
2416
- }
2417
- set shadows(v) {
2418
- this._renderer.shadowMap.enabled = v;
2419
- }
2420
- get backgroundBlurriness() {
2421
- return this._scene.backgroundBlurriness;
2422
- }
2423
- set backgroundBlurriness(v) {
2424
- this._scene.backgroundBlurriness = v;
2425
- }
2426
- constructor(viewer){
2427
- super();
2428
- this._scene = viewer.scene;
2429
- this._renderer = viewer.renderer;
2430
- }
2548
+ function targetName(target) {
2549
+ return target.name || target.constructor.name || target.type;
2431
2550
  }
2432
- _ts_decorate([
2433
- property({
2434
- value: {
2435
- SRGBColorSpace: "srgb",
2436
- LinearSRGBColorSpace: "srgb-linear",
2437
- DisplayP3ColorSpace: "display-p3",
2438
- LinearDisplayP3ColorSpace: "display-p3-linear"
2439
- }
2440
- })
2441
- ], ViewerExtension.prototype, "outputColorSpace", null);
2442
- _ts_decorate([
2443
- property({
2551
+ function propsSort(props) {
2552
+ const order = (v)=>v.order || 10000;
2553
+ const values = Object.entries(props);
2554
+ const array0 = values.filter((v)=>!v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
2555
+ const array1 = values.filter((v)=>v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
2556
+ return array0.concat(array1);
2557
+ }
2558
+ const materialProperties = {
2559
+ visible: {
2560
+ order: 1
2561
+ },
2562
+ transparent: {
2563
+ order: 2
2564
+ },
2565
+ side: {
2566
+ order: 3,
2444
2567
  value: {
2445
- NoToneMapping: 0,
2446
- LinearToneMapping: 1,
2447
- ReinhardToneMapping: 2,
2448
- CineonToneMapping: 3,
2449
- ACESFilmicToneMapping: 4
2568
+ FrontSide: 0,
2569
+ BackSide: 1,
2570
+ DoubleSide: 2
2450
2571
  }
2451
- })
2452
- ], ViewerExtension.prototype, "toneMapping", null);
2453
- _ts_decorate([
2454
- property({
2455
- min: 0,
2456
- max: 10,
2457
- step: 0.01
2458
- })
2459
- ], ViewerExtension.prototype, "toneMappingExposure", null);
2460
- _ts_decorate([
2461
- property
2462
- ], ViewerExtension.prototype, "shadows", null);
2463
- _ts_decorate([
2464
- property({
2572
+ },
2573
+ color: {
2574
+ order: 4,
2575
+ dir: "diffuse"
2576
+ },
2577
+ opacity: {
2578
+ order: 5,
2579
+ dir: "diffuse",
2465
2580
  min: 0,
2466
2581
  max: 1,
2467
2582
  step: 0.01
2468
- })
2469
- ], ViewerExtension.prototype, "backgroundBlurriness", null);
2583
+ }
2584
+ };
2585
+ for(let k in materialProperties){
2586
+ property(materialProperties[k])(Material.prototype, k);
2587
+ }
2470
2588
  const meshBasicMaterislProperties = {
2471
2589
  map: {
2472
2590
  dir: "diffuse"
@@ -2499,24 +2617,6 @@ for(let k in meshBasicMaterislProperties){
2499
2617
  property(meshBasicMaterislProperties[k])(MeshBasicMaterial.prototype, k);
2500
2618
  }
2501
2619
  const meshStandardMaterialProperties = {
2502
- visible: {},
2503
- transparent: {},
2504
- side: {
2505
- value: {
2506
- FrontSide: 0,
2507
- BackSide: 1,
2508
- DoubleSide: 2
2509
- }
2510
- },
2511
- color: {
2512
- dir: "diffuse"
2513
- },
2514
- opacity: {
2515
- dir: "diffuse",
2516
- min: 0,
2517
- max: 1,
2518
- step: 0.01
2519
- },
2520
2620
  map: {
2521
2621
  dir: "diffuse"
2522
2622
  },
@@ -2566,7 +2666,8 @@ const meshStandardMaterialProperties = {
2566
2666
  },
2567
2667
  normalScale: {
2568
2668
  dir: "normal",
2569
- parent: "normalMap"
2669
+ step: 0.01,
2670
+ parent: "normalMap "
2570
2671
  },
2571
2672
  displacementScale: {
2572
2673
  dir: "displacement",
@@ -2586,7 +2687,8 @@ const meshStandardMaterialProperties = {
2586
2687
  dir: "envMap",
2587
2688
  min: 0,
2588
2689
  max: 1,
2589
- step: 0.01
2690
+ step: 0.01,
2691
+ parent: "envMap"
2590
2692
  },
2591
2693
  lightMap: {
2592
2694
  dir: "lightMap"
@@ -2602,6 +2704,116 @@ const meshStandardMaterialProperties = {
2602
2704
  for(let k in meshStandardMaterialProperties){
2603
2705
  property(meshStandardMaterialProperties[k])(MeshStandardMaterial.prototype, k);
2604
2706
  }
2707
+ const meshPhysicalMaterialProperties = {
2708
+ ior: {
2709
+ min: 0,
2710
+ max: 10,
2711
+ step: 0.01
2712
+ },
2713
+ anisotropy: {
2714
+ min: 0,
2715
+ max: 10,
2716
+ step: 0.01
2717
+ },
2718
+ clearcoat: {
2719
+ dir: "clearcoat"
2720
+ },
2721
+ clearcoatMap: {
2722
+ dir: "clearcoat",
2723
+ min: 0,
2724
+ max: 1,
2725
+ step: 0.01
2726
+ },
2727
+ clearcoatRoughness: {
2728
+ dir: "clearcoat",
2729
+ min: 0,
2730
+ max: 1,
2731
+ step: 0.01
2732
+ },
2733
+ clearcoatNormalScale: {
2734
+ dir: "clearcoat",
2735
+ step: 0.01
2736
+ },
2737
+ clearcoatNormalMap: {
2738
+ dir: "clearcoat"
2739
+ },
2740
+ iridescence: {
2741
+ dir: "iridescence",
2742
+ min: 0,
2743
+ max: 1,
2744
+ step: 0.01
2745
+ },
2746
+ iridescenceMap: {
2747
+ dir: "iridescence"
2748
+ },
2749
+ iridescenceIOR: {
2750
+ dir: "iridescence",
2751
+ step: 0.01
2752
+ },
2753
+ iridescenceThicknessRange: {
2754
+ dir: "iridescence"
2755
+ },
2756
+ iridescenceThicknessMap: {
2757
+ dir: "iridescence"
2758
+ },
2759
+ sheen: {
2760
+ dir: "sheen"
2761
+ },
2762
+ sheenColor: {
2763
+ dir: "sheen"
2764
+ },
2765
+ sheenColorMap: {
2766
+ dir: "sheen"
2767
+ },
2768
+ sheenRoughness: {
2769
+ dir: "sheen",
2770
+ min: 0,
2771
+ max: 1,
2772
+ step: 0.01
2773
+ },
2774
+ sheenRoughnessMap: {
2775
+ dir: "sheen"
2776
+ },
2777
+ transmission: {
2778
+ dir: "transmission"
2779
+ },
2780
+ transmissionMap: {
2781
+ dir: "transmission"
2782
+ },
2783
+ thickness: {
2784
+ dir: "thickness",
2785
+ min: 0,
2786
+ max: 1,
2787
+ step: 0.01
2788
+ },
2789
+ thicknessMap: {
2790
+ dir: "thickness"
2791
+ },
2792
+ attenuationDistance: {
2793
+ dir: "attenuation"
2794
+ },
2795
+ attenuationColor: {
2796
+ dir: "attenuation"
2797
+ },
2798
+ specularIntensity: {
2799
+ dir: "specular",
2800
+ min: 0,
2801
+ max: 1,
2802
+ step: 0.01
2803
+ },
2804
+ specularIntensityMap: {
2805
+ dir: "specular"
2806
+ },
2807
+ specularColor: {
2808
+ dir: "specular"
2809
+ },
2810
+ specularColorMap: {
2811
+ dir: "specular"
2812
+ }
2813
+ };
2814
+ for(let k in meshPhysicalMaterialProperties){
2815
+ property(meshPhysicalMaterialProperties[k])(MeshPhysicalMaterial.prototype, k);
2816
+ }
2605
2817
 
2606
2818
  /**
2607
2819
  * @author mrdoob / http://mrdoob.com/
@@ -2651,7 +2863,7 @@ var Panel = function(name, fg, bg) {
2651
2863
  }
2652
2864
  };
2653
2865
  };
2654
- var Stats = function() {
2866
+ var Stats$1 = function() {
2655
2867
  var mode = 0;
2656
2868
  var container = document.createElement('div');
2657
2869
  container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
@@ -2710,8 +2922,19 @@ var Stats = function() {
2710
2922
  };
2711
2923
  };
2712
2924
 
2713
- class StatsPlugin extends Plugin {
2714
- onUpdate(dt) {
2925
+ class Stats extends Mount {
2926
+ onLoad() {
2927
+ this._stats.addPanel(this._dcPanel);
2928
+ this._stats.addPanel(this._texPanel);
2929
+ this._stats.addPanel(this._triPanel);
2930
+ this._stats.addPanel(this._prgPanel);
2931
+ this._stats.showPanel(0);
2932
+ document.body.appendChild(this._stats.dom);
2933
+ }
2934
+ onDestroy() {
2935
+ document.body.removeChild(this._stats.dom);
2936
+ }
2937
+ update(dt) {
2715
2938
  const info = this.viewer.renderer.info;
2716
2939
  this._dcPanel.update(info.render.calls, 300);
2717
2940
  this._triPanel.update(info.render.triangles, 500000);
@@ -2719,26 +2942,35 @@ class StatsPlugin extends Plugin {
2719
2942
  this._prgPanel.update(info.programs.length, 50);
2720
2943
  this._stats.update();
2721
2944
  }
2722
- constructor(){
2723
- super();
2724
- this._stats = new Stats();
2945
+ constructor(...args){
2946
+ super(...args);
2947
+ this._stats = new Stats$1();
2725
2948
  this._dcPanel = new Panel('DC', '#ff8', '#221');
2726
2949
  this._triPanel = new Panel("TRI", '#ff8', '#221');
2727
2950
  this._texPanel = new Panel('TEX', '#ff8', '#221');
2728
2951
  this._prgPanel = new Panel('PRG', '#ff8', '#221');
2729
- this.install = ()=>{
2730
- this._stats.addPanel(this._dcPanel);
2731
- this._stats.addPanel(this._texPanel);
2732
- this._stats.addPanel(this._triPanel);
2733
- this._stats.addPanel(this._prgPanel);
2734
- this._stats.showPanel(0);
2735
- document.body.appendChild(this._stats.dom);
2736
- };
2737
- this.uninstall = ()=>{
2738
- document.body.removeChild(this._stats.dom);
2739
- };
2740
2952
  }
2741
2953
  }
2742
2954
 
2743
- export { GUI, InspectorPlugin, StatsPlugin };
2955
+ class BoxProjectionHelper extends Mount {
2956
+ onLoad() {
2957
+ this._box3 = new Box3();
2958
+ this._target = this.viewer.mount(BoxProjection);
2959
+ this._helper = this.viewer.add(new Box3Helper(this._box3));
2960
+ }
2961
+ onEnable() {
2962
+ this._helper.visible = true;
2963
+ }
2964
+ onDisable() {
2965
+ this._helper.visible = false;
2966
+ }
2967
+ update(dt) {
2968
+ const { center, boxMin, boxMax } = this._target;
2969
+ this._box3.min.copy(center).add(boxMin);
2970
+ this._box3.max.copy(center).add(boxMax);
2971
+ this._helper.updateMatrixWorld();
2972
+ }
2973
+ }
2974
+
2975
+ export { BoxProjectionHelper, GUI, Inspector, Stats };
2744
2976
  //# sourceMappingURL=module.js.map