@react-three/drei 9.83.9 → 9.84.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 +70 -2
- package/core/AccumulativeShadows.d.ts +3 -3
- package/core/AccumulativeShadows.js +30 -36
- package/core/AdaptiveDpr.js +4 -4
- package/core/ArcballControls.d.ts +1 -1
- package/core/ArcballControls.js +0 -1
- package/core/AsciiRenderer.d.ts +3 -3
- package/core/AsciiRenderer.js +12 -6
- package/core/BBAnchor.cjs.js +1 -1
- package/core/BBAnchor.d.ts +2 -2
- package/core/BBAnchor.js +5 -5
- package/core/Backdrop.d.ts +2 -2
- package/core/Backdrop.js +0 -3
- package/core/Billboard.d.ts +1 -1
- package/core/Billboard.js +6 -3
- package/core/Bounds.d.ts +5 -5
- package/core/Bounds.js +5 -32
- package/core/CameraControls.d.ts +2 -2
- package/core/CameraControls.js +0 -3
- package/core/CameraShake.js +0 -4
- package/core/CatmullRomLine.d.ts +1 -1
- package/core/CatmullRomLine.js +0 -2
- package/core/Caustics.d.ts +1 -1
- package/core/Caustics.js +31 -32
- package/core/Center.d.ts +2 -2
- package/core/Center.js +2 -1
- package/core/Clone.d.ts +1 -1
- package/core/Clone.js +10 -13
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +2 -2
- package/core/Cloud.js +1 -2
- package/core/ComputedAttribute.d.ts +2 -2
- package/core/ComputedAttribute.js +0 -1
- package/core/ContactShadows.d.ts +1 -1
- package/core/ContactShadows.js +6 -7
- package/core/CubeCamera.cjs.js +1 -1
- package/core/CubeCamera.d.ts +2 -2
- package/core/CubeCamera.js +1 -1
- package/core/CubicBezierLine.d.ts +1 -1
- package/core/CurveModifier.d.ts +1 -1
- package/core/CurveModifier.js +2 -4
- package/core/Decal.d.ts +1 -1
- package/core/Decal.js +8 -15
- package/core/Detailed.d.ts +1 -1
- package/core/Detailed.js +0 -1
- package/core/DeviceOrientationControls.d.ts +1 -1
- package/core/DeviceOrientationControls.js +3 -4
- package/core/Edges.d.ts +1 -1
- package/core/Edges.js +0 -2
- package/core/Effects.d.ts +1 -1
- package/core/Effects.js +5 -7
- package/core/Environment.d.ts +3 -3
- package/core/Environment.js +6 -12
- package/core/Example.d.ts +3 -3
- package/core/Example.js +2 -1
- package/core/FaceControls.cjs.js +1 -1
- package/core/FaceControls.d.ts +5 -5
- package/core/FaceControls.js +42 -39
- package/core/FaceLandmarker.d.ts +3 -2
- package/core/FaceLandmarker.js +1 -1
- package/core/Facemesh.d.ts +6 -6
- package/core/Facemesh.js +47 -53
- package/core/FirstPersonControls.d.ts +1 -1
- package/core/Float.d.ts +1 -1
- package/core/Float.js +0 -1
- package/core/FlyControls.d.ts +1 -1
- package/core/FlyControls.js +1 -2
- package/core/GizmoHelper.cjs.js +1 -1
- package/core/GizmoHelper.d.ts +2 -2
- package/core/GizmoHelper.js +18 -19
- package/core/GizmoViewcube.d.ts +3 -3
- package/core/GizmoViewcube.js +0 -14
- package/core/GizmoViewport.d.ts +3 -3
- package/core/GizmoViewport.js +0 -7
- package/core/Gltf.d.ts +1 -1
- package/core/GradientTexture.d.ts +3 -3
- package/core/GradientTexture.js +2 -5
- package/core/Grid.d.ts +2 -2
- package/core/Grid.js +2 -6
- package/core/Hud.d.ts +2 -2
- package/core/Hud.js +6 -9
- package/core/Image.d.ts +2 -2
- package/core/Image.js +4 -6
- package/core/Instances.d.ts +6 -6
- package/core/Instances.js +20 -35
- package/core/Lightformer.d.ts +1 -1
- package/core/Lightformer.js +4 -2
- package/core/Line.d.ts +1 -1
- package/core/Line.js +0 -3
- package/core/MapControls.d.ts +1 -1
- package/core/MapControls.js +0 -2
- package/core/MarchingCubes.d.ts +3 -3
- package/core/Mask.d.ts +1 -1
- package/core/MeshDistortMaterial.d.ts +2 -2
- package/core/MeshDistortMaterial.js +0 -9
- package/core/MeshPortalMaterial.d.ts +4 -4
- package/core/MeshPortalMaterial.js +22 -61
- package/core/MeshReflectorMaterial.d.ts +1 -1
- package/core/MeshReflectorMaterial.js +12 -14
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.d.ts +3 -3
- package/core/MeshRefractionMaterial.js +9 -14
- package/core/MeshTransmissionMaterial.d.ts +2 -2
- package/core/MeshTransmissionMaterial.js +32 -33
- package/core/MeshWobbleMaterial.d.ts +2 -2
- package/core/MeshWobbleMaterial.js +0 -7
- package/core/MotionPathControls.cjs.js +1 -0
- package/core/MotionPathControls.d.ts +15 -0
- package/core/MotionPathControls.js +114 -0
- package/core/OrbitControls.d.ts +2 -2
- package/core/OrbitControls.js +0 -4
- package/core/OrthographicCamera.d.ts +1 -1
- package/core/OrthographicCamera.js +2 -3
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.d.ts +3 -3
- package/core/Outlines.js +2 -7
- package/core/PerformanceMonitor.d.ts +4 -4
- package/core/PerformanceMonitor.js +8 -12
- package/core/PerspectiveCamera.d.ts +1 -1
- package/core/PerspectiveCamera.js +2 -3
- package/core/PointMaterial.d.ts +1 -1
- package/core/PointMaterial.js +0 -2
- package/core/PointerLockControls.d.ts +1 -1
- package/core/PointerLockControls.js +4 -6
- package/core/Points.d.ts +2 -2
- package/core/Points.js +6 -23
- package/core/PositionalAudio.d.ts +1 -1
- package/core/PositionalAudio.js +0 -5
- package/core/Preload.d.ts +1 -1
- package/core/Preload.js +8 -9
- package/core/QuadraticBezierLine.d.ts +2 -2
- package/core/QuadraticBezierLine.js +0 -2
- package/core/Reflector.d.ts +1 -1
- package/core/Reflector.js +11 -12
- package/core/RenderTexture.d.ts +1 -1
- package/core/RenderTexture.js +9 -11
- package/core/Resize.d.ts +2 -2
- package/core/RoundedBox.cjs.js +1 -1
- package/core/RoundedBox.d.ts +1 -1
- package/core/RoundedBox.js +1 -3
- package/core/Sampler.d.ts +5 -5
- package/core/Sampler.js +0 -10
- package/core/ScreenQuad.d.ts +1 -1
- package/core/ScreenQuad.js +0 -1
- package/core/ScreenSpace.d.ts +1 -1
- package/core/Segments.d.ts +2 -2
- package/core/Segments.js +0 -6
- package/core/Shadow.d.ts +1 -1
- package/core/Sky.d.ts +1 -1
- package/core/Sparkles.js +0 -10
- package/core/SpotLight.d.ts +2 -2
- package/core/SpotLight.js +3 -10
- package/core/SpriteAnimator.d.ts +1 -1
- package/core/SpriteAnimator.js +16 -34
- package/core/Stage.d.ts +4 -4
- package/core/Stage.js +2 -4
- package/core/Stars.d.ts +1 -1
- package/core/Stars.js +2 -11
- package/core/Stats.d.ts +1 -1
- package/core/Stats.js +2 -2
- package/core/StatsGl.d.ts +1 -1
- package/core/StatsGl.js +4 -3
- package/core/Svg.js +0 -2
- package/core/Text.d.ts +1 -1
- package/core/Text3D.d.ts +1 -1
- package/core/Text3D.js +1 -3
- package/core/TrackballControls.d.ts +1 -1
- package/core/TrackballControls.js +0 -1
- package/core/Trail.d.ts +3 -3
- package/core/Trail.js +6 -17
- package/core/TransformControls.d.ts +1 -1
- package/core/TransformControls.js +3 -9
- package/core/Wireframe.d.ts +1 -1
- package/core/Wireframe.js +0 -28
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/meshBounds.js +4 -14
- package/core/shaderMaterial.js +10 -9
- package/core/shapes.d.ts +2 -2
- package/core/shapes.js +3 -6
- package/core/softShadows.d.ts +1 -1
- package/core/softShadows.js +1 -4
- package/core/useAnimations.d.ts +1 -1
- package/core/useAnimations.js +2 -4
- package/core/useBVH.d.ts +1 -1
- package/core/useBVH.js +3 -4
- package/core/useBoxProjectedEnv.js +15 -22
- package/core/useCamera.js +0 -1
- package/core/useContextBridge.js +1 -2
- package/core/useCubeCamera.d.ts +1 -1
- package/core/useCubeTexture.d.ts +1 -1
- package/core/useCubeTexture.js +4 -3
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useEnvironment.d.ts +2 -2
- package/core/useEnvironment.js +9 -11
- package/core/useFBO.d.ts +1 -1
- package/core/useFBO.js +3 -12
- package/core/useFBX.js +0 -2
- package/core/useFont.d.ts +2 -2
- package/core/useFont.js +0 -4
- package/core/useGLTF.d.ts +2 -2
- package/core/useGLTF.js +0 -8
- package/core/useHelper.d.ts +3 -3
- package/core/useHelper.js +2 -5
- package/core/useIntersect.js +5 -8
- package/core/useKTX2.js +3 -5
- package/core/useMatcapTexture.js +0 -6
- package/core/useNormalTexture.d.ts +1 -1
- package/core/useProgress.d.ts +1 -1
- package/core/useProgress.js +0 -5
- package/core/useTexture.js +4 -6
- package/core/useTrailTexture.d.ts +1 -1
- package/core/useTrailTexture.js +10 -21
- package/helpers/environment-assets.d.ts +1 -1
- package/helpers/ts-utils.d.ts +2 -2
- package/helpers/useEffectfulState.d.ts +1 -1
- package/helpers/useEffectfulState.js +0 -1
- package/index.cjs.js +1 -1
- package/index.js +1 -0
- package/materials/BlurPass.js +2 -5
- package/materials/ConvolutionMaterial.js +0 -3
- package/materials/MeshReflectorMaterial.d.ts +1 -1
- package/materials/MeshReflectorMaterial.js +0 -34
- package/materials/MeshRefractionMaterial.js +2 -6
- package/materials/SpotLightMaterial.js +2 -7
- package/materials/WireframeMaterial.js +7 -25
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +2 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/CycleRaycast.d.ts +1 -1
- package/web/CycleRaycast.js +20 -24
- package/web/Html.d.ts +2 -2
- package/web/Html.js +6 -50
- package/web/KeyboardControls.d.ts +10 -10
- package/web/KeyboardControls.js +9 -6
- package/web/Loader.d.ts +2 -2
- package/web/Loader.js +8 -5
- package/web/PresentationControls.d.ts +2 -2
- package/web/PresentationControls.js +2 -1
- package/web/ScrollControls.d.ts +4 -4
- package/web/ScrollControls.js +5 -16
- package/web/Select.d.ts +3 -3
- package/web/Select.js +6 -17
- package/web/View.d.ts +5 -5
- package/web/View.js +7 -20
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +6 -15
- package/web/pivotControls/AxisRotator.js +8 -23
- package/web/pivotControls/PlaneSlider.js +6 -16
- package/web/pivotControls/context.d.ts +2 -2
- package/web/pivotControls/index.d.ts +1 -1
- package/web/pivotControls/index.js +2 -9
package/core/useTrailTexture.js
CHANGED
|
@@ -14,11 +14,10 @@ import { Texture } from 'three';
|
|
|
14
14
|
// smooth new sample (measurement) based on previous sample (current)
|
|
15
15
|
function smoothAverage(current, measurement, smoothing = 0.9) {
|
|
16
16
|
return measurement * smoothing + current * (1.0 - smoothing);
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
19
18
|
|
|
19
|
+
// default ease
|
|
20
20
|
const easeCircleOut = x => Math.sqrt(1 - Math.pow(x - 1, 2));
|
|
21
|
-
|
|
22
21
|
class TrailTexture {
|
|
23
22
|
constructor({
|
|
24
23
|
size = 256,
|
|
@@ -45,7 +44,6 @@ class TrailTexture {
|
|
|
45
44
|
this.force = 0;
|
|
46
45
|
this.initTexture();
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
initTexture() {
|
|
50
48
|
this.canvas = document.createElement('canvas');
|
|
51
49
|
this.canvas.width = this.canvas.height = this.size;
|
|
@@ -56,44 +54,40 @@ class TrailTexture {
|
|
|
56
54
|
this.canvas.id = 'touchTexture';
|
|
57
55
|
this.canvas.style.width = this.canvas.style.height = `${this.canvas.width}px`;
|
|
58
56
|
}
|
|
59
|
-
|
|
60
57
|
update(delta) {
|
|
61
|
-
this.clear();
|
|
58
|
+
this.clear();
|
|
62
59
|
|
|
60
|
+
// age points
|
|
63
61
|
this.trail.forEach((point, i) => {
|
|
64
|
-
point.age += delta * 1000;
|
|
65
|
-
|
|
62
|
+
point.age += delta * 1000;
|
|
63
|
+
// remove old
|
|
66
64
|
if (point.age > this.maxAge) {
|
|
67
65
|
this.trail.splice(i, 1);
|
|
68
66
|
}
|
|
69
|
-
});
|
|
67
|
+
});
|
|
70
68
|
|
|
69
|
+
// reset force when empty (when smoothing)
|
|
71
70
|
if (!this.trail.length) this.force = 0;
|
|
72
71
|
this.trail.forEach(point => {
|
|
73
72
|
this.drawTouch(point);
|
|
74
73
|
});
|
|
75
74
|
this.texture.needsUpdate = true;
|
|
76
75
|
}
|
|
77
|
-
|
|
78
76
|
clear() {
|
|
79
77
|
this.ctx.globalCompositeOperation = 'source-over';
|
|
80
78
|
this.ctx.fillStyle = 'black';
|
|
81
79
|
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
82
80
|
}
|
|
83
|
-
|
|
84
81
|
addTouch(point) {
|
|
85
82
|
const last = this.trail[this.trail.length - 1];
|
|
86
|
-
|
|
87
83
|
if (last) {
|
|
88
84
|
const dx = last.x - point.x;
|
|
89
85
|
const dy = last.y - point.y;
|
|
90
86
|
const dd = dx * dx + dy * dy;
|
|
91
87
|
const force = Math.max(this.minForce, Math.min(dd * 10000, 1));
|
|
92
88
|
this.force = smoothAverage(force, this.force, this.smoothing);
|
|
93
|
-
|
|
94
89
|
if (!!this.interpolate) {
|
|
95
90
|
const lines = Math.ceil(dd / Math.pow(this.radius * 0.5 / this.interpolate, 2));
|
|
96
|
-
|
|
97
91
|
if (lines > 1) {
|
|
98
92
|
for (let i = 1; i < lines; i++) {
|
|
99
93
|
this.trail.push({
|
|
@@ -106,7 +100,6 @@ class TrailTexture {
|
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
102
|
}
|
|
109
|
-
|
|
110
103
|
this.trail.push({
|
|
111
104
|
x: point.x,
|
|
112
105
|
y: point.y,
|
|
@@ -114,22 +107,20 @@ class TrailTexture {
|
|
|
114
107
|
force: this.force
|
|
115
108
|
});
|
|
116
109
|
}
|
|
117
|
-
|
|
118
110
|
drawTouch(point) {
|
|
119
111
|
const pos = {
|
|
120
112
|
x: point.x * this.size,
|
|
121
113
|
y: (1 - point.y) * this.size
|
|
122
114
|
};
|
|
123
115
|
let intensity = 1;
|
|
124
|
-
|
|
125
116
|
if (point.age < this.maxAge * 0.3) {
|
|
126
117
|
intensity = this.ease(point.age / (this.maxAge * 0.3));
|
|
127
118
|
} else {
|
|
128
119
|
intensity = this.ease(1 - (point.age - this.maxAge * 0.3) / (this.maxAge * 0.7));
|
|
129
120
|
}
|
|
121
|
+
intensity *= point.force;
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
// apply blending
|
|
133
124
|
this.ctx.globalCompositeOperation = this.blend;
|
|
134
125
|
const radius = this.size * this.radius * intensity;
|
|
135
126
|
const grd = this.ctx.createRadialGradient(pos.x, pos.y, Math.max(0, radius * 0.25), pos.x, pos.y, Math.max(0, radius));
|
|
@@ -140,9 +131,7 @@ class TrailTexture {
|
|
|
140
131
|
this.ctx.arc(pos.x, pos.y, Math.max(0, radius), 0, Math.PI * 2);
|
|
141
132
|
this.ctx.fill();
|
|
142
133
|
}
|
|
143
|
-
|
|
144
134
|
}
|
|
145
|
-
|
|
146
135
|
function useTrailTexture(config = {}) {
|
|
147
136
|
const {
|
|
148
137
|
size,
|
package/helpers/ts-utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type NamedArrayTuple<T extends (...args: any) => any> = Parameters<T>;
|
|
3
|
+
export type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
type RefType<T> = React.MutableRefObject<T> | ((state: T) => void);
|
|
3
3
|
export declare function useEffectfulState<T>(fn: () => T, deps?: React.DependencyList, cb?: RefType<T>): T | undefined;
|
|
4
4
|
export {};
|
|
@@ -3,7 +3,6 @@ import * as React from 'react';
|
|
|
3
3
|
function call(ref, value) {
|
|
4
4
|
if (typeof ref === 'function') ref(value);else if (ref != null) ref.current = value;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
function useEffectfulState(fn, deps = [], cb) {
|
|
8
7
|
const [state, set] = React.useState();
|
|
9
8
|
React.useLayoutEffect(() => {
|