Permalink
Browse files

Fixes for #178 & #198

  • Loading branch information...
1 parent 35d3fd5 commit e49076415a626906160786103c18f7486c7c9027 @Greg209 Greg209 committed Jul 1, 2013
@@ -582,13 +582,14 @@ package awaybuilder.utils.scene
// Hide representations to get clear bounds
if (excludeGizmos) {
- for each (rep in textureProjectorGizmos) rep.visible = false;
+ for each (rep in lightGizmos) rep.visible = false;
for each (rep in textureProjectorGizmos) rep.visible = false;
for each (rep in cameraGizmos) rep.visible = false;
for each (rep in containerGizmos) rep.visible = false;
}
// Get all scene child container bounds
+//trace("\nSceneBounds:");
while (ctr < oCCount) {
var oC:ObjectContainer3D = Scene3DManager.view.scene.getChildAt(ctr++);
if (!(oC is SkyBox || oC is PointLight || oC == Scene3DManager.grid)) {
@@ -605,7 +606,7 @@ package awaybuilder.utils.scene
// Re-show representations
if (excludeGizmos) {
- for each (rep in textureProjectorGizmos) rep.visible = true;
+ for each (rep in lightGizmos) rep.visible = true;
for each (rep in textureProjectorGizmos) rep.visible = true;
for each (rep in cameraGizmos) rep.visible = true;
for each (rep in containerGizmos) rep.visible = true;
@@ -708,6 +709,8 @@ package awaybuilder.utils.scene
if (getQualifiedClassName(container)=="away3d.containers::ObjectContainer3D" && container.numChildren == 0) {
addEmptyContainerRepresentation(container);
+ } else if (container is Camera3D) {
+ addCamera(container as Camera3D);
}
updateDefaultCameraFarPlane();
@@ -55,8 +55,7 @@ package awaybuilder.view.scene.controls
}
public function updateRepresentation() : void {
- _representation.position = sceneObject.position.clone();
- _representation.eulers = sceneObject.eulers.clone();
+ _representation.transform = sceneObject.sceneTransform.clone();
var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(sceneObject.scenePosition);
_representation.scaleX = _representation.scaleY = _representation.scaleZ = 0.6 * dist.length / 1500;
@@ -1,5 +1,6 @@
package awaybuilder.view.scene.controls
{
+ import flash.geom.Matrix3D;
import away3d.containers.ObjectContainer3D;
import away3d.lights.DirectionalLight;
import away3d.materials.ColorMaterial;
@@ -68,16 +69,18 @@ package awaybuilder.view.scene.controls
public function update():void
{
- var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(this.scenePosition);
+ this.scaleX = this.scaleY = this.scaleZ = content.scaleX = content.scaleY = content.scaleZ = 1;
+
+ var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(content.scenePosition);
var scale:Number = dist.length/1000;
content.scaleX = scale;
content.scaleY = scale;
content.scaleZ = scale;
-
+
content.transform = content.transform.clone(); // Force the transform invalidation
ambientLight.direction = Scene3DManager.camera.forwardVector;
-
+
if (currentMesh && !active) updatePositionAndRotation();
}
@@ -99,8 +102,19 @@ package awaybuilder.view.scene.controls
protected function updatePositionAndRotation() : void {
if (type == TRANSLATE_GIZMO) {
+ if (!currentMesh.parent) return;
+
this.rotationX = this.rotationY = this.rotationZ = 0;
- this.position = currentMesh.scenePosition.clone();
+ var vecs:Vector.<Vector3D> = currentMesh.parent.sceneTransform.decompose();
+ vecs[0] = new Vector3D();
+ vecs[2] = new Vector3D(1, 1, 1);
+ var mat:Matrix3D = new Matrix3D();
+ mat.recompose(vecs);
+ var pos:Vector3D = new Vector3D(currentMesh.x, currentMesh.y, currentMesh.z);
+ pos = mat.transformVector(pos);
+ content.position = pos;
+ this.position = currentMesh.parent.scenePosition.clone();
+
return;
}
@@ -65,12 +65,12 @@ package awaybuilder.view.scene.controls
_representation.rotationX -= 90;
_representation.scaleX = _representation.scaleY = _representation.scaleZ = Scene3DManager.stage.stageHeight/720;
} else {
+ _representation.transform = sceneObject.sceneTransform.clone();
_representation.eulers = CameraManager.camera.eulers.clone();
_representation.rotationX -= 90;
_representation.rotationY -= 1; // Temporary fix for bounds visiblity
var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(_representation.scenePosition);
_representation.scaleX = _representation.scaleZ = dist.length/1500;
- _representation.position = sceneObject.position.clone();
}
}
}
@@ -56,8 +56,7 @@ package awaybuilder.view.scene.controls
}
public function updateRepresentation() : void {
- _representation.position = sceneObject.position.clone();
- _representation.eulers = sceneObject.eulers.clone();
+ _representation.transform = sceneObject.sceneTransform.clone();
var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(sceneObject.scenePosition);
_representation.scaleX = _representation.scaleY = _representation.scaleZ = dist.length / 1500;
}
@@ -178,14 +178,15 @@ package awaybuilder.view.scene.controls
{
super.update();
- if (pivot && currentMesh) {
- pivot.scaleX = content.scaleX;
- pivot.scaleY = content.scaleY;
- pivot.scaleZ = content.scaleZ;
-
+ if (pivot && currentMesh && currentMesh.parent) {
pivot.eulers = CameraManager.camera.eulers.clone();
- var piv:Vector3D = currentMesh.sceneTransform.deltaTransformVector(currentMesh.pivotPoint);
- pivot.position = piv;
+
+ var piv:Vector3D = currentMesh.parent.sceneTransform.deltaTransformVector(currentMesh.pivotPoint);
+ pivot.position = content.position.add(piv);
+
+ var dist:Vector3D = Scene3DManager.camera.scenePosition.subtract(pivot.scenePosition);
+ var scale:Number = dist.length/1000;
+ pivot.scaleX = pivot.scaleY = pivot.scaleZ = scale;
}
}
@@ -200,7 +201,7 @@ package awaybuilder.view.scene.controls
else actualMesh = currentMesh;
startValue = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
- startScenePosition = actualMesh.scenePosition.clone();
+ startScenePosition = actualMesh.parent.scenePosition.clone();
switch(currentAxis)
{

0 comments on commit e490764

Please sign in to comment.