UNPKG

@vuemap/vue-amap-extra

Version:

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

62 lines (57 loc) 1.75 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var three = require('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 three.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 three.Color(color); this.refresh(); } getColorHex(color) { return new three.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; } } } exports.default = ThreeLightPoint; //# sourceMappingURL=ThreeLightPoint.js.map