123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400 |
- this.simpleBodyDef = {
- "extends": "http://vwf.example.com/aframe/abox.vwf",
- "properties": {
- "position": "0 0.66 0.7",
- "height": 1.3,
- "width": 0.65,
- "depth": 0.1,
- },
- "children": {
- "material": {
- "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
- "type": "component",
- "properties":{
- "color": "white"
- }
- }
- }
- }
- this.modelBodyDef = {
- "extends": "http://vwf.example.com/aframe/agltfmodel.vwf",
- "properties": {
- "src": "#avatar",
- "position": "0 0 0.8",
- "rotation": "0 180 0"
- },
- "children": {
- "animation-mixer": {
- "extends": "http://vwf.example.com/aframe/anim-mixer-component.vwf",
- "properties": {
- "clip": "*",
- "duration": 1
- }
- }
- }
- }
- this.createAvatarBody = function (modelSrc) {
- var userHeight = 0;
-
-
-
- let myColor = this.getRandomColor();
- let myBodyDef = this.simpleBodyDef;
-
- myBodyDef.children.material.properties.color = myColor;
- var newNode = {
- "extends": "http://vwf.example.com/aframe/aentity.vwf",
- "properties": {
- "position": [0, userHeight, 0]
- },
- children: {
-
- "myBody": myBodyDef,
-
- "myHead": {
- "extends": "http://vwf.example.com/aframe/aentity.vwf",
- "properties": {
- "position": "0 1.6 0.7",
- "visible": true
- },
- children: {
- "interpolation":
- {
- "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
- "type": "component",
- "properties": {
- "enabled": true
- }
- },
- "visual": {
- "extends": "http://vwf.example.com/aframe/abox.vwf",
- "properties": {
- "height": 0.5,
- "width": 0.5,
- "depth": 0.1,
- "visible": true
- },
- "children": {
- "material": {
- "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
- "type": "component",
- "properties":{
- "color": myColor
- }
- }
- }
- },
-
- "myCamera":
- {
- "id": 'camera-' + this.id,
- "extends": "http://vwf.example.com/aframe/acamera.vwf",
- "properties": {
- "position": "0 0 -0.7",
- "look-controls-enabled": false,
- "wasd-controls-enabled": false,
- "user-height": 0
- }
- },
- "myCursor":
- {
- "id": 'myCursor-' + this.id,
- "extends": "http://vwf.example.com/aframe/aentity.vwf",
- "properties": {},
- "children": {
- "vis": {
- "extends": "http://vwf.example.com/aframe/abox.vwf",
- "properties": {
- "position": "0 0 -3",
- "height": 0.05,
- "width": 0.05,
- "depth": 0.01,
- "visible": true
- },
- "children": {
- "material": {
- "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
- "type": "component",
- "properties":{
- "color": myColor
- }
- }
- }
-
- },
- "line": {
- "extends": "http://vwf.example.com/aframe/lineComponent.vwf",
- "type": "component",
- "properties": {
- "start": "0 0 -1",
- "end": "0 0 -3",
- "color": myColor
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- "myRayCaster": {
- "extends": "http://vwf.example.com/aframe/aentity.vwf",
- "properties": {},
- "children": {
- "raycaster": {
- "extends": "http://vwf.example.com/aframe/raycasterComponent.vwf",
- "type": "component",
- "properties": {
- recursive: false,
- interval: 1000,
- far: 3,
- objects: ".intersectable"
- }
- }
- }
- },
-
-
-
-
-
- }
- }
- }
- },
- "myName": {
- "extends": "http://vwf.example.com/aframe/atext.vwf",
- "properties": {
- "color": myColor,
- "value": this.id,
- "side": "double",
- "rotation": "0 180 0",
- "position": "0.3 2.05 0.5"
- }
- }
- }
- }
- if (modelSrc) {
- let myBodyDef = this.modelBodyDef;
- myBodyDef.properties.src = modelSrc;
- newNode.children.myBody = myBodyDef;
- newNode.children.myHead.children.visual.properties.visible = false;
- newNode.children.myHead.children.myCursor.properties.visible = true;
- }
-
-
-
-
-
- let interpolation = {
- "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
- "type": "component",
- "properties": {
- "enabled": true
- }
- }
- this.children.create( "interpolation", interpolation );
-
-
-
- this.children.create("avatarNode", newNode);
-
-
-
-
-
-
-
-
- }
- this.getRandomColor = function () {
- var letters = '0123456789ABCDEF';
- var color = '#';
- for (var i = 0; i < 6; i++) {
- color += letters[Math.floor(this.random() * 16)];
- }
- return color;
- }
- this.followAvatarControl = function (position, rotation) {
-
-
- this.position = AFRAME.utils.coordinates.stringify(position);
- let myRot = AFRAME.utils.coordinates.parse(this.rotation);
- let myHeadRot = AFRAME.utils.coordinates.parse(this.avatarNode.myHead.rotation);
- let myBodyRot = AFRAME.utils.coordinates.parse(this.avatarNode.myBody.rotation);
- this.rotation = [myRot.x, rotation.y, myRot.z];
-
-
-
-
- this.avatarNode.myHead.rotation = [rotation.x, myHeadRot.y, rotation.z];
-
-
-
- }
- this.createSimpleAvatar = function(){
- if (this.avatarNode.myBody) {
- this.avatarNode.children.delete(this.avatarNode.myBody);
- var myColor = this.getRandomColor();
- if (this.avatarNode.myHead){
- myColor = this.avatarNode.myHead.visual.material.color;
- }
- let myBodyDef = this.simpleBodyDef;
- myBodyDef.material.color = myColor;
- this.avatarNode.children.create("myBody", myBodyDef);
- this.avatarNode.myHead.visual.properties.visible = true;
- }
- }
- this.createAvatarFromGLTF = function(modelSrc){
- if (this.avatarNode.myBody) {
- this.avatarNode.children.delete(this.avatarNode.myBody);
-
- let myBodyDef = this.modelBodyDef;
- myBodyDef.properties.src = modelSrc;
- this.avatarNode.children.create("myBody", myBodyDef);
- this.avatarNode.myHead.visual.properties.visible = false;
- this.avatarNode.myHead.myCursor.properties.visible = true;
- }
- }
- this.showHideCursor = function(bool){
- this.avatarNode.myHead.myCursor.properties.visible = bool;
- }
- this.showHideAvatar = function(bool){
- this.properties.visible = bool;
- }
- this.setBigVideoHead = function(val){
- this.avatarNode.myHead.visual.height = 4;
- this.avatarNode.myHead.visual.width = 3;
- this.avatarNode.myBody.visible = false;
- }
- this.setSmallVideoHead = function(val){
- this.avatarNode.myHead.visual.height = 0.5;
- this.avatarNode.myHead.visual.width = 0.5;
- this.avatarNode.myBody.visible = true;
- }
- this.setVideoTexture = function(val){
- console.log(val);
-
- this.avatarNode.myHead.visual.material.color = "white";
- this.avatarNode.myHead.visual.material.src = '#temp';
- this.avatarNode.myHead.visual.material.src = '#'+val;
- }
- this.removeVideoTexture = function(){
-
- this.avatarNode.myHead.visual.material.color = this.avatarNode.myBody.material.color;
- this.avatarNode.myHead.visual.material.src = "";
-
- }
- this.removeSoundWebRTC = function(){
- if (this.avatarNode.audio)
- this.avatarNode.children.delete(this.avatarNode.audio);
- }
- this.setSoundWebRTC = function(val){
- console.log(val);
- if (this.avatarNode.audio) this.removeSoundWebRTC();
- var soundNode = {
- "extends": "http://vwf.example.com/aframe/aentity.vwf",
- "properties": {
- },
- "children":{
- "streamsound":{
- "extends": "http://vwf.example.com/aframe/streamSoundComponent.vwf",
- "type": "component",
- "properties": {
- }
- }
- }
- }
- this.avatarNode.children.create("audio", soundNode );
-
-
-
- }
- this.webrtcTurnOnOff = function(val){
- console.log('WEBRTC is ', val);
- }
- this.webrtcMuteAudio = function(val){
- console.log('WEBRTC Audio is ', val);
- }
- this.webrtcMuteVideo = function(val){
- console.log('WEBRTC Video is ', val);
- }
- this.initialize = function() {
-
- };
|