# <vgl-obj-loader>

# Example Usage

<template>
  <div>
    <vgl-renderer>
      <template #scene>
        <vgl-scene>
          <vgl-obj-loader
            :src="model[name]"
            :position-y="name === 'cottage' ? 250 : 0"
            :position-z="name === 'seahorse' ? 300 : 5"
            :rotation-x="name === 'cottage' ? -1.5 : 0"
            :rotation-y="name === 'cottage' ? 1 : 0"
          />
          <vgl-ambient-light :intensity="0.5" />
          <vgl-directional-light
            :position-x="1"
            :position-y="1"
            :position-z="1"
            :intensity="0.5"
          />
        </vgl-scene>
      </template>
      <template #camera>
        <vgl-perspective-camera
          position="spherical"
          :position-radius="290"
          rotation="lookAt"
        />
      </template>
    </vgl-renderer>
    <aside>
      <select v-model="name">
        <option value="seahorse">
          Seahorse
        </option>
        <option value="cottage">
          Cottage
        </option>
      </select>
    </aside>
  </div>
</template>

<script>
import {
  VglRenderer, VglScene, VglAmbientLight, VglDirectionalLight, VglPerspectiveCamera,
} from 'vue-gl';
import VglObjLoader from 'vue-gl/dist/examples/loaders/vgl-obj-loader';
import seahorse from './seahorse.obj';
import cottage from './cottage.obj';

export default {
  components: {
    VglRenderer,
    VglScene,
    VglAmbientLight,
    VglDirectionalLight,
    VglPerspectiveCamera,
    VglObjLoader,
  },
  data: () => ({ name: 'seahorse', model: { seahorse, cottage } }),
};
</script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

# Props

  • src : string
    The path to the source OBJ file