@jscad/regl-renderer 2.4.0 → 2.5.2
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
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
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.5.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.5.1...@jscad/regl-renderer@2.5.2) (2021-12-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @jscad/regl-renderer
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.5.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.5.0...@jscad/regl-renderer@2.5.1) (2021-11-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @jscad/regl-renderer
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [2.5.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.4.1...@jscad/regl-renderer@2.5.0) (2021-10-17)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **web:** changed default serialize to false, eliminating JSON serialize/deserialize ([#928](https://github.com/jscad/OpenJSCAD.org/issues/928)) ([b29993a](https://github.com/jscad/OpenJSCAD.org/commit/b29993a8fd3da3bd43a5f871edae4c60d7f56fc7))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [2.4.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.4.0...@jscad/regl-renderer@2.4.1) (2021-10-04)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @jscad/regl-renderer
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
# [2.4.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.3.0...@jscad/regl-renderer@2.4.0) (2021-09-27)
|
|
7
42
|
|
|
8
43
|
|
|
@@ -317,7 +317,7 @@ const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefault
|
|
|
317
317
|
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};
|
|
318
318
|
|
|
319
319
|
},{}],107:[function(require,module,exports){
|
|
320
|
-
const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection, unormal;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nattribute float ao;\nvarying float ambientAo;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n surfacePosition = (unormal * vec4(position, 1.0)).xyz;\n surfaceNormal = (unormal * vec4(normal, 1.0)).xyz; //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n //gl_Position = projection * view * worldSpacePosition;\n\n vColor = color;\n\n //ambientAo = (1. - ao) * (0.5 * max(normal.x, 0.) + 0.5);\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n //gl_Position = zBufferAdjust(glPosition, camNear, camFar);\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal, surfacePosition;\n\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform float specularLightAmount;\n\nuniform vec3 lightDirection;\nuniform vec4 lightColor;\nuniform vec3 opacity;\nuniform float uMaterialShininess;\n\nvarying vec4 vColor;\nuniform vec4 ucolor;\nuniform float vColorToggler;\n\nuniform vec2 printableArea;\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);//vec4(0.15, 0.15, 0.15, 0.3);\nvarying vec4 _worldSpacePosition;\nvarying float ambientAo;\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n vec4 endColor = vColor * vColorToggler + ucolor * (1.0 - vColorToggler);\n\n vec3 ambient = ambientLightAmount * endColor.rgb ; //ambientAo * \n\n float diffuseWeight = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight , 0.0, 1.0 );\n\n //specular\n \n vec4 specularColor = vec4(lightColor);\n vec3 eyeDirection = normalize(surfacePosition.xyz);\n vec3 reflectionDirection = reflect(-lightDirection, -surfaceNormal);\n float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;\n\n /*float light2Multiplier = 0.2;\n float diffuseWeight2 = dot(surfaceNormal, vec3(-lightDirection.x, lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight2 , 0.0, 1.0 ) * light2Multiplier;\n\n float light3Multiplier = 0.2; \n float diffuseWeight3 = dot(surfaceNormal, vec3(lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse3 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight3 , 0.0, 1.0 ) * light3Multiplier;\n\n float light4Multiplier = 0.2; \n float diffuseWeight4 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse4 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight4 , 0.0, 1.0 ) * light4Multiplier;*/\n \n gl_FragColor = vec4((ambient + diffuse + specular), endColor.a);\n //gl_FragColor = vec4((ambient + diffuse + diffuse2 + diffuse3 + diffuse4), endColor.a);\n}\n";module.exports={frag:vColorFrag,vert:vColorVert};
|
|
320
|
+
const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection, unormal;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nattribute float ao;\nvarying float ambientAo;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n surfacePosition = (unormal * vec4(position, 1.0)).xyz;\n surfaceNormal = normalize((unormal * vec4(normal, 1.0)).xyz); //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n //gl_Position = projection * view * worldSpacePosition;\n\n vColor = color;\n\n //ambientAo = (1. - ao) * (0.5 * max(normal.x, 0.) + 0.5);\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n //gl_Position = zBufferAdjust(glPosition, camNear, camFar);\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal, surfacePosition;\n\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform float specularLightAmount;\n\nuniform vec3 lightDirection;\nuniform vec4 lightColor;\nuniform vec3 opacity;\nuniform float uMaterialShininess;\n\nvarying vec4 vColor;\nuniform vec4 ucolor;\nuniform float vColorToggler;\n\nuniform vec2 printableArea;\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);//vec4(0.15, 0.15, 0.15, 0.3);\nvarying vec4 _worldSpacePosition;\nvarying float ambientAo;\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n vec4 endColor = vColor * vColorToggler + ucolor * (1.0 - vColorToggler);\n\n vec3 ambient = ambientLightAmount * endColor.rgb ; //ambientAo * \n\n float diffuseWeight = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight , 0.0, 1.0 );\n\n //specular\n \n vec4 specularColor = vec4(lightColor);\n vec3 eyeDirection = normalize(surfacePosition.xyz);\n vec3 reflectionDirection = reflect(-lightDirection, -surfaceNormal);\n float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;\n\n /*float light2Multiplier = 0.2;\n float diffuseWeight2 = dot(surfaceNormal, vec3(-lightDirection.x, lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight2 , 0.0, 1.0 ) * light2Multiplier;\n\n float light3Multiplier = 0.2; \n float diffuseWeight3 = dot(surfaceNormal, vec3(lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse3 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight3 , 0.0, 1.0 ) * light3Multiplier;\n\n float light4Multiplier = 0.2; \n float diffuseWeight4 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse4 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight4 , 0.0, 1.0 ) * light4Multiplier;*/\n \n gl_FragColor = vec4((ambient + diffuse + specular), endColor.a);\n //gl_FragColor = vec4((ambient + diffuse + diffuse2 + diffuse3 + diffuse4), endColor.a);\n}\n";module.exports={frag:vColorFrag,vert:vColorVert};
|
|
321
321
|
|
|
322
322
|
},{}],108:[function(require,module,exports){
|
|
323
323
|
const renderContext=require("./renderContext"),renderDefaults=require("./renderDefaults"),prepareRender=e=>{const r=Object.assign({},{},e.glOptions,{onDone:(e,r)=>{if(e)throw e}}),n=require("regl")(r),a=new Map;return function(e){var r;n.poll(),(r=e).rendering=Object.assign({},renderDefaults,r.rendering),renderContext(n)(r,e=>{n.clear({color:r.rendering.background,depth:1}),r.entities&&r.entities.sort((e,r)=>{const n="transparent"in e.visuals&&e.visuals.transparent;return n===("transparent"in r.visuals&&r.visuals.transparent)?0:n?1:-1}).forEach(e=>{const{visuals:t}=e;if((!("show"in t)||t.show)&&t.drawCmd&&r.drawCommands[t.drawCmd]){let s;t.cacheId?s=a.get(t.cacheId):(t.cacheId=a.size,s=r.drawCommands[t.drawCmd](n,e),a.set(t.cacheId,s)),s({...e,...t,camera:r.camera})}})})}};module.exports=prepareRender;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/regl-renderer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Renderer for JSCAD Geometries",
|
|
5
5
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@jscad/img-utils": "2.0.1",
|
|
38
|
-
"@jscad/modeling": "2.
|
|
38
|
+
"@jscad/modeling": "2.7.0",
|
|
39
39
|
"ava": "3.15.0",
|
|
40
40
|
"browserify": "16.5.1",
|
|
41
41
|
"budo": "11.6.4",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"typescript": "^4.0.0",
|
|
44
44
|
"uglifyify": "5.0.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "fbc9b90f0ae02bea4e6e7b974c65e751c3858269"
|
|
47
47
|
}
|
|
@@ -16,7 +16,7 @@ varying vec4 vColor;
|
|
|
16
16
|
|
|
17
17
|
void main() {
|
|
18
18
|
surfacePosition = (unormal * vec4(position, 1.0)).xyz;
|
|
19
|
-
surfaceNormal = (unormal * vec4(normal, 1.0)).xyz; //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
|
|
19
|
+
surfaceNormal = normalize((unormal * vec4(normal, 1.0)).xyz); //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
|
|
20
20
|
vec4 worldSpacePosition = model * vec4(position, 1);
|
|
21
21
|
_worldSpacePosition = worldSpacePosition;
|
|
22
22
|
//gl_Position = projection * view * worldSpacePosition;
|