Skip to content

Commit 4a44809

Browse files
committed
wip(mesh): simplify ocean logic 'n update readme
1 parent 36625db commit 4a44809

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

Diff for: README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Vue.use(VueThreejs)
1818
<renderer :size="{ w: 600, h: 400 }">
1919
<scene>
2020
<camera :position="{ z: 15 }"></camera>
21-
<object3d :obj="mesh" :position="{ y: -200 }"></object3d>
21+
<mesh :obj="mesh" :position="{ y: -200 }"></mesh>
2222
<animation :fn="animate" :speed="3"></animation>
2323
</scene>
2424
</renderer>
@@ -40,15 +40,27 @@ Vue.use(VueThreejs)
4040
</movement-system>
4141
```
4242

43+
```vue
44+
<oimo-world :options="{ gravity: [0, -9.8, 0] }">
45+
<space-system :m-scale="10 ** 4">
46+
<space-object v-for="t in textures" :key="t">
47+
<oimo-body :options="{ move: true, density: 1 }">
48+
<cube :texture="t" :size="1"></cube>
49+
</oimo-body>
50+
</space-object>
51+
</space-system>
52+
</oimo-world>
53+
```
54+
4355
**Roadmap**
4456

45-
- [ ] Basic components
57+
- [x] Basic components
4658
- [x] renderer/scene/camera/listener
4759
- [x] object3d/light/audio/controls/animation
48-
- [ ] mesh/more
60+
- [x] mesh/geometry/material/texture/obj-mtl
4961
- [ ] Watch for props change
50-
- [x] position/rotation
51-
- [ ] obj/more
62+
- [x] position/rotation/obj
63+
- [ ] more
5264
- [ ] Animation
5365
- [x] component/animate/speed/paused/blocked
5466
- [ ] global-control

Diff for: examples/Ocean.vue

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<template>
22
<div>
3-
<mesh name="Ocean">
4-
<geometry type="Plane" :args="[10000, 10000, 40, 40]"
5-
:obj.sync="geom"></geometry>
3+
<mesh name="Ocean" @update:obj="handleMesh">
4+
<geometry type="Plane" :args="[10000, 10000, 40, 40]"></geometry>
65
<material type="MeshBasic" :color="0x0044ff">
76
<texture :options="txtOpts"></texture>
87
</material>
98
</mesh>
10-
<animation v-if="geomReady" :fn="animate" :speed="5"></animation>
9+
<animation v-if="geom" :fn="animate" :speed="5"></animation>
1110
</div>
1211
</template>
1312

@@ -28,23 +27,21 @@ export default {
2827
wrapT: RepeatWrapping,
2928
repeat: [5, 5]
3029
},
31-
geomReady: false,
32-
geom: null,
33-
ocean: null
30+
geom: null
3431
}
3532
},
3633
37-
watch: {
38-
geom (g) {
34+
methods: {
35+
handleMesh (mesh) {
36+
if (!mesh) return
37+
let g = mesh.geometry
3938
g.rotateX(-Math.PI / 2)
4039
for (let i = 0, l = g.vertices.length; i < l; i++) {
4140
g.vertices[ i ].y = 10 * Math.sin(i / 2)
4241
}
43-
this.geomReady = true
44-
}
45-
},
42+
this.geom = g
43+
},
4644
47-
methods: {
4845
animate (tt) {
4946
let g = this.geom
5047
for (let i = 0, l = g.vertices.length; i < l; i++) {

Diff for: src/components/Object3D.vue

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default {
4141
Object.assign(this.curObj.rotation, v)
4242
}
4343
},
44+
obj (obj) {
45+
this.curObj = obj
46+
},
4447
curObj (obj, oldObj) {
4548
this.unsetObj(oldObj)
4649
this.setObj(obj)

0 commit comments

Comments
 (0)