morazan Posted March 17, 2018 Share Posted March 17, 2018 Greetings! I am a total newbie. For my first Pixi project I am trying to modify this awesome Codepen which integrates a photo with a dangling piece of interactive pixi-cloth: https://codepen.io/shshaw/pen/JbrQrW Instead of using the full screen, I want my photo to appear in a div, just like a regular photo. After much struggle I figured out how to append the canvas onto a div called "canvas-parent" instead of the body, and to force it to a fixed size of 350x500 instead of basing it on the screen size. I am using the codepen guy's code with the following changes: ```javascript var canvasContainer = document.getElementById('canvas-parent'); canvasContainer.appendChild(canvas); ... let renderer = PIXI.autoDetectRenderer(350, 500, {transparent: true }); ``` It took forever to figure out the CSS issues of absolute positioning, transparency, and z-index. Finally, I thought it was working great. But then I realized that my "cloth" was responding to mouse movements NOT at the new location inside my div, but at the old location -- starting at 0,0 relative to the body. As you can see, my mouse pointer is WAY over to the left side of the photo while the photo is reacting to it. For the life of me I can't figure out what I need to change to make my cloth respond to mouse events occurring INSIDE the region of my canvas/div. I have looked at the beginner materials on pixi site, but none of them show an example of the user interacting with a piece of cloth, and none of them show how to work inside of an HTML element. As you can see, I am tearing my hair out, so any pointer in the right direction would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 17, 2018 Share Posted March 17, 2018 Shameless promotion: https://github.com/gameofbombs/pixi-heaven has a cloth demo: https://gameofbombs.github.io/examples-heaven/#/mesh/plane.js Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 17, 2018 Share Posted March 17, 2018 InteractionManager doesnt account for CSS transforms. However, there's a workaround: https://github.com/pixijs/pixi.js/wiki/v4-Gotchas#css-transforms-on-canvas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.