super-three 0.154.1 → 0.156.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +360 -160
- package/build/three.js +360 -160
- package/build/three.min.js +1 -1
- package/build/three.module.js +355 -161
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +155 -25
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +1 -0
- package/examples/jsm/interactive/SelectionHelper.js +7 -0
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +25 -10
- package/examples/jsm/loaders/KTX2Loader.js +128 -79
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PLYLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/loaders/TGALoader.js +10 -10
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
- package/examples/jsm/misc/Volume.js +4 -6
- package/examples/jsm/nodes/Nodes.js +8 -6
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
- package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/LightingModel.js +7 -9
- package/examples/jsm/nodes/core/Node.js +28 -3
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
- package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
- package/examples/jsm/nodes/lighting/AONode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
- package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
- package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +2 -0
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -9
- package/examples/jsm/objects/Refractor.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/MaskPass.js +4 -1
- package/examples/jsm/postprocessing/OutputPass.js +33 -14
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Background.js +22 -20
- package/examples/jsm/renderers/common/Binding.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +7 -10
- package/examples/jsm/renderers/common/Geometries.js +1 -1
- package/examples/jsm/renderers/common/Pipelines.js +96 -47
- package/examples/jsm/renderers/common/RenderContext.js +1 -0
- package/examples/jsm/renderers/common/RenderContexts.js +41 -5
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +26 -6
- package/examples/jsm/renderers/common/RenderObjects.js +10 -7
- package/examples/jsm/renderers/common/Renderer.js +82 -42
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +172 -20
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/OutputShader.js +19 -2
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
- package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
- package/package.json +2 -2
- package/src/Three.js +3 -0
- package/src/animation/PropertyBinding.js +1 -1
- package/src/audio/Audio.js +6 -0
- package/src/cameras/CubeCamera.js +1 -4
- package/src/constants.js +4 -1
- package/src/core/BufferAttribute.js +20 -0
- package/src/core/Object3D.js +2 -15
- package/src/core/RenderTarget.js +122 -0
- package/src/core/UniformsGroup.js +2 -2
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/loaders/DataTextureLoader.js +19 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
- package/src/renderers/WebGLRenderTarget.js +3 -110
- package/src/renderers/WebGLRenderer.js +83 -57
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLGeometries.js +5 -1
- package/src/renderers/webgl/WebGLMaterials.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +19 -3
- package/src/renderers/webgl/WebGLTextures.js +101 -16
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/CompressedCubeTexture.js +19 -0
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
- package/examples/jsm/renderers/common/RenderTarget.js +0 -15
- package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -5,7 +5,10 @@ import {
|
|
|
5
5
|
Spherical,
|
|
6
6
|
TOUCH,
|
|
7
7
|
Vector2,
|
|
8
|
-
Vector3
|
|
8
|
+
Vector3,
|
|
9
|
+
Plane,
|
|
10
|
+
Ray,
|
|
11
|
+
MathUtils
|
|
9
12
|
} from 'three';
|
|
10
13
|
|
|
11
14
|
// OrbitControls performs orbiting, dollying (zooming), and panning.
|
|
@@ -18,6 +21,9 @@ import {
|
|
|
18
21
|
const _changeEvent = { type: 'change' };
|
|
19
22
|
const _startEvent = { type: 'start' };
|
|
20
23
|
const _endEvent = { type: 'end' };
|
|
24
|
+
const _ray = new Ray();
|
|
25
|
+
const _plane = new Plane();
|
|
26
|
+
const TILT_LIMIT = Math.cos( 70 * MathUtils.DEG2RAD );
|
|
21
27
|
|
|
22
28
|
class OrbitControls extends EventDispatcher {
|
|
23
29
|
|
|
@@ -72,6 +78,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
72
78
|
this.panSpeed = 1.0;
|
|
73
79
|
this.screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up
|
|
74
80
|
this.keyPanSpeed = 7.0; // pixels moved per arrow key push
|
|
81
|
+
this.zoomToCursor = false;
|
|
75
82
|
|
|
76
83
|
// Set to true to automatically rotate around the target
|
|
77
84
|
// If auto-rotate is enabled, you must call controls.update() in your animation loop
|
|
@@ -169,7 +176,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
169
176
|
|
|
170
177
|
const twoPI = 2 * Math.PI;
|
|
171
178
|
|
|
172
|
-
return function update() {
|
|
179
|
+
return function update( deltaTime = null ) {
|
|
173
180
|
|
|
174
181
|
const position = scope.object.position;
|
|
175
182
|
|
|
@@ -183,7 +190,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
183
190
|
|
|
184
191
|
if ( scope.autoRotate && state === STATE.NONE ) {
|
|
185
192
|
|
|
186
|
-
rotateLeft( getAutoRotationAngle() );
|
|
193
|
+
rotateLeft( getAutoRotationAngle( deltaTime ) );
|
|
187
194
|
|
|
188
195
|
}
|
|
189
196
|
|
|
@@ -230,11 +237,6 @@ class OrbitControls extends EventDispatcher {
|
|
|
230
237
|
spherical.makeSafe();
|
|
231
238
|
|
|
232
239
|
|
|
233
|
-
spherical.radius *= scale;
|
|
234
|
-
|
|
235
|
-
// restrict radius to be between desired limits
|
|
236
|
-
spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
|
|
237
|
-
|
|
238
240
|
// move target to panned location
|
|
239
241
|
|
|
240
242
|
if ( scope.enableDamping === true ) {
|
|
@@ -247,6 +249,19 @@ class OrbitControls extends EventDispatcher {
|
|
|
247
249
|
|
|
248
250
|
}
|
|
249
251
|
|
|
252
|
+
// adjust the camera position based on zoom only if we're not zooming to the cursor or if it's an ortho camera
|
|
253
|
+
// we adjust zoom later in these cases
|
|
254
|
+
if ( scope.zoomToCursor && performCursorZoom || scope.object.isOrthographicCamera ) {
|
|
255
|
+
|
|
256
|
+
spherical.radius = clampDistance( spherical.radius );
|
|
257
|
+
|
|
258
|
+
} else {
|
|
259
|
+
|
|
260
|
+
spherical.radius = clampDistance( spherical.radius * scale );
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
250
265
|
offset.setFromSpherical( spherical );
|
|
251
266
|
|
|
252
267
|
// rotate offset back to "camera-up-vector-is-up" space
|
|
@@ -271,7 +286,91 @@ class OrbitControls extends EventDispatcher {
|
|
|
271
286
|
|
|
272
287
|
}
|
|
273
288
|
|
|
289
|
+
// adjust camera position
|
|
290
|
+
let zoomChanged = false;
|
|
291
|
+
if ( scope.zoomToCursor && performCursorZoom ) {
|
|
292
|
+
|
|
293
|
+
let newRadius = null;
|
|
294
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
295
|
+
|
|
296
|
+
// move the camera down the pointer ray
|
|
297
|
+
// this method avoids floating point error
|
|
298
|
+
const prevRadius = offset.length();
|
|
299
|
+
newRadius = clampDistance( prevRadius * scale );
|
|
300
|
+
|
|
301
|
+
const radiusDelta = prevRadius - newRadius;
|
|
302
|
+
scope.object.position.addScaledVector( dollyDirection, radiusDelta );
|
|
303
|
+
scope.object.updateMatrixWorld();
|
|
304
|
+
|
|
305
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
306
|
+
|
|
307
|
+
// adjust the ortho camera position based on zoom changes
|
|
308
|
+
const mouseBefore = new Vector3( mouse.x, mouse.y, 0 );
|
|
309
|
+
mouseBefore.unproject( scope.object );
|
|
310
|
+
|
|
311
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
|
|
312
|
+
scope.object.updateProjectionMatrix();
|
|
313
|
+
zoomChanged = true;
|
|
314
|
+
|
|
315
|
+
const mouseAfter = new Vector3( mouse.x, mouse.y, 0 );
|
|
316
|
+
mouseAfter.unproject( scope.object );
|
|
317
|
+
|
|
318
|
+
scope.object.position.sub( mouseAfter ).add( mouseBefore );
|
|
319
|
+
scope.object.updateMatrixWorld();
|
|
320
|
+
|
|
321
|
+
newRadius = offset.length();
|
|
322
|
+
|
|
323
|
+
} else {
|
|
324
|
+
|
|
325
|
+
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.' );
|
|
326
|
+
scope.zoomToCursor = false;
|
|
327
|
+
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// handle the placement of the target
|
|
331
|
+
if ( newRadius !== null ) {
|
|
332
|
+
|
|
333
|
+
if ( this.screenSpacePanning ) {
|
|
334
|
+
|
|
335
|
+
// position the orbit target in front of the new camera position
|
|
336
|
+
scope.target.set( 0, 0, - 1 )
|
|
337
|
+
.transformDirection( scope.object.matrix )
|
|
338
|
+
.multiplyScalar( newRadius )
|
|
339
|
+
.add( scope.object.position );
|
|
340
|
+
|
|
341
|
+
} else {
|
|
342
|
+
|
|
343
|
+
// get the ray and translation plane to compute target
|
|
344
|
+
_ray.origin.copy( scope.object.position );
|
|
345
|
+
_ray.direction.set( 0, 0, - 1 ).transformDirection( scope.object.matrix );
|
|
346
|
+
|
|
347
|
+
// if the camera is 20 degrees above the horizon then don't adjust the focus target to avoid
|
|
348
|
+
// extremely large values
|
|
349
|
+
if ( Math.abs( scope.object.up.dot( _ray.direction ) ) < TILT_LIMIT ) {
|
|
350
|
+
|
|
351
|
+
object.lookAt( scope.target );
|
|
352
|
+
|
|
353
|
+
} else {
|
|
354
|
+
|
|
355
|
+
_plane.setFromNormalAndCoplanarPoint( scope.object.up, scope.target );
|
|
356
|
+
_ray.intersectPlane( _plane, scope.target );
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
365
|
+
|
|
366
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
|
|
367
|
+
scope.object.updateProjectionMatrix();
|
|
368
|
+
zoomChanged = true;
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
274
372
|
scale = 1;
|
|
373
|
+
performCursorZoom = false;
|
|
275
374
|
|
|
276
375
|
// update condition is:
|
|
277
376
|
// min(camera displacement, camera rotation in radians)^2 > EPS
|
|
@@ -350,7 +449,6 @@ class OrbitControls extends EventDispatcher {
|
|
|
350
449
|
|
|
351
450
|
let scale = 1;
|
|
352
451
|
const panOffset = new Vector3();
|
|
353
|
-
let zoomChanged = false;
|
|
354
452
|
|
|
355
453
|
const rotateStart = new Vector2();
|
|
356
454
|
const rotateEnd = new Vector2();
|
|
@@ -364,12 +462,24 @@ class OrbitControls extends EventDispatcher {
|
|
|
364
462
|
const dollyEnd = new Vector2();
|
|
365
463
|
const dollyDelta = new Vector2();
|
|
366
464
|
|
|
465
|
+
const dollyDirection = new Vector3();
|
|
466
|
+
const mouse = new Vector2();
|
|
467
|
+
let performCursorZoom = false;
|
|
468
|
+
|
|
367
469
|
const pointers = [];
|
|
368
470
|
const pointerPositions = {};
|
|
369
471
|
|
|
370
|
-
function getAutoRotationAngle() {
|
|
472
|
+
function getAutoRotationAngle( deltaTime ) {
|
|
371
473
|
|
|
372
|
-
|
|
474
|
+
if ( deltaTime !== null ) {
|
|
475
|
+
|
|
476
|
+
return ( 2 * Math.PI / 60 * scope.autoRotateSpeed ) * deltaTime;
|
|
477
|
+
|
|
478
|
+
} else {
|
|
479
|
+
|
|
480
|
+
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
481
|
+
|
|
482
|
+
}
|
|
373
483
|
|
|
374
484
|
}
|
|
375
485
|
|
|
@@ -474,16 +584,10 @@ class OrbitControls extends EventDispatcher {
|
|
|
474
584
|
|
|
475
585
|
function dollyOut( dollyScale ) {
|
|
476
586
|
|
|
477
|
-
if ( scope.object.isPerspectiveCamera ) {
|
|
587
|
+
if ( scope.object.isPerspectiveCamera || scope.object.isOrthographicCamera ) {
|
|
478
588
|
|
|
479
589
|
scale /= dollyScale;
|
|
480
590
|
|
|
481
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
482
|
-
|
|
483
|
-
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
|
|
484
|
-
scope.object.updateProjectionMatrix();
|
|
485
|
-
zoomChanged = true;
|
|
486
|
-
|
|
487
591
|
} else {
|
|
488
592
|
|
|
489
593
|
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
@@ -495,16 +599,10 @@ class OrbitControls extends EventDispatcher {
|
|
|
495
599
|
|
|
496
600
|
function dollyIn( dollyScale ) {
|
|
497
601
|
|
|
498
|
-
if ( scope.object.isPerspectiveCamera ) {
|
|
602
|
+
if ( scope.object.isPerspectiveCamera || scope.object.isOrthographicCamera ) {
|
|
499
603
|
|
|
500
604
|
scale *= dollyScale;
|
|
501
605
|
|
|
502
|
-
} else if ( scope.object.isOrthographicCamera ) {
|
|
503
|
-
|
|
504
|
-
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
|
|
505
|
-
scope.object.updateProjectionMatrix();
|
|
506
|
-
zoomChanged = true;
|
|
507
|
-
|
|
508
606
|
} else {
|
|
509
607
|
|
|
510
608
|
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
|
|
@@ -514,6 +612,35 @@ class OrbitControls extends EventDispatcher {
|
|
|
514
612
|
|
|
515
613
|
}
|
|
516
614
|
|
|
615
|
+
function updateMouseParameters( event ) {
|
|
616
|
+
|
|
617
|
+
if ( ! scope.zoomToCursor ) {
|
|
618
|
+
|
|
619
|
+
return;
|
|
620
|
+
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
performCursorZoom = true;
|
|
624
|
+
|
|
625
|
+
const rect = scope.domElement.getBoundingClientRect();
|
|
626
|
+
const x = event.clientX - rect.left;
|
|
627
|
+
const y = event.clientY - rect.top;
|
|
628
|
+
const w = rect.width;
|
|
629
|
+
const h = rect.height;
|
|
630
|
+
|
|
631
|
+
mouse.x = ( x / w ) * 2 - 1;
|
|
632
|
+
mouse.y = - ( y / h ) * 2 + 1;
|
|
633
|
+
|
|
634
|
+
dollyDirection.set( mouse.x, mouse.y, 1 ).unproject( scope.object ).sub( scope.object.position ).normalize();
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function clampDistance( dist ) {
|
|
639
|
+
|
|
640
|
+
return Math.max( scope.minDistance, Math.min( scope.maxDistance, dist ) );
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
517
644
|
//
|
|
518
645
|
// event callbacks - update the object state
|
|
519
646
|
//
|
|
@@ -526,6 +653,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
526
653
|
|
|
527
654
|
function handleMouseDownDolly( event ) {
|
|
528
655
|
|
|
656
|
+
updateMouseParameters( event );
|
|
529
657
|
dollyStart.set( event.clientX, event.clientY );
|
|
530
658
|
|
|
531
659
|
}
|
|
@@ -592,6 +720,8 @@ class OrbitControls extends EventDispatcher {
|
|
|
592
720
|
|
|
593
721
|
function handleMouseWheel( event ) {
|
|
594
722
|
|
|
723
|
+
updateMouseParameters( event );
|
|
724
|
+
|
|
595
725
|
if ( event.deltaY < 0 ) {
|
|
596
726
|
|
|
597
727
|
dollyIn( getZoomScale() );
|
|
@@ -8,12 +8,26 @@ geometry.position = - vViewPosition;
|
|
|
8
8
|
geometry.normal = normal;
|
|
9
9
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
10
10
|
|
|
11
|
-
#ifdef
|
|
11
|
+
#ifdef USE_CLEARCOAT
|
|
12
12
|
|
|
13
13
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
14
14
|
|
|
15
15
|
#endif
|
|
16
16
|
|
|
17
|
+
#ifdef USE_IRIDESCENCE
|
|
18
|
+
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
19
|
+
if ( material.iridescenceThickness == 0.0 ) {
|
|
20
|
+
material.iridescence = 0.0;
|
|
21
|
+
} else {
|
|
22
|
+
material.iridescence = saturate( material.iridescence );
|
|
23
|
+
}
|
|
24
|
+
if ( material.iridescence > 0.0 ) {
|
|
25
|
+
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
26
|
+
// Iridescence F0 approximation
|
|
27
|
+
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
28
|
+
}
|
|
29
|
+
#endif
|
|
30
|
+
|
|
17
31
|
IncidentLight directLight;
|
|
18
32
|
|
|
19
33
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
@@ -45,6 +59,10 @@ IncidentLight directLight;
|
|
|
45
59
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
46
60
|
|
|
47
61
|
SpotLight spotLight;
|
|
62
|
+
vec4 spotColor;
|
|
63
|
+
vec3 spotLightCoord;
|
|
64
|
+
bool inSpotLightMap;
|
|
65
|
+
|
|
48
66
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
49
67
|
SpotLightShadow spotLightShadow;
|
|
50
68
|
#endif
|
|
@@ -56,6 +74,22 @@ IncidentLight directLight;
|
|
|
56
74
|
|
|
57
75
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
58
76
|
|
|
77
|
+
// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]
|
|
78
|
+
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
79
|
+
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
80
|
+
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
81
|
+
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
82
|
+
#else
|
|
83
|
+
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
84
|
+
#endif
|
|
85
|
+
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
86
|
+
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
87
|
+
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
88
|
+
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
89
|
+
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
90
|
+
#endif
|
|
91
|
+
#undef SPOT_LIGHT_MAP_INDEX
|
|
92
|
+
|
|
59
93
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
60
94
|
spotLightShadow = spotLightShadows[ i ];
|
|
61
95
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
@@ -26,7 +26,7 @@ class RoomEnvironment extends Scene {
|
|
|
26
26
|
|
|
27
27
|
let intensity = 5;
|
|
28
28
|
|
|
29
|
-
if ( renderer !== null && renderer.
|
|
29
|
+
if ( renderer !== null && renderer._useLegacyLights === false ) intensity = 900;
|
|
30
30
|
|
|
31
31
|
const mainLight = new PointLight( 0xffffff, intensity, 28, 2 );
|
|
32
32
|
mainLight.position.set( 0.418, 16.199, 0.300 );
|
|
@@ -15,9 +15,12 @@ class SelectionHelper {
|
|
|
15
15
|
this.pointBottomRight = new Vector2();
|
|
16
16
|
|
|
17
17
|
this.isDown = false;
|
|
18
|
+
this.enabled = true;
|
|
18
19
|
|
|
19
20
|
this.onPointerDown = function ( event ) {
|
|
20
21
|
|
|
22
|
+
if ( this.enabled === false ) return;
|
|
23
|
+
|
|
21
24
|
this.isDown = true;
|
|
22
25
|
this.onSelectStart( event );
|
|
23
26
|
|
|
@@ -25,6 +28,8 @@ class SelectionHelper {
|
|
|
25
28
|
|
|
26
29
|
this.onPointerMove = function ( event ) {
|
|
27
30
|
|
|
31
|
+
if ( this.enabled === false ) return;
|
|
32
|
+
|
|
28
33
|
if ( this.isDown ) {
|
|
29
34
|
|
|
30
35
|
this.onSelectMove( event );
|
|
@@ -35,6 +40,8 @@ class SelectionHelper {
|
|
|
35
40
|
|
|
36
41
|
this.onPointerUp = function ( ) {
|
|
37
42
|
|
|
43
|
+
if ( this.enabled === false ) return;
|
|
44
|
+
|
|
38
45
|
this.isDown = false;
|
|
39
46
|
this.onSelectOver();
|
|
40
47
|
|