@plastic-software/three 0.182.0 → 0.183.1
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/LICENSE +1 -1
- package/build/three.cjs +11521 -10878
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +510 -263
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
package/examples/jsm/Addons.js
CHANGED
|
@@ -123,9 +123,7 @@ export * from './loaders/VRMLLoader.js';
|
|
|
123
123
|
export * from './loaders/VTKLoader.js';
|
|
124
124
|
export * from './loaders/XYZLoader.js';
|
|
125
125
|
|
|
126
|
-
export * from './materials/MeshGouraudMaterial.js';
|
|
127
126
|
export * from './materials/LDrawConditionalLineMaterial.js';
|
|
128
|
-
export * from './materials/MeshPostProcessingMaterial.js';
|
|
129
127
|
|
|
130
128
|
export * from './math/Capsule.js';
|
|
131
129
|
export * from './math/ColorConverter.js';
|
|
@@ -225,7 +223,6 @@ export * from './shaders/FilmShader.js';
|
|
|
225
223
|
export * from './shaders/FocusShader.js';
|
|
226
224
|
export * from './shaders/FreiChenShader.js';
|
|
227
225
|
export * from './shaders/GammaCorrectionShader.js';
|
|
228
|
-
export * from './shaders/GodRaysShader.js';
|
|
229
226
|
export * from './shaders/GTAOShader.js';
|
|
230
227
|
export * from './shaders/HalftoneShader.js';
|
|
231
228
|
export * from './shaders/HorizontalBlurShader.js';
|
|
@@ -50,7 +50,7 @@ class CCDIKSolver {
|
|
|
50
50
|
/**
|
|
51
51
|
* The IK objects.
|
|
52
52
|
*
|
|
53
|
-
* @type {
|
|
53
|
+
* @type {Array<CCDIKSolver~IK>}
|
|
54
54
|
*/
|
|
55
55
|
this.iks = iks;
|
|
56
56
|
|
|
@@ -357,7 +357,7 @@ class CCDIKHelper extends Object3D {
|
|
|
357
357
|
/**
|
|
358
358
|
* The helpers sphere geometry.
|
|
359
359
|
*
|
|
360
|
-
* @type {
|
|
360
|
+
* @type {SphereGeometry}
|
|
361
361
|
*/
|
|
362
362
|
this.sphereGeometry = new SphereGeometry( sphereSize, 16, 8 );
|
|
363
363
|
|
|
@@ -98,9 +98,9 @@ const _EPS = 0.000001;
|
|
|
98
98
|
* consistent camera movements. Dragging cursor/fingers will cause camera to orbit around the center of the trackball in a conservative
|
|
99
99
|
* way (returning to the starting point will make the camera return to its starting orientation).
|
|
100
100
|
*
|
|
101
|
-
* In addition to supporting pan, zoom and pinch gestures,
|
|
102
|
-
*
|
|
103
|
-
*
|
|
101
|
+
* In addition to supporting pan, zoom and pinch gestures, double clicking/tapping focuses on a point, intuitively moving the object's
|
|
102
|
+
* point of interest to the center of the virtual trackball. Focus allows a much better inspection and navigation in complex environment.
|
|
103
|
+
* Moreover Arcball controls allow FOV manipulation (in a vertigo-style method) and z-rotation. Saving and restoring of Camera State
|
|
104
104
|
* is supported also through clipboard (use ctrl+c and ctrl+v shortcuts for copy and paste the state).
|
|
105
105
|
*
|
|
106
106
|
* Unlike {@link OrbitControls} and {@link TrackballControls}, `ArcballControls` doesn't require `update()` to be called externally in an
|
|
@@ -391,6 +391,8 @@ class OrbitControls extends Controls {
|
|
|
391
391
|
*/
|
|
392
392
|
this.zoom0 = this.object.zoom;
|
|
393
393
|
|
|
394
|
+
this._cursorStyle = 'auto';
|
|
395
|
+
|
|
394
396
|
// the target DOM element for key events
|
|
395
397
|
this._domElementKeyEvents = null;
|
|
396
398
|
|
|
@@ -462,6 +464,34 @@ class OrbitControls extends Controls {
|
|
|
462
464
|
|
|
463
465
|
}
|
|
464
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Defines the visual representation of the cursor.
|
|
469
|
+
*
|
|
470
|
+
* @type {('auto'|'grab')}
|
|
471
|
+
* @default 'auto'
|
|
472
|
+
*/
|
|
473
|
+
set cursorStyle( type ) {
|
|
474
|
+
|
|
475
|
+
this._cursorStyle = type;
|
|
476
|
+
|
|
477
|
+
if ( type === 'grab' ) {
|
|
478
|
+
|
|
479
|
+
this.domElement.style.cursor = 'grab';
|
|
480
|
+
|
|
481
|
+
} else {
|
|
482
|
+
|
|
483
|
+
this.domElement.style.cursor = 'auto';
|
|
484
|
+
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
get cursorStyle() {
|
|
490
|
+
|
|
491
|
+
return this._cursorStyle;
|
|
492
|
+
|
|
493
|
+
}
|
|
494
|
+
|
|
465
495
|
connect( element ) {
|
|
466
496
|
|
|
467
497
|
super.connect( element );
|
|
@@ -594,6 +624,67 @@ class OrbitControls extends Controls {
|
|
|
594
624
|
|
|
595
625
|
}
|
|
596
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Programmatically pan the camera.
|
|
629
|
+
*
|
|
630
|
+
* @param {number} deltaX - The horizontal pan amount in pixels.
|
|
631
|
+
* @param {number} deltaY - The vertical pan amount in pixels.
|
|
632
|
+
*/
|
|
633
|
+
pan( deltaX, deltaY ) {
|
|
634
|
+
|
|
635
|
+
this._pan( deltaX, deltaY );
|
|
636
|
+
this.update();
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Programmatically dolly in (zoom in for perspective camera).
|
|
642
|
+
*
|
|
643
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
644
|
+
*/
|
|
645
|
+
dollyIn( dollyScale ) {
|
|
646
|
+
|
|
647
|
+
this._dollyIn( dollyScale );
|
|
648
|
+
this.update();
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Programmatically dolly out (zoom out for perspective camera).
|
|
654
|
+
*
|
|
655
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
656
|
+
*/
|
|
657
|
+
dollyOut( dollyScale ) {
|
|
658
|
+
|
|
659
|
+
this._dollyOut( dollyScale );
|
|
660
|
+
this.update();
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Programmatically rotate the camera left (around the vertical axis).
|
|
666
|
+
*
|
|
667
|
+
* @param {number} angle - The rotation angle in radians.
|
|
668
|
+
*/
|
|
669
|
+
rotateLeft( angle ) {
|
|
670
|
+
|
|
671
|
+
this._rotateLeft( angle );
|
|
672
|
+
this.update();
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Programmatically rotate the camera up (around the horizontal axis).
|
|
678
|
+
*
|
|
679
|
+
* @param {number} angle - The rotation angle in radians.
|
|
680
|
+
*/
|
|
681
|
+
rotateUp( angle ) {
|
|
682
|
+
|
|
683
|
+
this._rotateUp( angle );
|
|
684
|
+
this.update();
|
|
685
|
+
|
|
686
|
+
}
|
|
687
|
+
|
|
597
688
|
update( deltaTime = null ) {
|
|
598
689
|
|
|
599
690
|
const position = this.object.position;
|
|
@@ -1481,6 +1572,12 @@ function onPointerDown( event ) {
|
|
|
1481
1572
|
|
|
1482
1573
|
}
|
|
1483
1574
|
|
|
1575
|
+
if ( this._cursorStyle === 'grab' ) {
|
|
1576
|
+
|
|
1577
|
+
this.domElement.style.cursor = 'grabbing';
|
|
1578
|
+
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1484
1581
|
}
|
|
1485
1582
|
|
|
1486
1583
|
function onPointerMove( event ) {
|
|
@@ -1516,6 +1613,12 @@ function onPointerUp( event ) {
|
|
|
1516
1613
|
|
|
1517
1614
|
this.state = _STATE.NONE;
|
|
1518
1615
|
|
|
1616
|
+
if ( this._cursorStyle === 'grab' ) {
|
|
1617
|
+
|
|
1618
|
+
this.domElement.style.cursor = 'grab';
|
|
1619
|
+
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1519
1622
|
break;
|
|
1520
1623
|
|
|
1521
1624
|
case 1:
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearFilter,
|
|
3
|
+
MathUtils,
|
|
3
4
|
Matrix3,
|
|
4
5
|
NearestFilter,
|
|
6
|
+
PerspectiveCamera,
|
|
5
7
|
RGBAFormat,
|
|
6
8
|
ShaderMaterial,
|
|
7
|
-
|
|
9
|
+
Vector3,
|
|
8
10
|
WebGLRenderTarget
|
|
9
11
|
} from 'three';
|
|
10
12
|
import { FullScreenQuad } from '../postprocessing/Pass.js';
|
|
13
|
+
import { frameCorners } from '../utils/CameraUtils.js';
|
|
14
|
+
|
|
15
|
+
const _cameraL = /*@__PURE__*/ new PerspectiveCamera();
|
|
16
|
+
const _cameraR = /*@__PURE__*/ new PerspectiveCamera();
|
|
17
|
+
|
|
18
|
+
// Reusable vectors for screen corner calculations
|
|
19
|
+
const _eyeL = /*@__PURE__*/ new Vector3();
|
|
20
|
+
const _eyeR = /*@__PURE__*/ new Vector3();
|
|
21
|
+
const _screenCenter = /*@__PURE__*/ new Vector3();
|
|
22
|
+
const _screenBottomLeft = /*@__PURE__*/ new Vector3();
|
|
23
|
+
const _screenBottomRight = /*@__PURE__*/ new Vector3();
|
|
24
|
+
const _screenTopLeft = /*@__PURE__*/ new Vector3();
|
|
25
|
+
const _right = /*@__PURE__*/ new Vector3();
|
|
26
|
+
const _up = /*@__PURE__*/ new Vector3();
|
|
27
|
+
const _forward = /*@__PURE__*/ new Vector3();
|
|
11
28
|
|
|
12
29
|
/**
|
|
13
|
-
* A class that creates an anaglyph effect
|
|
30
|
+
* A class that creates an anaglyph effect using physically-correct
|
|
31
|
+
* off-axis stereo projection.
|
|
32
|
+
*
|
|
33
|
+
* This implementation uses CameraUtils.frameCorners() to align stereo
|
|
34
|
+
* camera frustums to a virtual screen plane, providing accurate depth
|
|
35
|
+
* perception with zero parallax at the plane distance.
|
|
14
36
|
*
|
|
15
37
|
* Note that this class can only be used with {@link WebGLRenderer}.
|
|
16
38
|
* When using {@link WebGPURenderer}, use {@link AnaglyphPassNode}.
|
|
@@ -42,13 +64,38 @@ class AnaglyphEffect {
|
|
|
42
64
|
- 0.00155529, - 0.0184503, 1.2264
|
|
43
65
|
] );
|
|
44
66
|
|
|
45
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The interpupillary distance (eye separation) in world units.
|
|
69
|
+
* Typical human IPD is 0.064 meters (64mm).
|
|
70
|
+
*
|
|
71
|
+
* @type {number}
|
|
72
|
+
* @default 0.064
|
|
73
|
+
*/
|
|
74
|
+
this.eyeSep = 0.064;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The distance in world units from the viewer to the virtual
|
|
78
|
+
* screen plane where zero parallax (screen depth) occurs.
|
|
79
|
+
* Objects at this distance appear at the screen surface.
|
|
80
|
+
* Objects closer appear in front of the screen (negative parallax).
|
|
81
|
+
* Objects further appear behind the screen (positive parallax).
|
|
82
|
+
*
|
|
83
|
+
* The screen dimensions are derived from the camera's FOV and aspect ratio
|
|
84
|
+
* at this distance, ensuring the stereo view matches the camera's field of view.
|
|
85
|
+
*
|
|
86
|
+
* @type {number}
|
|
87
|
+
* @default 0.5
|
|
88
|
+
*/
|
|
89
|
+
this.planeDistance = 0.5;
|
|
46
90
|
|
|
47
91
|
const _params = { minFilter: LinearFilter, magFilter: NearestFilter, format: RGBAFormat };
|
|
48
92
|
|
|
49
93
|
const _renderTargetL = new WebGLRenderTarget( width, height, _params );
|
|
50
94
|
const _renderTargetR = new WebGLRenderTarget( width, height, _params );
|
|
51
95
|
|
|
96
|
+
_cameraL.layers.enable( 1 );
|
|
97
|
+
_cameraR.layers.enable( 2 );
|
|
98
|
+
|
|
52
99
|
const _material = new ShaderMaterial( {
|
|
53
100
|
|
|
54
101
|
uniforms: {
|
|
@@ -141,16 +188,64 @@ class AnaglyphEffect {
|
|
|
141
188
|
|
|
142
189
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
143
190
|
|
|
144
|
-
|
|
145
|
-
|
|
191
|
+
// Get the camera's local coordinate axes from its world matrix
|
|
192
|
+
camera.matrixWorld.extractBasis( _right, _up, _forward );
|
|
193
|
+
_right.normalize();
|
|
194
|
+
_up.normalize();
|
|
195
|
+
_forward.normalize();
|
|
196
|
+
|
|
197
|
+
// Calculate eye positions
|
|
198
|
+
const halfSep = this.eyeSep / 2;
|
|
199
|
+
_eyeL.copy( camera.position ).addScaledVector( _right, - halfSep );
|
|
200
|
+
_eyeR.copy( camera.position ).addScaledVector( _right, halfSep );
|
|
201
|
+
|
|
202
|
+
// Calculate screen center (at planeDistance in front of the camera center)
|
|
203
|
+
_screenCenter.copy( camera.position ).addScaledVector( _forward, - this.planeDistance );
|
|
204
|
+
|
|
205
|
+
// Calculate screen dimensions from camera FOV and aspect ratio
|
|
206
|
+
const halfHeight = this.planeDistance * Math.tan( MathUtils.DEG2RAD * camera.fov / 2 );
|
|
207
|
+
const halfWidth = halfHeight * camera.aspect;
|
|
208
|
+
|
|
209
|
+
// Calculate screen corners
|
|
210
|
+
_screenBottomLeft.copy( _screenCenter )
|
|
211
|
+
.addScaledVector( _right, - halfWidth )
|
|
212
|
+
.addScaledVector( _up, - halfHeight );
|
|
213
|
+
|
|
214
|
+
_screenBottomRight.copy( _screenCenter )
|
|
215
|
+
.addScaledVector( _right, halfWidth )
|
|
216
|
+
.addScaledVector( _up, - halfHeight );
|
|
217
|
+
|
|
218
|
+
_screenTopLeft.copy( _screenCenter )
|
|
219
|
+
.addScaledVector( _right, - halfWidth )
|
|
220
|
+
.addScaledVector( _up, halfHeight );
|
|
221
|
+
|
|
222
|
+
// Set up left eye camera
|
|
223
|
+
_cameraL.position.copy( _eyeL );
|
|
224
|
+
_cameraL.near = camera.near;
|
|
225
|
+
_cameraL.far = camera.far;
|
|
226
|
+
frameCorners( _cameraL, _screenBottomLeft, _screenBottomRight, _screenTopLeft, true );
|
|
227
|
+
_cameraL.matrixWorld.compose( _cameraL.position, _cameraL.quaternion, _cameraL.scale );
|
|
228
|
+
_cameraL.matrixWorldInverse.copy( _cameraL.matrixWorld ).invert();
|
|
229
|
+
|
|
230
|
+
// Set up right eye camera
|
|
231
|
+
_cameraR.position.copy( _eyeR );
|
|
232
|
+
_cameraR.near = camera.near;
|
|
233
|
+
_cameraR.far = camera.far;
|
|
234
|
+
frameCorners( _cameraR, _screenBottomLeft, _screenBottomRight, _screenTopLeft, true );
|
|
235
|
+
_cameraR.matrixWorld.compose( _cameraR.position, _cameraR.quaternion, _cameraR.scale );
|
|
236
|
+
_cameraR.matrixWorldInverse.copy( _cameraR.matrixWorld ).invert();
|
|
237
|
+
|
|
238
|
+
// Render left eye
|
|
146
239
|
renderer.setRenderTarget( _renderTargetL );
|
|
147
240
|
renderer.clear();
|
|
148
|
-
renderer.render( scene,
|
|
241
|
+
renderer.render( scene, _cameraL );
|
|
149
242
|
|
|
243
|
+
// Render right eye
|
|
150
244
|
renderer.setRenderTarget( _renderTargetR );
|
|
151
245
|
renderer.clear();
|
|
152
|
-
renderer.render( scene,
|
|
246
|
+
renderer.render( scene, _cameraR );
|
|
153
247
|
|
|
248
|
+
// Composite anaglyph
|
|
154
249
|
renderer.setRenderTarget( null );
|
|
155
250
|
_quad.render( renderer );
|
|
156
251
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BackSide,
|
|
3
|
+
Mesh,
|
|
4
|
+
MeshBasicMaterial,
|
|
5
|
+
SphereGeometry,
|
|
6
|
+
Scene
|
|
7
|
+
} from 'three';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This class represents a scene with a uniform color that can be used as
|
|
11
|
+
* input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents
|
|
12
|
+
* uniform ambient lighting and can be used for Image Based Lighting by
|
|
13
|
+
* assigning it to {@link Scene#environment}.
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* const environment = new ColorEnvironment( 0x00ff00 );
|
|
17
|
+
* const pmremGenerator = new THREE.PMREMGenerator( renderer );
|
|
18
|
+
*
|
|
19
|
+
* const envMap = pmremGenerator.fromScene( environment ).texture;
|
|
20
|
+
* scene.environment = envMap;
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @augments Scene
|
|
24
|
+
* @three_import import { ColorEnvironment } from 'three/addons/environments/ColorEnvironment.js';
|
|
25
|
+
*/
|
|
26
|
+
class ColorEnvironment extends Scene {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new color environment.
|
|
30
|
+
*
|
|
31
|
+
* @param {number|Color} color - The color of the environment.
|
|
32
|
+
*/
|
|
33
|
+
constructor( color = 0xffffff ) {
|
|
34
|
+
|
|
35
|
+
super();
|
|
36
|
+
|
|
37
|
+
this.name = 'ColorEnvironment';
|
|
38
|
+
|
|
39
|
+
const geometry = new SphereGeometry( 1, 16, 16 );
|
|
40
|
+
const material = new MeshBasicMaterial( { color: color, side: BackSide } );
|
|
41
|
+
|
|
42
|
+
this.add( new Mesh( geometry, material ) );
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Frees internal resources. This method should be called
|
|
48
|
+
* when the environment is no longer required.
|
|
49
|
+
*/
|
|
50
|
+
dispose() {
|
|
51
|
+
|
|
52
|
+
this.children[ 0 ].geometry.dispose();
|
|
53
|
+
this.children[ 0 ].material.dispose();
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { ColorEnvironment };
|
|
@@ -90,7 +90,7 @@ function supportedRTT( renderTarget ) {
|
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if ( renderTarget.isWebGLCubeRenderTarget || renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
93
|
+
if ( renderTarget.isCubeRenderTarget || renderTarget.isWebGLCubeRenderTarget || renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
94
94
|
|
|
95
95
|
throw Error( 'EXRExporter.parse: Unsupported render target type, expected instance of WebGLRenderTarget.' );
|
|
96
96
|
|
|
@@ -1852,12 +1852,12 @@ class GLTFWriter {
|
|
|
1852
1852
|
! ( array instanceof Uint8Array ) ) {
|
|
1853
1853
|
|
|
1854
1854
|
console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
|
|
1855
|
-
modifiedAttribute =
|
|
1855
|
+
modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Uint16Array );
|
|
1856
1856
|
|
|
1857
1857
|
} else if ( ( array instanceof Uint32Array || array instanceof Int32Array ) && ! attributeName.startsWith( '_' ) ) {
|
|
1858
1858
|
|
|
1859
1859
|
console.warn( `GLTFExporter: Attribute "${ attributeName }" converted to type FLOAT.` );
|
|
1860
|
-
modifiedAttribute = GLTFExporter.Utils.
|
|
1860
|
+
modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Float32Array );
|
|
1861
1861
|
|
|
1862
1862
|
}
|
|
1863
1863
|
|
|
@@ -2355,6 +2355,13 @@ class GLTFWriter {
|
|
|
2355
2355
|
|
|
2356
2356
|
if ( ! json.nodes ) json.nodes = [];
|
|
2357
2357
|
|
|
2358
|
+
// Handle pivot by creating a container node
|
|
2359
|
+
if ( object.pivot !== null ) {
|
|
2360
|
+
|
|
2361
|
+
return await this._processNodeWithPivotAsync( object );
|
|
2362
|
+
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2358
2365
|
const nodeDef = {};
|
|
2359
2366
|
|
|
2360
2367
|
if ( options.trs ) {
|
|
@@ -2451,6 +2458,126 @@ class GLTFWriter {
|
|
|
2451
2458
|
|
|
2452
2459
|
}
|
|
2453
2460
|
|
|
2461
|
+
/**
|
|
2462
|
+
* Process Object3D node with pivot using container approach
|
|
2463
|
+
* @param {THREE.Object3D} object Object3D with pivot
|
|
2464
|
+
* @return {Promise<number>} Index of the container node
|
|
2465
|
+
*/
|
|
2466
|
+
async _processNodeWithPivotAsync( object ) {
|
|
2467
|
+
|
|
2468
|
+
const json = this.json;
|
|
2469
|
+
const options = this.options;
|
|
2470
|
+
const nodeMap = this.nodeMap;
|
|
2471
|
+
|
|
2472
|
+
const pivot = object.pivot;
|
|
2473
|
+
|
|
2474
|
+
// Container node: holds position + pivot offset, rotation, scale
|
|
2475
|
+
// Animations will target this node
|
|
2476
|
+
const containerDef = {};
|
|
2477
|
+
|
|
2478
|
+
const rotation = object.quaternion.toArray();
|
|
2479
|
+
const position = [
|
|
2480
|
+
object.position.x + pivot.x,
|
|
2481
|
+
object.position.y + pivot.y,
|
|
2482
|
+
object.position.z + pivot.z
|
|
2483
|
+
];
|
|
2484
|
+
const scale = object.scale.toArray();
|
|
2485
|
+
|
|
2486
|
+
if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
|
|
2487
|
+
|
|
2488
|
+
containerDef.rotation = rotation;
|
|
2489
|
+
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
|
|
2493
|
+
|
|
2494
|
+
containerDef.translation = position;
|
|
2495
|
+
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
|
|
2499
|
+
|
|
2500
|
+
containerDef.scale = scale;
|
|
2501
|
+
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
// Store pivot in extras for round-trip reconstruction
|
|
2505
|
+
containerDef.extras = { pivot: pivot.toArray() };
|
|
2506
|
+
|
|
2507
|
+
if ( object.name !== '' ) containerDef.name = String( object.name );
|
|
2508
|
+
|
|
2509
|
+
this.serializeUserData( object, containerDef );
|
|
2510
|
+
|
|
2511
|
+
const containerIndex = json.nodes.push( containerDef ) - 1;
|
|
2512
|
+
|
|
2513
|
+
// Map original object to container so animations target it
|
|
2514
|
+
nodeMap.set( object, containerIndex );
|
|
2515
|
+
|
|
2516
|
+
// Child node: holds mesh with -pivot offset
|
|
2517
|
+
const childDef = {};
|
|
2518
|
+
|
|
2519
|
+
const childPosition = [ - pivot.x, - pivot.y, - pivot.z ];
|
|
2520
|
+
|
|
2521
|
+
if ( ! equalArray( childPosition, [ 0, 0, 0 ] ) ) {
|
|
2522
|
+
|
|
2523
|
+
childDef.translation = childPosition;
|
|
2524
|
+
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
2528
|
+
|
|
2529
|
+
const meshIndex = await this.processMeshAsync( object );
|
|
2530
|
+
|
|
2531
|
+
if ( meshIndex !== null ) childDef.mesh = meshIndex;
|
|
2532
|
+
|
|
2533
|
+
} else if ( object.isCamera ) {
|
|
2534
|
+
|
|
2535
|
+
childDef.camera = this.processCamera( object );
|
|
2536
|
+
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
if ( object.isSkinnedMesh ) this.skins.push( object );
|
|
2540
|
+
|
|
2541
|
+
const childIndex = json.nodes.push( childDef ) - 1;
|
|
2542
|
+
|
|
2543
|
+
// Build children array for container
|
|
2544
|
+
const containerChildren = [ childIndex ];
|
|
2545
|
+
|
|
2546
|
+
// Process object's children as children of the child node
|
|
2547
|
+
if ( object.children.length > 0 ) {
|
|
2548
|
+
|
|
2549
|
+
const grandchildren = [];
|
|
2550
|
+
|
|
2551
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
2552
|
+
|
|
2553
|
+
const child = object.children[ i ];
|
|
2554
|
+
|
|
2555
|
+
if ( child.visible || options.onlyVisible === false ) {
|
|
2556
|
+
|
|
2557
|
+
const childNodeIndex = await this.processNodeAsync( child );
|
|
2558
|
+
|
|
2559
|
+
if ( childNodeIndex !== null ) grandchildren.push( childNodeIndex );
|
|
2560
|
+
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
if ( grandchildren.length > 0 ) childDef.children = grandchildren;
|
|
2566
|
+
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
containerDef.children = containerChildren;
|
|
2570
|
+
|
|
2571
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2572
|
+
|
|
2573
|
+
ext.writeNode && ext.writeNode( object, containerDef );
|
|
2574
|
+
|
|
2575
|
+
} );
|
|
2576
|
+
|
|
2577
|
+
return containerIndex;
|
|
2578
|
+
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2454
2581
|
/**
|
|
2455
2582
|
* Process Scene
|
|
2456
2583
|
* @param {Scene} scene Scene to process
|
|
@@ -3538,9 +3665,9 @@ GLTFExporter.Utils = {
|
|
|
3538
3665
|
|
|
3539
3666
|
},
|
|
3540
3667
|
|
|
3541
|
-
|
|
3668
|
+
toTypedBufferAttribute: function ( srcAttribute, TypedArray ) {
|
|
3542
3669
|
|
|
3543
|
-
const dstAttribute = new BufferAttribute( new
|
|
3670
|
+
const dstAttribute = new BufferAttribute( new TypedArray( srcAttribute.count * srcAttribute.itemSize ), srcAttribute.itemSize, false );
|
|
3544
3671
|
|
|
3545
3672
|
if ( ! srcAttribute.normalized && ! srcAttribute.isInterleavedBufferAttribute ) {
|
|
3546
3673
|
|
|
@@ -501,7 +501,6 @@ function buildHierarchy( object, parentNode, materials, usedNames, files, option
|
|
|
501
501
|
function buildXform( object, usedNames ) {
|
|
502
502
|
|
|
503
503
|
const name = getName( object, usedNames );
|
|
504
|
-
const transform = buildMatrix( object.matrix );
|
|
505
504
|
|
|
506
505
|
if ( object.matrix.determinant() < 0 ) {
|
|
507
506
|
|
|
@@ -514,8 +513,28 @@ function buildXform( object, usedNames ) {
|
|
|
514
513
|
|
|
515
514
|
const node = new USDNode( name, 'Xform' );
|
|
516
515
|
|
|
517
|
-
|
|
518
|
-
|
|
516
|
+
if ( object.pivot !== null ) {
|
|
517
|
+
|
|
518
|
+
// Export with pivot using separate transform ops
|
|
519
|
+
const p = object.position;
|
|
520
|
+
const q = object.quaternion;
|
|
521
|
+
const s = object.scale;
|
|
522
|
+
const piv = object.pivot;
|
|
523
|
+
|
|
524
|
+
node.addProperty( `float3 xformOp:translate = (${p.x.toPrecision( PRECISION )}, ${p.y.toPrecision( PRECISION )}, ${p.z.toPrecision( PRECISION )})` );
|
|
525
|
+
node.addProperty( `float3 xformOp:translate:pivot = (${piv.x.toPrecision( PRECISION )}, ${piv.y.toPrecision( PRECISION )}, ${piv.z.toPrecision( PRECISION )})` );
|
|
526
|
+
node.addProperty( `quatf xformOp:orient = (${q.w.toPrecision( PRECISION )}, ${q.x.toPrecision( PRECISION )}, ${q.y.toPrecision( PRECISION )}, ${q.z.toPrecision( PRECISION )})` );
|
|
527
|
+
node.addProperty( `float3 xformOp:scale = (${s.x.toPrecision( PRECISION )}, ${s.y.toPrecision( PRECISION )}, ${s.z.toPrecision( PRECISION )})` );
|
|
528
|
+
node.addProperty( 'uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]' );
|
|
529
|
+
|
|
530
|
+
} else {
|
|
531
|
+
|
|
532
|
+
// Export as single transform matrix
|
|
533
|
+
const transform = buildMatrix( object.matrix );
|
|
534
|
+
node.addProperty( `matrix4d xformOp:transform = ${transform}` );
|
|
535
|
+
node.addProperty( 'uniform token[] xformOpOrder = ["xformOp:transform"]' );
|
|
536
|
+
|
|
537
|
+
}
|
|
519
538
|
|
|
520
539
|
return node;
|
|
521
540
|
|