|
|
@@ -184,53 +184,10 @@ THREE.Baker.prototype = {
|
|
|
result.applyMatrix4(object.bindMatrixInverse)
|
|
|
|
|
|
p.copy(result)
|
|
|
- //return result.applyMatrix4 (skin.bindMatrixInverse);
|
|
|
-
|
|
|
- // const skinIndex = skinIndices[i]
|
|
|
- // const skinWeight = skinWeights[i]
|
|
|
- // skinIndex.forEach((s, j) => {
|
|
|
- // //https://stackoverflow.com/questions/31620194/how-to-calculate-transformed-skin-vertices
|
|
|
- // //result.add (temp.copy (skinVertex).applyMatrix4 (tempMatrix).multiplyScalar (skinWeights[properties[i]]));
|
|
|
-
|
|
|
-
|
|
|
- // const w = skinWeight[j]
|
|
|
- // const bone = bones[s]
|
|
|
- // if (bone) {
|
|
|
- // p.add(p.clone().applyMatrix4(bone.matrixWorld).multiplyScalar(w))
|
|
|
- // }
|
|
|
- // })
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // attributes.position is a flattened Array<Array<Vector3>>.
|
|
|
- // attributes.skinIndex is a flattened Array<Array(4)<Int>>. Each is an ordinal to a bone.
|
|
|
- // attributes.skinWeight is a flattened Array<Array(4)<Float>>. Each is a 0.0 - 1.0 weight for a bone.
|
|
|
-
|
|
|
-
|
|
|
- // if (attributes.skinIndex) {
|
|
|
- // const skinIndex = attributes.skinIndex
|
|
|
- // const skinWeight = attributes.skinWeight
|
|
|
-
|
|
|
- // const bones = object.skeleton.bones
|
|
|
- // const bonesPerPosition = slices(Array.from(skinIndex.array).map(i => bones[i]), 4)
|
|
|
- // const weightsPerPosition = slices(skinWeight.array, 4)
|
|
|
- // positions.forEach((p, i) => {
|
|
|
- // const bones = bonesPerPosition[i]
|
|
|
- // const weights = weightsPerPosition[i]
|
|
|
- // bones.forEach((bone, b) => {
|
|
|
- // const weight = weights[b]
|
|
|
- // if (weight !== 0) {
|
|
|
- // const matrix = bone.matrix.clone().multiply(object.matrixWorld)
|
|
|
- // //matrix.multiplyScalar(weight)
|
|
|
- // p.applyMatrix4(matrix)
|
|
|
- // }
|
|
|
- // })
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
pushAll(_triangles, triangles)
|
|
|
|
|
|
/* END FROM*/
|
|
|
@@ -238,8 +195,14 @@ THREE.Baker.prototype = {
|
|
|
|
|
|
});
|
|
|
|
|
|
- console.log('Triangles', triangles)
|
|
|
- const stl = toStl(rotate(triangles))
|
|
|
+ // Finally, transform each triangle. Apply z-up rotation, and scale by 1000% percent.
|
|
|
+
|
|
|
+ const final = triangles.map(t => t.map(v =>
|
|
|
+ v.clone().set(v.x, -v.z, v.y).multiplyScalar(10)
|
|
|
+ ))
|
|
|
+
|
|
|
+ console.log('Triangles', final)
|
|
|
+ const stl = toStl(final)
|
|
|
window.save = (filename) => console.save(stl, filename || 'export.stl')
|
|
|
console.log('save([filename]) to save')
|
|
|
};
|