@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.
- package/.prettierignore +67 -0
- package/.prettierrc +12 -0
- package/CHANGELOG.md +42 -0
- package/LICENSE +8 -0
- package/README.md +199 -0
- package/debug-storybook.log +179 -0
- package/declarations.d.ts +17 -0
- package/dist/standard-view.es.js +9522 -0
- package/dist/standard-view.es.js.map +1 -0
- package/dist/standard-view.umd.js +41 -0
- package/dist/standard-view.umd.js.map +1 -0
- package/fonts/gentilis.bold.typeface.json +1 -0
- package/fonts/gentilis.typeface.json +1 -0
- package/fonts/helvetiker.bold.typeface.json +1 -0
- package/fonts/helvetiker.typeface.json +1 -0
- package/fonts/optimer.bold.typeface.json +1 -0
- package/fonts/optimer.typeface.json +1 -0
- package/images.d.ts +7 -0
- package/index.js +10 -0
- package/lib/controls/OrbitControls.d.ts +9 -0
- package/lib/controls/OrbitControls.js +761 -0
- package/lib/controls/index.d.ts +1 -0
- package/lib/controls/index.js +18 -0
- package/lib/groups/Arrow.d.ts +19 -0
- package/lib/groups/Arrow.js +134 -0
- package/lib/groups/Axis.d.ts +20 -0
- package/lib/groups/Axis.js +147 -0
- package/lib/groups/BoundingBox.d.ts +9 -0
- package/lib/groups/BoundingBox.js +143 -0
- package/lib/groups/Camera.d.ts +32 -0
- package/lib/groups/Camera.js +477 -0
- package/lib/groups/Capsule.d.ts +9 -0
- package/lib/groups/Capsule.js +112 -0
- package/lib/groups/FBX.d.ts +9 -0
- package/lib/groups/FBX.js +213 -0
- package/lib/groups/GLTF.d.ts +9 -0
- package/lib/groups/GLTF.js +198 -0
- package/lib/groups/Group.d.ts +63 -0
- package/lib/groups/Group.js +426 -0
- package/lib/groups/OBJ.d.ts +11 -0
- package/lib/groups/OBJ.js +252 -0
- package/lib/groups/PCD.d.ts +9 -0
- package/lib/groups/PCD.js +82 -0
- package/lib/groups/Path.d.ts +19 -0
- package/lib/groups/Path.js +160 -0
- package/lib/groups/index.d.ts +11 -0
- package/lib/groups/index.js +91 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +298 -0
- package/lib/lights/AmbientLight.d.ts +8 -0
- package/lib/lights/AmbientLight.js +37 -0
- package/lib/lights/DirectionalLight.d.ts +8 -0
- package/lib/lights/DirectionalLight.js +43 -0
- package/lib/lights/HemisphereLight.d.ts +13 -0
- package/lib/lights/HemisphereLight.js +108 -0
- package/lib/lights/LightWithShadows.d.ts +24 -0
- package/lib/lights/LightWithShadows.js +188 -0
- package/lib/lights/PointLight.d.ts +9 -0
- package/lib/lights/PointLight.js +47 -0
- package/lib/lights/RectAreaLight.d.ts +13 -0
- package/lib/lights/RectAreaLight.js +177 -0
- package/lib/lights/SpotLight.d.ts +10 -0
- package/lib/lights/SpotLight.js +49 -0
- package/lib/lights/index.d.ts +6 -0
- package/lib/lights/index.js +48 -0
- package/lib/primitives/Box.d.ts +6 -0
- package/lib/primitives/Box.js +43 -0
- package/lib/primitives/Circle.d.ts +10 -0
- package/lib/primitives/Circle.js +85 -0
- package/lib/primitives/Cylinder.d.ts +15 -0
- package/lib/primitives/Cylinder.js +180 -0
- package/lib/primitives/Label.d.ts +18 -0
- package/lib/primitives/Label.js +189 -0
- package/lib/primitives/Line.d.ts +19 -0
- package/lib/primitives/Line.js +173 -0
- package/lib/primitives/Mesh.d.ts +72 -0
- package/lib/primitives/Mesh.js +642 -0
- package/lib/primitives/Plane.d.ts +7 -0
- package/lib/primitives/Plane.js +47 -0
- package/lib/primitives/Polygon.d.ts +8 -0
- package/lib/primitives/Polygon.js +75 -0
- package/lib/primitives/Quad.d.ts +9 -0
- package/lib/primitives/Quad.js +110 -0
- package/lib/primitives/Sphere.d.ts +14 -0
- package/lib/primitives/Sphere.js +92 -0
- package/lib/primitives/Text.d.ts +20 -0
- package/lib/primitives/Text.js +285 -0
- package/lib/primitives/Triangle.d.ts +8 -0
- package/lib/primitives/Triangle.js +83 -0
- package/lib/primitives/index.d.ts +12 -0
- package/lib/primitives/index.js +90 -0
- package/lib/shaders/index.d.ts +0 -0
- package/lib/shaders/index.js +2 -0
- package/lib/types/three-jsx.d.js +5 -0
- package/lib/utils/constants.js +181 -0
- package/lib/utils/events.d.ts +22 -0
- package/lib/utils/events.js +98 -0
- package/lib/utils/hooks.d.ts +8 -0
- package/lib/utils/hooks.js +96 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +110 -0
- package/lib/utils/interfaces.d.ts +9 -0
- package/lib/utils/interfaces.js +5 -0
- package/lib/utils/math.d.ts +12 -0
- package/lib/utils/math.js +31 -0
- package/lib/utils/performance.d.ts +7 -0
- package/lib/utils/performance.js +114 -0
- package/lib/utils/styles.js +10 -0
- package/lib/utils/util.d.ts +76 -0
- package/lib/utils/util.js +290 -0
- package/lib/views/ContextBridge.d.ts +23 -0
- package/lib/views/ContextBridge.js +98 -0
- package/lib/views/SceneCamera.d.ts +7 -0
- package/lib/views/SceneCamera.js +52 -0
- package/lib/views/SetBackground.d.ts +9 -0
- package/lib/views/SetBackground.js +90 -0
- package/lib/views/SetControls.d.ts +19 -0
- package/lib/views/SetControls.js +173 -0
- package/lib/views/SetRenderer.d.ts +25 -0
- package/lib/views/SetRenderer.js +66 -0
- package/lib/views/SetShadows.d.ts +7 -0
- package/lib/views/SetShadows.js +48 -0
- package/lib/views/View3D.d.ts +21 -0
- package/lib/views/View3D.js +289 -0
- package/lib/views/ViewContext.d.ts +23 -0
- package/lib/views/ViewContext.js +55 -0
- package/lib/views/index.d.ts +2 -0
- package/lib/views/index.js +20 -0
- package/netlify.toml +15 -0
- package/package.json +110 -0
- package/tsconfig.json +42 -0
- package/tsconfig.prod.json +3 -0
- package/tsconfig.test.json +6 -0
- package/vite.config.ts +37 -0
|
@@ -0,0 +1,188 @@
|
|
|
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 _hooks = require("../utils/hooks");
|
|
10
|
+
var _math = require("../utils/math");
|
|
11
|
+
var _excluded = ["THREELight", "THREEHelper", "lightParams", "helperParams", "position", "target", "castShadow", "shadowCameraNear", "shadowCameraFar", "shadowMapWidth", "shadowMapHeight", "helper"]; // LightWithShadows.tsx
|
|
12
|
+
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); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
16
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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; } }
|
|
20
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
21
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
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; }
|
|
25
|
+
var useEffect = React.useEffect,
|
|
26
|
+
useMemo = React.useMemo,
|
|
27
|
+
memo = React.memo;
|
|
28
|
+
|
|
29
|
+
// -------------------------------------- //
|
|
30
|
+
// ----- CommonLightWithShadows ----- //
|
|
31
|
+
// -------------------------------------- //
|
|
32
|
+
|
|
33
|
+
// -------------------------------- //
|
|
34
|
+
// ----- LightWithShadows ----- //
|
|
35
|
+
// -------------------------------- //
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* LightWithShadows
|
|
39
|
+
*
|
|
40
|
+
* Similar to the Mesh component, the Light component is what most lights
|
|
41
|
+
* are under the hood.
|
|
42
|
+
*
|
|
43
|
+
* However, unlike Mesh--which actually boils down to a
|
|
44
|
+
* three.js Mesh component, Light does not boil down to any specific three.js
|
|
45
|
+
* component. Instead, Light is like an abstraction to reduce repetitive setup
|
|
46
|
+
* that is common to DirectionalLight, SpotLight, and PointLight.
|
|
47
|
+
*
|
|
48
|
+
* Technically, the specific three.js light constructor and helper constructor
|
|
49
|
+
* is passed in through the THREELight and THREEHelper props.
|
|
50
|
+
*
|
|
51
|
+
* Just as in three.js, Light is an abstract base class, in Standard View, Light
|
|
52
|
+
* is like an "abstract" base component.
|
|
53
|
+
*/
|
|
54
|
+
var LightWithShadows = function LightWithShadows(_ref) {
|
|
55
|
+
var THREELight = _ref.THREELight,
|
|
56
|
+
THREEHelper = _ref.THREEHelper,
|
|
57
|
+
lightParams = _ref.lightParams,
|
|
58
|
+
helperParams = _ref.helperParams,
|
|
59
|
+
_ref$position = _ref.position,
|
|
60
|
+
position = _ref$position === void 0 ? [0, 0, 1] : _ref$position,
|
|
61
|
+
target = _ref.target,
|
|
62
|
+
_ref$castShadow = _ref.castShadow,
|
|
63
|
+
castShadow = _ref$castShadow === void 0 ? false : _ref$castShadow,
|
|
64
|
+
_ref$shadowCameraNear = _ref.shadowCameraNear,
|
|
65
|
+
shadowCameraNear = _ref$shadowCameraNear === void 0 ? 0.1 : _ref$shadowCameraNear,
|
|
66
|
+
_ref$shadowCameraFar = _ref.shadowCameraFar,
|
|
67
|
+
shadowCameraFar = _ref$shadowCameraFar === void 0 ? 100 : _ref$shadowCameraFar,
|
|
68
|
+
_ref$shadowMapWidth = _ref.shadowMapWidth,
|
|
69
|
+
shadowMapWidth = _ref$shadowMapWidth === void 0 ? 1024 : _ref$shadowMapWidth,
|
|
70
|
+
_ref$shadowMapHeight = _ref.shadowMapHeight,
|
|
71
|
+
shadowMapHeight = _ref$shadowMapHeight === void 0 ? 1024 : _ref$shadowMapHeight,
|
|
72
|
+
_ref$helper = _ref.helper,
|
|
73
|
+
helper = _ref$helper === void 0 ? false : _ref$helper,
|
|
74
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
75
|
+
// Light
|
|
76
|
+
var light = useMemo(function createLight() {
|
|
77
|
+
return _construct(THREELight, _toConsumableArray(lightParams));
|
|
78
|
+
}, [lightParams, THREELight]);
|
|
79
|
+
|
|
80
|
+
// Position
|
|
81
|
+
useEffect(function updatePosition() {
|
|
82
|
+
var _light$position;
|
|
83
|
+
// @ts-ignore:TS2569 spread
|
|
84
|
+
(_light$position = light.position).set.apply(_light$position, _toConsumableArray(position));
|
|
85
|
+
}, [light, position]);
|
|
86
|
+
|
|
87
|
+
// Target
|
|
88
|
+
var _useViewContext = (0, _hooks.useViewContext)(),
|
|
89
|
+
scene = _useViewContext.scene;
|
|
90
|
+
useEffect(function updateTarget() {
|
|
91
|
+
if (light.target && target) {
|
|
92
|
+
// light.target must be Object3D
|
|
93
|
+
if (Array.isArray(target)) {
|
|
94
|
+
var _light$target$positio;
|
|
95
|
+
(_light$target$positio = light.target.position).set.apply(_light$target$positio, _toConsumableArray(target));
|
|
96
|
+
}
|
|
97
|
+
scene.add(light.target);
|
|
98
|
+
}
|
|
99
|
+
}, [light, scene, target]);
|
|
100
|
+
|
|
101
|
+
// Check position overlap with target
|
|
102
|
+
useEffect(function checkPositionTarget() {
|
|
103
|
+
if (!light.target) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check position overlap target
|
|
108
|
+
var pos = position;
|
|
109
|
+
var tpos = light.target.position;
|
|
110
|
+
if (pos[0] === tpos.x && pos[1] === tpos.y && pos[2] === tpos.z) {
|
|
111
|
+
/* eslint-disable-next-line no-console */
|
|
112
|
+
console.warn("[LightWithShadows] position and target cannot be the same!");
|
|
113
|
+
|
|
114
|
+
/* eslint-disable no-param-reassign */
|
|
115
|
+
position[2] += _math.EPS;
|
|
116
|
+
light.position.z += _math.EPS;
|
|
117
|
+
/* eslint-enable no-param-reassign */
|
|
118
|
+
}
|
|
119
|
+
}, [light, position, target]);
|
|
120
|
+
|
|
121
|
+
// Shadows
|
|
122
|
+
useEffect(function updateShadows() {
|
|
123
|
+
light.castShadow = castShadow;
|
|
124
|
+
light.shadow.camera.near = shadowCameraNear;
|
|
125
|
+
light.shadow.camera.far = shadowCameraFar;
|
|
126
|
+
light.shadow.mapSize.width = (0, _math.nextPowerOfTwo)(shadowMapWidth);
|
|
127
|
+
light.shadow.mapSize.height = (0, _math.nextPowerOfTwo)(shadowMapHeight);
|
|
128
|
+
}, [light, castShadow, shadowCameraNear, shadowCameraFar, shadowMapWidth, shadowMapHeight]);
|
|
129
|
+
|
|
130
|
+
// Helper Params
|
|
131
|
+
// Helper needs a reference to light as the first param.
|
|
132
|
+
var _helperParams = useMemo(function updateHelperParams() {
|
|
133
|
+
return [light].concat(_toConsumableArray(helperParams));
|
|
134
|
+
}, [light, helperParams]);
|
|
135
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("primitive", _extends({
|
|
136
|
+
object: light
|
|
137
|
+
}, otherProps)), helper && /*#__PURE__*/React.createElement(LightWithShadowsHelper, {
|
|
138
|
+
THREEHelper: THREEHelper,
|
|
139
|
+
helperParams: _helperParams,
|
|
140
|
+
helper: helper
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
var LightWithShadowsMemo = memo(LightWithShadows);
|
|
144
|
+
LightWithShadowsMemo.displayName = "LightWithShadows";
|
|
145
|
+
var _default = exports["default"] = LightWithShadowsMemo; // -------------------------------------- //
|
|
146
|
+
// ----- LightWithShadowsHelper ----- //
|
|
147
|
+
// -------------------------------------- //
|
|
148
|
+
/**
|
|
149
|
+
* UpdateLightWithShadowsHelper
|
|
150
|
+
*
|
|
151
|
+
* Isolates the useFrame hook to avoid larger components, namely
|
|
152
|
+
* CreateLightHelper, from re-rendering up to 3 times--this is
|
|
153
|
+
* a bug from @react-three/fiber.
|
|
154
|
+
* Any @react-three/fiber hook call incurs additional renders.
|
|
155
|
+
*/
|
|
156
|
+
function UpdateLightWithShadowsHelper(_ref2) {
|
|
157
|
+
var helper = _ref2.helper,
|
|
158
|
+
lightHelper = _ref2.lightHelper;
|
|
159
|
+
(0, _hooks.useFrame)(function updateHelper() {
|
|
160
|
+
if (helper) {
|
|
161
|
+
lightHelper.update();
|
|
162
|
+
}
|
|
163
|
+
}, 2);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* LightWithShadowsHelper
|
|
168
|
+
*
|
|
169
|
+
* Generates light helper object and also adds the update
|
|
170
|
+
* function in three.js's render loop.
|
|
171
|
+
*/
|
|
172
|
+
var LightWithShadowsHelper = function LightWithShadowsHelper(_ref3) {
|
|
173
|
+
var THREEHelper = _ref3.THREEHelper,
|
|
174
|
+
helperParams = _ref3.helperParams,
|
|
175
|
+
helper = _ref3.helper;
|
|
176
|
+
var lightHelper = useMemo(function updateTHREEHelper() {
|
|
177
|
+
return _construct(THREEHelper, _toConsumableArray(helperParams));
|
|
178
|
+
}, [helperParams, THREEHelper]);
|
|
179
|
+
if (!helper) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UpdateLightWithShadowsHelper, {
|
|
183
|
+
helper: helper,
|
|
184
|
+
lightHelper: lightHelper
|
|
185
|
+
}), /*#__PURE__*/React.createElement("primitive", {
|
|
186
|
+
object: lightHelper
|
|
187
|
+
}));
|
|
188
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { CommonLightWithShadowsProps } from "./LightWithShadows";
|
|
3
|
+
interface PointLightProps extends CommonLightWithShadowsProps {
|
|
4
|
+
distance?: number;
|
|
5
|
+
decay?: number;
|
|
6
|
+
helperSize?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const PointLightMemo: React.NamedExoticComponent<PointLightProps>;
|
|
9
|
+
export default PointLightMemo;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 _LightWithShadows = _interopRequireDefault(require("./LightWithShadows"));
|
|
11
|
+
var _excluded = ["color", "intensity", "distance", "decay", "helperSize", "helperColor"]; // PointLight.tsx
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var useMemo = React.useMemo,
|
|
18
|
+
memo = React.memo;
|
|
19
|
+
var PointLight = function PointLight(_ref) {
|
|
20
|
+
var _ref$color = _ref.color,
|
|
21
|
+
color = _ref$color === void 0 ? "white" : _ref$color,
|
|
22
|
+
_ref$intensity = _ref.intensity,
|
|
23
|
+
intensity = _ref$intensity === void 0 ? 1 : _ref$intensity,
|
|
24
|
+
_ref$distance = _ref.distance,
|
|
25
|
+
distance = _ref$distance === void 0 ? 0 : _ref$distance,
|
|
26
|
+
_ref$decay = _ref.decay,
|
|
27
|
+
decay = _ref$decay === void 0 ? 1 : _ref$decay,
|
|
28
|
+
_ref$helperSize = _ref.helperSize,
|
|
29
|
+
helperSize = _ref$helperSize === void 0 ? 1 : _ref$helperSize,
|
|
30
|
+
helperColor = _ref.helperColor,
|
|
31
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
var lightParams = useMemo(function updateLightParams() {
|
|
33
|
+
return [color, intensity, distance, decay];
|
|
34
|
+
}, [color, intensity, distance, decay]);
|
|
35
|
+
var helperParams = useMemo(function updateHelperParams() {
|
|
36
|
+
return [helperSize, helperColor || color];
|
|
37
|
+
}, [helperSize, helperColor, color]);
|
|
38
|
+
return /*#__PURE__*/React.createElement(_LightWithShadows["default"], _extends({
|
|
39
|
+
THREELight: THREE.PointLight,
|
|
40
|
+
THREEHelper: THREE.PointLightHelper,
|
|
41
|
+
lightParams: lightParams,
|
|
42
|
+
helperParams: helperParams
|
|
43
|
+
}, otherProps));
|
|
44
|
+
};
|
|
45
|
+
var PointLightMemo = memo(PointLight);
|
|
46
|
+
PointLightMemo.displayName = "PointLight";
|
|
47
|
+
var _default = exports["default"] = PointLightMemo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface RectAreaLightProps {
|
|
3
|
+
position?: Array<number>;
|
|
4
|
+
intensity?: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
target?: Array<number>;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
helper?: boolean;
|
|
10
|
+
helperColor?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const RectAreaLightMemo: React.NamedExoticComponent<RectAreaLightProps>;
|
|
13
|
+
export default RectAreaLightMemo;
|
|
@@ -0,0 +1,177 @@
|
|
|
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 _Plane = _interopRequireDefault(require("../primitives/Plane"));
|
|
11
|
+
var _Cylinder = _interopRequireDefault(require("../primitives/Cylinder"));
|
|
12
|
+
var _math = require("../utils/math");
|
|
13
|
+
var _excluded = ["position", "target", "color", "intensity", "width", "height", "helper", "helperColor"];
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
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); }
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
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; } // RectAreaLight.tsx
|
|
28
|
+
var useEffect = React.useEffect,
|
|
29
|
+
useMemo = React.useMemo,
|
|
30
|
+
memo = React.memo;
|
|
31
|
+
/**
|
|
32
|
+
* RectAreaLightHelper
|
|
33
|
+
*
|
|
34
|
+
* During a re-render, @react-three/fiber's reconciler executes a switchInstance
|
|
35
|
+
* function if a component has new arguments. This switchInstance basically creates
|
|
36
|
+
* a newInstance with the new arguments and removes old instance.
|
|
37
|
+
*
|
|
38
|
+
* The old instance of the component is removed via a removeChild function which
|
|
39
|
+
* also invokes a removeRecursive function that also removes children of the child,
|
|
40
|
+
* recursively. This ensures all nested children are removed.
|
|
41
|
+
*
|
|
42
|
+
* Unfortunately, @react-three/fiber's removeChild function first removes the child,
|
|
43
|
+
* then recursively removes its children, and then checks if the child has a
|
|
44
|
+
* dispose function and calls it--which allows for three.js cleanup code to execute
|
|
45
|
+
* upon removal, and finally deletes the reference.
|
|
46
|
+
*
|
|
47
|
+
* Due to this order of remove, recursively remove, dispose, and delete,
|
|
48
|
+
* an invalid reference crash occurs.
|
|
49
|
+
*
|
|
50
|
+
* This bug is due to the fact that three.js normally stores the geometry and material
|
|
51
|
+
* of a Mesh/Object3D in class variables named geometry and material.
|
|
52
|
+
* However, for RectAreaLightHelper, the Line's (outlining the plane of the helper) has
|
|
53
|
+
* its geometry and material stored in variables of those names, but another Mesh (of
|
|
54
|
+
* the quad) is stored as a child.
|
|
55
|
+
*
|
|
56
|
+
* Normally this is fine, since all children are recursively removed by @react-three/fiber,
|
|
57
|
+
* but unfortunatley, RectAreaLightHelper's dispose function spefically calls:
|
|
58
|
+
* this.children[0].geometry.dispose()
|
|
59
|
+
* this.children[0].material.dispose()
|
|
60
|
+
* refering to the quad mesh as `this.children[0]`. By the time RectAreaLightHelper's
|
|
61
|
+
* dispose function is called, @react-three/fiber has already recursively removed the
|
|
62
|
+
* children, hence this.childern is an empty array, resulting in an array reference crash.
|
|
63
|
+
*
|
|
64
|
+
* For other light helpers, the geometry and material are not stored in the children
|
|
65
|
+
* property of the helper, but just in the named variables such as
|
|
66
|
+
* PointLight: `geometry`, `material`,
|
|
67
|
+
* SpotLight: `cone.geometry`, `cone.material`,
|
|
68
|
+
* DirectionalLight: `lightPlane.geometry`, `lightPlane.material`,
|
|
69
|
+
* `targetLine.geometry`, `targetLine.material`,
|
|
70
|
+
* and those helpers' dispose function does not reference any children.
|
|
71
|
+
*
|
|
72
|
+
* Therefore, THREE.RectAreaLightHelper / rectAreaLightHelper cannot safely re-render
|
|
73
|
+
* through @react-three/fiber's reconciler.
|
|
74
|
+
*
|
|
75
|
+
* This is the custom RectAreaLightHelper.
|
|
76
|
+
*/
|
|
77
|
+
function RectAreaLightHelper(_ref) {
|
|
78
|
+
var position = _ref.position,
|
|
79
|
+
target = _ref.target,
|
|
80
|
+
width = _ref.width,
|
|
81
|
+
height = _ref.height,
|
|
82
|
+
helperColor = _ref.helperColor;
|
|
83
|
+
var dist = useMemo(function updateDist() {
|
|
84
|
+
var posVec = _construct(THREE.Vector3, _toConsumableArray(position));
|
|
85
|
+
var targetVec = _construct(THREE.Vector3, _toConsumableArray(target));
|
|
86
|
+
return posVec.distanceTo(targetVec);
|
|
87
|
+
}, [position, target]);
|
|
88
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Plane["default"], {
|
|
89
|
+
scale: [width, height, 1],
|
|
90
|
+
color: helperColor,
|
|
91
|
+
side: THREE.FrontSide,
|
|
92
|
+
wireframe: true
|
|
93
|
+
}), /*#__PURE__*/React.createElement(_Plane["default"], {
|
|
94
|
+
scale: [width, height, 1],
|
|
95
|
+
color: helperColor,
|
|
96
|
+
side: THREE.BackSide
|
|
97
|
+
}), /*#__PURE__*/React.createElement(_Cylinder["default"], {
|
|
98
|
+
start: [0, 0, 0],
|
|
99
|
+
end: [0, 0, -dist],
|
|
100
|
+
radius: 0.02,
|
|
101
|
+
color: helperColor
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* RectAreaLight
|
|
106
|
+
*/
|
|
107
|
+
var RectAreaLight = function RectAreaLight(_ref2) {
|
|
108
|
+
var _ref2$position = _ref2.position,
|
|
109
|
+
position = _ref2$position === void 0 ? [0, 10, 0] : _ref2$position,
|
|
110
|
+
_ref2$target = _ref2.target,
|
|
111
|
+
target = _ref2$target === void 0 ? [0, 0, 0] : _ref2$target,
|
|
112
|
+
_ref2$color = _ref2.color,
|
|
113
|
+
color = _ref2$color === void 0 ? "white" : _ref2$color,
|
|
114
|
+
_ref2$intensity = _ref2.intensity,
|
|
115
|
+
intensity = _ref2$intensity === void 0 ? 1 : _ref2$intensity,
|
|
116
|
+
_ref2$width = _ref2.width,
|
|
117
|
+
width = _ref2$width === void 0 ? 1 : _ref2$width,
|
|
118
|
+
_ref2$height = _ref2.height,
|
|
119
|
+
height = _ref2$height === void 0 ? 1 : _ref2$height,
|
|
120
|
+
_ref2$helper = _ref2.helper,
|
|
121
|
+
helper = _ref2$helper === void 0 ? false : _ref2$helper,
|
|
122
|
+
helperColor = _ref2.helperColor,
|
|
123
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded);
|
|
124
|
+
var _helperColor = useMemo(function updateHelperColor() {
|
|
125
|
+
return helperColor || color;
|
|
126
|
+
}, [helperColor, color]);
|
|
127
|
+
var _useMemo = useMemo(function updateDimensions() {
|
|
128
|
+
return {
|
|
129
|
+
_width: Math.max(width, _math.EPS),
|
|
130
|
+
_height: Math.max(height, _math.EPS)
|
|
131
|
+
};
|
|
132
|
+
}, [width, height]),
|
|
133
|
+
_width = _useMemo._width,
|
|
134
|
+
_height = _useMemo._height;
|
|
135
|
+
var light = useMemo(function createLight() {
|
|
136
|
+
return new THREE.RectAreaLight(color, intensity, _width, _height);
|
|
137
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
138
|
+
}, []);
|
|
139
|
+
var helperProps = useMemo(function updateHelperProps() {
|
|
140
|
+
return {
|
|
141
|
+
position: position,
|
|
142
|
+
target: target,
|
|
143
|
+
width: _width,
|
|
144
|
+
height: _height,
|
|
145
|
+
helperColor: _helperColor
|
|
146
|
+
};
|
|
147
|
+
}, [position, target, _width, _height, _helperColor]);
|
|
148
|
+
useEffect(function updateColor() {
|
|
149
|
+
light.color.set(color);
|
|
150
|
+
}, [light, color]);
|
|
151
|
+
useEffect(function updateIntensity() {
|
|
152
|
+
light.intensity = intensity;
|
|
153
|
+
}, [light, intensity]);
|
|
154
|
+
useEffect(function updateDimensions() {
|
|
155
|
+
light.width = _width;
|
|
156
|
+
light.height = _height;
|
|
157
|
+
}, [light, _width, _height]);
|
|
158
|
+
useEffect(function updatePosition() {
|
|
159
|
+
var _light$position;
|
|
160
|
+
// @ts-ignore:TS2556 // sphread
|
|
161
|
+
(_light$position = light.position).set.apply(_light$position, _toConsumableArray(position));
|
|
162
|
+
}, [light, position]);
|
|
163
|
+
useEffect(function updateTarget() {
|
|
164
|
+
// @ts-ignore:TS2556 spread
|
|
165
|
+
light.lookAt.apply(light, _toConsumableArray(target));
|
|
166
|
+
}, [light, target]);
|
|
167
|
+
return (
|
|
168
|
+
/*#__PURE__*/
|
|
169
|
+
// @ts-ignore:2339 property primitive does not exist
|
|
170
|
+
React.createElement("primitive", _extends({
|
|
171
|
+
object: light
|
|
172
|
+
}, otherProps), helper && /*#__PURE__*/React.createElement(RectAreaLightHelper, helperProps))
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
var RectAreaLightMemo = memo(RectAreaLight);
|
|
176
|
+
RectAreaLightMemo.displayName = "RectAreaLight";
|
|
177
|
+
var _default = exports["default"] = RectAreaLightMemo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { CommonLightWithShadowsProps } from "./LightWithShadows";
|
|
3
|
+
interface SpotLightProps extends CommonLightWithShadowsProps {
|
|
4
|
+
distance?: number;
|
|
5
|
+
decay?: number;
|
|
6
|
+
angle?: number;
|
|
7
|
+
penumbra?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const SpotLightMemo: React.NamedExoticComponent<SpotLightProps>;
|
|
10
|
+
export default SpotLightMemo;
|
|
@@ -0,0 +1,49 @@
|
|
|
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 _LightWithShadows = _interopRequireDefault(require("./LightWithShadows"));
|
|
11
|
+
var _excluded = ["color", "intensity", "distance", "decay", "angle", "penumbra", "helperColor"]; // SpotLight.tsx
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var useMemo = React.useMemo,
|
|
18
|
+
memo = React.memo;
|
|
19
|
+
var SpotLight = function SpotLight(_ref) {
|
|
20
|
+
var _ref$color = _ref.color,
|
|
21
|
+
color = _ref$color === void 0 ? "white" : _ref$color,
|
|
22
|
+
_ref$intensity = _ref.intensity,
|
|
23
|
+
intensity = _ref$intensity === void 0 ? 1 : _ref$intensity,
|
|
24
|
+
_ref$distance = _ref.distance,
|
|
25
|
+
distance = _ref$distance === void 0 ? 0 : _ref$distance,
|
|
26
|
+
_ref$decay = _ref.decay,
|
|
27
|
+
decay = _ref$decay === void 0 ? 1 : _ref$decay,
|
|
28
|
+
_ref$angle = _ref.angle,
|
|
29
|
+
angle = _ref$angle === void 0 ? Math.PI * 0.333 : _ref$angle,
|
|
30
|
+
_ref$penumbra = _ref.penumbra,
|
|
31
|
+
penumbra = _ref$penumbra === void 0 ? 0 : _ref$penumbra,
|
|
32
|
+
helperColor = _ref.helperColor,
|
|
33
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
var lightParams = useMemo(function updateLightParams() {
|
|
35
|
+
return [color, intensity, distance, angle, penumbra, decay];
|
|
36
|
+
}, [color, intensity, distance, angle, penumbra, decay]);
|
|
37
|
+
var helperParams = useMemo(function updateHelperParams() {
|
|
38
|
+
return [helperColor || color];
|
|
39
|
+
}, [helperColor, color]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(_LightWithShadows["default"], _extends({
|
|
41
|
+
THREELight: THREE.SpotLight,
|
|
42
|
+
THREEHelper: THREE.SpotLightHelper,
|
|
43
|
+
lightParams: lightParams,
|
|
44
|
+
helperParams: helperParams
|
|
45
|
+
}, otherProps));
|
|
46
|
+
};
|
|
47
|
+
var SpotLightMemo = memo(SpotLight);
|
|
48
|
+
SpotLightMemo.displayName = "SpotLight";
|
|
49
|
+
var _default = exports["default"] = SpotLightMemo;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as AmbientLight } from "./AmbientLight";
|
|
2
|
+
export { default as DirectionalLight } from "./DirectionalLight";
|
|
3
|
+
export { default as HemisphereLight } from "./HemisphereLight";
|
|
4
|
+
export { default as PointLight } from "./PointLight";
|
|
5
|
+
export { default as RectAreaLight } from "./RectAreaLight";
|
|
6
|
+
export { default as SpotLight } from "./SpotLight";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AmbientLight", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AmbientLight["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "DirectionalLight", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _DirectionalLight["default"];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "HemisphereLight", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _HemisphereLight["default"];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PointLight", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _PointLight["default"];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "RectAreaLight", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _RectAreaLight["default"];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "SpotLight", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _SpotLight["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _AmbientLight = _interopRequireDefault(require("./AmbientLight"));
|
|
43
|
+
var _DirectionalLight = _interopRequireDefault(require("./DirectionalLight"));
|
|
44
|
+
var _HemisphereLight = _interopRequireDefault(require("./HemisphereLight"));
|
|
45
|
+
var _PointLight = _interopRequireDefault(require("./PointLight"));
|
|
46
|
+
var _RectAreaLight = _interopRequireDefault(require("./RectAreaLight"));
|
|
47
|
+
var _SpotLight = _interopRequireDefault(require("./SpotLight"));
|
|
48
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -0,0 +1,43 @@
|
|
|
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 _Mesh = _interopRequireDefault(require("./Mesh"));
|
|
11
|
+
var _excluded = ["children"]; // Box.tsx
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var useMemo = React.useMemo,
|
|
18
|
+
memo = React.memo;
|
|
19
|
+
|
|
20
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Box
|
|
24
|
+
*
|
|
25
|
+
* Nothing particularly special about boxes. All the properties of
|
|
26
|
+
* Meshes can be applied and will be passed into the Box's Mesh.
|
|
27
|
+
*
|
|
28
|
+
* @param {BoxProps} props
|
|
29
|
+
*/
|
|
30
|
+
var Box = function Box(_ref) {
|
|
31
|
+
var children = _ref.children,
|
|
32
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
// Box Buffer Geometry
|
|
34
|
+
var geometry = useMemo(function initGeometry() {
|
|
35
|
+
return new THREE.BoxGeometry(1, 1, 1);
|
|
36
|
+
}, []);
|
|
37
|
+
return /*#__PURE__*/React.createElement(_Mesh["default"], _extends({
|
|
38
|
+
geometry: geometry
|
|
39
|
+
}, otherProps), children);
|
|
40
|
+
};
|
|
41
|
+
var BoxMemo = memo(Box);
|
|
42
|
+
BoxMemo.displayName = "Box";
|
|
43
|
+
var _default = exports["default"] = BoxMemo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MeshProps } from "./Mesh";
|
|
3
|
+
interface CircleProps extends MeshProps {
|
|
4
|
+
radius?: number;
|
|
5
|
+
segments?: number;
|
|
6
|
+
thetaStart?: number;
|
|
7
|
+
thetaLength?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const CircleMemo: React.NamedExoticComponent<CircleProps>;
|
|
10
|
+
export default CircleMemo;
|