Permalink
Browse files

imported demo from tquery repo

  • Loading branch information...
1 parent f1f9d41 commit 692318435b01b662f49d44bfebf07ce729d11c37 @jeromeetienne committed Mar 18, 2013
Showing 347 changed files with 166,996 additions and 2 deletions.
View
@@ -0,0 +1,10 @@
+# makefile to automatize simple operations
+
+server:
+ python -m SimpleHTTPServer
+
+deploy:
+ # assume there is something to commit
+ # use "git diff --exit-code HEAD" to know if there is something to commit
+ # so two lines: one if no commit, one if something to commit
+ git commit -a -m "New deploy" && git push -f origin HEAD:gh-pages && git reset HEAD~
View
@@ -1,4 +1,4 @@
-webglmeeting2
-=============
+webglmeeting
+============
WebGL Meeting - Chat with friends in 3D
View
@@ -0,0 +1,170 @@
+<!doctype html><title>WebGL Video Chat</title>
+<script src="vendor/tquery/build/tquery-bundle-require.js"></script>
+<body><script>
+requirejs.config({
+ paths : {
+ 'build' : 'vendor/tquery/build',
+ 'plugins' : 'vendor/tquery/plugins',
+ 'threex' : 'vendor/tquery/vendor/threex',
+ 'three.js' : 'vendor/tquery/vendor/three.js',
+ },
+});
+require([ 'tquery.loaders'
+ , 'tquery.checkerboard'
+ , 'tquery.pproc'
+ , 'tquery.fog'
+ , 'tquery.shadowmap'
+ , 'tquery.videos'
+ , 'tquery.webrtcio'
+], function(){
+ var world = tQuery.createWorld().boilerplate().start();
+
+ world.shadowMapEnabled(true)
+ world.tCamera().position.y = 0.75
+ world.tCamera().position.y = 0.3
+ world.tCamera().position.z = 1.5
+ //world.tCamera().position.z = 5
+
+ var target = world.scene().position().clone().add(tQuery.createVector3(0,0,-1))
+ //var target = world.scene().position().clone().add(tQuery.createVector3(0,0.25,-0.5))
+ world.tCamera().lookAt(target);
+
+ world.removeCameraControls();
+
+ world.tRenderer().setClearColorHex( 0x000000, 1 );
+
+ // add the fog
+ world.addFogExp2({density: 0.15});
+
+ //////////////////////////////////////////////////////////////////////////////////
+ // add ground //
+ //////////////////////////////////////////////////////////////////////////////////
+
+ tQuery.createCheckerboard({
+ segmentsW : 60,
+ segmentsH : 60
+ }).addTo(world)
+ .scaleBy(20)
+ .receiveShadow(true);
+
+ //////////////////////////////////////////////////////////////////////////////////
+ // add some lights //
+ //////////////////////////////////////////////////////////////////////////////////
+
+ tQuery.createAmbientLight().addTo(world)
+ .color(0x444444)
+ tQuery.createDirectionalLight().addTo(world)
+ .position(4,2,4)
+ .color(0xcccccc)
+ .castShadow(true)
+ .shadowDarkness(0.8)
+ .shadowMap(512*2,512*2)
+ .shadowCamera(3, -3, 3, -3, 0.1, 30)
+ //.shadowCameraVisible(true)
+
+ //////////////////////////////////////////////////////////////////////////////////
+ // load the model //
+ //////////////////////////////////////////////////////////////////////////////////
+
+ var loader = new THREE.ColladaLoader();
+ var tvSetModel = null;
+ loader.options.convertUpAxis = true;
+ var modelUrl = 'models/OldTelevisionSet01/models/Old Television Set 01.dae';
+ loader.load(modelUrl, function(collada){
+ tvSetModel = tQuery(collada.scene);
+ // set castShadow
+ tQuery('mesh', tvSetModel).castShadow(true)
+ // notify everybody
+ onModelLoaded();
+ });
+
+
+ //////////////////////////////////////////////////////////////////////////////////
+ // comment //
+ //////////////////////////////////////////////////////////////////////////////////
+
+
+ var room = 'public';
+ var serverUrl = "ws://localhost:8080/";
+
+ function onModelLoaded(){
+ // connect the server
+ rtc.connect(serverUrl, room);
+ // honot nostream
+ var nostream = window.location.hash === '#nostream'
+ if( nostream ) return;
+ // create a local stream
+ rtc.createStream({'video': true, 'audio': true}, function(mediaStream){
+ console.log('created stream', arguments)
+ createScreen(mediaStream)
+ reflowScreens();
+ }, function(){
+ console.log('createStream failed', arguments)
+ });
+ }
+
+ rtc.on('connect', function(){
+ console.log('connected to server', serverUrl)
+ })
+
+ rtc.on('connections', function(connections){
+ console.log('received connections event', connections)
+ })
+
+ rtc.on('add remote stream', function(mediaStream, socketId) {
+ createScreen(mediaStream)
+ .addClass('socketId-'+socketId)
+ reflowScreens();
+ });
+
+ rtc.on('disconnect stream', function(socketId) {
+ var nRemote = tQuery('.socketId-'+socketId).length;
+ console.log('remove',socketId,'currently', nRemote);
+ // TODO related to 'destroy' event
+ //tQuery('.socketId-'+socketId).destroy();
+ });
+
+ /**
+ * adapt screens layout depending on their numbers
+ */
+ function reflowScreens(){
+ var screens = tQuery('.screen');
+ var offsetX = -(screens.length - 1)/2
+ var width = 0.7
+ screens.each(function(tObject3D, idx){
+ tObject3D.position.x = width * (idx + offsetX);
+ })
+ }
+ /**
+ * create a 3d screen for a mediaStream
+ * @param {[type]} mediaStream [description]
+ * @return {tQuery.Mesh} the created tQuery.Mesh
+ */
+ function createScreen(mediaStream){
+ var container = tQuery.createObject3D().addTo(world)
+ .addClass('screen')
+
+ tvSetModel.clone().addTo(container)
+ .positionY(-0.4)
+ .addClass('tvSet')
+
+ var url = URL.createObjectURL(mediaStream);
+ var texture = tQuery.createVideoTexture(url);
+ tQuery.createPlane().addTo(container)
+ .addClass('plane')
+ .setBasicMaterial()
+ .map(texture)
+ .back()
+ .positionY(0.5).positionY(0.31).positionZ(0.16)
+ .scaleX(1/2.2).scaleY(1/2.85)
+
+ // // FIXME this event isnt really triggered
+ // // TODO code that in tQuery.Node
+ // screen.addEventListener('destroy', function(){
+ // screen.detach();
+ // texture.poorlyCodedClose();
+ // })
+ return container;
+ }
+});
+</script></body>
@@ -0,0 +1,58 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<kml xmlns='http://earth.google.com/kml/2.1'>
+<Folder>
+ <name>Old Television Set 01</name>
+ <description><![CDATA[Created with <a href="http://sketchup.google.com/">Google SketchUp 7.0.8657</a>]]></description>
+ <DocumentSource>SketchUp</DocumentSource>
+<visibility>1</visibility>
+<LookAt>
+<heading>29.5425</heading>
+<tilt>69.5454</tilt>
+<latitude>53.48298719662231</latitude>
+<longitude>-2.250012226700597</longitude>
+<range>2.834899368965995</range>
+<altitude>1.034892153507135</altitude>
+</LookAt>
+<Folder>
+<name>Tour</name>
+<Placemark>
+<name><![CDATA[Camera]]></name>
+<visibility>1</visibility>
+<LookAt>
+<heading>29.5425</heading>
+<tilt>69.5454</tilt>
+<latitude>53.48298719662231</latitude>
+<longitude>-2.250012226700597</longitude>
+<range>2.834899368965995</range>
+<altitude>1.034892153507135</altitude>
+</LookAt>
+</Placemark>
+</Folder>
+ <Placemark>
+ <name>Model</name>
+ <description><![CDATA[A 1950s television set. By IDW]]></description>
+ <Style id='default'>
+ </Style>
+ <Model>
+ <altitudeMode>relativeToGround</altitudeMode>
+ <Location>
+ <longitude>-2.250000000000</longitude>
+ <latitude>53.483000000000</latitude>
+ <altitude>0.000000000000</altitude>
+ </Location>
+ <Orientation>
+ <heading>0</heading>
+ <tilt>0</tilt>
+ <roll>0</roll>
+ </Orientation>
+ <Scale>
+ <x>1.0</x>
+ <y>1.0</y>
+ <z>1.0</z>
+ </Scale>
+ <Link>
+ <href>models/Old Television Set 01.dae</href>
+ </Link>
+ </Model>
+ </Placemark></Folder>
+</kml>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 6923184

Please sign in to comment.