Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples > Add VFX flames #1149

Merged
merged 3 commits into from
Aug 16, 2024
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
105 changes: 103 additions & 2 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13311,7 +13311,7 @@ index d0255e43..c924d666 100644
init();

diff --git a/examples-testing/examples/webgpu_backdrop_area.ts b/examples-testing/examples/webgpu_backdrop_area.ts
index fab3ee88..434b816f 100644
index 208bb15e..ad6da1e5 100644
--- a/examples-testing/examples/webgpu_backdrop_area.ts
+++ b/examples-testing/examples/webgpu_backdrop_area.ts
@@ -1,4 +1,4 @@
Expand All @@ -13331,7 +13331,7 @@ index fab3ee88..434b816f 100644

init();

@@ -128,13 +128,13 @@ function init() {
@@ -135,13 +135,13 @@ function init() {
};

const gui = new GUI();
Expand Down Expand Up @@ -15170,6 +15170,84 @@ index e8ebe87d..9fae06bd 100644
const size = texture.image.width * texture.image.height;
const data = texture.image.data;

diff --git a/examples-testing/examples/webgpu_tsl_vfx_flames.ts b/examples-testing/examples/webgpu_tsl_vfx_flames.ts
index 890cc697..8526c7db 100644
--- a/examples-testing/examples/webgpu_tsl_vfx_flames.ts
+++ b/examples-testing/examples/webgpu_tsl_vfx_flames.ts
@@ -1,9 +1,32 @@
-import * as THREE from 'three';
-import { PI2, dot, sin, step, texture, timerLocal, tslFn, uv, vec2, vec3, vec4, mix } from 'three/tsl';
+import * as THREE from 'three/webgpu';
+import {
+ PI2,
+ dot,
+ sin,
+ step,
+ texture,
+ timerLocal,
+ tslFn,
+ uv,
+ vec2,
+ vec3,
+ vec4,
+ mix,
+ Node,
+ ShaderNodeObject,
+} from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

-let camera, scene, renderer, controls;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer, controls: OrbitControls;
+
+interface Gradient {
+ element: HTMLCanvasElement;
+ context: CanvasRenderingContext2D;
+ colors: string[];
+ texture: THREE.CanvasTexture;
+ update: () => void;
+}

init();

@@ -23,21 +46,28 @@ function init() {

// TSL functions

- const spherizeUv = tslFn(([input, center, strength, offset]) => {
- const delta = input.sub(center);
- const delta2 = dot(delta, delta);
- const delta4 = delta2.mul(delta2);
- const deltaOffset = delta4.mul(strength);
- return input.add(delta.mul(deltaOffset)).add(offset);
- });
+ const spherizeUv = tslFn(
+ ([input, center, strength, offset]: [
+ ShaderNodeObject<Node>,
+ ShaderNodeObject<Node>,
+ ShaderNodeObject<Node>,
+ ShaderNodeObject<Node>,
+ ]) => {
+ const delta = input.sub(center);
+ const delta2 = dot(delta, delta);
+ const delta4 = delta2.mul(delta2);
+ const deltaOffset = delta4.mul(strength);
+ return input.add(delta.mul(deltaOffset)).add(offset);
+ },
+ );

// gradient canvas

- const gradient = {};
+ const gradient: Gradient = {} as Gradient;
gradient.element = document.createElement('canvas');
gradient.element.width = 128;
gradient.element.height = 1;
- gradient.context = gradient.element.getContext('2d');
+ gradient.context = gradient.element.getContext('2d')!;

gradient.colors = ['#090033', '#5f1f93', '#e02e96', '#ffbd80', '#fff0db'];

diff --git a/examples-testing/examples/webgpu_video_panorama.ts b/examples-testing/examples/webgpu_video_panorama.ts
index e409b3c0..78885bec 100644
--- a/examples-testing/examples/webgpu_video_panorama.ts
Expand Down Expand Up @@ -15656,3 +15734,26 @@ index 2cd50ba4..b97f3eee 100644

isDepthSupplied = false;
});
diff --git a/types/three/src/nodes/core/VarNode.d.ts b/types/three/src/nodes/core/VarNode.d.ts
index 9e4bdcd2..b5de30a2 100644
--- a/types/three/src/nodes/core/VarNode.d.ts
+++ b/types/three/src/nodes/core/VarNode.d.ts
@@ -1,4 +1,3 @@
-import { OperatorNodeOp } from "../math/OperatorNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";
import Node from "./Node.js";

@@ -9,13 +8,6 @@ export default class VarNode extends Node {
readonly isVarNode: true;

constructor(node: Node, name?: string | null);
-
- op(op: OperatorNodeOp, ...params: Node[]): this;
- assign(...params: Node[]): this;
- add(...params: Node[]): this;
- sub(...params: Node[]): this;
- mul(...params: Node[]): this;
- div(...params: Node[]): this;
}

export const temp: (node: NodeRepresentation, name?: string | null) => ShaderNodeObject<VarNode>;
8 changes: 0 additions & 8 deletions types/three/src/nodes/core/VarNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OperatorNodeOp } from "../math/OperatorNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";
import Node from "./Node.js";

Expand All @@ -9,13 +8,6 @@ export default class VarNode extends Node {
readonly isVarNode: true;

constructor(node: Node, name?: string | null);

op(op: OperatorNodeOp, ...params: Node[]): this;
assign(...params: Node[]): this;
add(...params: Node[]): this;
sub(...params: Node[]): this;
mul(...params: Node[]): this;
div(...params: Node[]): this;
}

export const temp: (node: NodeRepresentation, name?: string | null) => ShaderNodeObject<VarNode>;
Expand Down
Loading