@shapediver/viewer.rendering-engine.intersection-engine 3.13.20 → 3.14.0
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/implementation/BoxSelection.d.ts +21 -0
- package/dist/implementation/BoxSelection.d.ts.map +1 -0
- package/dist/implementation/BoxSelection.js +114 -0
- package/dist/implementation/BoxSelection.js.map +1 -0
- package/dist/implementation/IntersectionEngine.d.ts +7 -3
- package/dist/implementation/IntersectionEngine.d.ts.map +1 -1
- package/dist/implementation/IntersectionEngine.js +45 -36
- package/dist/implementation/IntersectionEngine.js.map +1 -1
- package/dist/implementation/SelectionBox.d.ts +31 -0
- package/dist/implementation/SelectionBox.d.ts.map +1 -0
- package/dist/implementation/SelectionBox.js +211 -0
- package/dist/implementation/SelectionBox.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/IIntersectionEngine.d.ts +6 -2
- package/dist/interfaces/IIntersectionEngine.d.ts.map +1 -1
- package/dist/interfaces/ISelectionBox.d.ts +22 -0
- package/dist/interfaces/ISelectionBox.d.ts.map +1 -0
- package/dist/interfaces/ISelectionBox.js +3 -0
- package/dist/interfaces/ISelectionBox.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IRay } from "@shapediver/viewer.shared.types";
|
|
2
|
+
export declare class SelectionBox {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(canvas: HTMLCanvasElement);
|
|
5
|
+
get coordinates(): {
|
|
6
|
+
start: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
end: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
} | undefined;
|
|
15
|
+
onDown(event: PointerEvent, ray: IRay): void;
|
|
16
|
+
onEnd(event: PointerEvent, ray: IRay): void;
|
|
17
|
+
onMove(event: PointerEvent, ray: IRay, insertionActive: boolean, removalActive: boolean): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
private updateSelectionBox;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=BoxSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoxSelection.d.ts","sourceRoot":"","sources":["../../src/implementation/BoxSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,iCAAiC,CAAC;AAErD,qBAAa,YAAY;;gBAQZ,MAAM,EAAE,iBAAiB;IAIrC,IAAW,WAAW;;;;;;;;;kBAErB;IAEM,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI;IAgB5C,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI;IAW3C,MAAM,CACZ,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,IAAI,EACT,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,OAAO,GACpB,IAAI;IAYA,KAAK,IAAI,IAAI;IAMpB,OAAO,CAAC,kBAAkB;CAsD1B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SelectionBox_canvas, _SelectionBox_htmlElement, _SelectionBox_coordinates;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SelectionBox = void 0;
|
|
16
|
+
class SelectionBox {
|
|
17
|
+
constructor(canvas) {
|
|
18
|
+
_SelectionBox_canvas.set(this, void 0);
|
|
19
|
+
_SelectionBox_htmlElement.set(this, void 0);
|
|
20
|
+
_SelectionBox_coordinates.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _SelectionBox_canvas, canvas, "f");
|
|
22
|
+
}
|
|
23
|
+
get coordinates() {
|
|
24
|
+
return __classPrivateFieldGet(this, _SelectionBox_coordinates, "f");
|
|
25
|
+
}
|
|
26
|
+
onDown(event, ray) {
|
|
27
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
28
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
29
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
30
|
+
__classPrivateFieldSet(this, _SelectionBox_coordinates, {
|
|
31
|
+
start: {
|
|
32
|
+
x: x,
|
|
33
|
+
y: y,
|
|
34
|
+
},
|
|
35
|
+
end: {
|
|
36
|
+
x: x,
|
|
37
|
+
y: y,
|
|
38
|
+
},
|
|
39
|
+
}, "f");
|
|
40
|
+
}
|
|
41
|
+
onEnd(event, ray) {
|
|
42
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
43
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
44
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
45
|
+
__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end = {
|
|
46
|
+
x: x,
|
|
47
|
+
y: y,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
onMove(event, ray, insertionActive, removalActive) {
|
|
51
|
+
// update box selection
|
|
52
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
53
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
54
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
55
|
+
__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end = {
|
|
56
|
+
x: x,
|
|
57
|
+
y: y,
|
|
58
|
+
};
|
|
59
|
+
this.updateSelectionBox(insertionActive, removalActive);
|
|
60
|
+
}
|
|
61
|
+
reset() {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = __classPrivateFieldGet(this, _SelectionBox_htmlElement, "f")) === null || _a === void 0 ? void 0 : _a.remove();
|
|
64
|
+
__classPrivateFieldSet(this, _SelectionBox_htmlElement, undefined, "f");
|
|
65
|
+
__classPrivateFieldSet(this, _SelectionBox_coordinates, undefined, "f");
|
|
66
|
+
}
|
|
67
|
+
updateSelectionBox(insertionActive, removalActive) {
|
|
68
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_coordinates, "f"))
|
|
69
|
+
return;
|
|
70
|
+
let color = "0, 0, 255"; // blue
|
|
71
|
+
if (insertionActive && !removalActive) {
|
|
72
|
+
color = "0, 255, 0"; // green
|
|
73
|
+
}
|
|
74
|
+
else if (!insertionActive && removalActive) {
|
|
75
|
+
color = "255, 0, 0"; // red
|
|
76
|
+
}
|
|
77
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f")) {
|
|
78
|
+
// create selection box div
|
|
79
|
+
__classPrivateFieldSet(this, _SelectionBox_htmlElement, document.createElement("div"), "f");
|
|
80
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.position = "absolute";
|
|
81
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border = `1px solid rgba(${color}, 0.8)`;
|
|
82
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.backgroundColor = `rgba(${color}, 0.1)`;
|
|
83
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.pointerEvents = "none";
|
|
84
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.zIndex = "9999"; // Ensure it's on top
|
|
85
|
+
document.body.appendChild(__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f"));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// check if the color needs to be updated
|
|
89
|
+
const currentBorderColor = __classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border;
|
|
90
|
+
const desiredBorderColor = `1px solid rgba(${color}, 0.8)`;
|
|
91
|
+
if (currentBorderColor !== desiredBorderColor) {
|
|
92
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border = desiredBorderColor;
|
|
93
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.backgroundColor = `rgba(${color}, 0.1)`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
97
|
+
// Convert normalized coordinates back to document coordinates
|
|
98
|
+
const convertedStartX = ((__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x + 1) / 2) * rect.width + rect.left;
|
|
99
|
+
const convertedStartY = ((1 - __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y) / 2) * rect.height + rect.top;
|
|
100
|
+
const convertedEndX = ((__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x + 1) / 2) * rect.width + rect.left;
|
|
101
|
+
const convertedEndY = ((1 - __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y) / 2) * rect.height + rect.top;
|
|
102
|
+
const x = Math.min(convertedStartX, convertedEndX);
|
|
103
|
+
const y = Math.min(convertedStartY, convertedEndY);
|
|
104
|
+
const width = Math.abs(convertedEndX - convertedStartX);
|
|
105
|
+
const height = Math.abs(convertedEndY - convertedStartY);
|
|
106
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.left = `${x}px`;
|
|
107
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.top = `${y}px`;
|
|
108
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.width = `${width}px`;
|
|
109
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.height = `${height}px`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.SelectionBox = SelectionBox;
|
|
113
|
+
_SelectionBox_canvas = new WeakMap(), _SelectionBox_htmlElement = new WeakMap(), _SelectionBox_coordinates = new WeakMap();
|
|
114
|
+
//# sourceMappingURL=BoxSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoxSelection.js","sourceRoot":"","sources":["../../src/implementation/BoxSelection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,MAAa,YAAY;IAQxB,YAAY,MAAyB;QAPrC,uCAA2B;QAC3B,4CAA8B;QAC9B,4CAGE;QAGD,uBAAA,IAAI,wBAAW,MAAM,MAAA,CAAC;IACvB,CAAC;IAED,IAAW,WAAW;QACrB,OAAO,uBAAA,IAAI,iCAAa,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,KAAmB,EAAE,GAAS;QAC3C,MAAM,IAAI,GAAG,uBAAA,IAAI,4BAAQ,CAAC,qBAAqB,EAAE,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAA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AAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,eAAe,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,eAAe,CAAC,CAAC;QAEzD,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACxC,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC;QACvC,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC;QAC7C,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;IAChD,CAAC;CACD;AAxHD,oCAwHC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ITreeNode } from "@shapediver/viewer.shared.node-tree";
|
|
2
|
-
import { GeometryData,
|
|
2
|
+
import { GeometryData, IIntersectionDefinition, IIntersectionFilter, IRay, IRayTracingIntersection } from "@shapediver/viewer.shared.types";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
import { IIntersectionEngine } from "../interfaces/IIntersectionEngine";
|
|
5
|
+
import { SelectionBox } from "./SelectionBox";
|
|
5
6
|
export declare class IntersectionEngine implements IIntersectionEngine {
|
|
6
7
|
private readonly _eventEngine;
|
|
7
8
|
private readonly _raycaster;
|
|
@@ -10,10 +11,13 @@ export declare class IntersectionEngine implements IIntersectionEngine {
|
|
|
10
11
|
private _intersectNodes;
|
|
11
12
|
private constructor();
|
|
12
13
|
static get instance(): IntersectionEngine;
|
|
13
|
-
intersect(ray: IRay, viewportId: string, filterCriteria?: IIntersectionFilter[],
|
|
14
|
+
intersect(ray: IRay, viewportId: string, filterCriteria?: IIntersectionFilter[], options?: {
|
|
15
|
+
rayCasterParams?: THREE.RaycasterParameters;
|
|
16
|
+
selectionBox?: SelectionBox;
|
|
17
|
+
}): IIntersectionDefinition[];
|
|
14
18
|
intersectNode(ray: IRay, node: ITreeNode, geometryData: {
|
|
15
19
|
[key: string]: GeometryData;
|
|
16
|
-
}, viewportId: string, filterCriteria?: IIntersectionFilter[], rayCasterParams?: THREE.RaycasterParameters):
|
|
20
|
+
}, viewportId: string, filterCriteria?: IIntersectionFilter[], rayCasterParams?: THREE.RaycasterParameters): IRayTracingIntersection[] | undefined;
|
|
17
21
|
/**
|
|
18
22
|
* Gather all nodes that contain geometry data.
|
|
19
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntersectionEngine.d.ts","sourceRoot":"","sources":["../../src/implementation/IntersectionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAO,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACN,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"IntersectionEngine.d.ts","sourceRoot":"","sources":["../../src/implementation/IntersectionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAO,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACN,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,IAAI,EACJ,uBAAuB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,kBAAmB,YAAW,mBAAmB;IAG7D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqC;IAClE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAE9C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqB;IAE7C,OAAO,CAAC,eAAe,CAMd;IAMT,OAAO;IAcP,WAAkB,QAAQ,uBAEzB;IAMM,SAAS,CACf,GAAG,EAAE,IAAI,EACT,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,mBAAmB,EAAE,EACtC,OAAO,CAAC,EAAE;QACT,eAAe,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC;QAC5C,YAAY,CAAC,EAAE,YAAY,CAAC;KAC5B,GACC,uBAAuB,EAAE;IAkErB,aAAa,CACnB,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,SAAS,EACf,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;KAAC,EAC3C,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,mBAAmB,EAAE,EACtC,eAAe,CAAC,EAAE,KAAK,CAAC,mBAAmB,GACzC,uBAAuB,EAAE,GAAG,SAAS;IAyCxC;;OAEG;IACH,OAAO,CAAC,WAAW;IAyCnB;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;CAyDxB"}
|
|
@@ -49,42 +49,50 @@ class IntersectionEngine {
|
|
|
49
49
|
}
|
|
50
50
|
// #endregion Public Static Getters And Setters (1)
|
|
51
51
|
// #region Public Methods (2)
|
|
52
|
-
intersect(ray, viewportId, filterCriteria,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
intersect(ray, viewportId, filterCriteria, options) {
|
|
53
|
+
if (options === null || options === void 0 ? void 0 : options.selectionBox) {
|
|
54
|
+
const selectionBox = options.selectionBox;
|
|
55
|
+
return selectionBox.intersectObjects(this._intersectNodes.map((n) => n.node), filterCriteria || []);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
let intersections = [];
|
|
59
|
+
this._intersectNodes.forEach((i) => {
|
|
60
|
+
const currentIntersections = this.intersectNode(ray, i.node, i.geometryData, viewportId, filterCriteria, options === null || options === void 0 ? void 0 : options.rayCasterParams);
|
|
61
|
+
if (currentIntersections)
|
|
62
|
+
intersections = intersections.concat(currentIntersections);
|
|
63
|
+
});
|
|
64
|
+
intersections.sort((a, b) => {
|
|
65
|
+
const distanceDiff = a.distance - b.distance;
|
|
66
|
+
if (distanceDiff !== 0)
|
|
67
|
+
return distanceDiff;
|
|
68
|
+
// if the distance is the same, sort by the closest InteractionData within the sceneTree
|
|
69
|
+
let depthA = Infinity;
|
|
70
|
+
let depthB = Infinity;
|
|
71
|
+
const computeDepth = (targetNode, node, depth = 0) => {
|
|
72
|
+
if (targetNode === node)
|
|
73
|
+
return depth;
|
|
74
|
+
if (node.parent)
|
|
75
|
+
return computeDepth(targetNode, node.parent, depth + 1);
|
|
76
|
+
return Infinity;
|
|
77
|
+
};
|
|
78
|
+
if (a.geometryData) {
|
|
79
|
+
a.node.traverse((node) => {
|
|
80
|
+
if (a.geometryData &&
|
|
81
|
+
node.data.includes(a.geometryData))
|
|
82
|
+
depthA = computeDepth(a.node, node);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (b.geometryData) {
|
|
86
|
+
b.node.traverse((node) => {
|
|
87
|
+
if (b.geometryData &&
|
|
88
|
+
node.data.includes(b.geometryData))
|
|
89
|
+
depthB = computeDepth(b.node, node);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return depthA - depthB;
|
|
93
|
+
});
|
|
94
|
+
return intersections;
|
|
95
|
+
}
|
|
88
96
|
}
|
|
89
97
|
intersectNode(ray, node, geometryData, viewportId, filterCriteria, rayCasterParams) {
|
|
90
98
|
if (node.visible === false)
|
|
@@ -169,6 +177,7 @@ class IntersectionEngine {
|
|
|
169
177
|
point: [i.point.x, i.point.y, i.point.z],
|
|
170
178
|
node: node,
|
|
171
179
|
geometryData: geometryData[`${i.object.parent.SDid}_${i.object.parent.SDversion}`],
|
|
180
|
+
type: "RayTracingIntersection",
|
|
172
181
|
};
|
|
173
182
|
return intersectionDefinition;
|
|
174
183
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntersectionEngine.js","sourceRoot":"","sources":["../../src/implementation/IntersectionEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iFAA2E;AAC3E,+EAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"IntersectionEngine.js","sourceRoot":"","sources":["../../src/implementation/IntersectionEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iFAA2E;AAC3E,+EAA0E;AAC1E,yEAMyC;AACzC,6CAA+B;AAI/B,MAAa,kBAAkB;IAiB9B,4BAA4B;IAE5B,2BAA2B;IAE3B;QApBA,yBAAyB;QAER,iBAAY,GAAgB,oCAAW,CAAC,QAAQ,CAAC;QACjD,eAAU,GAAoB,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpD,UAAK,GAAU,8BAAI,CAAC,QAAQ,CAAC;QAItC,oBAAe,GAMjB,EAAE,CAAC;QAOR,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,YAAY,CAAC,WAAW,CAC5B,kCAAS,CAAC,QAAQ,CAAC,gBAAgB,EACnC,GAAG,EAAE;YACJ,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CACD,CAAC;IACH,CAAC;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H;YACD,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;YACtD,OAAO,aAAa,CAAC;SACrB;IACF,CAAC;CAGD;AAnRD,gDAmRC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ITreeNode } from "@shapediver/viewer.shared.node-tree";
|
|
2
|
+
import { IBoxSelectionIntersection, IIntersectionFilter } from "@shapediver/viewer.shared.types";
|
|
3
|
+
import { vec2, vec3 } from "gl-matrix";
|
|
4
|
+
import { ISelectionBox } from "../interfaces/ISelectionBox";
|
|
5
|
+
export declare class SelectionBox implements ISelectionBox {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(canvas: HTMLCanvasElement);
|
|
8
|
+
get coordinates(): {
|
|
9
|
+
start: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
end: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
} | undefined;
|
|
18
|
+
intersectObjects(nodes: ITreeNode[], filterCriteria: IIntersectionFilter[]): IBoxSelectionIntersection[];
|
|
19
|
+
/**
|
|
20
|
+
* Intersect drawing tool points with the selection box
|
|
21
|
+
* @param points Array of 3D points to test
|
|
22
|
+
* @returns Array of indices of points that are inside the selection box
|
|
23
|
+
*/
|
|
24
|
+
intersectPoints(points: vec3[]): number[];
|
|
25
|
+
onDown(event: PointerEvent, project: (p: vec3) => vec2): void;
|
|
26
|
+
onEnd(event: PointerEvent): void;
|
|
27
|
+
onMove(event: PointerEvent, insertionActive: boolean, removalActive: boolean): void;
|
|
28
|
+
reset(): void;
|
|
29
|
+
private updateSelectionBox;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=SelectionBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionBox.d.ts","sourceRoot":"","sources":["../../src/implementation/SelectionBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAErC,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAE1D,qBAAa,YAAa,YAAW,aAAa;;gBASrC,MAAM,EAAE,iBAAiB;IAIrC,IAAW,WAAW;;;;;;;;;kBAErB;IAEM,gBAAgB,CACtB,KAAK,EAAE,SAAS,EAAE,EAClB,cAAc,EAAE,mBAAmB,EAAE,GACnC,yBAAyB,EAAE;IA4F9B;;;;OAIG;IACI,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE;IAsCzC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAiB7D,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAWhC,MAAM,CACZ,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,OAAO,GACpB,IAAI;IAYA,KAAK,IAAI,IAAI;IAMpB,OAAO,CAAC,kBAAkB;CAsD1B"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SelectionBox_canvas, _SelectionBox_coordinates, _SelectionBox_htmlElement, _SelectionBox_project;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SelectionBox = void 0;
|
|
16
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
17
|
+
class SelectionBox {
|
|
18
|
+
constructor(canvas) {
|
|
19
|
+
_SelectionBox_canvas.set(this, void 0);
|
|
20
|
+
_SelectionBox_coordinates.set(this, void 0);
|
|
21
|
+
_SelectionBox_htmlElement.set(this, void 0);
|
|
22
|
+
_SelectionBox_project.set(this, void 0);
|
|
23
|
+
__classPrivateFieldSet(this, _SelectionBox_canvas, canvas, "f");
|
|
24
|
+
}
|
|
25
|
+
get coordinates() {
|
|
26
|
+
return __classPrivateFieldGet(this, _SelectionBox_coordinates, "f");
|
|
27
|
+
}
|
|
28
|
+
intersectObjects(nodes, filterCriteria) {
|
|
29
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_coordinates, "f"))
|
|
30
|
+
return [];
|
|
31
|
+
const minX = Math.min(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x);
|
|
32
|
+
const maxX = Math.max(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x);
|
|
33
|
+
const minY = Math.min(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y);
|
|
34
|
+
const maxY = Math.max(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y);
|
|
35
|
+
// check if the selection is from the right or left side
|
|
36
|
+
const isRightSelection = __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x < __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x;
|
|
37
|
+
// for all nodes that can be intersected
|
|
38
|
+
// check if the bounding sphere center is within the selection box
|
|
39
|
+
const selectedObjects = [];
|
|
40
|
+
nodes.forEach((i) => {
|
|
41
|
+
const shouldTest = filterCriteria
|
|
42
|
+
? filterCriteria.some((fc) => fc(i))
|
|
43
|
+
: true;
|
|
44
|
+
if (!shouldTest)
|
|
45
|
+
return;
|
|
46
|
+
// for the selection from the right side, all points of the bounding box have to be included
|
|
47
|
+
let isIncluded = false;
|
|
48
|
+
let breakLoop = false;
|
|
49
|
+
for (let xPoint of [i.boundingBox.min[0], i.boundingBox.max[0]]) {
|
|
50
|
+
for (let yPoint of [
|
|
51
|
+
i.boundingBox.min[1],
|
|
52
|
+
i.boundingBox.max[1],
|
|
53
|
+
]) {
|
|
54
|
+
for (let zPoint of [
|
|
55
|
+
i.boundingBox.min[2],
|
|
56
|
+
i.boundingBox.max[2],
|
|
57
|
+
]) {
|
|
58
|
+
const projection = __classPrivateFieldGet(this, _SelectionBox_project, "f").call(this, gl_matrix_1.vec3.fromValues(xPoint, yPoint, zPoint));
|
|
59
|
+
if (isRightSelection) {
|
|
60
|
+
if (!(projection[0] >= minX &&
|
|
61
|
+
projection[0] <= maxX &&
|
|
62
|
+
projection[1] >= minY &&
|
|
63
|
+
projection[1] <= maxY)) {
|
|
64
|
+
isIncluded = false;
|
|
65
|
+
breakLoop = true;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
isIncluded = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (projection[0] >= minX &&
|
|
73
|
+
projection[0] <= maxX &&
|
|
74
|
+
projection[1] >= minY &&
|
|
75
|
+
projection[1] <= maxY) {
|
|
76
|
+
isIncluded = true;
|
|
77
|
+
breakLoop = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (breakLoop)
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (breakLoop)
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
if (breakLoop)
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (isIncluded) {
|
|
90
|
+
selectedObjects.push({
|
|
91
|
+
node: i,
|
|
92
|
+
type: "BoxSelectionIntersection",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return selectedObjects;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Intersect drawing tool points with the selection box
|
|
100
|
+
* @param points Array of 3D points to test
|
|
101
|
+
* @returns Array of indices of points that are inside the selection box
|
|
102
|
+
*/
|
|
103
|
+
intersectPoints(points) {
|
|
104
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_coordinates, "f") || !__classPrivateFieldGet(this, _SelectionBox_project, "f"))
|
|
105
|
+
return [];
|
|
106
|
+
const minX = Math.min(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x);
|
|
107
|
+
const maxX = Math.max(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x);
|
|
108
|
+
const minY = Math.min(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y);
|
|
109
|
+
const maxY = Math.max(__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y, __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y);
|
|
110
|
+
const selectedPointIndices = [];
|
|
111
|
+
points.forEach((point, index) => {
|
|
112
|
+
const projection = __classPrivateFieldGet(this, _SelectionBox_project, "f").call(this, point);
|
|
113
|
+
if (projection[0] >= minX &&
|
|
114
|
+
projection[0] <= maxX &&
|
|
115
|
+
projection[1] >= minY &&
|
|
116
|
+
projection[1] <= maxY) {
|
|
117
|
+
selectedPointIndices.push(index);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return selectedPointIndices;
|
|
121
|
+
}
|
|
122
|
+
onDown(event, project) {
|
|
123
|
+
__classPrivateFieldSet(this, _SelectionBox_project, project, "f");
|
|
124
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
125
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
126
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
127
|
+
__classPrivateFieldSet(this, _SelectionBox_coordinates, {
|
|
128
|
+
start: {
|
|
129
|
+
x: x,
|
|
130
|
+
y: y,
|
|
131
|
+
},
|
|
132
|
+
end: {
|
|
133
|
+
x: x,
|
|
134
|
+
y: y,
|
|
135
|
+
},
|
|
136
|
+
}, "f");
|
|
137
|
+
}
|
|
138
|
+
onEnd(event) {
|
|
139
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
140
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
141
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
142
|
+
__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end = {
|
|
143
|
+
x: x,
|
|
144
|
+
y: y,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
onMove(event, insertionActive, removalActive) {
|
|
148
|
+
// update box selection
|
|
149
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
150
|
+
const x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
|
151
|
+
const y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
|
152
|
+
__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end = {
|
|
153
|
+
x: x,
|
|
154
|
+
y: y,
|
|
155
|
+
};
|
|
156
|
+
this.updateSelectionBox(insertionActive, removalActive);
|
|
157
|
+
}
|
|
158
|
+
reset() {
|
|
159
|
+
var _a;
|
|
160
|
+
(_a = __classPrivateFieldGet(this, _SelectionBox_htmlElement, "f")) === null || _a === void 0 ? void 0 : _a.remove();
|
|
161
|
+
__classPrivateFieldSet(this, _SelectionBox_htmlElement, undefined, "f");
|
|
162
|
+
__classPrivateFieldSet(this, _SelectionBox_coordinates, undefined, "f");
|
|
163
|
+
}
|
|
164
|
+
updateSelectionBox(insertionActive, removalActive) {
|
|
165
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_coordinates, "f"))
|
|
166
|
+
return;
|
|
167
|
+
let color = "0, 0, 255"; // blue
|
|
168
|
+
if (insertionActive && !removalActive) {
|
|
169
|
+
color = "0, 255, 0"; // green
|
|
170
|
+
}
|
|
171
|
+
else if (!insertionActive && removalActive) {
|
|
172
|
+
color = "255, 0, 0"; // red
|
|
173
|
+
}
|
|
174
|
+
if (!__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f")) {
|
|
175
|
+
// create selection box div
|
|
176
|
+
__classPrivateFieldSet(this, _SelectionBox_htmlElement, document.createElement("div"), "f");
|
|
177
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.position = "absolute";
|
|
178
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border = `1px solid rgba(${color}, 0.8)`;
|
|
179
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.backgroundColor = `rgba(${color}, 0.1)`;
|
|
180
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.pointerEvents = "none";
|
|
181
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.zIndex = "9999"; // Ensure it's on top
|
|
182
|
+
document.body.appendChild(__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f"));
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// check if the color needs to be updated
|
|
186
|
+
const currentBorderColor = __classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border;
|
|
187
|
+
const desiredBorderColor = `1px solid rgba(${color}, 0.8)`;
|
|
188
|
+
if (currentBorderColor !== desiredBorderColor) {
|
|
189
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.border = desiredBorderColor;
|
|
190
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.backgroundColor = `rgba(${color}, 0.1)`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const rect = __classPrivateFieldGet(this, _SelectionBox_canvas, "f").getBoundingClientRect();
|
|
194
|
+
// Convert normalized coordinates back to document coordinates
|
|
195
|
+
const convertedStartX = ((__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.x + 1) / 2) * rect.width + rect.left;
|
|
196
|
+
const convertedStartY = ((1 - __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").start.y) / 2) * rect.height + rect.top;
|
|
197
|
+
const convertedEndX = ((__classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.x + 1) / 2) * rect.width + rect.left;
|
|
198
|
+
const convertedEndY = ((1 - __classPrivateFieldGet(this, _SelectionBox_coordinates, "f").end.y) / 2) * rect.height + rect.top;
|
|
199
|
+
const x = Math.min(convertedStartX, convertedEndX);
|
|
200
|
+
const y = Math.min(convertedStartY, convertedEndY);
|
|
201
|
+
const width = Math.abs(convertedEndX - convertedStartX);
|
|
202
|
+
const height = Math.abs(convertedEndY - convertedStartY);
|
|
203
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.left = `${x}px`;
|
|
204
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.top = `${y}px`;
|
|
205
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.width = `${width}px`;
|
|
206
|
+
__classPrivateFieldGet(this, _SelectionBox_htmlElement, "f").style.height = `${height}px`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.SelectionBox = SelectionBox;
|
|
210
|
+
_SelectionBox_canvas = new WeakMap(), _SelectionBox_coordinates = new WeakMap(), _SelectionBox_htmlElement = new WeakMap(), _SelectionBox_project = new WeakMap();
|
|
211
|
+
//# sourceMappingURL=SelectionBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionBox.js","sourceRoot":"","sources":["../../src/implementation/SelectionBox.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,yCAAqC;AAIrC,MAAa,YAAY;IASxB,YAAY,MAAyB;QARrC,uCAA2B;QAC3B,4CAGE;QACF,4CAA8B;QAC9B,wCAA6B;QAG5B,uBAAA,IAAI,wBAAW,MAAM,MAAA,CAAC;IACvB,CAAC;IAED,IAAW,WAAW;QACrB,OAAO,uBAAA,IAAI,iCAAa,CAAC;IAC1B,CAAC;IAEM,gBAAgB,CACtB,KAAkB,EAClB,cAAqC;QAErC,IAAI,CAAC,uBAAA,IAAI,iCAAa;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CACpB,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,CAAC,EACzB,uBAAA,IAAI,iCAAa,CAAC,GAAG,CAAC,CAAC,CACvB,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CACpB,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,CAAC,EACzB,uBAAA,IAAI,iCAAa,CAAC,GAAG,CAAC,CAAC,CACvB,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CACpB,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,CAAC,EACzB,uBAAA,IAAI,iCAAa,CAAC,GAAG,CAAC,CAAC,CACvB,CAAC;QAEF,MAAM,IAAI,GAAG,IAAI,CA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CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;QAE9D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,eAAe,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,eAAe,CAAC,CAAC;QAEzD,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACxC,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC;QACvC,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC;QAC7C,uBAAA,IAAI,iCAAa,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;IAChD,CAAC;CACD;AAnQD,oCAmQC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RaycasterParameters } from "three";
|
|
2
2
|
import { IntersectionEngine } from "./implementation/IntersectionEngine";
|
|
3
|
+
import { SelectionBox } from "./implementation/SelectionBox";
|
|
3
4
|
import { IIntersectionEngine } from "./interfaces/IIntersectionEngine";
|
|
4
|
-
|
|
5
|
-
export {
|
|
5
|
+
import { ISelectionBox } from "./interfaces/ISelectionBox";
|
|
6
|
+
export { IIntersectionEngine, ISelectionBox, RaycasterParameters };
|
|
7
|
+
export { IntersectionEngine, SelectionBox };
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAC,mBAAmB,EAAE,aAAa,EAAE,mBAAmB,EAAC,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntersectionEngine = void 0;
|
|
3
|
+
exports.SelectionBox = exports.IntersectionEngine = void 0;
|
|
4
4
|
const IntersectionEngine_1 = require("./implementation/IntersectionEngine");
|
|
5
5
|
Object.defineProperty(exports, "IntersectionEngine", { enumerable: true, get: function () { return IntersectionEngine_1.IntersectionEngine; } });
|
|
6
|
+
const SelectionBox_1 = require("./implementation/SelectionBox");
|
|
7
|
+
Object.defineProperty(exports, "SelectionBox", { enumerable: true, get: function () { return SelectionBox_1.SelectionBox; } });
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,4EAAuE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAM/D,mGANA,uCAAkB,OAMA;AAL1B,gEAA2D;AAK/B,6FALpB,2BAAY,OAKoB"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IIntersectionDefinition, IIntersectionFilter, IRay } from "@shapediver/viewer.shared.types";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
+
import { SelectionBox } from "../implementation/SelectionBox";
|
|
3
4
|
export interface IIntersectionEngine {
|
|
4
|
-
intersect(ray: IRay, viewportId: string, filterCriteria?: IIntersectionFilter[],
|
|
5
|
+
intersect(ray: IRay, viewportId: string, filterCriteria?: IIntersectionFilter[], options?: {
|
|
6
|
+
rayCasterParams?: THREE.RaycasterParameters;
|
|
7
|
+
selectionBox?: SelectionBox;
|
|
8
|
+
}): IIntersectionDefinition[];
|
|
5
9
|
}
|
|
6
10
|
//# sourceMappingURL=IIntersectionEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IIntersectionEngine.d.ts","sourceRoot":"","sources":["../../src/interfaces/IIntersectionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"IIntersectionEngine.d.ts","sourceRoot":"","sources":["../../src/interfaces/IIntersectionEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EACnB,IAAI,EACJ,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAGnC,SAAS,CACR,GAAG,EAAE,IAAI,EACT,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,mBAAmB,EAAE,EACtC,OAAO,CAAC,EAAE;QACT,eAAe,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC;QAC5C,YAAY,CAAC,EAAE,YAAY,CAAC;KAC5B,GACC,uBAAuB,EAAE,CAAC;CAG7B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ITreeNode } from "@shapediver/viewer.shared.node-tree";
|
|
2
|
+
import { IBoxSelectionIntersection, IIntersectionFilter } from "@shapediver/viewer.shared.types";
|
|
3
|
+
import { vec2, vec3 } from "gl-matrix";
|
|
4
|
+
export interface ISelectionBox {
|
|
5
|
+
readonly coordinates?: {
|
|
6
|
+
start: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
end: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
intersectObjects(nodes: ITreeNode[], filterCriteria: IIntersectionFilter[]): IBoxSelectionIntersection[];
|
|
16
|
+
intersectPoints(points: vec3[]): number[];
|
|
17
|
+
onDown(event: PointerEvent, project: (p: vec3) => vec2): void;
|
|
18
|
+
onEnd(event: PointerEvent): void;
|
|
19
|
+
onMove(event: PointerEvent, insertionActive: boolean, removalActive: boolean): void;
|
|
20
|
+
reset(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ISelectionBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISelectionBox.d.ts","sourceRoot":"","sources":["../../src/interfaces/ISelectionBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtB,KAAK,EAAE;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAC,CAAC;QAC9B,GAAG,EAAE;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAC,CAAC;KAC5B,CAAC;IAEF,gBAAgB,CACf,KAAK,EAAE,SAAS,EAAE,EAClB,cAAc,EAAE,mBAAmB,EAAE,GACnC,yBAAyB,EAAE,CAAC;IAC/B,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACjC,MAAM,CACL,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,OAAO,GACpB,IAAI,CAAC;IACR,KAAK,IAAI,IAAI,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISelectionBox.js","sourceRoot":"","sources":["../../src/interfaces/ISelectionBox.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.rendering-engine.intersection-engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shapediver/viewer.rendering-engine.rendering-engine": "3.
|
|
42
|
-
"@shapediver/viewer.shared.math": "3.
|
|
43
|
-
"@shapediver/viewer.shared.node-tree": "3.
|
|
44
|
-
"@shapediver/viewer.shared.services": "3.
|
|
45
|
-
"@shapediver/viewer.shared.types": "3.
|
|
41
|
+
"@shapediver/viewer.rendering-engine.rendering-engine": "3.14.0",
|
|
42
|
+
"@shapediver/viewer.shared.math": "3.14.0",
|
|
43
|
+
"@shapediver/viewer.shared.node-tree": "3.14.0",
|
|
44
|
+
"@shapediver/viewer.shared.services": "3.14.0",
|
|
45
|
+
"@shapediver/viewer.shared.types": "3.14.0",
|
|
46
46
|
"@types/three": "0.162.0",
|
|
47
47
|
"detect-it": "4.0.1",
|
|
48
48
|
"gl-matrix": "3.3.0",
|
|
49
49
|
"three": "0.162.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a28209d1dc84f1dc5a72b284e4eddd792b82f27f"
|
|
52
52
|
}
|