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