@ifiwas/standard-view 2.0.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.
Files changed (134) hide show
  1. package/.prettierignore +67 -0
  2. package/.prettierrc +12 -0
  3. package/CHANGELOG.md +42 -0
  4. package/LICENSE +8 -0
  5. package/README.md +199 -0
  6. package/debug-storybook.log +179 -0
  7. package/declarations.d.ts +17 -0
  8. package/dist/standard-view.es.js +9522 -0
  9. package/dist/standard-view.es.js.map +1 -0
  10. package/dist/standard-view.umd.js +41 -0
  11. package/dist/standard-view.umd.js.map +1 -0
  12. package/fonts/gentilis.bold.typeface.json +1 -0
  13. package/fonts/gentilis.typeface.json +1 -0
  14. package/fonts/helvetiker.bold.typeface.json +1 -0
  15. package/fonts/helvetiker.typeface.json +1 -0
  16. package/fonts/optimer.bold.typeface.json +1 -0
  17. package/fonts/optimer.typeface.json +1 -0
  18. package/images.d.ts +7 -0
  19. package/index.js +10 -0
  20. package/lib/controls/OrbitControls.d.ts +9 -0
  21. package/lib/controls/OrbitControls.js +761 -0
  22. package/lib/controls/index.d.ts +1 -0
  23. package/lib/controls/index.js +18 -0
  24. package/lib/groups/Arrow.d.ts +19 -0
  25. package/lib/groups/Arrow.js +134 -0
  26. package/lib/groups/Axis.d.ts +20 -0
  27. package/lib/groups/Axis.js +147 -0
  28. package/lib/groups/BoundingBox.d.ts +9 -0
  29. package/lib/groups/BoundingBox.js +143 -0
  30. package/lib/groups/Camera.d.ts +32 -0
  31. package/lib/groups/Camera.js +477 -0
  32. package/lib/groups/Capsule.d.ts +9 -0
  33. package/lib/groups/Capsule.js +112 -0
  34. package/lib/groups/FBX.d.ts +9 -0
  35. package/lib/groups/FBX.js +213 -0
  36. package/lib/groups/GLTF.d.ts +9 -0
  37. package/lib/groups/GLTF.js +198 -0
  38. package/lib/groups/Group.d.ts +63 -0
  39. package/lib/groups/Group.js +426 -0
  40. package/lib/groups/OBJ.d.ts +11 -0
  41. package/lib/groups/OBJ.js +252 -0
  42. package/lib/groups/PCD.d.ts +9 -0
  43. package/lib/groups/PCD.js +82 -0
  44. package/lib/groups/Path.d.ts +19 -0
  45. package/lib/groups/Path.js +160 -0
  46. package/lib/groups/index.d.ts +11 -0
  47. package/lib/groups/index.js +91 -0
  48. package/lib/index.d.ts +6 -0
  49. package/lib/index.js +298 -0
  50. package/lib/lights/AmbientLight.d.ts +8 -0
  51. package/lib/lights/AmbientLight.js +37 -0
  52. package/lib/lights/DirectionalLight.d.ts +8 -0
  53. package/lib/lights/DirectionalLight.js +43 -0
  54. package/lib/lights/HemisphereLight.d.ts +13 -0
  55. package/lib/lights/HemisphereLight.js +108 -0
  56. package/lib/lights/LightWithShadows.d.ts +24 -0
  57. package/lib/lights/LightWithShadows.js +188 -0
  58. package/lib/lights/PointLight.d.ts +9 -0
  59. package/lib/lights/PointLight.js +47 -0
  60. package/lib/lights/RectAreaLight.d.ts +13 -0
  61. package/lib/lights/RectAreaLight.js +177 -0
  62. package/lib/lights/SpotLight.d.ts +10 -0
  63. package/lib/lights/SpotLight.js +49 -0
  64. package/lib/lights/index.d.ts +6 -0
  65. package/lib/lights/index.js +48 -0
  66. package/lib/primitives/Box.d.ts +6 -0
  67. package/lib/primitives/Box.js +43 -0
  68. package/lib/primitives/Circle.d.ts +10 -0
  69. package/lib/primitives/Circle.js +85 -0
  70. package/lib/primitives/Cylinder.d.ts +15 -0
  71. package/lib/primitives/Cylinder.js +180 -0
  72. package/lib/primitives/Label.d.ts +18 -0
  73. package/lib/primitives/Label.js +189 -0
  74. package/lib/primitives/Line.d.ts +19 -0
  75. package/lib/primitives/Line.js +173 -0
  76. package/lib/primitives/Mesh.d.ts +72 -0
  77. package/lib/primitives/Mesh.js +642 -0
  78. package/lib/primitives/Plane.d.ts +7 -0
  79. package/lib/primitives/Plane.js +47 -0
  80. package/lib/primitives/Polygon.d.ts +8 -0
  81. package/lib/primitives/Polygon.js +75 -0
  82. package/lib/primitives/Quad.d.ts +9 -0
  83. package/lib/primitives/Quad.js +110 -0
  84. package/lib/primitives/Sphere.d.ts +14 -0
  85. package/lib/primitives/Sphere.js +92 -0
  86. package/lib/primitives/Text.d.ts +20 -0
  87. package/lib/primitives/Text.js +285 -0
  88. package/lib/primitives/Triangle.d.ts +8 -0
  89. package/lib/primitives/Triangle.js +83 -0
  90. package/lib/primitives/index.d.ts +12 -0
  91. package/lib/primitives/index.js +90 -0
  92. package/lib/shaders/index.d.ts +0 -0
  93. package/lib/shaders/index.js +2 -0
  94. package/lib/types/three-jsx.d.js +5 -0
  95. package/lib/utils/constants.js +181 -0
  96. package/lib/utils/events.d.ts +22 -0
  97. package/lib/utils/events.js +98 -0
  98. package/lib/utils/hooks.d.ts +8 -0
  99. package/lib/utils/hooks.js +96 -0
  100. package/lib/utils/index.d.ts +3 -0
  101. package/lib/utils/index.js +110 -0
  102. package/lib/utils/interfaces.d.ts +9 -0
  103. package/lib/utils/interfaces.js +5 -0
  104. package/lib/utils/math.d.ts +12 -0
  105. package/lib/utils/math.js +31 -0
  106. package/lib/utils/performance.d.ts +7 -0
  107. package/lib/utils/performance.js +114 -0
  108. package/lib/utils/styles.js +10 -0
  109. package/lib/utils/util.d.ts +76 -0
  110. package/lib/utils/util.js +290 -0
  111. package/lib/views/ContextBridge.d.ts +23 -0
  112. package/lib/views/ContextBridge.js +98 -0
  113. package/lib/views/SceneCamera.d.ts +7 -0
  114. package/lib/views/SceneCamera.js +52 -0
  115. package/lib/views/SetBackground.d.ts +9 -0
  116. package/lib/views/SetBackground.js +90 -0
  117. package/lib/views/SetControls.d.ts +19 -0
  118. package/lib/views/SetControls.js +173 -0
  119. package/lib/views/SetRenderer.d.ts +25 -0
  120. package/lib/views/SetRenderer.js +66 -0
  121. package/lib/views/SetShadows.d.ts +7 -0
  122. package/lib/views/SetShadows.js +48 -0
  123. package/lib/views/View3D.d.ts +21 -0
  124. package/lib/views/View3D.js +289 -0
  125. package/lib/views/ViewContext.d.ts +23 -0
  126. package/lib/views/ViewContext.js +55 -0
  127. package/lib/views/index.d.ts +2 -0
  128. package/lib/views/index.js +20 -0
  129. package/netlify.toml +15 -0
  130. package/package.json +110 -0
  131. package/tsconfig.json +42 -0
  132. package/tsconfig.prod.json +3 -0
  133. package/tsconfig.test.json +6 -0
  134. package/vite.config.ts +37 -0
@@ -0,0 +1 @@
1
+ export { OrbitControls, MapControls } from "./OrbitControls";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "MapControls", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _OrbitControls.MapControls;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "OrbitControls", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _OrbitControls.OrbitControls;
16
+ }
17
+ });
18
+ var _OrbitControls = require("./OrbitControls");
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { MeshProps } from "../primitives/Mesh";
3
+ interface ArrowProps extends MeshProps {
4
+ tail?: Array<number>;
5
+ start?: Array<number>;
6
+ position?: Array<number>;
7
+ head?: Array<number>;
8
+ end?: Array<number>;
9
+ target?: Array<number>;
10
+ normal?: Array<number>;
11
+ magnitude?: number;
12
+ radius?: number;
13
+ shaftRadius?: number;
14
+ headTipRadius?: number;
15
+ headBaseRadius?: number;
16
+ headRatio?: number;
17
+ }
18
+ declare const ArrowMemo: React.NamedExoticComponent<ArrowProps>;
19
+ export default ArrowMemo;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var THREE = _interopRequireWildcard(require("three"));
10
+ var _Group = _interopRequireDefault(require("./Group"));
11
+ var _Cylinder = _interopRequireDefault(require("../primitives/Cylinder"));
12
+ var _Sphere = _interopRequireDefault(require("../primitives/Sphere"));
13
+ var _constants = require("../utils/constants");
14
+ var _math = require("../utils/math");
15
+ var _excluded = ["tail", "start", "position", "head", "end", "target", "radius", "shaftRadius", "headBaseRadius", "headTipRadius", "headRatio", "normal", "magnitude", "color", "hoverColor", "children"]; // Arrow.tsx
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
18
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
19
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
20
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
23
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
25
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
26
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
27
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
28
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
29
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
30
+ var useMemo = React.useMemo,
31
+ memo = React.memo;
32
+ /**
33
+ * Arrow
34
+ *
35
+ * In Standard View, Arrow is a Group comprised of two Cylinders and a Sphere.
36
+ * The head of the arrow is Cylinder with different radiusTop and radiusBottom,
37
+ * which scales according to the magnitude of the arrow's length by default.
38
+ * The tail also has a Sphere which also scales according to the magnitude of
39
+ * the shaftRadius.
40
+ * The shaftRadius, headBaseRadius, and headTipRadius may be specifically set.
41
+ * The tail and head may be specified with tail/start/position and
42
+ * head/end/target props.
43
+ * The tail/start/position is also the center of the Sphere at the tail,
44
+ * and head/end/target is the tip of the Cylinder at the head.
45
+ *
46
+ * @param {CapsuleProps} props
47
+ */
48
+ var Arrow = function Arrow(_ref) {
49
+ var tail = _ref.tail,
50
+ start = _ref.start,
51
+ _ref$position = _ref.position,
52
+ position = _ref$position === void 0 ? [0, 0, 0] : _ref$position,
53
+ head = _ref.head,
54
+ end = _ref.end,
55
+ target = _ref.target,
56
+ radius = _ref.radius,
57
+ shaftRadius = _ref.shaftRadius,
58
+ headBaseRadius = _ref.headBaseRadius,
59
+ _ref$headTipRadius = _ref.headTipRadius,
60
+ headTipRadius = _ref$headTipRadius === void 0 ? 0 : _ref$headTipRadius,
61
+ _ref$headRatio = _ref.headRatio,
62
+ headRatio = _ref$headRatio === void 0 ? 0.1 : _ref$headRatio,
63
+ _ref$normal = _ref.normal,
64
+ normal = _ref$normal === void 0 ? _constants.DEFAULT_NORMAL : _ref$normal,
65
+ _ref$magnitude = _ref.magnitude,
66
+ magnitude = _ref$magnitude === void 0 ? 1 : _ref$magnitude,
67
+ color = _ref.color,
68
+ hoverColor = _ref.hoverColor,
69
+ children = _ref.children,
70
+ otherProps = _objectWithoutProperties(_ref, _excluded);
71
+ var _useMemo = useMemo(function updateTail() {
72
+ // Head and Tail
73
+ /* eslint-disable no-shadow */
74
+ var _tail = tail || start || position;
75
+ var _head = head || end || target;
76
+ /* eslint-enable no-shadow */
77
+
78
+ // Compute head and headBase
79
+ var tailVec = _construct(THREE.Vector3, _toConsumableArray(_tail));
80
+ var arrowVec;
81
+ if (_head != null) {
82
+ // Define Arrow with head/end/target
83
+ arrowVec = _construct(THREE.Vector3, _toConsumableArray(_head)).sub(tailVec);
84
+ } else {
85
+ // Define Arrow with position, normal, and magnitude
86
+ arrowVec = _construct(THREE.Vector3, _toConsumableArray(normal)).normalize().multiplyScalar(magnitude);
87
+ }
88
+ /* eslint-disable no-shadow */
89
+ _head = [arrowVec.x, arrowVec.y, arrowVec.z];
90
+ var _headRatio = (0, _math.minmax)(headRatio, 0, 1);
91
+ var headBaseVec = arrowVec.clone().multiplyScalar(1 - _headRatio);
92
+ var _headBase = [headBaseVec.x, headBaseVec.y, headBaseVec.z];
93
+ var _magnitude = arrowVec.length();
94
+ /* eslint-enable no-shadow */
95
+
96
+ return {
97
+ _tail: _tail,
98
+ _head: _head,
99
+ _headBase: _headBase,
100
+ _headRatio: _headRatio,
101
+ _magnitude: _magnitude
102
+ };
103
+ }, [tail, start, position, head, end, target, headRatio, normal, magnitude]),
104
+ _tail = _useMemo._tail,
105
+ _head = _useMemo._head,
106
+ _headBase = _useMemo._headBase,
107
+ _headRatio = _useMemo._headRatio,
108
+ _magnitude = _useMemo._magnitude;
109
+ var _shaftRadius = useMemo(function updateShaftRadius() {
110
+ return shaftRadius || radius || 0.02 * _magnitude;
111
+ }, [shaftRadius, radius, _magnitude]);
112
+ var _headBaseRadius = useMemo(function updateHeadBaseRadius() {
113
+ return headBaseRadius || _headRatio * _magnitude;
114
+ }, [headBaseRadius, _headRatio, _magnitude]);
115
+ return /*#__PURE__*/React.createElement(_Group["default"], _extends({
116
+ position: _tail,
117
+ color: color,
118
+ hoverColor: hoverColor
119
+ }, otherProps), /*#__PURE__*/React.createElement(_Sphere["default"], {
120
+ radius: _shaftRadius
121
+ }), /*#__PURE__*/React.createElement(_Cylinder["default"], {
122
+ radius: _shaftRadius,
123
+ start: [0, 0, 0],
124
+ end: _headBase
125
+ }), /*#__PURE__*/React.createElement(_Cylinder["default"], {
126
+ start: _headBase,
127
+ end: _head,
128
+ radiusBottom: _headBaseRadius,
129
+ radiusTop: headTipRadius
130
+ }, children));
131
+ };
132
+ var ArrowMemo = memo(Arrow);
133
+ ArrowMemo.displayName = "Arrow";
134
+ var _default = exports["default"] = ArrowMemo;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { GroupProps } from './Group';
3
+ interface AxisProps extends GroupProps {
4
+ x?: Array<number>;
5
+ y?: Array<number>;
6
+ z?: Array<number>;
7
+ xColor?: string;
8
+ yColor?: string;
9
+ zColor?: string;
10
+ labelColor?: string;
11
+ xLabel?: string;
12
+ yLabel?: string;
13
+ zLabel?: string;
14
+ labelSize?: number;
15
+ labelDepth?: number;
16
+ labelRotation?: Array<number>;
17
+ thickness?: number;
18
+ }
19
+ declare const AxisMemo: React.NamedExoticComponent<AxisProps>;
20
+ export default AxisMemo;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var THREE = _interopRequireWildcard(require("three"));
10
+ var _Group = _interopRequireWildcard(require("./Group"));
11
+ var _Cylinder = _interopRequireDefault(require("../primitives/Cylinder"));
12
+ var _Sphere = _interopRequireDefault(require("../primitives/Sphere"));
13
+ var _Text = _interopRequireDefault(require("../primitives/Text"));
14
+ var _excluded = ["x", "y", "z", "xColor", "yColor", "zColor", "labelColor", "xLabel", "yLabel", "zLabel", "labelSize", "labelDepth", "labelRotation", "thickness", "children"]; // Axis.tsx
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
18
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
19
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
22
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
24
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
25
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
26
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
28
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
29
+ var useMemo = React.useMemo,
30
+ memo = React.memo;
31
+ /**
32
+ * Axis
33
+ *
34
+ * Axis of unit length with text labels.
35
+ * By default the axis is along x, y, and z directions.
36
+ * The colors, axis directions, thickness of each axis Cylinder,
37
+ * and label text may be set. The color of each axis and label text
38
+ * may be individually set as well.
39
+ *
40
+ * @param {AxisProps} props
41
+ */
42
+ var Axis = function Axis(props) {
43
+ var _generateGroupProps = (0, _Group.generateGroupProps)(props),
44
+ cleanedProps = _generateGroupProps.cleanedProps,
45
+ groupProps = _generateGroupProps.groupProps;
46
+ var _cleanedProps$x = cleanedProps.x,
47
+ x = _cleanedProps$x === void 0 ? [1, 0, 0] : _cleanedProps$x,
48
+ _cleanedProps$y = cleanedProps.y,
49
+ y = _cleanedProps$y === void 0 ? [0, 1, 0] : _cleanedProps$y,
50
+ _cleanedProps$z = cleanedProps.z,
51
+ z = _cleanedProps$z === void 0 ? [0, 0, 1] : _cleanedProps$z,
52
+ _cleanedProps$xColor = cleanedProps.xColor,
53
+ xColor = _cleanedProps$xColor === void 0 ? 'red' : _cleanedProps$xColor,
54
+ _cleanedProps$yColor = cleanedProps.yColor,
55
+ yColor = _cleanedProps$yColor === void 0 ? 'blue' : _cleanedProps$yColor,
56
+ _cleanedProps$zColor = cleanedProps.zColor,
57
+ zColor = _cleanedProps$zColor === void 0 ? 'lime' : _cleanedProps$zColor,
58
+ _cleanedProps$labelCo = cleanedProps.labelColor,
59
+ labelColor = _cleanedProps$labelCo === void 0 ? 'gray' : _cleanedProps$labelCo,
60
+ _cleanedProps$xLabel = cleanedProps.xLabel,
61
+ xLabel = _cleanedProps$xLabel === void 0 ? 'x' : _cleanedProps$xLabel,
62
+ _cleanedProps$yLabel = cleanedProps.yLabel,
63
+ yLabel = _cleanedProps$yLabel === void 0 ? 'y' : _cleanedProps$yLabel,
64
+ _cleanedProps$zLabel = cleanedProps.zLabel,
65
+ zLabel = _cleanedProps$zLabel === void 0 ? 'z' : _cleanedProps$zLabel,
66
+ _cleanedProps$labelSi = cleanedProps.labelSize,
67
+ labelSize = _cleanedProps$labelSi === void 0 ? 0.2 : _cleanedProps$labelSi,
68
+ _cleanedProps$labelDe = cleanedProps.labelDepth,
69
+ labelDepth = _cleanedProps$labelDe === void 0 ? 0.02 : _cleanedProps$labelDe,
70
+ _cleanedProps$labelRo = cleanedProps.labelRotation,
71
+ labelRotation = _cleanedProps$labelRo === void 0 ? [0, 0, 0] : _cleanedProps$labelRo,
72
+ _cleanedProps$thickne = cleanedProps.thickness,
73
+ thickness = _cleanedProps$thickne === void 0 ? 0.1 : _cleanedProps$thickne,
74
+ children = cleanedProps.children,
75
+ otherProps = _objectWithoutProperties(cleanedProps, _excluded);
76
+ var offsetX = useMemo(function updateOffsetX() {
77
+ var axisX = _construct(THREE.Vector3, _toConsumableArray(x));
78
+ var offX = axisX.multiplyScalar(1.25);
79
+ return [offX.x, offX.y, offX.z];
80
+ }, [x]);
81
+ var offsetY = useMemo(function updateOffsetY() {
82
+ var axisY = _construct(THREE.Vector3, _toConsumableArray(y));
83
+ var offY = axisY.multiplyScalar(1.25);
84
+ return [offY.x, offY.y, offY.z];
85
+ }, [y]);
86
+ var offsetZ = useMemo(function updateOffsetZ() {
87
+ var axisZ = _construct(THREE.Vector3, _toConsumableArray(z));
88
+ var offZ = axisZ.multiplyScalar(1.25);
89
+ return [offZ.x, offZ.y, offZ.z];
90
+ }, [z]);
91
+ return /*#__PURE__*/React.createElement(_Group["default"], groupProps, /*#__PURE__*/React.createElement(_Cylinder["default"], _extends({
92
+ start: [0, 0, 0],
93
+ end: x,
94
+ color: xColor,
95
+ radius: thickness
96
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Sphere["default"], _extends({
97
+ position: x,
98
+ color: xColor,
99
+ radius: thickness
100
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Cylinder["default"], _extends({
101
+ start: [0, 0, 0],
102
+ end: y,
103
+ color: yColor,
104
+ radius: thickness
105
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Sphere["default"], _extends({
106
+ position: y,
107
+ color: yColor,
108
+ radius: thickness
109
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Cylinder["default"], _extends({
110
+ start: [0, 0, 0],
111
+ end: z,
112
+ color: zColor,
113
+ radius: thickness
114
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Sphere["default"], _extends({
115
+ position: z,
116
+ color: zColor,
117
+ radius: thickness
118
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Sphere["default"], _extends({
119
+ position: [0, 0, 0],
120
+ color: "black",
121
+ radius: thickness
122
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Text["default"], {
123
+ position: offsetX,
124
+ size: labelSize,
125
+ depth: labelDepth,
126
+ text: xLabel,
127
+ color: labelColor,
128
+ billboard: true
129
+ }), /*#__PURE__*/React.createElement(_Text["default"], {
130
+ position: offsetY,
131
+ size: labelSize,
132
+ depth: labelDepth,
133
+ text: yLabel,
134
+ color: labelColor,
135
+ billboard: true
136
+ }), /*#__PURE__*/React.createElement(_Text["default"], {
137
+ position: offsetZ,
138
+ size: labelSize,
139
+ depth: labelDepth,
140
+ text: zLabel,
141
+ color: labelColor,
142
+ billboard: true
143
+ }));
144
+ };
145
+ var AxisMemo = memo(Axis);
146
+ AxisMemo.displayName = 'Axis';
147
+ var _default = exports["default"] = AxisMemo;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { GroupProps } from "./Group";
3
+ import { LineProps } from "../primitives/Line";
4
+ interface BoundingBoxProps extends LineProps, GroupProps {
5
+ min?: Array<number>;
6
+ max?: Array<number>;
7
+ }
8
+ declare const BoundingBoxMemo: React.NamedExoticComponent<BoundingBoxProps>;
9
+ export default BoundingBoxMemo;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var THREE = _interopRequireWildcard(require("three"));
10
+ var _Group = _interopRequireWildcard(require("./Group"));
11
+ var _Line = _interopRequireDefault(require("../primitives/Line"));
12
+ var _math = require("../utils/math");
13
+ var _excluded = ["min", "max", "color", "hoverColor", "children"],
14
+ _excluded2 = ["position", "scale"]; // BoundingBox.tsx
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
18
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
19
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
22
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
24
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
25
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
26
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
28
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
29
+ var useMemo = React.useMemo,
30
+ memo = React.memo;
31
+ /**
32
+ * BoundingBox
33
+ *
34
+ * In Standard View, BoundingBox is a shape composed with Line primitives.
35
+ * The min and max points are used to determine the bounding box.
36
+ * The position represents the center of the bounding box and based on the
37
+ * min and max the box is scaled to match the min and max corners.
38
+ *
39
+ * If max coordinates are less than or equal to min for any dimension,
40
+ * a small but non-zero scale is used. This seemingly collapses dimensions
41
+ * without incurring uninvertibility and also prevents inverting min and max.
42
+ *
43
+ * @param {BoundingBoxProps} props
44
+ */
45
+ var BoundingBox = function BoundingBox(props) {
46
+ var _generateGroupProps = (0, _Group.generateGroupProps)(props),
47
+ cleanedProps = _generateGroupProps.cleanedProps,
48
+ groupProps = _generateGroupProps.groupProps;
49
+ // hoverColor for Line has issues because the boundingbox has some bugs
50
+ /* eslint-disable @typescript-eslint/no-unused-vars */
51
+ var min = cleanedProps.min,
52
+ max = cleanedProps.max,
53
+ color = cleanedProps.color,
54
+ hoverColor = cleanedProps.hoverColor,
55
+ children = cleanedProps.children,
56
+ otherProps = _objectWithoutProperties(cleanedProps, _excluded);
57
+ var _groupProps$position = groupProps.position,
58
+ position = _groupProps$position === void 0 ? [0, 0, 0] : _groupProps$position,
59
+ scale = groupProps.scale,
60
+ otherGroupProps = _objectWithoutProperties(groupProps, _excluded2);
61
+
62
+ // Position
63
+ var _useMemo = useMemo(function updatePositionAndScale() {
64
+ var _min = min;
65
+ var _max = max;
66
+ var _pos = position;
67
+
68
+ // Min and Max
69
+ if (_min == null || _max == null) {
70
+ var x = _pos[0];
71
+ var y = _pos[1];
72
+ var z = _pos[2];
73
+ _min = [x - 0.5, y - 0.5, z - 0.5];
74
+ _max = [x + 0.5, y + 0.5, z + 0.5];
75
+ }
76
+ var minVec = _construct(THREE.Vector3, _toConsumableArray(_min));
77
+ var maxVec = _construct(THREE.Vector3, _toConsumableArray(_max));
78
+ var displacement = maxVec.clone().sub(minVec);
79
+
80
+ // Position
81
+ var center = minVec.clone().add(maxVec).multiplyScalar(0.5);
82
+ return {
83
+ _position: [center.x, center.y, center.z],
84
+ disp: displacement
85
+ };
86
+ }, [position, min, max]),
87
+ _position = _useMemo._position,
88
+ disp = _useMemo.disp;
89
+ var _scale = useMemo(function updateScale() {
90
+ // Scale
91
+ if (scale) {
92
+ return scale;
93
+ }
94
+ disp.x = Math.max(disp.x, _math.EPS);
95
+ disp.y = Math.max(disp.y, _math.EPS);
96
+ disp.z = Math.max(disp.z, _math.EPS);
97
+ return [disp.x, disp.y, disp.z];
98
+ }, [scale, disp]);
99
+ return /*#__PURE__*/React.createElement(_Group["default"], _extends({
100
+ position: _position,
101
+ scale: _scale,
102
+ color: color
103
+ }, otherGroupProps), /*#__PURE__*/React.createElement(_Line["default"], _extends({
104
+ start: [-0.5, -0.5, -0.5],
105
+ end: [0.5, -0.5, -0.5]
106
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
107
+ start: [-0.5, -0.5, -0.5],
108
+ end: [-0.5, 0.5, -0.5]
109
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
110
+ start: [-0.5, -0.5, -0.5],
111
+ end: [-0.5, -0.5, 0.5]
112
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
113
+ start: [0.5, -0.5, -0.5],
114
+ end: [0.5, 0.5, -0.5]
115
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
116
+ start: [0.5, -0.5, -0.5],
117
+ end: [0.5, -0.5, 0.5]
118
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
119
+ start: [-0.5, 0.5, -0.5],
120
+ end: [0.5, 0.5, -0.5]
121
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
122
+ start: [-0.5, 0.5, -0.5],
123
+ end: [-0.5, 0.5, 0.5]
124
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
125
+ start: [-0.5, -0.5, 0.5],
126
+ end: [0.5, -0.5, 0.5]
127
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
128
+ start: [-0.5, -0.5, 0.5],
129
+ end: [-0.5, 0.5, 0.5]
130
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
131
+ start: [0.5, 0.5, 0.5],
132
+ end: [-0.5, 0.5, 0.5]
133
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
134
+ start: [0.5, 0.5, 0.5],
135
+ end: [0.5, -0.5, 0.5]
136
+ }, otherProps), children), /*#__PURE__*/React.createElement(_Line["default"], _extends({
137
+ start: [0.5, 0.5, 0.5],
138
+ end: [0.5, 0.5, -0.5]
139
+ }, otherProps), children));
140
+ };
141
+ var BoundingBoxMemo = memo(BoundingBox);
142
+ BoundingBoxMemo.displayName = "BoundingBox";
143
+ var _default = exports["default"] = BoundingBoxMemo;
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import { MeshProps } from '../primitives/Mesh';
3
+ interface CameraProps extends MeshProps {
4
+ type?: string;
5
+ width?: number;
6
+ height?: number;
7
+ left?: number;
8
+ right?: number;
9
+ top?: number;
10
+ bottom?: number;
11
+ near?: number;
12
+ far?: number;
13
+ fov?: number;
14
+ aspect?: number;
15
+ roll?: number;
16
+ helper?: boolean;
17
+ meshColor?: string;
18
+ wireframeColor?: string;
19
+ coverageColor?: string;
20
+ coverageOpacity?: number;
21
+ showUp?: boolean;
22
+ showNormal?: boolean;
23
+ showRoll?: boolean;
24
+ showLookAt?: boolean;
25
+ showLabel?: boolean;
26
+ labelText?: string;
27
+ labelOffset?: Array<number>;
28
+ target?: Array<number>;
29
+ cull?: boolean;
30
+ }
31
+ declare const CameraMemo: React.NamedExoticComponent<CameraProps>;
32
+ export default CameraMemo;