Skip to content

Commit 7b5590f

Browse files
authored
Merge pull request #11 from martinRenou/rgb
Add RGB effect
2 parents cb85193 + 7089e87 commit 7b5590f

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

Diff for: src/Effects/RGB.ts

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import * as Nodes from 'three/examples/jsm/nodes/Nodes';
2+
3+
import {
4+
Effect, Input, InputDimension
5+
} from '../EffectBlock';
6+
7+
import {
8+
Block
9+
} from '../Block';
10+
11+
import {
12+
Component
13+
} from '../Data';
14+
15+
import {
16+
NodeOperation
17+
} from '../NodeMesh';
18+
19+
import {
20+
IdentityNode
21+
} from '../utils/Nodes';
22+
23+
24+
export
25+
class RGB extends Effect {
26+
27+
constructor (parent: Block, input: Input) {
28+
super(parent, input);
29+
30+
this.colorNode = new IdentityNode(this.inputNode);
31+
32+
this.addColorNode(NodeOperation.ASSIGN, this.colorNode);
33+
34+
this.buildMaterial();
35+
36+
this.initialized = true;
37+
}
38+
39+
setInput(input?: Input) : void {
40+
super.setInput(input);
41+
42+
if (this.initialized) {
43+
this.colorNode.value = this.inputNode;
44+
45+
this.buildMaterial();
46+
}
47+
}
48+
49+
get inputDimension () : InputDimension {
50+
return 3;
51+
}
52+
53+
private initialized: boolean = false;
54+
55+
private colorNode: IdentityNode;
56+
57+
protected inputs: [Component];
58+
protected inputNode: Nodes.Node;
59+
60+
}

Diff for: src/Effects/effects.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './Alpha';
2+
export * from './RGB';
23

34
export * from './IsoColor';
45

0 commit comments

Comments
 (0)