Skip to content

Commit

Permalink
TSL: Introduce time (#1318)
Browse files Browse the repository at this point in the history
* TSL: Introduce time

* Update three.js

* Add examples

* Update patch and delete examples

* Fix build
  • Loading branch information
Methuselah96 authored Nov 3, 2024
1 parent e2aae3d commit fd346f1
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 70 deletions.
8 changes: 4 additions & 4 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14926,13 +14926,13 @@ index dc30eb60..2a156b13 100644
init();

diff --git a/examples-testing/examples/webgpu_postprocessing_dof.ts b/examples-testing/examples/webgpu_postprocessing_dof.ts
index 4ef10636..d3e5c3a7 100644
index 281858ff..5b9879f0 100644
--- a/examples-testing/examples/webgpu_postprocessing_dof.ts
+++ b/examples-testing/examples/webgpu_postprocessing_dof.ts
@@ -1,4 +1,4 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';
import { cubeTexture, positionWorld, oscSine, timerGlobal, pass, uniform } from 'three/tsl';
import { cubeTexture, positionWorld, oscSine, time, pass, uniform } from 'three/tsl';
import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';

@@ -8,7 +8,11 @@ import Stats from 'three/addons/libs/stats.module.js';
Expand Down Expand Up @@ -15636,7 +15636,7 @@ index 07fb8d27..ea32b4d6 100644
}

diff --git a/examples-testing/examples/webgpu_tsl_coffee_smoke.ts b/examples-testing/examples/webgpu_tsl_coffee_smoke.ts
index 9e2404cc..9bd5ef8a 100644
index 90c9abd1..3fb25db7 100644
--- a/examples-testing/examples/webgpu_tsl_coffee_smoke.ts
+++ b/examples-testing/examples/webgpu_tsl_coffee_smoke.ts
@@ -1,4 +1,4 @@
Expand Down Expand Up @@ -15666,7 +15666,7 @@ index 9e2404cc..9bd5ef8a 100644
});

diff --git a/examples-testing/examples/webgpu_tsl_vfx_flames.ts b/examples-testing/examples/webgpu_tsl_vfx_flames.ts
index 6e72392a..b04fdc77 100644
index f788c088..cf705f89 100644
--- a/examples-testing/examples/webgpu_tsl_vfx_flames.ts
+++ b/examples-testing/examples/webgpu_tsl_vfx_flames.ts
@@ -1,4 +1,4 @@
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 37 files
+7 −7 examples/jsm/objects/WaterMesh.js
+225 −224 examples/jsm/shaders/FXAAShader.js
+1 −1 examples/jsm/transpiler/ShaderToyDecoder.js
+173 −180 examples/jsm/tsl/display/FXAANode.js
+ examples/screenshots/webgpu_backdrop_water.jpg
+2 −3 examples/webgpu_animation_retargeting.html
+2 −2 examples/webgpu_backdrop.html
+2 −2 examples/webgpu_backdrop_water.html
+4 −6 examples/webgpu_compute_particles_rain.html
+3 −5 examples/webgpu_compute_particles_snow.html
+2 −2 examples/webgpu_cubemap_mix.html
+2 −2 examples/webgpu_instance_mesh.html
+3 −3 examples/webgpu_instance_points.html
+2 −4 examples/webgpu_instance_sprites.html
+2 −3 examples/webgpu_materialx_noise.html
+6 −5 examples/webgpu_particles.html
+3 −3 examples/webgpu_portal.html
+2 −2 examples/webgpu_postprocessing_dof.html
+2 −2 examples/webgpu_sandbox.html
+1 −1 examples/webgpu_shadertoy.html
+2 −2 examples/webgpu_skinning_instancing.html
+2 −3 examples/webgpu_texturegrad.html
+2 −2 examples/webgpu_textures_2d-array.html
+1 −2 examples/webgpu_tsl_coffee_smoke.html
+3 −3 examples/webgpu_tsl_editor.html
+1 −3 examples/webgpu_tsl_galaxy.html
+4 −4 examples/webgpu_tsl_interoperability.html
+1 −3 examples/webgpu_tsl_raging_sea.html
+1 −5 examples/webgpu_tsl_vfx_flames.html
+3 −3 examples/webgpu_tsl_vfx_linkedparticles.html
+14 −14 examples/webgpu_tsl_vfx_tornado.html
+0 −2 src/nodes/Nodes.js
+2 −2 src/nodes/TSL.js
+0 −85 src/nodes/utils/OscNode.js
+6 −0 src/nodes/utils/Oscillators.js
+29 −0 src/nodes/utils/Timer.js
+0 −97 src/nodes/utils/TimerNode.js
2 changes: 0 additions & 2 deletions types/three/src/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export { default as JoinNode } from "./utils/JoinNode.js";
export { default as LoopNode } from "./utils/LoopNode.js";
export { default as MatcapUVNode } from "./utils/MatcapUVNode.js";
export { default as MaxMipLevelNode } from "./utils/MaxMipLevelNode.js";
export { default as OscNode, OscNodeMethod } from "./utils/OscNode.js";
export { default as ReflectorNode, ReflectorNodeParameters } from "./utils/ReflectorNode.js";
export { default as RemapNode } from "./utils/RemapNode.js";
export { default as RotateNode } from "./utils/RotateNode.js";
Expand All @@ -64,7 +63,6 @@ export { default as SetNode } from "./utils/SetNode.js";
export { default as SplitNode } from "./utils/SplitNode.js";
export { default as SpriteSheetUVNode } from "./utils/SpriteSheetUVNode.js";
export { default as StorageArrayElementNode } from "./utils/StorageArrayElementNode.js";
export { default as TimerNode, TimerNodeScope } from "./utils/TimerNode.js";
export { default as TriplanarTexturesNode } from "./utils/TriplanarTexturesNode.js";

// accessors
Expand Down
4 changes: 2 additions & 2 deletions types/three/src/nodes/TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export * from "./utils/FunctionOverloadingNode.js";
export * from "./utils/LoopNode.js";
export * from "./utils/MatcapUVNode.js";
export * from "./utils/MaxMipLevelNode.js";
export * from "./utils/OscNode.js";
export * from "./utils/Oscillators.js";
export * from "./utils/Packing.js";
export * from "./utils/ReflectorNode.js";
export * from "./utils/RemapNode.js";
export * from "./utils/RotateNode.js";
export * from "./utils/RTTNode.js";
export * from "./utils/SpriteSheetUVNode.js";
export * from "./utils/SpriteUtils.js";
export * from "./utils/TimerNode.js";
export * from "./utils/Timer.js";
export * from "./utils/TriplanarTexturesNode.js";
export * from "./utils/UVUtils.js";
export * from "./utils/ViewportUtils.js";
Expand Down
25 changes: 0 additions & 25 deletions types/three/src/nodes/utils/OscNode.d.ts

This file was deleted.

7 changes: 7 additions & 0 deletions types/three/src/nodes/utils/Oscillators.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Node from "../core/Node.js";
import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";

export const oscSine: (timeNode?: NodeRepresentation) => ShaderNodeObject<Node>;
export const oscSquare: (timeNode?: NodeRepresentation) => ShaderNodeObject<Node>;
export const oscTriangle: (timeNode?: NodeRepresentation) => ShaderNodeObject<Node>;
export const oscSawtooth: (timeNode?: NodeRepresentation) => ShaderNodeObject<Node>;
21 changes: 21 additions & 0 deletions types/three/src/nodes/utils/Timer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Node from "../core/Node.js";
import { ShaderNodeObject } from "../tsl/TSLCore.js";

export const time: ShaderNodeObject<Node>;
export const deltaTime: ShaderNodeObject<Node>;
export const frameId: ShaderNodeObject<Node>;

/**
* @deprecated Use "time" instead.
*/
export const timerLocal: (timeScale?: number) => ShaderNodeObject<Node>;

/**
* @deprecated Use "time" instead.
*/
export const timerGlobal: (timeScale?: number) => ShaderNodeObject<Node>;

/**
* @deprecated Use "deltaTime" instead.
*/
export const timerDelta: (timeScale?: number) => ShaderNodeObject<Node>;
25 changes: 0 additions & 25 deletions types/three/src/nodes/utils/TimerNode.d.ts

This file was deleted.

11 changes: 0 additions & 11 deletions types/three/test/unit/examples/jsm/nodes/ShaderNode/ShaderNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
Node,
nodeArray,
nodeImmutable,
nodeProxy,
OscNode,
PropertyNode,
ShaderNode,
ShaderNodeObject,
Expand All @@ -31,15 +29,6 @@ aa[0].xy = s;
aa[1].w = s;
aa[2] = "hello";

const oscNode0 = nodeProxy(OscNode);
assertSwizzable<OscNode>(oscNode0("sawtooth", s));

const oscNode1 = nodeProxy(OscNode, OscNode.SAWTOOTH);
assertSwizzable<OscNode>(oscNode1(s));

export const oscSine0 = nodeProxy(OscNode, OscNode.SAWTOOTH, 1);
assertSwizzable<OscNode>(oscSine0());

assertSwizzable<MaterialNode>(nodeImmutable(MaterialNode, MaterialNode.ROTATION));
assertSwizzable<PropertyNode>(nodeImmutable(PropertyNode, "vec4", "DiffuseColor"));

Expand Down

0 comments on commit fd346f1

Please sign in to comment.