|
@@ -165,6 +165,8 @@ class GpuPartGroup {
|
|
public var colorGradient : h3d.mat.Texture = null;
|
|
public var colorGradient : h3d.mat.Texture = null;
|
|
|
|
|
|
public var isRelative(default, set) : Bool = false;
|
|
public var isRelative(default, set) : Bool = false;
|
|
|
|
+ public var attachToCam(default, set) : Bool = false;
|
|
|
|
+ public var distanceToCam(default, set) : Float = 0;
|
|
|
|
|
|
inline function set_sortMode(v) { needRebuild = true; return sortMode = v; }
|
|
inline function set_sortMode(v) { needRebuild = true; return sortMode = v; }
|
|
inline function set_size(v) { needRebuild = true; return size = v; }
|
|
inline function set_size(v) { needRebuild = true; return size = v; }
|
|
@@ -189,6 +191,8 @@ class GpuPartGroup {
|
|
inline function set_rotSpeed(v) { needRebuild = true; return rotSpeed = v; }
|
|
inline function set_rotSpeed(v) { needRebuild = true; return rotSpeed = v; }
|
|
inline function set_rotSpeedRand(v) { needRebuild = true; return rotSpeedRand = v; }
|
|
inline function set_rotSpeedRand(v) { needRebuild = true; return rotSpeedRand = v; }
|
|
inline function set_isRelative(v) { needRebuild = true; return isRelative = v; }
|
|
inline function set_isRelative(v) { needRebuild = true; return isRelative = v; }
|
|
|
|
+ inline function set_attachToCam(v) { needRebuild = true; return attachToCam = v; }
|
|
|
|
+ inline function set_distanceToCam(v) { needRebuild = true; return distanceToCam = v; }
|
|
|
|
|
|
public function new(parent) {
|
|
public function new(parent) {
|
|
this.parent = parent;
|
|
this.parent = parent;
|
|
@@ -963,7 +967,17 @@ class GpuParticles extends h3d.scene.MultiMaterial {
|
|
g.pshader.transform.load(absPos);
|
|
g.pshader.transform.load(absPos);
|
|
else
|
|
else
|
|
g.pshader.transform.identity();
|
|
g.pshader.transform.identity();
|
|
- g.pshader.offset.set(0, 0, 0);
|
|
|
|
|
|
+ if ( g.attachToCam ) {
|
|
|
|
+ ignoreParentTransform = true;
|
|
|
|
+ var camPos = ctx.camera.pos;
|
|
|
|
+ var camDir = ctx.camera.target.sub(ctx.camera.pos).normalized().clone();
|
|
|
|
+ var offset = camDir;
|
|
|
|
+ offset.scale(g.distanceToCam);
|
|
|
|
+ var emitterPos = camPos.add(offset);
|
|
|
|
+ g.pshader.offset.set( getAbsPos().getPosition().x + emitterPos.x, getAbsPos().getPosition().y + emitterPos.y, getAbsPos().getPosition().z + emitterPos.z );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ g.pshader.offset.set(0, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|