@vuemap/vue-amap-extra
Version:
@vuemap/vue-amap扩展库,包含threejs相关图层
66 lines (61 loc) • 1.71 kB
JavaScript
'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 ThreeLightDirectional {
// threejs的图层对象
constructor(layer, options) {
__publicField(this, "object");
// Light
__publicField(this, "layer");
this.layer = layer;
const light = new three.DirectionalLight(this.getColorHex(options.color), options.intensity);
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) {
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;
}
}
}
exports.default = ThreeLightDirectional;
//# sourceMappingURL=ThreeLightDirectional.js.map