<commit_before>import { CameraHelper } from 'three';
import VglObject3d from '../core/vgl-object3d';
import { string } from '../validators';

/**
 * This helps with visualizing what a camera contains in its frustum,
 * corresponding [THREE.CameraHelper](https://threejs.org/docs/index.html#api/helpers/CameraHelper).
 * It visualizes the frustum of a camera using a LineSegments.
 *
 * Properties of [VglObject3d](../core/vgl-object3d) are also available as mixin.
 */

export default {
  mixins: [VglObject3d],
  props: {
    /** Name of the camera to visualize. */
    camera: string,
  },
  methods: {
    setHelper() {
      if (!this.inst.children.length) {
        this.inst.add(new CameraHelper(this.vglNamespace.cameras.get(this.camera)));
      } else {
        const [helper] = this.inst.children;
        helper.camera = this.vglNamespace.cameras.get(this.camera);
        helper.camera.updateProjectionMatrix();
        helper.update();
      }
    },
  },
  created() { this.vglNamespace.beforeRender.push(this.setHelper); },
  beforeDestroy() {
    const { vglNamespace: { beforeRender }, setHelper } = this;
    beforeRender.splice(beforeRender.indexOf(setHelper), 1);
  },
};<commit_msg>fix: component to use new namespace api<commit_after>import { CameraHelper, Object3D } from 'three';
import VglObject3d from '../core/vgl-object3d';
import { string } from '../validators';

/**
 * This helps with visualizing what a camera contains in its frustum,
 * corresponding [THREE.CameraHelper](https://threejs.org/docs/index.html#api/helpers/CameraHelper).
 * It visualizes the frustum of a camera using a LineSegments.
 *
 * Properties of [VglObject3d](../core/vgl-object3d) are also available as mixin.
 */

export default {
  mixins: [VglObject3d],
  props: {
    /** Name of the camera to visualize. */
    camera: string,
  },
  computed: {
    inst() {
      const camera = this.vglNamespace.cameras.get(this.camera);
      return camera && new CameraHelper(camera) || new Object3D();
    },
  },
  watch: {
    camera: {
      handler(name, oldName) {
        if (oldName !== undefined) this.vglNamespace.cameras.unlisten(oldName, this.update);
        this.vglNamespace.cameras.listen(name, this.update);
      },
      immediate: true,
    },
  },
  methods: {
    update(camera) {
      if (!camera || !(this.inst instanceof CameraHelper)) return;
      camera.updateProjectionMatrix();
      this.inst.camera = camera;
      this.inst.update();
    },
  },
  beforeDestroy() { this.vglNamespace.cameras.unlisten(this.camera, this.update); },
};
{'fraction_non_alphanumeric': 0.1410756040530008, 'fraction_numerical': 0.005066250974279034, 'mean_word_length': 3.2783333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209575', 'n_tokens_mistral': 805, 'n_tokens_neox': 800, 'n_words': 182}