Skip to content
Merged
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
32 changes: 32 additions & 0 deletions docs/TSL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ An Approach to Productive and Maintainable Shader Creation.
- [Storage](#storage)
- [Struct](#struct)
- [Flow Control](#flow-control)
- [Override Node](#override-node)
- [Fog](#fog)
- [Color Adjustments](#color-adjustments)
- [Utilities](#utilities)
Expand Down Expand Up @@ -903,6 +904,8 @@ The module also provides `Break()` and `Continue()` TSL expression for loop cont
| `step( edge, x )` | Generate a step function by comparing two values. |
| `tan( x )` | Return the tangent of the parameter. |
| `transformDirection( dir, matrix )` | Transform the direction of a vector by a matrix and then normalize the result. |
| `transformNormalByViewMatrix( normal, viewMatrix )` | Transform a normal vector (given in world space) by the view matrix and normalize the result. |
| `transformNormalByInverseViewMatrix( normal, viewMatrix )` | Transform a normal vector (given in view space) by the inverse of the view matrix and normalize the result. |
| `trunc( x )` | Truncate the parameter, removing the fractional part. |

```js
Expand Down Expand Up @@ -1086,6 +1089,7 @@ Screen nodes will return the values related to the current `frame buffer`, eithe
| `spherizeUV( uv, strength, centerNode = vec2( 0.5 ) )` | Distorts UV coordinates with a spherical effect around a center point. | `vec2` |
| `spritesheetUV( count, uv = uv(), frame = float( 0 ) )` | Computes UV coordinates for a sprite sheet based on the number of frames, UV coordinates, and frame index. | `vec2` |
| `equirectUV( direction = positionWorldDirection )` | Computes UV coordinates for equirectangular mapping based on the direction vector. | `vec2` |
| `equirectDirection( uv = uv() )` | Computes a direction vector from the given equirectangular UV coordinates (inverse of `equirectUV`). | `vec3` |

```js
import { texture, matcapUV } from 'three/tsl';
Expand Down Expand Up @@ -1420,6 +1424,33 @@ const customFragment = Fn( () => {
material.colorNode = customFragment();
```

## Override Node

Override nodes allow you to replace specific target nodes within a node sub-graph or flow dynamically during compilation, without having to reconstruct or duplicate the source nodes. This is useful, for example, to inject a custom `positionLocal` or normal into an existing flow through the material's `contextNode`.

| Name | Description |
| -- | -- |
| `overrideNode( targetNode, callback = null, flowNode = null )` | Overrides a single target node. `callback` returns the overriding node (receiving the builder as argument) or can be the overriding node itself. |
| `overrideNodes( overrides, flowNode = null )` | Overrides multiple target nodes at once using a `Map` or an array of `[ targetNode, callback \| node ]` pairs. |

Example:

```js
import { overrideNode, overrideNodes, positionLocal, positionView, vec3 } from 'three/tsl';

// Override a single node through the material context
material.contextNode = overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );

// Override multiple nodes at once
material.contextNode = overrideNodes( [
[ positionView, customPositionView ], // You can use a node directly like customPositionView.
[ positionLocal, ( builder ) => positionLocal.add( vec3( 1, 0, 0 ) ) ]
] );

// Method chaining is also supported
node.overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );
```

## Fog

Functions for creating fog effects in the scene. Assign the fog node to `scene.fogNode`.
Expand Down Expand Up @@ -1477,6 +1508,7 @@ Utility functions for common shader tasks.
| -- | -- | -- |
| `billboarding( { position, horizontal, vertical } )` | Orients flat meshes always towards the camera. `position`: vertex positions in world space (default: `null`). `horizontal`: follow camera horizontally (default: `true`). `vertical`: follow camera vertically (default: `false`). | `vec3` |
| `checker( coord )` | Creates a 2x2 checkerboard pattern. | `float` |
| `negateOnBackSide( vector )` | Negates a vector when rendering the back side of a face, according to the material's `side` configuration (`BackSide`, `DoubleSide` or `FrontSide`). | `vec3` |

Example:

Expand Down
81 changes: 68 additions & 13 deletions docs/index.html

Large diffs are not rendered by default.

73 changes: 55 additions & 18 deletions docs/llms-full.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ CORRECT - modern pattern (always use latest version):
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.184.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.184.0/examples/jsm/"
"three": "https://cdn.jsdelivr.net/npm/three@0.185.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.185.0/examples/jsm/"
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/ARButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 translate="no">ARButton</h1>
<header>
<div class="class-description"><p>A utility class for creating a button that allows to initiate
immersive AR sessions based on WebXR. The button can be created
with a factory method and then appended ot the website's DOM.</p></div>
with a factory method and then appended to the website's DOM.</p></div>
<h2>Code Example</h2>
<div translate="no"><pre><code class="language-js">document.body.appendChild( ARButton.createButton( renderer ) );
</code></pre></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/ARButton.html.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ARButton

A utility class for creating a button that allows to initiate immersive AR sessions based on WebXR. The button can be created with a factory method and then appended ot the website's DOM.
A utility class for creating a button that allows to initiate immersive AR sessions based on WebXR. The button can be created with a factory method and then appended to the website's DOM.

## Code Example

Expand Down
10 changes: 5 additions & 5 deletions docs/pages/AmmoPhysics.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ <h1 translate="no">AmmoPhysics</h1>
<section>
<header>
<div class="class-description"><p>Can be used to include Ammo.js as a Physics engine into
<code>three.js</code> apps. Make sure to include <code>ammo.wasm.js</code> first:</p>
<pre class="prettyprint source"><code>&lt;script src=&quot;jsm/libs/ammo.wasm.js&quot;>&lt;/script>
</code></pre>
<p>It is then possible to initialize the API via:</p>
<pre><code class="language-js">const physics = await AmmoPhysics();
<code>three.js</code> apps. The API can be initialized via:</p>
<p>The component automatically imports Ammo.js from a CDN so make sure
to use the component with an active Internet connection.</p></div>
<h2>Code Example</h2>
<div translate="no"><pre><code class="language-js">const physics = await AmmoPhysics();
</code></pre></div>
</header>
<article>
Expand Down
8 changes: 3 additions & 5 deletions docs/pages/AmmoPhysics.html.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# AmmoPhysics

Can be used to include Ammo.js as a Physics engine into `three.js` apps. Make sure to include `ammo.wasm.js` first:
Can be used to include Ammo.js as a Physics engine into `three.js` apps. The API can be initialized via:

```js
<script src="jsm/libs/ammo.wasm.js"></script>
```
The component automatically imports Ammo.js from a CDN so make sure to use the component with an active Internet connection.

It is then possible to initialize the API via:
## Code Example

```js
const physics = await AmmoPhysics();
Expand Down
222 changes: 0 additions & 222 deletions docs/pages/AnamorphicNode.html

This file was deleted.

Loading
Loading