@anov/3d-ability 0.0.103 → 0.0.104

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.
@@ -1,2 +1,2 @@
1
1
  export declare const heightVertexShader = "\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uHeight;\n uniform sampler2D map;\n\n void main() {\n vUv = uv;\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n float h = texture2D(map, vUv).a * uHeight;\n // gl_Position = projectionMatrix * viewMatrix * vec4(worldPosition.x, worldPosition.y, h, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, position.y, position.z, 1.0);\n }\n";
2
- export declare const heightFragmentShader = "\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n \nvec4 createPixelGraphEffect(sampler2D map, vec2 vUv, float granularity, float threshold, vec2 range, vec3 worldPos) {\n vec2 pixelSize = vec2(1.0) / granularity;\n vec2 cell = floor(vUv / pixelSize);\n vec2 cellUv = fract(vUv / pixelSize);\n\n vec4 texColor = texture2D(map, (cell + 0.5) * pixelSize);\n\n vec2 pointCenter = vec2(0.5, 0.5);\n vec2 rotatedUv = cellUv - pointCenter;\n vec2 rotated = vec2(\n (rotatedUv.x - rotatedUv.y) * 0.7071067811865476,\n (rotatedUv.x + rotatedUv.y) * 0.7071067811865476\n );\n\n float dist = abs(rotated.x) + abs(rotated.y);\n\n float intensity = (texColor.r + texColor.g + texColor.b) / 3.0;\n float pointSize = 0.3 * smoothstep(0.0, threshold, intensity);\n\n if (dist > pointSize || intensity < 0.05) {\n discard;\n }\n\n return texColor;\n}\n\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n discard;\n }\n }\n";
2
+ export declare const heightFragmentShader = "\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n \nvec4 createPixelGraphEffect(sampler2D map, vec2 vUv, float granularity, float threshold, vec2 range, vec3 worldPos) {\n vec2 pixelSize = vec2(1.0) / granularity;\n vec2 cell = floor(vUv / pixelSize);\n vec2 cellUv = fract(vUv / pixelSize);\n\n vec4 texColor = texture2D(map, (cell + 0.5) * pixelSize);\n\n vec2 pointCenter = vec2(0.5, 0.5);\n vec2 rotatedUv = cellUv - pointCenter;\n vec2 rotated = vec2(\n (rotatedUv.x - rotatedUv.y) * 0.7071067811865476,\n (rotatedUv.x + rotatedUv.y) * 0.7071067811865476\n );\n\n float dist = abs(rotated.x) + abs(rotated.y);\n\n float intensity = (texColor.r + texColor.g + texColor.b) / 3.0;\n float pointSize = 0.3 * smoothstep(0.0, threshold, intensity);\n\n if (dist > pointSize || intensity < 0.05) {\n discard;\n }\n\n return texColor;\n}\n\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n // if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n // vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n // discard;\n // }\n }\n";
@@ -1,4 +1,4 @@
1
1
  export var heightVertexShader = /* glsl */"\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uHeight;\n uniform sampler2D map;\n\n void main() {\n vUv = uv;\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n float h = texture2D(map, vUv).a * uHeight;\n // gl_Position = projectionMatrix * viewMatrix * vec4(worldPosition.x, worldPosition.y, h, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, position.y, position.z, 1.0);\n }\n";
2
2
  var pixelGraphFunc = /* glsl */"\nvec4 createPixelGraphEffect(sampler2D map, vec2 vUv, float granularity, float threshold, vec2 range, vec3 worldPos) {\n vec2 pixelSize = vec2(1.0) / granularity;\n vec2 cell = floor(vUv / pixelSize);\n vec2 cellUv = fract(vUv / pixelSize);\n\n vec4 texColor = texture2D(map, (cell + 0.5) * pixelSize);\n\n vec2 pointCenter = vec2(0.5, 0.5);\n vec2 rotatedUv = cellUv - pointCenter;\n vec2 rotated = vec2(\n (rotatedUv.x - rotatedUv.y) * 0.7071067811865476,\n (rotatedUv.x + rotatedUv.y) * 0.7071067811865476\n );\n\n float dist = abs(rotated.x) + abs(rotated.y);\n\n float intensity = (texColor.r + texColor.g + texColor.b) / 3.0;\n float pointSize = 0.3 * smoothstep(0.0, threshold, intensity);\n\n if (dist > pointSize || intensity < 0.05) {\n discard;\n }\n\n return texColor;\n}\n";
3
- export var heightFragmentShader = /* glsl */"\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n ".concat(pixelGraphFunc, "\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n discard;\n }\n }\n");
3
+ export var heightFragmentShader = /* glsl */"\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n ".concat(pixelGraphFunc, "\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n // if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n // vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n // discard;\n // }\n }\n");
4
4
  //# sourceMappingURL=shader.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["heightVertexShader","pixelGraphFunc","heightFragmentShader","concat"],"sources":["../../../src/business/HeatMap/shader.ts"],"sourcesContent":["export const heightVertexShader = /* glsl */ `\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uHeight;\n uniform sampler2D map;\n\n void main() {\n vUv = uv;\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n float h = texture2D(map, vUv).a * uHeight;\n // gl_Position = projectionMatrix * viewMatrix * vec4(worldPosition.x, worldPosition.y, h, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, position.y, position.z, 1.0);\n }\n`\n\nconst pixelGraphFunc = /* glsl */ `\nvec4 createPixelGraphEffect(sampler2D map, vec2 vUv, float granularity, float threshold, vec2 range, vec3 worldPos) {\n vec2 pixelSize = vec2(1.0) / granularity;\n vec2 cell = floor(vUv / pixelSize);\n vec2 cellUv = fract(vUv / pixelSize);\n\n vec4 texColor = texture2D(map, (cell + 0.5) * pixelSize);\n\n vec2 pointCenter = vec2(0.5, 0.5);\n vec2 rotatedUv = cellUv - pointCenter;\n vec2 rotated = vec2(\n (rotatedUv.x - rotatedUv.y) * 0.7071067811865476,\n (rotatedUv.x + rotatedUv.y) * 0.7071067811865476\n );\n\n float dist = abs(rotated.x) + abs(rotated.y);\n\n float intensity = (texColor.r + texColor.g + texColor.b) / 3.0;\n float pointSize = 0.3 * smoothstep(0.0, threshold, intensity);\n\n if (dist > pointSize || intensity < 0.05) {\n discard;\n }\n\n return texColor;\n}\n`\n\nexport const heightFragmentShader = /* glsl */ `\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n ${pixelGraphFunc}\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n discard;\n }\n }\n`\n"],"mappings":"AAAA,OAAO,IAAMA,kBAAkB,GAAG,kgBAcjC;AAED,IAAMC,cAAc,GAAG,u1BA0BtB;AAED,OAAO,IAAMC,oBAAoB,GAAG,wOAAAC,MAAA,CAUhCF,cAAc,weAgBjB"}
1
+ {"version":3,"names":["heightVertexShader","pixelGraphFunc","heightFragmentShader","concat"],"sources":["../../../src/business/HeatMap/shader.ts"],"sourcesContent":["export const heightVertexShader = /* glsl */ `\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uHeight;\n uniform sampler2D map;\n\n void main() {\n vUv = uv;\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vWorldPosition = worldPosition.xyz;\n float h = texture2D(map, vUv).a * uHeight;\n // gl_Position = projectionMatrix * viewMatrix * vec4(worldPosition.x, worldPosition.y, h, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position.x, position.y, position.z, 1.0);\n }\n`\n\nconst pixelGraphFunc = /* glsl */ `\nvec4 createPixelGraphEffect(sampler2D map, vec2 vUv, float granularity, float threshold, vec2 range, vec3 worldPos) {\n vec2 pixelSize = vec2(1.0) / granularity;\n vec2 cell = floor(vUv / pixelSize);\n vec2 cellUv = fract(vUv / pixelSize);\n\n vec4 texColor = texture2D(map, (cell + 0.5) * pixelSize);\n\n vec2 pointCenter = vec2(0.5, 0.5);\n vec2 rotatedUv = cellUv - pointCenter;\n vec2 rotated = vec2(\n (rotatedUv.x - rotatedUv.y) * 0.7071067811865476,\n (rotatedUv.x + rotatedUv.y) * 0.7071067811865476\n );\n\n float dist = abs(rotated.x) + abs(rotated.y);\n\n float intensity = (texColor.r + texColor.g + texColor.b) / 3.0;\n float pointSize = 0.3 * smoothstep(0.0, threshold, intensity);\n\n if (dist > pointSize || intensity < 0.05) {\n discard;\n }\n\n return texColor;\n}\n`\n\nexport const heightFragmentShader = /* glsl */ `\n uniform sampler2D map;\n uniform float granularity;\n uniform float threshold;\n uniform vec2 uRange;\n varying vec2 vUv;\n varying vec3 vWorldPosition;\n uniform float uOpacity;\n uniform bool isPixel;\n\n ${pixelGraphFunc}\n\n void main() {\n vec4 texColor = isPixel ? \n createPixelGraphEffect(map, vUv, granularity, threshold, uRange, vWorldPosition) : \n texture2D(map, vUv);\n \n float a = texColor.a * uOpacity;\n gl_FragColor = texColor;\n gl_FragColor.a = min(a, 1.0); \n\n // if(vWorldPosition.x < uRange.x || vWorldPosition.x > uRange.y || \n // vWorldPosition.z < uRange.x || vWorldPosition.z > uRange.y) {\n // discard;\n // }\n }\n`\n"],"mappings":"AAAA,OAAO,IAAMA,kBAAkB,GAAG,kgBAcjC;AAED,IAAMC,cAAc,GAAG,u1BA0BtB;AAED,OAAO,IAAMC,oBAAoB,GAAG,wOAAAC,MAAA,CAUhCF,cAAc,ofAgBjB"}
@@ -1,13 +1,14 @@
1
1
  import { Color, RepeatWrapping, ShaderChunk, TextureLoader, Vector4 } from '@anov/3d-core';
2
+ import { demo03, demo04, main } from "./groundBase64";
2
3
  var TEXTURE_BASE_PATH = './';
3
4
  var TEXTURE_REPEAT_COUNT = 5000;
4
5
  var MASK_TEXTURE_REPEAT = 10;
5
6
  var DEFAULT_GROUND_COLOR = '#096ddb';
6
7
  var DEFAULT_MASK_COLOR = '#ffffff';
7
8
  var textureLoader = new TextureLoader();
8
- var groundBaseTexture = textureLoader.load("".concat(TEXTURE_BASE_PATH, "demo03.jpg"));
9
- var groundMaskTexture = textureLoader.load("".concat(TEXTURE_BASE_PATH, "demo04.jpg"));
10
- var groundPlaneTexture = textureLoader.load("".concat(TEXTURE_BASE_PATH, "test04.jpg"));
9
+ var groundBaseTexture = textureLoader.load(demo03);
10
+ var groundMaskTexture = textureLoader.load(demo04);
11
+ var groundPlaneTexture = textureLoader.load(main);
11
12
  var configureTexture = function configureTexture(texture, repeatX, repeatY) {
12
13
  texture.wrapS = RepeatWrapping;
13
14
  texture.wrapT = RepeatWrapping;
@@ -59,7 +60,7 @@ export var uniforms = {
59
60
  var vertexShader = /* glsl */"\n ".concat(ShaderChunk.logdepthbuf_pars_vertex, "\n \n bool isPerspectiveMatrix(mat4) {\n return true;\n }\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vPosition = worldPosition.xyz;\n ").concat(ShaderChunk.logdepthbuf_vertex, "\n }\n");
60
61
 
61
62
  // Fragment shader
62
- var fragmentShader = /* glsl */"\n ".concat(ShaderChunk.logdepthbuf_pars_fragment, " \n\n uniform sampler2D _Texture;\n uniform sampler2D _TexturePlane;\n uniform vec4 _Color;\n uniform float _ColorS;\n uniform sampler2D _TextureMask;\n uniform float _MaskUV;\n uniform vec4 _ColorMask;\n uniform float _ColorMaskS;\n uniform float time;\n uniform float progress;\n uniform float objSize;\n uniform bool isFadeIn;\n uniform vec4 center;\n uniform bool isApi;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vec4 highlightColor = vec4(0.0, 0.6, 1.0, 1.0);\n vec3 baseColor = vec3(0.2);\n vec4 outputColor = vec4(baseColor, 1.0);\n \n // todo \u540E\u671F\u9700\u8981\u6839\u636E\u5927\u5C0F\u81EA\u52A8\u8C03\u6574\n vec2 mainTextureUV = vUv * 30.0;\n vec4 baseTexture = texture2D(_Texture, mainTextureUV);\n vec4 planeTexture = texture2D(_TexturePlane, mainTextureUV);\n \n vec2 maskScale = vec2(_MaskUV) * 3.0;\n vec2 maskUV = vUv * maskScale;\n vec2 animatedMaskUV = vec2(time, time) + maskUV;\n \n outputColor.rgb = (\n (planeTexture * 0.1) +\n (_Color * baseTexture.r * _ColorS) +\n (highlightColor * (baseTexture.r * texture2D(_TextureMask, animatedMaskUV).r) * _ColorMaskS * 10.0)\n ).rgb;\n\n if (isApi) {\n outputColor.rgb = mix(vec3(0.0), outputColor.rgb, 0.1);\n }\n \n outputColor.a = 1.0;\n\n vec3 myWorldPosition = vPosition / objSize;\n if (isFadeIn) {\n float circle1 = step(distance(center.xyz / objSize, myWorldPosition), progress - 0.02);\n float circle2 = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.rgb += vec3(circle2 - circle1) * 3.;\n outputColor.a = outputColor.a * circle2;\n } else {\n float circle = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.a *= step(circle, 0.);\n }\n \n gl_FragColor = outputColor;\n ").concat(ShaderChunk.logdepthbuf_fragment, "\n }\n");
63
+ var fragmentShader = /* glsl */"\n ".concat(ShaderChunk.logdepthbuf_pars_fragment, " \n\n uniform sampler2D _Texture;\n uniform sampler2D _TexturePlane;\n uniform vec4 _Color;\n uniform float _ColorS;\n uniform sampler2D _TextureMask;\n uniform float _MaskUV;\n uniform vec4 _ColorMask;\n uniform float _ColorMaskS;\n uniform float time;\n uniform float progress;\n uniform float objSize;\n uniform bool isFadeIn;\n uniform vec4 center;\n uniform bool isApi;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vec4 highlightColor = vec4(0.0, 0.6, 1.0, 1.0);\n vec3 baseColor = vec3(0.2);\n vec4 outputColor = vec4(baseColor, 1.0);\n \n // todo \u540E\u671F\u9700\u8981\u6839\u636E\u5927\u5C0F\u81EA\u52A8\u8C03\u6574\n // vec2 mainTextureUV = vUv * 20.0;\n vec4 baseTexture = texture2D(_Texture, vUv * 25.0);\n vec4 planeTexture = texture2D(_TexturePlane, vUv * 15.0);\n \n vec2 maskScale = vec2(_MaskUV) * 20.0;\n vec2 maskUV = vUv * maskScale;\n vec2 animatedMaskUV = vec2(time, time) + maskUV;\n \n outputColor.rgb = (\n (planeTexture * 0.09) +\n (_Color * baseTexture.r * _ColorS) +\n (highlightColor * (baseTexture.r * texture2D(_TextureMask, animatedMaskUV).r) * _ColorMaskS * 10.0)\n ).rgb;\n\n if (isApi) {\n outputColor.rgb = mix(vec3(0.0), outputColor.rgb, 0.1);\n }\n \n outputColor.a = 1.0;\n\n vec3 myWorldPosition = vPosition / objSize;\n if (isFadeIn) {\n float circle1 = step(distance(center.xyz / objSize, myWorldPosition), progress - 0.02);\n float circle2 = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.rgb += vec3(circle2 - circle1) * 3.;\n outputColor.a = outputColor.a * circle2;\n } else {\n float circle = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.a *= step(circle, 0.);\n }\n \n gl_FragColor = outputColor;\n ").concat(ShaderChunk.logdepthbuf_fragment, "\n }\n");
63
64
  export var ground = {
64
65
  vertexShader: vertexShader,
65
66
  fragmentShader: fragmentShader,
@@ -1 +1 @@
1
- {"version":3,"names":["Color","RepeatWrapping","ShaderChunk","TextureLoader","Vector4","TEXTURE_BASE_PATH","TEXTURE_REPEAT_COUNT","MASK_TEXTURE_REPEAT","DEFAULT_GROUND_COLOR","DEFAULT_MASK_COLOR","textureLoader","groundBaseTexture","load","concat","groundMaskTexture","groundPlaneTexture","configureTexture","texture","repeatX","repeatY","wrapS","wrapT","repeat","set","uniforms","_Texture","value","_Texture_ST","_Color","r","g","b","_ColorS","_TextureMask","_TexturePlane","_MaskUV","_ColorMask","_ColorMaskS","_Speed","_OP","time","vertexShader","logdepthbuf_pars_vertex","logdepthbuf_vertex","fragmentShader","logdepthbuf_pars_fragment","logdepthbuf_fragment","ground"],"sources":["../../../../src/business/MaterialSwitch/shader/ground.ts"],"sourcesContent":["import type { Mesh, ShaderMaterial } from '@anov/3d-core'\nimport { Color, LoaderModule, RepeatWrapping, ShaderChunk, TextureLoader, Vector4, utils } from '@anov/3d-core'\n\nconst TEXTURE_BASE_PATH = './'\nconst TEXTURE_REPEAT_COUNT = 5000\nconst MASK_TEXTURE_REPEAT = 10\nconst DEFAULT_GROUND_COLOR = '#096ddb'\nconst DEFAULT_MASK_COLOR = '#ffffff'\n\nconst textureLoader = new TextureLoader()\n\nconst groundBaseTexture = textureLoader.load(`${TEXTURE_BASE_PATH}demo03.jpg`)\nconst groundMaskTexture = textureLoader.load(`${TEXTURE_BASE_PATH}demo04.jpg`)\nconst groundPlaneTexture = textureLoader.load(`${TEXTURE_BASE_PATH}test04.jpg`)\n\nconst configureTexture = (texture: THREE.Texture, repeatX: number, repeatY: number) => {\n texture.wrapS = RepeatWrapping\n texture.wrapT = RepeatWrapping\n texture.repeat.set(repeatX, repeatY)\n}\n\nconfigureTexture(groundBaseTexture, TEXTURE_REPEAT_COUNT, TEXTURE_REPEAT_COUNT)\nconfigureTexture(groundMaskTexture, MASK_TEXTURE_REPEAT, MASK_TEXTURE_REPEAT)\nconfigureTexture(groundPlaneTexture, TEXTURE_REPEAT_COUNT, TEXTURE_REPEAT_COUNT)\n\nexport const uniforms = {\n _Texture: { value: groundBaseTexture },\n _Texture_ST: { value: new Vector4() },\n _Color: {\n value: new Vector4(\n new Color(DEFAULT_GROUND_COLOR).r,\n new Color(DEFAULT_GROUND_COLOR).g,\n new Color(DEFAULT_GROUND_COLOR).b,\n 0.5,\n ),\n },\n _ColorS: { value: 1 },\n _TextureMask: { value: groundMaskTexture },\n _TexturePlane: { value: groundPlaneTexture },\n _MaskUV: { value: 1 },\n _ColorMask: {\n value: new Vector4(\n new Color(DEFAULT_MASK_COLOR).r,\n new Color(DEFAULT_MASK_COLOR).g,\n new Color(DEFAULT_MASK_COLOR).b,\n 1,\n ),\n },\n _ColorMaskS: { value: 1 },\n _Speed: { value: new Vector4(0.0, 0.2, 0, 0) },\n _OP: { value: 1.0 },\n time: { value: 1.0 },\n}\n\n// Vertex shader\nconst vertexShader = /* glsl */`\n ${ShaderChunk.logdepthbuf_pars_vertex}\n \n bool isPerspectiveMatrix(mat4) {\n return true;\n }\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vPosition = worldPosition.xyz;\n ${ShaderChunk.logdepthbuf_vertex}\n }\n`\n\n// Fragment shader\nconst fragmentShader = /* glsl */`\n ${ShaderChunk.logdepthbuf_pars_fragment} \n\n uniform sampler2D _Texture;\n uniform sampler2D _TexturePlane;\n uniform vec4 _Color;\n uniform float _ColorS;\n uniform sampler2D _TextureMask;\n uniform float _MaskUV;\n uniform vec4 _ColorMask;\n uniform float _ColorMaskS;\n uniform float time;\n uniform float progress;\n uniform float objSize;\n uniform bool isFadeIn;\n uniform vec4 center;\n uniform bool isApi;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vec4 highlightColor = vec4(0.0, 0.6, 1.0, 1.0);\n vec3 baseColor = vec3(0.2);\n vec4 outputColor = vec4(baseColor, 1.0);\n \n // todo 后期需要根据大小自动调整\n vec2 mainTextureUV = vUv * 30.0;\n vec4 baseTexture = texture2D(_Texture, mainTextureUV);\n vec4 planeTexture = texture2D(_TexturePlane, mainTextureUV);\n \n vec2 maskScale = vec2(_MaskUV) * 3.0;\n vec2 maskUV = vUv * maskScale;\n vec2 animatedMaskUV = vec2(time, time) + maskUV;\n \n outputColor.rgb = (\n (planeTexture * 0.1) +\n (_Color * baseTexture.r * _ColorS) +\n (highlightColor * (baseTexture.r * texture2D(_TextureMask, animatedMaskUV).r) * _ColorMaskS * 10.0)\n ).rgb;\n\n if (isApi) {\n outputColor.rgb = mix(vec3(0.0), outputColor.rgb, 0.1);\n }\n \n outputColor.a = 1.0;\n\n vec3 myWorldPosition = vPosition / objSize;\n if (isFadeIn) {\n float circle1 = step(distance(center.xyz / objSize, myWorldPosition), progress - 0.02);\n float circle2 = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.rgb += vec3(circle2 - circle1) * 3.;\n outputColor.a = outputColor.a * circle2;\n } else {\n float circle = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.a *= step(circle, 0.);\n }\n \n gl_FragColor = outputColor;\n ${ShaderChunk.logdepthbuf_fragment}\n }\n`\n\nexport const ground = { vertexShader, fragmentShader, uniforms }"],"mappings":"AACA,SAASA,KAAK,EAAgBC,cAAc,EAAEC,WAAW,EAAEC,aAAa,EAAEC,OAAO,QAAe,eAAe;AAE/G,IAAMC,iBAAiB,GAAG,IAAI;AAC9B,IAAMC,oBAAoB,GAAG,IAAI;AACjC,IAAMC,mBAAmB,GAAG,EAAE;AAC9B,IAAMC,oBAAoB,GAAG,SAAS;AACtC,IAAMC,kBAAkB,GAAG,SAAS;AAEpC,IAAMC,aAAa,GAAG,IAAIP,aAAa,CAAC,CAAC;AAEzC,IAAMQ,iBAAiB,GAAGD,aAAa,CAACE,IAAI,IAAAC,MAAA,CAAIR,iBAAiB,eAAY,CAAC;AAC9E,IAAMS,iBAAiB,GAAGJ,aAAa,CAACE,IAAI,IAAAC,MAAA,CAAIR,iBAAiB,eAAY,CAAC;AAC9E,IAAMU,kBAAkB,GAAGL,aAAa,CAACE,IAAI,IAAAC,MAAA,CAAIR,iBAAiB,eAAY,CAAC;AAE/E,IAAMW,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,OAAsB,EAAEC,OAAe,EAAEC,OAAe,EAAK;EACrFF,OAAO,CAACG,KAAK,GAAGnB,cAAc;EAC9BgB,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;IAAEZ,KAAK,EAAE,IAAItB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;EAAE,CAAC;EAC9CmC,GAAG,EAAE;IAAEb,KAAK,EAAE;EAAI,CAAC;EACnBc,IAAI,EAAE;IAAEd,KAAK,EAAE;EAAI;AACrB,CAAC;;AAED;AACA,IAAMe,YAAY,GAAG,mBAAA5B,MAAA,CACfX,WAAW,CAACwC,uBAAuB,qXAAA7B,MAAA,CAc/BX,WAAW,CAACyC,kBAAkB,cAEvC;;AAED;AACA,IAAMC,cAAc,GAAG,mBAAA/B,MAAA,CACjBX,WAAW,CAAC2C,yBAAyB,6iEAAAhC,MAAA,CA0DjCX,WAAW,CAAC4C,oBAAoB,cAEzC;AAED,OAAO,IAAMC,MAAM,GAAG;EAAEN,YAAY,EAAZA,YAAY;EAAEG,cAAc,EAAdA,cAAc;EAAEpB,QAAQ,EAARA;AAAS,CAAC"}
1
+ {"version":3,"names":["Color","RepeatWrapping","ShaderChunk","TextureLoader","Vector4","demo03","demo04","main","TEXTURE_BASE_PATH","TEXTURE_REPEAT_COUNT","MASK_TEXTURE_REPEAT","DEFAULT_GROUND_COLOR","DEFAULT_MASK_COLOR","textureLoader","groundBaseTexture","load","groundMaskTexture","groundPlaneTexture","configureTexture","texture","repeatX","repeatY","wrapS","wrapT","repeat","set","uniforms","_Texture","value","_Texture_ST","_Color","r","g","b","_ColorS","_TextureMask","_TexturePlane","_MaskUV","_ColorMask","_ColorMaskS","_Speed","_OP","time","vertexShader","concat","logdepthbuf_pars_vertex","logdepthbuf_vertex","fragmentShader","logdepthbuf_pars_fragment","logdepthbuf_fragment","ground"],"sources":["../../../../src/business/MaterialSwitch/shader/ground.ts"],"sourcesContent":["import type { Mesh, ShaderMaterial } from '@anov/3d-core'\nimport { Color, LoaderModule, RepeatWrapping, ShaderChunk, TextureLoader, Vector4, utils } from '@anov/3d-core'\nimport { demo03, demo04, main } from './groundBase64'\n\nconst TEXTURE_BASE_PATH = './'\nconst TEXTURE_REPEAT_COUNT = 5000\nconst MASK_TEXTURE_REPEAT = 10\nconst DEFAULT_GROUND_COLOR = '#096ddb'\nconst DEFAULT_MASK_COLOR = '#ffffff'\n\nconst textureLoader = new TextureLoader()\n\nconst groundBaseTexture = textureLoader.load(demo03)\nconst groundMaskTexture = textureLoader.load(demo04)\nconst groundPlaneTexture = textureLoader.load(main)\n\nconst configureTexture = (texture: THREE.Texture, repeatX: number, repeatY: number) => {\n texture.wrapS = RepeatWrapping\n texture.wrapT = RepeatWrapping\n texture.repeat.set(repeatX, repeatY)\n}\n\nconfigureTexture(groundBaseTexture, TEXTURE_REPEAT_COUNT, TEXTURE_REPEAT_COUNT)\nconfigureTexture(groundMaskTexture, MASK_TEXTURE_REPEAT, MASK_TEXTURE_REPEAT)\nconfigureTexture(groundPlaneTexture, TEXTURE_REPEAT_COUNT, TEXTURE_REPEAT_COUNT)\n\nexport const uniforms = {\n _Texture: { value: groundBaseTexture },\n _Texture_ST: { value: new Vector4() },\n _Color: {\n value: new Vector4(\n new Color(DEFAULT_GROUND_COLOR).r,\n new Color(DEFAULT_GROUND_COLOR).g,\n new Color(DEFAULT_GROUND_COLOR).b,\n 0.5,\n ),\n },\n _ColorS: { value: 1 },\n _TextureMask: { value: groundMaskTexture },\n _TexturePlane: { value: groundPlaneTexture },\n _MaskUV: { value: 1 },\n _ColorMask: {\n value: new Vector4(\n new Color(DEFAULT_MASK_COLOR).r,\n new Color(DEFAULT_MASK_COLOR).g,\n new Color(DEFAULT_MASK_COLOR).b,\n 1,\n ),\n },\n _ColorMaskS: { value: 1 },\n _Speed: { value: new Vector4(0.0, 0.2, 0, 0) },\n _OP: { value: 1.0 },\n time: { value: 1.0 },\n}\n\n// Vertex shader\nconst vertexShader = /* glsl */`\n ${ShaderChunk.logdepthbuf_pars_vertex}\n \n bool isPerspectiveMatrix(mat4) {\n return true;\n }\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vPosition = worldPosition.xyz;\n ${ShaderChunk.logdepthbuf_vertex}\n }\n`\n\n// Fragment shader\nconst fragmentShader = /* glsl */`\n ${ShaderChunk.logdepthbuf_pars_fragment} \n\n uniform sampler2D _Texture;\n uniform sampler2D _TexturePlane;\n uniform vec4 _Color;\n uniform float _ColorS;\n uniform sampler2D _TextureMask;\n uniform float _MaskUV;\n uniform vec4 _ColorMask;\n uniform float _ColorMaskS;\n uniform float time;\n uniform float progress;\n uniform float objSize;\n uniform bool isFadeIn;\n uniform vec4 center;\n uniform bool isApi;\n \n varying vec2 vUv;\n varying vec3 vPosition;\n\n void main() {\n vec4 highlightColor = vec4(0.0, 0.6, 1.0, 1.0);\n vec3 baseColor = vec3(0.2);\n vec4 outputColor = vec4(baseColor, 1.0);\n \n // todo 后期需要根据大小自动调整\n // vec2 mainTextureUV = vUv * 20.0;\n vec4 baseTexture = texture2D(_Texture, vUv * 25.0);\n vec4 planeTexture = texture2D(_TexturePlane, vUv * 15.0);\n \n vec2 maskScale = vec2(_MaskUV) * 20.0;\n vec2 maskUV = vUv * maskScale;\n vec2 animatedMaskUV = vec2(time, time) + maskUV;\n \n outputColor.rgb = (\n (planeTexture * 0.09) +\n (_Color * baseTexture.r * _ColorS) +\n (highlightColor * (baseTexture.r * texture2D(_TextureMask, animatedMaskUV).r) * _ColorMaskS * 10.0)\n ).rgb;\n\n if (isApi) {\n outputColor.rgb = mix(vec3(0.0), outputColor.rgb, 0.1);\n }\n \n outputColor.a = 1.0;\n\n vec3 myWorldPosition = vPosition / objSize;\n if (isFadeIn) {\n float circle1 = step(distance(center.xyz / objSize, myWorldPosition), progress - 0.02);\n float circle2 = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.rgb += vec3(circle2 - circle1) * 3.;\n outputColor.a = outputColor.a * circle2;\n } else {\n float circle = step(distance(center.xyz / objSize, myWorldPosition), progress);\n outputColor.a *= step(circle, 0.);\n }\n \n gl_FragColor = outputColor;\n ${ShaderChunk.logdepthbuf_fragment}\n }\n`\n\nexport const ground = { vertexShader, fragmentShader, uniforms }"],"mappings":"AACA,SAASA,KAAK,EAAgBC,cAAc,EAAEC,WAAW,EAAEC,aAAa,EAAEC,OAAO,QAAe,eAAe;AAC/G,SAASC,MAAM,EAAEC,MAAM,EAAEC,IAAI;AAE7B,IAAMC,iBAAiB,GAAG,IAAI;AAC9B,IAAMC,oBAAoB,GAAG,IAAI;AACjC,IAAMC,mBAAmB,GAAG,EAAE;AAC9B,IAAMC,oBAAoB,GAAG,SAAS;AACtC,IAAMC,kBAAkB,GAAG,SAAS;AAEpC,IAAMC,aAAa,GAAG,IAAIV,aAAa,CAAC,CAAC;AAEzC,IAAMW,iBAAiB,GAAGD,aAAa,CAACE,IAAI,CAACV,MAAM,CAAC;AACpD,IAAMW,iBAAiB,GAAGH,aAAa,CAACE,IAAI,CAACT,MAAM,CAAC;AACpD,IAAMW,kBAAkB,GAAGJ,aAAa,CAACE,IAAI,CAACR,IAAI,CAAC;AAEnD,IAAMW,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,OAAsB,EAAEC,OAAe,EAAEC,OAAe,EAAK;EACrFF,OAAO,CAACG,KAAK,GAAGrB,cAAc;EAC9BkB,OAAO,CAACI,KAAK,GAAGtB,cAAc;EAC9BkB,OAAO,CAACK,MAAM,CAACC,GAAG,CAACL,OAAO,EAAEC,OAAO,CAAC;AACtC,CAAC;AAEDH,gBAAgB,CAACJ,iBAAiB,EAAEL,oBAAoB,EAAEA,oBAAoB,CAAC;AAC/ES,gBAAgB,CAACF,iBAAiB,EAAEN,mBAAmB,EAAEA,mBAAmB,CAAC;AAC7EQ,gBAAgB,CAACD,kBAAkB,EAAER,oBAAoB,EAAEA,oBAAoB,CAAC;AAEhF,OAAO,IAAMiB,QAAQ,GAAG;EACtBC,QAAQ,EAAE;IAAEC,KAAK,EAAEd;EAAkB,CAAC;EAC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