Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/abstractions/decal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sourcecode: src/core/Decal.tsx

Abstraction around Three's `DecalGeometry`. It will use the its parent `mesh` as the decal surface by default.

The decal box has to intersect the surface, otherwise it will not be visible. if you do not specifiy a rotation it will look at the parents center point. You can also pass a single number as the rotation which allows you to spin it.
The decal box has to intersect the surface, otherwise it will not be visible. if you do not specify a rotation it will look at the parents center point. You can also pass a single number as the rotation which allows you to spin it.

```js
<mesh>
Expand Down
2 changes: 1 addition & 1 deletion docs/abstractions/effects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SSAOPass } from "three-stdlib"

extend({ SSAOPass })

<Effects multisamping={8} renderIndex={1} disableGamma={false} disableRenderPass={false} disableRender={false}>
<Effects multisampling={8} renderIndex={1} disableGamma={false} disableRenderPass={false} disableRender={false}>
<sSAOPass args={[scene, camera, 100, 100]} kernelRadius={1.2} kernelSize={0} />
</Effects>
```
2 changes: 1 addition & 1 deletion docs/abstractions/splat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type SplatProps = {
<Splat src="https://huggingface.co/cakewalk/splat-data/resolve/main/nike.splat" />
```

In order to depth sort multiple splats correectly you can either use alphaTest, for instance with a low value. But keep in mind that this can show a slight outline under some viewing conditions.
In order to depth sort multiple splats correctly you can either use alphaTest, for instance with a low value. But keep in mind that this can show a slight outline under some viewing conditions.

```jsx
<Splat alphaTest={0.1} src="foo.splat" />
Expand Down
2 changes: 1 addition & 1 deletion docs/cameras/perspective-camera.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can also drive it manually, it won't be responsive and you have to calculate
<PerspectiveCamera manual aspect={...} onUpdate={(c) => c.updateProjectionMatrix()}>
```

You can use the PerspectiveCamera to film contents into a RenderTarget, similar to CubeCamera. As a child you must provide a render-function which receives the texture as its first argument. The result of that function will _not follow the camera_, instead it will be set invisible while the FBO renders so as to avoid issues where the meshes that receive the texture are interrering.
You can use the PerspectiveCamera to film contents into a RenderTarget, similar to CubeCamera. As a child you must provide a render-function which receives the texture as its first argument. The result of that function will _not follow the camera_, instead it will be set invisible while the FBO renders so as to avoid issues where the meshes that receive the texture are interfering.

```jsx
<PerspectiveCamera position={[0, 0, 10]}>
Expand Down
4 changes: 2 additions & 2 deletions docs/misc/html.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Html
sourceocde: src/web/Html.tsx
sourcecode: src/web/Html.tsx
---

[![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.vercel.app/?path=/story/misc-html--html-st) ![](https://img.shields.io/badge/-Dom only-red)
Expand Down Expand Up @@ -94,7 +94,7 @@ You can also give HTML material properties using the `material` prop.
/>
```

Enable shadows using the `castShadow` and `recieveShadow` prop.
Enable shadows using the `castShadow` and `receiveShadow` prop.

> Note: Shadows only work with a custom material. Shadows will not work with `meshBasicMaterial` and `shaderMaterial` by default.

Expand Down
2 changes: 1 addition & 1 deletion docs/misc/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Props = {
}
```

This component allows you to select/unselect objects by clicking on them. It keeps track of the currently selected objects and can select multiple objects (with the shift key). Nested components can request the current selection (which is always an array) with the `useSelect` hook. With the `box` prop it will let you shift-box-select objects by holding and draging the cursor over multiple objects. Optionally you can filter the selected items as well as define in which shape they are stored by defining the `filter` prop.
This component allows you to select/unselect objects by clicking on them. It keeps track of the currently selected objects and can select multiple objects (with the shift key). Nested components can request the current selection (which is always an array) with the `useSelect` hook. With the `box` prop it will let you shift-box-select objects by holding and dragging the cursor over multiple objects. Optionally you can filter the selected items as well as define in which shape they are stored by defining the `filter` prop.

```jsx
<Select box multiple onChange={console.log} filter={items => items}>
Expand Down
6 changes: 3 additions & 3 deletions docs/misc/wireframe.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Renders an Antialiased, shader based wireframe on or around a geometry.
fillOpacity={0.25} // Opacity of the inner fill
stroke={"#ff0000"} // Color of the stroke
strokeOpacity={1} // Opacity of the stroke
thickness={0.05} // Thinkness of the lines
thickness={0.05} // Thickness of the lines
colorBackfaces={false} // Whether to draw lines that are facing away from the camera
backfaceStroke={"#0000ff"} // Color of the lines that are facing away from the camera
dashInvert={true} // Invert the dashes
dash={false} // Whether to draw lines as dashes
dashRepeats={4} // Number of dashes in one seqment
dashRepeats={4} // Number of dashes in one segment
dashLength={0.5} // Length of each dash
squeeze={false} // Narrow the centers of each line segment
squeezeMin={0.2} // Smallest width to squueze to
squeezeMin={0.2} // Smallest width to squeeze to
squeezeMax={1} // Largest width to squeeze from
/>

Expand Down
4 changes: 2 additions & 2 deletions docs/modifiers/curve-modifier.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ useFrame(() => {
if (curveRef.current) {
// Move continuously along the curve
curveRef.current.moveAlongCurve(0.001)

// Move along the curve using the scrollbar
curveRef.current.uniforms.pathOffset.value = scroll.offset
}
Expand All @@ -39,7 +39,7 @@ type CurveModifierRef = {
curveArray: Curve<any>[];
curveLengthArray: number[];
object3D: TMesh;
splineTexure: DataTexture;
splineTexture: DataTexture;
uniforms: CurveModifierUniforms;
updateCurve<TCurve extends Curve<any>>(index: number, curve: TCurve): void;
moveAlongCurve(amount: number): void;
Expand Down
4 changes: 2 additions & 2 deletions docs/performances/instances.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void main() {
...
```

👉 Note: While creating instances declaratively keeps all the power of components with reduced draw calls, it comes at the cost of CPU overhead. For cases like foliage where you want no CPU overhead with thousands of intances you should use THREE.InstancedMesh such as in this [example](https://codesandbox.io/s/grass-shader-5xho4?file=/src/Grass.js).
👉 Note: While creating instances declaratively keeps all the power of components with reduced draw calls, it comes at the cost of CPU overhead. For cases like foliage where you want no CPU overhead with thousands of instances you should use THREE.InstancedMesh such as in this [example](https://codesandbox.io/s/grass-shader-5xho4?file=/src/Grass.js).

### Typed Instances

Expand All @@ -122,7 +122,7 @@ function App() {
<InstancedAttribute name="myCustomAttribute" defaultValue={1} />
<sphereGeometry />
<shaderMaterial
// will recienve myCustomAttribute as an attribute
// will receive myCustomAttribute as an attribute
vertexShader={`
attribute float myCustomAttribute;
void main() {
Expand Down
2 changes: 1 addition & 1 deletion docs/performances/performance-monitor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Since this would normally cause ping-ponging between the two callbacks you defin
type PerformanceMonitorProps = {
/** How much time in milliseconds to collect an average fps, 250 */
ms?: number
/** How many interations of averages to collect, 10 */
/** How many interactions of averages to collect, 10 */
iterations?: number
/** The percentage of iterations that are matched against the lower and upper bounds, 0.75 */
threshold?: number
Expand Down
2 changes: 1 addition & 1 deletion docs/performances/preload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Preload
sourcecode: src/core/Preload.tsx
---

The WebGLRenderer will compile materials only when they hit the frustrum, which can cause jank. This component precompiles the scene using [gl.compile](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.compile) which makes sure that your app is responsive from the get go.
The WebGLRenderer will compile materials only when they hit the frustum, which can cause jank. This component precompiles the scene using [gl.compile](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.compile) which makes sure that your app is responsive from the get go.

By default gl.compile will only preload visible objects, if you supply the `all` prop, it will circumvent that. With the `scene` and `camera` props you could also use it in portals.

Expand Down
2 changes: 1 addition & 1 deletion docs/portals/hud.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sourcecode: src/core/Hud.tsx
</li>
</Grid>

Renders a heads-up-display (HUD). Each HUD is a scene on top of the previous. That scene is inside a React `createPortal` and is completely isolated, you can have your own cameras in there, environments, etc. The first HUD (`renderpriotity === 1`) will clear the scene and render the default scene, it needs to be the first to execute! Make sure to be explicit about the `renderpriority` of your HUDs.
Renders a heads-up-display (HUD). Each HUD is a scene on top of the previous. That scene is inside a React `createPortal` and is completely isolated, you can have your own cameras in there, environments, etc. The first HUD (`renderpriority === 1`) will clear the scene and render the default scene, it needs to be the first to execute! Make sure to be explicit about the `renderpriority` of your HUDs.

```tsx
type HudProps = {
Expand Down
2 changes: 1 addition & 1 deletion docs/portals/mesh-portal-material.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type PortalProps = ThreeElements['shaderMaterial'] & {
eventPriority?: number
/** Optional render priority, defaults to 0 */
renderPriority?: number
/** Optionally diable events inside the portal, defaults to false */
/** Optionally disable events inside the portal, defaults to false */
events?: boolean
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/shaders/mesh-discard-material.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A material that renders nothing. In comparison to `<mesh visible={false}` it can

```jsx
<mesh castShadow>
<torusKnotGeonetry />
<torusKnotGeometry />
<MeshDiscardMaterial />
{/* Shadows and edges will show, but the model itself won't */}
<Edges />
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/accumulative-shadows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface AccumulativeContext {
getMesh: () => THREE.Mesh<THREE.PlaneGeometry, SoftShadowMaterialProps & THREE.ShaderMaterial>
/** Resets the buffers, starting from scratch */
reset: () => void
/** Updates the lightmap for a number of frames accumulartively */
/** Updates the lightmap for a number of frames accumulatively */
update: (frames?: number) => void
/** Allows children to subscribe. AccumulativeShadows will call child.update() in its own update function */
setLights: React.Dispatch<React.SetStateAction<AccumulativeLightContext[]>>
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/camera-shake.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sourcecode: src/core/CameraShake.tsx
</li>
</Grid>

A component for applying a configurable camera shake effect. Currently only supports rotational camera shake. Pass a ref to recieve the `ShakeController` API.
A component for applying a configurable camera shake effect. Currently only supports rotational camera shake. Pass a ref to receive the `ShakeController` API.

If you use shake in combination with controls make sure to set the `makeDefault` prop on your controls, in that case you do not have to pass them via the `controls` prop.

Expand Down
4 changes: 2 additions & 2 deletions docs/staging/caustics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type CausticsProps = ThreeElements['group'] & {
backsideIOR?: number
/** The texel size, default: 0.3125 */
worldRadius?: number
/** Intensity of the prjected caustics, default: 0.05 */
/** Intensity of the projected caustics, default: 0.05 */
intensity?: number
/** Caustics color, default: white */
color?: ReactThreeFiber.Color
Expand All @@ -43,7 +43,7 @@ type CausticsProps = ThreeElements['group'] & {

It will create a transparent plane that blends the caustics of the objects it receives into your scene. It will only render once and not take resources any longer!

Make sure to use the `debug` flag to help you stage your contents. Like ContactShadows and AccumulativeShadows the plane faces Y up. It is recommended to use [leva](https://github.com/pmndrs/leva) to configue the props above as some can be micro fractional depending on the models (intensity, worldRadius, ior and backsideIOR especially).
Make sure to use the `debug` flag to help you stage your contents. Like ContactShadows and AccumulativeShadows the plane faces Y up. It is recommended to use [leva](https://github.com/pmndrs/leva) to configure the props above as some can be micro fractional depending on the models (intensity, worldRadius, ior and backsideIOR especially).

```jsx
<Caustics debug backside lightSource={[2.5, 5, -2.5]}>
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/environment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Environment can also be ground projected, that is, put your model on the "ground
<Environment ground />
```

You can provide optional options to configure this projecion.
You can provide optional options to configure this projection.

```jsx
<Environment
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/randomized-light.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type RandomizedLightProps = ThreeElements['group'] & {
<RandomizedLight castShadow amount={8} frames={100} position={[5, 5, -10]} />
```

## Refernce api
## Reference api

```jsx
interface AccumulativeLightContext {
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/shadow-alpha.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Makes an object's shadow respect its opacity and alphaMap.
</mesh>
```

> Note: This component uses Screendoor transparency using a dither pattern. This pattern is notacible when the camera gets close to the shadow.
> Note: This component uses Screendoor transparency using a dither pattern. This pattern is noticeable when the camera gets close to the shadow.

<details>
<summary>Maintenance</summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/staging/spot-light-shadow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ A shadow caster that can help cast shadows of different patterns (textures) onto
scale={1} // Scale of the shadow caster plane
map={undefined} // Texture - Pattern of the shadow
shader={undefined} // Optional shader to run. Lets you add effects to the shadow map. See bellow
width={512} // Width of the shadow map. The higher the more expnsive
height={512} // Height of the shadow map. The higher the more expnsive
width={512} // Width of the shadow map. The higher the more expensive
height={512} // Height of the shadow map. The higher the more expensive
/>
</SpotLight>
```
Expand Down
2 changes: 1 addition & 1 deletion docs/staging/use-environment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can use it without properties, which will default to px, nx, py, ny, pz, nz
const cubeTexture = useEnvironment()
```

Or you can specificy from where to load the files.
Or you can specify from where to load the files.

```jsx
const presetTexture = useEnvironment({ preset: 'city' })
Expand Down
2 changes: 1 addition & 1 deletion src/core/AccumulativeShadows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface AccumulativeContext {
getMesh: () => THREE.Mesh<THREE.PlaneGeometry, SoftShadowMaterialProps & THREE.ShaderMaterial>
/** Resets the buffers, starting from scratch */
reset: () => void
/** Updates the lightmap for a number of frames accumulartively */
/** Updates the lightmap for a number of frames accumulatively */
update: (frames?: number) => void
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Caustics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type CausticsProps = Omit<ThreeElements['group'], 'ref'> & {
backsideIOR?: number
/** The texel size, default: 0.3125 */
worldRadius?: number
/** Intensity of the prjected caustics, default: 0.05 */
/** Intensity of the projected caustics, default: 0.05 */
intensity?: number
/** Caustics color, default: white */
color?: ReactThreeFiber.Color
Expand Down
6 changes: 3 additions & 3 deletions src/core/Effects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EffectComposer, RenderPass, ShaderPass, GammaCorrectionShader } from 't
import { ForwardRefComponent } from '../helpers/ts-utils'

export type EffectsProps = Omit<ThreeElements['effectComposer'], 'ref' | 'args'> & {
multisamping?: number
multisampling?: number
colorSpace?: ColorSpace
type?: TextureDataType
renderIndex?: number
Expand Down Expand Up @@ -38,7 +38,7 @@ export const Effects: ForwardRefComponent<EffectsProps, EffectComposer> = /* @__
(
{
children,
multisamping = 8,
multisampling = 8,
renderIndex = 1,
disableRender,
disableGamma,
Expand Down Expand Up @@ -70,7 +70,7 @@ export const Effects: ForwardRefComponent<EffectsProps, EffectComposer> = /* @__
t.texture.colorSpace = colorSpace
}

t.samples = multisamping
t.samples = multisampling
return t
})

Expand Down
4 changes: 2 additions & 2 deletions src/core/Fisheye.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function Fisheye({
const sphere = React.useRef<THREE.Mesh>(null!)
const cubeApi = React.useRef<RenderCubeTextureApi>(null!)

// This isn't more than a simple sphere and a fixed orthographc camera
// This isn't more than a simple sphere and a fixed orthographic camera
// pointing at it. A virtual scene is portalled into the environment map
// of its material. The cube-camera filming that scene is being synced to
// the portals default camera with the <UpdateCubeCamera> component.
Expand All @@ -59,7 +59,7 @@ export function Fisheye({
// Raycast from the render camera to the sphere and get the surface normal
// of the point hit in world space of the sphere scene
// We have to set the raycaster using the orthocam and pointer
// to perform sphere interscetions.
// to perform sphere intersections.
state.pointer.set((event.offsetX / state.size.width) * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1)
state.raycaster.setFromCamera(state.pointer, orthoC)
if (!state.raycaster.ray.intersectSphere(sph, normal)) return
Expand Down
2 changes: 1 addition & 1 deletion src/core/MeshPortalMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type PortalProps = Omit<ThreeElements['portalMaterialImpl'], 'ref' | 'ble
eventPriority?: number
/** Optional render priority, defaults to 0 */
renderPriority?: number
/** Optionally diable events inside the portal, defaults to false */
/** Optionally disable events inside the portal, defaults to false */
events?: boolean
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/MeshTransmissionMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
// Head
shader.fragmentShader =
/*glsl*/ `
uniform float chromaticAberration;
uniform float anisotropicBlur;
uniform float chromaticAberration;
uniform float anisotropicBlur;
uniform float time;
uniform float distortion;
uniform float distortionScale;
Expand Down Expand Up @@ -254,7 +254,7 @@ class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
// Direction of refracted light.
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
// Compute rotation-independant scaling of the model matrix.
// Compute rotation-independent scaling of the model matrix.
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
Expand All @@ -268,7 +268,7 @@ class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
#ifdef USE_SAMPLER
#ifdef texture2DLodEXT
return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);
Expand Down Expand Up @@ -314,7 +314,7 @@ class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
// Add refraction
shader.fragmentShader = shader.fragmentShader.replace(
'#include <transmission_fragment>',
/*glsl*/ `
/*glsl*/ `
// Improve the refraction to use the world pos
material.transmission = _transmission;
material.transmissionAlpha = 1.0;
Expand All @@ -327,7 +327,7 @@ class MeshTransmissionMaterialImpl extends THREE.MeshPhysicalMaterial {
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vUv ).g;
#endif

vec3 pos = vWorldPosition;
float runningSeed = 0.0;
vec3 v = normalize( cameraPosition - pos );
Expand Down
Loading