Siddi

Members
  • Content Count

    12
  • Joined

  • Last visited

  1. Siddi

    Dispatch Events

    I assume that the interaction manager works, and want to test my own code. I found a solution for me. I fire standard JavaScript events (MouseEvent and PointerEvent) directly on the canvas element. The rest (triggering the events on a certain DisplayObject) then takes over pixi for me. It is easier than expected 🙂, thank you!
  2. Siddi

    Dispatch Events

    OK, thank you!
  3. Siddi

    Dispatch Events

    I've looked into the sources, but still don't know if it's best to use app.renderer.plugins.interaction.emit('pointerup', originalEvent) or app.renderer.plugins.interaction.onPointerUp(originalEvent) But I think both should work, or not?
  4. Siddi

    Dispatch Events

    Hi, I'd like to develop some automated UI tests for my PixiJS application (PixiJS 4.8.1). My test procedure should look something like this later: const test = new UITest() test.click({x: 100, y: 80}) test.drag({x: 100, y: 80}, {x: 120, y: 40}) test.dblClick({x: 200, y: 120}) etc. For this I have to trigger events. I know that the InteractionManager and DisplayObject inherit from EventEmitter. Which option is the best way to trigger events? 1. directly on the canvas element? const originalEvent = new MouseEvent('click', { bubbles: true, cancelable: true, ... }) app.view.dispatchEvent(originalEvent) 2. or via app.renderer.plugins.interaction.onPointerUp (originalEvent) for example? 3. or via app.renderer.plugins.interaction.emit(originalEvent) Unfortunately, I have not yet managed to trigger an event with these three ways 😞 What already worked was to call the emit method directly on a PIXI.DisplayObject, but I needed to create a PIXI.InteractionEvent object myself, which was quite expensive ... Thanks in advance! Siddi
  5. Siddi

    Add raw WebGL texture to Pixi.js

    Thank you for your support!!
  6. Siddi

    Add raw WebGL texture to Pixi.js

    So, is it best to call app.renderer.reset() ?
  7. Siddi

    Add raw WebGL texture to Pixi.js

    I just found out, that if I add the line sprites.forEach(sprite => app.renderer.unbindTexture(sprite.texture)) before calling sprite._texture.baseTexture._glTextures[app.renderer.CONTEXT_UID].texture = tex.data it works, but I don't know why?
  8. Siddi

    Add raw WebGL texture to Pixi.js

    It is called only once, just inside the fromSource-method: Texture.fromSource = function(gl, source, premultiplyAlpha) { var texture = new Texture(gl); texture.premultiplyAlpha = premultiplyAlpha || false; texture.upload(source); return texture; }; After this call, the third Sprite turns black...
  9. Siddi

    Add raw WebGL texture to Pixi.js

    Thanks for your answer! Interesting new features in version 5. I can not wait for it to be released ;-) I tried to use PIXI.glCore.GLTexture.fromSource(). First, three sprites are loaded and added to the Stage: const loader = new PIXI.loaders.Loader() loader.add(`../../var/textures/tiles/20/301520/354150.png`) loader.add(`../../var/textures/tiles/20/301521/354150.png`) loader.add(`../../var/textures/tiles/20/301522/354150.png`) let x = 100 loader.load(function(loader, resources) { let sprites = [] for (let id in resources) { let sprite = new PIXI.Sprite(resources[id].texture) sprite.width = sprite.height = 100 sprite.x = x sprite.y = 100 x += 100 sprites.push(sprite) } app.stage.addChild(...sprites) setTimeout(function() { loadWebGlTexture() }, 1000) }) After one second, loadWebGlTexture() is called: function loadWebGlTexture() { const url = `../../var/textures/tiles/20/301436/354176.png` let image = new Image() image.addEventListener('load', function () { let texture = PIXI.glCore.GLTexture.fromSource(app.renderer.gl, image, false) }, false) image.addEventListener('error', function(error) { console.error(error) }, false) image.src = url } Inside this function, as soon as the line "PIXI.glCore.GLTexture.fromSource" is called, the last added Sprite turns black: I still don't know why the texture is automatically exchanged? Do you have any idea?
  10. Hi, I want to create a PIXI.Texture from a WebGL texture. Unfortunately, I have not managed this yet. My WebGL texture is created in the same WebGL renderer context as Pixi with "app.renderer.gl.createTexture()", this works. Then I tried to hang the texture on an existing PIXI.Texture: sprite.texture.baseTexture._glTextures[app.renderer.CONTEXT_UID].texture = myWebglTexture Even without the above line of code, my WebGL texture is inserted into the canvas element and always swaps the texture of the last sprite loaded in Pixi (Change-Texture.mp4). Unfortunately I cannot swap my WebGL Texture with a texture of a specific sprite :-( This approach has unfortunately not worked: Does anyone have an idea? Thank you for your support!
  11. Siddi

    Retina Resolution Question

    Perfect, thank you!!!
  12. Siddi

    Retina Resolution Question

    Hi, I have a question about the resolution in PIXI.js: If I create a PIXI.Graphic object (for example a rectangle) with the size 50 pixels by 50 pixels, this rectangle will be the same size on my desktop machine (devicePixelRatio 1) as a 50 pixel by 50 pixel div element. When I look at the same page with an iPad Air 2 (devicePixelRatio 2), the rectangle drawn with PIXI is twice the size of the div element. In my opinion, on the iPad, both elements should be equally large, right? I have created a CodePen: http://codepen.io/fresh5/pen/jBxNjO Thanks for your support!