elation-engine 0.9.121 → 0.9.123
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.
- package/package.json +1 -1
- package/scripts/assets.js +6 -1
- package/scripts/external/three/three-objects.js +7 -0
- package/scripts/external/three/three.js +1 -1
- package/scripts/systems/controls.js +1 -0
- package/scripts/systems/physics.js +2 -2
- package/scripts/systems/render.js +7 -1
- package/scripts/things/generic.js +18 -5
- package/scripts/things/player.js +11 -4
package/package.json
CHANGED
package/scripts/assets.js
CHANGED
|
@@ -80,11 +80,14 @@ elation.require(['utils.workerpool', 'engine.external.three.three', 'engine.exte
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
initTextureLoaders: function(rendersystem, libpath) {
|
|
83
|
+
this.rendersystem = rendersystem;
|
|
83
84
|
let renderer = rendersystem.renderer;
|
|
85
|
+
/*
|
|
84
86
|
let basisloader = new THREE.BasisTextureLoader();
|
|
85
87
|
basisloader.setTranscoderPath(libpath);
|
|
86
88
|
basisloader.detectSupport(renderer);
|
|
87
89
|
this.basisloader = basisloader;
|
|
90
|
+
*/
|
|
88
91
|
|
|
89
92
|
this.ktx2loader = new THREE.KTX2Loader();
|
|
90
93
|
this.ktx2loader.setTranscoderPath(libpath);
|
|
@@ -94,7 +97,6 @@ elation.require(['utils.workerpool', 'engine.external.three.three', 'engine.exte
|
|
|
94
97
|
pmremGenerator.compileEquirectangularShader();
|
|
95
98
|
this.pmremGenerator = pmremGenerator;
|
|
96
99
|
|
|
97
|
-
this.rendersystem = rendersystem;
|
|
98
100
|
},
|
|
99
101
|
loadAssetPack: function(url, baseurl) {
|
|
100
102
|
this.assetroot = new elation.engine.assets.pack({name: url, src: url, baseurl: baseurl});
|
|
@@ -1528,6 +1530,9 @@ console.log('set up hls', hlsConfig);
|
|
|
1528
1530
|
if (n.geometry && !n.geometry.attributes.normal) {
|
|
1529
1531
|
n.geometry.computeVertexNormals();
|
|
1530
1532
|
}
|
|
1533
|
+
if (n.name.match(/^mixamorig:/)) {
|
|
1534
|
+
n.name = n.name.replace('mixamorig:', '');
|
|
1535
|
+
}
|
|
1531
1536
|
});
|
|
1532
1537
|
|
|
1533
1538
|
if (modeldata.userData && modeldata.userData.gltfExtensions && modeldata.userData.gltfExtensions.VRM) {
|
|
@@ -739,6 +739,13 @@ console.log('skelly data', boneDatas);
|
|
|
739
739
|
|
|
740
740
|
//console.log('found a part to clone!', oldname, parts[0], src, dst, track.name);
|
|
741
741
|
found = true;
|
|
742
|
+
} else if (parts[0].indexOf(':') > -1) {
|
|
743
|
+
let parts2 = parts[0].split(':');
|
|
744
|
+
if (parts2[1] == src.name || parts[1] == src.uuid) {
|
|
745
|
+
parts[0] = dst.name || dst.uuid;
|
|
746
|
+
track.name = parts.join('.');
|
|
747
|
+
found = true;
|
|
748
|
+
}
|
|
742
749
|
}
|
|
743
750
|
});
|
|
744
751
|
if (!found) {
|
|
@@ -45194,7 +45194,7 @@
|
|
|
45194
45194
|
}
|
|
45195
45195
|
|
|
45196
45196
|
// Characters [].:/ are reserved for track binding syntax.
|
|
45197
|
-
const _RESERVED_CHARS_RE = '\\[\\]
|
|
45197
|
+
const _RESERVED_CHARS_RE = '\\[\\]\\.\\/';
|
|
45198
45198
|
const _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' );
|
|
45199
45199
|
|
|
45200
45200
|
// Attempts to allow node names from any language. ES5's `\w` regexp matches
|
|
@@ -810,6 +810,7 @@ elation.require(['ui.window', 'ui.panel', 'ui.toggle', 'ui.slider', 'ui.label',
|
|
|
810
810
|
this.state[bindid] = 0;
|
|
811
811
|
this.changes.push(bindid);
|
|
812
812
|
}, 10);
|
|
813
|
+
ev.preventDefault();
|
|
813
814
|
}
|
|
814
815
|
this.keydown = function(ev) {
|
|
815
816
|
// Send key events for both keyboard_<key> and keyboard_<modname>_<key>
|
|
@@ -21,13 +21,13 @@ elation.require(["physics.cyclone"], function() {
|
|
|
21
21
|
this.engine_start = function(ev) {
|
|
22
22
|
//console.log("PHYSICS: starting");
|
|
23
23
|
this.system.start({subprocessor: 'cpu', processorargs: { path: 'https://baicoianu.com/~bai/janusweb/build/1.5.32/media/lib/physx/'}});
|
|
24
|
-
this.lasttime =
|
|
24
|
+
this.lasttime = performance.now();
|
|
25
25
|
if (this.interval) {
|
|
26
26
|
clearInterval(this.interval);
|
|
27
27
|
}
|
|
28
28
|
if (this.async) {
|
|
29
29
|
this.interval = setInterval(elation.bind(this, function() {
|
|
30
|
-
var now =
|
|
30
|
+
var now = performance.now();
|
|
31
31
|
//this.system.step(this.timescale * (now - this.lasttime) / 1000);
|
|
32
32
|
//if (this.stats) this.stats.update();
|
|
33
33
|
this.step((now - this.lasttime) / 1000);
|
|
@@ -178,10 +178,13 @@ elation.require([
|
|
|
178
178
|
renderer.getViewport(oldviewport);
|
|
179
179
|
renderer.setViewport(viewport);
|
|
180
180
|
renderer.setRenderTarget(rendertarget);
|
|
181
|
+
let isXR = renderer.xr.enabled;
|
|
182
|
+
renderer.xr.enabled = false;
|
|
181
183
|
renderer.render(scene, camera);
|
|
182
184
|
renderer.readRenderTargetPixels(rendertarget, 0, 0, size, size, pixeldata);
|
|
183
185
|
renderer.setRenderTarget(oldrendertarget);
|
|
184
186
|
renderer.setViewport(oldviewport);
|
|
187
|
+
renderer.xr.enabled = isXR;
|
|
185
188
|
|
|
186
189
|
texture.encoding = oldencoding;
|
|
187
190
|
|
|
@@ -1476,7 +1479,10 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
|
|
|
1476
1479
|
img = resized.toDataURL('image/jpeg');
|
|
1477
1480
|
} else if (format == 'png') {
|
|
1478
1481
|
img = resized.toDataURL('image/png');
|
|
1479
|
-
}
|
|
1482
|
+
} else if (format == 'rgba') {
|
|
1483
|
+
let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
1484
|
+
img = pixels.data;
|
|
1485
|
+
}
|
|
1480
1486
|
if (img) {
|
|
1481
1487
|
resolve(img);
|
|
1482
1488
|
} else {
|
|
@@ -1529,7 +1529,9 @@ elation.component.add("engine.things.generic", function() {
|
|
|
1529
1529
|
}
|
|
1530
1530
|
return orient;
|
|
1531
1531
|
}
|
|
1532
|
-
this.worldToLocalOrientation = function(
|
|
1532
|
+
this.worldToLocalOrientation = (function() {
|
|
1533
|
+
const worldorient = new THREE.Quaternion();
|
|
1534
|
+
return function(orient) {
|
|
1533
1535
|
if (!orient) orient = new THREE.Quaternion();
|
|
1534
1536
|
/*
|
|
1535
1537
|
var n = this.parent;
|
|
@@ -1541,10 +1543,21 @@ elation.component.add("engine.things.generic", function() {
|
|
|
1541
1543
|
return orient.multiply(worldorient);
|
|
1542
1544
|
*/
|
|
1543
1545
|
// FIXME - this is cheating!
|
|
1544
|
-
var tmpquat = new THREE.Quaternion();
|
|
1545
|
-
return orient.multiply(tmpquat.copy(this.objects.dynamics.orientationWorld).
|
|
1546
|
-
|
|
1547
|
-
|
|
1546
|
+
//var tmpquat = new THREE.Quaternion();
|
|
1547
|
+
//return orient.multiply(tmpquat.copy(this.objects.dynamics.orientationWorld).invert());
|
|
1548
|
+
if (!orient) orient = new THREE.Quaternion();
|
|
1549
|
+
|
|
1550
|
+
var n = this.parent;
|
|
1551
|
+
worldorient.copy(this.orientation);
|
|
1552
|
+
|
|
1553
|
+
while (n && n.orientation) {
|
|
1554
|
+
worldorient.premultiply(n.orientation);
|
|
1555
|
+
n = n.parent;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
return orient.multiply(worldorient.invert());
|
|
1559
|
+
}
|
|
1560
|
+
})();
|
|
1548
1561
|
this.getWorldPosition = function(target) {
|
|
1549
1562
|
if (!target) target = new THREE.Vector3();
|
|
1550
1563
|
if (this.objects['3d'].matrixWorldNeedsUpdate) {
|
package/scripts/things/player.js
CHANGED
|
@@ -77,6 +77,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
77
77
|
this.viewmatrix = new THREE.Matrix4();
|
|
78
78
|
|
|
79
79
|
this.gravityVector = new THREE.Vector3();
|
|
80
|
+
this.lastjumptime = 0;
|
|
80
81
|
|
|
81
82
|
elation.events.add(this.engine, 'engine_frame', elation.bind(this, this.engine_frame));
|
|
82
83
|
elation.events.add(this.engine, 'engine_frame', elation.bind(this, this.handleTargeting));
|
|
@@ -206,7 +207,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
206
207
|
// The hardcoded offset is also specific to my own personal set-up, and helps to keep leap motion and tracked controllers in sync
|
|
207
208
|
this.tracker = this.head.spawn('objecttracker', null, {player: this, position: [0, -.05, -.185]});
|
|
208
209
|
this.camera = this.head.spawn('camera', this.name + '_camera', { position: [0,0,0], mass: 0.1, player_id: this.properties.player_id } );
|
|
209
|
-
this.
|
|
210
|
+
this.head.objects['3d'].add(this.ears);
|
|
210
211
|
|
|
211
212
|
//var camhelper = new THREE.CameraHelper(this.camera.camera);
|
|
212
213
|
//this.engine.systems.world.scene['world-3d'].add(camhelper);
|
|
@@ -222,7 +223,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
222
223
|
'position': [0,1.45,0]
|
|
223
224
|
});
|
|
224
225
|
this.head = this.neck.spawn('generic', this.properties.player_id + '_head', {
|
|
225
|
-
'position': [0,.
|
|
226
|
+
'position': [0,.2,0],
|
|
226
227
|
'mass': 1
|
|
227
228
|
});
|
|
228
229
|
|
|
@@ -332,7 +333,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
332
333
|
this.frictionForce.update(this.properties.movefriction);
|
|
333
334
|
if (this.controlstate['jump']) {
|
|
334
335
|
this.jumpForce.update(new THREE.Vector3(0, this.jumpstrength, 0));
|
|
335
|
-
console.log('jump up!', this.jumpForce.force.toArray());
|
|
336
|
+
//console.log('jump up!', this.jumpForce.force.toArray());
|
|
336
337
|
setTimeout(elation.bind(this, function() {
|
|
337
338
|
this.jumpForce.update(new THREE.Vector3(0, 0, 0));
|
|
338
339
|
}), this.jumptime);
|
|
@@ -640,7 +641,13 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
640
641
|
}
|
|
641
642
|
this.handleJump = function(ev) {
|
|
642
643
|
var keydown = ev.value;
|
|
643
|
-
if (
|
|
644
|
+
if (keydown) {
|
|
645
|
+
if (ev.timeStamp - this.lastjumptime < 250) {
|
|
646
|
+
console.log('toggle flying');
|
|
647
|
+
this.toggle_flying();
|
|
648
|
+
}
|
|
649
|
+
this.lastjumptime = ev.timeStamp;
|
|
650
|
+
} else {
|
|
644
651
|
this.jumpForce.update(new THREE.Vector3(0, 0, 0));
|
|
645
652
|
}
|
|
646
653
|
}
|