Skip to content

Commit 9081441

Browse files
authored
Merge pull request #10 from martinRenou/update_three
Upgrade to last Threejs version
2 parents 7b5590f + 5b110da commit 9081441

File tree

5 files changed

+22
-45
lines changed

5 files changed

+22
-45
lines changed

Diff for: .travis.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
language: node_js
2-
node_js:
3-
- 12
1+
language: generic
42
os:
53
- linux
64
- osx
7-
addons:
8-
chrome: beta
9-
script:
5+
before_install:
6+
- if [[ $TRAVIS_OS_NAME == linux ]]; then sudo apt-get update; fi
7+
- if [[ $TRAVIS_OS_NAME == linux ]]; then wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; fi
8+
- if [[ $TRAVIS_OS_NAME == osx ]]; then wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh; fi
9+
- bash miniconda.sh -b -p $HOME/miniconda
10+
- export PATH="$HOME/miniconda/bin:$PATH"
11+
- hash -r
12+
- conda config --set always_yes yes --set changeps1 no
13+
- conda update -q conda
14+
- conda info -a
15+
- conda create -q -n test-environment nodejs
16+
- source activate test-environment
17+
install:
1018
- npm install
1119
- npm run build
12-

Diff for: package-lock.json

+3-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"backbone": "^1.4.0",
3232
"binary-search-tree": "^0.2.6",
3333
"jquery": "^3.4.1",
34-
"three": "^0.110.0",
34+
"three": "^0.112.0",
3535
"uuid": "^3.3.3"
3636
},
3737
"devDependencies": {
38-
"@types/node": "^10.11.6",
38+
"@types/node": "^10.17.13",
3939
"typescript": "~3.1.2"
4040
}
4141
}

Diff for: src/NodeMesh.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ class NodeMesh {
8080

8181
this.hasIndex = this.geometry.index != null;
8282

83-
// @ts-ignore: Monkey patching material, workaround for github.com/mrdoob/three.js/issues/12132
84-
this.material.version = 0;
85-
8683
this.mesh = new T(geometry, this.material);
8784

8885
// We need to set this to false because we directly play with the position matrix
@@ -140,11 +137,8 @@ class NodeMesh {
140137
this.material.flatShading = true;
141138
this.material.side = THREE.DoubleSide;
142139

143-
// @ts-ignore
144140
this.material.position = position;
145-
// @ts-ignore
146141
this.material.alpha = alpha;
147-
// @ts-ignore
148142
this.material.color = color;
149143

150144
// Workaround for https://github.com/mrdoob/three.js/issues/18152
@@ -156,9 +150,6 @@ class NodeMesh {
156150
this.material.alphaTest = 0.1;
157151

158152
this.material.build();
159-
160-
// @ts-ignore
161-
this.material.version++;
162153
}
163154

164155
copy () {
@@ -237,7 +228,7 @@ class NodeMesh {
237228
const vertex = this.geometry.getAttribute('position').array;
238229

239230
let indices: ArrayLike<number>;
240-
if (this.hasIndex) {
231+
if (this.hasIndex && this.geometry.index !== null) {
241232
indices = this.geometry.index.array;
242233
} else {
243234
indices = Array.from(Array(vertex.length / 3).keys());
@@ -284,7 +275,7 @@ class NodeMesh {
284275
newIndices[3 * i + 2] = indices[3 * triangleIndex + 2]
285276
}
286277

287-
if (this.hasIndex) {
278+
if (this.hasIndex && this.geometry.index !== null) {
288279
this.geometry.index.set(newIndices);
289280
this.geometry.index.needsUpdate = true;
290281
} else {
@@ -300,7 +291,7 @@ class NodeMesh {
300291
}
301292

302293
geometry: THREE.BufferGeometry;
303-
material: Nodes.NodeMaterial;
294+
material: Nodes.StandardNodeMaterial;
304295
mesh: THREE.Object3D;
305296
readonly data: Data[];
306297

Diff for: src/Scene.ts

-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as THREE from 'three';
2-
import * as Nodes from 'three/examples/jsm/nodes/Nodes';
32

43
import {
54
TrackballControls
@@ -170,21 +169,6 @@ class Renderer {
170169
private animate () {
171170
this.animationID = window.requestAnimationFrame(this.animate.bind(this));
172171

173-
// This is a workaround for github.com/mrdoob/three.js/issues/12132
174-
for (const child of this.scene.scene.children) {
175-
if (child instanceof THREE.Mesh && child.material instanceof Nodes.StandardNodeMaterial) {
176-
const id = child.material.uuid;
177-
// @ts-ignore
178-
const version = child.material.version
179-
180-
if (id in this.materialVersions && this.materialVersions[id] != version) {
181-
child.material.needsUpdate = true;
182-
}
183-
184-
this.materialVersions[id] = version;
185-
}
186-
}
187-
188172
this.renderer.render(this.scene.scene, this.camera);
189173

190174
this.controls.update();

0 commit comments

Comments
 (0)