mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
45 lines • 1.72 kB
JavaScript
import { Reactive } from "@lincode/reactivity";
import Cylinder from "./primitives/Cylinder";
import mainCamera from "../engine/mainCamera";
import { emitSelectionTarget, onSelectionTarget } from "../events/onSelectionTarget";
import { appendableRoot } from "../api/core/Appendable";
import { getCameraRendered } from "../states/useCameraRendered";
import { spawnPointDefaults, spawnPointSchema } from "../interface/ISpawnPoint";
import ObjectManager from "./core/ObjectManager";
import scene from "../engine/scene";
export default class SpawnPoint extends ObjectManager {
static componentName = "spawnPoint";
static defaults = spawnPointDefaults;
static schema = spawnPointSchema;
helperState = new Reactive(true);
get helper() {
return this.helperState.get();
}
set helper(val) {
this.helperState.set(val);
}
isSpawnPoint = true;
constructor() {
super();
this.createEffect(() => {
if (!this.helperState.get() || getCameraRendered() !== mainCamera)
return;
const h = new Cylinder();
appendableRoot.delete(h);
this.outerObject3d.add(h.outerObject3d);
h.opacity = 0.5;
h.height = 10;
const handle = onSelectionTarget(({ target }) => target === h && emitSelectionTarget(this));
return () => {
h.dispose();
handle.cancel();
};
}, [this.helperState.get, getCameraRendered]);
}
append(child) {
this._append(child);
scene.add(child.outerObject3d);
child.placeAt(this);
}
}
//# sourceMappingURL=SpawnPoint.js.map