@woosh/meep-engine 2.109.10 → 2.109.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/tools/v2/GizmoNode.js +71 -0
- package/editor/tools/v2/TransformControls.js +10 -980
- package/editor/tools/v2/TransformControlsGizmo.js +774 -0
- package/editor/tools/v2/TransformControlsPlane.js +118 -0
- package/editor/tools/v2/TransformMode.js +8 -0
- package/editor/tools/v2/TranslateHelperGeometry.js +14 -0
- package/package.json +1 -1
- package/src/core/model/node-graph/NodeGraph.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeDescription.d.ts +1 -1
- package/src/core/model/node-graph/node/NodeDescription.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeInstance.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.d.ts +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.js +5 -5
- package/src/core/model/node-graph/node/NodeRegistry.spec.js +1 -1
- package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
- package/src/core/model/node-graph/node/Port.js +3 -2
- package/src/core/model/node-graph/node/Port.spec.js +1 -1
- package/src/core/model/node-graph/type/DataType.d.ts.map +1 -0
- package/src/core/model/node-graph/{DataType.js → type/DataType.js} +2 -2
- package/src/core/model/node-graph/type/DataType.spec.d.ts.map +1 -0
- package/src/core/model/node-graph/{ParametricDataType.d.ts → type/ParametricDataType.d.ts} +6 -1
- package/src/core/model/node-graph/type/ParametricDataType.d.ts.map +1 -0
- package/src/core/model/node-graph/{ParametricDataType.js → type/ParametricDataType.js} +19 -4
- package/src/core/model/node-graph/type/ParametricDataType.spec.d.ts +2 -0
- package/src/core/model/node-graph/type/ParametricDataType.spec.d.ts.map +1 -0
- package/src/core/model/node-graph/type/ParametricDataType.spec.js +63 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.d.ts +8 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.d.ts.map +1 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.js +24 -0
- package/src/engine/graphics/geometry/CircleGeometry.d.ts +20 -0
- package/src/engine/graphics/geometry/CircleGeometry.d.ts.map +1 -0
- package/src/engine/graphics/geometry/CircleGeometry.js +17 -0
- package/src/engine/graphics/particles/node-based/nodes/ParticleDataTypes.js +1 -1
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts +10 -8
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/common.glsl +171 -95
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +4 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +4 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +52 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +4 -4
- package/src/core/model/node-graph/DataType.d.ts.map +0 -1
- package/src/core/model/node-graph/DataType.spec.d.ts.map +0 -1
- package/src/core/model/node-graph/ParametricDataType.d.ts.map +0 -1
- /package/src/core/model/node-graph/{DataType.d.ts → type/DataType.d.ts} +0 -0
- /package/src/core/model/node-graph/{DataType.spec.d.ts → type/DataType.spec.d.ts} +0 -0
- /package/src/core/model/node-graph/{DataType.spec.js → type/DataType.spec.js} +0 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoxGeometry,
|
|
3
|
+
BufferGeometry,
|
|
4
|
+
CylinderGeometry,
|
|
5
|
+
Euler,
|
|
6
|
+
Float32BufferAttribute,
|
|
7
|
+
LineBasicMaterial,
|
|
8
|
+
Matrix4,
|
|
9
|
+
MeshBasicMaterial,
|
|
10
|
+
OctahedronGeometry,
|
|
11
|
+
Quaternion,
|
|
12
|
+
SphereGeometry,
|
|
13
|
+
TorusGeometry,
|
|
14
|
+
Vector3
|
|
15
|
+
} from "three";
|
|
16
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
17
|
+
import { DrawMode } from "../../../src/engine/graphics/ecs/mesh-v2/DrawMode.js";
|
|
18
|
+
import { ShadedGeometry } from "../../../src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
19
|
+
import { ShadedGeometryFlags } from "../../../src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
20
|
+
import { CircleGeometry } from "../../../src/engine/graphics/geometry/CircleGeometry.js";
|
|
21
|
+
import { GizmoNode } from "./GizmoNode.js";
|
|
22
|
+
import { TransformMode } from "./TransformMode.js";
|
|
23
|
+
import { TranslateHelperGeometry } from "./TranslateHelperGeometry.js";
|
|
24
|
+
|
|
25
|
+
// Reusable utility variables
|
|
26
|
+
const _alignVector = new Vector3(0, 1, 0);
|
|
27
|
+
const _identityQuaternion = new Quaternion();
|
|
28
|
+
const _tempVector = new Vector3();
|
|
29
|
+
const _tempQuaternion = new Quaternion();
|
|
30
|
+
const _tempEuler = new Euler();
|
|
31
|
+
const _zeroVector = new Vector3(0, 0, 0);
|
|
32
|
+
const _lookAtMatrix = new Matrix4();
|
|
33
|
+
const _tempQuaternion2 = new Quaternion();
|
|
34
|
+
|
|
35
|
+
const _unitX = new Vector3(1, 0, 0);
|
|
36
|
+
const _unitY = new Vector3(0, 1, 0);
|
|
37
|
+
const _unitZ = new Vector3(0, 0, 1);
|
|
38
|
+
class TransformControlsGizmo extends GizmoNode {
|
|
39
|
+
|
|
40
|
+
constructor() {
|
|
41
|
+
|
|
42
|
+
super();
|
|
43
|
+
|
|
44
|
+
this.isTransformControlsGizmo = true;
|
|
45
|
+
|
|
46
|
+
this.type = 'TransformControlsGizmo';
|
|
47
|
+
|
|
48
|
+
// shared materials
|
|
49
|
+
|
|
50
|
+
const gizmoMaterial = new MeshBasicMaterial({
|
|
51
|
+
depthTest: false,
|
|
52
|
+
depthWrite: false,
|
|
53
|
+
fog: false,
|
|
54
|
+
toneMapped: false,
|
|
55
|
+
transparent: true
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const gizmoLineMaterial = new LineBasicMaterial({
|
|
59
|
+
depthTest: false,
|
|
60
|
+
depthWrite: false,
|
|
61
|
+
fog: false,
|
|
62
|
+
toneMapped: false,
|
|
63
|
+
transparent: true
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Make unique material for each axis/color
|
|
67
|
+
|
|
68
|
+
const matInvisible = gizmoMaterial.clone();
|
|
69
|
+
matInvisible.opacity = 0.15;
|
|
70
|
+
|
|
71
|
+
const matHelper = gizmoLineMaterial.clone();
|
|
72
|
+
matHelper.opacity = 0.5;
|
|
73
|
+
|
|
74
|
+
const matRed = gizmoMaterial.clone();
|
|
75
|
+
matRed.color.setHex(0xff0000);
|
|
76
|
+
|
|
77
|
+
const matGreen = gizmoMaterial.clone();
|
|
78
|
+
matGreen.color.setHex(0x00ff00);
|
|
79
|
+
|
|
80
|
+
const matBlue = gizmoMaterial.clone();
|
|
81
|
+
matBlue.color.setHex(0x0000ff);
|
|
82
|
+
|
|
83
|
+
const matRedTransparent = gizmoMaterial.clone();
|
|
84
|
+
matRedTransparent.color.setHex(0xff0000);
|
|
85
|
+
matRedTransparent.opacity = 0.5;
|
|
86
|
+
|
|
87
|
+
const matGreenTransparent = gizmoMaterial.clone();
|
|
88
|
+
matGreenTransparent.color.setHex(0x00ff00);
|
|
89
|
+
matGreenTransparent.opacity = 0.5;
|
|
90
|
+
|
|
91
|
+
const matBlueTransparent = gizmoMaterial.clone();
|
|
92
|
+
matBlueTransparent.color.setHex(0x0000ff);
|
|
93
|
+
matBlueTransparent.opacity = 0.5;
|
|
94
|
+
|
|
95
|
+
const matWhiteTransparent = gizmoMaterial.clone();
|
|
96
|
+
matWhiteTransparent.opacity = 0.25;
|
|
97
|
+
|
|
98
|
+
const matYellowTransparent = gizmoMaterial.clone();
|
|
99
|
+
matYellowTransparent.color.setHex(0xffff00);
|
|
100
|
+
matYellowTransparent.opacity = 0.25;
|
|
101
|
+
|
|
102
|
+
const matYellow = gizmoMaterial.clone();
|
|
103
|
+
matYellow.color.setHex(0xffff00);
|
|
104
|
+
|
|
105
|
+
const matGray = gizmoMaterial.clone();
|
|
106
|
+
matGray.color.setHex(0x787878);
|
|
107
|
+
|
|
108
|
+
// reusable geometry
|
|
109
|
+
|
|
110
|
+
const arrowGeometry = new CylinderGeometry(0, 0.04, 0.1, 12);
|
|
111
|
+
arrowGeometry.translate(0, 0.05, 0);
|
|
112
|
+
|
|
113
|
+
const scaleHandleGeometry = new BoxGeometry(0.08, 0.08, 0.08);
|
|
114
|
+
scaleHandleGeometry.translate(0, 0.04, 0);
|
|
115
|
+
|
|
116
|
+
const lineGeometry = new BufferGeometry();
|
|
117
|
+
lineGeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3));
|
|
118
|
+
|
|
119
|
+
const lineGeometry2 = new CylinderGeometry(0.0075, 0.0075, 0.5, 3);
|
|
120
|
+
lineGeometry2.translate(0, 0.25, 0);
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
// Gizmo definitions - custom hierarchy definitions for setupGizmo() function
|
|
124
|
+
|
|
125
|
+
const gizmoTranslate = {
|
|
126
|
+
X: [
|
|
127
|
+
[ShadedGeometry.from(arrowGeometry, matRed, DrawMode.Triangles), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
128
|
+
[ShadedGeometry.from(arrowGeometry, matRed, DrawMode.Triangles), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
129
|
+
[ShadedGeometry.from(lineGeometry2, matRed, DrawMode.Triangles), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
130
|
+
],
|
|
131
|
+
Y: [
|
|
132
|
+
[ShadedGeometry.from(arrowGeometry, matGreen, DrawMode.Triangles), [0, 0.5, 0]],
|
|
133
|
+
[ShadedGeometry.from(arrowGeometry, matGreen, DrawMode.Triangles), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
134
|
+
[ShadedGeometry.from(lineGeometry2, matGreen, DrawMode.Triangles)]
|
|
135
|
+
],
|
|
136
|
+
Z: [
|
|
137
|
+
[ShadedGeometry.from(arrowGeometry, matBlue, DrawMode.Triangles), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
138
|
+
[ShadedGeometry.from(arrowGeometry, matBlue, DrawMode.Triangles), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
139
|
+
[ShadedGeometry.from(lineGeometry2, matBlue, DrawMode.Triangles), null, [Math.PI / 2, 0, 0]]
|
|
140
|
+
],
|
|
141
|
+
XYZ: [
|
|
142
|
+
[ShadedGeometry.from(new OctahedronGeometry(0.1, 0), matWhiteTransparent.clone(), DrawMode.Triangles), [0, 0, 0]]
|
|
143
|
+
],
|
|
144
|
+
XY: [
|
|
145
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matBlueTransparent.clone(), DrawMode.Triangles), [0.15, 0.15, 0]]
|
|
146
|
+
],
|
|
147
|
+
YZ: [
|
|
148
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matRedTransparent.clone(), DrawMode.Triangles), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
149
|
+
],
|
|
150
|
+
XZ: [
|
|
151
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matGreenTransparent.clone(), DrawMode.Triangles), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
152
|
+
]
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const pickerTranslate = {
|
|
156
|
+
X: [
|
|
157
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
158
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
159
|
+
],
|
|
160
|
+
Y: [
|
|
161
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [0, 0.3, 0]],
|
|
162
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
163
|
+
],
|
|
164
|
+
Z: [
|
|
165
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
166
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible, DrawMode.Triangles), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
167
|
+
],
|
|
168
|
+
XYZ: [
|
|
169
|
+
[ShadedGeometry.from(new OctahedronGeometry(0.2, 0), matInvisible, DrawMode.Triangles)]
|
|
170
|
+
],
|
|
171
|
+
XY: [
|
|
172
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible, DrawMode.Triangles), [0.15, 0.15, 0]]
|
|
173
|
+
],
|
|
174
|
+
YZ: [
|
|
175
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible, DrawMode.Triangles), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
176
|
+
],
|
|
177
|
+
XZ: [
|
|
178
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible, DrawMode.Triangles), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const helperTranslate = {
|
|
183
|
+
START: [
|
|
184
|
+
[ShadedGeometry.from(new OctahedronGeometry(0.01, 2), matHelper, DrawMode.Triangles), null, null, null, 'helper']
|
|
185
|
+
],
|
|
186
|
+
END: [
|
|
187
|
+
[ShadedGeometry.from(new OctahedronGeometry(0.01, 2), matHelper, DrawMode.Triangles), null, null, null, 'helper']
|
|
188
|
+
],
|
|
189
|
+
DELTA: [
|
|
190
|
+
[ShadedGeometry.from(TranslateHelperGeometry(), matHelper, DrawMode.Lines), null, null, null, 'helper']
|
|
191
|
+
],
|
|
192
|
+
X: [
|
|
193
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
194
|
+
],
|
|
195
|
+
Y: [
|
|
196
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], 'helper']
|
|
197
|
+
],
|
|
198
|
+
Z: [
|
|
199
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], 'helper']
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const gizmoRotate = {
|
|
204
|
+
XYZE: [
|
|
205
|
+
[ShadedGeometry.from(CircleGeometry(0.5, 1), matGray, DrawMode.Triangles), null, [0, Math.PI / 2, 0]]
|
|
206
|
+
],
|
|
207
|
+
X: [
|
|
208
|
+
[ShadedGeometry.from(CircleGeometry(0.5, 0.5), matRed, DrawMode.Triangles)]
|
|
209
|
+
],
|
|
210
|
+
Y: [
|
|
211
|
+
[ShadedGeometry.from(CircleGeometry(0.5, 0.5), matGreen, DrawMode.Triangles), null, [0, 0, -Math.PI / 2]]
|
|
212
|
+
],
|
|
213
|
+
Z: [
|
|
214
|
+
[ShadedGeometry.from(CircleGeometry(0.5, 0.5), matBlue, DrawMode.Triangles), null, [0, Math.PI / 2, 0]]
|
|
215
|
+
],
|
|
216
|
+
E: [
|
|
217
|
+
[ShadedGeometry.from(CircleGeometry(0.75, 1), matYellowTransparent, DrawMode.Triangles), null, [0, Math.PI / 2, 0]]
|
|
218
|
+
]
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const helperRotate = {
|
|
222
|
+
AXIS: [
|
|
223
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
224
|
+
]
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const pickerRotate = {
|
|
228
|
+
XYZE: [
|
|
229
|
+
[ShadedGeometry.from(new SphereGeometry(0.25, 10, 8), matInvisible, DrawMode.Triangles)]
|
|
230
|
+
],
|
|
231
|
+
X: [
|
|
232
|
+
[ShadedGeometry.from(new TorusGeometry(0.5, 0.1, 4, 24), matInvisible, DrawMode.Triangles), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]],
|
|
233
|
+
],
|
|
234
|
+
Y: [
|
|
235
|
+
[ShadedGeometry.from(new TorusGeometry(0.5, 0.1, 4, 24), matInvisible, DrawMode.Triangles), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
236
|
+
],
|
|
237
|
+
Z: [
|
|
238
|
+
[ShadedGeometry.from(new TorusGeometry(0.5, 0.1, 4, 24), matInvisible, DrawMode.Triangles), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
239
|
+
],
|
|
240
|
+
E: [
|
|
241
|
+
[ShadedGeometry.from(new TorusGeometry(0.75, 0.1, 2, 24), matInvisible, DrawMode.Triangles)]
|
|
242
|
+
]
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const gizmoScale = {
|
|
246
|
+
X: [
|
|
247
|
+
[ShadedGeometry.from(scaleHandleGeometry, matRed), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
248
|
+
[ShadedGeometry.from(lineGeometry2, matRed), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
249
|
+
[ShadedGeometry.from(scaleHandleGeometry, matRed), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
250
|
+
],
|
|
251
|
+
Y: [
|
|
252
|
+
[ShadedGeometry.from(scaleHandleGeometry, matGreen), [0, 0.5, 0]],
|
|
253
|
+
[ShadedGeometry.from(lineGeometry2, matGreen)],
|
|
254
|
+
[ShadedGeometry.from(scaleHandleGeometry, matGreen), [0, -0.5, 0], [0, 0, Math.PI]],
|
|
255
|
+
],
|
|
256
|
+
Z: [
|
|
257
|
+
[ShadedGeometry.from(scaleHandleGeometry, matBlue), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
258
|
+
[ShadedGeometry.from(lineGeometry2, matBlue), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
259
|
+
[ShadedGeometry.from(scaleHandleGeometry, matBlue), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
260
|
+
],
|
|
261
|
+
XY: [
|
|
262
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matBlueTransparent), [0.15, 0.15, 0]]
|
|
263
|
+
],
|
|
264
|
+
YZ: [
|
|
265
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matRedTransparent), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
266
|
+
],
|
|
267
|
+
XZ: [
|
|
268
|
+
[ShadedGeometry.from(new BoxGeometry(0.15, 0.15, 0.01), matGreenTransparent), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
269
|
+
],
|
|
270
|
+
XYZ: [
|
|
271
|
+
[ShadedGeometry.from(new BoxGeometry(0.1, 0.1, 0.1), matWhiteTransparent.clone())],
|
|
272
|
+
]
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const pickerScale = {
|
|
276
|
+
X: [
|
|
277
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
278
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
279
|
+
],
|
|
280
|
+
Y: [
|
|
281
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0.3, 0]],
|
|
282
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
283
|
+
],
|
|
284
|
+
Z: [
|
|
285
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
286
|
+
[ShadedGeometry.from(new CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
287
|
+
],
|
|
288
|
+
XY: [
|
|
289
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0.15, 0]],
|
|
290
|
+
],
|
|
291
|
+
YZ: [
|
|
292
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0, 0.15, 0.15], [0, Math.PI / 2, 0]],
|
|
293
|
+
],
|
|
294
|
+
XZ: [
|
|
295
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]],
|
|
296
|
+
],
|
|
297
|
+
XYZ: [
|
|
298
|
+
[ShadedGeometry.from(new BoxGeometry(0.2, 0.2, 0.2), matInvisible), [0, 0, 0]],
|
|
299
|
+
]
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const helperScale = {
|
|
303
|
+
X: [
|
|
304
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
305
|
+
],
|
|
306
|
+
Y: [
|
|
307
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], 'helper']
|
|
308
|
+
],
|
|
309
|
+
Z: [
|
|
310
|
+
[ShadedGeometry.from(lineGeometry, matHelper.clone(), DrawMode.Lines), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], 'helper']
|
|
311
|
+
]
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Creates an Object3D with gizmos described in custom hierarchy definition.
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
*
|
|
318
|
+
* @returns {EntityNode}
|
|
319
|
+
*/
|
|
320
|
+
function setupGizmo(gizmoMap) {
|
|
321
|
+
|
|
322
|
+
const gizmo = new GizmoNode();
|
|
323
|
+
|
|
324
|
+
for (const name in gizmoMap) {
|
|
325
|
+
|
|
326
|
+
const gizmo_elements = gizmoMap[name];
|
|
327
|
+
|
|
328
|
+
for (let i = gizmo_elements.length; i--;) {
|
|
329
|
+
const gizmo_element = gizmo_elements[i];
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* @type {ShadedGeometry}
|
|
333
|
+
*/
|
|
334
|
+
const shaded_geometry = gizmo_element[0].clone();
|
|
335
|
+
|
|
336
|
+
// disable shadows
|
|
337
|
+
shaded_geometry.clearFlag(ShadedGeometryFlags.CastShadow | ShadedGeometryFlags.ReceiveShadow);
|
|
338
|
+
|
|
339
|
+
// make it so that gizmo is always drawn using direct mode
|
|
340
|
+
shaded_geometry.draw_method = 0;
|
|
341
|
+
shaded_geometry.setFlag(ShadedGeometryFlags.DrawMethodLocked);
|
|
342
|
+
|
|
343
|
+
const node = new GizmoNode();
|
|
344
|
+
const transform = node.entity.getComponent(Transform);
|
|
345
|
+
node.entity.add(shaded_geometry);
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @type {number[]|undefined}
|
|
349
|
+
*/
|
|
350
|
+
const position = gizmo_element[1];
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @type {number[]|undefined}
|
|
354
|
+
*/
|
|
355
|
+
const rotation = gizmo_element[2];
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @type {number[]|undefined}
|
|
359
|
+
*/
|
|
360
|
+
const scale = gizmo_element[3];
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @type {string|undefined}
|
|
364
|
+
*/
|
|
365
|
+
const tag = gizmo_element[4];
|
|
366
|
+
|
|
367
|
+
// name and tag properties are essential for picking and updating logic.
|
|
368
|
+
node.name = name;
|
|
369
|
+
node.tag = tag;
|
|
370
|
+
|
|
371
|
+
if (position) {
|
|
372
|
+
|
|
373
|
+
transform.position.set(position[0], position[1], position[2]);
|
|
374
|
+
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (rotation) {
|
|
378
|
+
|
|
379
|
+
transform.rotation.fromEulerAnglesXYZ(rotation[0], rotation[1], rotation[2]);
|
|
380
|
+
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (scale) {
|
|
384
|
+
|
|
385
|
+
transform.scale.set(scale[0], scale[1], scale[2]);
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const tempGeometry = shaded_geometry.geometry.clone();
|
|
390
|
+
const m4 = new Matrix4();
|
|
391
|
+
transform.toMatrix4(m4.elements);
|
|
392
|
+
tempGeometry.applyMatrix4(m4);
|
|
393
|
+
|
|
394
|
+
shaded_geometry.geometry = tempGeometry;
|
|
395
|
+
// TODO add support for render order to ShadedGeometry
|
|
396
|
+
shaded_geometry.renderOrder = Infinity;
|
|
397
|
+
|
|
398
|
+
transform.makeIdentity();
|
|
399
|
+
|
|
400
|
+
gizmo.addChild(node);
|
|
401
|
+
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return gizmo;
|
|
407
|
+
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Gizmo creation
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
*
|
|
414
|
+
* @type {Object<EntityNode>}
|
|
415
|
+
*/
|
|
416
|
+
this.gizmo = {};
|
|
417
|
+
/**
|
|
418
|
+
*
|
|
419
|
+
* @type {Object<EntityNode>}
|
|
420
|
+
*/
|
|
421
|
+
this.picker = {};
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
* @type {Object<EntityNode>}
|
|
425
|
+
*/
|
|
426
|
+
this.helper = {};
|
|
427
|
+
|
|
428
|
+
this.addChild(this.gizmo[TransformMode.Translate] = setupGizmo(gizmoTranslate));
|
|
429
|
+
this.addChild(this.gizmo[TransformMode.Rotate] = setupGizmo(gizmoRotate));
|
|
430
|
+
this.addChild(this.gizmo[TransformMode.Scale] = setupGizmo(gizmoScale));
|
|
431
|
+
this.addChild(this.picker[TransformMode.Translate] = setupGizmo(pickerTranslate));
|
|
432
|
+
this.addChild(this.picker[TransformMode.Rotate] = setupGizmo(pickerRotate));
|
|
433
|
+
this.addChild(this.picker[TransformMode.Scale] = setupGizmo(pickerScale));
|
|
434
|
+
this.addChild(this.helper[TransformMode.Translate] = setupGizmo(helperTranslate));
|
|
435
|
+
this.addChild(this.helper[TransformMode.Rotate] = setupGizmo(helperRotate));
|
|
436
|
+
this.addChild(this.helper[TransformMode.Scale] = setupGizmo(helperScale));
|
|
437
|
+
|
|
438
|
+
// Pickers should be hidden always
|
|
439
|
+
|
|
440
|
+
this.picker[TransformMode.Translate].visible = false;
|
|
441
|
+
this.picker[TransformMode.Rotate].visible = false;
|
|
442
|
+
this.picker[TransformMode.Scale].visible = false;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
446
|
+
|
|
447
|
+
update(force) {
|
|
448
|
+
|
|
449
|
+
const space = (this.mode === TransformMode.Scale) ? 'local' : this.space; // scale always oriented to local rotation
|
|
450
|
+
|
|
451
|
+
const quaternion = (space === 'local') ? this.worldQuaternion : _identityQuaternion;
|
|
452
|
+
|
|
453
|
+
// Show only gizmos for current transform mode
|
|
454
|
+
|
|
455
|
+
this.gizmo[TransformMode.Translate].visible = this.mode === TransformMode.Translate;
|
|
456
|
+
this.gizmo[TransformMode.Rotate].visible = this.mode === TransformMode.Rotate;
|
|
457
|
+
this.gizmo[TransformMode.Scale].visible = this.mode === TransformMode.Scale;
|
|
458
|
+
|
|
459
|
+
this.helper[TransformMode.Translate].visible = this.mode === TransformMode.Translate;
|
|
460
|
+
this.helper[TransformMode.Rotate].visible = this.mode === TransformMode.Rotate;
|
|
461
|
+
this.helper[TransformMode.Scale].visible = this.mode === TransformMode.Scale;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
*
|
|
465
|
+
* @type {(GizmoNode|{name:string,tag:string})[]}
|
|
466
|
+
*/
|
|
467
|
+
let handles = [];
|
|
468
|
+
handles = handles.concat(this.picker[this.mode].children);
|
|
469
|
+
handles = handles.concat(this.gizmo[this.mode].children);
|
|
470
|
+
handles = handles.concat(this.helper[this.mode].children);
|
|
471
|
+
|
|
472
|
+
for (let i = 0; i < handles.length; i++) {
|
|
473
|
+
|
|
474
|
+
const handle = handles[i];
|
|
475
|
+
|
|
476
|
+
// hide aligned to camera
|
|
477
|
+
|
|
478
|
+
handle.visible = true;
|
|
479
|
+
handle.transform.rotation.fromEulerAnglesXYZ(0, 0, 0);
|
|
480
|
+
handle.transform.position.copy(this.worldPosition);
|
|
481
|
+
|
|
482
|
+
let factor;
|
|
483
|
+
|
|
484
|
+
if (this.camera.isOrthographicCamera) {
|
|
485
|
+
|
|
486
|
+
factor = (this.camera.top - this.camera.bottom) / this.camera.zoom;
|
|
487
|
+
|
|
488
|
+
} else {
|
|
489
|
+
|
|
490
|
+
factor = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7);
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (factor === 0) {
|
|
495
|
+
// prevent 0 size
|
|
496
|
+
factor = 1e-10;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
handle.transform.scale.setScalar(factor * this.size / 4);
|
|
500
|
+
|
|
501
|
+
// TODO: simplify helpers and consider decoupling from gizmo
|
|
502
|
+
|
|
503
|
+
if (handle.tag === 'helper') {
|
|
504
|
+
handle.visible = false;
|
|
505
|
+
|
|
506
|
+
if (handle.name === 'AXIS') {
|
|
507
|
+
|
|
508
|
+
handle.transform.position.copy(this.worldPositionStart);
|
|
509
|
+
handle.visible = !!this.axis;
|
|
510
|
+
|
|
511
|
+
if (this.axis === 'X') {
|
|
512
|
+
|
|
513
|
+
_tempQuaternion.setFromEuler(_tempEuler.set(0, 0, 0));
|
|
514
|
+
handle.transform.rotation.copy(quaternion);
|
|
515
|
+
handle.transform.rotation.multiply(_tempQuaternion);
|
|
516
|
+
|
|
517
|
+
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
518
|
+
|
|
519
|
+
handle.visible = false;
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (this.axis === 'Y') {
|
|
526
|
+
|
|
527
|
+
_tempQuaternion.setFromEuler(_tempEuler.set(0, 0, Math.PI / 2));
|
|
528
|
+
handle.transform.rotation.copy(quaternion);
|
|
529
|
+
handle.transform.rotation.multiply(_tempQuaternion);
|
|
530
|
+
|
|
531
|
+
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
532
|
+
|
|
533
|
+
handle.visible = false;
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (this.axis === 'Z') {
|
|
540
|
+
|
|
541
|
+
_tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
|
|
542
|
+
handle.transform.rotation.copy(quaternion);
|
|
543
|
+
handle.transform.rotation.multiply(_tempQuaternion);
|
|
544
|
+
|
|
545
|
+
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
546
|
+
|
|
547
|
+
handle.visible = false;
|
|
548
|
+
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (this.axis === 'XYZE') {
|
|
554
|
+
|
|
555
|
+
_tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
|
|
556
|
+
_alignVector.copy(this.rotationAxis);
|
|
557
|
+
handle.transform.rotation.setFromRotationMatrix(_lookAtMatrix.lookAt(_zeroVector, _alignVector, _unitY));
|
|
558
|
+
handle.transform.rotation.multiply(_tempQuaternion);
|
|
559
|
+
handle.visible = this.dragging;
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (this.axis === 'E') {
|
|
564
|
+
|
|
565
|
+
handle.visible = false;
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
} else if (handle.name === 'START') {
|
|
571
|
+
|
|
572
|
+
handle.transform.position.copy(this.worldPositionStart);
|
|
573
|
+
handle.visible = this.dragging;
|
|
574
|
+
|
|
575
|
+
} else if (handle.name === 'END') {
|
|
576
|
+
|
|
577
|
+
handle.transform.position.copy(this.worldPosition);
|
|
578
|
+
handle.visible = this.dragging;
|
|
579
|
+
|
|
580
|
+
} else if (handle.name === 'DELTA') {
|
|
581
|
+
|
|
582
|
+
handle.transform.position.copy(this.worldPositionStart);
|
|
583
|
+
handle.transform.rotation.copy(this.worldQuaternionStart);
|
|
584
|
+
_tempVector.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1);
|
|
585
|
+
_tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert());
|
|
586
|
+
handle.transform.scale.copy(_tempVector);
|
|
587
|
+
handle.visible = this.dragging;
|
|
588
|
+
|
|
589
|
+
} else {
|
|
590
|
+
|
|
591
|
+
handle.transform.rotation.copy(quaternion);
|
|
592
|
+
|
|
593
|
+
if (this.dragging) {
|
|
594
|
+
|
|
595
|
+
handle.transform.position.copy(this.worldPositionStart);
|
|
596
|
+
|
|
597
|
+
} else {
|
|
598
|
+
|
|
599
|
+
handle.transform.position.copy(this.worldPosition);
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (this.axis) {
|
|
604
|
+
|
|
605
|
+
handle.visible = this.axis.search(handle.name) !== -1;
|
|
606
|
+
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// If updating helper, skip rest of the loop
|
|
612
|
+
continue;
|
|
613
|
+
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Align handles to current local or world rotation
|
|
617
|
+
|
|
618
|
+
handle.transform.rotation.copy(quaternion);
|
|
619
|
+
|
|
620
|
+
if (this.mode === TransformMode.Translate || this.mode === TransformMode.Scale) {
|
|
621
|
+
|
|
622
|
+
// Hide translate and scale axis facing the camera
|
|
623
|
+
|
|
624
|
+
const AXIS_HIDE_TRESHOLD = 0.99;
|
|
625
|
+
const PLANE_HIDE_TRESHOLD = 0.2;
|
|
626
|
+
|
|
627
|
+
if (handle.name === 'X') {
|
|
628
|
+
|
|
629
|
+
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_TRESHOLD) {
|
|
630
|
+
|
|
631
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
632
|
+
handle.visible = false;
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (handle.name === 'Y') {
|
|
639
|
+
|
|
640
|
+
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_TRESHOLD) {
|
|
641
|
+
|
|
642
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
643
|
+
handle.visible = false;
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (handle.name === 'Z') {
|
|
650
|
+
|
|
651
|
+
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_TRESHOLD) {
|
|
652
|
+
|
|
653
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
654
|
+
handle.visible = false;
|
|
655
|
+
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
if (handle.name === 'XY') {
|
|
661
|
+
|
|
662
|
+
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_TRESHOLD) {
|
|
663
|
+
|
|
664
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
665
|
+
handle.visible = false;
|
|
666
|
+
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (handle.name === 'YZ') {
|
|
672
|
+
|
|
673
|
+
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_TRESHOLD) {
|
|
674
|
+
|
|
675
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
676
|
+
handle.visible = false;
|
|
677
|
+
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (handle.name === 'XZ') {
|
|
683
|
+
|
|
684
|
+
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_TRESHOLD) {
|
|
685
|
+
|
|
686
|
+
handle.transform.scale.set(1e-10, 1e-10, 1e-10);
|
|
687
|
+
handle.visible = false;
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
} else if (this.mode === TransformMode.Rotate) {
|
|
694
|
+
|
|
695
|
+
// Align handles to current local or world rotation
|
|
696
|
+
|
|
697
|
+
_tempQuaternion2.copy(quaternion);
|
|
698
|
+
_alignVector.copy(this.eye).applyQuaternion(_tempQuaternion.copy(quaternion).invert());
|
|
699
|
+
|
|
700
|
+
if (handle.name.search('E') !== -1) {
|
|
701
|
+
|
|
702
|
+
handle.transform.rotation.setFromRotationMatrix(_lookAtMatrix.lookAt(this.eye, _zeroVector, _unitY));
|
|
703
|
+
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
if (handle.name === 'X') {
|
|
707
|
+
|
|
708
|
+
_tempQuaternion.setFromAxisAngle(_unitX, Math.atan2(-_alignVector.y, _alignVector.z));
|
|
709
|
+
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
710
|
+
handle.transform.rotation.copy(_tempQuaternion);
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (handle.name === 'Y') {
|
|
715
|
+
|
|
716
|
+
_tempQuaternion.setFromAxisAngle(_unitY, Math.atan2(_alignVector.x, _alignVector.z));
|
|
717
|
+
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
718
|
+
handle.transform.rotation.copy(_tempQuaternion);
|
|
719
|
+
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (handle.name === 'Z') {
|
|
723
|
+
|
|
724
|
+
_tempQuaternion.setFromAxisAngle(_unitZ, Math.atan2(_alignVector.y, _alignVector.x));
|
|
725
|
+
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
726
|
+
handle.transform.rotation.copy(_tempQuaternion);
|
|
727
|
+
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// Hide disabled axes
|
|
733
|
+
handle.visible = handle.visible && (handle.name.indexOf('X') === -1 || this.showX);
|
|
734
|
+
handle.visible = handle.visible && (handle.name.indexOf('Y') === -1 || this.showY);
|
|
735
|
+
handle.visible = handle.visible && (handle.name.indexOf('Z') === -1 || this.showZ);
|
|
736
|
+
handle.visible = handle.visible && (handle.name.indexOf('E') === -1 || (this.showX && this.showY && this.showZ));
|
|
737
|
+
|
|
738
|
+
// highlight selected axis
|
|
739
|
+
const sg = handle.entity.getComponent(ShadedGeometry);
|
|
740
|
+
|
|
741
|
+
sg.material._color = sg.material._color || sg.material.color.clone();
|
|
742
|
+
sg.material._opacity = sg.material._opacity || sg.material.opacity;
|
|
743
|
+
|
|
744
|
+
sg.material.color.copy(sg.material._color);
|
|
745
|
+
sg.material.opacity = sg.material._opacity;
|
|
746
|
+
|
|
747
|
+
if (this.enabled && this.axis) {
|
|
748
|
+
|
|
749
|
+
if (handle.name === this.axis) {
|
|
750
|
+
|
|
751
|
+
sg.material.color.setHex(0xffff00);
|
|
752
|
+
sg.material.opacity = 1.0;
|
|
753
|
+
|
|
754
|
+
} else if (this.axis.split('').some(function (a) {
|
|
755
|
+
|
|
756
|
+
return handle.name === a;
|
|
757
|
+
|
|
758
|
+
})) {
|
|
759
|
+
|
|
760
|
+
sg.material.color.setHex(0xffff00);
|
|
761
|
+
sg.material.opacity = 1.0;
|
|
762
|
+
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
super.update();
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export { TransformControlsGizmo };
|