Permalink
Browse files

Fixes for #180, #178, #156, #155, #83

  • Loading branch information...
1 parent 5d6d0e0 commit dfee430ee544a95f7554eeb93828d6814e7a0b4d @Greg209 Greg209 committed Jun 21, 2013
@@ -1,6 +1,5 @@
package awaybuilder.view.scene.controls
{
- import flash.geom.Matrix3D;
import away3d.containers.ObjectContainer3D;
import away3d.lights.DirectionalLight;
import away3d.materials.ColorMaterial;
@@ -74,14 +73,8 @@ package awaybuilder.view.scene.controls
content.scaleX = scale;
content.scaleY = scale;
content.scaleZ = scale;
-//trace("this.position:"+this.position)
- if (!active && currentMesh != null)
- {
- if (!(isLightGizmo && isLightGizmo.type == LightGizmo3D.DIRECTIONAL_LIGHT)) {
-// var pivot:Vector3D = currentMesh.transform.deltaTransformVector(currentMesh.pivotPoint);
-// this.position = currentMesh.scenePosition.add(pivot);
- }
- }
+
+ content.transform = content.transform.clone(); // Force the transform invalidation
ambientLight.direction = Scene3DManager.camera.forwardVector;
}
@@ -94,34 +87,31 @@ package awaybuilder.view.scene.controls
isContainerGizmo = currentMesh.parent as ContainerGizmo3D;
isTextureProjectorGizmo = currentMesh.parent as TextureProjectorGizmo3D;
- var pivot:Vector3D = currentMesh.sceneTransform.deltaTransformVector(currentMesh.pivotPoint);
- this.position = currentMesh.scenePosition.add(pivot);
- if (isLightGizmo)
+ content.transform.identity();
+ this.transform = currentMesh.parent.sceneTransform.clone();
+
+ if (isTextureProjectorGizmo)
{
- content.rotationX = content.rotationY = content.rotationZ = 0;
+ if (type != TRANSLATE_GIZMO) {
+ content.rotationX = isTextureProjectorGizmo.sceneObject.rotationX;
+ content.rotationY = isTextureProjectorGizmo.sceneObject.rotationY;
+ content.rotationZ = isTextureProjectorGizmo.sceneObject.rotationZ;
+ } else this.rotationX = this.rotationY = this.rotationZ = 0;
}
- else if (isTextureProjectorGizmo)
- {
- if (type == TRANSLATE_GIZMO) {
- content.rotationX = content.rotationY = content.rotationZ = 0;
- } else {
- content.rotationX = isTextureProjectorGizmo.sceneObject.rotationX;
- content.rotationY = isTextureProjectorGizmo.sceneObject.rotationY;
- content.rotationZ = isTextureProjectorGizmo.sceneObject.rotationZ;
- }
- }
- else
+ else if (!isLightGizmo)
{
- if (type == TRANSLATE_GIZMO) {
- content.rotationX = content.rotationY = content.rotationZ = 0;
- } else {
- content.rotationX = (isContainerGizmo) ? isContainerGizmo.parent.rotationX : sceneObject.rotationX;
- content.rotationY = (isContainerGizmo) ? isContainerGizmo.parent.rotationY : sceneObject.rotationY;
- content.rotationZ = (isContainerGizmo) ? isContainerGizmo.parent.rotationZ : sceneObject.rotationZ;
- }
+ if (type != TRANSLATE_GIZMO) {
+ content.rotationX = (isContainerGizmo) ? isContainerGizmo.parent.rotationX : currentMesh.rotationX;
+ content.rotationY = (isContainerGizmo) ? isContainerGizmo.parent.rotationY : currentMesh.rotationY;
+ content.rotationZ = (isContainerGizmo) ? isContainerGizmo.parent.rotationZ : currentMesh.rotationZ;
+ } else this.rotationX = this.rotationY = this.rotationZ = 0;
}
+ var pivot:Vector3D = currentMesh.sceneTransform.deltaTransformVector(currentMesh.pivotPoint);
+ this.position = (type == TRANSLATE_GIZMO) ? currentMesh.scenePosition.clone() : currentMesh.scenePosition.add(pivot);
this.visible = true;
+
+ update();
}
public function hide():void
@@ -4,7 +4,6 @@ package awaybuilder.view.scene.controls
import away3d.primitives.CylinderGeometry;
import away3d.lights.DirectionalLight;
import away3d.containers.ObjectContainer3D;
- import away3d.core.math.Quaternion;
import away3d.core.pick.PickingColliderType;
import away3d.entities.Mesh;
import away3d.entities.SegmentSet;
@@ -42,6 +41,7 @@ package awaybuilder.view.scene.controls
private var actualMesh:ObjectContainer3D;
private var startValue:Vector3D;
+ //private var startSceneRotation:Vector3D;
private var behindGizmoPlane : Boolean;
public function RotateGizmo3D()
@@ -238,7 +238,7 @@ package awaybuilder.view.scene.controls
CameraManager.active = false;
startValue = actualMesh.eulers.clone();
-
+
Scene3DManager.stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
Scene3DManager.stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
}
@@ -311,8 +311,8 @@ package awaybuilder.view.scene.controls
}
if (isLightGizmo && isLightGizmo.type == LightGizmo3D.DIRECTIONAL_LIGHT) updateDirectionalLight();
- else actualMesh.eulers = content.eulers;
-
+ else actualMesh.eulers = content.eulers.clone();
+
click.x = Scene3DManager.stage.mouseX;
click.y = Scene3DManager.stage.mouseY;
@@ -1,7 +1,7 @@
package awaybuilder.view.scene.controls
{
+ import away3d.primitives.WireframeRegularPolygon;
import awaybuilder.view.scene.representations.ISceneRepresentation;
- import away3d.core.math.Vector3DUtils;
import away3d.containers.ObjectContainer3D;
import away3d.core.pick.PickingColliderType;
import away3d.entities.Mesh;
@@ -32,6 +32,7 @@ package awaybuilder.view.scene.controls
private var actualMesh : ObjectContainer3D;
private var startScenePosition : Vector3D;
+ private var pivot : ObjectContainer3D;
public function TranslateGizmo3D()
{
@@ -103,7 +104,14 @@ package awaybuilder.view.scene.controls
zCone.addEventListener(MouseEvent3D.MOUSE_DOWN, handleMouseDown);
zCone.rotationX = 180;
zCone.z = 100 + (coneGeom.height/2);
- content.addChild(zCone);
+ content.addChild(zCone);
+
+ pivot = new ObjectContainer3D();
+ var p1:WireframeRegularPolygon = new WireframeRegularPolygon(15, 20, 0xffffff, 0.5, "xy");
+ var p2:WireframeRegularPolygon = new WireframeRegularPolygon(5, 20, 0xff0000, 0.5, "xy");
+ pivot.addChild(p1);
+ pivot.addChild(p2);
+ this.addChild(pivot);
}
protected function handleMouseOut(event:MouseEvent3D):void
@@ -169,6 +177,12 @@ package awaybuilder.view.scene.controls
override public function update():void
{
super.update();
+
+ if (pivot && currentMesh) {
+ pivot.eulers = CameraManager.camera.eulers.clone();
+ var piv:Vector3D = currentMesh.sceneTransform.deltaTransformVector(currentMesh.pivotPoint);
+ pivot.position = piv;
+ }
}
protected function handleMouseDown(e:Event):void
@@ -182,8 +196,7 @@ package awaybuilder.view.scene.controls
else actualMesh = currentMesh;
startValue = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
- var pivot:Vector3D = actualMesh.transform.deltaTransformVector(actualMesh.pivotPoint);
- startScenePosition = actualMesh.scenePosition.add(pivot);
+ startScenePosition = actualMesh.scenePosition.clone();
switch(currentAxis)
{
@@ -270,7 +283,9 @@ package awaybuilder.view.scene.controls
click.x = Scene3DManager.stage.mouseX;
click.y = Scene3DManager.stage.mouseY;
- var pos:Vector3D = this.position.subtract(startScenePosition).add(startValue);
+ var pos:Vector3D = this.position.subtract(startScenePosition);
+ pos = actualMesh.parent.inverseSceneTransform.deltaTransformVector(pos).add(startValue);
+
actualMesh.x = pos.x;
actualMesh.y = pos.y;
actualMesh.z = pos.z;
@@ -296,7 +311,7 @@ package awaybuilder.view.scene.controls
zCone.material = zAxisMaterial;
zCylinder.material = zAxisMaterial;
- var pos:Vector3D = this.position.subtract(actualMesh.pivotPoint).subtract(actualMesh.parent.scenePosition);
+ var pos:Vector3D = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
dispatchEvent(new Gizmo3DEvent(Gizmo3DEvent.RELEASE, GizmoMode.TRANSLATE, actualMesh, pos, startValue, pos));
}

0 comments on commit dfee430

Please sign in to comment.