@xviewer.js/debug 1.0.0-alpha.5 → 1.0.0-alpha.50
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 +184 -78
- package/dist/main.js.map +1 -1
- package/dist/module.js +185 -79
- package/dist/module.js.map +1 -1
- package/package.json +18 -21
- package/types/gui/controllers/NumberController.d.ts +1 -1
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MeshBasicMaterial, MeshStandardMaterial,
|
|
1
|
+
import { Material, MeshBasicMaterial, MeshStandardMaterial, MeshPhysicalMaterial, ShaderMaterial } from 'three';
|
|
2
2
|
import { property, Plugin, PropertyManager, Component, ObjectInstance } from '@xviewer.js/core';
|
|
3
3
|
|
|
4
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}}
|
|
@@ -449,14 +449,14 @@ class NumberController extends Controller {
|
|
|
449
449
|
return false;
|
|
450
450
|
}
|
|
451
451
|
updateDisplay() {
|
|
452
|
-
const value = this.getValue();
|
|
452
|
+
const value = this._snap(this.getValue());
|
|
453
453
|
if (this._hasSlider) {
|
|
454
454
|
let percent = (value - this._min) / (this._max - this._min);
|
|
455
455
|
percent = Math.max(0, Math.min(percent, 1));
|
|
456
456
|
this.$fill.style.width = percent * 100 + '%';
|
|
457
457
|
}
|
|
458
458
|
if (!this._inputFocused) {
|
|
459
|
-
this.$input.value = value;
|
|
459
|
+
this.$input.value = "" + value;
|
|
460
460
|
}
|
|
461
461
|
return this;
|
|
462
462
|
}
|
|
@@ -929,67 +929,34 @@ class ColorController extends Controller {
|
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
|
|
932
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
933
|
-
try {
|
|
934
|
-
var info = gen[key](arg);
|
|
935
|
-
var value = info.value;
|
|
936
|
-
} catch (error) {
|
|
937
|
-
reject(error);
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
if (info.done) resolve(value);
|
|
941
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
942
|
-
}
|
|
943
|
-
function _async_to_generator(fn) {
|
|
944
|
-
return function() {
|
|
945
|
-
var self = this, args = arguments;
|
|
946
|
-
|
|
947
|
-
return new Promise(function(resolve, reject) {
|
|
948
|
-
var gen = fn.apply(self, args);
|
|
949
|
-
|
|
950
|
-
function _next(value) {
|
|
951
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
function _throw(err) {
|
|
955
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
_next(undefined);
|
|
959
|
-
});
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
|
|
963
932
|
class ImageController extends Controller {
|
|
964
|
-
static toDataURL(img) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
return url;
|
|
988
|
-
}
|
|
933
|
+
static async toDataURL(img) {
|
|
934
|
+
if (img instanceof HTMLImageElement) {
|
|
935
|
+
return img.src;
|
|
936
|
+
} else {
|
|
937
|
+
if (img) {
|
|
938
|
+
let url = ImageController._imageMap.get(img);
|
|
939
|
+
if (url) return url;
|
|
940
|
+
const w = Math.min(img.width, 256);
|
|
941
|
+
const h = Math.min(img.height, 256);
|
|
942
|
+
if (ImageController._context == null) {
|
|
943
|
+
ImageController._context = document.createElement('canvas').getContext("2d");
|
|
944
|
+
}
|
|
945
|
+
ImageController._context.canvas.width = w;
|
|
946
|
+
ImageController._context.canvas.height = h;
|
|
947
|
+
if (img.data) {
|
|
948
|
+
let imageData = ImageController._context.createImageData(img.width, img.height);
|
|
949
|
+
imageData.data.set(img.data);
|
|
950
|
+
img = await createImageBitmap(imageData);
|
|
951
|
+
}
|
|
952
|
+
if (img instanceof ImageBitmap) {
|
|
953
|
+
ImageController._context.drawImage(img, 0, 0, img.width, img.height, 0, 0, w, h);
|
|
954
|
+
ImageController._imageMap.set(img, url = ImageController._context.canvas.toDataURL());
|
|
955
|
+
return url;
|
|
989
956
|
}
|
|
990
|
-
return "";
|
|
991
957
|
}
|
|
992
|
-
|
|
958
|
+
return "";
|
|
959
|
+
}
|
|
993
960
|
}
|
|
994
961
|
updateDisplay() {
|
|
995
962
|
ImageController.toDataURL(this.getValue()).then((url)=>this.$img.src = url);
|
|
@@ -1092,8 +1059,8 @@ class UINumber extends UIElement {
|
|
|
1092
1059
|
return this;
|
|
1093
1060
|
}
|
|
1094
1061
|
updateDisplay() {
|
|
1095
|
-
let value = this.getValue();
|
|
1096
|
-
this.dom.value = "" +
|
|
1062
|
+
let value = this._snap(this.getValue());
|
|
1063
|
+
this.dom.value = "" + value;
|
|
1097
1064
|
if (this.unit !== '') this.dom.value += ' ' + this.unit;
|
|
1098
1065
|
}
|
|
1099
1066
|
_getImplicitStep(value) {
|
|
@@ -2322,7 +2289,10 @@ class InspectorPlugin extends Plugin {
|
|
|
2322
2289
|
}
|
|
2323
2290
|
_updateFolders() {
|
|
2324
2291
|
const statesMap = this._statesMap;
|
|
2325
|
-
const setState = (v)=>
|
|
2292
|
+
const setState = (v)=>{
|
|
2293
|
+
if (statesMap.get(v) === -1) statesMap.set(v, 0);
|
|
2294
|
+
if (statesMap.get(v) === undefined) statesMap.set(v, 1);
|
|
2295
|
+
};
|
|
2326
2296
|
statesMap.forEach((_, k, map)=>map.set(k, -1));
|
|
2327
2297
|
this.viewer.traversePlugins(setState);
|
|
2328
2298
|
this.viewer.traverseComponents(setState);
|
|
@@ -2339,7 +2309,7 @@ class InspectorPlugin extends Plugin {
|
|
|
2339
2309
|
}
|
|
2340
2310
|
_getPropertiesList(target) {
|
|
2341
2311
|
const list = [];
|
|
2342
|
-
let props = PropertyManager._getMergedProperties(target);
|
|
2312
|
+
let props = PropertyManager._getMergedProperties(target.constructor);
|
|
2343
2313
|
if (props) {
|
|
2344
2314
|
list.push(props);
|
|
2345
2315
|
this._targetMap.set(props, target);
|
|
@@ -2398,7 +2368,7 @@ class InspectorPlugin extends Plugin {
|
|
|
2398
2368
|
if (prop.dir) {
|
|
2399
2369
|
folder = folder.getFolder(prop.dir) || folder.addFolder(prop.dir).close();
|
|
2400
2370
|
}
|
|
2401
|
-
if (PropertyManager._hasProperties(value)) {
|
|
2371
|
+
if (PropertyManager._hasProperties(value.constructor)) {
|
|
2402
2372
|
this._addPropsListGUI(folder, this._getPropertiesList(value), target, k);
|
|
2403
2373
|
}
|
|
2404
2374
|
const type = typeof value;
|
|
@@ -2484,8 +2454,15 @@ class ViewerExtension extends ObjectInstance {
|
|
|
2484
2454
|
set backgroundBlurriness(v) {
|
|
2485
2455
|
this._scene.backgroundBlurriness = v;
|
|
2486
2456
|
}
|
|
2457
|
+
get targetFrameRate() {
|
|
2458
|
+
return this._viewer.targetFrameRate;
|
|
2459
|
+
}
|
|
2460
|
+
set targetFrameRate(v) {
|
|
2461
|
+
this._viewer.targetFrameRate = v;
|
|
2462
|
+
}
|
|
2487
2463
|
constructor(viewer){
|
|
2488
2464
|
super();
|
|
2465
|
+
this._viewer = viewer;
|
|
2489
2466
|
this._scene = viewer.scene;
|
|
2490
2467
|
this._renderer = viewer.renderer;
|
|
2491
2468
|
}
|
|
@@ -2528,6 +2505,36 @@ __decorate([
|
|
|
2528
2505
|
step: 0.01
|
|
2529
2506
|
})
|
|
2530
2507
|
], ViewerExtension.prototype, "backgroundBlurriness", null);
|
|
2508
|
+
__decorate([
|
|
2509
|
+
property({
|
|
2510
|
+
min: 1,
|
|
2511
|
+
max: 120,
|
|
2512
|
+
step: 1
|
|
2513
|
+
})
|
|
2514
|
+
], ViewerExtension.prototype, "targetFrameRate", null);
|
|
2515
|
+
const materialProperties = {
|
|
2516
|
+
visible: {},
|
|
2517
|
+
transparent: {},
|
|
2518
|
+
side: {
|
|
2519
|
+
value: {
|
|
2520
|
+
FrontSide: 0,
|
|
2521
|
+
BackSide: 1,
|
|
2522
|
+
DoubleSide: 2
|
|
2523
|
+
}
|
|
2524
|
+
},
|
|
2525
|
+
color: {
|
|
2526
|
+
dir: "diffuse"
|
|
2527
|
+
},
|
|
2528
|
+
opacity: {
|
|
2529
|
+
dir: "diffuse",
|
|
2530
|
+
min: 0,
|
|
2531
|
+
max: 1,
|
|
2532
|
+
step: 0.01
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
for(let k in materialProperties){
|
|
2536
|
+
property(materialProperties[k])(Material.prototype, k);
|
|
2537
|
+
}
|
|
2531
2538
|
const meshBasicMaterislProperties = {
|
|
2532
2539
|
map: {
|
|
2533
2540
|
dir: "diffuse"
|
|
@@ -2560,18 +2567,6 @@ for(let k in meshBasicMaterislProperties){
|
|
|
2560
2567
|
property(meshBasicMaterislProperties[k])(MeshBasicMaterial.prototype, k);
|
|
2561
2568
|
}
|
|
2562
2569
|
const meshStandardMaterialProperties = {
|
|
2563
|
-
visible: {},
|
|
2564
|
-
transparent: {},
|
|
2565
|
-
side: {
|
|
2566
|
-
value: {
|
|
2567
|
-
FrontSide: 0,
|
|
2568
|
-
BackSide: 1,
|
|
2569
|
-
DoubleSide: 2
|
|
2570
|
-
}
|
|
2571
|
-
},
|
|
2572
|
-
color: {
|
|
2573
|
-
dir: "diffuse"
|
|
2574
|
-
},
|
|
2575
2570
|
opacity: {
|
|
2576
2571
|
dir: "diffuse",
|
|
2577
2572
|
min: 0,
|
|
@@ -2627,7 +2622,8 @@ const meshStandardMaterialProperties = {
|
|
|
2627
2622
|
},
|
|
2628
2623
|
normalScale: {
|
|
2629
2624
|
dir: "normal",
|
|
2630
|
-
parent: "normalMap"
|
|
2625
|
+
parent: "normalMap",
|
|
2626
|
+
step: 0.01
|
|
2631
2627
|
},
|
|
2632
2628
|
displacementScale: {
|
|
2633
2629
|
dir: "displacement",
|
|
@@ -2663,6 +2659,116 @@ const meshStandardMaterialProperties = {
|
|
|
2663
2659
|
for(let k in meshStandardMaterialProperties){
|
|
2664
2660
|
property(meshStandardMaterialProperties[k])(MeshStandardMaterial.prototype, k);
|
|
2665
2661
|
}
|
|
2662
|
+
const meshPhysicalMaterialProperties = {
|
|
2663
|
+
ior: {
|
|
2664
|
+
min: 0,
|
|
2665
|
+
max: 10,
|
|
2666
|
+
step: 0.01
|
|
2667
|
+
},
|
|
2668
|
+
anisotropy: {
|
|
2669
|
+
min: 0,
|
|
2670
|
+
max: 10,
|
|
2671
|
+
step: 0.01
|
|
2672
|
+
},
|
|
2673
|
+
clearcoat: {
|
|
2674
|
+
dir: "clearcoat"
|
|
2675
|
+
},
|
|
2676
|
+
clearcoatMap: {
|
|
2677
|
+
dir: "clearcoat",
|
|
2678
|
+
min: 0,
|
|
2679
|
+
max: 1,
|
|
2680
|
+
step: 0.01
|
|
2681
|
+
},
|
|
2682
|
+
clearcoatRoughness: {
|
|
2683
|
+
dir: "clearcoat",
|
|
2684
|
+
min: 0,
|
|
2685
|
+
max: 1,
|
|
2686
|
+
step: 0.01
|
|
2687
|
+
},
|
|
2688
|
+
clearcoatNormalScale: {
|
|
2689
|
+
dir: "clearcoat",
|
|
2690
|
+
step: 0.01
|
|
2691
|
+
},
|
|
2692
|
+
clearcoatNormalMap: {
|
|
2693
|
+
dir: "clearcoat"
|
|
2694
|
+
},
|
|
2695
|
+
iridescence: {
|
|
2696
|
+
dir: "iridescence",
|
|
2697
|
+
min: 0,
|
|
2698
|
+
max: 1,
|
|
2699
|
+
step: 0.01
|
|
2700
|
+
},
|
|
2701
|
+
iridescenceMap: {
|
|
2702
|
+
dir: "iridescence"
|
|
2703
|
+
},
|
|
2704
|
+
iridescenceIOR: {
|
|
2705
|
+
dir: "iridescence",
|
|
2706
|
+
step: 0.01
|
|
2707
|
+
},
|
|
2708
|
+
iridescenceThicknessRange: {
|
|
2709
|
+
dir: "iridescence"
|
|
2710
|
+
},
|
|
2711
|
+
iridescenceThicknessMap: {
|
|
2712
|
+
dir: "iridescence"
|
|
2713
|
+
},
|
|
2714
|
+
sheen: {
|
|
2715
|
+
dir: "sheen"
|
|
2716
|
+
},
|
|
2717
|
+
sheenColor: {
|
|
2718
|
+
dir: "sheen"
|
|
2719
|
+
},
|
|
2720
|
+
sheenColorMap: {
|
|
2721
|
+
dir: "sheen"
|
|
2722
|
+
},
|
|
2723
|
+
sheenRoughness: {
|
|
2724
|
+
dir: "sheen",
|
|
2725
|
+
min: 0,
|
|
2726
|
+
max: 1,
|
|
2727
|
+
step: 0.01
|
|
2728
|
+
},
|
|
2729
|
+
sheenRoughnessMap: {
|
|
2730
|
+
dir: "sheen"
|
|
2731
|
+
},
|
|
2732
|
+
transmission: {
|
|
2733
|
+
dir: "transmission"
|
|
2734
|
+
},
|
|
2735
|
+
transmissionMap: {
|
|
2736
|
+
dir: "transmission"
|
|
2737
|
+
},
|
|
2738
|
+
thickness: {
|
|
2739
|
+
dir: "thickness",
|
|
2740
|
+
min: 0,
|
|
2741
|
+
max: 1,
|
|
2742
|
+
step: 0.01
|
|
2743
|
+
},
|
|
2744
|
+
thicknessMap: {
|
|
2745
|
+
dir: "thickness"
|
|
2746
|
+
},
|
|
2747
|
+
attenuationDistance: {
|
|
2748
|
+
dir: "attenuation"
|
|
2749
|
+
},
|
|
2750
|
+
attenuationColor: {
|
|
2751
|
+
dir: "attenuation"
|
|
2752
|
+
},
|
|
2753
|
+
specularIntensity: {
|
|
2754
|
+
dir: "specular",
|
|
2755
|
+
min: 0,
|
|
2756
|
+
max: 1,
|
|
2757
|
+
step: 0.01
|
|
2758
|
+
},
|
|
2759
|
+
specularIntensityMap: {
|
|
2760
|
+
dir: "specular"
|
|
2761
|
+
},
|
|
2762
|
+
specularColor: {
|
|
2763
|
+
dir: "specular"
|
|
2764
|
+
},
|
|
2765
|
+
specularColorMap: {
|
|
2766
|
+
dir: "specular"
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
for(let k in meshPhysicalMaterialProperties){
|
|
2770
|
+
property(meshPhysicalMaterialProperties[k])(MeshPhysicalMaterial.prototype, k);
|
|
2771
|
+
}
|
|
2666
2772
|
|
|
2667
2773
|
/**
|
|
2668
2774
|
* @author mrdoob / http://mrdoob.com/
|