@xviewer.js/debug 1.0.5-alhpa.13 → 1.0.5-alhpa.15
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.cjs +113 -170
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +115 -172
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
- package/types/Inspector.d.ts +1 -3
package/dist/main.cjs
CHANGED
|
@@ -2651,147 +2651,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
2651
2651
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2652
2652
|
};
|
|
2653
2653
|
|
|
2654
|
-
class ViewerHelper extends core.ObjectInstance {
|
|
2655
|
-
get outputColorSpace() {
|
|
2656
|
-
return this._renderer.outputColorSpace;
|
|
2657
|
-
}
|
|
2658
|
-
set outputColorSpace(v) {
|
|
2659
|
-
this._renderer.outputColorSpace = v;
|
|
2660
|
-
}
|
|
2661
|
-
get toneMapping() {
|
|
2662
|
-
return this._renderer.toneMapping;
|
|
2663
|
-
}
|
|
2664
|
-
set toneMapping(v) {
|
|
2665
|
-
this._renderer.toneMapping = v;
|
|
2666
|
-
}
|
|
2667
|
-
get toneMappingExposure() {
|
|
2668
|
-
return this._renderer.toneMappingExposure;
|
|
2669
|
-
}
|
|
2670
|
-
set toneMappingExposure(v) {
|
|
2671
|
-
this._renderer.toneMappingExposure = v;
|
|
2672
|
-
}
|
|
2673
|
-
get shadows() {
|
|
2674
|
-
return this._renderer.shadowMap.enabled;
|
|
2675
|
-
}
|
|
2676
|
-
set shadows(v) {
|
|
2677
|
-
this._renderer.shadowMap.enabled = v;
|
|
2678
|
-
}
|
|
2679
|
-
get backgroundBlurriness() {
|
|
2680
|
-
return this._scene.backgroundBlurriness;
|
|
2681
|
-
}
|
|
2682
|
-
set backgroundBlurriness(v) {
|
|
2683
|
-
this._scene.backgroundBlurriness = v;
|
|
2684
|
-
}
|
|
2685
|
-
get environment() {
|
|
2686
|
-
return this._scene.environment;
|
|
2687
|
-
}
|
|
2688
|
-
set environment(v) {
|
|
2689
|
-
this._scene.environment = v;
|
|
2690
|
-
}
|
|
2691
|
-
get environmentIntensity() {
|
|
2692
|
-
return this._scene.environmentIntensity;
|
|
2693
|
-
}
|
|
2694
|
-
set environmentIntensity(v) {
|
|
2695
|
-
this._scene.environmentIntensity = v;
|
|
2696
|
-
}
|
|
2697
|
-
get environmentRotation() {
|
|
2698
|
-
return this._scene.environmentRotation;
|
|
2699
|
-
}
|
|
2700
|
-
set environmentRotation(v) {
|
|
2701
|
-
this._scene.environmentRotation.copy(v);
|
|
2702
|
-
}
|
|
2703
|
-
get background() {
|
|
2704
|
-
return this._scene.background;
|
|
2705
|
-
}
|
|
2706
|
-
set background(v) {
|
|
2707
|
-
this._scene.background = v;
|
|
2708
|
-
}
|
|
2709
|
-
get backgroundRotation() {
|
|
2710
|
-
return this._scene.backgroundRotation;
|
|
2711
|
-
}
|
|
2712
|
-
set backgroundRotation(v) {
|
|
2713
|
-
this._scene.backgroundRotation.copy(v);
|
|
2714
|
-
}
|
|
2715
|
-
get targetFrameRate() {
|
|
2716
|
-
return this._viewer.targetFrameRate;
|
|
2717
|
-
}
|
|
2718
|
-
set targetFrameRate(v) {
|
|
2719
|
-
this._viewer.targetFrameRate = v;
|
|
2720
|
-
}
|
|
2721
|
-
constructor(viewer){
|
|
2722
|
-
super();
|
|
2723
|
-
this._viewer = viewer;
|
|
2724
|
-
this._scene = viewer.scene;
|
|
2725
|
-
this._renderer = viewer.renderer;
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
__decorate([
|
|
2729
|
-
core.property({
|
|
2730
|
-
value: {
|
|
2731
|
-
SRGBColorSpace: "srgb",
|
|
2732
|
-
LinearSRGBColorSpace: "srgb-linear",
|
|
2733
|
-
DisplayP3ColorSpace: "display-p3",
|
|
2734
|
-
LinearDisplayP3ColorSpace: "display-p3-linear"
|
|
2735
|
-
}
|
|
2736
|
-
})
|
|
2737
|
-
], ViewerHelper.prototype, "outputColorSpace", null);
|
|
2738
|
-
__decorate([
|
|
2739
|
-
core.property({
|
|
2740
|
-
value: {
|
|
2741
|
-
NoToneMapping: 0,
|
|
2742
|
-
LinearToneMapping: 1,
|
|
2743
|
-
ReinhardToneMapping: 2,
|
|
2744
|
-
CineonToneMapping: 3,
|
|
2745
|
-
ACESFilmicToneMapping: 4
|
|
2746
|
-
}
|
|
2747
|
-
})
|
|
2748
|
-
], ViewerHelper.prototype, "toneMapping", null);
|
|
2749
|
-
__decorate([
|
|
2750
|
-
core.property({
|
|
2751
|
-
min: 0,
|
|
2752
|
-
max: 10,
|
|
2753
|
-
step: 0.01
|
|
2754
|
-
})
|
|
2755
|
-
], ViewerHelper.prototype, "toneMappingExposure", null);
|
|
2756
|
-
__decorate([
|
|
2757
|
-
core.property
|
|
2758
|
-
], ViewerHelper.prototype, "shadows", null);
|
|
2759
|
-
__decorate([
|
|
2760
|
-
core.property({
|
|
2761
|
-
min: 0,
|
|
2762
|
-
max: 1,
|
|
2763
|
-
step: 0.01
|
|
2764
|
-
})
|
|
2765
|
-
], ViewerHelper.prototype, "backgroundBlurriness", null);
|
|
2766
|
-
__decorate([
|
|
2767
|
-
core.property({
|
|
2768
|
-
value: new three.Texture()
|
|
2769
|
-
})
|
|
2770
|
-
], ViewerHelper.prototype, "environment", null);
|
|
2771
|
-
__decorate([
|
|
2772
|
-
core.property({
|
|
2773
|
-
min: 0,
|
|
2774
|
-
max: 5,
|
|
2775
|
-
step: 0.01
|
|
2776
|
-
})
|
|
2777
|
-
], ViewerHelper.prototype, "environmentIntensity", null);
|
|
2778
|
-
__decorate([
|
|
2779
|
-
core.property({
|
|
2780
|
-
step: 0.01
|
|
2781
|
-
})
|
|
2782
|
-
], ViewerHelper.prototype, "environmentRotation", null);
|
|
2783
|
-
__decorate([
|
|
2784
|
-
core.property
|
|
2785
|
-
], ViewerHelper.prototype, "background", null);
|
|
2786
|
-
__decorate([
|
|
2787
|
-
core.property({
|
|
2788
|
-
step: 0.01
|
|
2789
|
-
})
|
|
2790
|
-
], ViewerHelper.prototype, "backgroundRotation", null);
|
|
2791
|
-
__decorate([
|
|
2792
|
-
core.property
|
|
2793
|
-
], ViewerHelper.prototype, "targetFrameRate", null);
|
|
2794
|
-
|
|
2795
2654
|
const vert_Sprite = `
|
|
2796
2655
|
uniform vec4 u_transform;
|
|
2797
2656
|
uniform vec4 u_resolution;
|
|
@@ -2828,54 +2687,49 @@ class Inspector extends core.Component {
|
|
|
2828
2687
|
width: 310,
|
|
2829
2688
|
title: "Inspector"
|
|
2830
2689
|
}).close();
|
|
2831
|
-
this._tree = this._gui.addSceneTree(this.viewer.scene);
|
|
2832
2690
|
this._gui.addFolder("Viewer").close().hide();
|
|
2833
2691
|
this._gui.addFolder("Component").close().hide();
|
|
2834
2692
|
this._gui.addFolder("Material").close().hide();
|
|
2835
2693
|
this._gui.addFolder("Other").close().hide();
|
|
2836
|
-
this._inspect(
|
|
2694
|
+
this._inspect(viewerProperites(this.viewer));
|
|
2837
2695
|
}
|
|
2838
2696
|
onDestroy() {
|
|
2839
|
-
if (this._tree) {
|
|
2840
|
-
this._tree.destroy();
|
|
2841
|
-
}
|
|
2842
2697
|
this._gui.destroy();
|
|
2843
2698
|
this._refCntMap.clear();
|
|
2844
2699
|
this._targetMap.clear();
|
|
2845
2700
|
}
|
|
2846
2701
|
update(dt) {
|
|
2847
2702
|
this._gui.update();
|
|
2848
|
-
if (this._tree) {
|
|
2849
|
-
this._tree.update();
|
|
2850
|
-
}
|
|
2851
2703
|
this._updateFolders();
|
|
2852
2704
|
}
|
|
2853
2705
|
resize(width, height) {
|
|
2854
2706
|
this._spriteUniforms.u_resolution.value.set(width, height, 1 / width, 1 / height);
|
|
2855
2707
|
}
|
|
2856
2708
|
_renderSprite(texture, w, h) {
|
|
2709
|
+
const viewer = this.viewer;
|
|
2857
2710
|
const resolution = this._spriteUniforms.u_resolution.value;
|
|
2858
2711
|
this._camera.viewport.set(0, resolution.y - h, w, h);
|
|
2859
2712
|
this._spriteUniforms.u_transform.value.set(0, resolution.y - h, w, h);
|
|
2860
2713
|
this._spriteUniforms.u_texture.value = texture;
|
|
2861
|
-
|
|
2862
|
-
return
|
|
2714
|
+
viewer.render(null, this._sprite, this._camera, 0, 0);
|
|
2715
|
+
return viewer.canvas;
|
|
2863
2716
|
}
|
|
2864
2717
|
_updateFolders() {
|
|
2718
|
+
const viewer = this.viewer;
|
|
2865
2719
|
const refCntMap = this._refCntMap;
|
|
2866
2720
|
const setState = (v)=>{
|
|
2867
2721
|
if (refCntMap.get(v) === -1) refCntMap.set(v, 0);
|
|
2868
2722
|
if (refCntMap.get(v) === undefined) refCntMap.set(v, 1);
|
|
2869
2723
|
};
|
|
2870
2724
|
refCntMap.forEach((_, k, map)=>map.set(k, -1));
|
|
2871
|
-
|
|
2872
|
-
scene.traverse((item)=>{
|
|
2725
|
+
viewer.scene.traverse((item)=>{
|
|
2873
2726
|
if (item.material) {
|
|
2874
2727
|
if (Array.isArray(item.material)) item.material.forEach(setState);
|
|
2875
2728
|
else setState(item.material);
|
|
2876
2729
|
}
|
|
2877
2730
|
});
|
|
2878
|
-
componentManager.traverseComponents(setState);
|
|
2731
|
+
viewer.componentManager.traverseComponents(setState);
|
|
2732
|
+
this.others.forEach(setState);
|
|
2879
2733
|
refCntMap.forEach((v, k, map)=>{
|
|
2880
2734
|
if (v === 1) {
|
|
2881
2735
|
this._inspect(k);
|
|
@@ -2888,11 +2742,14 @@ class Inspector extends core.Component {
|
|
|
2888
2742
|
}
|
|
2889
2743
|
_getPropertiesList(target) {
|
|
2890
2744
|
const list = [];
|
|
2891
|
-
|
|
2892
|
-
if (props) {
|
|
2745
|
+
const addSortedProps = (props, target)=>{
|
|
2893
2746
|
const values = propsSort(props);
|
|
2894
2747
|
this._targetMap.set(values, target);
|
|
2895
2748
|
list.push(values);
|
|
2749
|
+
};
|
|
2750
|
+
let props = core.PropertyManager._getMergedProperties(target.constructor);
|
|
2751
|
+
if (props) {
|
|
2752
|
+
addSortedProps(props, target);
|
|
2896
2753
|
}
|
|
2897
2754
|
if (target instanceof three.ShaderMaterial) {
|
|
2898
2755
|
props = Object.create(null);
|
|
@@ -2906,9 +2763,7 @@ class Inspector extends core.Component {
|
|
|
2906
2763
|
dir: "uniforms"
|
|
2907
2764
|
};
|
|
2908
2765
|
});
|
|
2909
|
-
|
|
2910
|
-
this._targetMap.set(values, uniforms);
|
|
2911
|
-
list.push(values);
|
|
2766
|
+
addSortedProps(props, uniforms);
|
|
2912
2767
|
}
|
|
2913
2768
|
return list;
|
|
2914
2769
|
}
|
|
@@ -2916,17 +2771,19 @@ class Inspector extends core.Component {
|
|
|
2916
2771
|
let propsList = this._getPropertiesList(target);
|
|
2917
2772
|
if (propsList.length === 0) return;
|
|
2918
2773
|
let gui = this._gui;
|
|
2919
|
-
if (target
|
|
2774
|
+
if (target.type === "Viewer") {
|
|
2920
2775
|
gui = gui.getFolder("Viewer").show();
|
|
2921
|
-
} else if (target instanceof core.Component) {
|
|
2922
|
-
gui = gui.getFolder("Component").show();
|
|
2923
|
-
} else if (target instanceof three.Material) {
|
|
2924
|
-
gui = gui.getFolder("Material").show();
|
|
2925
2776
|
} else {
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2777
|
+
if (target instanceof core.Component) {
|
|
2778
|
+
gui = gui.getFolder("Component").show();
|
|
2779
|
+
} else if (target instanceof three.Material) {
|
|
2780
|
+
gui = gui.getFolder("Material").show();
|
|
2781
|
+
} else {
|
|
2782
|
+
gui = gui.getFolder("Other").show();
|
|
2783
|
+
}
|
|
2784
|
+
const name = targetName(target);
|
|
2785
|
+
const uuid = target.uuid || name;
|
|
2786
|
+
gui = gui.getFolder(uuid) || gui.addFolder(name, uuid).close();
|
|
2930
2787
|
}
|
|
2931
2788
|
this._addGUI(gui, propsList, target);
|
|
2932
2789
|
return target;
|
|
@@ -3008,10 +2865,12 @@ class Inspector extends core.Component {
|
|
|
3008
2865
|
u_resolution: {
|
|
3009
2866
|
value: new three.Vector4()
|
|
3010
2867
|
}
|
|
3011
|
-
}, this._refCntMap = new Map(), this._targetMap = new Map();
|
|
2868
|
+
}, this._refCntMap = new Map(), this._targetMap = new Map(), this.others = [];
|
|
3012
2869
|
}
|
|
3013
2870
|
}
|
|
3014
|
-
Inspector
|
|
2871
|
+
Inspector = __decorate([
|
|
2872
|
+
core.single()
|
|
2873
|
+
], Inspector);
|
|
3015
2874
|
function targetName(target) {
|
|
3016
2875
|
return target.name || target.constructor.name || target.type;
|
|
3017
2876
|
}
|
|
@@ -3022,6 +2881,87 @@ function propsSort(props) {
|
|
|
3022
2881
|
const array1 = values.filter((v)=>v[1].dir).sort((a, b)=>order(a[1]) - order(b[1]));
|
|
3023
2882
|
return array0.concat(array1);
|
|
3024
2883
|
}
|
|
2884
|
+
function viewerProperites(viewer) {
|
|
2885
|
+
const properties = {
|
|
2886
|
+
outputColorSpace: {
|
|
2887
|
+
get: ()=>viewer.renderer.outputColorSpace,
|
|
2888
|
+
set: (v)=>viewer.renderer.outputColorSpace = v,
|
|
2889
|
+
value: {
|
|
2890
|
+
SRGBColorSpace: "srgb",
|
|
2891
|
+
LinearSRGBColorSpace: "srgb-linear",
|
|
2892
|
+
DisplayP3ColorSpace: "display-p3",
|
|
2893
|
+
LinearDisplayP3ColorSpace: "display-p3-linear"
|
|
2894
|
+
}
|
|
2895
|
+
},
|
|
2896
|
+
toneMapping: {
|
|
2897
|
+
get: ()=>viewer.renderer.toneMapping,
|
|
2898
|
+
set: (v)=>viewer.renderer.toneMapping = v,
|
|
2899
|
+
value: {
|
|
2900
|
+
NoToneMapping: 0,
|
|
2901
|
+
LinearToneMapping: 1,
|
|
2902
|
+
ReinhardToneMapping: 2,
|
|
2903
|
+
CineonToneMapping: 3,
|
|
2904
|
+
ACESFilmicToneMapping: 4
|
|
2905
|
+
}
|
|
2906
|
+
},
|
|
2907
|
+
toneMappingExposure: {
|
|
2908
|
+
get: ()=>viewer.renderer.toneMappingExposure,
|
|
2909
|
+
set: (v)=>viewer.renderer.toneMappingExposure = v,
|
|
2910
|
+
min: 0,
|
|
2911
|
+
max: 10
|
|
2912
|
+
},
|
|
2913
|
+
shadows: {
|
|
2914
|
+
get: ()=>viewer.renderer.shadowMap.enabled,
|
|
2915
|
+
set: (v)=>viewer.renderer.shadowMap.enabled = v
|
|
2916
|
+
},
|
|
2917
|
+
environment: {
|
|
2918
|
+
get: ()=>viewer.scene.environment,
|
|
2919
|
+
set: (v)=>viewer.scene.environment = v,
|
|
2920
|
+
value: new three.Texture()
|
|
2921
|
+
},
|
|
2922
|
+
environmentIntensity: {
|
|
2923
|
+
get: ()=>viewer.scene.environmentIntensity,
|
|
2924
|
+
set: (v)=>viewer.scene.environmentIntensity = v,
|
|
2925
|
+
min: 0,
|
|
2926
|
+
max: 5
|
|
2927
|
+
},
|
|
2928
|
+
environmentRotation: {
|
|
2929
|
+
get: ()=>viewer.scene.environmentRotation,
|
|
2930
|
+
set: (v)=>viewer.scene.environmentRotation = v
|
|
2931
|
+
},
|
|
2932
|
+
background: {
|
|
2933
|
+
get: ()=>viewer.scene.background,
|
|
2934
|
+
set: (v)=>viewer.scene.background = v
|
|
2935
|
+
},
|
|
2936
|
+
backgroundRotation: {
|
|
2937
|
+
get: ()=>viewer.scene.backgroundRotation,
|
|
2938
|
+
set: (v)=>viewer.scene.backgroundRotation = v
|
|
2939
|
+
},
|
|
2940
|
+
backgroundBlurriness: {
|
|
2941
|
+
get: ()=>viewer.scene.backgroundBlurriness,
|
|
2942
|
+
set: (v)=>viewer.scene.backgroundBlurriness = v,
|
|
2943
|
+
min: 0,
|
|
2944
|
+
max: 1
|
|
2945
|
+
},
|
|
2946
|
+
targetFrameRate: {
|
|
2947
|
+
get: ()=>viewer.targetFrameRate,
|
|
2948
|
+
set: (v)=>viewer.targetFrameRate = v
|
|
2949
|
+
}
|
|
2950
|
+
};
|
|
2951
|
+
const wrapper = Object.assign(Object.create((function() {}).prototype), {
|
|
2952
|
+
name: "Viewer",
|
|
2953
|
+
type: "Viewer"
|
|
2954
|
+
});
|
|
2955
|
+
for(let k in properties){
|
|
2956
|
+
const prop = properties[k];
|
|
2957
|
+
Object.defineProperty(wrapper, k, {
|
|
2958
|
+
get: prop.get,
|
|
2959
|
+
set: prop.set
|
|
2960
|
+
});
|
|
2961
|
+
core.property(prop)(wrapper, k);
|
|
2962
|
+
}
|
|
2963
|
+
return wrapper;
|
|
2964
|
+
}
|
|
3025
2965
|
const materialProperties = {
|
|
3026
2966
|
visible: {
|
|
3027
2967
|
order: 1
|
|
@@ -3417,6 +3357,9 @@ class Stats extends core.Component {
|
|
|
3417
3357
|
super(...args), this._stats = new Stats$1(), this._dcPanel = new Panel('DC', '#ff8', '#221'), this._triPanel = new Panel("TRI", '#ff8', '#221'), this._texPanel = new Panel('TEX', '#ff8', '#221'), this._prgPanel = new Panel('PRG', '#ff8', '#221');
|
|
3418
3358
|
}
|
|
3419
3359
|
}
|
|
3360
|
+
Stats = __decorate([
|
|
3361
|
+
core.single()
|
|
3362
|
+
], Stats);
|
|
3420
3363
|
|
|
3421
3364
|
exports.GUI = GUI;
|
|
3422
3365
|
exports.Inspector = Inspector;
|