Skip to content

Commit 17122c4

Browse files
authored
Update README.md
1 parent 857e29f commit 17122c4

File tree

1 file changed

+62
-36
lines changed

1 file changed

+62
-36
lines changed

README.md

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1-
# Vue Three.js
1+
# vue-threejs-composer
22

33
/!\ This module is still in development.
44

5-
Contains Vuejs bindings for creating and interacting with Threejs scenes and objects in a easy and reactive way.
5+
Build beautiful and interactive scenes in the easy way.
66

7-
**Features:**
7+
## Features
88

9-
Only core features will be present in this package: You will be able to extend this libraries classes and components to easily add your own required features.
9+
This library's strong points:
1010

11-
However, for now, there are still some shipped in features. Some features are bound to change as the library evolves.
11+
1. Core features to easily register assets and create objects in your scenes.
1212

13-
- Asset manager to automatically load and unload your assets.
14-
- Custom asset factory functions to load (asynchronously) custom geometries, materials and textures.
13+
2. Asset manager to store your assets.
1514

16-
- Scene manager able to handle multiple scenes. Only once scene at a time may be active however
17-
- Meshes, cameras and lights and groups with reactive property bindings
18-
- Behaviour components for data manipulation: Can be placed in the object, scene or application scope, depending on the seeked result.
15+
3. If necessary, easily create even the most unique geometries, materials and textures with dedicated factory functions.
1916

20-
- Other default components such as fog.
17+
4. Behaviours you can attach to objects, scenes or your application to move the world.
2118

22-
- First version of a input manager based on [pinput](https://github.com/ichub/pinput)
19+
5. Inbuild input manager to handle inputs in a more forward way.
2320

24-
**Todo:**
21+
6. Scenes with asset preloading
22+
23+
7. Easily add your own content! It is very easy to create your own components and wrappers on top of this library.
2524

26-
- Remove scene active prop (can be done with an v-if attribute)
25+
**Todo:**
2726

2827
- Add cube texture component
29-
- Add default materials and geometries
28+
- Add basic materials and geometries
29+
- Add basic meshes and lights
30+
- Add obj/fbx file loading and saving in asset manager
3031

3132
## Usage
3233

33-
###Installation
34+
### Installation
3435

3536
1. Install THREE.js:
3637

@@ -44,7 +45,7 @@ However, for now, there are still some shipped in features. Some features are bo
4445

4546
`npm install vue-threejs-composer --save`
4647

47-
###Samples
48+
### Samples
4849

4950
If you want to test out our samples, you can clone our repository and launch our samples with the following commands:
5051

@@ -58,31 +59,41 @@ If you want to test out our samples, you can clone our repository and launch our
5859

5960
3. Play around with the files in */samples*. The demo scene is situated at */samples/views/Demo.vue*
6061

61-
###Define your scenes
62+
### Define your scenes
6263

6364
```html
6465
<div>
65-
<canvas ref="canvas" class="webglCanvas"></canvas>
66-
<div v-if="canvas">
66+
<canvas ref="canvas" class="webglCanvas"></canvas>
67+
<div v-if="canvas">
6768
<three :canvas="canvas" antialias>
6869

69-
<scene name="MyScene" active>
70+
<scene name="MyScene" active @load="loadingStarted" @load-progress="loadingProgress" @loaded="loadingFinished">
7071
<template slot="preload">
71-
<material name="cubeMat" :factory="cubeMaterialFactory"/>
72-
<geometry name="cube" :factory="cubeFactory"/>
72+
73+
<div>
74+
<material name="cubeMat" :factory="cubeMaterialFactory"/>
75+
<geometry name="cube" :factory="cubeFactory"/>
76+
</div>
7377

7478
<material name="waterMat" :factory="waterMaterialFactory"/>
7579
<geometry name="plane" :factory="planeFactory"/>
7680
</template>
7781

82+
<fog exp2/>
83+
<grid :size="10" :divisions="10"/>
84+
<axes :size="1"/>
85+
7886
<camera name="mainCamera" :factory="cameraFactory">
79-
<position :value="scene1.camera.position"/>
80-
<rotation :value="scene1.camera.rotation" rad/>
87+
<position :value="camera.position"/>
88+
<rotation :value="camera.rotation" rad/>
8189
</camera>
8290

8391
<light name="light" :factory="lightFactory">
84-
<position :value="{x: 0, y: 10, z: 0}"/>
92+
<position :value="light.position"/>
8593
<shadows cast/>
94+
95+
<!-- See custom behaviour implementation below -->
96+
<hover-behaviour :position="light.position" :distance="1" :speed="5">
8697
</light>
8798

8899
<mesh name="waterPlane" geometry="plane" material="waterMat">
@@ -104,24 +115,30 @@ If you want to test out our samples, you can clone our repository and launch our
104115
</scene>
105116

106117
</three>
118+
</div>
107119
</div>
108120
```
109121

110-
###Define custom behaviours
122+
### Define custom behaviours
111123

112124
```ts
113125
import { Component, Mixins, Prop } from "vue-property-decorator";
114126

115127
import { Behaviour } from "vue-threejs-composer";
116128

117129
@Component
118-
export class MyBehaviour extends Mixins(Behaviour) {
119-
@Prop()
120-
public data!: {
121-
position: Vec3;
122-
};
130+
export class HoverBehaviour extends Mixins(Behaviour) {
131+
@Prop({ required: true, type: Object })
132+
public position!: { x: number, y: number, z: number };
133+
134+
@Prop({ type: Number, default: 1 })
135+
public distance!: number;
136+
137+
@Prop({ type: Number, default: 1 })
138+
public speed!: number;
123139

124140
private m_moveUp = true;
141+
private m_originalY = 0;
125142

126143
public created() {
127144
// access app
@@ -133,18 +150,19 @@ export class MyBehaviour extends Mixins(Behaviour) {
133150
// access object if behaviour is placed in an object
134151
const object = this.object();
135152

153+
this.m_originalY = this.position.y;
154+
136155
// once your component is ready
137156
this.ready();
138157
}
139158

140159
// lifecycle function called before each frame (optional)
141160
public update(deltaTime: number) {
142-
const speed = 5; // 5 y / second
143-
this.data.position.y += deltaTime * (this.m_moveUp ? 1 : -1) * speed;
161+
this.position.y += deltaTime * (this.m_moveUp ? 1 : -1) * this.speed;
144162

145-
if (this.data.position.y > 10) {
163+
if (this.position.y > (this.m_originalY + this.distance)) {
146164
this.m_moveUp = false;
147-
} else if (this.data.position.y < 0) {
165+
} else if (this.position.y < (this.m_originalY - this.distance)) {
148166
this.m_moveUp = true;
149167
}
150168
}
@@ -158,3 +176,11 @@ export class MyBehaviour extends Mixins(Behaviour) {
158176
}
159177
}
160178
```
179+
180+
## License
181+
182+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) for details
183+
184+
## Acknowledgments
185+
186+
- First version of a input manager based on [pinput](https://github.com/ichub/pinput)

0 commit comments

Comments
 (0)