@plastic-software/three 0.183.3 → 0.184.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +783 -290
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -184
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/PMREMGenerator.js +1 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +148 -49
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -0
- package/src/renderers/webgl/WebGLPrograms.js +24 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Color, Node, Vector3, Vector4 } from 'three/webgpu';
|
|
2
|
+
import { Loop, NodeUpdateType, getDistanceAttenuation, positionView, renderGroup, uniform, uniformArray, vec3 } from 'three/tsl';
|
|
3
|
+
|
|
4
|
+
const _position = /*@__PURE__*/ new Vector3();
|
|
5
|
+
|
|
6
|
+
const warn = ( message ) => {
|
|
7
|
+
|
|
8
|
+
console.warn( `THREE.PointLightDataNode: ${ message }` );
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Batched data node for point lights in dynamic lighting mode.
|
|
14
|
+
*
|
|
15
|
+
* @augments Node
|
|
16
|
+
*/
|
|
17
|
+
class PointLightDataNode extends Node {
|
|
18
|
+
|
|
19
|
+
static get type() {
|
|
20
|
+
|
|
21
|
+
return 'PointLightDataNode';
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor( maxCount = 16 ) {
|
|
26
|
+
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
this.maxCount = maxCount;
|
|
30
|
+
this._lights = [];
|
|
31
|
+
this._colors = [];
|
|
32
|
+
this._positionsAndCutoff = [];
|
|
33
|
+
this._decays = [];
|
|
34
|
+
|
|
35
|
+
for ( let i = 0; i < maxCount; i ++ ) {
|
|
36
|
+
|
|
37
|
+
this._colors.push( new Color() );
|
|
38
|
+
this._positionsAndCutoff.push( new Vector4() );
|
|
39
|
+
this._decays.push( new Vector4() );
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.colorsNode = uniformArray( this._colors, 'color' ).setGroup( renderGroup );
|
|
44
|
+
this.positionsAndCutoffNode = uniformArray( this._positionsAndCutoff, 'vec4' ).setGroup( renderGroup );
|
|
45
|
+
this.decaysNode = uniformArray( this._decays, 'vec4' ).setGroup( renderGroup );
|
|
46
|
+
this.countNode = uniform( 0, 'int' ).setGroup( renderGroup );
|
|
47
|
+
this.updateType = NodeUpdateType.RENDER;
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setLights( lights ) {
|
|
52
|
+
|
|
53
|
+
if ( lights.length > this.maxCount ) {
|
|
54
|
+
|
|
55
|
+
warn( `${ lights.length } lights exceed the configured max of ${ this.maxCount }. Excess lights are ignored.` );
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this._lights = lights;
|
|
60
|
+
|
|
61
|
+
return this;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
update( { camera } ) {
|
|
66
|
+
|
|
67
|
+
const count = Math.min( this._lights.length, this.maxCount );
|
|
68
|
+
|
|
69
|
+
this.countNode.value = count;
|
|
70
|
+
|
|
71
|
+
for ( let i = 0; i < count; i ++ ) {
|
|
72
|
+
|
|
73
|
+
const light = this._lights[ i ];
|
|
74
|
+
|
|
75
|
+
this._colors[ i ].copy( light.color ).multiplyScalar( light.intensity );
|
|
76
|
+
|
|
77
|
+
_position.setFromMatrixPosition( light.matrixWorld );
|
|
78
|
+
_position.applyMatrix4( camera.matrixWorldInverse );
|
|
79
|
+
|
|
80
|
+
const positionAndCutoff = this._positionsAndCutoff[ i ];
|
|
81
|
+
positionAndCutoff.x = _position.x;
|
|
82
|
+
positionAndCutoff.y = _position.y;
|
|
83
|
+
positionAndCutoff.z = _position.z;
|
|
84
|
+
positionAndCutoff.w = light.distance;
|
|
85
|
+
|
|
86
|
+
this._decays[ i ].x = light.decay;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setup( builder ) {
|
|
93
|
+
|
|
94
|
+
const surfacePosition = builder.context.positionView || positionView;
|
|
95
|
+
const { lightingModel, reflectedLight } = builder.context;
|
|
96
|
+
const dynDiffuse = vec3( 0 ).toVar( 'dynPointDiffuse' );
|
|
97
|
+
const dynSpecular = vec3( 0 ).toVar( 'dynPointSpecular' );
|
|
98
|
+
|
|
99
|
+
Loop( this.countNode, ( { i } ) => {
|
|
100
|
+
|
|
101
|
+
const positionAndCutoff = this.positionsAndCutoffNode.element( i );
|
|
102
|
+
const lightViewPosition = positionAndCutoff.xyz;
|
|
103
|
+
const cutoffDistance = positionAndCutoff.w;
|
|
104
|
+
const decayExponent = this.decaysNode.element( i ).x;
|
|
105
|
+
|
|
106
|
+
const lightVector = lightViewPosition.sub( surfacePosition ).toVar();
|
|
107
|
+
const lightDirection = lightVector.normalize().toVar();
|
|
108
|
+
const lightDistance = lightVector.length();
|
|
109
|
+
|
|
110
|
+
const attenuation = getDistanceAttenuation( {
|
|
111
|
+
lightDistance,
|
|
112
|
+
cutoffDistance,
|
|
113
|
+
decayExponent
|
|
114
|
+
} );
|
|
115
|
+
|
|
116
|
+
const lightColor = this.colorsNode.element( i ).mul( attenuation ).toVar();
|
|
117
|
+
|
|
118
|
+
lightingModel.direct( {
|
|
119
|
+
lightDirection,
|
|
120
|
+
lightColor,
|
|
121
|
+
lightNode: { light: {}, shadowNode: null },
|
|
122
|
+
reflectedLight: { directDiffuse: dynDiffuse, directSpecular: dynSpecular }
|
|
123
|
+
}, builder );
|
|
124
|
+
|
|
125
|
+
} );
|
|
126
|
+
|
|
127
|
+
reflectedLight.directDiffuse.addAssign( dynDiffuse );
|
|
128
|
+
reflectedLight.directSpecular.addAssign( dynSpecular );
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default PointLightDataNode;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Color, Node, Vector3, Vector4 } from 'three/webgpu';
|
|
2
|
+
import { Loop, NodeUpdateType, getDistanceAttenuation, positionView, renderGroup, smoothstep, uniform, uniformArray, vec3 } from 'three/tsl';
|
|
3
|
+
|
|
4
|
+
const _lightPosition = /*@__PURE__*/ new Vector3();
|
|
5
|
+
const _targetPosition = /*@__PURE__*/ new Vector3();
|
|
6
|
+
|
|
7
|
+
const warn = ( message ) => {
|
|
8
|
+
|
|
9
|
+
console.warn( `THREE.SpotLightDataNode: ${ message }` );
|
|
10
|
+
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Batched data node for simple spot lights in dynamic lighting mode.
|
|
15
|
+
*
|
|
16
|
+
* Projected spot lights keep the default per-light path.
|
|
17
|
+
*
|
|
18
|
+
* @augments Node
|
|
19
|
+
*/
|
|
20
|
+
class SpotLightDataNode extends Node {
|
|
21
|
+
|
|
22
|
+
static get type() {
|
|
23
|
+
|
|
24
|
+
return 'SpotLightDataNode';
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor( maxCount = 16 ) {
|
|
29
|
+
|
|
30
|
+
super();
|
|
31
|
+
|
|
32
|
+
this.maxCount = maxCount;
|
|
33
|
+
this._lights = [];
|
|
34
|
+
this._colors = [];
|
|
35
|
+
this._positionsAndCutoff = [];
|
|
36
|
+
this._directionsAndDecay = [];
|
|
37
|
+
this._cones = [];
|
|
38
|
+
|
|
39
|
+
for ( let i = 0; i < maxCount; i ++ ) {
|
|
40
|
+
|
|
41
|
+
this._colors.push( new Color() );
|
|
42
|
+
this._positionsAndCutoff.push( new Vector4() );
|
|
43
|
+
this._directionsAndDecay.push( new Vector4() );
|
|
44
|
+
this._cones.push( new Vector4() );
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.colorsNode = uniformArray( this._colors, 'color' ).setGroup( renderGroup );
|
|
49
|
+
this.positionsAndCutoffNode = uniformArray( this._positionsAndCutoff, 'vec4' ).setGroup( renderGroup );
|
|
50
|
+
this.directionsAndDecayNode = uniformArray( this._directionsAndDecay, 'vec4' ).setGroup( renderGroup );
|
|
51
|
+
this.conesNode = uniformArray( this._cones, 'vec4' ).setGroup( renderGroup );
|
|
52
|
+
this.countNode = uniform( 0, 'int' ).setGroup( renderGroup );
|
|
53
|
+
this.updateType = NodeUpdateType.RENDER;
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setLights( lights ) {
|
|
58
|
+
|
|
59
|
+
if ( lights.length > this.maxCount ) {
|
|
60
|
+
|
|
61
|
+
warn( `${ lights.length } lights exceed the configured max of ${ this.maxCount }. Excess lights are ignored.` );
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this._lights = lights;
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
update( { camera } ) {
|
|
72
|
+
|
|
73
|
+
const count = Math.min( this._lights.length, this.maxCount );
|
|
74
|
+
|
|
75
|
+
this.countNode.value = count;
|
|
76
|
+
|
|
77
|
+
for ( let i = 0; i < count; i ++ ) {
|
|
78
|
+
|
|
79
|
+
const light = this._lights[ i ];
|
|
80
|
+
|
|
81
|
+
this._colors[ i ].copy( light.color ).multiplyScalar( light.intensity );
|
|
82
|
+
|
|
83
|
+
_lightPosition.setFromMatrixPosition( light.matrixWorld );
|
|
84
|
+
_lightPosition.applyMatrix4( camera.matrixWorldInverse );
|
|
85
|
+
|
|
86
|
+
const positionAndCutoff = this._positionsAndCutoff[ i ];
|
|
87
|
+
positionAndCutoff.x = _lightPosition.x;
|
|
88
|
+
positionAndCutoff.y = _lightPosition.y;
|
|
89
|
+
positionAndCutoff.z = _lightPosition.z;
|
|
90
|
+
positionAndCutoff.w = light.distance;
|
|
91
|
+
|
|
92
|
+
_lightPosition.setFromMatrixPosition( light.matrixWorld );
|
|
93
|
+
_targetPosition.setFromMatrixPosition( light.target.matrixWorld );
|
|
94
|
+
_lightPosition.sub( _targetPosition ).transformDirection( camera.matrixWorldInverse );
|
|
95
|
+
|
|
96
|
+
const directionAndDecay = this._directionsAndDecay[ i ];
|
|
97
|
+
directionAndDecay.x = _lightPosition.x;
|
|
98
|
+
directionAndDecay.y = _lightPosition.y;
|
|
99
|
+
directionAndDecay.z = _lightPosition.z;
|
|
100
|
+
directionAndDecay.w = light.decay;
|
|
101
|
+
|
|
102
|
+
const cone = this._cones[ i ];
|
|
103
|
+
cone.x = Math.cos( light.angle );
|
|
104
|
+
cone.y = Math.cos( light.angle * ( 1 - light.penumbra ) );
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setup( builder ) {
|
|
111
|
+
|
|
112
|
+
const surfacePosition = builder.context.positionView || positionView;
|
|
113
|
+
const { lightingModel, reflectedLight } = builder.context;
|
|
114
|
+
const dynDiffuse = vec3( 0 ).toVar( 'dynSpotDiffuse' );
|
|
115
|
+
const dynSpecular = vec3( 0 ).toVar( 'dynSpotSpecular' );
|
|
116
|
+
|
|
117
|
+
Loop( this.countNode, ( { i } ) => {
|
|
118
|
+
|
|
119
|
+
const positionAndCutoff = this.positionsAndCutoffNode.element( i );
|
|
120
|
+
const lightViewPosition = positionAndCutoff.xyz;
|
|
121
|
+
const cutoffDistance = positionAndCutoff.w;
|
|
122
|
+
|
|
123
|
+
const directionAndDecay = this.directionsAndDecayNode.element( i );
|
|
124
|
+
const spotDirection = directionAndDecay.xyz;
|
|
125
|
+
const decayExponent = directionAndDecay.w;
|
|
126
|
+
|
|
127
|
+
const cone = this.conesNode.element( i );
|
|
128
|
+
const coneCos = cone.x;
|
|
129
|
+
const penumbraCos = cone.y;
|
|
130
|
+
|
|
131
|
+
const lightVector = lightViewPosition.sub( surfacePosition ).toVar();
|
|
132
|
+
const lightDirection = lightVector.normalize().toVar();
|
|
133
|
+
const lightDistance = lightVector.length();
|
|
134
|
+
|
|
135
|
+
const angleCos = lightDirection.dot( spotDirection );
|
|
136
|
+
const spotAttenuation = smoothstep( coneCos, penumbraCos, angleCos );
|
|
137
|
+
const distanceAttenuation = getDistanceAttenuation( {
|
|
138
|
+
lightDistance,
|
|
139
|
+
cutoffDistance,
|
|
140
|
+
decayExponent
|
|
141
|
+
} );
|
|
142
|
+
|
|
143
|
+
const lightColor = this.colorsNode.element( i ).mul( spotAttenuation ).mul( distanceAttenuation ).toVar();
|
|
144
|
+
|
|
145
|
+
lightingModel.direct( {
|
|
146
|
+
lightDirection,
|
|
147
|
+
lightColor,
|
|
148
|
+
lightNode: { light: {}, shadowNode: null },
|
|
149
|
+
reflectedLight: { directDiffuse: dynDiffuse, directSpecular: dynSpecular }
|
|
150
|
+
}, builder );
|
|
151
|
+
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
reflectedLight.directDiffuse.addAssign( dynDiffuse );
|
|
155
|
+
reflectedLight.directSpecular.addAssign( dynSpecular );
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default SpotLightDataNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageBitmapLoader, Texture } from 'three';
|
|
2
2
|
import { Fn, int, ivec2, textureLoad, screenUV, screenSize, mod, floor, float, vec3 } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -25,7 +25,18 @@ export const bayer16 = Fn( ( [ uv ] ) => {
|
|
|
25
25
|
|
|
26
26
|
const bayer16Base64 = 'data:image/png;base64,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';
|
|
27
27
|
|
|
28
|
-
bayer16Texture = new
|
|
28
|
+
bayer16Texture = new Texture();
|
|
29
|
+
const loader = new ImageBitmapLoader();
|
|
30
|
+
|
|
31
|
+
loader.setOptions( { imageOrientation: 'flipY', premultiplyAlpha: 'none' } );
|
|
32
|
+
|
|
33
|
+
loader.load( bayer16Base64, ( imageBitmap ) => {
|
|
34
|
+
|
|
35
|
+
bayer16Texture.image = imageBitmap;
|
|
36
|
+
bayer16Texture.flipY = false;
|
|
37
|
+
bayer16Texture.needsUpdate = true;
|
|
38
|
+
|
|
39
|
+
} );
|
|
29
40
|
|
|
30
41
|
}
|
|
31
42
|
|
|
@@ -286,8 +286,7 @@ function mergeGeometries( geometries, useGroups = false ) {
|
|
|
286
286
|
for ( const name in morphAttributes ) {
|
|
287
287
|
|
|
288
288
|
const numMorphTargets = morphAttributes[ name ][ 0 ].length;
|
|
289
|
-
|
|
290
|
-
if ( numMorphTargets === 0 ) break;
|
|
289
|
+
if ( numMorphTargets === 0 ) continue;
|
|
291
290
|
|
|
292
291
|
mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
|
|
293
292
|
mergedGeometry.morphAttributes[ name ] = [];
|
|
@@ -1021,7 +1020,7 @@ function computeMorphedAttributes( object ) {
|
|
|
1021
1020
|
const morphPosition = geometry.morphAttributes.position;
|
|
1022
1021
|
const morphTargetsRelative = geometry.morphTargetsRelative;
|
|
1023
1022
|
const normalAttribute = geometry.attributes.normal;
|
|
1024
|
-
const morphNormal = geometry.morphAttributes.
|
|
1023
|
+
const morphNormal = geometry.morphAttributes.normal;
|
|
1025
1024
|
|
|
1026
1025
|
const groups = geometry.groups;
|
|
1027
1026
|
const drawRange = geometry.drawRange;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { MathUtils, SRGBColorSpace } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module ColorUtils
|
|
5
|
+
* @three_import import * as ColorUtils from 'three/addons/utils/ColorUtils.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sets the given color from a color temperature in Kelvin.
|
|
10
|
+
*
|
|
11
|
+
* Converts a correlated color temperature (CTT) to an approximate sRGB color
|
|
12
|
+
* using Tanner Helland's algorithm. Useful for physically-based lighting
|
|
13
|
+
* setups — e.g. candle flame (~1900K), tungsten bulb (~3200K), daylight
|
|
14
|
+
* (~6500K), or clear blue sky (~10000K). Values outside [1000, 40000] are
|
|
15
|
+
* clamped.
|
|
16
|
+
*
|
|
17
|
+
* Reference: https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html
|
|
18
|
+
*
|
|
19
|
+
* @param {Color} color - The color to set.
|
|
20
|
+
* @param {number} kelvin - Color temperature in Kelvin. Clamped to [1000, 40000].
|
|
21
|
+
* @return {Color} The updated color.
|
|
22
|
+
*/
|
|
23
|
+
function setKelvin( color, kelvin ) {
|
|
24
|
+
|
|
25
|
+
// Algorithm by Tanner Helland (2012). Inputs are divided by 100.
|
|
26
|
+
const temp = MathUtils.clamp( kelvin, 1000, 40000 ) / 100;
|
|
27
|
+
|
|
28
|
+
let r, g, b;
|
|
29
|
+
|
|
30
|
+
// Red channel
|
|
31
|
+
if ( temp <= 66 ) {
|
|
32
|
+
|
|
33
|
+
r = 255;
|
|
34
|
+
|
|
35
|
+
} else {
|
|
36
|
+
|
|
37
|
+
r = 329.698727446 * Math.pow( temp - 60, - 0.1332047592 );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Green channel
|
|
42
|
+
if ( temp <= 66 ) {
|
|
43
|
+
|
|
44
|
+
g = 99.4708025861 * Math.log( temp ) - 161.1195681661;
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
|
|
48
|
+
g = 288.1221695283 * Math.pow( temp - 60, - 0.0755148492 );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Blue channel
|
|
53
|
+
if ( temp >= 66 ) {
|
|
54
|
+
|
|
55
|
+
b = 255;
|
|
56
|
+
|
|
57
|
+
} else if ( temp <= 19 ) {
|
|
58
|
+
|
|
59
|
+
b = 0;
|
|
60
|
+
|
|
61
|
+
} else {
|
|
62
|
+
|
|
63
|
+
b = 138.5177312231 * Math.log( temp - 10 ) - 305.0447927307;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return color.setRGB(
|
|
68
|
+
MathUtils.clamp( r, 0, 255 ) / 255,
|
|
69
|
+
MathUtils.clamp( g, 0, 255 ) / 255,
|
|
70
|
+
MathUtils.clamp( b, 0, 255 ) / 255,
|
|
71
|
+
SRGBColorSpace
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { setKelvin };
|
|
@@ -27,11 +27,13 @@ function getBoneName( bone, options ) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Retargets the skeleton from the given source
|
|
31
|
-
* target 3D object.
|
|
30
|
+
* Retargets the skeleton from the given source to the target.
|
|
32
31
|
*
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
32
|
+
* Both `target` and `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
|
33
|
+
* or a {@link Skeleton} directly.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object3D|Skeleton} target - The target object.
|
|
36
|
+
* @param {Object3D|Skeleton} source - The source object.
|
|
35
37
|
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
|
36
38
|
*/
|
|
37
39
|
function retarget( target, source, options = {} ) {
|
|
@@ -210,11 +212,13 @@ function retarget( target, source, options = {} ) {
|
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
/**
|
|
213
|
-
* Retargets the animation clip of the source
|
|
214
|
-
*
|
|
215
|
+
* Retargets the animation clip of the source to the target 3D object.
|
|
216
|
+
*
|
|
217
|
+
* The `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
|
218
|
+
* or a {@link Skeleton} directly.
|
|
215
219
|
*
|
|
216
|
-
* @param {Object3D} target - The target 3D object.
|
|
217
|
-
* @param {Object3D} source - The source
|
|
220
|
+
* @param {Object3D} target - The target 3D object. Must have a `skeleton` property.
|
|
221
|
+
* @param {Object3D|Skeleton} source - The source object.
|
|
218
222
|
* @param {AnimationClip} clip - The animation clip.
|
|
219
223
|
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
|
220
224
|
* @return {AnimationClip} The retargeted animation clip.
|
|
@@ -481,6 +485,8 @@ function parallelTraverse( a, b, callback ) {
|
|
|
481
485
|
* @property {string} [hip='hip'] - The name of the source's hip bone.
|
|
482
486
|
* @property {Vector3} [hipInfluence=(1,1,1)] - The hip influence.
|
|
483
487
|
* @property {number} [scale=1] - The scale.
|
|
488
|
+
* @property {Object<string,Matrix4>} [localOffsets] - Per-bone local offset matrices, keyed by bone name.
|
|
489
|
+
* @property {Vector3} [hipPosition] - An additional position offset applied to the hip bone.
|
|
484
490
|
**/
|
|
485
491
|
|
|
486
492
|
export {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GLTFLoader } from '../loaders/GLTFLoader.js';
|
|
2
|
+
import { clone } from '../utils/SkeletonUtils.js';
|
|
2
3
|
|
|
3
4
|
const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/';
|
|
4
5
|
|
|
@@ -20,8 +21,9 @@ class XRHandMeshModel {
|
|
|
20
21
|
* @param {XRHandedness} handedness - The handedness of the XR input source.
|
|
21
22
|
* @param {?Loader} [loader=null] - The loader. If not provided, an instance of `GLTFLoader` will be used to load models.
|
|
22
23
|
* @param {?Function} [onLoad=null] - A callback that is executed when a controller model has been loaded.
|
|
24
|
+
* @param {?Object} [customCache=null] - An optional shared cache object for storing and reusing loaded assets across instances.
|
|
23
25
|
*/
|
|
24
|
-
constructor( handModel, controller, path, handedness, loader = null, onLoad = null ) {
|
|
26
|
+
constructor( handModel, controller, path, handedness, loader = null, onLoad = null, customCache = null ) {
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* The WebXR controller.
|
|
@@ -45,16 +47,11 @@ class XRHandMeshModel {
|
|
|
45
47
|
*/
|
|
46
48
|
this.bones = [];
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
const pathToUse = path || DEFAULT_HAND_PROFILE_PATH;
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
loader.setPath( path || DEFAULT_HAND_PROFILE_PATH );
|
|
52
|
+
const processAsset = ( gltf ) => {
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
loader.load( `${handedness}.glb`, gltf => {
|
|
56
|
-
|
|
57
|
-
const object = gltf.scene.children[ 0 ];
|
|
54
|
+
const object = clone( gltf.scene.children[ 0 ] );
|
|
58
55
|
this.handModel.add( object );
|
|
59
56
|
|
|
60
57
|
const mesh = object.getObjectByProperty( 'type', 'SkinnedMesh' );
|
|
@@ -110,7 +107,36 @@ class XRHandMeshModel {
|
|
|
110
107
|
|
|
111
108
|
if ( onLoad ) onLoad( object );
|
|
112
109
|
|
|
113
|
-
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const assetUrl = `${pathToUse}${handedness}.glb`;
|
|
113
|
+
|
|
114
|
+
if ( customCache && customCache[ assetUrl ] ) {
|
|
115
|
+
|
|
116
|
+
processAsset( customCache[ assetUrl ] );
|
|
117
|
+
|
|
118
|
+
} else {
|
|
119
|
+
|
|
120
|
+
if ( loader === null ) {
|
|
121
|
+
|
|
122
|
+
loader = new GLTFLoader();
|
|
123
|
+
loader.setPath( pathToUse );
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
loader.load( `${handedness}.glb`, gltf => {
|
|
128
|
+
|
|
129
|
+
if ( customCache ) {
|
|
130
|
+
|
|
131
|
+
customCache[ assetUrl ] = gltf;
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
processAsset( gltf );
|
|
136
|
+
|
|
137
|
+
} );
|
|
138
|
+
|
|
139
|
+
}
|
|
114
140
|
|
|
115
141
|
}
|
|
116
142
|
|
|
@@ -118,6 +118,7 @@ class XRHandModelFactory {
|
|
|
118
118
|
* @default null
|
|
119
119
|
*/
|
|
120
120
|
this.path = null;
|
|
121
|
+
this._assetCache = {};
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
124
|
* A callback that is executed when a hand model has been loaded.
|
|
@@ -173,7 +174,7 @@ class XRHandModelFactory {
|
|
|
173
174
|
|
|
174
175
|
} else if ( profile === 'mesh' ) {
|
|
175
176
|
|
|
176
|
-
handModel.motionController = new XRHandMeshModel( handModel, controller, this.path, xrInputSource.handedness, this.gltfLoader, this.onLoad );
|
|
177
|
+
handModel.motionController = new XRHandMeshModel( handModel, controller, this.path, xrInputSource.handedness, this.gltfLoader, this.onLoad, this._assetCache );
|
|
177
178
|
|
|
178
179
|
}
|
|
179
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plastic-software/three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.184.0",
|
|
4
4
|
"description": "JavaScript 3D library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/three.cjs",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@eslint/js": "^9.0.0",
|
|
95
95
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
96
|
-
"@rollup/plugin-terser": "^0.
|
|
96
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
97
97
|
"eslint": "^9.0.0",
|
|
98
98
|
"eslint-config-mdcs": "^5.0.0",
|
|
99
|
-
"eslint-plugin-compat": "^
|
|
99
|
+
"eslint-plugin-compat": "^7.0.0",
|
|
100
100
|
"eslint-plugin-html": "^8.1.3",
|
|
101
101
|
"eslint-plugin-jsdoc": "^62.0.0",
|
|
102
102
|
"globals": "^17.0.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"jsdoc": "^4.0.5",
|
|
105
105
|
"magic-string": "^0.30.0",
|
|
106
106
|
"pngjs": "^7.0.0",
|
|
107
|
-
"puppeteer": "^24.
|
|
107
|
+
"puppeteer": "^24.40.0",
|
|
108
108
|
"qunit": "^2.19.4",
|
|
109
109
|
"rollup": "^4.6.0",
|
|
110
110
|
"turndown": "^7.2.2"
|
package/src/Three.Core.js
CHANGED
|
@@ -33,6 +33,7 @@ export { CompressedArrayTexture } from './textures/CompressedArrayTexture.js';
|
|
|
33
33
|
export { CompressedCubeTexture } from './textures/CompressedCubeTexture.js';
|
|
34
34
|
export { CubeTexture } from './textures/CubeTexture.js';
|
|
35
35
|
export { CanvasTexture } from './textures/CanvasTexture.js';
|
|
36
|
+
export { HTMLTexture } from './textures/HTMLTexture.js';
|
|
36
37
|
export { DepthTexture } from './textures/DepthTexture.js';
|
|
37
38
|
export { CubeDepthTexture } from './textures/CubeDepthTexture.js';
|
|
38
39
|
export { ExternalTexture } from './textures/ExternalTexture.js';
|
package/src/Three.TSL.js
CHANGED
|
@@ -40,6 +40,7 @@ export const VarIntent = TSL.VarIntent;
|
|
|
40
40
|
export const abs = TSL.abs;
|
|
41
41
|
export const acesFilmicToneMapping = TSL.acesFilmicToneMapping;
|
|
42
42
|
export const acos = TSL.acos;
|
|
43
|
+
export const acosh = TSL.acosh;
|
|
43
44
|
export const add = TSL.add;
|
|
44
45
|
export const addMethodChaining = TSL.addMethodChaining;
|
|
45
46
|
export const addNodeElement = TSL.addNodeElement;
|
|
@@ -55,8 +56,10 @@ export const append = TSL.append;
|
|
|
55
56
|
export const array = TSL.array;
|
|
56
57
|
export const arrayBuffer = TSL.arrayBuffer;
|
|
57
58
|
export const asin = TSL.asin;
|
|
59
|
+
export const asinh = TSL.asinh;
|
|
58
60
|
export const assign = TSL.assign;
|
|
59
61
|
export const atan = TSL.atan;
|
|
62
|
+
export const atanh = TSL.atanh;
|
|
60
63
|
export const atomicAdd = TSL.atomicAdd;
|
|
61
64
|
export const atomicAnd = TSL.atomicAnd;
|
|
62
65
|
export const atomicFunc = TSL.atomicFunc;
|
|
@@ -140,6 +143,7 @@ export const countLeadingZeros = TSL.countLeadingZeros;
|
|
|
140
143
|
export const countOneBits = TSL.countOneBits;
|
|
141
144
|
export const countTrailingZeros = TSL.countTrailingZeros;
|
|
142
145
|
export const cos = TSL.cos;
|
|
146
|
+
export const cosh = TSL.cosh;
|
|
143
147
|
export const cross = TSL.cross;
|
|
144
148
|
export const cubeTexture = TSL.cubeTexture;
|
|
145
149
|
export const cubeTextureBase = TSL.cubeTextureBase;
|
|
@@ -498,6 +502,7 @@ export const shiftRight = TSL.shiftRight;
|
|
|
498
502
|
export const shininess = TSL.shininess;
|
|
499
503
|
export const sign = TSL.sign;
|
|
500
504
|
export const sin = TSL.sin;
|
|
505
|
+
export const sinh = TSL.sinh;
|
|
501
506
|
export const sinc = TSL.sinc;
|
|
502
507
|
export const skinning = TSL.skinning;
|
|
503
508
|
export const smoothstep = TSL.smoothstep;
|
|
@@ -542,6 +547,7 @@ export const subgroupShuffleXor = TSL.subgroupShuffleXor;
|
|
|
542
547
|
export const subgroupSize = TSL.subgroupSize;
|
|
543
548
|
export const subgroupXor = TSL.subgroupXor;
|
|
544
549
|
export const tan = TSL.tan;
|
|
550
|
+
export const tanh = TSL.tanh;
|
|
545
551
|
export const tangentGeometry = TSL.tangentGeometry;
|
|
546
552
|
export const tangentLocal = TSL.tangentLocal;
|
|
547
553
|
export const tangentView = TSL.tangentView;
|
|
@@ -2,12 +2,15 @@ export * from './Three.Core.js';
|
|
|
2
2
|
|
|
3
3
|
export * from './materials/nodes/NodeMaterials.js';
|
|
4
4
|
export { default as WebGPURenderer } from './renderers/webgpu/WebGPURenderer.Nodes.js';
|
|
5
|
+
export { default as WebGPUBackend } from './renderers/webgpu/WebGPUBackend.js';
|
|
6
|
+
export { default as WebGLBackend } from './renderers/webgl-fallback/WebGLBackend.js';
|
|
5
7
|
export { default as Lighting } from './renderers/common/Lighting.js';
|
|
6
8
|
export { default as BundleGroup } from './renderers/common/BundleGroup.js';
|
|
7
9
|
export { default as QuadMesh } from './renderers/common/QuadMesh.js';
|
|
8
10
|
export { default as PMREMGenerator } from './renderers/common/extras/PMREMGenerator.js';
|
|
9
11
|
export { default as RenderPipeline } from './renderers/common/RenderPipeline.js';
|
|
10
12
|
export { default as PostProcessing } from './renderers/common/PostProcessing.js';
|
|
13
|
+
export { default as ReadbackBuffer } from './renderers/common/ReadbackBuffer.js';
|
|
11
14
|
import * as RendererUtils from './renderers/common/RendererUtils.js';
|
|
12
15
|
export { RendererUtils };
|
|
13
16
|
export { default as StorageTexture } from './renderers/common/StorageTexture.js';
|
package/src/Three.WebGPU.js
CHANGED
|
@@ -2,12 +2,16 @@ export * from './Three.Core.js';
|
|
|
2
2
|
|
|
3
3
|
export * from './materials/nodes/NodeMaterials.js';
|
|
4
4
|
export { default as WebGPURenderer } from './renderers/webgpu/WebGPURenderer.js';
|
|
5
|
+
export { default as WebGPUBackend } from './renderers/webgpu/WebGPUBackend.js';
|
|
6
|
+
export { default as WebGLBackend } from './renderers/webgl-fallback/WebGLBackend.js';
|
|
7
|
+
export { default as WebGLCapabilities } from './renderers/webgl-fallback/utils/WebGLCapabilities.js';
|
|
5
8
|
export { default as Lighting } from './renderers/common/Lighting.js';
|
|
6
9
|
export { default as BundleGroup } from './renderers/common/BundleGroup.js';
|
|
7
10
|
export { default as QuadMesh } from './renderers/common/QuadMesh.js';
|
|
8
11
|
export { default as PMREMGenerator } from './renderers/common/extras/PMREMGenerator.js';
|
|
9
12
|
export { default as RenderPipeline } from './renderers/common/RenderPipeline.js';
|
|
10
13
|
export { default as PostProcessing } from './renderers/common/PostProcessing.js';
|
|
14
|
+
export { default as ReadbackBuffer } from './renderers/common/ReadbackBuffer.js';
|
|
11
15
|
import * as RendererUtils from './renderers/common/RendererUtils.js';
|
|
12
16
|
export { RendererUtils };
|
|
13
17
|
export { default as CubeRenderTarget } from './renderers/common/CubeRenderTarget.js';
|
|
@@ -25,6 +29,8 @@ export { default as NodeMaterialLoader } from './loaders/nodes/NodeMaterialLoade
|
|
|
25
29
|
export { default as InspectorBase } from './renderers/common/InspectorBase.js';
|
|
26
30
|
export { default as CanvasTarget } from './renderers/common/CanvasTarget.js';
|
|
27
31
|
export { default as BlendMode } from './renderers/common/BlendMode.js';
|
|
32
|
+
export { default as GLSLNodeBuilder } from './renderers/webgl-fallback/nodes/GLSLNodeBuilder.js';
|
|
33
|
+
export { default as BasicNodeLibrary } from './renderers/webgpu/nodes/BasicNodeLibrary.js';
|
|
28
34
|
export { ClippingGroup } from './objects/ClippingGroup.js';
|
|
29
35
|
export * from './nodes/Nodes.js';
|
|
30
36
|
import * as TSL from './nodes/TSL.js';
|