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