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.
- package/LICENSE +201 -201
- package/README.md +478 -436
- package/dist/EditControl.d.ts +323 -315
- package/dist/EditControl.js +1 -1
- package/dist/EditControl.js.map +1 -1
- package/dist/EditControl.max.js +2055 -2124
- package/dist/EditControl.max.js.map +1 -1
- package/package.json +37 -37
- package/src/EditControl.ts +84 -84
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "babylonjs-editcontrol",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A transform control for Babylonjs mesh",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git://github.com/ssatguru/BabylonJS-EditControl.git"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"babylonjs",
|
|
11
|
-
"transform control",
|
|
12
|
-
"widget",
|
|
13
|
-
"gizmo"
|
|
14
|
-
],
|
|
15
|
-
"author": "satguru <ssatguru@gmail.com>",
|
|
16
|
-
"license": "Apache-2.0",
|
|
17
|
-
"contributors": [],
|
|
18
|
-
"main": "dist/EditControl.js",
|
|
19
|
-
"types": "dist/EditControl.d.ts",
|
|
20
|
-
"dependencies": {},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"babylonjs": "^
|
|
23
|
-
"babylonjs-gui": "^
|
|
24
|
-
"
|
|
25
|
-
"terser-webpack-plugin": "^
|
|
26
|
-
"ts-loader": "^
|
|
27
|
-
"typescript": "^
|
|
28
|
-
"webpack": "^
|
|
29
|
-
"webpack-cli": "^
|
|
30
|
-
"webpack-dev-server": "^
|
|
31
|
-
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"build-prod": "webpack --mode production",
|
|
34
|
-
"build": "webpack",
|
|
35
|
-
"start": "webpack-dev-server --open
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "babylonjs-editcontrol",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "A transform control for Babylonjs mesh",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git://github.com/ssatguru/BabylonJS-EditControl.git"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"babylonjs",
|
|
11
|
+
"transform control",
|
|
12
|
+
"widget",
|
|
13
|
+
"gizmo"
|
|
14
|
+
],
|
|
15
|
+
"author": "satguru <ssatguru@gmail.com>",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"contributors": [],
|
|
18
|
+
"main": "dist/EditControl.js",
|
|
19
|
+
"types": "dist/EditControl.d.ts",
|
|
20
|
+
"dependencies": {},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"babylonjs": "^8.47.0",
|
|
23
|
+
"babylonjs-gui": "^8.47.0",
|
|
24
|
+
"babylonjs-inspector": "^8.47.0",
|
|
25
|
+
"terser-webpack-plugin": "^5.3.6",
|
|
26
|
+
"ts-loader": "^9.4.2",
|
|
27
|
+
"typescript": "^5.9.3",
|
|
28
|
+
"webpack": "^5.104.1",
|
|
29
|
+
"webpack-cli": "^6.0.1",
|
|
30
|
+
"webpack-dev-server": "^5.2.3"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build-prod": "webpack --mode production",
|
|
34
|
+
"build": "webpack",
|
|
35
|
+
"start": "webpack-dev-server --open /tst/test.html"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/EditControl.ts
CHANGED
|
@@ -18,7 +18,9 @@ import {
|
|
|
18
18
|
StandardMaterial,
|
|
19
19
|
Vector3,
|
|
20
20
|
TransformNode,
|
|
21
|
-
Engine
|
|
21
|
+
Engine,
|
|
22
|
+
DeepImmutableObject,
|
|
23
|
+
UtilityLayerRenderer
|
|
22
24
|
}
|
|
23
25
|
from 'babylonjs';
|
|
24
26
|
|
|
@@ -49,6 +51,7 @@ export class EditControl {
|
|
|
49
51
|
|
|
50
52
|
private _canvas: HTMLCanvasElement;
|
|
51
53
|
private _scene: Scene;
|
|
54
|
+
private _utilLayer: UtilityLayerRenderer;
|
|
52
55
|
private _mainCamera: Camera;
|
|
53
56
|
//root of the edit control
|
|
54
57
|
private _ecRoot: Mesh;
|
|
@@ -66,24 +69,31 @@ export class EditControl {
|
|
|
66
69
|
private _blueMat: StandardMaterial;
|
|
67
70
|
private _whiteMat: StandardMaterial;
|
|
68
71
|
private _yellowMat: StandardMaterial;
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
private
|
|
72
|
-
private
|
|
73
|
-
|
|
72
|
+
|
|
73
|
+
private _redCol: Color3 = new Color3(1, 0.34, 0.26);
|
|
74
|
+
private _greenCol: Color3 = new Color3(0.0, 0.8, 0.16);
|
|
75
|
+
private _blueCol: Color3 = new Color3(0.21, 0.5, 1);
|
|
76
|
+
|
|
77
|
+
private _whiteCol: Color3 = new Color3(0.7, 0.7, 0.7);
|
|
78
|
+
private _yellowCol: Color3 = new Color3(1, 1, 0);
|
|
74
79
|
|
|
75
80
|
private _actHist: ActHist;
|
|
76
81
|
private _renderer: () => void;
|
|
77
82
|
private _pointerdown: EventListener;
|
|
78
83
|
private _pointerup: EventListener;
|
|
79
84
|
private _pointermove: EventListener;
|
|
85
|
+
|
|
80
86
|
//axes visibility
|
|
81
87
|
private _visibility: number = 0.75;
|
|
82
88
|
|
|
83
89
|
//lhs-rhs issue. lhs mesh in rhs or rhs mesh in lhs
|
|
84
90
|
private _lhsRhs: boolean = false;
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
private _isEulerian(mesh:TransformNode):boolean{
|
|
93
|
+
return ((mesh.rotationQuaternion == null) || (mesh.rotationQuaternion == undefined));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public constructor(mesh: TransformNode, camera: Camera, canvas: HTMLCanvasElement, scale?: number, pickWidth?: number) {
|
|
87
97
|
|
|
88
98
|
this._mesh = mesh;
|
|
89
99
|
this._mainCamera = camera;
|
|
@@ -92,26 +102,24 @@ export class EditControl {
|
|
|
92
102
|
if (scale != null) {
|
|
93
103
|
this._axesScale = scale;
|
|
94
104
|
}
|
|
95
|
-
|
|
96
|
-
if (eulerian !== null) {
|
|
97
|
-
this._eulerian = eulerian;
|
|
98
|
-
} else {
|
|
99
|
-
this._eulerian = false;
|
|
100
|
-
}
|
|
101
|
-
this._checkQuaternion();
|
|
105
|
+
|
|
102
106
|
|
|
103
107
|
if (pickWidth != null) {
|
|
104
108
|
this._pickWidth = pickWidth;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
|
|
112
|
+
this._utilLayer = UtilityLayerRenderer.DefaultUtilityLayer;
|
|
113
|
+
this._utilLayer.onlyCheckPointerDownEvents = false;
|
|
114
|
+
this._scene = this._utilLayer.utilityLayerScene;
|
|
115
|
+
|
|
108
116
|
this._actHist = new ActHist(mesh, 10);
|
|
109
117
|
|
|
110
118
|
mesh.computeWorldMatrix(true);
|
|
111
119
|
this._boundingDimesion = this._getBoundingDimension(mesh);
|
|
112
120
|
this._setLocalAxes(mesh);
|
|
113
121
|
this._lhsRhs = this._check_LHS_RHS(mesh);
|
|
114
|
-
console.
|
|
122
|
+
if (this._lhsRhs) console.warn("we have lhs rhs issue " + this._lhsRhs);
|
|
115
123
|
|
|
116
124
|
//build the edit control axes
|
|
117
125
|
this._ecRoot = new Mesh("", this._scene);
|
|
@@ -149,16 +157,6 @@ export class EditControl {
|
|
|
149
157
|
return this._ecRoot;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
|
-
//make sure that if eulerian is set to false then mesh's rotation is in quaternion
|
|
153
|
-
//throw error and exit if not so.
|
|
154
|
-
private _checkQuaternion() {
|
|
155
|
-
if (!this._eulerian) {
|
|
156
|
-
if ((this._mesh.rotationQuaternion == null) || (this._mesh.rotationQuaternion == undefined)) {
|
|
157
|
-
throw "Error: Eulerian is set to false but the mesh's rotationQuaternion is not set.";
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
160
|
/**
|
|
163
161
|
* checks if a have left hand , right hand issue.
|
|
164
162
|
* In other words if a mesh is a LHS mesh in RHS system or
|
|
@@ -223,7 +221,7 @@ export class EditControl {
|
|
|
223
221
|
private _setECRotation() {
|
|
224
222
|
if (this._local) {
|
|
225
223
|
if (this._mesh.parent == null) {
|
|
226
|
-
if (this.
|
|
224
|
+
if (this._isEulerian(this._mesh)) {
|
|
227
225
|
let rot: Vector3 = this._mesh.rotation;
|
|
228
226
|
Quaternion.RotationYawPitchRollToRef(rot.y, rot.x, rot.z, this._ecRoot.rotationQuaternion);
|
|
229
227
|
} else {
|
|
@@ -262,7 +260,7 @@ export class EditControl {
|
|
|
262
260
|
private _cameraNormal: Vector3 = new Vector3(0, 0, 0);
|
|
263
261
|
private _setECScale() {
|
|
264
262
|
this._ecRoot.position.subtractToRef(this._mainCamera.position, this._cameraTOec);
|
|
265
|
-
Vector3.
|
|
263
|
+
Vector3.FromArrayToRef(this._mainCamera.getWorldMatrix().asArray(), 8, this._cameraNormal);
|
|
266
264
|
|
|
267
265
|
//get distance of edit control from the camera plane
|
|
268
266
|
//project "camera to edit control" vector onto the camera normal
|
|
@@ -346,13 +344,9 @@ export class EditControl {
|
|
|
346
344
|
|
|
347
345
|
|
|
348
346
|
|
|
349
|
-
public switchTo(mesh: TransformNode
|
|
347
|
+
public switchTo(mesh: TransformNode) {
|
|
350
348
|
mesh.computeWorldMatrix(true);
|
|
351
349
|
this._mesh = mesh;
|
|
352
|
-
if (eulerian != null) {
|
|
353
|
-
this._eulerian = eulerian;
|
|
354
|
-
}
|
|
355
|
-
this._checkQuaternion();
|
|
356
350
|
this._setLocalAxes(mesh);
|
|
357
351
|
this._actHist = new ActHist(mesh, 10);
|
|
358
352
|
this._lhsRhs = this._check_LHS_RHS(mesh);
|
|
@@ -489,7 +483,7 @@ export class EditControl {
|
|
|
489
483
|
evt.preventDefault();
|
|
490
484
|
this._pDown = true;
|
|
491
485
|
if ((<PointerEvent>evt).button != 0) return;
|
|
492
|
-
let engine: Engine = this._scene.getEngine();
|
|
486
|
+
let engine: Engine = <Engine> this._scene.getEngine();
|
|
493
487
|
let x = (engine.isPointerLock) ? this._canvas.width * 0.5 : this._scene.pointerX;
|
|
494
488
|
let y = (engine.isPointerLock) ? this._canvas.height * 0.5 : this._scene.pointerY;
|
|
495
489
|
let pickResult: PickingInfo = this._scene.pick(x, y, (mesh) => {
|
|
@@ -501,7 +495,7 @@ export class EditControl {
|
|
|
501
495
|
if ((mesh == this._sX) || (mesh == this._sY) || (mesh == this._sZ) || (mesh == this._sXZ) || (mesh == this._sZY) || (mesh == this._sYX) || (mesh == this._sAll)) return true;
|
|
502
496
|
}
|
|
503
497
|
return false;
|
|
504
|
-
},
|
|
498
|
+
}, false, this._mainCamera);
|
|
505
499
|
|
|
506
500
|
if (pickResult.hit) {
|
|
507
501
|
//this.setAxesVisiblity(0);
|
|
@@ -565,7 +559,7 @@ export class EditControl {
|
|
|
565
559
|
private _detachCamera(cam: Object, can: Object) {
|
|
566
560
|
let camera: Camera = <Camera>cam;
|
|
567
561
|
let canvas: HTMLCanvasElement = <HTMLCanvasElement>can;
|
|
568
|
-
let engine: Engine = this._scene.getEngine();
|
|
562
|
+
let engine: Engine = <Engine> this._scene.getEngine();
|
|
569
563
|
if (!engine.isPointerLock) {
|
|
570
564
|
camera.detachControl(canvas)
|
|
571
565
|
}
|
|
@@ -582,7 +576,7 @@ export class EditControl {
|
|
|
582
576
|
private _savedCol: Color3;
|
|
583
577
|
private _onPointerOver() {
|
|
584
578
|
//if(this.pDown) return;
|
|
585
|
-
let engine: Engine = this._scene.getEngine();
|
|
579
|
+
let engine: Engine = <Engine> this._scene.getEngine();
|
|
586
580
|
let x = (engine.isPointerLock) ? this._canvas.width * 0.5 : this._scene.pointerX;
|
|
587
581
|
let y = (engine.isPointerLock) ? this._canvas.height * 0.5 : this._scene.pointerY;
|
|
588
582
|
let pickResult: PickingInfo = this._scene.pick(x, y, (mesh) => {
|
|
@@ -594,7 +588,7 @@ export class EditControl {
|
|
|
594
588
|
if ((mesh == this._sX) || (mesh == this._sY) || (mesh == this._sZ) || (mesh == this._sXZ) || (mesh == this._sZY) || (mesh == this._sYX) || (mesh == this._sAll)) return true;
|
|
595
589
|
}
|
|
596
590
|
return false;
|
|
597
|
-
},
|
|
591
|
+
}, false, this._mainCamera);
|
|
598
592
|
if (pickResult.hit) {
|
|
599
593
|
//if we are still over the same axis mesh then don't do anything
|
|
600
594
|
if (<Mesh>pickResult.pickedMesh != this._prevOverMesh) {
|
|
@@ -604,7 +598,7 @@ export class EditControl {
|
|
|
604
598
|
this._prevOverMesh = <Mesh>pickResult.pickedMesh;
|
|
605
599
|
if (this._rotEnabled) {
|
|
606
600
|
this._savedCol = (<LinesMesh>this._prevOverMesh.getChildren()[0]).color;
|
|
607
|
-
(<LinesMesh>this._prevOverMesh.getChildren()[0]).color = this.
|
|
601
|
+
(<LinesMesh>this._prevOverMesh.getChildren()[0]).color = this._yellowCol;
|
|
608
602
|
} else {
|
|
609
603
|
let childs: Node[] = this._prevOverMesh.getChildren();
|
|
610
604
|
if (childs.length > 0) {
|
|
@@ -616,11 +610,11 @@ export class EditControl {
|
|
|
616
610
|
}
|
|
617
611
|
}
|
|
618
612
|
if (this._prevOverMesh.name == "X") {
|
|
619
|
-
this._xaxis.color = this.
|
|
613
|
+
this._xaxis.color = this._yellowCol;
|
|
620
614
|
} else if (this._prevOverMesh.name == "Y") {
|
|
621
|
-
this._yaxis.color = this.
|
|
615
|
+
this._yaxis.color = this._yellowCol;
|
|
622
616
|
} else if (this._prevOverMesh.name == "Z") {
|
|
623
|
-
this._zaxis.color = this.
|
|
617
|
+
this._zaxis.color = this._yellowCol;
|
|
624
618
|
}
|
|
625
619
|
}
|
|
626
620
|
} else {
|
|
@@ -670,9 +664,9 @@ export class EditControl {
|
|
|
670
664
|
private _onPointerUp(evt: Event) {
|
|
671
665
|
this._pDown = false;
|
|
672
666
|
if (this._editing) {
|
|
673
|
-
let engine: Engine = this._scene.getEngine();
|
|
667
|
+
let engine: Engine = <Engine> this._scene.getEngine();
|
|
674
668
|
if (!engine.isPointerLock) {
|
|
675
|
-
this._mainCamera.attachControl(
|
|
669
|
+
this._mainCamera.attachControl(true);
|
|
676
670
|
}
|
|
677
671
|
this._setEditing(false);
|
|
678
672
|
//this.setAxesVisiblity(1);
|
|
@@ -1035,9 +1029,9 @@ export class EditControl {
|
|
|
1035
1029
|
*/
|
|
1036
1030
|
private _setLocalAxes(mesh: Node) {
|
|
1037
1031
|
let meshMatrix: Matrix = mesh.getWorldMatrix();
|
|
1038
|
-
Vector3.
|
|
1039
|
-
Vector3.
|
|
1040
|
-
Vector3.
|
|
1032
|
+
Vector3.FromArrayToRef(meshMatrix.m, 0, this._localX);
|
|
1033
|
+
Vector3.FromArrayToRef(meshMatrix.m, 4, this._localY);
|
|
1034
|
+
Vector3.FromArrayToRef(meshMatrix.m, 8, this._localZ);
|
|
1041
1035
|
}
|
|
1042
1036
|
|
|
1043
1037
|
|
|
@@ -1072,7 +1066,7 @@ export class EditControl {
|
|
|
1072
1066
|
this._boundingDimesion = this._getBoundingDimension(this._mesh);
|
|
1073
1067
|
}
|
|
1074
1068
|
|
|
1075
|
-
private _eulerian: boolean = false;
|
|
1069
|
+
// private _eulerian: boolean = false;
|
|
1076
1070
|
private _snapRA: number = 0;
|
|
1077
1071
|
private _doRotation(mesh: TransformNode, axis: Mesh, newPos: Vector3, prevPos: Vector3) {
|
|
1078
1072
|
|
|
@@ -1131,10 +1125,6 @@ export class EditControl {
|
|
|
1131
1125
|
mesh.rotate(rAxis, angle, Space.WORLD);
|
|
1132
1126
|
}
|
|
1133
1127
|
|
|
1134
|
-
if (this._eulerian) {
|
|
1135
|
-
mesh.rotation = mesh.rotationQuaternion.toEulerAngles();
|
|
1136
|
-
mesh.rotationQuaternion = null;
|
|
1137
|
-
}
|
|
1138
1128
|
|
|
1139
1129
|
if (this._local) {
|
|
1140
1130
|
if (this._lhsRhs) {
|
|
@@ -1152,7 +1142,7 @@ export class EditControl {
|
|
|
1152
1142
|
}
|
|
1153
1143
|
|
|
1154
1144
|
private _getPosOnPickPlane(): Vector3 {
|
|
1155
|
-
let engine: Engine = this._scene.getEngine();
|
|
1145
|
+
let engine: Engine = <Engine> this._scene.getEngine();
|
|
1156
1146
|
let x = (engine.isPointerLock) ? this._canvas.width * 0.5 : this._scene.pointerX;
|
|
1157
1147
|
let y = (engine.isPointerLock) ? this._canvas.height * 0.5 : this._scene.pointerY;
|
|
1158
1148
|
let pickinfo: PickingInfo = this._scene.pick(x, y, (mesh) => {
|
|
@@ -1241,10 +1231,7 @@ export class EditControl {
|
|
|
1241
1231
|
return this._rotEnabled;
|
|
1242
1232
|
}
|
|
1243
1233
|
|
|
1244
|
-
|
|
1245
|
-
this._eulerian = euler;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1234
|
+
|
|
1248
1235
|
public enableRotation() {
|
|
1249
1236
|
if (this._hidden) return;
|
|
1250
1237
|
if (this._rCtl == null) {
|
|
@@ -1357,9 +1344,9 @@ export class EditControl {
|
|
|
1357
1344
|
let guideAxes: Mesh = new Mesh("", this._scene);
|
|
1358
1345
|
|
|
1359
1346
|
//the big axes, shown when an axis is selected
|
|
1360
|
-
this._bXaxis =
|
|
1361
|
-
this._bYaxis =
|
|
1362
|
-
this._bZaxis =
|
|
1347
|
+
this._bXaxis = MeshBuilder.CreateLines("", { points: [new Vector3(-100, 0, 0), new Vector3(100, 0, 0)] }, this._scene);
|
|
1348
|
+
this._bYaxis = MeshBuilder.CreateLines("", { points: [new Vector3(0, -100, 0), new Vector3(0, 100, 0)] }, this._scene);
|
|
1349
|
+
this._bZaxis = MeshBuilder.CreateLines("", { points: [new Vector3(0, 0, -100), new Vector3(0, 0, 100)] }, this._scene);
|
|
1363
1350
|
|
|
1364
1351
|
//lines are now pickable too
|
|
1365
1352
|
this._bXaxis.isPickable = false;
|
|
@@ -1376,9 +1363,9 @@ export class EditControl {
|
|
|
1376
1363
|
|
|
1377
1364
|
//the small axis
|
|
1378
1365
|
let al: number = this._axesLen * this._axesScale * 0.75;
|
|
1379
|
-
this._xaxis =
|
|
1380
|
-
this._yaxis =
|
|
1381
|
-
this._zaxis =
|
|
1366
|
+
this._xaxis = MeshBuilder.CreateLines("", { points: [new Vector3(0, 0, 0), new Vector3(al, 0, 0)] }, this._scene);
|
|
1367
|
+
this._yaxis = MeshBuilder.CreateLines("", { points: [new Vector3(0, 0, 0), new Vector3(0, al, 0)] }, this._scene);
|
|
1368
|
+
this._zaxis = MeshBuilder.CreateLines("", { points: [new Vector3(0, 0, 0), new Vector3(0, 0, al)] }, this._scene);
|
|
1382
1369
|
|
|
1383
1370
|
//lines are now pickable too
|
|
1384
1371
|
this._xaxis.isPickable = false;
|
|
@@ -1406,10 +1393,10 @@ export class EditControl {
|
|
|
1406
1393
|
private _pYX: Mesh;
|
|
1407
1394
|
|
|
1408
1395
|
private _createPickPlanes() {
|
|
1409
|
-
this._pALL =
|
|
1410
|
-
this._pXZ =
|
|
1411
|
-
this._pZY =
|
|
1412
|
-
this._pYX =
|
|
1396
|
+
this._pALL = MeshBuilder.CreatePlane("", { size: 5 }, this._scene);
|
|
1397
|
+
this._pXZ = MeshBuilder.CreatePlane("", { size: 5 }, this._scene);
|
|
1398
|
+
this._pZY = MeshBuilder.CreatePlane("", { size: 5 }, this._scene);
|
|
1399
|
+
this._pYX = MeshBuilder.CreatePlane("", { size: 5 }, this._scene);
|
|
1413
1400
|
|
|
1414
1401
|
this._pALL.isPickable = false;
|
|
1415
1402
|
this._pXZ.isPickable = false;
|
|
@@ -1468,22 +1455,33 @@ export class EditControl {
|
|
|
1468
1455
|
|
|
1469
1456
|
this._tCtl = new Mesh("", this._scene);
|
|
1470
1457
|
|
|
1471
|
-
|
|
1458
|
+
// pickable invisible boxes around axes lines
|
|
1472
1459
|
this._createPickableTrans(r, l, this._tCtl, this._scene);
|
|
1473
1460
|
|
|
1474
1461
|
//non pickable but visible cones at end of axes lines
|
|
1475
1462
|
this._createNonPickableTrans(r, l, this._scene);
|
|
1476
1463
|
}
|
|
1477
1464
|
|
|
1465
|
+
/**
|
|
1466
|
+
* pickable but invisible
|
|
1467
|
+
* a) 3 boxes around each of the 3 small axes lines
|
|
1468
|
+
* b) 3 small planes near origin for movement along a plane
|
|
1469
|
+
* @param r
|
|
1470
|
+
* @param l
|
|
1471
|
+
* @param tCtl
|
|
1472
|
+
* @param scene
|
|
1473
|
+
*/
|
|
1474
|
+
|
|
1478
1475
|
private _createPickableTrans(r: number, l: number, tCtl: Mesh, scene: Scene) {
|
|
1479
1476
|
let tX = this._extrudeBox(r / 2, l);
|
|
1480
1477
|
tX.name = "X";
|
|
1481
1478
|
let tY = tX.clone("Y");
|
|
1482
1479
|
let tZ = tX.clone("Z");
|
|
1483
1480
|
|
|
1484
|
-
let
|
|
1485
|
-
let
|
|
1486
|
-
let
|
|
1481
|
+
let s = r * 2;
|
|
1482
|
+
let tXZ = MeshBuilder.CreatePlane("XZ", { size: s }, scene);
|
|
1483
|
+
let tZY = MeshBuilder.CreatePlane("ZY", { size: s }, scene);
|
|
1484
|
+
let tYX = MeshBuilder.CreatePlane("YX", { size: s }, scene);
|
|
1487
1485
|
|
|
1488
1486
|
tXZ.rotation.x = 1.57;
|
|
1489
1487
|
tZY.rotation.y = -1.57;
|
|
@@ -1501,7 +1499,7 @@ export class EditControl {
|
|
|
1501
1499
|
tZY.bakeCurrentTransformIntoVertices();
|
|
1502
1500
|
tYX.bakeCurrentTransformIntoVertices();
|
|
1503
1501
|
|
|
1504
|
-
let tAll =
|
|
1502
|
+
let tAll = MeshBuilder.CreateBox("ALL", { size: r * 2 }, scene);
|
|
1505
1503
|
|
|
1506
1504
|
tX.parent = tCtl;
|
|
1507
1505
|
tY.parent = tCtl;
|
|
@@ -1529,12 +1527,15 @@ export class EditControl {
|
|
|
1529
1527
|
this._setPickableFalse(this._all_t)
|
|
1530
1528
|
}
|
|
1531
1529
|
|
|
1530
|
+
//non pickable but visible
|
|
1531
|
+
// a) 3 cones at end of the 3 small axes lines
|
|
1532
|
+
// b) 3 small planes near origin for movement along a plane
|
|
1532
1533
|
private _createNonPickableTrans(r: number, l: number, scene: Scene) {
|
|
1533
1534
|
//cone length
|
|
1534
1535
|
let cl: number = l / 5;
|
|
1535
1536
|
//cone base radius
|
|
1536
1537
|
//let cr: number = r;
|
|
1537
|
-
let tEndX =
|
|
1538
|
+
let tEndX = MeshBuilder.CreateCylinder("", { height: cl, diameterTop: 0, diameterBottom: r, tessellation: 6, subdivisions: 1 }, scene);
|
|
1538
1539
|
let tEndY = tEndX.clone("");
|
|
1539
1540
|
let tEndZ = tEndX.clone("");
|
|
1540
1541
|
|
|
@@ -1544,7 +1545,7 @@ export class EditControl {
|
|
|
1544
1545
|
let tEndZY = MeshBuilder.CreatePlane("ZY", { size: s }, scene);
|
|
1545
1546
|
let tEndYX = MeshBuilder.CreatePlane("YX", { size: s }, scene);
|
|
1546
1547
|
|
|
1547
|
-
let tEndAll =
|
|
1548
|
+
let tEndAll = MeshBuilder.CreateBox("ALL", { size: r }, scene);
|
|
1548
1549
|
|
|
1549
1550
|
tEndX.rotation.x = 1.57;
|
|
1550
1551
|
tEndY.rotation.x = 1.57;
|
|
@@ -1696,7 +1697,7 @@ export class EditControl {
|
|
|
1696
1697
|
rEndX.color = this._redCol;
|
|
1697
1698
|
rEndY.color = this._greenCol;
|
|
1698
1699
|
rEndZ.color = this._blueCol;
|
|
1699
|
-
rEndAll.color = this.
|
|
1700
|
+
rEndAll.color = this._whiteCol;
|
|
1700
1701
|
rEndAll2.color = Color3.Gray();
|
|
1701
1702
|
|
|
1702
1703
|
this._rEndX = rEndX;
|
|
@@ -1723,7 +1724,7 @@ export class EditControl {
|
|
|
1723
1724
|
private _extrudeBox(w: number, l: number): Mesh {
|
|
1724
1725
|
let shape: Vector3[] = [new Vector3(w, w, 0), new Vector3(-w, w, 0), new Vector3(-w, -w, 0), new Vector3(w, -w, 0), new Vector3(w, w, 0)];
|
|
1725
1726
|
let path: Vector3[] = [new Vector3(0, 0, 0), new Vector3(0, 0, l)];
|
|
1726
|
-
let box: Mesh =
|
|
1727
|
+
let box: Mesh = MeshBuilder.ExtrudeShape("", { shape: shape, path: path, scale: 1, rotation: 0, cap: 2 }, this._scene);
|
|
1727
1728
|
return box;
|
|
1728
1729
|
}
|
|
1729
1730
|
|
|
@@ -1749,7 +1750,7 @@ export class EditControl {
|
|
|
1749
1750
|
p++;
|
|
1750
1751
|
}
|
|
1751
1752
|
}
|
|
1752
|
-
let circle: LinesMesh =
|
|
1753
|
+
let circle: LinesMesh = MeshBuilder.CreateLines("", { points: points }, this._scene);
|
|
1753
1754
|
return circle;
|
|
1754
1755
|
}
|
|
1755
1756
|
|
|
@@ -1766,7 +1767,7 @@ export class EditControl {
|
|
|
1766
1767
|
points[p] = new Vector3(x, 0, z);
|
|
1767
1768
|
p++;
|
|
1768
1769
|
}
|
|
1769
|
-
let tube: Mesh =
|
|
1770
|
+
let tube: Mesh = MeshBuilder.CreateTube("", { path: points, radius: this._pickWidth * this._axesScale * 2, tessellation: 3, cap: Mesh.NO_CAP }, this._scene);
|
|
1770
1771
|
return tube;
|
|
1771
1772
|
}
|
|
1772
1773
|
|
|
@@ -1834,7 +1835,7 @@ export class EditControl {
|
|
|
1834
1835
|
sZY.bakeCurrentTransformIntoVertices();
|
|
1835
1836
|
sYX.bakeCurrentTransformIntoVertices();
|
|
1836
1837
|
|
|
1837
|
-
let sAll: Mesh =
|
|
1838
|
+
let sAll: Mesh = MeshBuilder.CreateBox("ALL", { size: 2 * r }, this._scene);
|
|
1838
1839
|
|
|
1839
1840
|
sX.parent = sCtl;
|
|
1840
1841
|
sY.parent = sCtl;
|
|
@@ -1864,7 +1865,7 @@ export class EditControl {
|
|
|
1864
1865
|
|
|
1865
1866
|
private _createNonPickableScale(r: number, l: number) {
|
|
1866
1867
|
|
|
1867
|
-
let sEndX =
|
|
1868
|
+
let sEndX = MeshBuilder.CreateBox("", { size: r }, this._scene);
|
|
1868
1869
|
let sEndY = sEndX.clone("");
|
|
1869
1870
|
let sEndZ = sEndX.clone("");
|
|
1870
1871
|
|
|
@@ -1874,7 +1875,7 @@ export class EditControl {
|
|
|
1874
1875
|
let sEndYX = MeshBuilder.CreatePlane("YX", { size: s }, this._scene);
|
|
1875
1876
|
|
|
1876
1877
|
|
|
1877
|
-
let sEndAll =
|
|
1878
|
+
let sEndAll = MeshBuilder.CreateBox("ALL", { size: r }, this._scene);
|
|
1878
1879
|
|
|
1879
1880
|
sEndXZ.rotation.x = 1.57;
|
|
1880
1881
|
sEndZY.rotation.y = -1.57;
|
|
@@ -2106,8 +2107,8 @@ export class EditControl {
|
|
|
2106
2107
|
this._redMat = EditControl._getStandardMaterial(this._redCol, scene);
|
|
2107
2108
|
this._greenMat = EditControl._getStandardMaterial(this._greenCol, scene);
|
|
2108
2109
|
this._blueMat = EditControl._getStandardMaterial(this._blueCol, scene);
|
|
2109
|
-
this._whiteMat = EditControl._getStandardMaterial(this.
|
|
2110
|
-
this._yellowMat = EditControl._getStandardMaterial(this.
|
|
2110
|
+
this._whiteMat = EditControl._getStandardMaterial(this._yellowCol, scene);
|
|
2111
|
+
this._yellowMat = EditControl._getStandardMaterial(this._whiteCol, scene);
|
|
2111
2112
|
}
|
|
2112
2113
|
|
|
2113
2114
|
private _disposeMaterials() {
|
|
@@ -2198,7 +2199,6 @@ class Act {
|
|
|
2198
2199
|
|
|
2199
2200
|
public constructor(mesh: TransformNode, at: number) {
|
|
2200
2201
|
this._p = mesh.position.clone();
|
|
2201
|
-
//if (mesh.rotationQuaternion == null) {
|
|
2202
2202
|
if (mesh.rotationQuaternion == null) {
|
|
2203
2203
|
this._rQ = null;
|
|
2204
2204
|
this._rE = mesh.rotation.clone();
|