3 |
4 |
5 |
38 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | let vueComs = {}
2 |
3 | let vueContext = require.context('./', true, /\.vue$/)
4 | vueContext.keys().forEach(path => {
5 | let com = vueContext(path).default
6 | vueComs[com.name] = com
7 | exports[com.name] = com
8 | })
9 |
10 | let loaderContext = require.context('./threex/loaders', false, /\.js$/)
11 | loaderContext.keys().forEach(path => {
12 | let com = loaderContext(path).default
13 | // fix: uglify would kill the function name
14 | let name = path.match(/([^/]+)\.js$/)[1]
15 | exports[name] = com
16 | })
17 |
18 | exports.install = Vue => {
19 | Object.keys(vueComs).forEach(k => {
20 | // fix: name 'object3d' is required,
21 | // or it would be parsed to 'object-3-d' somewhere else
22 | let rk
23 | if (k === 'Object3D') rk = 'object3d'
24 | if (rk) Vue.component(rk, vueComs[k])
25 | Vue.component(k, vueComs[k])
26 | })
27 | }
28 |
--------------------------------------------------------------------------------
/src/physics/MovementObject.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
42 |
--------------------------------------------------------------------------------
/src/components/Scene.vue:
--------------------------------------------------------------------------------
1 |
37 |
--------------------------------------------------------------------------------
/src/physics/MassObject.vue:
--------------------------------------------------------------------------------
1 |
43 |
--------------------------------------------------------------------------------
/tests/unit/Object3D.spec.js:
--------------------------------------------------------------------------------
1 | import { shallowMount } from '@vue/test-utils'
2 | import Object3D from '@/components/Object3D'
3 |
4 | describe('Object3D.vue', () => {
5 | ['position', 'rotation'].forEach(k => {
6 | describe(`#${k}`, () => {
7 | it('should init by default', () => {
8 | const wrapper = shallowMount(Object3D)
9 | expect(wrapper.vm.curObj[k])
10 | .toMatchObject({ x: 0, y: 0, z: 0 })
11 | })
12 |
13 | it('should init via props', () => {
14 | const wrapper = shallowMount(Object3D, {
15 | propsData: { [k]: { y: 3, z: -5 } }
16 | })
17 | expect(wrapper.vm.curObj[k])
18 | .toMatchObject({ x: 0, y: 3, z: -5 })
19 | })
20 |
21 | it('should watch props', () => {
22 | const wrapper = shallowMount(Object3D)
23 | wrapper.setProps({ [k]: { x: -7 } })
24 | setTimeout(() => {
25 | expect(wrapper.vm.curObj[k])
26 | .toMatchObject({ x: -7, y: 0, z: 0 })
27 | })
28 | })
29 | })
30 | })
31 | })
32 |
--------------------------------------------------------------------------------
/src/mesh/MObjMtl.vue:
--------------------------------------------------------------------------------
1 |
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Fritz Lin
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
--------------------------------------------------------------------------------
/src/physics/MovementSystem.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
46 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | let isLib = process.env.TARGET === 'lib'
2 |
3 | module.exports = {
4 | css: {
5 | extract: !isLib
6 | },
7 | chainWebpack: config => {
8 | if (isLib) {
9 | // https://github.com/vuejs/vue-cli/issues/2646
10 | config.merge({
11 | externals: {
12 | vue: {
13 | commonjs: 'vue',
14 | commonjs2: 'vue',
15 | root: 'Vue',
16 | },
17 | three: {
18 | commonjs: 'three',
19 | commonjs2: 'three',
20 | root: 'THREE',
21 | },
22 | 'dat.gui': {
23 | commonjs: 'dat.gui',
24 | commonjs2: 'dat.gui',
25 | // https://github.com/dataarts/dat.gui/blob/1b18f7227e56c8b5071337732342101501b9fa95/rollup.config.js#L30
26 | root: 'dat',
27 | },
28 | oimo: {
29 | commonjs: 'oimo',
30 | commonjs2: 'oimo',
31 | // https://github.com/lo-th/Oimo.js/blob/0ce1c3d8ff3f857d9180035076a70d8d6976a3e6/rollup.config.js#L7
32 | root: 'OIMO',
33 | },
34 | }
35 | })
36 | }
37 | },
38 | }
39 |
--------------------------------------------------------------------------------
/public/static/threex/spaceships/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Jerome Etienne
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/components/OrbitControls.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
51 |
--------------------------------------------------------------------------------
/src/components/Animation.vue:
--------------------------------------------------------------------------------
1 |
65 |
--------------------------------------------------------------------------------
/src/mesh/Texture.vue:
--------------------------------------------------------------------------------
1 |
57 |
--------------------------------------------------------------------------------
/src/components/PositionalAudio.vue:
--------------------------------------------------------------------------------
1 |
2 |