GithubHelp home page GithubHelp logo

zalo / cascadestudio Goto Github PK

View Code? Open in Web Editor NEW
957.0 35.0 118.0 190.68 MB

A Full Live-Scripted CAD Kernel in the Browser

Home Page: https://zalo.github.io/CascadeStudio/

License: MIT License

HTML 4.07% JavaScript 81.32% TypeScript 13.01% CSS 1.01% Python 0.59%
scad opencascade cad modeling brep

cascadestudio's People

Contributors

awkor avatar billiam avatar brad avatar drb3st avatar fponticelli avatar lukebarlow avatar milkowski avatar urishx avatar zalo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cascadestudio's Issues

CascadeStudio models randomly corrupted

I started playing with CascadeStudio every since the hackaday article 1-2 months ago, and I really like it.

However, as I try building more complex models I run into geometrical corruption issues, where changing a small parameter controlling the size of an objects can cause total model corruption. sometimes changing the model, evaluating it, and reverting the change fixes the corruption. For my previous model I had to rewrite it for a different platform (www.jscad.xyz), just because CascadeStudio wasn't stable enough.

Today it happened again, so I wanted to share the model to get to the bottom of it. Here is a minimum example from a larger model:


let space_diag = 0.2
let height = 60
let rad_ext = 2.5
let width = 30 - 2 * rad_ext
let line_spacing = 16.5
let axis_d = 0.5 // distance from axis to start of base
let line1_w = 1.6
let line2_w = 2
let grid_angle = (90 - 47.5)
let axis_o = -15.21 

//let holder = Translate([10,10,0], hold_s)
let line_2 = Rotate([1, 0, 0], 180 + grid_angle, Box(2, line2_w + space_diag, 3*width))
let line_1 = Rotate([1, 0, 0], -grid_angle, Box(2, line1_w + space_diag, 3*width))

let line = Translate([rad_ext, 0, height], Union([line_2, line_1]))
let line_grid = Union([
    Translate([0, axis_o, line_spacing * 2], line),
    Translate([0, axis_o, line_spacing], line),
    Translate([0, axis_o, 0], line),
    Translate([0, axis_o, -line_spacing], line),
    Translate([0, axis_o, -line_spacing * 2], line),
    Translate([0, axis_o, -line_spacing * 3], line),
    Translate([0, axis_o, -line_spacing * 4], line),
    Translate([0, axis_o, -line_spacing * 5], line),
    Translate([0, axis_o, -line_spacing * 6], line)
])
let b2 = Translate([rad_ext, 0, 0], Box(2, width, height, false))
let plane1 = Difference(b2, [line_grid])

When I render this (clean, InPrivate (same as incognito in chrome) on Microsoft Edge), I get:
bad_grid

After commenting out the last line (Difference(...)) , evaluating the script and removing the comment again, I now get:
good_grid

I think my problems in previous models were also related to Difference().

Lofting "twists"

For fun, I have tried out using Loft to try to model a rhodonea (rose) curve.

At many places, always aligned with one axis (Y I think, but without an orientation cube / vectors it's hard to tell), the loft is inverted:

image

I don't see a math mistake in my model, though it's possible that one exists. The debugging I've done so far hasn't found one.

I have this modeled well enough for my uses in OpenSCAD, I just thought Loft would be a more natural way to describe this shape than lots of polyhedron segments.

STL Files not Loading

When I try to import a binary STL file that I exported from the demo application It outputs an error to the console and stops loading the model. Besides, ASCII STL Models error out with an "Error to read binary STL" message

CascadeStudio parameter sanity checking

It seems that CascadeStudio is not doing any sanity checking on parameters. As a result, a call such as:

Sphere(-10)

Will result in:

Line 75: Uncaught ReferenceError: ___cxa_is_pointer_type is not defined
Line 18: Uncaught There were no scene shapes returned!

When this is a part of a larger script, and the parameters are due to long calculations, it is very hard to debug the scripts.
This is an example only, there are other unchecked calls.

Embed Kiri:moto into CascadeStudio?

Kiri:moto is designed to be able to be embedded; Thingiverse and Onshape both embed it for slicing/pathing. Might be a convenient integration for CascadeStudio as well?

https://grid.space/kiri/frame.html — looks like kiri.frame.parse(stlData); would be a way to have one-touch access. The only trick is that the spaces are oriented at 90° so parts I design flat in CascadeStudio are on edge in Kiri:moto which I am using for toolpathing.

Problems with npm install

First of all, I found this project through Hackady, and I think it's really great! Thank you!

I tried to add a library (newtype-ts, as described in PR #31), but running npm install newtype-ts scrambles all my local node-modules libraries.

I think there should be a better / more robust way for adding, changing, or upgrading npm modules.

Questions about performances

Hi all,

First of all, thank you for porting opencascade to wasm, it rocks!

I am having one issue using one of the examples from cadhub.xyz

The example I am using is the following: https://cadhub.xyz/u/chnorzibaert/through-hole-resistors-box/ide

I am testing how the 3D Viewer behave once we increase the value of numberOfCompartmentsHorizontal from 8 to 64 for instance.

And once I use 64 in cascadeStudio (instead of 8) then the loader is stuck at state "UNION"

image

Since the provided algo (from cadhub) is not so simple, I tested on a very simple X,Y translation of a cylinder, and then I got:

image

ending with

image

Am I missing something or is there any performance limitation to keep in mind?
In other words my question is: is CascadeStudio suitable for 2D or 3D grids of basic objects (cylinders for instance) ?

Regards,
Antony

CascadeStudio error reporting

Another bug/missing feature is a generic mechanism that shows errors in terms of script line numbers instead of pointing to the line number inside CascadeStudio where eval() is called with the script.
I've tried fixing that myself in a my private copy using a try {} block around the eval() call:

    eval('try { ' + payload.code + ' } catch(err) { console.log("xxx" , err.stack); }');

But couldn't get any useful result (I know enough Javascript to write models for CascadeStudio, but has zero knowledge about front end programming). Apparently you can only get so far by copying StackOverflow code snippets.

Questions about syntax

This seems a very promising progression for OpenScad.
I have been playing around with it and I have few questions

This is some test code I am using for examples.

 let ball = Sphere(10)
//let ball = Cylinder(20,50)

let bolero = Translate([50,0,0], ball); 

function draw(shape){

 [1,2,3,4,5,6].forEach(x=>{
    console.log(x)
    Rotate([0,0,1],60*x,shape)})
}
draw(bolero)

Questions.

  1. If my Array is [1,2,3,4,5,6] I get 6 balls. However if my array is [0,1,2,3,4,5] I only get 5 balls. I think I should get 6 since 5*60 = 360 = 0 degrees. The zero degree case does not seem to show.

  2. If I comment out ball then it persists between evaluations. (I can see I should reset the project). Not really a question I suppose.t

  3. A. If I just write Sphere(40) it draws a sphere. Fair enough.
    B. If I write let sp = Sphere(40) it also draws a sphere. Why? Shouldn't it just assign Sphere to sp.
    C. If I write let sp = Sphere(40) as above, but also pass it as a parameter to my function draw(shape), it does NOT draw the original sphere. I think this is the correct behaviour but it seems inconsistent with B.

COMMENT AND QUESTIONS. (probably ill-informed but I am trying to understand this stuff).
Looking at the code it seems that shapes are drawn on creation.
eg sceneShapes.push(curBox);
But why does it not draw when passed as a function? Is creation delayed somehow?

I dont think shapes should be drawn on creation. I think that is a mistake that OpenScad makes, too.
Like any mathematical calculation the print should not occur during the calculation phase, only when we ask it to print (or draw or whatever the appropriate name is in this context).

This way the work flow would be to design our shapes in a modular way and with composition. Drawing should be only done explicitly when we have finished designing. This would also allow a sort of backdoor to introspection because we could introspect bits of code (by a special function say boundingbox for instance) separate from the drawing process.

3D Textures

Maybe more of a question than an issue since I am not very familiar with the OpenCascade API. Is there any way to apply 3D Textures to surfaces? Something like what is described here.
I think such feature would make this library standout from many others (certainly OpenSCAD).
If OpenCascade doesn't support it naively, are there post processing strategies that people are aware of?

Random thoughts about introspection

On Hover in the GUI you get an index to a line or a face. Presumably this index refers to something that has gone through many transformations since starting as a primitive shape and thus is hard to relate to the original drawing.

Also I presume that even if we noted the index from the GUI and could do some introspection (on say face[8] for instance) the index is likely to change after even simple modifications.

It seems to me that if you can do fillet and chamfer programatically then should you know a fair bit about position of elements after various transformations.

Would it be possible do some introspection with this mechanism.

For instance say we had a box and knew the absolute coordinates of some point on the box like a corner. We could define this point then at the point of visualisation echo its new absolute position. A point can move or disappear (like in difference operation). If we knew the point survived transformations because it was still visible after being transformed then knowing its absolute position through code would be of great benefit.

Cylinder of same radius having different radius during visualization

When, I was running the following code:

function DrawCylinder(Center, Radius, Length, Angle,  Direction)
{
    let shape = Cylinder(Radius, Length, false);
    shape = Rotate(Direction, Angle,shape, false);
    shape = Translate(Center, shape, false);
    return shape
}
let scale = 2.0;
let Radius = Slider("Radius", 0.65 , 0.5 , 1.0);

let RefPipe = DrawCylinder([0,0,0], Radius *scale, 4*scale,0, [1,0,0]);
let Pipe1 = DrawCylinder([8*scale,75*scale,8*scale], Radius *scale, 4*scale, -90, [1,0,0]);
let Pipe2 = DrawCylinder([8*scale,79*scale,8*scale], Radius *scale, 12*scale, 0, [1,0,0]);
let Pipe3 = DrawCylinder([8*scale,79*scale,20*scale], Radius *scale, 37*scale, 90, [1,0,0]);

Pipe2 has a vastly different radius than rest of the cylinders. This is on google chrome.

Topo Name Issue?

Hi, I'm very new to code based CAD, so excuse me if I'm missing obvious stuff. But... do we have the topological naming issue (as known and loved in FreeCAD) here as well? Meaning when I add a fillet/chamfer after piecing together two bodies with Union() and later change a part of that union, the fillet/chamfer gets applied to a random other edge?

Recreating code deflation and inflation in other languages

I'm trying to create a simple Python script that can take a local file and open it using CascadeStudio.
My idea was to encode the file in the same format CascadeStudio uses and building a URL with that.

Encoding the parameter from python did not work (Trying to compress through zlib, encoding as base64 and then apply url encoding), so I set out to try and decode the code parameter value for the default code:

import urllib.parse
import base64
import zlib

url_data = "lZPbahsxEIbv%2FRRj3zgGpd4cXGhLbmqnJNCSEKe0TciFKo28IrJmkbSJ8%2FYdaX3CFEqXPfyaw6fZ2dnxGH6gU7RESARTGZXUCPPUakt9ALjCgCD5ijmkjWhaB6b1Klny8WNvPAa4D9JHJxMejQTcUVqruZKuiG82BApZffeclcXMGsNkr0rAtU8YIhbm0agwP9OqMJqaw7KavjnrNRbMlHyx3eMqnc2yuiX3ttgm3xgTMWX75SqFVu8Vpvct%2BELupchb25TnVzIlr2C%2BWOcwXeoFxrJrLZdc9GZdQubObmqqUT3%2F7qrOdV37pi2oWaBG02uurcc4qMnhndS2jXCxyR90hoGAswoEnObbeTX61GXE0gTIx8WmI5PszU617stDdv7t2DZut3HeoRLAjcADyq9MWX%2FCx0qciOpJwIdK%2FItygPm5j2HIf2B6u2niAoDPSU7eG5iuHQIet7uJXf07%2BfB0iDs%2BnRTgeQauZ2dwZfu57e%2FZ8%2B6E%2FUMerkhOxmFJ5488Iz9MYCgs%2BA35J2naWINdNhR4nIACkDrWaKznVaxlgxGs57io0OO8M%2FBSag2pxmXW%2FIRXCs%2BxkQr7fwA%3D&gui=q1ZKzs8tyM9LzSvxS8xNVbJSSk4sTk5MSQ3LTC1X0lHyTS3OCEotVrIy0DPUUXJOTM5ItVeyKikqTdVRci%2FKL81LCchJzEMWy0yBc4ISUzJLgXqNDWoB"

binary_data = base64.b64decode(urllib.parse.unquote(url_data))

code = zlib.decompress(binary_data)

This will always fail on the decompression step with zlib.error: Error -3 while decompressing data: incorrect header check.
It seems like other people have also come across this issue with js-deflate: dankogai/js-deflate#15 .

Any tips on how to get this to work?
If this really is an issue js-deflate, would you consider switching to a different compression library or do you want to keep compatibility with old URLs between versions?

Slow performance for Boolean

Hi.
Performing operations such as Cut on several dozen Shapes takes significantly longer (~10-20 times) than when using CAD Builder (an application using the C ++ core) where the same operations on the same Shapes are performed instantly. What could be causing this and is there any way to speed it up?

Slider with realTime false evaluates instantly, hard to change values in UI

It's hard to use the sliders.

  • Setting realTime to false doesn't prevent them from firing, making the "evaluate" button useless
  • The hover docs suggest a callback function not present in the signature.
  • Typing an exact value doesn't work; every keystroke results in lost focus and re-evaluating the model with that one character change.
  • Using the mouse doesn't work either because it starts evaluating even before I let up the mouse button, so I can't even move the slider where I want it with the mouse.
  • I can't figure out how to revert to the default values in code in an existing model, since it appears that the current slider values are encoded in the URL.

Am I missing something?

CascadeStudio + CadHub 💪

Hey @zalo,

First off thanks for putting this project together. As a big fan of OpenScad as well as being a javascript dev, I'm very excited at the prospect of js CADing, and using openCascade under the hood with wasm is very neat. I think filleting, and STEP file support alone are enough for me to buy into this.

I've been thinking about a community hub for code-cad for a while and seeing CascadeStudio made me pull the trigger and start putting something together. I don't like talking about ideas without some kind of proof of concept so here it is.

CadHub

repo

Expect bugs on the above, but you should be able to click through to a part, then "open IDE" to open up CascadeStudio for that part.

Long term I have hopes for CadHub becoming a centralised hub for all things code-cad, as I think the community is a little too dispersed atm (did you know there are this many code-cad projects!). But that's pie is the sky stuff. For the time being I'de like to make the CascadeStudio integration really solid and I think trying to form a community at the same time is a good way of increasing cascadeStudio's impact.

Anyway all of this is just to show you and ask what do you think?
Are you happy for CadHub to use CascadeStudio like this?
Are you interested in collaborating at all?
Any other ideas or thoughts?

Obviously I'm happy to lend a hand, I noticed in #32 the discussion around trying to get the project bundled, I might be able to help there, but three people might be too many.

Is firefox supported?

The page opens correctly on firefox 92.0 and generally seems to function as intended - changes in the code window are reflected in the CAD view after pressing control-s.

However the "Save Project" and "Load Project" buttons seem to have no effect in firefox. In chrome they open file dialogs as expected.

Feature Request: Better project saves

When saving a project, I face 2 problems causing inconvenience:

  1. The save file is always the same, you cannot control it
  2. The location is always the download folder

I would like to see an option for controlling the filename, perhaps by hinting it inside the project (a specially marked comment perhaps)
As for (2), I hardly know JS, and have zero knowledge about the security implication of file writes, so I don't know how easy it is to write a file to the local filesystem by the client, or pop up a 'saveAs' dialog, (and keeping the default directory from the last time it was saved).
I understand that for security reason, a client app cannot arbitrarily write to the client disk, but with a saveAs dialog, perhaps this is possible, since it requires user intervention?

Interface questions

First of all I would like to thank you for developing this project!!
I have some questions about the interface and how to display 3D models:

  1. I want to know if you can change the type of camera from perspective to orthographic
  2. If you zoom out - respectively the object moves in size, in a short time it disappears from the scene - can this aspect be remedied?
  3. It is possible to display a scene world coordinate system?
  4. It is possible to change the colors/size of the grid scene and the scene color: for example the background scene color to be white or less darker than actual color - best for me a subtle grey gradient?
  5. It is possible to change the rotational movement of the camera? For example Helix Toolkit uses turntable/turnball/trackball rotational styles and inspect/walkaround/fixedposition CameraMode..
    Thank you!!

CSG.scad reimplemented in CascadeStudio

Chamfer/Fillet/Union/Difference unexpected behavior

This may just be my misunderstanding, but I'm running into a couple of issues related to chamfers and fillets:

Example

When applying a chamfer to one or more already-filleted edges, the edge which will be chamfered is unpredictable and doesn't respect the selected edge(s), and then the filleted edge reappears.

When a shape with a chamfer is Unioned or Differenced with anything else (including just Union([self])), the previously chamfered edges reappear in place.

Request: STL Z direction

Step and STL exports use a different Z-up direction currently.

It would be nice if STLs could be rotated during export to match the step export (and display)

PEBCAK? Debugging internal opencascade error

I'm trying to recreate a curve generator inspired by Youness Alaoui's OpenSCAD curve generator that I've been playing with, but rewriting it to (at least for now) be limited to the rhodonea curve and using polygons and loft.

I substantially rewrote it in OpenSCAD from using linear extrude to assembling polygons, and wished that OpenSCAD had a loft function. Then I remembered that CascadeStudio has Loft() so I thought I'd give it a shot here.

My attempt at a CascadeStudio model almost certainly has a bug that is hard to debug due to the internal error. But I haven't identified yet what I did wrong.

Line 140: Uncaught ReferenceError: INTERNAL OPENCASCADE ERROR DURING GENERATE: ___cxa_is_pointer_type is not defined

If Loft() can't self-intersect, then I can't make this shape, so I'm hoping that's not the problem, but I don't have enough experience to guess correctly so far what I might have done wrong. I get a different error if I limit myself to three iterations to avoid self-intersection, so perhaps there's more than one problem.

This is just an intellectual exercise—my OpenSCAD model is sufficient for my arcane purpose—but if this can work it might make a nice example! ☺

Scene - Edit Defaults

Hello,
how can i remove fog from the scene, add more light to it and make bigger the view frustum so my whole model to be visible?

Thank you in advanced

Execution via node.js, is it possible?

This might already be possible but I couldn't see any docs or obvious entrypoint CLI tool to do this? Can WASM be used with node???

Say I have a JS/TS script that defines my model can I use node.js (not the browser) to then export an STL/STEP/SVG/etc file?
Similar to the example given by CadQuery https://cadquery.readthedocs.io/en/latest/installation.html#test-your-installation

I like the idea of using say VsCode on one screen to edit the JS/TS script and then having a simple STL viewer open on another screen watching for changes. This is similar to how I can use both OpenSCAD and CadQuery.

Other use cases would be the ability to have a CI/CD pipeline that say automatically generates various exports like an STL, 2d plans, bill of materials, slices it into gcode if your 3d printing & then creates a new github release with such assets just like you would if it were a traditional software package that your pipeline was compiling & releasing.

Union operation failure

The script shown below gives the following error in the cascadestudio console:

Line 78: Uncaught ReferenceError: Line 68: Union() encountered ___cxa_is_pointer_type is not defined

and this traceback in the chrome browser console:

Uncaught ReferenceError: Line 68: Union() encountered  ___cxa_is_pointer_type is not defined
    at ___cxa_find_matching_catch_2 (opencascade.wasm.js:11)
    at opencascade.wasm.wasm:0x8a0cbe
    at opencascade.wasm.wasm:0xbe966e
    at invoke_viiiiidddiiiiii (opencascade.wasm.js:11)
    at opencascade.wasm.wasm:0x8b318d
    at opencascade.wasm.wasm:0xbec1c2
    at invoke_viii (opencascade.wasm.js:11)
    at opencascade.wasm.wasm:0x8ba63f
    at opencascade.wasm.wasm:0xa3f12b
    at ShapeUpgrade_UnifySameDomain.Build.ShapeUpgrade_UnifySameDomain.Build (opencascade.wasm.js:11)

The two components being combined with Union() both render correctly without error.

What's the way to debug this?


Test script

let num_leds = 30;
let led_spacing = 17;
let triangle_spacing = led_spacing * Math.cos(30 * Math.PI / 180);
let wall_thickness = 1.5;
let lightbox_depth = 35;
let inner_diameter = num_leds * triangle_spacing / Math.PI;
let outer_diameter = inner_diameter + lightbox_depth;
let layer_height = outer_diameter * Math.PI / num_leds * Math.tan(60 * Math.PI / 180);
let diffuser_overhang_thickness = 1.2;
let diffuser_wall_thickness = 1.0;
let diffuser_radius_gap = 0.1;
let cap_vert_overhang = 5;
let cap_horz_overhang = 3;
let top_cap_diam = outer_diameter + 2 * (diffuser_radius_gap + diffuser_wall_thickness + cap_horz_overhang);
let base_outer_radius = top_cap_diam / 2;
let base_outer_height = 20;
let inset1_radius = base_outer_radius - cap_horz_overhang;
let inset1_height = cap_vert_overhang;
let inset2_radius = inner_diameter / 2;

// A box in cylindrical coordinates 
function ccbox(x1, x2, a1, a2, z1, z2) {
    const rect = new Sketch([x1, z1])
        .LineTo([x1, z2])
        .LineTo([x2, z2])
        .LineTo([x2, z1])
        .End(true)
        .Face();
    return Rotate([0, 0, 1], a1, Revolve(Rotate([1, 0, 0], 90, rect), a2 - a1, [0, 0, 1], false, false))
}

function leg() {
    let height = 40;
    let hextra = 5;
    let angle = 20;
    let aextra = 20;
    let fillet1 = 10;

    const box1 = ccbox(inset2_radius, inset1_radius, -(angle + aextra) / 2, (angle + aextra) / 2, -height, hextra)
    const box2 = FilletEdges(
        ccbox(inset2_radius, inset1_radius, -(angle + aextra) / 2, -angle / 2, -height, 0),
        fillet1, [6]
    )
    return  Difference(box1, [box2])
}

function base() {
    let shell = Cylinder(base_outer_radius, base_outer_height);
    let inset1 = Cylinder(inset1_radius, inset1_height);
    let inset2 = Cylinder(inset2_radius, base_outer_height);
    return Difference(shell, [
        Translate([0, 0, base_outer_height - inset1_height], inset1),
        inset2
    ])
}

// Works:
//
// base()

// Works:
//
// leg()

// Reports error, but renders as expected:
//
Union([base(),leg()])

// Reports same error and fails to render correctly as intersection
//
// Intersection([
//     ccbox(30, 100, -30, 30, -50, 50),
//     Union([base(),leg()]),
// ])

Line 18: Uncaught Null Shape detected in sceneShapes; skipping

I'm trying our CascadeStudio after years of OpenSCAD and there are a lot of things I really like about it! A well-known language, fillets and chamfers, and so far zero Z-fighting come to mind. Thanks for working on it, it's really an attractive idea. I looked around for something geometrical to model as an exercise and saw a game, so tried modeling it as an exercise to learn CascadeStudio.

The line numbers in the error messages not being linked back to the line numbers in the source has given me a little trouble finding the occasional misplace parenthesis. But this looks like even if the model has a bug, it might also be a bug in CascadeStudio. I'm getting lots of errors of this sort:

Line 18: Uncaught Null Shape detected in sceneShapes; skipping: {\"ptr\":16073848,\"hash\":-1935030109}
...

I narrowed my model down to something relatively simple:

https://zalo.github.io/CascadeStudio/?code=hVJNa4QwEL37K%2BaoNf3QuqVg97KnFhYKpaWHsgfrjq4gsWgEbdn%2F3kliPnZ7aBCTGTPvvXljiwLKFou%2B4CXCGpI8aCn1WQy4RU6JdKUzI2%2FEQPG9DvfvzZ4ic%2B8a0qssyZZi%2FMb2iQ90XMPtkuuKXtaIA%2BU01oWtjiGVkS3LA1fziE19kECLji%2BsberOpp6rStO5zySJgD0MQq1GXoqm4%2FJaGMFPALQWiC3WVK%2F6unSW5OpKj2LsObx0ohAYftwwoCfZMchWDDbdFOp6Bt6uSRmIfsQoyoOjRy8b30hlJyKUVtLwSsxD6zH5RlBbO83pLGXw53zOLjmqrodQEk1q0LQ96FHQMY6NEqNmsp6GEzmiZ0bskRtcbgss9KyhZwc9n0Ib%2BNnBz%2F%2FCy2XceePkoG6e%2BVYteplBZu6%2FIMP0xI0Tch0D917mq0DVpLwB5b8%3D&gui=Pc0xC8IwEAXgvyI3h3AmLmYR0VWHDC7icCanDTZp6bU4iP%2FdKNTxPd7He0Hoct8VLuORMoODQBIo8inxExQcWBrPAg61sf%2Foqdzr9owal8pcFOwoNLwBNw4TK%2FAU01SNtXo9p5kYVCusYivC%2BdpyBHejVqra0%2FBY9InD9%2B7XvT8%3D

Thanks!

saving doesn't work for me?

what do I have to do? I can't save anything nothing hapend when I press any save or load button. Do I have to clone the project to my account? I have install it as an app in chrome under debian/testing.

Add Color() for viewing?

I could imagine Color("colorspec", [oc.TopoDS_Shape]) or something like that to apply a color to a list of objects.

Sometimes I apply random colors to objects just to be able to tell them apart easily when I'm making a complex model.

If the "colorspec" included alpha it could be used for debugging as well; if that's hard to do with oc then perhaps instead there could be a separate Transparency() that is like it but provides, say a 0-1 range of transparency for the object.

RuntimeError: function signature mismatch

I use the following code to generate a list of TopoDS_Shape brepList

function ForEachShell(shape, callback) {
  let shell_index = 0;
  let anExplorer = new oc.TopExp_Explorer(shape, oc.TopAbs_SHELL);
  for (anExplorer.Init(shape, oc.TopAbs_SHELL); anExplorer.More(); anExplorer.Next()) {
    callback(shell_index++, anExplorer.Current());
  }
}

Then modify one of the shape in brepList like
brepList[0] = Rotate(axis = [0, 1, 0], degrees = 1, brepList[0] );
and the following code to make an compound

let scene = new oc.TopoDS_Compound();
let sceneBuilder = new oc.BRep_Builder();
sceneBuilder.MakeCompound(scene);
brepList.forEach((curShape) => {
                  console.log(curShape)
                  sceneBuilder.Add(scene, curShape);
});
this.updateShape(scene, 0.01 )

I got Uncaught RuntimeError: function signature mismatch at BRep_Builder.Add.BRep_Builder.Add (http://127.0.0.1:5500/node_modules/opencascade.js/dist/opencascade.wasm.js:11:914335)

Any suggestion? Did I misuse the functions? I print the curShape and it looks fine...
@zalo

Feature request: Make project JSON more friendly for software version control

At the moment, the script is saved as a single string with embedded newlines.
In order to make diffing different versions easier, could you please store the multiline script as a string array?
inspired by: https://stackoverflow.com/a/7744658
e.g. instead of :

    "code": "// a\n// b\n// c\n",

It would be stored as :

    "code": [
            "// a",
            "// b",
            "// c"
    ],

You could still support reading single string scripts, but write it out as a string array.

Why GPL license?

Disclaimer: Not a lawyer or an expert on licenses.

This is a really interesting project that could be a great alternative to OpenScad and others. I am wondering if the current licensing is deterring people from collaborating to it as it is not the most liberal license out there. What is the rationale to not use more permissive licenses like MIT or Apache 2?

Thanks for the great work!

Is BRepBuilderAPI_MakeEdge from GC_MakeArcOfCircle not working?

Hi. I am trying to create an edge from an arc:

let arc_curve = new oc.GC_MakeArcOfCircle(p1, p2, p3).Value();
let arc1 = new oc.BRepBuilderAPI_MakeEdge(arc_curve).Edge();

sceneShapes.push(arc1);

but I get the error:

Line 12511002: RuntimeError: indirect call to null
Line 18: uncaught exception: There were no scene shapes returned!

Everything works for an edge from a line (GC_MakeSegment) .

Orientation cube in the viewer

It would be great to have a classic orientation cube in the viewer, that would indicate the camera orientation,
as well as allow for easy navigation between the views.

image

Is this a feature you think would be handy for the project?

Thanks

Units and aggressive fog

Hi,

I assume the system is made for arbitrary units, like openscad.
When I assume the units to be mm, and I make a 15mmx15mmx400mm prism the fog hides most of the model.
If I try and scale the units down, ex: instead of passing 15, 400, I'm passing 1.4 and 40, I get this error:

Line 140: Uncaught RuntimeError: INTERNAL OPENCASCADE ERROR DURING GENERATE: function signature mismatch

It looks like not all the functions accept both floats and ints, or it's not possible to mix argument types.

Is this intentional? I see that the fog is added in the three.js scene, I assume it's some sort of a standard scene type.
Maybe it's worth allowing adjusting the fog intensity? Or add the ability to toggle it?

Thanks

Trying to call BRepOffsetAPI_MakeThickSolid

Firstly thank you for making such a good tool.

I'm trying to go through the Open CASCADE tutorial using the oc namespace.
https://old.opencascade.com/doc/occt-7.0.0/overview/html/occt__tutorial.html

Im stuck calling BRepOffsetAPI_MakeThickSolid and am getting an error in the console.
"Line 9943664: RuntimeError: indirect call to null"

there is my code for now.

var myHeight = 70;
var myWidth  = 50;
var myThickness  = 30;

// define Geomertic points
var aPnt1  = new oc.gp_Pnt(-myWidth / 2., 0, 0);
var aPnt2 = new oc.gp_Pnt(-myWidth / 2., -myThickness / 4., 0);
var aPnt3 = new oc.gp_Pnt (0, -myThickness / 2., 0);
var aPnt4 = new oc.gp_Pnt (myWidth / 2., -myThickness / 4., 0);
var aPnt5 = new oc.gp_Pnt (myWidth / 2., 0, 0);

// define Geometric Arcs and lines
var aArcOfCircle = new oc.GC_MakeArcOfCircle(aPnt2,aPnt3,aPnt4).Value();
var aSegment1    = new oc.GC_MakeSegment(aPnt1, aPnt2).Value();
var aSegment2    = new oc.GC_MakeSegment(aPnt4, aPnt5).Value();

// define edges
var  aEdge1 = new oc.BRepBuilderAPI_MakeEdge(aSegment1).Edge();
var  aEdge2 = new oc.BRepBuilderAPI_MakeEdge(aArcOfCircle).Edge();
var  aEdge3 = new oc.BRepBuilderAPI_MakeEdge(aSegment2).Edge();

// define wire
var  aWire = new oc.BRepBuilderAPI_MakeWire(aEdge1, aEdge2, aEdge3).Wire();


// define x axis to mirror the wire
var xAxis = oc.gp.prototype.OX();

// define transformation
var aTrsf = new oc.gp_Trsf() ;
aTrsf.SetMirror(xAxis);

// perform the transform
var aBRepTrsf = new oc.BRepBuilderAPI_Transform(aWire, aTrsf);

var aMirroredShape = aBRepTrsf.Shape();

var  aMirroredWire = oc.TopoDS.prototype.Wire(aMirroredShape);
 
var mkWire = new oc.BRepBuilderAPI_MakeWire() ;
mkWire.Add(aWire);
mkWire.Add(aMirroredWire);


var myWireProfile = new oc.TopoDS_Wire( mkWire.Wire());

 var myFaceProfile = new oc.BRepBuilderAPI_MakeFace(myWireProfile).Face();

var aPrismVec = new oc.gp_Vec(0, 0, myHeight);

var myBody = new oc.BRepPrimAPI_MakePrism(myFaceProfile, aPrismVec).Shape();

var mkFillet = new oc.BRepFilletAPI_MakeFillet(myBody);

var anEdgeExplorer = new oc.TopExp_Explorer(myBody, oc.TopAbs_EDGE);

while(anEdgeExplorer.More()){
    var anEdge = oc.TopoDS.prototype.Edge(anEdgeExplorer.Current());
        mkFillet.Add(myThickness / 12., anEdge);
    anEdgeExplorer.Next();
}

myBody = mkFillet.Shape();

var neckLocation = new oc.gp_Pnt (0, 0, myHeight);
var neckAxis = oc.gp.prototype.DZ();
var neckAx2 = new oc.gp_Ax2(neckLocation, neckAxis);

var  myNeckRadius = myThickness / 4.;
var myNeckHeight = myHeight / 10;
var MKCylinder = new oc.BRepPrimAPI_MakeCylinder (neckAx2, myNeckRadius, myNeckHeight);
var myNeck = MKCylinder.Shape();

myBody = new oc.BRepAlgoAPI_Fuse(myBody, myNeck).Shape();

var faceToRemove;
var zMax = -1;

for(var aFaceExplorer = new oc.TopExp_Explorer(myBody, oc.TopAbs_FACE) ; aFaceExplorer.More() ; aFaceExplorer.Next()){
    var aFace = oc.TopoDS.prototype.Face(aFaceExplorer.Current());

    var aSurface = oc.BRep_Tool.prototype.Surface(aFace).get();
    
    if(aSurface.DynamicType().get().Name() == 'Geom_Plane'){
        var aPlane = new oc.Handle_Geom_Plane(aSurface.DynamicType().get()).get();
        var aPnt = aPlane.Location();
        var  aZ = aPnt.Z();
        if(aZ > zMax){
            zMax = aZ;
            faceToRemove = aFace;
        }
    }
}
var facesToRemove = new oc.TopTools_ListOfShape();
facesToRemove.Append(faceToRemove);
var MyBody = new oc.BRepOffsetAPI_MakeThickSolid().MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50,1e-3);

sceneShapes.push(MyBody);

How to start the program?

Thanks for sharing your work.

Could you please explain how to start the web application in the README? That would be great for beginners like me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.