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

Change to use Face3 to remove Face4 three.js deprecated usage #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
var THREE = require('three')

module.exports = function(data, mesher, scaleFactor, three) {
return new Mesh(data, mesher, scaleFactor, three)
module.exports = function(data, mesher, scaleFactor, three, mesherExtraData) {
return new Mesh(data, mesher, scaleFactor, three, mesherExtraData)
}

module.exports.Mesh = Mesh

function Mesh(data, mesher, scaleFactor, three) {
function Mesh(data, mesher, scaleFactor, three, mesherExtraData) {
this.THREE = three || THREE
this.data = data
var geometry = this.geometry = new this.THREE.Geometry()
this.scale = scaleFactor || new this.THREE.Vector3(10, 10, 10)

var result = mesher( data.voxels, data.dims )
var result = mesher( data.voxels, data.dims, mesherExtraData )
this.meshed = result

geometry.vertices.length = 0
Expand All @@ -24,17 +24,24 @@ function Mesh(data, mesher, scaleFactor, three) {
}

for (var i = 0; i < result.faces.length; ++i) {
geometry.faceVertexUvs[0].push(this.faceVertexUv(i))

var q = result.faces[i]
if (q.length === 5) {
var f = new this.THREE.Face4(q[0], q[1], q[2], q[3])
var uv = this.faceVertexUv(i)

var f = new this.THREE.Face3(q[0], q[1], q[3])
f.color = new this.THREE.Color(q[4])
geometry.faces.push(f)
geometry.faceVertexUvs[0].push([uv[0], uv[1], uv[3]])

var g = new this.THREE.Face3(q[1], q[2], q[3])
g.color = new this.THREE.Color(q[4])
geometry.faces.push(g)
geometry.faceVertexUvs[0].push([uv[1], uv[2], uv[3]])
} else if (q.length == 4) {
var f = new this.THREE.Face3(q[0], q[1], q[2])
f.color = new this.THREE.Color(q[3])
geometry.faces.push(f)
geometry.faceVertexUvs[0].push(this.faceVertexUv(i))
}
}

Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"email": "[email protected]"
},
"license": "MIT",
"peerDependencies": {
"three": "*"
},
"engine": {
"node": ">=0.6.0"
}
Expand Down