|
|
@ -53,7 +53,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
&>canvas{ |
|
|
|
&>canvas,&>.modelPopover{ |
|
|
|
position:fixed; |
|
|
|
pointer-events: all; |
|
|
|
z-index: -10; |
|
|
@ -62,6 +62,9 @@ |
|
|
|
width:100%; |
|
|
|
height:100%; |
|
|
|
} |
|
|
|
&>.modelPopover{ |
|
|
|
pointer-events: none; |
|
|
|
} |
|
|
|
svg{ |
|
|
|
opacity: 0; |
|
|
|
} |
|
|
@ -85,7 +88,9 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div ref="demoEl" style="height:20px;background:red;">asdaf</div> |
|
|
|
<canvas ref="map" @click="tap"/> |
|
|
|
<div ref="modelPopover" class="modelPopover"/> |
|
|
|
<svg ref="svg"> |
|
|
|
<text :fill="labelName.color" dominant-baseline="text-before-edge" font-size="30" font-weight="900" v-html="labelName.text"></text> |
|
|
|
</svg> |
|
|
@ -93,21 +98,33 @@ |
|
|
|
</template> |
|
|
|
<script setup> |
|
|
|
import * as THREE from 'three' |
|
|
|
import {CSS2DRenderer, CSS2DObject} from 'three/examples/jsm/renderers/CSS2DRenderer' |
|
|
|
import gsap from 'gsap' |
|
|
|
import { MapControls } from 'three/examples/jsm/controls/MapControls' |
|
|
|
import { nextTick, onMounted, reactive, ref, resolveTransitionHooks, watch } from 'vue'; |
|
|
|
import yuanmou from '@/assets/map/yuanmou.json' |
|
|
|
import {SVGToBase64} from 'black-knight/lib/config/tools' |
|
|
|
|
|
|
|
var time_line=gsap.timeline() |
|
|
|
var value={value:0} |
|
|
|
time_line.to(value,{value:3,duration:1,onUpdate(a,b,c,d){ |
|
|
|
console.log(a,b,c,d,time_line,'-----afd----------') |
|
|
|
},onUpdateParams:[1,2,value]}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var svg=ref() |
|
|
|
var labelName=reactive({ |
|
|
|
text:"", |
|
|
|
color:"#fff" |
|
|
|
}) |
|
|
|
var demoEl=ref() |
|
|
|
|
|
|
|
var offset=reactive({x:0,y:0,z:0,w:0,h:0}) |
|
|
|
|
|
|
|
var map=ref(); |
|
|
|
var scene,renderer,camera; |
|
|
|
var modelPopover=ref() |
|
|
|
var scene,renderer,camera,modalRenderer; |
|
|
|
var group=new THREE.Group() |
|
|
|
var names=[] |
|
|
|
var labels=[] |
|
|
@ -149,7 +166,6 @@ import {SVGToBase64} from 'black-knight/lib/config/tools' |
|
|
|
// controls.enableRotate=false |
|
|
|
controls.maxPolarAngle=Math.PI/2 |
|
|
|
controls.minPolarAngle=0 |
|
|
|
controls.maxZoom=1.3 |
|
|
|
} |
|
|
|
function addMap(){ |
|
|
|
var shape = new THREE.Shape() |
|
|
@ -358,6 +374,8 @@ import {SVGToBase64} from 'black-knight/lib/config/tools' |
|
|
|
115*(-center[0]+label[0]+points[0]), label[1]+points[1], 115*(-center[1]+label[2]+points[2]), |
|
|
|
115*(-center[0]+label[0]+points[3]), label[1]+points[4], 115*(-center[1]+label[2]+points[5]), |
|
|
|
], 3)) |
|
|
|
|
|
|
|
|
|
|
|
var lineMaterial=new THREE.LineBasicMaterial({ |
|
|
|
color:color, |
|
|
|
}) |
|
|
@ -384,9 +402,35 @@ import {SVGToBase64} from 'black-knight/lib/config/tools' |
|
|
|
resolve() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
function addPoint(){ |
|
|
|
const geometry = new THREE.SphereGeometry( 1, 20, 20 ); |
|
|
|
let material = new THREE.MeshPhysicalMaterial( { |
|
|
|
clearcoat: 1.0, |
|
|
|
clearcoatRoughness: 0.4, |
|
|
|
metalness: 0.8, |
|
|
|
roughness: 0.5, |
|
|
|
color: 0x69E7FC, |
|
|
|
emissive:0x24BBD4, |
|
|
|
flatShading:false, |
|
|
|
normalScale: new THREE.Vector2( 0.15, 0.15 ), |
|
|
|
}); |
|
|
|
var mesh=new THREE.Mesh(geometry, material) |
|
|
|
mesh.position.set(0,1.5,0) |
|
|
|
scene.add(mesh) |
|
|
|
|
|
|
|
modalRenderer=new CSS2DRenderer({element: modelPopover.value}) |
|
|
|
modalRenderer.setSize(map.value.clientWidth, map.value.clientHeight) |
|
|
|
|
|
|
|
var demo=new CSS2DObject(demoEl.value) |
|
|
|
demo.position.set(-10,7,0) |
|
|
|
scene.add(demo) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
function render(){ |
|
|
|
renderer.render(scene, camera); |
|
|
|
modalRenderer.render(scene, camera); |
|
|
|
requestAnimationFrame(render) |
|
|
|
|
|
|
|
var z=Math.sqrt(Math.pow(camera.position.x,2)+Math.pow(camera.position.z,2)) |
|
|
@ -417,6 +461,7 @@ import {SVGToBase64} from 'black-knight/lib/config/tools' |
|
|
|
init() |
|
|
|
addMap() |
|
|
|
await addLabel() |
|
|
|
addPoint() |
|
|
|
render() |
|
|
|
// setTimeout(()=>{ |
|
|
|
await addBG1() |
|
|
|