15 public float KeyboardMovementSpeed = 1.5f;
16 public float GestureMovementSpeed = 1.0f;
22 private bool wasThickSliceEnabled;
24 public bool ThickSliceEnabled =
true;
31 PlaneX.GetComponent<Renderer>().sharedMaterial = mat;
32 PlaneY.GetComponent<Renderer>().sharedMaterial = mat;
33 PlaneZ.GetComponent<Renderer>().sharedMaterial = mat;
36 private void OnEnable()
39 wasThickSliceEnabled = !ThickSliceEnabled;
44 private void OnDisable()
51 this.ThickSliceEnabled = on;
58 Vector4 planeEquation;
60 var forward = this.transform.forward;
61 var pos = this.transform.position;
63 planeEquation.x = forward.x;
64 planeEquation.y = forward.y;
65 planeEquation.z = forward.z;
68 planeEquation.w = (planeEquation.x * pos.x +
69 planeEquation.y * pos.y +
70 planeEquation.z * pos.z);
72 Shader.SetGlobalVector(
"CutPlane", planeEquation);
74 var cornerPos = this.transform.localPosition;
75 var slabMin =
new Vector4(cornerPos.x - 0.5f, cornerPos.y - 0.5f, cornerPos.z - 0.5f, 0.0f);
76 var slabMax =
new Vector4(cornerPos.x + 0.5f, cornerPos.y + 0.5f, cornerPos.z + 0.5f, 0.0f);
78 Shader.SetGlobalVector(
"SlabMin", slabMin);
79 Shader.SetGlobalVector(
"SlabMax", slabMax);
81 if (ThickSliceEnabled != wasThickSliceEnabled)
83 SetMaterial(ThickSliceEnabled ? ThickSliceMaterial : SliceMaterial);
84 wasThickSliceEnabled = ThickSliceEnabled;
87 Shader.SetGlobalMatrix(
"_SlicingWorldToLocal", this.transform.worldToLocalMatrix);
90 void HandleDebugKeys()
92 float movementDelta = KeyboardMovementSpeed * Time.deltaTime;
94 var positionDeltaX = this.transform.localRotation *
new Vector3(movementDelta, 0.0f, 0.0f);
95 var positionDeltaY = this.transform.localRotation *
new Vector3(0.0f, movementDelta, 0.0f);
96 var positionDeltaZ = this.transform.localRotation *
new Vector3(0.0f, 0.0f, movementDelta);
98 if (Input.GetKey(KeyCode.L)) { this.transform.localPosition += positionDeltaX; }
99 if (Input.GetKey(KeyCode.J)) { this.transform.localPosition -= positionDeltaX; }
101 if (Input.GetKey(KeyCode.I)) { this.transform.localPosition += positionDeltaY; }
102 if (Input.GetKey(KeyCode.K)) { this.transform.localPosition -= positionDeltaY; }
104 if (Input.GetKey(KeyCode.RightBracket)) { this.transform.localPosition += positionDeltaZ; }
105 if (Input.GetKey(KeyCode.LeftBracket)) { this.transform.localPosition -= positionDeltaZ; }
113 float movementDelta = GestureMovementSpeed * Time.deltaTime;
116 this.transform.localPosition += this.transform.localRotation * eventData.
CumulativeDelta * movementDelta;