@react-three/drei 9.84.2 → 9.85.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/README.md +41 -8
- package/core/AccumulativeShadows.cjs.js +1 -1
- package/core/AccumulativeShadows.js +8 -7
- package/core/ArcballControls.js +1 -1
- package/core/BBAnchor.js +2 -2
- package/core/Billboard.js +1 -1
- package/core/Bounds.js +1 -1
- package/core/CameraControls.js +1 -1
- package/core/CameraShake.js +1 -1
- package/core/CatmullRomLine.js +1 -1
- package/core/Caustics.cjs.js +1 -1
- package/core/Caustics.js +13 -12
- package/core/Center.js +1 -1
- package/core/Clone.js +1 -1
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +31 -11
- package/core/Cloud.js +213 -47
- package/core/ContactShadows.js +1 -1
- package/core/CubicBezierLine.js +1 -1
- package/core/CurveModifier.js +1 -1
- package/core/Decal.js +1 -1
- package/core/Detailed.js +1 -1
- package/core/DeviceOrientationControls.js +1 -1
- package/core/Edges.js +1 -1
- package/core/Effects.js +1 -1
- package/core/Example.js +1 -1
- package/core/FaceControls.js +4 -4
- package/core/FaceLandmarker.js +1 -1
- package/core/Facemesh.d.ts +3 -3
- package/core/Facemesh.js +4 -4
- package/core/FirstPersonControls.js +1 -1
- package/core/Float.js +1 -1
- package/core/FlyControls.js +1 -1
- package/core/GizmoHelper.js +7 -7
- package/core/GizmoViewcube.js +3 -3
- package/core/Gltf.js +1 -1
- package/core/GradientTexture.js +4 -1
- package/core/Grid.cjs.js +1 -1
- package/core/Grid.js +8 -7
- package/core/Image.cjs.js +1 -1
- package/core/Image.js +8 -7
- package/core/Instances.js +3 -3
- package/core/Lightformer.js +1 -1
- package/core/Line.js +1 -1
- package/core/MapControls.js +1 -1
- package/core/MarchingCubes.js +4 -4
- package/core/Mask.js +1 -1
- package/core/MeshDiscardMaterial.js +1 -1
- package/core/MeshDistortMaterial.js +1 -1
- package/core/MeshPortalMaterial.cjs.js +1 -1
- package/core/MeshPortalMaterial.js +6 -5
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.js +2 -2
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.js +1 -1
- package/core/MeshWobbleMaterial.js +1 -1
- package/core/MotionPathControls.js +2 -2
- package/core/OrbitControls.js +1 -1
- package/core/OrthographicCamera.js +1 -1
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.js +5 -4
- package/core/PerformanceMonitor.js +1 -1
- package/core/PerspectiveCamera.js +1 -1
- package/core/PointMaterial.cjs.js +1 -1
- package/core/PointMaterial.js +4 -3
- package/core/PointerLockControls.js +1 -1
- package/core/Points.js +4 -4
- package/core/PositionalAudio.js +1 -1
- package/core/QuadraticBezierLine.js +3 -3
- package/core/Reflector.cjs.js +1 -1
- package/core/Reflector.js +2 -2
- package/core/RenderTexture.js +1 -1
- package/core/Resize.js +1 -1
- package/core/RoundedBox.js +1 -1
- package/core/ScreenQuad.js +1 -1
- package/core/ScreenSpace.js +1 -1
- package/core/Segments.js +3 -3
- package/core/Shadow.js +1 -1
- package/core/Sky.js +1 -1
- package/core/Sparkles.cjs.js +1 -1
- package/core/Sparkles.js +4 -3
- package/core/SpotLight.cjs.js +1 -1
- package/core/SpotLight.js +1 -1
- package/core/Stage.cjs.js +1 -1
- package/core/Stars.cjs.js +1 -1
- package/core/Stars.js +4 -4
- package/core/Svg.js +1 -1
- package/core/Text.js +1 -1
- package/core/Text3D.js +1 -1
- package/core/TrackballControls.js +1 -1
- package/core/Trail.js +1 -1
- package/core/TransformControls.js +1 -1
- package/core/Wireframe.cjs.js +1 -1
- package/core/Wireframe.js +1 -1
- package/core/index.cjs.js +1 -1
- package/core/index.js +3 -2
- package/core/meshBounds.js +4 -4
- package/core/shapes.js +19 -19
- package/core/useBVH.js +1 -1
- package/core/useProgress.js +1 -1
- package/core/useTexture.cjs.js +1 -1
- package/core/useTexture.js +5 -2
- package/helpers/constants.cjs.js +1 -0
- package/helpers/constants.d.ts +1 -0
- package/helpers/constants.js +5 -0
- package/index.cjs.js +1 -1
- package/index.js +1 -1
- package/materials/BlurPass.cjs.js +1 -1
- package/materials/ConvolutionMaterial.cjs.js +1 -1
- package/materials/ConvolutionMaterial.js +2 -1
- package/materials/DiscardMaterial.js +1 -1
- package/materials/MeshRefractionMaterial.cjs.js +1 -1
- package/materials/MeshRefractionMaterial.js +8 -7
- package/materials/SpotLightMaterial.cjs.js +1 -1
- package/materials/SpotLightMaterial.js +2 -1
- package/materials/WireframeMaterial.js +4 -4
- package/native/index.cjs.js +1 -1
- package/native/index.js +3 -2
- package/package.json +3 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/Html.cjs.js +1 -1
- package/web/Html.js +6 -6
- package/web/ScrollControls.js +4 -4
- package/web/Select.js +1 -1
- package/web/View.js +1 -1
- package/web/index.cjs.js +1 -1
- package/web/index.js +3 -2
- package/web/pivotControls/AxisArrow.js +4 -4
- package/web/pivotControls/AxisRotator.js +6 -6
- package/web/pivotControls/PlaneSlider.js +3 -3
- package/web/pivotControls/context.js +1 -1
- package/web/pivotControls/index.js +21 -21
package/core/Cloud.js
CHANGED
|
@@ -1,58 +1,224 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Plane } from './shapes.js';
|
|
3
|
+
import { Quaternion, Vector3, DynamicDrawUsage, MeshLambertMaterial, Matrix4, Color } from 'three';
|
|
4
|
+
import { extend, useFrame, applyProps } from '@react-three/fiber';
|
|
5
5
|
import { useTexture } from './useTexture.js';
|
|
6
|
+
import { v4 } from 'uuid';
|
|
6
7
|
|
|
7
8
|
const CLOUD_URL = 'https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const parentMatrix =
|
|
10
|
+
/*@__PURE__*/
|
|
11
|
+
/*@__PURE__*/
|
|
12
|
+
new Matrix4();
|
|
13
|
+
const translation =
|
|
14
|
+
/*@__PURE__*/
|
|
15
|
+
/*@__PURE__*/
|
|
16
|
+
new Vector3();
|
|
17
|
+
const rotation =
|
|
18
|
+
/*@__PURE__*/
|
|
19
|
+
/*@__PURE__*/
|
|
20
|
+
new Quaternion();
|
|
21
|
+
const cpos =
|
|
22
|
+
/*@__PURE__*/
|
|
23
|
+
/*@__PURE__*/
|
|
24
|
+
new Vector3();
|
|
25
|
+
const cquat =
|
|
26
|
+
/*@__PURE__*/
|
|
27
|
+
/*@__PURE__*/
|
|
28
|
+
new Quaternion();
|
|
29
|
+
const scale =
|
|
30
|
+
/*@__PURE__*/
|
|
31
|
+
/*@__PURE__*/
|
|
32
|
+
new Vector3();
|
|
33
|
+
const context = /*@__PURE__*/React.createContext(null);
|
|
34
|
+
const Clouds = /*@__PURE__*/React.forwardRef(({
|
|
35
|
+
children,
|
|
36
|
+
material = MeshLambertMaterial,
|
|
14
37
|
texture = CLOUD_URL,
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
range,
|
|
39
|
+
limit = 200,
|
|
17
40
|
...props
|
|
18
|
-
}) {
|
|
19
|
-
|
|
41
|
+
}, fref) => {
|
|
42
|
+
var _image$width, _image$height;
|
|
43
|
+
const CloudMaterial = React.useMemo(() => {
|
|
44
|
+
return class extends material {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.onBeforeCompile = shader => {
|
|
48
|
+
shader.vertexShader = `attribute float opacity;
|
|
49
|
+
varying float vOpacity;
|
|
50
|
+
` + shader.vertexShader.replace('#include <fog_vertex>', `#include <fog_vertex>
|
|
51
|
+
vOpacity = opacity;
|
|
52
|
+
`);
|
|
53
|
+
shader.fragmentShader = `varying float vOpacity;
|
|
54
|
+
` + shader.fragmentShader.replace('#include <opaque_fragment>', `#include <opaque_fragment>
|
|
55
|
+
gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);
|
|
56
|
+
`);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}, [material]);
|
|
61
|
+
extend({
|
|
62
|
+
CloudMaterial
|
|
63
|
+
});
|
|
64
|
+
const instance = React.useRef(null);
|
|
65
|
+
const clouds = React.useRef([]);
|
|
66
|
+
const opacities = React.useMemo(() => new Float32Array(Array.from({
|
|
67
|
+
length: limit
|
|
68
|
+
}, () => 1)), [limit]);
|
|
69
|
+
const colors = React.useMemo(() => new Float32Array(Array.from({
|
|
70
|
+
length: limit
|
|
71
|
+
}, () => [1, 1, 1]).flat()), [limit]);
|
|
20
72
|
const cloudTexture = useTexture(texture);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
73
|
+
let t = 0;
|
|
74
|
+
let index = 0;
|
|
75
|
+
let config;
|
|
76
|
+
const qat = new Quaternion();
|
|
77
|
+
const dir = new Vector3(0, 0, 1);
|
|
78
|
+
useFrame((state, delta) => {
|
|
79
|
+
t = state.clock.getElapsedTime();
|
|
80
|
+
parentMatrix.copy(instance.current.matrixWorld).invert();
|
|
81
|
+
state.camera.matrixWorld.decompose(cpos, cquat, scale);
|
|
82
|
+
for (index = 0; index < clouds.current.length; index++) {
|
|
83
|
+
config = clouds.current[index];
|
|
84
|
+
config.ref.current.matrixWorld.decompose(translation, rotation, scale);
|
|
85
|
+
translation.add(config.position).applyQuaternion(rotation);
|
|
86
|
+
rotation.copy(cquat).multiply(qat.setFromAxisAngle(dir, config.rotation += delta * config.rotationFactor));
|
|
87
|
+
scale.addScalar(config.volume + (1 + Math.sin(t * config.density * config.speed)) / 2 * config.growth);
|
|
88
|
+
config.matrix.compose(translation, rotation, scale).premultiply(parentMatrix);
|
|
89
|
+
config.dist = translation.distanceTo(cpos);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Depth-sort. Instances have no specific draw order, w/o sorting z would be random
|
|
93
|
+
clouds.current.sort((a, b) => b.dist - a.dist);
|
|
94
|
+
for (index = 0; index < clouds.current.length; index++) {
|
|
95
|
+
config = clouds.current[index];
|
|
96
|
+
opacities[index] = config.opacity * (config.dist < config.fade - 1 ? config.dist / config.fade : 1);
|
|
97
|
+
instance.current.setMatrixAt(index, config.matrix);
|
|
98
|
+
instance.current.setColorAt(index, config.color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Update instance
|
|
102
|
+
instance.current.geometry.attributes.opacity.needsUpdate = true;
|
|
103
|
+
instance.current.instanceMatrix.needsUpdate = true;
|
|
104
|
+
if (instance.current.instanceColor) instance.current.instanceColor.needsUpdate = true;
|
|
34
105
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}, /*#__PURE__*/React.createElement("
|
|
106
|
+
React.useLayoutEffect(() => {
|
|
107
|
+
const updateRange = Math.min(limit, range !== undefined ? range : limit, clouds.current.length);
|
|
108
|
+
instance.current.count = updateRange;
|
|
109
|
+
instance.current.instanceMatrix.updateRange.count = updateRange * 16;
|
|
110
|
+
if (instance.current.instanceColor) instance.current.instanceColor.updateRange.count = updateRange * 3;
|
|
111
|
+
instance.current.geometry.attributes.opacity.updateRange.count = updateRange;
|
|
112
|
+
});
|
|
113
|
+
let imageBounds = [(_image$width = cloudTexture.image.width) !== null && _image$width !== void 0 ? _image$width : 1, (_image$height = cloudTexture.image.height) !== null && _image$height !== void 0 ? _image$height : 1];
|
|
114
|
+
let max = Math.max(imageBounds[0], imageBounds[1]);
|
|
115
|
+
imageBounds = [imageBounds[0] / max, imageBounds[1] / max];
|
|
116
|
+
return /*#__PURE__*/React.createElement("group", _extends({
|
|
117
|
+
ref: fref
|
|
118
|
+
}, props), /*#__PURE__*/React.createElement(context.Provider, {
|
|
119
|
+
value: clouds
|
|
120
|
+
}, children, /*#__PURE__*/React.createElement("instancedMesh", {
|
|
121
|
+
matrixAutoUpdate: false,
|
|
122
|
+
ref: instance,
|
|
123
|
+
args: [null, null, limit]
|
|
124
|
+
}, /*#__PURE__*/React.createElement("instancedBufferAttribute", {
|
|
125
|
+
usage: DynamicDrawUsage,
|
|
126
|
+
attach: "instanceColor",
|
|
127
|
+
args: [colors, 3]
|
|
128
|
+
}), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
129
|
+
args: [...imageBounds]
|
|
130
|
+
}, /*#__PURE__*/React.createElement("instancedBufferAttribute", {
|
|
131
|
+
usage: DynamicDrawUsage,
|
|
132
|
+
attach: "attributes-opacity",
|
|
133
|
+
args: [opacities, 1]
|
|
134
|
+
})), /*#__PURE__*/React.createElement("cloudMaterial", {
|
|
135
|
+
key: material.name,
|
|
50
136
|
map: cloudTexture,
|
|
51
137
|
transparent: true,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
138
|
+
depthWrite: false
|
|
139
|
+
}))));
|
|
140
|
+
});
|
|
141
|
+
const CloudInstance = /*@__PURE__*/React.forwardRef(({
|
|
142
|
+
opacity = 1,
|
|
143
|
+
speed = 0,
|
|
144
|
+
bounds = [5, 1, 1],
|
|
145
|
+
segments = 20,
|
|
146
|
+
color = '#ffffff',
|
|
147
|
+
fade = 10,
|
|
148
|
+
volume = 6,
|
|
149
|
+
growth = 4,
|
|
150
|
+
seed = Math.random(),
|
|
151
|
+
...props
|
|
152
|
+
}, fref) => {
|
|
153
|
+
function random() {
|
|
154
|
+
const x = Math.sin(seed++) * 10000;
|
|
155
|
+
return x - Math.floor(x);
|
|
156
|
+
}
|
|
157
|
+
const parent = React.useContext(context);
|
|
158
|
+
const ref = React.useRef(null);
|
|
159
|
+
const [uuid] = React.useState(() => v4());
|
|
160
|
+
const clouds = React.useMemo(() => {
|
|
161
|
+
return [...new Array(segments)].map((_, index) => ({
|
|
162
|
+
segments,
|
|
163
|
+
bounds: new Vector3(1, 1, 1),
|
|
164
|
+
position: new Vector3(),
|
|
165
|
+
uuid,
|
|
166
|
+
index,
|
|
167
|
+
ref,
|
|
168
|
+
dist: 0,
|
|
169
|
+
matrix: new Matrix4(),
|
|
170
|
+
color: new Color(),
|
|
171
|
+
rotation: index * (Math.PI / segments)
|
|
172
|
+
}));
|
|
173
|
+
}, [segments, uuid]);
|
|
174
|
+
React.useLayoutEffect(() => {
|
|
175
|
+
clouds.forEach((cloud, index) => {
|
|
176
|
+
applyProps(cloud, {
|
|
177
|
+
color,
|
|
178
|
+
speed,
|
|
179
|
+
growth,
|
|
180
|
+
opacity,
|
|
181
|
+
fade,
|
|
182
|
+
bounds,
|
|
183
|
+
density: Math.max(0.5, random()),
|
|
184
|
+
rotationFactor: Math.max(0.2, 0.5 * random()) * speed
|
|
185
|
+
});
|
|
186
|
+
// Only distribute randomly if there are multiple segments
|
|
187
|
+
if (segments > 1) cloud.position.copy(cloud.bounds).multiply({
|
|
188
|
+
x: random() * 2 - 1,
|
|
189
|
+
y: random() * 2 - 1,
|
|
190
|
+
z: random() * 2 - 1
|
|
191
|
+
});
|
|
192
|
+
const xDiff = Math.abs(cloud.position.x);
|
|
193
|
+
const yDiff = Math.abs(cloud.position.y);
|
|
194
|
+
const zDiff = Math.abs(cloud.position.z);
|
|
195
|
+
const max = Math.max(xDiff, yDiff, zDiff);
|
|
196
|
+
cloud.length = 1;
|
|
197
|
+
if (xDiff === max) cloud.length -= xDiff / cloud.bounds.x;
|
|
198
|
+
if (yDiff === max) cloud.length -= yDiff / cloud.bounds.y;
|
|
199
|
+
if (zDiff === max) cloud.length -= zDiff / cloud.bounds.z;
|
|
200
|
+
cloud.volume = Math.max(0.25, cloud.length) * volume;
|
|
201
|
+
});
|
|
202
|
+
}, [bounds, fade, color, opacity, growth, volume, seed, segments, speed]);
|
|
203
|
+
React.useLayoutEffect(() => {
|
|
204
|
+
const temp = clouds;
|
|
205
|
+
parent.current = [...parent.current, ...temp];
|
|
206
|
+
return () => {
|
|
207
|
+
parent.current = parent.current.filter(item => item.uuid !== uuid);
|
|
208
|
+
};
|
|
209
|
+
}, [clouds]);
|
|
210
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
211
|
+
return /*#__PURE__*/React.createElement("group", _extends({
|
|
212
|
+
ref: ref
|
|
213
|
+
}, props));
|
|
214
|
+
});
|
|
215
|
+
const Cloud = /*@__PURE__*/React.forwardRef((props, fref) => {
|
|
216
|
+
const parent = React.useContext(context);
|
|
217
|
+
if (parent) return /*#__PURE__*/React.createElement(CloudInstance, _extends({
|
|
218
|
+
ref: fref
|
|
219
|
+
}, props));else return /*#__PURE__*/React.createElement(Clouds, null, /*#__PURE__*/React.createElement(CloudInstance, _extends({
|
|
220
|
+
ref: fref
|
|
221
|
+
}, props)));
|
|
222
|
+
});
|
|
57
223
|
|
|
58
|
-
export { Cloud };
|
|
224
|
+
export { Cloud, CloudInstance, Clouds };
|
package/core/ContactShadows.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as THREE from 'three';
|
|
|
4
4
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
5
5
|
import { HorizontalBlurShader, VerticalBlurShader } from 'three-stdlib';
|
|
6
6
|
|
|
7
|
-
const ContactShadows =
|
|
7
|
+
const ContactShadows = /*@__PURE__*/React.forwardRef(({
|
|
8
8
|
scale = 10,
|
|
9
9
|
frames = Infinity,
|
|
10
10
|
opacity = 1,
|
package/core/CubicBezierLine.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { Vector3, CubicBezierCurve3 } from 'three';
|
|
4
4
|
import { Line } from './Line.js';
|
|
5
5
|
|
|
6
|
-
const CubicBezierLine =
|
|
6
|
+
const CubicBezierLine = /*@__PURE__*/React.forwardRef(function CubicBezierLine({
|
|
7
7
|
start,
|
|
8
8
|
end,
|
|
9
9
|
midA,
|
package/core/CurveModifier.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as THREE from 'three';
|
|
|
3
3
|
import { createPortal } from '@react-three/fiber';
|
|
4
4
|
import { Flow } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const CurveModifier =
|
|
6
|
+
const CurveModifier = /*@__PURE__*/React.forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
curve
|
|
9
9
|
}, ref) => {
|
package/core/Decal.js
CHANGED
|
@@ -16,7 +16,7 @@ function vecToArray(vec = [0, 0, 0]) {
|
|
|
16
16
|
return [vec, vec, vec];
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const Decal =
|
|
19
|
+
const Decal = /*@__PURE__*/React.forwardRef(function Decal({
|
|
20
20
|
debug,
|
|
21
21
|
depthTest = false,
|
|
22
22
|
polygonOffsetFactor = -10,
|
package/core/Detailed.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useFrame } from '@react-three/fiber';
|
|
4
4
|
import mergeRefs from 'react-merge-refs';
|
|
5
5
|
|
|
6
|
-
const Detailed =
|
|
6
|
+
const Detailed = /*@__PURE__*/React.forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
hysteresis = 0,
|
|
9
9
|
distances,
|
|
@@ -3,7 +3,7 @@ import { useThree, useFrame } from '@react-three/fiber';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { DeviceOrientationControls as DeviceOrientationControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const DeviceOrientationControls =
|
|
6
|
+
const DeviceOrientationControls = /*@__PURE__*/React.forwardRef((props, ref) => {
|
|
7
7
|
const {
|
|
8
8
|
camera,
|
|
9
9
|
onChange,
|
package/core/Edges.js
CHANGED
package/core/Effects.js
CHANGED
package/core/Example.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Text3D } from './Text3D.js';
|
|
|
3
3
|
import { Center } from './Center.js';
|
|
4
4
|
|
|
5
5
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
6
|
-
const Example =
|
|
6
|
+
const Example = /*@__PURE__*/React.forwardRef(({
|
|
7
7
|
font,
|
|
8
8
|
color = '#cbcbcb',
|
|
9
9
|
bevelSize = 0.04,
|
package/core/FaceControls.js
CHANGED
|
@@ -23,8 +23,8 @@ function localToLocal(objSrc, v, objDst) {
|
|
|
23
23
|
//
|
|
24
24
|
//
|
|
25
25
|
//
|
|
26
|
-
const FaceControlsContext =
|
|
27
|
-
const FaceControls =
|
|
26
|
+
const FaceControlsContext = /*@__PURE__*/createContext({});
|
|
27
|
+
const FaceControls = /*@__PURE__*/forwardRef(({
|
|
28
28
|
camera,
|
|
29
29
|
autostart = true,
|
|
30
30
|
webcam = true,
|
|
@@ -233,7 +233,7 @@ const useFaceControls = () => useContext(FaceControlsContext);
|
|
|
233
233
|
//
|
|
234
234
|
// Webcam
|
|
235
235
|
//
|
|
236
|
-
const Webcam =
|
|
236
|
+
const Webcam = /*@__PURE__*/forwardRef(({
|
|
237
237
|
videoTextureSrc,
|
|
238
238
|
autostart = true
|
|
239
239
|
}, fref) => {
|
|
@@ -275,7 +275,7 @@ const Webcam = /*#__PURE__*/forwardRef(({
|
|
|
275
275
|
//
|
|
276
276
|
// VideoTexture
|
|
277
277
|
//
|
|
278
|
-
const VideoTexture =
|
|
278
|
+
const VideoTexture = /*@__PURE__*/forwardRef(({
|
|
279
279
|
src,
|
|
280
280
|
start
|
|
281
281
|
}, fref) => {
|
package/core/FaceLandmarker.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FilesetResolver, FaceLandmarker as FaceLandmarker$1 } from '@mediapipe/
|
|
|
4
4
|
import { suspend, clear } from 'suspend-react';
|
|
5
5
|
|
|
6
6
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
7
|
-
const FaceLandmarkerContext =
|
|
7
|
+
const FaceLandmarkerContext = /*@__PURE__*/createContext({});
|
|
8
8
|
const FaceLandmarkerDefaults = {
|
|
9
9
|
basePath: 'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.2/wasm',
|
|
10
10
|
options: {
|
package/core/Facemesh.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
export type MediaPipeFaceMesh = typeof FacemeshDatas.SAMPLE_FACE;
|
|
4
|
-
export type MediaPipePoints = typeof FacemeshDatas.SAMPLE_FACE.keypoints | typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0];
|
|
4
|
+
export type MediaPipePoints = typeof FacemeshDatas.SAMPLE_FACE.keypoints | (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks)[0];
|
|
5
5
|
export type FacemeshProps = {
|
|
6
6
|
points?: MediaPipePoints;
|
|
7
7
|
face?: MediaPipeFaceMesh;
|
|
@@ -10,10 +10,10 @@ export type FacemeshProps = {
|
|
|
10
10
|
depth?: number;
|
|
11
11
|
verticalTri?: [number, number, number];
|
|
12
12
|
origin?: number | THREE.Vector3;
|
|
13
|
-
facialTransformationMatrix?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes[0];
|
|
13
|
+
facialTransformationMatrix?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes)[0];
|
|
14
14
|
offset?: boolean;
|
|
15
15
|
offsetScalar?: number;
|
|
16
|
-
faceBlendshapes?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes[0];
|
|
16
|
+
faceBlendshapes?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes)[0];
|
|
17
17
|
eyes?: boolean;
|
|
18
18
|
eyesAsOrigin?: boolean;
|
|
19
19
|
debug?: boolean;
|
package/core/Facemesh.js
CHANGED
|
@@ -4,8 +4,8 @@ import { useThree } from '@react-three/fiber';
|
|
|
4
4
|
import { Line } from './Line.js';
|
|
5
5
|
|
|
6
6
|
/* eslint react-hooks/exhaustive-deps: 1 */
|
|
7
|
-
const defaultLookAt = new THREE.Vector3(0, 0, -1);
|
|
8
|
-
const normal = function () {
|
|
7
|
+
const defaultLookAt = /*@__PURE__*/new THREE.Vector3(0, 0, -1);
|
|
8
|
+
const normal = /*@__PURE__*/function () {
|
|
9
9
|
const a = new THREE.Vector3();
|
|
10
10
|
const b = new THREE.Vector3();
|
|
11
11
|
const c = new THREE.Vector3();
|
|
@@ -23,7 +23,7 @@ const normal = function () {
|
|
|
23
23
|
function mean(v1, v2) {
|
|
24
24
|
return v1.clone().add(v2).multiplyScalar(0.5);
|
|
25
25
|
}
|
|
26
|
-
const Facemesh =
|
|
26
|
+
const Facemesh = /*@__PURE__*/React.forwardRef(({
|
|
27
27
|
points = FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0],
|
|
28
28
|
face,
|
|
29
29
|
facialTransformationMatrix,
|
|
@@ -241,7 +241,7 @@ const FacemeshEyeDefaults = {
|
|
|
241
241
|
vertical: 90
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
const FacemeshEye =
|
|
244
|
+
const FacemeshEye = /*@__PURE__*/React.forwardRef(({
|
|
245
245
|
side,
|
|
246
246
|
debug = true
|
|
247
247
|
}, fref) => {
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
4
4
|
import { FirstPersonControls as FirstPersonControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const FirstPersonControls =
|
|
6
|
+
const FirstPersonControls = /*@__PURE__*/React.forwardRef(({
|
|
7
7
|
domElement,
|
|
8
8
|
makeDefault,
|
|
9
9
|
...props
|
package/core/Float.js
CHANGED
package/core/FlyControls.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useThree, useFrame } from '@react-three/fiber';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { FlyControls as FlyControls$1 } from 'three-stdlib';
|
|
5
5
|
|
|
6
|
-
const FlyControls =
|
|
6
|
+
const FlyControls = /*@__PURE__*/React.forwardRef(({
|
|
7
7
|
domElement,
|
|
8
8
|
...props
|
|
9
9
|
}, fref) => {
|
package/core/GizmoHelper.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useThree, useFrame } from '@react-three/fiber';
|
|
3
|
-
import { Object3D, Matrix4, Quaternion
|
|
3
|
+
import { Vector3, Object3D, Matrix4, Quaternion } from 'three';
|
|
4
4
|
import { OrthographicCamera } from './OrthographicCamera.js';
|
|
5
5
|
import { Hud } from './Hud.js';
|
|
6
6
|
|
|
7
|
-
const Context =
|
|
7
|
+
const Context = /*@__PURE__*/React.createContext({});
|
|
8
8
|
const useGizmoContext = () => {
|
|
9
9
|
return React.useContext(Context);
|
|
10
10
|
};
|
|
11
11
|
const turnRate = 2 * Math.PI; // turn rate in angles per second
|
|
12
|
-
const dummy = new Object3D();
|
|
13
|
-
const matrix = new Matrix4();
|
|
14
|
-
const [q1, q2] = [new Quaternion(), new Quaternion()];
|
|
15
|
-
const target = new Vector3();
|
|
16
|
-
const targetPosition = new Vector3();
|
|
12
|
+
const dummy = /*@__PURE__*/new Object3D();
|
|
13
|
+
const matrix = /*@__PURE__*/new Matrix4();
|
|
14
|
+
const [q1, q2] = [/*@__PURE__*/new Quaternion(), /*@__PURE__*/new Quaternion()];
|
|
15
|
+
const target = /*@__PURE__*/new Vector3();
|
|
16
|
+
const targetPosition = /*@__PURE__*/new Vector3();
|
|
17
17
|
const isOrbitControls = controls => {
|
|
18
18
|
return 'minPolarAngle' in controls;
|
|
19
19
|
};
|
package/core/GizmoViewcube.js
CHANGED
|
@@ -12,10 +12,10 @@ const colors = {
|
|
|
12
12
|
};
|
|
13
13
|
const defaultFaces = ['Right', 'Left', 'Top', 'Bottom', 'Front', 'Back'];
|
|
14
14
|
const makePositionVector = xyz => new Vector3(...xyz).multiplyScalar(0.38);
|
|
15
|
-
const corners = [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]].map(makePositionVector);
|
|
15
|
+
const corners = /*@__PURE__*/[[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]].map(makePositionVector);
|
|
16
16
|
const cornerDimensions = [0.25, 0.25, 0.25];
|
|
17
|
-
const edges = [[1, 1, 0], [1, 0, 1], [1, 0, -1], [1, -1, 0], [0, 1, 1], [0, 1, -1], [0, -1, 1], [0, -1, -1], [-1, 1, 0], [-1, 0, 1], [-1, 0, -1], [-1, -1, 0]].map(makePositionVector);
|
|
18
|
-
const edgeDimensions = edges.map(edge => edge.toArray().map(axis => axis == 0 ? 0.5 : 0.25));
|
|
17
|
+
const edges = /*@__PURE__*/[[1, 1, 0], [1, 0, 1], [1, 0, -1], [1, -1, 0], [0, 1, 1], [0, 1, -1], [0, -1, 1], [0, -1, -1], [-1, 1, 0], [-1, 0, 1], [-1, 0, -1], [-1, -1, 0]].map(makePositionVector);
|
|
18
|
+
const edgeDimensions = /*@__PURE__*/edges.map(edge => edge.toArray().map(axis => axis == 0 ? 0.5 : 0.25));
|
|
19
19
|
const FaceMaterial = ({
|
|
20
20
|
hover,
|
|
21
21
|
index,
|
package/core/Gltf.js
CHANGED
package/core/GradientTexture.js
CHANGED
|
@@ -2,7 +2,10 @@ import _extends from '@babel/runtime/helpers/esm/extends';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useThree } from '@react-three/fiber';
|
|
4
4
|
|
|
5
|
-
let GradientType =
|
|
5
|
+
let GradientType =
|
|
6
|
+
/*@__PURE__*/
|
|
7
|
+
/*#__PURE__*/
|
|
8
|
+
function (GradientType) {
|
|
6
9
|
GradientType["Linear"] = "linear";
|
|
7
10
|
GradientType["Radial"] = "radial";
|
|
8
11
|
return GradientType;
|
package/core/Grid.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("react"),o=require("three"),i=require("react-merge-refs"),r=require("@react-three/fiber"),t=require("./shaderMaterial.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("react"),o=require("three"),i=require("react-merge-refs"),r=require("@react-three/fiber"),t=require("./shaderMaterial.cjs.js"),l=require("../helpers/constants.cjs.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}})),n.default=e,Object.freeze(n)}var c=a(e),f=s(n),d=s(o),u=a(i);const m=t.shaderMaterial({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new d.Color,sectionColor:new d.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new d.Vector3,worldPlanePosition:new d.Vector3},"\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform vec3 worldPlanePosition;\n uniform float fadeDistance;\n uniform bool infiniteGrid;\n uniform bool followCamera;\n\n void main() {\n localPosition = position.xzy;\n if (infiniteGrid) localPosition *= 1.0 + fadeDistance;\n \n worldPosition = modelMatrix * vec4(localPosition, 1.0);\n if (followCamera) {\n worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);\n localPosition = (inverse(modelMatrix) * worldPosition).xyz;\n }\n\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n }\n ",`\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n\n float getGrid(float size, float thickness) {\n vec2 r = localPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1.0 - thickness;\n return 1.0 - min(line, 1.0);\n }\n\n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n\n float dist = distance(worldCamProjPosition, worldPosition.xyz);\n float d = 1.0 - min(dist / fadeDistance, 1.0);\n vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));\n\n gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n\n #include <tonemapping_fragment>\n #include <${l.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `),g=f.forwardRef((({args:e,cellColor:n="#000000",sectionColor:o="#2080ff",cellSize:i=.5,sectionSize:t=1,followCamera:l=!1,infiniteGrid:a=!1,fadeDistance:s=100,fadeStrength:g=1,cellThickness:P=.5,sectionThickness:w=1,side:v=d.BackSide,...C},h)=>{r.extend({GridMaterial:m});const p=f.useRef(null),x=new d.Plane,j=new d.Vector3(0,1,0),z=new d.Vector3(0,0,0);r.useFrame((e=>{x.setFromNormalAndCoplanarPoint(j,z).applyMatrix4(p.current.matrixWorld);const n=p.current.material,o=n.uniforms.worldCamProjPosition,i=n.uniforms.worldPlanePosition;x.projectPoint(e.camera.position,o.value),i.value.set(0,0,0).applyMatrix4(p.current.matrixWorld)}));const y={cellSize:i,sectionSize:t,cellColor:n,sectionColor:o,cellThickness:P,sectionThickness:w},S={fadeDistance:s,fadeStrength:g,infiniteGrid:a,followCamera:l};return f.createElement("mesh",c.default({ref:u.default([p,h]),frustumCulled:!1},C),f.createElement("gridMaterial",c.default({transparent:!0,"extensions-derivatives":!0,side:v},y,S)),f.createElement("planeGeometry",{args:e}))}));exports.Grid=g;
|
package/core/Grid.js
CHANGED
|
@@ -4,20 +4,21 @@ import * as THREE from 'three';
|
|
|
4
4
|
import mergeRefs from 'react-merge-refs';
|
|
5
5
|
import { extend, useFrame } from '@react-three/fiber';
|
|
6
6
|
import { shaderMaterial } from './shaderMaterial.js';
|
|
7
|
+
import { version } from '../helpers/constants.js';
|
|
7
8
|
|
|
8
|
-
const GridMaterial = shaderMaterial({
|
|
9
|
+
const GridMaterial = /*@__PURE__*/shaderMaterial({
|
|
9
10
|
cellSize: 0.5,
|
|
10
11
|
sectionSize: 1,
|
|
11
12
|
fadeDistance: 100,
|
|
12
13
|
fadeStrength: 1,
|
|
13
14
|
cellThickness: 0.5,
|
|
14
15
|
sectionThickness: 1,
|
|
15
|
-
cellColor: new THREE.Color(),
|
|
16
|
-
sectionColor: new THREE.Color(),
|
|
16
|
+
cellColor: /*@__PURE__*/new THREE.Color(),
|
|
17
|
+
sectionColor: /*@__PURE__*/new THREE.Color(),
|
|
17
18
|
infiniteGrid: false,
|
|
18
19
|
followCamera: false,
|
|
19
|
-
worldCamProjPosition: new THREE.Vector3(),
|
|
20
|
-
worldPlanePosition: new THREE.Vector3()
|
|
20
|
+
worldCamProjPosition: /*@__PURE__*/new THREE.Vector3(),
|
|
21
|
+
worldPlanePosition: /*@__PURE__*/new THREE.Vector3()
|
|
21
22
|
}, /* glsl */`
|
|
22
23
|
varying vec3 localPosition;
|
|
23
24
|
varying vec4 worldPosition;
|
|
@@ -74,10 +75,10 @@ const GridMaterial = shaderMaterial({
|
|
|
74
75
|
if (gl_FragColor.a <= 0.0) discard;
|
|
75
76
|
|
|
76
77
|
#include <tonemapping_fragment>
|
|
77
|
-
#include <${
|
|
78
|
+
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
78
79
|
}
|
|
79
80
|
`);
|
|
80
|
-
const Grid =
|
|
81
|
+
const Grid = /*@__PURE__*/React.forwardRef(({
|
|
81
82
|
args,
|
|
82
83
|
cellColor = '#000000',
|
|
83
84
|
sectionColor = '#2080ff',
|
package/core/Image.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber"),a=require("./shaderMaterial.cjs.js"),o=require("./useTexture.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber"),a=require("./shaderMaterial.cjs.js"),o=require("./useTexture.cjs.js"),c=require("../helpers/constants.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var l=i(e),u=s(r),f=s(t);const m=a.shaderMaterial({color:new f.Color("white"),scale:[1,1],imageBounds:[1,1],map:null,zoom:1,grayscale:0,opacity:1},"\n varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }\n",`\n // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44\n varying vec2 vUv;\n uniform vec2 scale;\n uniform vec2 imageBounds;\n uniform vec3 color;\n uniform sampler2D map;\n uniform float zoom;\n uniform float grayscale;\n uniform float opacity;\n const vec3 luma = vec3(.299, 0.587, 0.114);\n vec4 toGrayscale(vec4 color, float intensity) {\n return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a);\n }\n vec2 aspect(vec2 size) {\n return size / min(size.x, size.y);\n }\n void main() {\n vec2 s = aspect(scale);\n vec2 i = aspect(imageBounds);\n float rs = s.x / s.y;\n float ri = i.x / i.y;\n vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);\n vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;\n vec2 uv = vUv * s / new + offset;\n vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5);\n gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity), grayscale);\n \n #include <tonemapping_fragment>\n #include <${c.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n`),v=u.forwardRef((({children:e,color:r,segments:t=1,scale:a=1,zoom:o=1,grayscale:c=0,opacity:i=1,texture:s,toneMapped:f,transparent:v,...d},y)=>{n.extend({ImageMaterial:m});const g=Array.isArray(a)?[a[0],a[1]]:[a,a],p=[s.image.width,s.image.height];return u.createElement("mesh",l.default({ref:y,scale:Array.isArray(a)?[...a,1]:a},d),u.createElement("planeGeometry",{args:[1,1,t,t]}),u.createElement("imageMaterial",{color:r,map:s,zoom:o,grayscale:c,opacity:i,scale:g,imageBounds:p,toneMapped:f,transparent:v}),e)})),d=u.forwardRef((({url:e,...r},t)=>{const n=o.useTexture(e);return u.createElement(v,l.default({},r,{texture:n,ref:t}))})),y=u.forwardRef((({url:e,...r},t)=>u.createElement(v,l.default({},r,{ref:t})))),g=u.forwardRef(((e,r)=>{if(e.url)return u.createElement(d,l.default({},e,{ref:r}));if(e.texture)return u.createElement(y,l.default({},e,{ref:r}));throw new Error("<Image /> requires a url or texture")}));exports.Image=g;
|