UNPKG

@vuemap/vue-amap-extra

Version:

@vuemap/vue-amap扩展库,包含threejs相关图层

58 lines (55 loc) 1.67 kB
import { PointLight, Color } from 'three'; 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 ThreeLightPoint { // threejs的图层对象 constructor(layer, options) { __publicField(this, "object"); // Light __publicField(this, "layer"); this.layer = layer; const light = new PointLight(this.getColorHex(options.color), options.intensity, options.distance, options.decay); this.object = light; this.setPosition(options.position); layer.add(light); } setColor(color) { this.object.color = new Color(color); this.refresh(); } getColorHex(color) { return new Color(color).getHex(); } setIntensity(intensity) { this.object.intensity = intensity; this.refresh(); } setPosition(position) { var _a; const positionConvert = (_a = this.layer) == null ? void 0 : _a.convertLngLat([position.x, position.y]); this.object.position.set(positionConvert[0], positionConvert[1], position.z); this.refresh(); } refresh() { var _a; (_a = this.layer) == null ? void 0 : _a.update(); } remove() { var _a; if (this.object) { (_a = this.layer) == null ? void 0 : _a.remove(this.object); } } destroy() { if (this.object) { this.object = null; this.layer = null; } } } export { ThreeLightPoint as default }; //# sourceMappingURL=ThreeLightPoint.mjs.map