Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
netpro2k
committed
Apr 1, 2016
0 parents
commit ba2f306
Showing
9 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-1"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": ["standard"], | ||
"parser": "babel-eslint", | ||
"rules": { | ||
"space-before-function-paren": [1, "never"], | ||
"no-unused-vars": 1, | ||
"semi": 1, | ||
"react/prop-types": 0, | ||
"no-multiple-empty-lines": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
bundle.js | ||
npm-debug.log |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
</head> | ||
<body> | ||
<div class="container"></div> | ||
</body> | ||
<script src="/bundle.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "altspace-webpack-starter", | ||
"version": "1.0.0", | ||
"description": "altspace webpack template", | ||
"main": "index.js", | ||
"private": true, | ||
"scripts": { | ||
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --inline", | ||
"build": "NODE_ENV=production webpack -p --progress --profile --colors" | ||
}, | ||
"author": "", | ||
"devDependencies": { | ||
"babel-core": "^6.2.1", | ||
"babel-loader": "^6.2.0", | ||
"babel-preset-es2015": "^6.1.18", | ||
"babel-preset-stage-1": "^6.1.18", | ||
"css-loader": "^0.23.1", | ||
"style-loader": "^0.13.0", | ||
"webpack": "^1.12.9", | ||
"webpack-dev-server": "^1.14.0" | ||
}, | ||
"dependencies": { | ||
"altspace": "^0.5.3", | ||
"css-wipe": "^4.1.2", | ||
"pleasejs": "^0.4.2", | ||
"three": "^0.73.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'css-wipe' | ||
import '../style/base.css' | ||
|
||
import THREE from 'three' | ||
import altspace from 'altspace' | ||
|
||
import Please from 'pleasejs' | ||
|
||
window.THREE = THREE | ||
|
||
var CUBE_SCALE = 150; | ||
//can change above value in live-coding, 10-500 works well | ||
|
||
var sim = altspace.utilities.Simulation(); | ||
var config = { authorId: 'AltspaceVR', appId: 'SpinningCube' }; | ||
var sceneSync; | ||
|
||
altspace.utilities.sync.connect(config).then(function(connection) { | ||
sceneSync = altspace.utilities.behaviors.SceneSync(connection.instance, { | ||
instantiators: {'Cube': createCube }, | ||
ready: ready | ||
}); | ||
sim.scene.addBehavior(sceneSync); | ||
}); | ||
|
||
function createCube() { | ||
var geometry = new THREE.BoxGeometry(1, 1, 1); | ||
var material = new THREE.MeshBasicMaterial({color:'#ffffff'}); | ||
var cube = new THREE.Mesh(geometry, material); | ||
cube.scale.multiplyScalar(CUBE_SCALE); | ||
cube.addBehaviors( | ||
altspace.utilities.behaviors.Object3DSync(), | ||
altspace.utilities.behaviors.Spin({speed: 0.0005}), | ||
ChangeColor() | ||
); | ||
sim.scene.add(cube); | ||
return cube; | ||
} | ||
|
||
function ready(firstInstance) { | ||
if (firstInstance) { | ||
sceneSync.instantiate('Cube'); | ||
} | ||
} | ||
|
||
function ChangeColor() {//define a custom behavior | ||
var object3d; | ||
var lastColor; | ||
var colorRef; | ||
function awake(o) { | ||
object3d = o; | ||
var sync = object3d.getBehaviorByType('Object3DSync');//TODO: better way of doing this | ||
colorRef = sync.dataRef.child('color'); | ||
colorRef.on('value', function (snapshot) { | ||
var value = snapshot.val(); | ||
if (!value) return; //we are first to create the cube, no color set yet | ||
object3d.material.color = new THREE.Color(value); | ||
object3d.material.needsUpdate = true;//currently required in Altspace | ||
}); | ||
object3d.addEventListener('cursordown', function() { | ||
var color = Please.make_color()[0];//random color | ||
colorRef.set(color); | ||
}); | ||
} | ||
function update(deltaTime) { | ||
/* no updating needed, color changes in Firebase 'value' callback above */ | ||
} | ||
return { awake: awake, update: update }; | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
entry: [ | ||
'./src/index.js' | ||
], | ||
output: { | ||
path: __dirname, | ||
publicPath: '/', | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
loaders: ['babel'] | ||
}, { | ||
test: /\.css$/, | ||
loader: 'style!css' | ||
} | ||
]}, | ||
resolve: { | ||
extensions: ['', '.js', '.jsx', '.css'] | ||
}, | ||
devServer: { | ||
historyApiFallback: true, | ||
contentBase: './' | ||
} | ||
} |