@react-three/drei 9.68.4 → 9.68.6

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/core/Grid.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),i=require("react"),n=require("three"),o=require("@react-three/fiber"),r=require("./shaderMaterial.cjs.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var i=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(i,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),i.default=e,Object.freeze(i)}var a=t(e),c=l(i),s=l(n);const f=r.shaderMaterial({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new s.Color,sectionColor:new s.Color,infiniteGrid:0,followCamera:0},"varying vec3 worldPosition;\n uniform float fadeDistance;\n uniform float infiniteGrid;\n uniform float followCamera;\n void main() {\n vec3 pos = position.xzy * (1. + fadeDistance * infiniteGrid);\n pos.xz += (cameraPosition.xz * followCamera);\n worldPosition = pos;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n }","varying vec3 worldPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n uniform float infiniteGrid;\n float getGrid(float size, float thickness) {\n vec2 r = worldPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1. - thickness;\n return 1.0 - min(line, 1.);\n }\n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / fadeDistance, 1.);\n vec3 color = mix(cellColor, sectionColor, min(1.,sectionThickness * g2));\n gl_FragColor = vec4(color, (g1 + g2) * pow(d,fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),d=c.forwardRef((({args:e,cellColor:i="#000000",sectionColor:n="#2080ff",cellSize:r=.5,sectionSize:t=1,followCamera:l=!1,infiniteGrid:d=!1,fadeDistance:u=100,fadeStrength:g=1,cellThickness:m=.5,sectionThickness:h=1,side:C=s.BackSide,...v},p)=>{o.extend({GridMaterial:f});const z={cellSize:r,sectionSize:t,cellColor:i,sectionColor:n,cellThickness:m,sectionThickness:h},w={fadeDistance:u,fadeStrength:g,infiniteGrid:d,followCamera:l};return c.createElement("mesh",a.default({ref:p,frustumCulled:!1},v),c.createElement("gridMaterial",a.default({transparent:!0,"extensions-derivatives":!0,side:C},z,w)),c.createElement("planeGeometry",{args:e}))}));exports.Grid=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),n=require("react"),i=require("three"),o=require("@react-three/fiber"),r=require("./shaderMaterial.cjs.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),n.default=e,Object.freeze(n)}var a=t(e),c=l(n),s=l(i);const f=r.shaderMaterial({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new s.Color,sectionColor:new s.Color,infiniteGrid:!1,followCamera:!1},"\n varying vec3 worldPosition;\n uniform float fadeDistance;\n uniform bool infiniteGrid;\n uniform bool followCamera;\n\n void main() {\n worldPosition = position.xzy;\n if (infiniteGrid) worldPosition *= 1.0 + fadeDistance;\n if (followCamera) worldPosition.xz +=cameraPosition.xz;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);\n }\n ","\n varying vec3 worldPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n\n float getGrid(float size, float thickness) {\n vec2 r = worldPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1. - thickness;\n return 1.0 - min(line, 1.);\n }\n\n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n\n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / fadeDistance, 1.);\n vec3 color = mix(cellColor, sectionColor, min(1.,sectionThickness * g2));\n\n gl_FragColor = vec4(color, (g1 + g2) * pow(d,fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }\n "),d=c.forwardRef((({args:e,cellColor:n="#000000",sectionColor:i="#2080ff",cellSize:r=.5,sectionSize:t=1,followCamera:l=!1,infiniteGrid:d=!1,fadeDistance:u=100,fadeStrength:g=1,cellThickness:m=.5,sectionThickness:h=1,side:C=s.BackSide,...v},w)=>{o.extend({GridMaterial:f});const z={cellSize:r,sectionSize:t,cellColor:n,sectionColor:i,cellThickness:m,sectionThickness:h},x={fadeDistance:u,fadeStrength:g,infiniteGrid:d,followCamera:l};return c.createElement("mesh",a.default({ref:w,frustumCulled:!1},v),c.createElement("gridMaterial",a.default({transparent:!0,"extensions-derivatives":!0,side:C},z,x)),c.createElement("planeGeometry",{args:e}))}));exports.Grid=d;
package/core/Grid.js CHANGED
@@ -13,44 +13,58 @@ const GridMaterial = shaderMaterial({
13
13
  sectionThickness: 1,
14
14
  cellColor: new THREE.Color(),
15
15
  sectionColor: new THREE.Color(),
16
- infiniteGrid: 0,
17
- followCamera: 0
18
- }, `varying vec3 worldPosition;
19
- uniform float fadeDistance;
20
- uniform float infiniteGrid;
21
- uniform float followCamera;
22
- void main() {
23
- vec3 pos = position.xzy * (1. + fadeDistance * infiniteGrid);
24
- pos.xz += (cameraPosition.xz * followCamera);
25
- worldPosition = pos;
26
- gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
27
- }`, `varying vec3 worldPosition;
28
- uniform float cellSize;
29
- uniform float sectionSize;
30
- uniform vec3 cellColor;
31
- uniform vec3 sectionColor;
32
- uniform float fadeDistance;
33
- uniform float fadeStrength;
34
- uniform float cellThickness;
35
- uniform float sectionThickness;
36
- uniform float infiniteGrid;
37
- float getGrid(float size, float thickness) {
38
- vec2 r = worldPosition.xz / size;
39
- vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
40
- float line = min(grid.x, grid.y) + 1. - thickness;
41
- return 1.0 - min(line, 1.);
42
- }
43
- void main() {
44
- float g1 = getGrid(cellSize, cellThickness);
45
- float g2 = getGrid(sectionSize, sectionThickness);
46
- float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / fadeDistance, 1.);
47
- vec3 color = mix(cellColor, sectionColor, min(1.,sectionThickness * g2));
48
- gl_FragColor = vec4(color, (g1 + g2) * pow(d,fadeStrength));
49
- gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
50
- if (gl_FragColor.a <= 0.0) discard;
51
- #include <tonemapping_fragment>
52
- #include <encodings_fragment>
53
- }`);
16
+ infiniteGrid: false,
17
+ followCamera: false
18
+ },
19
+ /* glsl */
20
+ `
21
+ varying vec3 worldPosition;
22
+ uniform float fadeDistance;
23
+ uniform bool infiniteGrid;
24
+ uniform bool followCamera;
25
+
26
+ void main() {
27
+ worldPosition = position.xzy;
28
+ if (infiniteGrid) worldPosition *= 1.0 + fadeDistance;
29
+ if (followCamera) worldPosition.xz +=cameraPosition.xz;
30
+
31
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPosition, 1.0);
32
+ }
33
+ `,
34
+ /* glsl */
35
+ `
36
+ varying vec3 worldPosition;
37
+ uniform float cellSize;
38
+ uniform float sectionSize;
39
+ uniform vec3 cellColor;
40
+ uniform vec3 sectionColor;
41
+ uniform float fadeDistance;
42
+ uniform float fadeStrength;
43
+ uniform float cellThickness;
44
+ uniform float sectionThickness;
45
+
46
+ float getGrid(float size, float thickness) {
47
+ vec2 r = worldPosition.xz / size;
48
+ vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
49
+ float line = min(grid.x, grid.y) + 1. - thickness;
50
+ return 1.0 - min(line, 1.);
51
+ }
52
+
53
+ void main() {
54
+ float g1 = getGrid(cellSize, cellThickness);
55
+ float g2 = getGrid(sectionSize, sectionThickness);
56
+
57
+ float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / fadeDistance, 1.);
58
+ vec3 color = mix(cellColor, sectionColor, min(1.,sectionThickness * g2));
59
+
60
+ gl_FragColor = vec4(color, (g1 + g2) * pow(d,fadeStrength));
61
+ gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
62
+ if (gl_FragColor.a <= 0.0) discard;
63
+
64
+ #include <tonemapping_fragment>
65
+ #include <encodings_fragment>
66
+ }
67
+ `);
54
68
  const Grid = /*#__PURE__*/React.forwardRef(({
55
69
  args,
56
70
  cellColor = '#000000',