@shijiu/jsview-vue-samples 2.2.128 → 2.2.201
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/CoupletsTest/widget/Banger/Maroon.vue +4 -6
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +52 -42
- package/CustomShader/App.vue +157 -0
- package/CustomShader/gaussianBlur.glsl +27 -0
- package/CustomShader/pageFlip.glsl +40 -0
- package/CustomShader/sdf.glsl +22 -0
- package/CustomShader/test.glsl +8 -0
- package/CustomShader/vortex.glsl +38 -0
- package/DemoHomepage/App.vue +36 -27
- package/DemoHomepage/router.js +10 -0
- package/DriftScopeTest/App.vue +128 -0
- package/FreeMove/App.vue +62 -64
- package/FreeMoveLink/App.vue +2 -2
- package/ImpactStop/App.vue +45 -45
- package/LongImage/App.vue +1 -2
- package/LongText/App.vue +2 -2
- package/LongText/LongTextScroll.vue +22 -22
- package/LongText/Scroll.vue +28 -9
- package/MetroWidgetDemos/RefreshDemo/App.vue +172 -56
- package/MetroWidgetDemos/RefreshDemo/ControlItem.vue +45 -0
- package/MetroWidgetDemos/RefreshDemo/Item.vue +20 -4
- package/SceneTransition/JsvSceneTransition.vue +30 -42
- package/ScrollBoxTest/App.vue +35 -86
- package/ScrollBoxTest/ClipBar.vue +153 -0
- package/ScrollBoxTest/DrawCircle.ts +25 -0
- package/ScrollBoxTest/NinePatchBar.vue +187 -0
- package/ScrollBoxTest/NoBackgroundBar.vue +125 -0
- package/ScrollBoxTest/SizeDivBar.vue +138 -0
- package/TombSweepingDayTest/Raining/Rain.vue +8 -8
- package/package.json +1 -1
- package/MetroWidgetDemos/RefreshDemo/data.js +0 -16
|
@@ -81,14 +81,12 @@ let deg = shallowRef(props.deg);
|
|
|
81
81
|
//动画处理
|
|
82
82
|
const fire = () => {
|
|
83
83
|
props.myRef.value.start();
|
|
84
|
-
actorControl.run([
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.setSpdAndAccel(undefined, 0, undefined, 0.15, null, null),
|
|
88
|
-
actorControl
|
|
84
|
+
actorControl.run((cmds) => [
|
|
85
|
+
cmds.action().setSpdAndAccel(undefined, 0, undefined, 0.15, null, null),
|
|
86
|
+
cmds
|
|
89
87
|
.condition()
|
|
90
88
|
.reachPosition(undefined, 280)
|
|
91
|
-
.then([
|
|
89
|
+
.then([cmds.action().stopMoving()]),
|
|
92
90
|
]);
|
|
93
91
|
};
|
|
94
92
|
|
|
@@ -160,16 +160,26 @@ const props = defineProps({
|
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
//火花图片素材
|
|
163
|
-
const group1_1 =
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
163
|
+
const group1_1 =
|
|
164
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/1/group1_1.png";
|
|
165
|
+
const group1_2 =
|
|
166
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/1/group1_2.png";
|
|
167
|
+
const group2_1 =
|
|
168
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/2/group2_1.png";
|
|
169
|
+
const group2_2 =
|
|
170
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/2/group2_2.png";
|
|
171
|
+
const group3_1 =
|
|
172
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/3/group3_1.png";
|
|
173
|
+
const group3_2 =
|
|
174
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/3/group3_2.png";
|
|
175
|
+
const group4_1 =
|
|
176
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/4/group4_1.png";
|
|
177
|
+
const group4_2 =
|
|
178
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/4/group4_2.png";
|
|
179
|
+
const group5_1 =
|
|
180
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/5/group5_1.png";
|
|
181
|
+
const group5_2 =
|
|
182
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Fireworks/images/5/group5_2.png";
|
|
173
183
|
//弹药图片素材(请按需修改)
|
|
174
184
|
const ammo =
|
|
175
185
|
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/images/star2.png";
|
|
@@ -180,7 +190,7 @@ const fireworksJson =
|
|
|
180
190
|
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SpringFestivalTest_2024/Sprite/fireworks.json";
|
|
181
191
|
|
|
182
192
|
//运动距离
|
|
183
|
-
let moveDistance = 260
|
|
193
|
+
let moveDistance = 260;
|
|
184
194
|
let sprite_info = shallowRef(null);
|
|
185
195
|
let view_size = shallowRef(null);
|
|
186
196
|
let isSpray = shallowRef(false);
|
|
@@ -195,7 +205,7 @@ let actorRef = shallowRef(null);
|
|
|
195
205
|
let myShow = shallowRef(false);
|
|
196
206
|
let actorControl;
|
|
197
207
|
//随机顺序绽放函数
|
|
198
|
-
const spray=()=> {
|
|
208
|
+
const spray = () => {
|
|
199
209
|
timer.id2 = setTimeout(() => {
|
|
200
210
|
let randomIndex = Math.floor(Math.random() * sprayArray.length);
|
|
201
211
|
sprayArray[randomIndex].value = true;
|
|
@@ -210,7 +220,7 @@ const spray=()=> {
|
|
|
210
220
|
}
|
|
211
221
|
}, 100);
|
|
212
222
|
}, 500);
|
|
213
|
-
}
|
|
223
|
+
};
|
|
214
224
|
|
|
215
225
|
//预加载
|
|
216
226
|
const preload_info = [
|
|
@@ -295,50 +305,50 @@ let ImgData4;
|
|
|
295
305
|
let ImgData5;
|
|
296
306
|
const allGroup = [group1, group2, group3, group4, group5];
|
|
297
307
|
//随机烟花颜色设定
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
remainingGroups.splice(randomIndex, 1);
|
|
308
|
+
const remainingGroups = [...allGroup];
|
|
309
|
+
for (let i = 1; i <= 5; i++) {
|
|
310
|
+
const randomIndex = Math.floor(Math.random() * remainingGroups.length);
|
|
311
|
+
const selectedGroup = remainingGroups[randomIndex];
|
|
312
|
+
switch (i) {
|
|
313
|
+
case 1:
|
|
314
|
+
ImgData1 = selectedGroup;
|
|
315
|
+
break;
|
|
316
|
+
case 2:
|
|
317
|
+
ImgData2 = selectedGroup;
|
|
318
|
+
break;
|
|
319
|
+
case 3:
|
|
320
|
+
ImgData3 = selectedGroup;
|
|
321
|
+
break;
|
|
322
|
+
case 4:
|
|
323
|
+
ImgData4 = selectedGroup;
|
|
324
|
+
break;
|
|
325
|
+
case 5:
|
|
326
|
+
ImgData5 = selectedGroup;
|
|
327
|
+
break;
|
|
321
328
|
}
|
|
322
329
|
|
|
330
|
+
remainingGroups.splice(randomIndex, 1);
|
|
331
|
+
}
|
|
332
|
+
|
|
323
333
|
watch(readyNum, (n, o) => {
|
|
324
334
|
if (o != 2 && n == 2) {
|
|
325
335
|
myShow.value = true;
|
|
326
336
|
timer.id2 = setTimeout(() => {
|
|
327
337
|
myRef.value.start();
|
|
328
338
|
|
|
329
|
-
actorControl.run([
|
|
330
|
-
|
|
339
|
+
actorControl.run((cmds) => [
|
|
340
|
+
cmds
|
|
331
341
|
.condition()
|
|
332
342
|
.onNextTick(2)
|
|
333
343
|
.then([
|
|
334
|
-
|
|
335
|
-
|
|
344
|
+
cmds.action().setSpeed(undefined, -9),
|
|
345
|
+
cmds.action(3).setAccel(undefined, 0.13),
|
|
336
346
|
]),
|
|
337
|
-
|
|
347
|
+
cmds
|
|
338
348
|
.condition()
|
|
339
349
|
.reachPosition(undefined, -moveDistance)
|
|
340
350
|
.then([
|
|
341
|
-
|
|
351
|
+
cmds.action().stopMoving(),
|
|
342
352
|
() => {
|
|
343
353
|
isSpray.value = true;
|
|
344
354
|
isShow.value = false;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { onMounted, onUnmounted, ref, computed } from "vue";
|
|
3
|
+
import { JsvFragShaderView } from "jsview";
|
|
4
|
+
import vortexShader from "./vortex.glsl?raw";
|
|
5
|
+
import pageFlipShader from "./pageFlip.glsl?raw";
|
|
6
|
+
import sdfShader from "./sdf.glsl?raw";
|
|
7
|
+
import gaussianBlurShader from "./gaussianBlur.glsl?raw";
|
|
8
|
+
// import testShader from "./test.glsl?raw";
|
|
9
|
+
|
|
10
|
+
const ImageChinChilla =
|
|
11
|
+
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/BackgroundLongmao.jpg";
|
|
12
|
+
const ImageLandscape = "https://oss.image.qcast.cn/ai-draw/landscape.jpeg";
|
|
13
|
+
const ImagePanda = "https://oss.image.qcast.cn/ai-draw/panda.jpeg";
|
|
14
|
+
const ImageOwl = "https://oss.image.qcast.cn/ai-draw/owl.jpeg";
|
|
15
|
+
|
|
16
|
+
const cShaderSettings = [
|
|
17
|
+
{
|
|
18
|
+
name: "vortex",
|
|
19
|
+
shader: vortexShader,
|
|
20
|
+
uniforms: [],
|
|
21
|
+
textures: [
|
|
22
|
+
{
|
|
23
|
+
name: "iChannel0",
|
|
24
|
+
resource: ImageOwl,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "pageFlip",
|
|
30
|
+
shader: pageFlipShader,
|
|
31
|
+
uniforms: [],
|
|
32
|
+
textures: [
|
|
33
|
+
{
|
|
34
|
+
name: "iChannel0",
|
|
35
|
+
resource: ImageOwl,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "sdf",
|
|
41
|
+
shader: sdfShader,
|
|
42
|
+
uniforms: [],
|
|
43
|
+
textures: [
|
|
44
|
+
{
|
|
45
|
+
name: "iChannel0",
|
|
46
|
+
resource: ImageOwl,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "gaussianBlur",
|
|
52
|
+
shader: gaussianBlurShader,
|
|
53
|
+
uniforms: [],
|
|
54
|
+
textures: [
|
|
55
|
+
{
|
|
56
|
+
name: "iChannel0",
|
|
57
|
+
resource: ImageOwl,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const rKeyCount = ref(0);
|
|
64
|
+
const rShaderInfo = computed(() => {
|
|
65
|
+
return cShaderSettings[rKeyCount.value];
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const rAutoplay = computed(() => {
|
|
69
|
+
return rKeyCount.value != 3;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const rWidgetRef = ref();
|
|
73
|
+
const onKeyDown = (ev) => {
|
|
74
|
+
switch (ev.keyCode) {
|
|
75
|
+
case 37: {
|
|
76
|
+
rKeyCount.value =
|
|
77
|
+
rKeyCount.value > 0 ? rKeyCount.value - 1 : rKeyCount.value;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
case 39: {
|
|
81
|
+
rKeyCount.value =
|
|
82
|
+
rKeyCount.value < cShaderSettings.length - 1
|
|
83
|
+
? rKeyCount.value + 1
|
|
84
|
+
: rKeyCount.value;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
case 13: {
|
|
88
|
+
if (rKeyCount.value != 3) {
|
|
89
|
+
rWidgetRef.value?.startAnim();
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
window.JsView?.enableFpsDisplay(true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
onUnmounted(() => {
|
|
103
|
+
window.JsView?.enableFpsDisplay(false);
|
|
104
|
+
});
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<template>
|
|
108
|
+
<jsv-focus-block
|
|
109
|
+
autoFocus
|
|
110
|
+
:onAction="{
|
|
111
|
+
onKeyDown,
|
|
112
|
+
}"
|
|
113
|
+
:style="{
|
|
114
|
+
width: 1920,
|
|
115
|
+
height: 1080,
|
|
116
|
+
backgroundImage: `url(${ImageChinChilla})`,
|
|
117
|
+
}"
|
|
118
|
+
></jsv-focus-block>
|
|
119
|
+
|
|
120
|
+
<jsv-frag-shader-view
|
|
121
|
+
:key="rKeyCount"
|
|
122
|
+
ref="rWidgetRef"
|
|
123
|
+
:style="{ left: 0, top: 0, width: 1920, height: 1080 }"
|
|
124
|
+
:duration="100000"
|
|
125
|
+
:shaderStr="rShaderInfo.shader"
|
|
126
|
+
:autoplay="rAutoplay"
|
|
127
|
+
:textures="rShaderInfo.textures"
|
|
128
|
+
></jsv-frag-shader-view>
|
|
129
|
+
<div
|
|
130
|
+
:key="rKeyCount"
|
|
131
|
+
:style="{
|
|
132
|
+
top: 20,
|
|
133
|
+
left: 500,
|
|
134
|
+
width: 500,
|
|
135
|
+
height: 50,
|
|
136
|
+
fontSize: 30,
|
|
137
|
+
textAlign: 'center',
|
|
138
|
+
backgroundColor: '#00000055',
|
|
139
|
+
color: '#ffffff',
|
|
140
|
+
}"
|
|
141
|
+
>
|
|
142
|
+
{{ rShaderInfo.name }}
|
|
143
|
+
</div>
|
|
144
|
+
<div
|
|
145
|
+
:style="{
|
|
146
|
+
top: 20,
|
|
147
|
+
left: 1400,
|
|
148
|
+
width: 500,
|
|
149
|
+
height: 50,
|
|
150
|
+
fontSize: 30,
|
|
151
|
+
backgroundColor: '#00000055',
|
|
152
|
+
color: '#ffffff',
|
|
153
|
+
}"
|
|
154
|
+
>
|
|
155
|
+
左右键切换效果, OK键重新播放
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const int samples = 35, LOD = 2, // gaussian done on MIPmap at scale LOD
|
|
2
|
+
sLOD = 4; // tile size = 2^LOD
|
|
3
|
+
const float sigma = float(samples) * .25;
|
|
4
|
+
|
|
5
|
+
float gaussian(vec2 i) {
|
|
6
|
+
return exp(-.5 * dot(i /= sigma, i)) / (6.28 * sigma * sigma);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
int myMod(int a, int b) {
|
|
10
|
+
return a - b * int(floor(float(a) / float(b)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
vec4 blur(sampler2D sp, vec2 U, vec2 scale) {
|
|
14
|
+
vec4 O = vec4(0);
|
|
15
|
+
int s = samples / sLOD;
|
|
16
|
+
|
|
17
|
+
for(int i = 0; i < s * s; i++) {
|
|
18
|
+
vec2 d = vec2(myMod(i, s), i / s) * float(sLOD) - float(samples) / 2.;
|
|
19
|
+
O += gaussian(d) * jsvTexture2D(sp, U + scale * d);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return O / O.a;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void mainImage(out vec4 O, vec2 U) {
|
|
26
|
+
O = blur(iChannel0, U / iResolution.xy, 1. / iResolution.xy);
|
|
27
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#define pi 3.14159265359
|
|
2
|
+
#define radius .1
|
|
3
|
+
|
|
4
|
+
float fastAsin(float x) {
|
|
5
|
+
float x2 = x * x;
|
|
6
|
+
float x3 = x2 * x;
|
|
7
|
+
float x5 = x3 * x2;
|
|
8
|
+
float x7 = x5 * x2;
|
|
9
|
+
return x + (1.0 / 6.0) * x3 + (3.0 / 40.0) * x5 + (5.0 / 112.0) * x7;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
13
|
+
vec2 aspect = iResolution.xy / iResolution.y;
|
|
14
|
+
vec2 uv = fragCoord * aspect / iResolution.xy;
|
|
15
|
+
vec2 anchor = aspect;
|
|
16
|
+
vec2 mouse = anchor - abs(sin(iTime / 2.)) * anchor;
|
|
17
|
+
vec2 mouseDir = normalize(anchor - mouse);
|
|
18
|
+
vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
|
|
19
|
+
float mouseDist = length(mouse - origin);
|
|
20
|
+
|
|
21
|
+
float proj = dot(uv - origin, mouseDir);
|
|
22
|
+
float dist = proj - mouseDist;
|
|
23
|
+
vec2 linePoint = uv - dist * mouseDir;
|
|
24
|
+
if(dist > radius) {
|
|
25
|
+
fragColor = vec4(0.0, 0.5, 0.6, 1.0);
|
|
26
|
+
fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
|
|
27
|
+
} else if(dist >= 0.) {
|
|
28
|
+
// map to cylinder point
|
|
29
|
+
float theta = fastAsin(dist / radius);
|
|
30
|
+
vec2 p2 = linePoint + mouseDir * (pi - theta) * radius;
|
|
31
|
+
vec2 p1 = linePoint + mouseDir * theta * radius;
|
|
32
|
+
uv = (p2.x <= aspect.x && p2.y <= aspect.y && p2.x > 0. && p2.y > 0.) ? p2 : p1;
|
|
33
|
+
fragColor = jsvTexture2D(iChannel0, uv / aspect);
|
|
34
|
+
fragColor.rgb *= pow(clamp((radius - dist) / radius, 0., 1.), .2);
|
|
35
|
+
} else {
|
|
36
|
+
vec2 p = linePoint + mouseDir * (abs(dist) + pi * radius);
|
|
37
|
+
uv = (p.x <= aspect.x && p.y <= aspect.y && p.x > 0. && p.y > 0.) ? p : uv;
|
|
38
|
+
fragColor = jsvTexture2D(iChannel0, uv / aspect);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
2
|
+
// Normalized pixel coordinates (from 0 to 1)
|
|
3
|
+
vec2 aspect = iResolution.xy / iResolution.y;
|
|
4
|
+
vec2 originUv = fragCoord / iResolution.xy;
|
|
5
|
+
vec2 uv = 2. * (originUv - 0.5) * aspect;
|
|
6
|
+
|
|
7
|
+
vec2 sum = vec2(0., 0.); // r, g
|
|
8
|
+
|
|
9
|
+
float modTime = iTime - (60. * floor(iTime / 60.));
|
|
10
|
+
float time = 50. * abs(fract(modTime / 30.) - .5);
|
|
11
|
+
|
|
12
|
+
for(int i = 10; i < 13; i++) {
|
|
13
|
+
vec2 pos = uv * 40. + vec2(sin(time / 3. * float(i) / 2.), cos(time / 3. * float(i) / 3.)) * 10. * (1.0 + float(i) / 10.);
|
|
14
|
+
float dist = 1. / length(pos) * 6.;
|
|
15
|
+
sum += dist;
|
|
16
|
+
}
|
|
17
|
+
sum *= 0.5;
|
|
18
|
+
// sum.x = clamp(sum.x, 0., 1.);
|
|
19
|
+
// sum.x = step(.5, sum.x);
|
|
20
|
+
// fragColor = vec4(.1, sum.x, sum.x, sum.x);
|
|
21
|
+
fragColor = sum.x > 0.5 ? jsvTexture2D(iChannel0, originUv) : vec4(0.);
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#define RANGE 6.
|
|
2
|
+
#define SPEED .5
|
|
3
|
+
#define STRENGTH 6.
|
|
4
|
+
|
|
5
|
+
mat2 rotate(float a) {
|
|
6
|
+
float s = sin(a);
|
|
7
|
+
float c = cos(a);
|
|
8
|
+
return mat2(c, -s, s, c);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void mainImage(out vec4 fragColor, vec2 coord) {
|
|
12
|
+
/** mediump精度10bit, 直接使用0-1的uv, 小值的normalize()会有精度问题, 导致异常大的结果; 但乘1920x1080又会有大值的问题, 所以选取16x9 */
|
|
13
|
+
vec2 aspect = (iResolution.xy / iResolution.y) * 9.;
|
|
14
|
+
vec2 center = 0.5 * aspect;
|
|
15
|
+
|
|
16
|
+
vec2 uv = coord / iResolution.xy * aspect;
|
|
17
|
+
uv -= center;
|
|
18
|
+
|
|
19
|
+
float d = length(uv);
|
|
20
|
+
float progress = sin(iTime * SPEED);
|
|
21
|
+
|
|
22
|
+
//vortex
|
|
23
|
+
float cTime = STRENGTH * progress;
|
|
24
|
+
d = smoothstep(0., RANGE, RANGE - d) * cTime;
|
|
25
|
+
uv *= rotate(d);
|
|
26
|
+
|
|
27
|
+
//shrink
|
|
28
|
+
float edge = aspect.y * abs(progress);
|
|
29
|
+
uv = uv + normalize(uv) * edge;
|
|
30
|
+
|
|
31
|
+
uv += center;
|
|
32
|
+
uv /= aspect;
|
|
33
|
+
if(uv.x > 1. || uv.y > 1. || uv.x < 0. || uv.y < 0.) {
|
|
34
|
+
fragColor = vec4(0.0, 0.5, 0.6, 1.);
|
|
35
|
+
} else {
|
|
36
|
+
fragColor = jsvTexture2D(iChannel0, uv);
|
|
37
|
+
}
|
|
38
|
+
}
|
package/DemoHomepage/App.vue
CHANGED
|
@@ -7,15 +7,21 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script setup>
|
|
9
9
|
import { shallowRef, onMounted, onUnmounted } from "vue";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
JsvPreload,
|
|
12
|
+
buildPreloadInfo,
|
|
13
|
+
jJsvRuntimeBridge,
|
|
14
|
+
JsvFocusBlock,
|
|
15
|
+
useFocusHub,
|
|
16
|
+
} from "jsview";
|
|
11
17
|
import { useRouter } from "vue-router";
|
|
12
|
-
import { setDataUrl, getDataUrl } from "../CommonUtils/ResourceData.js"
|
|
13
|
-
import { getSearchQuery } from "../CommonUtils/getSearchQuery.js"
|
|
18
|
+
import { setDataUrl, getDataUrl } from "../CommonUtils/ResourceData.js";
|
|
19
|
+
import { getSearchQuery } from "../CommonUtils/getSearchQuery.js";
|
|
14
20
|
|
|
15
|
-
let DemoResourceBase=shallowRef("")
|
|
21
|
+
let DemoResourceBase = shallowRef("");
|
|
16
22
|
let backgroundImageUrl = shallowRef(null);
|
|
17
23
|
|
|
18
|
-
let preloadInfo = shallowRef([]);
|
|
24
|
+
// let preloadInfo = shallowRef([]);
|
|
19
25
|
|
|
20
26
|
window.DebugFocusHub = useFocusHub();
|
|
21
27
|
|
|
@@ -41,52 +47,56 @@ let testKeepAliveModeText = shallowRef(1);
|
|
|
41
47
|
let testKeepAliveTimer = -1;
|
|
42
48
|
|
|
43
49
|
//解析url
|
|
44
|
-
let query = getSearchQuery(window.location.href, undefined, 0)
|
|
50
|
+
let query = getSearchQuery(window.location.href, undefined, 0);
|
|
45
51
|
if (query.DemoResourceBase) {
|
|
46
|
-
setDataUrl(query.DemoResourceBase)
|
|
52
|
+
setDataUrl(query.DemoResourceBase);
|
|
47
53
|
//无网络环境下使用
|
|
48
|
-
DemoResourceBase.value = getDataUrl()
|
|
54
|
+
DemoResourceBase.value = getDataUrl();
|
|
49
55
|
}
|
|
50
56
|
onMounted(() => {
|
|
51
57
|
console.log("simulate async get background url");
|
|
52
58
|
setTimeout(() => {
|
|
53
59
|
console.log("simulate background url got");
|
|
54
|
-
backgroundImageUrl.value = DemoResourceBase.value
|
|
55
|
-
|
|
56
|
-
"https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/BackgroundLongmao.jpg";
|
|
57
|
-
preloadInfo.value = [buildPreloadInfo(backgroundImageUrl.value)];
|
|
60
|
+
backgroundImageUrl.value = DemoResourceBase.value
|
|
61
|
+
? `${DemoResourceBase.value}/BackgroundLongmao.jpg`
|
|
62
|
+
: "https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/BackgroundLongmao.jpg";
|
|
63
|
+
// preloadInfo.value = [buildPreloadInfo(backgroundImageUrl.value)];
|
|
58
64
|
}, 0);
|
|
59
65
|
|
|
60
66
|
console.log("start homepage interval");
|
|
61
|
-
testKeepAliveTimer = setInterval(()=>{
|
|
67
|
+
testKeepAliveTimer = setInterval(() => {
|
|
62
68
|
testKeepAliveModeText.value++;
|
|
63
|
-
}, 1000)
|
|
69
|
+
}, 1000);
|
|
64
70
|
});
|
|
65
71
|
|
|
66
|
-
onUnmounted(()=>{
|
|
72
|
+
onUnmounted(() => {
|
|
67
73
|
if (testKeepAliveTimer > 0) {
|
|
68
74
|
console.log("remove homepage interval");
|
|
69
75
|
clearInterval(testKeepAliveTimer);
|
|
70
76
|
testKeepAliveTimer = -1;
|
|
71
77
|
}
|
|
72
|
-
})
|
|
73
|
-
|
|
78
|
+
});
|
|
74
79
|
</script>
|
|
75
80
|
|
|
76
81
|
<template>
|
|
77
82
|
<div>
|
|
78
|
-
<jsv-preload :key="backgroundImageUrl" :preloadList="preloadInfo" :onPreloadDone="_onPreloadDone" />
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
<!-- <jsv-preload :key="backgroundImageUrl" :preloadList="preloadInfo" :onPreloadDone="_onPreloadDone" /> -->
|
|
84
|
+
<img
|
|
85
|
+
:src="backgroundImageUrl"
|
|
86
|
+
:style="{
|
|
87
|
+
width: 1280,
|
|
88
|
+
height: 720,
|
|
89
|
+
}"
|
|
90
|
+
@load="_onPreloadDone"
|
|
91
|
+
/>
|
|
84
92
|
<div class="TestKeepAliveDiv">
|
|
85
93
|
{{ "刷新:" + testKeepAliveModeText }}
|
|
86
94
|
</div>
|
|
87
|
-
<jsv-focus-block
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
<jsv-focus-block
|
|
96
|
+
:onAction="{
|
|
97
|
+
onKeyDown: _OnKeyDown,
|
|
98
|
+
}"
|
|
99
|
+
>
|
|
90
100
|
<router-view v-slot="{ Component, route }">
|
|
91
101
|
<keep-alive>
|
|
92
102
|
<component v-if="route.meta.keepAlive" :is="Component" />
|
|
@@ -107,5 +117,4 @@ onUnmounted(()=>{
|
|
|
107
117
|
line-height: 30;
|
|
108
118
|
color: #eb20c6;
|
|
109
119
|
}
|
|
110
|
-
|
|
111
120
|
</style>
|
package/DemoHomepage/router.js
CHANGED
|
@@ -366,6 +366,16 @@ let routeList = [
|
|
|
366
366
|
path: '/touch/ScrollBoxTest',
|
|
367
367
|
component: () => import('jsview-vue-samples/ScrollBoxTest/App.vue'),
|
|
368
368
|
},
|
|
369
|
+
// {
|
|
370
|
+
// name: '透视镜效果样例',
|
|
371
|
+
// path: '/Operations/DriftScopeTest',
|
|
372
|
+
// component: () => import('jsview-vue-samples/DriftScopeTest/App.vue'),
|
|
373
|
+
// },
|
|
374
|
+
{
|
|
375
|
+
name: '自定义shader',
|
|
376
|
+
path: '/Operations/CustomShader',
|
|
377
|
+
component: () => import('jsview-vue-samples/CustomShader/App.vue'),
|
|
378
|
+
},
|
|
369
379
|
];
|
|
370
380
|
|
|
371
381
|
//添加MetroWidget demo
|