@shijiu/jsview-vue-samples 2.2.201 → 2.2.373
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/BakeViewDemo/App.vue +6 -1
- package/Basic/components/anim/AnimEasingCubicBezier.vue +56 -0
- package/Basic/components/anim/AnimGroup2.vue +33 -0
- package/Basic/components/panel/Panel2.vue +8 -3
- package/CoupletsTest/widget/Banger/Maroon.vue +0 -1
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +0 -2
- package/CustomShader/App.vue +30 -13
- package/CustomShader/pageFlip.glsl +3 -2
- package/DemoHomepage/App.vue +14 -5
- package/DemoHomepage/components/Item.vue +23 -12
- package/DemoHomepage/index.d.ts +5 -2
- package/DemoHomepage/router.js +97 -74
- package/DispersedFocusControl/App.vue +67 -0
- package/DispersedFocusControl/Button.vue +76 -0
- package/DispersedFocusControl/data.js +44 -0
- package/DragBox/App.vue +148 -0
- package/FlexCellDemo/App.vue +47 -223
- package/FlexCellDemo/TestFrame1.vue +88 -0
- package/FlexCellDemo/TestFrame2.vue +100 -0
- package/FlexCellDemo/TestFrame3.vue +97 -0
- package/FlexCellDemo/TestFrame4.vue +60 -0
- package/FlexCellDemo/TestFrame5.vue +60 -0
- package/FlexCellDemo/images/6.jpg +0 -0
- package/FocusMoveStyle/App.vue +1 -0
- package/FocusMoveStyle/CreepFocus.vue +11 -1
- package/FocusMoveStyle/FoldableItem.vue +1 -1
- package/FullScreenFlex/App.vue +42 -0
- package/FullScreenFlex/TestFrame2.vue +107 -0
- package/FullScreenFlex/images/1.png +0 -0
- package/HashHistory/App.vue +8 -4
- package/Input/App.vue +184 -97
- package/Input/InputPanel.vue +98 -82
- package/LatexFormula/App.vue +97 -10
- package/MetroWidgetDemos/itemSizeUpdate/backward/Item.vue +1 -1
- package/MetroWidgetDemos/routeList.js +17 -17
- package/MindMap/App.vue +10 -1
- package/MindMap/data.js +34 -8
- package/Parkour/appConfig/jsview.config.mjs +0 -4
- package/PosterPacker/App.vue +207 -0
- package/PosterPacker/images/bg.jpg +0 -0
- package/PosterPacker/images/blue.png +0 -0
- package/PosterPacker/images/darkGreen.png +0 -0
- package/PosterPacker/images/left.png +0 -0
- package/PosterPacker/images/orange.png +0 -0
- package/PosterPacker/images/pink.png +0 -0
- package/PosterPacker/images/purple.png +0 -0
- package/PosterPacker/images/red.png +0 -0
- package/PosterPacker/images/right.png +0 -0
- package/PosterPacker/images/yellowGreen.png +0 -0
- package/PosterPacker/tools/geniePakcer/Genie.vue +686 -0
- package/PosterPacker/tools/geniePakcer/genieBottom.glsl +49 -0
- package/PosterPacker/tools/geniePakcer/genieLeft.glsl +50 -0
- package/PosterPacker/tools/geniePakcer/genieRight.glsl +57 -0
- package/PosterPacker/tools/geniePakcer/genieTop.glsl +50 -0
- package/PosterPacker/tools/particlePacker/Particle.vue +71 -0
- package/PosterPacker/tools/vortexPacker/Vortex.vue +135 -0
- package/PosterPacker/tools/vortexPacker/vortex.glsl +37 -0
- package/Preload/App.vue +1 -1
- package/ScrollBoxTest/ClipBar.vue +1 -0
- package/ScrollBoxTest/NinePatchBar.vue +1 -0
- package/ScrollBoxTest/SizeDivBar.vue +1 -0
- package/SprayMove/App.vue +75 -0
- package/SprayMove/SprayMove.vue +173 -0
- package/SprayView/App.vue +8 -9
- package/TestNativeSharedView/App.vue +6 -4
- package/TextShadowDemo/App.vue +3 -3
- package/TextureAnimation/App.vue +244 -148
- package/TextureAnimation/App2.vue +66 -14
- package/TextureAnimation/assets/blackWhiteTurntable.png +0 -0
- package/TextureAnimation/assets/circleHaloMask.png +0 -0
- package/TouchWidget/App.vue +79 -40
- package/TouchWidget/Item.vue +15 -3
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/TextureAnimation/assets/mask.png +0 -0
- package/TextureAnimation/assets/php.jpg +0 -0
- package/TouchSample/App.vue +0 -136
- package/TouchSample/Item.vue +0 -102
- package/TouchSample/MetroWidgetHorizontal.vue +0 -144
- package/TouchSample/MetroWidgetVertical.vue +0 -144
- package/TouchSample/TouchContainerHorizontal.vue +0 -160
- package/TouchSample/TouchContainerVertical.vue +0 -160
- package/TouchSample/data.js +0 -81
- /package/TextureAnimation/assets/{php2.png → borderOpacity.png} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#define VTIME 0.3
|
|
2
|
+
|
|
3
|
+
float yPoint(float y0, float y1, float x) {
|
|
4
|
+
float a = 2. * (y0 - y1);
|
|
5
|
+
float b = 3. * (y1 - y0);
|
|
6
|
+
float d = y0;
|
|
7
|
+
return a * x * x * x + b * x * x + d;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
float remap2(float uv, float inputLow, float inputHigh, float outputLow, float outputHigh){
|
|
11
|
+
float t = (uv - inputLow)/(inputHigh - inputLow);
|
|
12
|
+
float final = mix(outputLow,outputHigh,t);
|
|
13
|
+
return final;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
17
|
+
{
|
|
18
|
+
// Normalized pixel coordinates (from 0 to 1)
|
|
19
|
+
vec2 uv = fragCoord/iResolution.xy;
|
|
20
|
+
float t = ${myTime} ;
|
|
21
|
+
// float t = abs(sin(iTime));
|
|
22
|
+
//v animation
|
|
23
|
+
if (t < VTIME) {
|
|
24
|
+
float vAnimP = (t) / VTIME;
|
|
25
|
+
float top = mix(1.0, ${RANGE_1}, vAnimP);
|
|
26
|
+
float bottom = mix(0.0, ${RANGE_2}, vAnimP);
|
|
27
|
+
float xTop = yPoint(top, 1., uv.y); // Swap uv.x with uv.y
|
|
28
|
+
float xBottom = yPoint(bottom, 0., uv.y); // Swap uv.x with uv.y
|
|
29
|
+
float newUvX = remap2(uv.x, xBottom, xTop, 0.0, 1.0); // Swap uv.x with uv.y
|
|
30
|
+
if (newUvX > 1. || newUvX < 0.) {
|
|
31
|
+
fragColor = vec4(0.);
|
|
32
|
+
} else {
|
|
33
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, uv.y));
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
//h animation
|
|
37
|
+
float xTop = yPoint(${RANGE_1}, 1., uv.y); // Swap uv.x with uv.y
|
|
38
|
+
float xBottom = yPoint(${RANGE_2}, 0., uv.y); // Swap uv.x with uv.y
|
|
39
|
+
float newUvX = remap2(uv.x, xBottom, xTop, 0.0, 1.0); // Swap uv.x with uv.y
|
|
40
|
+
float hAnimP = (t - VTIME) / (1. - VTIME);
|
|
41
|
+
float yStart = mix(0., 1., hAnimP); // Calculate the vertical shift
|
|
42
|
+
float newUvY = uv.y + yStart; // Adjust the y-coordinate
|
|
43
|
+
if (newUvX > 1. || newUvX < 0. || newUvY > 1. || newUvY < 0.) {
|
|
44
|
+
fragColor = vec4(0.);
|
|
45
|
+
} else {
|
|
46
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, newUvY));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#define VTIME 0.3
|
|
2
|
+
|
|
3
|
+
float yPoint(float y0, float y1, float x) {
|
|
4
|
+
float a = 2. * (y0 - y1);
|
|
5
|
+
float b = 3. * (y1 - y0);
|
|
6
|
+
//float c. = 0.;
|
|
7
|
+
float d = y0;
|
|
8
|
+
return a * x * x * x + b * x * x + d;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
float remap2(float uv, float inputLow, float inputHigh, float outputLow, float outputHigh){
|
|
12
|
+
float t = (uv - inputLow)/(inputHigh - inputLow);
|
|
13
|
+
float final = mix(outputLow,outputHigh,t);
|
|
14
|
+
return final;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
18
|
+
{
|
|
19
|
+
// Normalized pixel coordinates (from 0 to 1)
|
|
20
|
+
vec2 uv = fragCoord/iResolution.xy;
|
|
21
|
+
float t = ${myTime} ;
|
|
22
|
+
// float t = abs(sin(iTime));
|
|
23
|
+
//v animation
|
|
24
|
+
if (t < VTIME) {
|
|
25
|
+
float vAnimP = (t) / VTIME;
|
|
26
|
+
float top = mix(1.0, ${RANGE_1}, vAnimP);
|
|
27
|
+
float bottom = mix(0.0, ${RANGE_2}, vAnimP);
|
|
28
|
+
float yTop = yPoint(top, 1., uv.x);
|
|
29
|
+
float yBottom = yPoint(bottom, 0., uv.x);
|
|
30
|
+
float newUvY = remap2(uv.y, yBottom, yTop, 0.0, 1.0);
|
|
31
|
+
if (newUvY > 1. || newUvY < 0.) {
|
|
32
|
+
fragColor = vec4(0.);
|
|
33
|
+
} else {
|
|
34
|
+
fragColor = jsvTexture2D(iChannel0, vec2(uv.x, newUvY));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
//h animation
|
|
38
|
+
float yTop = yPoint(${RANGE_1}, 1., uv.x);
|
|
39
|
+
float yBottom = yPoint(${RANGE_2}, 0., uv.x);
|
|
40
|
+
float newUvY = remap2(uv.y, yBottom, yTop, 0.0, 1.0);
|
|
41
|
+
float hAnimP = (t - VTIME) / (1. - VTIME);
|
|
42
|
+
float xStart = mix(0., 1., hAnimP);
|
|
43
|
+
float newUvX = uv.x + xStart;
|
|
44
|
+
if (newUvY > 1. || newUvY < 0. || newUvX > 1. || newUvY < 0.) {
|
|
45
|
+
fragColor = vec4(0.);
|
|
46
|
+
} else {
|
|
47
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, newUvY));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#define VTIME 0.3
|
|
2
|
+
|
|
3
|
+
float yPoint(float y0, float y1, float x) {
|
|
4
|
+
float a = 2. * (y1 - y0); // 交换 y0 和 y1
|
|
5
|
+
float b = 3. * (y0 - y1);
|
|
6
|
+
float d = y1; // 交换 y0 和 y1
|
|
7
|
+
return a * x * x * x + b * x * x + d;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
float remap2(float uv, float inputLow, float inputHigh, float outputLow, float outputHigh){
|
|
11
|
+
float t = (uv - inputLow)/(inputHigh - inputLow);
|
|
12
|
+
float final = mix(outputLow,outputHigh,t);
|
|
13
|
+
return final;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
17
|
+
{
|
|
18
|
+
// Normalized pixel coordinates (from 0 to 1)
|
|
19
|
+
vec2 uv = fragCoord/iResolution.xy;
|
|
20
|
+
float t = ${myTime} ;
|
|
21
|
+
// float t = abs(sin(iTime));
|
|
22
|
+
//v animation
|
|
23
|
+
if (t < VTIME) {
|
|
24
|
+
// 垂直动画
|
|
25
|
+
float vAnimP = (t) / VTIME;
|
|
26
|
+
float top = mix(1.0, ${RANGE_1}, vAnimP);
|
|
27
|
+
float bottom = mix(0.0, ${RANGE_2}, vAnimP);
|
|
28
|
+
float yTop = yPoint(top, 1., uv.x);
|
|
29
|
+
float yBottom = yPoint(bottom, 0., uv.x);
|
|
30
|
+
float newUvY = remap2(uv.y, yBottom, yTop, 0.0, 1.0);
|
|
31
|
+
if (newUvY > 1. || newUvY < 0.) {
|
|
32
|
+
fragColor = vec4(0.);
|
|
33
|
+
} else {
|
|
34
|
+
fragColor = jsvTexture2D(iChannel0, vec2(uv.x, newUvY));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// 水平动画
|
|
38
|
+
float yTop = yPoint(${RANGE_1}, 1., uv.x);
|
|
39
|
+
float yBottom = yPoint(${RANGE_2}, 0., uv.x);
|
|
40
|
+
float newUvY = remap2(uv.y, yBottom, yTop, 0.0, 1.0);
|
|
41
|
+
|
|
42
|
+
// 水平收缩动画的进度
|
|
43
|
+
float hAnimP = (t - VTIME) / (1. - VTIME);
|
|
44
|
+
|
|
45
|
+
// 从左到右收缩效果,xStart 从 0 渐变到 1
|
|
46
|
+
float xStart = mix(0., 1., hAnimP);
|
|
47
|
+
|
|
48
|
+
// 计算新的 UV X
|
|
49
|
+
float newUvX = uv.x - xStart;
|
|
50
|
+
// 确保 newUvX 和 newUvY 在合法范围内
|
|
51
|
+
if (newUvY > 1. || newUvY < 0. || newUvX > 1. || newUvX < 0.) {
|
|
52
|
+
fragColor = vec4(0.);
|
|
53
|
+
} else {
|
|
54
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, newUvY));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#define VTIME 0.3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
float yPoint(float y0, float y1, float x) {
|
|
5
|
+
float a = 2. * (y1 - y0);
|
|
6
|
+
float b = 3. * (y0 - y1);
|
|
7
|
+
float d = y1;
|
|
8
|
+
return a * x * x * x + b * x * x + d;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
float remap2(float uv, float inputLow, float inputHigh, float outputLow, float outputHigh){
|
|
12
|
+
float t = (uv - inputLow)/(inputHigh - inputLow);
|
|
13
|
+
float final = mix(outputLow, outputHigh, t);
|
|
14
|
+
return final;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
18
|
+
{
|
|
19
|
+
// Normalized pixel coordinates (from 0 to 1)
|
|
20
|
+
vec2 uv = fragCoord/iResolution.xy;
|
|
21
|
+
float t = ${myTime} ;
|
|
22
|
+
// float t = abs(sin(iTime));
|
|
23
|
+
//v animation
|
|
24
|
+
if (t < VTIME) {
|
|
25
|
+
float vAnimP = (t) / VTIME;
|
|
26
|
+
float top = mix(1.0, ${RANGE_1}, vAnimP);
|
|
27
|
+
float bottom = mix(0.0, ${RANGE_2}, vAnimP);
|
|
28
|
+
float xTop = yPoint(top, 1., uv.y);
|
|
29
|
+
float xBottom = yPoint(bottom, 0., uv.y);
|
|
30
|
+
float newUvX = remap2(uv.x, xBottom, xTop, 0.0, 1.0);
|
|
31
|
+
if (newUvX > 1. || newUvX < 0.) {
|
|
32
|
+
fragColor = vec4(0.);
|
|
33
|
+
} else {
|
|
34
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, uv.y));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
//h animation
|
|
38
|
+
float xTop = yPoint(${RANGE_1}, 1., uv.y);
|
|
39
|
+
float xBottom = yPoint(${RANGE_2}, 0., uv.y);
|
|
40
|
+
float newUvX = remap2(uv.x, xBottom, xTop, 0.0, 1.0);
|
|
41
|
+
float hAnimP = (t - VTIME) / (1. - VTIME);
|
|
42
|
+
float yStart = mix(0., 1., hAnimP); // Calculate the vertical shift
|
|
43
|
+
float newUvY = uv.y - yStart; // Adjust the y-coordinate for downward animation
|
|
44
|
+
if (newUvX > 1. || newUvX < 0. || newUvY > 1. || newUvY < 0.) {
|
|
45
|
+
fragColor = vec4(0.);
|
|
46
|
+
} else {
|
|
47
|
+
fragColor = jsvTexture2D(iChannel0, vec2(newUvX, newUvY));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
/**
|
|
3
|
+
* @file Particle组件说明
|
|
4
|
+
* Particle:粒子装饰组件
|
|
5
|
+
* props说明:
|
|
6
|
+
* @prop {Object} style (必填) 组件的基础样式
|
|
7
|
+
* @prop {Array<String>} imgArray (必填) 传入的粒子数组,每个item是图片的url
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
import { JsvSpray } from "jsview";
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
style: { type: Object, require: true },
|
|
14
|
+
imgArray: { type: Array,require: true},
|
|
15
|
+
});
|
|
16
|
+
//粒子图片数组
|
|
17
|
+
const ImgData = [];
|
|
18
|
+
//检查传入的imgArray格式
|
|
19
|
+
if (props.imgArray !== undefined) {
|
|
20
|
+
if (Array.isArray(props.imgArray)) {
|
|
21
|
+
props.imgArray.forEach((item, index) => {
|
|
22
|
+
ImgData.push(item);
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
console.warn("请传入正确的数组格式");
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
console.error("请传入图片数组");
|
|
29
|
+
}
|
|
30
|
+
//粒子特效配置
|
|
31
|
+
const sprayOk = {
|
|
32
|
+
type: 1,
|
|
33
|
+
particleNum: 5,
|
|
34
|
+
deltaAngle: 0,
|
|
35
|
+
deltaWidth: props.style.width / 2,
|
|
36
|
+
deltaHeight: 1,
|
|
37
|
+
pointSizeMin: 20,
|
|
38
|
+
pointSizeMax: 30,
|
|
39
|
+
speedMin: -3,
|
|
40
|
+
speedMax: -5,
|
|
41
|
+
lifeMin: 1500,
|
|
42
|
+
lifeMax: 3000,
|
|
43
|
+
accelerateX: 0,
|
|
44
|
+
accelerateY: 0,
|
|
45
|
+
particleAddSpeed: 0.002,
|
|
46
|
+
angularVelocityMin: 10,
|
|
47
|
+
angularVelocityMax: 15,
|
|
48
|
+
enableFade: false,
|
|
49
|
+
enableShrink: false,
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
52
|
+
<template>
|
|
53
|
+
<div
|
|
54
|
+
:style="{
|
|
55
|
+
width: props.style.width,
|
|
56
|
+
height: props.style.height,
|
|
57
|
+
left: props.style.left,
|
|
58
|
+
top: props.style.top,
|
|
59
|
+
overflow: 'hidden',
|
|
60
|
+
}"
|
|
61
|
+
>
|
|
62
|
+
<jsv-spray
|
|
63
|
+
v-for="item in ImgData"
|
|
64
|
+
:key="`item_${item}`"
|
|
65
|
+
:pointRes="`url(${item})`"
|
|
66
|
+
:sprayStyle="sprayOk"
|
|
67
|
+
:ignoreClip="false"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
<style scoped></style>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :key="keyNum">
|
|
3
|
+
<jsv-frag-shader-view
|
|
4
|
+
ref="rWidgetRef"
|
|
5
|
+
:style="{ left: 100, top: 200, width: props.width, height: props.height }"
|
|
6
|
+
:duration="rShaderInfo.duration"
|
|
7
|
+
:shaderStr="rShaderInfo.shader.value"
|
|
8
|
+
:autoplay="true"
|
|
9
|
+
:textures="rShaderInfo.textures"
|
|
10
|
+
:onEnd="rShaderInfo.onEnd"
|
|
11
|
+
>
|
|
12
|
+
</jsv-frag-shader-view>
|
|
13
|
+
<div
|
|
14
|
+
:style="{
|
|
15
|
+
width: props.width,
|
|
16
|
+
height: props.height,
|
|
17
|
+
left: 100,
|
|
18
|
+
top: 200,
|
|
19
|
+
}"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
:style="{
|
|
23
|
+
width: 50,
|
|
24
|
+
height: 50,
|
|
25
|
+
left: myX * props.width - 25,
|
|
26
|
+
top: props.height - (myY * props.height + 25),
|
|
27
|
+
backgroundColor: '#FF1213',
|
|
28
|
+
}"
|
|
29
|
+
></div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup>
|
|
35
|
+
import vortexShader from "./vortex.glsl?raw";
|
|
36
|
+
import { shallowRef, computed, onMounted, onUnmounted } from "vue";
|
|
37
|
+
import { JsvFragShaderView } from "jsview";
|
|
38
|
+
const props = defineProps({
|
|
39
|
+
width: { type: Number, require: true },
|
|
40
|
+
height: { type: Number, require: true },
|
|
41
|
+
imgUrl: { type: String, require: true },
|
|
42
|
+
left: { type: Number, default: 0 },
|
|
43
|
+
top: { type: Number, default: 0 },
|
|
44
|
+
});
|
|
45
|
+
//图片
|
|
46
|
+
const ImagePanda = "https://oss.image.qcast.cn/ai-draw/panda.jpeg";
|
|
47
|
+
//0-1的x和y的坐标值(初始为x和y的中心点)
|
|
48
|
+
let myX = 0.5;
|
|
49
|
+
let myY = 0.5;
|
|
50
|
+
let keyNum = shallowRef(0);
|
|
51
|
+
//ref
|
|
52
|
+
const rWidgetRef = shallowRef();
|
|
53
|
+
let vSTRENGTH = '10.'
|
|
54
|
+
//替换
|
|
55
|
+
let replacedShader = shallowRef(
|
|
56
|
+
vortexShader
|
|
57
|
+
.replace(/\$\{myCustomCenterX\}/g, myX)
|
|
58
|
+
.replace(/\$\{myCustomCenterY\}/g, myY)
|
|
59
|
+
.replace(/\$\{STRENGTH\}/g, vSTRENGTH)
|
|
60
|
+
);
|
|
61
|
+
console.log(9998,vortexShader);
|
|
62
|
+
|
|
63
|
+
//随机替换
|
|
64
|
+
const getRandomDecimal = () => {
|
|
65
|
+
myX = 0.9;
|
|
66
|
+
myY = 0.1;
|
|
67
|
+
//根据x轴的位置确定转数
|
|
68
|
+
if(myX>=0.8||myX<=0.2){
|
|
69
|
+
console.log('很小或很大');
|
|
70
|
+
vSTRENGTH = '40.'
|
|
71
|
+
}else if(myX>0.2<=0.4){
|
|
72
|
+
vSTRENGTH = '30.'
|
|
73
|
+
}else if(myX >=0.6 && myX < 0.8 ){
|
|
74
|
+
vSTRENGTH = '30.'
|
|
75
|
+
}else if(myX>0.4 && myX<0.6){
|
|
76
|
+
vSTRENGTH = '10.'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
replacedShader.value = vortexShader
|
|
80
|
+
.replace(/\$\{myCustomCenterX\}/g, myX)
|
|
81
|
+
.replace(/\$\{myCustomCenterY\}/g, myY)
|
|
82
|
+
.replace(/\$\{STRENGTH\}/g, vSTRENGTH)
|
|
83
|
+
keyNum.value += 1;
|
|
84
|
+
};
|
|
85
|
+
//接收外部设定中心点
|
|
86
|
+
const SetCenter = (x, y) => {
|
|
87
|
+
myX = x;
|
|
88
|
+
myY = y;
|
|
89
|
+
replacedShader.value = vortexShader
|
|
90
|
+
.replace(/\$\{myCustomCenterX\}/g, myX)
|
|
91
|
+
.replace(/\$\{myCustomCenterY\}/g, myY);
|
|
92
|
+
keyNum.value += 1;
|
|
93
|
+
};
|
|
94
|
+
//重新加载动画
|
|
95
|
+
const reloading1 = () => {
|
|
96
|
+
rWidgetRef.value?.startAnim();
|
|
97
|
+
};
|
|
98
|
+
const rShowShaderView = shallowRef(true);
|
|
99
|
+
//配置
|
|
100
|
+
const cShaderSettings = {
|
|
101
|
+
name: "vortex",
|
|
102
|
+
shader: replacedShader,
|
|
103
|
+
uniforms: [],
|
|
104
|
+
textures: [
|
|
105
|
+
{
|
|
106
|
+
name: "iChannel0",
|
|
107
|
+
resource: ImagePanda,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
duration: 3000,
|
|
111
|
+
onEnd: () => {
|
|
112
|
+
console.log("flip anim end");
|
|
113
|
+
rShowShaderView.value = false;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const rShaderInfo = computed(() => {
|
|
118
|
+
return cShaderSettings;
|
|
119
|
+
});
|
|
120
|
+
onMounted(() => {
|
|
121
|
+
window.JsView?.enableFpsDisplay(true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
onUnmounted(() => {
|
|
125
|
+
window.JsView?.enableFpsDisplay(false);
|
|
126
|
+
});
|
|
127
|
+
//向父组件暴露方法
|
|
128
|
+
defineExpose({
|
|
129
|
+
getRandomDecimal,
|
|
130
|
+
reloading1,
|
|
131
|
+
SetCenter,
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#define RANGE 6.
|
|
2
|
+
#define SPEED .5
|
|
3
|
+
|
|
4
|
+
mat2 rotate(float a) {
|
|
5
|
+
float s = sin(a);
|
|
6
|
+
float c = cos(a);
|
|
7
|
+
return mat2(c, -s, s, c);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
void mainImage(out vec4 fragColor, vec2 coord) {
|
|
11
|
+
/** mediump精度10bit, 直接使用0-1的uv, 小值的normalize()会有精度问题, 导致异常大的结果; 但乘1920x1080又会有大值的问题, 所以选取16x9 */
|
|
12
|
+
vec2 aspect = (iResolution.xy / iResolution.y) * 9.;
|
|
13
|
+
vec2 center = vec2(${myCustomCenterX}, ${myCustomCenterY}) * aspect;
|
|
14
|
+
|
|
15
|
+
vec2 uv = coord / iResolution.xy * aspect;
|
|
16
|
+
uv -= center;
|
|
17
|
+
|
|
18
|
+
float d = length(uv);
|
|
19
|
+
float progress = sin(iTime * SPEED);
|
|
20
|
+
|
|
21
|
+
//vortex
|
|
22
|
+
float cTime = ${STRENGTH} * progress;
|
|
23
|
+
d = smoothstep(0., RANGE, RANGE - d) * cTime;
|
|
24
|
+
uv *= rotate(d);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
float edge = aspect.y * abs(progress);
|
|
28
|
+
uv = uv + normalize(uv) * edge;
|
|
29
|
+
|
|
30
|
+
uv += center;
|
|
31
|
+
uv /= aspect;
|
|
32
|
+
if(uv.x > 1. || uv.y > 1. || uv.x < 0. || uv.y < 0.) {
|
|
33
|
+
fragColor = vec4(0.0, 0.5, 0.6, 1.);
|
|
34
|
+
} else {
|
|
35
|
+
fragColor = jsvTexture2D(iChannel0, uv);
|
|
36
|
+
}
|
|
37
|
+
}
|
package/Preload/App.vue
CHANGED
|
@@ -141,6 +141,7 @@ y=${Math.floor(y)}`
|
|
|
141
141
|
|
|
142
142
|
// 注册按下抬起的监听
|
|
143
143
|
rPressDetectDiv.value.jsvSetTapListener({
|
|
144
|
+
onTouchStart: () => {console.log(" touch start")},
|
|
144
145
|
onTouchEnd: () => {
|
|
145
146
|
rPercentDisp.value =
|
|
146
147
|
Math.floor(rJsvScrollBox.value.currentPercent() * 100) / 100;
|
|
@@ -161,6 +161,7 @@ y=${Math.floor(y)}`
|
|
|
161
161
|
|
|
162
162
|
// 注册按下抬起的监听
|
|
163
163
|
rPressDetectDiv.value.jsvSetTapListener({
|
|
164
|
+
onTouchStart: () => {console.log(" touch start")},
|
|
164
165
|
onTouchEnd: () => {
|
|
165
166
|
rPercentDisp.value =
|
|
166
167
|
Math.floor(rJsvScrollBox.value.currentPercent() * 100) / 100;
|
|
@@ -126,6 +126,7 @@ y=${Math.floor(y)}`
|
|
|
126
126
|
|
|
127
127
|
// 注册按下抬起的监听
|
|
128
128
|
rPressDetectDiv.value.jsvSetTapListener({
|
|
129
|
+
onTouchStart: () => {console.log(" touch start")},
|
|
129
130
|
onTouchEnd: () => {
|
|
130
131
|
rPercentDisp.value =
|
|
131
132
|
Math.floor(rJsvScrollBox.value.currentPercent() * 100) / 100;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="{ width: 1280, height: 720, backgroundColor: '#0000FF' }">
|
|
3
|
+
<div v-for="(item, index) in CenterSet">
|
|
4
|
+
<SprayMove
|
|
5
|
+
v-if="showArray[index]"
|
|
6
|
+
:center="item.center"
|
|
7
|
+
:color="item.color"
|
|
8
|
+
:num="item.num"
|
|
9
|
+
></SprayMove>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
import SprayMove from "./SprayMove.vue";
|
|
16
|
+
import { onMounted, reactive } from "vue";
|
|
17
|
+
|
|
18
|
+
//随机数(6-12)
|
|
19
|
+
const getRandomNumber = (min = 6, max = 12) => {
|
|
20
|
+
const result = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
//组件配置
|
|
24
|
+
const CenterSet = [
|
|
25
|
+
{
|
|
26
|
+
center: { x: 100, y: 100 },
|
|
27
|
+
num: getRandomNumber(),
|
|
28
|
+
color: "#FFFF00",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
center: { x: 200, y: 500 },
|
|
32
|
+
num: getRandomNumber(),
|
|
33
|
+
color: "#00FF00",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
center: { x: 820, y: 200 },
|
|
37
|
+
num: getRandomNumber(),
|
|
38
|
+
color: "#FFA500",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
center: { x: 900, y: 500 },
|
|
42
|
+
num: getRandomNumber(),
|
|
43
|
+
color: "#FF0000",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
center: { x: 500, y: 320 },
|
|
47
|
+
num: getRandomNumber(),
|
|
48
|
+
color: "#FFFFFF",
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
//定时器控制实现烟花绚烂效果
|
|
52
|
+
const showArray = reactive([]);
|
|
53
|
+
CenterSet.forEach((item, index) => {
|
|
54
|
+
showArray.push(false);
|
|
55
|
+
});
|
|
56
|
+
showArray[0] = true;
|
|
57
|
+
console.log(showArray);
|
|
58
|
+
|
|
59
|
+
const timer = { id: -1 };
|
|
60
|
+
|
|
61
|
+
onMounted(() => {
|
|
62
|
+
timer.id = setInterval(() => {
|
|
63
|
+
const index = showArray.indexOf(false); // 找到第一个 false 的索引
|
|
64
|
+
if (index !== -1) {
|
|
65
|
+
showArray[index] = true; // 将第一个 false 改为 true
|
|
66
|
+
console.log(showArray);
|
|
67
|
+
} else {
|
|
68
|
+
// 如果数组内所有的 false 都变为 true,清除定时器
|
|
69
|
+
clearInterval(timer.id);
|
|
70
|
+
}
|
|
71
|
+
}, 1000); // 每 1.5 秒执行一次
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<style lang="scss" scoped></style>
|