viral-viewer-2 6.2.0 → 6.2.3
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/README.md +0 -0
- package/dist/threejs-addon/n8ao/post-processing.d.ts +109 -109
- package/dist/viralution-viewer.js +2 -0
- package/dist/viralution-viewer.js.LICENSE.txt +19 -0
- package/package.json +6 -4
- package/dist/components/animation/viral-animation.js +0 -59
- package/dist/components/animation/viral-animation.js.map +0 -1
- package/dist/components/bvh/viral-bvh.js +0 -19
- package/dist/components/bvh/viral-bvh.js.map +0 -1
- package/dist/components/camera/viral-camera.js +0 -201
- package/dist/components/camera/viral-camera.js.map +0 -1
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.d.ts +0 -7
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js +0 -47
- package/dist/components/centralized-event-handler/viral-centralized-event-handler.js.map +0 -1
- package/dist/components/compress/viral-compress.processor.js +0 -13
- package/dist/components/compress/viral-compress.processor.js.map +0 -1
- package/dist/components/context-menu/viral-context-menu.d.ts +0 -17
- package/dist/components/context-menu/viral-context-menu.js +0 -74
- package/dist/components/context-menu/viral-context-menu.js.map +0 -1
- package/dist/components/custom-objects/index.js +0 -6
- package/dist/components/custom-objects/index.js.map +0 -1
- package/dist/components/custom-objects/viral-instanced-mesh.js +0 -200
- package/dist/components/custom-objects/viral-instanced-mesh.js.map +0 -1
- package/dist/components/data-manager/viral-data-manager.js +0 -35
- package/dist/components/data-manager/viral-data-manager.js.map +0 -1
- package/dist/components/event-handler/base/event-dispatcher.js +0 -35
- package/dist/components/event-handler/base/event-dispatcher.js.map +0 -1
- package/dist/components/event-handler/keyboard/viral-keyboard.js +0 -76
- package/dist/components/event-handler/keyboard/viral-keyboard.js.map +0 -1
- package/dist/components/event-handler/mouse/viral-mouse.js +0 -234
- package/dist/components/event-handler/mouse/viral-mouse.js.map +0 -1
- package/dist/components/event-handler/viral-centralized-event-handler.js +0 -158
- package/dist/components/event-handler/viral-centralized-event-handler.js.map +0 -1
- package/dist/components/event-handler/viral-lifecycle-event-handler.js +0 -55
- package/dist/components/event-handler/viral-lifecycle-event-handler.js.map +0 -1
- package/dist/components/keyboard/viral-keyboard.d.ts +0 -17
- package/dist/components/keyboard/viral-keyboard.js +0 -76
- package/dist/components/keyboard/viral-keyboard.js.map +0 -1
- package/dist/components/loader/viral-point-cloud.loader.js +0 -33
- package/dist/components/loader/viral-point-cloud.loader.js.map +0 -1
- package/dist/components/loader/viral-revit.loader.js +0 -119
- package/dist/components/loader/viral-revit.loader.js.map +0 -1
- package/dist/components/loader/viral-three.loader.js +0 -20
- package/dist/components/loader/viral-three.loader.js.map +0 -1
- package/dist/components/loader/viral.loader.js +0 -16
- package/dist/components/loader/viral.loader.js.map +0 -1
- package/dist/components/material/viral-material-manager.js +0 -60
- package/dist/components/material/viral-material-manager.js.map +0 -1
- package/dist/components/mouse/viral-mouse.d.ts +0 -31
- package/dist/components/mouse/viral-mouse.js +0 -234
- package/dist/components/mouse/viral-mouse.js.map +0 -1
- package/dist/components/navigation-cube/components/cube-camera.d.ts +0 -15
- package/dist/components/navigation-cube/components/cube-camera.js +0 -74
- package/dist/components/navigation-cube/components/cube-camera.js.map +0 -1
- package/dist/components/navigation-cube/components/cube-renderer.d.ts +0 -9
- package/dist/components/navigation-cube/components/cube-renderer.js +0 -31
- package/dist/components/navigation-cube/components/cube-renderer.js.map +0 -1
- package/dist/components/navigation-cube/components/cube-scene.d.ts +0 -13
- package/dist/components/navigation-cube/components/cube-scene.js +0 -546
- package/dist/components/navigation-cube/components/cube-scene.js.map +0 -1
- package/dist/components/navigation-cube/components/cube.mouse.d.ts +0 -9
- package/dist/components/navigation-cube/components/cube.mouse.js +0 -109
- package/dist/components/navigation-cube/components/cube.mouse.js.map +0 -1
- package/dist/components/navigation-cube/viral-navigation-cube.d.ts +0 -16
- package/dist/components/navigation-cube/viral-navigation-cube.js +0 -50
- package/dist/components/navigation-cube/viral-navigation-cube.js.map +0 -1
- package/dist/components/post-processing/ambient-occlusion-effect.d.ts +0 -11
- package/dist/components/post-processing/ambient-occlusion-effect.js +0 -32
- package/dist/components/post-processing/ambient-occlusion-effect.js.map +0 -1
- package/dist/components/post-processing/bloom-effect.d.ts +0 -11
- package/dist/components/post-processing/bloom-effect.js +0 -29
- package/dist/components/post-processing/bloom-effect.js.map +0 -1
- package/dist/components/post-processing/outline-effect.d.ts +0 -13
- package/dist/components/post-processing/outline-effect.js +0 -33
- package/dist/components/post-processing/outline-effect.js.map +0 -1
- package/dist/components/post-processing/post-processing-renderer.js +0 -46
- package/dist/components/post-processing/post-processing-renderer.js.map +0 -1
- package/dist/components/post-processing/viral-post-processing.d.ts +0 -11
- package/dist/components/post-processing/viral-post-processing.js +0 -29
- package/dist/components/post-processing/viral-post-processing.js.map +0 -1
- package/dist/components/renderer/viral-renderer.js +0 -51
- package/dist/components/renderer/viral-renderer.js.map +0 -1
- package/dist/components/scene/viral-scene.js +0 -129
- package/dist/components/scene/viral-scene.js.map +0 -1
- package/dist/components/spinner/viral-spinner.d.ts +0 -10
- package/dist/components/spinner/viral-spinner.js +0 -207
- package/dist/components/spinner/viral-spinner.js.map +0 -1
- package/dist/components/stats/viral-stats.js +0 -17
- package/dist/components/stats/viral-stats.js.map +0 -1
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.d.ts +0 -7
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js +0 -16
- package/dist/components/tools/tools/viral-tool-ambient-occlusion.js.map +0 -1
- package/dist/components/tools/tools/viral-tool-dark-mode.d.ts +0 -7
- package/dist/components/tools/tools/viral-tool-dark-mode.js +0 -21
- package/dist/components/tools/tools/viral-tool-dark-mode.js.map +0 -1
- package/dist/components/tools/tools/viral-tool-elevation.d.ts +0 -11
- package/dist/components/tools/tools/viral-tool-elevation.js +0 -30
- package/dist/components/tools/tools/viral-tool-elevation.js.map +0 -1
- package/dist/components/tools/tools/viral-tool-measure.d.ts +0 -33
- package/dist/components/tools/tools/viral-tool-measure.js +0 -243
- package/dist/components/tools/tools/viral-tool-measure.js.map +0 -1
- package/dist/components/tools/tools/viral-tool-sunlight.d.ts +0 -7
- package/dist/components/tools/tools/viral-tool-sunlight.js +0 -46
- package/dist/components/tools/tools/viral-tool-sunlight.js.map +0 -1
- package/dist/components/tools/viral-tools.d.ts +0 -32
- package/dist/components/tools/viral-tools.js +0 -213
- package/dist/components/tools/viral-tools.js.map +0 -1
- package/dist/components/visibility-manager/viral-visibility-manager.js +0 -166
- package/dist/components/visibility-manager/viral-visibility-manager.js.map +0 -1
- package/dist/components/worker/base/worker-pool.js +0 -68
- package/dist/components/worker/base/worker-pool.js.map +0 -1
- package/dist/components/worker/base/worker-thread.js +0 -35
- package/dist/components/worker/base/worker-thread.js.map +0 -1
- package/dist/components/worker/fetch-data.worker.js +0 -31
- package/dist/components/worker/fetch-data.worker.js.map +0 -1
- package/dist/components/worker/viral-viewer-2.worker.js +0 -127
- package/dist/components/worker/viral-viewer-2.worker.js.map +0 -1
- package/dist/components/worker/viral-viewer-3.worker.js +0 -82
- package/dist/components/worker/viral-viewer-3.worker.js.map +0 -1
- package/dist/components/worker/viral-viewer-4.worker.js +0 -97
- package/dist/components/worker/viral-viewer-4.worker.js.map +0 -1
- package/dist/components/worker/viral-viewer.worker.js +0 -107
- package/dist/components/worker/viral-viewer.worker.js.map +0 -1
- package/dist/components/worker-script/fetch-data-worker.script.js +0 -56
- package/dist/components/worker-script/fetch-data-worker.script.js.map +0 -1
- package/dist/components/worker-script/load-model-worker-2.script.js +0 -2704
- package/dist/components/worker-script/load-model-worker-2.script.js.map +0 -1
- package/dist/components/worker-script/load-model-worker-3.script.js +0 -34170
- package/dist/components/worker-script/load-model-worker-3.script.js.map +0 -1
- package/dist/components/worker-script/load-model-worker.script.js +0 -148
- package/dist/components/worker-script/load-model-worker.script.js.map +0 -1
- package/dist/components/worker-script/threejs.types.js +0 -34162
- package/dist/components/worker-script/threejs.types.js.map +0 -1
- package/dist/const/colors.js +0 -38
- package/dist/const/colors.js.map +0 -1
- package/dist/const/fonts.js +0 -17
- package/dist/const/fonts.js.map +0 -1
- package/dist/gui/context-menu/viral-context-menu.js +0 -74
- package/dist/gui/context-menu/viral-context-menu.js.map +0 -1
- package/dist/gui/draggable-modal/viral-draggable-modal.js +0 -91
- package/dist/gui/draggable-modal/viral-draggable-modal.js.map +0 -1
- package/dist/gui/fonts/fonts.js +0 -20
- package/dist/gui/fonts/fonts.js.map +0 -1
- package/dist/gui/navigation-cube/components/cube-camera.js +0 -74
- package/dist/gui/navigation-cube/components/cube-camera.js.map +0 -1
- package/dist/gui/navigation-cube/components/cube-renderer.js +0 -31
- package/dist/gui/navigation-cube/components/cube-renderer.js.map +0 -1
- package/dist/gui/navigation-cube/components/cube-scene.js +0 -546
- package/dist/gui/navigation-cube/components/cube-scene.js.map +0 -1
- package/dist/gui/navigation-cube/components/cube.mouse.js +0 -109
- package/dist/gui/navigation-cube/components/cube.mouse.js.map +0 -1
- package/dist/gui/navigation-cube/viral-navigation-cube.js +0 -50
- package/dist/gui/navigation-cube/viral-navigation-cube.js.map +0 -1
- package/dist/gui/spinner/viral-spinner.js +0 -102
- package/dist/gui/spinner/viral-spinner.js.map +0 -1
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js +0 -16
- package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js.map +0 -1
- package/dist/gui/tools/tools/viral-tool-dark-mode.js +0 -21
- package/dist/gui/tools/tools/viral-tool-dark-mode.js.map +0 -1
- package/dist/gui/tools/tools/viral-tool-elevation.js +0 -30
- package/dist/gui/tools/tools/viral-tool-elevation.js.map +0 -1
- package/dist/gui/tools/tools/viral-tool-measure.js +0 -243
- package/dist/gui/tools/tools/viral-tool-measure.js.map +0 -1
- package/dist/gui/tools/tools/viral-tool-sunlight.js +0 -46
- package/dist/gui/tools/tools/viral-tool-sunlight.js.map +0 -1
- package/dist/gui/tools/viral-tools.js +0 -213
- package/dist/gui/tools/viral-tools.js.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/models/dictionary.model.d.ts +0 -0
- package/dist/models/dictionary.model.js +0 -1
- package/dist/models/dictionary.model.js.map +0 -1
- package/dist/services/local-storage.service.js +0 -57
- package/dist/services/local-storage.service.js.map +0 -1
- package/dist/threejs-addon/buffer-geometry-utils.d.ts +0 -64
- package/dist/threejs-addon/buffer-geometry-utils.js +0 -807
- package/dist/threejs-addon/buffer-geometry-utils.js.map +0 -1
- package/dist/threejs-addon/gltf-loader.d.ts +0 -17
- package/dist/threejs-addon/gltf-loader.js +0 -2796
- package/dist/threejs-addon/gltf-loader.js.map +0 -1
- package/dist/threejs-addon/n8ao/n8ao.js +0 -1952
- package/dist/threejs-addon/n8ao/n8ao.js.map +0 -1
- package/dist/threejs-addon/n8ao/post-processing.js +0 -15145
- package/dist/threejs-addon/n8ao/post-processing.js.map +0 -1
- package/dist/threejs-addon/post-processing/effect-composer.d.ts +0 -27
- package/dist/threejs-addon/post-processing/effect-composer.js +0 -134
- package/dist/threejs-addon/post-processing/effect-composer.js.map +0 -1
- package/dist/threejs-addon/post-processing/mask-pass.d.ts +0 -11
- package/dist/threejs-addon/post-processing/mask-pass.js +0 -69
- package/dist/threejs-addon/post-processing/mask-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/outline-pass.d.ts +0 -58
- package/dist/threejs-addon/post-processing/outline-pass.js +0 -484
- package/dist/threejs-addon/post-processing/outline-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/output-pass.d.ts +0 -11
- package/dist/threejs-addon/post-processing/output-pass.js +0 -61
- package/dist/threejs-addon/post-processing/output-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/pass.d.ts +0 -20
- package/dist/threejs-addon/post-processing/pass.js +0 -48
- package/dist/threejs-addon/post-processing/pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/render-pass.d.ts +0 -13
- package/dist/threejs-addon/post-processing/render-pass.js +0 -50
- package/dist/threejs-addon/post-processing/render-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/sao-pass.d.ts +0 -62
- package/dist/threejs-addon/post-processing/sao-pass.js +0 -296
- package/dist/threejs-addon/post-processing/sao-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/shader-pass.d.ts +0 -11
- package/dist/threejs-addon/post-processing/shader-pass.js +0 -48
- package/dist/threejs-addon/post-processing/shader-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/ssaa-render-pass.d.ts +0 -30
- package/dist/threejs-addon/post-processing/ssaa-render-pass.js +0 -202
- package/dist/threejs-addon/post-processing/ssaa-render-pass.js.map +0 -1
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.d.ts +0 -48
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js +0 -290
- package/dist/threejs-addon/post-processing/unreal-bloom-pass.js.map +0 -1
- package/dist/threejs-addon/shaders/color-correction-shader.d.ts +0 -22
- package/dist/threejs-addon/shaders/color-correction-shader.js +0 -43
- package/dist/threejs-addon/shaders/color-correction-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/copy-shader.d.ts +0 -13
- package/dist/threejs-addon/shaders/copy-shader.js +0 -39
- package/dist/threejs-addon/shaders/copy-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.d.ts +0 -48
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js +0 -142
- package/dist/threejs-addon/shaders/depth-limited-blur-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/fxaa-shader.d.ts +0 -14
- package/dist/threejs-addon/shaders/fxaa-shader.js +0 -279
- package/dist/threejs-addon/shaders/fxaa-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.d.ts +0 -27
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js +0 -56
- package/dist/threejs-addon/shaders/luminosity-high-pass-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/output-shader.d.ts +0 -13
- package/dist/threejs-addon/shaders/output-shader.js +0 -72
- package/dist/threejs-addon/shaders/output-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/sao-shader.d.ts +0 -71
- package/dist/threejs-addon/shaders/sao-shader.js +0 -180
- package/dist/threejs-addon/shaders/sao-shader.js.map +0 -1
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.d.ts +0 -13
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js +0 -41
- package/dist/threejs-addon/shaders/unpack-depth-rgba-shader.js.map +0 -1
- package/dist/threejs-addon/simplify-modifier.d.ts +0 -4
- package/dist/threejs-addon/simplify-modifier.js +0 -325
- package/dist/threejs-addon/simplify-modifier.js.map +0 -1
- package/dist/threejs-addon/stats.js +0 -102
- package/dist/threejs-addon/stats.js.map +0 -1
- package/dist/threejs-addon/transform-control.d.ts +0 -74
- package/dist/threejs-addon/transform-control.js +0 -1033
- package/dist/threejs-addon/transform-control.js.map +0 -1
- package/dist/types.js +0 -145
- package/dist/types.js.map +0 -1
- package/dist/utils/html.js +0 -12
- package/dist/utils/html.js.map +0 -1
- package/dist/utils/index.js +0 -10
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/log.js +0 -14
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/threejs.js +0 -44
- package/dist/utils/threejs.js.map +0 -1
- package/dist/viral-viewer-api.js +0 -73
- package/dist/viral-viewer-api.js.map +0 -1
|
@@ -1,1033 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransformControlsPlane = exports.TransformControlsGizmo = exports.TransformControls = void 0;
|
|
4
|
-
const three_1 = require("three");
|
|
5
|
-
const _raycaster = new three_1.Raycaster();
|
|
6
|
-
const _tempVector = new three_1.Vector3();
|
|
7
|
-
const _tempVector2 = new three_1.Vector3();
|
|
8
|
-
const _tempQuaternion = new three_1.Quaternion();
|
|
9
|
-
const _unit = {
|
|
10
|
-
X: new three_1.Vector3(1, 0, 0),
|
|
11
|
-
Y: new three_1.Vector3(0, 1, 0),
|
|
12
|
-
Z: new three_1.Vector3(0, 0, 1)
|
|
13
|
-
};
|
|
14
|
-
const _changeEvent = { type: 'change' };
|
|
15
|
-
const _mouseDownEvent = { type: 'mouseDown' };
|
|
16
|
-
const _mouseUpEvent = { type: 'mouseUp', mode: null };
|
|
17
|
-
const _objectChangeEvent = { type: 'objectChange' };
|
|
18
|
-
class TransformControls extends three_1.Object3D {
|
|
19
|
-
constructor(camera, domElement) {
|
|
20
|
-
super();
|
|
21
|
-
if (domElement === undefined) {
|
|
22
|
-
console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.');
|
|
23
|
-
domElement = document;
|
|
24
|
-
}
|
|
25
|
-
this.isTransformControls = true;
|
|
26
|
-
this.visible = false;
|
|
27
|
-
this.domElement = domElement;
|
|
28
|
-
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
29
|
-
const _gizmo = new TransformControlsGizmo();
|
|
30
|
-
this._gizmo = _gizmo;
|
|
31
|
-
this.add(_gizmo);
|
|
32
|
-
const _plane = new TransformControlsPlane();
|
|
33
|
-
this._plane = _plane;
|
|
34
|
-
this.add(_plane);
|
|
35
|
-
const scope = this;
|
|
36
|
-
// Defined getter, setter and store for a property
|
|
37
|
-
function defineProperty(propName, defaultValue) {
|
|
38
|
-
let propValue = defaultValue;
|
|
39
|
-
Object.defineProperty(scope, propName, {
|
|
40
|
-
get: function () {
|
|
41
|
-
return propValue !== undefined ? propValue : defaultValue;
|
|
42
|
-
},
|
|
43
|
-
set: function (value) {
|
|
44
|
-
if (propValue !== value) {
|
|
45
|
-
propValue = value;
|
|
46
|
-
_plane[propName] = value;
|
|
47
|
-
_gizmo[propName] = value;
|
|
48
|
-
scope.dispatchEvent({ type: propName + '-changed', value: value });
|
|
49
|
-
scope.dispatchEvent(_changeEvent);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
scope[propName] = defaultValue;
|
|
54
|
-
_plane[propName] = defaultValue;
|
|
55
|
-
_gizmo[propName] = defaultValue;
|
|
56
|
-
}
|
|
57
|
-
// Define properties with getters/setter
|
|
58
|
-
// Setting the defined property will automatically trigger change event
|
|
59
|
-
// Defined properties are passed down to gizmo and plane
|
|
60
|
-
defineProperty('camera', camera);
|
|
61
|
-
defineProperty('object', undefined);
|
|
62
|
-
defineProperty('enabled', true);
|
|
63
|
-
defineProperty('axis', null);
|
|
64
|
-
defineProperty('mode', 'translate');
|
|
65
|
-
defineProperty('translationSnap', null);
|
|
66
|
-
defineProperty('rotationSnap', null);
|
|
67
|
-
defineProperty('scaleSnap', null);
|
|
68
|
-
defineProperty('space', 'world');
|
|
69
|
-
defineProperty('size', 1);
|
|
70
|
-
defineProperty('dragging', false);
|
|
71
|
-
defineProperty('showX', true);
|
|
72
|
-
defineProperty('showY', true);
|
|
73
|
-
defineProperty('showZ', true);
|
|
74
|
-
// Reusable utility variables
|
|
75
|
-
const worldPosition = new three_1.Vector3();
|
|
76
|
-
const worldPositionStart = new three_1.Vector3();
|
|
77
|
-
const worldQuaternion = new three_1.Quaternion();
|
|
78
|
-
const worldQuaternionStart = new three_1.Quaternion();
|
|
79
|
-
const cameraPosition = new three_1.Vector3();
|
|
80
|
-
const cameraQuaternion = new three_1.Quaternion();
|
|
81
|
-
const pointStart = new three_1.Vector3();
|
|
82
|
-
const pointEnd = new three_1.Vector3();
|
|
83
|
-
const rotationAxis = new three_1.Vector3();
|
|
84
|
-
const rotationAngle = 0;
|
|
85
|
-
const eye = new three_1.Vector3();
|
|
86
|
-
// TODO: remove properties unused in plane and gizmo
|
|
87
|
-
defineProperty('worldPosition', worldPosition);
|
|
88
|
-
defineProperty('worldPositionStart', worldPositionStart);
|
|
89
|
-
defineProperty('worldQuaternion', worldQuaternion);
|
|
90
|
-
defineProperty('worldQuaternionStart', worldQuaternionStart);
|
|
91
|
-
defineProperty('cameraPosition', cameraPosition);
|
|
92
|
-
defineProperty('cameraQuaternion', cameraQuaternion);
|
|
93
|
-
defineProperty('pointStart', pointStart);
|
|
94
|
-
defineProperty('pointEnd', pointEnd);
|
|
95
|
-
defineProperty('rotationAxis', rotationAxis);
|
|
96
|
-
defineProperty('rotationAngle', rotationAngle);
|
|
97
|
-
defineProperty('eye', eye);
|
|
98
|
-
this._offset = new three_1.Vector3();
|
|
99
|
-
this._startNorm = new three_1.Vector3();
|
|
100
|
-
this._endNorm = new three_1.Vector3();
|
|
101
|
-
this._cameraScale = new three_1.Vector3();
|
|
102
|
-
this._parentPosition = new three_1.Vector3();
|
|
103
|
-
this._parentQuaternion = new three_1.Quaternion();
|
|
104
|
-
this._parentQuaternionInv = new three_1.Quaternion();
|
|
105
|
-
this._parentScale = new three_1.Vector3();
|
|
106
|
-
this._worldScaleStart = new three_1.Vector3();
|
|
107
|
-
this._worldQuaternionInv = new three_1.Quaternion();
|
|
108
|
-
this._worldScale = new three_1.Vector3();
|
|
109
|
-
this._positionStart = new three_1.Vector3();
|
|
110
|
-
this._quaternionStart = new three_1.Quaternion();
|
|
111
|
-
this._scaleStart = new three_1.Vector3();
|
|
112
|
-
this._getPointer = getPointer.bind(this);
|
|
113
|
-
this._onPointerDown = onPointerDown.bind(this);
|
|
114
|
-
this._onPointerHover = onPointerHover.bind(this);
|
|
115
|
-
this._onPointerMove = onPointerMove.bind(this);
|
|
116
|
-
this._onPointerUp = onPointerUp.bind(this);
|
|
117
|
-
this.domElement.addEventListener('pointerdown', this._onPointerDown);
|
|
118
|
-
this.domElement.addEventListener('pointermove', this._onPointerHover);
|
|
119
|
-
this.domElement.addEventListener('pointerup', this._onPointerUp);
|
|
120
|
-
}
|
|
121
|
-
// updateMatrixWorld updates key transformation variables
|
|
122
|
-
updateMatrixWorld() {
|
|
123
|
-
if (this.object !== undefined) {
|
|
124
|
-
this.object.updateMatrixWorld();
|
|
125
|
-
if (this.object.parent === null) {
|
|
126
|
-
console.error('TransformControls: The attached 3D object must be a part of the scene graph.');
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.object.parent.matrixWorld.decompose(this._parentPosition, this._parentQuaternion, this._parentScale);
|
|
130
|
-
}
|
|
131
|
-
this.object.matrixWorld.decompose(this.worldPosition, this.worldQuaternion, this._worldScale);
|
|
132
|
-
this._parentQuaternionInv.copy(this._parentQuaternion).invert();
|
|
133
|
-
this._worldQuaternionInv.copy(this.worldQuaternion).invert();
|
|
134
|
-
}
|
|
135
|
-
this.camera.updateMatrixWorld();
|
|
136
|
-
this.camera.matrixWorld.decompose(this.cameraPosition, this.cameraQuaternion, this._cameraScale);
|
|
137
|
-
if (this.camera.isOrthographicCamera) {
|
|
138
|
-
this.camera.getWorldDirection(this.eye).negate();
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize();
|
|
142
|
-
}
|
|
143
|
-
super.updateMatrixWorld(this);
|
|
144
|
-
}
|
|
145
|
-
pointerHover(pointer) {
|
|
146
|
-
if (this.object === undefined || this.dragging === true)
|
|
147
|
-
return;
|
|
148
|
-
_raycaster.setFromCamera(pointer, this.camera);
|
|
149
|
-
const intersect = intersectObjectWithRay(this._gizmo.picker[this.mode], _raycaster);
|
|
150
|
-
if (intersect) {
|
|
151
|
-
this.axis = intersect.object.name;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this.axis = null;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
pointerDown(pointer) {
|
|
158
|
-
if (this.object === undefined || this.dragging === true || pointer.button !== 0)
|
|
159
|
-
return;
|
|
160
|
-
if (this.axis !== null) {
|
|
161
|
-
_raycaster.setFromCamera(pointer, this.camera);
|
|
162
|
-
const planeIntersect = intersectObjectWithRay(this._plane, _raycaster, true);
|
|
163
|
-
if (planeIntersect) {
|
|
164
|
-
this.object.updateMatrixWorld();
|
|
165
|
-
this.object.parent.updateMatrixWorld();
|
|
166
|
-
this._positionStart.copy(this.object.position);
|
|
167
|
-
this._quaternionStart.copy(this.object.quaternion);
|
|
168
|
-
this._scaleStart.copy(this.object.scale);
|
|
169
|
-
this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart);
|
|
170
|
-
this.pointStart.copy(planeIntersect.point).sub(this.worldPositionStart);
|
|
171
|
-
}
|
|
172
|
-
this.dragging = true;
|
|
173
|
-
_mouseDownEvent.mode = this.mode;
|
|
174
|
-
this.dispatchEvent(_mouseDownEvent);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
pointerMove(pointer) {
|
|
178
|
-
const axis = this.axis;
|
|
179
|
-
const mode = this.mode;
|
|
180
|
-
const object = this.object;
|
|
181
|
-
let space = this.space;
|
|
182
|
-
if (mode === 'scale') {
|
|
183
|
-
space = 'local';
|
|
184
|
-
}
|
|
185
|
-
else if (axis === 'E' || axis === 'XYZE' || axis === 'XYZ') {
|
|
186
|
-
space = 'world';
|
|
187
|
-
}
|
|
188
|
-
if (object === undefined || axis === null || this.dragging === false || pointer.button !== -1)
|
|
189
|
-
return;
|
|
190
|
-
_raycaster.setFromCamera(pointer, this.camera);
|
|
191
|
-
const planeIntersect = intersectObjectWithRay(this._plane, _raycaster, true);
|
|
192
|
-
if (!planeIntersect)
|
|
193
|
-
return;
|
|
194
|
-
this.pointEnd.copy(planeIntersect.point).sub(this.worldPositionStart);
|
|
195
|
-
if (mode === 'translate') {
|
|
196
|
-
// Apply translate
|
|
197
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
198
|
-
if (space === 'local' && axis !== 'XYZ') {
|
|
199
|
-
this._offset.applyQuaternion(this._worldQuaternionInv);
|
|
200
|
-
}
|
|
201
|
-
if (axis.indexOf('X') === -1)
|
|
202
|
-
this._offset.x = 0;
|
|
203
|
-
if (axis.indexOf('Y') === -1)
|
|
204
|
-
this._offset.y = 0;
|
|
205
|
-
if (axis.indexOf('Z') === -1)
|
|
206
|
-
this._offset.z = 0;
|
|
207
|
-
if (space === 'local' && axis !== 'XYZ') {
|
|
208
|
-
this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale);
|
|
212
|
-
}
|
|
213
|
-
object.position.copy(this._offset).add(this._positionStart);
|
|
214
|
-
// Apply translation snap
|
|
215
|
-
if (this.translationSnap) {
|
|
216
|
-
if (space === 'local') {
|
|
217
|
-
object.position.applyQuaternion(_tempQuaternion.copy(this._quaternionStart).invert());
|
|
218
|
-
if (axis.search('X') !== -1) {
|
|
219
|
-
object.position.x = Math.round(object.position.x / this.translationSnap) * this.translationSnap;
|
|
220
|
-
}
|
|
221
|
-
if (axis.search('Y') !== -1) {
|
|
222
|
-
object.position.y = Math.round(object.position.y / this.translationSnap) * this.translationSnap;
|
|
223
|
-
}
|
|
224
|
-
if (axis.search('Z') !== -1) {
|
|
225
|
-
object.position.z = Math.round(object.position.z / this.translationSnap) * this.translationSnap;
|
|
226
|
-
}
|
|
227
|
-
object.position.applyQuaternion(this._quaternionStart);
|
|
228
|
-
}
|
|
229
|
-
if (space === 'world') {
|
|
230
|
-
if (object.parent) {
|
|
231
|
-
object.position.add(_tempVector.setFromMatrixPosition(object.parent.matrixWorld));
|
|
232
|
-
}
|
|
233
|
-
if (axis.search('X') !== -1) {
|
|
234
|
-
object.position.x = Math.round(object.position.x / this.translationSnap) * this.translationSnap;
|
|
235
|
-
}
|
|
236
|
-
if (axis.search('Y') !== -1) {
|
|
237
|
-
object.position.y = Math.round(object.position.y / this.translationSnap) * this.translationSnap;
|
|
238
|
-
}
|
|
239
|
-
if (axis.search('Z') !== -1) {
|
|
240
|
-
object.position.z = Math.round(object.position.z / this.translationSnap) * this.translationSnap;
|
|
241
|
-
}
|
|
242
|
-
if (object.parent) {
|
|
243
|
-
object.position.sub(_tempVector.setFromMatrixPosition(object.parent.matrixWorld));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else if (mode === 'scale') {
|
|
249
|
-
if (axis.search('XYZ') !== -1) {
|
|
250
|
-
let d = this.pointEnd.length() / this.pointStart.length();
|
|
251
|
-
if (this.pointEnd.dot(this.pointStart) < 0)
|
|
252
|
-
d *= -1;
|
|
253
|
-
_tempVector2.set(d, d, d);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
_tempVector.copy(this.pointStart);
|
|
257
|
-
_tempVector2.copy(this.pointEnd);
|
|
258
|
-
_tempVector.applyQuaternion(this._worldQuaternionInv);
|
|
259
|
-
_tempVector2.applyQuaternion(this._worldQuaternionInv);
|
|
260
|
-
_tempVector2.divide(_tempVector);
|
|
261
|
-
if (axis.search('X') === -1) {
|
|
262
|
-
_tempVector2.x = 1;
|
|
263
|
-
}
|
|
264
|
-
if (axis.search('Y') === -1) {
|
|
265
|
-
_tempVector2.y = 1;
|
|
266
|
-
}
|
|
267
|
-
if (axis.search('Z') === -1) {
|
|
268
|
-
_tempVector2.z = 1;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Apply scale
|
|
272
|
-
object.scale.copy(this._scaleStart).multiply(_tempVector2);
|
|
273
|
-
if (this.scaleSnap) {
|
|
274
|
-
if (axis.search('X') !== -1) {
|
|
275
|
-
object.scale.x = Math.round(object.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
|
|
276
|
-
}
|
|
277
|
-
if (axis.search('Y') !== -1) {
|
|
278
|
-
object.scale.y = Math.round(object.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
|
|
279
|
-
}
|
|
280
|
-
if (axis.search('Z') !== -1) {
|
|
281
|
-
object.scale.z = Math.round(object.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
else if (mode === 'rotate') {
|
|
286
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
287
|
-
const ROTATION_SPEED = 20 / this.worldPosition.distanceTo(_tempVector.setFromMatrixPosition(this.camera.matrixWorld));
|
|
288
|
-
if (axis === 'E') {
|
|
289
|
-
this.rotationAxis.copy(this.eye);
|
|
290
|
-
this.rotationAngle = this.pointEnd.angleTo(this.pointStart);
|
|
291
|
-
this._startNorm.copy(this.pointStart).normalize();
|
|
292
|
-
this._endNorm.copy(this.pointEnd).normalize();
|
|
293
|
-
this.rotationAngle *= (this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1);
|
|
294
|
-
}
|
|
295
|
-
else if (axis === 'XYZE') {
|
|
296
|
-
this.rotationAxis.copy(this._offset).cross(this.eye).normalize();
|
|
297
|
-
this.rotationAngle = this._offset.dot(_tempVector.copy(this.rotationAxis).cross(this.eye)) * ROTATION_SPEED;
|
|
298
|
-
}
|
|
299
|
-
else if (axis === 'X' || axis === 'Y' || axis === 'Z') {
|
|
300
|
-
this.rotationAxis.copy(_unit[axis]);
|
|
301
|
-
_tempVector.copy(_unit[axis]);
|
|
302
|
-
if (space === 'local') {
|
|
303
|
-
_tempVector.applyQuaternion(this.worldQuaternion);
|
|
304
|
-
}
|
|
305
|
-
this.rotationAngle = this._offset.dot(_tempVector.cross(this.eye).normalize()) * ROTATION_SPEED;
|
|
306
|
-
}
|
|
307
|
-
// Apply rotation snap
|
|
308
|
-
if (this.rotationSnap)
|
|
309
|
-
this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap;
|
|
310
|
-
// Apply rotate
|
|
311
|
-
if (space === 'local' && axis !== 'E' && axis !== 'XYZE') {
|
|
312
|
-
object.quaternion.copy(this._quaternionStart);
|
|
313
|
-
object.quaternion.multiply(_tempQuaternion.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize();
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
this.rotationAxis.applyQuaternion(this._parentQuaternionInv);
|
|
317
|
-
object.quaternion.copy(_tempQuaternion.setFromAxisAngle(this.rotationAxis, this.rotationAngle));
|
|
318
|
-
object.quaternion.multiply(this._quaternionStart).normalize();
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
this.dispatchEvent(_changeEvent);
|
|
322
|
-
this.dispatchEvent(_objectChangeEvent);
|
|
323
|
-
}
|
|
324
|
-
pointerUp(pointer) {
|
|
325
|
-
if (pointer.button !== 0)
|
|
326
|
-
return;
|
|
327
|
-
if (this.dragging && (this.axis !== null)) {
|
|
328
|
-
_mouseUpEvent.mode = this.mode;
|
|
329
|
-
this.dispatchEvent(_mouseUpEvent);
|
|
330
|
-
}
|
|
331
|
-
this.dragging = false;
|
|
332
|
-
this.axis = null;
|
|
333
|
-
}
|
|
334
|
-
dispose() {
|
|
335
|
-
this.domElement.removeEventListener('pointerdown', this._onPointerDown);
|
|
336
|
-
this.domElement.removeEventListener('pointermove', this._onPointerHover);
|
|
337
|
-
this.domElement.removeEventListener('pointermove', this._onPointerMove);
|
|
338
|
-
this.domElement.removeEventListener('pointerup', this._onPointerUp);
|
|
339
|
-
this.traverse(function (child) {
|
|
340
|
-
if (child.geometry)
|
|
341
|
-
child.geometry.dispose();
|
|
342
|
-
if (child.material)
|
|
343
|
-
child.material.dispose();
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
// Set current object
|
|
347
|
-
attach(object) {
|
|
348
|
-
this.object = object;
|
|
349
|
-
this.visible = true;
|
|
350
|
-
return this;
|
|
351
|
-
}
|
|
352
|
-
// Detach from object
|
|
353
|
-
detach() {
|
|
354
|
-
this.object = undefined;
|
|
355
|
-
this.visible = false;
|
|
356
|
-
this.axis = null;
|
|
357
|
-
return this;
|
|
358
|
-
}
|
|
359
|
-
reset() {
|
|
360
|
-
if (!this.enabled)
|
|
361
|
-
return;
|
|
362
|
-
if (this.dragging) {
|
|
363
|
-
this.object.position.copy(this._positionStart);
|
|
364
|
-
this.object.quaternion.copy(this._quaternionStart);
|
|
365
|
-
this.object.scale.copy(this._scaleStart);
|
|
366
|
-
this.dispatchEvent(_changeEvent);
|
|
367
|
-
this.dispatchEvent(_objectChangeEvent);
|
|
368
|
-
this.pointStart.copy(this.pointEnd);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
getRaycaster() {
|
|
372
|
-
return _raycaster;
|
|
373
|
-
}
|
|
374
|
-
// TODO: deprecate
|
|
375
|
-
getMode() {
|
|
376
|
-
return this.mode;
|
|
377
|
-
}
|
|
378
|
-
setMode(mode) {
|
|
379
|
-
this.mode = mode;
|
|
380
|
-
}
|
|
381
|
-
setTranslationSnap(translationSnap) {
|
|
382
|
-
this.translationSnap = translationSnap;
|
|
383
|
-
}
|
|
384
|
-
setRotationSnap(rotationSnap) {
|
|
385
|
-
this.rotationSnap = rotationSnap;
|
|
386
|
-
}
|
|
387
|
-
setScaleSnap(scaleSnap) {
|
|
388
|
-
this.scaleSnap = scaleSnap;
|
|
389
|
-
}
|
|
390
|
-
setSize(size) {
|
|
391
|
-
this.size = size;
|
|
392
|
-
}
|
|
393
|
-
setSpace(space) {
|
|
394
|
-
this.space = space;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
exports.TransformControls = TransformControls;
|
|
398
|
-
// mouse / touch event handlers
|
|
399
|
-
function getPointer(event) {
|
|
400
|
-
if (this.domElement.ownerDocument.pointerLockElement) {
|
|
401
|
-
return {
|
|
402
|
-
x: 0,
|
|
403
|
-
y: 0,
|
|
404
|
-
button: event.button
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
const rect = this.domElement.getBoundingClientRect();
|
|
409
|
-
return {
|
|
410
|
-
x: (event.clientX - rect.left) / rect.width * 2 - 1,
|
|
411
|
-
y: -(event.clientY - rect.top) / rect.height * 2 + 1,
|
|
412
|
-
button: event.button
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
function onPointerHover(event) {
|
|
417
|
-
if (!this.enabled)
|
|
418
|
-
return;
|
|
419
|
-
switch (event.pointerType) {
|
|
420
|
-
case 'mouse':
|
|
421
|
-
case 'pen':
|
|
422
|
-
this.pointerHover(this._getPointer(event));
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
function onPointerDown(event) {
|
|
427
|
-
if (!this.enabled)
|
|
428
|
-
return;
|
|
429
|
-
if (!document.pointerLockElement) {
|
|
430
|
-
this.domElement.setPointerCapture(event.pointerId);
|
|
431
|
-
}
|
|
432
|
-
this.domElement.addEventListener('pointermove', this._onPointerMove);
|
|
433
|
-
this.pointerHover(this._getPointer(event));
|
|
434
|
-
this.pointerDown(this._getPointer(event));
|
|
435
|
-
}
|
|
436
|
-
function onPointerMove(event) {
|
|
437
|
-
if (!this.enabled)
|
|
438
|
-
return;
|
|
439
|
-
this.pointerMove(this._getPointer(event));
|
|
440
|
-
}
|
|
441
|
-
function onPointerUp(event) {
|
|
442
|
-
if (!this.enabled)
|
|
443
|
-
return;
|
|
444
|
-
this.domElement.releasePointerCapture(event.pointerId);
|
|
445
|
-
this.domElement.removeEventListener('pointermove', this._onPointerMove);
|
|
446
|
-
this.pointerUp(this._getPointer(event));
|
|
447
|
-
}
|
|
448
|
-
function intersectObjectWithRay(object, raycaster, includeInvisible) {
|
|
449
|
-
const allIntersections = raycaster.intersectObject(object, true);
|
|
450
|
-
for (let i = 0; i < allIntersections.length; i++) {
|
|
451
|
-
if (allIntersections[i].object.visible || includeInvisible) {
|
|
452
|
-
return allIntersections[i];
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
//
|
|
458
|
-
// Reusable utility variables
|
|
459
|
-
const _tempEuler = new three_1.Euler();
|
|
460
|
-
const _alignVector = new three_1.Vector3(0, 1, 0);
|
|
461
|
-
const _zeroVector = new three_1.Vector3(0, 0, 0);
|
|
462
|
-
const _lookAtMatrix = new three_1.Matrix4();
|
|
463
|
-
const _tempQuaternion2 = new three_1.Quaternion();
|
|
464
|
-
const _identityQuaternion = new three_1.Quaternion();
|
|
465
|
-
const _dirVector = new three_1.Vector3();
|
|
466
|
-
const _tempMatrix = new three_1.Matrix4();
|
|
467
|
-
const _unitX = new three_1.Vector3(1, 0, 0);
|
|
468
|
-
const _unitY = new three_1.Vector3(0, 1, 0);
|
|
469
|
-
const _unitZ = new three_1.Vector3(0, 0, 1);
|
|
470
|
-
const _v1 = new three_1.Vector3();
|
|
471
|
-
const _v2 = new three_1.Vector3();
|
|
472
|
-
const _v3 = new three_1.Vector3();
|
|
473
|
-
class TransformControlsGizmo extends three_1.Object3D {
|
|
474
|
-
constructor() {
|
|
475
|
-
super();
|
|
476
|
-
this.isTransformControlsGizmo = true;
|
|
477
|
-
this.type = 'TransformControlsGizmo';
|
|
478
|
-
// shared materials
|
|
479
|
-
const gizmoMaterial = new three_1.MeshBasicMaterial({
|
|
480
|
-
depthTest: false,
|
|
481
|
-
depthWrite: false,
|
|
482
|
-
fog: false,
|
|
483
|
-
toneMapped: false,
|
|
484
|
-
transparent: true
|
|
485
|
-
});
|
|
486
|
-
const gizmoLineMaterial = new three_1.LineBasicMaterial({
|
|
487
|
-
depthTest: false,
|
|
488
|
-
depthWrite: false,
|
|
489
|
-
fog: false,
|
|
490
|
-
toneMapped: false,
|
|
491
|
-
transparent: true
|
|
492
|
-
});
|
|
493
|
-
// Make unique material for each axis/color
|
|
494
|
-
const matInvisible = gizmoMaterial.clone();
|
|
495
|
-
matInvisible.opacity = 0.15;
|
|
496
|
-
const matHelper = gizmoLineMaterial.clone();
|
|
497
|
-
matHelper.opacity = 0.5;
|
|
498
|
-
const matRed = gizmoMaterial.clone();
|
|
499
|
-
matRed.color.setHex(0xff0000);
|
|
500
|
-
const matGreen = gizmoMaterial.clone();
|
|
501
|
-
matGreen.color.setHex(0x00ff00);
|
|
502
|
-
const matBlue = gizmoMaterial.clone();
|
|
503
|
-
matBlue.color.setHex(0x0000ff);
|
|
504
|
-
const matRedTransparent = gizmoMaterial.clone();
|
|
505
|
-
matRedTransparent.color.setHex(0xff0000);
|
|
506
|
-
matRedTransparent.opacity = 0.5;
|
|
507
|
-
const matGreenTransparent = gizmoMaterial.clone();
|
|
508
|
-
matGreenTransparent.color.setHex(0x00ff00);
|
|
509
|
-
matGreenTransparent.opacity = 0.5;
|
|
510
|
-
const matBlueTransparent = gizmoMaterial.clone();
|
|
511
|
-
matBlueTransparent.color.setHex(0x0000ff);
|
|
512
|
-
matBlueTransparent.opacity = 0.5;
|
|
513
|
-
const matWhiteTransparent = gizmoMaterial.clone();
|
|
514
|
-
matWhiteTransparent.opacity = 0.25;
|
|
515
|
-
const matYellowTransparent = gizmoMaterial.clone();
|
|
516
|
-
matYellowTransparent.color.setHex(0xffff00);
|
|
517
|
-
matYellowTransparent.opacity = 0.25;
|
|
518
|
-
const matYellow = gizmoMaterial.clone();
|
|
519
|
-
matYellow.color.setHex(0xffff00);
|
|
520
|
-
const matGray = gizmoMaterial.clone();
|
|
521
|
-
matGray.color.setHex(0x787878);
|
|
522
|
-
// reusable geometry
|
|
523
|
-
const arrowGeometry = new three_1.CylinderGeometry(0, 0.04, 0.1, 12);
|
|
524
|
-
arrowGeometry.translate(0, 0.05, 0);
|
|
525
|
-
const scaleHandleGeometry = new three_1.BoxGeometry(0.08, 0.08, 0.08);
|
|
526
|
-
scaleHandleGeometry.translate(0, 0.04, 0);
|
|
527
|
-
const lineGeometry = new three_1.BufferGeometry();
|
|
528
|
-
lineGeometry.setAttribute('position', new three_1.Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3));
|
|
529
|
-
const lineGeometry2 = new three_1.CylinderGeometry(0.0075, 0.0075, 0.5, 3);
|
|
530
|
-
lineGeometry2.translate(0, 0.25, 0);
|
|
531
|
-
function CircleGeometry(radius, arc) {
|
|
532
|
-
const geometry = new three_1.TorusGeometry(radius, 0.0075, 3, 64, arc * Math.PI * 2);
|
|
533
|
-
geometry.rotateY(Math.PI / 2);
|
|
534
|
-
geometry.rotateX(Math.PI / 2);
|
|
535
|
-
return geometry;
|
|
536
|
-
}
|
|
537
|
-
// Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
|
|
538
|
-
function TranslateHelperGeometry() {
|
|
539
|
-
const geometry = new three_1.BufferGeometry();
|
|
540
|
-
geometry.setAttribute('position', new three_1.Float32BufferAttribute([0, 0, 0, 1, 1, 1], 3));
|
|
541
|
-
return geometry;
|
|
542
|
-
}
|
|
543
|
-
// Gizmo definitions - custom hierarchy definitions for setupGizmo() function
|
|
544
|
-
const gizmoTranslate = {
|
|
545
|
-
X: [
|
|
546
|
-
[new three_1.Mesh(arrowGeometry, matRed), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
547
|
-
[new three_1.Mesh(arrowGeometry, matRed), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
548
|
-
[new three_1.Mesh(lineGeometry2, matRed), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
549
|
-
],
|
|
550
|
-
Y: [
|
|
551
|
-
[new three_1.Mesh(arrowGeometry, matGreen), [0, 0.5, 0]],
|
|
552
|
-
[new three_1.Mesh(arrowGeometry, matGreen), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
553
|
-
[new three_1.Mesh(lineGeometry2, matGreen)]
|
|
554
|
-
],
|
|
555
|
-
Z: [
|
|
556
|
-
[new three_1.Mesh(arrowGeometry, matBlue), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
557
|
-
[new three_1.Mesh(arrowGeometry, matBlue), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
558
|
-
[new three_1.Mesh(lineGeometry2, matBlue), null, [Math.PI / 2, 0, 0]]
|
|
559
|
-
],
|
|
560
|
-
XYZ: [
|
|
561
|
-
[new three_1.Mesh(new three_1.OctahedronGeometry(0.1, 0), matWhiteTransparent.clone()), [0, 0, 0]]
|
|
562
|
-
],
|
|
563
|
-
XY: [
|
|
564
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matBlueTransparent.clone()), [0.15, 0.15, 0]]
|
|
565
|
-
],
|
|
566
|
-
YZ: [
|
|
567
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matRedTransparent.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
568
|
-
],
|
|
569
|
-
XZ: [
|
|
570
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matGreenTransparent.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
571
|
-
]
|
|
572
|
-
};
|
|
573
|
-
const pickerTranslate = {
|
|
574
|
-
X: [
|
|
575
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
576
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
577
|
-
],
|
|
578
|
-
Y: [
|
|
579
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0.3, 0]],
|
|
580
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
581
|
-
],
|
|
582
|
-
Z: [
|
|
583
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
584
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
585
|
-
],
|
|
586
|
-
XYZ: [
|
|
587
|
-
[new three_1.Mesh(new three_1.OctahedronGeometry(0.2, 0), matInvisible)]
|
|
588
|
-
],
|
|
589
|
-
XY: [
|
|
590
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0.15, 0]]
|
|
591
|
-
],
|
|
592
|
-
YZ: [
|
|
593
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
594
|
-
],
|
|
595
|
-
XZ: [
|
|
596
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
597
|
-
]
|
|
598
|
-
};
|
|
599
|
-
const helperTranslate = {
|
|
600
|
-
START: [
|
|
601
|
-
[new three_1.Mesh(new three_1.OctahedronGeometry(0.01, 2), matHelper), null, null, null, 'helper']
|
|
602
|
-
],
|
|
603
|
-
END: [
|
|
604
|
-
[new three_1.Mesh(new three_1.OctahedronGeometry(0.01, 2), matHelper), null, null, null, 'helper']
|
|
605
|
-
],
|
|
606
|
-
DELTA: [
|
|
607
|
-
[new three_1.Line(TranslateHelperGeometry(), matHelper), null, null, null, 'helper']
|
|
608
|
-
],
|
|
609
|
-
X: [
|
|
610
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
611
|
-
],
|
|
612
|
-
Y: [
|
|
613
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], 'helper']
|
|
614
|
-
],
|
|
615
|
-
Z: [
|
|
616
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], 'helper']
|
|
617
|
-
]
|
|
618
|
-
};
|
|
619
|
-
const gizmoRotate = {
|
|
620
|
-
XYZE: [
|
|
621
|
-
[new three_1.Mesh(CircleGeometry(0.5, 1), matGray), null, [0, Math.PI / 2, 0]]
|
|
622
|
-
],
|
|
623
|
-
X: [
|
|
624
|
-
[new three_1.Mesh(CircleGeometry(0.5, 0.5), matRed)]
|
|
625
|
-
],
|
|
626
|
-
Y: [
|
|
627
|
-
[new three_1.Mesh(CircleGeometry(0.5, 0.5), matGreen), null, [0, 0, -Math.PI / 2]]
|
|
628
|
-
],
|
|
629
|
-
Z: [
|
|
630
|
-
[new three_1.Mesh(CircleGeometry(0.5, 0.5), matBlue), null, [0, Math.PI / 2, 0]]
|
|
631
|
-
],
|
|
632
|
-
E: [
|
|
633
|
-
[new three_1.Mesh(CircleGeometry(0.75, 1), matYellowTransparent), null, [0, Math.PI / 2, 0]]
|
|
634
|
-
]
|
|
635
|
-
};
|
|
636
|
-
const helperRotate = {
|
|
637
|
-
AXIS: [
|
|
638
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
639
|
-
]
|
|
640
|
-
};
|
|
641
|
-
const pickerRotate = {
|
|
642
|
-
XYZE: [
|
|
643
|
-
[new three_1.Mesh(new three_1.SphereGeometry(0.25, 10, 8), matInvisible)]
|
|
644
|
-
],
|
|
645
|
-
X: [
|
|
646
|
-
[new three_1.Mesh(new three_1.TorusGeometry(0.5, 0.1, 4, 24), matInvisible), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]],
|
|
647
|
-
],
|
|
648
|
-
Y: [
|
|
649
|
-
[new three_1.Mesh(new three_1.TorusGeometry(0.5, 0.1, 4, 24), matInvisible), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
650
|
-
],
|
|
651
|
-
Z: [
|
|
652
|
-
[new three_1.Mesh(new three_1.TorusGeometry(0.5, 0.1, 4, 24), matInvisible), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
653
|
-
],
|
|
654
|
-
E: [
|
|
655
|
-
[new three_1.Mesh(new three_1.TorusGeometry(0.75, 0.1, 2, 24), matInvisible)]
|
|
656
|
-
]
|
|
657
|
-
};
|
|
658
|
-
const gizmoScale = {
|
|
659
|
-
X: [
|
|
660
|
-
[new three_1.Mesh(scaleHandleGeometry, matRed), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
661
|
-
[new three_1.Mesh(lineGeometry2, matRed), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
662
|
-
[new three_1.Mesh(scaleHandleGeometry, matRed), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
663
|
-
],
|
|
664
|
-
Y: [
|
|
665
|
-
[new three_1.Mesh(scaleHandleGeometry, matGreen), [0, 0.5, 0]],
|
|
666
|
-
[new three_1.Mesh(lineGeometry2, matGreen)],
|
|
667
|
-
[new three_1.Mesh(scaleHandleGeometry, matGreen), [0, -0.5, 0], [0, 0, Math.PI]],
|
|
668
|
-
],
|
|
669
|
-
Z: [
|
|
670
|
-
[new three_1.Mesh(scaleHandleGeometry, matBlue), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
671
|
-
[new three_1.Mesh(lineGeometry2, matBlue), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
672
|
-
[new three_1.Mesh(scaleHandleGeometry, matBlue), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
673
|
-
],
|
|
674
|
-
XY: [
|
|
675
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matBlueTransparent), [0.15, 0.15, 0]]
|
|
676
|
-
],
|
|
677
|
-
YZ: [
|
|
678
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matRedTransparent), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
679
|
-
],
|
|
680
|
-
XZ: [
|
|
681
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.15, 0.15, 0.01), matGreenTransparent), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
682
|
-
],
|
|
683
|
-
XYZ: [
|
|
684
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.1, 0.1, 0.1), matWhiteTransparent.clone())],
|
|
685
|
-
]
|
|
686
|
-
};
|
|
687
|
-
const pickerScale = {
|
|
688
|
-
X: [
|
|
689
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
690
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
691
|
-
],
|
|
692
|
-
Y: [
|
|
693
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0.3, 0]],
|
|
694
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
695
|
-
],
|
|
696
|
-
Z: [
|
|
697
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
698
|
-
[new three_1.Mesh(new three_1.CylinderGeometry(0.2, 0, 0.6, 4), matInvisible), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
699
|
-
],
|
|
700
|
-
XY: [
|
|
701
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0.15, 0]],
|
|
702
|
-
],
|
|
703
|
-
YZ: [
|
|
704
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0, 0.15, 0.15], [0, Math.PI / 2, 0]],
|
|
705
|
-
],
|
|
706
|
-
XZ: [
|
|
707
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.01), matInvisible), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]],
|
|
708
|
-
],
|
|
709
|
-
XYZ: [
|
|
710
|
-
[new three_1.Mesh(new three_1.BoxGeometry(0.2, 0.2, 0.2), matInvisible), [0, 0, 0]],
|
|
711
|
-
]
|
|
712
|
-
};
|
|
713
|
-
const helperScale = {
|
|
714
|
-
X: [
|
|
715
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], 'helper']
|
|
716
|
-
],
|
|
717
|
-
Y: [
|
|
718
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], 'helper']
|
|
719
|
-
],
|
|
720
|
-
Z: [
|
|
721
|
-
[new three_1.Line(lineGeometry, matHelper.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], 'helper']
|
|
722
|
-
]
|
|
723
|
-
};
|
|
724
|
-
// Creates an Object3D with gizmos described in custom hierarchy definition.
|
|
725
|
-
function setupGizmo(gizmoMap) {
|
|
726
|
-
const gizmo = new three_1.Object3D();
|
|
727
|
-
for (const name in gizmoMap) {
|
|
728
|
-
for (let i = gizmoMap[name].length; i--;) {
|
|
729
|
-
const object = gizmoMap[name][i][0].clone();
|
|
730
|
-
const position = gizmoMap[name][i][1];
|
|
731
|
-
const rotation = gizmoMap[name][i][2];
|
|
732
|
-
const scale = gizmoMap[name][i][3];
|
|
733
|
-
const tag = gizmoMap[name][i][4];
|
|
734
|
-
// name and tag properties are essential for picking and updating logic.
|
|
735
|
-
object.name = name;
|
|
736
|
-
object.tag = tag;
|
|
737
|
-
if (position) {
|
|
738
|
-
object.position.set(position[0], position[1], position[2]);
|
|
739
|
-
}
|
|
740
|
-
if (rotation) {
|
|
741
|
-
object.rotation.set(rotation[0], rotation[1], rotation[2]);
|
|
742
|
-
}
|
|
743
|
-
if (scale) {
|
|
744
|
-
object.scale.set(scale[0], scale[1], scale[2]);
|
|
745
|
-
}
|
|
746
|
-
object.updateMatrix();
|
|
747
|
-
const tempGeometry = object.geometry.clone();
|
|
748
|
-
tempGeometry.applyMatrix4(object.matrix);
|
|
749
|
-
object.geometry = tempGeometry;
|
|
750
|
-
object.renderOrder = Infinity;
|
|
751
|
-
object.position.set(0, 0, 0);
|
|
752
|
-
object.rotation.set(0, 0, 0);
|
|
753
|
-
object.scale.set(1, 1, 1);
|
|
754
|
-
gizmo.add(object);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return gizmo;
|
|
758
|
-
}
|
|
759
|
-
// Gizmo creation
|
|
760
|
-
this.gizmo = {};
|
|
761
|
-
this.picker = {};
|
|
762
|
-
this.helper = {};
|
|
763
|
-
this.add(this.gizmo['translate'] = setupGizmo(gizmoTranslate));
|
|
764
|
-
this.add(this.gizmo['rotate'] = setupGizmo(gizmoRotate));
|
|
765
|
-
this.add(this.gizmo['scale'] = setupGizmo(gizmoScale));
|
|
766
|
-
this.add(this.picker['translate'] = setupGizmo(pickerTranslate));
|
|
767
|
-
this.add(this.picker['rotate'] = setupGizmo(pickerRotate));
|
|
768
|
-
this.add(this.picker['scale'] = setupGizmo(pickerScale));
|
|
769
|
-
this.add(this.helper['translate'] = setupGizmo(helperTranslate));
|
|
770
|
-
this.add(this.helper['rotate'] = setupGizmo(helperRotate));
|
|
771
|
-
this.add(this.helper['scale'] = setupGizmo(helperScale));
|
|
772
|
-
// Pickers should be hidden always
|
|
773
|
-
this.picker['translate'].visible = false;
|
|
774
|
-
this.picker['rotate'].visible = false;
|
|
775
|
-
this.picker['scale'].visible = false;
|
|
776
|
-
}
|
|
777
|
-
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
778
|
-
updateMatrixWorld(force) {
|
|
779
|
-
const space = (this.mode === 'scale') ? 'local' : this.space; // scale always oriented to local rotation
|
|
780
|
-
const quaternion = (space === 'local') ? this.worldQuaternion : _identityQuaternion;
|
|
781
|
-
// Show only gizmos for current transform mode
|
|
782
|
-
this.gizmo['translate'].visible = this.mode === 'translate';
|
|
783
|
-
this.gizmo['rotate'].visible = this.mode === 'rotate';
|
|
784
|
-
this.gizmo['scale'].visible = this.mode === 'scale';
|
|
785
|
-
this.helper['translate'].visible = this.mode === 'translate';
|
|
786
|
-
this.helper['rotate'].visible = this.mode === 'rotate';
|
|
787
|
-
this.helper['scale'].visible = this.mode === 'scale';
|
|
788
|
-
let handles = [];
|
|
789
|
-
handles = handles.concat(this.picker[this.mode].children);
|
|
790
|
-
handles = handles.concat(this.gizmo[this.mode].children);
|
|
791
|
-
handles = handles.concat(this.helper[this.mode].children);
|
|
792
|
-
for (let i = 0; i < handles.length; i++) {
|
|
793
|
-
const handle = handles[i];
|
|
794
|
-
// hide aligned to camera
|
|
795
|
-
handle.visible = true;
|
|
796
|
-
handle.rotation.set(0, 0, 0);
|
|
797
|
-
handle.position.copy(this.worldPosition);
|
|
798
|
-
let factor;
|
|
799
|
-
if (this.camera.isOrthographicCamera) {
|
|
800
|
-
factor = (this.camera.top - this.camera.bottom) / this.camera.zoom;
|
|
801
|
-
}
|
|
802
|
-
else {
|
|
803
|
-
factor = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7);
|
|
804
|
-
}
|
|
805
|
-
handle.scale.set(1, 1, 1).multiplyScalar(factor * this.size / 4);
|
|
806
|
-
// TODO: simplify helpers and consider decoupling from gizmo
|
|
807
|
-
if (handle.tag === 'helper') {
|
|
808
|
-
handle.visible = false;
|
|
809
|
-
if (handle.name === 'AXIS') {
|
|
810
|
-
handle.visible = !!this.axis;
|
|
811
|
-
if (this.axis === 'X') {
|
|
812
|
-
_tempQuaternion.setFromEuler(_tempEuler.set(0, 0, 0));
|
|
813
|
-
handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
|
|
814
|
-
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
815
|
-
handle.visible = false;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
if (this.axis === 'Y') {
|
|
819
|
-
_tempQuaternion.setFromEuler(_tempEuler.set(0, 0, Math.PI / 2));
|
|
820
|
-
handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
|
|
821
|
-
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
822
|
-
handle.visible = false;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
if (this.axis === 'Z') {
|
|
826
|
-
_tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
|
|
827
|
-
handle.quaternion.copy(quaternion).multiply(_tempQuaternion);
|
|
828
|
-
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) > 0.9) {
|
|
829
|
-
handle.visible = false;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
if (this.axis === 'XYZE') {
|
|
833
|
-
_tempQuaternion.setFromEuler(_tempEuler.set(0, Math.PI / 2, 0));
|
|
834
|
-
_alignVector.copy(this.rotationAxis);
|
|
835
|
-
handle.quaternion.setFromRotationMatrix(_lookAtMatrix.lookAt(_zeroVector, _alignVector, _unitY));
|
|
836
|
-
handle.quaternion.multiply(_tempQuaternion);
|
|
837
|
-
handle.visible = this.dragging;
|
|
838
|
-
}
|
|
839
|
-
if (this.axis === 'E') {
|
|
840
|
-
handle.visible = false;
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
else if (handle.name === 'START') {
|
|
844
|
-
handle.position.copy(this.worldPositionStart);
|
|
845
|
-
handle.visible = this.dragging;
|
|
846
|
-
}
|
|
847
|
-
else if (handle.name === 'END') {
|
|
848
|
-
handle.position.copy(this.worldPosition);
|
|
849
|
-
handle.visible = this.dragging;
|
|
850
|
-
}
|
|
851
|
-
else if (handle.name === 'DELTA') {
|
|
852
|
-
handle.position.copy(this.worldPositionStart);
|
|
853
|
-
handle.quaternion.copy(this.worldQuaternionStart);
|
|
854
|
-
_tempVector.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1);
|
|
855
|
-
_tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert());
|
|
856
|
-
handle.scale.copy(_tempVector);
|
|
857
|
-
handle.visible = this.dragging;
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
handle.quaternion.copy(quaternion);
|
|
861
|
-
if (this.dragging) {
|
|
862
|
-
handle.position.copy(this.worldPositionStart);
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
handle.position.copy(this.worldPosition);
|
|
866
|
-
}
|
|
867
|
-
if (this.axis) {
|
|
868
|
-
handle.visible = this.axis.search(handle.name) !== -1;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
// If updating helper, skip rest of the loop
|
|
872
|
-
continue;
|
|
873
|
-
}
|
|
874
|
-
// Align handles to current local or world rotation
|
|
875
|
-
handle.quaternion.copy(quaternion);
|
|
876
|
-
if (this.mode === 'translate' || this.mode === 'scale') {
|
|
877
|
-
// Hide translate and scale axis facing the camera
|
|
878
|
-
const AXIS_HIDE_THRESHOLD = 0.99;
|
|
879
|
-
const PLANE_HIDE_THRESHOLD = 0.2;
|
|
880
|
-
if (handle.name === 'X') {
|
|
881
|
-
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_THRESHOLD) {
|
|
882
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
883
|
-
handle.visible = false;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
if (handle.name === 'Y') {
|
|
887
|
-
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_THRESHOLD) {
|
|
888
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
889
|
-
handle.visible = false;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
if (handle.name === 'Z') {
|
|
893
|
-
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) > AXIS_HIDE_THRESHOLD) {
|
|
894
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
895
|
-
handle.visible = false;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
if (handle.name === 'XY') {
|
|
899
|
-
if (Math.abs(_alignVector.copy(_unitZ).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_THRESHOLD) {
|
|
900
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
901
|
-
handle.visible = false;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
if (handle.name === 'YZ') {
|
|
905
|
-
if (Math.abs(_alignVector.copy(_unitX).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_THRESHOLD) {
|
|
906
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
907
|
-
handle.visible = false;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
if (handle.name === 'XZ') {
|
|
911
|
-
if (Math.abs(_alignVector.copy(_unitY).applyQuaternion(quaternion).dot(this.eye)) < PLANE_HIDE_THRESHOLD) {
|
|
912
|
-
handle.scale.set(1e-10, 1e-10, 1e-10);
|
|
913
|
-
handle.visible = false;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
else if (this.mode === 'rotate') {
|
|
918
|
-
// Align handles to current local or world rotation
|
|
919
|
-
_tempQuaternion2.copy(quaternion);
|
|
920
|
-
_alignVector.copy(this.eye).applyQuaternion(_tempQuaternion.copy(quaternion).invert());
|
|
921
|
-
if (handle.name.search('E') !== -1) {
|
|
922
|
-
handle.quaternion.setFromRotationMatrix(_lookAtMatrix.lookAt(this.eye, _zeroVector, _unitY));
|
|
923
|
-
}
|
|
924
|
-
if (handle.name === 'X') {
|
|
925
|
-
_tempQuaternion.setFromAxisAngle(_unitX, Math.atan2(-_alignVector.y, _alignVector.z));
|
|
926
|
-
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
927
|
-
handle.quaternion.copy(_tempQuaternion);
|
|
928
|
-
}
|
|
929
|
-
if (handle.name === 'Y') {
|
|
930
|
-
_tempQuaternion.setFromAxisAngle(_unitY, Math.atan2(_alignVector.x, _alignVector.z));
|
|
931
|
-
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
932
|
-
handle.quaternion.copy(_tempQuaternion);
|
|
933
|
-
}
|
|
934
|
-
if (handle.name === 'Z') {
|
|
935
|
-
_tempQuaternion.setFromAxisAngle(_unitZ, Math.atan2(_alignVector.y, _alignVector.x));
|
|
936
|
-
_tempQuaternion.multiplyQuaternions(_tempQuaternion2, _tempQuaternion);
|
|
937
|
-
handle.quaternion.copy(_tempQuaternion);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
// Hide disabled axes
|
|
941
|
-
handle.visible = handle.visible && (handle.name.indexOf('X') === -1 || this.showX);
|
|
942
|
-
handle.visible = handle.visible && (handle.name.indexOf('Y') === -1 || this.showY);
|
|
943
|
-
handle.visible = handle.visible && (handle.name.indexOf('Z') === -1 || this.showZ);
|
|
944
|
-
handle.visible = handle.visible && (handle.name.indexOf('E') === -1 || (this.showX && this.showY && this.showZ));
|
|
945
|
-
// highlight selected axis
|
|
946
|
-
handle.material._color = handle.material._color || handle.material.color.clone();
|
|
947
|
-
handle.material._opacity = handle.material._opacity || handle.material.opacity;
|
|
948
|
-
handle.material.color.copy(handle.material._color);
|
|
949
|
-
handle.material.opacity = handle.material._opacity;
|
|
950
|
-
if (this.enabled && this.axis) {
|
|
951
|
-
if (handle.name === this.axis) {
|
|
952
|
-
handle.material.color.setHex(0xffff00);
|
|
953
|
-
handle.material.opacity = 1.0;
|
|
954
|
-
}
|
|
955
|
-
else if (this.axis.split('').some(function (a) {
|
|
956
|
-
return handle.name === a;
|
|
957
|
-
})) {
|
|
958
|
-
handle.material.color.setHex(0xffff00);
|
|
959
|
-
handle.material.opacity = 1.0;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
super.updateMatrixWorld(force);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
exports.TransformControlsGizmo = TransformControlsGizmo;
|
|
967
|
-
//
|
|
968
|
-
class TransformControlsPlane extends three_1.Mesh {
|
|
969
|
-
constructor() {
|
|
970
|
-
super(new three_1.PlaneGeometry(100000, 100000, 2, 2), new three_1.MeshBasicMaterial({ visible: false, wireframe: true, side: three_1.DoubleSide, transparent: true, opacity: 0.1, toneMapped: false }));
|
|
971
|
-
this.isTransformControlsPlane = true;
|
|
972
|
-
this.type = 'TransformControlsPlane';
|
|
973
|
-
}
|
|
974
|
-
updateMatrixWorld(force) {
|
|
975
|
-
let space = this.space;
|
|
976
|
-
this.position.copy(this.worldPosition);
|
|
977
|
-
if (this.mode === 'scale')
|
|
978
|
-
space = 'local'; // scale always oriented to local rotation
|
|
979
|
-
_v1.copy(_unitX).applyQuaternion(space === 'local' ? this.worldQuaternion : _identityQuaternion);
|
|
980
|
-
_v2.copy(_unitY).applyQuaternion(space === 'local' ? this.worldQuaternion : _identityQuaternion);
|
|
981
|
-
_v3.copy(_unitZ).applyQuaternion(space === 'local' ? this.worldQuaternion : _identityQuaternion);
|
|
982
|
-
// Align the plane for current transform mode, axis and space.
|
|
983
|
-
_alignVector.copy(_v2);
|
|
984
|
-
switch (this.mode) {
|
|
985
|
-
case 'translate':
|
|
986
|
-
case 'scale':
|
|
987
|
-
switch (this.axis) {
|
|
988
|
-
case 'X':
|
|
989
|
-
_alignVector.copy(this.eye).cross(_v1);
|
|
990
|
-
_dirVector.copy(_v1).cross(_alignVector);
|
|
991
|
-
break;
|
|
992
|
-
case 'Y':
|
|
993
|
-
_alignVector.copy(this.eye).cross(_v2);
|
|
994
|
-
_dirVector.copy(_v2).cross(_alignVector);
|
|
995
|
-
break;
|
|
996
|
-
case 'Z':
|
|
997
|
-
_alignVector.copy(this.eye).cross(_v3);
|
|
998
|
-
_dirVector.copy(_v3).cross(_alignVector);
|
|
999
|
-
break;
|
|
1000
|
-
case 'XY':
|
|
1001
|
-
_dirVector.copy(_v3);
|
|
1002
|
-
break;
|
|
1003
|
-
case 'YZ':
|
|
1004
|
-
_dirVector.copy(_v1);
|
|
1005
|
-
break;
|
|
1006
|
-
case 'XZ':
|
|
1007
|
-
_alignVector.copy(_v3);
|
|
1008
|
-
_dirVector.copy(_v2);
|
|
1009
|
-
break;
|
|
1010
|
-
case 'XYZ':
|
|
1011
|
-
case 'E':
|
|
1012
|
-
_dirVector.set(0, 0, 0);
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
break;
|
|
1016
|
-
case 'rotate':
|
|
1017
|
-
default:
|
|
1018
|
-
// special case for rotate
|
|
1019
|
-
_dirVector.set(0, 0, 0);
|
|
1020
|
-
}
|
|
1021
|
-
if (_dirVector.length() === 0) {
|
|
1022
|
-
// If in rotate mode, make the plane parallel to camera
|
|
1023
|
-
this.quaternion.copy(this.cameraQuaternion);
|
|
1024
|
-
}
|
|
1025
|
-
else {
|
|
1026
|
-
_tempMatrix.lookAt(_tempVector.set(0, 0, 0), _dirVector, _alignVector);
|
|
1027
|
-
this.quaternion.setFromRotationMatrix(_tempMatrix);
|
|
1028
|
-
}
|
|
1029
|
-
super.updateMatrixWorld(force);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
exports.TransformControlsPlane = TransformControlsPlane;
|
|
1033
|
-
//# sourceMappingURL=transform-control.js.map
|