Now allows STL download on Firefox as well; better error reporting if browser lacks WebGL support
This commit is contained in:
parent
8c3aaac16d
commit
fb5cf38207
3 changed files with 146 additions and 134 deletions
1
csg.js
1
csg.js
|
@ -773,6 +773,7 @@ CSG.roundedCylinder = function(options) {
|
|||
for(var slice2 = 0; slice2 <= qresolution; slice2++)
|
||||
{
|
||||
var pitch = 0.5 * Math.PI * slice2 / qresolution;
|
||||
//var pitch = Math.asin(slice2/qresolution);
|
||||
var cospitch = Math.cos(pitch);
|
||||
var sinpitch = Math.sin(pitch);
|
||||
if(slice2 > 0)
|
||||
|
|
|
@ -110,6 +110,8 @@ without the need to edit the source script. See the <a href="gearsdemo.html">Gea
|
|||
<li>Properties and Connectors (see below) make it very easy to attach objects to each other at predetermined
|
||||
points, even if you don't know the actual orientation or size.</li>
|
||||
<li>Extensive built in <a href="#math">support for 2D and 3D math</a> (classes for Vector2D, Vector3D, Plane, Line3D, Line2D)</li>
|
||||
<li>Debugging support: step through your code, set breakpoints, inspect variables, etc. See the
|
||||
<a href="processfile.html">OpenJsCad parser</a> for details.</li>
|
||||
</ul>
|
||||
<h2>Viewer navigation</h2>
|
||||
Click and drag to rotate the model around the origin.<br>
|
||||
|
@ -278,7 +280,7 @@ var rounded = csg.expand(0.2, 8);
|
|||
</pre>
|
||||
|
||||
<h2>Using Properties</h2>
|
||||
The 'property' property of a solid can be used to store metdata for the object,
|
||||
The 'property' property of a solid can be used to store metadata for the object,
|
||||
for example the coordinate of a specific point of interest of the solid. Whenever
|
||||
the object is transformed (i.e. rotated, scaled or translated), the properties
|
||||
are transformed with it. So the property will keep pointing to the same point
|
||||
|
|
49
openjscad.js
49
openjscad.js
|
@ -4,8 +4,6 @@ OpenJsCad = function() {
|
|||
// A viewer is a WebGL canvas that lets the user view a mesh. The user can
|
||||
// tumble it around by dragging the mouse.
|
||||
OpenJsCad.Viewer = function(containerelement, width, height, initialdepth) {
|
||||
try
|
||||
{
|
||||
var gl = GL.create();
|
||||
this.gl = gl;
|
||||
this.angleX = 0;
|
||||
|
@ -81,10 +79,6 @@ OpenJsCad.Viewer = function(containerelement, width, height, initialdepth) {
|
|||
_this.onDraw();
|
||||
};
|
||||
this.clear();
|
||||
}
|
||||
catch (e) {
|
||||
containerelement.innerHTML = "<b><br><br>Error: "+e.toString()+"</b><br><br>OpenJsCad currently requires Google Chrome with WebGL enabled";
|
||||
}
|
||||
};
|
||||
|
||||
OpenJsCad.Viewer.prototype = {
|
||||
|
@ -470,7 +464,9 @@ OpenJsCad.Processor.prototype = {
|
|||
{
|
||||
this.viewer = new OpenJsCad.Viewer(this.viewerdiv, this.viewerwidth, this.viewerheight, this.initialViewerDistance);
|
||||
} catch (e) {
|
||||
this.viewerdiv.innerHTML = e.toString();
|
||||
// this.viewer = null;
|
||||
this.viewerdiv.innerHTML = "<b><br><br>Error: "+e.toString()+"</b><br><br>OpenJsCad currently requires Google Chrome with WebGL enabled";
|
||||
// this.viewerdiv.innerHTML = e.toString();
|
||||
}
|
||||
this.errordiv = document.createElement("div");
|
||||
this.errorpre = document.createElement("pre");
|
||||
|
@ -728,18 +724,6 @@ OpenJsCad.Processor.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
generateStl1: function() {
|
||||
this.clearStl();
|
||||
if(this.validcsg)
|
||||
{
|
||||
var stltxt = this.solid.toStlString();
|
||||
this.stlBlobUrl = OpenJsCad.textToBlobUrl(stltxt);
|
||||
this.hasstl = true;
|
||||
this.downloadStlLink.href = this.stlBlobUrl;
|
||||
this.enableItems();
|
||||
if(this.onchange) this.onchange();
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
clearStl: function() {
|
||||
|
@ -751,6 +735,11 @@ OpenJsCad.Processor.prototype = {
|
|||
this.stlDirEntry.removeRecursively(function(){});
|
||||
this.stlDirEntry=null;
|
||||
}
|
||||
if(this.stlBlobUrl)
|
||||
{
|
||||
OpenJsCad.revokeBlobUrl(this.stlBlobUrl);
|
||||
this.stlBlobUrl = null;
|
||||
}
|
||||
this.enableItems();
|
||||
if(this.onchange) this.onchange();
|
||||
}
|
||||
|
@ -760,6 +749,27 @@ OpenJsCad.Processor.prototype = {
|
|||
this.clearStl();
|
||||
if(this.validcsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.generateStlFileSystem();
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
this.generateStlBlobUrl();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
generateStlBlobUrl: function() {
|
||||
var stltxt = this.solid.toStlString();
|
||||
this.stlBlobUrl = OpenJsCad.textToBlobUrl(stltxt);
|
||||
this.hasstl = true;
|
||||
this.downloadStlLink.href = this.stlBlobUrl;
|
||||
this.enableItems();
|
||||
if(this.onchange) this.onchange();
|
||||
},
|
||||
|
||||
generateStlFileSystem: function() {
|
||||
var stltxt = this.solid.toStlString();
|
||||
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
|
||||
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
|
||||
|
@ -805,7 +815,6 @@ OpenJsCad.Processor.prototype = {
|
|||
},
|
||||
function(fileerror){OpenJsCad.FileSystemApiErrorHandler(fileerror, "requestFileSystem");}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
createParamControls: function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue