@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
package/lib/index.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
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 _lights.AmbientLight;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Arrow", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _groups.Arrow;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Axis", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _groups.Axis;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "BoundingBox", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _groups.BoundingBox;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "Box", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _primitives.Box;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "CAMERA_TYPES", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _utils.CAMERA_TYPES;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "CONTROLS_TYPES", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _utils.CONTROLS_TYPES;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "Camera", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _groups.Camera;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "Capsule", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _groups.Capsule;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "Circle", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _primitives.Circle;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "Cylinder", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _primitives.Cylinder;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "DEFAULT_NORMAL", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _utils.DEFAULT_NORMAL;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "DEFAULT_NORMAL_VEC3", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _utils.DEFAULT_NORMAL_VEC3;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "DEFAULT_RIGHT", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _utils.DEFAULT_RIGHT;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "DEFAULT_RIGHT_VEC3", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _utils.DEFAULT_RIGHT_VEC3;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "DEFAULT_UP", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _utils.DEFAULT_UP;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "DEFAULT_UP_VEC3", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return _utils.DEFAULT_UP_VEC3;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "DirectionalLight", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function get() {
|
|
111
|
+
return _lights.DirectionalLight;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "FBX", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function get() {
|
|
117
|
+
return _groups.FBX;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "FPS", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function get() {
|
|
123
|
+
return _utils.FPS;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "GLTF", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function get() {
|
|
129
|
+
return _groups.GLTF;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "Group", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function get() {
|
|
135
|
+
return _groups.Group;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "HemisphereLight", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function get() {
|
|
141
|
+
return _lights.HemisphereLight;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "Label", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function get() {
|
|
147
|
+
return _primitives.Label;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "Line", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function get() {
|
|
153
|
+
return _primitives.Line;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "Mesh", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function get() {
|
|
159
|
+
return _primitives.Mesh;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "OBJ", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function get() {
|
|
165
|
+
return _groups.OBJ;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "PCD", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function get() {
|
|
171
|
+
return _groups.PCD;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "Path", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function get() {
|
|
177
|
+
return _groups.Path;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "Plane", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function get() {
|
|
183
|
+
return _primitives.Plane;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "PointLight", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function get() {
|
|
189
|
+
return _lights.PointLight;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "Polygon", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function get() {
|
|
195
|
+
return _primitives.Polygon;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(exports, "Quad", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function get() {
|
|
201
|
+
return _primitives.Quad;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(exports, "RectAreaLight", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function get() {
|
|
207
|
+
return _lights.RectAreaLight;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(exports, "SIDE_TYPES", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function get() {
|
|
213
|
+
return _utils.SIDE_TYPES;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(exports, "Sphere", {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
get: function get() {
|
|
219
|
+
return _primitives.Sphere;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(exports, "SpotLight", {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
get: function get() {
|
|
225
|
+
return _lights.SpotLight;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(exports, "Text", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function get() {
|
|
231
|
+
return _primitives.Text;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(exports, "Triangle", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function get() {
|
|
237
|
+
return _primitives.Triangle;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(exports, "View3D", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function get() {
|
|
243
|
+
return _views.View3D;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
Object.defineProperty(exports, "X_AXIS", {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function get() {
|
|
249
|
+
return _utils.X_AXIS;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
Object.defineProperty(exports, "Y_AXIS", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function get() {
|
|
255
|
+
return _utils.Y_AXIS;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
Object.defineProperty(exports, "Z_AXIS", {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get: function get() {
|
|
261
|
+
return _utils.Z_AXIS;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
Object.defineProperty(exports, "billboard", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function get() {
|
|
267
|
+
return _utils.billboard;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
Object.defineProperty(exports, "generateGroupProps", {
|
|
271
|
+
enumerable: true,
|
|
272
|
+
get: function get() {
|
|
273
|
+
return _groups.generateGroupProps;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(exports, "useAnimationFrame", {
|
|
277
|
+
enumerable: true,
|
|
278
|
+
get: function get() {
|
|
279
|
+
return _utils.useAnimationFrame;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
Object.defineProperty(exports, "useFrame", {
|
|
283
|
+
enumerable: true,
|
|
284
|
+
get: function get() {
|
|
285
|
+
return _utils.useFrame;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
Object.defineProperty(exports, "useViewContext", {
|
|
289
|
+
enumerable: true,
|
|
290
|
+
get: function get() {
|
|
291
|
+
return _utils.useViewContext;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
var _views = require("./views");
|
|
295
|
+
var _primitives = require("./primitives");
|
|
296
|
+
var _groups = require("./groups");
|
|
297
|
+
var _lights = require("./lights");
|
|
298
|
+
var _utils = require("./utils");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
interface AmbientLightProps {
|
|
4
|
+
color?: string | THREE.Color;
|
|
5
|
+
intensity?: number;
|
|
6
|
+
}
|
|
7
|
+
declare const AmbientLightMemo: React.NamedExoticComponent<AmbientLightProps>;
|
|
8
|
+
export default AmbientLightMemo;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 _excluded = ["color", "intensity"]; // AmbientalLight.tsx
|
|
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 _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); }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
var useMemo = React.useMemo,
|
|
16
|
+
memo = React.memo;
|
|
17
|
+
var AmbientLight = function AmbientLight(_ref) {
|
|
18
|
+
var _ref$color = _ref.color,
|
|
19
|
+
color = _ref$color === void 0 ? "white" : _ref$color,
|
|
20
|
+
_ref$intensity = _ref.intensity,
|
|
21
|
+
intensity = _ref$intensity === void 0 ? 1 : _ref$intensity,
|
|
22
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
var _color = useMemo(function updateColor() {
|
|
24
|
+
return new THREE.Color(color);
|
|
25
|
+
}, [color]);
|
|
26
|
+
return (
|
|
27
|
+
/*#__PURE__*/
|
|
28
|
+
// @ts-ignore: Property 'ambientLight' does not exist on type 'JSX.IntrinsicElements'
|
|
29
|
+
React.createElement("ambientLight", _extends({
|
|
30
|
+
color: _color,
|
|
31
|
+
intensity: intensity
|
|
32
|
+
}, otherProps))
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
var AmbientLightMemo = memo(AmbientLight);
|
|
36
|
+
AmbientLightMemo.displayName = "AmbientLight";
|
|
37
|
+
var _default = exports["default"] = AmbientLightMemo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { CommonLightWithShadowsProps } from "./LightWithShadows";
|
|
3
|
+
interface DirectionalLightProps extends CommonLightWithShadowsProps {
|
|
4
|
+
target?: Array<number>;
|
|
5
|
+
helperSize?: number;
|
|
6
|
+
}
|
|
7
|
+
declare const DirectionalLightMemo: React.NamedExoticComponent<DirectionalLightProps>;
|
|
8
|
+
export default DirectionalLightMemo;
|
|
@@ -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 _LightWithShadows = _interopRequireDefault(require("./LightWithShadows"));
|
|
11
|
+
var _excluded = ["color", "intensity", "helperSize", "helperColor"]; // DirectionalLight.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 DirectionalLight = function DirectionalLight(_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$helperSize = _ref.helperSize,
|
|
25
|
+
helperSize = _ref$helperSize === void 0 ? 1 : _ref$helperSize,
|
|
26
|
+
helperColor = _ref.helperColor,
|
|
27
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
var lightParams = useMemo(function updateLightParams() {
|
|
29
|
+
return [color, intensity];
|
|
30
|
+
}, [color, intensity]);
|
|
31
|
+
var helperParams = useMemo(function updateHelperParams() {
|
|
32
|
+
return [helperSize, helperColor || color];
|
|
33
|
+
}, [helperSize, helperColor, color]);
|
|
34
|
+
return /*#__PURE__*/React.createElement(_LightWithShadows["default"], _extends({
|
|
35
|
+
THREELight: THREE.DirectionalLight,
|
|
36
|
+
THREEHelper: THREE.DirectionalLightHelper,
|
|
37
|
+
lightParams: lightParams,
|
|
38
|
+
helperParams: helperParams
|
|
39
|
+
}, otherProps));
|
|
40
|
+
};
|
|
41
|
+
var DirectionalLightMemo = memo(DirectionalLight);
|
|
42
|
+
DirectionalLightMemo.displayName = "DirectionalLight";
|
|
43
|
+
var _default = exports["default"] = DirectionalLightMemo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface HemisphereLightProps {
|
|
3
|
+
position?: Array<number>;
|
|
4
|
+
color?: string;
|
|
5
|
+
skyColor?: string;
|
|
6
|
+
groundColor?: string;
|
|
7
|
+
intensity?: number;
|
|
8
|
+
helper?: boolean;
|
|
9
|
+
helperSize?: number;
|
|
10
|
+
children?: any;
|
|
11
|
+
}
|
|
12
|
+
declare const HemisphereLightMemo: React.NamedExoticComponent<HemisphereLightProps>;
|
|
13
|
+
export default HemisphereLightMemo;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 _Sphere = _interopRequireDefault(require("../primitives/Sphere"));
|
|
11
|
+
var _excluded = ["position", "color", "groundColor", "intensity", "helper", "helperSize", "skyColor"]; // HemispherealLight.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
|
+
* HemisphereLightHelper
|
|
21
|
+
*
|
|
22
|
+
* @react-three/fiber's reconciler switchInstance function for re-rendering
|
|
23
|
+
* components with new arguments, the order of execution is removeChild,
|
|
24
|
+
* recursiveRemove, dispose, and delete. Since children are removed before
|
|
25
|
+
* disposing a three.js object, if the dispose function references the
|
|
26
|
+
* children, an array reference crash occurs.
|
|
27
|
+
*
|
|
28
|
+
* HemisphereLightHelper's dispose function calls:
|
|
29
|
+
* this.children[0].geometry.dispose();
|
|
30
|
+
* this.children[0].material.dispose();
|
|
31
|
+
* where this.children[0] is refering to the Octahedron that represents the
|
|
32
|
+
* hemisphere light. Unfortunatley, three.js's poor choice of array
|
|
33
|
+
* referencing and @react-three/fiber's order of component removal causes
|
|
34
|
+
* an array reference crash (since the children were recursively removed,
|
|
35
|
+
* and only an empty array exists at the HemisphereLightHelper's dispose call).
|
|
36
|
+
*
|
|
37
|
+
* See RectAreaLight.js for more details, since the same issue exists for
|
|
38
|
+
* that light helper too.
|
|
39
|
+
*
|
|
40
|
+
* Ultimately, THREE.HemisphereLightHelper / hemisphereLightHelper cannot
|
|
41
|
+
* safely re-render through @react-three/fiber's reconciler.
|
|
42
|
+
*
|
|
43
|
+
* This is the custom HemisphereLightHelper.
|
|
44
|
+
*/
|
|
45
|
+
function HemisphereLightHelper(_ref) {
|
|
46
|
+
var helperSize = _ref.helperSize,
|
|
47
|
+
color = _ref.color,
|
|
48
|
+
groundColor = _ref.groundColor;
|
|
49
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Sphere["default"], {
|
|
50
|
+
radius: helperSize,
|
|
51
|
+
widthSegments: 10,
|
|
52
|
+
heightSegments: 10,
|
|
53
|
+
thetaStart: 0,
|
|
54
|
+
thetaLength: Math.PI * 0.5,
|
|
55
|
+
color: color,
|
|
56
|
+
wireframe: true
|
|
57
|
+
}), /*#__PURE__*/React.createElement(_Sphere["default"], {
|
|
58
|
+
radius: helperSize,
|
|
59
|
+
widthSegments: 10,
|
|
60
|
+
heightSegments: 10,
|
|
61
|
+
thetaStart: Math.PI * 0.5,
|
|
62
|
+
thetaLength: Math.PI,
|
|
63
|
+
color: groundColor,
|
|
64
|
+
wireframe: true
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
var HemisphereLight = function HemisphereLight(_ref2) {
|
|
68
|
+
var _ref2$position = _ref2.position,
|
|
69
|
+
position = _ref2$position === void 0 ? [0, 10, 0] : _ref2$position,
|
|
70
|
+
_ref2$color = _ref2.color,
|
|
71
|
+
color = _ref2$color === void 0 ? "lightskyblue" : _ref2$color,
|
|
72
|
+
_ref2$groundColor = _ref2.groundColor,
|
|
73
|
+
groundColor = _ref2$groundColor === void 0 ? "sandybrown" : _ref2$groundColor,
|
|
74
|
+
_ref2$intensity = _ref2.intensity,
|
|
75
|
+
intensity = _ref2$intensity === void 0 ? 1 : _ref2$intensity,
|
|
76
|
+
_ref2$helper = _ref2.helper,
|
|
77
|
+
helper = _ref2$helper === void 0 ? false : _ref2$helper,
|
|
78
|
+
_ref2$helperSize = _ref2.helperSize,
|
|
79
|
+
helperSize = _ref2$helperSize === void 0 ? 1 : _ref2$helperSize,
|
|
80
|
+
skyColor = _ref2.skyColor,
|
|
81
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded);
|
|
82
|
+
var _color = useMemo(function updatedColor() {
|
|
83
|
+
return new THREE.Color(skyColor || color);
|
|
84
|
+
}, [color, skyColor]);
|
|
85
|
+
var _groundColor = useMemo(function updateGroundColor() {
|
|
86
|
+
return new THREE.Color(groundColor);
|
|
87
|
+
}, [groundColor]);
|
|
88
|
+
var helperProps = useMemo(function updateHelperProps() {
|
|
89
|
+
return {
|
|
90
|
+
helperSize: helperSize,
|
|
91
|
+
color: _color,
|
|
92
|
+
groundColor: _groundColor
|
|
93
|
+
};
|
|
94
|
+
}, [helperSize, _color, _groundColor]);
|
|
95
|
+
return (
|
|
96
|
+
/*#__PURE__*/
|
|
97
|
+
// @ts-ignore: Property 'hemisphereLight' does not exist on type 'JSX.IntrinsicElements'
|
|
98
|
+
React.createElement("hemisphereLight", _extends({
|
|
99
|
+
color: _color,
|
|
100
|
+
groundColor: _groundColor,
|
|
101
|
+
position: position,
|
|
102
|
+
intensity: intensity
|
|
103
|
+
}, otherProps), helper && /*#__PURE__*/React.createElement(HemisphereLightHelper, helperProps))
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
var HemisphereLightMemo = memo(HemisphereLight);
|
|
107
|
+
HemisphereLightMemo.displayName = "HemisphereLight";
|
|
108
|
+
var _default = exports["default"] = HemisphereLightMemo;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
export interface CommonLightWithShadowsProps {
|
|
4
|
+
position?: Array<number>;
|
|
5
|
+
intensity?: number;
|
|
6
|
+
color?: string | THREE.Color;
|
|
7
|
+
castShadow?: boolean;
|
|
8
|
+
shadowCameraNear?: number;
|
|
9
|
+
shadowCameraFar?: number;
|
|
10
|
+
shadowMapWidth?: number;
|
|
11
|
+
shadowMapHeight?: number;
|
|
12
|
+
helper?: boolean;
|
|
13
|
+
helperColor?: string;
|
|
14
|
+
children?: any;
|
|
15
|
+
}
|
|
16
|
+
interface LightWithShadowsProps extends CommonLightWithShadowsProps {
|
|
17
|
+
THREELight: any;
|
|
18
|
+
THREEHelper: any;
|
|
19
|
+
lightParams: Array<any>;
|
|
20
|
+
helperParams: Array<any>;
|
|
21
|
+
target?: Array<number>;
|
|
22
|
+
}
|
|
23
|
+
declare const LightWithShadowsMemo: React.NamedExoticComponent<LightWithShadowsProps>;
|
|
24
|
+
export default LightWithShadowsMemo;
|