# V2 Update

• @z3dev I don't have a real implementation of projection, but I'm using a function that returns a 2d geometry from a 3d one, it needs an axis and retrieve polygons from the 3d geometry that lies on this axis or are paralleled. It works well with intersection of the 3d geometry and a cuboid. If you use it, beware, I suspect that I am mistaken with axes (X, Y, Z) affectations as I need to reverse the points for 'y'.

``````function vol2surf(vol, axe, orig = 0){ // axe = 'x' | 'y' | 'z'
var n, pts, ok, P, i, pt;
let S = [];
var X, Y, Z;

for(n = 0; n < vol.polygons.length; n++){
pts = [];
P = vol.polygons[n];
ok = true;
switch(axe){
case 'x':
X = 1; Y = 2; Z = 0;
break;
case 'y':
X = 0; Y = 2; Z = 1;
break;
case 'z':
X = 0; Y = 1; Z = 2;
break;
}
for(i=0; (i < P.vertices.length) && ok; i++){
pt = P.vertices[i];
if(Math.abs(pt[Z] - orig)< 0.05){
pts.push([pt[X], pt[Y]]);
} else {
ok = false;
}
}
if (ok){
if(axe == 'x'){
S.push(polygon({points:pts.reverse()}));
} else {
S.push(polygon({points:pts}));
}
}
}

return S;
}
``````

• @gilboonet said in V2 Update:

Hello, I'm restarting to test V2.
I'm on Ubuntu 20 64 bits, Firefox 79. There was a 404 error on the downloading of fonts, my package/web didn't have assets directory, so I took it from package/desktop, but not there's an error with the fonts files, maybe those from desktop are not the good ones ?

This is from the CSS file, which specifies a specific font to access. We'll remove this at a later time, so please ignore.

• I noticed that when you populate an array with geometries that will be returned, if there are empty values, it fires an error. For the moment I filter them by geometry.polygons.length > 0.

Thanks. I created issue 665 for tracking and fixing this.

• Is there anything on v2 lib to do projection from 3d to 2d ?

Not yet. There have been several requests. Does anyone have an implementation of projection?

• I now have a 2 axis slicer that works. It made me notice that when you get a slice from x axis (keep points y and z from a polygon points having same x) you must reverse points order, but when you get a slice from y axis (keep points x and z from points with same y), you don't have to reverse points order. I hope this stays the same for all kinds of 3d models.

• @gilboonet One more little feedback : it was not hard to adapt my code from V1 and I was even able to improve it. On this capture is the result of an intersection, it is retrieved into one bunch of polygons and my code split them so I'm able to cut each one in two equal parts.

• Hello, I'm restarting to test V2.

• I'm on Ubuntu 20 64 bits, Firefox 79. There was a 404 error on the downloading of fonts, my package/web didn't have assets directory, so I took it from package/desktop, but not there's an error with the fonts files, maybe those from desktop are not the good ones ?

• I noticed that when you populate an array with geometries that will be returned, if there are empty values, it fires an error. For the moment I filter them by geometry.polygons.length > 0.

• Is there anything on v2 lib to do projection from 3d to 2d ?

• This version seems very cool.

• @z3dev

Yes, absolutely. I will file bugs right away after verifying that the issue is still present in the latest version. Very excited about the pace of changes.

• @BarbourSmith Thanks much.

Can you create new issues for these two bugs?

Next, keep your local copy of OpenJSCAD.org up to date, as there are changes being made almost daily now.

• @z3dev

I am very much willing to test and help. I'm not particularly knowledgeable, but I'm excited to give V2 a go.

• @BarbourSmith thanks.

those test cases create files on the fly, and it seems that the paths to those files are not the same on windows.

we definitely needs some testing / fixes on windows. anyone willing to help?

• Update:

I am able to launch the web viewer, however I am seeing what seems to be a related error there:

• Hey everyone, I went to give V2 a test and I'm running into an issue when running the tests. Here's what I'm seeing:

Edit: This is on windows.

``````─
@jscad/core: > ava './**/*.test.js' --verbose --timeout 2m
@jscad/amf-serializer: > ava --verbose --timeout 2m 'tests/**/*.test.js'
@jscad/amf-serializer:   √ serialize 3D geometry to amf
@jscad/core:   × webRequire: should support require, from a single file Error thrown in test
@jscad/core:   × webRequire: should support require, from a directory with index.js Error thrown in test
@jscad/core:   × webRequire: should support require, from a directory with index.json Error thrown in test
@jscad/core:   × webRequire: should support require, from a directory with project.json Error thrown in test
@jscad/core:   × webRequire: should support require, from a directory with dependent files Error thrown in test
@jscad/core:   × webRequire: should allow using require.extensions like the native node require (simple) Error thrown in test
@jscad/core:   × webRequire: should allow using require.extensions like the native node require (parser) Error thrown in test
@jscad/core:   webRequire: should support require, from a single file
@jscad/core:    14:   let requireFn = makeWebRequire(singleFileJs, { apiMainPath })
@jscad/core:    15:   let designRootModule = requireFn(singleFileJs[0].fullPath)
@jscad/core:     message: 'Cannot find relative path to module C:\\logo.js',
@jscad/core:   webRequire: should support require, from a directory with index.js
@jscad/core:    33:   const requireFn = makeWebRequire(directoryWithIndexJs, { apiMainPath })
@jscad/core:    34:   const designRootModule = requireFn('/project')
@jscad/core:     message: 'Cannot find relative path to module C:\\project',
@jscad/core:   webRequire: should support require, from a directory with index.json
@jscad/core:    43:   const requireFn = makeWebRequire(directoryWithIndexJson, { apiMainPath…
@jscad/core:    44:   const designRootModule = requireFn('/project')
@jscad/core:     message: 'Cannot find relative path to module C:\\project',
@jscad/core:   webRequire: should support require, from a directory with project.json
@jscad/core:    53:   const requireFn = makeWebRequire(directoryWithPackageJson, { apiMainPa…
@jscad/core:    54:   const designRootModule = requireFn('/project')
@jscad/core:     message: 'Cannot find relative path to module C:\\project',
@jscad/core:   webRequire: should support require, from a directory with dependent files
@jscad/core:    66:   const designRootModule = requireFn('/project')
@jscad/core:     message: 'Cannot find relative path to module C:\\project',
@jscad/core:   webRequire: should allow using require.extensions like the native node require (simple)
@jscad/core:    102:   const designRootModule = requireFn(mainPath)
@jscad/core:   webRequire: should allow using require.extensions like the native node require (parser)
@jscad/core:    151:   const designRootModule = requireFn(mainPath)
@jscad/core:     message: 'Cannot find relative path to module C:\\examples\\logo.js',
@jscad/core: npm ERR! Exit status 1
@jscad/core: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@jscad/core: npm ERR! A complete log of this run can be found in:
lerna ERR! npm run test exited 1 in '@jscad/core'
lerna WARN complete Waiting for 2 child processes to exit. CTRL-C to exit immediately.
npm ERR! Test failed.  See above for more details.
``````

• Nice! I'll pull it down tonight.