Permalink
Browse files

Update

  • Loading branch information...
Etienne
Etienne committed Jun 4, 2017
1 parent 8ef62a7 commit 95a547256102baeb6659320849847ac693c08aac
Showing with 2,656 additions and 96 deletions.
  1. +27 −19 Makefile
  2. +12 −2 README.md
  3. +5 −0 extras/templates/Project/app.js
  4. +25 −0 extras/templates/Project/index.html
  5. +64 −26 gulpfile.coffee
  6. +78 −0 hologram/Animation.coffee
  7. +57 −0 hologram/Assets.coffee
  8. +138 −0 hologram/BaseClass.coffee
  9. +17 −0 hologram/Box.coffee
  10. +17 −0 hologram/Camera.coffee
  11. +14 −0 hologram/Circle.coffee
  12. +11 −0 hologram/ColladaModel.coffee
  13. +17 −0 hologram/Cone.coffee
  14. +52 −0 hologram/Config.coffee
  15. +337 −0 hologram/Context.coffee
  16. +103 −0 hologram/Cursor.coffee
  17. +16 −0 hologram/CurvedImage.coffee
  18. +17 −0 hologram/Cylinder.coffee
  19. +53 −0 hologram/DOMEventManager.coffee
  20. +15 −0 hologram/Dodecahedron.coffee
  21. +260 −0 hologram/Entity.coffee
  22. +32 −0 hologram/Event.coffee
  23. +68 −0 hologram/EventBuffer.coffee
  24. +24 −0 hologram/EventEmitter.coffee
  25. +11 −0 hologram/GltfModel.coffee
  26. +58 −0 hologram/GradientSky.coffee
  27. +37 −0 hologram/HandControls.coffee
  28. +67 −0 hologram/Hologram.coffee
  29. +11 −0 hologram/Icosahedron.coffee
  30. +14 −0 hologram/Image.coffee
  31. +46 −0 hologram/Light.coffee
  32. +28 −0 hologram/ObjectModel.coffee
  33. +11 −0 hologram/Octahedron.coffee
  34. +14 −0 hologram/Plane.coffee
  35. +1 −9 hologram/Print.coffee
  36. +16 −0 hologram/Ring.coffee
  37. +42 −0 hologram/Scene.coffee
  38. +26 −0 hologram/Sky.coffee
  39. +27 −0 hologram/Sound.coffee
  40. +17 −0 hologram/Sphere.coffee
  41. +11 −0 hologram/Tetrahedron.coffee
  42. +28 −0 hologram/Text.coffee
  43. +14 −0 hologram/Torus.coffee
  44. +14 −0 hologram/TorusKnot.coffee
  45. +0 −11 hologram/Utils.coffee
  46. +221 −0 hologram/Values.coffee
  47. +15 −0 hologram/Video.coffee
  48. +17 −0 hologram/VideoSphere.coffee
  49. +9 −3 package.json
  50. +2 −2 scripts/dist.sh
  51. 0 scripts/site_builder.coffee
  52. 0 scripts/site_builder.sh
  53. +5 −0 test/default/app.js
  54. +25 −0 test/default/index.html
  55. +409 −0 vendors/aframe.js
  56. +1 −0 vendors/aframe_gif_shader.js
  57. +0 −24 wercker.yml
View
@@ -1,49 +1,57 @@
# Configuration
# Config
BIN = $(CURDIR)/node_modules/.bin
.PHONY: watch test debug release
.PHONY: bootstrap unbootstrap clean watch build debug lint release
default: lazy_bootstrap lazy_build test
default: build
# Utilities
#-------------------------------------------------------
# Utils
bootstrap:
npm install
lazy_bootstrap: ; @test -d ./node_modules || make bootstrap
unbootstrap:
rm -Rf node_modules
clean:
clean: clearvendors
rm -rf build
rm -Rf node_modules
clearvendors: SHELL:=/bin/bash
clearvendors:
bash -c "rm -R ./vendors"
# Building and testing
build: lazy_bootstrap
$(BIN)/gulp webpack:debug
#-------------------------------------------------------
# Build
lazy_build: ; @test -f ./build/hologram.debug.js || make build
vendors: clearvendors
$(BIN)/gulp vendors
test: lazy_build
$(BIN)/gulp test
build: bootstrap vendors
$(BIN)/gulp webpack:debug
lint: lazy_build
lint: build
$(BIN)/gulp lint
release: lazy_bootstrap
release: bootstrap vendors
$(BIN)/gulp webpack:release
# Distribution
watch: bootstrap vendors
$(BIN)/gulp watch
dev: bootstrap vendors
$(BIN)/gulp webpack:dev-server
#-------------------------------------------------------
# Dist
dist: release
scripts/dist.sh
site-build: dist
predeploy: dist
scripts/site_builder.sh
site-upload: bootstrap site-build
deploy: predeploy
$(BIN)/coffee scripts/site_builder.coffee upload
View
@@ -6,16 +6,26 @@ Beyond Wonderland.
# Documentation
[Documentation](https://hologram.cool/docs)
[Twitter](https://twitter.com/etiennepinchon)
# Contribute
###### Building
- Download or fork the repository
- Make sure you have the latest version of node and npm installed
- Run `make dist` to build the latest version
- Run `make` to rebuild the latest version on changes
###### Reporting Issues
- Please use the issue tracker
- Try to include an example and clearly describe expected behaviour
# Others
- [Twitter](https://twitter.com/hologram_cool) — Follow us for updates & the latest work
- [Latest builds](http://builds.hologram.cool/) — The latest builds of Hologram.js
- [The Newsletter](https://hologram.cool/newsletter/) — Get the best work & latest news in your inbox
# About
Created by Etienne Pinchon (@etiennepinchon)
[Twitter](https://twitter.com/etiennepinchon)
@@ -0,0 +1,5 @@
// Welcome to Hologram
// This is just demo code. Feel free to delete it all.
console.log("hello!");
@@ -0,0 +1,25 @@
<html>
<head>
<meta charset="utf-8">
<style type="text/css" media="screen">
* {
margin:0;
padding:0;
border:none;
-webkit-user-select:none;
}
body {
background: black;
color: #FFF;
overflow: hidden;
}
a {
color: #bfbfbf;
}
</style>
</head>
<body>
<script src="hologram/hologram.js"></script>
<script src="app.js"></script>
</body>
</html>
View
@@ -1,45 +1,39 @@
_ = require("lodash")
async = require("async")
gulp = require("gulp")
phantomjs = require("gulp-mocha-phantomjs")
webpack = require("webpack")
rename = require("gulp-rename")
template = require("gulp-template")
gutil = require("gulp-util")
{exec} = require("child_process")
coffeelint = require('gulp-coffeelint')
#-------------------------------------------------------------------------------
#-------------------------------------------------------
# Base webpack config
WEBPACK =
entry: "./hologram/Hologram.coffee"
module:
loaders: [{test: /\.coffee$/, loader: "coffee-loader"}]
loaders: [
{test: /\.coffee$/, loader: "coffee-loader"}
]
resolve:
extensions: ["", ".web.coffee", ".web.js", ".coffee", ".js"]
devtool: "sourcemap"
cache: true
quiet: true
#-------------------------------------------------------------------------------
#-------------------------------------------------------
# Gulp tasks
gulp.task "watch", ["test"], ->
gulp.watch(["./*.coffee", "hologram/**", "test/tests/**", "!Version.coffee"], ["test"])
gulp.task "vendors", ->
importVendors()
gulp.task "test", ["webpack:tests", "lint"], ->
return gulp
.src("test/phantomjs/index.html")
.pipe(phantomjs({
reporter: "dot",
viewportSize: {width: 1024, height: 768},
useColors: true,
loadImages: false
}))
gulp.task "watch", ["webpack:debug"], ->
gulp.watch(["./*.coffee", "hologram/**", "!Version.coffee"], ["webpack:debug"])
gulp.task 'lint', ->
gulp.src(["./hologram/**/*.coffee", "!./hologram/Version.coffee.template", "./test/tests/**", "./test/tests.coffee", "./gulpfile.coffee", "scripts/site.coffee"])
gulp.src(["./hologram/**/*.coffee", "!./hologram/Version.coffee.template", "./gulpfile.coffee", "scripts/site_builder.coffee"])
.pipe(coffeelint())
.pipe(coffeelint.reporter())
@@ -64,9 +58,18 @@ gulp.task "version", (callback) ->
callback(null, task)
################################################################################
#-------------------------------------------------------
# Webpack tasks
gulp.task "webpack:debug", ["version"], (callback) ->
config = _.extend WEBPACK,
debug: true
output:
filename: "build/hologram.debug.js"
sourceMapFilename: "[file].map?hash=[hash]"
webpackDev("webpack:debug", config, callback)
gulp.task "webpack:release", ["version"], (callback) ->
config = _.extend WEBPACK,
@@ -84,18 +87,25 @@ gulp.task "webpack:release", ["version"], (callback) ->
webpackDev("webpack:release", config, callback)
gulp.task "webpack:tests", ["webpack:debug"], (callback) ->
gulp.task 'webpack:dev-server', (callback) ->
config = _.extend WEBPACK,
entry: "./test/tests.coffee"
debug: true
output:
filename: "test/phantomjs/tests.js"
debug: true
webpackDev("webpack:tests", config, callback)
################################################################################
path: __dirname+'/test/default'
filename: "test/default/hologram.debug.js"
sourceMapFilename: "[file].map?hash=[hash]"
# Start a webpack-dev-server
new webpackDevServer(webpack(_.clone(config)),
publicPath: __dirname+'/test/default/'
stats: colors: true).listen 8080, 'localhost', (err) ->
if err
throw new (gutil.PluginError)('webpack-dev-server', err)
log 'webpack-dev-server', 'http://localhost:8080/webpack-dev-server'
return
#-------------------------------------------------------
# Utils
log = (task, args...) ->
@@ -125,3 +135,31 @@ versionInfo = (callback) ->
hash: results[1]
build: results[2]
date: Math.floor(Date.now() / 1000)
importVendors = ->
http = require 'https'
fs = require 'fs'
replaceStream = require 'replacestream'
vendors = [
name: 'aframe'
path: 'https://aframe.io/releases/0.5.0/aframe.min.js'
,
name: 'aframe_gif_shader'
path: 'https://rawgit.com/mayognaise/aframe-gif-shader/master/dist/aframe-gif-shader.min.js'
]
dir = './vendors'
if not fs.existsSync(dir)
fs.mkdirSync(dir)
vendors.map (vendor) ->
file_path = dir+"/#{vendor.name}.js"
if not fs.existsSync(file_path)
log "vendors", gutil.colors.green("Fetching #{vendor.path}")
file = fs.createWriteStream(file_path)
request = http.get(vendor.path, (response) ->
response
.pipe(replaceStream('new Image;', 'new _Image;'))
.pipe file
return
)
View
@@ -0,0 +1,78 @@
{Entity} = require "./Entity"
class _AnimationItem extends Entity
_kind : 'Animation'
_elementType : 'a-animation'
@_d 'dur', 1000 # duration
@_d 'delay', 0
@_d 'easing', 'ease'
@_d 'repeat', 0
@_d 'direction', 'normal'
@_d 'attribute', undefined
@_d 'fill', 'forwards'
@_d 'to', undefined # end value
class exports.Animation extends Element
_kind : 'Animation'
_elementType : 'a-animation'
time : 1
delay : 0
repeat : 0
curve : 'ease'
direction : 'normal'
entity : undefined
properties : {}
_animationItems : []
constructor: (options={}) ->
super
# Retrieve properties to animate
excluded = ['time', 'delay', 'repeat', 'curve', 'direction', 'fill', 'entity']
for item of options
if excluded.indexOf(item) is -1
@properties[item] = options[item]
else
@[item] = options[item]
if options.entity
@entity = options.entity
return
start : ->
@_animationItems = []
for property of @properties
animationItem = new _AnimationItem
attribute: property
to: @properties[property]
if @time isnt 1
animationItem.dur = @time*1000
if @delay isnt 0
animationItem.delay = @delay*1000
if @repeat isnt 0
animationItem.repeat = @repeat
if @curve isnt 'ease'
animationItem.easing = @curve.replace(/([A-Z])/g, "-$1").toLowerCase()
if @direction isnt 'normal'
animationItem.direction = @direction
if @fill isnt 'forwards'
animationItem.fill = @fill
@_animationItems.push animationItem
if @entity
animationItem.parent = @entity
stop : ->
for item in @_animationItems
item.parent = null
#-------------------------------------------------------
# PROPERTIES
#-------------------------------------------------------
# METHODS
onLoad : (callback)-> @on Events.Load, cb
Oops, something went wrong.

0 comments on commit 95a5472

Please sign in to comment.