Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not use editor export json file #185

Open
kawais opened this issue Sep 29, 2022 · 4 comments
Open

can not use editor export json file #185

kawais opened this issue Sep 29, 2022 · 4 comments

Comments

@kawais
Copy link

kawais commented Sep 29, 2022

json is download from editor, but occur error:
Cannot use 'in' operator to search for 'framerate' in undefined
pixi version: 6.5.4
particle-emitter version: 5.0.7
`
var json={
"alpha": {
"start": 1,
"end": 0
},
"scale": {
"start": 0.1,
"end": 0.01,
"minimumScaleMultiplier": 1
},
"color": {
"start": "#e4f9ff",
"end": "#3fcbff"
},
"speed": {
"start": 200,
"end": 50,
"minimumSpeedMultiplier": 1
},
"acceleration": {
"x": 0,
"y": 0
},
"maxSpeed": 0,
"startRotation": {
"min": 0,
"max": 360
},
"noRotation": false,
"rotationSpeed": {
"min": 0,
"max": 0
},
"lifetime": {
"min": 0.2,
"max": 0.8
},
"blendMode": "normal",
"frequency": 0.001,
"emitterLifetime": -1,
"maxParticles": 500,
"pos": {
"x": 0,
"y": 0
},
"addAtBack": false,
"spawnType": "circle",
"spawnCircle": {
"x": 0,
"y": 0,
"r": 0
}
}

var emitterContainer = new PIXI.Container()
var emitter = new particles.Emitter(
emitterContainer,
particles.upgradeConfig(json, [])
);
app.stage.addChild(emitterContainer)

// Calculate the current time
var elapsed = Date.now();

// Update function every frame
var update = function () {

// Update the next frame
requestAnimationFrame(update);

var now = Date.now();

// The emitter requires the elapsed
// number of seconds since the last update
emitter.update((now - elapsed) * 0.001);
elapsed = now;

};

// Start emitting
emitter.emit = true;

// Start the update
update();

`

@andrewstart
Copy link
Contributor

The second parameter for upgradeConfig() must be an array of textures or urls to textures - it is throwing the error because you have an empty array there.

@GuanTina
Copy link

How to get textures or urls to textures , I met the same question, and I can not understand how to get the second parameter?

@andrewstart
Copy link
Contributor

Because texture usage and urls are specific to your build process and hosting, there is no way for the editor to give you a url - you have to generate and provide that yourself.

@thegoldenmule
Copy link

thegoldenmule commented Feb 14, 2024

Incredibly unhelpful answer. This particle library has to be one of the worst documented projects I've ever tried to use. Good lord.

Anyway, @GuanTina to answer your actual question instead of acting like you're an idiot:

  1. Scroll down on the particle editor window until you see the "Particle Images" section:
image
  1. Download that image and serve it so that your application can download it. For instance, I'm using NextJS, so I can stick this image file in my public/ directory.

  2. When you call upgradeConfig, you need to pass the path to this particle. Full example here:

const config = upgradeConfig(
  {
		"alpha": {
			"start": 0.29,
			"end": 0
		},
		"scale": {
			"start": 0.5,
			"end": 20,
			"minimumScaleMultiplier": 1
		},
		"color": {
			"start": "#ffffff",
			"end": "#ffffff"
		},
		"speed": {
			"start": 2000,
			"end": 3000,
			"minimumSpeedMultiplier": 1
		},
		"acceleration": {
			"x": 0,
			"y": 0
		},
		"maxSpeed": 0,
		"startRotation": {
			"min": 65,
			"max": 65
		},
		"noRotation": false,
		"rotationSpeed": {
			"min": 0,
			"max": 0
		},
		"lifetime": {
			"min": 0.81,
			"max": 0.81
		},
		"blendMode": "screen",
		"frequency": 0.01,
		"emitterLifetime": -1,
		"maxParticles": 1000,
		"pos": {
			"x": 0,
			"y": 0
		},
		"addAtBack": false,
		"spawnType": "rect",
		"spawnRect": {
			"x": -600,
			"y": -460,
			"w": 900,
			"h": 20
		}
	}
), ["/particle.png"]);

const emitter = new Emitter(
  myParticleContainer,
  config);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants