super-three 0.141.0 → 0.144.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/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebGLNodeBuilder } from './WebGLNodeBuilder.js';
|
|
2
|
-
import NodeFrame from 'three
|
|
2
|
+
import { NodeFrame } from 'three/nodes';
|
|
3
3
|
|
|
4
4
|
import { Material } from 'three';
|
|
5
5
|
|
|
@@ -8,7 +8,11 @@ export const nodeFrame = new NodeFrame();
|
|
|
8
8
|
|
|
9
9
|
Material.prototype.onBuild = function ( object, parameters, renderer ) {
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if ( object.material.isNodeMaterial === true ) {
|
|
12
|
+
|
|
13
|
+
builders.set( this, new WebGLNodeBuilder( object, renderer, parameters ).build() );
|
|
14
|
+
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
};
|
|
14
18
|
|
|
@@ -37,7 +41,7 @@ Material.prototype.onBeforeRender = function ( renderer, scene, camera, geometry
|
|
|
37
41
|
nodeFrame.updateNode( node );
|
|
38
42
|
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GPULoadOp, GPUStoreOp } from './constants.js';
|
|
2
|
-
import { Color } from 'three';
|
|
2
|
+
import { Color, Mesh, BoxGeometry, BackSide } from 'three';
|
|
3
|
+
import { context, transformDirection, positionWorld, modelWorldMatrix, MeshBasicNodeMaterial } from 'three/nodes';
|
|
3
4
|
|
|
4
5
|
let _clearAlpha;
|
|
5
6
|
const _clearColor = new Color();
|
|
@@ -10,6 +11,8 @@ class WebGPUBackground {
|
|
|
10
11
|
|
|
11
12
|
this.renderer = renderer;
|
|
12
13
|
|
|
14
|
+
this.boxMesh = null;
|
|
15
|
+
|
|
13
16
|
this.forceClear = false;
|
|
14
17
|
|
|
15
18
|
}
|
|
@@ -20,10 +23,11 @@ class WebGPUBackground {
|
|
|
20
23
|
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
update( scene ) {
|
|
26
|
+
update( renderList, scene ) {
|
|
24
27
|
|
|
25
28
|
const renderer = this.renderer;
|
|
26
|
-
const background = ( scene.isScene === true ) ? scene.background : null;
|
|
29
|
+
const background = ( scene.isScene === true ) ? scene.backgroundNode || scene.background : null;
|
|
30
|
+
|
|
27
31
|
let forceClear = this.forceClear;
|
|
28
32
|
|
|
29
33
|
if ( background === null ) {
|
|
@@ -41,6 +45,38 @@ class WebGPUBackground {
|
|
|
41
45
|
_clearAlpha = 1;
|
|
42
46
|
forceClear = true;
|
|
43
47
|
|
|
48
|
+
} else if ( background.isNode === true ) {
|
|
49
|
+
|
|
50
|
+
_clearColor.copy( renderer._clearColor );
|
|
51
|
+
_clearAlpha = renderer._clearAlpha;
|
|
52
|
+
|
|
53
|
+
let boxMesh = this.boxMesh;
|
|
54
|
+
|
|
55
|
+
if ( boxMesh === null ) {
|
|
56
|
+
|
|
57
|
+
const colorNode = context( background, {
|
|
58
|
+
uvNode: transformDirection( positionWorld, modelWorldMatrix )
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
const nodeMaterial = new MeshBasicNodeMaterial();
|
|
62
|
+
nodeMaterial.colorNode = colorNode;
|
|
63
|
+
nodeMaterial.side = BackSide;
|
|
64
|
+
nodeMaterial.depthTest = false;
|
|
65
|
+
nodeMaterial.depthWrite = false;
|
|
66
|
+
nodeMaterial.fog = false;
|
|
67
|
+
|
|
68
|
+
this.boxMesh = boxMesh = new Mesh( new BoxGeometry( 1, 1, 1 ), nodeMaterial );
|
|
69
|
+
|
|
70
|
+
boxMesh.onBeforeRender = function ( renderer, scene, camera ) {
|
|
71
|
+
|
|
72
|
+
this.matrixWorld.copyPosition( camera.matrixWorld );
|
|
73
|
+
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
renderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );
|
|
79
|
+
|
|
44
80
|
} else {
|
|
45
81
|
|
|
46
82
|
console.error( 'THREE.WebGPURenderer: Unsupported background configuration.', background );
|
|
@@ -15,7 +15,7 @@ class WebGPUObjects {
|
|
|
15
15
|
const updateMap = this.updateMap;
|
|
16
16
|
const frame = this.info.render.frame;
|
|
17
17
|
|
|
18
|
-
if ( updateMap.get( geometry ) !== frame ) {
|
|
18
|
+
if ( this.geometries.has( geometry ) === false || updateMap.get( geometry ) !== frame ) {
|
|
19
19
|
|
|
20
20
|
this.geometries.update( geometry );
|
|
21
21
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GPUIndexFormat, GPUCompareFunction, GPUFrontFace, GPUCullMode, GPUVertexFormat, GPUBlendFactor, GPUBlendOperation, BlendColorFactor, OneMinusBlendColorFactor, GPUColorWriteFlags, GPUStencilOperation, GPUInputStepMode } from './constants.js';
|
|
2
2
|
import {
|
|
3
3
|
FrontSide, BackSide, DoubleSide,
|
|
4
4
|
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
class WebGPURenderPipeline {
|
|
13
13
|
|
|
14
|
-
constructor( device,
|
|
14
|
+
constructor( device, utils ) {
|
|
15
15
|
|
|
16
16
|
this.cacheKey = null;
|
|
17
17
|
this.shaderAttributes = null;
|
|
@@ -20,8 +20,7 @@ class WebGPURenderPipeline {
|
|
|
20
20
|
this.usedTimes = 0;
|
|
21
21
|
|
|
22
22
|
this._device = device;
|
|
23
|
-
this.
|
|
24
|
-
this._sampleCount = sampleCount;
|
|
23
|
+
this._utils = utils;
|
|
25
24
|
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -89,8 +88,9 @@ class WebGPURenderPipeline {
|
|
|
89
88
|
const primitiveState = this._getPrimitiveState( object, material );
|
|
90
89
|
const colorWriteMask = this._getColorWriteMask( material );
|
|
91
90
|
const depthCompare = this._getDepthCompare( material );
|
|
92
|
-
const colorFormat = this.
|
|
93
|
-
const depthStencilFormat = this.
|
|
91
|
+
const colorFormat = this._utils.getCurrentColorFormat();
|
|
92
|
+
const depthStencilFormat = this._utils.getCurrentDepthStencilFormat();
|
|
93
|
+
const sampleCount = this._utils.getSampleCount();
|
|
94
94
|
|
|
95
95
|
this.pipeline = this._device.createRenderPipeline( {
|
|
96
96
|
vertex: Object.assign( {}, stageVertex.stage, { buffers: vertexBuffers } ),
|
|
@@ -113,7 +113,7 @@ class WebGPURenderPipeline {
|
|
|
113
113
|
stencilWriteMask: material.stencilWriteMask
|
|
114
114
|
},
|
|
115
115
|
multisample: {
|
|
116
|
-
count:
|
|
116
|
+
count: sampleCount
|
|
117
117
|
},
|
|
118
118
|
layout: 'auto'
|
|
119
119
|
} );
|
|
@@ -144,7 +144,13 @@ class WebGPURenderPipeline {
|
|
|
144
144
|
break;
|
|
145
145
|
|
|
146
146
|
case AdditiveBlending:
|
|
147
|
-
|
|
147
|
+
|
|
148
|
+
alphaBlend = {
|
|
149
|
+
srcFactor: GPUBlendFactor.Zero,
|
|
150
|
+
dstFactor: GPUBlendFactor.One,
|
|
151
|
+
operation: GPUBlendOperation.Add
|
|
152
|
+
};
|
|
153
|
+
|
|
148
154
|
break;
|
|
149
155
|
|
|
150
156
|
case SubtractiveBlending:
|
|
@@ -162,6 +168,7 @@ class WebGPURenderPipeline {
|
|
|
162
168
|
break;
|
|
163
169
|
|
|
164
170
|
case MultiplyBlending:
|
|
171
|
+
|
|
165
172
|
if ( premultipliedAlpha === true ) {
|
|
166
173
|
|
|
167
174
|
alphaBlend = {
|
|
@@ -318,7 +325,6 @@ class WebGPURenderPipeline {
|
|
|
318
325
|
switch ( blending ) {
|
|
319
326
|
|
|
320
327
|
case NormalBlending:
|
|
321
|
-
|
|
322
328
|
colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
|
|
323
329
|
colorBlend.dstFactor = GPUBlendFactor.OneMinusSrcAlpha;
|
|
324
330
|
colorBlend.operation = GPUBlendOperation.Add;
|
|
@@ -326,6 +332,7 @@ class WebGPURenderPipeline {
|
|
|
326
332
|
|
|
327
333
|
case AdditiveBlending:
|
|
328
334
|
colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
|
|
335
|
+
colorBlend.dstFactor = GPUBlendFactor.One;
|
|
329
336
|
colorBlend.operation = GPUBlendOperation.Add;
|
|
330
337
|
break;
|
|
331
338
|
|
|
@@ -423,7 +430,7 @@ class WebGPURenderPipeline {
|
|
|
423
430
|
|
|
424
431
|
const descriptor = {};
|
|
425
432
|
|
|
426
|
-
descriptor.topology = this.
|
|
433
|
+
descriptor.topology = this._utils.getPrimitiveTopology( object );
|
|
427
434
|
|
|
428
435
|
if ( object.isLine === true && object.isLineSegments !== true ) {
|
|
429
436
|
|
|
@@ -460,15 +467,6 @@ class WebGPURenderPipeline {
|
|
|
460
467
|
|
|
461
468
|
}
|
|
462
469
|
|
|
463
|
-
_getPrimitiveTopology( object ) {
|
|
464
|
-
|
|
465
|
-
if ( object.isMesh ) return GPUPrimitiveTopology.TriangleList;
|
|
466
|
-
else if ( object.isPoints ) return GPUPrimitiveTopology.PointList;
|
|
467
|
-
else if ( object.isLineSegments ) return GPUPrimitiveTopology.LineList;
|
|
468
|
-
else if ( object.isLine ) return GPUPrimitiveTopology.LineStrip;
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
|
|
472
470
|
_getStencilCompare( material ) {
|
|
473
471
|
|
|
474
472
|
let stencilCompare;
|
|
@@ -3,13 +3,13 @@ import WebGPUProgrammableStage from './WebGPUProgrammableStage.js';
|
|
|
3
3
|
|
|
4
4
|
class WebGPURenderPipelines {
|
|
5
5
|
|
|
6
|
-
constructor(
|
|
6
|
+
constructor( device, nodes, utils ) {
|
|
7
7
|
|
|
8
|
-
this.renderer = renderer;
|
|
9
8
|
this.device = device;
|
|
10
|
-
this.sampleCount = sampleCount;
|
|
11
9
|
this.nodes = nodes;
|
|
12
|
-
this.
|
|
10
|
+
this.utils = utils;
|
|
11
|
+
|
|
12
|
+
this.bindings = null;
|
|
13
13
|
|
|
14
14
|
this.pipelines = [];
|
|
15
15
|
this.objectCache = new WeakMap();
|
|
@@ -125,7 +125,7 @@ class WebGPURenderPipelines {
|
|
|
125
125
|
|
|
126
126
|
if ( pipeline === undefined ) {
|
|
127
127
|
|
|
128
|
-
pipeline = new WebGPURenderPipeline( this.device, this.
|
|
128
|
+
pipeline = new WebGPURenderPipeline( this.device, this.utils );
|
|
129
129
|
pipeline.init( cacheKey, stageVertex, stageFragment, object, nodeBuilder );
|
|
130
130
|
|
|
131
131
|
pipelines.push( pipeline );
|
|
@@ -139,7 +139,7 @@ class WebGPURenderPipelines {
|
|
|
139
139
|
_computeCacheKey( stageVertex, stageFragment, object ) {
|
|
140
140
|
|
|
141
141
|
const material = object.material;
|
|
142
|
-
const
|
|
142
|
+
const utils = this.utils;
|
|
143
143
|
|
|
144
144
|
const parameters = [
|
|
145
145
|
stageVertex.id, stageFragment.id,
|
|
@@ -152,8 +152,9 @@ class WebGPURenderPipelines {
|
|
|
152
152
|
material.stencilFail, material.stencilZFail, material.stencilZPass,
|
|
153
153
|
material.stencilFuncMask, material.stencilWriteMask,
|
|
154
154
|
material.side,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
utils.getSampleCount(),
|
|
156
|
+
utils.getCurrentEncoding(), utils.getCurrentColorFormat(), utils.getCurrentDepthStencilFormat(),
|
|
157
|
+
utils.getPrimitiveTopology( object )
|
|
157
158
|
];
|
|
158
159
|
|
|
159
160
|
return parameters.join();
|
|
@@ -267,16 +268,17 @@ class WebGPURenderPipelines {
|
|
|
267
268
|
|
|
268
269
|
// check renderer state
|
|
269
270
|
|
|
270
|
-
const
|
|
271
|
+
const utils = this.utils;
|
|
271
272
|
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
const
|
|
273
|
+
const sampleCount = utils.getSampleCount();
|
|
274
|
+
const encoding = utils.getCurrentEncoding();
|
|
275
|
+
const colorFormat = utils.getCurrentColorFormat();
|
|
276
|
+
const depthStencilFormat = utils.getCurrentDepthStencilFormat();
|
|
275
277
|
|
|
276
|
-
if ( cache.sampleCount !==
|
|
278
|
+
if ( cache.sampleCount !== sampleCount || cache.encoding !== encoding ||
|
|
277
279
|
cache.colorFormat !== colorFormat || cache.depthStencilFormat !== depthStencilFormat ) {
|
|
278
280
|
|
|
279
|
-
cache.sampleCount =
|
|
281
|
+
cache.sampleCount = sampleCount;
|
|
280
282
|
cache.encoding = encoding;
|
|
281
283
|
cache.colorFormat = colorFormat;
|
|
282
284
|
cache.depthStencilFormat = depthStencilFormat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import LightsNode from 'three
|
|
1
|
+
import { LightsNode } from 'three/nodes';
|
|
2
2
|
|
|
3
3
|
class WebGPURenderState {
|
|
4
4
|
|
|
@@ -38,7 +38,7 @@ class WebGPURenderStates {
|
|
|
38
38
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
get( scene, camera ) {
|
|
41
|
+
get( scene, /* camera */ ) {
|
|
42
42
|
|
|
43
43
|
const renderStates = this.renderStates;
|
|
44
44
|
|
|
@@ -12,6 +12,7 @@ import WebGPURenderStates from './WebGPURenderStates.js';
|
|
|
12
12
|
import WebGPUTextures from './WebGPUTextures.js';
|
|
13
13
|
import WebGPUBackground from './WebGPUBackground.js';
|
|
14
14
|
import WebGPUNodes from './nodes/WebGPUNodes.js';
|
|
15
|
+
import WebGPUUtils from './WebGPUUtils.js';
|
|
15
16
|
|
|
16
17
|
import { Frustum, Matrix4, Vector3, Color, LinearEncoding } from 'three';
|
|
17
18
|
|
|
@@ -48,15 +49,34 @@ Matrix4.prototype.makeOrthographic = function ( left, right, top, bottom, near,
|
|
|
48
49
|
const y = ( top + bottom ) * h;
|
|
49
50
|
const z = near * p;
|
|
50
51
|
|
|
51
|
-
te[ 0 ] = 2 * w; te[ 4 ] = 0;
|
|
52
|
-
te[ 1 ] = 0;
|
|
53
|
-
te[ 2 ] = 0;
|
|
54
|
-
te[ 3 ] = 0;
|
|
52
|
+
te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
|
|
53
|
+
te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
|
|
54
|
+
te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 1 * p; te[ 14 ] = - z;
|
|
55
|
+
te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
|
|
55
56
|
|
|
56
57
|
return this;
|
|
57
58
|
|
|
58
59
|
};
|
|
59
60
|
|
|
61
|
+
Frustum.prototype.setFromProjectionMatrix = function ( m ) {
|
|
62
|
+
|
|
63
|
+
const planes = this.planes;
|
|
64
|
+
const me = m.elements;
|
|
65
|
+
const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
|
|
66
|
+
const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
|
|
67
|
+
const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
|
|
68
|
+
const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
|
|
69
|
+
|
|
70
|
+
planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
|
|
71
|
+
planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
|
|
72
|
+
planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
|
|
73
|
+
planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
|
|
74
|
+
planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
|
|
75
|
+
planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize();
|
|
76
|
+
|
|
77
|
+
return this;
|
|
78
|
+
|
|
79
|
+
};
|
|
60
80
|
|
|
61
81
|
const _frustum = new Frustum();
|
|
62
82
|
const _projScreenMatrix = new Matrix4();
|
|
@@ -174,7 +194,7 @@ class WebGPURenderer {
|
|
|
174
194
|
context.configure( {
|
|
175
195
|
device: device,
|
|
176
196
|
format: GPUTextureFormat.BGRA8Unorm, // this is the only valid context format right now (r121)
|
|
177
|
-
|
|
197
|
+
alphaMode: 'premultiplied'
|
|
178
198
|
} );
|
|
179
199
|
|
|
180
200
|
this._adapter = adapter;
|
|
@@ -187,9 +207,10 @@ class WebGPURenderer {
|
|
|
187
207
|
this._geometries = new WebGPUGeometries( this._attributes, this._info );
|
|
188
208
|
this._textures = new WebGPUTextures( device, this._properties, this._info );
|
|
189
209
|
this._objects = new WebGPUObjects( this._geometries, this._info );
|
|
210
|
+
this._utils = new WebGPUUtils( this );
|
|
190
211
|
this._nodes = new WebGPUNodes( this, this._properties );
|
|
191
212
|
this._computePipelines = new WebGPUComputePipelines( device, this._nodes );
|
|
192
|
-
this._renderPipelines = new WebGPURenderPipelines(
|
|
213
|
+
this._renderPipelines = new WebGPURenderPipelines( device, this._nodes, this._utils );
|
|
193
214
|
this._bindings = this._renderPipelines.bindings = new WebGPUBindings( device, this._info, this._properties, this._textures, this._renderPipelines, this._computePipelines, this._attributes, this._nodes );
|
|
194
215
|
this._renderLists = new WebGPURenderLists();
|
|
195
216
|
this._renderStates = new WebGPURenderStates();
|
|
@@ -221,9 +242,9 @@ class WebGPURenderer {
|
|
|
221
242
|
|
|
222
243
|
//
|
|
223
244
|
|
|
224
|
-
if ( scene.
|
|
245
|
+
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
225
246
|
|
|
226
|
-
if ( camera.parent === null ) camera.updateMatrixWorld();
|
|
247
|
+
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
227
248
|
|
|
228
249
|
if ( this._info.autoReset === true ) this._info.reset();
|
|
229
250
|
|
|
@@ -282,7 +303,7 @@ class WebGPURenderer {
|
|
|
282
303
|
|
|
283
304
|
//
|
|
284
305
|
|
|
285
|
-
this._background.update( scene );
|
|
306
|
+
this._background.update( this._currentRenderList, scene );
|
|
286
307
|
|
|
287
308
|
// start render pass
|
|
288
309
|
|
|
@@ -482,55 +503,6 @@ class WebGPURenderer {
|
|
|
482
503
|
|
|
483
504
|
}
|
|
484
505
|
|
|
485
|
-
getCurrentEncoding() {
|
|
486
|
-
|
|
487
|
-
const renderTarget = this.getRenderTarget();
|
|
488
|
-
return ( renderTarget !== null ) ? renderTarget.texture.encoding : this.outputEncoding;
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
getCurrentColorFormat() {
|
|
493
|
-
|
|
494
|
-
let format;
|
|
495
|
-
|
|
496
|
-
const renderTarget = this.getRenderTarget();
|
|
497
|
-
|
|
498
|
-
if ( renderTarget !== null ) {
|
|
499
|
-
|
|
500
|
-
const renderTargetProperties = this._properties.get( renderTarget );
|
|
501
|
-
format = renderTargetProperties.colorTextureFormat;
|
|
502
|
-
|
|
503
|
-
} else {
|
|
504
|
-
|
|
505
|
-
format = GPUTextureFormat.BGRA8Unorm; // default context format
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return format;
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
getCurrentDepthStencilFormat() {
|
|
514
|
-
|
|
515
|
-
let format;
|
|
516
|
-
|
|
517
|
-
const renderTarget = this.getRenderTarget();
|
|
518
|
-
|
|
519
|
-
if ( renderTarget !== null ) {
|
|
520
|
-
|
|
521
|
-
const renderTargetProperties = this._properties.get( renderTarget );
|
|
522
|
-
format = renderTargetProperties.depthTextureFormat;
|
|
523
|
-
|
|
524
|
-
} else {
|
|
525
|
-
|
|
526
|
-
format = GPUTextureFormat.Depth24PlusStencil8;
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return format;
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
534
506
|
getClearColor( target ) {
|
|
535
507
|
|
|
536
508
|
return target.copy( this._clearColor );
|
|
@@ -616,14 +588,24 @@ class WebGPURenderer {
|
|
|
616
588
|
compute( ...computeNodes ) {
|
|
617
589
|
|
|
618
590
|
const device = this._device;
|
|
591
|
+
const computePipelines = this._computePipelines;
|
|
592
|
+
|
|
619
593
|
const cmdEncoder = device.createCommandEncoder( {} );
|
|
620
594
|
const passEncoder = cmdEncoder.beginComputePass();
|
|
621
595
|
|
|
622
596
|
for ( const computeNode of computeNodes ) {
|
|
623
597
|
|
|
598
|
+
// onInit
|
|
599
|
+
|
|
600
|
+
if ( computePipelines.has( computeNode ) === false ) {
|
|
601
|
+
|
|
602
|
+
computeNode.onInit( { renderer: this } );
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
624
606
|
// pipeline
|
|
625
607
|
|
|
626
|
-
const pipeline =
|
|
608
|
+
const pipeline = computePipelines.get( computeNode );
|
|
627
609
|
passEncoder.setPipeline( pipeline );
|
|
628
610
|
|
|
629
611
|
// node
|
|
@@ -768,19 +750,7 @@ class WebGPURenderer {
|
|
|
768
750
|
// @TODO: Add support for multiple materials per object. This will require to extract
|
|
769
751
|
// the material from the renderItem object and pass it with its group data to _renderObject().
|
|
770
752
|
|
|
771
|
-
const object = renderItem
|
|
772
|
-
|
|
773
|
-
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
774
|
-
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
775
|
-
|
|
776
|
-
this._objects.update( object );
|
|
777
|
-
|
|
778
|
-
// send scene properties to object
|
|
779
|
-
|
|
780
|
-
const objectProperties = this._properties.get( object );
|
|
781
|
-
|
|
782
|
-
objectProperties.lightsNode = lightsNode;
|
|
783
|
-
objectProperties.scene = scene;
|
|
753
|
+
const { object, geometry, material, group } = renderItem;
|
|
784
754
|
|
|
785
755
|
if ( camera.isArrayCamera ) {
|
|
786
756
|
|
|
@@ -798,9 +768,7 @@ class WebGPURenderer {
|
|
|
798
768
|
|
|
799
769
|
passEncoder.setViewport( vp.x, vp.y, vp.width, vp.height, minDepth, maxDepth );
|
|
800
770
|
|
|
801
|
-
this.
|
|
802
|
-
this._bindings.update( object );
|
|
803
|
-
this._renderObject( object, passEncoder );
|
|
771
|
+
this._renderObject( object, scene, camera2, geometry, material, group, lightsNode, passEncoder );
|
|
804
772
|
|
|
805
773
|
}
|
|
806
774
|
|
|
@@ -808,9 +776,7 @@ class WebGPURenderer {
|
|
|
808
776
|
|
|
809
777
|
} else {
|
|
810
778
|
|
|
811
|
-
this.
|
|
812
|
-
this._bindings.update( object );
|
|
813
|
-
this._renderObject( object, passEncoder );
|
|
779
|
+
this._renderObject( object, scene, camera, geometry, material, group, lightsNode, passEncoder );
|
|
814
780
|
|
|
815
781
|
}
|
|
816
782
|
|
|
@@ -818,10 +784,30 @@ class WebGPURenderer {
|
|
|
818
784
|
|
|
819
785
|
}
|
|
820
786
|
|
|
821
|
-
_renderObject( object, passEncoder ) {
|
|
787
|
+
_renderObject( object, scene, camera, geometry, material, group, lightsNode, passEncoder ) {
|
|
822
788
|
|
|
823
789
|
const info = this._info;
|
|
824
790
|
|
|
791
|
+
// send scene properties to object
|
|
792
|
+
|
|
793
|
+
const objectProperties = this._properties.get( object );
|
|
794
|
+
|
|
795
|
+
objectProperties.lightsNode = lightsNode;
|
|
796
|
+
objectProperties.scene = scene;
|
|
797
|
+
|
|
798
|
+
//
|
|
799
|
+
|
|
800
|
+
object.onBeforeRender( this, scene, camera, geometry, material, group );
|
|
801
|
+
|
|
802
|
+
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
803
|
+
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
804
|
+
|
|
805
|
+
// updates
|
|
806
|
+
|
|
807
|
+
this._nodes.update( object, camera );
|
|
808
|
+
this._bindings.update( object );
|
|
809
|
+
this._objects.update( object );
|
|
810
|
+
|
|
825
811
|
// pipeline
|
|
826
812
|
|
|
827
813
|
const renderPipeline = this._renderPipelines.get( object );
|
|
@@ -834,7 +820,6 @@ class WebGPURenderer {
|
|
|
834
820
|
|
|
835
821
|
// index
|
|
836
822
|
|
|
837
|
-
const geometry = object.geometry;
|
|
838
823
|
const index = geometry.index;
|
|
839
824
|
|
|
840
825
|
const hasIndex = ( index !== null );
|
|
@@ -964,7 +949,7 @@ class WebGPURenderer {
|
|
|
964
949
|
device: device,
|
|
965
950
|
format: GPUTextureFormat.BGRA8Unorm,
|
|
966
951
|
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
967
|
-
|
|
952
|
+
alphaMode: 'premultiplied'
|
|
968
953
|
} );
|
|
969
954
|
|
|
970
955
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
19
|
// SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import { GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology, GPULoadOp, GPUStoreOp } from './constants.js';
|
|
21
|
+
import { GPUTextureViewDimension, GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology, GPULoadOp, GPUStoreOp } from './constants.js';
|
|
22
22
|
|
|
23
23
|
// ported from https://github.com/toji/web-texture-tool/blob/master/src/webgpu-mipmap-generator.js
|
|
24
24
|
|
|
@@ -34,7 +34,7 @@ struct VarysStruct {
|
|
|
34
34
|
@location( 0 ) vTex : vec2<f32>
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
@
|
|
37
|
+
@vertex
|
|
38
38
|
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
|
|
39
39
|
|
|
40
40
|
var Varys : VarysStruct;
|
|
@@ -68,7 +68,7 @@ var imgSampler : sampler;
|
|
|
68
68
|
@group( 0 ) @binding( 1 )
|
|
69
69
|
var img : texture_2d<f32>;
|
|
70
70
|
|
|
71
|
-
@
|
|
71
|
+
@fragment
|
|
72
72
|
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
73
73
|
|
|
74
74
|
return textureSample( img, imgSampler, vTex );
|
|
@@ -132,6 +132,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
132
132
|
let srcView = textureGPU.createView( {
|
|
133
133
|
baseMipLevel: 0,
|
|
134
134
|
mipLevelCount: 1,
|
|
135
|
+
dimension: GPUTextureViewDimension.TwoD,
|
|
135
136
|
baseArrayLayer
|
|
136
137
|
} );
|
|
137
138
|
|
|
@@ -140,6 +141,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
140
141
|
const dstView = textureGPU.createView( {
|
|
141
142
|
baseMipLevel: i,
|
|
142
143
|
mipLevelCount: 1,
|
|
144
|
+
dimension: GPUTextureViewDimension.TwoD,
|
|
143
145
|
baseArrayLayer
|
|
144
146
|
} );
|
|
145
147
|
|
|
@@ -428,7 +428,7 @@ class WebGPUTextures {
|
|
|
428
428
|
|
|
429
429
|
if ( image.isDataTexture ) {
|
|
430
430
|
|
|
431
|
-
this._copyBufferToTexture( image.image, format, textureGPU, { z
|
|
431
|
+
this._copyBufferToTexture( image.image, format, textureGPU, { z: i } );
|
|
432
432
|
|
|
433
433
|
if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureGPUDescriptor, i );
|
|
434
434
|
|
|
@@ -436,7 +436,7 @@ class WebGPUTextures {
|
|
|
436
436
|
|
|
437
437
|
this._getImageBitmap( image, texture ).then( imageBitmap => {
|
|
438
438
|
|
|
439
|
-
this._copyExternalImageToTexture( imageBitmap, textureGPU, { z
|
|
439
|
+
this._copyExternalImageToTexture( imageBitmap, textureGPU, { z: i } );
|
|
440
440
|
|
|
441
441
|
if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureGPUDescriptor, i );
|
|
442
442
|
|