@plastic-software/three 0.167.0 → 0.167.2
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/build/three.cjs +6 -16
- package/build/three.module.js +6 -21
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +510 -354
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/controls/Controls.js +32 -0
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/package.json +1 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/nodes/Nodes.js +3 -2
- package/src/nodes/accessors/BatchNode.js +2 -2
- package/src/nodes/accessors/ClippingNode.js +8 -8
- package/src/nodes/accessors/MorphNode.js +4 -4
- package/src/nodes/accessors/TangentNode.js +2 -2
- package/src/nodes/accessors/Texture3DNode.js +8 -8
- package/src/nodes/accessors/UniformArrayNode.js +5 -3
- package/src/nodes/core/StackNode.js +22 -6
- package/src/nodes/display/AfterImageNode.js +3 -3
- package/src/nodes/display/AnamorphicNode.js +4 -4
- package/src/nodes/display/BleachBypassNode.js +2 -2
- package/src/nodes/display/BlendModeNode.js +8 -8
- package/src/nodes/display/BloomNode.js +9 -9
- package/src/nodes/display/BumpMapNode.js +3 -3
- package/src/nodes/display/ColorAdjustmentNode.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/DenoiseNode.js +8 -8
- package/src/nodes/display/DepthOfFieldNode.js +2 -2
- package/src/nodes/display/DotScreenNode.js +3 -3
- package/src/nodes/display/FXAANode.js +11 -11
- package/src/nodes/display/FilmNode.js +2 -2
- package/src/nodes/display/GTAONode.js +9 -9
- package/src/nodes/display/GaussianBlurNode.js +2 -2
- package/src/nodes/display/Lut3DNode.js +2 -2
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +71 -3
- package/src/nodes/display/PixelationPassNode.js +3 -3
- package/src/nodes/display/RGBShiftNode.js +2 -2
- package/src/nodes/display/SepiaNode.js +2 -2
- package/src/nodes/display/SobelOperatorNode.js +2 -2
- package/src/nodes/display/ToneMappingNode.js +13 -13
- package/src/nodes/display/TransitionNode.js +3 -3
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +2 -2
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +18 -18
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/lighting/AnalyticLightNode.js +5 -5
- package/src/nodes/lighting/BasicEnvironmentNode.js +2 -1
- package/src/nodes/lighting/LightProbeNode.js +80 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
- package/src/nodes/materials/Line2NodeMaterial.js +17 -17
- package/src/nodes/materials/MeshPhysicalNodeMaterial.js +1 -1
- package/src/nodes/materials/VolumeNodeMaterial.js +5 -5
- package/src/nodes/materialx/lib/mx_hsv.js +12 -12
- package/src/nodes/materialx/lib/mx_noise.js +80 -80
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/CondNode.js +13 -2
- package/src/nodes/math/MathNode.js +2 -2
- package/src/nodes/math/TriNoise3D.js +6 -6
- package/src/nodes/pmrem/PMREMUtils.js +34 -34
- package/src/nodes/procedural/CheckerNode.js +2 -2
- package/src/nodes/shadernode/ShaderNode.js +11 -4
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/LoopNode.js +10 -4
- package/src/nodes/utils/SpriteUtils.js +2 -2
- package/src/nodes/utils/UVUtils.js +3 -3
- package/src/nodes/utils/ViewportUtils.js +3 -3
- package/src/renderers/WebGLRenderer.js +8 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderObject.js +1 -1
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +0 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +0 -2
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl-fallback/WebGLBackend.js +31 -27
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +12 -8
- package/src/renderers/webgpu/WebGPUBackend.js +10 -14
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +30 -2
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EventDispatcher } from 'three';
|
|
2
|
+
|
|
3
|
+
class Controls extends EventDispatcher {
|
|
4
|
+
|
|
5
|
+
constructor( object, domElement ) {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.object = object;
|
|
10
|
+
this.domElement = domElement;
|
|
11
|
+
|
|
12
|
+
this.enabled = true;
|
|
13
|
+
|
|
14
|
+
this.state = - 1;
|
|
15
|
+
|
|
16
|
+
this.keys = {};
|
|
17
|
+
this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
|
|
18
|
+
this.touches = { ONE: null, TWO: null };
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
connect() {}
|
|
23
|
+
|
|
24
|
+
disconnect() {}
|
|
25
|
+
|
|
26
|
+
dispose() {}
|
|
27
|
+
|
|
28
|
+
update() {}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Controls };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EventDispatcher,
|
|
3
2
|
Matrix4,
|
|
4
3
|
Plane,
|
|
5
4
|
Raycaster,
|
|
6
5
|
Vector2,
|
|
7
|
-
Vector3
|
|
6
|
+
Vector3,
|
|
7
|
+
MOUSE,
|
|
8
|
+
TOUCH
|
|
8
9
|
} from 'three';
|
|
10
|
+
import { Controls } from './Controls.js';
|
|
9
11
|
|
|
10
12
|
const _plane = new Plane();
|
|
11
|
-
const _raycaster = new Raycaster();
|
|
12
13
|
|
|
13
14
|
const _pointer = new Vector2();
|
|
14
15
|
const _offset = new Vector3();
|
|
@@ -21,262 +22,389 @@ const _inverseMatrix = new Matrix4();
|
|
|
21
22
|
const _up = new Vector3();
|
|
22
23
|
const _right = new Vector3();
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
let _selected = null, _hovered = null;
|
|
26
|
+
const _intersections = [];
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
const STATE = {
|
|
29
|
+
NONE: - 1,
|
|
30
|
+
PAN: 0,
|
|
31
|
+
ROTATE: 1
|
|
32
|
+
};
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
class DragControls extends Controls {
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
constructor( objects, camera, domElement = null ) {
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
super( camera, domElement );
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.mode = 'translate';
|
|
40
|
+
this.objects = objects;
|
|
37
41
|
|
|
42
|
+
this.recursive = true;
|
|
43
|
+
this.transformGroup = false;
|
|
38
44
|
this.rotateSpeed = 1;
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
this.raycaster = new Raycaster();
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
// interaction
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
this.mouseButtons = { LEFT: MOUSE.PAN, MIDDLE: MOUSE.PAN, RIGHT: MOUSE.ROTATE };
|
|
51
|
+
this.touches = { ONE: TOUCH.PAN };
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
_domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
48
|
-
_domElement.addEventListener( 'pointerup', onPointerCancel );
|
|
49
|
-
_domElement.addEventListener( 'pointerleave', onPointerCancel );
|
|
53
|
+
// event listeners
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
this._onPointerMove = onPointerMove.bind( this );
|
|
56
|
+
this._onPointerDown = onPointerDown.bind( this );
|
|
57
|
+
this._onPointerCancel = onPointerCancel.bind( this );
|
|
58
|
+
this._onContextMenu = onContextMenu.bind( this );
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
//
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
_domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
57
|
-
_domElement.removeEventListener( 'pointerup', onPointerCancel );
|
|
58
|
-
_domElement.removeEventListener( 'pointerleave', onPointerCancel );
|
|
62
|
+
if ( domElement !== null ) {
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
this.connect();
|
|
61
65
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
}
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
connect() {
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
this.domElement.addEventListener( 'pointermove', this._onPointerMove );
|
|
73
|
+
this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
|
|
74
|
+
this.domElement.addEventListener( 'pointerup', this._onPointerCancel );
|
|
75
|
+
this.domElement.addEventListener( 'pointerleave', this._onPointerCancel );
|
|
76
|
+
this.domElement.addEventListener( 'contextmenu', this._onContextMenu );
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
71
79
|
|
|
72
|
-
|
|
80
|
+
}
|
|
73
81
|
|
|
74
|
-
|
|
82
|
+
disconnect() {
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
|
|
85
|
+
this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
|
|
86
|
+
this.domElement.removeEventListener( 'pointerup', this._onPointerCancel );
|
|
87
|
+
this.domElement.removeEventListener( 'pointerleave', this._onPointerCancel );
|
|
88
|
+
this.domElement.removeEventListener( 'contextmenu', this._onContextMenu );
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
this.domElement.style.touchAction = 'auto';
|
|
91
|
+
this.domElement.style.cursor = '';
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
dispose() {
|
|
96
|
+
|
|
97
|
+
this.disconnect();
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_updatePointer( event ) {
|
|
102
|
+
|
|
103
|
+
const rect = this.domElement.getBoundingClientRect();
|
|
104
|
+
|
|
105
|
+
_pointer.x = ( event.clientX - rect.left ) / rect.width * 2 - 1;
|
|
106
|
+
_pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_updateState( event ) {
|
|
111
|
+
|
|
112
|
+
// determine action
|
|
113
|
+
|
|
114
|
+
let action;
|
|
115
|
+
|
|
116
|
+
if ( event.pointerType === 'touch' ) {
|
|
81
117
|
|
|
82
|
-
|
|
118
|
+
action = this.touches.ONE;
|
|
83
119
|
|
|
84
|
-
|
|
120
|
+
} else {
|
|
121
|
+
|
|
122
|
+
switch ( event.button ) {
|
|
123
|
+
|
|
124
|
+
case 0:
|
|
125
|
+
|
|
126
|
+
action = this.mouseButtons.LEFT;
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 1:
|
|
130
|
+
|
|
131
|
+
action = this.mouseButtons.MIDDLE;
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case 2:
|
|
135
|
+
|
|
136
|
+
action = this.mouseButtons.RIGHT;
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
|
|
141
|
+
action = null;
|
|
142
|
+
|
|
143
|
+
}
|
|
85
144
|
|
|
86
145
|
}
|
|
87
146
|
|
|
88
|
-
|
|
147
|
+
// determine state
|
|
89
148
|
|
|
90
|
-
|
|
149
|
+
switch ( action ) {
|
|
91
150
|
|
|
92
|
-
|
|
151
|
+
case MOUSE.PAN:
|
|
152
|
+
case TOUCH.PAN:
|
|
93
153
|
|
|
94
|
-
|
|
154
|
+
this.state = STATE.PAN;
|
|
95
155
|
|
|
96
|
-
|
|
156
|
+
break;
|
|
97
157
|
|
|
98
|
-
|
|
158
|
+
case MOUSE.ROTATE:
|
|
159
|
+
case TOUCH.ROTATE:
|
|
99
160
|
|
|
100
|
-
|
|
161
|
+
this.state = STATE.ROTATE;
|
|
101
162
|
|
|
102
|
-
|
|
163
|
+
break;
|
|
103
164
|
|
|
104
|
-
|
|
165
|
+
default:
|
|
105
166
|
|
|
106
|
-
|
|
167
|
+
this.state = STATE.NONE;
|
|
107
168
|
|
|
108
|
-
|
|
109
|
-
_selected.rotateOnWorldAxis( _up, _diff.x );
|
|
110
|
-
_selected.rotateOnWorldAxis( _right.normalize(), - _diff.y );
|
|
169
|
+
}
|
|
111
170
|
|
|
112
|
-
|
|
171
|
+
}
|
|
113
172
|
|
|
114
|
-
|
|
173
|
+
getRaycaster() {
|
|
115
174
|
|
|
116
|
-
|
|
175
|
+
console.warn( 'THREE.DragControls: getRaycaster() has been deprecated. Use controls.raycaster instead.' ); // @deprecated r169
|
|
117
176
|
|
|
118
|
-
|
|
177
|
+
return this.raycaster;
|
|
178
|
+
|
|
179
|
+
}
|
|
119
180
|
|
|
120
|
-
|
|
181
|
+
setObjects( objects ) {
|
|
121
182
|
|
|
122
|
-
|
|
183
|
+
console.warn( 'THREE.DragControls: setObjects() has been deprecated. Use controls.objects instead.' ); // @deprecated r169
|
|
123
184
|
|
|
124
|
-
|
|
185
|
+
this.objects = objects;
|
|
125
186
|
|
|
126
|
-
|
|
127
|
-
_raycaster.intersectObjects( _objects, scope.recursive, _intersections );
|
|
187
|
+
}
|
|
128
188
|
|
|
129
|
-
|
|
189
|
+
getObjects() {
|
|
130
190
|
|
|
131
|
-
|
|
191
|
+
console.warn( 'THREE.DragControls: getObjects() has been deprecated. Use controls.objects instead.' ); // @deprecated r169
|
|
132
192
|
|
|
133
|
-
|
|
193
|
+
return this.objects;
|
|
134
194
|
|
|
135
|
-
|
|
195
|
+
}
|
|
136
196
|
|
|
137
|
-
|
|
197
|
+
activate() {
|
|
138
198
|
|
|
139
|
-
|
|
140
|
-
|
|
199
|
+
console.warn( 'THREE.DragControls: activate() has been renamed to connect().' ); // @deprecated r169
|
|
200
|
+
this.connect();
|
|
141
201
|
|
|
142
|
-
|
|
202
|
+
}
|
|
143
203
|
|
|
144
|
-
|
|
204
|
+
deactivate() {
|
|
145
205
|
|
|
146
|
-
|
|
206
|
+
console.warn( 'THREE.DragControls: deactivate() has been renamed to disconnect().' ); // @deprecated r169
|
|
207
|
+
this.disconnect();
|
|
147
208
|
|
|
148
|
-
|
|
149
|
-
_hovered = object;
|
|
209
|
+
}
|
|
150
210
|
|
|
151
|
-
|
|
211
|
+
set mode( value ) {
|
|
152
212
|
|
|
153
|
-
|
|
213
|
+
console.warn( 'THREE.DragControls: The .mode property has been removed. Define the type of transformation via the .mouseButtons or .touches properties.' ); // @deprecated r169
|
|
154
214
|
|
|
155
|
-
|
|
215
|
+
}
|
|
156
216
|
|
|
157
|
-
|
|
217
|
+
get mode() {
|
|
158
218
|
|
|
159
|
-
|
|
160
|
-
_hovered = null;
|
|
219
|
+
console.warn( 'THREE.DragControls: The .mode property has been removed. Define the type of transformation via the .mouseButtons or .touches properties.' ); // @deprecated r169
|
|
161
220
|
|
|
162
|
-
|
|
221
|
+
}
|
|
163
222
|
|
|
164
|
-
|
|
223
|
+
}
|
|
165
224
|
|
|
166
|
-
|
|
225
|
+
function onPointerMove( event ) {
|
|
226
|
+
|
|
227
|
+
const camera = this.object;
|
|
228
|
+
const domElement = this.domElement;
|
|
229
|
+
const raycaster = this.raycaster;
|
|
230
|
+
|
|
231
|
+
if ( this.enabled === false ) return;
|
|
232
|
+
|
|
233
|
+
this._updatePointer( event );
|
|
234
|
+
|
|
235
|
+
raycaster.setFromCamera( _pointer, camera );
|
|
236
|
+
|
|
237
|
+
if ( _selected ) {
|
|
238
|
+
|
|
239
|
+
if ( this.state === STATE.PAN ) {
|
|
240
|
+
|
|
241
|
+
if ( raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
|
242
|
+
|
|
243
|
+
_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
|
|
167
244
|
|
|
168
245
|
}
|
|
169
246
|
|
|
170
|
-
|
|
247
|
+
} else if ( this.state === STATE.ROTATE ) {
|
|
248
|
+
|
|
249
|
+
_diff.subVectors( _pointer, _previousPointer ).multiplyScalar( this.rotateSpeed );
|
|
250
|
+
_selected.rotateOnWorldAxis( _up, _diff.x );
|
|
251
|
+
_selected.rotateOnWorldAxis( _right.normalize(), - _diff.y );
|
|
171
252
|
|
|
172
253
|
}
|
|
173
254
|
|
|
174
|
-
|
|
255
|
+
this.dispatchEvent( { type: 'drag', object: _selected } );
|
|
256
|
+
|
|
257
|
+
_previousPointer.copy( _pointer );
|
|
175
258
|
|
|
176
|
-
|
|
259
|
+
} else {
|
|
177
260
|
|
|
178
|
-
|
|
261
|
+
// hover support
|
|
262
|
+
|
|
263
|
+
if ( event.pointerType === 'mouse' || event.pointerType === 'pen' ) {
|
|
179
264
|
|
|
180
265
|
_intersections.length = 0;
|
|
181
266
|
|
|
182
|
-
|
|
183
|
-
|
|
267
|
+
raycaster.setFromCamera( _pointer, camera );
|
|
268
|
+
raycaster.intersectObjects( this.objects, this.recursive, _intersections );
|
|
184
269
|
|
|
185
270
|
if ( _intersections.length > 0 ) {
|
|
186
271
|
|
|
187
|
-
|
|
272
|
+
const object = _intersections[ 0 ].object;
|
|
188
273
|
|
|
189
|
-
|
|
274
|
+
_plane.setFromNormalAndCoplanarPoint( camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
|
|
190
275
|
|
|
191
|
-
|
|
276
|
+
if ( _hovered !== object && _hovered !== null ) {
|
|
192
277
|
|
|
193
|
-
|
|
278
|
+
this.dispatchEvent( { type: 'hoveroff', object: _hovered } );
|
|
194
279
|
|
|
195
|
-
|
|
280
|
+
domElement.style.cursor = 'auto';
|
|
281
|
+
_hovered = null;
|
|
196
282
|
|
|
197
283
|
}
|
|
198
284
|
|
|
199
|
-
|
|
285
|
+
if ( _hovered !== object ) {
|
|
200
286
|
|
|
201
|
-
|
|
287
|
+
this.dispatchEvent( { type: 'hoveron', object: object } );
|
|
202
288
|
|
|
203
|
-
|
|
289
|
+
domElement.style.cursor = 'pointer';
|
|
290
|
+
_hovered = object;
|
|
204
291
|
|
|
205
|
-
|
|
206
|
-
_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
|
|
292
|
+
}
|
|
207
293
|
|
|
208
|
-
|
|
294
|
+
} else {
|
|
209
295
|
|
|
210
|
-
|
|
211
|
-
_up.set( 0, 1, 0 ).applyQuaternion( _camera.quaternion ).normalize();
|
|
212
|
-
_right.set( 1, 0, 0 ).applyQuaternion( _camera.quaternion ).normalize();
|
|
296
|
+
if ( _hovered !== null ) {
|
|
213
297
|
|
|
214
|
-
}
|
|
298
|
+
this.dispatchEvent( { type: 'hoveroff', object: _hovered } );
|
|
299
|
+
|
|
300
|
+
domElement.style.cursor = 'auto';
|
|
301
|
+
_hovered = null;
|
|
215
302
|
|
|
216
303
|
}
|
|
217
304
|
|
|
218
|
-
|
|
305
|
+
}
|
|
219
306
|
|
|
220
|
-
|
|
307
|
+
}
|
|
221
308
|
|
|
222
|
-
|
|
309
|
+
}
|
|
223
310
|
|
|
224
|
-
|
|
311
|
+
_previousPointer.copy( _pointer );
|
|
225
312
|
|
|
226
|
-
|
|
313
|
+
}
|
|
227
314
|
|
|
228
|
-
|
|
315
|
+
function onPointerDown( event ) {
|
|
229
316
|
|
|
230
|
-
|
|
317
|
+
const camera = this.object;
|
|
318
|
+
const domElement = this.domElement;
|
|
319
|
+
const raycaster = this.raycaster;
|
|
231
320
|
|
|
232
|
-
|
|
321
|
+
if ( this.enabled === false ) return;
|
|
233
322
|
|
|
234
|
-
|
|
323
|
+
this._updatePointer( event );
|
|
324
|
+
this._updateState( event );
|
|
235
325
|
|
|
236
|
-
|
|
326
|
+
_intersections.length = 0;
|
|
237
327
|
|
|
238
|
-
|
|
328
|
+
raycaster.setFromCamera( _pointer, camera );
|
|
329
|
+
raycaster.intersectObjects( this.objects, this.recursive, _intersections );
|
|
239
330
|
|
|
240
|
-
|
|
331
|
+
if ( _intersections.length > 0 ) {
|
|
241
332
|
|
|
242
|
-
|
|
333
|
+
if ( this.transformGroup === true ) {
|
|
243
334
|
|
|
244
|
-
|
|
335
|
+
// look for the outermost group in the object's upper hierarchy
|
|
245
336
|
|
|
246
|
-
|
|
337
|
+
_selected = findGroup( _intersections[ 0 ].object );
|
|
247
338
|
|
|
248
|
-
|
|
249
|
-
|
|
339
|
+
} else {
|
|
340
|
+
|
|
341
|
+
_selected = _intersections[ 0 ].object;
|
|
250
342
|
|
|
251
343
|
}
|
|
252
344
|
|
|
253
|
-
|
|
345
|
+
_plane.setFromNormalAndCoplanarPoint( camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
|
|
346
|
+
|
|
347
|
+
if ( raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
|
348
|
+
|
|
349
|
+
if ( this.state === STATE.PAN ) {
|
|
254
350
|
|
|
255
|
-
|
|
351
|
+
_inverseMatrix.copy( _selected.parent.matrixWorld ).invert();
|
|
352
|
+
_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
|
|
256
353
|
|
|
257
|
-
if (
|
|
354
|
+
} else if ( this.state === STATE.ROTATE ) {
|
|
258
355
|
|
|
259
|
-
|
|
356
|
+
// the controls only support Y+ up
|
|
357
|
+
_up.set( 0, 1, 0 ).applyQuaternion( camera.quaternion ).normalize();
|
|
358
|
+
_right.set( 1, 0, 0 ).applyQuaternion( camera.quaternion ).normalize();
|
|
359
|
+
|
|
360
|
+
}
|
|
260
361
|
|
|
261
362
|
}
|
|
262
363
|
|
|
263
|
-
|
|
364
|
+
domElement.style.cursor = 'move';
|
|
264
365
|
|
|
265
|
-
|
|
366
|
+
this.dispatchEvent( { type: 'dragstart', object: _selected } );
|
|
266
367
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
_previousPointer.copy( _pointer );
|
|
270
371
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function onPointerCancel() {
|
|
375
|
+
|
|
376
|
+
if ( this.enabled === false ) return;
|
|
377
|
+
|
|
378
|
+
if ( _selected ) {
|
|
379
|
+
|
|
380
|
+
this.dispatchEvent( { type: 'dragend', object: _selected } );
|
|
381
|
+
|
|
382
|
+
_selected = null;
|
|
277
383
|
|
|
278
384
|
}
|
|
279
385
|
|
|
386
|
+
this.domElement.style.cursor = _hovered ? 'pointer' : 'auto';
|
|
387
|
+
|
|
388
|
+
this.state = STATE.NONE;
|
|
389
|
+
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function onContextMenu( event ) {
|
|
393
|
+
|
|
394
|
+
if ( this.enabled === false ) return;
|
|
395
|
+
|
|
396
|
+
event.preventDefault();
|
|
397
|
+
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function findGroup( obj, group = null ) {
|
|
401
|
+
|
|
402
|
+
if ( obj.isGroup ) group = obj;
|
|
403
|
+
|
|
404
|
+
if ( obj.parent === null ) return group;
|
|
405
|
+
|
|
406
|
+
return findGroup( obj.parent, group );
|
|
407
|
+
|
|
280
408
|
}
|
|
281
409
|
|
|
282
410
|
export { DragControls };
|
|
@@ -322,9 +322,9 @@ class TSLEncoder {
|
|
|
322
322
|
const leftStr = this.emitExpression( node.left );
|
|
323
323
|
const rightStr = this.emitExpression( node.right );
|
|
324
324
|
|
|
325
|
-
this.addImport( '
|
|
325
|
+
this.addImport( 'select' );
|
|
326
326
|
|
|
327
|
-
return `
|
|
327
|
+
return `select( ${ condStr }, ${ leftStr }, ${ rightStr } )`;
|
|
328
328
|
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -349,7 +349,7 @@ ${ this.tab }} )`;
|
|
|
349
349
|
|
|
350
350
|
const elseCondStr = this.emitExpression( current.elseConditional.cond );
|
|
351
351
|
|
|
352
|
-
ifStr += `.
|
|
352
|
+
ifStr += `.ElseIf( ${ elseCondStr }, () => {
|
|
353
353
|
|
|
354
354
|
${ elseBodyStr }
|
|
355
355
|
|
|
@@ -357,7 +357,7 @@ ${ this.tab }} )`;
|
|
|
357
357
|
|
|
358
358
|
} else {
|
|
359
359
|
|
|
360
|
-
ifStr += `.
|
|
360
|
+
ifStr += `.Else( () => {
|
|
361
361
|
|
|
362
362
|
${ elseBodyStr }
|
|
363
363
|
|
|
@@ -391,13 +391,13 @@ ${ this.tab }} )`;
|
|
|
391
391
|
const conditionParam = condition !== '<' ? `, condition: '${ condition }'` : '';
|
|
392
392
|
const updateParam = update !== '++' ? `, update: '${ update }'` : '';
|
|
393
393
|
|
|
394
|
-
let loopStr = `
|
|
394
|
+
let loopStr = `Loop( { start: ${ start }, end: ${ end + nameParam + typeParam + conditionParam + updateParam } }, ( { ${ name } } ) => {\n\n`;
|
|
395
395
|
|
|
396
396
|
loopStr += this.emitBody( node.body ) + '\n\n';
|
|
397
397
|
|
|
398
398
|
loopStr += this.tab + '} )';
|
|
399
399
|
|
|
400
|
-
this.imports.add( '
|
|
400
|
+
this.imports.add( 'Loop' );
|
|
401
401
|
|
|
402
402
|
return loopStr;
|
|
403
403
|
|
|
@@ -586,7 +586,7 @@ ${ this.tab }} )`;
|
|
|
586
586
|
|
|
587
587
|
const prefix = this.iife === false ? 'export ' : '';
|
|
588
588
|
|
|
589
|
-
let funcStr = `${ prefix }const ${ fnName } = /*#__PURE__*/
|
|
589
|
+
let funcStr = `${ prefix }const ${ fnName } = /*#__PURE__*/ Fn( (${ paramsStr }) => {
|
|
590
590
|
|
|
591
591
|
${ bodyStr }
|
|
592
592
|
|
|
@@ -608,7 +608,7 @@ ${ this.tab }} )`;
|
|
|
608
608
|
|
|
609
609
|
funcStr += ';\n';
|
|
610
610
|
|
|
611
|
-
this.imports.add( '
|
|
611
|
+
this.imports.add( 'Fn' );
|
|
612
612
|
|
|
613
613
|
this.global.add( node.name );
|
|
614
614
|
|
package/package.json
CHANGED
|
@@ -836,7 +836,7 @@ class ObjectLoader extends Loader {
|
|
|
836
836
|
case 'DirectionalLight':
|
|
837
837
|
|
|
838
838
|
object = new DirectionalLight( data.color, data.intensity );
|
|
839
|
-
object.target = data.target ||
|
|
839
|
+
object.target = data.target || '';
|
|
840
840
|
|
|
841
841
|
break;
|
|
842
842
|
|
|
@@ -855,7 +855,7 @@ class ObjectLoader extends Loader {
|
|
|
855
855
|
case 'SpotLight':
|
|
856
856
|
|
|
857
857
|
object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
|
|
858
|
-
object.target = data.target ||
|
|
858
|
+
object.target = data.target || '';
|
|
859
859
|
|
|
860
860
|
break;
|
|
861
861
|
|
|
@@ -1132,7 +1132,7 @@ class ObjectLoader extends Loader {
|
|
|
1132
1132
|
|
|
1133
1133
|
object.traverse( function ( child ) {
|
|
1134
1134
|
|
|
1135
|
-
if ( child.isDirectionalLight ||
|
|
1135
|
+
if ( child.isDirectionalLight || child.isSpotLight ) {
|
|
1136
1136
|
|
|
1137
1137
|
const uuid = child.target;
|
|
1138
1138
|
|