@crispcode/shimmer 5.0.2 → 5.1.0
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/README.md +1 -0
- package/package.json +32 -32
- package/scripts/index.js +2 -0
- package/scripts/shimmer.js +21 -24
- package/scripts/video.js +75 -0
- package/test/app.js +0 -1
- package/test/public/movie.mp4 +0 -0
- package/test/scripts/components/layout/index.js +2 -1
- package/test/scripts/components/shimmer/index.js +6 -3
- package/test/scripts/index.js +2 -0
package/README.md
CHANGED
@@ -26,6 +26,7 @@ In order to support older versions of browsers, you can use [polyfill.io](https:
|
|
26
26
|
| Element | `import { Element } from 'shimmer'` | The base class for all Shimmer objects |
|
27
27
|
| Shimmer | `import { Shimmer } from 'shimmer'` | The Shimmer component class, check Modux/Component for more information |
|
28
28
|
| Tween | `import { Tween } from 'shimmer'` | A class used to create animation tweens in Element or Shimmer |
|
29
|
+
| Video | `import { Video } from 'shimmer'` | A Video class which extends the Element class |
|
29
30
|
| Sprite | `import { Sprite } from 'shimmer'` | PIXI.JS Sprite class |
|
30
31
|
| AnimatedSprite | `import { AnimatedSprite } from 'shimmer'` | PIXI.JS AnimatedSprite class |
|
31
32
|
| Text | `import { Text } from 'shimmer'` | PIXI.JS Text class |
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@crispcode/shimmer",
|
3
|
-
"version": "5.0
|
3
|
+
"version": "5.1.0",
|
4
4
|
"description": "A PIXI.JS wrapper plugin for MODUX",
|
5
5
|
"author": "Crisp Code ( contact@crispcode.ro )",
|
6
6
|
"access": "public",
|
@@ -17,39 +17,39 @@
|
|
17
17
|
"url": "https://github.com/CrispCode/shimmer/issues"
|
18
18
|
},
|
19
19
|
"dependencies": {
|
20
|
-
"@pixi/
|
21
|
-
"@pixi/canvas-
|
22
|
-
"@pixi/canvas-
|
23
|
-
"@pixi/canvas-
|
24
|
-
"@pixi/canvas-
|
25
|
-
"@pixi/canvas-
|
26
|
-
"@pixi/canvas-
|
27
|
-
"@pixi/canvas-
|
28
|
-
"@pixi/canvas-sprite
|
29
|
-
"@pixi/canvas-
|
30
|
-
"@pixi/
|
31
|
-
"@pixi/
|
32
|
-
"@pixi/
|
33
|
-
"@pixi/
|
34
|
-
"@pixi/
|
35
|
-
"@pixi/
|
36
|
-
"@pixi/
|
37
|
-
"@pixi/
|
38
|
-
"@pixi/mesh
|
39
|
-
"@pixi/
|
40
|
-
"@pixi/
|
41
|
-
"@pixi/
|
42
|
-
"@pixi/
|
43
|
-
"@pixi/
|
44
|
-
"@pixi/sprite
|
45
|
-
"@pixi/sprite-
|
46
|
-
"@pixi/
|
47
|
-
"@pixi/
|
48
|
-
"@pixi/
|
49
|
-
"
|
20
|
+
"@pixi/assets": "^6.5.1",
|
21
|
+
"@pixi/canvas-display": "^6.5.1",
|
22
|
+
"@pixi/canvas-extract": "^6.5.1",
|
23
|
+
"@pixi/canvas-graphics": "^6.5.1",
|
24
|
+
"@pixi/canvas-mesh": "^6.5.1",
|
25
|
+
"@pixi/canvas-particle-container": "^6.5.1",
|
26
|
+
"@pixi/canvas-prepare": "^6.5.1",
|
27
|
+
"@pixi/canvas-renderer": "^6.5.1",
|
28
|
+
"@pixi/canvas-sprite": "^6.5.1",
|
29
|
+
"@pixi/canvas-sprite-tiling": "^6.5.1",
|
30
|
+
"@pixi/canvas-text": "^6.5.1",
|
31
|
+
"@pixi/constants": "^6.5.1",
|
32
|
+
"@pixi/core": "^6.5.1",
|
33
|
+
"@pixi/display": "^6.5.1",
|
34
|
+
"@pixi/extensions": "^6.5.1",
|
35
|
+
"@pixi/graphics": "^6.5.1",
|
36
|
+
"@pixi/interaction": "^6.5.1",
|
37
|
+
"@pixi/math": "^6.5.1",
|
38
|
+
"@pixi/mesh": "^6.5.1",
|
39
|
+
"@pixi/mesh-extras": "^6.5.1",
|
40
|
+
"@pixi/particle-container": "^6.5.1",
|
41
|
+
"@pixi/prepare": "^6.5.1",
|
42
|
+
"@pixi/runner": "^6.5.1",
|
43
|
+
"@pixi/settings": "^6.5.1",
|
44
|
+
"@pixi/sprite": "^6.5.1",
|
45
|
+
"@pixi/sprite-animated": "^6.5.1",
|
46
|
+
"@pixi/sprite-tiling": "^6.5.1",
|
47
|
+
"@pixi/text": "^6.5.1",
|
48
|
+
"@pixi/ticker": "^6.5.1",
|
49
|
+
"@pixi/utils": "^6.5.1"
|
50
50
|
},
|
51
51
|
"peerDependencies": {
|
52
|
-
"@crispcode/modux": "
|
52
|
+
"@crispcode/modux": "^5.1.5"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
55
|
"esdoc": "^1.1.0",
|
package/scripts/index.js
CHANGED
@@ -5,6 +5,7 @@ import { Shimmer } from './shimmer.js'
|
|
5
5
|
import { Button } from './button.js'
|
6
6
|
import { Element } from './element.js'
|
7
7
|
import { Tween } from './tween.js'
|
8
|
+
import { Video } from './video.js'
|
8
9
|
|
9
10
|
import { Sprite } from '@pixi/sprite'
|
10
11
|
import { AnimatedSprite } from '@pixi/sprite-animated'
|
@@ -18,6 +19,7 @@ export {
|
|
18
19
|
Button,
|
19
20
|
Element,
|
20
21
|
Tween,
|
22
|
+
Video,
|
21
23
|
|
22
24
|
Sprite,
|
23
25
|
AnimatedSprite,
|
package/scripts/shimmer.js
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
'use strict'
|
4
4
|
|
5
|
-
import { Component, extend,
|
5
|
+
import { Component, extend, logger } from '@crispcode/modux'
|
6
6
|
|
7
|
-
import { autoDetectRenderer,
|
8
|
-
import {
|
7
|
+
import { autoDetectRenderer, BatchRenderer } from '@pixi/core'
|
8
|
+
import { Assets } from '@pixi/assets'
|
9
9
|
import { Ticker } from '@pixi/ticker'
|
10
10
|
import { InteractionManager } from '@pixi/interaction'
|
11
11
|
import { skipHello, isWebGLSupported } from '@pixi/utils'
|
12
|
+
import { extensions } from '@pixi/extensions'
|
12
13
|
|
13
14
|
// Canvas support
|
14
15
|
import '@pixi/canvas-display'
|
@@ -25,15 +26,8 @@ import '@pixi/canvas-text'
|
|
25
26
|
import { Element } from './element.js'
|
26
27
|
import { Controls } from './controls.js'
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
CanvasRenderer.registerPlugin( 'interaction', InteractionManager )
|
32
|
-
CanvasRenderer.registerPlugin( 'extract', CanvasExtract )
|
33
|
-
CanvasRenderer.registerPlugin( 'graphics', CanvasGraphicsRenderer )
|
34
|
-
CanvasRenderer.registerPlugin( 'mesh', CanvasMeshRenderer )
|
35
|
-
CanvasRenderer.registerPlugin( 'prepare', CanvasPrepare )
|
36
|
-
CanvasRenderer.registerPlugin( 'sprite', CanvasSpriteRenderer )
|
29
|
+
extensions.add( InteractionManager )
|
30
|
+
extensions.add( BatchRenderer )
|
37
31
|
|
38
32
|
/**
|
39
33
|
* This class is used to create the shimmer component
|
@@ -66,19 +60,12 @@ export class Shimmer extends Component {
|
|
66
60
|
|
67
61
|
/**
|
68
62
|
* This method preloads a colection of assets
|
69
|
-
* @param {Object}
|
63
|
+
* @param {Object} bundle A collection of assets
|
70
64
|
* @return {Promise} A promise which is resolved upon loading the assets. It resolves the loaded resources.
|
71
65
|
*/
|
72
|
-
preload (
|
73
|
-
|
74
|
-
return
|
75
|
-
loop( assets, ( data, name ) => {
|
76
|
-
loader.add( name, data )
|
77
|
-
} )
|
78
|
-
loader.load( ( loader, resources ) => {
|
79
|
-
resolve( resources )
|
80
|
-
} )
|
81
|
-
} )
|
66
|
+
preload ( bundle ) {
|
67
|
+
Assets.addBundle( 'bundle', bundle )
|
68
|
+
return Assets.loadBundle( 'bundle' )
|
82
69
|
}
|
83
70
|
|
84
71
|
/**
|
@@ -163,7 +150,17 @@ export class Shimmer extends Component {
|
|
163
150
|
* Stores the renderer
|
164
151
|
* @type {Renderer}
|
165
152
|
*/
|
166
|
-
this.renderer =
|
153
|
+
this.renderer = null
|
154
|
+
if ( isWebGLSupported() && !this.settings.forceCanvas ) {
|
155
|
+
this.renderer = autoDetectRenderer( rendererSettings )
|
156
|
+
} else {
|
157
|
+
extensions.add( CanvasExtract )
|
158
|
+
extensions.add( CanvasGraphicsRenderer )
|
159
|
+
extensions.add( CanvasMeshRenderer )
|
160
|
+
extensions.add( CanvasPrepare )
|
161
|
+
extensions.add( CanvasSpriteRenderer )
|
162
|
+
this.renderer = new CanvasRenderer( rendererSettings )
|
163
|
+
}
|
167
164
|
|
168
165
|
this.renderer.resize( this.element.clientWidth, this.element.clientHeight )
|
169
166
|
|
package/scripts/video.js
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
/* globals document */
|
2
|
+
|
3
|
+
'use strict'
|
4
|
+
|
5
|
+
import { VideoResource, Texture } from '@pixi/core'
|
6
|
+
import { Sprite } from '@pixi/sprite'
|
7
|
+
|
8
|
+
import { Element } from './element.js'
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This class is used to create video elements for shimmer
|
12
|
+
*/
|
13
|
+
export class Video extends Element {
|
14
|
+
/**
|
15
|
+
* Creates an instance of Video
|
16
|
+
*/
|
17
|
+
constructor ( source, options = {} ) {
|
18
|
+
super()
|
19
|
+
|
20
|
+
this.__source = document.createElement( 'video' )
|
21
|
+
this.__source.playsInline = true
|
22
|
+
this.__source.preload = 'auto'
|
23
|
+
this.__source.autoplay = false
|
24
|
+
this.__source.playbackRate = ( options.playbackRate !== undefined ) ? options.playbackRate : 1
|
25
|
+
this.__source.muted = ( options.muted !== undefined ) ? options.muted : false
|
26
|
+
|
27
|
+
this.__source.loop = ( options.loop !== undefined ) ? options.loop : true
|
28
|
+
this.__source.src = source
|
29
|
+
|
30
|
+
this.__resource = new VideoResource( this.__source, {
|
31
|
+
autoPlay: ( options.autoPlay !== undefined ) ? options.autoPlay : false,
|
32
|
+
autoLoad: ( options.autoLoad !== undefined ) ? options.autoLoad : true,
|
33
|
+
updateFPS: ( options.updateFPS !== undefined ) ? options.updateFPS : 0,
|
34
|
+
crossorigin: ( options.crossorigin !== undefined ) ? options.crossorigin : true
|
35
|
+
} )
|
36
|
+
|
37
|
+
let texture = Texture.from( this.__resource )
|
38
|
+
let sprite = new Sprite( texture )
|
39
|
+
|
40
|
+
this.addChild( sprite )
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Loads the video file
|
45
|
+
*/
|
46
|
+
load () {
|
47
|
+
return this.__resource.load()
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Plays the video at a specific rate, or default if nothing is specified
|
52
|
+
* @param {Number} playbackRate
|
53
|
+
*/
|
54
|
+
play ( playbackRate ) {
|
55
|
+
if ( playbackRate ) {
|
56
|
+
this.__source.playbackRate = playbackRate
|
57
|
+
}
|
58
|
+
this.__source.play()
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Pause the video
|
63
|
+
*/
|
64
|
+
pause () {
|
65
|
+
this.__source.pause()
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Mutes or unmutes the video
|
70
|
+
* @param {boolean} muted
|
71
|
+
*/
|
72
|
+
muted ( muted ) {
|
73
|
+
this.__source.muted = !!muted
|
74
|
+
}
|
75
|
+
}
|
package/test/app.js
CHANGED
Binary file
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { approx, rnd, loop } from '@crispcode/modux'
|
4
4
|
|
5
|
-
import { Shimmer } from './../../../../scripts'
|
5
|
+
import { Shimmer, Video } from './../../../../scripts'
|
6
6
|
|
7
7
|
import { ButtonMain } from './buttonMain.js'
|
8
8
|
import { Moon } from './moon.js'
|
@@ -37,13 +37,16 @@ export class ShimmerComponent extends Shimmer {
|
|
37
37
|
'image2': '/image2.png'
|
38
38
|
} )
|
39
39
|
.then( ( resources ) => {
|
40
|
-
this.
|
40
|
+
this.__background = new Video( '/movie.mp4', { loop: false, autoPlay: true, muted: true } )
|
41
|
+
this.stage.addElementChild( 'background', this.__background )
|
42
|
+
|
43
|
+
this.__button = new ButtonMain( resources[ 'image1' ] )
|
41
44
|
this.stage.addElementChild( 'button', this.__button )
|
42
45
|
|
43
46
|
this.__moons = {}
|
44
47
|
|
45
48
|
for ( let i = 0; i < 20; i++ ) {
|
46
|
-
let moon = new Moon( resources[ 'image2' ]
|
49
|
+
let moon = new Moon( resources[ 'image2' ] )
|
47
50
|
moon.setAngle( rnd( 0, 359 ) )
|
48
51
|
moon.setRadius( rnd( 200, 500 ) )
|
49
52
|
moon.setSpeed( rnd( 10, 50 ) / 10 )
|
package/test/scripts/index.js
CHANGED
@@ -7,6 +7,8 @@ import { Module, logger } from '@crispcode/modux'
|
|
7
7
|
import { LayoutComponent } from './components/layout'
|
8
8
|
import { ShimmerComponent } from './components/shimmer'
|
9
9
|
|
10
|
+
import './../styles/index.scss'
|
11
|
+
|
10
12
|
let initialize = () => {
|
11
13
|
// Create application
|
12
14
|
let app = new Module( 'app' )
|