@buerli.io/core 0.10.0 → 0.12.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/CHANGELOG.md +5 -0
- package/README.md +12 -12
- package/build/cjs/geometry/ThreeGeometryCreator.js +320 -320
- package/build/cjs/geometry/index.js +17 -17
- package/build/cjs/graphic/filters.js +25 -25
- package/build/cjs/index.js +25 -25
- package/build/cjs/store/index.js +37 -37
- package/build/cjs/store/states/buerli.js +98 -98
- package/build/cjs/store/states/cad.js +47 -35
- package/build/cjs/store/states/drawing.js +49 -49
- package/build/cjs/store/states/geometry.js +137 -137
- package/build/cjs/store/states/graphic.js +112 -112
- package/build/cjs/store/states/interaction.js +55 -55
- package/build/cjs/store/states/message.js +25 -25
- package/build/cjs/store/states/plugin.js +115 -115
- package/build/cjs/store/states/selection.js +267 -267
- package/build/cjs/store/states/structure.js +250 -250
- package/build/cjs/store/store.js +9 -9
- package/build/cjs/store/subscribtion/selection.js +49 -49
- package/build/cjs/store/subscribtion/subscribeToDrawing.js +13 -13
- package/build/cjs/types/IGraphicPackage.js +46 -46
- package/build/cjs/types/IStructurePatch.js +2 -2
- package/build/cjs/types/IStructureTree.js +28 -28
- package/build/cjs/types/InteractionInfo.js +11 -11
- package/build/cjs/types/index.js +20 -20
- package/build/cjs/utils/Math.js +91 -91
- package/build/cjs/utils/Measure.js +576 -576
- package/build/cjs/utils/Timing.js +34 -34
- package/build/esm/geometry/ThreeGeometryCreator.js +291 -291
- package/build/esm/geometry/index.js +1 -1
- package/build/esm/graphic/filters.js +12 -12
- package/build/esm/index.js +9 -9
- package/build/esm/store/index.js +26 -26
- package/build/esm/store/states/buerli.js +92 -92
- package/build/esm/store/states/cad.js +42 -30
- package/build/esm/store/states/drawing.js +45 -45
- package/build/esm/store/states/geometry.js +109 -109
- package/build/esm/store/states/graphic.js +107 -107
- package/build/esm/store/states/interaction.js +50 -50
- package/build/esm/store/states/message.js +21 -21
- package/build/esm/store/states/plugin.js +109 -109
- package/build/esm/store/states/selection.js +261 -261
- package/build/esm/store/states/structure.js +219 -219
- package/build/esm/store/store.js +3 -3
- package/build/esm/store/subscribtion/selection.js +44 -44
- package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -9
- package/build/esm/types/IGraphicPackage.js +43 -43
- package/build/esm/types/IStructurePatch.js +1 -1
- package/build/esm/types/IStructureTree.js +24 -24
- package/build/esm/types/InteractionInfo.js +6 -6
- package/build/esm/types/index.js +4 -4
- package/build/esm/utils/Math.js +65 -65
- package/build/esm/utils/Measure.js +550 -550
- package/build/esm/utils/Timing.js +31 -31
- package/build/types/geometry/ThreeGeometryCreator.d.ts +256 -256
- package/build/types/geometry/index.d.ts +1 -1
- package/build/types/graphic/filters.d.ts +11 -11
- package/build/types/index.d.ts +37 -37
- package/build/types/store/index.d.ts +16 -16
- package/build/types/store/states/buerli.d.ts +41 -41
- package/build/types/store/states/cad.d.ts +53 -42
- package/build/types/store/states/drawing.d.ts +45 -45
- package/build/types/store/states/geometry.d.ts +63 -63
- package/build/types/store/states/graphic.d.ts +22 -22
- package/build/types/store/states/interaction.d.ts +34 -34
- package/build/types/store/states/message.d.ts +30 -30
- package/build/types/store/states/plugin.d.ts +53 -53
- package/build/types/store/states/selection.d.ts +62 -62
- package/build/types/store/states/structure.d.ts +47 -47
- package/build/types/store/store.d.ts +2 -2
- package/build/types/store/subscribtion/selection.d.ts +7 -7
- package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -4
- package/build/types/types/IGraphicPackage.d.ts +157 -155
- package/build/types/types/IStructurePatch.d.ts +6 -6
- package/build/types/types/IStructureTree.d.ts +80 -80
- package/build/types/types/InteractionInfo.d.ts +43 -43
- package/build/types/types/index.d.ts +4 -4
- package/build/types/utils/Math.d.ts +21 -21
- package/build/types/utils/Measure.d.ts +64 -64
- package/build/types/utils/Timing.d.ts +8 -8
- package/package.json +44 -44
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.subscribeToDrawing = void 0;
|
|
4
|
-
function subscribeToDrawing(buerliApi, drawingId, sel, callback) {
|
|
5
|
-
const unsub = buerliApi.subscribe((state, prev) => {
|
|
6
|
-
const curDrawing = state.drawing.refs[drawingId] && sel(state.drawing.refs[drawingId]);
|
|
7
|
-
const prevDrawing = prev.drawing.refs[drawingId] && sel(prev.drawing.refs[drawingId]);
|
|
8
|
-
if (curDrawing !== prevDrawing)
|
|
9
|
-
callback(curDrawing);
|
|
10
|
-
});
|
|
11
|
-
return unsub;
|
|
12
|
-
}
|
|
13
|
-
exports.subscribeToDrawing = subscribeToDrawing;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribeToDrawing = void 0;
|
|
4
|
+
function subscribeToDrawing(buerliApi, drawingId, sel, callback) {
|
|
5
|
+
const unsub = buerliApi.subscribe((state, prev) => {
|
|
6
|
+
const curDrawing = state.drawing.refs[drawingId] && sel(state.drawing.refs[drawingId]);
|
|
7
|
+
const prevDrawing = prev.drawing.refs[drawingId] && sel(prev.drawing.refs[drawingId]);
|
|
8
|
+
if (curDrawing !== prevDrawing)
|
|
9
|
+
callback(curDrawing);
|
|
10
|
+
});
|
|
11
|
+
return unsub;
|
|
12
|
+
}
|
|
13
|
+
exports.subscribeToDrawing = subscribeToDrawing;
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PointTypes = exports.EntityTypes = exports.CurveTypes = exports.EdgeTypes = exports.MeshTypes = exports.ContainerType = exports.GraphicType = void 0;
|
|
4
|
-
var GraphicType;
|
|
5
|
-
(function (GraphicType) {
|
|
6
|
-
// Primitives
|
|
7
|
-
GraphicType["POINT"] = "point";
|
|
8
|
-
GraphicType["LINE"] = "line";
|
|
9
|
-
GraphicType["ARC"] = "arc";
|
|
10
|
-
GraphicType["CIRCLE"] = "circle";
|
|
11
|
-
GraphicType["PLANE"] = "plane";
|
|
12
|
-
GraphicType["CYLINDER"] = "cylinder";
|
|
13
|
-
GraphicType["CONE"] = "cone";
|
|
14
|
-
GraphicType["SPHERE"] = "sphere";
|
|
15
|
-
GraphicType["NURBSCURVE"] = "nurbsCurve";
|
|
16
|
-
GraphicType["NURBSSURFACE"] = "nurbsSurface";
|
|
17
|
-
// Entities
|
|
18
|
-
GraphicType["NONE"] = "none";
|
|
19
|
-
GraphicType["BREP"] = "brep";
|
|
20
|
-
GraphicType["POLYBREP"] = "polyBrep";
|
|
21
|
-
GraphicType["CURVEARRAY"] = "curveArray";
|
|
22
|
-
// Curve array elements
|
|
23
|
-
GraphicType["CURVELINE"] = "curveLine";
|
|
24
|
-
GraphicType["CURVESPLINE"] = "curveSpline";
|
|
25
|
-
GraphicType["CURVEARC"] = "curveArc";
|
|
26
|
-
GraphicType["CURVECIRCLE"] = "curveCircle";
|
|
27
|
-
GraphicType["CURVEPOINT"] = "curvePoint";
|
|
28
|
-
// Custom type(s) (not defined by server protocol)
|
|
29
|
-
GraphicType["LOOP"] = "loop";
|
|
30
|
-
})(GraphicType = exports.GraphicType || (exports.GraphicType = {}));
|
|
31
|
-
var ContainerType;
|
|
32
|
-
(function (ContainerType) {
|
|
33
|
-
ContainerType[ContainerType["NONE"] = 0] = "NONE";
|
|
34
|
-
ContainerType[ContainerType["BREP"] = 1] = "BREP";
|
|
35
|
-
ContainerType[ContainerType["CURVEARRAY"] = 2] = "CURVEARRAY";
|
|
36
|
-
ContainerType[ContainerType["POLYBREP"] = 3] = "POLYBREP";
|
|
37
|
-
// POINTARRAY = 4, // Not used at the moment
|
|
38
|
-
// GRAPHIC = 5, // Not used at the moment
|
|
39
|
-
// LIGHTWEIGHTBREP = 6, // Not used at the moment
|
|
40
|
-
})(ContainerType = exports.ContainerType || (exports.ContainerType = {}));
|
|
41
|
-
const G = GraphicType;
|
|
42
|
-
exports.MeshTypes = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBSSURFACE];
|
|
43
|
-
exports.EdgeTypes = [G.LINE, G.ARC, G.CIRCLE, G.NURBSCURVE];
|
|
44
|
-
exports.CurveTypes = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
|
|
45
|
-
exports.EntityTypes = [G.BREP, G.POLYBREP, G.CURVEARRAY];
|
|
46
|
-
exports.PointTypes = [G.POINT, G.CURVEPOINT];
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PointTypes = exports.EntityTypes = exports.CurveTypes = exports.EdgeTypes = exports.MeshTypes = exports.ContainerType = exports.GraphicType = void 0;
|
|
4
|
+
var GraphicType;
|
|
5
|
+
(function (GraphicType) {
|
|
6
|
+
// Primitives
|
|
7
|
+
GraphicType["POINT"] = "point";
|
|
8
|
+
GraphicType["LINE"] = "line";
|
|
9
|
+
GraphicType["ARC"] = "arc";
|
|
10
|
+
GraphicType["CIRCLE"] = "circle";
|
|
11
|
+
GraphicType["PLANE"] = "plane";
|
|
12
|
+
GraphicType["CYLINDER"] = "cylinder";
|
|
13
|
+
GraphicType["CONE"] = "cone";
|
|
14
|
+
GraphicType["SPHERE"] = "sphere";
|
|
15
|
+
GraphicType["NURBSCURVE"] = "nurbsCurve";
|
|
16
|
+
GraphicType["NURBSSURFACE"] = "nurbsSurface";
|
|
17
|
+
// Entities
|
|
18
|
+
GraphicType["NONE"] = "none";
|
|
19
|
+
GraphicType["BREP"] = "brep";
|
|
20
|
+
GraphicType["POLYBREP"] = "polyBrep";
|
|
21
|
+
GraphicType["CURVEARRAY"] = "curveArray";
|
|
22
|
+
// Curve array elements
|
|
23
|
+
GraphicType["CURVELINE"] = "curveLine";
|
|
24
|
+
GraphicType["CURVESPLINE"] = "curveSpline";
|
|
25
|
+
GraphicType["CURVEARC"] = "curveArc";
|
|
26
|
+
GraphicType["CURVECIRCLE"] = "curveCircle";
|
|
27
|
+
GraphicType["CURVEPOINT"] = "curvePoint";
|
|
28
|
+
// Custom type(s) (not defined by server protocol)
|
|
29
|
+
GraphicType["LOOP"] = "loop";
|
|
30
|
+
})(GraphicType = exports.GraphicType || (exports.GraphicType = {}));
|
|
31
|
+
var ContainerType;
|
|
32
|
+
(function (ContainerType) {
|
|
33
|
+
ContainerType[ContainerType["NONE"] = 0] = "NONE";
|
|
34
|
+
ContainerType[ContainerType["BREP"] = 1] = "BREP";
|
|
35
|
+
ContainerType[ContainerType["CURVEARRAY"] = 2] = "CURVEARRAY";
|
|
36
|
+
ContainerType[ContainerType["POLYBREP"] = 3] = "POLYBREP";
|
|
37
|
+
// POINTARRAY = 4, // Not used at the moment
|
|
38
|
+
// GRAPHIC = 5, // Not used at the moment
|
|
39
|
+
// LIGHTWEIGHTBREP = 6, // Not used at the moment
|
|
40
|
+
})(ContainerType = exports.ContainerType || (exports.ContainerType = {}));
|
|
41
|
+
const G = GraphicType;
|
|
42
|
+
exports.MeshTypes = [G.PLANE, G.CYLINDER, G.CONE, G.SPHERE, G.NURBSSURFACE];
|
|
43
|
+
exports.EdgeTypes = [G.LINE, G.ARC, G.CIRCLE, G.NURBSCURVE];
|
|
44
|
+
exports.CurveTypes = [G.CURVELINE, G.CURVESPLINE, G.CURVEARC, G.CURVECIRCLE];
|
|
45
|
+
exports.EntityTypes = [G.BREP, G.POLYBREP, G.CURVEARRAY];
|
|
46
|
+
exports.PointTypes = [G.POINT, G.CURVEPOINT];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemberType = exports.NOID = exports.DEFAULT_STRUCTURE_TREE = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Defines the default structure tree.
|
|
6
|
-
* Should be used to initialize a new structure tree.
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_STRUCTURE_TREE = () => {
|
|
9
|
-
return {
|
|
10
|
-
tree: {},
|
|
11
|
-
root: exports.NOID,
|
|
12
|
-
currentProduct: exports.NOID,
|
|
13
|
-
currentNode: exports.NOID,
|
|
14
|
-
currentInstance: exports.NOID,
|
|
15
|
-
testRoot: exports.NOID,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.DEFAULT_STRUCTURE_TREE = DEFAULT_STRUCTURE_TREE;
|
|
19
|
-
/** Zero is no Id in classcad, and no object will exist in the CCDatabase for Id === 0! */
|
|
20
|
-
exports.NOID = 0;
|
|
21
|
-
var MemberType;
|
|
22
|
-
(function (MemberType) {
|
|
23
|
-
MemberType["ARRAY"] = "array";
|
|
24
|
-
MemberType["ID"] = "id";
|
|
25
|
-
MemberType["POINT"] = "point";
|
|
26
|
-
MemberType["REAL"] = "real";
|
|
27
|
-
MemberType["STRING"] = "string";
|
|
28
|
-
})(MemberType = exports.MemberType || (exports.MemberType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberType = exports.NOID = exports.DEFAULT_STRUCTURE_TREE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Defines the default structure tree.
|
|
6
|
+
* Should be used to initialize a new structure tree.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_STRUCTURE_TREE = () => {
|
|
9
|
+
return {
|
|
10
|
+
tree: {},
|
|
11
|
+
root: exports.NOID,
|
|
12
|
+
currentProduct: exports.NOID,
|
|
13
|
+
currentNode: exports.NOID,
|
|
14
|
+
currentInstance: exports.NOID,
|
|
15
|
+
testRoot: exports.NOID,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.DEFAULT_STRUCTURE_TREE = DEFAULT_STRUCTURE_TREE;
|
|
19
|
+
/** Zero is no Id in classcad, and no object will exist in the CCDatabase for Id === 0! */
|
|
20
|
+
exports.NOID = 0;
|
|
21
|
+
var MemberType;
|
|
22
|
+
(function (MemberType) {
|
|
23
|
+
MemberType["ARRAY"] = "array";
|
|
24
|
+
MemberType["ID"] = "id";
|
|
25
|
+
MemberType["POINT"] = "point";
|
|
26
|
+
MemberType["REAL"] = "real";
|
|
27
|
+
MemberType["STRING"] = "string";
|
|
28
|
+
})(MemberType = exports.MemberType || (exports.MemberType = {}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createUniqueIdent = exports.createInfo = void 0;
|
|
4
|
-
const createInfo = (data) => {
|
|
5
|
-
return Object.assign({ uniqueIdent: (0, exports.createUniqueIdent)(data) }, data);
|
|
6
|
-
};
|
|
7
|
-
exports.createInfo = createInfo;
|
|
8
|
-
const createUniqueIdent = (data) => {
|
|
9
|
-
return `${[data.prodRefId, data.objectId, data.containerId, data.graphicId]}`;
|
|
10
|
-
};
|
|
11
|
-
exports.createUniqueIdent = createUniqueIdent;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUniqueIdent = exports.createInfo = void 0;
|
|
4
|
+
const createInfo = (data) => {
|
|
5
|
+
return Object.assign({ uniqueIdent: (0, exports.createUniqueIdent)(data) }, data);
|
|
6
|
+
};
|
|
7
|
+
exports.createInfo = createInfo;
|
|
8
|
+
const createUniqueIdent = (data) => {
|
|
9
|
+
return `${[data.prodRefId, data.objectId, data.containerId, data.graphicId]}`;
|
|
10
|
+
};
|
|
11
|
+
exports.createUniqueIdent = createUniqueIdent;
|
package/build/cjs/types/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./IGraphicPackage"), exports);
|
|
18
|
-
__exportStar(require("./InteractionInfo"), exports);
|
|
19
|
-
__exportStar(require("./IStructurePatch"), exports);
|
|
20
|
-
__exportStar(require("./IStructureTree"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IGraphicPackage"), exports);
|
|
18
|
+
__exportStar(require("./InteractionInfo"), exports);
|
|
19
|
+
__exportStar(require("./IStructurePatch"), exports);
|
|
20
|
+
__exportStar(require("./IStructureTree"), exports);
|
package/build/cjs/utils/Math.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.MathUtils = void 0;
|
|
27
|
-
const THREE = __importStar(require("three"));
|
|
28
|
-
const degToRad = THREE.MathUtils.degToRad;
|
|
29
|
-
const tolerance = 1e-6;
|
|
30
|
-
exports.MathUtils = {
|
|
31
|
-
convertToMatrix4: function (coordinateSystem) {
|
|
32
|
-
const [orig, vx, vy, vz] = coordinateSystem.map(row => new THREE.Vector3().fromArray(row));
|
|
33
|
-
return new THREE.Matrix4().makeBasis(vx, vy, vz).setPosition(orig);
|
|
34
|
-
},
|
|
35
|
-
convertToMatrix3: function (coordinateSystem) {
|
|
36
|
-
const [, vx, vy, vz] = coordinateSystem;
|
|
37
|
-
return new THREE.Matrix3().fromArray([...vx, ...vy, ...vz]);
|
|
38
|
-
},
|
|
39
|
-
convertToCoordinateSystem: function (matrix) {
|
|
40
|
-
const position = new THREE.Vector3();
|
|
41
|
-
const xAxis = new THREE.Vector3();
|
|
42
|
-
const yAxis = new THREE.Vector3();
|
|
43
|
-
const zAxis = new THREE.Vector3();
|
|
44
|
-
position.setFromMatrixPosition(matrix);
|
|
45
|
-
matrix.extractBasis(xAxis, yAxis, zAxis);
|
|
46
|
-
const coordSys = [];
|
|
47
|
-
coordSys[0] = [position.x, position.y, position.z];
|
|
48
|
-
coordSys[1] = [xAxis.x, xAxis.y, xAxis.z];
|
|
49
|
-
coordSys[2] = [yAxis.x, yAxis.y, yAxis.z];
|
|
50
|
-
coordSys[3] = [zAxis.x, zAxis.y, zAxis.z];
|
|
51
|
-
return coordSys;
|
|
52
|
-
},
|
|
53
|
-
round(value, digits) {
|
|
54
|
-
if (isNaN(value))
|
|
55
|
-
return NaN;
|
|
56
|
-
const factor = Math.pow(10, digits);
|
|
57
|
-
return Math.round(value * factor) / factor;
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* Calculates a transformation matrix.
|
|
61
|
-
*
|
|
62
|
-
* xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products.
|
|
63
|
-
*
|
|
64
|
-
* @param originPos The origin position.
|
|
65
|
-
* @param xDir The x direction.
|
|
66
|
-
* @param yDir The y direction.
|
|
67
|
-
* @param offset The offset vector.
|
|
68
|
-
* @param rotation The rotation vector.
|
|
69
|
-
* @param inverted The inverted flag --- 0: do not invert; 1: do invert.
|
|
70
|
-
* @returns The calculated THREE.Matrix4
|
|
71
|
-
*/
|
|
72
|
-
calcluateTransform: function (originPos, xDir, yDir, offset, rotation, inverted) {
|
|
73
|
-
rotation = new THREE.Vector3(degToRad(rotation.x), degToRad(rotation.y), degToRad(rotation.z));
|
|
74
|
-
const xAxis = xDir.clone().normalize();
|
|
75
|
-
let yDir_ = yDir.clone().normalize();
|
|
76
|
-
if (Math.abs(yDir_.dot(xAxis.clone())) > 1 - tolerance) {
|
|
77
|
-
yDir_ = Math.abs(xAxis.y) !== 1 ? new THREE.Vector3(0.0, 1.0, 0.0) : new THREE.Vector3(1.0, 0.0, 0.0);
|
|
78
|
-
}
|
|
79
|
-
const zAxis = xAxis.clone().cross(yDir_).normalize();
|
|
80
|
-
const yAxis = zAxis.clone().cross(xAxis).normalize();
|
|
81
|
-
if (inverted) {
|
|
82
|
-
xAxis.negate();
|
|
83
|
-
zAxis.negate();
|
|
84
|
-
}
|
|
85
|
-
const mLocal = new THREE.Matrix4()
|
|
86
|
-
.makeRotationFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z))
|
|
87
|
-
.setPosition(offset.x, offset.y, offset.z);
|
|
88
|
-
const mGlobal = new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(originPos);
|
|
89
|
-
return mGlobal.clone().multiply(mLocal);
|
|
90
|
-
},
|
|
91
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MathUtils = void 0;
|
|
27
|
+
const THREE = __importStar(require("three"));
|
|
28
|
+
const degToRad = THREE.MathUtils.degToRad;
|
|
29
|
+
const tolerance = 1e-6;
|
|
30
|
+
exports.MathUtils = {
|
|
31
|
+
convertToMatrix4: function (coordinateSystem) {
|
|
32
|
+
const [orig, vx, vy, vz] = coordinateSystem.map(row => new THREE.Vector3().fromArray(row));
|
|
33
|
+
return new THREE.Matrix4().makeBasis(vx, vy, vz).setPosition(orig);
|
|
34
|
+
},
|
|
35
|
+
convertToMatrix3: function (coordinateSystem) {
|
|
36
|
+
const [, vx, vy, vz] = coordinateSystem;
|
|
37
|
+
return new THREE.Matrix3().fromArray([...vx, ...vy, ...vz]);
|
|
38
|
+
},
|
|
39
|
+
convertToCoordinateSystem: function (matrix) {
|
|
40
|
+
const position = new THREE.Vector3();
|
|
41
|
+
const xAxis = new THREE.Vector3();
|
|
42
|
+
const yAxis = new THREE.Vector3();
|
|
43
|
+
const zAxis = new THREE.Vector3();
|
|
44
|
+
position.setFromMatrixPosition(matrix);
|
|
45
|
+
matrix.extractBasis(xAxis, yAxis, zAxis);
|
|
46
|
+
const coordSys = [];
|
|
47
|
+
coordSys[0] = [position.x, position.y, position.z];
|
|
48
|
+
coordSys[1] = [xAxis.x, xAxis.y, xAxis.z];
|
|
49
|
+
coordSys[2] = [yAxis.x, yAxis.y, yAxis.z];
|
|
50
|
+
coordSys[3] = [zAxis.x, zAxis.y, zAxis.z];
|
|
51
|
+
return coordSys;
|
|
52
|
+
},
|
|
53
|
+
round(value, digits) {
|
|
54
|
+
if (isNaN(value))
|
|
55
|
+
return NaN;
|
|
56
|
+
const factor = Math.pow(10, digits);
|
|
57
|
+
return Math.round(value * factor) / factor;
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Calculates a transformation matrix.
|
|
61
|
+
*
|
|
62
|
+
* xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products.
|
|
63
|
+
*
|
|
64
|
+
* @param originPos The origin position.
|
|
65
|
+
* @param xDir The x direction.
|
|
66
|
+
* @param yDir The y direction.
|
|
67
|
+
* @param offset The offset vector.
|
|
68
|
+
* @param rotation The rotation vector.
|
|
69
|
+
* @param inverted The inverted flag --- 0: do not invert; 1: do invert.
|
|
70
|
+
* @returns The calculated THREE.Matrix4
|
|
71
|
+
*/
|
|
72
|
+
calcluateTransform: function (originPos, xDir, yDir, offset, rotation, inverted) {
|
|
73
|
+
rotation = new THREE.Vector3(degToRad(rotation.x), degToRad(rotation.y), degToRad(rotation.z));
|
|
74
|
+
const xAxis = xDir.clone().normalize();
|
|
75
|
+
let yDir_ = yDir.clone().normalize();
|
|
76
|
+
if (Math.abs(yDir_.dot(xAxis.clone())) > 1 - tolerance) {
|
|
77
|
+
yDir_ = Math.abs(xAxis.y) !== 1 ? new THREE.Vector3(0.0, 1.0, 0.0) : new THREE.Vector3(1.0, 0.0, 0.0);
|
|
78
|
+
}
|
|
79
|
+
const zAxis = xAxis.clone().cross(yDir_).normalize();
|
|
80
|
+
const yAxis = zAxis.clone().cross(xAxis).normalize();
|
|
81
|
+
if (inverted) {
|
|
82
|
+
xAxis.negate();
|
|
83
|
+
zAxis.negate();
|
|
84
|
+
}
|
|
85
|
+
const mLocal = new THREE.Matrix4()
|
|
86
|
+
.makeRotationFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z))
|
|
87
|
+
.setPosition(offset.x, offset.y, offset.z);
|
|
88
|
+
const mGlobal = new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(originPos);
|
|
89
|
+
return mGlobal.clone().multiply(mLocal);
|
|
90
|
+
},
|
|
91
|
+
};
|