@vuemap/vue-amap-extra
Version:
@vuemap/vue-amap扩展库,包含threejs相关图层
73 lines (68 loc) • 2.16 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var three = require('three');
var CircleSweepPass = require('./CircleSweepPass.js');
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
class ThreePassCircle {
constructor(layer, options) {
__publicField(this, "object");
// Light
__publicField(this, "layer");
// threejs的图层对象
__publicField(this, "shaderMaterial");
__publicField(this, "frame", -1);
__publicField(this, "maxRadius");
this.maxRadius = options.maxRadius;
this.layer = layer;
const center = this.layer.convertLngLat(options.position);
const vp = new three.Vector3(center[0], center[1], 0);
const shaderPass = new CircleSweepPass.CircleSweepPass(this.layer.getRender(), this.layer.getScene(), this.layer.getCamera(), {
center: vp,
innerRadius: 0,
outerRadius: 10
});
this.object = shaderPass;
this.layer.addPass(shaderPass);
this.start();
}
start() {
if (this.object.depthMaterial.uniforms.innerRadius.value > 100) {
this.object.depthMaterial.uniforms.innerRadius.value = 0;
this.object.depthMaterial.uniforms.outerRadius.value = 10;
}
this.object.depthMaterial.uniforms.innerRadius.value += 0.4;
this.object.depthMaterial.uniforms.outerRadius.value += 0.4;
this.refresh();
this.frame = requestAnimationFrame(() => {
this.start();
});
}
stop() {
cancelAnimationFrame(this.frame);
}
refresh() {
this.layer.update();
}
remove() {
if (this.object) {
this.layer.removePass(this.object);
}
}
destroy() {
this.stop();
if (this.object) {
if (this.object.dispose) {
this.object.dispose();
}
this.object = null;
this.layer = null;
}
}
}
exports.default = ThreePassCircle;
//# sourceMappingURL=ThreePassCircle.js.map