misc/toucheffect
파티클용 방사형 그라디언트 텍스처. (흰색으로 구워 셰이더 틴트로 착색)
- WebGL2 에는 그라디언트 API 가 없으므로 오프스크린 2D 캔버스에 1회만 굽는다.
Radial gradient texture for particles. (Baked in white and colored by the shader tint)
- WebGL2 has no gradient API, so it is baked only once onto an offscreen 2D canvas.
TouchParticleextends Object
터치 입자.
Touch particle.
import { TouchParticle, Vector2 } from "./build/vanilla.js";
const touchParticle = new TouchParticle();
touchParticle.position = Vector2.create(100, 100);
touchParticle.velocity = Vector2.create(30, -60);
touchParticle.radius = 20;
const timeDelta = 0.1;
touchParticle.life -= timeDelta * 2.5;
const step = touchParticle.velocity.multiply(timeDelta);
touchParticle.position = touchParticle.position.add(step);
const opacity = touchParticle.life / touchParticle.maxLife;
console.log(opacity, touchParticle.position.x, touchParticle.position.y);자리. (픽셀, TouchEffect 노드 기준)
Position. (pixels, relative to the TouchEffect node)
반환ReturnsVector2
짝Counterpart: vanilla-engine TouchParticle.position
속도. (픽셀 / 초)
Velocity. (pixels / second)
반환ReturnsVector2
짝Counterpart: vanilla-engine TouchParticle.velocity
남은 수명. (1 에서 시작해 초당 2.5 씩 줄고 0 이하면 지운다)
Remaining life. (Starts at 1, decreases by 2.5 per second, removed at 0 or below)
반환Returnsnumber
짝Counterpart: vanilla-engine TouchParticle.life
처음 수명. (불투명도는 life / maxLife)
Initial life. (Opacity is life / maxLife)
반환Returnsnumber
짝Counterpart: vanilla-engine TouchParticle.max_life
TouchEffectextends WorldNode
터치 효과.
Touch effect.
import { Engine, EngineConfiguration, Scene, TouchEffect } from "./build/vanilla.js";
const touchEffect = new TouchEffect();
class MainScene extends Scene {
initialize(engine) {
super.initialize(engine);
const root = this.getRoot();
root.addChild(touchEffect);
for (let index = 0; index < 8; ++index) {
touchEffect.createTouchParticle(320, 180);
}
}
touchPress(viewInputPosition) {
super.touchPress(viewInputPosition);
for (let index = 0; index < 8; ++index) {
touchEffect.createTouchParticle(viewInputPosition.x, viewInputPosition.y);
}
}
}
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());갱신.
Update.
- timeDeltanumber
- 지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
출력 상태 시작.
Begins the draw state.
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
출력 상태 종료.
Ends the draw state.
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
터치 파티클 생성.
Creates touch particles.
- xnumber
- 입자를 낼 X. (이 노드 기준 좌표, 10 픽셀 안에서 흔든다)X to emit particles at. (Coordinates relative to this node, jittered within 10 pixels)
- ynumber
- 입자를 낼 Y. (이 노드 기준 좌표, 10 픽셀 안에서 흔든다)Y to emit particles at. (Coordinates relative to this node, jittered within 10 pixels)
짝Counterpart: vanilla-engine TouchEffect.create_touch_particle
터치 파티클 갱신.
Updates touch particles.
- timeDeltanumber
- 지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
짝Counterpart: vanilla-engine TouchEffect.update_touch_particles
터치 파티클 출력.
Renders touch particles.
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
짝Counterpart: vanilla-engine TouchEffect.draw_touch_particles