Skip to content

Commit

Permalink
- remove redundant emplate block in favor of inheritance from mixins
Browse files Browse the repository at this point in the history
- remove unnecessary object3d wrapper of examples/Ocean
  • Loading branch information
fritx committed Oct 21, 2016
1 parent e1332be commit e08f9d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 0 additions & 4 deletions src/components/Camera.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<template>
<div><slot></slot></div>
</template>

<script>
import { Camera, PerspectiveCamera } from 'three'
import Object3D from './Object3D'
Expand Down
4 changes: 0 additions & 4 deletions src/components/Scene.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<template>
<div><slot></slot></div>
</template>

<script>
import * as THREE from 'three'
import Object3D from './Object3D'
Expand Down
16 changes: 6 additions & 10 deletions src/examples/Ocean.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<template>
<object3d :obj="mesh"></object3d>
</template>

<script>
/* global requestAnimationFrame */
import * as THREE from 'three'
Expand All @@ -16,7 +12,7 @@ export default {
created () {
this.animate = this.animate.bind(this)
this.clock = new THREE.Clock()
this.mesh = this.createOcean()
this._obj = this.createOcean()
},
mounted () {
Expand All @@ -25,9 +21,9 @@ export default {
methods: {
createOcean () {
const geometry = this.geometry = new THREE.PlaneGeometry(10000, 10000, 40, 40)
const geometry = new THREE.PlaneGeometry(10000, 10000, 40, 40)
geometry.rotateX(-Math.PI / 2)
for (var i = 0, l = geometry.vertices.length; i < l; i++) {
for (let i = 0, l = geometry.vertices.length; i < l; i++) {
geometry.vertices[ i ].y = 10 * Math.sin(i / 2)
}
Expand All @@ -44,10 +40,10 @@ export default {
animate () {
requestAnimationFrame(this.animate)
const time = this.clock.getElapsedTime() * 5
for (var i = 0, l = this.geometry.vertices.length; i < l; i++) {
this.geometry.vertices[i].y = 10 * Math.sin(i / 5 + (time + i) / 7)
for (let i = 0, l = this._obj.geometry.vertices.length; i < l; i++) {
this._obj.geometry.vertices[i].y = 10 * Math.sin(i / 5 + (time + i) / 7)
}
this.mesh.geometry.verticesNeedUpdate = true
this._obj.geometry.verticesNeedUpdate = true
}
}
}
Expand Down

0 comments on commit e08f9d0

Please sign in to comment.