question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use pixi3d with pixi-viewport?

See original GitHub issue

Hi,

First of all; great work! This is a very nice piece of tool to be able to use 3d inside pixi! Thanks a lot for this!

At the moment I’m learning all features of it. I’m stumbling on one thing though I can’t find the answer to so far: When adding the Model as a child of a pixi-viewport Container (which does scaling, dragging and all kind of cool stuff to navigate a 2d scene), the Model isn’t moving with it. This does work with other display objects, but unfortunately not with a pixi3d model. At least I can’t get it to work here.

How can we make the Model move and scale with the viewport (preferrably by not changing anything in the 3d object/scene nor the camera, so only its 2d ‘render’ output)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jnsmalmcommented, Feb 12, 2022

I fiddled around with the functions for texture in PixiJS. Might have found a solution for this. Let me know if it works for you, when maybe I can add it to the API. Also not entirely sure what you mean with PixiJS viewport, is this the same as the canvas?

In this example I render a 3d object using PostProcessingSprite. The sprite is scaled 4 times which makes it blurry by default. I can press A/Z to increase/decrease the resolution which changes the quality of the rendered output without changing the size of the sprite.

let sprite = app.stage.addChild(new PIXI3D.PostProcessingSprite(app.renderer, {
    objectToRender: world,
    width: 128,
    height: 128
  }))

  sprite.scale.set(4)

  function setResolution(resolution) {
    sprite.texture.setResolution(resolution)
    sprite.texture.resize(128, 128, true)
  }

  let resolution = 1
  document.addEventListener("keydown", e => {
    if (e.key === "a") {
      resolution = resolution * 2
      setResolution(resolution)
    }
    if (e.key === "z") {
      resolution /= 2
      setResolution(resolution)
    }
  })
1reaction
jnsmalmcommented, Feb 14, 2022

Glad it worked out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

davidfig/pixi-viewport - GitHub
A highly configurable viewport/2D camera designed to work with pixi.js. Features include dragging, pinch-to-zoom, mouse wheel zooming, decelerated dragging, ...
Read more >
How to use the pixi-viewport function in pixi-viewport - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Pixi3D - The 3D renderer for PixiJS. Seamless integration with ...
The 3D renderer for PixiJS. Seamless integration with 2D applications. Get started API GitHub · Desert racing · Walrus cave · Pink cube...
Read more >
Stylized ocean scene created using Pixi3D - YouTube
Stylized ocean scene created using Pixi3D - The 3D renderer for PixiJS. The realtime demo and more can be found at https:// pixi3d....
Read more >
pixi-viewport examples - CodeSandbox
Learn how to use pixi-viewport by viewing and forking pixi-viewport example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found