Quantcast
Channel: Pixi.js Latest Topics
Viewing all 3978 articles
Browse latest View live

The "Learn Pixi.js" book. TypeScript Port

$
0
0

This is an official link to original book examples: https://github.com/kittykatattack/learningPixi

I will public examples on:

  • Playground. You will be able to see a code and a result. I use complication to  AMD modules (Asynchronous Module Definition) and the RequireJS library to load AMD modules
  • GitHub Pages. I use compilation to CommonJS modules. I bundle JS files to bundle.min.js using Browserify and minify it to bundle.min.js using UglifyJS
  • Source code on GitHub: will be later

I will NOT use Webpack, Gulp, Grunt and so on. I will public the instruction on GitHub how to build examples locally in the README.md file.

Note. Release version is loaded more quickly, but on playground you can see a code, you can make a fork, change the code and save it with new link.

  1. Hello World: playground, release
  2. Displaying the canvas: playground, release

  3.  Sprite From Image: playground


Top-Down Tank Game Showcase

iOS 13: WebGL: INVALID_VALUE: uniform1iv: invalid texture unit

$
0
0

Hello is anyone else experiencing this error on iOS 13:

WebGL: INVALID_VALUE: uniform1iv: invalid texture unit

Here's the full message:

[Warning] Turning drawing buffer preservation for the WebGL canvas being captured (0.0.js, line 6472)
[Error] WebGL: INVALID_VALUE: uniform1iv: invalid texture unit
	uniform1iv
	anonymous (Anonymous Script 1 (line 7))
	syncUniforms (0.0.js:9832)
	syncUniformGroup (0.0.js:9818)
	anonymous (Anonymous Script 2 (line 22))
	syncUniforms (0.0.js:9832)
	syncUniformGroup (0.0.js:9818)
	bind (0.0.js:9791)
	_render (5.5.js:5905)
	render (0.0.js:14434)
	render (0.0.js:14439)
	render (0.0.js:14439)
	render (0.0.js:14439)
	renderAdvanced (0.0.js:14492)
	render (0.0.js:14430)
	render (0.0.js:14439)
	render (0.0.js:11619)
	render (5.5.js:748)
	emit (0.0.js:17454)
	update (0.0.js:17993)
	(anonymous function) (0.0.js:17692)

 

pixi.js 5.1.5 - "Cannot read property 'start' of undefined"

Maintaining Sharpness while Downscaling Large Sprites

$
0
0

I have a program where images are shown in normal HTML <img> tags as well as inside of PIXI canvases. If I have a large image, I notice it has very crisp edges even when shown at ~1% of its size. The pixi.js canvas is using pixi-viewport (https://www.npmjs.com/package/pixi-viewport) so I can zoom in and out, and I noticed that if I zoom out so that the image is the same size as the HTML one, the edges look blurry. I've tried changing the SCALE_MODE and resolution, tried forcing the canvas renderer or forcing FXAA, and even the image-rendering css property, but I can't seem to make it look like the image inside the <img> tag. This is what I'm seeing:

image.png.7cadc29ef0457301de78cc68827f0f83.png

 

To be clear, the one on the left is inside the <img> and the one on the right is inside a pixi.js canvas. Despite them being about the same size, you'll notice its less clear. 

If I change the SCALE_MODE it just looks pixelated. If I change the resolution (I've tried 1, 2, 4, and 10) I have to zoom in more, but once I have its just as blurry. Forcing the canvas renderer just made it look worse, and FXAA didn't seem to change anything. The image-rendering property seemed to have no effect except on the pixelate setting (which, obviously, just made it look pixelated).

Edit: For reference I'm using pixi.js-4.5.3 and pixi-viewport-3.23.1

Pixi.js Showcase

$
0
0

Made anything cool with pixi.js? Post it up here and share it with the world!

 

Whether it's a cool game demo, a fully fledged website or some tripped-out crazy experiment, we would all LOVE to see it!

 

To get the ball rolling, here are some pixi.js projects that exist out on the internets:

 

games:

 

http://www.goodboydigital.com/runpixierun/

http://www.theleisuresociety.co.uk/fightforeveryone/

http://flashvhtml.com/

 

experiments:

 

http://gametest.mobi/pixi/morph/

http://gametest.mobi/pixi/balls/

http://www.goodboydigital.com/pixijs/bunnymark/

 

 

 

 

 

How to read the pixel at a specific coordinate from color buffer?

$
0
0

Hello, 

Currently I am working on a map application which can let the users to interactive with huge amount of entities including points and polygons. I use leaflet map framework and a library called PixiOverlay to achieve that. The data are stored in particleContainer and also indexed by kd-tree. Therefore, we can select entities on the map by searching the coordinates of a click event in the tree.

Now I want to implement an onHover function that changes the appearance of cursor when the mouse pointer hovers on the entities. Soon I noticed that continually search in the tree takes too much time when the amount of entities is huge.

Although I am new to WebGL, I still tried hard to google for potential solutions. I found there is a color picking algorithm which includes the step "Read the pixel at location (mouse_x,mouse_y) from the color buffer which identifies the object." Is it also possible to read the color of a pixel directly in pixi.js?

Thanks.

Untitled.png

Looking for old pixi tech demo

$
0
0

I can't seem to find it, but thought it did a good job of showcasing Pixi's capabilities and speed and wished to show it to someone.

It had those bunny sprites used in the documentation but you could just keep dumping more in and they'd bounce around the container and it was lag free.  I know it's not a typical question but spend 30 mins looking for it so thought maybe one of you guys had it bookmarked.


Set absolute position

$
0
0

Hello,

I want to set the absolute position of a graphic to 0, if goes out of bounds. However, after a few hours I was not able to do this.

This is my code:

import * as PIXI from 'pixi.js'

const app = new PIXI.Application({
	width: window.innerWidth,
	height: window.innerHeight,
	antialias: true,
	view: document.querySelector('#canvas'),
})

const container = new PIXI.Container()
app.stage.addChild(container)

let graphics = new PIXI.Graphics()

for (let i = 0; i <= 0; i++) {
	graphics.beginFill(0xFFFFFF)
	graphics.drawCircle(
		Math.random() * app.renderer.width,
		Math.random() * app.renderer.height,
		10,
	)
	graphics.endFill()
}

container.addChild(graphics)

app.ticker.add((delta) => {
	container.children.forEach((circle) => {
		circle.x += 10 * delta

		if (circle.x >= app.renderer.width) {
			circle.x = 0
		}
	})
})

 

Need help with shader code

$
0
0

I'm very new to shaders and trying to create a zoom blur effect on a container. I have one uniform 'center' where i just give it some coordinates. But this just gives me a black screen. I would love any help with this.

I'm trying to convert the code from https://www.shadertoy.com/view/3slSRj

Here's the shader code:

precision mediump float;
    
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform vec3 iResolution;
uniform vec2 center;

void main()
{
	float focusPower = 10.0;
    const int focusDetail = 7;

    vec2 uv = vTextureCoord.xy / iResolution.xy;
    vec2 mousePos = center.xy / iResolution.xy;
	vec2 focus = uv - mousePos;

    vec4 outColor;
    outColor = vec4(0, 0, 0, 1);

    for (int i=0; i<focusDetail; i++) {
        float power = 1.0 - focusPower * (1.0/iResolution.x) * float(i);
        outColor.rgb += texture2D(uSampler, focus * power + mousePos).rgb;
    }
    
    outColor.rgb *= 1.0 / float(focusDetail);

	gl_FragColor = outColor;
}

Thanks in advance!

How to add login form and a data table to pixijs application

$
0
0

Hi every one...

I am very new to pixijs...  need do a userlogin screen, I am unable to figure out how to add a textbox to  canvas .. please let me know how can I do that..

and I want present the table of data.. in the next screen as well so let me now how to add a table as like object to the canvas..

Thank you for your time..

 

Sprite texture from dynamically rendered SVG?

$
0
0

Hi Everyone!

Just a quick (hopefully!) general question for someone who might have done something like this before. I'm working on a game with lots of speech bubbles. The bubbles can contain a variable amount of text, so they would need to dynamically scale based on how much text they contain. The text also needs to be screen-reader accessible, so it can't be purely embedded in a bitmap. I'm thinking of dynamically rendering the speech bubbles with text as SVG. My question is: can I use the dynamically rendered SVG as a Pixi sprite texture?

Thank you!

 

How to preprocess content in the loader?

$
0
0

Hi all,

I'm trying to add SVGZ (gzipped SVG) support to Pixi loader in our game app. Pixi 5 has loader plugins but we have to use Pixi 4.8 so far. Is it possible to deflate loaded SVGZ images before Pixi parses them as SVG ? I've found some hints about afterMiddleware event and after() method but still can't figure it out.

Loading Sounds and Json...?

$
0
0

Hi Everyone!

Just wondering what the state of Pixi's loader is these days: Does it handle sound files and Json? 

I remember trying to load sounds with the version used in 3.x, I had to set extensions Resource.LOAD_TYPE.XHR and Resource.XHR_RESPONSE_TYPE.BUFFER for each sound file type. Is this still something I'll need to do.

How about JSON, can I just load that as-is?

Thanks!


 

Layered Lighting System Using Masks Issue

$
0
0

I've been trying to sort this out for a bit. I'll try to keep it simple.

I'm using pixi-layers & pixi v4.

I have Sprites that use a texture (generally png) as a light. This gets added to the stage and assigned to a sorting group. Layering works fine at this point.

Next is ambient lighting, it's also added to the stage at the highest zIndex and assigned to the sorting group so (obviously it renders above everything else).

Next each light has a mask that is based off of the Sprites texture.

This gets added to the ambient lighting container. Herein lies the problem.

The mask in the ambient lighting container, of course renders at the same zIndex that the ambient lighting container is at and not at the zIndex that the light sprite is at.

The mask should render at the same zIndex as the light sprite.

Any suggestions on how to go about this?

 

Thanks! I've attached an example screenshot of my current results.

As you can see the light sprite renders at the proper zIndex (lets say 3 for example).

The tree renders at zIndex 4 for example.

The mask renders above the tree (which it shouldn't).

Screen Shot 2019-10-24 at 8.55.30 PM.png


Playable Ads with Pixi Js

$
0
0

Hey! I was wondering if Pixi JS is a good engine to create Playable Ads!

For a playable ad I need a single html file with embedded assets and inline javascript. Is there a possibility to do it in Pixi or
is there a simple solution in the internet to do it after I created the playable in Pixi?

Thanks for your help !

How does PixiJS transform sprites?

$
0
0
When I create a custom fragment shader and attach it to some sprite, the fragment shader works with some bounding rectangle of the sprite but not with the transformed quad.
When sprited rotated, this rectangle remains perpendicular to the coordinate axis. You can take a look at this example: https://jsfiddle.net/q2rux5wc/ (the red zone is this "bounding rectangle").
In my understanding, when we rotate the sprite, a different matrix should be passed into the vertex shader, it should transform the input quad, then the fragment shader works with transformed quad.
But looks like PixiJS uses another approach. So can somebody explain (or give some links) how it's implemented in PixiJS and why?

bitwise operator not supported?

$
0
0

I'm trying to use '>>' and '&' in fragment code for a Filter. It said bit-wise operator supported in GLSL ES 3.00 and above only". I tried adding "#version 300 es" to the top of my fragment shader code, but it keeps giving me "#version directive must occur before anything else, except for comments and white space" (it's at the very top, without any white space too)

How can I enable bitwise operators? Or is there an alternative?

Curved and dashed line

$
0
0

Hi community,

I want to generate a dashed curve in PixiJs and need a little help.

I want these results:   

https://i.ibb.co/5RNR2h8/Bildschirmfoto-2019-10-29-um-07-10-15.png

https://i.ibb.co/xqxqw5N/Bildschirmfoto-2019-10-29-um-07-10-28.png

 

My first attempt was to use the 'bezierCurve' function, but a dashed curve in combination with this seems impossible.

So I created a loop with many straight lines to create the dashed optic and it works for a straight line.

        const line_amount = 20;
        const space = 300;
        for (let i = 1; i < line_amount; i++) {

            let percent = ((100 / line_amount) / 100) * i;
            let percent2 = (((100 / line_amount) / 100) * i) + 0.02;

            path_line.moveTo(start_x, start_y);
            path_line
                .lineTo(((-space * percent) + start_x), (last_calc_position_y * percent))
                .moveTo(((-space * percent2) + start_x), (last_calc_position_y * percent2));
        }

But how to get a curve with this attempt?

I think you can add some x and y value in the process, then remove it, but all my tries looking horrible.

Probably is a mathematic approach the right direction.

 

Please help. I spend two days to this and get no good result.

Pixi.js Showcase

$
0
0

Made anything cool with pixi.js? Post it up here and share it with the world!

 

Whether it's a cool game demo, a fully fledged website or some tripped-out crazy experiment, we would all LOVE to see it!

 

To get the ball rolling, here are some pixi.js projects that exist out on the internets:

 

games:

 

http://www.goodboydigital.com/runpixierun/

http://www.theleisuresociety.co.uk/fightforeveryone/

http://flashvhtml.com/

 

experiments:

 

http://gametest.mobi/pixi/morph/

http://gametest.mobi/pixi/balls/

http://www.goodboydigital.com/pixijs/bunnymark/

 

 

 

 

 

Viewing all 3978 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>