|
@@ -16,38 +16,42 @@ class Scene3D extends Sprite {
|
|
}
|
|
}
|
|
|
|
|
|
class ObjectFollower extends Sprite {
|
|
class ObjectFollower extends Sprite {
|
|
-
|
|
|
|
|
|
+
|
|
public var follow : h3d.scene.Object;
|
|
public var follow : h3d.scene.Object;
|
|
-
|
|
|
|
|
|
+ public var pixelSnap = true;
|
|
|
|
+ public var offsetX = 0.;
|
|
|
|
+ public var offsetY = 0.;
|
|
|
|
+ public var offsetZ = 0.;
|
|
|
|
+
|
|
public function new( obj, ?parent ) {
|
|
public function new( obj, ?parent ) {
|
|
super(parent);
|
|
super(parent);
|
|
this.follow = obj;
|
|
this.follow = obj;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
function followObject() {
|
|
function followObject() {
|
|
if( follow == null )
|
|
if( follow == null )
|
|
return;
|
|
return;
|
|
var scene = @:privateAccess follow.getScene();
|
|
var scene = @:privateAccess follow.getScene();
|
|
if( scene == null )
|
|
if( scene == null )
|
|
return;
|
|
return;
|
|
- var s2d = getScene();
|
|
|
|
|
|
+ var s2d = getScene();
|
|
var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
|
|
var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
|
|
var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
|
|
var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
|
|
var absPos = follow.getAbsPos();
|
|
var absPos = follow.getAbsPos();
|
|
- var p = scene.camera.project(absPos._41, absPos._42, absPos._43, width, height, true);
|
|
|
|
|
|
+ var p = scene.camera.project(absPos._41 + offsetX, absPos._42 + offsetY, absPos._43 + offsetZ, width, height, pixelSnap);
|
|
x = p.x;
|
|
x = p.x;
|
|
y = p.y;
|
|
y = p.y;
|
|
visible = p.z > 0;
|
|
visible = p.z > 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
override function syncPos() {
|
|
override function syncPos() {
|
|
followObject();
|
|
followObject();
|
|
super.syncPos();
|
|
super.syncPos();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
override function sync(ctx) {
|
|
override function sync(ctx) {
|
|
followObject();
|
|
followObject();
|
|
super.sync(ctx);
|
|
super.sync(ctx);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|