@inweb/viewer-three 26.4.0 → 26.4.2
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/viewer-three.js +727 -166
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +17 -6
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/commands/index.d.ts +1 -1
- package/lib/Viewer/components/RoomEnvironmentComponent.d.ts +7 -0
- package/package.json +5 -5
- package/src/Viewer/commands/index.ts +1 -1
- package/src/Viewer/components/BackgroundComponent.ts +1 -9
- package/src/Viewer/components/CameraComponent.ts +5 -1
- package/src/Viewer/components/ExtentsComponent.ts +1 -2
- package/src/Viewer/components/LightComponent.ts +6 -4
- package/src/Viewer/components/RoomEnvironmentComponent.ts +47 -0
- package/src/Viewer/components/index.ts +2 -0
package/dist/viewer-three.js
CHANGED
|
@@ -68,25 +68,22 @@
|
|
|
68
68
|
|
|
69
69
|
class DraggersRegistry {
|
|
70
70
|
constructor() {
|
|
71
|
-
this.
|
|
71
|
+
this._providers = new Map;
|
|
72
72
|
}
|
|
73
73
|
registerDragger(name, provider) {
|
|
74
|
-
this.
|
|
74
|
+
this._providers.set(name, provider);
|
|
75
75
|
}
|
|
76
76
|
registerDraggerAlias(name, alias) {
|
|
77
|
-
const provider = this.
|
|
77
|
+
const provider = this._providers.get(name);
|
|
78
78
|
if (provider) this.registerDragger(alias, (viewer => provider(viewer)));
|
|
79
79
|
}
|
|
80
|
-
getDragger(name) {
|
|
81
|
-
return this._draggers.get(name);
|
|
82
|
-
}
|
|
83
80
|
getDraggers() {
|
|
84
81
|
const map = new Map;
|
|
85
|
-
this.
|
|
82
|
+
this._providers.forEach(((value, key) => map.set(key, value)));
|
|
86
83
|
return map;
|
|
87
84
|
}
|
|
88
85
|
createDragger(name, viewer) {
|
|
89
|
-
const provider = this.
|
|
86
|
+
const provider = this._providers.get(name);
|
|
90
87
|
if (!provider) return null;
|
|
91
88
|
const dragger = provider(viewer);
|
|
92
89
|
dragger.name = name;
|
|
@@ -114,25 +111,22 @@
|
|
|
114
111
|
|
|
115
112
|
class Components {
|
|
116
113
|
constructor() {
|
|
117
|
-
this.
|
|
114
|
+
this._providers = new Map;
|
|
118
115
|
}
|
|
119
116
|
registerComponent(name, provider) {
|
|
120
|
-
this.
|
|
117
|
+
this._providers.set(name, provider);
|
|
121
118
|
}
|
|
122
119
|
registerComponentAlias(name, alias) {
|
|
123
|
-
const provider = this.
|
|
120
|
+
const provider = this._providers.get(name);
|
|
124
121
|
if (provider) this.registerComponent(alias, (viewer => provider(viewer)));
|
|
125
122
|
}
|
|
126
|
-
getComponent(name) {
|
|
127
|
-
return this._components.get(name);
|
|
128
|
-
}
|
|
129
123
|
getComponents() {
|
|
130
124
|
const map = new Map;
|
|
131
|
-
this.
|
|
125
|
+
this._providers.forEach(((value, key) => map.set(key, value)));
|
|
132
126
|
return map;
|
|
133
127
|
}
|
|
134
128
|
createComponent(name, viewer) {
|
|
135
|
-
const provider = this.
|
|
129
|
+
const provider = this._providers.get(name);
|
|
136
130
|
if (!provider) return null;
|
|
137
131
|
const component = provider(viewer);
|
|
138
132
|
component.name = name;
|
|
@@ -12410,10 +12404,29 @@
|
|
|
12410
12404
|
const LineTypeSpecs = new Map([ [ "solid", [] ], [ "dot", [ 30, 30, .001, 30 ] ], [ "dash", [ 30, 30 ] ] ]);
|
|
12411
12405
|
|
|
12412
12406
|
class KonvaLine {
|
|
12413
|
-
constructor(params, ref = null) {
|
|
12407
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12414
12408
|
var _a, _b;
|
|
12409
|
+
this._worldTransformer = worldTransformer;
|
|
12415
12410
|
if (ref) {
|
|
12416
12411
|
this._ref = ref;
|
|
12412
|
+
let wcsPoints = this._ref.getAttr("wcsPoints");
|
|
12413
|
+
if (!wcsPoints) {
|
|
12414
|
+
wcsPoints = [];
|
|
12415
|
+
let points = this._ref.points();
|
|
12416
|
+
let wcsPoint;
|
|
12417
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
12418
|
+
wcsPoint = this._worldTransformer.screenToWorld({
|
|
12419
|
+
x: points[i],
|
|
12420
|
+
y: points[i + 1]
|
|
12421
|
+
});
|
|
12422
|
+
wcsPoints.push({
|
|
12423
|
+
x: wcsPoint.x,
|
|
12424
|
+
y: wcsPoint.y,
|
|
12425
|
+
z: wcsPoint.z
|
|
12426
|
+
});
|
|
12427
|
+
}
|
|
12428
|
+
this._ref.setAttr("wcsPoints", wcsPoints);
|
|
12429
|
+
}
|
|
12417
12430
|
return;
|
|
12418
12431
|
}
|
|
12419
12432
|
if (!params) params = {};
|
|
@@ -12425,7 +12438,19 @@
|
|
|
12425
12438
|
y: 100
|
|
12426
12439
|
} ];
|
|
12427
12440
|
const konvaPoints = [];
|
|
12428
|
-
|
|
12441
|
+
const wcsPoints = [];
|
|
12442
|
+
params.points.forEach((point => {
|
|
12443
|
+
konvaPoints.push(point.x, point.y);
|
|
12444
|
+
let wcsPoint = this._worldTransformer.screenToWorld({
|
|
12445
|
+
x: point.x,
|
|
12446
|
+
y: point.y
|
|
12447
|
+
});
|
|
12448
|
+
wcsPoints.push({
|
|
12449
|
+
x: wcsPoint.x,
|
|
12450
|
+
y: wcsPoint.y,
|
|
12451
|
+
z: wcsPoint.z
|
|
12452
|
+
});
|
|
12453
|
+
}));
|
|
12429
12454
|
this._ref = new Konva.Line({
|
|
12430
12455
|
stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
|
|
12431
12456
|
strokeWidth: (_b = params.width) !== null && _b !== undefined ? _b : 4,
|
|
@@ -12437,10 +12462,55 @@
|
|
|
12437
12462
|
strokeScaleEnabled: false,
|
|
12438
12463
|
dash: LineTypeSpecs.get(params.type) || []
|
|
12439
12464
|
});
|
|
12465
|
+
this._ref.setAttr("wcsPoints", wcsPoints);
|
|
12440
12466
|
this._ref.on("transform", (e => {
|
|
12441
12467
|
const attrs = e.target.attrs;
|
|
12442
12468
|
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
12443
12469
|
}));
|
|
12470
|
+
this._ref.on("transformend", (e => {
|
|
12471
|
+
const absoluteTransform = this._ref.getAbsoluteTransform();
|
|
12472
|
+
let wcsPoints = [];
|
|
12473
|
+
let points = this._ref.points();
|
|
12474
|
+
let wcsPoint;
|
|
12475
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
12476
|
+
const position = absoluteTransform.point({
|
|
12477
|
+
x: points[i],
|
|
12478
|
+
y: points[i + 1]
|
|
12479
|
+
});
|
|
12480
|
+
wcsPoint = this._worldTransformer.screenToWorld({
|
|
12481
|
+
x: position.x,
|
|
12482
|
+
y: position.y
|
|
12483
|
+
});
|
|
12484
|
+
wcsPoints.push({
|
|
12485
|
+
x: wcsPoint.x,
|
|
12486
|
+
y: wcsPoint.y,
|
|
12487
|
+
z: wcsPoint.z
|
|
12488
|
+
});
|
|
12489
|
+
}
|
|
12490
|
+
this._ref.setAttr("wcsPoints", wcsPoints);
|
|
12491
|
+
}));
|
|
12492
|
+
this._ref.on("dragend", (e => {
|
|
12493
|
+
const absoluteTransform = this._ref.getAbsoluteTransform();
|
|
12494
|
+
let wcsPoints = [];
|
|
12495
|
+
let points = this._ref.points();
|
|
12496
|
+
let wcsPoint;
|
|
12497
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
12498
|
+
const position = absoluteTransform.point({
|
|
12499
|
+
x: points[i],
|
|
12500
|
+
y: points[i + 1]
|
|
12501
|
+
});
|
|
12502
|
+
wcsPoint = this._worldTransformer.screenToWorld({
|
|
12503
|
+
x: position.x,
|
|
12504
|
+
y: position.y
|
|
12505
|
+
});
|
|
12506
|
+
wcsPoints.push({
|
|
12507
|
+
x: wcsPoint.x,
|
|
12508
|
+
y: wcsPoint.y,
|
|
12509
|
+
z: wcsPoint.z
|
|
12510
|
+
});
|
|
12511
|
+
}
|
|
12512
|
+
this._ref.setAttr("wcsPoints", wcsPoints);
|
|
12513
|
+
}));
|
|
12444
12514
|
this._ref.id(this._ref._id.toString());
|
|
12445
12515
|
}
|
|
12446
12516
|
ref() {
|
|
@@ -12510,19 +12580,48 @@
|
|
|
12510
12580
|
}
|
|
12511
12581
|
addPoints(points) {
|
|
12512
12582
|
let newPoints = this._ref.points();
|
|
12583
|
+
let wcsPoints = this._ref.getAttr("wcsPoints");
|
|
12513
12584
|
points.forEach((point => {
|
|
12514
12585
|
newPoints = newPoints.concat([ point.x, point.y ]);
|
|
12586
|
+
let wcsPoint = this._worldTransformer.screenToWorld(point);
|
|
12587
|
+
wcsPoints.push(wcsPoint);
|
|
12515
12588
|
}));
|
|
12516
12589
|
this._ref.points(newPoints);
|
|
12517
12590
|
}
|
|
12591
|
+
updateScreenCoordinates() {
|
|
12592
|
+
let wcsPoints = this._ref.getAttr("wcsPoints");
|
|
12593
|
+
let points = [];
|
|
12594
|
+
let invert = this._ref.getAbsoluteTransform().copy();
|
|
12595
|
+
invert = invert.invert();
|
|
12596
|
+
wcsPoints.forEach((point => {
|
|
12597
|
+
let screenPoint = this._worldTransformer.worldToScreen(point);
|
|
12598
|
+
screenPoint = invert.point({
|
|
12599
|
+
x: screenPoint.x,
|
|
12600
|
+
y: screenPoint.y
|
|
12601
|
+
});
|
|
12602
|
+
points.push(screenPoint.x);
|
|
12603
|
+
points.push(screenPoint.y);
|
|
12604
|
+
}));
|
|
12605
|
+
this._ref.points([]);
|
|
12606
|
+
this._ref.points(points);
|
|
12607
|
+
this._ref.clearCache();
|
|
12608
|
+
}
|
|
12518
12609
|
}
|
|
12519
12610
|
|
|
12520
12611
|
class KonvaText {
|
|
12521
|
-
constructor(params, ref = null) {
|
|
12612
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12522
12613
|
var _a, _b, _c;
|
|
12523
12614
|
this.TEXT_FONT_FAMILY = "Calibri";
|
|
12615
|
+
this._worldTransformer = worldTransformer;
|
|
12524
12616
|
if (ref) {
|
|
12525
12617
|
this._ref = ref;
|
|
12618
|
+
const wcsStart = this._ref.getAttr("wcsStart");
|
|
12619
|
+
if (!wcsStart) {
|
|
12620
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12621
|
+
x: ref.x(),
|
|
12622
|
+
y: ref.y()
|
|
12623
|
+
}));
|
|
12624
|
+
}
|
|
12526
12625
|
return;
|
|
12527
12626
|
}
|
|
12528
12627
|
if (!params) params = {};
|
|
@@ -12543,6 +12642,10 @@
|
|
|
12543
12642
|
rotation: (_c = params.rotation) !== null && _c !== undefined ? _c : 0
|
|
12544
12643
|
});
|
|
12545
12644
|
this._ref.width(this._ref.getTextWidth());
|
|
12645
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12646
|
+
x: params.position.x,
|
|
12647
|
+
y: params.position.y
|
|
12648
|
+
}));
|
|
12546
12649
|
this._ref.on("transform", (e => {
|
|
12547
12650
|
const attrs = e.target.attrs;
|
|
12548
12651
|
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
@@ -12566,6 +12669,24 @@
|
|
|
12566
12669
|
y: 1
|
|
12567
12670
|
});
|
|
12568
12671
|
}));
|
|
12672
|
+
this._ref.on("transformend", (e => {
|
|
12673
|
+
const attrs = e.target.attrs;
|
|
12674
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
12675
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
12676
|
+
const position = absoluteTransform.point({
|
|
12677
|
+
x: this._ref.x(),
|
|
12678
|
+
y: this._ref.y()
|
|
12679
|
+
});
|
|
12680
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
12681
|
+
}));
|
|
12682
|
+
this._ref.on("dragend", (e => {
|
|
12683
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
12684
|
+
const position = absoluteTransform.point({
|
|
12685
|
+
x: this._ref.x(),
|
|
12686
|
+
y: this._ref.y()
|
|
12687
|
+
});
|
|
12688
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
12689
|
+
}));
|
|
12569
12690
|
this._ref.id(this._ref._id.toString());
|
|
12570
12691
|
}
|
|
12571
12692
|
ref() {
|
|
@@ -12616,6 +12737,10 @@
|
|
|
12616
12737
|
x: x,
|
|
12617
12738
|
y: y
|
|
12618
12739
|
});
|
|
12740
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12741
|
+
x: x,
|
|
12742
|
+
y: y
|
|
12743
|
+
}));
|
|
12619
12744
|
}
|
|
12620
12745
|
getFontSize() {
|
|
12621
12746
|
return this._ref.fontSize();
|
|
@@ -12623,13 +12748,42 @@
|
|
|
12623
12748
|
setFontSize(size) {
|
|
12624
12749
|
this._ref.fontSize(size);
|
|
12625
12750
|
}
|
|
12751
|
+
updateScreenCoordinates() {
|
|
12752
|
+
let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
|
|
12753
|
+
let invert = this._ref.getStage().getAbsoluteTransform().copy();
|
|
12754
|
+
invert = invert.invert();
|
|
12755
|
+
const positionStart = invert.point(screenPositionStart);
|
|
12756
|
+
this._ref.position({
|
|
12757
|
+
x: positionStart.x,
|
|
12758
|
+
y: positionStart.y
|
|
12759
|
+
});
|
|
12760
|
+
}
|
|
12626
12761
|
}
|
|
12627
12762
|
|
|
12628
12763
|
class KonvaRectangle {
|
|
12629
|
-
constructor(params, ref = null) {
|
|
12764
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12630
12765
|
var _a, _b, _c, _d;
|
|
12766
|
+
this._worldTransformer = worldTransformer;
|
|
12631
12767
|
if (ref) {
|
|
12632
12768
|
this._ref = ref;
|
|
12769
|
+
const wcsStart = this._ref.getAttr("wcsStart");
|
|
12770
|
+
const wcsEnd = this._ref.getAttr("wcsEnd");
|
|
12771
|
+
if (!wcsStart) {
|
|
12772
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12773
|
+
x: ref.x(),
|
|
12774
|
+
y: ref.y()
|
|
12775
|
+
}));
|
|
12776
|
+
}
|
|
12777
|
+
if (!wcsEnd) {
|
|
12778
|
+
const rightBottomPoint = {
|
|
12779
|
+
x: ref.x() + ref.width(),
|
|
12780
|
+
y: ref.y() + ref.height()
|
|
12781
|
+
};
|
|
12782
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
12783
|
+
x: rightBottomPoint.x,
|
|
12784
|
+
y: rightBottomPoint.y
|
|
12785
|
+
}));
|
|
12786
|
+
}
|
|
12633
12787
|
return;
|
|
12634
12788
|
}
|
|
12635
12789
|
if (!params) params = {};
|
|
@@ -12637,6 +12791,24 @@
|
|
|
12637
12791
|
x: 0,
|
|
12638
12792
|
y: 0
|
|
12639
12793
|
};
|
|
12794
|
+
if (params.position2) {
|
|
12795
|
+
params.width = params.position.x - params.position2.x;
|
|
12796
|
+
params.height = params.position.y - params.position2.y;
|
|
12797
|
+
} else {
|
|
12798
|
+
if (!params.width || !params.height) {
|
|
12799
|
+
params.position2 = {
|
|
12800
|
+
x: 200,
|
|
12801
|
+
y: 200
|
|
12802
|
+
};
|
|
12803
|
+
params.width = 200;
|
|
12804
|
+
params.height = 200;
|
|
12805
|
+
} else {
|
|
12806
|
+
params.position2 = {
|
|
12807
|
+
x: params.position.x + params.width,
|
|
12808
|
+
y: params.position.y + params.height
|
|
12809
|
+
};
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12640
12812
|
this._ref = new Konva.Rect({
|
|
12641
12813
|
stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
|
|
12642
12814
|
strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
|
|
@@ -12650,9 +12822,16 @@
|
|
|
12650
12822
|
draggable: true,
|
|
12651
12823
|
strokeScaleEnabled: false
|
|
12652
12824
|
});
|
|
12825
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12826
|
+
x: params.position.x,
|
|
12827
|
+
y: params.position.y
|
|
12828
|
+
}));
|
|
12829
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
12830
|
+
x: params.position2.x,
|
|
12831
|
+
y: params.position2.y
|
|
12832
|
+
}));
|
|
12653
12833
|
this._ref.on("transform", (e => {
|
|
12654
12834
|
const attrs = e.target.attrs;
|
|
12655
|
-
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
12656
12835
|
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
12657
12836
|
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
12658
12837
|
let newWidth = this._ref.width();
|
|
@@ -12674,6 +12853,32 @@
|
|
|
12674
12853
|
y: 1
|
|
12675
12854
|
});
|
|
12676
12855
|
}));
|
|
12856
|
+
this._ref.on("transformend", (e => {
|
|
12857
|
+
const attrs = e.target.attrs;
|
|
12858
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
12859
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
12860
|
+
const position = absoluteTransform.point({
|
|
12861
|
+
x: this._ref.x(),
|
|
12862
|
+
y: this._ref.y()
|
|
12863
|
+
});
|
|
12864
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
12865
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
12866
|
+
x: position.x + this._ref.width(),
|
|
12867
|
+
y: position.y + this._ref.height()
|
|
12868
|
+
}));
|
|
12869
|
+
}));
|
|
12870
|
+
this._ref.on("dragend", (e => {
|
|
12871
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
12872
|
+
const position = absoluteTransform.point({
|
|
12873
|
+
x: this._ref.x(),
|
|
12874
|
+
y: this._ref.y()
|
|
12875
|
+
});
|
|
12876
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
12877
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
12878
|
+
x: position.x + this._ref.width(),
|
|
12879
|
+
y: position.y + this._ref.height()
|
|
12880
|
+
}));
|
|
12881
|
+
}));
|
|
12677
12882
|
this._ref.id(this._ref._id.toString());
|
|
12678
12883
|
}
|
|
12679
12884
|
getPosition() {
|
|
@@ -12687,15 +12892,31 @@
|
|
|
12687
12892
|
}
|
|
12688
12893
|
setWidth(w) {
|
|
12689
12894
|
this._ref.width(w);
|
|
12895
|
+
const rightLowerPoint = {
|
|
12896
|
+
x: this._ref.x() + w,
|
|
12897
|
+
y: this._ref.y() + this._ref.height()
|
|
12898
|
+
};
|
|
12899
|
+
const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
|
|
12900
|
+
this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
|
|
12690
12901
|
}
|
|
12691
12902
|
setHeight(h) {
|
|
12692
12903
|
this._ref.height(h);
|
|
12904
|
+
const rightLowerPoint = {
|
|
12905
|
+
x: this._ref.x() + this._ref.width(),
|
|
12906
|
+
y: this._ref.y() + h
|
|
12907
|
+
};
|
|
12908
|
+
const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
|
|
12909
|
+
this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
|
|
12693
12910
|
}
|
|
12694
12911
|
setPosition(x, y) {
|
|
12695
12912
|
this._ref.setPosition({
|
|
12696
12913
|
x: x,
|
|
12697
12914
|
y: y
|
|
12698
12915
|
});
|
|
12916
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
12917
|
+
x: x,
|
|
12918
|
+
y: y
|
|
12919
|
+
}));
|
|
12699
12920
|
}
|
|
12700
12921
|
ref() {
|
|
12701
12922
|
return this._ref;
|
|
@@ -12737,13 +12958,49 @@
|
|
|
12737
12958
|
getLineWidth() {
|
|
12738
12959
|
return this._ref.strokeWidth();
|
|
12739
12960
|
}
|
|
12961
|
+
updateScreenCoordinates() {
|
|
12962
|
+
let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
|
|
12963
|
+
let screenPositionEnd = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
|
|
12964
|
+
let invert = this._ref.getStage().getAbsoluteTransform().copy();
|
|
12965
|
+
invert = invert.invert();
|
|
12966
|
+
const positionStart = invert.point(screenPositionStart);
|
|
12967
|
+
const positionEnd = invert.point(screenPositionEnd);
|
|
12968
|
+
this._ref.position({
|
|
12969
|
+
x: positionStart.x,
|
|
12970
|
+
y: positionStart.y
|
|
12971
|
+
});
|
|
12972
|
+
this._ref.width(Math.abs(positionEnd.x - positionStart.x));
|
|
12973
|
+
this._ref.height(Math.abs(positionEnd.y - positionStart.y));
|
|
12974
|
+
}
|
|
12740
12975
|
}
|
|
12741
12976
|
|
|
12742
12977
|
class KonvaEllipse {
|
|
12743
|
-
constructor(params, ref = null) {
|
|
12978
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12744
12979
|
var _a, _b;
|
|
12980
|
+
this._worldTransformer = worldTransformer;
|
|
12745
12981
|
if (ref) {
|
|
12746
12982
|
this._ref = ref;
|
|
12983
|
+
const wcsPosition = this._ref.getAttr("wcsPosition");
|
|
12984
|
+
const radiusX = this._ref.getAttr("wcsRadiusX");
|
|
12985
|
+
const radiusY = this._ref.getAttr("wcsRadiusY");
|
|
12986
|
+
if (!wcsPosition) {
|
|
12987
|
+
this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({
|
|
12988
|
+
x: ref.x(),
|
|
12989
|
+
y: ref.y()
|
|
12990
|
+
}));
|
|
12991
|
+
}
|
|
12992
|
+
if (!radiusX) {
|
|
12993
|
+
this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({
|
|
12994
|
+
x: ref.x() + ref.radiusX(),
|
|
12995
|
+
y: ref.y()
|
|
12996
|
+
}));
|
|
12997
|
+
}
|
|
12998
|
+
if (!radiusY) {
|
|
12999
|
+
this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({
|
|
13000
|
+
x: ref.x(),
|
|
13001
|
+
y: ref.y() + ref.radiusY()
|
|
13002
|
+
}));
|
|
13003
|
+
}
|
|
12747
13004
|
return;
|
|
12748
13005
|
}
|
|
12749
13006
|
if (!params) params = {};
|
|
@@ -12768,6 +13025,18 @@
|
|
|
12768
13025
|
draggable: true,
|
|
12769
13026
|
strokeScaleEnabled: false
|
|
12770
13027
|
});
|
|
13028
|
+
this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({
|
|
13029
|
+
x: params.position.x,
|
|
13030
|
+
y: params.position.y
|
|
13031
|
+
}));
|
|
13032
|
+
this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({
|
|
13033
|
+
x: this._ref.x() + params.radius.x,
|
|
13034
|
+
y: this._ref.y()
|
|
13035
|
+
}));
|
|
13036
|
+
this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({
|
|
13037
|
+
x: this._ref.x(),
|
|
13038
|
+
y: this._ref.y() + params.radius.y
|
|
13039
|
+
}));
|
|
12771
13040
|
this._ref.on("transform", (e => {
|
|
12772
13041
|
const attrs = e.target.attrs;
|
|
12773
13042
|
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
@@ -12804,6 +13073,42 @@
|
|
|
12804
13073
|
y: 1
|
|
12805
13074
|
});
|
|
12806
13075
|
}));
|
|
13076
|
+
this._ref.on("transformend", (e => {
|
|
13077
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13078
|
+
const position = absoluteTransform.point({
|
|
13079
|
+
x: this._ref.x(),
|
|
13080
|
+
y: this._ref.y()
|
|
13081
|
+
});
|
|
13082
|
+
this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld(position));
|
|
13083
|
+
const radiusX = absoluteTransform.point({
|
|
13084
|
+
x: this._ref.x() + this._ref.radiusX(),
|
|
13085
|
+
y: this._ref.y()
|
|
13086
|
+
});
|
|
13087
|
+
this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld(radiusX));
|
|
13088
|
+
const radiusY = absoluteTransform.point({
|
|
13089
|
+
x: this._ref.x(),
|
|
13090
|
+
y: this._ref.y() + this._ref.radiusY()
|
|
13091
|
+
});
|
|
13092
|
+
this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
|
|
13093
|
+
}));
|
|
13094
|
+
this._ref.on("dragend", (e => {
|
|
13095
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13096
|
+
const position = absoluteTransform.point({
|
|
13097
|
+
x: this._ref.x(),
|
|
13098
|
+
y: this._ref.y()
|
|
13099
|
+
});
|
|
13100
|
+
this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld(position));
|
|
13101
|
+
const radiusX = absoluteTransform.point({
|
|
13102
|
+
x: this._ref.x() + this._ref.radiusX(),
|
|
13103
|
+
y: this._ref.y()
|
|
13104
|
+
});
|
|
13105
|
+
this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld(radiusX));
|
|
13106
|
+
const radiusY = absoluteTransform.point({
|
|
13107
|
+
x: this._ref.x(),
|
|
13108
|
+
y: this._ref.y() + this._ref.radiusY()
|
|
13109
|
+
});
|
|
13110
|
+
this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
|
|
13111
|
+
}));
|
|
12807
13112
|
this._ref.id(this._ref._id.toString());
|
|
12808
13113
|
}
|
|
12809
13114
|
getPosition() {
|
|
@@ -12814,18 +13119,30 @@
|
|
|
12814
13119
|
x: x,
|
|
12815
13120
|
y: y
|
|
12816
13121
|
});
|
|
13122
|
+
this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({
|
|
13123
|
+
x: x,
|
|
13124
|
+
y: y
|
|
13125
|
+
}));
|
|
12817
13126
|
}
|
|
12818
13127
|
getRadiusX() {
|
|
12819
13128
|
return this._ref.radiusX();
|
|
12820
13129
|
}
|
|
12821
13130
|
setRadiusX(r) {
|
|
12822
13131
|
this._ref.radiusX(r);
|
|
13132
|
+
this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({
|
|
13133
|
+
x: this._ref.x() + r,
|
|
13134
|
+
y: this._ref.y()
|
|
13135
|
+
}));
|
|
12823
13136
|
}
|
|
12824
13137
|
getRadiusY() {
|
|
12825
13138
|
return this._ref.radiusY();
|
|
12826
13139
|
}
|
|
12827
13140
|
setRadiusY(r) {
|
|
12828
13141
|
this._ref.radiusY(r);
|
|
13142
|
+
this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({
|
|
13143
|
+
x: this._ref.x(),
|
|
13144
|
+
y: this._ref.y() + r
|
|
13145
|
+
}));
|
|
12829
13146
|
}
|
|
12830
13147
|
getLineWidth() {
|
|
12831
13148
|
return this._ref.strokeWidth();
|
|
@@ -12867,13 +13184,43 @@
|
|
|
12867
13184
|
this._ref.destroy();
|
|
12868
13185
|
this._ref = null;
|
|
12869
13186
|
}
|
|
13187
|
+
updateScreenCoordinates() {
|
|
13188
|
+
let screenPosition = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition"));
|
|
13189
|
+
let radiusX = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX"));
|
|
13190
|
+
let radiusY = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));
|
|
13191
|
+
let invert = this._ref.getStage().getAbsoluteTransform().copy();
|
|
13192
|
+
invert = invert.invert();
|
|
13193
|
+
const position = invert.point({
|
|
13194
|
+
x: screenPosition.x,
|
|
13195
|
+
y: screenPosition.y
|
|
13196
|
+
});
|
|
13197
|
+
this._ref.position({
|
|
13198
|
+
x: position.x,
|
|
13199
|
+
y: position.y
|
|
13200
|
+
});
|
|
13201
|
+
this._ref.radius({
|
|
13202
|
+
x: Math.abs(invert.point(radiusX).x - position.x),
|
|
13203
|
+
y: Math.abs(invert.point(radiusY).y - position.y)
|
|
13204
|
+
});
|
|
13205
|
+
}
|
|
12870
13206
|
}
|
|
12871
13207
|
|
|
12872
13208
|
class KonvaArrow {
|
|
12873
|
-
constructor(params, ref = null) {
|
|
13209
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12874
13210
|
var _a, _b;
|
|
13211
|
+
this._worldTransformer = worldTransformer;
|
|
12875
13212
|
if (ref) {
|
|
12876
13213
|
this._ref = ref;
|
|
13214
|
+
const wcsStart = this._ref.getAttr("wcsStart");
|
|
13215
|
+
const wcsEnd = this._ref.getAttr("wcsEnd");
|
|
13216
|
+
if (!wcsStart) this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13217
|
+
x: ref.points()[0],
|
|
13218
|
+
y: ref.points()[1]
|
|
13219
|
+
}));
|
|
13220
|
+
if (!wcsEnd) this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13221
|
+
x: ref.points()[2],
|
|
13222
|
+
y: ref.points()[3]
|
|
13223
|
+
}));
|
|
12877
13224
|
return;
|
|
12878
13225
|
}
|
|
12879
13226
|
if (!params) params = {};
|
|
@@ -12896,9 +13243,43 @@
|
|
|
12896
13243
|
draggable: true,
|
|
12897
13244
|
strokeScaleEnabled: false
|
|
12898
13245
|
});
|
|
12899
|
-
this._ref.
|
|
13246
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13247
|
+
x: params.start.x,
|
|
13248
|
+
y: params.start.y
|
|
13249
|
+
}));
|
|
13250
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13251
|
+
x: params.end.x,
|
|
13252
|
+
y: params.end.y
|
|
13253
|
+
}));
|
|
13254
|
+
this._ref.on("transformend", (e => {
|
|
12900
13255
|
const attrs = e.target.attrs;
|
|
12901
13256
|
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
13257
|
+
const points = this._ref.points();
|
|
13258
|
+
const absoluteTransform = this._ref.getAbsoluteTransform();
|
|
13259
|
+
const transformStart = absoluteTransform.point({
|
|
13260
|
+
x: points[0],
|
|
13261
|
+
y: points[1]
|
|
13262
|
+
});
|
|
13263
|
+
const transformEnd = absoluteTransform.point({
|
|
13264
|
+
x: points[2],
|
|
13265
|
+
y: points[3]
|
|
13266
|
+
});
|
|
13267
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
|
|
13268
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
|
|
13269
|
+
}));
|
|
13270
|
+
this._ref.on("dragend", (e => {
|
|
13271
|
+
const points = this._ref.points();
|
|
13272
|
+
const absoluteTransform = e.target.getAbsoluteTransform();
|
|
13273
|
+
const transformStart = absoluteTransform.point({
|
|
13274
|
+
x: points[0],
|
|
13275
|
+
y: points[1]
|
|
13276
|
+
});
|
|
13277
|
+
const transformEnd = absoluteTransform.point({
|
|
13278
|
+
x: points[2],
|
|
13279
|
+
y: points[3]
|
|
13280
|
+
});
|
|
13281
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
|
|
13282
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
|
|
12902
13283
|
}));
|
|
12903
13284
|
this._ref.id(this._ref._id.toString());
|
|
12904
13285
|
}
|
|
@@ -12949,6 +13330,14 @@
|
|
|
12949
13330
|
}
|
|
12950
13331
|
setPoints(points) {
|
|
12951
13332
|
if (points.length === 2) {
|
|
13333
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13334
|
+
x: points[0].x,
|
|
13335
|
+
y: points[0].y
|
|
13336
|
+
}));
|
|
13337
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13338
|
+
x: points[1].x,
|
|
13339
|
+
y: points[1].y
|
|
13340
|
+
}));
|
|
12952
13341
|
this._ref.points([ points[0].x, points[0].y, points[1].x, points[1].y ]);
|
|
12953
13342
|
}
|
|
12954
13343
|
}
|
|
@@ -12962,6 +13351,10 @@
|
|
|
12962
13351
|
setStartPoint(x, y) {
|
|
12963
13352
|
const points = this._ref.points();
|
|
12964
13353
|
this._ref.points([ x, y, points[2], points[3] ]);
|
|
13354
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13355
|
+
x: x,
|
|
13356
|
+
y: y
|
|
13357
|
+
}));
|
|
12965
13358
|
}
|
|
12966
13359
|
getEndPoint() {
|
|
12967
13360
|
const points = this._ref.points();
|
|
@@ -12973,16 +13366,36 @@
|
|
|
12973
13366
|
setEndPoint(x, y) {
|
|
12974
13367
|
const points = this._ref.points();
|
|
12975
13368
|
this._ref.points([ points[0], points[1], x, y ]);
|
|
13369
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13370
|
+
x: x,
|
|
13371
|
+
y: y
|
|
13372
|
+
}));
|
|
13373
|
+
}
|
|
13374
|
+
updateScreenCoordinates() {
|
|
13375
|
+
let screenStartPoint = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
|
|
13376
|
+
let screenEndPoint = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
|
|
13377
|
+
let invert = this._ref.getAbsoluteTransform().copy();
|
|
13378
|
+
invert = invert.invert();
|
|
13379
|
+
const startPoint = invert.point({
|
|
13380
|
+
x: screenStartPoint.x,
|
|
13381
|
+
y: screenStartPoint.y
|
|
13382
|
+
});
|
|
13383
|
+
const endPoint = invert.point({
|
|
13384
|
+
x: screenEndPoint.x,
|
|
13385
|
+
y: screenEndPoint.y
|
|
13386
|
+
});
|
|
13387
|
+
this._ref.points([ startPoint.x, startPoint.y, endPoint.x, endPoint.y ]);
|
|
12976
13388
|
}
|
|
12977
13389
|
}
|
|
12978
13390
|
|
|
12979
13391
|
class KonvaImage {
|
|
12980
|
-
constructor(params, ref = null) {
|
|
13392
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
12981
13393
|
var _a, _b;
|
|
12982
13394
|
this._ratio = 1;
|
|
12983
13395
|
this.EPSILON = 1e-5;
|
|
12984
13396
|
this.BASE64_HEADER_START = "data:image/";
|
|
12985
13397
|
this.BASE64_NOT_FOUND = "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=";
|
|
13398
|
+
this._worldTransformer = worldTransformer;
|
|
12986
13399
|
if (ref) {
|
|
12987
13400
|
if (!ref.src || !ref.src.startsWith(this.BASE64_HEADER_START)) ref.src = this.BASE64_NOT_FOUND;
|
|
12988
13401
|
if (ref.height() <= this.EPSILON) ref.height(32);
|
|
@@ -12990,6 +13403,13 @@
|
|
|
12990
13403
|
this._ref = ref;
|
|
12991
13404
|
this._canvasImage = ref.image();
|
|
12992
13405
|
this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
|
|
13406
|
+
const wcsStart = this._ref.getAttr("wcsStart");
|
|
13407
|
+
if (!wcsStart) {
|
|
13408
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13409
|
+
x: ref.x(),
|
|
13410
|
+
y: ref.y()
|
|
13411
|
+
}));
|
|
13412
|
+
}
|
|
12993
13413
|
return;
|
|
12994
13414
|
}
|
|
12995
13415
|
if (!params) params = {};
|
|
@@ -13031,6 +13451,10 @@
|
|
|
13031
13451
|
height: (_b = params.height) !== null && _b !== undefined ? _b : 0,
|
|
13032
13452
|
draggable: true
|
|
13033
13453
|
});
|
|
13454
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13455
|
+
x: params.position.x,
|
|
13456
|
+
y: params.position.y
|
|
13457
|
+
}));
|
|
13034
13458
|
this._ref.on("transform", (e => {
|
|
13035
13459
|
const attrs = e.target.attrs;
|
|
13036
13460
|
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
@@ -13061,6 +13485,22 @@
|
|
|
13061
13485
|
y: 1
|
|
13062
13486
|
});
|
|
13063
13487
|
}));
|
|
13488
|
+
this._ref.on("transformend", (e => {
|
|
13489
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13490
|
+
const position = absoluteTransform.point({
|
|
13491
|
+
x: this._ref.x(),
|
|
13492
|
+
y: this._ref.y()
|
|
13493
|
+
});
|
|
13494
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
13495
|
+
}));
|
|
13496
|
+
this._ref.on("dragend", (e => {
|
|
13497
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13498
|
+
const position = absoluteTransform.point({
|
|
13499
|
+
x: this._ref.x(),
|
|
13500
|
+
y: this._ref.y()
|
|
13501
|
+
});
|
|
13502
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
13503
|
+
}));
|
|
13064
13504
|
this._ref.id(this._ref._id.toString());
|
|
13065
13505
|
}
|
|
13066
13506
|
getSrc() {
|
|
@@ -13119,14 +13559,47 @@
|
|
|
13119
13559
|
x: x,
|
|
13120
13560
|
y: y
|
|
13121
13561
|
});
|
|
13562
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13563
|
+
x: x,
|
|
13564
|
+
y: y
|
|
13565
|
+
}));
|
|
13566
|
+
}
|
|
13567
|
+
updateScreenCoordinates() {
|
|
13568
|
+
let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
|
|
13569
|
+
let invert = this._ref.getStage().getAbsoluteTransform().copy();
|
|
13570
|
+
invert = invert.invert();
|
|
13571
|
+
const positionStart = invert.point(screenPositionStart);
|
|
13572
|
+
this._ref.position({
|
|
13573
|
+
x: positionStart.x,
|
|
13574
|
+
y: positionStart.y
|
|
13575
|
+
});
|
|
13122
13576
|
}
|
|
13123
13577
|
}
|
|
13124
13578
|
|
|
13125
13579
|
class KonvaCloud {
|
|
13126
|
-
constructor(params, ref = null) {
|
|
13580
|
+
constructor(params, ref = null, worldTransformer = new WorldTransform) {
|
|
13127
13581
|
var _a, _b, _c, _d;
|
|
13582
|
+
this._worldTransformer = worldTransformer;
|
|
13128
13583
|
if (ref) {
|
|
13129
13584
|
this._ref = ref;
|
|
13585
|
+
const wcsStart = this._ref.getAttr("wcsStart");
|
|
13586
|
+
const wcsEnd = this._ref.getAttr("wcsEnd");
|
|
13587
|
+
if (!wcsStart) {
|
|
13588
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13589
|
+
x: ref.x(),
|
|
13590
|
+
y: ref.y()
|
|
13591
|
+
}));
|
|
13592
|
+
}
|
|
13593
|
+
if (!wcsEnd) {
|
|
13594
|
+
const rightBottomPoint = {
|
|
13595
|
+
x: ref.x() + ref.width(),
|
|
13596
|
+
y: ref.y() + ref.height()
|
|
13597
|
+
};
|
|
13598
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13599
|
+
x: rightBottomPoint.x,
|
|
13600
|
+
y: rightBottomPoint.y
|
|
13601
|
+
}));
|
|
13602
|
+
}
|
|
13130
13603
|
return;
|
|
13131
13604
|
}
|
|
13132
13605
|
if (!params) params = {};
|
|
@@ -13134,7 +13607,25 @@
|
|
|
13134
13607
|
x: 0,
|
|
13135
13608
|
y: 0
|
|
13136
13609
|
};
|
|
13137
|
-
|
|
13610
|
+
if (params.position2) {
|
|
13611
|
+
params.width = params.position.x - params.position2.x;
|
|
13612
|
+
params.height = params.position.y - params.position2.y;
|
|
13613
|
+
} else {
|
|
13614
|
+
if (!params.width || !params.height) {
|
|
13615
|
+
params.position2 = {
|
|
13616
|
+
x: 200,
|
|
13617
|
+
y: 200
|
|
13618
|
+
};
|
|
13619
|
+
params.width = 200;
|
|
13620
|
+
params.height = 200;
|
|
13621
|
+
} else {
|
|
13622
|
+
params.position2 = {
|
|
13623
|
+
x: params.position.x + params.width,
|
|
13624
|
+
y: params.position.y + params.height
|
|
13625
|
+
};
|
|
13626
|
+
}
|
|
13627
|
+
}
|
|
13628
|
+
const ARC_RADIUS = 16;
|
|
13138
13629
|
this._ref = new Konva.Shape({
|
|
13139
13630
|
x: params.position.x,
|
|
13140
13631
|
y: params.position.y,
|
|
@@ -13193,9 +13684,9 @@
|
|
|
13193
13684
|
const counterClockwise = pX > midPoint.x && pY > midPoint.y;
|
|
13194
13685
|
for (let iArc = 0; iArc < arcCount; iArc++) {
|
|
13195
13686
|
if (counterClockwise) {
|
|
13196
|
-
context.arc(pX, pY,
|
|
13687
|
+
context.arc(pX, pY, ARC_RADIUS, endAngle, startAngle);
|
|
13197
13688
|
} else {
|
|
13198
|
-
context.arc(pX, pY,
|
|
13689
|
+
context.arc(pX, pY, ARC_RADIUS, startAngle, endAngle);
|
|
13199
13690
|
}
|
|
13200
13691
|
pX += dx / arcCount;
|
|
13201
13692
|
pY += dy / arcCount;
|
|
@@ -13206,9 +13697,16 @@
|
|
|
13206
13697
|
}
|
|
13207
13698
|
});
|
|
13208
13699
|
this._ref.className = "Cloud";
|
|
13700
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13701
|
+
x: params.position.x,
|
|
13702
|
+
y: params.position.y
|
|
13703
|
+
}));
|
|
13704
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13705
|
+
x: params.position2.x,
|
|
13706
|
+
y: params.position2.y
|
|
13707
|
+
}));
|
|
13209
13708
|
this._ref.on("transform", (e => {
|
|
13210
13709
|
const attrs = e.target.attrs;
|
|
13211
|
-
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
13212
13710
|
const scaleByX = Math.abs(attrs.scaleX - 1) > 1e-5;
|
|
13213
13711
|
const scaleByY = Math.abs(attrs.scaleY - 1) > 1e-5;
|
|
13214
13712
|
let newWidth = this._ref.width();
|
|
@@ -13230,11 +13728,37 @@
|
|
|
13230
13728
|
y: 1
|
|
13231
13729
|
});
|
|
13232
13730
|
}));
|
|
13731
|
+
this._ref.on("transformend", (e => {
|
|
13732
|
+
const attrs = e.target.attrs;
|
|
13733
|
+
if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
|
|
13734
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13735
|
+
const position = absoluteTransform.point({
|
|
13736
|
+
x: this._ref.x(),
|
|
13737
|
+
y: this._ref.y()
|
|
13738
|
+
});
|
|
13739
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
13740
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13741
|
+
x: position.x + this._ref.width(),
|
|
13742
|
+
y: position.y + this._ref.height()
|
|
13743
|
+
}));
|
|
13744
|
+
}));
|
|
13745
|
+
this._ref.on("dragend", (e => {
|
|
13746
|
+
const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
|
|
13747
|
+
const position = absoluteTransform.point({
|
|
13748
|
+
x: this._ref.x(),
|
|
13749
|
+
y: this._ref.y()
|
|
13750
|
+
});
|
|
13751
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
|
|
13752
|
+
this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({
|
|
13753
|
+
x: position.x + this._ref.width(),
|
|
13754
|
+
y: position.y + this._ref.height()
|
|
13755
|
+
}));
|
|
13756
|
+
}));
|
|
13233
13757
|
this._ref.getSelfRect = () => ({
|
|
13234
|
-
x: 0 -
|
|
13235
|
-
y: 0 -
|
|
13236
|
-
width: this._ref.width() + 2 *
|
|
13237
|
-
height: this._ref.height() + 2 *
|
|
13758
|
+
x: 0 - ARC_RADIUS,
|
|
13759
|
+
y: 0 - ARC_RADIUS,
|
|
13760
|
+
width: this._ref.width() + 2 * ARC_RADIUS,
|
|
13761
|
+
height: this._ref.height() + 2 * ARC_RADIUS
|
|
13238
13762
|
});
|
|
13239
13763
|
this._ref.id(this._ref._id.toString());
|
|
13240
13764
|
}
|
|
@@ -13280,18 +13804,34 @@
|
|
|
13280
13804
|
x: x,
|
|
13281
13805
|
y: y
|
|
13282
13806
|
});
|
|
13807
|
+
this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({
|
|
13808
|
+
x: x,
|
|
13809
|
+
y: y
|
|
13810
|
+
}));
|
|
13283
13811
|
}
|
|
13284
13812
|
getWidth() {
|
|
13285
13813
|
return this._ref.width();
|
|
13286
13814
|
}
|
|
13287
13815
|
setWidth(w) {
|
|
13288
13816
|
this._ref.width(w);
|
|
13817
|
+
const rightLowerPoint = {
|
|
13818
|
+
x: this._ref.x() + w,
|
|
13819
|
+
y: this._ref.y() + this._ref.height()
|
|
13820
|
+
};
|
|
13821
|
+
const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
|
|
13822
|
+
this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
|
|
13289
13823
|
}
|
|
13290
13824
|
getHeigth() {
|
|
13291
13825
|
return this._ref.height();
|
|
13292
13826
|
}
|
|
13293
13827
|
setHeight(h) {
|
|
13294
13828
|
this._ref.height(h);
|
|
13829
|
+
const rightLowerPoint = {
|
|
13830
|
+
x: this._ref.x() + this._ref.width(),
|
|
13831
|
+
y: this._ref.y() + h
|
|
13832
|
+
};
|
|
13833
|
+
const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
|
|
13834
|
+
this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
|
|
13295
13835
|
}
|
|
13296
13836
|
getLineWidth() {
|
|
13297
13837
|
return this._ref.strokeWidth();
|
|
@@ -13299,6 +13839,20 @@
|
|
|
13299
13839
|
setLineWidth(size) {
|
|
13300
13840
|
this._ref.strokeWidth(size);
|
|
13301
13841
|
}
|
|
13842
|
+
updateScreenCoordinates() {
|
|
13843
|
+
let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
|
|
13844
|
+
let screenPositionEnd = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
|
|
13845
|
+
let invert = this._ref.getStage().getAbsoluteTransform().copy();
|
|
13846
|
+
invert = invert.invert();
|
|
13847
|
+
const positionStart = invert.point(screenPositionStart);
|
|
13848
|
+
const positionEnd = invert.point(screenPositionEnd);
|
|
13849
|
+
this._ref.position({
|
|
13850
|
+
x: positionStart.x,
|
|
13851
|
+
y: positionStart.y
|
|
13852
|
+
});
|
|
13853
|
+
this._ref.width(Math.abs(positionEnd.x - positionStart.x));
|
|
13854
|
+
this._ref.height(Math.abs(positionEnd.y - positionStart.y));
|
|
13855
|
+
}
|
|
13302
13856
|
}
|
|
13303
13857
|
|
|
13304
13858
|
const MarkupMode2Konva = {
|
|
@@ -13308,37 +13862,49 @@
|
|
|
13308
13862
|
},
|
|
13309
13863
|
Line: {
|
|
13310
13864
|
name: "Line",
|
|
13311
|
-
initializer: (ref, params = null) => new KonvaLine(params, ref)
|
|
13865
|
+
initializer: (ref, params = null, ...attr) => new KonvaLine(params, ref, ...attr)
|
|
13312
13866
|
},
|
|
13313
13867
|
Text: {
|
|
13314
13868
|
name: "Text",
|
|
13315
|
-
initializer: (ref, params = null) => new KonvaText(params, ref)
|
|
13869
|
+
initializer: (ref, params = null, ...attr) => new KonvaText(params, ref, ...attr)
|
|
13316
13870
|
},
|
|
13317
13871
|
Rectangle: {
|
|
13318
13872
|
name: "Rect",
|
|
13319
|
-
initializer: (ref, params = null) => new KonvaRectangle(params, ref)
|
|
13873
|
+
initializer: (ref, params = null, ...attr) => new KonvaRectangle(params, ref, ...attr)
|
|
13320
13874
|
},
|
|
13321
13875
|
Ellipse: {
|
|
13322
13876
|
name: "Ellipse",
|
|
13323
|
-
initializer: (ref, params = null) => new KonvaEllipse(params, ref)
|
|
13877
|
+
initializer: (ref, params = null, ...attr) => new KonvaEllipse(params, ref, ...attr)
|
|
13324
13878
|
},
|
|
13325
13879
|
Arrow: {
|
|
13326
13880
|
name: "Arrow",
|
|
13327
|
-
initializer: (ref, params = null) => new KonvaArrow(params, ref)
|
|
13881
|
+
initializer: (ref, params = null, ...attr) => new KonvaArrow(params, ref, ...attr)
|
|
13328
13882
|
},
|
|
13329
13883
|
Image: {
|
|
13330
13884
|
name: "Image",
|
|
13331
|
-
initializer: (ref, params = null) => new KonvaImage(params, ref)
|
|
13885
|
+
initializer: (ref, params = null, ...attr) => new KonvaImage(params, ref, ...attr)
|
|
13332
13886
|
},
|
|
13333
13887
|
Cloud: {
|
|
13334
13888
|
name: "Cloud",
|
|
13335
|
-
initializer: (ref, params = null) => new KonvaCloud(params, ref)
|
|
13889
|
+
initializer: (ref, params = null, ...attr) => new KonvaCloud(params, ref, ...attr)
|
|
13336
13890
|
}
|
|
13337
13891
|
};
|
|
13338
13892
|
|
|
13893
|
+
function debounce(func, wait) {
|
|
13894
|
+
let timeout = null;
|
|
13895
|
+
return (...args) => {
|
|
13896
|
+
if (timeout) {
|
|
13897
|
+
clearTimeout(timeout);
|
|
13898
|
+
}
|
|
13899
|
+
timeout = setTimeout((() => {
|
|
13900
|
+
timeout = null;
|
|
13901
|
+
func(...args);
|
|
13902
|
+
}), wait);
|
|
13903
|
+
};
|
|
13904
|
+
}
|
|
13905
|
+
|
|
13339
13906
|
class KonvaMarkup {
|
|
13340
13907
|
constructor() {
|
|
13341
|
-
this._containerEvents = [];
|
|
13342
13908
|
this._markupIsActive = false;
|
|
13343
13909
|
this._markupColor = new MarkupColor(255, 0, 0);
|
|
13344
13910
|
this.lineWidth = 4;
|
|
@@ -13357,25 +13923,29 @@
|
|
|
13357
13923
|
if (!this._konvaStage) return;
|
|
13358
13924
|
this._konvaStage.width(width);
|
|
13359
13925
|
this._konvaStage.height(height);
|
|
13926
|
+
this.getObjects().forEach((markupObject => {
|
|
13927
|
+
markupObject.updateScreenCoordinates();
|
|
13928
|
+
}));
|
|
13929
|
+
};
|
|
13930
|
+
this.resizeViewer = event => {
|
|
13931
|
+
const {width: width, height: height} = event;
|
|
13932
|
+
if (!width || !height) return;
|
|
13933
|
+
if (!this._konvaStage) return;
|
|
13934
|
+
this._konvaStage.width(width);
|
|
13935
|
+
this._konvaStage.height(height);
|
|
13936
|
+
this.getObjects().forEach((markupObject => {
|
|
13937
|
+
markupObject.updateScreenCoordinates();
|
|
13938
|
+
}));
|
|
13360
13939
|
};
|
|
13361
13940
|
this.pan = event => {
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
};
|
|
13366
|
-
this._konvaStage.position(newPos);
|
|
13941
|
+
this.getObjects().forEach((markupObject => {
|
|
13942
|
+
markupObject.updateScreenCoordinates();
|
|
13943
|
+
}));
|
|
13367
13944
|
};
|
|
13368
13945
|
this.zoomAt = event => {
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
y: newScale
|
|
13373
|
-
});
|
|
13374
|
-
const newPos = {
|
|
13375
|
-
x: event.x - (event.x - this._konvaStage.x()) * event.data,
|
|
13376
|
-
y: event.y - (event.y - this._konvaStage.y()) * event.data
|
|
13377
|
-
};
|
|
13378
|
-
this._konvaStage.position(newPos);
|
|
13946
|
+
this.getObjects().forEach((markupObject => {
|
|
13947
|
+
markupObject.updateScreenCoordinates();
|
|
13948
|
+
}));
|
|
13379
13949
|
};
|
|
13380
13950
|
this.redirectToViewer = event => {
|
|
13381
13951
|
if (this._viewer) this._viewer.emit(event);
|
|
@@ -13392,7 +13962,6 @@
|
|
|
13392
13962
|
this._viewer = viewer;
|
|
13393
13963
|
this._worldTransformer = worldTransformer !== null && worldTransformer !== undefined ? worldTransformer : new WorldTransform;
|
|
13394
13964
|
this._container = container;
|
|
13395
|
-
this._containerEvents = containerEvents !== null && containerEvents !== undefined ? containerEvents : [];
|
|
13396
13965
|
this._markupContainer = document.createElement("div");
|
|
13397
13966
|
this._markupContainer.id = "markup-container";
|
|
13398
13967
|
this._markupContainer.style.position = "absolute";
|
|
@@ -13402,8 +13971,7 @@
|
|
|
13402
13971
|
this._markupContainer.style.pointerEvents = "none";
|
|
13403
13972
|
const parentDiv = this._container.parentElement;
|
|
13404
13973
|
parentDiv.appendChild(this._markupContainer);
|
|
13405
|
-
this._resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
13406
|
-
this._resizeObserver.observe(parentDiv);
|
|
13974
|
+
if (viewer) this._viewer.addEventListener("resize", this.resizeViewer); else this._resizeObserver = new ResizeObserver(debounce(this.resizeContainer, 100));
|
|
13407
13975
|
this._markupColor.setColor(255, 0, 0);
|
|
13408
13976
|
this.initializeKonva();
|
|
13409
13977
|
if (this._viewer) {
|
|
@@ -13498,7 +14066,7 @@
|
|
|
13498
14066
|
}));
|
|
13499
14067
|
(_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect => {
|
|
13500
14068
|
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
13501
|
-
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
14069
|
+
this.addRectangle(screenPoint, null, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
13502
14070
|
}));
|
|
13503
14071
|
(_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse => {
|
|
13504
14072
|
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
@@ -13511,7 +14079,7 @@
|
|
|
13511
14079
|
}));
|
|
13512
14080
|
(_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud => {
|
|
13513
14081
|
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
13514
|
-
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
14082
|
+
this.addCloud(screenPoint, null, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
13515
14083
|
}));
|
|
13516
14084
|
(_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image => {
|
|
13517
14085
|
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
@@ -13552,7 +14120,7 @@
|
|
|
13552
14120
|
createObject(type, params) {
|
|
13553
14121
|
const konvaShape = MarkupMode2Konva[type];
|
|
13554
14122
|
if (!konvaShape || !konvaShape.initializer) throw new Error(`Markup CreateObject - unsupported markup type ${type}`);
|
|
13555
|
-
const object = konvaShape.initializer(null, params);
|
|
14123
|
+
const object = konvaShape.initializer(null, params, this._worldTransformer);
|
|
13556
14124
|
this.addObject(object);
|
|
13557
14125
|
return object;
|
|
13558
14126
|
}
|
|
@@ -13560,7 +14128,7 @@
|
|
|
13560
14128
|
const objects = [];
|
|
13561
14129
|
Object.keys(MarkupMode2Konva).forEach((type => {
|
|
13562
14130
|
const konvaShape = MarkupMode2Konva[type];
|
|
13563
|
-
this.konvaLayerFind(type).forEach((ref => objects.push(konvaShape.initializer(ref))));
|
|
14131
|
+
this.konvaLayerFind(type).forEach((ref => objects.push(konvaShape.initializer(ref, null, this._worldTransformer))));
|
|
13564
14132
|
}));
|
|
13565
14133
|
return objects;
|
|
13566
14134
|
}
|
|
@@ -13569,7 +14137,7 @@
|
|
|
13569
14137
|
return this._konvaTransformer.nodes().map((ref => {
|
|
13570
14138
|
const name = ref.className;
|
|
13571
14139
|
const konvaShape = Object.values(MarkupMode2Konva).find((shape => shape.name === name));
|
|
13572
|
-
return konvaShape ? konvaShape.initializer(ref) : null;
|
|
14140
|
+
return konvaShape ? konvaShape.initializer(ref, null, this._worldTransformer) : null;
|
|
13573
14141
|
})).filter((x => x));
|
|
13574
14142
|
}
|
|
13575
14143
|
selectObjects(objects) {
|
|
@@ -13645,7 +14213,7 @@
|
|
|
13645
14213
|
this.addRectangle({
|
|
13646
14214
|
x: startX,
|
|
13647
14215
|
y: startY
|
|
13648
|
-
}, dX, dY);
|
|
14216
|
+
}, null, dX, dY);
|
|
13649
14217
|
} else if (this._markupMode === "Ellipse") {
|
|
13650
14218
|
this.addEllipse({
|
|
13651
14219
|
x: startX,
|
|
@@ -13666,7 +14234,7 @@
|
|
|
13666
14234
|
this.addCloud({
|
|
13667
14235
|
x: startX,
|
|
13668
14236
|
y: startY
|
|
13669
|
-
}, Math.max(100, dX), Math.max(100, dY));
|
|
14237
|
+
}, null, Math.max(100, dX), Math.max(100, dY));
|
|
13670
14238
|
}
|
|
13671
14239
|
}
|
|
13672
14240
|
}
|
|
@@ -13705,7 +14273,7 @@
|
|
|
13705
14273
|
} else lastObj = this.addRectangle({
|
|
13706
14274
|
x: startX,
|
|
13707
14275
|
y: startY
|
|
13708
|
-
}, dX, dY);
|
|
14276
|
+
}, null, dX, dY);
|
|
13709
14277
|
} else if (this._markupMode === "Ellipse") {
|
|
13710
14278
|
if (lastObj) {
|
|
13711
14279
|
lastObj.setPosition(startX, startY);
|
|
@@ -13726,7 +14294,7 @@
|
|
|
13726
14294
|
} else lastObj = this.addCloud({
|
|
13727
14295
|
x: startX,
|
|
13728
14296
|
y: startY
|
|
13729
|
-
}, dX, dY);
|
|
14297
|
+
}, null, dX, dY);
|
|
13730
14298
|
}
|
|
13731
14299
|
}));
|
|
13732
14300
|
stage.on("click tap", (e => {
|
|
@@ -13818,22 +14386,12 @@
|
|
|
13818
14386
|
getMarkupLines() {
|
|
13819
14387
|
const lines = [];
|
|
13820
14388
|
this.konvaLayerFind("Line").forEach((ref => {
|
|
13821
|
-
const
|
|
13822
|
-
if (!
|
|
13823
|
-
const
|
|
13824
|
-
const absoluteTransform = ref.getAbsoluteTransform();
|
|
13825
|
-
for (let i = 0; i < linePoints.length; i += 2) {
|
|
13826
|
-
const atPoint = absoluteTransform.point({
|
|
13827
|
-
x: linePoints[i],
|
|
13828
|
-
y: linePoints[i + 1]
|
|
13829
|
-
});
|
|
13830
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13831
|
-
worldPoints.push(worldPoint);
|
|
13832
|
-
}
|
|
13833
|
-
const konvaLine = new KonvaLine(null, ref);
|
|
14389
|
+
const wcsPoints = ref.getAttr("wcsPoints");
|
|
14390
|
+
if (!wcsPoints) return;
|
|
14391
|
+
const konvaLine = new KonvaLine(null, ref, this._worldTransformer);
|
|
13834
14392
|
const line = {
|
|
13835
14393
|
id: konvaLine.id(),
|
|
13836
|
-
points:
|
|
14394
|
+
points: wcsPoints,
|
|
13837
14395
|
color: konvaLine.getColor() || "#ff0000",
|
|
13838
14396
|
type: konvaLine.getLineType() || this.lineType,
|
|
13839
14397
|
width: konvaLine.getLineWidth() || this.lineWidth
|
|
@@ -13847,17 +14405,12 @@
|
|
|
13847
14405
|
this.konvaLayerFind("Text").forEach((ref => {
|
|
13848
14406
|
const textSize = .02;
|
|
13849
14407
|
const textScale = this._worldTransformer.getScale();
|
|
13850
|
-
const
|
|
14408
|
+
const wcsPosition = ref.getAttr("wcsStart");
|
|
13851
14409
|
const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
|
|
13852
|
-
const
|
|
13853
|
-
x: position.x,
|
|
13854
|
-
y: position.y
|
|
13855
|
-
});
|
|
13856
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13857
|
-
const shape = new KonvaText(null, ref);
|
|
14410
|
+
const shape = new KonvaText(null, ref, this._worldTransformer);
|
|
13858
14411
|
const text = {
|
|
13859
14412
|
id: shape.id(),
|
|
13860
|
-
position:
|
|
14413
|
+
position: wcsPosition,
|
|
13861
14414
|
text: shape.getText(),
|
|
13862
14415
|
text_size: textSize * textScale.y,
|
|
13863
14416
|
angle: shape.getRotation(),
|
|
@@ -13871,20 +14424,16 @@
|
|
|
13871
14424
|
getMarkupRectangles() {
|
|
13872
14425
|
const rectangles = [];
|
|
13873
14426
|
this.konvaLayerFind("Rectangle").forEach((ref => {
|
|
13874
|
-
const
|
|
13875
|
-
const
|
|
13876
|
-
const
|
|
13877
|
-
|
|
13878
|
-
|
|
13879
|
-
});
|
|
13880
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13881
|
-
const scale = stageAbsoluteTransform.getMatrix()[0];
|
|
13882
|
-
const shape = new KonvaRectangle(null, ref);
|
|
14427
|
+
const wcsStart = ref.getAttr("wcsStart");
|
|
14428
|
+
const wcsEnd = ref.getAttr("wcsEnd");
|
|
14429
|
+
const screenStart = this._worldTransformer.worldToScreen(wcsStart);
|
|
14430
|
+
const screenEnd = this._worldTransformer.worldToScreen(wcsEnd);
|
|
14431
|
+
const shape = new KonvaRectangle(null, ref, this._worldTransformer);
|
|
13883
14432
|
const rectangle = {
|
|
13884
14433
|
id: shape.id(),
|
|
13885
|
-
position:
|
|
13886
|
-
width:
|
|
13887
|
-
height:
|
|
14434
|
+
position: wcsStart,
|
|
14435
|
+
width: Math.abs(screenStart.x - screenEnd.x),
|
|
14436
|
+
height: Math.abs(screenStart.y - screenEnd.y),
|
|
13888
14437
|
line_width: shape.getLineWidth(),
|
|
13889
14438
|
color: shape.getColor()
|
|
13890
14439
|
};
|
|
@@ -13895,18 +14444,13 @@
|
|
|
13895
14444
|
getMarkupEllipses() {
|
|
13896
14445
|
const ellipses = [];
|
|
13897
14446
|
this.konvaLayerFind("Ellipse").forEach((ref => {
|
|
13898
|
-
const
|
|
14447
|
+
const wcsPosition = ref.getAttr("wcsPosition");
|
|
13899
14448
|
const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
|
|
13900
|
-
const atPoint = stageAbsoluteTransform.point({
|
|
13901
|
-
x: position.x,
|
|
13902
|
-
y: position.y
|
|
13903
|
-
});
|
|
13904
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13905
14449
|
const scale = stageAbsoluteTransform.getMatrix()[0];
|
|
13906
|
-
const shape = new KonvaEllipse(null, ref);
|
|
14450
|
+
const shape = new KonvaEllipse(null, ref, this._worldTransformer);
|
|
13907
14451
|
const ellipse = {
|
|
13908
14452
|
id: shape.id(),
|
|
13909
|
-
position:
|
|
14453
|
+
position: wcsPosition,
|
|
13910
14454
|
radius: {
|
|
13911
14455
|
x: ref.getRadiusX() * scale,
|
|
13912
14456
|
y: ref.getRadiusY() * scale
|
|
@@ -13921,22 +14465,13 @@
|
|
|
13921
14465
|
getMarkupArrows() {
|
|
13922
14466
|
const arrows = [];
|
|
13923
14467
|
this.konvaLayerFind("Arrow").forEach((ref => {
|
|
13924
|
-
const
|
|
13925
|
-
const
|
|
13926
|
-
|
|
13927
|
-
y: ref.points()[1]
|
|
13928
|
-
});
|
|
13929
|
-
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
13930
|
-
const atEndPoint = absoluteTransform.point({
|
|
13931
|
-
x: ref.points()[2],
|
|
13932
|
-
y: ref.points()[3]
|
|
13933
|
-
});
|
|
13934
|
-
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
13935
|
-
const shape = new KonvaArrow(null, ref);
|
|
14468
|
+
const wcsStart = ref.getAttr("wcsStart");
|
|
14469
|
+
const wcsEnd = ref.getAttr("wcsEnd");
|
|
14470
|
+
const shape = new KonvaArrow(null, ref, this._worldTransformer);
|
|
13936
14471
|
const arrow = {
|
|
13937
14472
|
id: shape.id(),
|
|
13938
|
-
start:
|
|
13939
|
-
end:
|
|
14473
|
+
start: wcsStart,
|
|
14474
|
+
end: wcsEnd,
|
|
13940
14475
|
color: shape.getColor()
|
|
13941
14476
|
};
|
|
13942
14477
|
arrows.push(arrow);
|
|
@@ -13946,18 +14481,13 @@
|
|
|
13946
14481
|
getMarkupImages() {
|
|
13947
14482
|
const images = [];
|
|
13948
14483
|
this.konvaLayerFind("Image").forEach((ref => {
|
|
13949
|
-
const
|
|
14484
|
+
const wcsStart = ref.getAttr("wcsStart");
|
|
13950
14485
|
const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
|
|
13951
|
-
const atPoint = stageAbsoluteTransform.point({
|
|
13952
|
-
x: position.x,
|
|
13953
|
-
y: position.y
|
|
13954
|
-
});
|
|
13955
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13956
14486
|
const scale = stageAbsoluteTransform.getMatrix()[0];
|
|
13957
|
-
const shape = new KonvaImage(null, ref);
|
|
14487
|
+
const shape = new KonvaImage(null, ref, this._worldTransformer);
|
|
13958
14488
|
const image = {
|
|
13959
14489
|
id: shape.id(),
|
|
13960
|
-
position:
|
|
14490
|
+
position: wcsStart,
|
|
13961
14491
|
src: shape.getSrc(),
|
|
13962
14492
|
width: shape.getWidth() * scale,
|
|
13963
14493
|
height: shape.getHeight() * scale
|
|
@@ -13969,20 +14499,16 @@
|
|
|
13969
14499
|
getMarkupClouds() {
|
|
13970
14500
|
const clouds = [];
|
|
13971
14501
|
this.konvaLayerFind("Cloud").forEach((ref => {
|
|
13972
|
-
const
|
|
13973
|
-
const
|
|
13974
|
-
const
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
});
|
|
13978
|
-
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
13979
|
-
const scale = stageAbsoluteTransform.getMatrix()[0];
|
|
13980
|
-
const shape = new KonvaCloud(null, ref);
|
|
14502
|
+
const wcsStart = ref.getAttr("wcsStart");
|
|
14503
|
+
const wcsEnd = ref.getAttr("wcsEnd");
|
|
14504
|
+
const screenStart = this._worldTransformer.worldToScreen(wcsStart);
|
|
14505
|
+
const screenEnd = this._worldTransformer.worldToScreen(wcsEnd);
|
|
14506
|
+
const shape = new KonvaCloud(null, ref, this._worldTransformer);
|
|
13981
14507
|
const cloud = {
|
|
13982
14508
|
id: shape.id(),
|
|
13983
|
-
position:
|
|
13984
|
-
width:
|
|
13985
|
-
height:
|
|
14509
|
+
position: wcsStart,
|
|
14510
|
+
width: Math.abs(screenStart.x - screenEnd.x),
|
|
14511
|
+
height: Math.abs(screenStart.y - screenEnd.y),
|
|
13986
14512
|
line_width: shape.getLineWidth(),
|
|
13987
14513
|
color: shape.getColor()
|
|
13988
14514
|
};
|
|
@@ -14019,7 +14545,7 @@
|
|
|
14019
14545
|
width: width || this.lineWidth,
|
|
14020
14546
|
color: color || this._markupColor.asHex(),
|
|
14021
14547
|
id: id
|
|
14022
|
-
});
|
|
14548
|
+
}, null, this._worldTransformer);
|
|
14023
14549
|
this.addObject(konvaLine);
|
|
14024
14550
|
return konvaLine;
|
|
14025
14551
|
}
|
|
@@ -14126,20 +14652,21 @@
|
|
|
14126
14652
|
fontSize: fontSize || this.fontSize,
|
|
14127
14653
|
color: color || this._markupColor.asHex(),
|
|
14128
14654
|
id: id
|
|
14129
|
-
});
|
|
14655
|
+
}, null, this._worldTransformer);
|
|
14130
14656
|
this.addObject(konvaText);
|
|
14131
14657
|
return konvaText;
|
|
14132
14658
|
}
|
|
14133
|
-
addRectangle(position, width, height, lineWidth, color, id) {
|
|
14659
|
+
addRectangle(position, position2, width, height, lineWidth, color, id) {
|
|
14134
14660
|
if (!position) return;
|
|
14135
14661
|
const konvaRectangle = new KonvaRectangle({
|
|
14136
14662
|
position: position,
|
|
14663
|
+
position2: position2,
|
|
14137
14664
|
width: width,
|
|
14138
14665
|
height: height,
|
|
14139
14666
|
lineWidth: lineWidth || this.lineWidth,
|
|
14140
14667
|
color: color || this._markupColor.asHex(),
|
|
14141
14668
|
id: id
|
|
14142
|
-
});
|
|
14669
|
+
}, null, this._worldTransformer);
|
|
14143
14670
|
this.addObject(konvaRectangle);
|
|
14144
14671
|
return konvaRectangle;
|
|
14145
14672
|
}
|
|
@@ -14151,7 +14678,7 @@
|
|
|
14151
14678
|
lineWidth: lineWidth,
|
|
14152
14679
|
color: color || this._markupColor.asHex(),
|
|
14153
14680
|
id: id
|
|
14154
|
-
});
|
|
14681
|
+
}, null, this._worldTransformer);
|
|
14155
14682
|
this.addObject(konvaEllipse);
|
|
14156
14683
|
return konvaEllipse;
|
|
14157
14684
|
}
|
|
@@ -14162,20 +14689,21 @@
|
|
|
14162
14689
|
end: end,
|
|
14163
14690
|
color: color || this._markupColor.asHex(),
|
|
14164
14691
|
id: id
|
|
14165
|
-
});
|
|
14692
|
+
}, null, this._worldTransformer);
|
|
14166
14693
|
this.addObject(konvaArrow);
|
|
14167
14694
|
return konvaArrow;
|
|
14168
14695
|
}
|
|
14169
|
-
addCloud(position, width, height, lineWidth, color, id) {
|
|
14696
|
+
addCloud(position, position2, width, height, lineWidth, color, id) {
|
|
14170
14697
|
if (!position || !width || !height) return;
|
|
14171
14698
|
const konvaCloud = new KonvaCloud({
|
|
14172
14699
|
position: position,
|
|
14700
|
+
position2: position2,
|
|
14173
14701
|
width: width,
|
|
14174
14702
|
height: height,
|
|
14175
14703
|
color: color || this._markupColor.asHex(),
|
|
14176
14704
|
lineWidth: lineWidth || this.lineWidth,
|
|
14177
14705
|
id: id
|
|
14178
|
-
});
|
|
14706
|
+
}, null, this._worldTransformer);
|
|
14179
14707
|
this.addObject(konvaCloud);
|
|
14180
14708
|
return konvaCloud;
|
|
14181
14709
|
}
|
|
@@ -14193,7 +14721,7 @@
|
|
|
14193
14721
|
maxWidth: this._konvaStage.width() - position.x,
|
|
14194
14722
|
maxHeight: this._konvaStage.height() - position.y,
|
|
14195
14723
|
id: id
|
|
14196
|
-
});
|
|
14724
|
+
}, null, this._worldTransformer);
|
|
14197
14725
|
this.addObject(konvaImage);
|
|
14198
14726
|
return konvaImage;
|
|
14199
14727
|
}
|
|
@@ -57514,7 +58042,7 @@ void main() {
|
|
|
57514
58042
|
// acknowledge and accept the above terms.
|
|
57515
58043
|
///////////////////////////////////////////////////////////////////////////////
|
|
57516
58044
|
/**
|
|
57517
|
-
*
|
|
58045
|
+
* Viewer commands registry. Use this registry to register custom commands.
|
|
57518
58046
|
*
|
|
57519
58047
|
* To implement custom command:
|
|
57520
58048
|
*
|
|
@@ -57588,6 +58116,45 @@ void main() {
|
|
|
57588
58116
|
commands.registerCommandAlias("ne", "k3DViewNE");
|
|
57589
58117
|
commands.registerCommandAlias("nw", "k3DViewNW");
|
|
57590
58118
|
|
|
58119
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
58120
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
58121
|
+
// All rights reserved.
|
|
58122
|
+
//
|
|
58123
|
+
// This software and its documentation and related materials are owned by
|
|
58124
|
+
// the Alliance. The software may only be incorporated into application
|
|
58125
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
58126
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
58127
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
58128
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
58129
|
+
// protected by copyright law and international treaty provisions. Application
|
|
58130
|
+
// programs incorporating this software must include the following statement
|
|
58131
|
+
// with their copyright notices:
|
|
58132
|
+
//
|
|
58133
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
58134
|
+
// license agreement with Open Design Alliance.
|
|
58135
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
58136
|
+
// All rights reserved.
|
|
58137
|
+
//
|
|
58138
|
+
// By use of this software, its documentation or related materials, you
|
|
58139
|
+
// acknowledge and accept the above terms.
|
|
58140
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
58141
|
+
class BackgroundComponent {
|
|
58142
|
+
constructor(viewer) {
|
|
58143
|
+
this.syncOptions = () => {
|
|
58144
|
+
this.backgroundColor.setHex(0xffffff);
|
|
58145
|
+
};
|
|
58146
|
+
this.viewer = viewer;
|
|
58147
|
+
this.backgroundColor = new Color(0xffffff);
|
|
58148
|
+
this.viewer.renderer.setClearColor(this.backgroundColor);
|
|
58149
|
+
this.viewer.scene.background = this.backgroundColor;
|
|
58150
|
+
this.viewer.addEventListener("optionschange", this.syncOptions);
|
|
58151
|
+
}
|
|
58152
|
+
dispose() {
|
|
58153
|
+
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
58154
|
+
this.viewer.scene.background = undefined;
|
|
58155
|
+
}
|
|
58156
|
+
}
|
|
58157
|
+
|
|
57591
58158
|
/**
|
|
57592
58159
|
* https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts
|
|
57593
58160
|
*/
|
|
@@ -57744,25 +58311,16 @@ void main() {
|
|
|
57744
58311
|
// By use of this software, its documentation or related materials, you
|
|
57745
58312
|
// acknowledge and accept the above terms.
|
|
57746
58313
|
///////////////////////////////////////////////////////////////////////////////
|
|
57747
|
-
class
|
|
58314
|
+
class RoomEnvironmentComponent {
|
|
57748
58315
|
constructor(viewer) {
|
|
57749
|
-
this.syncOptions = () => {
|
|
57750
|
-
this.backgroundColor.setHex(0xffffff);
|
|
57751
|
-
};
|
|
57752
58316
|
this.viewer = viewer;
|
|
57753
|
-
this.backgroundColor = new Color(0xffffff);
|
|
57754
58317
|
const environment = new RoomEnvironment();
|
|
57755
58318
|
const pmremGenerator = new PMREMGenerator(this.viewer.renderer);
|
|
57756
|
-
this.viewer.renderer.setClearColor(this.backgroundColor);
|
|
57757
|
-
this.viewer.scene.background = this.backgroundColor;
|
|
57758
58319
|
this.viewer.scene.environment = pmremGenerator.fromScene(environment).texture;
|
|
57759
|
-
this.viewer.addEventListener("optionschange", this.syncOptions);
|
|
57760
58320
|
environment.dispose();
|
|
57761
58321
|
}
|
|
57762
58322
|
dispose() {
|
|
57763
|
-
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
57764
58323
|
this.viewer.scene.environment = undefined;
|
|
57765
|
-
this.viewer.scene.background = undefined;
|
|
57766
58324
|
}
|
|
57767
58325
|
}
|
|
57768
58326
|
|
|
@@ -57791,9 +58349,11 @@ void main() {
|
|
|
57791
58349
|
class CameraComponent {
|
|
57792
58350
|
constructor(viewer) {
|
|
57793
58351
|
this.geometryEnd = () => {
|
|
58352
|
+
const extentsCenter = this.viewer.extents.getCenter(new Vector3());
|
|
57794
58353
|
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
|
|
57795
58354
|
const rendererSize = this.viewer.renderer.getSize(new Vector2());
|
|
57796
58355
|
const aspect = rendererSize.x / rendererSize.y;
|
|
58356
|
+
// TODO: do not change the camera and target after opening the second model in "append" mode
|
|
57797
58357
|
let sceneCamera;
|
|
57798
58358
|
this.viewer.scene.traverse((object) => {
|
|
57799
58359
|
if (object.isCamera)
|
|
@@ -57821,6 +58381,7 @@ void main() {
|
|
|
57821
58381
|
camera.far = extentsSize * 100;
|
|
57822
58382
|
camera.updateProjectionMatrix();
|
|
57823
58383
|
}
|
|
58384
|
+
this.viewer.target.copy(extentsCenter);
|
|
57824
58385
|
if (!sceneCamera) {
|
|
57825
58386
|
this.viewer.executeCommand("setDefaultViewPosition");
|
|
57826
58387
|
}
|
|
@@ -57861,7 +58422,6 @@ void main() {
|
|
|
57861
58422
|
const extents = new Box3();
|
|
57862
58423
|
this.viewer.scene.traverseVisible((object) => !object.children.length && extents.expandByObject(object));
|
|
57863
58424
|
this.viewer.extents.copy(extents);
|
|
57864
|
-
this.viewer.target.copy(extents.getCenter(new Vector3()));
|
|
57865
58425
|
};
|
|
57866
58426
|
this.viewer = viewer;
|
|
57867
58427
|
this.viewer.addEventListener("databasechunk", this.syncExtents);
|
|
@@ -58166,6 +58726,7 @@ void main() {
|
|
|
58166
58726
|
components.registerComponent("ExtentsComponent", (viewer) => new ExtentsComponent(viewer));
|
|
58167
58727
|
components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
|
|
58168
58728
|
components.registerComponent("BackgroundComponent", (viewer) => new BackgroundComponent(viewer));
|
|
58729
|
+
components.registerComponent("RoomEnvironmentComponent", (viewer) => new RoomEnvironmentComponent(viewer));
|
|
58169
58730
|
// components.registerComponent("LightComponent", (viewer) => new LightComponent(viewer));
|
|
58170
58731
|
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
58171
58732
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|