@react-three/drei 9.74.13 → 9.74.14
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 +2 -3
- 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
package/src/core/Grid.js
DELETED
|
@@ -1,112 +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 { extend } from '@react-three/fiber';
|
|
5
|
-
import { shaderMaterial } from './shaderMaterial.js';
|
|
6
|
-
|
|
7
|
-
const GridMaterial = shaderMaterial({
|
|
8
|
-
cellSize: 0.5,
|
|
9
|
-
sectionSize: 1,
|
|
10
|
-
fadeDistance: 100,
|
|
11
|
-
fadeStrength: 1,
|
|
12
|
-
cellThickness: 0.5,
|
|
13
|
-
sectionThickness: 1,
|
|
14
|
-
cellColor: new THREE.Color(),
|
|
15
|
-
sectionColor: new THREE.Color(),
|
|
16
|
-
infiniteGrid: false,
|
|
17
|
-
followCamera: false
|
|
18
|
-
},
|
|
19
|
-
/* glsl */
|
|
20
|
-
`
|
|
21
|
-
varying vec3 worldPosition;
|
|
22
|
-
uniform float fadeDistance;
|
|
23
|
-
uniform bool infiniteGrid;
|
|
24
|
-
uniform bool followCamera;
|
|
25
|
-
|
|
26
|
-
void main() {
|
|
27
|
-
worldPosition = position.xzy;
|
|
28
|
-
if (infiniteGrid) worldPosition *= 1.0 + fadeDistance;
|
|
29
|
-
if (followCamera) worldPosition.xz +=cameraPosition.xz;
|
|
30
|
-
|
|
31
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
|
|
32
|
-
}
|
|
33
|
-
`,
|
|
34
|
-
/* glsl */
|
|
35
|
-
`
|
|
36
|
-
varying vec3 worldPosition;
|
|
37
|
-
uniform float cellSize;
|
|
38
|
-
uniform float sectionSize;
|
|
39
|
-
uniform vec3 cellColor;
|
|
40
|
-
uniform vec3 sectionColor;
|
|
41
|
-
uniform float fadeDistance;
|
|
42
|
-
uniform float fadeStrength;
|
|
43
|
-
uniform float cellThickness;
|
|
44
|
-
uniform float sectionThickness;
|
|
45
|
-
|
|
46
|
-
float getGrid(float size, float thickness) {
|
|
47
|
-
vec2 r = worldPosition.xz / size;
|
|
48
|
-
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
|
49
|
-
float line = min(grid.x, grid.y) + 1. - thickness;
|
|
50
|
-
return 1.0 - min(line, 1.);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void main() {
|
|
54
|
-
float g1 = getGrid(cellSize, cellThickness);
|
|
55
|
-
float g2 = getGrid(sectionSize, sectionThickness);
|
|
56
|
-
|
|
57
|
-
float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / fadeDistance, 1.);
|
|
58
|
-
vec3 color = mix(cellColor, sectionColor, min(1.,sectionThickness * g2));
|
|
59
|
-
|
|
60
|
-
gl_FragColor = vec4(color, (g1 + g2) * pow(d,fadeStrength));
|
|
61
|
-
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
|
|
62
|
-
if (gl_FragColor.a <= 0.0) discard;
|
|
63
|
-
|
|
64
|
-
#include <tonemapping_fragment>
|
|
65
|
-
#include <encodings_fragment>
|
|
66
|
-
}
|
|
67
|
-
`);
|
|
68
|
-
const Grid = /*#__PURE__*/React.forwardRef(({
|
|
69
|
-
args,
|
|
70
|
-
cellColor = '#000000',
|
|
71
|
-
sectionColor = '#2080ff',
|
|
72
|
-
cellSize = 0.5,
|
|
73
|
-
sectionSize = 1,
|
|
74
|
-
followCamera = false,
|
|
75
|
-
infiniteGrid = false,
|
|
76
|
-
fadeDistance = 100,
|
|
77
|
-
fadeStrength = 1,
|
|
78
|
-
cellThickness = 0.5,
|
|
79
|
-
sectionThickness = 1,
|
|
80
|
-
side = THREE.BackSide,
|
|
81
|
-
...props
|
|
82
|
-
}, fRef) => {
|
|
83
|
-
extend({
|
|
84
|
-
GridMaterial
|
|
85
|
-
});
|
|
86
|
-
const uniforms1 = {
|
|
87
|
-
cellSize,
|
|
88
|
-
sectionSize,
|
|
89
|
-
cellColor,
|
|
90
|
-
sectionColor,
|
|
91
|
-
cellThickness,
|
|
92
|
-
sectionThickness
|
|
93
|
-
};
|
|
94
|
-
const uniforms2 = {
|
|
95
|
-
fadeDistance,
|
|
96
|
-
fadeStrength,
|
|
97
|
-
infiniteGrid,
|
|
98
|
-
followCamera
|
|
99
|
-
};
|
|
100
|
-
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
101
|
-
ref: fRef,
|
|
102
|
-
frustumCulled: false
|
|
103
|
-
}, props), /*#__PURE__*/React.createElement("gridMaterial", _extends({
|
|
104
|
-
transparent: true,
|
|
105
|
-
"extensions-derivatives": true,
|
|
106
|
-
side: side
|
|
107
|
-
}, uniforms1, uniforms2)), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
108
|
-
args: args
|
|
109
|
-
}));
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export { Grid };
|
package/src/core/Hud.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { useThree, createPortal, useFrame } from '@react-three/fiber';
|
|
4
|
-
|
|
5
|
-
function RenderHud({
|
|
6
|
-
defaultScene,
|
|
7
|
-
defaultCamera,
|
|
8
|
-
renderPriority = 1
|
|
9
|
-
}) {
|
|
10
|
-
const {
|
|
11
|
-
gl,
|
|
12
|
-
scene,
|
|
13
|
-
camera
|
|
14
|
-
} = useThree();
|
|
15
|
-
let oldCLear;
|
|
16
|
-
useFrame(() => {
|
|
17
|
-
oldCLear = gl.autoClear;
|
|
18
|
-
|
|
19
|
-
if (renderPriority === 1) {
|
|
20
|
-
// Clear scene and render the default scene
|
|
21
|
-
gl.autoClear = true;
|
|
22
|
-
gl.render(defaultScene, defaultCamera);
|
|
23
|
-
} // Disable cleaning and render the portal with its own camera
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
gl.autoClear = false;
|
|
27
|
-
gl.clearDepth();
|
|
28
|
-
gl.render(scene, camera); // Restore default
|
|
29
|
-
|
|
30
|
-
gl.autoClear = oldCLear;
|
|
31
|
-
}, renderPriority); // Without an element that receives pointer events state.pointer will always be 0/0
|
|
32
|
-
|
|
33
|
-
return /*#__PURE__*/React.createElement("group", {
|
|
34
|
-
onPointerOver: () => null
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function Hud({
|
|
39
|
-
children,
|
|
40
|
-
renderPriority = 1
|
|
41
|
-
}) {
|
|
42
|
-
const {
|
|
43
|
-
scene: defaultScene,
|
|
44
|
-
camera: defaultCamera
|
|
45
|
-
} = useThree();
|
|
46
|
-
const [hudScene] = React.useState(() => new THREE.Scene());
|
|
47
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(RenderHud, {
|
|
48
|
-
defaultScene: defaultScene,
|
|
49
|
-
defaultCamera: defaultCamera,
|
|
50
|
-
renderPriority: renderPriority
|
|
51
|
-
})), hudScene, {
|
|
52
|
-
events: {
|
|
53
|
-
priority: renderPriority + 1
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { Hud };
|
package/src/core/Image.js
DELETED
|
@@ -1,119 +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 { extend } from '@react-three/fiber';
|
|
5
|
-
import { shaderMaterial } from './shaderMaterial.js';
|
|
6
|
-
import { useTexture } from './useTexture.js';
|
|
7
|
-
|
|
8
|
-
const ImageMaterialImpl = shaderMaterial({
|
|
9
|
-
color: new THREE.Color('white'),
|
|
10
|
-
scale: [1, 1],
|
|
11
|
-
imageBounds: [1, 1],
|
|
12
|
-
map: null,
|
|
13
|
-
zoom: 1,
|
|
14
|
-
grayscale: 0,
|
|
15
|
-
opacity: 1
|
|
16
|
-
},
|
|
17
|
-
/* glsl */
|
|
18
|
-
`
|
|
19
|
-
varying vec2 vUv;
|
|
20
|
-
void main() {
|
|
21
|
-
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
|
|
22
|
-
vUv = uv;
|
|
23
|
-
}
|
|
24
|
-
`,
|
|
25
|
-
/* glsl */
|
|
26
|
-
`
|
|
27
|
-
// mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44
|
|
28
|
-
varying vec2 vUv;
|
|
29
|
-
uniform vec2 scale;
|
|
30
|
-
uniform vec2 imageBounds;
|
|
31
|
-
uniform vec3 color;
|
|
32
|
-
uniform sampler2D map;
|
|
33
|
-
uniform float zoom;
|
|
34
|
-
uniform float grayscale;
|
|
35
|
-
uniform float opacity;
|
|
36
|
-
const vec3 luma = vec3(.299, 0.587, 0.114);
|
|
37
|
-
vec4 toGrayscale(vec4 color, float intensity) {
|
|
38
|
-
return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a);
|
|
39
|
-
}
|
|
40
|
-
vec2 aspect(vec2 size) {
|
|
41
|
-
return size / min(size.x, size.y);
|
|
42
|
-
}
|
|
43
|
-
void main() {
|
|
44
|
-
vec2 s = aspect(scale);
|
|
45
|
-
vec2 i = aspect(imageBounds);
|
|
46
|
-
float rs = s.x / s.y;
|
|
47
|
-
float ri = i.x / i.y;
|
|
48
|
-
vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);
|
|
49
|
-
vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;
|
|
50
|
-
vec2 uv = vUv * s / new + offset;
|
|
51
|
-
vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5);
|
|
52
|
-
gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity), grayscale);
|
|
53
|
-
|
|
54
|
-
#include <tonemapping_fragment>
|
|
55
|
-
#include <encodings_fragment>
|
|
56
|
-
}
|
|
57
|
-
`);
|
|
58
|
-
const ImageBase = /*#__PURE__*/React.forwardRef(({
|
|
59
|
-
children,
|
|
60
|
-
color,
|
|
61
|
-
segments = 1,
|
|
62
|
-
scale = 1,
|
|
63
|
-
zoom = 1,
|
|
64
|
-
grayscale = 0,
|
|
65
|
-
opacity = 1,
|
|
66
|
-
texture,
|
|
67
|
-
toneMapped,
|
|
68
|
-
transparent,
|
|
69
|
-
...props
|
|
70
|
-
}, ref) => {
|
|
71
|
-
extend({
|
|
72
|
-
ImageMaterial: ImageMaterialImpl
|
|
73
|
-
});
|
|
74
|
-
const planeBounds = Array.isArray(scale) ? [scale[0], scale[1]] : [scale, scale];
|
|
75
|
-
const imageBounds = [texture.image.width, texture.image.height];
|
|
76
|
-
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
77
|
-
ref: ref,
|
|
78
|
-
scale: Array.isArray(scale) ? [...scale, 1] : scale
|
|
79
|
-
}, props), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
80
|
-
args: [1, 1, segments, segments]
|
|
81
|
-
}), /*#__PURE__*/React.createElement("imageMaterial", {
|
|
82
|
-
color: color,
|
|
83
|
-
map: texture,
|
|
84
|
-
zoom: zoom,
|
|
85
|
-
grayscale: grayscale,
|
|
86
|
-
opacity: opacity,
|
|
87
|
-
scale: planeBounds,
|
|
88
|
-
imageBounds: imageBounds,
|
|
89
|
-
toneMapped: toneMapped,
|
|
90
|
-
transparent: transparent
|
|
91
|
-
}), children);
|
|
92
|
-
});
|
|
93
|
-
const ImageWithUrl = /*#__PURE__*/React.forwardRef(({
|
|
94
|
-
url,
|
|
95
|
-
...props
|
|
96
|
-
}, ref) => {
|
|
97
|
-
const texture = useTexture(url);
|
|
98
|
-
return /*#__PURE__*/React.createElement(ImageBase, _extends({}, props, {
|
|
99
|
-
texture: texture,
|
|
100
|
-
ref: ref
|
|
101
|
-
}));
|
|
102
|
-
});
|
|
103
|
-
const ImageWithTexture = /*#__PURE__*/React.forwardRef(({
|
|
104
|
-
url: _url,
|
|
105
|
-
...props
|
|
106
|
-
}, ref) => {
|
|
107
|
-
return /*#__PURE__*/React.createElement(ImageBase, _extends({}, props, {
|
|
108
|
-
ref: ref
|
|
109
|
-
}));
|
|
110
|
-
});
|
|
111
|
-
const Image = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
112
|
-
if (props.url) return /*#__PURE__*/React.createElement(ImageWithUrl, _extends({}, props, {
|
|
113
|
-
ref: ref
|
|
114
|
-
}));else if (props.texture) return /*#__PURE__*/React.createElement(ImageWithTexture, _extends({}, props, {
|
|
115
|
-
ref: ref
|
|
116
|
-
}));else throw new Error('<Image /> requires a url or texture');
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
export { Image };
|
package/src/core/Instances.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { extend, useFrame } from '@react-three/fiber';
|
|
5
|
-
import mergeRefs from 'react-merge-refs';
|
|
6
|
-
import Composer from 'react-composer';
|
|
7
|
-
|
|
8
|
-
const _instanceLocalMatrix = /*@__PURE__*/new THREE.Matrix4();
|
|
9
|
-
|
|
10
|
-
const _instanceWorldMatrix = /*@__PURE__*/new THREE.Matrix4();
|
|
11
|
-
|
|
12
|
-
const _instanceIntersects = [];
|
|
13
|
-
|
|
14
|
-
const _mesh = /*@__PURE__*/new THREE.Mesh();
|
|
15
|
-
|
|
16
|
-
class PositionMesh extends THREE.Group {
|
|
17
|
-
constructor() {
|
|
18
|
-
super();
|
|
19
|
-
this.color = new THREE.Color('white');
|
|
20
|
-
this.instance = {
|
|
21
|
-
current: undefined
|
|
22
|
-
};
|
|
23
|
-
this.instanceKey = {
|
|
24
|
-
current: undefined
|
|
25
|
-
};
|
|
26
|
-
} // This will allow the virtual instance have bounds
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
get geometry() {
|
|
30
|
-
var _this$instance$curren;
|
|
31
|
-
|
|
32
|
-
return (_this$instance$curren = this.instance.current) == null ? void 0 : _this$instance$curren.geometry;
|
|
33
|
-
} // And this will allow the virtual instance to receive events
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
raycast(raycaster, intersects) {
|
|
37
|
-
const parent = this.instance.current;
|
|
38
|
-
if (!parent) return;
|
|
39
|
-
if (!parent.geometry || !parent.material) return;
|
|
40
|
-
_mesh.geometry = parent.geometry;
|
|
41
|
-
const matrixWorld = parent.matrixWorld;
|
|
42
|
-
const instanceId = parent.userData.instances.indexOf(this.instanceKey); // If the instance wasn't found or exceeds the parents draw range, bail out
|
|
43
|
-
|
|
44
|
-
if (instanceId === -1 || instanceId > parent.count) return; // calculate the world matrix for each instance
|
|
45
|
-
|
|
46
|
-
parent.getMatrixAt(instanceId, _instanceLocalMatrix);
|
|
47
|
-
|
|
48
|
-
_instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix); // the mesh represents this single instance
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_mesh.matrixWorld = _instanceWorldMatrix; // raycast side according to instance material
|
|
52
|
-
|
|
53
|
-
if (parent.material instanceof THREE.Material) _mesh.material.side = parent.material.side;else _mesh.material.side = parent.material[0].side;
|
|
54
|
-
|
|
55
|
-
_mesh.raycast(raycaster, _instanceIntersects); // process the result of raycast
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (let i = 0, l = _instanceIntersects.length; i < l; i++) {
|
|
59
|
-
const intersect = _instanceIntersects[i];
|
|
60
|
-
intersect.instanceId = instanceId;
|
|
61
|
-
intersect.object = this;
|
|
62
|
-
intersects.push(intersect);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_instanceIntersects.length = 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const globalContext = /*@__PURE__*/React.createContext(null);
|
|
71
|
-
const parentMatrix = /*@__PURE__*/new THREE.Matrix4();
|
|
72
|
-
const instanceMatrix = /*@__PURE__*/new THREE.Matrix4();
|
|
73
|
-
const tempMatrix = /*@__PURE__*/new THREE.Matrix4();
|
|
74
|
-
const translation = /*@__PURE__*/new THREE.Vector3();
|
|
75
|
-
const rotation = /*@__PURE__*/new THREE.Quaternion();
|
|
76
|
-
const scale = /*@__PURE__*/new THREE.Vector3();
|
|
77
|
-
const Instance = /*#__PURE__*/React.forwardRef(({
|
|
78
|
-
context,
|
|
79
|
-
children,
|
|
80
|
-
...props
|
|
81
|
-
}, ref) => {
|
|
82
|
-
React.useMemo(() => extend({
|
|
83
|
-
PositionMesh
|
|
84
|
-
}), []);
|
|
85
|
-
const group = React.useRef();
|
|
86
|
-
const {
|
|
87
|
-
subscribe,
|
|
88
|
-
getParent
|
|
89
|
-
} = React.useContext(context || globalContext);
|
|
90
|
-
React.useLayoutEffect(() => subscribe(group), []);
|
|
91
|
-
return /*#__PURE__*/React.createElement("positionMesh", _extends({
|
|
92
|
-
instance: getParent(),
|
|
93
|
-
instanceKey: group,
|
|
94
|
-
ref: mergeRefs([ref, group])
|
|
95
|
-
}, props), children);
|
|
96
|
-
});
|
|
97
|
-
const Instances = /*#__PURE__*/React.forwardRef(({
|
|
98
|
-
children,
|
|
99
|
-
range,
|
|
100
|
-
limit = 1000,
|
|
101
|
-
frames = Infinity,
|
|
102
|
-
...props
|
|
103
|
-
}, ref) => {
|
|
104
|
-
const [{
|
|
105
|
-
context,
|
|
106
|
-
instance
|
|
107
|
-
}] = React.useState(() => {
|
|
108
|
-
const context = /*#__PURE__*/React.createContext(null);
|
|
109
|
-
return {
|
|
110
|
-
context,
|
|
111
|
-
instance: /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(Instance, _extends({
|
|
112
|
-
context: context
|
|
113
|
-
}, props, {
|
|
114
|
-
ref: ref
|
|
115
|
-
})))
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
const parentRef = React.useRef(null);
|
|
119
|
-
const [instances, setInstances] = React.useState([]);
|
|
120
|
-
const [[matrices, colors]] = React.useState(() => {
|
|
121
|
-
const mArray = new Float32Array(limit * 16);
|
|
122
|
-
|
|
123
|
-
for (let i = 0; i < limit; i++) tempMatrix.identity().toArray(mArray, i * 16);
|
|
124
|
-
|
|
125
|
-
return [mArray, new Float32Array([...new Array(limit * 3)].map(() => 1))];
|
|
126
|
-
});
|
|
127
|
-
React.useEffect(() => {
|
|
128
|
-
// We might be a frame too late? 🤷♂️
|
|
129
|
-
parentRef.current.instanceMatrix.needsUpdate = true;
|
|
130
|
-
});
|
|
131
|
-
let count = 0;
|
|
132
|
-
let updateRange = 0;
|
|
133
|
-
useFrame(() => {
|
|
134
|
-
if (frames === Infinity || count < frames) {
|
|
135
|
-
parentRef.current.updateMatrix();
|
|
136
|
-
parentRef.current.updateMatrixWorld();
|
|
137
|
-
parentMatrix.copy(parentRef.current.matrixWorld).invert();
|
|
138
|
-
updateRange = Math.min(limit, range !== undefined ? range : limit, instances.length);
|
|
139
|
-
parentRef.current.count = updateRange;
|
|
140
|
-
parentRef.current.instanceMatrix.updateRange.count = updateRange * 16;
|
|
141
|
-
parentRef.current.instanceColor.updateRange.count = updateRange * 3;
|
|
142
|
-
|
|
143
|
-
for (let i = 0; i < instances.length; i++) {
|
|
144
|
-
const instance = instances[i].current; // Multiply the inverse of the InstancedMesh world matrix or else
|
|
145
|
-
// Instances will be double-transformed if <Instances> isn't at identity
|
|
146
|
-
|
|
147
|
-
instance.matrixWorld.decompose(translation, rotation, scale);
|
|
148
|
-
instanceMatrix.compose(translation, rotation, scale).premultiply(parentMatrix);
|
|
149
|
-
instanceMatrix.toArray(matrices, i * 16);
|
|
150
|
-
parentRef.current.instanceMatrix.needsUpdate = true;
|
|
151
|
-
instance.color.toArray(colors, i * 3);
|
|
152
|
-
parentRef.current.instanceColor.needsUpdate = true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
count++;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
const api = React.useMemo(() => ({
|
|
159
|
-
getParent: () => parentRef,
|
|
160
|
-
subscribe: ref => {
|
|
161
|
-
setInstances(instances => [...instances, ref]);
|
|
162
|
-
return () => setInstances(instances => instances.filter(item => item.current !== ref.current));
|
|
163
|
-
}
|
|
164
|
-
}), []);
|
|
165
|
-
return /*#__PURE__*/React.createElement("instancedMesh", _extends({
|
|
166
|
-
userData: {
|
|
167
|
-
instances
|
|
168
|
-
},
|
|
169
|
-
matrixAutoUpdate: false,
|
|
170
|
-
ref: mergeRefs([ref, parentRef]),
|
|
171
|
-
args: [null, null, 0],
|
|
172
|
-
raycast: () => null
|
|
173
|
-
}, props), /*#__PURE__*/React.createElement("instancedBufferAttribute", {
|
|
174
|
-
attach: "instanceMatrix",
|
|
175
|
-
count: matrices.length / 16,
|
|
176
|
-
array: matrices,
|
|
177
|
-
itemSize: 16,
|
|
178
|
-
usage: THREE.DynamicDrawUsage
|
|
179
|
-
}), /*#__PURE__*/React.createElement("instancedBufferAttribute", {
|
|
180
|
-
attach: "instanceColor",
|
|
181
|
-
count: colors.length / 3,
|
|
182
|
-
array: colors,
|
|
183
|
-
itemSize: 3,
|
|
184
|
-
usage: THREE.DynamicDrawUsage
|
|
185
|
-
}), typeof children === 'function' ? /*#__PURE__*/React.createElement(context.Provider, {
|
|
186
|
-
value: api
|
|
187
|
-
}, children(instance)) : /*#__PURE__*/React.createElement(globalContext.Provider, {
|
|
188
|
-
value: api
|
|
189
|
-
}, children));
|
|
190
|
-
});
|
|
191
|
-
const Merged = /*#__PURE__*/React.forwardRef(function Merged({
|
|
192
|
-
meshes,
|
|
193
|
-
children,
|
|
194
|
-
...props
|
|
195
|
-
}, ref) {
|
|
196
|
-
const isArray = Array.isArray(meshes); // Filter out meshes from collections, which may contain non-meshes
|
|
197
|
-
|
|
198
|
-
if (!isArray) for (const key of Object.keys(meshes)) if (!meshes[key].isMesh) delete meshes[key];
|
|
199
|
-
return /*#__PURE__*/React.createElement("group", {
|
|
200
|
-
ref: ref
|
|
201
|
-
}, /*#__PURE__*/React.createElement(Composer, {
|
|
202
|
-
components: (isArray ? meshes : Object.values(meshes)).map(({
|
|
203
|
-
geometry,
|
|
204
|
-
material
|
|
205
|
-
}) => /*#__PURE__*/React.createElement(Instances, _extends({
|
|
206
|
-
key: geometry.uuid,
|
|
207
|
-
geometry: geometry,
|
|
208
|
-
material: material
|
|
209
|
-
}, props)))
|
|
210
|
-
}, args => isArray ? children(...args) : children(Object.keys(meshes).filter(key => meshes[key].isMesh).reduce((acc, key, i) => ({ ...acc,
|
|
211
|
-
[key]: args[i]
|
|
212
|
-
}), {}))));
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
export { Instance, Instances, Merged };
|
package/src/core/Lightformer.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import { applyProps } from '@react-three/fiber';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
import mergeRefs from 'react-merge-refs';
|
|
6
|
-
|
|
7
|
-
const Lightformer = /*#__PURE__*/React.forwardRef(({
|
|
8
|
-
args,
|
|
9
|
-
map,
|
|
10
|
-
toneMapped = false,
|
|
11
|
-
color = 'white',
|
|
12
|
-
form: Form = 'rect',
|
|
13
|
-
intensity = 1,
|
|
14
|
-
scale = 1,
|
|
15
|
-
target,
|
|
16
|
-
children,
|
|
17
|
-
...props
|
|
18
|
-
}, forwardRef) => {
|
|
19
|
-
// Apply emissive power
|
|
20
|
-
const ref = React.useRef(null);
|
|
21
|
-
React.useLayoutEffect(() => {
|
|
22
|
-
if (!children && !props.material) {
|
|
23
|
-
applyProps(ref.current.material, {
|
|
24
|
-
color
|
|
25
|
-
});
|
|
26
|
-
ref.current.material.color.multiplyScalar(intensity);
|
|
27
|
-
}
|
|
28
|
-
}, [color, intensity, children, props.material]); // Target light
|
|
29
|
-
|
|
30
|
-
React.useLayoutEffect(() => {
|
|
31
|
-
if (target) ref.current.lookAt(Array.isArray(target) ? new THREE.Vector3(...target) : target);
|
|
32
|
-
}, [target]); // Fix 2-dimensional scale
|
|
33
|
-
|
|
34
|
-
scale = Array.isArray(scale) && scale.length === 2 ? [scale[0], scale[1], 1] : scale;
|
|
35
|
-
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
36
|
-
ref: mergeRefs([ref, forwardRef]),
|
|
37
|
-
scale: scale
|
|
38
|
-
}, props), Form === 'circle' ? /*#__PURE__*/React.createElement("ringGeometry", {
|
|
39
|
-
args: [0, 1, 64]
|
|
40
|
-
}) : Form === 'ring' ? /*#__PURE__*/React.createElement("ringGeometry", {
|
|
41
|
-
args: [0.5, 1, 64]
|
|
42
|
-
}) : Form === 'rect' ? /*#__PURE__*/React.createElement("planeGeometry", null) : /*#__PURE__*/React.createElement(Form, {
|
|
43
|
-
args: args
|
|
44
|
-
}), children ? children : !props.material ? /*#__PURE__*/React.createElement("meshBasicMaterial", {
|
|
45
|
-
toneMapped: toneMapped,
|
|
46
|
-
map: map,
|
|
47
|
-
side: THREE.DoubleSide
|
|
48
|
-
}) : null);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export { Lightformer };
|
package/src/core/Line.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Vector3, Vector2, Color } from 'three';
|
|
4
|
-
import { useThree } from '@react-three/fiber';
|
|
5
|
-
import { LineSegments2, Line2, LineMaterial, LineSegmentsGeometry, LineGeometry } from 'three-stdlib';
|
|
6
|
-
|
|
7
|
-
const Line = /*#__PURE__*/React.forwardRef(function Line({
|
|
8
|
-
points,
|
|
9
|
-
color = 'black',
|
|
10
|
-
vertexColors,
|
|
11
|
-
linewidth,
|
|
12
|
-
lineWidth,
|
|
13
|
-
segments,
|
|
14
|
-
dashed,
|
|
15
|
-
...rest
|
|
16
|
-
}, ref) {
|
|
17
|
-
const size = useThree(state => state.size);
|
|
18
|
-
const line2 = React.useMemo(() => segments ? new LineSegments2() : new Line2(), [segments]);
|
|
19
|
-
const [lineMaterial] = React.useState(() => new LineMaterial());
|
|
20
|
-
const lineGeom = React.useMemo(() => {
|
|
21
|
-
const geom = segments ? new LineSegmentsGeometry() : new LineGeometry();
|
|
22
|
-
const pValues = points.map(p => {
|
|
23
|
-
const isArray = Array.isArray(p);
|
|
24
|
-
return p instanceof Vector3 ? [p.x, p.y, p.z] : p instanceof Vector2 ? [p.x, p.y, 0] : isArray && p.length === 3 ? [p[0], p[1], p[2]] : isArray && p.length === 2 ? [p[0], p[1], 0] : p;
|
|
25
|
-
});
|
|
26
|
-
geom.setPositions(pValues.flat());
|
|
27
|
-
|
|
28
|
-
if (vertexColors) {
|
|
29
|
-
const cValues = vertexColors.map(c => c instanceof Color ? c.toArray() : c);
|
|
30
|
-
geom.setColors(cValues.flat());
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return geom;
|
|
34
|
-
}, [points, segments, vertexColors]);
|
|
35
|
-
React.useLayoutEffect(() => {
|
|
36
|
-
line2.computeLineDistances();
|
|
37
|
-
}, [points, line2]);
|
|
38
|
-
React.useLayoutEffect(() => {
|
|
39
|
-
if (dashed) {
|
|
40
|
-
lineMaterial.defines.USE_DASH = '';
|
|
41
|
-
} else {
|
|
42
|
-
// Setting lineMaterial.defines.USE_DASH to undefined is apparently not sufficient.
|
|
43
|
-
delete lineMaterial.defines.USE_DASH;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
lineMaterial.needsUpdate = true;
|
|
47
|
-
}, [dashed, lineMaterial]);
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
return () => lineGeom.dispose();
|
|
50
|
-
}, [lineGeom]);
|
|
51
|
-
return /*#__PURE__*/React.createElement("primitive", _extends({
|
|
52
|
-
object: line2,
|
|
53
|
-
ref: ref
|
|
54
|
-
}, rest), /*#__PURE__*/React.createElement("primitive", {
|
|
55
|
-
object: lineGeom,
|
|
56
|
-
attach: "geometry"
|
|
57
|
-
}), /*#__PURE__*/React.createElement("primitive", _extends({
|
|
58
|
-
object: lineMaterial,
|
|
59
|
-
attach: "material",
|
|
60
|
-
color: color,
|
|
61
|
-
vertexColors: Boolean(vertexColors),
|
|
62
|
-
resolution: [size.width, size.height],
|
|
63
|
-
linewidth: linewidth !== null && linewidth !== void 0 ? linewidth : lineWidth,
|
|
64
|
-
dashed: dashed
|
|
65
|
-
}, rest)));
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export { Line };
|
package/src/core/MapControls.js
DELETED
|
@@ -1,64 +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 { MapControls as MapControls$1 } from 'three-stdlib';
|
|
5
|
-
|
|
6
|
-
const MapControls = /*#__PURE__*/React.forwardRef((props = {
|
|
7
|
-
enableDamping: true
|
|
8
|
-
}, ref) => {
|
|
9
|
-
const {
|
|
10
|
-
domElement,
|
|
11
|
-
camera,
|
|
12
|
-
makeDefault,
|
|
13
|
-
onChange,
|
|
14
|
-
onStart,
|
|
15
|
-
onEnd,
|
|
16
|
-
...rest
|
|
17
|
-
} = props;
|
|
18
|
-
const invalidate = useThree(state => state.invalidate);
|
|
19
|
-
const defaultCamera = useThree(state => state.camera);
|
|
20
|
-
const gl = useThree(state => state.gl);
|
|
21
|
-
const events = useThree(state => state.events);
|
|
22
|
-
const set = useThree(state => state.set);
|
|
23
|
-
const get = useThree(state => state.get);
|
|
24
|
-
const explDomElement = domElement || events.connected || gl.domElement;
|
|
25
|
-
const explCamera = camera || defaultCamera;
|
|
26
|
-
const controls = React.useMemo(() => new MapControls$1(explCamera), [explCamera]);
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
controls.connect(explDomElement);
|
|
29
|
-
|
|
30
|
-
const callback = e => {
|
|
31
|
-
invalidate();
|
|
32
|
-
if (onChange) onChange(e);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
controls.addEventListener('change', callback);
|
|
36
|
-
if (onStart) controls.addEventListener('start', onStart);
|
|
37
|
-
if (onEnd) controls.addEventListener('end', onEnd);
|
|
38
|
-
return () => {
|
|
39
|
-
controls.dispose();
|
|
40
|
-
controls.removeEventListener('change', callback);
|
|
41
|
-
if (onStart) controls.removeEventListener('start', onStart);
|
|
42
|
-
if (onEnd) controls.removeEventListener('end', onEnd);
|
|
43
|
-
};
|
|
44
|
-
}, [onChange, onStart, onEnd, controls, invalidate, explDomElement]);
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
if (makeDefault) {
|
|
47
|
-
const old = get().controls;
|
|
48
|
-
set({
|
|
49
|
-
controls
|
|
50
|
-
});
|
|
51
|
-
return () => set({
|
|
52
|
-
controls: old
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}, [makeDefault, controls]);
|
|
56
|
-
useFrame(() => controls.update(), -1);
|
|
57
|
-
return /*#__PURE__*/React.createElement("primitive", _extends({
|
|
58
|
-
ref: ref,
|
|
59
|
-
object: controls,
|
|
60
|
-
enableDamping: true
|
|
61
|
-
}, rest));
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export { MapControls };
|