This commit is contained in:
ann 2023-02-28 23:30:07 +08:00
parent 2bdc3eabef
commit dc637ac7fb
2 changed files with 497 additions and 24207 deletions

24635
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -121,7 +121,7 @@ export default {
// this.orbitControls.minAzimuthAngle = 0
// this.orbitControls.maxAzimuthAngle = 0
this.orbitControls.minZoom = 1
this.orbitControls.maxZoom = 1.5
this.orbitControls.maxZoom = 2
},
initModel() {
var geometry = new Three.SphereGeometry(100, 40, 40) //
@ -251,6 +251,7 @@ export default {
})
this.scene.add(map1)
},
// geojson
transformToLatLon(a, b) {
var d = b.jsonmarginX
var f = b.jsonmarginY
@ -277,19 +278,6 @@ export default {
x: b.x
}
},
// getPosition(_longitude, _latitude, _radius) {
// var lg = Three.Math.degToRad(_longitude)
// var lt = Three.Math.degToRad(_latitude)
// var temp = _radius * Math.cos(lt)
// var x = temp * Math.sin(lg)
// var y = _radius * Math.sin(lt)
// var z = temp * Math.cos(lg)
// return {
// x: x,
// y: y,
// z: z
// }
// },
init() {
this.initRender()
this.initScene()
@ -300,44 +288,33 @@ export default {
this.initMap()
this.raycaster = new Three.Raycaster()
// 线
var intersects = this.raycaster.intersectObjects(this.scene.children)
for (var i = 0; i < intersects.length; i++) {
intersects[ i ].object.material.color.set(0xff0000)
}
document.addEventListener('mousedown', this.onDocumentMouseDown, false)
},
onDocumentMouseDown(event) {
// x y (-1 to +1)
console.log('fk')
// event.preventDefault()
const mouseX = (event.clientX / window.innerWidth) * 2 - 1
const mouseY = -(event.clientY / window.innerHeight) * 2 + 1
onDocumentMouseDown(e) {
e.preventDefault()
var raycaster = new Three.Raycaster()
this.raycaster.setFromCamera(new Three.Vector2(mouseX, mouseY), this.camera)
console.log(this.raycaster)
// var intersects = this.raycaster.intersectObjects([])
// if (intersects.length > 0) {
// if (this.intersected) this.intersected.material.map = this.intersected.currentMap
// this.intersected = intersects[0].object
// this.intersected.currentMap = this.intersected.material.map
// // this.intersected.material.map = (128, '#cccccc', 'cccccc')
// }
var mouse = new Three.Vector2() // threejs,
mouse.x = (e.clientX / window.innerWidth) * 2 - 1
mouse.y = -(e.clientY / window.innerHeight) * 2 + 1
// z0.5
//
// var vector = new Three.Vector3(mouse.x, mouse.y, 0.5).unproject(this.camera)
raycaster.setFromCamera(mouse, this.camera)
// 线,线 线
// var raycaster = new Three.Raycaster(this.camera.position, vector.sub(this.camera.position).normalize())
// 线线
// console.log(this.scene)
var intersects = raycaster.intersectObjects(this.scene.children)
console.log(intersects)
if (intersects.length > 0) {
// 线
console.log(intersects[0].object)
}
},
//
setSatellites(rotation, speed) {
// var track = new Three.Mesh(new Three.RingGeometry(satelliteRadius, satelliteRadius + 0.05, 50, 1))
// var centerMesh = new Three.Mesh(new Three.SphereGeometry(1, 1, 1), new Three.MeshLambertMaterial())
// satellite.scale.x = satellite.scale.y = satellite.scale.z = satelliteSize
// satellite.position.set(satelliteRadius, 0, 0)
// var pivotPoint = new Three.Object3D()
// pivotPoint.add(satellite)
// pivotPoint.add(track)
// centerMesh.add(pivotPoint)
// centerMesh.rotation.set(rotation.x, rotation.y, rotation.z)
const distance = 130
const satellite = new Three.Sprite(new Three.SpriteMaterial({ map: new Three.CanvasTexture(this.generateSprite()) }))
satellite.scale.x = satellite.scale.y = satellite.scale.z = 3