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
12 changes: 6 additions & 6 deletions src/examples/compute/compute-particles-fluid/FluidParticles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function FluidParticles() {
// Fixed-point codec for the atomic grid. Cast: struct member access types as a bare
// `Node`, which has no fluent surface (typed-TSL gap, AGENTS.md B10/B11 cast family).
const encodeFixedPoint = (value: Node<'float'>) => int(value.mul(FIXED_POINT_MULTIPLIER));
const readCell = (field: Node) => float(atomicLoad(field as unknown as Node<'int'>)).div(FIXED_POINT_MULTIPLIER);
const readCell = (field: Node) => float(atomicLoad(field as Node<'int'>)).div(FIXED_POINT_MULTIPLIER);

// Cast: @types/three's Loop overloads stop at two ranges and both are handed to
// the callback as `{ i, j }`. The runtime takes any number of ranges and names
Expand Down Expand Up @@ -222,9 +222,9 @@ export function FluidParticles() {
const element = particleBuffer.element(instanceIndex);
// Casts: struct member access types as a bare `Node`, which has no fluent vec
// surface (typed-TSL gap, AGENTS.md B10/B11 cast family).
const particlePosition = (element.get('position') as unknown as Node<'vec3'>).toConst();
const particlePosition = (element.get('position') as Node<'vec3'>).toConst();
const particleVelocity = (element.get('velocity') as unknown as Node<'vec3'>).toConst();
const affineMomentum = (element.get('C') as unknown as Node<'mat3'>).toConst();
const affineMomentum = (element.get('C') as Node<'mat3'>).toConst();

const gridPosition = particlePosition.mul(GRID_SIZE).toVar();
const cellIndex = ivec3(gridPosition).sub(1).toConst();
Expand Down Expand Up @@ -267,7 +267,7 @@ export function FluidParticles() {
const volume = float(1).div(density);
const pressure = max(0, pow(density.div(REST_DENSITY), 5).sub(1).mul(STIFFNESS)).toConst();
const stress = mat3(pressure.negate(), 0, 0, 0, pressure.negate(), 0, 0, 0, pressure.negate()).toVar();
const dudv = (element.get('C') as unknown as Node<'mat3'>).toConst();
const dudv = (element.get('C') as Node<'mat3'>).toConst();
const strain = dudv.add(dudv.transpose());
stress.addAssign(strain.mul(DYNAMIC_VISCOSITY));
const eq16Term0 = volume.mul(-4).mul(stress).mul(uDelta);
Expand Down Expand Up @@ -355,7 +355,7 @@ export function FluidParticles() {
particleVelocity.addAssign(weightedVelocity);
});

(element.get('C') as unknown as Node<'mat3'>).assign(B.mul(4));
(element.get('C') as Node<'mat3'>).assign(B.mul(4));

particleVelocity.addAssign(vec3(0, GRAVITY, 0).mul(uDelta));
// Grid units -> unit cube, so the rest of this runs in the particle's own space.
Expand All @@ -379,7 +379,7 @@ export function FluidParticles() {
particleVelocity.mulAssign(GRID_SIZE);

(element.get('position') as unknown as Node<'vec3'>).assign(particlePosition);
(element.get('velocity') as unknown as Node<'vec3'>).assign(particleVelocity);
(element.get('velocity') as Node<'vec3'>).assign(particleVelocity);
})().compute(DEFAULT_PARTICLE_COUNT, [WORKGROUP_SIZE, 1, 1]);

return {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/compute/compute-points.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function PointsField() {
const points = pointsRef.current;
if (!points) return;
points.geometry.drawRange.count = 1;
(points as unknown as { count: number }).count = PARTICLE_COUNT;
(points as { count: number }).count = PARTICLE_COUNT;
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function namedLoop<K extends string, T extends 'int' | 'uint'>(
params: { name: K; type: T; start: Node<T> | number; end: Node<T> | number; condition: string },
body: (inputs: Record<K, Node<T>>) => void,
) {
(Loop as unknown as (loopParams: typeof params, loopBody: typeof body) => void)(params, body);
(Loop as (loopParams: typeof params, loopBody: typeof body) => void)(params, body);
}

/** Signed screen-space area of a triangle — also the barycentric weight generator. */
Expand Down
2 changes: 1 addition & 1 deletion src/examples/compute/compute-rasterizer/Rasterizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function namedLoop<K extends string, T extends 'int' | 'uint'>(
params: { name: K; type: T; start: Node<T> | number; end: Node<T> | number; condition: string },
body: (inputs: Record<K, Node<T>>) => void,
) {
(Loop as unknown as (loopParams: typeof params, loopBody: typeof body) => void)(params, body);
(Loop as (loopParams: typeof params, loopBody: typeof body) => void)(params, body);
}

// Signed area of a triangle in screen space — also the barycentric weight generator.
Expand Down
2 changes: 1 addition & 1 deletion src/examples/compute/compute-texture-3d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function CloudVolume() {
const tex = new Storage3DTexture(GRID_SIZE, GRID_SIZE, GRID_SIZE);
tex.generateMipmaps = false;
tex.name = 'cloud';
return tex as unknown as StorageTexture;
return tex as StorageTexture;
});

// ROOT-LEVEL useNodes on purpose (UPSTREAM.md B16): a scoped call would name entries
Expand Down
6 changes: 3 additions & 3 deletions src/examples/compute/compute-water/Water.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export function Water({ controlsRef }: WaterProps) {
const duckElement = waterDuckData.element(instanceIndex);
// Casts: struct member access (`.get`) types as bare `Node` — the fluent
// vec surface doesn't resolve through it (typed-TSL gap, B10 cast family).
const instancePosition = (duckElement.get('position') as unknown as Node<'vec3'>).toVar();
const instancePosition = (duckElement.get('position') as Node<'vec3'>).toVar();
const velocity = (duckElement.get('velocity') as unknown as Node<'vec2'>).toVar();

// Simulation-grid texel under the duck.
Expand Down Expand Up @@ -316,14 +316,14 @@ export function Water({ controlsRef }: WaterProps) {
velocity.y.mulAssign(bounceDamping);
});

(duckElement.get('position') as unknown as Node<'vec3'>).assign(instancePosition);
(duckElement.get('position') as Node<'vec3'>).assign(instancePosition);
(duckElement.get('velocity') as unknown as Node<'vec2'>).assign(velocity);
})().compute(NUM_DUCKS);

// Instance placement for the duck mesh — offset the source geometry by the
// struct buffer's live position (same B10-family cast as above).
const duckPositionNode = Fn(() => {
const instancePosition = waterDuckData.element(instanceIndex).get('position') as unknown as Node<'vec3'>;
const instancePosition = waterDuckData.element(instanceIndex).get('position') as Node<'vec3'>;
return positionLocal.add(instancePosition);
})();

Expand Down
2 changes: 1 addition & 1 deletion src/examples/loaders/loader-materialx/GridFloor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Node } from 'three/webgpu';
// default-value typing — AGENTS.md B10. `coord` is always called with a vec2
// (`positionWorld.xz`); regain that so `.x`/`.y` swizzles typecheck below.
const grid = Fn(([coordIn, lineWidth = float(0.01), dotSize = float(0.03)]) => {
const coord = coordIn as unknown as Node<'vec2'>;
const coord = coordIn as Node<'vec2'>;
const g = fract(coord);
const fw = fwidth(coord);
const gx = abs(g.x.sub(0.5));
Expand Down
2 changes: 1 addition & 1 deletion src/examples/postprocessing/postprocessing-anamorphic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function PostFX() {

// `highPassFn`'s declared type is `(params) => void`; the runtime (and the
// addon's own default) returns a Node — documented @types gap, cast once.
bloomPass.highPassFn = anamorphicHighPass as unknown as typeof bloomPass.highPassFn;
bloomPass.highPassFn = anamorphicHighPass as typeof bloomPass.highPassFn;

renderPipeline.outputNode = scenePassColor.add(bloomPass.mul(uniforms.tintColor));
});
Expand Down
2 changes: 1 addition & 1 deletion src/examples/scene/portal/PortalModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function PortalGhost() {
// the original's plain `material.colorNode = ...` on a classic material works at
// all. `@types/three` only declares `colorNode` on the Node-suffixed classes
// (same duck-typed-property pattern as `scene.fogNode`/`backgroundNode`).
(material as unknown as { colorNode: Node | null }).colorNode = colorNode;
(material as { colorNode: Node | null }).colorNode = colorNode;
material.wireframe = true;
mesh.material = material;
});
Expand Down
2 changes: 1 addition & 1 deletion src/examples/shadows/shadowmap-opacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function DragonScene() {
// Duck-typed cast (AGENTS.md B11 family): GLTFLoader hands back a classic
// MeshPhysicalMaterial, but attenuationColor/castShadowNode both read fine at
// runtime regardless of the material's declared TS type.
const dragonMaterial = dragon.material as unknown as MeshPhysicalNodeMaterial;
const dragonMaterial = dragon.material as MeshPhysicalNodeMaterial;

const dragon2 = dragon.clone();
dragon2.material = dragonMaterial.clone();
Expand Down
22 changes: 11 additions & 11 deletions src/examples/tsl/tsl-vfx-tornado/Tornado.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export function Tornado() {
const toRadialUv = Fn(([uvIn, multiplierIn, rotationIn, offsetIn]) => {
// Fn's destructured params come back as bare `ShaderNodeObject<Node>` — too
// loose for the swizzles/typed math below (three-side gap, UPSTREAM.md B10).
const uvInput = uvIn as unknown as Node<'vec2'>;
const multiplier = multiplierIn as unknown as Node<'vec2'>;
const rotation = rotationIn as unknown as Node<'float'>;
const offset = offsetIn as unknown as Node<'float'>;
const uvInput = uvIn as Node<'vec2'>;
const multiplier = multiplierIn as Node<'vec2'>;
const rotation = rotationIn as Node<'float'>;
const offset = offsetIn as Node<'float'>;

const centeredUv = vec2(uvInput).sub(0.5).toVar();
const distanceToCenter = centeredUv.length();
Expand All @@ -101,20 +101,20 @@ export function Tornado() {
// Shear the UV space — turns straight scrolling noise into diagonal streaks
// (the "wind-dragged" look on the cylinders).
const toSkewedUv = Fn(([uvIn, skewIn]) => {
const uvInput = uvIn as unknown as Node<'vec2'>; // B10 cast, as above
const skew = skewIn as unknown as Node<'vec2'>;
const uvInput = uvIn as Node<'vec2'>; // B10 cast, as above
const skew = skewIn as Node<'vec2'>;

return vec2(uvInput.x.add(uvInput.y.mul(skew.x)), uvInput.y.add(uvInput.x.mul(skew.y)));
});

// The funnel: re-radius every cylinder vertex along a parabola of its height,
// plus a sine turbulence wobble that climbs over time.
const twistedCylinder = Fn(([positionIn, strengthIn, offsetIn, amplitudeIn, timeIn]) => {
const position = positionIn as unknown as Node<'vec3'>; // B10 casts, as above
const strength = strengthIn as unknown as Node<'float'>;
const offset = offsetIn as unknown as Node<'float'>;
const amplitude = amplitudeIn as unknown as Node<'float'>;
const t = timeIn as unknown as Node<'float'>;
const position = positionIn as Node<'vec3'>; // B10 casts, as above
const strength = strengthIn as Node<'float'>;
const offset = offsetIn as Node<'float'>;
const amplitude = amplitudeIn as Node<'float'>;
const t = timeIn as Node<'float'>;

const angle = atan(position.z, position.x).toVar();
const elevation = position.y;
Expand Down
2 changes: 1 addition & 1 deletion src/examples/volume/volume-fire/VolumeFire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function createStorage3D(wrap: Wrapping = ClampToEdgeWrapping): StorageTexture {
texture.wrapS = wrap;
texture.wrapT = wrap;
texture.wrapR = wrap;
return texture as unknown as StorageTexture;
return texture as StorageTexture;
}

export function VolumeFire({ cameraControlsRef }: { cameraControlsRef: RefObject<CameraControlsImpl | null> }) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/resumeAudioContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
import { AudioContext as ThreeAudioContext } from 'three/webgpu';

export function resumeAudioContext() {
return (ThreeAudioContext.getContext() as unknown as globalThis.AudioContext).resume();
return (ThreeAudioContext.getContext() as globalThis.AudioContext).resume();
}