awv3
Version:
⚡ AWV3 embedded CAD
99 lines (81 loc) • 3.23 kB
JavaScript
import _createClass from "@babel/runtime/helpers/createClass";
import * as THREE from 'three';
/** A heads up display that renders a separate scene. */
var Hud =
/*#__PURE__*/
function () {
function Hud(view) {
this.enabled = true;
this.view = view;
this.renderer = view.renderer;
this.scene = new THREE.Scene();
this.scene.canvas = view.canvas;
this.scene.view = view;
this.camera = undefined;
this.controls = undefined;
this.ambient = new THREE.AmbientLight(view.options.ambientColor ? view.options.ambientColor : 0xffffff);
this.ambient.intensity = typeof view.options.ambientIntensity !== 'undefined' ? view.options.ambientIntensity : 1.0;
this.ambient.keep = true;
this.ambient.view = this;
this.scene.add(this.ambient);
}
var _proto = Hud.prototype;
_proto.onMouseWheel = function onMouseWheel(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onMouseWheel(state);
};
_proto.onMouseMove = function onMouseMove(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onMouseMove(state);
};
_proto.onMouseDown = function onMouseDown(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onMouseDown(state);
};
_proto.onMouseUp = function onMouseUp(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onMouseUp(state);
};
_proto.onTouchStart = function onTouchStart(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onTouchStart(state);
};
_proto.onTouchMove = function onTouchMove(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onTouchMove(state);
};
_proto.onTouchEnd = function onTouchEnd(state) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.onTouchEnd(state);
};
_proto.update = function update(time) {
this.enabled && this.controls && this.controls != this.view.controls && this.controls.update(time);
};
_proto.calibrate = function calibrate(width, height) {
if (this.enabled && this.camera && this.camera != this.view.camera) {
this.camera.aspect = this.view.camera.aspect;
this.camera.updateProjectionMatrix();
this.camera.radius = (width + height) / 4;
}
};
_proto.render = function render() {
this.enabled && this.renderer.gl.render(this.scene, this.camera && this.camera.display || this.view.camera.display);
};
_proto.destroy = function destroy() {
this.view && this.view.removeHud(this);
this.view = undefined;
this.renderer = undefined;
if (this.scene) {
this.scene.destroy({
keep: false
});
this.scene.canvas = undefined;
this.scene.view = undefined;
}
this.scene = undefined;
this.camera = undefined;
this.controls = undefined;
this.ambient = undefined;
};
_createClass(Hud, [{
key: "inMotion",
get: function get() {
return this.enabled && this.controls && this.controls.inMotion;
}
}]);
return Hud;
}();
export { Hud as default };