使用 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 = {
extends: ['@webank/eslint-config-webank/vue.js'],
overrides: [
@ -24,7 +32,9 @@ module.exports = {
'prettier/prettier': 'off',
"vue/space-unary-ops": "off",
"vue/comma-dangle": "off",
"no-debugger": "off"
"no-debugger": "off",
// "semi": "off",
// "init-declarations": "off",
// "space-unary-ops": "off",
// 'import/no-unresolved': [
// 2,

View File

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

View File

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

View File

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

View File

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

View File

@ -11,21 +11,17 @@
</template>
<script setup lang="ts">
import { reactive, onMounted } from 'vue';
import { TresCanvas, useRenderLoop, useTexture } from '@tresjs/core';
import { OrbitControls } from '@tresjs/cientos';
import rayMarchingMaterial from '../components/rayMarchingMaterial.vue';
import { Pane } from 'tweakpane';
import axios from 'axios';
import { TresCanvas } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'
import rayMarchingMaterial from '../components/rayMarchingMaterial.vue'
const state = {
clearColor: '#000000',
shadows: true,
alpha: false,
useLegacyLights: true,
};
const controlsState = { autoRotate: false, enableDamping: true };
const controlsState = { autoRotate: false, enableDamping: true }
const { onLoop } = useRenderLoop();
onLoop(({ delta }) => {});
onMounted(() => {});
</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>
<TresCanvas v-bind="state" window-size>
<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="[5, 10, 0]" :intensity="0.2" />
<TresDirectionalLight :position="[-5, 10, 0]" :intensity="0.2" />
<!-- <TresGridHelper /> -->
<Suspense>
<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>
<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" />
<TresDirectionalLight :position="[100, 100, 0]" :intensity="0.5" color="#ffffff" />

View File

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

View File

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