elation-engine 0.9.122 → 0.9.124
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 +34 -2
- package/scripts/systems/render.js +7 -1
- package/scripts/things/generic.js +18 -5
- package/scripts/things/player.js +10 -3
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});
|
|
@@ -2183,6 +2185,7 @@ console.log('set up hls', hlsConfig);
|
|
|
2183
2185
|
|
|
2184
2186
|
_construct: function(args) {
|
|
2185
2187
|
elation.class.call(this, args);
|
|
2188
|
+
this.instances = [];
|
|
2186
2189
|
if (this.shadertype == 'shadertoy') {
|
|
2187
2190
|
this.uniforms = [
|
|
2188
2191
|
{ name: 'iResolution', value: new THREE.Vector3(512, 512, 0, 0) },
|
|
@@ -2218,6 +2221,14 @@ console.log('set up hls', hlsConfig);
|
|
|
2218
2221
|
this._material.uniforms.iTimeDelta.value = this.uniformsMap.iTimeDelta.value;
|
|
2219
2222
|
this._material.uniforms.iFrame.value = this.uniformsMap.iFrame.value;
|
|
2220
2223
|
this._material.uniforms.iDate.value = this.uniformsMap.iDate.value;
|
|
2224
|
+
|
|
2225
|
+
this.instances.forEach(mat => {
|
|
2226
|
+
mat.uniforms.iTime.value = this.uniformsMap.iTime.value;
|
|
2227
|
+
mat.uniforms.iTimeDelta.value = this.uniformsMap.iTimeDelta.value;
|
|
2228
|
+
mat.uniforms.iFrame.value = this.uniformsMap.iFrame.value;
|
|
2229
|
+
mat.uniforms.iDate.value = this.uniformsMap.iDate.value;
|
|
2230
|
+
});
|
|
2231
|
+
|
|
2221
2232
|
lasttime = now;
|
|
2222
2233
|
}
|
|
2223
2234
|
}, 16);
|
|
@@ -2249,6 +2260,8 @@ console.log('set up hls', hlsConfig);
|
|
|
2249
2260
|
this._material.fragmentShader = `
|
|
2250
2261
|
#include <common>
|
|
2251
2262
|
#include <uv_pars_fragment>
|
|
2263
|
+
#include <color_pars_fragment>
|
|
2264
|
+
#include <map_pars_fragment>
|
|
2252
2265
|
|
|
2253
2266
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
|
2254
2267
|
uniform float iTime; // shader playback time (in seconds)
|
|
@@ -2264,10 +2277,15 @@ console.log('set up hls', hlsConfig);
|
|
|
2264
2277
|
uniform vec4 iDate; // (year, month, day, time in seconds)
|
|
2265
2278
|
uniform float iSampleRate; // sound sample rate (i.e., 44100)
|
|
2266
2279
|
|
|
2280
|
+
uniform vec3 diffuse;
|
|
2281
|
+
uniform float opacity;
|
|
2282
|
+
|
|
2267
2283
|
${shadercode}
|
|
2268
2284
|
|
|
2269
2285
|
void main() {
|
|
2286
|
+
vec4 diffuseColor = vec4(diffuse, opacity);
|
|
2270
2287
|
#include <map_fragment>
|
|
2288
|
+
#include <color_fragment>
|
|
2271
2289
|
|
|
2272
2290
|
mainImage(gl_FragColor, vUv * iResolution.xy);
|
|
2273
2291
|
}
|
|
@@ -2275,6 +2293,12 @@ console.log('set up hls', hlsConfig);
|
|
|
2275
2293
|
}
|
|
2276
2294
|
this._material.defines['USE_UV'] = 1;
|
|
2277
2295
|
this._material.needsUpdate = true;
|
|
2296
|
+
this.instances.forEach(mat => {
|
|
2297
|
+
mat.vertexShader = this._material.vertexShader;
|
|
2298
|
+
mat.fragmentShader = this._material.fragmentShader;
|
|
2299
|
+
mat.defines = this._material.defines;
|
|
2300
|
+
mat.needsUpdate = true;
|
|
2301
|
+
});
|
|
2278
2302
|
});
|
|
2279
2303
|
} else {
|
|
2280
2304
|
this._material.fragmentShader = THREE.ShaderLib.basic.fragmentShader;
|
|
@@ -2292,6 +2316,12 @@ console.log('set up hls', hlsConfig);
|
|
|
2292
2316
|
if (this.uniforms) {
|
|
2293
2317
|
this._material.uniforms = this.uniformsMap;
|
|
2294
2318
|
}
|
|
2319
|
+
this.instances.forEach(mat => {
|
|
2320
|
+
mat.vertexShader = this._material.vertexShader;
|
|
2321
|
+
mat.fragmentShader = this._material.fragmentShader;
|
|
2322
|
+
mat.defines = this._material.defines;
|
|
2323
|
+
mat.needsUpdate = true;
|
|
2324
|
+
});
|
|
2295
2325
|
this.complete();
|
|
2296
2326
|
},
|
|
2297
2327
|
complete: function(data) {
|
|
@@ -2315,7 +2345,9 @@ console.log('set up hls', hlsConfig);
|
|
|
2315
2345
|
if (!this._material) {
|
|
2316
2346
|
this.load();
|
|
2317
2347
|
}
|
|
2318
|
-
|
|
2348
|
+
let mat = this._material.clone();
|
|
2349
|
+
this.instances.push(mat);
|
|
2350
|
+
return mat;
|
|
2319
2351
|
}
|
|
2320
2352
|
}, elation.engine.assets.base);
|
|
2321
2353
|
});
|
|
@@ -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);
|
|
@@ -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
|
}
|