vanilladocs
vanillapunch.com
API / effect/particlesystem

effect/particlesystem

파티클 시스템.

Particle system.

ParticleSystemextends Component

짝Counterpart: vanilla-engine ParticleSystem

파티클 시스템.

  • 유니티 ParticleSystem 의 자주 쓰는 부분을 2D 로 옮긴 컴포넌트. 방출(rate / burst), 모양(shape), 수명 / 속도 / 크기 / 회전 / 색의 시작 범위, 수명에 따른 크기 / 색 / 회전 변화, 중력 / 감쇠, 가산 합성, 이미지 스프라이트를 지원한다.
  • 사용:
const particleSystem = node.addComponent(ParticleSystem);
particleSystem.setEmissionRate(40);
particleSystem.setStartLifetime(0.6, 1.2);
particleSystem.setStartSpeed(40, 120);
particleSystem.setColorOverLifetime([
    { time: 0, color: new Color(1, 0.8, 0.3, 1) },
    { time: 1, color: new Color(1, 0.2, 0, 0) },
]);
particleSystem.play();

Particle system.

  • A component that ports the commonly used parts of Unity's ParticleSystem to 2D. Supports emission (rate / burst), shape, start ranges for lifetime / speed / size / rotation / color, size / color / rotation over lifetime, gravity / damping, additive blending, and image sprites.
  • Usage:
const particleSystem = node.addComponent(ParticleSystem);
particleSystem.setEmissionRate(40);
particleSystem.setStartLifetime(0.6, 1.2);
particleSystem.setStartSpeed(40, 120);
particleSystem.setColorOverLifetime([
    { time: 0, color: new Color(1, 0.8, 0.3, 1) },
    { time: 1, color: new Color(1, 0.2, 0, 0) },
]);
particleSystem.play();
예제Example노드에 붙여 불꽃 뿜기Attach to a node and spout flames
import { Engine, EngineConfiguration, Scene, WorldNode, ParticleSystem, ParticleEmitterShape, Color, Vector2 } from "./build/vanilla.js";

class MainScene extends Scene {
	initialize(engine) {
		super.initialize(engine);
		const node = new WorldNode();
		node.setLocalPosition(Vector2.create(320, 300));
		const root = this.getRoot();
		root.addChild(node);
		const particleSystem = node.addComponent(ParticleSystem);
		particleSystem.setEmitterShape(ParticleEmitterShape.cone);
		particleSystem.setShapeRadius(10);
		particleSystem.setConeAngle(0.3);
		particleSystem.setEmissionRate(60);
		particleSystem.setStartLifetime(0.6, 1.2);
		particleSystem.setStartSpeed(40, 120);
		particleSystem.setStartSize(10, 18);
		particleSystem.setSizeOverLifetime(1, 0.2);
		particleSystem.setColorOverLifetime([
			{ time: 0, color: new Color(1, 0.8, 0.3, 1) },
			{ time: 1, color: new Color(1, 0.2, 0, 0) },
		]);
		particleSystem.setAdditive(true);
		particleSystem.play();
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
Attach to a node and spout flames
생성자constructorconstructor()#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

짝Counterpart: vanilla-engine ParticleSystem.new

메서드methodplay()#0.3.0 부터since 0.3.0소스source

재생 / 정지.

Play / stop.

짝Counterpart: vanilla-engine ParticleSystem.play

메서드methodstop(isClearing = false)#0.3.0 부터since 0.3.0소스source

정지. (방출을 멈춘다, 살아 있는 파티클은 isClearing 이 아니면 수명까지 움직인다)

Stops. (stops emitting, living particles keep moving until their lifetime ends unless isClearing)

isClearingboolean
참이면 살아 있는 파티클도 지운다.If true, also clears living particles.

짝Counterpart: vanilla-engine ParticleSystem.stop

메서드methodemit(count, worldOffset = null)#0.3.0 부터since 0.3.0소스source

한 번에 여러 개 방출. (버튼 클릭 등 이벤트성 연출)

Emits several at once. (event effects such as button clicks)

countnumber
방출할 수. (최대 수에 닿으면 더 만들지 않는다)Number to emit. (no more are made once the maximum count is reached)
worldOffsetVector2 | null
방출 원점 보정. (노드 로컬 기준)Emission origin offset. (in node local space)

짝Counterpart: vanilla-engine ParticleSystem.emit

메서드methodtick(timeDelta)#0.3.0 부터since 0.3.0소스source

갱신. (노드 갱신, 수동 틱이면 건너뛴다)

Update. (node update, skipped in manual tick mode)

timeDeltanumber
지난 시간. (초)Elapsed time. (seconds)
메서드methodsimulate(timeDelta)#0.3.0 부터since 0.3.0소스source

시간 진행. (방출 + 적분, 수동 틱 모드에서는 외부가 부른다)

Advances time. (emission + integration, called externally in manual tick mode)

timeDeltanumber
진행할 시간. (초)Time to advance. (seconds)

짝Counterpart: vanilla-engine ParticleSystem.simulate

메서드methoddraw(graphic)#0.3.0 부터since 0.3.0소스source

출력. (정점 색 배치, 파티클 수와 무관하게 시스템당 드로우 한 번)

  • circle 은 부드러운 원 텍스처, rect / streak 은 흰 텍스처 쿼드로 그린다. image 는 파티클 수가 적다는 가정으로 개별 드로우를 유지한다.

Output. (vertex color batching, one draw per system regardless of particle count)

  • circle draws with a soft circle texture, rect / streak with white texture quads. image keeps individual draws on the assumption that particle counts are small.
graphicGraphic
그릴 그래픽.Graphic to draw with.
메서드methodcalculateDrawnRect(rect)#0.4.0 부터since 0.4.0소스source

그리는 사각형 셈하기. (오버라이드: 살아 있는 파티클이 그리는 쿼드를 모두 품는 사각형, 노드 내용 좌표)

  • 파티클마다 그리는 크기의 반에 √2 를 곱한 만큼(돌린 사각형, 그림), 꼬리 쿼드면 머리와 꼬리를 품고 굵기의 반만큼, 흔들림 폭만큼 좌우를 넓히고 한 단위 여유를 둔다.
  • 시뮬레이션(simulate)이 돌 때마다, 방출(emit)과 지움(stop)에, 그리는 꼴을 바꾸는 세터에 다시 셈하게 알린다. (그리는 것이 화면 밖이면 그리기를 건너뛰고 시뮬레이션은 tick 이라 그대로 돈다)
  • 파티클이 없으면 크기 0 (그리지 않는다).
  • 월드 공간이면서 수동 틱이면 모른다. (노드를 옮기면 그리는 자리가 바뀌는데 그때 다시 셈할 길이 없다)

Calculates the drawn rectangle. (Override: a rectangle enclosing every quad the live particles draw, in node content coordinates)

  • Each particle grows by half its drawn size times √2 (rotated rectangles, images), streak quads enclose head and tail grown by half the width, the wobble amplitude is added left and right, plus one unit of margin.
  • Recalculation is requested whenever the simulation (simulate) runs, on emit and on clearing (stop), and in setters that change how particles are drawn. (Drawing is skipped when off screen while the simulation keeps running in tick)
  • With no particles the size is 0 (nothing is drawn).
  • Unknown when in world space with manual tick. (Moving the node moves where it draws and there is no point at which to recalculate)
rectRect
그리는 사각형을 적을 곳. (노드 내용 영역의 왼쪽 위가 원점)Where to write the drawn rectangle. (origin at the top-left of the node's content area)

반환Returnsboolean 알면 참.True if known.

예제Example방출한 파티클을 품는 사각형A rectangle enclosing emitted particles
import { WorldNode, ParticleSystem, Rect } from "./build/vanilla.js";

const node = new WorldNode();
const particleSystem = node.addComponent(ParticleSystem);
particleSystem.setStartSpeed(0);
particleSystem.setStartSize(10);
particleSystem.emit(3);
const drawnRect = Rect.zero();
console.log(particleSystem.calculateDrawnRect(drawnRect), drawnRect.size.x > 0);
메서드methodsetEmissionRate(emissionRate)#0.3.0 부터since 0.3.0소스source

초당 방출 수 설정. (기본 20)

Sets the emission count per second. (default 20)

emissionRatenumber
초당 방출 수.Emissions per second.

짝Counterpart: vanilla-engine ParticleSystem.set_emission_rate

메서드methodsetBurstList(burstList)#0.3.0 부터since 0.3.0소스source

버스트 목록 설정. (정한 때에 한꺼번에 방출한다, 루프면 duration 마다 되풀이)

Sets the burst list. (emits all at once at the given times, repeats every duration when looping)

burstListobject[]
[{ time, count }]

짝Counterpart: vanilla-engine ParticleSystem.set_burst_list

예제Example한 번 터지고 끝나는 폭죽A firework that bursts once and ends
import { Engine, EngineConfiguration, Scene, WorldNode, ParticleSystem, ParticleEmitterShape, Vector2 } from "./build/vanilla.js";

class MainScene extends Scene {
	initialize(engine) {
		super.initialize(engine);
		const node = new WorldNode();
		node.setLocalPosition(Vector2.create(320, 180));
		const root = this.getRoot();
		root.addChild(node);
		const particleSystem = node.addComponent(ParticleSystem);
		particleSystem.setLooping(false);
		particleSystem.setDuration(0.5);
		particleSystem.setEmissionRate(0);
		particleSystem.setBurstList([
			{ time: 0, count: 40 },
			{ time: 0.3, count: 20 },
		]);
		particleSystem.setEmitterShape(ParticleEmitterShape.circle);
		particleSystem.setShapeRadius(4);
		particleSystem.setStartSpeed(80, 200);
		particleSystem.setGravity(0, 300);
		particleSystem.play();
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
메서드methodsetEmitterShape(emitterShape)#0.3.0 부터since 0.3.0소스source

방출 모양 설정. (기본 point)

Sets the emitter shape. (default point)

emitterShapestring
ParticleEmitterShape 값.ParticleEmitterShape value.

짝Counterpart: vanilla-engine ParticleSystem.set_emitter_shape

메서드methodsetShapeRadius(shapeRadius)#0.3.0 부터since 0.3.0소스source

방출 반지름 설정. (픽셀, 기본 0)

Sets the emission radius. (pixels, default 0)

shapeRadiusnumber
circle / cone 반지름.circle / cone radius.

짝Counterpart: vanilla-engine ParticleSystem.set_shape_radius

메서드methodsetConeAngle(coneAngleRadian)#0.3.0 부터since 0.3.0소스source

cone 반각 설정. (기본 0.5 라디안)

Sets the cone half angle. (default 0.5 radians)

coneAngleRadiannumber
cone 반각. (라디안)cone half-angle. (radians)

짝Counterpart: vanilla-engine ParticleSystem.set_cone_angle

메서드methodsetBoxSize(width, height)#0.3.0 부터since 0.3.0소스source

box 크기 설정. (픽셀, 기본 0, 0)

Sets the box size. (pixels, default 0, 0)

widthnumber
box 가로.box width.
heightnumber
box 크기.box size.

짝Counterpart: vanilla-engine ParticleSystem.set_box_size

메서드methodsetEdgeWidth(edgeWidth)#0.3.0 부터since 0.3.0소스source

edge 길이 설정. (픽셀, 기본 0)

Sets the edge length. (pixels, default 0)

edgeWidthnumber
edge 가로 길이.edge width.

짝Counterpart: vanilla-engine ParticleSystem.set_edge_width

메서드methodsetStartLifetime(minSeconds, maxSeconds = minSeconds)#0.3.0 부터since 0.3.0소스source

시작 수명 범위 설정. (기본 1 초)

Sets the start lifetime range. (default 1 second)

minSecondsnumber
수명 최솟값. (초)Minimum lifetime. (seconds)
maxSecondsnumber
수명 최댓값. (초, 주지 않으면 최솟값)Maximum lifetime. (seconds, the minimum if omitted)

짝Counterpart: vanilla-engine ParticleSystem.set_start_lifetime

메서드methodsetStartSpeed(minSpeed, maxSpeed = minSpeed)#0.3.0 부터since 0.3.0소스source

시작 속력 범위 설정. (기본 60)

Sets the start speed range. (default 60)

minSpeednumber
속력 최솟값. (초당 픽셀)Minimum speed. (pixels per second)
maxSpeednumber
속력 최댓값. (초당 픽셀, 주지 않으면 최솟값)Maximum speed. (pixels per second, the minimum if omitted)

짝Counterpart: vanilla-engine ParticleSystem.set_start_speed

메서드methodsetStartSize(minSize, maxSize = minSize)#0.3.0 부터since 0.3.0소스source

시작 크기 범위 설정. (기본 6)

Sets the start size range. (default 6)

minSizenumber
크기 최솟값. (픽셀)Minimum size. (pixels)
maxSizenumber
크기 최댓값. (픽셀, 주지 않으면 최솟값)Maximum size. (pixels, the minimum if omitted)

짝Counterpart: vanilla-engine ParticleSystem.set_start_size

메서드methodsetStartRotation(minRadian, maxRadian = minRadian)#0.3.0 부터since 0.3.0소스source

시작 회전 범위 설정. (기본 0)

Sets the start rotation range. (default 0)

minRadiannumber
회전 최솟값. (라디안)Minimum rotation. (radians)
maxRadiannumber
회전 최댓값. (라디안, 주지 않으면 최솟값)Maximum rotation. (radians, the minimum if omitted)

짝Counterpart: vanilla-engine ParticleSystem.set_start_rotation

메서드methodsetStartColor(colorA, colorB = colorA)#0.3.0 부터since 0.3.0소스source

시작 색 범위 설정. (기본 흰색)

Sets the start color range. (default white)

colorAColor | string
시작 색. (복사해 둔다)Start color. (kept as a copy)
colorBColor | string
둘 사이 무작위.Random between the two.

짝Counterpart: vanilla-engine ParticleSystem.set_start_color

메서드methodsetColorOverLifetime(gradient)#0.3.0 부터since 0.3.0소스source

수명에 따른 색 설정. (시작 색에 곱한다, 키 사이는 선형 보간)

Sets the color over lifetime. (multiplied with the start color, linear interpolation between keys)

gradientobject[]
[{ time: 0~1, color }]

짝Counterpart: vanilla-engine ParticleSystem.set_color_over_lifetime

메서드methodsetSizeOverLifetime(startScale, endScale)#0.3.0 부터since 0.3.0소스source

수명에 따른 크기 배율 설정. (시작에서 끝으로 선형, 기본 1, 1)

Sets the size scale over lifetime. (linear from start to end, default 1, 1)

startScalenumber
태어날 때의 크기 배율.Size scale at birth.
endScalenumber
수명이 다할 때의 크기 배율.Size scale at the end of the lifetime.

짝Counterpart: vanilla-engine ParticleSystem.set_size_over_lifetime

메서드methodsetAngularVelocity(minRadianPerSecond, maxRadianPerSecond = minRadianPerSecond)#0.3.0 부터since 0.3.0소스source

회전 속도 범위 설정. (기본 0)

Sets the angular velocity range. (default 0)

minRadianPerSecondnumber
회전 속도 최솟값. (초당 라디안)Minimum angular velocity. (radians per second)
maxRadianPerSecondnumber
회전 속도 최댓값. (초당 라디안, 주지 않으면 최솟값)Maximum angular velocity. (radians per second, the minimum if omitted)

짝Counterpart: vanilla-engine ParticleSystem.set_angular_velocity

메서드methodsetGravity(gravityX, gravityY)#0.3.0 부터since 0.3.0소스source

중력 설정. (기본 0, 0)

Sets the gravity. (default 0, 0)

gravityXnumber
가로 가속. (매초 속도에 더하는 초당 픽셀)Horizontal acceleration. (pixels per second added to the velocity every second)
gravityYnumber
세로 가속. (매초 속도에 더하는 초당 픽셀, 양수가 아래)Vertical acceleration. (pixels per second added to the velocity every second, positive is down)

짝Counterpart: vanilla-engine ParticleSystem.set_gravity

메서드methodsetDamping(damping)#0.3.0 부터since 0.3.0소스source

감쇠 설정. (기본 0)

Sets the damping. (default 0)

dampingnumber
초당 감쇠 계수. (0 = 없음)Damping coefficient per second. (0 = none)

짝Counterpart: vanilla-engine ParticleSystem.set_damping

메서드methodsetRenderShape(renderShape)#0.3.0 부터since 0.3.0소스source

렌더 모양 설정. (기본 circle)

Sets the render shape. (default circle)

renderShapestring
ParticleRenderShape 값.ParticleRenderShape value.

짝Counterpart: vanilla-engine ParticleSystem.set_render_shape

메서드methodsetImage(image)#0.3.0 부터since 0.3.0소스source

파티클 이미지 설정.

Sets the particle image.

image*
엔진 이미지. (renderShape image 전용)Engine image. (renderShape image only)

짝Counterpart: vanilla-engine ParticleSystem.set_image

메서드methodsetAdditive(isAdditive)#0.3.0 부터since 0.3.0소스source

가산 합성 설정.

Sets additive blending.

isAdditiveboolean
가산 합성 여부. (setBlendMode("lighter") 의 설탕)Whether additive blending. (sugar for setBlendMode("lighter"))

짝Counterpart: vanilla-engine ParticleSystem.set_additive

메서드methodsetBlendMode(blendMode)#0.3.0 부터since 0.3.0소스source

블렌드 모드 설정. (기본 "source-over")

Sets the blend mode. (default "source-over")

blendModestring
Graphic.setBlendMode 가 받는 이름. ("source-over" | "lighter" | "multiply" | "screen" 등 SpriteBlendMode 26 가지, 셰이더 섞기 모드는 서로 겹치지 않는 파티클끼리 모아 그린다)Name accepted by Graphic.setBlendMode. ("source-over" | "lighter" | "multiply" | "screen", etc., the 26 SpriteBlendMode values, shader blend modes draw particles together in groups that do not overlap each other)

짝Counterpart: vanilla-engine ParticleSystem.set_blend_mode

메서드methodsetAttractor(x, y, strength, swirl = 0)#0.3.0 부터since 0.3.0소스source

끌개 설정. (중심으로 끌거나 밀고, 접선으로 돌린다)

Sets the attractor. (pulls toward or pushes from the center, and spins along the tangent)

xnumber
끌림 중심 x. (노드 로컬 픽셀)Attractor center x. (node local pixels)
ynumber
끌림 중심 y. (노드 로컬 픽셀)Attractor center y. (node local pixels)
strengthnumber
중심 가속.Radial acceleration.
swirlnumber
접선 가속.Tangential acceleration.

짝Counterpart: vanilla-engine ParticleSystem.set_attractor

메서드methodclearAttractor()#0.3.0 부터since 0.3.0소스source

어트랙터 해제.

Removes the attractor.

짝Counterpart: vanilla-engine ParticleSystem.clear_attractor

메서드methodsetWobble(amplitude, frequency = 4)#0.3.0 부터since 0.3.0소스source

살랑임 설정. (그릴 때만 좌우로 흔들고 움직임에는 넣지 않는다)

Sets the wobble. (sways left and right only when drawing, not added to the motion)

amplitudenumber
살랑임 폭.Wiggle amplitude.
frequencynumber
초당 각속도.Angular velocity per second.

짝Counterpart: vanilla-engine ParticleSystem.set_wobble

메서드methodsetStreakScale(streakScale)#0.3.0 부터since 0.3.0소스source

streak 길이 배율 설정. (기본 0.06)

Sets the streak length scale. (default 0.06)

streakScalenumber
streak 길이 = 속도 x 이 값.streak length = speed x this value.

짝Counterpart: vanilla-engine ParticleSystem.set_streak_scale

메서드methodsetWorldSpace(isWorldSpace)#0.3.0 부터since 0.3.0소스source

월드 공간 설정. (기본 거짓)

Sets world space. (default false)

isWorldSpaceboolean
참이면 방출 뒤 노드 이동의 영향을 받지 않는다.If true, unaffected by node movement after emission.

짝Counterpart: vanilla-engine ParticleSystem.set_world_space

메서드methodsetLooping(isLooping)#0.3.0 부터since 0.3.0소스source

반복 방출 설정.

Sets looping emission.

isLoopingboolean
참이면 계속 방출한다. (기본 참, 거짓이면 duration 동안만)If true, keeps emitting. (default true, if false only during duration)

짝Counterpart: vanilla-engine ParticleSystem.set_looping

메서드methodsetDuration(duration)#0.3.0 부터since 0.3.0소스source

방출 시간 설정. (초, 기본 1)

Sets the emission duration. (seconds, default 1)

durationnumber
루프 꺼짐일 때 방출 시간. (버스트 반복 주기)Emission duration when looping is off. (burst repeat period)

짝Counterpart: vanilla-engine ParticleSystem.set_duration

메서드methodsetMaxParticleCount(maxParticleCount)#0.3.0 부터since 0.3.0소스source

최대 파티클 수 설정.

Sets the maximum particle count.

maxParticleCountnumber
살아 있을 수 있는 최대 수. (기본 512)Maximum number that can be alive. (default 512)

짝Counterpart: vanilla-engine ParticleSystem.set_max_particle_count

메서드methodapplyDescription(description)#0.3.0 부터since 0.3.0소스source

서술(JSON) 적용., vfx 애셋 로드 / 파티클 편집기 공용.

  • 모든 항목은 선택 사항이며 준 것만 반영한다. 색은 [r, g, b, a] 배열.
  • imageDataUrl 은 파티클 편집기가 고른 그림의 data: 주소다. 그 그림을 입자 이미지로 걸고(브라우저가 다 풀면 그린다), 비었거나 null 이면 그림을 비운다.

Applies a description (JSON)., shared by vfx asset loading / the particle editor.

  • All fields are optional and only those given are applied. Colors are [r, g, b, a] arrays.
  • imageDataUrl is the data: URL of the image chosen in the particle editor. That image is set as the particle image (drawn once the browser has decoded it), and the image is cleared if it is empty or null.
descriptionobject
서술 객체. (looping, duration, maxParticleCount, emissionRate, bursts, shape, shapeRadius, coneAngle, boxSize, edgeWidth, lifetime, speed, size, rotation, angularVelocity, startColorA, startColorB, colorOverLifetime, sizeOverLifetime, gravity, damping, attractor, wobble, renderShape, blendMode, streakScale, worldSpace, imageDataUrl)Description object. (looping, duration, maxParticleCount, emissionRate, bursts, shape, shapeRadius, coneAngle, boxSize, edgeWidth, lifetime, speed, size, rotation, angularVelocity, startColorA, startColorB, colorOverLifetime, sizeOverLifetime, gravity, damping, attractor, wobble, renderShape, blendMode, streakScale, worldSpace, imageDataUrl)

짝Counterpart: vanilla-engine ParticleSystem.apply_description

예제ExampleJSON 서술로 설정하기Configure from a JSON description
import { ParticleSystem } from "./build/vanilla.js";

const particleSystem = new ParticleSystem();
particleSystem.applyDescription({
	looping: false,
	duration: 0.2,
	emissionRate: 50,
	shape: "box",
	boxSize: [200, 10],
	lifetime: [0.5, 1],
	speed: [20, 40],
	startColorA: [0.6, 0.8, 1, 1],
	colorOverLifetime: [
		{ time: 0, color: [1, 1, 1, 1] },
		{ time: 1, color: [1, 1, 1, 0] },
	],
	gravity: [0, 98],
	renderShape: "streak",
});
particleSystem.simulate(0.1);
console.log(particleSystem.getParticleCount());
메서드methodgetParticleCount()#0.3.0 부터since 0.3.0소스source

살아 있는 파티클 수 반환.

Returns the living particle count.

반환Returnsnumber 살아 있는 파티클 수.Living particle count.

짝Counterpart: vanilla-engine ParticleSystem.get_particle_count

메서드methodgetParticlePositionList()#0.4.0 부터since 0.4.0소스source

입자 자리 목록. (노드 로컬, 흔들림을 넣지 않은 적분 자리. 같은 씨앗 비교와 시험용)

List of particle positions. (node local, integrated positions without the wiggle applied. For same-seed comparison and tests)

반환ReturnsVector2[] 파티클 자리 목록. (새로 만든 Vector2)Particle position list. (newly created Vector2s)

짝Counterpart: vanilla-engine ParticleSystem.get_particle_position_list

메서드methodisPlaying()#0.3.0 부터since 0.3.0소스source

방출 중인지 반환.

Returns whether it is emitting.

반환Returnsboolean 방출 중이면 참. (생성 직후 참)True if emitting. (true right after construction)

짝Counterpart: vanilla-engine ParticleSystem.is_playing

메서드methodisFinished()#0.4.0 부터since 0.4.0소스source

다 끝났는지. (방출할 것이 더 없고 남은 입자도 없음, 일회성 노드를 치울 때)

  • 정지했거나, 루프가 아니고 duration 이 지났으며 버스트를 다 냈으면 방출할 것이 없다.

Whether it has finished. (nothing more to emit and no particles left, for disposing of one-shot nodes)

  • If stopped, or not looping with duration elapsed and all bursts emitted, there is nothing to emit.

반환Returnsboolean 다 끝났으면 참.True if everything is finished.

짝Counterpart: vanilla-engine ParticleSystem.is_finished

메서드methodsetManualTick(isManualTick)#0.3.0 부터since 0.3.0소스source

수동 틱 설정. (참이면 노드 갱신 대신 simulate() 로만 진행, 타임라인이 시간을 다룬다)

Sets manual tick. (if true, advances only through simulate() instead of the node update, the timeline handles time)

isManualTickboolean
참이면 노드 갱신에서 진행하지 않는다. (기본 거짓)If true, does not advance in the node update. (default false)

짝Counterpart: vanilla-engine ParticleSystem.set_manual_tick

메서드methodisManualTick()#0.3.0 부터since 0.3.0소스source

수동 틱인지 반환.

Returns whether it is manual tick.

반환Returnsboolean 수동 틱이면 참.True if manual tick.

짝Counterpart: vanilla-engine ParticleSystem.is_manual_tick

메서드methodsetRandomSeed(seed)#0.3.0 부터since 0.3.0소스source

난수 시드 설정. (설정하면 스폰 난수가 시드 난수로 바뀌고 stop(true) 마다 시드로 되돌아간다, 되감기 재현용)

Sets the random seed. (when set, spawn randomness switches to the seeded random and returns to the seed on every stop(true), for reproducible rewinding)

seednumber
난수 시드.Random seed.

짝Counterpart: vanilla-engine ParticleSystem.set_random_seed

예제Example시드로 같은 방출 되풀이하기Repeat the same emission with a seed
import { ParticleSystem } from "./build/vanilla.js";

const particleSystem = new ParticleSystem();
particleSystem.setManualTick(true);
particleSystem.setRandomSeed(7);
particleSystem.setEmissionRate(30);
particleSystem.simulate(0.5);
const firstPositionList = particleSystem.getParticlePositionList();
particleSystem.stop(true);
particleSystem.play();
particleSystem.simulate(0.5);
const secondPositionList = particleSystem.getParticlePositionList();
console.log(firstPositionList.length, secondPositionList[0].x === firstPositionList[0].x);
메서드methodgetRandomSeed()#0.3.0 부터since 0.3.0소스source

난수 시드 반환.

Returns the random seed.

반환Returnsnumber | null 난수 시드. (설정하지 않았으면 null)Random seed. (null if not set)

짝Counterpart: vanilla-engine ParticleSystem.get_random_seed

메서드methodrandomRange(minValue, maxValue)#0.3.0 부터since 0.3.0소스source

스폰용 난수. (시드가 있으면 시드 난수, 없으면 전역 난수)

Random for spawning. (seeded random if a seed is set, otherwise the global random)

minValuenumber
최솟값.Minimum value.
maxValuenumber
최댓값.Maximum value.

반환Returnsnumber 최솟값과 최댓값 사이의 난수.A random number between the minimum and maximum.

짝Counterpart: vanilla-engine ParticleSystem.random_range

ParticleEmitterShapeenum

짝Counterpart: vanilla-engine ParticleEmitterShape

방출 모양.

  • point: 노드 원점 한 점.
  • circle: 반지름 안 무작위 위치, 바깥 방향.
  • cone: 위쪽(-y) 기준 각도 부채꼴 방향, 반지름 안 위치.
  • box: 사각 영역 안 무작위 위치, 위쪽 방향.
  • edge: 가로 선분 위 무작위 위치, 아래쪽(+y) 방향. (눈 / 비처럼 위에서 뿌릴 때)

Emission shape.

  • point: a single point at the node origin.
  • circle: random position within the radius, outward direction.
  • cone: fan of directions within the angle around up (-y), position within the radius.
  • box: random position within a rectangular area, upward direction.
  • edge: random position on a horizontal line segment, downward (+y) direction. (for scattering from above like snow / rain)
이름Name값Value설명Description
pointpoint노드 원점 한 점에서 무작위 방향.A random direction from a single point at the node origin.
circlecircle반지름 안 무작위 위치에서 중심 바깥 방향.Outward from the center at a random position within the radius.
conecone반지름 안 위치에서 위쪽(-y) 기준 반각 안 부채꼴 방향.A fan of directions within the half angle around up (-y), at a position within the radius.
boxbox사각 영역 안 무작위 위치에서 위쪽(-y) 방향.Up (-y) from a random position inside the rectangle.
edgeedge가로 선분 위 무작위 위치에서 아래쪽(+y) 방향.Down (+y) from a random position on a horizontal line segment.

ParticleRenderShapeenum

짝Counterpart: vanilla-engine ParticleRenderShape

파티클 렌더 모양.

  • circle: 부드러운 원. (기본)
  • rect: 사각형. (색종이 조각처럼 회전하는 판)
  • streak: 진행 방향으로 늘인 띠. (비 / 유성)
  • image: setImage 로 넣은 이미지.

Particle render shape.

  • circle: soft circle. (default)
  • rect: rectangle. (a rotating plate like confetti)
  • streak: band stretched along the direction of travel. (rain / meteors)
  • image: the image set with setImage.
이름Name값Value설명Description
circlecircle부드러운 원. (기본)Soft circle. (default)
rectrect사각형. (회전하는 판)Rectangle. (a rotating plate)
streakstreak진행 방향으로 늘인 띠.A band stretched along the direction of travel.
imageimagesetImage 로 넣은 이미지.The image set with setImage.