Skip to content

Commit 30250be

Browse files
authored
Merge pull request #13 from martinRenou/add_water
Add water effect
2 parents 3899478 + d572e3c commit 30250be

16 files changed

Lines changed: 632 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"backbone": "^1.4.0",
3232
"binary-search-tree": "^0.2.6",
3333
"jquery": "^3.4.1",
34-
"three": "^0.112.0",
34+
"three": "^0.117.0",
3535
"uuid": "^3.3.3"
3636
},
3737
"devDependencies": {

src/Block.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ abstract class Block extends Events {
4949
for (const mesh of this._environmentMeshes) {
5050
mesh.matrixAutoUpdate = false;
5151
}
52-
53-
this.updateMatrix();
54-
5552
}
5653

5754
/**
@@ -62,6 +59,7 @@ abstract class Block extends Events {
6259

6360
this.handleVerticesChange();
6461

62+
// TODO: Separate vertices change and triangles change event?
6563
this.trigger('change:geometry');
6664
}
6765

@@ -79,6 +77,8 @@ abstract class Block extends Events {
7977
this._triangleIndices = triangleIndices;
8078

8179
this.handleTriangleIndicesChange();
80+
81+
this.trigger('change:geometry');
8282
}
8383

8484
/**
@@ -138,7 +138,7 @@ abstract class Block extends Events {
138138
this.updateMatrix();
139139
}
140140

141-
private updateMatrix () {
141+
protected updateMatrix () {
142142
const scaleMatrix = new THREE.Matrix4().makeScale(this._scale.x, this._scale.y, this._scale.z);
143143
const positionMatrix = new THREE.Matrix4().makeTranslation(this._position.x, this._position.y, this._position.z);
144144

@@ -214,4 +214,6 @@ abstract class Block extends Events {
214214

215215
parent: Block | null = null;
216216

217+
beforeRenderHook: ((renderer: THREE.WebGLRenderer) => void) | null = null;
218+
217219
}

src/EffectBlock.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class Effect extends Block {
6161
*/
6262
setInput (input?: Input) : void {
6363
if (this.inputDimension == 0) {
64-
// Do nothing (Maybe throw?)
6564
return;
6665
}
6766

src/Effects/Alpha.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Alpha extends Effect {
3838
this.parent.on('change:geometry', this.sortTriangleIndices.bind(this));
3939

4040
this.initialized = true;
41+
this.updateMatrix();
4142
}
4243

4344
setInput(input?: Input) : void {

src/Effects/IsoColor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class IsoColor extends Effect {
4545
this.buildMaterial();
4646

4747
this.initialized = true;
48+
this.updateMatrix();
4849
}
4950

5051
setInput(input?: Input) : void {

src/Effects/IsoSurface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class IsoSurface extends Effect {
6868
this.inputComponent.on('change:array', this.onInputArrayChange.bind(this));
6969

7070
this.initialized = true;
71+
this.updateMatrix();
7172
}
7273

7374
updateGeometry () {

src/Effects/RGB.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class RGB extends Effect {
3434
this.buildMaterial();
3535

3636
this.initialized = true;
37+
this.updateMatrix();
3738
}
3839

3940
setInput(input?: Input) : void {

src/Effects/Warp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Warp extends Effect {
3838
this.buildMaterial();
3939

4040
this.initialized = true;
41+
this.updateMatrix();
4142
}
4243

4344
setInput(input?: Input) : void {

src/MeshBlock.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ class PolyMesh extends Block {
5959
const indexBuffer = new THREE.BufferAttribute(this.triangleIndices, 1);
6060
this.geometry.setIndex(indexBuffer);
6161
}
62-
6362
}
6463

6564
get boundingSphere () : THREE.Sphere {
6665
this.geometry.computeBoundingSphere();
67-
return this.geometry.boundingSphere;
66+
return this.geometry.boundingSphere as THREE.Sphere;
6867
}
6968

7069
_triangleIndices: Uint32Array;
@@ -125,7 +124,7 @@ class PointCloud extends Block {
125124

126125
get boundingSphere () : THREE.Sphere {
127126
this.geometry.computeBoundingSphere();
128-
return this.geometry.boundingSphere;
127+
return this.geometry.boundingSphere as THREE.Sphere;
129128
}
130129

131130
geometry: THREE.BufferGeometry;

src/NodeMesh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class NodeMesh {
180180

181181
get boundingSphere () : THREE.Sphere {
182182
this.geometry.computeBoundingSphere();
183-
return this.geometry.boundingSphere;
183+
return this.geometry.boundingSphere as THREE.Sphere;
184184
}
185185

186186
set defaultColor (defaultColor: string) {

0 commit comments

Comments
 (0)