@inweb/viewer-three 26.5.2 → 26.5.3
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 +61 -47
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -2
- package/package.json +5 -5
package/dist/viewer-three.js
CHANGED
|
@@ -79248,7 +79248,10 @@ void main() {
|
|
|
79248
79248
|
};
|
|
79249
79249
|
}
|
|
79250
79250
|
}
|
|
79251
|
-
const ARC_RADIUS =
|
|
79251
|
+
const ARC_RADIUS = 8;
|
|
79252
|
+
const ARC_LENGTH = 15;
|
|
79253
|
+
const MIN_CLOUD_WIDTH = 50;
|
|
79254
|
+
const MIN_CLOUD_HEIGHT = 50;
|
|
79252
79255
|
this._ref = new Konva.Shape({
|
|
79253
79256
|
x: params.position.x,
|
|
79254
79257
|
y: params.position.y,
|
|
@@ -79260,63 +79263,76 @@ void main() {
|
|
|
79260
79263
|
strokeScaleEnabled: false,
|
|
79261
79264
|
globalCompositeOperation: "source-over",
|
|
79262
79265
|
sceneFunc: (context, shape) => {
|
|
79263
|
-
|
|
79264
|
-
|
|
79265
|
-
const midY = position.y + height / 2;
|
|
79266
|
-
return {
|
|
79267
|
-
x: midX,
|
|
79268
|
-
y: midY
|
|
79269
|
-
};
|
|
79270
|
-
}
|
|
79266
|
+
const width = this._ref.width();
|
|
79267
|
+
const height = this._ref.height();
|
|
79271
79268
|
const points = [ {
|
|
79272
79269
|
x: 0,
|
|
79273
79270
|
y: 0
|
|
79274
79271
|
}, {
|
|
79275
|
-
x: 0 +
|
|
79272
|
+
x: 0 + width,
|
|
79276
79273
|
y: 0
|
|
79277
79274
|
}, {
|
|
79278
|
-
x: 0 +
|
|
79279
|
-
y: 0 +
|
|
79275
|
+
x: 0 + width,
|
|
79276
|
+
y: 0 + height
|
|
79280
79277
|
}, {
|
|
79281
79278
|
x: 0,
|
|
79282
|
-
y: 0 +
|
|
79279
|
+
y: 0 + height
|
|
79283
79280
|
}, {
|
|
79284
79281
|
x: 0,
|
|
79285
79282
|
y: 0
|
|
79286
79283
|
} ];
|
|
79287
|
-
|
|
79288
|
-
|
|
79289
|
-
|
|
79290
|
-
|
|
79291
|
-
|
|
79292
|
-
|
|
79293
|
-
|
|
79294
|
-
|
|
79295
|
-
|
|
79296
|
-
|
|
79297
|
-
const
|
|
79298
|
-
|
|
79299
|
-
|
|
79300
|
-
|
|
79301
|
-
|
|
79302
|
-
let
|
|
79303
|
-
|
|
79304
|
-
|
|
79305
|
-
|
|
79306
|
-
|
|
79307
|
-
|
|
79308
|
-
|
|
79309
|
-
|
|
79310
|
-
|
|
79311
|
-
|
|
79312
|
-
|
|
79284
|
+
if (width >= MIN_CLOUD_WIDTH - 1 || height >= MIN_CLOUD_HEIGHT - 1) drawCloud(ARC_RADIUS, ARC_LENGTH); else if (width >= MIN_CLOUD_WIDTH / 2 || height >= MIN_CLOUD_HEIGHT / 2) drawCloud(ARC_RADIUS / 2, ARC_LENGTH / 2); else drawRectangle();
|
|
79285
|
+
function calculateMidpoint(position) {
|
|
79286
|
+
const midX = position.x + width / 2;
|
|
79287
|
+
const midY = position.y + height / 2;
|
|
79288
|
+
return {
|
|
79289
|
+
x: midX,
|
|
79290
|
+
y: midY
|
|
79291
|
+
};
|
|
79292
|
+
}
|
|
79293
|
+
function drawCloud(arcRadius, arcLength) {
|
|
79294
|
+
const midPoint = calculateMidpoint({
|
|
79295
|
+
x: 0,
|
|
79296
|
+
y: 0
|
|
79297
|
+
});
|
|
79298
|
+
context.beginPath();
|
|
79299
|
+
for (let iPoint = 0; iPoint < points.length - 1; iPoint++) {
|
|
79300
|
+
let approxArcLength = arcLength;
|
|
79301
|
+
const dx = points[iPoint + 1].x - points[iPoint].x;
|
|
79302
|
+
const dy = points[iPoint + 1].y - points[iPoint].y;
|
|
79303
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
79304
|
+
const arcCount = Math.floor(length / approxArcLength);
|
|
79305
|
+
const lengthMod = length % approxArcLength;
|
|
79306
|
+
approxArcLength = arcLength + arcCount / lengthMod;
|
|
79307
|
+
let pX = points[iPoint].x + dx / arcCount / 2;
|
|
79308
|
+
let pY = points[iPoint].y + dy / arcCount / 2;
|
|
79309
|
+
const pEndX = points[iPoint + 1].x;
|
|
79310
|
+
const pEndY = points[iPoint + 1].y;
|
|
79311
|
+
const endAngle = Math.atan((pEndY - pY) / (pEndX - pX));
|
|
79312
|
+
const startAngle = endAngle + Math.PI;
|
|
79313
|
+
const counterClockwise = pX > midPoint.x && pY > midPoint.y;
|
|
79314
|
+
for (let iArc = 0; iArc < arcCount; iArc++) {
|
|
79315
|
+
if (counterClockwise) {
|
|
79316
|
+
context.arc(pX, pY, arcRadius, endAngle, startAngle);
|
|
79317
|
+
} else {
|
|
79318
|
+
context.arc(pX, pY, arcRadius, startAngle, endAngle);
|
|
79319
|
+
}
|
|
79320
|
+
pX += dx / arcCount;
|
|
79321
|
+
pY += dy / arcCount;
|
|
79313
79322
|
}
|
|
79314
|
-
pX += dx / arcCount;
|
|
79315
|
-
pY += dy / arcCount;
|
|
79316
79323
|
}
|
|
79324
|
+
context.closePath();
|
|
79325
|
+
context.fillStrokeShape(shape);
|
|
79326
|
+
}
|
|
79327
|
+
function drawRectangle() {
|
|
79328
|
+
context.beginPath();
|
|
79329
|
+
context.lineTo(points[1].x, points[1].y);
|
|
79330
|
+
context.lineTo(points[2].x, points[2].y);
|
|
79331
|
+
context.lineTo(points[3].x, points[3].y);
|
|
79332
|
+
context.lineTo(points[4].x, points[4].y);
|
|
79333
|
+
context.closePath();
|
|
79334
|
+
context.fillStrokeShape(shape);
|
|
79317
79335
|
}
|
|
79318
|
-
context.closePath();
|
|
79319
|
-
context.fillStrokeShape(shape);
|
|
79320
79336
|
}
|
|
79321
79337
|
});
|
|
79322
79338
|
this._ref.className = "Cloud";
|
|
@@ -79336,10 +79352,8 @@ void main() {
|
|
|
79336
79352
|
if (scaleByX) newWidth *= attrs.scaleX;
|
|
79337
79353
|
let newHeight = this._ref.height();
|
|
79338
79354
|
if (scaleByY) newHeight *= attrs.scaleY;
|
|
79339
|
-
|
|
79340
|
-
|
|
79341
|
-
if (newWidth < minWidth) newWidth = minWidth;
|
|
79342
|
-
if (newHeight < minHeight) newHeight = minHeight;
|
|
79355
|
+
if (newWidth < MIN_CLOUD_WIDTH) newWidth = MIN_CLOUD_WIDTH;
|
|
79356
|
+
if (newHeight < MIN_CLOUD_HEIGHT) newHeight = MIN_CLOUD_HEIGHT;
|
|
79343
79357
|
if (scaleByX) {
|
|
79344
79358
|
this._ref.width(newWidth);
|
|
79345
79359
|
}
|