Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The edges geometry component #182

Open
h-ikeda opened this issue Mar 28, 2018 · 2 comments
Open

The edges geometry component #182

h-ikeda opened this issue Mar 28, 2018 · 2 comments

Comments

@h-ikeda
Copy link
Member

h-ikeda commented Mar 28, 2018

No description provided.

@Denis-Davidoff
Copy link

Denis-Davidoff commented Feb 21, 2020

I'm create file /src/geometries/vgl-edges-geometry.js with content:

import { EdgesGeometry } from 'three';
import VglGeometry from '../core/vgl-geometry';
//import { float, int } from '../types';
import { name, boolean } from '../types';
import { validateName } from '../validators';

/**
 * This is the quadrilateral primitive geometry component,
 * corresponding [THREE.BoxGeometry](https://threejs.org/docs/index.html#api/geometries/EdgesGeometry).
 *
 * Properties of [VglGeometry](../core/vgl-geometry) are also available as mixin.
 */

export default {
  mixins: [VglGeometry],
  props: {
    geometry: { type: name, validator: validateName },
  },
  computed: {
    inst() {
      return new EdgesGeometry( this.vglNamespace.geometries.get( this.geometry ) );
    },
  },
};

And add its to index.js as import and export

Works as:

<!-- geometry -->
<vgl-box-geometry ref="floor" name="floor" :width="floor.size.x" :depth="floor.size.y" :height="floor.size.z"></vgl-box-geometry>

<vgl-edges-geometry name="edges-floor" geometry="floor"></vgl-edges-geometry>

<vgl-line-basic-material
                            name="line"
                            linewidth="2"
                            color="rgb(150, 200, 20)"
                        />

<vgl-line-segments geometry="edges-floor" material="mat-line" :position="`${floor.position.x} ${floor.position.z} ${floor.position.y}`" ref="floor"></vgl-line-segments>

It's works fine, but if can check on memory leaks and add it to project.
And emits on remove/change/add for correct works.

Thanks.

@h-ikeda
Copy link
Member Author

h-ikeda commented Feb 21, 2020

It's nice of you.

Actually, using namespace manually is a little complex because objects got from namespace are not reactive.

Reading the VglSpotLightHelper component may be helpful.

The component stores object's uuid and the computed property refers it. So that helper instance will be re-created when different uuid is set.
Then, we can handle changing target object (in this case, light) with namespace's listen method. So we should call it when component is created and when target name changes.

Because THREE.Geometry also have uuid property like THREE.Object3D, this approach must be eligible in this case, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants