使用 GitHub Copilot 优化部分代码

This commit is contained in:
hawk86104 2024-03-05 19:00:30 +08:00
parent 4ae200299f
commit 0d42031a7e
10 changed files with 59 additions and 41 deletions

View File

@ -1,3 +1,11 @@
/*
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2023-10-16 10:53:09
* @LastEditors: 地虎降天龙
* @LastEditTime: 2024-03-05 18:51:52
*/
module.exports = { module.exports = {
extends: ['@webank/eslint-config-webank/vue.js'], extends: ['@webank/eslint-config-webank/vue.js'],
overrides: [ overrides: [
@ -24,7 +32,9 @@ module.exports = {
'prettier/prettier': 'off', 'prettier/prettier': 'off',
"vue/space-unary-ops": "off", "vue/space-unary-ops": "off",
"vue/comma-dangle": "off", "vue/comma-dangle": "off",
"no-debugger": "off" "no-debugger": "off",
// "semi": "off",
// "init-declarations": "off",
// "space-unary-ops": "off", // "space-unary-ops": "off",
// 'import/no-unresolved': [ // 'import/no-unresolved': [
// 2, // 2,

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
...require("@webank/eslint-config-webank/.prettierrc.js"), ...require("@webank/eslint-config-webank/.prettierrc.js")
}; };

View File

@ -16,12 +16,12 @@
"access": "public" "access": "public"
}, },
"devDependencies": { "devDependencies": {
"@tweakpane/core": "^2.0.3",
"@types/mapbox__tilebelt": "^1.0.4", "@types/mapbox__tilebelt": "^1.0.4",
"@types/offscreencanvas": "^2019.7.3", "@types/offscreencanvas": "^2019.7.3",
"@types/three": "0.161.1", "@types/three": "0.161.1",
"@webank/eslint-config-webank": "1.3.1", "@webank/eslint-config-webank": "1.3.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3"
"tweakpane": "4.0.3"
}, },
"dependencies": { "dependencies": {
"3d-tiles-renderer": "^0.3.25", "3d-tiles-renderer": "^0.3.25",
@ -56,6 +56,7 @@
"three-mesh-bvh": "0.7.1", "three-mesh-bvh": "0.7.1",
"three-subdivide": "^1.1.5", "three-subdivide": "^1.1.5",
"tilebelt-wgs84": "^1.0.4", "tilebelt-wgs84": "^1.0.4",
"tweakpane": "4.0.3",
"unocss": "0.58.4", "unocss": "0.58.4",
"vanta": "^0.5.24", "vanta": "^0.5.24",
"vue": "3.4.15" "vue": "3.4.15"

View File

@ -4,7 +4,7 @@
* @Autor: 地虎降天龙 * @Autor: 地虎降天龙
* @Date: 2024-01-05 09:23:48 * @Date: 2024-01-05 09:23:48
* @LastEditors: 地虎降天龙 * @LastEditors: 地虎降天龙
* @LastEditTime: 2024-01-06 09:14:24 * @LastEditTime: 2024-03-05 18:51:05
--> -->
<script setup lang="ts"> <script setup lang="ts">
@ -16,7 +16,7 @@ import { Pane } from 'tweakpane'
const tcRef = ref() const tcRef = ref()
const meshList = [] const meshList = [] as number[]
for (let index = 1; index < 30; index += 2) { for (let index = 1; index < 30; index += 2) {
meshList.push(index) meshList.push(index)
} }
@ -34,7 +34,7 @@ const params = {
watchEffect(() => { watchEffect(() => {
if (tcRef.value) { if (tcRef.value) {
let renderer = tcRef.value.context.renderer.value const renderer = tcRef.value.context.renderer.value
renderer.localClippingEnabled = true renderer.localClippingEnabled = true
} }
}) })
@ -72,12 +72,12 @@ paneControl.addBinding(clipPlanes[2], 'constant', {
<OrbitControls /> <OrbitControls />
<TresGroup> <TresGroup>
<TresMesh v-for="i in meshList " :key="i"> <TresMesh v-for="i in meshList " :key="i">
<TresSphereGeometry :args="[i / 30, 48, 24]" /> <TresSphereGeometry :args="[i / 30, 48, 24]" />
<TresMeshLambertMaterial :color="[MathUtils.randInt(0.1, 1), MathUtils.randInt(0, 1), MathUtils.randInt(0, 1)]" <TresMeshLambertMaterial :color="[MathUtils.randInt(0.1, 1), MathUtils.randInt(0, 1), MathUtils.randInt(0, 1)]"
:side="DoubleSide" :clippingPlanes="clipPlanes" :clipIntersection="params.clipIntersection" /> :side="DoubleSide" :clippingPlanes="clipPlanes" :clipIntersection="params.clipIntersection"
/>
</TresMesh> </TresMesh>
</TresGroup> </TresGroup>
</TresCanvas>
</TresCanvas>
</template> </template>

View File

@ -3,8 +3,8 @@
* @version: * @version:
* @Author: Jsonco * @Author: Jsonco
* @Date: 2023-11-29 20:09:06 * @Date: 2023-11-29 20:09:06
* @LastEditors: sueRimn * @LastEditors: 地虎降天龙
* @LastEditTime: 2023-11-30 23:02:23 * @LastEditTime: 2024-03-05 18:57:47
--> -->
<template> <template>
<TresMesh ref="MeshRef" :rotation="[Math.PI / 2, 0, 0]"> <TresMesh ref="MeshRef" :rotation="[Math.PI / 2, 0, 0]">
@ -14,12 +14,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { TresCanvas, useRenderLoop, useTresContextProvider, useTresContext, useTexture } from '@tresjs/core'; import { useRenderLoop } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'; import { DoubleSide, Vector2 } from 'three'
import { AdditiveBlending, DoubleSide, Vector2, LinearFilter, RGBAFormat, WebGLRenderTarget, Color } from 'three'; import { watchEffect } from 'vue'
import { ref, watch, defineExpose, watchEffect } from 'vue';
import stringVertex from '../shaders/rayMarching.vert?raw'; import stringVertex from '../shaders/rayMarching.vert?raw'
import stringFrag from '../shaders/rayMarching.frag?raw'; import stringFrag from '../shaders/rayMarching.frag?raw'
const { onLoop, onAfterLoop } = useRenderLoop(); const { onLoop, onAfterLoop } = useRenderLoop();
const shader = { const shader = {
transparent: true, transparent: true,
@ -44,14 +44,14 @@ const windowHalfX = window.innerWidth / 2;
const windowHalfY = window.innerHeight / 2; const windowHalfY = window.innerHeight / 2;
let mouseX = 0; let mouseX = 0;
let mouseY = 0; let mouseY = 0;
function onMouseMove(e) { function onMouseMove(e: MouseEvent) {
mouseX = e.clientX - windowHalfX; mouseX = e.clientX - windowHalfX;
mouseY = e.clientY - windowHalfY; mouseY = e.clientY - windowHalfY;
} }
document.addEventListener('mousemove', onMouseMove, false); document.addEventListener('mousemove', onMouseMove, false);
watchEffect(() => {}); watchEffect(() => {});
onLoop(({ elapsed }) => { onLoop(() => {
shader.uniforms.u_time.value += 0.001; shader.uniforms.u_time.value += 0.01;
shader.uniforms.u_mouse.value = new Vector2(mouseX, mouseY); shader.uniforms.u_mouse.value = new Vector2(mouseX, mouseY);
}); });
onAfterLoop(() => {}); onAfterLoop(() => {});

View File

@ -11,21 +11,17 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, onMounted } from 'vue'; import { TresCanvas } from '@tresjs/core'
import { TresCanvas, useRenderLoop, useTexture } from '@tresjs/core'; import { OrbitControls } from '@tresjs/cientos'
import { OrbitControls } from '@tresjs/cientos';
import rayMarchingMaterial from '../components/rayMarchingMaterial.vue'; import rayMarchingMaterial from '../components/rayMarchingMaterial.vue'
import { Pane } from 'tweakpane';
import axios from 'axios';
const state = { const state = {
clearColor: '#000000', clearColor: '#000000',
shadows: true, shadows: true,
alpha: false, alpha: false,
useLegacyLights: true, useLegacyLights: true,
}; };
const controlsState = { autoRotate: false, enableDamping: true }; const controlsState = { autoRotate: false, enableDamping: true }
const { onLoop } = useRenderLoop();
onLoop(({ delta }) => {});
onMounted(() => {});
</script> </script>

View File

@ -1,3 +1,11 @@
<!--
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2024-03-05 12:42:04
* @LastEditors: 地虎降天龙
* @LastEditTime: 2024-03-05 18:53:47
-->
<template> <template>
<TresCanvas v-bind="state" window-size> <TresCanvas v-bind="state" window-size>
<TresPerspectiveCamera :position="[0, 12, 0]" :fov="75" :near="0.1" :far="1000" /> <TresPerspectiveCamera :position="[0, 12, 0]" :fov="75" :near="0.1" :far="1000" />
@ -7,10 +15,6 @@
<TresDirectionalLight :position="[0, 10, -5]" :intensity="0.2" /> <TresDirectionalLight :position="[0, 10, -5]" :intensity="0.2" />
<TresDirectionalLight :position="[5, 10, 0]" :intensity="0.2" /> <TresDirectionalLight :position="[5, 10, 0]" :intensity="0.2" />
<TresDirectionalLight :position="[-5, 10, 0]" :intensity="0.2" /> <TresDirectionalLight :position="[-5, 10, 0]" :intensity="0.2" />
<!-- <TresGridHelper /> --> <!-- <TresGridHelper /> -->
<Suspense> <Suspense>
<jiangSuMapMesh /> <jiangSuMapMesh />

View File

@ -1,7 +1,15 @@
<!--
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2024-02-29 18:51:13
* @LastEditors: 地虎降天龙
* @LastEditTime: 2024-03-05 18:54:09
-->
<template> <template>
<TresCanvas v-bind="state" window-size> <TresCanvas v-bind="state" window-size>
<TresPerspectiveCamera :position="mapCenter" :fov="60" :near="1" :far="1e8" :up="[0, 0, 1]" /> <TresPerspectiveCamera :position="new THREE.Vector3(mapCenter[0], mapCenter[1], mapCenter[2])" :fov="60" :near="1" :far="1e8" :up="[0, 0, 1]" />
<TresAmbientLight color="#ffffff" /> <TresAmbientLight color="#ffffff" />
<TresDirectionalLight :position="[100, 100, 0]" :intensity="0.5" color="#ffffff" /> <TresDirectionalLight :position="[100, 100, 0]" :intensity="0.5" color="#ffffff" />

View File

@ -4,12 +4,11 @@
* @Autor: 地虎降天龙 * @Autor: 地虎降天龙
* @Date: 2024-02-24 10:03:05 * @Date: 2024-02-24 10:03:05
* @LastEditors: 地虎降天龙 * @LastEditors: 地虎降天龙
* @LastEditTime: 2024-02-29 11:52:57 * @LastEditTime: 2024-03-05 18:03:12
--> -->
<template> <template>
<TresCanvas v-bind="state" window-size> <TresCanvas v-bind="state" window-size>
<TresPerspectiveCamera :position="mapCenter" :fov="60" :near="1" :far="1e8" :look-at="[mapCenter[0], mapCenter[1], 0]" <TresPerspectiveCamera :position="new THREE.Vector3(mapCenter[0], mapCenter[1], mapCenter[2])" :fov="60" :near="1" :far="1e8" :look-at="[mapCenter[0], mapCenter[1], 0]" :up="[0, 0, 1]" />
:up="[0, 0, 1]" />
<Suspense> <Suspense>
<tileMapMesh :bbox="[104.955976, 20.149765, 120.998419, 30.528687]" /> <tileMapMesh :bbox="[104.955976, 20.149765, 120.998419, 30.528687]" />
</Suspense> </Suspense>

View File

@ -15,7 +15,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true, "ignoreDeprecations": "5.0",
"noUnusedLocals": true, "noUnusedLocals": true,
"allowJs": true, "allowJs": true,
"experimentalDecorators": true, "experimentalDecorators": true,