@xviewer.js/debug 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +58 -77
- package/dist/main.js.map +1 -1
- package/dist/module.js +59 -78
- 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;
|
|
@@ -2530,6 +2500,29 @@ __decorate([
|
|
|
2530
2500
|
step: 0.01
|
|
2531
2501
|
})
|
|
2532
2502
|
], ViewerExtension.prototype, "backgroundBlurriness", null);
|
|
2503
|
+
const materialProperties = {
|
|
2504
|
+
visible: {},
|
|
2505
|
+
transparent: {},
|
|
2506
|
+
side: {
|
|
2507
|
+
value: {
|
|
2508
|
+
FrontSide: 0,
|
|
2509
|
+
BackSide: 1,
|
|
2510
|
+
DoubleSide: 2
|
|
2511
|
+
}
|
|
2512
|
+
},
|
|
2513
|
+
color: {
|
|
2514
|
+
dir: "diffuse"
|
|
2515
|
+
},
|
|
2516
|
+
opacity: {
|
|
2517
|
+
dir: "diffuse",
|
|
2518
|
+
min: 0,
|
|
2519
|
+
max: 1,
|
|
2520
|
+
step: 0.01
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
for(let k in materialProperties){
|
|
2524
|
+
core.property(materialProperties[k])(three.Material.prototype, k);
|
|
2525
|
+
}
|
|
2533
2526
|
const meshBasicMaterislProperties = {
|
|
2534
2527
|
map: {
|
|
2535
2528
|
dir: "diffuse"
|
|
@@ -2562,18 +2555,6 @@ for(let k in meshBasicMaterislProperties){
|
|
|
2562
2555
|
core.property(meshBasicMaterislProperties[k])(three.MeshBasicMaterial.prototype, k);
|
|
2563
2556
|
}
|
|
2564
2557
|
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
2558
|
opacity: {
|
|
2578
2559
|
dir: "diffuse",
|
|
2579
2560
|
min: 0,
|