Open GoogleCodeExporter opened 8 years ago
Very interesting usage of Jsc3d library! It is somewaht similar to a commercial
application called princeton-ring, except that they generate ring models via a
gateway program running on server side.
I took a quick look into your code. The basic idea is alright. To update the
ring model according to the new parameters, just remove the old mesh from the
scene object, construct a new one from the new values and then insert the new
mesh to the scene. The interface of the scene object is documented here:
http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Scene.html.
I've made some modifications into your code as well as correcting a minor bug.
It seems the output is as expected now. See the modified version in the
attachment please :-)
Original comment by Humu2...@gmail.com
on 15 Nov 2014 at 7:48
Attachments:
Wow! This is great.
Eventually I want to port over code I use in blender scripts to create these
types of rings: http://www.5xj.com/wood_rings/woodrings_insert.html
Thanks a lot - this really helps.
Roy
Original comment by cnc...@gmail.com
on 15 Nov 2014 at 9:31
My pleasure! I'll be glad if you could show me the final outcome when it's done.
Original comment by Humu2...@gmail.com
on 16 Nov 2014 at 2:11
By the way, if you are to generate real-looking ring models by coding via
parameters, I guess this application http://humu2009.github.io/OpenJSCAD can be
a good reference, which is capable to produce very complicated models using CSG
method.
Original comment by Humu2...@gmail.com
on 16 Nov 2014 at 2:39
I've been working on ring scripts in blender for quite a few years now.
It's a whole lot easier for me to port my python scripts to javascript than it
is to go with OpenJSCAD.
My scripts also generate *.NC files that cut the rings.
(the scripts are designed from the ground up to be able to generate *.nc
files...
it doesn't do me any good to create pretty pictures if I can't make the rings)
You can see videos of the mills cutting rings here:
https://www.youtube.com/user/www5xjcom/videos.
You can also download the blender (2.49b) script here:
http://www.5xj.com/blendercnc/Blender_5xj_Rings.html
Original comment by cnc...@gmail.com
on 16 Nov 2014 at 3:39
Thanks Roy! It looks charming! I've never seen a wood ring as exquisite as
these ones.
Original comment by Humu2...@gmail.com
on 16 Nov 2014 at 8:08
Here is a Tongue & Groove Ti Lined Ring Demo.
I love the way this project is coming together.
I couldn't have done it without your help.
Roy
Original comment by cnc...@gmail.com
on 17 Nov 2014 at 11:09
Attachments:
Just impressive! Don't hesitate to drop me a note whenever you need any
technical support in developping this great application :-)
Original comment by Humu2...@gmail.com
on 17 Nov 2014 at 1:53
Half Round Band Demo.
Still needs error checking on inputs.
Original comment by cnc...@gmail.com
on 20 Nov 2014 at 6:48
Attachments:
Current pages: http://www.5xj.com/WoodRings/jsc3d/HalfRoundTongueGroove.html
What I'm trying to do is map graphics (xyz pt files) and html text inputs
onto the inside and outside of rings.
Re: the spinner ring - how can I rotate (with a button input, 10 deg at a click)
the half round object window object and it's graphics about the rest of the
objects.
ie. I just want to spin a single object.
Thanks
Roy
Original comment by cnc...@gmail.com
on 21 Nov 2014 at 7:03
Well done!
Need to rotate a single component? It's nothing more than making transformation
(rotation only) onto all vertices of that mesh and regenerate the mesh.
First you should know the axis to rotate around, from which to construct a
rotation matrix. Then, transform all the vertices with it. And finally, create
a new mesh with the transformed vertices and replace the old mesh.
It requires a bit more coding work but not very hard.
Original comment by Humu2...@gmail.com
on 21 Nov 2014 at 11:17
I got the spinner ring 'window' working.
Now I'm trying to deal with drawing 'lines' in 3d space.
What I'd like to do is draw a line or edge using two verts.
yea, I know, this is a problem when you render graphics.
Do I have to create a face (with 4 verts) in order to draw a line?
The reason I ask is I do a lot of simulation with toolpaths, and toolpaths are
edges...
or lines... at least what I'm using.
Or would it be possible to write a function that inputs two verts and creates 4
verts and a face so I could display 'lines' (from *.xyz pt files or scripts) in
3d space?
ok, one problem with lines is where is the normal pointing? I guess you would
have to specify it somehow. (or draw a cylinder)
What I'd usually do is draw the lines on a flat rectangle (regular canvas 2d)
and
then map the flat surface to a known ring surface.
I've been screwing around with this issue for a long time (in blender) and
haven't
found a good solution. Sometimes I extrude lines (or bezier curves) to create
surfaces... but it always a cluge. (because I'm not extruding the lines on a
surface)
Roy
Original comment by cnc...@gmail.com
on 22 Nov 2014 at 1:51
Yes indeed, there's no line primitive in Jsc3d, only faces are supported. But
it won't be a problem. The idea is as following:
For every line segment, we create a triangle face with the third vertex
coinciding with the first one. Say we have a mesh that contains only a single
line segment:
var line = new JSC3D.Mesh;
The trick is like this:
line.vertexBuffer = [x0, y0, z0, x1, y1, z1];
line.indexBuffer = [0, 1, 0, -1];
and here are the key steps:
line.isDoubleSided = true; // disable face culling
line.init();
line.setRenderMode('wireframe');
which specifies this degenerate triangle should be rendered as lines and
disables face culling. As for the normals, we just don't mind them since thay
would never be used in drawing this type of faces.
The property 'isDoubleSided' and the method 'setRenderMode' are documented
here: http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Mesh.html.
And a good example may be this one:
http://jsc3d.googlecode.com/svn/trunk/jsc3d/demos/hotel.html, where the
bounding box is calculated with code and is sent to display using the method
mentioned above.
Original comment by Humu2...@gmail.com
on 22 Nov 2014 at 3:15
Thanks, this really works.
I edited my blender *.obj export script to add the third vertex. (simple mod)
The attached files show that it works great (the cave.obj toolpath being used
in HalfRound_cave.html).
Things I don't understand:
1. How do I load obj files and not overwrite the interactive meshes.
I'm doing something wrong. Just don't understand the process.
2. Can I scale obj files on the fly when I make changes in ring size?
ie. can I edit the loaded obj file verts list?
Thanks
Original comment by cnc...@gmail.com
on 22 Nov 2014 at 8:13
Attachments:
It looks fine!
1. Do not specify the 'sceneUrl' startup parameter. Use a loader object
(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.ObjLoader.html)
instead. The 'onload' handler of the loader object should be overridden with a
call back function to receive and process the result. You can see the modified
version in the attachment for how it works. A problem is that the loaded
ornament part may need to be rotated to fit the ring.
2. Yes of course. It's a mesh object too. You can get its vertices by access
the 'vertexBuffer' array and transform (scale/rotate) the vertices using the
same method as that for the ring part. It should be noted that file requests
through network are asynchronous, so you should check whether the mesh is ready
before accessing its properties.
Original comment by Humu2...@gmail.com
on 23 Nov 2014 at 7:53
Sorry, here is the attachment.
Original comment by Humu2...@gmail.com
on 23 Nov 2014 at 7:55
Attachments:
Thanks a lot - You've been a big help.
Roy
Original comment by cnc...@gmail.com
on 23 Nov 2014 at 8:06
11/23/14
http://www.5xj.com/WoodRings/jsc3d/HalfRoundTongueGroove.html
'Spin Cave Faces' controls the spinner window width.
'Spin Ang' rotates Spinner on Ring.
'Cave' Toolpath pocketed graphics are on the 'Ring Body'
Original comment by cnc...@gmail.com
on 23 Nov 2014 at 9:52
I've been unable to figure out how to add two obj files to this project.
I can get twoObj.html to load the two obj files
but that's as far as I've been able to go.
Cave obj scales up and down nicely with size change.
Spinner window now in mm's.
Spinner rotation now in deg's.
Original comment by cnc...@gmail.com
on 24 Nov 2014 at 2:22
Attachments:
I introduced some new errors in the above file, this puts things back to where
the cave obj loads ok.
Original comment by cnc...@gmail.com
on 24 Nov 2014 at 2:38
Attachments:
There's just a small mistake. A loader object would better not be used to load
more than one files. The best practise is to create a loader object for each
request. See the fixed version in the attachment. I think it works as expected
:-)
Original comment by Humu2...@gmail.com
on 24 Nov 2014 at 12:42
Attachments:
You make it look easy, I can follow your examples but I really just see
patterns.
I don't understand the fine details.
This looks really good. I'm running out of questions.
Thanks again.
Original comment by cnc...@gmail.com
on 24 Nov 2014 at 1:55
Hi, Roy:
Once the major functions have been done, you could try to add WebGL render
support for the application, which is capable to make use of hardware
acceleration (if available) for better graphic quality and higher performance.
It's just easy. Include this file:
jsc3d.webgl.js
together with other script files. And then assign an extra startup parameter
for construction of the viewer instance:
var viewer = new JSC3D.Viewer(..., {
...,
Renderer: 'webgl'
});
to enable the WebGL render backend explicitly. This parameter is documented
here http://code.google.com/p/jsc3d/wiki/StartupParameters#Renderer. It would
not do harm on browsers where WebGL is unavailable.
Original comment by Humu2...@gmail.com
on 26 Nov 2014 at 4:07
Looks like everything works now.
Rocket obj rotates with spinner.
Rocket expands and contracts when ring size changes.
Added webgl support (my computer doesn't support it)
The next thing I need to work on is materials.
I'm really surprised how responsive this program is.
I was afraid the larger obj files would kill things but that doesn't seem to be
the case.
attached file uses cave and rocket obj files posted on nov23.
Original comment by cnc...@gmail.com
on 26 Nov 2014 at 5:44
Attachments:
I have tested this on IE9 which does not support WebGL and has a rather slow
javascript runtime (compared to modern browsers). The performance is ok. If
the models grow so large that the calculation does impair performance, we can
shift the calculation to a WebWorker object which won't block the main/UI
thread. It's not likely to employ such a complicated solution at this momment
:-)
Original comment by Humu2...@gmail.com
on 26 Nov 2014 at 8:41
performance issues - I was thinking about comparing this what we are doing here
to
https://sketchfab.com/models/AgxzXjmbpXZIDGriASsO42nXCdF
It isn't a fair comparison.
I have a lot of control over the obj file size. With toolpaths if I inc the
step over distance file size will drop. Also, before I export the obj file in
blender I can specify the min dis between pts. Numbers between 0.1mm and 0.2mm
seem to work well but if needed they can go larger (with resulting img
degradation)
The other thought - we can check out which browser is running,
if it's a old/slow browser just load low resolution obj files.
(and add a note: upgrade your browser for better performance)
Original comment by cnc...@gmail.com
on 26 Nov 2014 at 11:30
Good idea! If necessary, we can generate a series of copies in descending LOD
levels from a large model using a mesh simplification tool such as Simplygon,
etc.
Original comment by Humu2...@gmail.com
on 26 Nov 2014 at 12:55
made axis corrections to the half round routines.
(xz pts changed to xy pts)
(ring frame is now aligned with blender frame)
I looked at simplygon, seems like overkill to me.
It may be a great program but I'm very happy these Blender results.
Here are different resolution test files:
max resolution: amy_2_jsc3d.obj - as good as it gets, overkill
93582 verts 93542 edges 4782 kb file size
0.02mm min dis between pts - amy_2a_jsc3d.obj
40989 verts 41359 edges 2085 kb file size
0.03 mm between pts - amy_2b_jsc3d.obj - still looks ok - the sweet spot?
25200 verts 25565 edges 1272 kb file size
0.04 mm between pts - amy_2c_jsc3d.obj - starting to look bad
18346 verts 18961 edges 924 kb file size
0.05 mm between pts - amy_2d_jsc3d.obj - that's as low as I went
11878 verts 13042 edges 600 kb file size
Original comment by cnc...@gmail.com
on 27 Nov 2014 at 3:18
Attachments:
had to break up attachments - exceeded 10MB limit
Original comment by cnc...@gmail.com
on 27 Nov 2014 at 3:23
Attachments:
server say 'project attachment quota exceeded' so no amy_2_jsc3d.obj file.
It's not all that important other when I machine these rings
I want all the info that I can get.
I'm running 5mm ballscrews with 8000 step/rev encoders...
With very tiny cutters (down to 0.1mm running up to 70k rpm cutting titanium)
So the mill is capable of pretty fine work.
I'm not sure if it really matters but I'll take it.
Original comment by cnc...@gmail.com
on 27 Nov 2014 at 3:34
I've rewritten all the pages. They are linked together.
(pipe cut, half round, tongue & groove, spinner)
A major change to these pages is I've converted all the rings to the xy
reference frame.
(which aligns them with the blender reference frame - also requires new obj
files)
The http://www.5xj.com/WoodRings/jsc3d/HalfRound.html
page now has comfort fit and toolpath toggles.
I don't understand why after you manually switch to 'render to environment'
and then toggle comfort fit or toolpath that rendering reverts to 'smooth'
To restore 'rendering to environment' you have to manually switch out of
'environment'
and then back into 'environment'.
Can't get it stay in 'environment' (even though it says it's still in
'environment'.
Also, when I load http://www.5xj.com/WoodRings/jsc3d/Spinner.html
sometimes the spinner angle cmd spins rocket obj with the spinner ring -
and sometimes it doesn't.
Most of the time it works... but it's not consistent behavior.
Original comment by cnc...@gmail.com
on 28 Nov 2014 at 9:23
[deleted comment]
You can set the property 'isEnvironmentCast' to true each time a new ring mesh
is calculated. I fixed it directly into your code. It is in the attachment.
It seems the second problem does not ocur on my own tests (Firefox 18, Chrome
28, Opera 11.2). Has it something to do with a specific browser? Is there any
error reported in your browser's console?
Original comment by Humu2...@gmail.com
on 29 Nov 2014 at 7:17
Attachments:
With Google Chrome Version 39.0.2171.71 m on a 32 bit windows xp machine
the 'rocket' spin alignment fails every so often when the page is loaded.
(ie. spinner body rotates, rocket toolpaths do not)
I haven't seen any errors displayed.
If I reboot chrome, sometime the problem goes away, sometimes it doesn't.
After 2 or 3 reboots problem seems to go away for a while.
I have no clue why this is happening - its very infrequent.
With limited tests have not found this to be a problem with Firefox or Opera.
Original comment by cnc...@gmail.com
on 29 Nov 2014 at 8:33
Well, is it because something is not ready when the rotation is executed? The
new edition uses more than 1 models and the all file requests are asynchronous.
So there's probability that when we spin, some components are still in loading,
thus the command is not applied on them.
Original comment by Humu2...@gmail.com
on 29 Nov 2014 at 9:10
I'm beginning to think it's a bug in Chrome.
Just now tried it (didn't work),
reloaded the page several times in Chrome,
waited a long time,
still didn't work.
Exited Chrome, Started again Chrome and it worked fine.
I think I'll just have to live with this tiny problem.
Or it could be the satellite connection, or the computer, or the wind blowing.
Original comment by cnc...@gmail.com
on 29 Nov 2014 at 1:36
I think we should try to insert some debug code that outputs runtime
information to watch the execution of that command.
Original comment by Humu2...@gmail.com
on 29 Nov 2014 at 3:11
Sounds good.
Just ran the spinner from win 7 64bit machine,
both firefox and chrome not rotating rocket obj with spinner.
What can I do to help?
Original comment by cnc...@gmail.com
on 1 Dec 2014 at 5:58
When the spinner slider does not work
http://www.5xj.com/WoodRings/jsc3d/Spinner.html
the resize scaling of the toolpaths also does not work.
When these are not working I noticed also that the resize scalling of toolpaths
are also not working on this page:
http://www.5xj.com/WoodRings/jsc3d/HalfRound.html
I tried to tie the rocket spinning to the onloader function
http://www.5xj.com/WoodRings/jsc3d/Spinner2.html
to try and force movement... but that didn't help.
It looks like I'm unable to access the *obj.vertexBuffer[i] array pts.
(when things don't work)
Original comment by cnc...@gmail.com
on 1 Dec 2014 at 5:17
Ok, I have something concrete to report.
The trouble I've been having is on a computer that supports webgl.
http://www.5xj.com/WoodRings/jsc3d/Spinner2.html does not work on this computer.
http://www.5xj.com/WoodRings/jsc3d/Spinner3.html does work on this computer.
The only differences between Spinner2 and Spinner3 is I commented out
// , Renderer: 'webgl'
So, I guess I don't have webgl set up right.
Original comment by cnc...@gmail.com
on 2 Dec 2014 at 12:12
Thanks Roy! I've caught the problem.
I noticed that you make in-place update on vertex buffers of the decoration
components when the spinning angle has been changed. When WebGL is enabled, a
mesh will be compiled to a group of buffer objects in the background, which
will latter be sent to the WebGL layer for rendering. If you make in-place
update, the compiled stuff stay unchanged without being noticed to be updated
or rebuilt.
It's recommended to create a new mesh each time the vertices of an object have
been updated. But for your convenience, a small hack can be applied to achieve
the goal, too. When the vertices have been changed, invalidate the 'compiled'
property of a mesh:
mesh.compiled = null;
It drops the compiled buffer objects and makes the render backend to rebuild it
on next frame.
I've fixed the bug in Spinner2.html. It works correctly now. Please check the
new version in the attachment.
Original comment by Humu2...@gmail.com
on 2 Dec 2014 at 3:09
Attachments:
Wow, I'd never figure this one out. What a difficult problem.
I hope it didn't drive you crazy (like it did me).
These objects I'm updating are always going to be a collection of edges
('toolpaths').
The question I have is what type of performance advantage is there with webgl?
Things seem to perform fast without it. Is it even worth using webgl with this
app?
Thanks for all you hard work.
Original comment by cnc...@gmail.com
on 2 Dec 2014 at 4:09
Oh, WebGL opens the door for web content to utilize the power of hardware
accelerated drawing. As on my system (Vista + Chrome/Firefox), Jsc3d + WebGL
outputs much better frame rates and there's additinal improvement of graphic
quality too. The larger the model grows, the more obvious the advantage is :-)
If WebGL is disabled or not supported on a platform (most mobile browsers still
does not support it at this moment), Jsc3d will seamlessly fall back to an
inner software renderer on implementation level, which walks through the
graphic pipeline and does the rasterization using pure Javascript code. This is
ok but less powerful.
I suggest you always assign that parameter to ask Jsc3d to select WebGL
rendering whenever available. It is harmless.
Original comment by Humu2...@gmail.com
on 2 Dec 2014 at 7:32
new design: http://www.5xj.com/WoodRings/jsc3d/Sides4.html
A few questions:
1. is it possible to take string characters with font specifications from html
and place them in the 3d canvas screen - and then position them in 3d space
(over existing objects)? Or do you have to convert these characters to objects.
If so, is there an easy way to do this (in page, on the fly)?
2. can I change the color of an 'edge' in a toolpath object on the fly
ie. I'd like to simulate machining nc files and run the file and change colors
as I go.
3. can you time movements, ie. if I simulate machining a toolpath can I control
how fast I process thru the file?
4. with the console, are there output specifications possible (like with scanf
in C)?
ie. can I limit the number of decimal places when writing to the console?
5. I'm using notepad++ to edit html files, can you recommend a better editor
(but I do like notepad++)?
when working with html and javascript I'm getting no error reports at all when I mess up a javascript line.
That makes it difficult to debug things. (maybe I can config notepad++, if so - how?)
Thanks again.
Original comment by cnc...@gmail.com
on 4 Dec 2014 at 9:21
Amazing! I love the new one! And the configuration is really, really
complicated now :-)
1. Do you mean making notations? It has nothing to do with 3D objects. Just
generate labels and place them directly on the canvas using CSS tricks. Or if
you mean generating 3D objects from a given strings and 'weld' them on existing
objects, maybe you could refer to the implementation of this project
http://humu2009.github.io/OpenJSCAD, which turns characters to 3D meshes via a
3rd-party library (? I can't remember the technical details) and merge the
results using CSG method.
2, 3. You can change the color of a whole mesh by assigning it a new material
with the given diffuse color. But I don't think you mean this. I guess what you
need is a way to play a piece of animation to simulate the machining along the
toolpath. This is a little challenging. As you know, Jsc3d is mainly designed
for static models. It has no direct support for animation. So this could be
done but requires a bit more programming with tricks. The idea is to extract
the path, splitting it into two meshes, one for the machined part and the other
for the rest, and updating their vertices as well as the display at a given
speed. I suggest you put the task to the end of your project. I hope I'll have
time then to help you with this.
4. Certainly. Don't forget it is Javascript, one of the most powerful guy all
over the world of programming languages. Use this native method
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
/Number/toPrecision to format a number.
5. I'm using editplus for writing Javascript and review of the HTML code. As
for the IDE, I recommend WebStorm https://www.jetbrains.com/webstorm/ published
by JetBrain, possibly the best tool, in my opinion, for web application
developers. I've got a team-licensed edition used in my company. It is at a
reasonable price for individual developers too.
Hope these would help with your development.
Original comment by Humu2...@gmail.com
on 5 Dec 2014 at 5:20
I'm starting work on the signet ring page, documentation is here:
http://www.5xj.com/WoodRings/jsc3d/SignetDesignDoc.html
It gets complicated.
A new question. With the 'edge' rendering, is there any options as to width of
the line rendered?
Re above:
1. I would like to create 3d objects on the fly from customer input. Mainly
this would be from text/font strings but could also be from customer supplied
obj files. This isn't high on my list of priorities.
2. In my dos mill program I preview the *.nc toolpaths and then change the
color of each line segment as it's cut.
I also change the line colors when I simulate running the *.nc files. This is
not a big issue, just wondering what is possible.
I also simulate running *.nc files in blender. In that case I start with a
blank screen and add a few line segments at a time between redraws.
I control the speed of the simulation by adding a 'delay' between the redraws.
This works very well and I thing the same thing would work
in jsc3D too. Again it isn't high on my priority list of things to do.
No, I didn't know Jsc3D was designed primarily for static models. It may be
that's what people are using it for but I don't really see a whole lot
of limitations - it's just finding out what is possible.
4. Yes, I've experimented with formatting numbers, it works fine. I keep
forgetting that this whole ball of wax is a combination of js3D, javascript and
html. I'm not really all that fluent with javascript and html scripting... so
I'm constantly looking things up with google.
Original comment by cnc...@gmail.com
on 6 Dec 2014 at 11:44
It is not an implemented feature. But I can create a modified branch version
with this (only in WebGL rendering) on your request.
Original comment by Humu2...@gmail.com
on 7 Dec 2014 at 3:06
I think the ability to set edge widths would be nice but not worth spending a
lot of time on. I got lots more things to deal with right now.
Have started coding the signet ring page.
I'm documenting the process so when I want to make changes I can figure things
out.
I had a difficult time setting up an external js file to store code in.
Ended up playing around with the console.js file. Wasn't planned, it just
happened.
So now I have two console windows, the second window can be useful.
http://www.5xj.com/WoodRings/jsc3d/coding/SignetCodingStepByStep.html
Original comment by cnc...@gmail.com
on 10 Dec 2014 at 6:28
Great!
When this project is going to its completion, I can write you an additional
script which allows a client to take screenshots directly from the canvas.
Original comment by Humu2...@gmail.com
on 11 Dec 2014 at 2:22
Step 6 uploaded, creates top mesh object.
http://www.5xj.com/WoodRings/jsc3d/coding/SignetRing6.html
http://www.5xj.com/WoodRings/jsc3d/coding/SignetCodingStepByStep.html
JSC3D.PickInfo
PickInfo PickInfo is used as the return value of JSC3D.Viewer's pick() method,
holding picking values at a given position on the canvas.
Is the PickInfo something that could be used to input info back into the script?
IE. Looking at this example: http://www.mathopenref.com/coordgeneralellipse.html
Is it possible to do something like this?
It might be a reach, but it sure is cool.
Roy
Original comment by cnc...@gmail.com
on 19 Dec 2014 at 10:50
Original issue reported on code.google.com by
cnc...@gmail.com
on 15 Nov 2014 at 12:46Attachments: