@plastic-software/three 0.182.0 → 0.183.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/build/three.cjs +11520 -10877
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +509 -262
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -174,7 +174,7 @@ class ConditionalNode extends Node {
|
|
|
174
174
|
|
|
175
175
|
if ( functionNode === null ) {
|
|
176
176
|
|
|
177
|
-
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
177
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.', this.stackTrace );
|
|
178
178
|
|
|
179
179
|
ifSnippet = '// ' + ifSnippet;
|
|
180
180
|
|
|
@@ -204,7 +204,7 @@ class ConditionalNode extends Node {
|
|
|
204
204
|
|
|
205
205
|
if ( functionNode === null ) {
|
|
206
206
|
|
|
207
|
-
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
207
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.', this.stackTrace );
|
|
208
208
|
|
|
209
209
|
elseSnippet = '// ' + elseSnippet;
|
|
210
210
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { sub, mul, div, mod
|
|
2
|
+
import { sub, mul, div, mod } from './OperatorNode.js';
|
|
3
3
|
import { addMethodChaining, nodeObject, nodeProxyIntent, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
4
4
|
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
5
|
import { warn } from '../../utils.js';
|
|
@@ -291,7 +291,7 @@ class MathNode extends TempNode {
|
|
|
291
291
|
|
|
292
292
|
if ( builder.shaderStage !== 'fragment' && ( method === MathNode.DFDX || method === MathNode.DFDY ) ) {
|
|
293
293
|
|
|
294
|
-
warn( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage
|
|
294
|
+
warn( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage.`, this.stackTrace );
|
|
295
295
|
|
|
296
296
|
method = '/*' + method + '*/';
|
|
297
297
|
|
|
@@ -784,23 +784,6 @@ export const inverse = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.INVERSE
|
|
|
784
784
|
|
|
785
785
|
// 2 inputs
|
|
786
786
|
|
|
787
|
-
/**
|
|
788
|
-
* Returns `true` if `x` equals `y`.
|
|
789
|
-
*
|
|
790
|
-
* @tsl
|
|
791
|
-
* @function
|
|
792
|
-
* @param {Node | number} x - The first parameter.
|
|
793
|
-
* @param {Node | number} y - The second parameter.
|
|
794
|
-
* @deprecated since r175. Use {@link equal} instead.
|
|
795
|
-
* @returns {Node<bool>}
|
|
796
|
-
*/
|
|
797
|
-
export const equals = ( x, y ) => { // @deprecated, r172
|
|
798
|
-
|
|
799
|
-
warn( 'TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"' );
|
|
800
|
-
return equal( x, y );
|
|
801
|
-
|
|
802
|
-
};
|
|
803
|
-
|
|
804
787
|
/**
|
|
805
788
|
* Returns the least of the given values.
|
|
806
789
|
*
|
|
@@ -981,7 +964,7 @@ export const mix = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.MIX ).setPa
|
|
|
981
964
|
* @param {Node | number} [high=1] - The upper bound.
|
|
982
965
|
* @returns {Node}
|
|
983
966
|
*/
|
|
984
|
-
export const clamp = ( value, low = 0, high = 1 ) =>
|
|
967
|
+
export const clamp = ( value, low = 0, high = 1 ) => new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) );
|
|
985
968
|
|
|
986
969
|
/**
|
|
987
970
|
* Constrains a value between `0` and `1`.
|
|
@@ -1081,24 +1064,6 @@ export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
|
1081
1064
|
*/
|
|
1082
1065
|
export const stepElement = ( x, edge ) => step( edge, x );
|
|
1083
1066
|
|
|
1084
|
-
/**
|
|
1085
|
-
* Returns the arc-tangent of the quotient of its parameters.
|
|
1086
|
-
*
|
|
1087
|
-
* @tsl
|
|
1088
|
-
* @function
|
|
1089
|
-
* @deprecated since r172. Use {@link atan} instead.
|
|
1090
|
-
*
|
|
1091
|
-
* @param {Node | number} y - The y parameter.
|
|
1092
|
-
* @param {Node | number} x - The x parameter.
|
|
1093
|
-
* @returns {Node}
|
|
1094
|
-
*/
|
|
1095
|
-
export const atan2 = ( y, x ) => { // @deprecated, r172
|
|
1096
|
-
|
|
1097
|
-
warn( 'TSL: "atan2" is overloaded. Use "atan" instead.' );
|
|
1098
|
-
return atan( y, x );
|
|
1099
|
-
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
1067
|
// GLSL alias function
|
|
1103
1068
|
|
|
1104
1069
|
export const faceforward = faceForward;
|
|
@@ -1108,7 +1073,6 @@ export const inversesqrt = inverseSqrt;
|
|
|
1108
1073
|
|
|
1109
1074
|
addMethodChaining( 'all', all );
|
|
1110
1075
|
addMethodChaining( 'any', any );
|
|
1111
|
-
addMethodChaining( 'equals', equals );
|
|
1112
1076
|
|
|
1113
1077
|
addMethodChaining( 'radians', radians );
|
|
1114
1078
|
addMethodChaining( 'degrees', degrees );
|
|
@@ -1140,7 +1104,6 @@ addMethodChaining( 'round', round );
|
|
|
1140
1104
|
addMethodChaining( 'reciprocal', reciprocal );
|
|
1141
1105
|
addMethodChaining( 'trunc', trunc );
|
|
1142
1106
|
addMethodChaining( 'fwidth', fwidth );
|
|
1143
|
-
addMethodChaining( 'atan2', atan2 );
|
|
1144
1107
|
addMethodChaining( 'min', min );
|
|
1145
1108
|
addMethodChaining( 'max', max );
|
|
1146
1109
|
addMethodChaining( 'step', stepElement );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
2
2
|
import TempNode from '../core/TempNode.js';
|
|
3
|
+
import StackTrace from '../core/StackTrace.js';
|
|
3
4
|
import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
4
5
|
import { warn } from '../../utils.js';
|
|
5
6
|
|
|
@@ -743,7 +744,7 @@ addMethodChaining( 'decrement', decrement );
|
|
|
743
744
|
*/
|
|
744
745
|
export const modInt = ( a, b ) => { // @deprecated, r175
|
|
745
746
|
|
|
746
|
-
warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.' );
|
|
747
|
+
warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.', new StackTrace() );
|
|
747
748
|
return mod( int( a ), int( b ) );
|
|
748
749
|
|
|
749
750
|
};
|
|
@@ -312,30 +312,24 @@ const hammersley = /*@__PURE__*/ Fn( ( [ i, N ] ) => {
|
|
|
312
312
|
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
313
313
|
// "Sampling the GGX Distribution of Visible Normals"
|
|
314
314
|
// https://jcgt.org/published/0007/04/01/
|
|
315
|
-
const importanceSampleGGX_VNDF = /*@__PURE__*/ Fn( ( [ Xi,
|
|
315
|
+
const importanceSampleGGX_VNDF = /*@__PURE__*/ Fn( ( [ Xi, V, roughness ] ) => {
|
|
316
316
|
|
|
317
|
-
const
|
|
318
|
-
const roughness = float( roughness_immutable );
|
|
319
|
-
const alpha = roughness.mul( roughness ).toVar();
|
|
320
|
-
|
|
321
|
-
// Section 3.2: Transform view direction to hemisphere configuration
|
|
322
|
-
const Vh = normalize( vec3( alpha.mul( V.x ), alpha.mul( V.y ), V.z ) ).toVar();
|
|
317
|
+
const alpha = roughness.mul( roughness ).toConst();
|
|
323
318
|
|
|
324
319
|
// Section 4.1: Orthonormal basis
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
const T2 = cross( Vh, T1 ).toVar();
|
|
320
|
+
const T1 = vec3( 1.0, 0.0, 0.0 ).toConst();
|
|
321
|
+
const T2 = cross( V, T1 ).toConst();
|
|
328
322
|
|
|
329
323
|
// Section 4.2: Parameterization of projected area
|
|
330
|
-
const r = sqrt( Xi.x );
|
|
331
|
-
const phi = mul( 2.0, 3.14159265359 ).mul( Xi.y );
|
|
332
|
-
const t1 = r.mul( cos( phi ) ).
|
|
324
|
+
const r = sqrt( Xi.x ).toConst();
|
|
325
|
+
const phi = mul( 2.0, 3.14159265359 ).mul( Xi.y ).toConst();
|
|
326
|
+
const t1 = r.mul( cos( phi ) ).toConst();
|
|
333
327
|
const t2 = r.mul( sin( phi ) ).toVar();
|
|
334
|
-
const s = mul( 0.5,
|
|
328
|
+
const s = mul( 0.5, V.z.add( 1.0 ) ).toConst();
|
|
335
329
|
t2.assign( s.oneMinus().mul( sqrt( t1.mul( t1 ).oneMinus() ) ).add( s.mul( t2 ) ) );
|
|
336
330
|
|
|
337
331
|
// Section 4.3: Reprojection onto hemisphere
|
|
338
|
-
const Nh = T1.mul( t1 ).add( T2.mul( t2 ) ).add(
|
|
332
|
+
const Nh = T1.mul( t1 ).add( T2.mul( t2 ) ).add( V.mul( sqrt( max( 0.0, t1.mul( t1 ).add( t2.mul( t2 ) ).oneMinus() ) ) ) );
|
|
339
333
|
|
|
340
334
|
// Section 3.4: Transform back to ellipsoid configuration
|
|
341
335
|
return normalize( vec3( alpha.mul( Nh.x ), alpha.mul( Nh.y ), max( 0.0, Nh.z ) ) );
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -7,6 +7,7 @@ import SetNode from '../utils/SetNode.js';
|
|
|
7
7
|
import FlipNode from '../utils/FlipNode.js';
|
|
8
8
|
import ConstNode from '../core/ConstNode.js';
|
|
9
9
|
import MemberNode from '../utils/MemberNode.js';
|
|
10
|
+
import StackTrace from '../core/StackTrace.js';
|
|
10
11
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
11
12
|
import { warn, error } from '../../utils.js';
|
|
12
13
|
|
|
@@ -18,6 +19,8 @@ const NodeElements = new Map();
|
|
|
18
19
|
|
|
19
20
|
export function addMethodChaining( name, nodeElement ) {
|
|
20
21
|
|
|
22
|
+
// No require StackTrace because this is internal API
|
|
23
|
+
|
|
21
24
|
if ( NodeElements.has( name ) ) {
|
|
22
25
|
|
|
23
26
|
warn( `TSL: Redefinition of method chaining '${ name }'.` );
|
|
@@ -66,7 +69,7 @@ Node.prototype.assign = function ( ...params ) {
|
|
|
66
69
|
|
|
67
70
|
} else {
|
|
68
71
|
|
|
69
|
-
error( 'TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().' );
|
|
72
|
+
error( 'TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().', new StackTrace() );
|
|
70
73
|
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -374,13 +377,13 @@ const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, setti
|
|
|
374
377
|
|
|
375
378
|
if ( minParams !== undefined && params.length < minParams ) {
|
|
376
379
|
|
|
377
|
-
error( `TSL: "${ tslName }" parameter length is less than minimum required
|
|
380
|
+
error( `TSL: "${ tslName }" parameter length is less than minimum required.`, new StackTrace() );
|
|
378
381
|
|
|
379
382
|
return params.concat( new Array( minParams - params.length ).fill( 0 ) );
|
|
380
383
|
|
|
381
384
|
} else if ( maxParams !== undefined && params.length > maxParams ) {
|
|
382
385
|
|
|
383
|
-
error( `TSL: "${ tslName }" parameter length exceeds limit
|
|
386
|
+
error( `TSL: "${ tslName }" parameter length exceeds limit.`, new StackTrace() );
|
|
384
387
|
|
|
385
388
|
return params.slice( 0, maxParams );
|
|
386
389
|
|
|
@@ -871,7 +874,7 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
871
874
|
|
|
872
875
|
if ( param === undefined ) {
|
|
873
876
|
|
|
874
|
-
error( `TSL: Invalid parameter for the type "${ type }"
|
|
877
|
+
error( `TSL: Invalid parameter for the type "${ type }".`, new StackTrace() );
|
|
875
878
|
|
|
876
879
|
return new ConstNode( 0, type );
|
|
877
880
|
|
|
@@ -960,7 +963,7 @@ class FnNode extends Node {
|
|
|
960
963
|
|
|
961
964
|
} else {
|
|
962
965
|
|
|
963
|
-
error( 'TSL: Invalid layout type.' );
|
|
966
|
+
error( 'TSL: Invalid layout type.', new StackTrace() );
|
|
964
967
|
|
|
965
968
|
}
|
|
966
969
|
|
|
@@ -1044,7 +1047,7 @@ class FnNode extends Node {
|
|
|
1044
1047
|
|
|
1045
1048
|
const type = this.getNodeType( builder );
|
|
1046
1049
|
|
|
1047
|
-
error( 'TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".' );
|
|
1050
|
+
error( 'TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".', this.stackTrace );
|
|
1048
1051
|
|
|
1049
1052
|
return builder.generateConst( type );
|
|
1050
1053
|
|
|
@@ -1198,8 +1201,8 @@ addMethodChaining( 'toMat4', mat4 );
|
|
|
1198
1201
|
// basic nodes
|
|
1199
1202
|
|
|
1200
1203
|
export const element = /*@__PURE__*/ nodeProxy( ArrayElementNode ).setParameterLength( 2 );
|
|
1201
|
-
export const convert = ( node, types ) =>
|
|
1202
|
-
export const split = ( node, channels ) =>
|
|
1204
|
+
export const convert = ( node, types ) => new ConvertNode( nodeObject( node ), types );
|
|
1205
|
+
export const split = ( node, channels ) => new SplitNode( nodeObject( node ), channels );
|
|
1203
1206
|
|
|
1204
1207
|
addMethodChaining( 'element', element );
|
|
1205
1208
|
addMethodChaining( 'convert', convert );
|
|
@@ -1216,14 +1219,14 @@ addMethodChaining( 'convert', convert );
|
|
|
1216
1219
|
*/
|
|
1217
1220
|
export const append = ( node ) => { // @deprecated, r176
|
|
1218
1221
|
|
|
1219
|
-
warn( 'TSL: append() has been renamed to Stack().' );
|
|
1222
|
+
warn( 'TSL: append() has been renamed to Stack().', new StackTrace() );
|
|
1220
1223
|
return Stack( node );
|
|
1221
1224
|
|
|
1222
1225
|
};
|
|
1223
1226
|
|
|
1224
1227
|
addMethodChaining( 'append', ( node ) => { // @deprecated, r176
|
|
1225
1228
|
|
|
1226
|
-
warn( 'TSL: .append() has been renamed to .toStack().' );
|
|
1229
|
+
warn( 'TSL: .append() has been renamed to .toStack().', new StackTrace() );
|
|
1227
1230
|
return Stack( node );
|
|
1228
1231
|
|
|
1229
1232
|
} );
|
|
@@ -42,21 +42,21 @@ class DebugNode extends TempNode {
|
|
|
42
42
|
const callback = this.callback;
|
|
43
43
|
const snippet = this.node.build( builder );
|
|
44
44
|
|
|
45
|
-
const title = '--- TSL debug - ' + builder.shaderStage + ' shader ---';
|
|
46
|
-
const border = '-'.repeat( title.length );
|
|
47
|
-
|
|
48
|
-
let code = '';
|
|
49
|
-
code += '// #' + title + '#\n';
|
|
50
|
-
code += builder.flow.code.replace( /^\t/mg, '' ) + '\n';
|
|
51
|
-
code += '/* ... */ ' + snippet + ' /* ... */\n';
|
|
52
|
-
code += '// #' + border + '#\n';
|
|
53
|
-
|
|
54
45
|
if ( callback !== null ) {
|
|
55
46
|
|
|
56
|
-
callback( builder,
|
|
47
|
+
callback( builder, snippet );
|
|
57
48
|
|
|
58
49
|
} else {
|
|
59
50
|
|
|
51
|
+
const title = '--- TSL debug - ' + builder.shaderStage + ' shader ---';
|
|
52
|
+
const border = '-'.repeat( title.length );
|
|
53
|
+
|
|
54
|
+
let code = '';
|
|
55
|
+
code += '// #' + title + '#\n';
|
|
56
|
+
code += builder.flow.code.replace( /^\t/mg, '' ) + '\n';
|
|
57
|
+
code += '/* ... */ ' + snippet + ' /* ... */\n';
|
|
58
|
+
code += '// #' + border + '#\n';
|
|
59
|
+
|
|
60
60
|
log( code );
|
|
61
61
|
|
|
62
62
|
}
|
|
@@ -78,6 +78,6 @@ export default DebugNode;
|
|
|
78
78
|
* @param {?Function} [callback=null] - Optional callback function to handle the debug output.
|
|
79
79
|
* @returns {DebugNode}
|
|
80
80
|
*/
|
|
81
|
-
export const debug = ( node, callback = null ) =>
|
|
81
|
+
export const debug = ( node, callback = null ) => new DebugNode( nodeObject( node ), callback ).toStack();
|
|
82
82
|
|
|
83
83
|
addMethodChaining( 'debug', debug );
|
|
@@ -71,7 +71,7 @@ class JoinNode extends TempNode {
|
|
|
71
71
|
|
|
72
72
|
if ( length >= maxLength ) {
|
|
73
73
|
|
|
74
|
-
error( `TSL: Length of parameters exceeds maximum length of function '${ type }()' type
|
|
74
|
+
error( `TSL: Length of parameters exceeds maximum length of function '${ type }()' type.`, this.stackTrace );
|
|
75
75
|
break;
|
|
76
76
|
|
|
77
77
|
}
|
|
@@ -82,7 +82,7 @@ class JoinNode extends TempNode {
|
|
|
82
82
|
|
|
83
83
|
if ( length + inputTypeLength > maxLength ) {
|
|
84
84
|
|
|
85
|
-
error( `TSL: Length of '${ type }()' data exceeds maximum length of output type
|
|
85
|
+
error( `TSL: Length of '${ type }()' data exceeds maximum length of output type.`, this.stackTrace );
|
|
86
86
|
|
|
87
87
|
inputTypeLength = maxLength - length;
|
|
88
88
|
inputType = builder.getTypeFromLength( inputTypeLength );
|
|
@@ -265,7 +265,7 @@ class LoopNode extends Node {
|
|
|
265
265
|
|
|
266
266
|
} else {
|
|
267
267
|
|
|
268
|
-
error( 'TSL: \'Loop( { update: ... } )\' is not a function, string or number.' );
|
|
268
|
+
error( 'TSL: \'Loop( { update: ... } )\' is not a function, string or number.', this.stackTrace );
|
|
269
269
|
|
|
270
270
|
updateSnippet = 'break /* invalid update */';
|
|
271
271
|
|
|
@@ -101,7 +101,7 @@ class MemberNode extends Node {
|
|
|
101
101
|
|
|
102
102
|
if ( this.hasMember( builder ) === false ) {
|
|
103
103
|
|
|
104
|
-
warn( `TSL: Member "${ this.property }" does not exist in struct
|
|
104
|
+
warn( `TSL: Member "${ this.property }" does not exist in struct.`, this.stackTrace );
|
|
105
105
|
|
|
106
106
|
const type = this.getNodeType( builder );
|
|
107
107
|
|
|
@@ -266,7 +266,7 @@ export default RTTNode;
|
|
|
266
266
|
* @param {Object} [options={type:HalfFloatType}] - The options for the internal render target.
|
|
267
267
|
* @returns {RTTNode}
|
|
268
268
|
*/
|
|
269
|
-
export const rtt = ( node, ...params ) =>
|
|
269
|
+
export const rtt = ( node, ...params ) => new RTTNode( nodeObject( node ), ...params );
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* TSL function for converting nodes to textures nodes.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import TextureNode from '../accessors/TextureNode.js';
|
|
3
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
4
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
5
4
|
import { screenUV } from '../display/ScreenNode.js';
|
|
6
5
|
|
|
@@ -134,10 +133,10 @@ class ReflectorNode extends TextureNode {
|
|
|
134
133
|
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
this._depthNode =
|
|
136
|
+
this._depthNode = new ReflectorNode( {
|
|
138
137
|
defaultTexture: _defaultRT.depthTexture,
|
|
139
138
|
reflector: this._reflectorBaseNode
|
|
140
|
-
} )
|
|
139
|
+
} );
|
|
141
140
|
|
|
142
141
|
}
|
|
143
142
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { uv } from '../accessors/UV.js';
|
|
2
|
+
import { Fn, float, vec2 } from '../tsl/TSLBase.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TSL function for computing texture coordinates for animated sprite sheets.
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* const uvNode = spritesheetUV( vec2( 6, 6 ), uv(), time.mul( animationSpeed ) );
|
|
9
|
+
*
|
|
10
|
+
* material.colorNode = texture( spriteSheet, uvNode );
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @tsl
|
|
14
|
+
* @function
|
|
15
|
+
* @param {Node<vec2>} countNode - The node that defines the number of sprites in the x and y direction (e.g 6x6).
|
|
16
|
+
* @param {?Node<vec2>} [uvNode=uv()] - The uv node.
|
|
17
|
+
* @param {?Node<float>} [frameNode=float(0)] - The node that defines the current frame/sprite.
|
|
18
|
+
* @returns {Node<vec2>}
|
|
19
|
+
*/
|
|
20
|
+
export const spritesheetUV = /*@__PURE__*/ Fn( ( [ countNode, uvNode = uv(), frameNode = float( 0 ) ] ) => {
|
|
21
|
+
|
|
22
|
+
const width = countNode.x;
|
|
23
|
+
const height = countNode.y;
|
|
24
|
+
|
|
25
|
+
const frameNum = frameNode.mod( width.mul( height ) ).floor();
|
|
26
|
+
|
|
27
|
+
const column = frameNum.mod( width );
|
|
28
|
+
const row = height.sub( frameNum.add( 1 ).div( width ).ceil() );
|
|
29
|
+
|
|
30
|
+
const scale = countNode.reciprocal();
|
|
31
|
+
const uvFrameOffset = vec2( column, row );
|
|
32
|
+
|
|
33
|
+
return uvNode.add( uvFrameOffset ).mul( scale );
|
|
34
|
+
|
|
35
|
+
} );
|
|
@@ -16,14 +16,16 @@ import { context } from '../core/ContextNode.js';
|
|
|
16
16
|
*
|
|
17
17
|
* @tsl
|
|
18
18
|
* @function
|
|
19
|
-
* @param {function(Node):Node<vec2>} callback - A callback that receives the texture node
|
|
19
|
+
* @param {function(Node):Node<vec2>|Node<vec2>} callback - A callback that receives the texture node
|
|
20
20
|
* and must return the new uv coordinates.
|
|
21
21
|
* @param {Node} [node=null] - An optional node to which the context will be applied.
|
|
22
22
|
* @return {ContextNode} A context node that replaces the default UV coordinates.
|
|
23
23
|
*/
|
|
24
24
|
export function replaceDefaultUV( callback, node = null ) {
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const getUV = typeof callback === 'function' ? callback : () => callback;
|
|
27
|
+
|
|
28
|
+
return context( node, { getUV } );
|
|
27
29
|
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -957,12 +957,10 @@ class BatchedMesh extends Mesh {
|
|
|
957
957
|
nextVertexStart += geometryInfo.reservedVertexCount;
|
|
958
958
|
geometryInfo.start = geometry.index ? geometryInfo.indexStart : geometryInfo.vertexStart;
|
|
959
959
|
|
|
960
|
-
// step the next geometry points to the shifted position
|
|
961
|
-
this._nextIndexStart = geometry.index ? geometryInfo.indexStart + geometryInfo.reservedIndexCount : 0;
|
|
962
|
-
this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
|
|
963
|
-
|
|
964
960
|
}
|
|
965
961
|
|
|
962
|
+
this._nextIndexStart = nextIndexStart;
|
|
963
|
+
this._nextVertexStart = nextVertexStart;
|
|
966
964
|
this._visibilityChanged = true;
|
|
967
965
|
|
|
968
966
|
return this;
|
|
@@ -1105,7 +1103,7 @@ class BatchedMesh extends Mesh {
|
|
|
1105
1103
|
* Sets the given color to the defined instance.
|
|
1106
1104
|
*
|
|
1107
1105
|
* @param {number} instanceId - The ID of an instance to set the color of.
|
|
1108
|
-
* @param {Color} color - The color to set the instance to.
|
|
1106
|
+
* @param {Color|Vector4} color - The color to set the instance to. Use a `Vector4` to also define alpha.
|
|
1109
1107
|
* @return {BatchedMesh} A reference to this batched mesh.
|
|
1110
1108
|
*/
|
|
1111
1109
|
setColorAt( instanceId, color ) {
|
|
@@ -1129,8 +1127,8 @@ class BatchedMesh extends Mesh {
|
|
|
1129
1127
|
* Returns the color of the defined instance.
|
|
1130
1128
|
*
|
|
1131
1129
|
* @param {number} instanceId - The ID of an instance to get the color of.
|
|
1132
|
-
* @param {Color} color - The target object that is used to store the method's result.
|
|
1133
|
-
* @return {Color} The instance's color.
|
|
1130
|
+
* @param {Color|Vector4} color - The target object that is used to store the method's result.
|
|
1131
|
+
* @return {Color|Vector4} The instance's color. Use a `Vector4` to also retrieve alpha.
|
|
1134
1132
|
*/
|
|
1135
1133
|
getColorAt( instanceId, color ) {
|
|
1136
1134
|
|
|
@@ -1515,7 +1513,19 @@ class BatchedMesh extends Mesh {
|
|
|
1515
1513
|
// the indexed version of the multi draw function requires specifying the start
|
|
1516
1514
|
// offset in bytes.
|
|
1517
1515
|
const index = geometry.getIndex();
|
|
1518
|
-
|
|
1516
|
+
let bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
// the "wireframe" attribute implicitly creates a line attribute in the renderer, which is double
|
|
1520
|
+
// the vertices to draw (3 lines per triangle) so we multiply the draw counts / starts and make
|
|
1521
|
+
// assumptions about the index buffer byte size.
|
|
1522
|
+
let multiDrawMultiplier = 1;
|
|
1523
|
+
if ( material.wireframe ) {
|
|
1524
|
+
|
|
1525
|
+
multiDrawMultiplier = 2;
|
|
1526
|
+
bytesPerElement = geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
1527
|
+
|
|
1528
|
+
}
|
|
1519
1529
|
|
|
1520
1530
|
const instanceInfo = this._instanceInfo;
|
|
1521
1531
|
const multiDrawStarts = this._multiDrawStarts;
|
|
@@ -1596,8 +1606,8 @@ class BatchedMesh extends Mesh {
|
|
|
1596
1606
|
for ( let i = 0, l = list.length; i < l; i ++ ) {
|
|
1597
1607
|
|
|
1598
1608
|
const item = list[ i ];
|
|
1599
|
-
multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement;
|
|
1600
|
-
multiDrawCounts[ multiDrawCount ] = item.count;
|
|
1609
|
+
multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement * multiDrawMultiplier;
|
|
1610
|
+
multiDrawCounts[ multiDrawCount ] = item.count * multiDrawMultiplier;
|
|
1601
1611
|
indirectArray[ multiDrawCount ] = item.index;
|
|
1602
1612
|
multiDrawCount ++;
|
|
1603
1613
|
|
|
@@ -1627,8 +1637,8 @@ class BatchedMesh extends Mesh {
|
|
|
1627
1637
|
if ( ! culled ) {
|
|
1628
1638
|
|
|
1629
1639
|
const geometryInfo = geometryInfoList[ geometryId ];
|
|
1630
|
-
multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement;
|
|
1631
|
-
multiDrawCounts[ multiDrawCount ] = geometryInfo.count;
|
|
1640
|
+
multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement * multiDrawMultiplier;
|
|
1641
|
+
multiDrawCounts[ multiDrawCount ] = geometryInfo.count * multiDrawMultiplier;
|
|
1632
1642
|
indirectArray[ multiDrawCount ] = i;
|
|
1633
1643
|
multiDrawCount ++;
|
|
1634
1644
|
|
|
@@ -56,6 +56,15 @@ class InstancedMesh extends Mesh {
|
|
|
56
56
|
*/
|
|
57
57
|
this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 );
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Represents the local transformation of all instances of the previous frame.
|
|
61
|
+
* Required for computing velocity. Maintained in {@link InstanceNode}.
|
|
62
|
+
*
|
|
63
|
+
* @type {?InstancedBufferAttribute}
|
|
64
|
+
* @default null
|
|
65
|
+
*/
|
|
66
|
+
this.previousInstanceMatrix = null;
|
|
67
|
+
|
|
59
68
|
/**
|
|
60
69
|
* Represents the color of all instances. You have to set its
|
|
61
70
|
* {@link BufferAttribute#needsUpdate} flag to true if you modify instanced data
|
|
@@ -185,6 +194,8 @@ class InstancedMesh extends Mesh {
|
|
|
185
194
|
|
|
186
195
|
this.instanceMatrix.copy( source.instanceMatrix );
|
|
187
196
|
|
|
197
|
+
if ( source.previousInstanceMatrix !== null ) this.previousInstanceMatrix = source.previousInstanceMatrix.clone();
|
|
198
|
+
|
|
188
199
|
if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
|
|
189
200
|
if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
|
|
190
201
|
|