Skip to content

Commit 796162c

Browse files
author
Sascha Braun
committed
transform to library and first pre-release
1 parent 1280c0a commit 796162c

File tree

112 files changed

+1237
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1237
-174
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
/dist
4+
/build
45

56
# local env files
67
.env.local

.npmignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.vscode
2+
.github
3+
/node_modules
4+
/public
5+
/samples
6+
/build/tests
7+
/src
8+
/tests
9+
10+
.prettierignore
11+
.editorconfig
12+
.postcssrc.js
13+
babel.config.js
14+
jest.config.js
15+
tsconfig.json
16+
tsconfig.prod.json
17+
tslint.json
18+
19+
# Log files
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
24+
yarn.lock
25+
package-lock.json

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# package.json is formatted by package managers, so we ignore it here
2+
package.json
3+
**/*.md

README.md

+53-14
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,68 @@
11
# Vue Three.js
22

3-
/!\ This module is still in development and not usable yet as a library.
3+
/!\ This module is still in development.
44

55
Contains Vuejs bindings for creating and interacting with Threejs scenes and objects in a easy and reactive way.
66

77
**Features:**
88

9-
- Only core features will be present in this package
10-
- Asset manager with preload possibility (loading events not done yet)
11-
- Scene manager with scene switching / loading
12-
- Reactive meshes, cameras and lights
13-
- Asynchronous asset and mesh loading
14-
- Custom factory functions to load (asynchronously) custom geometries, materials and textures
15-
- Input manager
16-
- Behaviour components for data manipulation
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.
10+
11+
However, for now, there are still some shipped in features. Some features are bound to change as the library evolves.
12+
13+
- Asset manager to automatically load and unload your assets.
14+
- Custom asset factory functions to load (asynchronously) custom geometries, materials and textures.
15+
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.
19+
20+
- Other default components such as fog.
21+
22+
- First version of a input manager based on [pinput](https://github.com/ichub/pinput)
1723

1824
**Todo:**
1925

20-
- Add delta time ( for now it is equals to 0 all time )
21-
- Change project to library and add samples
22-
- Publish first pre-release on npm
26+
- Add delta time ( for now it is not set and is always equals to 0 )
27+
28+
- Add scene loading events for tracking loading progress
29+
- Remove scene active prop (can be done with an v-if attribute)
30+
- Add scene preload nested assets handling
31+
- Add cube texture component
32+
33+
- Add default materials and geometries
2334

2435
## Usage
2536

26-
####Define your scenes
37+
###Installation
38+
39+
1. Install THREE.js:
40+
41+
`npm install three --save`
42+
43+
2. Optionally, install THREE.js typings:
44+
45+
`npm install @types/three --save-dev`
46+
47+
3. Install this package:
48+
49+
`npm install vue-threejs-composer --save`
50+
51+
###Samples
52+
53+
If you want to test out our samples, you can clone our repository and launch our samples with the following commands:
54+
55+
1. Install dependencies
56+
57+
`npm install`
58+
59+
2. Launch development server
60+
61+
`npm run serve`
62+
63+
3. Play around with the files in */samples*. The demo scene is situated at */samples/views/Demo.vue*
64+
65+
###Define your scenes
2766

2867
```html
2968
<div>
@@ -72,7 +111,7 @@ Contains Vuejs bindings for creating and interacting with Threejs scenes and obj
72111
</div>
73112
```
74113

75-
####Define custom behaviours
114+
###Define custom behaviours
76115

77116
```ts
78117
import { Component, Mixins, Prop } from "vue-property-decorator";

jest.config.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
module.exports = {
2-
moduleFileExtensions: [
3-
'js',
4-
'jsx',
5-
'json',
6-
'vue',
7-
'ts',
8-
'tsx'
9-
],
2+
moduleFileExtensions: ["js", "jsx", "json", "vue", "ts", "tsx"],
103
transform: {
11-
'^.+\\.vue$': 'vue-jest',
12-
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
13-
'^.+\\.tsx?$': 'ts-jest'
4+
"^.+\\.vue$": "vue-jest",
5+
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$":
6+
"jest-transform-stub",
7+
"^.+\\.tsx?$": "ts-jest"
148
},
159
moduleNameMapper: {
16-
'^@/(.*)$': '<rootDir>/src/$1'
10+
"^@/(.*)$": "<rootDir>/src/$1"
1711
},
18-
snapshotSerializers: [
19-
'jest-serializer-vue'
20-
],
12+
snapshotSerializers: ["jest-serializer-vue"],
2113
testMatch: [
22-
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
14+
"**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
2315
],
24-
testURL: 'http://localhost/'
25-
}
16+
testURL: "http://localhost/"
17+
};

package.json

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
{
2-
"name": "vue-three-composer",
2+
"name": "vue-threejs-composer",
33
"version": "0.1.0",
4-
"private": true,
4+
"main": "build/src/index.js",
5+
"typings": "build/src/index.d.ts",
6+
"repository": "https://github.com/sascha245/vue-threejs-composer",
7+
"license": "MIT",
8+
"keywords": [
9+
"vue",
10+
"threejs"
11+
],
512
"scripts": {
6-
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build",
13+
"serve": "vue-cli-service serve ./samples/main.ts",
14+
"build": "tsc -p tsconfig.prod.json",
815
"lint": "vue-cli-service lint",
9-
"test:unit": "vue-cli-service test:unit"
16+
"test:unit": "vue-cli-service test:unit",
17+
"validate": "npm run build && npm run test:unit && npm pack --dry-run"
1018
},
1119
"dependencies": {
12-
"@types/three": "^0.92.24",
13-
"three": "^0.97.0",
14-
"vue": "^2.5.17",
20+
"events": "^3.0.0",
1521
"vue-class-component": "^6.0.0",
16-
"vue-property-decorator": "^7.0.0",
17-
"vue-router": "^3.0.1",
18-
"vuex": "^3.0.1"
22+
"vue-property-decorator": "^7.0.0"
1923
},
2024
"devDependencies": {
25+
"@types/events": "^1.2.0",
2126
"@types/jest": "^23.1.4",
27+
"@types/three": "^0.92.24",
2228
"@vue/cli-plugin-babel": "^3.0.4",
2329
"@vue/cli-plugin-typescript": "^3.0.4",
2430
"@vue/cli-plugin-unit-jest": "^3.0.4",
2531
"@vue/cli-service": "^3.0.4",
2632
"@vue/test-utils": "^1.0.0-beta.20",
2733
"babel-core": "7.0.0-bridge.0",
2834
"lint-staged": "^7.2.2",
35+
"three": "^0.97.0",
2936
"ts-jest": "^23.0.0",
3037
"tslint-config-prettier": "^1.15.0",
3138
"typescript": "^3.0.0",
39+
"vue": "^2.5.17",
40+
"vue-router": "^3.0.1",
3241
"vue-template-compiler": "^2.5.17"
3342
},
3443
"browserslist": [
@@ -48,5 +57,9 @@
4857
"vue-cli-service lint",
4958
"git add"
5059
]
60+
},
61+
"peerDependencies": {
62+
"three": "^0.97.0",
63+
"vue": "^2.5.17"
5164
}
5265
}

src/App.vue renamed to samples/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div id="app">
33
<div id="nav">
44
<router-link to="/">Home</router-link> |
5-
<router-link to="/about">About</router-link>
5+
<router-link to="/demo">Demo</router-link>
66
</div>
77
<router-view/>
88
</div>

samples/main.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Vue from "vue";
2+
3+
import App from "./App.vue";
4+
import router from "./router";
5+
6+
Vue.config.productionTip = false;
7+
8+
new Vue({
9+
router,
10+
render: h => h(App)
11+
}).$mount("#app");
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Vue from 'vue';
2-
import Router from 'vue-router';
1+
import Vue from "vue";
2+
import Router from "vue-router";
33

4-
import Home from './views/Home';
4+
import Home from "./views/Home";
55

6-
const About = () => import(/* webpackChunkName: "about" */ "./views/About");
6+
const Demo = () => import(/* webpackChunkName: "about" */ "./views/Demo");
77

88
Vue.use(Router);
99

@@ -15,12 +15,12 @@ export default new Router({
1515
component: Home
1616
},
1717
{
18-
path: "/about",
19-
name: "about",
18+
path: "/demo",
19+
name: "demo",
2020
// route level code-splitting
2121
// this generates a separate chunk (about.[hash].js) for this route
2222
// which is lazy-loaded when the route is visited.
23-
component: About
23+
component: Demo
2424
}
2525
]
2626
});
File renamed without changes.

src/views/About.ts renamed to samples/views/Demo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, Vue } from "vue-property-decorator";
33

44
import {
55
CameraFactory, components, GeometryFactory, LightFactory, MaterialFactory
6-
} from "@/vue-three";
6+
} from "../../src";
77

88
import { MyBehaviour } from "./MyBehaviour";
99

src/views/About.vue renamed to samples/views/Demo.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" src="./About.ts"></script>
1+
<script lang="ts" src="./Demo.ts"></script>
22

33
<template>
44
<div class="about">
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { Component, Vue } from 'vue-property-decorator';
22

3-
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
4-
53
@Component({
64
components: {
7-
HelloWorld
85
}
96
})
107
export default class Home extends Vue {}

src/views/Home.vue renamed to samples/views/Home.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
<template>
44
<div class="home">
5-
<img alt="Vue logo" src="../assets/logo.png">
6-
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
5+
Home
76
</div>
87
</template>
98

src/views/MyBehaviour.ts renamed to samples/views/MyBehaviour.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as THREE from "three";
22
import { Component, Mixins, Prop } from "vue-property-decorator";
33

4-
import { Behaviour } from "@/vue-three";
5-
4+
import { Behaviour } from "../../src";
65
import { OrbitControls } from "./OrbitControls";
76

87
interface Vec3 {
File renamed without changes.

src/assets/logo.png

-6.69 KB
Binary file not shown.

src/components/Behaviour.jsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as tslib_1 from "tslib";
2+
import { Component, Mixins } from "vue-property-decorator";
3+
import { ThreeComponent, ThreeObjectComponent, ThreeSceneComponent } from "./base";
4+
let Behaviour = class Behaviour extends Mixins(ThreeComponent, ThreeSceneComponent, ThreeObjectComponent) {
5+
ready() {
6+
if (this.update) {
7+
this.app().on("update", this.update);
8+
}
9+
}
10+
beforeDestroy() {
11+
console.log("before destroy behaviour");
12+
if (this.update) {
13+
this.app().off("update", this.update);
14+
}
15+
}
16+
};
17+
Behaviour = tslib_1.__decorate([
18+
Component
19+
], Behaviour);
20+
export { Behaviour };
21+
//# sourceMappingURL=Behaviour.jsx.map

src/components/Behaviour.jsx.map

+1
Original file line numberDiff line numberDiff line change
File renamed without changes.

0 commit comments

Comments
 (0)