GithubHelp home page GithubHelp logo

Comments (9)

jnsmalm avatar jnsmalm commented on May 18, 2024 1

Thanks! I noticed the issue you are experiencing only first time in Safari (not after that), Chrome works fine for me). I think I know what the issue could be, I'll look into it.

from pixi3d.

jnsmalm avatar jnsmalm commented on May 18, 2024 1

Thanks for the help, fix is included in release 1.1.2.

from pixi3d.

jnsmalm avatar jnsmalm commented on May 18, 2024

I can load both of those models you linked to using this code:

let app = new PIXI.Application({
  backgroundColor: 0xdddddd, resizeTo: window, antialias: true
})
document.body.appendChild(app.view)

app.loader.add("assets/BarramundiFish.glb")

app.loader.load((_, resources) => {
  let model = app.stage.addChild(
    PIXI3D.Model.from(resources["assets/BarramundiFish.glb"].gltf))
})

You sure you downloaded those glb files correctly?

from pixi3d.

goldenratio avatar goldenratio commented on May 18, 2024

I am writing down my findings here,

this callback seems to be called multiple times, number of call is equal to number of images.
https://github.com/jnsmalm/pixi3d/blob/develop/src/gltf/gltf-asset.ts#L119

I think this kinda messes up the loader's next() call, https://github.com/jnsmalm/pixi3d/blob/develop/src/loader/gltf-binary-loader.ts#L14

Adding a setTimeout before adding to stage, seems to do the trick, example:

import * as PIXI from 'pixi.js';
import { Model } from 'pixi3d';

const app = new PIXI.Application({
	width: 600,
	height: 400,
	backgroundColor: 0x1099bb,
	resolution: window.devicePixelRatio || 1,
	sharedTicker: true,
});

document.body.appendChild(app.view);

PIXI.Loader.shared
	.add('barramundi-fish', './resources/barramundi-fish.glb')
	.load((_, resources) => {
	  // this fails
	  // @ts-ignore
          app.stage.addChild(Model.from(resources['barramundi-fish'].gltf));

           // this works
           // setTimeout(() => {
             // @ts-ignore
             // app.stage.addChild(Model.from(resources['barramundi-fish'].gltf));
           // }, 100);
	});

from pixi3d.

jnsmalm avatar jnsmalm commented on May 18, 2024

Which device/os/browser are you using?

from pixi3d.

goldenratio avatar goldenratio commented on May 18, 2024

mac os Catalina / Chrome

from pixi3d.

goldenratio avatar goldenratio commented on May 18, 2024

I created minimal reproducible demo,
https://goldenratio.github.io/pixi3d-poc-72/ (please, open dev console to see the error)

Here is the repo,
https://github.com/goldenratio/pixi3d-poc-72

mac os Catalina / Chrome
image

from pixi3d.

jnsmalm avatar jnsmalm commented on May 18, 2024

I have updated the develop branch with an update, it would be huge help if you would like to test the following (because I can't really reproduce it)

  1. Clone the repo git clone https://github.com/jnsmalm/pixi3d.git
  2. npm install
  3. Update the contents of the file /serve/src/index.js with the code below (pretty much a copy of your code)
  4. npm run serve
  5. Hopefully it will work now!

/serve/src/index.js

const app = new PIXI.Application({
	width: 600,
	height: 400,
	backgroundColor: 0x1099bb,
	resolution: window.devicePixelRatio || 1,
	sharedTicker: true,
});

document.body.appendChild(app.view);

PIXI.Loader.shared.add('barramundi-fish', './resources/barramundi-fish.glb').load((_, resources) => {
	// this should work now
	app.stage.addChild(PIXI3D.Model.from(resources['barramundi-fish'].gltf));

	// this works also
	// setTimeout(() => {
	// 	app.stage.addChild(PIXI3D.Model.from(resources['barramundi-fish'].gltf));
	// }, 100);
});

from pixi3d.

goldenratio avatar goldenratio commented on May 18, 2024

fix seems to work. Thanks!

image

from pixi3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.