@thatopen/components 2.4.0-alpha.30 → 2.4.0-alpha.32
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/core/ConfigManager/src/configurator.d.ts +3 -4
- package/dist/core/Types/src/config-types.d.ts +5 -0
- package/dist/index.cjs +140 -100
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.mjs +3 -3
- package/dist/index.mjs +140 -100
- package/dist/namespace.d.ts +3798 -3794
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3858,6 +3858,97 @@ class DataMap extends Map {
|
|
|
3858
3858
|
}
|
|
3859
3859
|
class ComponentWithUI extends Component {
|
|
3860
3860
|
}
|
|
3861
|
+
class ControlsUtils {
|
|
3862
|
+
static isEntry(item) {
|
|
3863
|
+
const types = /* @__PURE__ */ new Set([
|
|
3864
|
+
"Boolean",
|
|
3865
|
+
"Color",
|
|
3866
|
+
"Text",
|
|
3867
|
+
"Number",
|
|
3868
|
+
"Select",
|
|
3869
|
+
"Vector3",
|
|
3870
|
+
"TextSet",
|
|
3871
|
+
"None"
|
|
3872
|
+
]);
|
|
3873
|
+
return types.has(item.type);
|
|
3874
|
+
}
|
|
3875
|
+
static copySchema(schema, copy = {}) {
|
|
3876
|
+
for (const name in schema) {
|
|
3877
|
+
const entry = schema[name];
|
|
3878
|
+
if (this.isEntry(entry)) {
|
|
3879
|
+
copy[name] = this.copyEntry(entry);
|
|
3880
|
+
} else {
|
|
3881
|
+
copy[name] = {};
|
|
3882
|
+
this.copySchema(entry, copy[name]);
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
return copy;
|
|
3886
|
+
}
|
|
3887
|
+
static copyEntry(controlEntry) {
|
|
3888
|
+
if (controlEntry.type === "Boolean") {
|
|
3889
|
+
const entry = controlEntry;
|
|
3890
|
+
return {
|
|
3891
|
+
type: entry.type,
|
|
3892
|
+
value: entry.value
|
|
3893
|
+
};
|
|
3894
|
+
}
|
|
3895
|
+
if (controlEntry.type === "Color") {
|
|
3896
|
+
const entry = controlEntry;
|
|
3897
|
+
return {
|
|
3898
|
+
type: entry.type,
|
|
3899
|
+
value: entry.value.clone()
|
|
3900
|
+
};
|
|
3901
|
+
}
|
|
3902
|
+
if (controlEntry.type === "Text") {
|
|
3903
|
+
const entry = controlEntry;
|
|
3904
|
+
return {
|
|
3905
|
+
type: entry.type,
|
|
3906
|
+
value: entry.value
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
if (controlEntry.type === "Number") {
|
|
3910
|
+
const entry = controlEntry;
|
|
3911
|
+
return {
|
|
3912
|
+
type: entry.type,
|
|
3913
|
+
value: entry.value,
|
|
3914
|
+
min: entry.min,
|
|
3915
|
+
max: entry.max,
|
|
3916
|
+
interpolable: entry.interpolable
|
|
3917
|
+
};
|
|
3918
|
+
}
|
|
3919
|
+
if (controlEntry.type === "Select") {
|
|
3920
|
+
const entry = controlEntry;
|
|
3921
|
+
return {
|
|
3922
|
+
type: entry.type,
|
|
3923
|
+
value: entry.value,
|
|
3924
|
+
multiple: entry.multiple,
|
|
3925
|
+
options: new Set(entry.options)
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
if (controlEntry.type === "Vector3") {
|
|
3929
|
+
const entry = controlEntry;
|
|
3930
|
+
return {
|
|
3931
|
+
type: entry.type,
|
|
3932
|
+
value: entry.value.clone()
|
|
3933
|
+
};
|
|
3934
|
+
}
|
|
3935
|
+
if (controlEntry.type === "TextSet") {
|
|
3936
|
+
const entry = controlEntry;
|
|
3937
|
+
return {
|
|
3938
|
+
type: entry.type,
|
|
3939
|
+
value: new Set(entry.value)
|
|
3940
|
+
};
|
|
3941
|
+
}
|
|
3942
|
+
if (controlEntry.type === "None") {
|
|
3943
|
+
const entry = controlEntry;
|
|
3944
|
+
return {
|
|
3945
|
+
type: entry.type,
|
|
3946
|
+
value: entry.value
|
|
3947
|
+
};
|
|
3948
|
+
}
|
|
3949
|
+
throw new Error("Invalid entry!");
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3861
3952
|
class EventManager {
|
|
3862
3953
|
constructor() {
|
|
3863
3954
|
/**
|
|
@@ -5533,12 +5624,7 @@ class Configurator {
|
|
|
5533
5624
|
configManager.list.set(this.uuid, this);
|
|
5534
5625
|
}
|
|
5535
5626
|
get controls() {
|
|
5536
|
-
|
|
5537
|
-
for (const name in this._config) {
|
|
5538
|
-
const entry = this._config[name];
|
|
5539
|
-
copy[name] = this.copyEntry(entry);
|
|
5540
|
-
}
|
|
5541
|
-
return copy;
|
|
5627
|
+
return ControlsUtils.copySchema(this._config);
|
|
5542
5628
|
}
|
|
5543
5629
|
set(data) {
|
|
5544
5630
|
for (const name in data) {
|
|
@@ -5548,106 +5634,59 @@ class Configurator {
|
|
|
5548
5634
|
}
|
|
5549
5635
|
}
|
|
5550
5636
|
}
|
|
5551
|
-
export() {
|
|
5552
|
-
const
|
|
5553
|
-
|
|
5554
|
-
const
|
|
5555
|
-
if (
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
const imported = {};
|
|
5572
|
-
for (const id in serializedData) {
|
|
5573
|
-
const control = serializedData[id];
|
|
5574
|
-
if (control.type === "Color") {
|
|
5575
|
-
const { r, g, b } = control.value;
|
|
5576
|
-
imported[id] = { ...control, value: new THREE$1.Color(r, g, b) };
|
|
5577
|
-
} else if (control.type === "Vector3") {
|
|
5578
|
-
const { x, y, z } = control.value;
|
|
5579
|
-
imported[id] = { ...control, value: new THREE$1.Vector3(x, y, z) };
|
|
5580
|
-
} else if (control.type === "Select" || control.type === "TextSet") {
|
|
5581
|
-
imported[id] = { ...control, value: new Set(control.value) };
|
|
5637
|
+
export(controls = this._config, exported = {}) {
|
|
5638
|
+
for (const id in controls) {
|
|
5639
|
+
const control = controls[id];
|
|
5640
|
+
const isControl = ControlsUtils.isEntry(control);
|
|
5641
|
+
if (isControl) {
|
|
5642
|
+
if (control.type === "Color") {
|
|
5643
|
+
const { r, g, b } = control.value;
|
|
5644
|
+
exported[id] = { ...control, value: { r, g, b } };
|
|
5645
|
+
} else if (control.type === "Vector3") {
|
|
5646
|
+
const { x, y, z } = control.value;
|
|
5647
|
+
exported[id] = { ...control, value: { x, y, z } };
|
|
5648
|
+
} else if (control.type === "TextSet") {
|
|
5649
|
+
const value = Array.from(control.value);
|
|
5650
|
+
exported[id] = { ...control, value };
|
|
5651
|
+
} else if (control.type === "Select") {
|
|
5652
|
+
const options = Array.from(control.options);
|
|
5653
|
+
exported[id] = { ...control, options };
|
|
5654
|
+
} else {
|
|
5655
|
+
exported[id] = { ...control };
|
|
5656
|
+
}
|
|
5582
5657
|
} else {
|
|
5583
|
-
|
|
5658
|
+
exported[id] = {};
|
|
5659
|
+
this.export(control, exported[id]);
|
|
5584
5660
|
}
|
|
5585
5661
|
}
|
|
5586
|
-
|
|
5662
|
+
return exported;
|
|
5587
5663
|
}
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
const
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
if (controlEntry.type === "Number") {
|
|
5611
|
-
const entry = controlEntry;
|
|
5612
|
-
return {
|
|
5613
|
-
type: entry.type,
|
|
5614
|
-
value: entry.value,
|
|
5615
|
-
min: entry.min,
|
|
5616
|
-
max: entry.max,
|
|
5617
|
-
interpolable: entry.interpolable
|
|
5618
|
-
};
|
|
5619
|
-
}
|
|
5620
|
-
if (controlEntry.type === "Select") {
|
|
5621
|
-
const entry = controlEntry;
|
|
5622
|
-
return {
|
|
5623
|
-
type: entry.type,
|
|
5624
|
-
value: entry.value,
|
|
5625
|
-
multiple: entry.multiple,
|
|
5626
|
-
options: new Set(entry.options)
|
|
5627
|
-
};
|
|
5628
|
-
}
|
|
5629
|
-
if (controlEntry.type === "Vector3") {
|
|
5630
|
-
const entry = controlEntry;
|
|
5631
|
-
return {
|
|
5632
|
-
type: entry.type,
|
|
5633
|
-
value: entry.value.clone()
|
|
5634
|
-
};
|
|
5635
|
-
}
|
|
5636
|
-
if (controlEntry.type === "TextSet") {
|
|
5637
|
-
const entry = controlEntry;
|
|
5638
|
-
return {
|
|
5639
|
-
type: entry.type,
|
|
5640
|
-
value: new Set(entry.value)
|
|
5641
|
-
};
|
|
5664
|
+
import(exported, imported = {}, first = true) {
|
|
5665
|
+
for (const id in exported) {
|
|
5666
|
+
const control = exported[id];
|
|
5667
|
+
const isControl = ControlsUtils.isEntry(control);
|
|
5668
|
+
if (isControl) {
|
|
5669
|
+
if (control.type === "Color") {
|
|
5670
|
+
const { r, g, b } = control.value;
|
|
5671
|
+
imported[id] = { ...control, value: new THREE$1.Color(r, g, b) };
|
|
5672
|
+
} else if (control.type === "Vector3") {
|
|
5673
|
+
const { x, y, z } = control.value;
|
|
5674
|
+
imported[id] = { ...control, value: new THREE$1.Vector3(x, y, z) };
|
|
5675
|
+
} else if (control.type === "TextSet") {
|
|
5676
|
+
imported[id] = { ...control, value: new Set(control.value) };
|
|
5677
|
+
} else if (control.type === "Select") {
|
|
5678
|
+
imported[id] = { ...control, options: new Set(control.options) };
|
|
5679
|
+
} else {
|
|
5680
|
+
imported[id] = { ...control };
|
|
5681
|
+
}
|
|
5682
|
+
} else {
|
|
5683
|
+
imported[id] = {};
|
|
5684
|
+
this.import(control, imported[id], false);
|
|
5685
|
+
}
|
|
5642
5686
|
}
|
|
5643
|
-
if (
|
|
5644
|
-
|
|
5645
|
-
return {
|
|
5646
|
-
type: entry.type,
|
|
5647
|
-
value: entry.value
|
|
5648
|
-
};
|
|
5687
|
+
if (first) {
|
|
5688
|
+
this.set(imported);
|
|
5649
5689
|
}
|
|
5650
|
-
throw new Error("Invalid entry!");
|
|
5651
5690
|
}
|
|
5652
5691
|
}
|
|
5653
5692
|
const _ConfigManager = class _ConfigManager extends Component {
|
|
@@ -27632,6 +27671,7 @@ export {
|
|
|
27632
27671
|
Components,
|
|
27633
27672
|
ConfigManager,
|
|
27634
27673
|
Configurator,
|
|
27674
|
+
ControlsUtils,
|
|
27635
27675
|
CullerRenderer,
|
|
27636
27676
|
Cullers,
|
|
27637
27677
|
DataMap,
|