qwc2 2025.7.2 → 2025.7.6
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/actions/map.js +1 -1
- package/components/AttributeForm.js +1 -1
- package/components/IdentifyViewer.js +4 -4
- package/components/QtDesignerForm.js +1 -1
- package/components/SearchBox.js +1 -1
- package/components/map3d/Compare3D.js +2 -2
- package/components/map3d/EditDataset3D.js +8 -0
- package/components/map3d/ExportObjects3D.js +2 -1
- package/components/map3d/Identify3D.js +1 -1
- package/components/map3d/ImportObjects3D.js +1 -1
- package/components/map3d/LayerTree3D.js +1 -1
- package/components/map3d/Map3D.js +14 -11
- package/components/map3d/Map3DLight.js +5 -5
- package/components/map3d/MapControls3D.js +4 -2
- package/components/map3d/SearchField3D.js +5 -5
- package/components/map3d/drawtool/EditTool3D.js +5 -7
- package/components/map3d/drawtool/NumericInput3D.js +3 -2
- package/components/map3d/drawtool/style/NumericInput3D.css +12 -0
- package/components/map3d/style/Map3D.css +10 -0
- package/components/map3d/utils/FirstPersonControls3D.js +3 -3
- package/components/map3d/utils/MiscUtils3D.js +7 -6
- package/components/map3d/utils/OrbitControls3D.js +1 -1
- package/components/style/SideBar.css +2 -0
- package/components/widgets/NumberInput.js +1 -1
- package/components/widgets/SearchWidget.js +1 -1
- package/icons/above.svg +81 -0
- package/icons/below.svg +81 -0
- package/icons/middle_h.svg +83 -0
- package/icons/middle_v.svg +83 -0
- package/package.json +1 -1
- package/plugins/API.js +49 -13
- package/plugins/FeatureForm.js +1 -1
- package/plugins/LayerTree.js +1 -1
- package/plugins/MapLegend.js +1 -1
- package/plugins/NewsPopup.js +2 -2
- package/plugins/TopBar.js +1 -1
- package/plugins/View3D.js +7 -6
- package/plugins/style/MapLegend.css +4 -2
- package/reducers/map.js +3 -3
- package/static/translations/bg-BG.json +0 -1
- package/static/translations/ca-ES.json +265 -266
- package/static/translations/cs-CZ.json +0 -1
- package/static/translations/de-CH.json +1 -2
- package/static/translations/de-DE.json +1 -2
- package/static/translations/en-US.json +1 -2
- package/static/translations/es-ES.json +264 -265
- package/static/translations/fi-FI.json +0 -1
- package/static/translations/fr-FR.json +1 -2
- package/static/translations/hu-HU.json +0 -1
- package/static/translations/it-IT.json +1 -2
- package/static/translations/ja-JP.json +26 -27
- package/static/translations/nl-NL.json +0 -1
- package/static/translations/no-NO.json +0 -1
- package/static/translations/pl-PL.json +0 -1
- package/static/translations/pt-BR.json +0 -1
- package/static/translations/pt-PT.json +0 -1
- package/static/translations/ro-RO.json +0 -1
- package/static/translations/ru-RU.json +0 -1
- package/static/translations/sv-SE.json +0 -1
- package/static/translations/tr-TR.json +0 -1
- package/static/translations/tsconfig.json +0 -1
- package/utils/ConfigUtils.js +2 -2
- package/utils/MapUtils.js +3 -3
- package/utils/img/person.png +0 -0
- package/components/map3d/drawtool/TransformControls.js +0 -259
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t)}:p}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},_get.apply(null,arguments)}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}import{BoxGeometry,BufferGeometry,Controls,CylinderGeometry,DoubleSide,Euler,Float32BufferAttribute,Line,LineBasicMaterial,Matrix4,Mesh,MeshBasicMaterial,Object3D,OctahedronGeometry,PlaneGeometry,Quaternion,Raycaster,SphereGeometry,TorusGeometry,Vector3}from"three";var _raycaster=new Raycaster;var _tempVector=new Vector3;var _tempVector2=new Vector3;var _tempQuaternion=new Quaternion;var _unit={X:new Vector3(1,0,0),Y:new Vector3(0,1,0),Z:new Vector3(0,0,1)};/**
|
|
2
|
-
* Fires if any type of change (object or property change) is performed. Property changes
|
|
3
|
-
* are separate events you can add event listeners to. The event type is "propertyname-changed".
|
|
4
|
-
*
|
|
5
|
-
* @event TransformControls#change
|
|
6
|
-
* @type {Object}
|
|
7
|
-
*/var _changeEvent={type:"change"};/**
|
|
8
|
-
* Fires if a pointer (mouse/touch) becomes active.
|
|
9
|
-
*
|
|
10
|
-
* @event TransformControls#mouseDown
|
|
11
|
-
* @type {Object}
|
|
12
|
-
*/var _mouseDownEvent={type:"mouseDown",mode:null};/**
|
|
13
|
-
* Fires if a pointer (mouse/touch) is no longer active.
|
|
14
|
-
*
|
|
15
|
-
* @event TransformControls#mouseUp
|
|
16
|
-
* @type {Object}
|
|
17
|
-
*/var _mouseUpEvent={type:"mouseUp",mode:null};/**
|
|
18
|
-
* Fires if the controlled 3D object is changed.
|
|
19
|
-
*
|
|
20
|
-
* @event TransformControls#objectChange
|
|
21
|
-
* @type {Object}
|
|
22
|
-
*/var _objectChangeEvent={type:"objectChange"};/**
|
|
23
|
-
* This class can be used to transform objects in 3D space by adapting a similar interaction model
|
|
24
|
-
* of DCC tools like Blender. Unlike other controls, it is not intended to transform the scene's camera.
|
|
25
|
-
*
|
|
26
|
-
* `TransformControls` expects that its attached 3D object is part of the scene graph.
|
|
27
|
-
*
|
|
28
|
-
* @augments Controls
|
|
29
|
-
* @three_import import { TransformControls } from 'three/addons/controls/TransformControls.js';
|
|
30
|
-
*/var TransformControls=/*#__PURE__*/function(_Controls){/**
|
|
31
|
-
* Constructs a new controls instance.
|
|
32
|
-
*
|
|
33
|
-
* @param {Camera} camera - The camera of the rendered scene.
|
|
34
|
-
* @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
|
|
35
|
-
*/function TransformControls(camera){var _this;var domElement=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;_classCallCheck(this,TransformControls);_this=_callSuper(this,TransformControls,[undefined,domElement]);var root=new TransformControlsRoot(_this);_this._root=root;var gizmo=new TransformControlsGizmo;_this._gizmo=gizmo;root.add(gizmo);var plane=new TransformControlsPlane;_this._plane=plane;root.add(plane);var scope=_this;// Defined getter, setter and store for a property
|
|
36
|
-
function defineProperty(propName,defaultValue){var propValue=defaultValue;Object.defineProperty(scope,propName,{get:function get(){return propValue!==undefined?propValue:defaultValue},set:function set(value){if(propValue!==value){propValue=value;plane[propName]=value;gizmo[propName]=value;scope.dispatchEvent({type:propName+"-changed",value:value});scope.dispatchEvent(_changeEvent)}}});scope[propName]=defaultValue;plane[propName]=defaultValue;gizmo[propName]=defaultValue}// Define properties with getters/setter
|
|
37
|
-
// Setting the defined property will automatically trigger change event
|
|
38
|
-
// Defined properties are passed down to gizmo and plane
|
|
39
|
-
/**
|
|
40
|
-
* The camera of the rendered scene.
|
|
41
|
-
*
|
|
42
|
-
* @name TransformControls#camera
|
|
43
|
-
* @type {Camera}
|
|
44
|
-
*/defineProperty("camera",camera);defineProperty("object",undefined);defineProperty("enabled",true);/**
|
|
45
|
-
* The current transformation axis.
|
|
46
|
-
*
|
|
47
|
-
* @name TransformControls#axis
|
|
48
|
-
* @type {string}
|
|
49
|
-
*/defineProperty("axis",null);/**
|
|
50
|
-
* The current transformation axis.
|
|
51
|
-
*
|
|
52
|
-
* @name TransformControls#mode
|
|
53
|
-
* @type {('translate'|'rotate'|'scale')}
|
|
54
|
-
* @default 'translate'
|
|
55
|
-
*/defineProperty("mode","translate");/**
|
|
56
|
-
* By default, 3D objects are continuously translated. If you set this property to a numeric
|
|
57
|
-
* value (world units), you can define in which steps the 3D object should be translated.
|
|
58
|
-
*
|
|
59
|
-
* @name TransformControls#translationSnap
|
|
60
|
-
* @type {?number}
|
|
61
|
-
* @default null
|
|
62
|
-
*/defineProperty("translationSnap",null);/**
|
|
63
|
-
* By default, 3D objects are continuously rotated. If you set this property to a numeric
|
|
64
|
-
* value (radians), you can define in which steps the 3D object should be rotated.
|
|
65
|
-
*
|
|
66
|
-
* @name TransformControls#rotationSnap
|
|
67
|
-
* @type {?number}
|
|
68
|
-
* @default null
|
|
69
|
-
*/defineProperty("rotationSnap",null);/**
|
|
70
|
-
* By default, 3D objects are continuously scaled. If you set this property to a numeric
|
|
71
|
-
* value, you can define in which steps the 3D object should be scaled.
|
|
72
|
-
*
|
|
73
|
-
* @name TransformControls#scaleSnap
|
|
74
|
-
* @type {?number}
|
|
75
|
-
* @default null
|
|
76
|
-
*/defineProperty("scaleSnap",null);/**
|
|
77
|
-
* Whether to scale the object from the pulled edge, and not around the center.
|
|
78
|
-
* Only applies to simple objects (not groups of objects).
|
|
79
|
-
*
|
|
80
|
-
* @name TransformControls#scaleFromEdge
|
|
81
|
-
* @type {boolean}
|
|
82
|
-
* @default false
|
|
83
|
-
*/defineProperty("scaleFromEdge",false);/**
|
|
84
|
-
* Whether to allow negative scales.
|
|
85
|
-
* @name TransformControls#allowNegativeScales
|
|
86
|
-
* @type {boolean}
|
|
87
|
-
* @default true
|
|
88
|
-
*/defineProperty("allowNegativeScales",true);/**
|
|
89
|
-
* Defines in which coordinate space transformations should be performed.
|
|
90
|
-
*
|
|
91
|
-
* @name TransformControls#space
|
|
92
|
-
* @type {('world'|'local')}
|
|
93
|
-
* @default 'world'
|
|
94
|
-
*/defineProperty("space","world");/**
|
|
95
|
-
* The size of the helper UI (axes/planes).
|
|
96
|
-
*
|
|
97
|
-
* @name TransformControls#size
|
|
98
|
-
* @type {number}
|
|
99
|
-
* @default 1
|
|
100
|
-
*/defineProperty("size",1);/**
|
|
101
|
-
* Whether dragging is currently performed or not.
|
|
102
|
-
*
|
|
103
|
-
* @name TransformControls#dragging
|
|
104
|
-
* @type {boolean}
|
|
105
|
-
* @readonly
|
|
106
|
-
* @default false
|
|
107
|
-
*/defineProperty("dragging",false);/**
|
|
108
|
-
* Whether the x-axis helper should be visible or not.
|
|
109
|
-
*
|
|
110
|
-
* @name TransformControls#showX
|
|
111
|
-
* @type {boolean}
|
|
112
|
-
* @default true
|
|
113
|
-
*/defineProperty("showX",true);/**
|
|
114
|
-
* Whether the y-axis helper should be visible or not.
|
|
115
|
-
*
|
|
116
|
-
* @name TransformControls#showY
|
|
117
|
-
* @type {boolean}
|
|
118
|
-
* @default true
|
|
119
|
-
*/defineProperty("showY",true);/**
|
|
120
|
-
* Whether the z-axis helper should be visible or not.
|
|
121
|
-
*
|
|
122
|
-
* @name TransformControls#showZ
|
|
123
|
-
* @type {boolean}
|
|
124
|
-
* @default true
|
|
125
|
-
*/defineProperty("showZ",true);/**
|
|
126
|
-
* The minimum allowed X position during translation.
|
|
127
|
-
*
|
|
128
|
-
* @name TransformControls#minX
|
|
129
|
-
* @type {number}
|
|
130
|
-
* @default -Infinity
|
|
131
|
-
*/defineProperty("minX",-Infinity);/**
|
|
132
|
-
* The maximum allowed X position during translation.
|
|
133
|
-
*
|
|
134
|
-
* @name TransformControls#maxX
|
|
135
|
-
* @type {number}
|
|
136
|
-
* @default Infinity
|
|
137
|
-
*/defineProperty("maxX",Infinity);/**
|
|
138
|
-
* The minimum allowed y position during translation.
|
|
139
|
-
*
|
|
140
|
-
* @name TransformControls#minY
|
|
141
|
-
* @type {number}
|
|
142
|
-
* @default -Infinity
|
|
143
|
-
*/defineProperty("minY",-Infinity);/**
|
|
144
|
-
* The maximum allowed Y position during translation.
|
|
145
|
-
*
|
|
146
|
-
* @name TransformControls#maxY
|
|
147
|
-
* @type {number}
|
|
148
|
-
* @default Infinity
|
|
149
|
-
*/defineProperty("maxY",Infinity);/**
|
|
150
|
-
* The minimum allowed z position during translation.
|
|
151
|
-
*
|
|
152
|
-
* @name TransformControls#minZ
|
|
153
|
-
* @type {number}
|
|
154
|
-
* @default -Infinity
|
|
155
|
-
*/defineProperty("minZ",-Infinity);/**
|
|
156
|
-
* The maximum allowed Z position during translation.
|
|
157
|
-
*
|
|
158
|
-
* @name TransformControls#maxZ
|
|
159
|
-
* @type {number}
|
|
160
|
-
* @default Infinity
|
|
161
|
-
*/defineProperty("maxZ",Infinity);// Reusable utility variables
|
|
162
|
-
var worldPosition=new Vector3;var worldPositionStart=new Vector3;var worldQuaternion=new Quaternion;var worldQuaternionStart=new Quaternion;var cameraPosition=new Vector3;var cameraQuaternion=new Quaternion;var pointStart=new Vector3;var pointEnd=new Vector3;var rotationAxis=new Vector3;var rotationAngle=0;var eye=new Vector3;// TODO: remove properties unused in plane and gizmo
|
|
163
|
-
defineProperty("worldPosition",worldPosition);defineProperty("worldPositionStart",worldPositionStart);defineProperty("worldQuaternion",worldQuaternion);defineProperty("worldQuaternionStart",worldQuaternionStart);defineProperty("cameraPosition",cameraPosition);defineProperty("cameraQuaternion",cameraQuaternion);defineProperty("pointStart",pointStart);defineProperty("pointEnd",pointEnd);defineProperty("rotationAxis",rotationAxis);defineProperty("rotationAngle",rotationAngle);defineProperty("eye",eye);_this._offset=new Vector3;_this._startNorm=new Vector3;_this._endNorm=new Vector3;_this._cameraScale=new Vector3;_this._parentPosition=new Vector3;_this._parentQuaternion=new Quaternion;_this._parentQuaternionInv=new Quaternion;_this._parentScale=new Vector3;_this._worldScaleStart=new Vector3;_this._worldQuaternionInv=new Quaternion;_this._worldScale=new Vector3;_this._positionStart=new Vector3;_this._quaternionStart=new Quaternion;_this._scaleStart=new Vector3;_this._getPointer=getPointer.bind(_this);_this._onPointerDown=onPointerDown.bind(_this);_this._onPointerHover=onPointerHover.bind(_this);_this._onPointerMove=onPointerMove.bind(_this);_this._onPointerUp=onPointerUp.bind(_this);_this._bbox=null;if(domElement!==null){_this.connect(domElement)}return _this}_inherits(TransformControls,_Controls);return _createClass(TransformControls,[{key:"connect",value:function connect(element){_superPropGet(TransformControls,"connect",this,3)([element]);this.domElement.addEventListener("pointerdown",this._onPointerDown);this.domElement.addEventListener("pointermove",this._onPointerHover);this.domElement.addEventListener("pointerup",this._onPointerUp);this.domElement.style.touchAction="none";// disable touch scroll
|
|
164
|
-
}},{key:"disconnect",value:function disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown);this.domElement.removeEventListener("pointermove",this._onPointerHover);this.domElement.removeEventListener("pointermove",this._onPointerMove);this.domElement.removeEventListener("pointerup",this._onPointerUp);this.domElement.style.touchAction="auto"}/**
|
|
165
|
-
* Returns the visual representation of the controls. Add the helper to your scene to
|
|
166
|
-
* visually transform the attached 3D object.
|
|
167
|
-
*
|
|
168
|
-
* @return {TransformControlsRoot} The helper.
|
|
169
|
-
*/},{key:"getHelper",value:function getHelper(){return this._root}},{key:"pointerHover",value:function pointerHover(pointer){if(this.object===undefined||this.dragging===true)return;if(pointer!==null)_raycaster.setFromCamera(pointer,this.camera);var intersect=intersectObjectWithRay(this._gizmo.picker[this.mode],_raycaster);if(intersect){this.axis=intersect.object.name}else{this.axis=null}}},{key:"pointerDown",value:function pointerDown(pointer){if(this.object===undefined||this.dragging===true||pointer!=null&&pointer.button!==0)return;if(this.axis!==null){if(pointer!==null)_raycaster.setFromCamera(pointer,this.camera);var planeIntersect=intersectObjectWithRay(this._plane,_raycaster,true);if(planeIntersect){this.object.updateMatrixWorld();this.object.parent.updateMatrixWorld();this._positionStart.copy(this.object.position);this._quaternionStart.copy(this.object.quaternion);this._scaleStart.copy(this.object.scale);this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart);this.pointStart.copy(planeIntersect.point).sub(this.worldPositionStart);if(this.object.geometry){this.object.geometry.computeBoundingBox();this._bbox=this.object.geometry.boundingBox.clone()}}this.dragging=true;_mouseDownEvent.mode=this.mode;this.dispatchEvent(_mouseDownEvent)}}},{key:"pointerMove",value:function pointerMove(pointer){var axis=this.axis;var mode=this.mode;var object=this.object;var space=this.space;if(mode==="scale"){space="local"}else if(axis==="E"||axis==="XYZE"||axis==="XYZ"){space="world"}if(object===undefined||axis===null||this.dragging===false||pointer!==null&&pointer.button!==-1)return;if(pointer!==null)_raycaster.setFromCamera(pointer,this.camera);var planeIntersect=intersectObjectWithRay(this._plane,_raycaster,true);if(!planeIntersect)return;this.pointEnd.copy(planeIntersect.point).sub(this.worldPositionStart);if(mode==="translate"){// Apply translate
|
|
170
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);if(space==="local"&&axis!=="XYZ"){this._offset.applyQuaternion(this._worldQuaternionInv)}if(axis.indexOf("X")===-1)this._offset.x=0;if(axis.indexOf("Y")===-1)this._offset.y=0;if(axis.indexOf("Z")===-1)this._offset.z=0;if(space==="local"&&axis!=="XYZ"){this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale)}else{this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale)}object.position.copy(this._offset).add(this._positionStart);// Apply translation snap
|
|
171
|
-
if(this.translationSnap){if(space==="local"){object.position.applyQuaternion(_tempQuaternion.copy(this._quaternionStart).invert());if(axis.search("X")!==-1){object.position.x=Math.round(object.position.x/this.translationSnap)*this.translationSnap}if(axis.search("Y")!==-1){object.position.y=Math.round(object.position.y/this.translationSnap)*this.translationSnap}if(axis.search("Z")!==-1){object.position.z=Math.round(object.position.z/this.translationSnap)*this.translationSnap}object.position.applyQuaternion(this._quaternionStart)}if(space==="world"){if(object.parent){object.position.add(_tempVector.setFromMatrixPosition(object.parent.matrixWorld))}if(axis.search("X")!==-1){object.position.x=Math.round(object.position.x/this.translationSnap)*this.translationSnap}if(axis.search("Y")!==-1){object.position.y=Math.round(object.position.y/this.translationSnap)*this.translationSnap}if(axis.search("Z")!==-1){object.position.z=Math.round(object.position.z/this.translationSnap)*this.translationSnap}if(object.parent){object.position.sub(_tempVector.setFromMatrixPosition(object.parent.matrixWorld))}}}object.position.x=Math.max(this.minX,Math.min(this.maxX,object.position.x));object.position.y=Math.max(this.minY,Math.min(this.maxY,object.position.y));object.position.z=Math.max(this.minZ,Math.min(this.maxZ,object.position.z))}else if(mode==="scale"){if(axis.search("XYZ")!==-1){var d=this.pointEnd.length()/this.pointStart.length();if(this.pointEnd.dot(this.pointStart)<0)d*=-1;_tempVector2.set(d,d,d)}else{_tempVector.copy(this.pointStart);_tempVector2.copy(this.pointEnd);_tempVector.applyQuaternion(this._worldQuaternionInv);_tempVector2.applyQuaternion(this._worldQuaternionInv);_tempVector2.divide(_tempVector);if(axis.search("X")===-1){_tempVector2.x=1}if(axis.search("Y")===-1){_tempVector2.y=1}if(axis.search("Z")===-1){_tempVector2.z=1}}// Apply scale
|
|
172
|
-
if(!this.allowNegativeScales&&(_tempVector2.x<0||_tempVector2.y<0||_tempVector2.z<0)){return}object.scale.copy(this._scaleStart).multiply(_tempVector2);if(this.scaleSnap){if(axis.search("X")!==-1){object.scale.x=Math.round(object.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap}if(axis.search("Y")!==-1){object.scale.y=Math.round(object.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap}if(axis.search("Z")!==-1){object.scale.z=Math.round(object.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap}}// Scale from pulled side
|
|
173
|
-
if(this.scaleFromEdge&&this._bbox){if(this.pointStart.x>0){this._offset.x=this._bbox.min.x*(this._scaleStart.x-object.scale.x)}else{this._offset.x=this._bbox.max.x*(this._scaleStart.x-object.scale.x)}if(this.pointStart.y>0){this._offset.y=this._bbox.min.y*(this._scaleStart.y-object.scale.y)}else{this._offset.y=this._bbox.max.y*(this._scaleStart.y-object.scale.y)}if(this.pointStart.z>0){this._offset.z=this._bbox.min.z*(this._scaleStart.z-object.scale.z)}else{this._offset.z=this._bbox.max.z*(this._scaleStart.z-object.scale.z)}this._offset.applyQuaternion(this._quaternionStart);object.position.copy(this._offset).add(this._positionStart)}}else if(mode==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);var ROTATION_SPEED=20/this.worldPosition.distanceTo(_tempVector.setFromMatrixPosition(this.camera.matrixWorld));var _inPlaneRotation=false;if(axis==="XYZE"){this.rotationAxis.copy(this._offset).cross(this.eye).normalize();this.rotationAngle=this._offset.dot(_tempVector.copy(this.rotationAxis).cross(this.eye))*ROTATION_SPEED}else if(axis==="X"||axis==="Y"||axis==="Z"){this.rotationAxis.copy(_unit[axis]);_tempVector.copy(_unit[axis]);if(space==="local"){_tempVector.applyQuaternion(this.worldQuaternion)}_tempVector.cross(this.eye);// When _tempVector is 0 after cross with this.eye the vectors are parallel and should use in-plane rotation logic.
|
|
174
|
-
if(_tempVector.length()===0){_inPlaneRotation=true}else{this.rotationAngle=this._offset.dot(_tempVector.normalize())*ROTATION_SPEED}}if(axis==="E"||_inPlaneRotation){this.rotationAxis.copy(this.eye);this.rotationAngle=this.pointEnd.angleTo(this.pointStart);this._startNorm.copy(this.pointStart).normalize();this._endNorm.copy(this.pointEnd).normalize();this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1}// Apply rotation snap
|
|
175
|
-
if(this.rotationSnap)this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap;// Apply rotate
|
|
176
|
-
if(space==="local"&&axis!=="E"&&axis!=="XYZE"){object.quaternion.copy(this._quaternionStart);object.quaternion.multiply(_tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()}else{this.rotationAxis.applyQuaternion(this._parentQuaternionInv);object.quaternion.copy(_tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle));object.quaternion.multiply(this._quaternionStart).normalize()}}this.dispatchEvent(_changeEvent);this.dispatchEvent(_objectChangeEvent)}},{key:"pointerUp",value:function pointerUp(pointer){if(pointer!==null&&pointer.button!==0)return;if(this.dragging&&this.axis!==null){_mouseUpEvent.mode=this.mode;this.dispatchEvent(_mouseUpEvent)}this.dragging=false;this.axis=null;this._bbox=null}},{key:"dispose",value:function dispose(){this.disconnect();this._root.dispose()}/**
|
|
177
|
-
* Sets the 3D object that should be transformed and ensures the controls UI is visible.
|
|
178
|
-
*
|
|
179
|
-
* @param {Object3D} object - The 3D object that should be transformed.
|
|
180
|
-
* @return {TransformControls} A reference to this controls.
|
|
181
|
-
*/},{key:"attach",value:function attach(object){this.object=object;this._root.visible=true;return this}/**
|
|
182
|
-
* Removes the current 3D object from the controls and makes the helper UI invisible.
|
|
183
|
-
*
|
|
184
|
-
* @return {TransformControls} A reference to this controls.
|
|
185
|
-
*/},{key:"detach",value:function detach(){this.object=undefined;this.axis=null;this._root.visible=false;return this}/**
|
|
186
|
-
* Resets the object's position, rotation and scale to when the current transform began.
|
|
187
|
-
*/},{key:"reset",value:function reset(){if(!this.enabled)return;if(this.dragging){this.object.position.copy(this._positionStart);this.object.quaternion.copy(this._quaternionStart);this.object.scale.copy(this._scaleStart);this.dispatchEvent(_changeEvent);this.dispatchEvent(_objectChangeEvent);this.pointStart.copy(this.pointEnd)}}/**
|
|
188
|
-
* Returns the raycaster that is used for user interaction. This object is shared between all
|
|
189
|
-
* instances of `TransformControls`.
|
|
190
|
-
*
|
|
191
|
-
* @returns {Raycaster} The internal raycaster.
|
|
192
|
-
*/},{key:"getRaycaster",value:function getRaycaster(){return _raycaster}/**
|
|
193
|
-
* Returns the transformation mode.
|
|
194
|
-
*
|
|
195
|
-
* @returns {'translate'|'rotate'|'scale'} The transformation mode.
|
|
196
|
-
*/},{key:"getMode",value:function getMode(){return this.mode}/**
|
|
197
|
-
* Sets the given transformation mode.
|
|
198
|
-
*
|
|
199
|
-
* @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
|
|
200
|
-
*/},{key:"setMode",value:function setMode(mode){this.mode=mode}/**
|
|
201
|
-
* Sets the translation snap.
|
|
202
|
-
*
|
|
203
|
-
* @param {?number} translationSnap - The translation snap to set.
|
|
204
|
-
*/},{key:"setTranslationSnap",value:function setTranslationSnap(translationSnap){this.translationSnap=translationSnap}/**
|
|
205
|
-
* Sets the rotation snap.
|
|
206
|
-
*
|
|
207
|
-
* @param {?number} rotationSnap - The rotation snap to set.
|
|
208
|
-
*/},{key:"setRotationSnap",value:function setRotationSnap(rotationSnap){this.rotationSnap=rotationSnap}/**
|
|
209
|
-
* Sets the scale snap.
|
|
210
|
-
*
|
|
211
|
-
* @param {?number} scaleSnap - The scale snap to set.
|
|
212
|
-
*/},{key:"setScaleSnap",value:function setScaleSnap(scaleSnap){this.scaleSnap=scaleSnap}/**
|
|
213
|
-
* Sets the size of the helper UI.
|
|
214
|
-
*
|
|
215
|
-
* @param {number} size - The size to set.
|
|
216
|
-
*/},{key:"setSize",value:function setSize(size){this.size=size}/**
|
|
217
|
-
* Sets the coordinate space in which transformations are applied.
|
|
218
|
-
*
|
|
219
|
-
* @param {'world'|'local'} space - The space to set.
|
|
220
|
-
*/},{key:"setSpace",value:function setSpace(space){this.space=space}/**
|
|
221
|
-
* Sets the colors of the control's gizmo.
|
|
222
|
-
*
|
|
223
|
-
* @param {number|Color|string} xAxis - The x-axis color.
|
|
224
|
-
* @param {number|Color|string} yAxis - The y-axis color.
|
|
225
|
-
* @param {number|Color|string} zAxis - The z-axis color.
|
|
226
|
-
* @param {number|Color|string} active - The color for active elements.
|
|
227
|
-
*/},{key:"setColors",value:function setColors(xAxis,yAxis,zAxis,active){var materialLib=this._gizmo.materialLib;materialLib.xAxis.color.set(xAxis);materialLib.yAxis.color.set(yAxis);materialLib.zAxis.color.set(zAxis);materialLib.active.color.set(active);materialLib.xAxisTransparent.color.set(xAxis);materialLib.yAxisTransparent.color.set(yAxis);materialLib.zAxisTransparent.color.set(zAxis);materialLib.activeTransparent.color.set(active);// update color caches
|
|
228
|
-
if(materialLib.xAxis._color)materialLib.xAxis._color.set(xAxis);if(materialLib.yAxis._color)materialLib.yAxis._color.set(yAxis);if(materialLib.zAxis._color)materialLib.zAxis._color.set(zAxis);if(materialLib.active._color)materialLib.active._color.set(active);if(materialLib.xAxisTransparent._color)materialLib.xAxisTransparent._color.set(xAxis);if(materialLib.yAxisTransparent._color)materialLib.yAxisTransparent._color.set(yAxis);if(materialLib.zAxisTransparent._color)materialLib.zAxisTransparent._color.set(zAxis);if(materialLib.activeTransparent._color)materialLib.activeTransparent._color.set(active)}}])}(Controls);// mouse / touch event handlers
|
|
229
|
-
function getPointer(event){if(this.domElement.ownerDocument.pointerLockElement){return{x:0,y:0,button:event.button}}else{var rect=this.domElement.getBoundingClientRect();return{x:(event.clientX-rect.left)/rect.width*2-1,y:-(event.clientY-rect.top)/rect.height*2+1,button:event.button}}}function onPointerHover(event){if(!this.enabled)return;switch(event.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(event));break}}function onPointerDown(event){if(!this.enabled)return;if(!document.pointerLockElement){this.domElement.setPointerCapture(event.pointerId)}this.domElement.addEventListener("pointermove",this._onPointerMove);this.pointerHover(this._getPointer(event));this.pointerDown(this._getPointer(event))}function onPointerMove(event){if(!this.enabled)return;this.pointerMove(this._getPointer(event))}function onPointerUp(event){if(!this.enabled)return;this.domElement.releasePointerCapture(event.pointerId);this.domElement.removeEventListener("pointermove",this._onPointerMove);this.pointerUp(this._getPointer(event))}function intersectObjectWithRay(object,raycaster,includeInvisible){var allIntersections=raycaster.intersectObject(object,true);for(var i=0;i<allIntersections.length;i++){if(allIntersections[i].object.visible||includeInvisible){return allIntersections[i]}}return false}//
|
|
230
|
-
// Reusable utility variables
|
|
231
|
-
var _tempEuler=new Euler;var _alignVector=new Vector3(0,1,0);var _zeroVector=new Vector3(0,0,0);var _lookAtMatrix=new Matrix4;var _tempQuaternion2=new Quaternion;var _identityQuaternion=new Quaternion;var _dirVector=new Vector3;var _tempMatrix=new Matrix4;var _unitX=new Vector3(1,0,0);var _unitY=new Vector3(0,1,0);var _unitZ=new Vector3(0,0,1);var _v1=new Vector3;var _v2=new Vector3;var _v3=new Vector3;var TransformControlsRoot=/*#__PURE__*/function(_Object3D){function TransformControlsRoot(controls){var _this2;_classCallCheck(this,TransformControlsRoot);_this2=_callSuper(this,TransformControlsRoot);_this2.isTransformControlsRoot=true;_this2.controls=controls;_this2.visible=false;return _this2}// updateMatrixWorld updates key transformation variables
|
|
232
|
-
_inherits(TransformControlsRoot,_Object3D);return _createClass(TransformControlsRoot,[{key:"updateMatrixWorld",value:function updateMatrixWorld(force){var controls=this.controls;if(controls.object!==undefined){controls.object.updateMatrixWorld();if(controls.object.parent===null){console.error("TransformControls: The attached 3D object must be a part of the scene graph.")}else{controls.object.parent.matrixWorld.decompose(controls._parentPosition,controls._parentQuaternion,controls._parentScale)}controls.object.matrixWorld.decompose(controls.worldPosition,controls.worldQuaternion,controls._worldScale);controls._parentQuaternionInv.copy(controls._parentQuaternion).invert();controls._worldQuaternionInv.copy(controls.worldQuaternion).invert()}controls.camera.updateMatrixWorld();controls.camera.matrixWorld.decompose(controls.cameraPosition,controls.cameraQuaternion,controls._cameraScale);if(controls.camera.isOrthographicCamera){controls.camera.getWorldDirection(controls.eye).negate()}else{controls.eye.copy(controls.cameraPosition).sub(controls.worldPosition).normalize()}_superPropGet(TransformControlsRoot,"updateMatrixWorld",this,3)([force])}},{key:"dispose",value:function dispose(){this.traverse(function(child){if(child.geometry)child.geometry.dispose();if(child.material)child.material.dispose()})}}])}(Object3D);var TransformControlsGizmo=/*#__PURE__*/function(_Object3D2){function TransformControlsGizmo(){var _this3;_classCallCheck(this,TransformControlsGizmo);_this3=_callSuper(this,TransformControlsGizmo);_this3.isTransformControlsGizmo=true;_this3.type="TransformControlsGizmo";// shared materials
|
|
233
|
-
var gizmoMaterial=new MeshBasicMaterial({depthTest:false,depthWrite:false,fog:false,toneMapped:false,transparent:true});var gizmoLineMaterial=new LineBasicMaterial({depthTest:false,depthWrite:false,fog:false,toneMapped:false,transparent:true});// Make unique material for each axis/color
|
|
234
|
-
var matInvisible=gizmoMaterial.clone();matInvisible.opacity=0.15;var matHelper=gizmoLineMaterial.clone();matHelper.opacity=0.5;var matRed=gizmoMaterial.clone();matRed.color.setHex(16711680);var matGreen=gizmoMaterial.clone();matGreen.color.setHex(65280);var matBlue=gizmoMaterial.clone();matBlue.color.setHex(255);var matRedTransparent=gizmoMaterial.clone();matRedTransparent.color.setHex(16711680);matRedTransparent.opacity=0.5;var matGreenTransparent=gizmoMaterial.clone();matGreenTransparent.color.setHex(65280);matGreenTransparent.opacity=0.5;var matBlueTransparent=gizmoMaterial.clone();matBlueTransparent.color.setHex(255);matBlueTransparent.opacity=0.5;var matWhiteTransparent=gizmoMaterial.clone();matWhiteTransparent.opacity=0.25;var matYellowTransparent=gizmoMaterial.clone();matYellowTransparent.color.setHex(16776960);matYellowTransparent.opacity=0.25;var matYellow=gizmoMaterial.clone();matYellow.color.setHex(16776960);var matGray=gizmoMaterial.clone();matGray.color.setHex(7895160);// materials in the below property are configurable via setColors()
|
|
235
|
-
_this3.materialLib={xAxis:matRed,yAxis:matGreen,zAxis:matBlue,active:matYellow,xAxisTransparent:matRedTransparent,yAxisTransparent:matGreenTransparent,zAxisTransparent:matBlueTransparent,activeTransparent:matYellowTransparent};// reusable geometry
|
|
236
|
-
var arrowGeometry=new CylinderGeometry(0,0.04,0.1,12);arrowGeometry.translate(0,0.05,0);var scaleHandleGeometry=new BoxGeometry(0.08,0.08,0.08);scaleHandleGeometry.translate(0,0.04,0);var lineGeometry=new BufferGeometry;lineGeometry.setAttribute("position",new Float32BufferAttribute([0,0,0,1,0,0],3));var lineGeometry2=new CylinderGeometry(0.0075,0.0075,0.5,3);lineGeometry2.translate(0,0.25,0);function CircleGeometry(radius,arc){var geometry=new TorusGeometry(radius,0.0075,3,64,arc*Math.PI*2);geometry.rotateY(Math.PI/2);geometry.rotateX(Math.PI/2);return geometry}// Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
|
|
237
|
-
function TranslateHelperGeometry(){var geometry=new BufferGeometry;geometry.setAttribute("position",new Float32BufferAttribute([0,0,0,1,1,1],3));return geometry}// Gizmo definitions - custom hierarchy definitions for setupGizmo() function
|
|
238
|
-
var gizmoTranslate={X:[[new Mesh(arrowGeometry,matRed),[0.5,0,0],[0,0,-Math.PI/2]],[new Mesh(arrowGeometry,matRed),[-0.5,0,0],[0,0,Math.PI/2]],[new Mesh(lineGeometry2,matRed),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Mesh(arrowGeometry,matGreen),[0,0.5,0]],[new Mesh(arrowGeometry,matGreen),[0,-0.5,0],[Math.PI,0,0]],[new Mesh(lineGeometry2,matGreen)]],Z:[[new Mesh(arrowGeometry,matBlue),[0,0,0.5],[Math.PI/2,0,0]],[new Mesh(arrowGeometry,matBlue),[0,0,-0.5],[-Math.PI/2,0,0]],[new Mesh(lineGeometry2,matBlue),null,[Math.PI/2,0,0]]],XYZ:[[new Mesh(new OctahedronGeometry(0.1,0),matWhiteTransparent),[0,0,0]]],XY:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matBlueTransparent),[0.15,0.15,0]]],YZ:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matRedTransparent),[0,0.15,0.15],[0,Math.PI/2,0]]],XZ:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matGreenTransparent),[0.15,0,0.15],[-Math.PI/2,0,0]]]};var pickerTranslate={X:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0.3,0,0],[0,0,-Math.PI/2]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[-0.3,0,0],[0,0,Math.PI/2]]],Y:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0.3,0]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,-0.3,0],[0,0,Math.PI]]],Z:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0,0.3],[Math.PI/2,0,0]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0,-0.3],[-Math.PI/2,0,0]]],XYZ:[[new Mesh(new OctahedronGeometry(0.2,0),matInvisible)]],XY:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0.15,0.15,0]]],YZ:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0,0.15,0.15],[0,Math.PI/2,0]]],XZ:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0.15,0,0.15],[-Math.PI/2,0,0]]]};var helperTranslate={START:[[new Mesh(new OctahedronGeometry(0.01,2),matHelper),null,null,null,"helper"]],END:[[new Mesh(new OctahedronGeometry(0.01,2),matHelper),null,null,null,"helper"]],DELTA:[[new Line(TranslateHelperGeometry(),matHelper),null,null,null,"helper"]],X:[[new Line(lineGeometry,matHelper),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Line(lineGeometry,matHelper),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Line(lineGeometry,matHelper),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};var gizmoRotate={XYZE:[[new Mesh(CircleGeometry(0.5,1),matGray),null,[0,Math.PI/2,0]]],X:[[new Mesh(CircleGeometry(0.5,0.5),matRed)]],Y:[[new Mesh(CircleGeometry(0.5,0.5),matGreen),null,[0,0,-Math.PI/2]]],Z:[[new Mesh(CircleGeometry(0.5,0.5),matBlue),null,[0,Math.PI/2,0]]],E:[[new Mesh(CircleGeometry(0.75,1),matYellowTransparent),null,[0,Math.PI/2,0]]]};var helperRotate={AXIS:[[new Line(lineGeometry,matHelper),[-1e3,0,0],null,[1e6,1,1],"helper"]]};var pickerRotate={XYZE:[[new Mesh(new SphereGeometry(0.25,10,8),matInvisible)]],X:[[new Mesh(new TorusGeometry(0.5,0.1,4,24),matInvisible),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Mesh(new TorusGeometry(0.5,0.1,4,24),matInvisible),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Mesh(new TorusGeometry(0.5,0.1,4,24),matInvisible),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Mesh(new TorusGeometry(0.75,0.1,2,24),matInvisible)]]};var gizmoScale={X:[[new Mesh(scaleHandleGeometry,matRed),[0.5,0,0],[0,0,-Math.PI/2]],[new Mesh(lineGeometry2,matRed),[0,0,0],[0,0,-Math.PI/2]],[new Mesh(scaleHandleGeometry,matRed),[-0.5,0,0],[0,0,Math.PI/2]]],Y:[[new Mesh(scaleHandleGeometry,matGreen),[0,0.5,0]],[new Mesh(lineGeometry2,matGreen)],[new Mesh(scaleHandleGeometry,matGreen),[0,-0.5,0],[0,0,Math.PI]]],Z:[[new Mesh(scaleHandleGeometry,matBlue),[0,0,0.5],[Math.PI/2,0,0]],[new Mesh(lineGeometry2,matBlue),[0,0,0],[Math.PI/2,0,0]],[new Mesh(scaleHandleGeometry,matBlue),[0,0,-0.5],[-Math.PI/2,0,0]]],XY:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matBlueTransparent),[0.15,0.15,0]]],YZ:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matRedTransparent),[0,0.15,0.15],[0,Math.PI/2,0]]],XZ:[[new Mesh(new BoxGeometry(0.15,0.15,0.01),matGreenTransparent),[0.15,0,0.15],[-Math.PI/2,0,0]]],XYZ:[[new Mesh(new BoxGeometry(0.1,0.1,0.1),matWhiteTransparent)]]};var pickerScale={X:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0.3,0,0],[0,0,-Math.PI/2]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[-0.3,0,0],[0,0,Math.PI/2]]],Y:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0.3,0]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,-0.3,0],[0,0,Math.PI]]],Z:[[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0,0.3],[Math.PI/2,0,0]],[new Mesh(new CylinderGeometry(0.2,0,0.6,4),matInvisible),[0,0,-0.3],[-Math.PI/2,0,0]]],XY:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0.15,0.15,0]]],YZ:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0,0.15,0.15],[0,Math.PI/2,0]]],XZ:[[new Mesh(new BoxGeometry(0.2,0.2,0.01),matInvisible),[0.15,0,0.15],[-Math.PI/2,0,0]]],XYZ:[[new Mesh(new BoxGeometry(0.2,0.2,0.2),matInvisible),[0,0,0]]]};var helperScale={X:[[new Line(lineGeometry,matHelper),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Line(lineGeometry,matHelper),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Line(lineGeometry,matHelper),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};// Creates an Object3D with gizmos described in custom hierarchy definition.
|
|
239
|
-
function setupGizmo(gizmoMap){var gizmo=new Object3D;for(var name in gizmoMap){for(var i=gizmoMap[name].length;i--;){var object=gizmoMap[name][i][0].clone();var position=gizmoMap[name][i][1];var rotation=gizmoMap[name][i][2];var scale=gizmoMap[name][i][3];var tag=gizmoMap[name][i][4];// name and tag properties are essential for picking and updating logic.
|
|
240
|
-
object.name=name;object.tag=tag;if(position){object.position.set(position[0],position[1],position[2])}if(rotation){object.rotation.set(rotation[0],rotation[1],rotation[2])}if(scale){object.scale.set(scale[0],scale[1],scale[2])}object.updateMatrix();var tempGeometry=object.geometry.clone();tempGeometry.applyMatrix4(object.matrix);object.geometry=tempGeometry;object.renderOrder=Infinity;object.position.set(0,0,0);object.rotation.set(0,0,0);object.scale.set(1,1,1);gizmo.add(object)}}return gizmo}// Gizmo creation
|
|
241
|
-
_this3.gizmo={};_this3.picker={};_this3.helper={};_this3.add(_this3.gizmo["translate"]=setupGizmo(gizmoTranslate));_this3.add(_this3.gizmo["rotate"]=setupGizmo(gizmoRotate));_this3.add(_this3.gizmo["scale"]=setupGizmo(gizmoScale));_this3.add(_this3.picker["translate"]=setupGizmo(pickerTranslate));_this3.add(_this3.picker["rotate"]=setupGizmo(pickerRotate));_this3.add(_this3.picker["scale"]=setupGizmo(pickerScale));_this3.add(_this3.helper["translate"]=setupGizmo(helperTranslate));_this3.add(_this3.helper["rotate"]=setupGizmo(helperRotate));_this3.add(_this3.helper["scale"]=setupGizmo(helperScale));// Pickers should be hidden always
|
|
242
|
-
_this3.picker["translate"].visible=false;_this3.picker["rotate"].visible=false;_this3.picker["scale"].visible=false;return _this3}// updateMatrixWorld will update transformations and appearance of individual handles
|
|
243
|
-
_inherits(TransformControlsGizmo,_Object3D2);return _createClass(TransformControlsGizmo,[{key:"updateMatrixWorld",value:function updateMatrixWorld(force){var _this4=this;var space=this.mode==="scale"?"local":this.space;// scale always oriented to local rotation
|
|
244
|
-
var quaternion=space==="local"?this.worldQuaternion:_identityQuaternion;// Show only gizmos for current transform mode
|
|
245
|
-
this.gizmo["translate"].visible=this.mode==="translate";this.gizmo["rotate"].visible=this.mode==="rotate";this.gizmo["scale"].visible=this.mode==="scale";this.helper["translate"].visible=this.mode==="translate";this.helper["rotate"].visible=this.mode==="rotate";this.helper["scale"].visible=this.mode==="scale";var handles=[];handles=handles.concat(this.picker[this.mode].children);handles=handles.concat(this.gizmo[this.mode].children);handles=handles.concat(this.helper[this.mode].children);var _loop=function _loop(){var handle=handles[i];// hide aligned to camera
|
|
246
|
-
handle.visible=true;handle.rotation.set(0,0,0);handle.position.copy(_this4.worldPosition);var factor;if(_this4.camera.isOrthographicCamera){factor=(_this4.camera.top-_this4.camera.bottom)/_this4.camera.zoom}else{factor=_this4.worldPosition.distanceTo(_this4.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*_this4.camera.fov/360)/_this4.camera.zoom,7)}handle.scale.set(1,1,1).multiplyScalar(factor*_this4.size/4);// TODO: simplify helpers and consider decoupling from gizmo
|
|
247
|
-
if(handle.tag==="helper"){handle.visible=false;if(handle.name==="AXIS"){handle.visible=!!_this4.axis;if(_this4.axis==="X"){_tempQuaternion.setFromEuler(_tempEuler.set(0,0,0));handle.quaternion.copy(quaternion).multiply(_tempQuaternion);if(Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(_this4.eye))>0.9){handle.visible=false}}if(_this4.axis==="Y"){_tempQuaternion.setFromEuler(_tempEuler.set(0,0,Math.PI/2));handle.quaternion.copy(quaternion).multiply(_tempQuaternion);if(Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(_this4.eye))>0.9){handle.visible=false}}if(_this4.axis==="Z"){_tempQuaternion.setFromEuler(_tempEuler.set(0,Math.PI/2,0));handle.quaternion.copy(quaternion).multiply(_tempQuaternion);if(Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(_this4.eye))>0.9){handle.visible=false}}if(_this4.axis==="XYZE"){_tempQuaternion.setFromEuler(_tempEuler.set(0,Math.PI/2,0));_alignVector.copy(_this4.rotationAxis);handle.quaternion.setFromRotationMatrix(_lookAtMatrix.lookAt(_zeroVector,_alignVector,_unitY));handle.quaternion.multiply(_tempQuaternion);handle.visible=_this4.dragging}if(_this4.axis==="E"){handle.visible=false}}else if(handle.name==="START"){handle.position.copy(_this4.worldPositionStart);handle.visible=_this4.dragging}else if(handle.name==="END"){handle.position.copy(_this4.worldPosition);handle.visible=_this4.dragging}else if(handle.name==="DELTA"){handle.position.copy(_this4.worldPositionStart);handle.quaternion.copy(_this4.worldQuaternionStart);_tempVector.set(1e-10,1e-10,1e-10).add(_this4.worldPositionStart).sub(_this4.worldPosition).multiplyScalar(-1);_tempVector.applyQuaternion(_this4.worldQuaternionStart.clone().invert());handle.scale.copy(_tempVector);handle.visible=_this4.dragging}else{handle.quaternion.copy(quaternion);if(_this4.dragging){handle.position.copy(_this4.worldPositionStart)}else{handle.position.copy(_this4.worldPosition)}if(_this4.axis){handle.visible=_this4.axis.search(handle.name)!==-1}}// If updating helper, skip rest of the loop
|
|
248
|
-
return 1;// continue
|
|
249
|
-
}// Align handles to current local or world rotation
|
|
250
|
-
handle.quaternion.copy(quaternion);if(_this4.mode==="translate"||_this4.mode==="scale"){// Hide translate and scale axis facing the camera
|
|
251
|
-
var AXIS_HIDE_THRESHOLD=0.99;var PLANE_HIDE_THRESHOLD=0.2;if(handle.name==="X"){if(Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(_this4.eye))>AXIS_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}if(handle.name==="Y"){if(Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(_this4.eye))>AXIS_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}if(handle.name==="Z"){if(Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(_this4.eye))>AXIS_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}if(handle.name==="XY"){if(Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(_this4.eye))<PLANE_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}if(handle.name==="YZ"){if(Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(_this4.eye))<PLANE_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}if(handle.name==="XZ"){if(Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(_this4.eye))<PLANE_HIDE_THRESHOLD){handle.scale.set(1e-10,1e-10,1e-10);handle.visible=false}}}else if(_this4.mode==="rotate"){// Align handles to current local or world rotation
|
|
252
|
-
_tempQuaternion2.copy(quaternion);_alignVector.copy(_this4.eye).applyQuaternion(_tempQuaternion.copy(quaternion).invert());if(handle.name.search("E")!==-1){handle.quaternion.setFromRotationMatrix(_lookAtMatrix.lookAt(_this4.eye,_zeroVector,_unitY))}if(handle.name==="X"){_tempQuaternion.setFromAxisAngle(_unitX,Math.atan2(-_alignVector.y,_alignVector.z));_tempQuaternion.multiplyQuaternions(_tempQuaternion2,_tempQuaternion);handle.quaternion.copy(_tempQuaternion)}if(handle.name==="Y"){_tempQuaternion.setFromAxisAngle(_unitY,Math.atan2(_alignVector.x,_alignVector.z));_tempQuaternion.multiplyQuaternions(_tempQuaternion2,_tempQuaternion);handle.quaternion.copy(_tempQuaternion)}if(handle.name==="Z"){_tempQuaternion.setFromAxisAngle(_unitZ,Math.atan2(_alignVector.y,_alignVector.x));_tempQuaternion.multiplyQuaternions(_tempQuaternion2,_tempQuaternion);handle.quaternion.copy(_tempQuaternion)}}// Hide disabled axes
|
|
253
|
-
handle.visible=handle.visible&&(handle.name.indexOf("X")===-1||_this4.showX);handle.visible=handle.visible&&(handle.name.indexOf("Y")===-1||_this4.showY);handle.visible=handle.visible&&(handle.name.indexOf("Z")===-1||_this4.showZ);handle.visible=handle.visible&&(handle.name.indexOf("E")===-1||_this4.showX&&_this4.showY&&_this4.showZ);// highlight selected axis
|
|
254
|
-
handle.material._color=handle.material._color||handle.material.color.clone();handle.material._opacity=handle.material._opacity||handle.material.opacity;handle.material.color.copy(handle.material._color);handle.material.opacity=handle.material._opacity;if(_this4.enabled&&_this4.axis){if(handle.name===_this4.axis){handle.material.color.copy(_this4.materialLib.active.color);handle.material.opacity=1}else if(_this4.axis.split("").some(function(a){return handle.name===a})){handle.material.color.copy(_this4.materialLib.active.color);handle.material.opacity=1}}};for(var i=0;i<handles.length;i++){if(_loop())continue}_superPropGet(TransformControlsGizmo,"updateMatrixWorld",this,3)([force])}}])}(Object3D);//
|
|
255
|
-
var TransformControlsPlane=/*#__PURE__*/function(_Mesh){function TransformControlsPlane(){var _this5;_classCallCheck(this,TransformControlsPlane);_this5=_callSuper(this,TransformControlsPlane,[new PlaneGeometry(100000,100000,2,2),new MeshBasicMaterial({visible:false,wireframe:true,side:DoubleSide,transparent:true,opacity:0.1,toneMapped:false})]);_this5.isTransformControlsPlane=true;_this5.type="TransformControlsPlane";return _this5}_inherits(TransformControlsPlane,_Mesh);return _createClass(TransformControlsPlane,[{key:"updateMatrixWorld",value:function updateMatrixWorld(force){var space=this.space;this.position.copy(this.worldPosition);if(this.mode==="scale")space="local";// scale always oriented to local rotation
|
|
256
|
-
_v1.copy(_unitX).applyQuaternion(space==="local"?this.worldQuaternion:_identityQuaternion);_v2.copy(_unitY).applyQuaternion(space==="local"?this.worldQuaternion:_identityQuaternion);_v3.copy(_unitZ).applyQuaternion(space==="local"?this.worldQuaternion:_identityQuaternion);// Align the plane for current transform mode, axis and space.
|
|
257
|
-
_alignVector.copy(_v2);switch(this.mode){case"translate":case"scale":switch(this.axis){case"X":_alignVector.copy(this.eye).cross(_v1);_dirVector.copy(_v1).cross(_alignVector);break;case"Y":_alignVector.copy(this.eye).cross(_v2);_dirVector.copy(_v2).cross(_alignVector);break;case"Z":_alignVector.copy(this.eye).cross(_v3);_dirVector.copy(_v3).cross(_alignVector);break;case"XY":_dirVector.copy(_v3);break;case"YZ":_dirVector.copy(_v1);break;case"XZ":_alignVector.copy(_v3);_dirVector.copy(_v2);break;case"XYZ":case"E":_dirVector.set(0,0,0);break}break;case"rotate":default:// special case for rotate
|
|
258
|
-
_dirVector.set(0,0,0)}if(_dirVector.length()===0){// If in rotate mode, make the plane parallel to camera
|
|
259
|
-
this.quaternion.copy(this.cameraQuaternion)}else{_tempMatrix.lookAt(_tempVector.set(0,0,0),_dirVector,_alignVector);this.quaternion.setFromRotationMatrix(_tempMatrix)}_superPropGet(TransformControlsPlane,"updateMatrixWorld",this,3)([force])}}])}(Mesh);export{TransformControls,TransformControlsGizmo,TransformControlsPlane};
|