babylonjs-editcontrol 3.2.5 → 4.0.0

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.
@@ -1,315 +1,323 @@
1
- import { AbstractMesh, Camera, Quaternion, Vector3, TransformNode } from 'babylonjs';
2
- /**
3
- * Draws a transform widget at the mesh's location (its pivot location).
4
- * The widget transforms(translates,rotates and scales) the mesh based on user
5
- * interactions with the widget.
6
- * The widget shows the mesh position and rotation at any time.
7
- * The widget follows the mesh constantly.
8
- * Note: An alternate approach would have been for the mesh to follow the widget.
9
- * The problem with the alternate approach - syncing the transforms
10
- * if the mesh was being transformed by entities other than the widget say physics
11
- * or script for example.
12
- *
13
- */
14
- export declare class EditControl {
15
- private _mesh;
16
- private _canvas;
17
- private _scene;
18
- private _mainCamera;
19
- private _ecRoot;
20
- private _local;
21
- private _snapT;
22
- private _snapR;
23
- private _transSnap;
24
- private _rotSnap;
25
- private _axesLen;
26
- private _axesScale;
27
- private _pickWidth;
28
- private _redMat;
29
- private _greenMat;
30
- private _blueMat;
31
- private _whiteMat;
32
- private _yellowMat;
33
- private _redCol;
34
- private _greenCol;
35
- private _blueCol;
36
- private _whiteCol;
37
- private _yellowCol;
38
- private _actHist;
39
- private _renderer;
40
- private _pointerdown;
41
- private _pointerup;
42
- private _pointermove;
43
- private _visibility;
44
- private _lhsRhs;
45
- constructor(mesh: TransformNode, camera: Camera, canvas: HTMLCanvasElement, scale?: number, eulerian?: boolean, pickWidth?: number);
46
- getRoot(): AbstractMesh;
47
- private _checkQuaternion;
48
- /**
49
- * checks if a have left hand , right hand issue.
50
- * In other words if a mesh is a LHS mesh in RHS system or
51
- * a RHS mesh in LHS system
52
- * The X axis will be reversed in such cases.
53
- * thus Cross product of X and Y should be inverse of Z.
54
- *
55
- * if no parent then we are ok.
56
- * If parent and parent has issue then we have issue.
57
- *
58
- */
59
- private _check_LHS_RHS;
60
- private _ecMatrix;
61
- private _ecTOcamera;
62
- private _renderLoopProcess;
63
- /**
64
- * sets rotaion of edit control to that of the mesh
65
- */
66
- private _setECRotation;
67
- /**
68
- * checks if any of the mesh's ancestors has non uniform scale
69
- */
70
- private _isScaleUnEqual;
71
- private _distFromCamera;
72
- private _cameraTOec;
73
- private _cameraNormal;
74
- private _setECScale;
75
- private _rotRotGuides;
76
- /**
77
- * rotate the planar guide so that they are facing the camera
78
- */
79
- private _rotPlanarGuides;
80
- switchTo(mesh: TransformNode, eulerian?: boolean): void;
81
- switchCamera(camera: Camera): void;
82
- setUndoCount(c: number): void;
83
- undo(): void;
84
- redo(): void;
85
- /**
86
- * detach the edit control from the mesh and dispose off all
87
- * resources created by the edit control
88
- */
89
- detach(): void;
90
- private _prevState;
91
- private _hidden;
92
- /**
93
- * hide the edit control. use show() to unhide the control.
94
- */
95
- hide(): void;
96
- private _hideCommonAxes;
97
- private _showCommonAxes;
98
- /**
99
- * unhide the editcontrol hidden using the hide() method
100
- */
101
- show(): void;
102
- /**
103
- * check if the editcontrol was hidden using the hide() methods
104
- */
105
- isHidden(): boolean;
106
- private _disposeAll;
107
- private _actionListener;
108
- private _actionStartListener;
109
- private _actionEndListener;
110
- addActionListener(actionListener: (actionType: number) => void): void;
111
- removeActionListener(): void;
112
- addActionStartListener(actionStartListener: (actionType: number) => void): void;
113
- removeActionStartListener(): void;
114
- addActionEndListener(actionEndListener: (actionType: number) => void): void;
115
- removeActionEndListener(): void;
116
- removeAllActionListeners(): void;
117
- private _pDown;
118
- private _axisPicked;
119
- private _onPointerDown;
120
- private _setEditing;
121
- isEditing(): boolean;
122
- /**
123
- * no camera movement during edit
124
- */
125
- private _detachCamera;
126
- private _prevOverMesh;
127
- private _pointerIsOver;
128
- isPointerOver(): boolean;
129
- private _savedMat;
130
- private _savedCol;
131
- private _onPointerOver;
132
- private _clearPrevOverMesh;
133
- private _restoreColor;
134
- private _editing;
135
- private _onPointerUp;
136
- private _actionType;
137
- private _setActionType;
138
- private _callActionListener;
139
- private _callActionStartListener;
140
- private _callActionEndListener;
141
- private _prevPos;
142
- private _onPointerMove;
143
- private _rotate2;
144
- private _getPickPlane;
145
- private _transBy;
146
- private _doTranslation;
147
- private _snapTV;
148
- private _transWithSnap;
149
- private _snapS;
150
- private _snapSV;
151
- private _scaleSnap;
152
- private _scale;
153
- private _doScaling;
154
- private _scaleWithSnap;
155
- private _localX;
156
- private _localY;
157
- private _localZ;
158
- private _setLocalAxes;
159
- private _boundingDimesion;
160
- private _getBoundingDimension;
161
- refreshBoundingInfo(): void;
162
- private _eulerian;
163
- private _snapRA;
164
- private _doRotation;
165
- private _getPosOnPickPlane;
166
- private _hideBaxis;
167
- getRotationQuaternion(): Quaternion;
168
- getPosition(): Vector3;
169
- private _transEnabled;
170
- isTranslationEnabled(): boolean;
171
- enableTranslation(): void;
172
- disableTranslation(): void;
173
- private _rotEnabled;
174
- isRotationEnabled(): boolean;
175
- returnEuler(euler: boolean): void;
176
- enableRotation(): void;
177
- disableRotation(): void;
178
- private _scaleEnabled;
179
- isScalingEnabled(): boolean;
180
- enableScaling(): void;
181
- disableScaling(): void;
182
- private _scaleBoundsMin;
183
- private _scaleBoundsMax;
184
- setScaleBounds(min?: Vector3, max?: Vector3): void;
185
- removeScaleBounds(): void;
186
- private _transBoundsMin;
187
- private _transBoundsMax;
188
- setTransBounds(min?: Vector3, max?: Vector3): void;
189
- removeTransBounds(): void;
190
- private _rotBoundsMin;
191
- private _rotBoundsMax;
192
- setRotBounds(min?: Vector3, max?: Vector3): void;
193
- removeRotBounds(): void;
194
- private _bXaxis;
195
- private _bYaxis;
196
- private _bZaxis;
197
- private _xaxis;
198
- private _yaxis;
199
- private _zaxis;
200
- private _createCommonAxes;
201
- private _pickedPlane;
202
- private _pALL;
203
- private _pXZ;
204
- private _pZY;
205
- private _pYX;
206
- private _createPickPlanes;
207
- private _tCtl;
208
- private _tX;
209
- private _tY;
210
- private _tZ;
211
- private _tXZ;
212
- private _tZY;
213
- private _tYX;
214
- private _tAll;
215
- private _all_t;
216
- private _tEndX;
217
- private _tEndY;
218
- private _tEndZ;
219
- private _tEndXZ;
220
- private _tEndZY;
221
- private _tEndYX;
222
- private _tEndAll;
223
- private _all_tEnd;
224
- private _createTransAxes;
225
- private _createPickableTrans;
226
- private _createNonPickableTrans;
227
- private _rCtl;
228
- private _rX;
229
- private _rY;
230
- private _rZ;
231
- private _rAll;
232
- private _all_r;
233
- private _rEndX;
234
- private _rEndY;
235
- private _rEndZ;
236
- private _rEndAll;
237
- private _rEndAll2;
238
- private _all_rEnd;
239
- private _guideSize;
240
- setRotGuideFull(y: boolean): void;
241
- private _createRotAxes;
242
- private _createPickableRot;
243
- private _createNonPickableRot;
244
- private _setVisibility;
245
- private _setPickableFalse;
246
- private _setRenderingGroup;
247
- private _extrudeBox;
248
- private _createCircle;
249
- private _createTube;
250
- private _sCtl;
251
- private _sX;
252
- private _sY;
253
- private _sZ;
254
- private _sXZ;
255
- private _sZY;
256
- private _sYX;
257
- private _sAll;
258
- private _all_s;
259
- private _sEndX;
260
- private _sEndY;
261
- private _sEndZ;
262
- private _sEndXZ;
263
- private _sEndZY;
264
- private _sEndYX;
265
- private _sEndAll;
266
- private _all_sEnd;
267
- private _createScaleAxes;
268
- private _createPickableScale;
269
- private _createNonPickableScale;
270
- /**
271
- * checks if a have left hand , right hand issue.
272
- * In other words if a mesh is a LHS mesh in RHS system or
273
- * a RHS mesh in LHS system
274
- * The X axis will be reversed in such cases.
275
- * thus Cross product of X and Y should be inverse of Z.
276
- *
277
- */
278
- /**
279
- * set how transparent the axes are
280
- * 0 to 1
281
- * 0 - completely transparent
282
- * 1 - completely non transparent
283
- * default is 0.75
284
- */
285
- setVisibility(v: number): void;
286
- setLocal(l: boolean): void;
287
- isLocal(): boolean;
288
- setTransSnap(s: boolean): void;
289
- isTransSnap(): boolean;
290
- setRotSnap(s: boolean): void;
291
- isRotSnap(): boolean;
292
- setScaleSnap(s: boolean): void;
293
- isScaleSnap(): boolean;
294
- private _tSnap;
295
- setTransSnapValue(t: number): void;
296
- getTransSnapValue(): number;
297
- setRotSnapValue(r: number): void;
298
- getRotSnapValue(): number;
299
- setScaleSnapValue(r: number): void;
300
- getScaleSnapValue(): number;
301
- private _tv1;
302
- private _tv2;
303
- private _tv3;
304
- private _tm;
305
- private _getAngle2;
306
- /**
307
- * finds the angle subtended from points p1 to p2 around the point p
308
- * checks if the user was trying to rotate clockwise (+ve in LHS) or anticlockwise (-ve in LHS)
309
- * to figure this check the orientation of the user(camera)to ec vector with the rotation normal vector
310
- */
311
- private _getAngle;
312
- private static _getStandardMaterial;
313
- private _createMaterials;
314
- private _disposeMaterials;
315
- }
1
+ import { AbstractMesh, Camera, Quaternion, Vector3, TransformNode } from 'babylonjs';
2
+ /**
3
+ * Draws a transform widget at the mesh's location (its pivot location).
4
+ * The widget transforms(translates,rotates and scales) the mesh based on user
5
+ * interactions with the widget.
6
+ * The widget shows the mesh position and rotation at any time.
7
+ * The widget follows the mesh constantly.
8
+ * Note: An alternate approach would have been for the mesh to follow the widget.
9
+ * The problem with the alternate approach - syncing the transforms
10
+ * if the mesh was being transformed by entities other than the widget say physics
11
+ * or script for example.
12
+ *
13
+ */
14
+ export declare class EditControl {
15
+ private _mesh;
16
+ private _canvas;
17
+ private _scene;
18
+ private _utilLayer;
19
+ private _mainCamera;
20
+ private _ecRoot;
21
+ private _local;
22
+ private _snapT;
23
+ private _snapR;
24
+ private _transSnap;
25
+ private _rotSnap;
26
+ private _axesLen;
27
+ private _axesScale;
28
+ private _pickWidth;
29
+ private _redMat;
30
+ private _greenMat;
31
+ private _blueMat;
32
+ private _whiteMat;
33
+ private _yellowMat;
34
+ private _redCol;
35
+ private _greenCol;
36
+ private _blueCol;
37
+ private _whiteCol;
38
+ private _yellowCol;
39
+ private _actHist;
40
+ private _renderer;
41
+ private _pointerdown;
42
+ private _pointerup;
43
+ private _pointermove;
44
+ private _visibility;
45
+ private _lhsRhs;
46
+ private _isEulerian;
47
+ constructor(mesh: TransformNode, camera: Camera, canvas: HTMLCanvasElement, scale?: number, pickWidth?: number);
48
+ getRoot(): AbstractMesh;
49
+ /**
50
+ * checks if a have left hand , right hand issue.
51
+ * In other words if a mesh is a LHS mesh in RHS system or
52
+ * a RHS mesh in LHS system
53
+ * The X axis will be reversed in such cases.
54
+ * thus Cross product of X and Y should be inverse of Z.
55
+ *
56
+ * if no parent then we are ok.
57
+ * If parent and parent has issue then we have issue.
58
+ *
59
+ */
60
+ private _check_LHS_RHS;
61
+ private _ecMatrix;
62
+ private _ecTOcamera;
63
+ private _renderLoopProcess;
64
+ /**
65
+ * sets rotaion of edit control to that of the mesh
66
+ */
67
+ private _setECRotation;
68
+ /**
69
+ * checks if any of the mesh's ancestors has non uniform scale
70
+ */
71
+ private _isScaleUnEqual;
72
+ private _distFromCamera;
73
+ private _cameraTOec;
74
+ private _cameraNormal;
75
+ private _setECScale;
76
+ private _rotRotGuides;
77
+ /**
78
+ * rotate the planar guide so that they are facing the camera
79
+ */
80
+ private _rotPlanarGuides;
81
+ switchTo(mesh: TransformNode): void;
82
+ switchCamera(camera: Camera): void;
83
+ setUndoCount(c: number): void;
84
+ undo(): void;
85
+ redo(): void;
86
+ /**
87
+ * detach the edit control from the mesh and dispose off all
88
+ * resources created by the edit control
89
+ */
90
+ detach(): void;
91
+ private _prevState;
92
+ private _hidden;
93
+ /**
94
+ * hide the edit control. use show() to unhide the control.
95
+ */
96
+ hide(): void;
97
+ private _hideCommonAxes;
98
+ private _showCommonAxes;
99
+ /**
100
+ * unhide the editcontrol hidden using the hide() method
101
+ */
102
+ show(): void;
103
+ /**
104
+ * check if the editcontrol was hidden using the hide() methods
105
+ */
106
+ isHidden(): boolean;
107
+ private _disposeAll;
108
+ private _actionListener;
109
+ private _actionStartListener;
110
+ private _actionEndListener;
111
+ addActionListener(actionListener: (actionType: number) => void): void;
112
+ removeActionListener(): void;
113
+ addActionStartListener(actionStartListener: (actionType: number) => void): void;
114
+ removeActionStartListener(): void;
115
+ addActionEndListener(actionEndListener: (actionType: number) => void): void;
116
+ removeActionEndListener(): void;
117
+ removeAllActionListeners(): void;
118
+ private _pDown;
119
+ private _axisPicked;
120
+ private _onPointerDown;
121
+ private _setEditing;
122
+ isEditing(): boolean;
123
+ /**
124
+ * no camera movement during edit
125
+ */
126
+ private _detachCamera;
127
+ private _prevOverMesh;
128
+ private _pointerIsOver;
129
+ isPointerOver(): boolean;
130
+ private _savedMat;
131
+ private _savedCol;
132
+ private _onPointerOver;
133
+ private _clearPrevOverMesh;
134
+ private _restoreColor;
135
+ private _editing;
136
+ private _onPointerUp;
137
+ private _actionType;
138
+ private _setActionType;
139
+ private _callActionListener;
140
+ private _callActionStartListener;
141
+ private _callActionEndListener;
142
+ private _prevPos;
143
+ private _onPointerMove;
144
+ private _rotate2;
145
+ private _getPickPlane;
146
+ private _transBy;
147
+ private _doTranslation;
148
+ private _snapTV;
149
+ private _transWithSnap;
150
+ private _snapS;
151
+ private _snapSV;
152
+ private _scaleSnap;
153
+ private _scale;
154
+ private _doScaling;
155
+ private _scaleWithSnap;
156
+ private _localX;
157
+ private _localY;
158
+ private _localZ;
159
+ private _setLocalAxes;
160
+ private _boundingDimesion;
161
+ private _getBoundingDimension;
162
+ refreshBoundingInfo(): void;
163
+ private _snapRA;
164
+ private _doRotation;
165
+ private _getPosOnPickPlane;
166
+ private _hideBaxis;
167
+ getRotationQuaternion(): Quaternion;
168
+ getPosition(): Vector3;
169
+ private _transEnabled;
170
+ isTranslationEnabled(): boolean;
171
+ enableTranslation(): void;
172
+ disableTranslation(): void;
173
+ private _rotEnabled;
174
+ isRotationEnabled(): boolean;
175
+ enableRotation(): void;
176
+ disableRotation(): void;
177
+ private _scaleEnabled;
178
+ isScalingEnabled(): boolean;
179
+ enableScaling(): void;
180
+ disableScaling(): void;
181
+ private _scaleBoundsMin;
182
+ private _scaleBoundsMax;
183
+ setScaleBounds(min?: Vector3, max?: Vector3): void;
184
+ removeScaleBounds(): void;
185
+ private _transBoundsMin;
186
+ private _transBoundsMax;
187
+ setTransBounds(min?: Vector3, max?: Vector3): void;
188
+ removeTransBounds(): void;
189
+ private _rotBoundsMin;
190
+ private _rotBoundsMax;
191
+ setRotBounds(min?: Vector3, max?: Vector3): void;
192
+ removeRotBounds(): void;
193
+ private _bXaxis;
194
+ private _bYaxis;
195
+ private _bZaxis;
196
+ private _xaxis;
197
+ private _yaxis;
198
+ private _zaxis;
199
+ private _createCommonAxes;
200
+ private _pickedPlane;
201
+ private _pALL;
202
+ private _pXZ;
203
+ private _pZY;
204
+ private _pYX;
205
+ private _createPickPlanes;
206
+ private _tCtl;
207
+ private _tX;
208
+ private _tY;
209
+ private _tZ;
210
+ private _tXZ;
211
+ private _tZY;
212
+ private _tYX;
213
+ private _tAll;
214
+ private _all_t;
215
+ private _tEndX;
216
+ private _tEndY;
217
+ private _tEndZ;
218
+ private _tEndXZ;
219
+ private _tEndZY;
220
+ private _tEndYX;
221
+ private _tEndAll;
222
+ private _all_tEnd;
223
+ private _createTransAxes;
224
+ /**
225
+ * pickable but invisible
226
+ * a) 3 boxes around each of the 3 small axes lines
227
+ * b) 3 small planes near origin for movement along a plane
228
+ * @param r
229
+ * @param l
230
+ * @param tCtl
231
+ * @param scene
232
+ */
233
+ private _createPickableTrans;
234
+ private _createNonPickableTrans;
235
+ private _rCtl;
236
+ private _rX;
237
+ private _rY;
238
+ private _rZ;
239
+ private _rAll;
240
+ private _all_r;
241
+ private _rEndX;
242
+ private _rEndY;
243
+ private _rEndZ;
244
+ private _rEndAll;
245
+ private _rEndAll2;
246
+ private _all_rEnd;
247
+ private _guideSize;
248
+ setRotGuideFull(y: boolean): void;
249
+ private _createRotAxes;
250
+ private _createPickableRot;
251
+ private _createNonPickableRot;
252
+ private _setVisibility;
253
+ private _setPickableFalse;
254
+ private _setRenderingGroup;
255
+ private _extrudeBox;
256
+ private _createCircle;
257
+ private _createTube;
258
+ private _sCtl;
259
+ private _sX;
260
+ private _sY;
261
+ private _sZ;
262
+ private _sXZ;
263
+ private _sZY;
264
+ private _sYX;
265
+ private _sAll;
266
+ private _all_s;
267
+ private _sEndX;
268
+ private _sEndY;
269
+ private _sEndZ;
270
+ private _sEndXZ;
271
+ private _sEndZY;
272
+ private _sEndYX;
273
+ private _sEndAll;
274
+ private _all_sEnd;
275
+ private _createScaleAxes;
276
+ private _createPickableScale;
277
+ private _createNonPickableScale;
278
+ /**
279
+ * checks if a have left hand , right hand issue.
280
+ * In other words if a mesh is a LHS mesh in RHS system or
281
+ * a RHS mesh in LHS system
282
+ * The X axis will be reversed in such cases.
283
+ * thus Cross product of X and Y should be inverse of Z.
284
+ *
285
+ */
286
+ /**
287
+ * set how transparent the axes are
288
+ * 0 to 1
289
+ * 0 - completely transparent
290
+ * 1 - completely non transparent
291
+ * default is 0.75
292
+ */
293
+ setVisibility(v: number): void;
294
+ setLocal(l: boolean): void;
295
+ isLocal(): boolean;
296
+ setTransSnap(s: boolean): void;
297
+ isTransSnap(): boolean;
298
+ setRotSnap(s: boolean): void;
299
+ isRotSnap(): boolean;
300
+ setScaleSnap(s: boolean): void;
301
+ isScaleSnap(): boolean;
302
+ private _tSnap;
303
+ setTransSnapValue(t: number): void;
304
+ getTransSnapValue(): number;
305
+ setRotSnapValue(r: number): void;
306
+ getRotSnapValue(): number;
307
+ setScaleSnapValue(r: number): void;
308
+ getScaleSnapValue(): number;
309
+ private _tv1;
310
+ private _tv2;
311
+ private _tv3;
312
+ private _tm;
313
+ private _getAngle2;
314
+ /**
315
+ * finds the angle subtended from points p1 to p2 around the point p
316
+ * checks if the user was trying to rotate clockwise (+ve in LHS) or anticlockwise (-ve in LHS)
317
+ * to figure this check the orientation of the user(camera)to ec vector with the rotation normal vector
318
+ */
319
+ private _getAngle;
320
+ private static _getStandardMaterial;
321
+ private _createMaterials;
322
+ private _disposeMaterials;
323
+ }