@react-three/drei 9.74.13 → 9.74.15
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/core/CatmullRomLine.js +0 -2
- package/core/Cloud.js +0 -3
- package/core/CubeCamera.js +0 -1
- package/core/CubicBezierLine.js +0 -2
- package/core/Environment.js +0 -1
- package/core/Example.js +0 -6
- package/core/FaceControls.cjs.js +1 -1
- package/core/FaceControls.js +0 -2
- package/core/FaceLandmarker.cjs.js +1 -1
- package/core/FaceLandmarker.js +3 -4
- package/core/Facemesh.js +0 -2
- package/core/GizmoHelper.js +0 -3
- package/core/GizmoViewcube.js +0 -4
- package/core/GizmoViewport.js +0 -4
- package/core/Gltf.js +0 -4
- package/core/MeshDiscardMaterial.js +0 -2
- package/core/MeshDistortMaterial.js +1 -2
- package/core/MeshReflectorMaterial.js +0 -1
- package/core/MeshRefractionMaterial.js +0 -2
- package/core/MeshTransmissionMaterial.js +0 -1
- package/core/OrthographicCamera.js +0 -1
- package/core/PerspectiveCamera.js +0 -1
- package/core/QuadraticBezierLine.js +0 -2
- package/core/Reflector.js +0 -1
- package/core/SpotLight.js +1 -2
- package/core/Stage.js +0 -7
- package/core/Text3D.js +0 -1
- package/core/Wireframe.js +0 -1
- package/core/index.cjs.js +1 -1
- package/core/index.js +1 -0
- package/core/useKTX2.js +0 -1
- package/core/useMatcapTexture.js +0 -2
- package/core/useNormalTexture.js +0 -1
- package/index.cjs.js +1 -1
- package/materials/DiscardMaterial.js +0 -1
- package/materials/MeshRefractionMaterial.js +1 -1
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +2 -2
- package/web/Loader.js +0 -2
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +0 -3
- package/web/pivotControls/AxisRotator.js +0 -3
- package/web/pivotControls/PlaneSlider.js +0 -3
- package/web/pivotControls/index.js +0 -5
- package/src/core/AccumulativeShadows.js +0 -311
- package/src/core/AdaptiveDpr.js +0 -28
- package/src/core/AdaptiveEvents.js +0 -20
- package/src/core/ArcballControls.js +0 -67
- package/src/core/AsciiRenderer.js +0 -60
- package/src/core/BBAnchor.js +0 -37
- package/src/core/Backdrop.js +0 -36
- package/src/core/BakeShadows.js +0 -16
- package/src/core/Billboard.js +0 -41
- package/src/core/Bounds.js +0 -245
- package/src/core/CameraControls.js +0 -92
- package/src/core/CameraShake.js +0 -61
- package/src/core/CatmullRomLine.js +0 -44
- package/src/core/Caustics.js +0 -375
- package/src/core/Center.js +0 -66
- package/src/core/Clone.js +0 -102
- package/src/core/Cloud.js +0 -59
- package/src/core/ComputedAttribute.js +0 -34
- package/src/core/ContactShadows.js +0 -114
- package/src/core/CubeCamera.js +0 -43
- package/src/core/CubicBezierLine.js +0 -28
- package/src/core/CurveModifier.js +0 -34
- package/src/core/Decal.js +0 -92
- package/src/core/Detailed.js +0 -34
- package/src/core/DeviceOrientationControls.js +0 -51
- package/src/core/Edges.js +0 -36
- package/src/core/Effects.js +0 -93
- package/src/core/Environment.js +0 -132
- package/src/core/Example.js +0 -42
- package/src/core/FaceControls.js +0 -315
- package/src/core/FaceLandmarker.js +0 -43
- package/src/core/Facemesh.js +0 -4545
- package/src/core/FirstPersonControls.js +0 -38
- package/src/core/Float.js +0 -36
- package/src/core/FlyControls.js +0 -55
- package/src/core/GizmoHelper.js +0 -111
- package/src/core/GizmoViewcube.js +0 -152
- package/src/core/GizmoViewport.js +0 -152
- package/src/core/Gltf.js +0 -20
- package/src/core/GradientTexture.js +0 -33
- package/src/core/Grid.js +0 -112
- package/src/core/Hud.js +0 -58
- package/src/core/Image.js +0 -119
- package/src/core/Instances.js +0 -215
- package/src/core/Lightformer.js +0 -51
- package/src/core/Line.js +0 -68
- package/src/core/MapControls.js +0 -64
- package/src/core/MarchingCubes.js +0 -76
- package/src/core/Mask.js +0 -42
- package/src/core/MeshDiscardMaterial.js +0 -15
- package/src/core/MeshDistortMaterial.js +0 -79
- package/src/core/MeshPortalMaterial.js +0 -381
- package/src/core/MeshReflectorMaterial.js +0 -182
- package/src/core/MeshRefractionMaterial.js +0 -79
- package/src/core/MeshTransmissionMaterial.js +0 -395
- package/src/core/MeshWobbleMaterial.js +0 -65
- package/src/core/OrbitControls.js +0 -82
- package/src/core/OrthographicCamera.js +0 -77
- package/src/core/PerformanceMonitor.js +0 -121
- package/src/core/PerspectiveCamera.js +0 -73
- package/src/core/PointMaterial.js +0 -36
- package/src/core/PointerLockControls.js +0 -90
- package/src/core/Points.js +0 -227
- package/src/core/PositionalAudio.js +0 -51
- package/src/core/Preload.js +0 -45
- package/src/core/QuadraticBezierLine.js +0 -44
- package/src/core/Reflector.js +0 -182
- package/src/core/RenderTexture.js +0 -96
- package/src/core/Resize.js +0 -39
- package/src/core/RoundedBox.js +0 -52
- package/src/core/Sampler.js +0 -85
- package/src/core/ScreenQuad.js +0 -24
- package/src/core/ScreenSpace.js +0 -25
- package/src/core/Segments.js +0 -102
- package/src/core/Shadow.js +0 -42
- package/src/core/Sky.js +0 -39
- package/src/core/Sparkles.js +0 -139
- package/src/core/SpotLight.js +0 -231
- package/src/core/SpriteAnimator.js +0 -342
- package/src/core/Stage.js +0 -135
- package/src/core/Stars.js +0 -108
- package/src/core/Stats.js +0 -30
- package/src/core/Svg.js +0 -59
- package/src/core/Text.js +0 -58
- package/src/core/Text3D.js +0 -76
- package/src/core/TrackballControls.js +0 -72
- package/src/core/Trail.js +0 -161
- package/src/core/TransformControls.js +0 -106
- package/src/core/Wireframe.js +0 -185
- package/src/core/meshBounds.js +0 -38
- package/src/core/shaderMaterial.js +0 -39
- package/src/core/shapes.js +0 -68
- package/src/core/softShadows.js +0 -161
- package/src/core/useAnimations.js +0 -56
- package/src/core/useAspect.js +0 -10
- package/src/core/useBVH.js +0 -90
- package/src/core/useBoxProjectedEnv.js +0 -98
- package/src/core/useCamera.js +0 -27
- package/src/core/useContextBridge.js +0 -21
- package/src/core/useCubeCamera.js +0 -49
- package/src/core/useCubeTexture.js +0 -18
- package/src/core/useDepthBuffer.js +0 -38
- package/src/core/useDetectGPU.js +0 -6
- package/src/core/useEnvironment.js +0 -48
- package/src/core/useFBO.js +0 -53
- package/src/core/useFBX.js +0 -12
- package/src/core/useFont.js +0 -20
- package/src/core/useGLTF.js +0 -37
- package/src/core/useHelper.js +0 -31
- package/src/core/useIntersect.js +0 -39
- package/src/core/useKTX2.js +0 -38
- package/src/core/useMatcapTexture.js +0 -45
- package/src/core/useNormalTexture.js +0 -30
- package/src/core/useProgress.js +0 -50
- package/src/core/useTexture.js +0 -35
- package/src/core/useTrailTexture.js +0 -164
- package/src/core/useVideoTexture.js +0 -41
- package/src/helpers/environment-assets.js +0 -14
- package/src/helpers/useEffectfulState.js +0 -18
- package/src/materials/BlurPass.js +0 -75
- package/src/materials/ConvolutionMaterial.js +0 -99
- package/src/materials/DiscardMaterial.js +0 -5
- package/src/materials/MeshReflectorMaterial.js +0 -290
- package/src/materials/MeshRefractionMaterial.js +0 -171
- package/src/materials/SpotLightMaterial.js +0 -111
- package/src/materials/WireframeMaterial.js +0 -235
- package/src/web/CycleRaycast.js +0 -97
- package/src/web/Html.js +0 -417
- package/src/web/KeyboardControls.js +0 -101
- package/src/web/Loader.js +0 -98
- package/src/web/PresentationControls.js +0 -86
- package/src/web/ScrollControls.js +0 -246
- package/src/web/Select.js +0 -175
- package/src/web/View.js +0 -206
- package/src/web/pivotControls/AxisArrow.js +0 -202
- package/src/web/pivotControls/AxisRotator.js +0 -235
- package/src/web/pivotControls/PlaneSlider.js +0 -211
- package/src/web/pivotControls/context.js +0 -5
- package/src/web/pivotControls/index.js +0 -223
- package/src/web/useCursor.js +0 -12
- /package/{src/helpers → helpers}/glsl/DefaultSpotlightShadowShadows.glsl.js +0 -0
- /package/{src/helpers → helpers}/glsl/distort.vert.glsl.js +0 -0
- /package/{src/index.js → index.js} +0 -0
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import * as THREE from 'three';
|
|
4
|
-
import { useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { HorizontalBlurShader, VerticalBlurShader } from 'three-stdlib';
|
|
6
|
-
|
|
7
|
-
const ContactShadows = /*#__PURE__*/React.forwardRef(({
|
|
8
|
-
scale = 10,
|
|
9
|
-
frames = Infinity,
|
|
10
|
-
opacity = 1,
|
|
11
|
-
width = 1,
|
|
12
|
-
height = 1,
|
|
13
|
-
blur = 1,
|
|
14
|
-
far = 10,
|
|
15
|
-
resolution = 512,
|
|
16
|
-
smooth = true,
|
|
17
|
-
color = '#000000',
|
|
18
|
-
depthWrite = false,
|
|
19
|
-
renderOrder,
|
|
20
|
-
...props
|
|
21
|
-
}, fref) => {
|
|
22
|
-
const ref = React.useRef(null);
|
|
23
|
-
const scene = useThree(state => state.scene);
|
|
24
|
-
const gl = useThree(state => state.gl);
|
|
25
|
-
const shadowCamera = React.useRef(null);
|
|
26
|
-
width = width * (Array.isArray(scale) ? scale[0] : scale || 1);
|
|
27
|
-
height = height * (Array.isArray(scale) ? scale[1] : scale || 1);
|
|
28
|
-
const [renderTarget, planeGeometry, depthMaterial, blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur] = React.useMemo(() => {
|
|
29
|
-
const renderTarget = new THREE.WebGLRenderTarget(resolution, resolution);
|
|
30
|
-
const renderTargetBlur = new THREE.WebGLRenderTarget(resolution, resolution);
|
|
31
|
-
renderTargetBlur.texture.generateMipmaps = renderTarget.texture.generateMipmaps = false;
|
|
32
|
-
const planeGeometry = new THREE.PlaneGeometry(width, height).rotateX(Math.PI / 2);
|
|
33
|
-
const blurPlane = new THREE.Mesh(planeGeometry);
|
|
34
|
-
const depthMaterial = new THREE.MeshDepthMaterial();
|
|
35
|
-
depthMaterial.depthTest = depthMaterial.depthWrite = false;
|
|
36
|
-
|
|
37
|
-
depthMaterial.onBeforeCompile = shader => {
|
|
38
|
-
shader.uniforms = { ...shader.uniforms,
|
|
39
|
-
ucolor: {
|
|
40
|
-
value: new THREE.Color(color)
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
shader.fragmentShader = shader.fragmentShader.replace(`void main() {`, //
|
|
44
|
-
`uniform vec3 ucolor;
|
|
45
|
-
void main() {
|
|
46
|
-
`);
|
|
47
|
-
shader.fragmentShader = shader.fragmentShader.replace('vec4( vec3( 1.0 - fragCoordZ ), opacity );', // Colorize the shadow, multiply by the falloff so that the center can remain darker
|
|
48
|
-
'vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );');
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const horizontalBlurMaterial = new THREE.ShaderMaterial(HorizontalBlurShader);
|
|
52
|
-
const verticalBlurMaterial = new THREE.ShaderMaterial(VerticalBlurShader);
|
|
53
|
-
verticalBlurMaterial.depthTest = horizontalBlurMaterial.depthTest = false;
|
|
54
|
-
return [renderTarget, planeGeometry, depthMaterial, blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur];
|
|
55
|
-
}, [resolution, width, height, scale, color]);
|
|
56
|
-
|
|
57
|
-
const blurShadows = blur => {
|
|
58
|
-
blurPlane.visible = true;
|
|
59
|
-
blurPlane.material = horizontalBlurMaterial;
|
|
60
|
-
horizontalBlurMaterial.uniforms.tDiffuse.value = renderTarget.texture;
|
|
61
|
-
horizontalBlurMaterial.uniforms.h.value = blur * 1 / 256;
|
|
62
|
-
gl.setRenderTarget(renderTargetBlur);
|
|
63
|
-
gl.render(blurPlane, shadowCamera.current);
|
|
64
|
-
blurPlane.material = verticalBlurMaterial;
|
|
65
|
-
verticalBlurMaterial.uniforms.tDiffuse.value = renderTargetBlur.texture;
|
|
66
|
-
verticalBlurMaterial.uniforms.v.value = blur * 1 / 256;
|
|
67
|
-
gl.setRenderTarget(renderTarget);
|
|
68
|
-
gl.render(blurPlane, shadowCamera.current);
|
|
69
|
-
blurPlane.visible = false;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
let count = 0;
|
|
73
|
-
let initialBackground;
|
|
74
|
-
let initialOverrideMaterial;
|
|
75
|
-
useFrame(() => {
|
|
76
|
-
if (shadowCamera.current && (frames === Infinity || count < frames)) {
|
|
77
|
-
count++;
|
|
78
|
-
initialBackground = scene.background;
|
|
79
|
-
initialOverrideMaterial = scene.overrideMaterial;
|
|
80
|
-
ref.current.visible = false;
|
|
81
|
-
scene.background = null;
|
|
82
|
-
scene.overrideMaterial = depthMaterial;
|
|
83
|
-
gl.setRenderTarget(renderTarget);
|
|
84
|
-
gl.render(scene, shadowCamera.current);
|
|
85
|
-
blurShadows(blur);
|
|
86
|
-
if (smooth) blurShadows(blur * 0.4);
|
|
87
|
-
gl.setRenderTarget(null);
|
|
88
|
-
ref.current.visible = true;
|
|
89
|
-
scene.overrideMaterial = initialOverrideMaterial;
|
|
90
|
-
scene.background = initialBackground;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
React.useImperativeHandle(fref, () => ref.current, []);
|
|
94
|
-
return /*#__PURE__*/React.createElement("group", _extends({
|
|
95
|
-
"rotation-x": Math.PI / 2
|
|
96
|
-
}, props, {
|
|
97
|
-
ref: ref
|
|
98
|
-
}), /*#__PURE__*/React.createElement("mesh", {
|
|
99
|
-
renderOrder: renderOrder,
|
|
100
|
-
geometry: planeGeometry,
|
|
101
|
-
scale: [1, -1, 1],
|
|
102
|
-
rotation: [-Math.PI / 2, 0, 0]
|
|
103
|
-
}, /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
104
|
-
transparent: true,
|
|
105
|
-
map: renderTarget.texture,
|
|
106
|
-
opacity: opacity,
|
|
107
|
-
depthWrite: depthWrite
|
|
108
|
-
})), /*#__PURE__*/React.createElement("orthographicCamera", {
|
|
109
|
-
ref: shadowCamera,
|
|
110
|
-
args: [-width / 2, width / 2, height / 2, -height / 2, 0, far]
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
export { ContactShadows };
|
package/src/core/CubeCamera.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useFrame } from '@react-three/fiber';
|
|
3
|
-
import { useCubeCamera } from './useCubeCamera.js';
|
|
4
|
-
|
|
5
|
-
function CubeCamera({
|
|
6
|
-
children,
|
|
7
|
-
frames = Infinity,
|
|
8
|
-
resolution,
|
|
9
|
-
near,
|
|
10
|
-
far,
|
|
11
|
-
envMap,
|
|
12
|
-
fog,
|
|
13
|
-
...props
|
|
14
|
-
}) {
|
|
15
|
-
const ref = React.useRef();
|
|
16
|
-
const {
|
|
17
|
-
fbo,
|
|
18
|
-
camera,
|
|
19
|
-
update
|
|
20
|
-
} = useCubeCamera({
|
|
21
|
-
resolution,
|
|
22
|
-
near,
|
|
23
|
-
far,
|
|
24
|
-
envMap,
|
|
25
|
-
fog
|
|
26
|
-
});
|
|
27
|
-
let count = 0;
|
|
28
|
-
useFrame(() => {
|
|
29
|
-
if (ref.current && (frames === Infinity || count < frames)) {
|
|
30
|
-
ref.current.visible = false;
|
|
31
|
-
update();
|
|
32
|
-
ref.current.visible = true;
|
|
33
|
-
count++;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return /*#__PURE__*/React.createElement("group", props, /*#__PURE__*/React.createElement("primitive", {
|
|
37
|
-
object: camera
|
|
38
|
-
}), /*#__PURE__*/React.createElement("group", {
|
|
39
|
-
ref: ref
|
|
40
|
-
}, children(fbo.texture)));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { CubeCamera };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Vector3, CubicBezierCurve3 } from 'three';
|
|
4
|
-
import { Line } from './Line.js';
|
|
5
|
-
|
|
6
|
-
const CubicBezierLine = /*#__PURE__*/React.forwardRef(function CubicBezierLine({
|
|
7
|
-
start,
|
|
8
|
-
end,
|
|
9
|
-
midA,
|
|
10
|
-
midB,
|
|
11
|
-
segments = 20,
|
|
12
|
-
...rest
|
|
13
|
-
}, ref) {
|
|
14
|
-
const points = React.useMemo(() => {
|
|
15
|
-
const startV = start instanceof Vector3 ? start : new Vector3(...start);
|
|
16
|
-
const endV = end instanceof Vector3 ? end : new Vector3(...end);
|
|
17
|
-
const midAV = midA instanceof Vector3 ? midA : new Vector3(...midA);
|
|
18
|
-
const midBV = midB instanceof Vector3 ? midB : new Vector3(...midB);
|
|
19
|
-
const interpolatedV = new CubicBezierCurve3(startV, midAV, midBV, endV).getPoints(segments);
|
|
20
|
-
return interpolatedV;
|
|
21
|
-
}, [start, end, midA, midB, segments]);
|
|
22
|
-
return /*#__PURE__*/React.createElement(Line, _extends({
|
|
23
|
-
ref: ref,
|
|
24
|
-
points: points
|
|
25
|
-
}, rest));
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export { CubicBezierLine };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { createPortal } from '@react-three/fiber';
|
|
4
|
-
import { Flow } from 'three-stdlib';
|
|
5
|
-
|
|
6
|
-
const CurveModifier = /*#__PURE__*/React.forwardRef(({
|
|
7
|
-
children,
|
|
8
|
-
curve
|
|
9
|
-
}, ref) => {
|
|
10
|
-
const [scene] = React.useState(() => new THREE.Scene());
|
|
11
|
-
const [obj, set] = React.useState();
|
|
12
|
-
const modifier = React.useRef();
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
modifier.current = new Flow(scene.children[0]);
|
|
15
|
-
set(modifier.current.object3D);
|
|
16
|
-
}, [children]);
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
var _modifier$current;
|
|
19
|
-
|
|
20
|
-
if (curve) (_modifier$current = modifier.current) == null ? void 0 : _modifier$current.updateCurve(0, curve);
|
|
21
|
-
}, [curve]);
|
|
22
|
-
React.useImperativeHandle(ref, () => ({
|
|
23
|
-
moveAlongCurve: val => {
|
|
24
|
-
var _modifier$current2;
|
|
25
|
-
|
|
26
|
-
(_modifier$current2 = modifier.current) == null ? void 0 : _modifier$current2.moveAlongCurve(val);
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal(children, scene), obj && /*#__PURE__*/React.createElement("primitive", {
|
|
30
|
-
object: obj
|
|
31
|
-
}));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export { CurveModifier };
|
package/src/core/Decal.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import * as THREE from 'three';
|
|
4
|
-
import { applyProps } from '@react-three/fiber';
|
|
5
|
-
import { DecalGeometry } from 'three-stdlib';
|
|
6
|
-
|
|
7
|
-
function isArray(vec) {
|
|
8
|
-
return Array.isArray(vec);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function vecToArray(vec = [0, 0, 0]) {
|
|
12
|
-
if (isArray(vec)) {
|
|
13
|
-
return vec;
|
|
14
|
-
} else if (vec instanceof THREE.Vector3 || vec instanceof THREE.Euler) {
|
|
15
|
-
return [vec.x, vec.y, vec.z];
|
|
16
|
-
} else {
|
|
17
|
-
return [vec, vec, vec];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const Decal = /*#__PURE__*/React.forwardRef(function Decal({
|
|
22
|
-
debug,
|
|
23
|
-
mesh,
|
|
24
|
-
children,
|
|
25
|
-
position,
|
|
26
|
-
rotation,
|
|
27
|
-
scale,
|
|
28
|
-
...props
|
|
29
|
-
}, forwardRef) {
|
|
30
|
-
const ref = React.useRef(null);
|
|
31
|
-
React.useImperativeHandle(forwardRef, () => ref.current);
|
|
32
|
-
const helper = React.useRef(null);
|
|
33
|
-
React.useLayoutEffect(() => {
|
|
34
|
-
const parent = (mesh == null ? void 0 : mesh.current) || ref.current.parent;
|
|
35
|
-
const target = ref.current;
|
|
36
|
-
|
|
37
|
-
if (!(parent instanceof THREE.Mesh)) {
|
|
38
|
-
throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const state = {
|
|
42
|
-
position: new THREE.Vector3(),
|
|
43
|
-
rotation: new THREE.Euler(),
|
|
44
|
-
scale: new THREE.Vector3(1, 1, 1)
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
if (parent) {
|
|
48
|
-
applyProps(state, {
|
|
49
|
-
position,
|
|
50
|
-
scale
|
|
51
|
-
}); // Zero out the parents matrix world for this operation
|
|
52
|
-
|
|
53
|
-
const matrixWorld = parent.matrixWorld.clone();
|
|
54
|
-
parent.matrixWorld.identity();
|
|
55
|
-
|
|
56
|
-
if (!rotation || typeof rotation === 'number') {
|
|
57
|
-
const o = new THREE.Object3D();
|
|
58
|
-
o.position.copy(state.position);
|
|
59
|
-
o.lookAt(parent.position);
|
|
60
|
-
if (typeof rotation === 'number') o.rotateZ(rotation);
|
|
61
|
-
applyProps(state, {
|
|
62
|
-
rotation: o.rotation
|
|
63
|
-
});
|
|
64
|
-
} else {
|
|
65
|
-
applyProps(state, {
|
|
66
|
-
rotation
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
target.geometry = new DecalGeometry(parent, state.position, state.rotation, state.scale);
|
|
71
|
-
if (helper.current) applyProps(helper.current, state); // Reset parents matix-world
|
|
72
|
-
|
|
73
|
-
parent.matrixWorld = matrixWorld;
|
|
74
|
-
return () => {
|
|
75
|
-
target.geometry.dispose();
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}, [mesh, ...vecToArray(position), ...vecToArray(scale), ...vecToArray(rotation)]);
|
|
79
|
-
return /*#__PURE__*/React.createElement("mesh", {
|
|
80
|
-
ref: ref
|
|
81
|
-
}, children || /*#__PURE__*/React.createElement("meshStandardMaterial", _extends({
|
|
82
|
-
transparent: true,
|
|
83
|
-
polygonOffset: true,
|
|
84
|
-
polygonOffsetFactor: -10
|
|
85
|
-
}, props)), debug && /*#__PURE__*/React.createElement("mesh", {
|
|
86
|
-
ref: helper
|
|
87
|
-
}, /*#__PURE__*/React.createElement("boxGeometry", null), /*#__PURE__*/React.createElement("meshNormalMaterial", {
|
|
88
|
-
wireframe: true
|
|
89
|
-
}), /*#__PURE__*/React.createElement("axesHelper", null)));
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export { Decal };
|
package/src/core/Detailed.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useFrame } from '@react-three/fiber';
|
|
4
|
-
import mergeRefs from 'react-merge-refs';
|
|
5
|
-
|
|
6
|
-
const Detailed = /*#__PURE__*/React.forwardRef(({
|
|
7
|
-
children,
|
|
8
|
-
hysteresis = 0,
|
|
9
|
-
distances,
|
|
10
|
-
...props
|
|
11
|
-
}, ref) => {
|
|
12
|
-
const lodRef = React.useRef(null);
|
|
13
|
-
React.useLayoutEffect(() => {
|
|
14
|
-
const {
|
|
15
|
-
current: lod
|
|
16
|
-
} = lodRef;
|
|
17
|
-
lod.levels.length = 0;
|
|
18
|
-
lod.children.forEach((object, index) => lod.levels.push({
|
|
19
|
-
object,
|
|
20
|
-
hysteresis,
|
|
21
|
-
distance: distances[index]
|
|
22
|
-
}));
|
|
23
|
-
});
|
|
24
|
-
useFrame(state => {
|
|
25
|
-
var _lodRef$current;
|
|
26
|
-
|
|
27
|
-
return (_lodRef$current = lodRef.current) == null ? void 0 : _lodRef$current.update(state.camera);
|
|
28
|
-
});
|
|
29
|
-
return /*#__PURE__*/React.createElement("lOD", _extends({
|
|
30
|
-
ref: mergeRefs([lodRef, ref])
|
|
31
|
-
}, props), children);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export { Detailed };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import { useThree, useFrame } from '@react-three/fiber';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { DeviceOrientationControls as DeviceOrientationControls$1 } from 'three-stdlib';
|
|
5
|
-
|
|
6
|
-
const DeviceOrientationControls = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
7
|
-
const {
|
|
8
|
-
camera,
|
|
9
|
-
onChange,
|
|
10
|
-
makeDefault,
|
|
11
|
-
...rest
|
|
12
|
-
} = props;
|
|
13
|
-
const defaultCamera = useThree(state => state.camera);
|
|
14
|
-
const invalidate = useThree(state => state.invalidate);
|
|
15
|
-
const get = useThree(state => state.get);
|
|
16
|
-
const set = useThree(state => state.set);
|
|
17
|
-
const explCamera = camera || defaultCamera;
|
|
18
|
-
const [controls] = React.useState(() => new DeviceOrientationControls$1(explCamera));
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
const callback = e => {
|
|
21
|
-
invalidate();
|
|
22
|
-
if (onChange) onChange(e);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
controls == null ? void 0 : controls.addEventListener == null ? void 0 : controls.addEventListener('change', callback);
|
|
26
|
-
return () => controls == null ? void 0 : controls.removeEventListener == null ? void 0 : controls.removeEventListener('change', callback);
|
|
27
|
-
}, [onChange, controls, invalidate]);
|
|
28
|
-
useFrame(() => controls == null ? void 0 : controls.update(), -1);
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
const current = controls;
|
|
31
|
-
current == null ? void 0 : current.connect();
|
|
32
|
-
return () => current == null ? void 0 : current.dispose();
|
|
33
|
-
}, [controls]);
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
if (makeDefault) {
|
|
36
|
-
const old = get().controls;
|
|
37
|
-
set({
|
|
38
|
-
controls
|
|
39
|
-
});
|
|
40
|
-
return () => set({
|
|
41
|
-
controls: old
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}, [makeDefault, controls]);
|
|
45
|
-
return controls ? /*#__PURE__*/React.createElement("primitive", _extends({
|
|
46
|
-
ref: ref,
|
|
47
|
-
object: controls
|
|
48
|
-
}, rest)) : null;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export { DeviceOrientationControls };
|
package/src/core/Edges.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import * as THREE from 'three';
|
|
4
|
-
|
|
5
|
-
const Edges = /*#__PURE__*/React.forwardRef(({
|
|
6
|
-
userData,
|
|
7
|
-
children,
|
|
8
|
-
geometry,
|
|
9
|
-
threshold = 15,
|
|
10
|
-
color = 'black',
|
|
11
|
-
...props
|
|
12
|
-
}, fref) => {
|
|
13
|
-
const ref = React.useRef(null);
|
|
14
|
-
React.useLayoutEffect(() => {
|
|
15
|
-
const parent = ref.current.parent;
|
|
16
|
-
|
|
17
|
-
if (parent) {
|
|
18
|
-
const geom = geometry || parent.geometry;
|
|
19
|
-
|
|
20
|
-
if (geom !== ref.current.userData.currentGeom || threshold !== ref.current.userData.currentThreshold) {
|
|
21
|
-
ref.current.userData.currentGeom = geom;
|
|
22
|
-
ref.current.userData.currentThreshold = threshold;
|
|
23
|
-
ref.current.geometry = new THREE.EdgesGeometry(geom, threshold);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
React.useImperativeHandle(fref, () => ref.current);
|
|
28
|
-
return /*#__PURE__*/React.createElement("lineSegments", _extends({
|
|
29
|
-
ref: ref,
|
|
30
|
-
raycast: () => null
|
|
31
|
-
}, props), children ? children : /*#__PURE__*/React.createElement("lineBasicMaterial", {
|
|
32
|
-
color: color
|
|
33
|
-
}));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export { Edges };
|
package/src/core/Effects.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { WebGLRenderTarget, HalfFloatType, RGBAFormat, UnsignedByteType } from 'three';
|
|
4
|
-
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { EffectComposer, RenderPass, ShaderPass, GammaCorrectionShader } from 'three-stdlib';
|
|
6
|
-
import mergeRefs from 'react-merge-refs';
|
|
7
|
-
|
|
8
|
-
const isWebGL2Available = () => {
|
|
9
|
-
try {
|
|
10
|
-
var canvas = document.createElement('canvas');
|
|
11
|
-
return !!(window.WebGL2RenderingContext && canvas.getContext('webgl2'));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const Effects = /*#__PURE__*/React.forwardRef(({
|
|
17
|
-
children,
|
|
18
|
-
multisamping = 8,
|
|
19
|
-
renderIndex = 1,
|
|
20
|
-
disableRender,
|
|
21
|
-
disableGamma,
|
|
22
|
-
disableRenderPass,
|
|
23
|
-
depthBuffer = true,
|
|
24
|
-
stencilBuffer = false,
|
|
25
|
-
anisotropy = 1,
|
|
26
|
-
encoding,
|
|
27
|
-
type,
|
|
28
|
-
...props
|
|
29
|
-
}, ref) => {
|
|
30
|
-
React.useMemo(() => extend({
|
|
31
|
-
EffectComposer,
|
|
32
|
-
RenderPass,
|
|
33
|
-
ShaderPass
|
|
34
|
-
}), []);
|
|
35
|
-
const composer = React.useRef();
|
|
36
|
-
const {
|
|
37
|
-
scene,
|
|
38
|
-
camera,
|
|
39
|
-
gl,
|
|
40
|
-
size,
|
|
41
|
-
viewport
|
|
42
|
-
} = useThree();
|
|
43
|
-
const [target] = React.useState(() => {
|
|
44
|
-
const t = new WebGLRenderTarget(size.width, size.height, {
|
|
45
|
-
type: type || HalfFloatType,
|
|
46
|
-
format: RGBAFormat,
|
|
47
|
-
depthBuffer,
|
|
48
|
-
stencilBuffer,
|
|
49
|
-
anisotropy
|
|
50
|
-
}); // sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
51
|
-
|
|
52
|
-
if (type === UnsignedByteType && encoding != null) {
|
|
53
|
-
if ('colorSpace' in t) t.texture.colorSpace = encoding;else t.texture.encoding = encoding;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
t.samples = multisamping;
|
|
57
|
-
return t;
|
|
58
|
-
});
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
var _composer$current, _composer$current2;
|
|
61
|
-
|
|
62
|
-
(_composer$current = composer.current) == null ? void 0 : _composer$current.setSize(size.width, size.height);
|
|
63
|
-
(_composer$current2 = composer.current) == null ? void 0 : _composer$current2.setPixelRatio(viewport.dpr);
|
|
64
|
-
}, [gl, size, viewport.dpr]);
|
|
65
|
-
useFrame(() => {
|
|
66
|
-
var _composer$current3;
|
|
67
|
-
|
|
68
|
-
if (!disableRender) (_composer$current3 = composer.current) == null ? void 0 : _composer$current3.render();
|
|
69
|
-
}, renderIndex);
|
|
70
|
-
const passes = [];
|
|
71
|
-
if (!disableRenderPass) passes.push( /*#__PURE__*/React.createElement("renderPass", {
|
|
72
|
-
key: "renderpass",
|
|
73
|
-
attach: `passes-${passes.length}`,
|
|
74
|
-
args: [scene, camera]
|
|
75
|
-
}));
|
|
76
|
-
if (!disableGamma) passes.push( /*#__PURE__*/React.createElement("shaderPass", {
|
|
77
|
-
attach: `passes-${passes.length}`,
|
|
78
|
-
key: "gammapass",
|
|
79
|
-
args: [GammaCorrectionShader]
|
|
80
|
-
}));
|
|
81
|
-
React.Children.forEach(children, el => {
|
|
82
|
-
el && passes.push( /*#__PURE__*/React.cloneElement(el, {
|
|
83
|
-
key: passes.length,
|
|
84
|
-
attach: `passes-${passes.length}`
|
|
85
|
-
}));
|
|
86
|
-
});
|
|
87
|
-
return /*#__PURE__*/React.createElement("effectComposer", _extends({
|
|
88
|
-
ref: mergeRefs([ref, composer]),
|
|
89
|
-
args: [gl, target]
|
|
90
|
-
}, props), passes);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
export { Effects, isWebGL2Available };
|
package/src/core/Environment.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useThree, useFrame, createPortal, extend } from '@react-three/fiber';
|
|
4
|
-
import { Scene, WebGLCubeRenderTarget, HalfFloatType } from 'three';
|
|
5
|
-
import { GroundProjectedEnv } from 'three-stdlib';
|
|
6
|
-
import { useEnvironment } from './useEnvironment.js';
|
|
7
|
-
|
|
8
|
-
const isRef = obj => obj.current && obj.current.isScene;
|
|
9
|
-
|
|
10
|
-
const resolveScene = scene => isRef(scene) ? scene.current : scene;
|
|
11
|
-
|
|
12
|
-
function setEnvProps(background, scene, defaultScene, texture, blur = 0) {
|
|
13
|
-
const target = resolveScene(scene || defaultScene);
|
|
14
|
-
const oldbg = target.background;
|
|
15
|
-
const oldenv = target.environment; // @ts-ignore
|
|
16
|
-
|
|
17
|
-
const oldBlur = target.backgroundBlurriness || 0;
|
|
18
|
-
if (background !== 'only') target.environment = texture;
|
|
19
|
-
if (background) target.background = texture; // @ts-ignore
|
|
20
|
-
|
|
21
|
-
if (background && target.backgroundBlurriness !== undefined) target.backgroundBlurriness = blur;
|
|
22
|
-
return () => {
|
|
23
|
-
if (background !== 'only') target.environment = oldenv;
|
|
24
|
-
if (background) target.background = oldbg; // @ts-ignore
|
|
25
|
-
|
|
26
|
-
if (background && target.backgroundBlurriness !== undefined) target.backgroundBlurriness = oldBlur;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function EnvironmentMap({
|
|
31
|
-
scene,
|
|
32
|
-
background = false,
|
|
33
|
-
blur,
|
|
34
|
-
map
|
|
35
|
-
}) {
|
|
36
|
-
const defaultScene = useThree(state => state.scene);
|
|
37
|
-
React.useLayoutEffect(() => {
|
|
38
|
-
if (map) return setEnvProps(background, scene, defaultScene, map, blur);
|
|
39
|
-
}, [defaultScene, scene, map, background, blur]);
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
function EnvironmentCube({
|
|
43
|
-
background = false,
|
|
44
|
-
scene,
|
|
45
|
-
blur,
|
|
46
|
-
...rest
|
|
47
|
-
}) {
|
|
48
|
-
const texture = useEnvironment(rest);
|
|
49
|
-
const defaultScene = useThree(state => state.scene);
|
|
50
|
-
React.useLayoutEffect(() => {
|
|
51
|
-
return setEnvProps(background, scene, defaultScene, texture, blur);
|
|
52
|
-
}, [texture, background, scene, defaultScene, blur]);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
function EnvironmentPortal({
|
|
56
|
-
children,
|
|
57
|
-
near = 1,
|
|
58
|
-
far = 1000,
|
|
59
|
-
resolution = 256,
|
|
60
|
-
frames = 1,
|
|
61
|
-
map,
|
|
62
|
-
background = false,
|
|
63
|
-
blur,
|
|
64
|
-
scene,
|
|
65
|
-
files,
|
|
66
|
-
path,
|
|
67
|
-
preset = undefined,
|
|
68
|
-
extensions
|
|
69
|
-
}) {
|
|
70
|
-
const gl = useThree(state => state.gl);
|
|
71
|
-
const defaultScene = useThree(state => state.scene);
|
|
72
|
-
const camera = React.useRef(null);
|
|
73
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
74
|
-
const fbo = React.useMemo(() => {
|
|
75
|
-
const fbo = new WebGLCubeRenderTarget(resolution);
|
|
76
|
-
fbo.texture.type = HalfFloatType;
|
|
77
|
-
return fbo;
|
|
78
|
-
}, [resolution]);
|
|
79
|
-
React.useLayoutEffect(() => {
|
|
80
|
-
if (frames === 1) camera.current.update(gl, virtualScene);
|
|
81
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, blur);
|
|
82
|
-
}, [children, virtualScene, fbo.texture, scene, defaultScene, background, frames, gl]);
|
|
83
|
-
let count = 1;
|
|
84
|
-
useFrame(() => {
|
|
85
|
-
if (frames === Infinity || count < frames) {
|
|
86
|
-
camera.current.update(gl, virtualScene);
|
|
87
|
-
count++;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement("cubeCamera", {
|
|
91
|
-
ref: camera,
|
|
92
|
-
args: [near, far, fbo]
|
|
93
|
-
}), files || preset ? /*#__PURE__*/React.createElement(EnvironmentCube, {
|
|
94
|
-
background: true,
|
|
95
|
-
files: files,
|
|
96
|
-
preset: preset,
|
|
97
|
-
path: path,
|
|
98
|
-
extensions: extensions
|
|
99
|
-
}) : map ? /*#__PURE__*/React.createElement(EnvironmentMap, {
|
|
100
|
-
background: true,
|
|
101
|
-
map: map,
|
|
102
|
-
extensions: extensions
|
|
103
|
-
}) : null), virtualScene));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function EnvironmentGround(props) {
|
|
107
|
-
var _props$ground, _props$ground2, _scale, _props$ground3;
|
|
108
|
-
|
|
109
|
-
const textureDefault = useEnvironment(props);
|
|
110
|
-
const texture = props.map || textureDefault;
|
|
111
|
-
React.useMemo(() => extend({
|
|
112
|
-
GroundProjectedEnvImpl: GroundProjectedEnv
|
|
113
|
-
}), []);
|
|
114
|
-
const args = React.useMemo(() => [texture], [texture]);
|
|
115
|
-
const height = (_props$ground = props.ground) == null ? void 0 : _props$ground.height;
|
|
116
|
-
const radius = (_props$ground2 = props.ground) == null ? void 0 : _props$ground2.radius;
|
|
117
|
-
const scale = (_scale = (_props$ground3 = props.ground) == null ? void 0 : _props$ground3.scale) !== null && _scale !== void 0 ? _scale : 1000;
|
|
118
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EnvironmentMap, _extends({}, props, {
|
|
119
|
-
map: texture
|
|
120
|
-
})), /*#__PURE__*/React.createElement("groundProjectedEnvImpl", {
|
|
121
|
-
args: args,
|
|
122
|
-
scale: scale,
|
|
123
|
-
height: height,
|
|
124
|
-
radius: radius
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function Environment(props) {
|
|
129
|
-
return props.ground ? /*#__PURE__*/React.createElement(EnvironmentGround, props) : props.map ? /*#__PURE__*/React.createElement(EnvironmentMap, props) : props.children ? /*#__PURE__*/React.createElement(EnvironmentPortal, props) : /*#__PURE__*/React.createElement(EnvironmentCube, props);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal };
|