janusweb 1.5.32 → 1.5.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG +39 -0
  2. package/media/assets/webui/apps/avatar/avatar.js +2 -1
  3. package/media/assets/webui/apps/buttons/buttons.html +2 -2
  4. package/media/assets/webui/apps/buttons/buttons.js +2 -2
  5. package/media/assets/webui/apps/comms/voip.js +2 -4
  6. package/media/assets/webui/apps/editor/codemirror/addon/hint/javascript-hint.js +162 -0
  7. package/media/assets/webui/apps/editor/codemirror/addon/hint/show-hint.css +36 -0
  8. package/media/assets/webui/apps/editor/codemirror/addon/hint/show-hint.js +529 -0
  9. package/media/assets/webui/apps/editor/codemirror/addon/hint/xml-hint.js +140 -0
  10. package/media/assets/webui/apps/editor/codemirror/keymap/vim.js +5734 -0
  11. package/media/assets/webui/apps/editor/codemirror/lib/codemirror.css +350 -0
  12. package/media/assets/webui/apps/editor/codemirror/lib/codemirror.js +9800 -0
  13. package/media/assets/webui/apps/editor/codemirror/lib/jmldark.css +33 -0
  14. package/media/assets/webui/apps/editor/codemirror/mode/css/css.js +864 -0
  15. package/media/assets/webui/apps/editor/codemirror/mode/htmlmixed/htmlmixed.js +153 -0
  16. package/media/assets/webui/apps/editor/codemirror/mode/javascript/javascript.js +942 -0
  17. package/media/assets/webui/apps/editor/codemirror/mode/xml/xml.js +413 -0
  18. package/media/assets/webui/apps/editor/editor.css +3 -0
  19. package/media/assets/webui/apps/editor/editor.js +407 -9
  20. package/media/assets/webui/apps/editor/editor.json +6 -3
  21. package/media/assets/webui/apps/inventory/inventory.js +2 -2
  22. package/media/assets/webui/apps/locomotion/teleporter.js +8 -7
  23. package/media/assets/webui/apps/navigation/navigation.js +12 -12
  24. package/media/assets/webui/apps/vfs/browserfs/browserfs.js +8 -0
  25. package/media/assets/webui/apps/vfs/vfs.css +52 -0
  26. package/media/assets/webui/apps/vfs/vfs.js +452 -0
  27. package/media/assets/webui/apps/vfs/vfs.json +10 -0
  28. package/media/assets/webui/default.json +2 -1
  29. package/media/assets/webui/themes/default.css +29 -2
  30. package/media/lib/physx/physx.release.js +21 -0
  31. package/media/lib/physx/physx.release.wasm +0 -0
  32. package/media/manifest.json +5 -5
  33. package/media/service-worker.js +7 -0
  34. package/package.json +2 -9
  35. package/scripts/client.js +65 -45
  36. package/scripts/config.js +2 -0
  37. package/scripts/elements/linesegments.js +5 -2
  38. package/scripts/image.js +7 -1
  39. package/scripts/janusbase.js +28 -11
  40. package/scripts/janusghost.js +4 -3
  41. package/scripts/janusparagraph.js +5 -3
  42. package/scripts/janusparticle.js +25 -14
  43. package/scripts/janusplayer.js +25 -10
  44. package/scripts/janusweb.js +22 -3
  45. package/scripts/janusxrplayer.js +4 -1
  46. package/scripts/multiplayermanager.js +3 -3
  47. package/scripts/object.js +172 -82
  48. package/scripts/portal.js +12 -10
  49. package/scripts/room.js +113 -54
  50. package/scripts/sound.js +0 -1
  51. package/scripts/text.js +10 -2
  52. package/scripts/translators/janusvfs.js +20 -0
  53. package/scripts/video.js +1 -1
  54. package/scripts/websurface.js +11 -2
  55. package/utils/build.sh +3 -0
  56. package/utils/init.sh +1 -1
package/scripts/client.js CHANGED
@@ -1,5 +1,4 @@
1
- elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient', 'engine.things.light_directional', 'engine.things.light_point', 'janusweb.janusweb', 'janusweb.chat', 'janusweb.janusplayer', 'janusweb.janusxrplayer', 'janusweb.external.document-register-element', 'janusweb.ui.main'], function() {
2
-
1
+ elation.require(['elements.elements', 'elements', 'engine.engine', 'engine.assets', 'engine.things.light_ambient', 'engine.things.light_directional', 'engine.things.light_point', 'janusweb.janusweb', 'janusweb.chat', 'janusweb.janusplayer', 'janusweb.janusxrplayer', 'janusweb.external.document-register-element', 'janusweb.ui.main', 'elements.elements'], function() {
3
2
  // If getCurrentScript returns non-null here, then it means we're in release mode
4
3
  var clientScript = elation.utils.getCurrentScript();
5
4
 
@@ -12,10 +11,10 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
12
11
  var homepage = elation.utils.any(args.homepage, elation.config.get('janusweb.homepage'), document.location.href);
13
12
  var corsproxy = elation.utils.any(args.corsproxy, elation.config.get('engine.assets.corsproxy'), document.location.href);
14
13
  var container = elation.utils.any(args.container, document.body);
15
- var fullsize = (container == document.body);
14
+ var fullsize = elation.utils.any(args.fullsize, container == document.body);
16
15
 
17
16
  if (elation.config.get('serviceworker.enabled') && 'serviceWorker' in navigator) {
18
- var workerscript = elation.config.get('serviceworker.script', 'serviceworker.js');
17
+ var workerscript = elation.config.get('serviceworker.script', 'service-worker.js');
19
18
  navigator.serviceWorker.register(workerscript)
20
19
  .then(function(reg) {
21
20
  // registration worked
@@ -58,7 +57,7 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
58
57
  document.head.appendChild(link);
59
58
  elation.html.addclass(document.body, 'dark');
60
59
  elation.html.addclass(document.body, 'janusweb');
61
- var janusweb = elation.janusweb.client({
60
+ var janusweb = elation.elements.create('janusweb.client', {
62
61
  append: container,
63
62
  homepage: homepage,
64
63
  corsproxy: corsproxy,
@@ -67,6 +66,7 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
67
66
  showchat: elation.utils.any(args.showchat, true),
68
67
  usevoip: elation.utils.any(args.usevoip, false),
69
68
  resolution: args.resolution,
69
+ fullsize: fullsize,
70
70
  url: args.url,
71
71
  networking: args.networking,
72
72
  autoload: args.autoload,
@@ -82,13 +82,31 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
82
82
  elation.events.add(janusweb.engine, 'engine_start', function() { resolve(janusweb); });
83
83
  });
84
84
  });
85
- elation.component.add('janusweb.client', function() {
86
- this.initEngine = function() {
85
+ elation.elements.define('janusweb.client', class extends elation.elements.engine.client {
86
+ init() {
87
+ super.init();
88
+ this.defineAttributes({
89
+ corsproxy: { type: 'string' },
90
+ homepage: { type: 'string' },
91
+ url: { type: 'string' },
92
+ uiconfig: { type: 'string' },
93
+ shownavigation: { type: 'boolean', default: true },
94
+ showchat: { type: 'boolean', default: true },
95
+ networking: { type: 'boolean', default: true },
96
+ usevoip: { type: 'boolean', default: false },
97
+ autoload: { type: 'boolean', default: true },
98
+ urltemplate: { type: 'string' },
99
+ server: { type: 'string' },
100
+ avatarsrc: { type: 'string' },
101
+ muted: { type: 'boolean', default: false },
102
+ });
103
+ }
104
+ initEngine() {
87
105
  this.initLoader();
88
106
 
89
107
  var hashargs = elation.url();
90
108
 
91
- this.enginecfg.stats = this.args.stats;
109
+ //this.enginecfg.stats = this.args.stats;
92
110
 
93
111
  this.enginecfg.systems = [];
94
112
  this.enginecfg.systems.push("controls");
@@ -102,7 +120,8 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
102
120
  this.enginecfg.systems.push("sound");
103
121
  this.enginecfg.crosshair = false;
104
122
  this.enginecfg.picking = true;
105
- this.enginecfg.useWebVRPolyfill = elation.utils.any(this.args.useWebVRPolyfill, true);
123
+ this.enginecfg.fullsize = this.fullsize && this.fullsize != 'false'; // FIXME - type coersion should be doing this
124
+ //this.enginecfg.useWebVRPolyfill = elation.utils.any(this.args.useWebVRPolyfill, true);
106
125
 
107
126
  if ('xr' in navigator) {
108
127
  navigator.xr.addEventListener('sessiongranted', (ev) => {
@@ -110,7 +129,7 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
110
129
  });
111
130
  }
112
131
  }
113
- this.initButtons = function() {
132
+ initButtons() {
114
133
  this.sharebutton = elation.ui.button({classname: 'janusweb_sharing', label: 'Share'});
115
134
  this.sharedialog = elation.engine.sharing({append: document.body, client: this, anchor: this.sharebutton});
116
135
  elation.events.add(this.sharebutton, 'ui_button_click', elation.bind(this.sharedialog, this.sharedialog.showShareDialog));
@@ -126,21 +145,21 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
126
145
 
127
146
  elation.events.add(document, 'pointerlockchange', elation.bind(this, function() { this.setUIActive(document.pointerLockElement === null); }));
128
147
  }
129
- this.initWorld = function() {
148
+ initWorld() {
130
149
  var things = this.world.load({
131
150
  name: 'janusweb',
132
151
  type: 'janusweb',
133
152
  properties: {
134
- corsproxy: elation.utils.any(this.args.corsproxy, elation.config.get('engine.assets.corsproxy')),
153
+ corsproxy: elation.utils.any(this.corsproxy, elation.config.get('engine.assets.corsproxy')),
135
154
  datapath: elation.config.get('janusweb.datapath'),
136
- homepage: this.args.homepage,
137
- url: this.args.url,
138
- showchat: this.args.showchat,
139
- networking: this.args.networking,
140
- autoload: this.args.autoload,
141
- urltemplate: this.args.urltemplate,
142
- server: this.args.server,
143
- muted: this.args.muted,
155
+ homepage: this.homepage,
156
+ url: this.url,
157
+ showchat: this.showchat,
158
+ networking: this.networking,
159
+ autoload: this.autoload,
160
+ //urltemplate: this.urltemplate,
161
+ server: this.server,
162
+ muted: this.muted,
144
163
  }
145
164
  });
146
165
  this.janusweb = things.children.janusweb;
@@ -151,22 +170,21 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
151
170
  height: 1.8,
152
171
  movespeed: 5000,
153
172
  collidable: true,
154
- usevoip: this.args.usevoip,
155
- avatarsrc: this.args.avatarsrc,
173
+ usevoip: this.usevoip,
174
+ avatarsrc: this.avatarsrc,
156
175
  staticfriction: 2,
157
176
  dynamicfriction: 1.9,
158
177
  });
159
178
  elation.events.add(this.engine.systems.render, 'render_view_add', (ev) => this.handleRenderViewAdd(ev));
160
179
 
161
- this.shownavigation = elation.utils.any(this.args.shownavigation, true);
162
180
  var datapath = elation.config.get('janusweb.datapath', '/media/janusweb');
163
- this.uiconfig = elation.utils.any(this.player.getSetting('uiconfig'), this.args.uiconfig, datapath + (datapath[datapath.length-1] != '/' ? '/' : '') + 'assets/webui/default.json');
181
+ this.uiconfig = elation.utils.any(this.player.getSetting('uiconfig'), this.uiconfig, datapath + (datapath[datapath.length-1] != '/' ? '/' : '') + 'assets/webui/default.json');
164
182
  if (this.shownavigation) {
165
183
  this.createUI();
166
184
  }
167
185
  this.view.pickingactive = true;
168
186
 
169
- let overlay = this.container.parentNode.querySelector('janus-overlay');
187
+ let overlay = this.parentNode.querySelector('janus-overlay');
170
188
  if (overlay) {
171
189
  this.overlay = overlay;
172
190
  }
@@ -174,16 +192,16 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
174
192
  elation.engine.assets.initTextureLoaders(this.engine.systems.render, elation.config.get('janusweb.datapath') + 'lib/basis/');
175
193
  elation.engine.assets.setDracoPath(elation.config.get('janusweb.datapath') + 'lib/draco/');
176
194
  }
177
- this.createUI = function() {
195
+ createUI() {
178
196
  if (!this.ui) {
179
197
  this.ui = elation.elements.create('janus.ui.main', {
180
- append: this.view,
198
+ append: this,
181
199
  client: this,
182
200
  config: this.uiconfig
183
201
  });
184
202
  }
185
203
  }
186
- this.initLoader = function() {
204
+ initLoader() {
187
205
  var loader = document.getElementsByClassName('engine_loading')[0];
188
206
  if (loader) {
189
207
  var logo = loader.getElementsByTagName('svg')[0];
@@ -197,12 +215,12 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
197
215
  elation.events.add(this.engine, 'engine_start', elation.bind(this, this.handleEngineStart));
198
216
  }
199
217
  }
200
- this.handleEngineStart = function(ev) {
218
+ handleEngineStart(ev) {
201
219
  if (this.loadingscreen) {
202
220
  this.loadingscreen.container.parentNode.removeChild(this.loadingscreen.container);
203
221
  }
204
222
  }
205
- this.handleEngineError = function(ev) {
223
+ handleEngineError(ev) {
206
224
  console.log('omg error!', ev);
207
225
  if (this.loadingscreen) {
208
226
  this.loadingscreen.label.innerHTML = 'Error!';
@@ -213,9 +231,9 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
213
231
  var errordiv = elation.html.create({tag: 'pre', append: this.loadingscreen.container, content: msg, classname: 'janusweb_error'});
214
232
  }
215
233
  }
216
- this.showMenu = function() {
234
+ showMenu() {
217
235
  }
218
- this.setUIActive = function(active) {
236
+ setUIActive(active) {
219
237
  if (active) {
220
238
  if (this.ui) this.ui.enable();
221
239
  if (this.buttons) this.buttons.enable();
@@ -224,12 +242,12 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
224
242
  if (this.buttons) this.buttons.disable();
225
243
  }
226
244
  }
227
- this.showAbout = function() {
245
+ showAbout() {
228
246
  var aboutwin = elation.ui.window({append: document.body, center: true, title: 'About JanusWeb'});
229
247
  var frame = elation.ui.iframe({src: 'http://github.com/jbaicoianu/janusweb/', classname: 'janusweb_about'});
230
248
  aboutwin.setcontent(frame);
231
249
  }
232
- this.toggleFullscreen = function(ev, updateOnly) {
250
+ toggleFullscreen(ev, updateOnly) {
233
251
  var view = this.view;
234
252
  if (!updateOnly && view && (typeof ev == 'undefined' || ev.value == 1 || typeof ev.value == 'undefined')) {
235
253
  view.toggleFullscreen();
@@ -244,7 +262,7 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
244
262
  }
245
263
  }
246
264
  }
247
- this.configureOptions = function() {
265
+ configureOptions() {
248
266
  if (!this.configmenu) {
249
267
  var configpanel = elation.janusweb.configuration({client: this});
250
268
  this.configmenu = elation.ui.window({
@@ -261,10 +279,10 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
261
279
  }
262
280
  this.configmenu.show();
263
281
  }
264
- this.registerElement = function(tagname, classobj, extendclass) {
282
+ registerElement(tagname, classobj, extendclass) {
265
283
  this.janusweb.registerElement(tagname, classobj, extendclass);
266
284
  }
267
- this.handleRenderViewAdd = function(ev) {
285
+ handleRenderViewAdd(ev) {
268
286
  let view = ev.data;
269
287
  if (view.xrsession && !this.xrplayer) {
270
288
  this.xrplayer = this.player.createObject('xrplayer', {
@@ -273,14 +291,14 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
273
291
  });
274
292
  }
275
293
  }
276
- }, elation.engine.client);
294
+ });
277
295
 
278
296
  if (typeof customElements != 'undefined') {
279
297
  elation.elements.define('janus.viewer', class extends elation.elements.base {
280
298
  init() {
281
299
  super.init();
282
300
  this.defineAttributes({
283
- fullscreen: { type: 'boolean', default: true },
301
+ fullsize: { type: 'boolean', default: true },
284
302
  autostart: { type: 'boolean', default: true },
285
303
  src: { type: 'string' },
286
304
  corsproxy: { type: 'string' },
@@ -305,11 +323,12 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
305
323
  }
306
324
  document.body.addEventListener('click', start);
307
325
  }
326
+ this.style.overflow = 'hidden';
308
327
  }
309
328
  getClientArgs() {
310
- var fullscreen = this.fullscreen,
311
- width = (this.fullscreen ? window.innerWidth : this.width),
312
- height = (this.fullscreen ? window.innerHeight : this.height);
329
+ var fullsize = this.fullsize,
330
+ width = (this.fullsize ? window.innerWidth : this.width),
331
+ height = (this.fullsize ? window.innerHeight : this.height);
313
332
  var args = {
314
333
  url: this.getRoomURL(),
315
334
  homepage: this.homepage || this.src,
@@ -321,6 +340,7 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
321
340
  avatarsrc: this.avatarsrc,
322
341
  uiconfig: this.uiconfig,
323
342
  container: this,
343
+ fullsize: this.fullsize,
324
344
  };
325
345
  return args;
326
346
  }
@@ -338,9 +358,9 @@ elation.require(['engine.engine', 'engine.assets', 'engine.things.light_ambient'
338
358
  create() {
339
359
  if (this.iframe) return;
340
360
  var iframe = document.createElement('iframe');
341
- var fullscreen = this.fullscreen;
342
- iframe.width = (this.fullscreen ? window.innerWidth : this.width);
343
- iframe.height = (this.fullscreen ? window.innerHeight : this.height);
361
+ var fullsize = this.fullsize;
362
+ iframe.width = (this.fullsize ? window.innerWidth : this.width);
363
+ iframe.height = (this.fullsize ? window.innerHeight : this.height);
344
364
  iframe.setAttribute('allowvr', 'yes');
345
365
  iframe.setAttribute('allowfullscreen', true);
346
366
  iframe.setAttribute('allow', 'vr');
package/scripts/config.js CHANGED
@@ -26,6 +26,8 @@ elation.config.set('share.targets.yahoo.clientid', '374523350201-p566ctvssq49sa4
26
26
  elation.config.set('share.targets.facebook.clientid', '1197654320349894');
27
27
  elation.config.set('share.targets.file.enabled', true);
28
28
 
29
+ elation.config.set('serviceworker.enabled', true);
30
+
29
31
  // FIXME - hack for dev, we should support role-based config
30
32
  if (typeof document != 'undefined' && document.location.origin == 'https://bai.dev.supcrit.com') {
31
33
  elation.config.set('share.imagebase', null);
@@ -6,6 +6,7 @@ elation.require(['janusweb.janusbase'], function() {
6
6
  linewidth: 1,
7
7
  depth_write: true,
8
8
  depth_test: true,
9
+ fog: true,
9
10
 
10
11
  create() {
11
12
 
@@ -33,16 +34,18 @@ elation.require(['janusweb.janusbase'], function() {
33
34
  let lineobj = new THREE.LineSegments(geo, new THREE.LineBasicMaterial({
34
35
  vertexColors: THREE.VertexColors,
35
36
  opacity: this.opacity,
36
- transparent: (this.opacity < 1),
37
+ transparent: (this.transparent !== null ? this.transparent : this.opacity < 1),
37
38
  depthWrite: this.depth_write,
38
39
  depthTest: this.depth_test,
39
40
  linewidth: this.linewidth,
41
+ fog: this.fog,
40
42
  }));
43
+ lineobj.renderOrder = this.renderorder;
41
44
  this.objects['3d'].add(lineobj);
42
45
  if (this.pickable || this.collidable) {
43
46
  //this.colliders.add(lineobj.clone());
44
47
  }
45
- lineobj.userData.thing = this;
48
+ lineobj.userData.thing = this._target || this;
46
49
  this.geometry = geo;
47
50
  this.lineobj = lineobj;
48
51
  }
package/scripts/image.js CHANGED
@@ -55,7 +55,7 @@ elation.require(['janusweb.janusbase'], function() {
55
55
  color: this.properties.color,
56
56
  transparent: (this.opacity < 1),
57
57
  opacity: this.opacity,
58
- alphaTest: 0.2
58
+ alphaTest: this.alphatest
59
59
  };
60
60
 
61
61
  this.asset = this.getAsset('image', this.image_id);
@@ -68,6 +68,9 @@ elation.require(['janusweb.janusbase'], function() {
68
68
  elation.events.add(this.texture, 'update', elation.bind(this, this.refresh));
69
69
 
70
70
  matargs.transparent = this.asset.hasalpha;
71
+ elation.events.add(this.asset, 'asset_load', ev => {
72
+ matargs.transparent = this.asset.hasalpha;
73
+ });
71
74
  }
72
75
  }
73
76
  if (this.texture) {
@@ -156,6 +159,9 @@ elation.require(['janusweb.janusbase'], function() {
156
159
  this.sidetex.image = this.texture.image;
157
160
  this.sidetex.needsUpdate = true;
158
161
 
162
+ this.frontmaterial.transparent = this.asset.hasalpha;
163
+ this.sidematerial.transparent = this.asset.hasalpha;
164
+
159
165
  if (this.properties.sbs3d || this.asset.sbs3d) {
160
166
  // TODO - to really support 3d video, we need to set offset based on which eye is being rendered
161
167
  var texture = new THREE.SBSTexture(this.texture.image);
@@ -19,6 +19,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
19
19
  js_id: { type: 'string' },
20
20
  color: { type: 'color', default: this.defaultcolor, set: this.updateColor, comment: 'Object color' },
21
21
  opacity: { type: 'float', default: 1.0, set: this.updateOpacity, min: 0, max: 1, comment: 'Object translucency, from 0..1' },
22
+ transparent: { type: 'bool', default: null, set: this.updateOpacity, comment: 'Override object transparency autodetection' },
22
23
  alphatest: { type: 'float', default: 0.05, set: this.updateAlphaTest, min: 0, max: 1 },
23
24
  fwd: { type: 'vector3', default: new THREE.Vector3(0,0,1), set: this.pushFrameUpdate, comment: 'Forward vector (zdir == fwd)' },
24
25
  xdir: { type: 'vector3', default: new THREE.Vector3(1,0,0), set: this.pushFrameUpdate, comment: 'Left vector' },
@@ -50,10 +51,12 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
50
51
  billboard: { type: 'string', default: '' },
51
52
  hasposition: { type: 'boolean', default: true },
52
53
  gazetime: { type: 'float' },
54
+ static: { type: 'boolean', default: false },
53
55
  ongazeenter: { type: 'callback' },
54
56
  ongazeleave: { type: 'callback' },
55
57
  ongazeprogress: { type: 'callback' },
56
58
  ongazeactivate: { type: 'callback' },
59
+ oncollision: { type: 'callback' },
57
60
  });
58
61
  this.lastframevalues = {
59
62
  position: new THREE.Vector3(0,0,0),
@@ -80,7 +83,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
80
83
  this.properties.orientation.copy(this.object.quaternion);
81
84
  return this.object;
82
85
  }
83
- if (this.renderorder) this.object.renderOrder = this.renderorder;
86
+ if (this.renderorder && this.object) this.object.renderOrder = this.renderorder;
84
87
  return new THREE.Object3D();
85
88
  }
86
89
  this.createChildren = function() {
@@ -120,7 +123,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
120
123
  this.refresh();
121
124
  }
122
125
  this.updateOpacity = function() {
123
- this.setOpacity(this.opacity);
126
+ this.setOpacity(this.opacity, this.transparent);
124
127
  },
125
128
  this.updateAlphaTest = function() {
126
129
  this.setAlphaTest(this.alphatest);
@@ -154,7 +157,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
154
157
  } else if (collision_id == 'cylinder') {
155
158
  this.setCollider('cylinder', {height: 1, radius: .5, offset: new THREE.Vector3(0, 0.5, 0), trigger: this.collision_trigger});
156
159
  } else if (collision_id == 'capsule') {
157
- this.setCollider('capsule', {height: 1, radius: .5, offset: new THREE.Vector3(0, 0.5, 0), trigger: this.collision_trigger});
160
+ this.setCollider('capsule', {length: 1, radius: .5, offset: new THREE.Vector3(0, 0, 0), trigger: this.collision_trigger});
158
161
  } else {
159
162
  var colliderasset = this.getAsset('model', collision_id);
160
163
  if (colliderasset) {
@@ -206,8 +209,12 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
206
209
  //this.colliders.add(collider);
207
210
  processMeshCollider(collider);
208
211
  } else {
212
+ let meshColliderLoaded = false;
209
213
  elation.events.add(collider, 'asset_load', elation.bind(this, function(ev) {
210
- processMeshCollider(collider);
214
+ if (!meshColliderLoaded) {
215
+ processMeshCollider(collider);
216
+ }
217
+ meshColliderLoaded = true;
211
218
  }) );
212
219
  }
213
220
  }
@@ -224,7 +231,9 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
224
231
  }
225
232
  }
226
233
  this.createForces = function() {
227
- elation.events.add(this.objects.dynamics, 'physics_collide', elation.bind(this, this.handleCollision));
234
+ if (this.collidable && !this.collision_trigger) {
235
+ elation.events.add(this.objects.dynamics, 'physics_collide', elation.bind(this, this.handleCollision));
236
+ }
228
237
  this.updateRotationSpeed();
229
238
  }
230
239
  this.updateRotationSpeed = function() {
@@ -348,6 +357,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
348
357
  dynamicfriction:['property', 'dynamicfriction'],
349
358
  staticfriction:['property', 'staticfriction'],
350
359
  opacity: ['property', 'opacity'],
360
+ transparent: ['property', 'transparent'],
351
361
  alphatest: ['property', 'alphatest'],
352
362
  sync: ['property', 'sync'],
353
363
  autosync: ['property', 'autosync'],
@@ -712,7 +722,11 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
712
722
  }
713
723
  this.start = function() {
714
724
  if (!this.started) {
715
- elation.events.add(this.room, 'janusweb_script_frame_end', this.handleFrameUpdates);
725
+ if (!this.static) {
726
+ elation.events.add(this.room, 'janusweb_script_frame_end', this.handleFrameUpdates);
727
+ } else {
728
+ this.handleFrameUpdates({data: {dt: 0}});
729
+ }
716
730
  this.started = true;
717
731
  }
718
732
  for (var k in this.children) {
@@ -729,7 +743,9 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
729
743
  }
730
744
  }
731
745
  if (this.started) {
732
- elation.events.remove(this.room, 'janusweb_script_frame_end', this.handleFrameUpdates);
746
+ if (!this.static) {
747
+ elation.events.remove(this.room, 'janusweb_script_frame_end', this.handleFrameUpdates);
748
+ }
733
749
  this.started = false;
734
750
  this.dispatchEvent({type: 'stop', bubbles: false});
735
751
  }
@@ -978,15 +994,16 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
978
994
  }
979
995
  }
980
996
  }
981
- this.setOpacity = function(opacity) {
982
- if (this.objects['3d'] && this.currentopacity != opacity) {
997
+ this.setOpacity = function(opacity, transparent) {
998
+ if (this.objects['3d'] && (this.currentopacity != opacity || this.currenttransparent !== transparent)) {
983
999
  this.currentopacity = opacity;
984
- this.traverseObjects(function(n) {
1000
+ this.currenttransparent = transparent;
1001
+ this.traverseObjects((n) => {
985
1002
  if (n.material) {
986
1003
  var m = (elation.utils.isArray(n.material) ? n.material : [n.material]);
987
1004
  for (var i = 0; i < m.length; i++) {
988
1005
  m[i].opacity = opacity;
989
- m[i].transparent = (opacity < 1);
1006
+ m[i].transparent = (transparent !== null ? transparent : opacity < 1);
990
1007
  if (m[i].transparent) {
991
1008
  m[i].alphaTest = this.alphatest;
992
1009
  }
@@ -97,7 +97,6 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
97
97
  size: .1,
98
98
  thickness: .03,
99
99
  align: 'center',
100
- collidable: false,
101
100
  text: name,
102
101
  pos: this.userid_pos,
103
102
  pickable: false,
@@ -280,9 +279,10 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
280
279
  lighting: this.lighting,
281
280
  //cull_face: 'none'
282
281
  opacity: 0.9999,
283
- shader_chunk_replace: {
282
+ renderorder: this.renderorder || 100,
283
+ shader_chunk_replace: (this.lighting ? {
284
284
  'color_fragment': 'color_fragment_discard_close',
285
- },
285
+ } : {}),
286
286
  });
287
287
  } else {
288
288
  this.body = bodyid;
@@ -636,6 +636,7 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
636
636
  this.bone_head = ghostdef.bone_head;
637
637
  this.morphtarget_mouth = ghostdef.morphtarget_mouth;
638
638
  this.morphtarget_eyes = ghostdef.morphtarget_eyes;
639
+ this.lighting = elation.utils.any(ghostdef.lighting, true);
639
640
  if (ghostdef.morphtarget_eyes) {
640
641
  this.blink();
641
642
  }
@@ -13,7 +13,7 @@ elation.require(['janusweb.janusbase'], function() {
13
13
  depth_write: { type: 'boolean', default: true },
14
14
  depth_test: { type: 'boolean', default: true },
15
15
  collision_id: { type: 'string', default: 'cube' },
16
- collision_scale: { type: 'vector3', default: V(1, 1, .02) },
16
+ collision_scale: { type: 'vector3', default: V(.5, .5, .02) },
17
17
  shadow: { type: 'boolean', default: true, set: this.updateMaterial },
18
18
  shadow_receive: { type: 'boolean', default: true, set: this.updateMaterial, comment: 'Receive shadows from self and other objects' },
19
19
  shadow_cast: { type: 'boolean', default: true, set: this.updateMaterial, comment: 'Cast shadows onto self and other objects' },
@@ -29,8 +29,10 @@ elation.require(['janusweb.janusbase'], function() {
29
29
  return mesh;
30
30
  }
31
31
  this.createForces = function() {
32
- this.setCollider('box', { min: V(-1, -1, -.01), max: V(1, 1, .01) });
32
+ this.setCollider('box', { min: V(-.8, -.8, -.01), max: V(.8, .8, .01) });
33
+ //this.collision_id = 'cube';
33
34
  }
35
+ this.updateColliderFromGeometry = function() { }
34
36
  this.createMaterial = function() {
35
37
  var texture = this.createTexture();
36
38
  var sidemap = {
@@ -115,7 +117,7 @@ elation.require(['janusweb.janusbase'], function() {
115
117
  texture.needsUpdate = true;
116
118
  this.refresh();
117
119
  }
118
- }
120
+ };
119
121
  this.currentImage = img;
120
122
  img.src = url;
121
123
  this.refresh();
@@ -39,7 +39,6 @@ elation.require(['janusweb.janusbase'], function() {
39
39
  opacity: { type: 'float', default: 1.0, set: this.updateMaterial },
40
40
  fade_in: { type: 'float', default: 1.0 },
41
41
  fade_out: { type: 'float', default: 1.0 },
42
- duration: { type: 'float', default: 1.0 },
43
42
  particle_scale: { type: 'vector3', default: [1, 1, 1], set: this.updateMaterial},
44
43
  particle_vel: { type: 'vector3', default: [0, 0, 0]},
45
44
  particle_accel: { type: 'vector3', default: [0, 0, 0]},
@@ -52,8 +51,8 @@ elation.require(['janusweb.janusbase'], function() {
52
51
  refreshrate: { type: 'int', default: 30 },
53
52
  blend_src: { type: 'string', default: 'src_alpha', set: this.updateMaterial },
54
53
  blend_dest: { type: 'string', default: 'one_minus_src_alpha', set: this.updateMaterial },
55
- depthwrite: { type: 'bool', default: false },
56
- depthtest: { type: 'bool', default: true },
54
+ depth_write: { type: 'bool', default: false },
55
+ depth_test: { type: 'bool', default: true },
57
56
  });
58
57
  this.particles = [];
59
58
  this.emitted = 0;
@@ -67,11 +66,12 @@ elation.require(['janusweb.janusbase'], function() {
67
66
  this.collidable = false;
68
67
  this.boundingRadiusSq = 0;
69
68
  this.boundingSphereWorld = new THREE.Sphere();
69
+ this.furthestPoint = new THREE.Vector3();
70
70
  this.lastrefresh = 0;
71
71
  this.updateParticles = elation.bind(this, this.updateParticles); // FIXME - hack, this should happen at the lower level of all components
72
72
  }
73
73
  this.createObject3D = function() {
74
- var geo = this.geometry = new THREE.BufferGeometry()
74
+ var geo = this.geometry = new THREE.BufferGeometry();
75
75
 
76
76
  var texture = null,
77
77
  textureasset = null;
@@ -131,8 +131,8 @@ elation.require(['janusweb.janusbase'], function() {
131
131
  //blending: THREE.AdditiveBlending,
132
132
  transparent: true,
133
133
  alphaTest: .001,
134
- depthWrite: this.depthwrite,
135
- depthTest: this.depthtest,
134
+ depthWrite: this.depth_write,
135
+ depthTest: this.depth_test,
136
136
  } );
137
137
 
138
138
  this.material = mat;
@@ -289,8 +289,8 @@ elation.require(['janusweb.janusbase'], function() {
289
289
  elapsed = now - this.lasttime,
290
290
  endtime = now + this.duration * 1000,
291
291
  emitted = 0,
292
- startpoint = this.currentpoint;
293
- spawncount = this.rate * elapsed / 1000;
292
+ startpoint = this.currentpoint,
293
+ spawncount = this.rate * elapsed / 1000,
294
294
  count = this.count,
295
295
  loop = this.loop;
296
296
 
@@ -324,11 +324,19 @@ elation.require(['janusweb.janusbase'], function() {
324
324
  // We also rate limit here, so if nothing else in the scene is changing, we
325
325
  // render at a lower fps
326
326
  this.localToWorld(this.boundingSphereWorld.center.set(0,0,0));
327
- if (!this.objects['3d'].geometry.boundingSphere) {
328
- this.objects['3d'].geometry.computeBoundingSphere();
327
+ let geo = this.objects['3d'].geometry;
328
+ if (!geo.boundingSphere) {
329
+ geo.computeBoundingSphere();
330
+ } else {
331
+ let currentBoundingRadius = geo.boundingSphere.radius;
332
+ if (this.boundingRadiusSq > currentBoundingRadius * currentBoundingRadius) {
333
+ geo.boundingSphere.radius = Math.sqrt(this.boundingRadiusSq) + .1;
334
+ }
329
335
  }
330
- this.boundingSphereWorld.radius = this.objects['3d'].geometry.boundingSphere.radius;
336
+
337
+ this.boundingSphereWorld.radius = geo.boundingSphere.radius;
331
338
  if (player.viewfrustum.intersectsSphere(this.boundingSphereWorld) && now - this.lastrefresh > (1000 / this.refreshrate)) {
339
+
332
340
  this.refresh();
333
341
  this.lastrefresh = now;
334
342
  }
@@ -341,11 +349,14 @@ elation.require(['janusweb.janusbase'], function() {
341
349
  var lengthSq = vec.lengthSq();
342
350
  if (lengthSq > this.boundingRadiusSq) {
343
351
  this.boundingRadiusSq = lengthSq;
352
+ this.furthestPoint.copy(vec);
353
+ /*
344
354
  var geo = this.objects['3d'].geometry;
345
355
  if (!geo.boundingSphere) {
346
356
  geo.boundingSphere = new THREE.Sphere();
347
357
  }
348
358
  geo.boundingSphere.radius = Math.sqrt(lengthSq);
359
+ */
349
360
  }
350
361
  }
351
362
  }
@@ -396,7 +407,7 @@ elation.require(['janusweb.janusbase'], function() {
396
407
  var randomInRange = function(range) {
397
408
  //return (Math.random() - .5) * range;
398
409
  return Math.random() * range;
399
- }
410
+ };
400
411
  let pointpos = point.pos;
401
412
  pointpos.set(randomInRange(rand_pos.x), randomInRange(rand_pos.y), randomInRange(rand_pos.z));
402
413
  if (this.emitpoints) {
@@ -520,8 +531,8 @@ elation.require(['janusweb.janusbase'], function() {
520
531
  count: [ 'property', 'count'],
521
532
  duration: [ 'property', 'duration'],
522
533
  opacity: [ 'property', 'opacity'],
523
- depthwrite: [ 'property', 'depthwrite'],
524
- depthtest: [ 'property', 'depthtest'],
534
+ depth_write: [ 'property', 'depth_write'],
535
+ depth_test: [ 'property', 'depth_test'],
525
536
  play: [ 'function', 'start'],
526
537
  };
527
538
  }