@react-three/drei 9.99.6 → 9.100.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 +1 -1
- package/core/Caustics.cjs.js +1 -1
- package/core/Caustics.js +7 -7
- package/core/Effects.d.ts +3 -2
- package/core/Mask.d.ts +4 -4
- package/core/MeshTransmissionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.d.ts +1 -0
- package/core/MeshTransmissionMaterial.js +5 -0
- package/core/Sampler.cjs.js +1 -1
- package/core/Sampler.js +1 -1
- package/core/Stats.cjs.js +1 -1
- package/core/Stats.js +1 -1
- package/index.cjs.js +1 -1
- package/materials/BlurPass.js +1 -0
- package/package.json +1 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/DragControls.cjs.js +1 -1
- package/web/DragControls.d.ts +2 -0
- package/web/DragControls.js +3 -1
- package/web/Html.cjs.js +1 -1
- package/web/Html.d.ts +1 -1
- package/web/Html.js +7 -5
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/ScalingSphere.cjs.js +1 -0
- package/web/pivotControls/ScalingSphere.d.ts +7 -0
- package/web/pivotControls/ScalingSphere.js +192 -0
- package/web/pivotControls/context.d.ts +2 -1
- package/web/pivotControls/index.cjs.js +1 -1
- package/web/pivotControls/index.d.ts +2 -0
- package/web/pivotControls/index.js +34 -14
|
@@ -5,6 +5,7 @@ import * as THREE from 'three';
|
|
|
5
5
|
import { AxisArrow } from './AxisArrow.js';
|
|
6
6
|
import { AxisRotator } from './AxisRotator.js';
|
|
7
7
|
import { PlaneSlider } from './PlaneSlider.js';
|
|
8
|
+
import { ScalingSphere } from './ScalingSphere.js';
|
|
8
9
|
import { context } from './context.js';
|
|
9
10
|
import { calculateScaleFactor } from '../../core/calculateScaleFactor.js';
|
|
10
11
|
|
|
@@ -16,12 +17,14 @@ const mW = /* @__PURE__ */new THREE.Matrix4();
|
|
|
16
17
|
const mL = /* @__PURE__ */new THREE.Matrix4();
|
|
17
18
|
const mL0Inv = /* @__PURE__ */new THREE.Matrix4();
|
|
18
19
|
const mdL = /* @__PURE__ */new THREE.Matrix4();
|
|
20
|
+
const mG = /* @__PURE__ */new THREE.Matrix4();
|
|
19
21
|
const bb = /* @__PURE__ */new THREE.Box3();
|
|
20
22
|
const bbObj = /* @__PURE__ */new THREE.Box3();
|
|
21
23
|
const vCenter = /* @__PURE__ */new THREE.Vector3();
|
|
22
24
|
const vSize = /* @__PURE__ */new THREE.Vector3();
|
|
23
25
|
const vAnchorOffset = /* @__PURE__ */new THREE.Vector3();
|
|
24
26
|
const vPosition = /* @__PURE__ */new THREE.Vector3();
|
|
27
|
+
const vScale = /* @__PURE__ */new THREE.Vector3();
|
|
25
28
|
const xDir = /* @__PURE__ */new THREE.Vector3(1, 0, 0);
|
|
26
29
|
const yDir = /* @__PURE__ */new THREE.Vector3(0, 1, 0);
|
|
27
30
|
const zDir = /* @__PURE__ */new THREE.Vector3(0, 0, 1);
|
|
@@ -35,6 +38,7 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
35
38
|
disableAxes = false,
|
|
36
39
|
disableSliders = false,
|
|
37
40
|
disableRotations = false,
|
|
41
|
+
disableScaling = false,
|
|
38
42
|
activeAxes = [true, true, true],
|
|
39
43
|
offset = [0, 0, 0],
|
|
40
44
|
rotation = [0, 0, 0],
|
|
@@ -43,6 +47,7 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
43
47
|
fixed = false,
|
|
44
48
|
translationLimits,
|
|
45
49
|
rotationLimits,
|
|
50
|
+
scaleLimits,
|
|
46
51
|
depthTest = true,
|
|
47
52
|
axisColors = ['#ff2060', '#20df80', '#2080ff'],
|
|
48
53
|
hoveredColor = '#ffff40',
|
|
@@ -60,6 +65,8 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
60
65
|
const gizmoRef = React.useRef(null);
|
|
61
66
|
const childrenRef = React.useRef(null);
|
|
62
67
|
const translation = React.useRef([0, 0, 0]);
|
|
68
|
+
const cameraScale = React.useRef(new THREE.Vector3(1, 1, 1));
|
|
69
|
+
const gizmoScale = React.useRef(new THREE.Vector3(1, 1, 1));
|
|
63
70
|
React.useLayoutEffect(() => {
|
|
64
71
|
if (!anchor) return;
|
|
65
72
|
childrenRef.current.updateWorldMatrix(true, true);
|
|
@@ -95,7 +102,9 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
95
102
|
mL.copy(mW).premultiply(mPInv);
|
|
96
103
|
mL0Inv.copy(mL0).invert();
|
|
97
104
|
mdL.copy(mL).multiply(mL0Inv);
|
|
98
|
-
if (autoTransform)
|
|
105
|
+
if (autoTransform) {
|
|
106
|
+
ref.current.matrix.copy(mL);
|
|
107
|
+
}
|
|
99
108
|
onDrag && onDrag(mL, mdL, mW, mdW);
|
|
100
109
|
invalidate();
|
|
101
110
|
},
|
|
@@ -116,26 +125,28 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
116
125
|
userData,
|
|
117
126
|
annotations,
|
|
118
127
|
annotationsClass
|
|
119
|
-
}), [onDragStart, onDrag, onDragEnd, translation, translationLimits, rotationLimits, depthTest, scale, lineWidth, fixed, ...axisColors, hoveredColor, opacity, userData, autoTransform, annotations, annotationsClass]);
|
|
128
|
+
}), [onDragStart, onDrag, onDragEnd, translation, translationLimits, rotationLimits, scaleLimits, depthTest, scale, lineWidth, fixed, ...axisColors, hoveredColor, opacity, userData, autoTransform, annotations, annotationsClass]);
|
|
120
129
|
const vec = new THREE.Vector3();
|
|
121
130
|
useFrame(state => {
|
|
122
131
|
if (fixed) {
|
|
123
132
|
const sf = calculateScaleFactor(gizmoRef.current.getWorldPosition(vec), scale, state.camera, state.size);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
cameraScale.current.setScalar(sf);
|
|
134
|
+
}
|
|
135
|
+
if (matrix && matrix instanceof THREE.Matrix4) {
|
|
136
|
+
ref.current.matrix = matrix;
|
|
137
|
+
}
|
|
138
|
+
// Update gizmo scale in accordance with matrix changes
|
|
139
|
+
// Without this, there might be noticable turbulences if scaling happens fast enough
|
|
140
|
+
ref.current.updateWorldMatrix(true, true);
|
|
141
|
+
mG.makeRotationFromEuler(gizmoRef.current.rotation).setPosition(gizmoRef.current.position).premultiply(ref.current.matrixWorld);
|
|
142
|
+
gizmoScale.current.setFromMatrixScale(mG);
|
|
143
|
+
vScale.copy(cameraScale.current).divide(gizmoScale.current);
|
|
144
|
+
if (Math.abs(gizmoRef.current.scale.x - vScale.x) > 1e-4 || Math.abs(gizmoRef.current.scale.y - vScale.y) > 1e-4 || Math.abs(gizmoRef.current.scale.z - vScale.z) > 1e-4) {
|
|
145
|
+
gizmoRef.current.scale.copy(vScale);
|
|
146
|
+
state.invalidate();
|
|
131
147
|
}
|
|
132
148
|
});
|
|
133
149
|
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
134
|
-
React.useLayoutEffect(() => {
|
|
135
|
-
// If the matrix is a real matrix4 it means that the user wants to control the gizmo
|
|
136
|
-
// In that case it should just be set, as a bare prop update would merely copy it
|
|
137
|
-
if (matrix && matrix instanceof THREE.Matrix4) ref.current.matrix = matrix;
|
|
138
|
-
}, [matrix]);
|
|
139
150
|
return /*#__PURE__*/React.createElement(context.Provider, {
|
|
140
151
|
value: config
|
|
141
152
|
}, /*#__PURE__*/React.createElement("group", {
|
|
@@ -182,6 +193,15 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
|
|
|
182
193
|
axis: 0,
|
|
183
194
|
dir1: yDir,
|
|
184
195
|
dir2: zDir
|
|
196
|
+
}), !disableScaling && activeAxes[0] && /*#__PURE__*/React.createElement(ScalingSphere, {
|
|
197
|
+
axis: 0,
|
|
198
|
+
direction: xDir
|
|
199
|
+
}), !disableScaling && activeAxes[1] && /*#__PURE__*/React.createElement(ScalingSphere, {
|
|
200
|
+
axis: 1,
|
|
201
|
+
direction: yDir
|
|
202
|
+
}), !disableScaling && activeAxes[2] && /*#__PURE__*/React.createElement(ScalingSphere, {
|
|
203
|
+
axis: 2,
|
|
204
|
+
direction: zDir
|
|
185
205
|
})), /*#__PURE__*/React.createElement("group", {
|
|
186
206
|
ref: childrenRef
|
|
187
207
|
}, children))));
|