private updateVisibility()

in packages/layers/marker/src/Marker.ts [578:618]


	private updateVisibility(cam: CameraProxy, projection: Projection) {
		if (this.getProp('autoHide')) {
			if (projection.isSphereProjection) {
				// 球面投影下使用球面切点判断可见性
				const camStates = cam.getCartesianStates()
				this._camPosition.set(
					camStates.position[0] - cam.center[0],
					camStates.position[1] - cam.center[1],
					camStates.position[2] - cam.center[2]
				)
				this._camRotationEuler.fromArray(camStates.rotationEuler)

				// earthCenter至相机方向
				const earthToCam = this._v2.subVectors(this._camPosition, this._earthCenter).normalize()
				const camDis = this._camPosition.distanceTo(this._earthCenter)

				// 夹角阈值(用来判断visibility) = 相机地球相切中心角 + marker相机与地球相切中心角
				this._angleThres = Math.acos(R / camDis) + this._altAngleThres

				const normal = this._v3.subVectors(this._worldPosition, this._earthCenter).normalize()

				if (Math.acos(earthToCam.dot(normal)) > this._angleThres) {
					this._onEarthFrontSide = false
				} else {
					this._onEarthFrontSide = true
				}
			} else {
				this._onEarthFrontSide = true
			}
			this.group.visible = this._onEarthFrontSide && this.visible
			if (this.view.html) {
				this.element.style.visibility =
					this._onEarthFrontSide && this.visible ? 'inherit' : 'hidden'
			}
		} else {
			this.group.visible = this.visible
			if (this.view.html) {
				this.element.style.visibility = this.visible ? 'inherit' : 'hidden'
			}
		}
	}