@xviewer.js/debug 1.0.0-beta.2 → 1.0.0
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 +520 -273
- package/dist/main.js.map +1 -1
- package/dist/module.js +519 -273
- package/dist/module.js.map +1 -1
- package/package.json +2 -7
- package/types/BoxProjectionHelper.d.ts +10 -0
- package/types/Inspector.d.ts +23 -0
- package/types/Stats.d.ts +11 -0
- package/types/ViewerHelper.d.ts +28 -0
- package/types/gui/GUI.d.ts +1 -9
- package/types/gui/controllers/NumberController.d.ts +1 -1
- package/types/gui/controllers/TextureController.d.ts +4 -2
- package/types/gui/controllers/TextureController_.d.ts +9 -0
- package/types/gui/utils/index.d.ts +2 -0
- package/types/index.d.ts +3 -2
package/dist/main.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var three = require('three');
|
|
4
3
|
var core = require('@xviewer.js/core');
|
|
4
|
+
var three = require('three');
|
|
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.image img {\n max-width: 100%;\n}\n.lil-gui .controller.image canvas {\n max-width: 100%;\n min-height: 1px;\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,{});
|
|
5
10
|
|
|
6
11
|
class Controller {
|
|
7
12
|
/**
|
|
@@ -417,6 +422,18 @@ function getPrecision(value) {
|
|
|
417
422
|
function hasDecimal(value) {
|
|
418
423
|
return value % 1 !== 0;
|
|
419
424
|
}
|
|
425
|
+
let renderer;
|
|
426
|
+
let material = new three.MeshBasicMaterial();
|
|
427
|
+
function renderToCanvas(texture) {
|
|
428
|
+
if (renderer === undefined) {
|
|
429
|
+
renderer = new three.WebGLRenderer();
|
|
430
|
+
}
|
|
431
|
+
const image = texture.image;
|
|
432
|
+
material.map = texture;
|
|
433
|
+
renderer.setSize(image.width, image.height, false);
|
|
434
|
+
core.Viewer.Blit(renderer, null, material);
|
|
435
|
+
return renderer.domElement;
|
|
436
|
+
}
|
|
420
437
|
|
|
421
438
|
class NumberController extends Controller {
|
|
422
439
|
min(min) {
|
|
@@ -446,14 +463,14 @@ class NumberController extends Controller {
|
|
|
446
463
|
return false;
|
|
447
464
|
}
|
|
448
465
|
updateDisplay() {
|
|
449
|
-
const value = this.getValue();
|
|
466
|
+
const value = this._snap(this.getValue());
|
|
450
467
|
if (this._hasSlider) {
|
|
451
468
|
let percent = (value - this._min) / (this._max - this._min);
|
|
452
469
|
percent = Math.max(0, Math.min(percent, 1));
|
|
453
470
|
this.$fill.style.width = percent * 100 + '%';
|
|
454
471
|
}
|
|
455
472
|
if (!this._inputFocused) {
|
|
456
|
-
this.$input.value = value;
|
|
473
|
+
this.$input.value = "" + value;
|
|
457
474
|
}
|
|
458
475
|
return this;
|
|
459
476
|
}
|
|
@@ -858,8 +875,7 @@ class ColorController extends Controller {
|
|
|
858
875
|
this.setValue(newValue);
|
|
859
876
|
} else {
|
|
860
877
|
this._format.fromHexString(value, this.getValue(), this._rgbScale);
|
|
861
|
-
this.
|
|
862
|
-
this.updateDisplay();
|
|
878
|
+
this.setValue(this.getValue());
|
|
863
879
|
}
|
|
864
880
|
}
|
|
865
881
|
save() {
|
|
@@ -926,49 +942,6 @@ class ColorController extends Controller {
|
|
|
926
942
|
}
|
|
927
943
|
}
|
|
928
944
|
|
|
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
945
|
class UIElement {
|
|
973
946
|
add(...args) {
|
|
974
947
|
for(let i = 0; i < args.length; i++){
|
|
@@ -1056,8 +1029,8 @@ class UINumber extends UIElement {
|
|
|
1056
1029
|
return this;
|
|
1057
1030
|
}
|
|
1058
1031
|
updateDisplay() {
|
|
1059
|
-
let value = this.getValue();
|
|
1060
|
-
this.dom.value = "" +
|
|
1032
|
+
let value = this._snap(this.getValue());
|
|
1033
|
+
this.dom.value = "" + value;
|
|
1061
1034
|
if (this.unit !== '') this.dom.value += ' ' + this.unit;
|
|
1062
1035
|
}
|
|
1063
1036
|
_getImplicitStep(value) {
|
|
@@ -1731,57 +1704,46 @@ class CurveController extends Controller {
|
|
|
1731
1704
|
}
|
|
1732
1705
|
|
|
1733
1706
|
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;
|
|
1744
|
-
}
|
|
1745
1707
|
updateDisplay() {
|
|
1746
1708
|
const canvas = this.$canvas;
|
|
1747
1709
|
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
1710
|
if (context) {
|
|
1752
|
-
// Always clear the context before set new texture, because new texture may has transparency
|
|
1753
1711
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
1754
1712
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1713
|
+
let texture = this.getValue();
|
|
1714
|
+
if (texture) {
|
|
1715
|
+
let image = texture.image;
|
|
1716
|
+
if (image && image.width > 0) {
|
|
1717
|
+
this.$label.textContent = `${image.width}x${image.height}`;
|
|
1718
|
+
canvas.title = texture.sourceFile;
|
|
1719
|
+
let scale = canvas.width / image.width;
|
|
1720
|
+
if (texture.isDataTexture || texture.isCompressedTexture) {
|
|
1721
|
+
context.drawImage(renderToCanvas(texture), 0, 0, image.width * scale, image.height * scale);
|
|
1722
|
+
} else if (image.depth) ; else {
|
|
1723
|
+
context.drawImage(image, 0, 0, image.width * scale, image.height * scale);
|
|
1724
|
+
}
|
|
1762
1725
|
} else {
|
|
1763
|
-
|
|
1726
|
+
canvas.title = texture.sourceFile + ' (error)';
|
|
1764
1727
|
}
|
|
1728
|
+
} else {
|
|
1729
|
+
canvas.title = 'empty';
|
|
1765
1730
|
}
|
|
1766
1731
|
return this;
|
|
1767
1732
|
}
|
|
1768
1733
|
constructor(parent, object, property){
|
|
1769
1734
|
super(parent, object, property, "image");
|
|
1770
|
-
|
|
1771
|
-
let group = document.createElement("div");
|
|
1735
|
+
const group = this.$widget.appendChild(document.createElement("div"));
|
|
1772
1736
|
group.style.display = "flex";
|
|
1773
1737
|
group.style.flexDirection = "column";
|
|
1774
1738
|
group.style.width = "100%";
|
|
1775
|
-
this.$
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
group.appendChild(button);
|
|
1784
|
-
}
|
|
1739
|
+
this.$canvas = group.appendChild(document.createElement("canvas"));
|
|
1740
|
+
const label = document.createElement("div");
|
|
1741
|
+
label.style.position = "absolute";
|
|
1742
|
+
label.style.display = "flex";
|
|
1743
|
+
label.style.backgroundColor = "black";
|
|
1744
|
+
this.$label = group.appendChild(label);
|
|
1745
|
+
group.onpointerover = (e)=>this.onpointerover && this.onpointerover(e);
|
|
1746
|
+
group.onpointerout = (e)=>this.onpointerout && this.onpointerout(e);
|
|
1785
1747
|
}
|
|
1786
1748
|
}
|
|
1787
1749
|
|
|
@@ -1842,14 +1804,6 @@ class GUI {
|
|
|
1842
1804
|
*/ addColor(object, property, rgbScale = 1) {
|
|
1843
1805
|
return new ColorController(this, object, property, rgbScale);
|
|
1844
1806
|
}
|
|
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
1807
|
addTexture(object, property) {
|
|
1854
1808
|
return new TextureController(this, object, property);
|
|
1855
1809
|
}
|
|
@@ -2193,7 +2147,9 @@ class GUI {
|
|
|
2193
2147
|
this.$title.setAttribute('role', 'button');
|
|
2194
2148
|
this.$title.setAttribute('aria-expanded', "true");
|
|
2195
2149
|
this.$title.setAttribute('tabindex', "0");
|
|
2196
|
-
this.$title.addEventListener('click', ()=>
|
|
2150
|
+
this.$title.addEventListener('click', ()=>{
|
|
2151
|
+
this.openAnimated(this._closed);
|
|
2152
|
+
});
|
|
2197
2153
|
this.$title.addEventListener('keydown', (e)=>{
|
|
2198
2154
|
if (e.code === 'Enter' || e.code === 'Space') {
|
|
2199
2155
|
e.preventDefault();
|
|
@@ -2236,61 +2192,259 @@ class GUI {
|
|
|
2236
2192
|
}
|
|
2237
2193
|
}
|
|
2238
2194
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2195
|
+
/******************************************************************************
|
|
2196
|
+
Copyright (c) Microsoft Corporation.
|
|
2197
|
+
|
|
2198
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2199
|
+
purpose with or without fee is hereby granted.
|
|
2200
|
+
|
|
2201
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2202
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2203
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2204
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2205
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2206
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2207
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2208
|
+
***************************************************************************** */
|
|
2209
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
function __decorate(decorators, target, key, desc) {
|
|
2213
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2214
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2215
|
+
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;
|
|
2216
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2244
2217
|
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2218
|
+
|
|
2219
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2220
|
+
var e = new Error(message);
|
|
2221
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2222
|
+
};
|
|
2223
|
+
|
|
2224
|
+
class ViewerHelper extends core.ObjectInstance {
|
|
2225
|
+
get outputColorSpace() {
|
|
2226
|
+
return this._renderer.outputColorSpace;
|
|
2227
|
+
}
|
|
2228
|
+
set outputColorSpace(v) {
|
|
2229
|
+
this._renderer.outputColorSpace = v;
|
|
2230
|
+
}
|
|
2231
|
+
get toneMapping() {
|
|
2232
|
+
return this._renderer.toneMapping;
|
|
2233
|
+
}
|
|
2234
|
+
set toneMapping(v) {
|
|
2235
|
+
this._renderer.toneMapping = v;
|
|
2236
|
+
}
|
|
2237
|
+
get toneMappingExposure() {
|
|
2238
|
+
return this._renderer.toneMappingExposure;
|
|
2239
|
+
}
|
|
2240
|
+
set toneMappingExposure(v) {
|
|
2241
|
+
this._renderer.toneMappingExposure = v;
|
|
2242
|
+
}
|
|
2243
|
+
get shadows() {
|
|
2244
|
+
return this._renderer.shadowMap.enabled;
|
|
2245
|
+
}
|
|
2246
|
+
set shadows(v) {
|
|
2247
|
+
this._renderer.shadowMap.enabled = v;
|
|
2248
|
+
}
|
|
2249
|
+
get backgroundBlurriness() {
|
|
2250
|
+
return this._scene.backgroundBlurriness;
|
|
2248
2251
|
}
|
|
2249
|
-
|
|
2252
|
+
set backgroundBlurriness(v) {
|
|
2253
|
+
this._scene.backgroundBlurriness = v;
|
|
2254
|
+
}
|
|
2255
|
+
get environment() {
|
|
2256
|
+
return this._scene.environment;
|
|
2257
|
+
}
|
|
2258
|
+
set environment(v) {
|
|
2259
|
+
this._scene.environment = v;
|
|
2260
|
+
}
|
|
2261
|
+
get environmentIntensity() {
|
|
2262
|
+
return this._scene.environmentIntensity;
|
|
2263
|
+
}
|
|
2264
|
+
set environmentIntensity(v) {
|
|
2265
|
+
this._scene.environmentIntensity = v;
|
|
2266
|
+
}
|
|
2267
|
+
get environmentRotation() {
|
|
2268
|
+
return this._scene.environmentRotation;
|
|
2269
|
+
}
|
|
2270
|
+
set environmentRotation(v) {
|
|
2271
|
+
this._scene.environmentRotation.copy(v);
|
|
2272
|
+
}
|
|
2273
|
+
get backgroundRotation() {
|
|
2274
|
+
return this._scene.backgroundRotation;
|
|
2275
|
+
}
|
|
2276
|
+
set backgroundRotation(v) {
|
|
2277
|
+
this._scene.backgroundRotation.copy(v);
|
|
2278
|
+
}
|
|
2279
|
+
get targetFrameRate() {
|
|
2280
|
+
return this._viewer.targetFrameRate;
|
|
2281
|
+
}
|
|
2282
|
+
set targetFrameRate(v) {
|
|
2283
|
+
this._viewer.targetFrameRate = v;
|
|
2284
|
+
}
|
|
2285
|
+
constructor(viewer){
|
|
2286
|
+
super();
|
|
2287
|
+
this._viewer = viewer;
|
|
2288
|
+
this._scene = viewer.scene;
|
|
2289
|
+
this._renderer = viewer.renderer;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
__decorate([
|
|
2293
|
+
core.property({
|
|
2294
|
+
value: {
|
|
2295
|
+
SRGBColorSpace: "srgb",
|
|
2296
|
+
LinearSRGBColorSpace: "srgb-linear",
|
|
2297
|
+
DisplayP3ColorSpace: "display-p3",
|
|
2298
|
+
LinearDisplayP3ColorSpace: "display-p3-linear"
|
|
2299
|
+
}
|
|
2300
|
+
})
|
|
2301
|
+
], ViewerHelper.prototype, "outputColorSpace", null);
|
|
2302
|
+
__decorate([
|
|
2303
|
+
core.property({
|
|
2304
|
+
value: {
|
|
2305
|
+
NoToneMapping: 0,
|
|
2306
|
+
LinearToneMapping: 1,
|
|
2307
|
+
ReinhardToneMapping: 2,
|
|
2308
|
+
CineonToneMapping: 3,
|
|
2309
|
+
ACESFilmicToneMapping: 4
|
|
2310
|
+
}
|
|
2311
|
+
})
|
|
2312
|
+
], ViewerHelper.prototype, "toneMapping", null);
|
|
2313
|
+
__decorate([
|
|
2314
|
+
core.property({
|
|
2315
|
+
min: 0,
|
|
2316
|
+
max: 10,
|
|
2317
|
+
step: 0.01
|
|
2318
|
+
})
|
|
2319
|
+
], ViewerHelper.prototype, "toneMappingExposure", null);
|
|
2320
|
+
__decorate([
|
|
2321
|
+
core.property
|
|
2322
|
+
], ViewerHelper.prototype, "shadows", null);
|
|
2323
|
+
__decorate([
|
|
2324
|
+
core.property({
|
|
2325
|
+
min: 0,
|
|
2326
|
+
max: 1,
|
|
2327
|
+
step: 0.01
|
|
2328
|
+
})
|
|
2329
|
+
], ViewerHelper.prototype, "backgroundBlurriness", null);
|
|
2330
|
+
__decorate([
|
|
2331
|
+
core.property
|
|
2332
|
+
], ViewerHelper.prototype, "environment", null);
|
|
2333
|
+
__decorate([
|
|
2334
|
+
core.property({
|
|
2335
|
+
min: 0,
|
|
2336
|
+
max: 1,
|
|
2337
|
+
step: 0.01
|
|
2338
|
+
})
|
|
2339
|
+
], ViewerHelper.prototype, "environmentIntensity", null);
|
|
2340
|
+
__decorate([
|
|
2341
|
+
core.property({
|
|
2342
|
+
step: 0.01
|
|
2343
|
+
})
|
|
2344
|
+
], ViewerHelper.prototype, "environmentRotation", null);
|
|
2345
|
+
__decorate([
|
|
2346
|
+
core.property({
|
|
2347
|
+
step: 0.01
|
|
2348
|
+
})
|
|
2349
|
+
], ViewerHelper.prototype, "backgroundRotation", null);
|
|
2350
|
+
__decorate([
|
|
2351
|
+
core.property({
|
|
2352
|
+
min: 1,
|
|
2353
|
+
max: 120,
|
|
2354
|
+
step: 1
|
|
2355
|
+
})
|
|
2356
|
+
], ViewerHelper.prototype, "targetFrameRate", null);
|
|
2357
|
+
|
|
2358
|
+
class Inspector extends core.Mount {
|
|
2359
|
+
onLoad() {
|
|
2360
|
+
this._scene = new three.Scene();
|
|
2361
|
+
this._camera = new three.OrthographicCamera(0, window.innerWidth, window.innerHeight, 0, -1, 1);
|
|
2362
|
+
this._gui = new GUI({
|
|
2363
|
+
width: 310,
|
|
2364
|
+
title: "Inspector"
|
|
2365
|
+
}).close();
|
|
2366
|
+
this._gui.addFolder("Viewer").close().hide();
|
|
2367
|
+
this._gui.addFolder("Component").close().hide();
|
|
2368
|
+
this._gui.addFolder("Material").close().hide();
|
|
2369
|
+
this._gui.addFolder("Other").close().hide();
|
|
2370
|
+
this._rect = this._gui.domElement.getBoundingClientRect();
|
|
2371
|
+
this._inspect(new ViewerHelper(this.viewer));
|
|
2372
|
+
this._addSprite();
|
|
2373
|
+
}
|
|
2374
|
+
onDestroy() {
|
|
2375
|
+
this._gui.destroy();
|
|
2376
|
+
this._refCntMap.clear();
|
|
2377
|
+
this._targetMap.clear();
|
|
2378
|
+
}
|
|
2379
|
+
update(dt) {
|
|
2250
2380
|
this._gui.update();
|
|
2251
2381
|
this._updateFolders();
|
|
2252
2382
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2383
|
+
resize(width, height) {
|
|
2384
|
+
this._camera.left = 0;
|
|
2385
|
+
this._camera.right = width;
|
|
2386
|
+
this._camera.top = height;
|
|
2387
|
+
this._camera.bottom = 0;
|
|
2388
|
+
this._camera.updateProjectionMatrix();
|
|
2389
|
+
this._rect = this._gui.domElement.getBoundingClientRect();
|
|
2390
|
+
}
|
|
2391
|
+
render(dt) {
|
|
2392
|
+
const { renderer } = this.viewer;
|
|
2393
|
+
const autoClearDepth = renderer.autoClearDepth;
|
|
2394
|
+
const autoClearColor = renderer.autoClearColor;
|
|
2395
|
+
renderer.autoClearDepth = true;
|
|
2396
|
+
renderer.autoClearColor = false;
|
|
2397
|
+
renderer.render(this._scene, this._camera);
|
|
2398
|
+
renderer.autoClearDepth = autoClearDepth;
|
|
2399
|
+
renderer.autoClearColor = autoClearColor;
|
|
2400
|
+
}
|
|
2401
|
+
_addSprite() {
|
|
2402
|
+
const viewer = this.viewer;
|
|
2403
|
+
this._tween = viewer.tween();
|
|
2404
|
+
this._background = viewer.add(three.Sprite, {
|
|
2405
|
+
parent: this._scene,
|
|
2406
|
+
scale: new three.Vector3(258, 258, 1),
|
|
2407
|
+
position: new three.Vector3(viewer.width / 2, viewer.height / 2)
|
|
2408
|
+
});
|
|
2409
|
+
this._background.material.opacity = 0;
|
|
2410
|
+
this._sprite = viewer.add(three.Sprite, {
|
|
2411
|
+
parent: this._scene,
|
|
2412
|
+
scale: new three.Vector3(256, 256, 1),
|
|
2413
|
+
position: new three.Vector3(viewer.width / 2, viewer.height / 2)
|
|
2414
|
+
});
|
|
2415
|
+
this._sprite.material.opacity = 0;
|
|
2263
2416
|
}
|
|
2264
2417
|
_updateFolders() {
|
|
2265
|
-
const
|
|
2266
|
-
const setState = (v)=>
|
|
2267
|
-
|
|
2268
|
-
|
|
2418
|
+
const refCntMap = this._refCntMap;
|
|
2419
|
+
const setState = (v)=>{
|
|
2420
|
+
if (refCntMap.get(v) === -1) refCntMap.set(v, 0);
|
|
2421
|
+
if (refCntMap.get(v) === undefined) refCntMap.set(v, 1);
|
|
2422
|
+
};
|
|
2423
|
+
refCntMap.forEach((_, k, map)=>map.set(k, -1));
|
|
2269
2424
|
this.viewer.traverseComponents(setState);
|
|
2270
2425
|
this.viewer.traverseMaterials(setState);
|
|
2271
|
-
|
|
2426
|
+
refCntMap.forEach((v, k, map)=>{
|
|
2272
2427
|
if (v === 1) {
|
|
2273
|
-
this.
|
|
2428
|
+
this._inspect(k);
|
|
2274
2429
|
}
|
|
2275
2430
|
if (v === -1) {
|
|
2276
|
-
this.
|
|
2431
|
+
this._uninspect(k);
|
|
2277
2432
|
map.delete(k);
|
|
2278
2433
|
}
|
|
2279
2434
|
});
|
|
2280
2435
|
}
|
|
2281
2436
|
_getPropertiesList(target) {
|
|
2282
2437
|
const list = [];
|
|
2283
|
-
let props = core.PropertyManager._getMergedProperties(target);
|
|
2438
|
+
let props = core.PropertyManager._getMergedProperties(target.constructor);
|
|
2284
2439
|
if (props) {
|
|
2285
|
-
|
|
2286
|
-
|
|
2440
|
+
const values = propsSort(props);
|
|
2441
|
+
list.push(values);
|
|
2442
|
+
this._targetMap.set(values, target);
|
|
2287
2443
|
}
|
|
2288
2444
|
if (target instanceof three.ShaderMaterial) {
|
|
2289
2445
|
props = Object.create(null);
|
|
2290
2446
|
const uniforms = Object.create(null);
|
|
2291
|
-
|
|
2292
|
-
const entries = Object.entries(target.uniforms);
|
|
2293
|
-
entries.forEach(([name])=>{
|
|
2447
|
+
Object.keys(target.uniforms).forEach((name)=>{
|
|
2294
2448
|
Object.defineProperty(uniforms, name, {
|
|
2295
2449
|
get: ()=>target.uniforms[name].value,
|
|
2296
2450
|
set: (v)=>target.uniforms[name].value = v
|
|
@@ -2299,18 +2453,18 @@ class InspectorPlugin extends core.Plugin {
|
|
|
2299
2453
|
dir: "uniforms"
|
|
2300
2454
|
};
|
|
2301
2455
|
});
|
|
2302
|
-
|
|
2456
|
+
const values = propsSort(props);
|
|
2457
|
+
list.push(values);
|
|
2458
|
+
this._targetMap.set(values, uniforms);
|
|
2303
2459
|
}
|
|
2304
2460
|
return list;
|
|
2305
2461
|
}
|
|
2306
|
-
|
|
2462
|
+
_inspect(target) {
|
|
2307
2463
|
let propsList = this._getPropertiesList(target);
|
|
2308
2464
|
if (propsList.length === 0) return;
|
|
2309
2465
|
let gui = this._gui;
|
|
2310
|
-
if (target instanceof
|
|
2466
|
+
if (target instanceof ViewerHelper) {
|
|
2311
2467
|
gui = gui.getFolder("Viewer").show();
|
|
2312
|
-
} else if (target instanceof core.Plugin) {
|
|
2313
|
-
gui = gui.getFolder("Plugin").show();
|
|
2314
2468
|
} else if (target instanceof core.Component) {
|
|
2315
2469
|
gui = gui.getFolder("Component").show();
|
|
2316
2470
|
} else if (target instanceof three.Material) {
|
|
@@ -2319,28 +2473,29 @@ class InspectorPlugin extends core.Plugin {
|
|
|
2319
2473
|
gui = gui.getFolder("Other").show();
|
|
2320
2474
|
}
|
|
2321
2475
|
if (gui._title !== "Viewer") {
|
|
2322
|
-
gui = gui.getFolder(target.uuid) || gui.addFolder(
|
|
2476
|
+
gui = gui.getFolder(target.uuid) || gui.addFolder(targetName(target), target.uuid).close();
|
|
2323
2477
|
}
|
|
2324
|
-
this.
|
|
2478
|
+
this._addGUI(gui, propsList, target);
|
|
2325
2479
|
return target;
|
|
2326
2480
|
}
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2481
|
+
_addGUI(gui, list, target, dir = "") {
|
|
2482
|
+
if (dir) {
|
|
2483
|
+
gui = gui.getFolder(dir) || gui.addFolder(dir).close();
|
|
2484
|
+
}
|
|
2485
|
+
const source = target;
|
|
2486
|
+
for (const props of list){
|
|
2333
2487
|
target = this._targetMap.get(props) || source;
|
|
2334
|
-
for(
|
|
2488
|
+
for (const [k, prop] of props){
|
|
2335
2489
|
let value = target[k];
|
|
2336
|
-
if (value == null)
|
|
2337
|
-
|
|
2490
|
+
if (value == null || prop.parent && target[prop.parent] == null) {
|
|
2491
|
+
continue;
|
|
2492
|
+
}
|
|
2338
2493
|
let folder = gui;
|
|
2339
2494
|
if (prop.dir) {
|
|
2340
2495
|
folder = folder.getFolder(prop.dir) || folder.addFolder(prop.dir).close();
|
|
2341
2496
|
}
|
|
2342
|
-
if (core.PropertyManager._hasProperties(value)) {
|
|
2343
|
-
this.
|
|
2497
|
+
if (core.PropertyManager._hasProperties(value.constructor)) {
|
|
2498
|
+
this._addGUI(folder, this._getPropertiesList(value), target, k);
|
|
2344
2499
|
}
|
|
2345
2500
|
const type = typeof value;
|
|
2346
2501
|
let ins = null;
|
|
@@ -2350,7 +2505,34 @@ class InspectorPlugin extends core.Plugin {
|
|
|
2350
2505
|
ins = folder.addCurve(target, k);
|
|
2351
2506
|
} else if (value.isVector2 || value.isVector3 || value.isVector4 || value.isEuler) {
|
|
2352
2507
|
ins = folder.addVector(target, k, prop.min, prop.max, prop.step);
|
|
2353
|
-
} else if (value.isTexture)
|
|
2508
|
+
} else if (value.isTexture) {
|
|
2509
|
+
ins = folder.addTexture(target, k);
|
|
2510
|
+
ins.onpointerover = ()=>{
|
|
2511
|
+
const image = value.image;
|
|
2512
|
+
const w = image.width * 256 / image.height, h = 256;
|
|
2513
|
+
const x = this._rect.x - w / 2 - 10;
|
|
2514
|
+
this._background.scale.set(w + 2, h + 2, 1);
|
|
2515
|
+
this._background.position.x = x;
|
|
2516
|
+
this._sprite.scale.set(w, h, 1);
|
|
2517
|
+
this._sprite.position.x = x;
|
|
2518
|
+
this._sprite.material.map = value;
|
|
2519
|
+
this._sprite.material.needsUpdate = true;
|
|
2520
|
+
this._tween.timeline(this._sprite.material).to({
|
|
2521
|
+
opacity: 1
|
|
2522
|
+
}, 0.3).start();
|
|
2523
|
+
this._tween.timeline(this._background.material).to({
|
|
2524
|
+
opacity: 1
|
|
2525
|
+
}, 0.3).start();
|
|
2526
|
+
};
|
|
2527
|
+
ins.onpointerout = ()=>{
|
|
2528
|
+
this._tween.timeline(this._background.material).to({
|
|
2529
|
+
opacity: 0
|
|
2530
|
+
}, 0.3).start();
|
|
2531
|
+
this._tween.timeline(this._sprite.material).to({
|
|
2532
|
+
opacity: 0
|
|
2533
|
+
}, 0.3).start();
|
|
2534
|
+
};
|
|
2535
|
+
} else if (type === "number" || type === "boolean" || type === "string" || type === "function") {
|
|
2354
2536
|
ins = folder.add(target, k, prop.value || prop.min, prop.max, prop.step);
|
|
2355
2537
|
} else ;
|
|
2356
2538
|
if (ins && prop.name) {
|
|
@@ -2359,11 +2541,9 @@ class InspectorPlugin extends core.Plugin {
|
|
|
2359
2541
|
}
|
|
2360
2542
|
}
|
|
2361
2543
|
}
|
|
2362
|
-
|
|
2544
|
+
_uninspect(target) {
|
|
2363
2545
|
let gui = this._gui;
|
|
2364
|
-
if (target instanceof core.
|
|
2365
|
-
gui = gui.getFolder("Plugin");
|
|
2366
|
-
} else if (target instanceof core.Component) {
|
|
2546
|
+
if (target instanceof core.Component) {
|
|
2367
2547
|
gui = gui.getFolder("Component");
|
|
2368
2548
|
} else if (target instanceof three.Material) {
|
|
2369
2549
|
gui = gui.getFolder("Material");
|
|
@@ -2375,100 +2555,52 @@ class InspectorPlugin extends core.Plugin {
|
|
|
2375
2555
|
gui.hide();
|
|
2376
2556
|
}
|
|
2377
2557
|
}
|
|
2378
|
-
constructor(){
|
|
2379
|
-
super();
|
|
2380
|
-
this.
|
|
2558
|
+
constructor(...args){
|
|
2559
|
+
super(...args);
|
|
2560
|
+
this._refCntMap = new Map();
|
|
2381
2561
|
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
2562
|
}
|
|
2396
2563
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
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
|
-
}
|
|
2564
|
+
function targetName(target) {
|
|
2565
|
+
return target.name || target.constructor.name || target.type;
|
|
2433
2566
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2567
|
+
function propsSort(props) {
|
|
2568
|
+
const order = (v)=>v.order || 10000;
|
|
2569
|
+
const values = Object.entries(props);
|
|
2570
|
+
const array0 = values.filter((v)=>!v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
|
|
2571
|
+
const array1 = values.filter((v)=>v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
|
|
2572
|
+
return array0.concat(array1);
|
|
2573
|
+
}
|
|
2574
|
+
const materialProperties = {
|
|
2575
|
+
visible: {
|
|
2576
|
+
order: 1
|
|
2577
|
+
},
|
|
2578
|
+
transparent: {
|
|
2579
|
+
order: 2
|
|
2580
|
+
},
|
|
2581
|
+
side: {
|
|
2582
|
+
order: 3,
|
|
2446
2583
|
value: {
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
CineonToneMapping: 3,
|
|
2451
|
-
ACESFilmicToneMapping: 4
|
|
2584
|
+
FrontSide: 0,
|
|
2585
|
+
BackSide: 1,
|
|
2586
|
+
DoubleSide: 2
|
|
2452
2587
|
}
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
], ViewerExtension.prototype, "toneMappingExposure", null);
|
|
2462
|
-
_ts_decorate([
|
|
2463
|
-
core.property
|
|
2464
|
-
], ViewerExtension.prototype, "shadows", null);
|
|
2465
|
-
_ts_decorate([
|
|
2466
|
-
core.property({
|
|
2588
|
+
},
|
|
2589
|
+
color: {
|
|
2590
|
+
order: 4,
|
|
2591
|
+
dir: "diffuse"
|
|
2592
|
+
},
|
|
2593
|
+
opacity: {
|
|
2594
|
+
order: 5,
|
|
2595
|
+
dir: "diffuse",
|
|
2467
2596
|
min: 0,
|
|
2468
2597
|
max: 1,
|
|
2469
2598
|
step: 0.01
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
for(let k in materialProperties){
|
|
2602
|
+
core.property(materialProperties[k])(three.Material.prototype, k);
|
|
2603
|
+
}
|
|
2472
2604
|
const meshBasicMaterislProperties = {
|
|
2473
2605
|
map: {
|
|
2474
2606
|
dir: "diffuse"
|
|
@@ -2501,24 +2633,6 @@ for(let k in meshBasicMaterislProperties){
|
|
|
2501
2633
|
core.property(meshBasicMaterislProperties[k])(three.MeshBasicMaterial.prototype, k);
|
|
2502
2634
|
}
|
|
2503
2635
|
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
2636
|
map: {
|
|
2523
2637
|
dir: "diffuse"
|
|
2524
2638
|
},
|
|
@@ -2568,7 +2682,8 @@ const meshStandardMaterialProperties = {
|
|
|
2568
2682
|
},
|
|
2569
2683
|
normalScale: {
|
|
2570
2684
|
dir: "normal",
|
|
2571
|
-
|
|
2685
|
+
step: 0.01,
|
|
2686
|
+
parent: "normalMap "
|
|
2572
2687
|
},
|
|
2573
2688
|
displacementScale: {
|
|
2574
2689
|
dir: "displacement",
|
|
@@ -2588,7 +2703,8 @@ const meshStandardMaterialProperties = {
|
|
|
2588
2703
|
dir: "envMap",
|
|
2589
2704
|
min: 0,
|
|
2590
2705
|
max: 1,
|
|
2591
|
-
step: 0.01
|
|
2706
|
+
step: 0.01,
|
|
2707
|
+
parent: "envMap"
|
|
2592
2708
|
},
|
|
2593
2709
|
lightMap: {
|
|
2594
2710
|
dir: "lightMap"
|
|
@@ -2604,6 +2720,116 @@ const meshStandardMaterialProperties = {
|
|
|
2604
2720
|
for(let k in meshStandardMaterialProperties){
|
|
2605
2721
|
core.property(meshStandardMaterialProperties[k])(three.MeshStandardMaterial.prototype, k);
|
|
2606
2722
|
}
|
|
2723
|
+
const meshPhysicalMaterialProperties = {
|
|
2724
|
+
ior: {
|
|
2725
|
+
min: 0,
|
|
2726
|
+
max: 10,
|
|
2727
|
+
step: 0.01
|
|
2728
|
+
},
|
|
2729
|
+
anisotropy: {
|
|
2730
|
+
min: 0,
|
|
2731
|
+
max: 10,
|
|
2732
|
+
step: 0.01
|
|
2733
|
+
},
|
|
2734
|
+
clearcoat: {
|
|
2735
|
+
dir: "clearcoat"
|
|
2736
|
+
},
|
|
2737
|
+
clearcoatMap: {
|
|
2738
|
+
dir: "clearcoat",
|
|
2739
|
+
min: 0,
|
|
2740
|
+
max: 1,
|
|
2741
|
+
step: 0.01
|
|
2742
|
+
},
|
|
2743
|
+
clearcoatRoughness: {
|
|
2744
|
+
dir: "clearcoat",
|
|
2745
|
+
min: 0,
|
|
2746
|
+
max: 1,
|
|
2747
|
+
step: 0.01
|
|
2748
|
+
},
|
|
2749
|
+
clearcoatNormalScale: {
|
|
2750
|
+
dir: "clearcoat",
|
|
2751
|
+
step: 0.01
|
|
2752
|
+
},
|
|
2753
|
+
clearcoatNormalMap: {
|
|
2754
|
+
dir: "clearcoat"
|
|
2755
|
+
},
|
|
2756
|
+
iridescence: {
|
|
2757
|
+
dir: "iridescence",
|
|
2758
|
+
min: 0,
|
|
2759
|
+
max: 1,
|
|
2760
|
+
step: 0.01
|
|
2761
|
+
},
|
|
2762
|
+
iridescenceMap: {
|
|
2763
|
+
dir: "iridescence"
|
|
2764
|
+
},
|
|
2765
|
+
iridescenceIOR: {
|
|
2766
|
+
dir: "iridescence",
|
|
2767
|
+
step: 0.01
|
|
2768
|
+
},
|
|
2769
|
+
iridescenceThicknessRange: {
|
|
2770
|
+
dir: "iridescence"
|
|
2771
|
+
},
|
|
2772
|
+
iridescenceThicknessMap: {
|
|
2773
|
+
dir: "iridescence"
|
|
2774
|
+
},
|
|
2775
|
+
sheen: {
|
|
2776
|
+
dir: "sheen"
|
|
2777
|
+
},
|
|
2778
|
+
sheenColor: {
|
|
2779
|
+
dir: "sheen"
|
|
2780
|
+
},
|
|
2781
|
+
sheenColorMap: {
|
|
2782
|
+
dir: "sheen"
|
|
2783
|
+
},
|
|
2784
|
+
sheenRoughness: {
|
|
2785
|
+
dir: "sheen",
|
|
2786
|
+
min: 0,
|
|
2787
|
+
max: 1,
|
|
2788
|
+
step: 0.01
|
|
2789
|
+
},
|
|
2790
|
+
sheenRoughnessMap: {
|
|
2791
|
+
dir: "sheen"
|
|
2792
|
+
},
|
|
2793
|
+
transmission: {
|
|
2794
|
+
dir: "transmission"
|
|
2795
|
+
},
|
|
2796
|
+
transmissionMap: {
|
|
2797
|
+
dir: "transmission"
|
|
2798
|
+
},
|
|
2799
|
+
thickness: {
|
|
2800
|
+
dir: "thickness",
|
|
2801
|
+
min: 0,
|
|
2802
|
+
max: 1,
|
|
2803
|
+
step: 0.01
|
|
2804
|
+
},
|
|
2805
|
+
thicknessMap: {
|
|
2806
|
+
dir: "thickness"
|
|
2807
|
+
},
|
|
2808
|
+
attenuationDistance: {
|
|
2809
|
+
dir: "attenuation"
|
|
2810
|
+
},
|
|
2811
|
+
attenuationColor: {
|
|
2812
|
+
dir: "attenuation"
|
|
2813
|
+
},
|
|
2814
|
+
specularIntensity: {
|
|
2815
|
+
dir: "specular",
|
|
2816
|
+
min: 0,
|
|
2817
|
+
max: 1,
|
|
2818
|
+
step: 0.01
|
|
2819
|
+
},
|
|
2820
|
+
specularIntensityMap: {
|
|
2821
|
+
dir: "specular"
|
|
2822
|
+
},
|
|
2823
|
+
specularColor: {
|
|
2824
|
+
dir: "specular"
|
|
2825
|
+
},
|
|
2826
|
+
specularColorMap: {
|
|
2827
|
+
dir: "specular"
|
|
2828
|
+
}
|
|
2829
|
+
};
|
|
2830
|
+
for(let k in meshPhysicalMaterialProperties){
|
|
2831
|
+
core.property(meshPhysicalMaterialProperties[k])(three.MeshPhysicalMaterial.prototype, k);
|
|
2832
|
+
}
|
|
2607
2833
|
|
|
2608
2834
|
/**
|
|
2609
2835
|
* @author mrdoob / http://mrdoob.com/
|
|
@@ -2653,7 +2879,7 @@ var Panel = function(name, fg, bg) {
|
|
|
2653
2879
|
}
|
|
2654
2880
|
};
|
|
2655
2881
|
};
|
|
2656
|
-
var Stats = function() {
|
|
2882
|
+
var Stats$1 = function() {
|
|
2657
2883
|
var mode = 0;
|
|
2658
2884
|
var container = document.createElement('div');
|
|
2659
2885
|
container.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
|
|
@@ -2712,8 +2938,19 @@ var Stats = function() {
|
|
|
2712
2938
|
};
|
|
2713
2939
|
};
|
|
2714
2940
|
|
|
2715
|
-
class
|
|
2716
|
-
|
|
2941
|
+
class Stats extends core.Mount {
|
|
2942
|
+
onLoad() {
|
|
2943
|
+
this._stats.addPanel(this._dcPanel);
|
|
2944
|
+
this._stats.addPanel(this._texPanel);
|
|
2945
|
+
this._stats.addPanel(this._triPanel);
|
|
2946
|
+
this._stats.addPanel(this._prgPanel);
|
|
2947
|
+
this._stats.showPanel(0);
|
|
2948
|
+
document.body.appendChild(this._stats.dom);
|
|
2949
|
+
}
|
|
2950
|
+
onDestroy() {
|
|
2951
|
+
document.body.removeChild(this._stats.dom);
|
|
2952
|
+
}
|
|
2953
|
+
update(dt) {
|
|
2717
2954
|
const info = this.viewer.renderer.info;
|
|
2718
2955
|
this._dcPanel.update(info.render.calls, 300);
|
|
2719
2956
|
this._triPanel.update(info.render.triangles, 500000);
|
|
@@ -2721,28 +2958,38 @@ class StatsPlugin extends core.Plugin {
|
|
|
2721
2958
|
this._prgPanel.update(info.programs.length, 50);
|
|
2722
2959
|
this._stats.update();
|
|
2723
2960
|
}
|
|
2724
|
-
constructor(){
|
|
2725
|
-
super();
|
|
2726
|
-
this._stats = new Stats();
|
|
2961
|
+
constructor(...args){
|
|
2962
|
+
super(...args);
|
|
2963
|
+
this._stats = new Stats$1();
|
|
2727
2964
|
this._dcPanel = new Panel('DC', '#ff8', '#221');
|
|
2728
2965
|
this._triPanel = new Panel("TRI", '#ff8', '#221');
|
|
2729
2966
|
this._texPanel = new Panel('TEX', '#ff8', '#221');
|
|
2730
2967
|
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
2968
|
}
|
|
2743
2969
|
}
|
|
2744
2970
|
|
|
2971
|
+
class BoxProjectionHelper extends core.Mount {
|
|
2972
|
+
onLoad() {
|
|
2973
|
+
this._box3 = new three.Box3();
|
|
2974
|
+
this._target = this.viewer.mount(core.BoxProjection);
|
|
2975
|
+
this._helper = this.viewer.add(new three.Box3Helper(this._box3));
|
|
2976
|
+
}
|
|
2977
|
+
onEnable() {
|
|
2978
|
+
this._helper.visible = true;
|
|
2979
|
+
}
|
|
2980
|
+
onDisable() {
|
|
2981
|
+
this._helper.visible = false;
|
|
2982
|
+
}
|
|
2983
|
+
update(dt) {
|
|
2984
|
+
const { center, boxMin, boxMax } = this._target;
|
|
2985
|
+
this._box3.min.copy(center).add(boxMin);
|
|
2986
|
+
this._box3.max.copy(center).add(boxMax);
|
|
2987
|
+
this._helper.updateMatrixWorld();
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
exports.BoxProjectionHelper = BoxProjectionHelper;
|
|
2745
2992
|
exports.GUI = GUI;
|
|
2746
|
-
exports.
|
|
2747
|
-
exports.
|
|
2993
|
+
exports.Inspector = Inspector;
|
|
2994
|
+
exports.Stats = Stats;
|
|
2748
2995
|
//# sourceMappingURL=main.js.map
|