threepipe
Version:
A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.
88 lines • 3.31 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var CameraView_1;
import { EventDispatcher, Quaternion, Vector3 } from 'three';
import { onChange, serializable, serialize } from 'ts-browser-helpers';
import { uiButton, uiInput, uiNumber, uiPanelContainer, uiVector } from 'uiconfig.js';
import { generateUUID } from '../../three';
let CameraView = CameraView_1 = class CameraView extends EventDispatcher {
constructor(name, position, target, quaternion, zoom) {
super();
this.uuid = generateUUID();
this.name = 'Camera View';
this.position = new Vector3();
this.target = new Vector3();
this.quaternion = new Quaternion();
this.zoom = 1;
this.isWorldSpace = true;
this.set = (camera) => this.dispatchEvent({ type: 'setView', camera, view: this });
this.update = (camera) => this.dispatchEvent({ type: 'updateView', camera, view: this });
this.delete = (camera) => this.dispatchEvent({ type: 'deleteView', camera, view: this });
this.animate = (camera, duration) => this.dispatchEvent({ type: 'animateView', camera, duration, view: this });
if (name !== undefined)
this.name = name;
if (position)
this.position.copy(position);
if (target)
this.target.copy(target);
if (quaternion)
this.quaternion.copy(quaternion);
if (zoom !== undefined)
this.zoom = zoom;
}
_nameChanged() {
if (this.uiConfig) {
this.uiConfig.label = this.name;
this.uiConfig.uiRefresh?.();
}
}
clone() {
return new CameraView_1(this.name, this.position, this.target, this.quaternion, this.zoom);
}
};
__decorate([
onChange(CameraView.prototype._nameChanged),
serialize(),
uiInput()
], CameraView.prototype, "name", void 0);
__decorate([
serialize(),
uiVector()
], CameraView.prototype, "position", void 0);
__decorate([
serialize(),
uiVector()
], CameraView.prototype, "target", void 0);
__decorate([
serialize(),
uiVector()
], CameraView.prototype, "quaternion", void 0);
__decorate([
serialize(),
uiNumber()
], CameraView.prototype, "zoom", void 0);
__decorate([
serialize()
], CameraView.prototype, "isWorldSpace", void 0);
__decorate([
uiButton()
], CameraView.prototype, "set", void 0);
__decorate([
uiButton()
], CameraView.prototype, "update", void 0);
__decorate([
uiButton()
], CameraView.prototype, "delete", void 0);
__decorate([
uiButton()
], CameraView.prototype, "animate", void 0);
CameraView = CameraView_1 = __decorate([
serializable('CameraView'),
uiPanelContainer('Camera View')
], CameraView);
export { CameraView };
//# sourceMappingURL=CameraView.js.map