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

Lines and other components not explicitly defined in the repo #22

Open
saumyasinghal747 opened this issue Feb 14, 2021 · 2 comments
Open

Comments

@saumyasinghal747
Copy link

I'm trying to create some lines according to this tutorial https://threejs.org/docs/index.html#manual/en/introduction/Drawing-lines, could I have help translating this into your module?

To be specific, I'm not sure how to create the Line or the Vector3D object.

Thank you!

@fritx
Copy link
Owner

fritx commented Jul 20, 2022

@saumyasinghal747 hi, here are some approaches:

  1. like https://github.com/fritx/vue-threejs/blob/dev/src/components/Light.vue#L17
<script>
import * as THREE from 'three'
import { Object3D } from 'vue-threejs'
export default {
  name: 'LineOrWhatever',
  mixins: [Object3D],
  props: {
    // ...
  },
  data () {
    let curObj = this.obj
    if (!curObj) {
      curObj = new THREE.Line({/* ... */})
      // curObj = new THREE.WhateverXXX({/* ... */})
    }
    curObj.name = curObj.name || curObj.type
    return { curObj }
  }
}
</script>
  1. like https://github.com/fritx/vue-threejs/blob/dev/examples/Ocean.vue#L3
<mesh name="Ocean" @update:obj="handleMesh">
  <geometry type="Plane" :args="[10000, 10000, 40, 40]"></geometry>
  <material type="MeshBasic" :color="0x0044ff">
  <texture :options="txtOpts"></texture>
  </material>
</mesh>

<script>
// ...
handleMesh(mesh) {
  if (!mesh) return
  // do something on the mesh...
  let g = mesh.geometry
  g.rotateX(-Math.PI / 2)
  for (let i = 0, l = g.vertices.length; i < l; i++) {
    g.vertices[ i ].y = 10 * Math.sin(i / 2)
  }
  this.geom = g
}
</script>

@fritx
Copy link
Owner

fritx commented Jul 20, 2022

@saumyasinghal747 sorry for the very, very late response T_T

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

No branches or pull requests

2 participants