@@ -13,16 +13,22 @@ import {
13
13
} from '../NodeMesh' ;
14
14
15
15
16
+ /**
17
+ * Transform the vertices positions. The new vertice position is equal to `factor * (offset + input) + initialPosition`
18
+ **/
16
19
export
17
20
class Warp extends Effect {
18
21
19
- constructor ( parent : Block , input : Input , factor : number ) {
22
+ constructor ( parent : Block , input : Input , factor : THREE . Vector3 , offset : THREE . Vector3 ) {
20
23
super ( parent , input ) ;
21
24
22
- this . factorNode = new Nodes . FloatNode ( factor ) ;
25
+ this . offsetNode = new Nodes . Vector3Node ( offset . x , offset . y , offset . z ) ;
26
+ this . factorNode = new Nodes . Vector3Node ( factor . x , factor . y , factor . z ) ;
27
+
28
+ this . intermediateTransformNode = new Nodes . OperatorNode ( this . offsetNode , this . inputNode , Nodes . OperatorNode . ADD ) ;
23
29
24
30
this . transformNode = new Nodes . OperatorNode (
25
- this . inputNode ,
31
+ this . intermediateTransformNode ,
26
32
this . factorNode ,
27
33
Nodes . OperatorNode . MUL
28
34
) ;
@@ -38,13 +44,21 @@ class Warp extends Effect {
38
44
super . setInput ( input ) ;
39
45
40
46
if ( this . initialized ) {
41
- this . transformNode . a = this . inputNode ;
47
+ this . intermediateTransformNode . b = this . inputNode ;
42
48
43
49
this . buildMaterial ( ) ;
44
50
}
45
51
}
46
52
47
- set factor ( value : number ) {
53
+ set offset ( value : THREE . Vector3 ) {
54
+ this . offsetNode . value = value ;
55
+ }
56
+
57
+ get offset ( ) {
58
+ return this . offsetNode . value ;
59
+ }
60
+
61
+ set factor ( value : THREE . Vector3 ) {
48
62
this . factorNode . value = value ;
49
63
}
50
64
@@ -58,7 +72,9 @@ class Warp extends Effect {
58
72
59
73
private initialized : boolean = false ;
60
74
61
- private factorNode : Nodes . FloatNode ;
75
+ private offsetNode : Nodes . Vector3Node ;
76
+ private factorNode : Nodes . Vector3Node ;
77
+ private intermediateTransformNode : Nodes . OperatorNode ;
62
78
private transformNode : Nodes . OperatorNode ;
63
79
64
80
protected inputNode : Nodes . Node ;
0 commit comments