@jscad/web 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/css/demo.css +8 -0
- package/dist/jscad-web.min.js +10 -6
- package/package.json +3 -3
- package/src/ui/views/editor.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.6.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/web@2.6.2...@jscad/web@2.6.3) (2023-01-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **web:** add render hotkey message in editor ([1e99fa5](https://github.com/jscad/OpenJSCAD.org/commit/1e99fa5222dfd12153f8318f3b112261088a2fe0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [2.6.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/web@2.6.1...@jscad/web@2.6.2) (2022-11-26)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @jscad/web
|
package/css/demo.css
CHANGED
package/dist/jscad-web.min.js
CHANGED
|
@@ -2213,7 +2213,7 @@ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{meshColor:
|
|
|
2213
2213
|
const mat4=require("gl-mat4"),maxIndex=Math.floor(32767.5),geom2ToGeometries=(o,e)=>{let{color:t}=o;const n=e.sides;if(0===n.length)return[];"color"in e&&(t=e.color);const r=t[3]<1,s=[],l=Math.floor(n.length/maxIndex)+1,a=(o,e)=>{s.push(o,e||o)},m=[];for(let o=0;o<l;o++){const l=o*maxIndex,c=Math.min(l+maxIndex,n.length),h=[];for(let o=l;o<c;o++){const e=n[o];if(e.color){if(0===s.length&&h.length>0){const o=h.length;for(let e=0;e<o;e++)s.push(t)}a(e.color,e.endColor)}else s.length&&a(t);h.push([e[0][0],e[0][1],0]),h.push([e[1][0],e[1][1],0])}const i=h.map(o=>[0,0,-1]),f=h.map((o,e)=>e),p=e.transforms?mat4.clone(e.transforms):mat4.create();m.push({type:"2d",positions:h,normals:i,indices:f,transforms:p,color:t,colors:s,isTransparent:r})}return m};module.exports=geom2ToGeometries;
|
|
2214
2214
|
|
|
2215
2215
|
},{"gl-mat4":543}],613:[function(require,module,exports){
|
|
2216
|
-
const vec3=require("gl-vec3"),mat4=require("gl-mat4"),maxIndex=65535,geom3ToGeometries=(o,e)=>{let{color:t,smoothLighting:n}=o;"color"in e&&(t=e.color);const r=e.polygons,l=e.transforms?mat4.clone(e.transforms):mat4.create(),s=[];let c=0;for(;c<r.length;){let o=0,e=c;for(let t=c;t<r.length&&!((o+=r[t].vertices.length)>65535);t++)e++;const n=[],i=[],a=[],p=[],m
|
|
2216
|
+
const vec3=require("gl-vec3"),mat4=require("gl-mat4"),maxIndex=65535,geom3ToGeometries=(o,e)=>{let{color:t,smoothLighting:n}=o;"color"in e&&(t=e.color);const r=e.polygons,l=e.transforms?mat4.clone(e.transforms):mat4.create(),s=[];let c=0;for(;c<r.length;){let o=0,e=c;for(let t=c;t<r.length&&!((o+=r[t].vertices.length)>65535);t++)e++;const n=[],i=[],a=[],p=[],m=t[3]<1;for(let o=c;o<e;o++){const e=r[o],l=e.vertices,s=calculateNormal(e),c=polygonColor(e,t),m=[];for(let o=0;o<l.length;o++){const e=l[o];n.push(e),i.push(s),p.push(c);const t=n.length-1;m.push(t)}for(let o=2;o<m.length;o++)a.push([m[0],m[o-1],m[o]])}const u={type:"3d",positions:n,normals:i,indices:a,colors:p,transforms:l,isTransparent:m};s.push(u),c=e}return s},smoothing=()=>{const o=[],e=[];let t=!0;const n=[],r=[],l=[],s=[],c=[];let i=0;for(let a=0;a<o.length;a++){const p=o[a],m=p.vertices,u=polygonColor(p,e),h=calculateNormal(p);u&&1!==u[3]&&(t=!0);const g=[];for(let o=0;o<m.length;o++){let e;const t=m[o];{const o={normal:h,position:t},l=fuzyNormalAndPositionLookup(c,o,.5);if(l)e=l.index;else{const l=c[o.position],a=[{normal:o.normal,index:i}];c[o.position]=l?c[o.position].concat(a):a,e=i,u&&s.push(u),r.push(h),n.push(t),i+=1}}g.push(e)}for(let o=2;o<g.length;o++)l.push([g[0],g[o-1],g[o]])}},polygonColor=(o,e)=>{let t=e;return o.color&&(t=o.color),t&&t.length<4&&t.push(1),t},calculateNormal=o=>{if(o.plane)return vec3.clone(o.plane);const e=o.vertices,t=vec3.create();vec3.subtract(t,e[1],e[0]);const n=vec3.create();vec3.subtract(n,e[2],e[0]);const r=vec3.create();return vec3.cross(r,t,n),vec3.normalize(r,r),r},areNormalsSimilar=(o,e,t)=>vec3.distance(o,e)<=t,fuzyNormalAndPositionLookup=(o,e,t)=>{const n=o[e.position];if(n)for(let o=0;o<n.length;o++){const r=n[o].normal;if(areNormalsSimilar(r,e.normal,t))return{tupple:{position:e.position,normal:r},index:n[o].index}}};module.exports=geom3ToGeometries;
|
|
2217
2217
|
|
|
2218
2218
|
},{"gl-mat4":543,"gl-vec3":576}],614:[function(require,module,exports){
|
|
2219
2219
|
const mat4=require("gl-mat4"),maxIndex=Math.floor(32767.5)-2,path2ToGeometries=(o,t)=>{let{color:e}=o;const s=t.points;if(0===s.length)return[];"color"in t&&(e=t.color);const n=e[3]<1,r=Math.floor(s.length/maxIndex)+1,a=[];for(let o=0;o<r;o++){const l=o*maxIndex,m=Math.min(l+maxIndex,s.length),c=[];let i;for(let o=l;o<m;o++){const t=s[o];i&&(c.push([i[0],i[1],0]),c.push([t[0],t[1],0])),i=t}if(o+1===r&&t.isClosed&&i){const o=s[0];c.push([i[0],i[1],0]),c.push([o[0],o[1],0])}const p=c.map(o=>[0,0,-1]),h=c.map((o,t)=>t),f=t.transforms?mat4.clone(t.transforms):mat4.create();a.push({type:"2d",positions:c,normals:p,indices:h,transforms:f,color:e,isTransparent:n})}return a};module.exports=path2ToGeometries;
|
|
@@ -2234,7 +2234,7 @@ const makeDrawMultiGrid=(e,i)=>{const{size:s,ticks:r}=Object.assign({},{size:[50
|
|
|
2234
2234
|
const vColorFrag="\nprecision mediump float;\nuniform vec4 ucolor;\n\nvoid main () {\n gl_FragColor = ucolor;\n}\n";module.exports={frag:vColorFrag};
|
|
2235
2235
|
|
|
2236
2236
|
},{}],620:[function(require,module,exports){
|
|
2237
|
-
const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawLines=(e,r={})=>{const
|
|
2237
|
+
const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawLines=(e,r={})=>{const o={color:meshColor,geometry:void 0};let{geometry:t,color:s,transparent:a}=Object.assign({},o,r);"color"in t&&(s=t.color);const l=!!(t.indices&&t.indices.length>0),i=!!(t.normals&&t.normals.length>0),n=!!(t.colors&&t.colors.length>0),c={primitive:"lines",vert:n?require("./vColorShaders").vert:require("./meshShaders").vert,frag:n?require("./vColorShaders").frag:require("./colorOnlyShaders").frag,uniforms:{model:(e,r)=>r.model||t.transforms||mat4.create(),ucolor:(e,r)=>r&&r.color?r.color:s},attributes:{position:e.buffer({usage:"static",type:"float",data:t.positions})}};return a&&(c.blend={enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}),n&&(c.attributes.color=e.buffer({usage:"static",type:"float",data:t.colors})),l&&(c.elements=e.elements({usage:"static",type:"uint16",data:t.indices})),i&&(c.attributes.normal=e.buffer({usage:"static",type:"float",data:t.normals})),e(c)};module.exports=drawLines;
|
|
2238
2238
|
|
|
2239
2239
|
},{"../../renderDefaults":628,"./colorOnlyShaders":619,"./meshShaders":621,"./vColorShaders":622,"gl-mat4":543}],621:[function(require,module,exports){
|
|
2240
2240
|
const meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\n\nvoid main() {\n\n\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n",meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}";module.exports={vert:meshVert,frag:meshFrag};
|
|
@@ -2243,7 +2243,7 @@ const meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nun
|
|
|
2243
2243
|
const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n vColor = color;\n\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec4 vColor;\n\nvoid main () {\n gl_FragColor = vColor;\n}\n";module.exports={frag:vColorFrag,vert:vColorVert};
|
|
2244
2244
|
|
|
2245
2245
|
},{}],623:[function(require,module,exports){
|
|
2246
|
-
const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawMesh=(e,r={extras:{}})=>{const t={useVertexColors:!0,dynamicCulling:!0,geometry:void 0,color:meshColor},{geometry:
|
|
2246
|
+
const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawMesh=(e,r={extras:{}})=>{const t={useVertexColors:!0,dynamicCulling:!0,geometry:void 0,color:meshColor,visuals:{}},{geometry:s,dynamicCulling:a,useVertexColors:o,color:l,visuals:n}=Object.assign({},t,r),i=e.buffer([]),u=!!(s.indices&&s.indices.length>0),c=!!(s.normals&&s.normals.length>0),m="transparent"in n&&n.transparent,g=!!(o&&s.colors&&s.colors.length>0),d=s.transforms||mat4.create(),f=mat4.determinant(d)<0,h=a&&f?"front":"back",p=g?require("./vColorShaders").vert:require("./meshShaders").vert,b=g?require("./vColorShaders").frag:require("./meshShaders").frag,v=mat4.invert(mat4.create(),d);let C={primitive:"triangles",vert:p,frag:b,uniforms:{model:(e,r)=>d,ucolor:(e,r)=>r&&r.color?r.color:l,vColorToggler:(e,r)=>r&&r.useVertexColors&&!0===r.useVertexColors?1:0,unormal:(e,r)=>{const t=mat4.invert(mat4.create(),r.camera.view);return mat4.multiply(t,v,t),mat4.transpose(t,t),t}},attributes:{position:e.buffer({usage:"static",type:"float",data:s.positions}),ao:i},cull:{enable:!0,face:h}};return m&&(C.blend={enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}),s.cells?C.elements=s.cells:u?C.elements=e.elements({usage:"static",type:"uint16",data:s.indices}):s.triangles?C.elements=s.triangles:C.count=s.positions.length/3,c&&(C.attributes.normal=e.buffer({usage:"static",type:"float",data:s.normals})),g&&(C.attributes.color=e.buffer({usage:"static",type:"float",data:s.colors})),e(C=Object.assign({},C,r.extras))};module.exports=drawMesh;
|
|
2247
2247
|
|
|
2248
2248
|
},{"../../renderDefaults":628,"./meshShaders":624,"./vColorShaders":625,"gl-mat4":543}],624:[function(require,module,exports){
|
|
2249
2249
|
const meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}",meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\nvoid main() {\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n";module.exports={vert:meshVert,frag:meshFrag};
|
|
@@ -3151,7 +3151,7 @@ var bundleFn=arguments[3],sources=arguments[4],cache=arguments[5],stringify=JSON
|
|
|
3151
3151
|
},{}],784:[function(require,module,exports){
|
|
3152
3152
|
module.exports={
|
|
3153
3153
|
"name": "@jscad/web",
|
|
3154
|
-
"version": "2.6.
|
|
3154
|
+
"version": "2.6.3",
|
|
3155
3155
|
"description": "Web Application for JSCAD",
|
|
3156
3156
|
"homepage": "https://openjscad.xyz/",
|
|
3157
3157
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
@@ -3191,7 +3191,7 @@ module.exports={
|
|
|
3191
3191
|
"@jscad/examples": "2.4.2",
|
|
3192
3192
|
"@jscad/io": "2.4.4",
|
|
3193
3193
|
"@jscad/modeling": "2.11.0",
|
|
3194
|
-
"@jscad/regl-renderer": "2.6.
|
|
3194
|
+
"@jscad/regl-renderer": "2.6.5",
|
|
3195
3195
|
"@most/create": "2.0.1",
|
|
3196
3196
|
"brace": "0.11.1",
|
|
3197
3197
|
"codemirror": "5.65.2",
|
|
@@ -3352,7 +3352,11 @@ const html=require("nanohtml"),{createParamControls:createParamControls}=require
|
|
|
3352
3352
|
},{"./parameterControls":829,"nanohtml":777}],823:[function(require,module,exports){
|
|
3353
3353
|
const html=require("nanohtml"),CodeMirror=require("codemirror");require("codemirror/mode/javascript/javascript"),require("codemirror/addon/hint/javascript-hint");const editorOptions={mode:"javascript",indentUnit:2,smartIndent:!1,indentWithTabs:!1,lineNumbers:!0,autofocus:!0};let editor,wrapper;const createFileTree=e=>{const r=e.getValue();return r&&r.length>0?[{ext:"js",fullPath:"/changes.js",mimetype:"javascript",name:"changes.js",source:r}]:null},createWrapper=(e,r)=>{if(!wrapper){(wrapper=html`
|
|
3354
3354
|
<section class='popup-menu' id='editor' key='editor' style='visibility:${"editor"===e.activeTool?"visible":"hidden"}'>
|
|
3355
|
-
|
|
3355
|
+
<textarea>
|
|
3356
|
+
</textarea>
|
|
3357
|
+
<p style='position:absolute;top:0rem;right:1rem;color:gray;user-select:none'>
|
|
3358
|
+
Press 'shift + enter' to render!
|
|
3359
|
+
</p>
|
|
3356
3360
|
</section>
|
|
3357
3361
|
`).onkeydown=(e=>e.stopPropagation()),wrapper.onkeyup=(e=>e.stopPropagation()),(editor=CodeMirror.fromTextArea(wrapper.firstChild,editorOptions)).setOption("extraKeys",{Tab:e=>{const r=Array(e.getOption("indentUnit")+1).join(" ");e.replaceSelection(r)}});const r=document.getElementsByTagName("HEAD")[0],t=document.createElement("LINK");t.rel="stylesheet",t.href="./css/codemirror.css",r.appendChild(t)}return wrapper},editorWrapper=(e,r)=>{const t=createWrapper(e);if("editor"===e.activeTool){t.style.visibility="visible",t.focus();let i=e.shortcuts.find(e=>"reevaluate"===e.args);i||(i={args:"Shift-Enter"});let o=i.key.toUpperCase();const s={Tab:e=>{const r=Array(e.getOption("indentUnit")+1).join(" ");e.replaceSelection(r)}};s[o=(o=(o=(o=(o=o.replace(/enter/i,"Enter")).replace(/alt[+-]/i,"Alt-")).replace(/cmd[+-]/i,"Cmd-")).replace(/control[+-]/i,"Ctrl-")).replace(/shift[+-]/i,"Shift-")]=(e=>{const t=createFileTree(e);t&&r.callback({type:"read",id:"loadRemote",data:t})}),editor.setOption("extraKeys",s),editor.focus(),editor.scrollIntoView({line:0,ch:0}),setTimeout(()=>editor.refresh(),0)}else t.style.visibility="hidden";if(e.design&&e.design.filesAndFolders&&1===e.design.filesAndFolders.length){const r=e.design.filesAndFolders[0];let t=r.source?r.source:"";r.mimetype?r.mimetype.indexOf("javascript")<0&&(t="// imported from external format"):t="// imported from project",t!==editor.getValue()&&(editor.focus(),editor.setValue(t),editor.setCursor(0,0),editor.refresh())}return t};module.exports={editorWrapper:editorWrapper};
|
|
3358
3362
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/web",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Web Application for JSCAD",
|
|
5
5
|
"homepage": "https://openjscad.xyz/",
|
|
6
6
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@jscad/examples": "2.4.2",
|
|
41
41
|
"@jscad/io": "2.4.4",
|
|
42
42
|
"@jscad/modeling": "2.11.0",
|
|
43
|
-
"@jscad/regl-renderer": "2.6.
|
|
43
|
+
"@jscad/regl-renderer": "2.6.5",
|
|
44
44
|
"@most/create": "2.0.1",
|
|
45
45
|
"brace": "0.11.1",
|
|
46
46
|
"codemirror": "5.65.2",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"url": "https://opencollective.com/openjscad",
|
|
68
68
|
"logo": "https://opencollective.com/openjscad/logo.txt"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "cf720e7e146eb2e3ab97cdfdb8036771f7761b0f"
|
|
71
71
|
}
|
package/src/ui/views/editor.js
CHANGED
|
@@ -34,7 +34,11 @@ const createWrapper = (state, callbackToStream) => {
|
|
|
34
34
|
if (!wrapper) {
|
|
35
35
|
wrapper = html`
|
|
36
36
|
<section class='popup-menu' id='editor' key='editor' style='visibility:${state.activeTool === 'editor' ? 'visible' : 'hidden'}'>
|
|
37
|
-
|
|
37
|
+
<textarea>
|
|
38
|
+
</textarea>
|
|
39
|
+
<p style='position:absolute;top:0rem;right:1rem;color:gray;user-select:none'>
|
|
40
|
+
Press 'shift + enter' to render!
|
|
41
|
+
</p>
|
|
38
42
|
</section>
|
|
39
43
|
`
|
|
40
44
|
wrapper.onkeydown = (e) => e.stopPropagation()
|