elation-engine 0.9.119 → 0.9.121
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
CHANGED
|
@@ -210,7 +210,7 @@ elation.require(['ui.window', 'ui.panel', 'ui.toggle', 'ui.slider', 'ui.label',
|
|
|
210
210
|
if (!this.container) this.container = (this.engine.systems.render ? this.engine.systems.render.renderer.domElement : window);
|
|
211
211
|
elation.events.add(this.container, "mousedown,mousemove,mouseup,mousewheel,click,DOMMouseScroll,gesturestart,gesturechange,gestureend", this);
|
|
212
212
|
//elation.events.add(this.container, "touchstart,touchmove,touchend, this);
|
|
213
|
-
elation.events.add(window, "keydown,keyup,webkitGamepadConnected,webkitgamepaddisconnected,MozGamepadConnected,MozGamepadDisconnected,gamepadconnected,gamepaddisconnected", this);
|
|
213
|
+
elation.events.add(window, "keydown,keyup,webkitGamepadConnected,webkitgamepaddisconnected,MozGamepadConnected,MozGamepadDisconnected,gamepadconnected,gamepaddisconnected,focus", this);
|
|
214
214
|
//elation.events.add(window, "deviceorientation,devicemotion", this);
|
|
215
215
|
elation.events.add(document, "pointerlockchange,webkitpointerlockchange,mozpointerlockchange", elation.bind(this, this.pointerLockChange));
|
|
216
216
|
elation.events.add(document, "pointerlockerror,webkitpointerlockerror,mozpointerlockerror", elation.bind(this, this.pointerLockError));
|
|
@@ -1000,6 +1000,9 @@ return;
|
|
|
1000
1000
|
this.capturekeys.splice(idx, 1);
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
+
this.focus = function(ev) {
|
|
1004
|
+
if (this.state['keyboard_alt']) this.state['keyboard_alt'] = 0; // fix sticky alt key on alt tab
|
|
1005
|
+
}
|
|
1003
1006
|
});
|
|
1004
1007
|
if (0) {
|
|
1005
1008
|
elation.component.add('engine.systems.controls.config', function() {
|
|
@@ -238,6 +238,7 @@ elation.require(["physics.cyclone"], function() {
|
|
|
238
238
|
let material1 = new THREE.LineBasicMaterial({color: 0x00ffff, transparent: true, depthWrite: false, depthTest: false, opacity: .05, blending: THREE.AdditiveBlending, linewidth: 4});
|
|
239
239
|
let material2 = new THREE.LineBasicMaterial({color: 0x00ffff, transparent: true, depthWrite: false, depthTest: true, opacity: .2, blending: THREE.AdditiveBlending, linewidth: 4});
|
|
240
240
|
this.geometry = geo;
|
|
241
|
+
geo.computeBoundingSphere();
|
|
241
242
|
let obj = new THREE.Object3D();
|
|
242
243
|
obj.add(new THREE.LineSegments(geo, material1));
|
|
243
244
|
obj.add(new THREE.LineSegments(geo, material2));
|
|
@@ -428,9 +429,9 @@ elation.require(["physics.cyclone"], function() {
|
|
|
428
429
|
this.createBoundingPlane = function(collider) {
|
|
429
430
|
var plane = new THREE.PlaneGeometry(1000, 1000);
|
|
430
431
|
var planemat = new THREE.MeshBasicMaterial({color: 0x00ffff, transparent: true, opacity: .04, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -5, polygonOffsetUnits: 1, wireframe: false, blending: THREE.AdditiveBlending });
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
432
|
+
// FIXME - this only really works for horizontal planes
|
|
433
|
+
var mat = new THREE.Matrix4().makeRotationFromQuaternion(new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1,0,0), -Math.PI/2));
|
|
434
|
+
plane.applyMatrix4(mat);
|
|
434
435
|
var mesh = new THREE.Mesh(plane, planemat);
|
|
435
436
|
return mesh;
|
|
436
437
|
}
|
|
@@ -441,7 +442,7 @@ elation.require(["physics.cyclone"], function() {
|
|
|
441
442
|
var mesh = new THREE.Mesh(cyl, cylmat);
|
|
442
443
|
console.log('my offset', collider.offset, collider);
|
|
443
444
|
let offset = collider.offset.clone();//.multiply(collider.body.scale);
|
|
444
|
-
cyl.
|
|
445
|
+
cyl.applyMatrix4(new THREE.Matrix4().makeTranslation(offset.x, offset.y, offset.z));
|
|
445
446
|
return mesh;
|
|
446
447
|
}
|
|
447
448
|
this.createBoundingMesh = function(collider) {
|
|
@@ -814,7 +815,7 @@ console.log('ffff', collision.impulses[i], len);
|
|
|
814
815
|
var size = [bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y, bbox.max.z - bbox.min.z];
|
|
815
816
|
var offset = [(bbox.max.x + bbox.min.x) / 2, (bbox.max.y - bbox.min.y) / 2, (bbox.max.z + bbox.min.z) / 2];
|
|
816
817
|
var insidegeo = new THREE.BoxGeometry(size[0], size[1], size[2]);
|
|
817
|
-
insidegeo.
|
|
818
|
+
insidegeo.applyMatrix4(new THREE.Matrix4().makeTranslation(offset[0], size[1]/2 + offset[1], offset[2]));
|
|
818
819
|
var insidemat_side = new THREE.MeshPhongMaterial({emissive: 0x006666, color: 0x00ffff, opacity: 0.8, transparent: true, depthWrite: false, depthTest: false});
|
|
819
820
|
var insidemat_top = new THREE.MeshPhongMaterial({emissive: 0x006666, color: 0x00ffff, opacity: 0.5, transparent: true, depthWrite: false, depthTest: false});
|
|
820
821
|
|
package/scripts/systems/world.js
CHANGED
|
@@ -357,7 +357,7 @@ elation.require([
|
|
|
357
357
|
this.spawn = function(type, name, spawnargs, parent, autoload) {
|
|
358
358
|
if (elation.utils.isNull(name)) name = type + Math.floor(Math.random() * 1000000);
|
|
359
359
|
if (!spawnargs) spawnargs = {};
|
|
360
|
-
if (!parent) parent = this.children['default'] || this;
|
|
360
|
+
//if (!parent) parent = this.children['default'] || this;
|
|
361
361
|
if (typeof autoload == 'undefined') autoload = true;
|
|
362
362
|
|
|
363
363
|
var logprefix = "";
|
|
@@ -388,8 +388,10 @@ elation.require([
|
|
|
388
388
|
} else {
|
|
389
389
|
currentobj = elation.engine.things[type]({type: realtype, container: elation.html.create(), name: name, engine: this.engine, client: this.client, properties: spawnargs});
|
|
390
390
|
}
|
|
391
|
-
parent
|
|
392
|
-
|
|
391
|
+
if (parent) {
|
|
392
|
+
parent.add(currentobj);
|
|
393
|
+
//currentobj.reparent(parent);
|
|
394
|
+
}
|
|
393
395
|
|
|
394
396
|
//console.log(logprefix + "\t- added new " + type + ": " + name, currentobj);
|
|
395
397
|
}
|
|
@@ -242,6 +242,9 @@ elation.component.add("engine.things.generic", function() {
|
|
|
242
242
|
configurable: true,
|
|
243
243
|
enumerable: true,
|
|
244
244
|
get: function() {
|
|
245
|
+
if ('get' in prop) {
|
|
246
|
+
return prop.get.call(this);
|
|
247
|
+
}
|
|
245
248
|
var proxy = this._proxies[propname];
|
|
246
249
|
if (proxy) {
|
|
247
250
|
return proxy;
|
package/scripts/things/player.js
CHANGED
|
@@ -25,6 +25,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
25
25
|
dynamicfriction:{ type: 'float', default: 2.0, comment: 'Dynamic friction inherent to this object' },
|
|
26
26
|
staticfriction: { type: 'float', default: 1.9, comment: 'Static friction inherent to this object' },
|
|
27
27
|
fov: { type: 'float', default: 75, set: this.updateCamera },
|
|
28
|
+
turnhead: { type: 'boolean', default: false, set: this.updateHeadLock },
|
|
28
29
|
});
|
|
29
30
|
this.controlstate = this.engine.systems.controls.addContext('player', {
|
|
30
31
|
'move_forward': ['keyboard_w', elation.bind(this, this.updateControls)],
|
|
@@ -182,6 +183,7 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
182
183
|
this.createChildren = function() {
|
|
183
184
|
// place camera at head height
|
|
184
185
|
this.headconstraint = this.head.objects.dynamics.addConstraint('axis', { axis: new THREE.Vector3(1,0,0), min: -Math.PI/2, max: Math.PI/2 });
|
|
186
|
+
this.neckconstraint = this.neck.objects.dynamics.addConstraint('axis', { axis: new THREE.Vector3(0,1,0), min: 3/4 * -Math.PI/2, max: 3/4 * Math.PI/2 });
|
|
185
187
|
this.reset_position();
|
|
186
188
|
}
|
|
187
189
|
this.createForces = function() {
|
|
@@ -491,7 +493,12 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
491
493
|
var theta = angular.length();
|
|
492
494
|
angular.divideScalar(theta);
|
|
493
495
|
tmpquat.setFromAxisAngle(angular, theta);
|
|
494
|
-
this.
|
|
496
|
+
if (this.turnhead) {
|
|
497
|
+
this.neck.properties.orientation.multiply(tmpquat);
|
|
498
|
+
} else {
|
|
499
|
+
this.properties.orientation.multiply(tmpquat);
|
|
500
|
+
this.neck.properties.orientation.set(0,0,0,1);
|
|
501
|
+
}
|
|
495
502
|
ev.data.mouse_turn = 0;
|
|
496
503
|
ev.data.mouse_look[0] = 0;
|
|
497
504
|
changed = true;
|
|
@@ -720,6 +727,17 @@ elation.require(['engine.things.generic', 'engine.things.camera', 'engine.things
|
|
|
720
727
|
this.camera.fov = this.fov;
|
|
721
728
|
}
|
|
722
729
|
}
|
|
723
|
-
|
|
730
|
+
this.updateHeadLock = function() {
|
|
731
|
+
if (this.headconstraint && this.neckconstraint) {
|
|
732
|
+
if (this.turnhead) {
|
|
733
|
+
//this.headconstraint.enabled = false;
|
|
734
|
+
this.neckconstraint.min = 3/4 * -Math.PI/2;
|
|
735
|
+
this.neckconstraint.max = 3/4 * Math.PI/2;
|
|
736
|
+
} else {
|
|
737
|
+
this.neckconstraint.min = 0;
|
|
738
|
+
this.neckconstraint.max = 0;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
724
742
|
}, elation.engine.things.generic);
|
|
725
743
|
});
|