@plastic-software/three 0.167.1 → 0.167.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.
Files changed (94) hide show
  1. package/build/three.cjs +17 -8
  2. package/build/three.module.js +17 -8
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +746 -374
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/controls/Controls.js +32 -0
  7. package/examples/jsm/controls/DragControls.js +260 -132
  8. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  9. package/package.json +1 -1
  10. package/src/loaders/ObjectLoader.js +3 -3
  11. package/src/nodes/Nodes.js +3 -2
  12. package/src/nodes/accessors/BatchNode.js +2 -2
  13. package/src/nodes/accessors/ClippingNode.js +8 -8
  14. package/src/nodes/accessors/MorphNode.js +4 -4
  15. package/src/nodes/accessors/TangentNode.js +2 -2
  16. package/src/nodes/accessors/Texture3DNode.js +8 -8
  17. package/src/nodes/accessors/UniformArrayNode.js +5 -3
  18. package/src/nodes/core/StackNode.js +22 -6
  19. package/src/nodes/display/AfterImageNode.js +3 -3
  20. package/src/nodes/display/AnamorphicNode.js +4 -4
  21. package/src/nodes/display/BleachBypassNode.js +2 -2
  22. package/src/nodes/display/BlendModeNode.js +8 -8
  23. package/src/nodes/display/BloomNode.js +9 -9
  24. package/src/nodes/display/BumpMapNode.js +3 -3
  25. package/src/nodes/display/ColorAdjustmentNode.js +4 -4
  26. package/src/nodes/display/ColorSpaceNode.js +3 -3
  27. package/src/nodes/display/DenoiseNode.js +8 -8
  28. package/src/nodes/display/DepthOfFieldNode.js +2 -2
  29. package/src/nodes/display/DotScreenNode.js +3 -3
  30. package/src/nodes/display/FXAANode.js +11 -11
  31. package/src/nodes/display/FilmNode.js +2 -2
  32. package/src/nodes/display/GTAONode.js +9 -9
  33. package/src/nodes/display/GaussianBlurNode.js +2 -2
  34. package/src/nodes/display/Lut3DNode.js +2 -2
  35. package/src/nodes/display/NormalMapNode.js +2 -2
  36. package/src/nodes/display/PassNode.js +71 -3
  37. package/src/nodes/display/PixelationPassNode.js +3 -3
  38. package/src/nodes/display/RGBShiftNode.js +2 -2
  39. package/src/nodes/display/SepiaNode.js +2 -2
  40. package/src/nodes/display/SobelOperatorNode.js +2 -2
  41. package/src/nodes/display/ToneMappingNode.js +13 -13
  42. package/src/nodes/display/TransitionNode.js +3 -3
  43. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -2
  44. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  45. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  46. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  47. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  48. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +2 -2
  49. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  50. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  51. package/src/nodes/functions/BSDF/LTC.js +6 -6
  52. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  53. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  54. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  55. package/src/nodes/functions/PhongLightingModel.js +3 -3
  56. package/src/nodes/functions/PhysicalLightingModel.js +18 -18
  57. package/src/nodes/functions/ToonLightingModel.js +2 -2
  58. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  59. package/src/nodes/functions/material/getRoughness.js +2 -2
  60. package/src/nodes/lighting/AnalyticLightNode.js +5 -5
  61. package/src/nodes/lighting/BasicEnvironmentNode.js +2 -1
  62. package/src/nodes/lighting/LightProbeNode.js +80 -0
  63. package/src/nodes/lighting/LightUtils.js +3 -3
  64. package/src/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
  65. package/src/nodes/materials/Line2NodeMaterial.js +17 -17
  66. package/src/nodes/materials/MeshPhysicalNodeMaterial.js +1 -1
  67. package/src/nodes/materials/VolumeNodeMaterial.js +5 -5
  68. package/src/nodes/materialx/lib/mx_hsv.js +12 -12
  69. package/src/nodes/materialx/lib/mx_noise.js +80 -80
  70. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  71. package/src/nodes/math/CondNode.js +13 -2
  72. package/src/nodes/math/MathNode.js +2 -2
  73. package/src/nodes/math/TriNoise3D.js +6 -6
  74. package/src/nodes/pmrem/PMREMUtils.js +34 -34
  75. package/src/nodes/procedural/CheckerNode.js +2 -2
  76. package/src/nodes/shadernode/ShaderNode.js +11 -4
  77. package/src/nodes/utils/CubeMapNode.js +157 -0
  78. package/src/nodes/utils/LoopNode.js +10 -4
  79. package/src/nodes/utils/SpriteUtils.js +2 -2
  80. package/src/nodes/utils/UVUtils.js +3 -3
  81. package/src/nodes/utils/ViewportUtils.js +3 -3
  82. package/src/renderers/WebGLRenderer.js +8 -0
  83. package/src/renderers/common/RenderContext.js +24 -0
  84. package/src/renderers/common/RenderObject.js +1 -1
  85. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +1 -1
  86. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
  87. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +0 -2
  88. package/src/renderers/shaders/ShaderLib/points.glsl.js +0 -2
  89. package/src/renderers/webgl/WebGLPrograms.js +2 -1
  90. package/src/renderers/webgl-fallback/WebGLBackend.js +31 -27
  91. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +12 -8
  92. package/src/renderers/webgpu/WebGPUBackend.js +10 -14
  93. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +30 -2
  94. 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
- class DragControls extends EventDispatcher {
25
+ let _selected = null, _hovered = null;
26
+ const _intersections = [];
25
27
 
26
- constructor( _objects, _camera, _domElement ) {
28
+ const STATE = {
29
+ NONE: - 1,
30
+ PAN: 0,
31
+ ROTATE: 1
32
+ };
27
33
 
28
- super();
34
+ class DragControls extends Controls {
29
35
 
30
- _domElement.style.touchAction = 'none'; // disable touch scroll
36
+ constructor( objects, camera, domElement = null ) {
31
37
 
32
- let _selected = null, _hovered = null;
38
+ super( camera, domElement );
33
39
 
34
- const _intersections = [];
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
- const scope = this;
48
+ // interaction
43
49
 
44
- function activate() {
50
+ this.mouseButtons = { LEFT: MOUSE.PAN, MIDDLE: MOUSE.PAN, RIGHT: MOUSE.ROTATE };
51
+ this.touches = { ONE: TOUCH.PAN };
45
52
 
46
- _domElement.addEventListener( 'pointermove', onPointerMove );
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
- function deactivate() {
60
+ //
54
61
 
55
- _domElement.removeEventListener( 'pointermove', onPointerMove );
56
- _domElement.removeEventListener( 'pointerdown', onPointerDown );
57
- _domElement.removeEventListener( 'pointerup', onPointerCancel );
58
- _domElement.removeEventListener( 'pointerleave', onPointerCancel );
62
+ if ( domElement !== null ) {
59
63
 
60
- _domElement.style.cursor = '';
64
+ this.connect();
61
65
 
62
66
  }
63
67
 
64
- function dispose() {
68
+ }
65
69
 
66
- deactivate();
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
- function getObjects() {
78
+ this.domElement.style.touchAction = 'none'; // disable touch scroll
71
79
 
72
- return _objects;
80
+ }
73
81
 
74
- }
82
+ disconnect() {
75
83
 
76
- function setObjects( objects ) {
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
- _objects = objects;
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
- function getRaycaster() {
118
+ action = this.touches.ONE;
83
119
 
84
- return _raycaster;
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
- function onPointerMove( event ) {
147
+ // determine state
89
148
 
90
- if ( scope.enabled === false ) return;
149
+ switch ( action ) {
91
150
 
92
- updatePointer( event );
151
+ case MOUSE.PAN:
152
+ case TOUCH.PAN:
93
153
 
94
- _raycaster.setFromCamera( _pointer, _camera );
154
+ this.state = STATE.PAN;
95
155
 
96
- if ( _selected ) {
156
+ break;
97
157
 
98
- if ( scope.mode === 'translate' ) {
158
+ case MOUSE.ROTATE:
159
+ case TOUCH.ROTATE:
99
160
 
100
- if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
161
+ this.state = STATE.ROTATE;
101
162
 
102
- _selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
163
+ break;
103
164
 
104
- }
165
+ default:
105
166
 
106
- } else if ( scope.mode === 'rotate' ) {
167
+ this.state = STATE.NONE;
107
168
 
108
- _diff.subVectors( _pointer, _previousPointer ).multiplyScalar( scope.rotateSpeed );
109
- _selected.rotateOnWorldAxis( _up, _diff.x );
110
- _selected.rotateOnWorldAxis( _right.normalize(), - _diff.y );
169
+ }
111
170
 
112
- }
171
+ }
113
172
 
114
- scope.dispatchEvent( { type: 'drag', object: _selected } );
173
+ getRaycaster() {
115
174
 
116
- _previousPointer.copy( _pointer );
175
+ console.warn( 'THREE.DragControls: getRaycaster() has been deprecated. Use controls.raycaster instead.' ); // @deprecated r169
117
176
 
118
- } else {
177
+ return this.raycaster;
178
+
179
+ }
119
180
 
120
- // hover support
181
+ setObjects( objects ) {
121
182
 
122
- if ( event.pointerType === 'mouse' || event.pointerType === 'pen' ) {
183
+ console.warn( 'THREE.DragControls: setObjects() has been deprecated. Use controls.objects instead.' ); // @deprecated r169
123
184
 
124
- _intersections.length = 0;
185
+ this.objects = objects;
125
186
 
126
- _raycaster.setFromCamera( _pointer, _camera );
127
- _raycaster.intersectObjects( _objects, scope.recursive, _intersections );
187
+ }
128
188
 
129
- if ( _intersections.length > 0 ) {
189
+ getObjects() {
130
190
 
131
- const object = _intersections[ 0 ].object;
191
+ console.warn( 'THREE.DragControls: getObjects() has been deprecated. Use controls.objects instead.' ); // @deprecated r169
132
192
 
133
- _plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
193
+ return this.objects;
134
194
 
135
- if ( _hovered !== object && _hovered !== null ) {
195
+ }
136
196
 
137
- scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
197
+ activate() {
138
198
 
139
- _domElement.style.cursor = 'auto';
140
- _hovered = null;
199
+ console.warn( 'THREE.DragControls: activate() has been renamed to connect().' ); // @deprecated r169
200
+ this.connect();
141
201
 
142
- }
202
+ }
143
203
 
144
- if ( _hovered !== object ) {
204
+ deactivate() {
145
205
 
146
- scope.dispatchEvent( { type: 'hoveron', object: object } );
206
+ console.warn( 'THREE.DragControls: deactivate() has been renamed to disconnect().' ); // @deprecated r169
207
+ this.disconnect();
147
208
 
148
- _domElement.style.cursor = 'pointer';
149
- _hovered = object;
209
+ }
150
210
 
151
- }
211
+ set mode( value ) {
152
212
 
153
- } else {
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
- if ( _hovered !== null ) {
215
+ }
156
216
 
157
- scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
217
+ get mode() {
158
218
 
159
- _domElement.style.cursor = 'auto';
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
- _previousPointer.copy( _pointer );
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
- function onPointerDown( event ) {
255
+ this.dispatchEvent( { type: 'drag', object: _selected } );
256
+
257
+ _previousPointer.copy( _pointer );
175
258
 
176
- if ( scope.enabled === false ) return;
259
+ } else {
177
260
 
178
- updatePointer( event );
261
+ // hover support
262
+
263
+ if ( event.pointerType === 'mouse' || event.pointerType === 'pen' ) {
179
264
 
180
265
  _intersections.length = 0;
181
266
 
182
- _raycaster.setFromCamera( _pointer, _camera );
183
- _raycaster.intersectObjects( _objects, scope.recursive, _intersections );
267
+ raycaster.setFromCamera( _pointer, camera );
268
+ raycaster.intersectObjects( this.objects, this.recursive, _intersections );
184
269
 
185
270
  if ( _intersections.length > 0 ) {
186
271
 
187
- if ( scope.transformGroup === true ) {
272
+ const object = _intersections[ 0 ].object;
188
273
 
189
- // look for the outermost group in the object's upper hierarchy
274
+ _plane.setFromNormalAndCoplanarPoint( camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
190
275
 
191
- _selected = findGroup( _intersections[ 0 ].object );
276
+ if ( _hovered !== object && _hovered !== null ) {
192
277
 
193
- } else {
278
+ this.dispatchEvent( { type: 'hoveroff', object: _hovered } );
194
279
 
195
- _selected = _intersections[ 0 ].object;
280
+ domElement.style.cursor = 'auto';
281
+ _hovered = null;
196
282
 
197
283
  }
198
284
 
199
- _plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
285
+ if ( _hovered !== object ) {
200
286
 
201
- if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
287
+ this.dispatchEvent( { type: 'hoveron', object: object } );
202
288
 
203
- if ( scope.mode === 'translate' ) {
289
+ domElement.style.cursor = 'pointer';
290
+ _hovered = object;
204
291
 
205
- _inverseMatrix.copy( _selected.parent.matrixWorld ).invert();
206
- _offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
292
+ }
207
293
 
208
- } else if ( scope.mode === 'rotate' ) {
294
+ } else {
209
295
 
210
- // the controls only support Y+ up
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
- _domElement.style.cursor = 'move';
305
+ }
219
306
 
220
- scope.dispatchEvent( { type: 'dragstart', object: _selected } );
307
+ }
221
308
 
222
- }
309
+ }
223
310
 
224
- _previousPointer.copy( _pointer );
311
+ _previousPointer.copy( _pointer );
225
312
 
226
- }
313
+ }
227
314
 
228
- function onPointerCancel() {
315
+ function onPointerDown( event ) {
229
316
 
230
- if ( scope.enabled === false ) return;
317
+ const camera = this.object;
318
+ const domElement = this.domElement;
319
+ const raycaster = this.raycaster;
231
320
 
232
- if ( _selected ) {
321
+ if ( this.enabled === false ) return;
233
322
 
234
- scope.dispatchEvent( { type: 'dragend', object: _selected } );
323
+ this._updatePointer( event );
324
+ this._updateState( event );
235
325
 
236
- _selected = null;
326
+ _intersections.length = 0;
237
327
 
238
- }
328
+ raycaster.setFromCamera( _pointer, camera );
329
+ raycaster.intersectObjects( this.objects, this.recursive, _intersections );
239
330
 
240
- _domElement.style.cursor = _hovered ? 'pointer' : 'auto';
331
+ if ( _intersections.length > 0 ) {
241
332
 
242
- }
333
+ if ( this.transformGroup === true ) {
243
334
 
244
- function updatePointer( event ) {
335
+ // look for the outermost group in the object's upper hierarchy
245
336
 
246
- const rect = _domElement.getBoundingClientRect();
337
+ _selected = findGroup( _intersections[ 0 ].object );
247
338
 
248
- _pointer.x = ( event.clientX - rect.left ) / rect.width * 2 - 1;
249
- _pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
339
+ } else {
340
+
341
+ _selected = _intersections[ 0 ].object;
250
342
 
251
343
  }
252
344
 
253
- function findGroup( obj, group = null ) {
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
- if ( obj.isGroup ) group = obj;
351
+ _inverseMatrix.copy( _selected.parent.matrixWorld ).invert();
352
+ _offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
256
353
 
257
- if ( obj.parent === null ) return group;
354
+ } else if ( this.state === STATE.ROTATE ) {
258
355
 
259
- return findGroup( obj.parent, group );
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
- activate();
364
+ domElement.style.cursor = 'move';
264
365
 
265
- // API
366
+ this.dispatchEvent( { type: 'dragstart', object: _selected } );
266
367
 
267
- this.enabled = true;
268
- this.recursive = true;
269
- this.transformGroup = false;
368
+ }
369
+
370
+ _previousPointer.copy( _pointer );
270
371
 
271
- this.activate = activate;
272
- this.deactivate = deactivate;
273
- this.dispose = dispose;
274
- this.getObjects = getObjects;
275
- this.getRaycaster = getRaycaster;
276
- this.setObjects = setObjects;
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( 'cond' );
325
+ this.addImport( 'select' );
326
326
 
327
- return `cond( ${ condStr }, ${ leftStr }, ${ rightStr } )`;
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 += `.elseif( ${ elseCondStr }, () => {
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 += `.else( () => {
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 = `loop( { start: ${ start }, end: ${ end + nameParam + typeParam + conditionParam + updateParam } }, ( { ${ name } } ) => {\n\n`;
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( 'loop' );
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__*/ tslFn( (${ paramsStr }) => {
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( 'tslFn' );
611
+ this.imports.add( 'Fn' );
612
612
 
613
613
  this.global.add( node.name );
614
614
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plastic-software/three",
3
- "version": "0.167.1",
3
+ "version": "0.167.3",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
@@ -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 || child.isSpotLight ) {
1135
+ if ( child.isDirectionalLight || child.isSpotLight ) {
1136
1136
 
1137
1137
  const uuid = child.target;
1138
1138