@urso/core 0.4.49 → 0.4.52
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/build/js/index.js +1 -1
- package/package.json +2 -1
- package/src/js/extra/_info.js +2 -0
- package/src/js/lib/logger.js +51 -3
- package/src/js/modules/objects/create.js +3 -0
- package/src/js/modules/objects/models/_info.js +1 -0
- package/src/js/modules/objects/models/emitterFx.js +99 -0
- package/src/js/modules/objects/propertyAdapter.js +1 -0
- package/src/js/modules/scenes/pixiWrapper.js +1 -1
- package/src/js/modules/template/types.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@urso/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.52",
|
|
4
4
|
"description": "HTML5 game engine",
|
|
5
5
|
"main": "build/js/index.js",
|
|
6
6
|
"author": "Megbrimef",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"homepage": "https://github.com/megbrimef/urso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@pixi/filter-drop-shadow": "^3.2.0",
|
|
26
|
+
"@urso/revolt-fx": "^0.1.0",
|
|
26
27
|
"gsap": "^3.1.1",
|
|
27
28
|
"howler": "^2.2.1",
|
|
28
29
|
"pixi-particles": "^4.3.0",
|
package/src/js/extra/_info.js
CHANGED
|
@@ -2,6 +2,8 @@ import * as PIXI from 'pixi.js';
|
|
|
2
2
|
window.PIXI = PIXI;
|
|
3
3
|
window.PIXI.particles = require('pixi-particles');
|
|
4
4
|
|
|
5
|
+
window.PIXI.particlesFx = require('@urso/revolt-fx');
|
|
6
|
+
|
|
5
7
|
import { DropShadowFilter } from '@pixi/filter-drop-shadow';
|
|
6
8
|
PIXI.filters['DropShadowFilter'] = DropShadowFilter;
|
|
7
9
|
|
package/src/js/lib/logger.js
CHANGED
|
@@ -1,23 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
//setup custom log level with: ?logLevel=1,2,3,4 OR ?logLevel=ERROR,WARNING,INFO,LOG
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LOG_LEVEL = 'ERROR,WARNING,INFO,LOG'; //also can be 0,1,2,3
|
|
4
|
+
|
|
5
|
+
const LEVELS = [
|
|
6
|
+
'ERROR',
|
|
7
|
+
'WARNING',
|
|
8
|
+
'INFO',
|
|
9
|
+
'LOG'
|
|
10
|
+
];
|
|
2
11
|
|
|
12
|
+
class LibLogger {
|
|
3
13
|
constructor() {
|
|
14
|
+
this._logLevel = {};
|
|
15
|
+
this._setupLevels();
|
|
16
|
+
|
|
4
17
|
//log
|
|
5
|
-
|
|
18
|
+
if (this._logLevel['LOG']) {
|
|
19
|
+
window.log = console.log.bind(console);
|
|
20
|
+
} else {
|
|
21
|
+
window.log = console.log = () => { }
|
|
22
|
+
}
|
|
6
23
|
}
|
|
7
24
|
|
|
8
25
|
//todo set log level (dev/prod)
|
|
9
26
|
|
|
10
27
|
log() {
|
|
28
|
+
if (!this._logLevel['LOG']) return;
|
|
29
|
+
|
|
11
30
|
console.log.apply(console, arguments);
|
|
12
31
|
}
|
|
13
32
|
|
|
33
|
+
info() {
|
|
34
|
+
if (!this._logLevel['INFO']) return;
|
|
35
|
+
|
|
36
|
+
console.info.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
|
|
14
39
|
warn() {
|
|
40
|
+
if (!this._logLevel['WARNING']) return;
|
|
41
|
+
|
|
15
42
|
console.warn.apply(this, arguments);
|
|
16
43
|
}
|
|
17
44
|
|
|
18
45
|
error() {
|
|
46
|
+
if (!this._logLevel['ERROR']) return;
|
|
47
|
+
|
|
19
48
|
console.error.apply(this, arguments);
|
|
20
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* setup logging levels
|
|
53
|
+
*/
|
|
54
|
+
_setupLevels() {
|
|
55
|
+
const logLevelsString = Urso.helper.parseGetParams('logLevel') || DEFAULT_LOG_LEVEL;
|
|
56
|
+
const logLevelsArray = logLevelsString.split(',');
|
|
57
|
+
|
|
58
|
+
for (const [index, level] of Object.entries(LEVELS)) {
|
|
59
|
+
let levelValue = false;
|
|
60
|
+
|
|
61
|
+
if (logLevelsArray.includes(index) || logLevelsArray.includes(level))
|
|
62
|
+
levelValue = true;
|
|
63
|
+
|
|
64
|
+
this._logLevel[level] = levelValue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`LibLogger log Level: ${JSON.stringify(this._logLevel)}`);
|
|
68
|
+
}
|
|
21
69
|
}
|
|
22
70
|
|
|
23
|
-
module.exports = LibLogger;
|
|
71
|
+
module.exports = LibLogger;
|
|
@@ -101,6 +101,9 @@ class ModulesObjectsCreate {
|
|
|
101
101
|
case Urso.types.objects.NINESLICEPLANE:
|
|
102
102
|
model = this.getInstance('Models.NineSlicePlane', object);
|
|
103
103
|
break;
|
|
104
|
+
case Urso.types.objects.EMITTERFX:
|
|
105
|
+
model = this.getInstance('Models.EmitterFx', object);
|
|
106
|
+
break;
|
|
104
107
|
|
|
105
108
|
default:
|
|
106
109
|
const objectName = Urso.helper.capitaliseFirstLetter(
|
|
@@ -8,6 +8,7 @@ Urso.Core.Modules.Objects.Models = {
|
|
|
8
8
|
Component: require('./component.js'),
|
|
9
9
|
Container: require('./container.js'),
|
|
10
10
|
Emitter: require('./emitter.js'),
|
|
11
|
+
EmitterFx: require('./emitterFx.js'),
|
|
11
12
|
Graphics: require('./graphics.js'),
|
|
12
13
|
Group: require('./group.js'),
|
|
13
14
|
HitArea: require('./hitArea.js'),
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
class ModulesObjectsModelsEmitterFx extends Urso.Core.Modules.Objects.BaseModel {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
super(params);
|
|
4
|
+
|
|
5
|
+
this.type = Urso.types.objects.EMITTERFX;
|
|
6
|
+
|
|
7
|
+
this.emitter = null;
|
|
8
|
+
this.update = this.update.bind(this);
|
|
9
|
+
|
|
10
|
+
this._addBaseObject();
|
|
11
|
+
this._createBundle();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} params
|
|
17
|
+
*
|
|
18
|
+
* - Params have to contain 'cfg' which is a key of JSON config made via
|
|
19
|
+
* https://editor.revoltfx.electronauts.net editor.
|
|
20
|
+
* - In a case config doesn't have textures described in it, you can use spritesheetFilter which should be a
|
|
21
|
+
* string, described common part of texures asset keys. That string will be used as filter to get textures from cache.
|
|
22
|
+
* If textures should be animated, texture's asset key have to be of the next format:
|
|
23
|
+
* mc_commonPart_01 - where 'mc' stands for 'movieclips' allows us use animation, commonPart - described all textures in a spriteSheet,
|
|
24
|
+
* and _01 - number of frame.
|
|
25
|
+
*/
|
|
26
|
+
setupParams(params) {
|
|
27
|
+
super.setupParams(params);
|
|
28
|
+
|
|
29
|
+
this.autostart = Urso.helper.recursiveGet('autostart', params, false);
|
|
30
|
+
this.cfg = Urso.helper.recursiveGet('cfg', params, false);
|
|
31
|
+
this.spritesheetFilter = Urso.helper.recursiveGet('spritesheetFilter', params, false);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
update(deltaTime) {
|
|
35
|
+
if (this._emitter) {
|
|
36
|
+
this._bundle.update(deltaTime * PIXI.settings.TARGET_FPMS);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {String} emitterName
|
|
42
|
+
* Inits emitter by it's name. If no name given - inits first emitter from config.
|
|
43
|
+
*/
|
|
44
|
+
play(emitterName) {
|
|
45
|
+
this._isActive = true;
|
|
46
|
+
|
|
47
|
+
emitterName = emitterName || this._defaultEmitterName;
|
|
48
|
+
|
|
49
|
+
this._emitter = this._bundle.getParticleEmitter(emitterName);
|
|
50
|
+
this._emitter.init(this._baseObject, true, 1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* Stops emitter. If new emitter wasn't inited before particles disappears - clears this._emitter to stop bundle update.
|
|
56
|
+
*/
|
|
57
|
+
stop() {
|
|
58
|
+
if(!this._emitter)
|
|
59
|
+
return;
|
|
60
|
+
|
|
61
|
+
this._emitter.stop();
|
|
62
|
+
this._emitter.on.completed.add(() => {
|
|
63
|
+
if(!this._isActive)
|
|
64
|
+
this._emitter = null;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
this._isActive = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_addBaseObject() {
|
|
71
|
+
this._baseObject = new PIXI.Container();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_createBundle() {
|
|
75
|
+
this._bundle = new PIXI.particlesFx.FX();
|
|
76
|
+
let fx_settings_data = Urso.cache.getJson(this.cfg).data;
|
|
77
|
+
|
|
78
|
+
if(this.spritesheetFilter)
|
|
79
|
+
fx_settings_data.spritesheetFilter = this.spritesheetFilter;
|
|
80
|
+
|
|
81
|
+
this._defaultEmitterName = fx_settings_data.emitters[0].name;
|
|
82
|
+
|
|
83
|
+
this._bundle.initBundle(fx_settings_data);
|
|
84
|
+
this.autostart && this.play();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_subscribeOnce() {
|
|
88
|
+
this.addListener(Urso.events.MODULES_SCENES_UPDATE, this.update);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_customDestroy() {
|
|
92
|
+
this.removeListener(Urso.events.MODULES_SCENES_UPDATE, this.update);
|
|
93
|
+
this._emitter.stop(false);
|
|
94
|
+
this._bundle = null;
|
|
95
|
+
this._emitter = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = ModulesObjectsModelsEmitterFx;
|
|
@@ -32,7 +32,7 @@ class ModulesScenesPixiWrapper {
|
|
|
32
32
|
this._createWorld();
|
|
33
33
|
|
|
34
34
|
// setup interaction
|
|
35
|
-
this.interaction = new PIXI.InteractionManager(
|
|
35
|
+
this.interaction = new PIXI.InteractionManager(this.renderer);
|
|
36
36
|
|
|
37
37
|
this._loaderScene = this.getInstance('Model');
|
|
38
38
|
this._requestAnimFrame(this.loop);
|