super-three 0.171.0 → 0.173.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/LICENSE +1 -1
- package/README.md +1 -1
- package/build/three.cjs +594 -427
- package/build/three.core.js +515 -81
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +79 -350
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +20 -7
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +29362 -3427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +29361 -3427
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +9 -7
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +48 -37
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +34 -29
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +4 -2
- package/examples/jsm/loaders/GLTFLoader.js +22 -4
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -2
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +14 -13
- package/examples/jsm/misc/Volume.js +27 -17
- package/examples/jsm/misc/VolumeSlice.js +7 -5
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +29 -24
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +4 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +18 -5
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/ImageUtils.js +1 -11
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +476 -23
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +121 -10
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +78 -20
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +95 -0
- package/src/nodes/Nodes.js +5 -6
- package/src/nodes/TSL.js +6 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +47 -6
- package/src/nodes/accessors/BatchNode.js +42 -6
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +113 -3
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +306 -12
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +65 -5
- package/src/nodes/accessors/Object3DNode.js +101 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +56 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +186 -0
- package/src/nodes/accessors/ReferenceNode.js +201 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +209 -8
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +38 -2
- package/src/nodes/accessors/Texture3DNode.js +91 -7
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +316 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +231 -25
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +80 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +350 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1166 -26
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +152 -1
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +51 -10
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +98 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +105 -6
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +146 -7
- package/src/nodes/core/VaryingNode.js +100 -3
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +300 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +96 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +110 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +174 -2
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +134 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +241 -35
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +78 -4
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +627 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +329 -18
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +2 -2
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +3 -2
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +39 -3
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +82 -2
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +54 -0
- package/src/nodes/utils/Timer.js +40 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/objects/ClippingGroup.js +49 -0
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +30 -4
- package/src/renderers/common/Animation.js +85 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +502 -44
- package/src/renderers/common/Background.js +48 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +45 -6
- package/src/renderers/common/ClippingContext.js +108 -15
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +91 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +78 -35
- package/src/renderers/common/Lighting.js +34 -6
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +99 -11
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +39 -10
- package/src/renderers/common/RenderContext.js +201 -2
- package/src/renderers/common/RenderContexts.js +59 -6
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +40 -3
- package/src/renderers/common/RenderObject.js +400 -17
- package/src/renderers/common/RenderObjects.js +103 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1170 -86
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +120 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +97 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +225 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +141 -2
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +76 -10
- package/src/renderers/common/nodes/NodeBuilderState.js +99 -5
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +90 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +243 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +352 -78
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +819 -116
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -18
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +58 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +168 -22
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +578 -164
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +36 -0
- package/src/renderers/webgpu/WebGPURenderer.js +36 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +674 -52
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +95 -14
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +94 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +262 -18
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +116 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +19 -2
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -190,7 +190,8 @@ class GLTFExporter {
|
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* Parse scenes and generate GLTF output
|
|
193
|
-
*
|
|
193
|
+
*
|
|
194
|
+
* @param {Scene|Array<Scene>} input Scene or Array of THREE.Scenes
|
|
194
195
|
* @param {Function} onDone Callback on completed
|
|
195
196
|
* @param {Function} onError Callback on errors
|
|
196
197
|
* @param {Object} options options
|
|
@@ -342,9 +343,10 @@ function isIdentityMatrix( matrix ) {
|
|
|
342
343
|
|
|
343
344
|
/**
|
|
344
345
|
* Get the min and max vectors from the given attribute
|
|
346
|
+
*
|
|
345
347
|
* @param {BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
|
|
346
|
-
* @param {
|
|
347
|
-
* @param {
|
|
348
|
+
* @param {Number} start Start index
|
|
349
|
+
* @param {Number} count Range to cover
|
|
348
350
|
* @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
|
|
349
351
|
*/
|
|
350
352
|
function getMinMax( attribute, start, count ) {
|
|
@@ -398,8 +400,8 @@ function getMinMax( attribute, start, count ) {
|
|
|
398
400
|
* Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
|
|
399
401
|
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
|
|
400
402
|
*
|
|
401
|
-
* @param {
|
|
402
|
-
* @returns {
|
|
403
|
+
* @param {Number} bufferSize The size the original buffer. Should be an integer.
|
|
404
|
+
* @returns {Number} new buffer size with required padding as an integer.
|
|
403
405
|
*
|
|
404
406
|
*/
|
|
405
407
|
function getPaddedBufferSize( bufferSize ) {
|
|
@@ -412,7 +414,7 @@ function getPaddedBufferSize( bufferSize ) {
|
|
|
412
414
|
* Returns a buffer aligned to 4-byte boundary.
|
|
413
415
|
*
|
|
414
416
|
* @param {ArrayBuffer} arrayBuffer Buffer to pad
|
|
415
|
-
* @param {
|
|
417
|
+
* @param {Number} [paddingByte=0] Should be an integer
|
|
416
418
|
* @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
|
|
417
419
|
*/
|
|
418
420
|
function getPaddedArrayBuffer( arrayBuffer, paddingByte = 0 ) {
|
|
@@ -543,9 +545,10 @@ class GLTFWriter {
|
|
|
543
545
|
|
|
544
546
|
/**
|
|
545
547
|
* Parse scenes and generate GLTF output
|
|
546
|
-
*
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
548
|
+
*
|
|
549
|
+
* @param {Scene|Array<Scene>} input Scene or Array of THREE.Scenes
|
|
550
|
+
* @param {Function} onDone Callback on completed
|
|
551
|
+
* @param {Object} options options
|
|
549
552
|
*/
|
|
550
553
|
async writeAsync( input, onDone, options = {} ) {
|
|
551
554
|
|
|
@@ -709,8 +712,10 @@ class GLTFWriter {
|
|
|
709
712
|
|
|
710
713
|
/**
|
|
711
714
|
* Returns ids for buffer attributes.
|
|
712
|
-
*
|
|
713
|
-
* @
|
|
715
|
+
*
|
|
716
|
+
* @param {Object} attribute
|
|
717
|
+
* @param {boolean} [isRelativeCopy=false]
|
|
718
|
+
* @return {Number} An integer
|
|
714
719
|
*/
|
|
715
720
|
getUID( attribute, isRelativeCopy = false ) {
|
|
716
721
|
|
|
@@ -964,7 +969,7 @@ class GLTFWriter {
|
|
|
964
969
|
/**
|
|
965
970
|
* Process a buffer to append to the default one.
|
|
966
971
|
* @param {ArrayBuffer} buffer
|
|
967
|
-
* @return {
|
|
972
|
+
* @return {0}
|
|
968
973
|
*/
|
|
969
974
|
processBuffer( buffer ) {
|
|
970
975
|
|
|
@@ -986,7 +991,7 @@ class GLTFWriter {
|
|
|
986
991
|
* @param {number} componentType
|
|
987
992
|
* @param {number} start
|
|
988
993
|
* @param {number} count
|
|
989
|
-
* @param {number} target
|
|
994
|
+
* @param {number?} target Target usage of the BufferView
|
|
990
995
|
* @return {Object}
|
|
991
996
|
*/
|
|
992
997
|
processBufferView( attribute, componentType, start, count, target ) {
|
|
@@ -1140,7 +1145,7 @@ class GLTFWriter {
|
|
|
1140
1145
|
/**
|
|
1141
1146
|
* Process and generate a BufferView from an image Blob.
|
|
1142
1147
|
* @param {Blob} blob
|
|
1143
|
-
* @return {Promise<
|
|
1148
|
+
* @return {Promise<Number>} An integer
|
|
1144
1149
|
*/
|
|
1145
1150
|
processBufferViewImage( blob ) {
|
|
1146
1151
|
|
|
@@ -1175,10 +1180,10 @@ class GLTFWriter {
|
|
|
1175
1180
|
/**
|
|
1176
1181
|
* Process attribute to generate an accessor
|
|
1177
1182
|
* @param {BufferAttribute} attribute Attribute to process
|
|
1178
|
-
* @param {THREE.BufferGeometry} geometry
|
|
1179
|
-
* @param {
|
|
1180
|
-
* @param {
|
|
1181
|
-
* @return {
|
|
1183
|
+
* @param {THREE.BufferGeometry?} geometry Geometry used for truncated draw range
|
|
1184
|
+
* @param {Number} [start=0]
|
|
1185
|
+
* @param {Number} [count=Infinity]
|
|
1186
|
+
* @return {Number?} Index of the processed accessor on the "accessors" array
|
|
1182
1187
|
*/
|
|
1183
1188
|
processAccessor( attribute, geometry, start, count ) {
|
|
1184
1189
|
|
|
@@ -1273,10 +1278,10 @@ class GLTFWriter {
|
|
|
1273
1278
|
/**
|
|
1274
1279
|
* Process image
|
|
1275
1280
|
* @param {Image} image to process
|
|
1276
|
-
* @param {
|
|
1281
|
+
* @param {Number} format Identifier of the format (RGBAFormat)
|
|
1277
1282
|
* @param {Boolean} flipY before writing out the image
|
|
1278
1283
|
* @param {String} mimeType export format
|
|
1279
|
-
* @return {
|
|
1284
|
+
* @return {Number} Index of the processed texture in the "images" array
|
|
1280
1285
|
*/
|
|
1281
1286
|
processImage( image, format, flipY, mimeType = 'image/png' ) {
|
|
1282
1287
|
|
|
@@ -1413,7 +1418,7 @@ class GLTFWriter {
|
|
|
1413
1418
|
/**
|
|
1414
1419
|
* Process sampler
|
|
1415
1420
|
* @param {Texture} map Texture to process
|
|
1416
|
-
* @return {
|
|
1421
|
+
* @return {Number} Index of the processed texture in the "samplers" array
|
|
1417
1422
|
*/
|
|
1418
1423
|
processSampler( map ) {
|
|
1419
1424
|
|
|
@@ -1435,7 +1440,7 @@ class GLTFWriter {
|
|
|
1435
1440
|
/**
|
|
1436
1441
|
* Process texture
|
|
1437
1442
|
* @param {Texture} map Map to process
|
|
1438
|
-
* @return {
|
|
1443
|
+
* @return {Promise<Number>} Index of the processed texture in the "textures" array
|
|
1439
1444
|
*/
|
|
1440
1445
|
async processTextureAsync( map ) {
|
|
1441
1446
|
|
|
@@ -1481,7 +1486,7 @@ class GLTFWriter {
|
|
|
1481
1486
|
/**
|
|
1482
1487
|
* Process material
|
|
1483
1488
|
* @param {THREE.Material} material Material to process
|
|
1484
|
-
* @return {
|
|
1489
|
+
* @return {Promise<Number|null>} Index of the processed material in the "materials" array
|
|
1485
1490
|
*/
|
|
1486
1491
|
async processMaterialAsync( material ) {
|
|
1487
1492
|
|
|
@@ -1657,7 +1662,7 @@ class GLTFWriter {
|
|
|
1657
1662
|
/**
|
|
1658
1663
|
* Process mesh
|
|
1659
1664
|
* @param {THREE.Mesh} mesh Mesh to process
|
|
1660
|
-
* @return {
|
|
1665
|
+
* @return {Promise<Number|null>} Index of the processed mesh in the "meshes" array
|
|
1661
1666
|
*/
|
|
1662
1667
|
async processMeshAsync( mesh ) {
|
|
1663
1668
|
|
|
@@ -2062,7 +2067,7 @@ class GLTFWriter {
|
|
|
2062
2067
|
/**
|
|
2063
2068
|
* Process camera
|
|
2064
2069
|
* @param {THREE.Camera} camera Camera to process
|
|
2065
|
-
* @return {
|
|
2070
|
+
* @return {Number} Index of the processed mesh in the "camera" array
|
|
2066
2071
|
*/
|
|
2067
2072
|
processCamera( camera ) {
|
|
2068
2073
|
|
|
@@ -2262,8 +2267,8 @@ class GLTFWriter {
|
|
|
2262
2267
|
|
|
2263
2268
|
/**
|
|
2264
2269
|
* Process Object3D node
|
|
2265
|
-
* @param {THREE.Object3D}
|
|
2266
|
-
* @return {
|
|
2270
|
+
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
2271
|
+
* @return {Promise<Number>} Index of the node in the nodes list
|
|
2267
2272
|
*/
|
|
2268
2273
|
async processNodeAsync( object ) {
|
|
2269
2274
|
|
|
@@ -2370,7 +2375,7 @@ class GLTFWriter {
|
|
|
2370
2375
|
|
|
2371
2376
|
/**
|
|
2372
2377
|
* Process Scene
|
|
2373
|
-
* @param {Scene}
|
|
2378
|
+
* @param {Scene} scene Scene to process
|
|
2374
2379
|
*/
|
|
2375
2380
|
async processSceneAsync( scene ) {
|
|
2376
2381
|
|
|
@@ -2414,7 +2419,7 @@ class GLTFWriter {
|
|
|
2414
2419
|
|
|
2415
2420
|
/**
|
|
2416
2421
|
* Creates a Scene to hold a list of objects and parse it
|
|
2417
|
-
* @param {Array} objects List of objects to process
|
|
2422
|
+
* @param {Array<THREE.Object3D>} objects List of objects to process
|
|
2418
2423
|
*/
|
|
2419
2424
|
async processObjectsAsync( objects ) {
|
|
2420
2425
|
|
|
@@ -120,7 +120,7 @@ const KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER = {
|
|
|
120
120
|
[ HalfFloatType ]: [ 0xbf800000, 0x3f800000 ],
|
|
121
121
|
[ UnsignedByteType ]: [ 0, 255 ],
|
|
122
122
|
|
|
123
|
-
}
|
|
123
|
+
};
|
|
124
124
|
|
|
125
125
|
const ERROR_INPUT = 'THREE.KTX2Exporter: Supported inputs are DataTexture, Data3DTexture, or WebGLRenderer and WebGLRenderTarget.';
|
|
126
126
|
const ERROR_FORMAT = 'THREE.KTX2Exporter: Supported formats are RGBAFormat, RGFormat, or RedFormat.';
|
|
@@ -124,7 +124,7 @@ class PLYExporter {
|
|
|
124
124
|
if ( includeIndices && faceCount !== Math.floor( faceCount ) ) {
|
|
125
125
|
|
|
126
126
|
// point cloud meshes will not have an index array and may not have a
|
|
127
|
-
// number of vertices that is
|
|
127
|
+
// number of vertices that is divisible by 3 (and therefore representable
|
|
128
128
|
// as triangles)
|
|
129
129
|
console.error(
|
|
130
130
|
|
|
@@ -206,7 +206,7 @@ class PLYExporter {
|
|
|
206
206
|
// 2 uv values at 4 bytes
|
|
207
207
|
const vertexListLength = vertexCount * ( 4 * 3 + ( includeNormals ? 4 * 3 : 0 ) + ( includeColors ? 3 : 0 ) + ( includeUVs ? 4 * 2 : 0 ) );
|
|
208
208
|
|
|
209
|
-
// 1 byte shape
|
|
209
|
+
// 1 byte shape descriptor
|
|
210
210
|
// 3 vertex indices at ${indexByteCount} bytes
|
|
211
211
|
const faceListLength = includeIndices ? faceCount * ( indexByteCount * 3 + 1 ) : 0;
|
|
212
212
|
const output = new DataView( new ArrayBuffer( headerBin.length + vertexListLength + faceListLength ) );
|
|
@@ -33,20 +33,9 @@ class TextGeometry extends ExtrudeGeometry {
|
|
|
33
33
|
|
|
34
34
|
const shapes = font.generateShapes( text, parameters.size );
|
|
35
35
|
|
|
36
|
-
// translate parameters to ExtrudeGeometry API
|
|
37
|
-
|
|
38
|
-
if ( parameters.depth === undefined && parameters.height !== undefined ) {
|
|
39
|
-
|
|
40
|
-
console.warn( 'THREE.TextGeometry: .height is now depreciated. Please use .depth instead' ); // @deprecated, r163
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
parameters.depth = parameters.depth !== undefined ?
|
|
45
|
-
parameters.depth : parameters.height !== undefined ?
|
|
46
|
-
parameters.height : 50;
|
|
47
|
-
|
|
48
36
|
// defaults
|
|
49
37
|
|
|
38
|
+
if ( parameters.depth === undefined ) parameters.depth = 50;
|
|
50
39
|
if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
|
|
51
40
|
if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
|
|
52
41
|
if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NodeMaterial,
|
|
2
3
|
BoxGeometry,
|
|
3
4
|
BufferAttribute,
|
|
4
5
|
Mesh,
|
|
5
6
|
PlaneGeometry,
|
|
7
|
+
DoubleSide,
|
|
6
8
|
Vector3,
|
|
7
9
|
} from 'three';
|
|
8
|
-
import {
|
|
10
|
+
import { texture as textureNode, cubeTexture, texture3D, float, vec4, attribute } from 'three/tsl';
|
|
9
11
|
import { mergeGeometries } from '../utils/BufferGeometryUtils.js';
|
|
10
12
|
|
|
11
13
|
class TextureHelper extends Mesh {
|
|
@@ -13,17 +15,25 @@ class TextureHelper extends Mesh {
|
|
|
13
15
|
constructor( texture, width = 1, height = 1, depth = 1 ) {
|
|
14
16
|
|
|
15
17
|
const material = new NodeMaterial();
|
|
18
|
+
material.side = DoubleSide;
|
|
19
|
+
material.transparent = true;
|
|
16
20
|
material.name = 'TextureHelper';
|
|
17
21
|
|
|
18
22
|
let colorNode;
|
|
19
23
|
|
|
24
|
+
const uvw = attribute( 'uvw' );
|
|
25
|
+
|
|
20
26
|
if ( texture.isCubeTexture ) {
|
|
21
27
|
|
|
22
|
-
colorNode = cubeTexture( texture );
|
|
28
|
+
colorNode = cubeTexture( texture ).sample( uvw );
|
|
23
29
|
|
|
24
30
|
} else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
|
|
25
31
|
|
|
26
|
-
colorNode = texture3D( texture );
|
|
32
|
+
colorNode = texture3D( texture ).sample( uvw );
|
|
33
|
+
|
|
34
|
+
} else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
|
|
35
|
+
|
|
36
|
+
colorNode = textureNode( texture ).sample( uvw.xy ).depth( uvw.z );
|
|
27
37
|
|
|
28
38
|
} else {
|
|
29
39
|
|
|
@@ -122,7 +132,7 @@ function createCubeGeometry( width, height, depth ) {
|
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
geometry.deleteAttribute( 'uv' );
|
|
125
|
-
geometry.setAttribute( '
|
|
135
|
+
geometry.setAttribute( 'uvw', uvw );
|
|
126
136
|
|
|
127
137
|
return geometry;
|
|
128
138
|
|
|
@@ -162,7 +172,7 @@ function createSliceGeometry( texture, width, height, depth ) {
|
|
|
162
172
|
}
|
|
163
173
|
|
|
164
174
|
geometry.deleteAttribute( 'uv' );
|
|
165
|
-
geometry.setAttribute( '
|
|
175
|
+
geometry.setAttribute( 'uvw', uvw );
|
|
166
176
|
|
|
167
177
|
geometries.push( geometry );
|
|
168
178
|
|
|
@@ -7,97 +7,154 @@ import {
|
|
|
7
7
|
const _pointer = new Vector2();
|
|
8
8
|
const _event = { type: '', data: _pointer };
|
|
9
9
|
|
|
10
|
+
// TODO: Dispatch pointerevents too
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The XR events that are mapped to "standard" pointer events
|
|
14
|
+
*/
|
|
15
|
+
const _events = {
|
|
16
|
+
'move': 'mousemove',
|
|
17
|
+
'select': 'click',
|
|
18
|
+
'selectstart': 'mousedown',
|
|
19
|
+
'selectend': 'mouseup'
|
|
20
|
+
};
|
|
21
|
+
|
|
10
22
|
const _raycaster = new Raycaster();
|
|
11
23
|
|
|
12
24
|
class InteractiveGroup extends Group {
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
constructor() {
|
|
27
|
+
|
|
28
|
+
super();
|
|
29
|
+
|
|
30
|
+
this.raycaster = new Raycaster();
|
|
15
31
|
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
this.element = null;
|
|
33
|
+
this.camera = null;
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
this.controllers = [];
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
this._onPointerEvent = this.onPointerEvent.bind( this );
|
|
38
|
+
this._onXRControllerEvent = this.onXRControllerEvent.bind( this );
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onPointerEvent( event ) {
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
event.stopPropagation();
|
|
26
45
|
|
|
27
|
-
|
|
28
|
-
_pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
|
|
46
|
+
const rect = this.element.getBoundingClientRect();
|
|
29
47
|
|
|
30
|
-
|
|
48
|
+
_pointer.x = ( event.clientX - rect.left ) / rect.width * 2 - 1;
|
|
49
|
+
_pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
|
|
31
50
|
|
|
32
|
-
|
|
51
|
+
this.raycaster.setFromCamera( _pointer, this.camera );
|
|
33
52
|
|
|
34
|
-
|
|
53
|
+
const intersects = this.raycaster.intersectObjects( this.children, false );
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
if ( intersects.length > 0 ) {
|
|
37
56
|
|
|
38
|
-
|
|
39
|
-
const uv = intersection.uv;
|
|
57
|
+
const intersection = intersects[ 0 ];
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
const object = intersection.object;
|
|
60
|
+
const uv = intersection.uv;
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
_event.type = event.type;
|
|
63
|
+
_event.data.set( uv.x, 1 - uv.y );
|
|
45
64
|
|
|
46
|
-
|
|
65
|
+
object.dispatchEvent( _event );
|
|
47
66
|
|
|
48
67
|
}
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onXRControllerEvent( event ) {
|
|
72
|
+
|
|
73
|
+
const controller = event.target;
|
|
74
|
+
|
|
75
|
+
_raycaster.setFromXRController( controller );
|
|
76
|
+
|
|
77
|
+
const intersections = _raycaster.intersectObjects( this.children, false );
|
|
78
|
+
|
|
79
|
+
if ( intersections.length > 0 ) {
|
|
80
|
+
|
|
81
|
+
const intersection = intersections[ 0 ];
|
|
82
|
+
|
|
83
|
+
const object = intersection.object;
|
|
84
|
+
const uv = intersection.uv;
|
|
85
|
+
|
|
86
|
+
_event.type = _events[ event.type ];
|
|
87
|
+
_event.data.set( uv.x, 1 - uv.y );
|
|
88
|
+
|
|
89
|
+
object.dispatchEvent( _event );
|
|
90
|
+
|
|
91
|
+
}
|
|
57
92
|
|
|
58
93
|
}
|
|
59
94
|
|
|
60
|
-
|
|
95
|
+
listenToPointerEvents( renderer, camera ) {
|
|
61
96
|
|
|
62
|
-
|
|
97
|
+
this.camera = camera;
|
|
98
|
+
this.element = renderer.domElement;
|
|
63
99
|
|
|
64
|
-
|
|
100
|
+
this.element.addEventListener( 'pointerdown', this._onPointerEvent );
|
|
101
|
+
this.element.addEventListener( 'pointerup', this._onPointerEvent );
|
|
102
|
+
this.element.addEventListener( 'pointermove', this._onPointerEvent );
|
|
103
|
+
this.element.addEventListener( 'mousedown', this._onPointerEvent );
|
|
104
|
+
this.element.addEventListener( 'mouseup', this._onPointerEvent );
|
|
105
|
+
this.element.addEventListener( 'mousemove', this._onPointerEvent );
|
|
106
|
+
this.element.addEventListener( 'click', this._onPointerEvent );
|
|
65
107
|
|
|
66
|
-
|
|
67
|
-
'move': 'mousemove',
|
|
68
|
-
'select': 'click',
|
|
69
|
-
'selectstart': 'mousedown',
|
|
70
|
-
'selectend': 'mouseup'
|
|
71
|
-
};
|
|
108
|
+
}
|
|
72
109
|
|
|
73
|
-
|
|
110
|
+
disconnectionPointerEvents() {
|
|
74
111
|
|
|
75
|
-
|
|
112
|
+
if ( this.element !== null ) {
|
|
76
113
|
|
|
77
|
-
|
|
114
|
+
this.element.removeEventListener( 'pointerdown', this._onPointerEvent );
|
|
115
|
+
this.element.removeEventListener( 'pointerup', this._onPointerEvent );
|
|
116
|
+
this.element.removeEventListener( 'pointermove', this._onPointerEvent );
|
|
117
|
+
this.element.removeEventListener( 'mousedown', this._onPointerEvent );
|
|
118
|
+
this.element.removeEventListener( 'mouseup', this._onPointerEvent );
|
|
119
|
+
this.element.removeEventListener( 'mousemove', this._onPointerEvent );
|
|
120
|
+
this.element.removeEventListener( 'click', this._onPointerEvent );
|
|
78
121
|
|
|
79
|
-
|
|
122
|
+
}
|
|
80
123
|
|
|
81
|
-
|
|
124
|
+
}
|
|
82
125
|
|
|
83
|
-
|
|
126
|
+
listenToXRControllerEvents( controller ) {
|
|
84
127
|
|
|
85
|
-
|
|
86
|
-
|
|
128
|
+
this.controllers.push( controller );
|
|
129
|
+
controller.addEventListener( 'move', this._onXRControllerEvent );
|
|
130
|
+
controller.addEventListener( 'select', this._onXRControllerEvent );
|
|
131
|
+
controller.addEventListener( 'selectstart', this._onXRControllerEvent );
|
|
132
|
+
controller.addEventListener( 'selectend', this._onXRControllerEvent );
|
|
87
133
|
|
|
88
|
-
|
|
89
|
-
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
disconnectXrControllerEvents() {
|
|
90
137
|
|
|
91
|
-
|
|
138
|
+
for ( const controller of this.controllers ) {
|
|
92
139
|
|
|
93
|
-
|
|
140
|
+
controller.removeEventListener( 'move', this._onXRControllerEvent );
|
|
141
|
+
controller.removeEventListener( 'select', this._onXRControllerEvent );
|
|
142
|
+
controller.removeEventListener( 'selectstart', this._onXRControllerEvent );
|
|
143
|
+
controller.removeEventListener( 'selectend', this._onXRControllerEvent );
|
|
94
144
|
|
|
95
145
|
}
|
|
96
146
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
disconnect() {
|
|
150
|
+
|
|
151
|
+
this.disconnectionPointerEvents();
|
|
152
|
+
this.disconnectXrControllerEvents();
|
|
153
|
+
|
|
154
|
+
this.camera = null;
|
|
155
|
+
this.element = null;
|
|
156
|
+
|
|
157
|
+
this.controllers = [];
|
|
101
158
|
|
|
102
159
|
}
|
|
103
160
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import MP4Box from 'https://cdn.jsdelivr.net/npm/mp4box@0.5.3/+esm';
|
|
2
|
+
|
|
3
|
+
// From: https://w3c.github.io/webcodecs/samples/video-decode-display/
|
|
4
|
+
|
|
5
|
+
// Wraps an MP4Box File as a WritableStream underlying sink.
|
|
6
|
+
class MP4FileSink {
|
|
7
|
+
#setStatus = null;
|
|
8
|
+
#file = null;
|
|
9
|
+
#offset = 0;
|
|
10
|
+
|
|
11
|
+
constructor(file, setStatus) {
|
|
12
|
+
this.#file = file;
|
|
13
|
+
this.#setStatus = setStatus;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
write(chunk) {
|
|
17
|
+
// MP4Box.js requires buffers to be ArrayBuffers, but we have a Uint8Array.
|
|
18
|
+
const buffer = new ArrayBuffer(chunk.byteLength);
|
|
19
|
+
new Uint8Array(buffer).set(chunk);
|
|
20
|
+
|
|
21
|
+
// Inform MP4Box where in the file this chunk is from.
|
|
22
|
+
buffer.fileStart = this.#offset;
|
|
23
|
+
this.#offset += buffer.byteLength;
|
|
24
|
+
|
|
25
|
+
// Append chunk.
|
|
26
|
+
this.#setStatus("fetch", (this.#offset / (1024 ** 2)).toFixed(1) + " MiB");
|
|
27
|
+
this.#file.appendBuffer(buffer);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
close() {
|
|
31
|
+
this.#setStatus("fetch", "Done");
|
|
32
|
+
this.#file.flush();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Demuxes the first video track of an MP4 file using MP4Box, calling
|
|
37
|
+
// `onConfig()` and `onChunk()` with appropriate WebCodecs objects.
|
|
38
|
+
export class MP4Demuxer {
|
|
39
|
+
#onConfig = null;
|
|
40
|
+
#onChunk = null;
|
|
41
|
+
#setStatus = null;
|
|
42
|
+
#file = null;
|
|
43
|
+
|
|
44
|
+
constructor(uri, {onConfig, onChunk, setStatus}) {
|
|
45
|
+
this.#onConfig = onConfig;
|
|
46
|
+
this.#onChunk = onChunk;
|
|
47
|
+
this.#setStatus = setStatus;
|
|
48
|
+
|
|
49
|
+
// Configure an MP4Box File for demuxing.
|
|
50
|
+
this.#file = MP4Box.createFile();
|
|
51
|
+
this.#file.onError = error => setStatus("demux", error);
|
|
52
|
+
this.#file.onReady = this.#onReady.bind(this);
|
|
53
|
+
this.#file.onSamples = this.#onSamples.bind(this);
|
|
54
|
+
|
|
55
|
+
// Fetch the file and pipe the data through.
|
|
56
|
+
const fileSink = new MP4FileSink(this.#file, setStatus);
|
|
57
|
+
fetch(uri).then(response => {
|
|
58
|
+
// highWaterMark should be large enough for smooth streaming, but lower is
|
|
59
|
+
// better for memory usage.
|
|
60
|
+
response.body.pipeTo(new WritableStream(fileSink, {highWaterMark: 2}));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Get the appropriate `description` for a specific track. Assumes that the
|
|
65
|
+
// track is H.264, H.265, VP8, VP9, or AV1.
|
|
66
|
+
#description(track) {
|
|
67
|
+
const trak = this.#file.getTrackById(track.id);
|
|
68
|
+
for (const entry of trak.mdia.minf.stbl.stsd.entries) {
|
|
69
|
+
const box = entry.avcC || entry.hvcC || entry.vpcC || entry.av1C;
|
|
70
|
+
if (box) {
|
|
71
|
+
const stream = new MP4Box.DataStream(undefined, 0, MP4Box.DataStream.BIG_ENDIAN);
|
|
72
|
+
box.write(stream);
|
|
73
|
+
return new Uint8Array(stream.buffer, 8); // Remove the box header.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
throw new Error("avcC, hvcC, vpcC, or av1C box not found");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#onReady(info) {
|
|
80
|
+
this.#setStatus("demux", "Ready");
|
|
81
|
+
const track = info.videoTracks[0];
|
|
82
|
+
|
|
83
|
+
// Generate and emit an appropriate VideoDecoderConfig.
|
|
84
|
+
this.#onConfig({
|
|
85
|
+
// Browser doesn't support parsing full vp8 codec (eg: `vp08.00.41.08`),
|
|
86
|
+
// they only support `vp8`.
|
|
87
|
+
codec: track.codec.startsWith('vp08') ? 'vp8' : track.codec,
|
|
88
|
+
codedHeight: track.video.height,
|
|
89
|
+
codedWidth: track.video.width,
|
|
90
|
+
description: this.#description(track),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Start demuxing.
|
|
94
|
+
this.#file.setExtractionOptions(track.id);
|
|
95
|
+
this.#file.start();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#onSamples(track_id, ref, samples) {
|
|
99
|
+
// Generate and emit an EncodedVideoChunk for each demuxed sample.
|
|
100
|
+
for (const sample of samples) {
|
|
101
|
+
this.#onChunk(new EncodedVideoChunk({
|
|
102
|
+
type: sample.is_sync ? "key" : "delta",
|
|
103
|
+
timestamp: 1e6 * sample.cts / sample.timescale,
|
|
104
|
+
duration: 1e6 * sample.duration / sample.timescale,
|
|
105
|
+
data: sample.data
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -99,7 +99,7 @@ class LightProbeGenerator {
|
|
|
99
99
|
// evaluate SH basis functions in direction dir
|
|
100
100
|
SphericalHarmonics3.getBasisAt( dir, shBasis );
|
|
101
101
|
|
|
102
|
-
//
|
|
102
|
+
// accumulate
|
|
103
103
|
for ( let j = 0; j < 9; j ++ ) {
|
|
104
104
|
|
|
105
105
|
shCoefficients[ j ].x += shBasis[ j ] * color.r * weight;
|
|
@@ -129,7 +129,7 @@ class LightProbeGenerator {
|
|
|
129
129
|
|
|
130
130
|
static async fromCubeRenderTarget( renderer, cubeRenderTarget ) {
|
|
131
131
|
|
|
132
|
-
const flip = renderer.coordinateSystem === WebGLCoordinateSystem ? -1 : 1;
|
|
132
|
+
const flip = renderer.coordinateSystem === WebGLCoordinateSystem ? - 1 : 1;
|
|
133
133
|
|
|
134
134
|
// The renderTarget must be set to RGBA in order to make readRenderTargetPixels works
|
|
135
135
|
let totalWeight = 0;
|
|
@@ -242,7 +242,7 @@ class LightProbeGenerator {
|
|
|
242
242
|
// evaluate SH basis functions in direction dir
|
|
243
243
|
SphericalHarmonics3.getBasisAt( dir, shBasis );
|
|
244
244
|
|
|
245
|
-
//
|
|
245
|
+
// accumulate
|
|
246
246
|
for ( let j = 0; j < 9; j ++ ) {
|
|
247
247
|
|
|
248
248
|
shCoefficients[ j ].x += shBasis[ j ] * color.r * weight;
|