@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,181 @@
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.Z_AXIS = exports.Y_AXIS = exports.X_AXIS = exports.SYNONYMOUS_CONTROLS_PROPS = exports.SYNONYMOUS_CAMERA_PROPS = exports.SIDE_TYPES = exports.MATERIAL_TYPES = exports.EULER_ORDERS = exports.DEFAULT_UP_VEC3 = exports.DEFAULT_UP = exports.DEFAULT_RIGHT_VEC3 = exports.DEFAULT_RIGHT = exports.DEFAULT_NORMAL_VEC3 = exports.DEFAULT_NORMAL = exports.CONTROLS_TYPES = exports.COLORS = exports.CAMERA_TYPES = exports.ANTONYMOUS_CONTROLS_PROPS = exports.ANCHOR_SYNONYMS = exports.ANCHORS = void 0;
8
+ var THREE = _interopRequireWildcard(require("three"));
9
+ 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); }
10
+ // constants.js
11
+
12
+ var Z_AXIS = exports.Z_AXIS = new THREE.Vector3(0, 0, 1);
13
+ var Y_AXIS = exports.Y_AXIS = new THREE.Vector3(0, 1, 0);
14
+ var X_AXIS = exports.X_AXIS = new THREE.Vector3(1, 0, 0);
15
+ var DEFAULT_UP_VEC3 = exports.DEFAULT_UP_VEC3 = Y_AXIS.clone();
16
+ var DEFAULT_NORMAL_VEC3 = exports.DEFAULT_NORMAL_VEC3 = Z_AXIS.clone();
17
+ var DEFAULT_RIGHT_VEC3 = exports.DEFAULT_RIGHT_VEC3 = X_AXIS.clone();
18
+ var DEFAULT_NORMAL = exports.DEFAULT_NORMAL = [0, 0, 1];
19
+ var DEFAULT_UP = exports.DEFAULT_UP = [0, 1, 0];
20
+ var DEFAULT_RIGHT = exports.DEFAULT_RIGHT = [1, 0, 0];
21
+
22
+ // Side Types
23
+ var SIDE_TYPES = exports.SIDE_TYPES = {
24
+ front: THREE.FrontSide,
25
+ back: THREE.BackSide,
26
+ "double": THREE.DoubleSide
27
+ };
28
+
29
+ // Euler Orders
30
+ var EULER_ORDERS = exports.EULER_ORDERS = {
31
+ XYZ: "XYZ",
32
+ XZY: "XZY",
33
+ YXZ: "YXZ",
34
+ YZX: "YZX",
35
+ ZXY: "ZXY",
36
+ ZYX: "ZYX"
37
+ };
38
+
39
+ // Control Types
40
+ var CONTROLS_TYPES = exports.CONTROLS_TYPES = {
41
+ ORBIT_CONTROLS: "orbitControls",
42
+ TRACKBALL_CONTROLS: "trackballControls",
43
+ MAP_CONTROLS: "mapControls"
44
+ };
45
+ var CAMERA_TYPES = exports.CAMERA_TYPES = {
46
+ ORTHOGRAPHIC: "orthographic",
47
+ PERSPECTIVE: "perspective"
48
+ };
49
+ var SYNONYMOUS_CONTROLS_PROPS = exports.SYNONYMOUS_CONTROLS_PROPS = [{
50
+ orbitControls: "dampingFactor",
51
+ mapControls: "dampingFactor",
52
+ trackballControls: "dynamicDampingFactor"
53
+ }];
54
+ var ANTONYMOUS_CONTROLS_PROPS = exports.ANTONYMOUS_CONTROLS_PROPS = [{
55
+ orbitControls: "enableZoom",
56
+ mapControls: "enableZoom",
57
+ trackballControls: "noZoom"
58
+ }, {
59
+ orbitControls: "enableRotate",
60
+ mapControls: "enableRotate",
61
+ trackballControls: "noRotate"
62
+ }, {
63
+ orbitControls: "enablePan",
64
+ mapControls: "enablePan",
65
+ trackballControls: "noPan"
66
+ }, {
67
+ orbitControls: "enableDamping",
68
+ mapControls: "enableDamping",
69
+ trackballControls: "staticMoving"
70
+ }];
71
+ var SYNONYMOUS_CAMERA_PROPS = exports.SYNONYMOUS_CAMERA_PROPS = [{
72
+ perspective: "minDistance",
73
+ orthographic: "minZoom"
74
+ }, {
75
+ perspective: "maxDistance",
76
+ orthographic: "maxZoom"
77
+ }];
78
+
79
+ // Material Types
80
+ var MATERIAL_TYPES = exports.MATERIAL_TYPES = {
81
+ material: "material",
82
+ basic: "meshBasicMaterial",
83
+ linebasic: "lineBasicMaterial",
84
+ linedashed: "lineDashedMaterial",
85
+ depth: "meshDepthMaterial",
86
+ distance: "meshDistanceMaterial",
87
+ lambert: "meshLambertMaterial",
88
+ matcap: "meshMatcapMaterial",
89
+ normal: "meshNormalMaterial",
90
+ phong: "meshPhongMaterial",
91
+ physical: "meshPhysicalMaterial",
92
+ standard: "meshStandardMaterial",
93
+ toon: "meshToonMaterial",
94
+ points: "pointsMaterial",
95
+ rawshader: "rawShaderMaterial",
96
+ shader: "shaderMaterial",
97
+ shadow: "shadowMaterial",
98
+ sprite: "spriteMaterial"
99
+ };
100
+
101
+ // Simple, Distinct Colors
102
+ var COLORS = exports.COLORS = ["#e6194b", "#3cb44b", "#ffe119", "#4363d8", "#f58231", "#911eb4", "#46f0f0", "#f032e6", "#bcf60c", "#fabebe", "#008080", "#e6beff", "#9a6324", "#fffac8", "#800000", "#aaffc3", "#808000", "#ffd8b1", "#000075", "#808080", "#ffffff", "#000000"];
103
+
104
+ /**
105
+ * BASE_ANCHORS
106
+ *
107
+ * The ◼'s represent the anchor points.
108
+ *
109
+ * ◼----◼----◼
110
+ * | |
111
+ * ◼ ◼ ◼
112
+ * | |
113
+ * ◼----◼----◼
114
+ */
115
+ var ANCHORS = exports.ANCHORS = {
116
+ "top-left": new THREE.Vector3(-0.5, 0.5, 0),
117
+ top: new THREE.Vector3(0, 0.5, 0),
118
+ "top-right": new THREE.Vector3(0.5, 0.5, 0),
119
+ left: new THREE.Vector3(-0.5, 0, 0),
120
+ center: new THREE.Vector3(0, 0, 0),
121
+ right: new THREE.Vector3(0.5, 0, 0),
122
+ "bottom-left": new THREE.Vector3(-0.5, -0.5, 0),
123
+ bottom: new THREE.Vector3(0, -0.5, 0),
124
+ "bottom-right": new THREE.Vector3(0.5, -0.5, 0)
125
+ };
126
+
127
+ /**
128
+ * ANCHOR_SYNONYMS
129
+ *
130
+ * Synonym map of anchor locations for aligmment positions.
131
+ */
132
+ var ANCHOR_SYNONYMS = exports.ANCHOR_SYNONYMS = {
133
+ "top-left": "top-left",
134
+ "up-left": "top-left",
135
+ "left-top": "top-left",
136
+ "left-up": "top-left",
137
+ top: "top",
138
+ up: "top",
139
+ "top-center": "top",
140
+ "top-middle": "top",
141
+ "up-center": "top",
142
+ "up-middle": "top",
143
+ "center-top": "top",
144
+ "center-up": "top",
145
+ "middle-top": "top",
146
+ "middle-up": "top",
147
+ "top-right": "top-right",
148
+ "up-right": "top-right",
149
+ "right-top": "top-right",
150
+ "right-up": "top-right",
151
+ left: "left",
152
+ "center-left": "left",
153
+ "middle-left": "left",
154
+ "left-center": "left",
155
+ "left-middle": "left",
156
+ center: "center",
157
+ middle: "center",
158
+ right: "right",
159
+ "center-right": "right",
160
+ "middle-right": "right",
161
+ "right-center": "right",
162
+ "right-middle": "right",
163
+ "bottom-left": "bottom-left",
164
+ "down-left": "bottom-left",
165
+ "left-bottom": "bottom-left",
166
+ "left-down": "bottom-left",
167
+ bottom: "bottom",
168
+ down: "bottom",
169
+ "bottom-center": "bottom",
170
+ "bottom-middle": "bottom",
171
+ "down-center": "bottom",
172
+ "down-middle": "bottom",
173
+ "center-bottom": "bottom",
174
+ "center-down": "bottom",
175
+ "middle-bottom": "bottom",
176
+ "middle-down": "bottom",
177
+ "bottom-right": "bottom-right",
178
+ "down-right": "bottom-right",
179
+ "right-bottom": "bottom-right",
180
+ "right-down": "bottom-right"
181
+ };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ import { RenderCallback } from "@react-three/fiber";
3
+ export declare function checkPropagation(e: any, mousePropagation: boolean): void;
4
+ interface HandleClickProps {
5
+ mousePropagation: boolean;
6
+ clickSensitivity: number;
7
+ eventProps: any;
8
+ onClick?: Function;
9
+ onDoubleClick?: Function;
10
+ }
11
+ export declare function handleClick({ mousePropagation, clickSensitivity, eventProps, onClick, onDoubleClick }: HandleClickProps): React.MouseEventHandler;
12
+ interface AnimationComponentProps {
13
+ animation: RenderCallback;
14
+ }
15
+ /**
16
+ * AnimationComponent
17
+ *
18
+ * Isolate @react-three/fiber's useFrame hook to add animation
19
+ * function to three's render loop.
20
+ */
21
+ export declare const AnimationComponent: React.NamedExoticComponent<AnimationComponentProps>;
22
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AnimationComponent = void 0;
7
+ exports.checkPropagation = checkPropagation;
8
+ exports.handleClick = handleClick;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _hooks = require("./hooks");
11
+ 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); }
12
+ 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); }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // events.tsx
18
+ var memo = React.memo;
19
+
20
+ // ----- Event Function Helpers ----- //
21
+ // Check Mouse Propagation
22
+ function checkPropagation(e, mousePropagation) {
23
+ if (!mousePropagation) {
24
+ e.stopPropagation();
25
+ }
26
+ }
27
+
28
+ // Handle Click and Double Click
29
+
30
+ function handleClick(_ref) {
31
+ var mousePropagation = _ref.mousePropagation,
32
+ clickSensitivity = _ref.clickSensitivity,
33
+ eventProps = _ref.eventProps,
34
+ onClick = _ref.onClick,
35
+ onDoubleClick = _ref.onDoubleClick;
36
+ return function (e) {
37
+ // Mouse Propagation
38
+ checkPropagation(e, mousePropagation);
39
+
40
+ // No Click Functions
41
+ if (!onClick && !onDoubleClick) {
42
+ return null;
43
+ }
44
+ var state = eventProps.state;
45
+
46
+ // No onDoubleClick
47
+ if (onClick && !onDoubleClick) {
48
+ // @ts-ignore TS2722 // Cannot invoke an object which is possible undefined
49
+ onClick(_objectSpread(_objectSpread({}, e), eventProps));
50
+ return null;
51
+ }
52
+
53
+ // Click Time
54
+ var currentTime = Date.now();
55
+
56
+ // Double Click
57
+ if (onDoubleClick) {
58
+ if (currentTime - state.lastClickTime <= clickSensitivity) {
59
+ // Set Last Click
60
+ state.lastClickTime = currentTime;
61
+ // @ts-ignore TS2722 // Cannot invoke an object which is possible undefined
62
+ onDoubleClick(_objectSpread(_objectSpread({}, e), eventProps));
63
+ return null;
64
+ }
65
+ }
66
+
67
+ // Single Click
68
+ if (onClick) {
69
+ // Waits to check for Double Click before executing
70
+ setTimeout(function () {
71
+ var initialClickTime = currentTime;
72
+ if (state.lastClickTime === initialClickTime) {
73
+ // @ts-ignore TS2722 // Cannot invoke an object which is possible undefined
74
+ onClick(_objectSpread(_objectSpread({}, e), eventProps));
75
+ }
76
+ return null;
77
+ }, clickSensitivity + 1);
78
+ }
79
+
80
+ // Set Last Click
81
+ state.lastClickTime = currentTime;
82
+ return null;
83
+ };
84
+ }
85
+ /**
86
+ * AnimationComponent
87
+ *
88
+ * Isolate @react-three/fiber's useFrame hook to add animation
89
+ * function to three's render loop.
90
+ */
91
+ var AnimationComponent = exports.AnimationComponent = memo(/* eslint-disable react/prop-types */
92
+ function AnimationComponent(_ref2) {
93
+ var animation = _ref2.animation;
94
+ (0, _hooks.useAnimationFrame)(animation, [animation]);
95
+ return null;
96
+ }
97
+ /* eslint-enable react/prop-types */);
98
+ AnimationComponent.displayName = "AnimationComponent";
@@ -0,0 +1,8 @@
1
+ import { RenderCallback } from "@react-three/fiber";
2
+ export declare function useToggle(initialValue: any, alternate?: any): [any, Function];
3
+ export declare function useFrame(f: RenderCallback, priority?: number, override?: boolean): void;
4
+ export declare function useViewContext(): any;
5
+ /**
6
+ * useAnimationFrame
7
+ */
8
+ export declare const useAnimationFrame: (callback: any, dependencies?: any[]) => void;
@@ -0,0 +1,96 @@
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.useAnimationFrame = void 0;
8
+ exports.useFrame = useFrame;
9
+ exports.useToggle = useToggle;
10
+ exports.useViewContext = useViewContext;
11
+ var _react = require("react");
12
+ var _fiber = require("@react-three/fiber");
13
+ var _ViewContext = require("../views/ViewContext");
14
+ var _excluded = ["setViewContextValue"];
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ 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; }
21
+ 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; }
22
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
23
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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; }
26
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
27
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // hooks.ts
28
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
29
+ function useToggle(initialValue, alternate) {
30
+ var _useState = (0, _react.useState)(initialValue),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ value = _useState2[0],
33
+ setValue = _useState2[1];
34
+ var alternateValue = (0, _react.useMemo)(function initAlternateValue() {
35
+ return alternate != null ? alternate : !initialValue;
36
+ }, [alternate, initialValue]);
37
+ function toggleValue() {
38
+ var newValue = value === initialValue ? alternateValue : initialValue;
39
+ setValue(newValue);
40
+ }
41
+ return [value, toggleValue];
42
+ }
43
+ function useFrame(f) {
44
+ var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
45
+ var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
46
+ var p = priority;
47
+ if (!override) {
48
+ p = p >= 2 ? p : 2;
49
+ }
50
+ (0, _fiber.useFrame)(f, p);
51
+ }
52
+
53
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
54
+ function useViewContext() {
55
+ var _useContext = (0, _react.useContext)(_ViewContext.ViewContext),
56
+ setViewContextValue = _useContext.setViewContextValue,
57
+ canvasProps = _objectWithoutProperties(_useContext, _excluded);
58
+ var setViewContext = (0, _react.useCallback)(/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
59
+ function updateSetViewContext(props) {
60
+ Object.entries(props).map(function (_ref) {
61
+ var _ref2 = _slicedToArray(_ref, 2),
62
+ key = _ref2[0],
63
+ value = _ref2[1];
64
+ // Replace Existing Key-Value or Add New Key-Value
65
+ canvasProps[key] = value;
66
+ return null;
67
+ });
68
+ setViewContextValue(canvasProps);
69
+ }, [setViewContextValue, canvasProps]);
70
+ return _objectSpread({
71
+ setViewContext: setViewContext
72
+ }, canvasProps);
73
+ }
74
+
75
+ /**
76
+ * useAnimationFrame
77
+ */
78
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
79
+ var useAnimationFrame = exports.useAnimationFrame = function useAnimationFrame(callback, dependencies) {
80
+ // Use useRef for mutable variables that we want to persist
81
+ // without triggering a re-render on their change
82
+ var requestRef = (0, _react.useRef)(undefined);
83
+ function animate() {
84
+ callback();
85
+ requestRef.current = requestAnimationFrame(animate);
86
+ }
87
+ (0, _react.useEffect)(function () {
88
+ animate();
89
+ return function () {
90
+ if (requestRef.current != null) {
91
+ cancelAnimationFrame(requestRef.current);
92
+ }
93
+ };
94
+ /* eslint-disable-next-line react-hooks/exhaustive-deps */
95
+ }, dependencies); // Make sure the effect runs only once
96
+ };
@@ -0,0 +1,3 @@
1
+ export { Z_AXIS, Y_AXIS, X_AXIS, DEFAULT_UP_VEC3, DEFAULT_NORMAL_VEC3, DEFAULT_RIGHT_VEC3, DEFAULT_UP, DEFAULT_NORMAL, DEFAULT_RIGHT, SIDE_TYPES, CONTROLS_TYPES, CAMERA_TYPES } from "./constants";
2
+ export { FPS, billboard } from "./util";
3
+ export { useFrame, useViewContext, useAnimationFrame } from "./hooks";
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CAMERA_TYPES", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _constants.CAMERA_TYPES;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "CONTROLS_TYPES", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _constants.CONTROLS_TYPES;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "DEFAULT_NORMAL", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _constants.DEFAULT_NORMAL;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "DEFAULT_NORMAL_VEC3", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _constants.DEFAULT_NORMAL_VEC3;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "DEFAULT_RIGHT", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _constants.DEFAULT_RIGHT;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "DEFAULT_RIGHT_VEC3", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _constants.DEFAULT_RIGHT_VEC3;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "DEFAULT_UP", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _constants.DEFAULT_UP;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "DEFAULT_UP_VEC3", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _constants.DEFAULT_UP_VEC3;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "FPS", {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _util.FPS;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "SIDE_TYPES", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _constants.SIDE_TYPES;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "X_AXIS", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _constants.X_AXIS;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "Y_AXIS", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _constants.Y_AXIS;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "Z_AXIS", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _constants.Z_AXIS;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "billboard", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _util.billboard;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "useAnimationFrame", {
91
+ enumerable: true,
92
+ get: function get() {
93
+ return _hooks.useAnimationFrame;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "useFrame", {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _hooks.useFrame;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "useViewContext", {
103
+ enumerable: true,
104
+ get: function get() {
105
+ return _hooks.useViewContext;
106
+ }
107
+ });
108
+ var _constants = require("./constants");
109
+ var _util = require("./util");
110
+ var _hooks = require("./hooks");
@@ -0,0 +1,9 @@
1
+ import * as THREE from "three";
2
+ export declare namespace StandardViewTypes {
3
+ type Geometries = THREE.BufferGeometry | THREE.BoxGeometry | THREE.CircleGeometry | THREE.CylinderGeometry | THREE.PlaneGeometry | THREE.SphereGeometry | THREE.EdgesGeometry;
4
+ type Point = Array<number> | {
5
+ x: number;
6
+ y: number;
7
+ z: number;
8
+ };
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,12 @@
1
+ export declare const EPS = 0.000001;
2
+ export declare const EPS_NANO = 1e-9;
3
+ export declare function nextPowerOfTwo(x: number): number;
4
+ /**
5
+ * randomBetween lower and upper, including lower but not upper.
6
+ */
7
+ export declare function randomBetween(lower: number, upper: number): number;
8
+ /**
9
+ * minmax
10
+ * Given a number, it will be bounded by the given min and max.
11
+ */
12
+ export declare function minmax(target: number, min: number, max: number): number;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EPS_NANO = exports.EPS = void 0;
7
+ exports.minmax = minmax;
8
+ exports.nextPowerOfTwo = nextPowerOfTwo;
9
+ exports.randomBetween = randomBetween;
10
+ // math.ts
11
+
12
+ var EPS = exports.EPS = 1e-6;
13
+ var EPS_NANO = exports.EPS_NANO = 1e-9;
14
+ function nextPowerOfTwo(x) {
15
+ return Math.pow(2, Math.ceil(Math.log2(x)));
16
+ }
17
+
18
+ /**
19
+ * randomBetween lower and upper, including lower but not upper.
20
+ */
21
+ function randomBetween(lower, upper) {
22
+ return Math.random() * (upper - lower) + lower;
23
+ }
24
+
25
+ /**
26
+ * minmax
27
+ * Given a number, it will be bounded by the given min and max.
28
+ */
29
+ function minmax(target, min, max) {
30
+ return Math.min(Math.max(target, min), max);
31
+ }
@@ -0,0 +1,7 @@
1
+ export declare function performanceStart(name?: string, stopwatchMode?: boolean): void;
2
+ export declare function performanceEnd(name?: string): void;
3
+ export declare function performanceLog(name?: string, print?: boolean): {
4
+ average: number;
5
+ total: number;
6
+ count: number;
7
+ };