vanilladocs
vanillapunch.com
API / effect/particlesystem

effect/particlesystem

파티클 시스템 컴포넌트.

  • 원본 effect/particlesystem.js 의 ParticleSystem. 이름, 기본값, 쓰임새(play / stop / emit / simulate / setStart...)는 원본을 따른다.
  • 입자는 원본처럼 컴포넌트가 그리는 좌표(노드 content_size 영역의 왼쪽 위가 원점)의 원점에서 나온다. content_size 가 0 인 노드면 노드 자리다. 끌개 자리(set_attractor)도 원본처럼 같은 좌표다.
  • 낼 때 난수를 뽑는 차례와 셈의 차례도 원본과 같다. 같은 씨앗(set_random_seed)이면 원본과 같은 입자가 나온다. (시드 난수는 원본과 비트까지 같은 수열이다. 입자 셈도 원본처럼 f64 다)
  • 정점마다 색을 실어 draw_colored_quads 로 그린다. image 모양도 원본처럼 색 곡선과 시작 색(r, g, b)을 쓰지 않고 시작 알파 x (1 - 수명 비율) 로만 흐려진다. 원본은 image 를 입자마다 따로 그리고, 러스트 판은 그림 텍스처로 한 번에 그린다. (그려지는 자리와 색은 같다)
  • 원본과 다른 것:
  • 방출 모양, 렌더 모양, 합성은 원본의 문자열 대신 열거형(ParticleEmitterShape, ParticleRenderShape, BlendMode)이다. 서술(apply_description)은 원본 문자열을 읽는다.
  • 원본의 기본 인자(setStartLifetime(min, max = min) 같은)는 러스트에 없어 두 값을 다 받는다. emit 의 원점 보정은 Option 이다.
  • 월드 공간(set_world_space)에서 낼 때 더하는 노드 로컬 위치는 tick 에서 읽어 둔다. 러스트 컴포넌트는 tick 과 draw 밖에서 노드를 읽을 수 없어서다. 원본처럼 낼 때의 노드 위치로 내려면 ParticleSystem::emit_in_tree(트리, 노드, 수, 보정)로 내거나, set_node_position 으로 위치를 넣고 emit 한다. (Timeline 의 emit 이벤트는 그 자리의 노드 위치를 넣고 낸다)
  • 정점 색 쿼드는 한 번에 그릴 수 있는 정점 수(Graphic 한도)씩 나눠 그린다. 원본은 배열을 늘려 한 번에 그린다.
  • 서술의 imageDataUrl(파티클 편집기가 고른 그림의 data: 주소)은 데스크탑이 그 자리에서 풀고, 웹은 원본처럼 브라우저가 풀어 다 풀리면 그린다.

Particle system component.

  • ParticleSystem of the original effect/particlesystem.js. Names, defaults and usage (play / stop / emit / simulate / setStart...) follow the original.
  • Like the original, particles come out of the origin of the coordinates the component draws in (the top left of the node content_size area is the origin). For a node whose content_size is 0, it is the node position. The attractor position (set_attractor) uses the same coordinates as in the original.
  • The order of drawing random numbers and of calculations when emitting is also the same as the original. With the same seed (set_random_seed), the same particles as the original come out. (The seeded random is the same sequence as the original down to the bit. Particle math is also f64 like the original)
  • Draws with draw_colored_quads, carrying a color per vertex. Like the original, the image shape also does not use the color curve or start color (r, g, b) and only fades by start alpha x (1 - life ratio). The original draws image separately per particle, and the Rust version draws at once with the image texture. (the drawn positions and colors are the same)
  • Differences from the original:
  • Emitter shape, render shape and blending are enums (ParticleEmitterShape, ParticleRenderShape, BlendMode) instead of the original strings. The description (apply_description) reads the original strings.
  • Rust has no default arguments of the original (like setStartLifetime(min, max = min)), so both values are taken. The origin offset of emit is an Option.
  • The node local position added when emitting in world space (set_world_space) is read in tick, because a Rust component cannot read the node outside tick and draw. To emit at the node position at emit time like the original, emit with ParticleSystem::emit_in_tree(tree, node, count, offset), or put the position with set_node_position and emit. (The emit event of Timeline emits after putting the node position at that moment)
  • Vertex color quads are drawn in parts of the vertex count that can be drawn at once (the Graphic limit). The original grows the array and draws at once.
  • The imageDataUrl of the description (the data: URL of the image picked in the particle editor) is decoded on the spot on desktop, and on the web the browser decodes it like the original and it draws once decoded.

ParticleSystemstruct traits Default, Component

짝Counterpart: vanilla.js ParticleSystem소스source

파티클 시스템 컴포넌트.

  • 노드에 붙이면 tick 마다 방출(초당 방출, 버스트)하고 입자를 적분해 정점 색 쿼드로 그린다. 좌표는 노드 content_size 영역의 왼쪽 위가 원점인 컴포넌트 좌표다.

Particle system component.

  • When attached to a node, it emits (per second emission, bursts) every tick, integrates particles and draws them as vertex color quads. Coordinates are component coordinates with the top left of the node's content_size area as the origin.
예제Example한 번 터지는 불꽃 버스트A firework burst that goes off once
use vanilla::{Color, NodeTree, ParticleEmitterShape, ParticleRenderShape, ParticleSystem};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let spark_id = node_tree.create_child(root_id, "Spark");
let particle_system = node_tree[spark_id].add_component(ParticleSystem::new());
particle_system.set_looping(false);
particle_system.set_emission_rate(0.0);
particle_system.set_burst_list(vec![(0.0, 24)]);
particle_system.set_emitter_shape(ParticleEmitterShape::Circle);
particle_system.set_shape_radius(8.0);
particle_system.set_start_lifetime(0.6, 1.0);
particle_system.set_start_speed(120.0, 240.0);
particle_system.set_start_color(Color::create(1.0, 0.8, 0.2, 1.0), Color::create(1.0, 0.4, 0.1, 1.0));
particle_system.set_gravity(0.0, 300.0);
particle_system.set_render_shape(ParticleRenderShape::Streak);
particle_system.set_additive(true);
particle_system.set_random_seed(7);
particle_system.simulate(0.016);
assert_eq!(particle_system.get_particle_count(), 24);
particle_system.simulate(1.5);
assert_eq!(particle_system.get_particle_count(), 0);
assert!(particle_system.is_finished());
A firework burst that goes off once
생성자constructorpub fn new() -> ParticleSystem#0.3.2 부터since 0.3.2소스source

생성. (원본 생성자의 기본값)

Creates. (defaults of the original constructor)

반환ReturnsParticleSystem 원본 기본값의 파티클 시스템. (재생 중, 반복, duration 1 초, 최대 512 개, 초당 20 개, Point 모양, 수명 1 초, 속력 60, 크기 6, 흰색, Circle 렌더, 보통 합성, 씨앗 없음)A particle system with the original defaults. (playing, looping, duration 1 second, up to 512, 20 per second, Point shape, lifetime 1 second, speed 60, size 6, white, Circle render, normal blending, no seed)

짝Counterpart: vanilla.js ParticleSystem.constructor

정적staticpub fn emit_in_tree(node_tree: &mut NodeTree, node_id: NodeId, count: usize, origin_offset: Option<Vector2>) -> bool#0.4.0 부터since 0.4.0소스source

노드의 지금 위치로 여러 개 방출. (원본 emit 처럼 낼 때 노드 로컬 위치를 읽는다. 노드나 파티클 시스템이 없으면 false)

Emits several at the node's current position. (reads the node local position at emit time like the original emit. false if there is no node or particle system)

node_tree&mut NodeTree
노드가 든 노드 트리.Node tree containing the node.
node_idNodeId
ParticleSystem 이 붙은 노드. (첫 번째 ParticleSystem 으로 낸다)Node with a ParticleSystem attached. (emits with the first ParticleSystem)
countusize
낼 입자 수.Number of particles to emit.
origin_offsetOption<Vector2>
방출 원점 보정. (컴포넌트 좌표) None 이면 원점.Emission origin offset. (component coordinates) The origin if None.

반환Returnsbool 냈으면 true. 노드가 없거나 ParticleSystem 이 붙어 있지 않으면 false.true if emitted. false if there is no node or no ParticleSystem attached.

예제Example월드 공간 입자를 노드 자리에서 내기Emit world space particles at the node's position
use vanilla::{NodeTree, ParticleSystem, Vector2};

let mut node_tree = NodeTree::new();
let root_id = node_tree.get_root_id();
let spark_id = node_tree.create_child(root_id, "Spark");
node_tree[spark_id].set_local_position(Vector2::create(100.0, 50.0));
let particle_system = node_tree[spark_id].add_component(ParticleSystem::new());
particle_system.set_world_space(true);
assert!(ParticleSystem::emit_in_tree(&mut node_tree, spark_id, 3, None));
let position_list = node_tree[spark_id].get_component::<ParticleSystem>().map(|particle_system| particle_system.get_particle_position_list()).unwrap_or_default();
assert_eq!(position_list, vec![Vector2::create(100.0, 50.0); 3]);
assert!(!ParticleSystem::emit_in_tree(&mut node_tree, root_id, 3, None));
메서드methodpub fn play(&mut self)#0.3.2 부터since 0.3.2소스source

재생.

Play.

짝Counterpart: vanilla.js ParticleSystem.play

메서드methodpub fn stop(&mut self, is_clearing: bool)#0.3.2 부터since 0.3.2소스source

정지. (is_clearing 이면 살아 있는 입자도 지운다)

Stops. (also clears live particles if is_clearing)

is_clearingbool
참이면 살아 있는 입자와 쌓인 방출량을 지우고 씨앗 난수를 처음으로 되돌린다. 거짓이면 내기만 멈추고 남은 입자는 수명대로 산다.If true, clears live particles and the accumulated emission and resets the seeded random numbers to the start. If false, only stops emitting and the remaining particles live out their lifetime.

짝Counterpart: vanilla.js ParticleSystem.stop

메서드methodpub fn emit(&mut self, count: usize, origin_offset: Option<Vector2>)#0.3.2 부터since 0.3.2소스source

한 번에 여러 개 방출. (버튼 클릭 등 이벤트성 연출, origin_offset 은 방출 원점 보정, 노드 로컬 기준)

  • 재생 중이 아니어도 낸다.

Emits several at once. (for event-like effects such as a button click, origin_offset adjusts the emission origin, relative to node local)

  • Emits even when not playing.
countusize
낼 입자 수. (최대 입자 수를 넘는 것은 내지 않는다)Number of particles to emit. (those beyond the maximum particle count are not emitted)
origin_offsetOption<Vector2>
방출 원점 보정. (컴포넌트 좌표) None 이면 원점.Emission origin offset. (component coordinates) The origin if None.

짝Counterpart: vanilla.js ParticleSystem.emit

예제Example최대 수까지 내고 원점을 옮겨 내기Emit up to the maximum and emit with a moved origin
use vanilla::{ParticleSystem, Vector2};

let mut particle_system = ParticleSystem::new();
particle_system.set_max_particle_count(12);
particle_system.emit(10, None);
particle_system.emit(5, Some(Vector2::create(0.0, -20.0)));
assert_eq!(particle_system.get_particle_count(), 12);
assert_eq!(particle_system.get_particle_position_list()[11], Vector2::create(0.0, -20.0));
메서드methodpub fn set_node_position(&mut self, node_position: Vector2)#0.4.0 부터since 0.4.0소스source

월드 공간에서 낼 때 더할 노드 로컬 위치 설정. (tick 이 읽어 두는 값을 낼 자리에서 고칠 때)

Sets the node local position added when emitting in world space. (for correcting the value tick records at the emitting site)

node_positionVector2
노드 로컬 위치. (부모 좌표, 다음 tick 이 노드 위치로 다시 덮는다)Node local position. (parent coordinates, the next tick overwrites it with the node position)
메서드methodpub fn simulate(&mut self, time_delta: f64)#0.3.2 부터since 0.3.2소스source

시간 진행. (방출 + 적분, 수동 tick 이면 밖에서 부른다)

  • 재생 중이 아니면 내지 않고 남은 입자만 움직인다. 한 번에 받은 시간을 한 걸음으로 적분한다.

Advances time. (emission + integration, called from outside for manual tick)

  • If not playing, nothing is emitted and only the remaining particles move. The time received at once is integrated in one step.
time_deltaf64
진행할 시간. (초)Time to advance. (seconds)

짝Counterpart: vanilla.js ParticleSystem.simulate

예제Example수동 tick 으로 0.5초 진행하기Advance 0.5 seconds with a manual tick
use vanilla::ParticleSystem;

let mut particle_system = ParticleSystem::new();
particle_system.set_manual_tick(true);
particle_system.set_emission_rate(10.0);
particle_system.simulate(0.5);
assert_eq!(particle_system.get_particle_count(), 5);
메서드methodpub fn set_emission_rate(&mut self, emission_rate: f64)#0.3.2 부터since 0.3.2소스source

초당 방출 수 설정.

Sets the per second emission count.

emission_ratef64
초당 내는 입자 수. (0 이하면 꾸준히 내지 않는다, 기본 20. 반복이 아니면 duration 동안만 낸다)Number of particles emitted per second. (0 or less means no steady emission, default 20. If not looping, emits only during duration)

짝Counterpart: vanilla.js ParticleSystem.setEmissionRate

메서드methodpub fn set_burst_list(&mut self, burst_list: Vec<(f64, usize)>)#0.3.2 부터since 0.3.2소스source

버스트 목록 설정. ((재생 시작부터 초, 개수) 목록)

Sets the burst list. (list of (seconds from playback start, count))

burst_listVec<(f64, usize)>
(재생 시작부터 초, 개수) 목록. 이전 목록을 바꾸고 낸 표시를 지운다. 반복이면 duration 주기마다 다시 낸다.List of (seconds from playback start, count). Replaces the previous list and clears the emitted marks. If looping, emits again every duration period.

짝Counterpart: vanilla.js ParticleSystem.setBurstList

메서드methodpub fn set_emitter_shape(&mut self, emitter_shape: ParticleEmitterShape)#0.3.2 부터since 0.3.2소스source

방출 모양 설정.

Sets the emitter shape.

emitter_shapeParticleEmitterShape
낼 자리와 방향을 정하는 모양. (기본 Point)Shape that decides where and in which direction particles are emitted. (default Point)

짝Counterpart: vanilla.js ParticleSystem.setEmitterShape

메서드methodpub fn set_shape_radius(&mut self, shape_radius: f64)#0.3.2 부터since 0.3.2소스source

circle / cone 반지름.

circle / cone radius.

shape_radiusf64
circle 과 cone 의 방출 반지름. (컴포넌트 좌표, 기본 0)Emission radius of circle and cone. (component coordinates, default 0)

짝Counterpart: vanilla.js ParticleSystem.setShapeRadius

메서드methodpub fn set_cone_angle(&mut self, cone_angle_radian: f64)#0.3.2 부터since 0.3.2소스source

cone 반각. (라디안)

cone half-angle. (radians)

cone_angle_radianf64
위쪽(-Y) 기준 부채꼴 반각. (라디안, 기본 0.5)Half angle of the fan relative to up (-Y). (radians, default 0.5)

짝Counterpart: vanilla.js ParticleSystem.setConeAngle

메서드methodpub fn set_box_size(&mut self, width: f64, height: f64)#0.3.2 부터since 0.3.2소스source

box 방출 영역 크기 설정. (원점이 가운데)

Sets the size of the box emission area. (the origin is the center)

widthf64
영역 너비. (컴포넌트 좌표, 기본 0)Area width. (component coordinates, default 0)
heightf64
영역 높이. (컴포넌트 좌표, 기본 0)Area height. (component coordinates, default 0)

짝Counterpart: vanilla.js ParticleSystem.setBoxSize

메서드methodpub fn set_edge_width(&mut self, edge_width: f64)#0.4.0 부터since 0.4.0소스source

edge 방출 모양의 가로 길이.

Horizontal length of the edge emitter shape.

edge_widthf64
가로 선분 길이. (컴포넌트 좌표, 원점이 가운데, 기본 0)Length of the horizontal line segment. (component coordinates, the origin is the center, default 0)

짝Counterpart: vanilla.js ParticleSystem.setEdgeWidth

메서드methodpub fn set_start_lifetime(&mut self, minimum_seconds: f64, maximum_seconds: f64)#0.3.2 부터since 0.3.2소스source

시작 수명 범위 설정. (낼 때 둘 사이 무작위)

Sets the start lifetime range. (random between the two when emitting)

minimum_secondsf64
가장 짧은 수명. (초, 기본 1)Shortest lifetime. (seconds, default 1)
maximum_secondsf64
가장 긴 수명. (초, 기본 1, 최소와 같으면 고정)Longest lifetime. (seconds, default 1, fixed if equal to the minimum)

짝Counterpart: vanilla.js ParticleSystem.setStartLifetime

메서드methodpub fn set_start_speed(&mut self, minimum_speed: f64, maximum_speed: f64)#0.3.2 부터since 0.3.2소스source

시작 속력 범위 설정. (낼 때 둘 사이 무작위)

Sets the start speed range. (random between the two when emitting)

minimum_speedf64
가장 느린 속력. (컴포넌트 좌표 초당, 기본 60)Slowest speed. (component coordinates per second, default 60)
maximum_speedf64
가장 빠른 속력. (컴포넌트 좌표 초당, 기본 60)Fastest speed. (component coordinates per second, default 60)

짝Counterpart: vanilla.js ParticleSystem.setStartSpeed

메서드methodpub fn set_start_size(&mut self, minimum_size: f64, maximum_size: f64)#0.3.2 부터since 0.3.2소스source

시작 크기 범위 설정. (낼 때 둘 사이 무작위)

Sets the start size range. (random between the two when emitting)

minimum_sizef64
가장 작은 지름. (컴포넌트 좌표, 기본 6)Smallest diameter. (component coordinates, default 6)
maximum_sizef64
가장 큰 지름. (컴포넌트 좌표, 기본 6)Largest diameter. (component coordinates, default 6)

짝Counterpart: vanilla.js ParticleSystem.setStartSize

메서드methodpub fn set_start_rotation(&mut self, minimum_radian: f64, maximum_radian: f64)#0.3.2 부터since 0.3.2소스source

시작 회전 범위 설정. (낼 때 둘 사이 무작위, rect 와 image 렌더만 돈다)

Sets the start rotation range. (random between the two when emitting, only rect and image renders rotate)

minimum_radianf64
가장 작은 회전. (라디안, 기본 0)Smallest rotation. (radians, default 0)
maximum_radianf64
가장 큰 회전. (라디안, 기본 0)Largest rotation. (radians, default 0)

짝Counterpart: vanilla.js ParticleSystem.setStartRotation

메서드methodpub fn set_start_color(&mut self, color_a: impl Into<Color>, color_b: impl Into<Color>)#0.3.2 부터since 0.3.2소스source

시작 색. (둘 사이 무작위)

Start color. (random between the two)

color_aimpl Into<Color>
한 끝 색. (Color 나 "#rrggbb" 같은 글, 기본 흰색)Color at one end. (a Color or text like "#rrggbb", default white)
color_bimpl Into<Color>
다른 끝 색. (낼 때 두 색 사이를 무작위 비율로 섞는다, 기본 흰색)Color at the other end. (mixes the two colors at a random ratio when emitting, default white)

짝Counterpart: vanilla.js ParticleSystem.setStartColor

메서드methodpub fn set_color_over_lifetime(&mut self, gradient: Vec<(f64, Color)>)#0.3.2 부터since 0.3.2소스source

수명에 따른 색 곡선. (수명 비율 0 ~ 1 과 색의 쌍 목록, 시작 색에 곱한다)

Color curve over lifetime. (list of pairs of life ratio 0 ~ 1 and color, multiplied by the start color)

gradientVec<(f64, Color)>
(수명 비율 0 ~ 1, 색) 목록. 비율 오름차순으로 준다. 사이는 선형으로 섞고 빈 목록이면 시작 색 그대로다. (image 렌더는 쓰지 않는다)List of (life ratio 0 ~ 1, color). Give them in ascending ratio order. Values in between are mixed linearly, and an empty list keeps the start color as is. (not used by the image render)

짝Counterpart: vanilla.js ParticleSystem.setColorOverLifetime

메서드methodpub fn set_size_over_lifetime(&mut self, start_scale: f64, end_scale: f64)#0.3.2 부터since 0.3.2소스source

수명에 따른 크기 배율 설정. (태어날 때에서 수명 끝까지 선형)

Sets the size scale over lifetime. (linear from birth to the end of life)

start_scalef64
태어날 때 배율. (기본 1)Scale at birth. (default 1)
end_scalef64
수명 끝 배율. (기본 1)Scale at the end of life. (default 1)

짝Counterpart: vanilla.js ParticleSystem.setSizeOverLifetime

메서드methodpub fn set_angular_velocity(&mut self, minimum_radian_per_second: f64, maximum_radian_per_second: f64)#0.3.2 부터since 0.3.2소스source

회전 속도 범위 설정. (낼 때 둘 사이 무작위)

Sets the angular velocity range. (random between the two when emitting)

minimum_radian_per_secondf64
가장 느린 회전 속도. (초당 라디안, 기본 0)Slowest angular velocity. (radians per second, default 0)
maximum_radian_per_secondf64
가장 빠른 회전 속도. (초당 라디안, 기본 0)Fastest angular velocity. (radians per second, default 0)

짝Counterpart: vanilla.js ParticleSystem.setAngularVelocity

메서드methodpub fn set_gravity(&mut self, gravity_x: f64, gravity_y: f64)#0.3.2 부터since 0.3.2소스source

중력 가속도 설정.

Sets the gravity acceleration.

gravity_xf64
가로 가속도. (컴포넌트 좌표 초당 초당, 기본 0)Horizontal acceleration. (component coordinates per second per second, default 0)
gravity_yf64
세로 가속도. (아래가 +, 기본 0)Vertical acceleration. (down is +, default 0)

짝Counterpart: vanilla.js ParticleSystem.setGravity

메서드methodpub fn set_damping(&mut self, damping: f64)#0.3.2 부터since 0.3.2소스source

초당 감쇠 계수. (0 = 없음)

Damping coefficient per second. (0 = none)

dampingf64
감쇠 계수. (simulate 마다 속도에 max(1 - 계수 x time_delta, 0) 을 곱한다. 0 이하면 없음, 기본 0)Damping coefficient. (each simulate multiplies the velocity by max(1 - coefficient x time_delta, 0). None if 0 or less, default 0)

짝Counterpart: vanilla.js ParticleSystem.setDamping

메서드methodpub fn set_render_shape(&mut self, render_shape: ParticleRenderShape)#0.4.0 부터since 0.4.0소스source

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

Sets the render shape. (default circle)

render_shapeParticleRenderShape
입자를 그릴 모양.Shape to draw particles with.

짝Counterpart: vanilla.js ParticleSystem.setRenderShape

메서드methodpub fn set_image(&mut self, image: Option<Rc<Image>>)#0.3.2 부터since 0.3.2소스source

입자 이미지. (렌더 모양이 image 일 때 쓴다)

Particle image. (used when the render shape is image)

imageOption<Rc<Image>>
Image 렌더로 그릴 그림. None 이면 Image 렌더도 흰 사각형에 입자 색으로 그린다.Image to draw with the Image render. If None, the Image render also draws a white square in the particle color.

짝Counterpart: vanilla.js ParticleSystem.setImage

메서드methodpub fn set_additive(&mut self, is_additive: bool)#0.3.2 부터since 0.3.2소스source

더하기 합성 여부. (set_blend_mode(Lighter) 의 설탕)

Whether to use additive blending. (sugar for set_blend_mode(Lighter))

is_additivebool
참이면 Lighter, 거짓이면 Normal 합성.Lighter blending if true, Normal if false.

짝Counterpart: vanilla.js ParticleSystem.setAdditive

메서드methodpub fn set_blend_mode(&mut self, blend_mode: BlendMode)#0.3.2 부터since 0.3.2소스source

합성 설정.

Sets the blending.

blend_modeBlendMode
입자를 그릴 합성. (기본 Normal, 그린 뒤 이전 합성으로 되돌린다)Blending to draw particles with. (default Normal, restores the previous blending after drawing)

짝Counterpart: vanilla.js ParticleSystem.setBlendMode

메서드methodpub fn set_attractor(&mut self, x: f64, y: f64, strength: f64, swirl: f64)#0.4.0 부터since 0.4.0소스source

끌개 설정. (컴포넌트 좌표의 자리, 중심 쪽 가속(음수면 밀어냄), 접선 쪽 가속(소용돌이))

Sets the attractor. (position in component coordinates, acceleration toward the center (pushes away if negative), tangential acceleration (swirl))

xf64
끌개 x. (컴포넌트 좌표)Attractor x. (component coordinates)
yf64
끌개 y. (컴포넌트 좌표)Attractor y. (component coordinates)
strengthf64
중심 쪽 가속. (초당 초당, 음수면 밀어낸다. 거리는 4 아래로 보지 않는다)Acceleration toward the center. (per second per second, pushes away if negative. Distances below 4 are treated as 4)
swirlf64
접선 쪽 가속. (초당 초당, 소용돌이)Tangential acceleration. (per second per second, swirl)

짝Counterpart: vanilla.js ParticleSystem.setAttractor

메서드methodpub fn clear_attractor(&mut self)#0.4.0 부터since 0.4.0소스source

끌개 해제.

Clears the attractor.

짝Counterpart: vanilla.js ParticleSystem.clearAttractor

메서드methodpub fn set_wobble(&mut self, amplitude: f64, frequency: f64)#0.4.0 부터since 0.4.0소스source

흔들림 설정. (가로로 살랑이는 폭, 초당 각속도. 원본 기본 각속도는 4)

Sets the wobble. (horizontal sway amplitude, angular speed per second. The original default angular speed is 4)

amplitudef64
가로로 살랑이는 폭. (컴포넌트 좌표, 0 이하면 없음. 그릴 때만 더하고 자리에는 넣지 않는다)Horizontal sway amplitude. (component coordinates, none if 0 or less. Added only when drawing, not to the position)
frequencyf64
살랑이는 각속도. (초당 라디안, 기본 4)Sway angular speed. (radians per second, default 4)

짝Counterpart: vanilla.js ParticleSystem.setWobble

메서드methodpub fn set_streak_scale(&mut self, streak_scale: f64)#0.4.0 부터since 0.4.0소스source

streak 길이 비율. (띠의 길이 = 속도 x 이 값)

Streak length ratio. (length of the streak = velocity x this value)

streak_scalef64
속력에 곱할 띠 길이 비율. (초, 기본 0.06)Streak length ratio multiplied by the speed. (seconds, default 0.06)

짝Counterpart: vanilla.js ParticleSystem.setStreakScale

메서드methodpub fn set_world_space(&mut self, is_world_space: bool)#0.4.0 부터since 0.4.0소스source

월드 공간 설정. (켜면 낸 뒤 노드가 움직여도 입자는 그 자리에 남는다)

Sets world space. (when on, particles stay where they are even if the node moves after emitting)

is_world_spacebool
참이면 낼 때 노드 로컬 위치를 더하고 그릴 때 노드 위치를 뺀다. (기본 거짓)If true, adds the node local position when emitting and subtracts the node position when drawing. (default false)

짝Counterpart: vanilla.js ParticleSystem.setWorldSpace

메서드methodpub fn set_looping(&mut self, is_looping: bool)#0.3.2 부터since 0.3.2소스source

반복 설정.

Sets looping.

is_loopingbool
참이면 끝없이 내고 버스트를 duration 주기로 다시 낸다. 거짓이면 duration 동안만 낸다. (기본 참)If true, emits endlessly and re-emits bursts every duration period. If false, emits only during duration. (default true)

짝Counterpart: vanilla.js ParticleSystem.setLooping

메서드methodpub fn set_duration(&mut self, duration: f64)#0.3.2 부터since 0.3.2소스source

루프 꺼짐일 때 방출 시간. (버스트 반복 주기)

Emission duration when looping is off. (burst repeat period)

durationf64
방출 시간이자 버스트 반복 주기. (초, 기본 1)Emission time and also the burst repeat period. (seconds, default 1)

짝Counterpart: vanilla.js ParticleSystem.setDuration

메서드methodpub fn set_max_particle_count(&mut self, max_particle_count: usize)#0.3.2 부터since 0.3.2소스source

최대 입자 수 설정.

Sets the maximum particle count.

max_particle_countusize
살아 있는 입자의 최대 수. (이만큼 있으면 새로 내지 않는다, 기본 512)Maximum number of live particles. (no new ones are emitted at this count, default 512)

짝Counterpart: vanilla.js ParticleSystem.setMaxParticleCount

메서드methodpub fn apply_description(&mut self, description: &serde_json::Value)#0.3.2 부터since 0.3.2소스source

서술(JSON) 적용. (원본 applyDescription. vfx 애셋 로드, 파티클 편집기 공용. 준 항목만 반영한다. 색은 [r, g, b, a] 배열)

  • attractor 는 { x, y, strength, swirl } 이고 null 이면 끌개를 푼다. wobble 은 [폭, 각속도] 이고 각속도를 빼면 4 다.
  • imageDataUrl 은 파티클 편집기가 고른 그림의 data: 주소다. 그 그림을 입자 이미지로 걸고, 비었거나 null 이면 그림을 비운다.
  • [최소, 최대] 쌍에서 최대를 빼면 원본 기본 인자처럼 최소와 같다.

Applies a description (JSON). (the original applyDescription. Shared by vfx asset loading and the particle editor. Only the given items are applied. Colors are [r, g, b, a] arrays)

  • attractor is { x, y, strength, swirl }, and null releases the attractor. wobble is [amplitude, angular speed], and the angular speed is 4 when omitted.
  • imageDataUrl is the data: URL of the image picked in the particle editor. That image is set as the particle image, and when empty or null the image is cleared.
  • When the maximum of a [minimum, maximum] pair is omitted, it is the same as the minimum, like the original default arguments.
description&serde_json::Value
서술 객체. (원본 키 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. 모르는 이름의 모양과 합성은 무시한다)Description object. (the original keys 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. Shapes and blending with unknown names are ignored)

짝Counterpart: vanilla.js ParticleSystem.applyDescription

예제Example서술로 한 번 터지는 버스트 정하기Set a one-shot burst with a description
use serde_json::json;
use vanilla::ParticleSystem;

let mut particle_system = ParticleSystem::new();
particle_system.apply_description(&json!({
	"looping": false,
	"duration": 1.2,
	"emissionRate": 0,
	"bursts": [{ "time": 0, "count": 25 }],
	"shape": "circle",
	"shapeRadius": 6,
	"lifetime": [0.8, 1.0],
	"speed": [100, 200],
	"startColorA": [1, 0.8, 0.2, 1],
	"blendMode": "lighter",
}));
particle_system.simulate(0.1);
assert_eq!(particle_system.get_particle_count(), 25);
메서드methodpub fn get_particle_count(&self) -> usize#0.3.2 부터since 0.3.2소스source

살아 있는 입자 수 반환.

Returns the number of live particles.

반환Returnsusize 살아 있는 입자 수.Number of live particles.

짝Counterpart: vanilla.js ParticleSystem.getParticleCount

메서드methodpub fn get_particle_position_list(&self) -> Vec<Vector2>#0.4.0 부터since 0.4.0소스source

입자 자리 목록. (컴포넌트 좌표, 흔들림을 넣지 않은 적분 자리. 같은 씨앗 비교와 시험용)

List of particle positions. (component coordinates, integrated positions without the wobble. For same seed comparisons and tests)

반환ReturnsVec<Vector2> 살아 있는 입자의 자리 목록. (낸 차례)List of positions of live particles. (in emission order)

짝Counterpart: vanilla.js ParticleSystem.getParticlePositionList

메서드methodpub fn is_playing(&self) -> bool#0.3.2 부터since 0.3.2소스source

재생 중 여부 반환.

Returns whether it is playing.

반환Returnsbool play 뒤 stop 전이면 true. (기본 true)true after play and before stop. (default true)

짝Counterpart: vanilla.js ParticleSystem.isPlaying

메서드methodpub fn is_finished(&self) -> bool#0.3.2 부터since 0.3.2소스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.

반환Returnsbool 남은 입자가 없고 더 낼 것도 없으면 true. (반복이면 정지 전까지 false)true if no particles remain and nothing more will be emitted. (false until stopped if looping)

짝Counterpart: vanilla.js ParticleSystem.isFinished

메서드methodpub fn set_manual_tick(&mut self, is_manual_tick: bool)#0.3.2 부터since 0.3.2소스source

수동 tick 설정. (켜면 노드 갱신에서 진행하지 않고 simulate 로만 진행한다. 타임라인처럼 밖에서 시간을 다룰 때)

Sets manual tick. (when on, it does not advance in the node update, only with simulate. For when time is handled from outside, like a timeline)

is_manual_tickbool
참이면 노드 tick 은 노드 위치만 읽어 두고 진행은 simulate 를 부를 때만 한다. (기본 거짓)If true, the node tick only records the node position, and it advances only when simulate is called. (default false)

짝Counterpart: vanilla.js ParticleSystem.setManualTick

메서드methodpub fn is_manual_tick(&self) -> bool#0.3.2 부터since 0.3.2소스source

수동 tick 여부 반환.

Returns whether manual tick is on.

반환Returnsbool 수동 tick 이면 true.true if manual tick.

짝Counterpart: vanilla.js ParticleSystem.isManualTick

메서드methodpub fn set_random_seed(&mut self, random_seed: u32)#0.3.2 부터since 0.3.2소스source

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

Sets the random seed. (when set, spawn random numbers switch to seeded random numbers and go back to the seed on every stop(true). For rewind reproduction)

random_seedu32
씨앗 값. (같은 씨앗이면 같은 입자가 나온다)Seed value. (the same seed gives the same particles)

짝Counterpart: vanilla.js ParticleSystem.setRandomSeed

예제Example같은 씨앗의 두 시스템은 같은 자리에 낸다Two systems with the same seed emit at the same positions
use vanilla::ParticleSystem;

let mut first_system = ParticleSystem::new();
let mut second_system = ParticleSystem::new();
first_system.set_random_seed(42);
second_system.set_random_seed(42);
first_system.emit(8, None);
second_system.emit(8, None);
first_system.simulate(0.25);
second_system.simulate(0.25);
assert_eq!(first_system.get_particle_position_list(), second_system.get_particle_position_list());
assert_eq!(first_system.get_random_seed(), Some(42));
메서드methodpub fn get_random_seed(&self) -> Option<u32>#0.3.2 부터since 0.3.2소스source

난수 씨앗 반환.

Returns the random seed.

반환ReturnsOption<u32> set_random_seed 로 준 씨앗. 주지 않았으면 None. (전역 난수를 쓴다)Seed given with set_random_seed. None if not given. (uses the global random numbers)

짝Counterpart: vanilla.js ParticleSystem.getRandomSeed

메서드methodpub fn random_range(&mut self, minimum_value: f64, maximum_value: f64) -> f64#0.3.2 부터since 0.3.2소스source

스폰용 난수. (씨앗이 있으면 씨앗 난수, 없으면 전역 난수)

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

minimum_valuef64
아래 끝. (포함)Lower bound. (inclusive)
maximum_valuef64
위 끝. (포함하지 않는다)Upper bound. (exclusive)

반환Returnsf64 minimum_value 이상 maximum_value 미만의 무작위 수. (씨앗 난수면 수열이 하나 나아간다)Random number from minimum_value inclusive to maximum_value exclusive. (advances the sequence by one for seeded random numbers)

짝Counterpart: vanilla.js ParticleSystem.randomRange

ParticleEmitterShapeenum traits Clone, Copy, Debug, PartialEq, Eq

짝Counterpart: vanilla.js ParticleEmitterShape소스source

방출 모양. (원본 ParticleEmitterShape)

Emitter shape. (the original ParticleEmitterShape)

이름Name설명Description
Point노드 원점 한 점에서 모든 방향으로.In all directions from a single point at the node origin.
Circle반지름 안 무작위 위치에서 바깥 방향으로.Outward from a random position inside the radius.
Cone위쪽(-Y) 기준 반각 cone_angle 부채꼴 방향으로, 그 방향 반지름 안 위치에서.In a fan direction with half angle cone_angle relative to up (-Y), from a position inside the radius in that direction.
Boxbox_size 사각 영역 안 무작위 위치에서 위쪽(-Y)으로.Upward (-Y) from a random position inside the box_size rectangle.
Edgeedge_width 가로 선분 위 무작위 위치에서 아래쪽(+Y)으로. (눈, 비처럼 위에서 뿌릴 때)Downward (+Y) from a random position on the horizontal line segment of edge_width. (for scattering from above, like snow or rain)

ParticleRenderShapeenum traits Clone, Copy, Debug, PartialEq, Eq

짝Counterpart: vanilla.js ParticleRenderShape소스source

렌더 모양. (원본 ParticleRenderShape)

Render shape. (the original ParticleRenderShape)

이름Name설명Description
Circle부드러운 원. (기본)Soft circle. (default)
Rect사각형. (색종이 조각처럼 도는 판)Rectangle. (a spinning plate like confetti)
Streak진행 방향으로 늘인 띠. (비, 유성)A streak stretched in the direction of travel. (rain, meteors)
Imageset_image 로 넣은 그림.The image set with set_image.