UNPKG

@vuemap/vue-amap-extra

Version:

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

62 lines (59 loc) 1.64 kB
import { DirectionalLight, 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 ThreeLightDirectional { // threejs的图层对象 constructor(layer, options) { __publicField(this, "object"); // Light __publicField(this, "layer"); this.layer = layer; const light = new DirectionalLight(this.getColorHex(options.color), options.intensity); 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) { this.object.position.set(position.x, position.y, position.z); this.refresh(); } setTarget(target) { if (target) { this.object.target = target; 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 { ThreeLightDirectional as default }; //# sourceMappingURL=ThreeLightDirectional.mjs.map