diff --git a/examples/jsm/addons.js b/examples/jsm/addons.js new file mode 100644 index 00000000000000..550785a2ee70f6 --- /dev/null +++ b/examples/jsm/addons.js @@ -0,0 +1,299 @@ + +export * from './animation/AnimationClipCreator.js'; +export * from './animation/CCDIKSolver.js'; +export * from './animation/MMDPhysics.js'; +export * from './animation/MMDAnimationHelper.js'; + +export * from './cameras/CinematicCamera.js'; + +export { default as WebGL } from './capabilities/WebGL.js'; +export { default as WebGPU } from './capabilities/WebGPU.js'; + +export * from './controls/FirstPersonControls.js'; +export * from './controls/TransformControls.js'; +export * from './controls/DragControls.js'; +export * from './controls/PointerLockControls.js'; +export * from './controls/ArcballControls.js'; +export * from './controls/TrackballControls.js'; +export * from './controls/OrbitControls.js'; +export * from './controls/FlyControls.js'; + +export * from './csm/CSM.js'; +export * from './csm/CSMShader.js'; +export * from './csm/CSMFrustum.js'; +export * from './csm/CSMHelper.js'; + +export * as NURBSUtils from './curves/NURBSUtils.js'; +export * from './curves/NURBSCurve.js'; +export * from './curves/NURBSSurface.js'; +export * as Curves from './curves/CurveExtras.js'; + +export * from './deprecated/Geometry.js'; + +export * from './effects/ParallaxBarrierEffect.js'; +export * from './effects/PeppersGhostEffect.js'; +export * from './effects/OutlineEffect.js'; +export * from './effects/AnaglyphEffect.js'; +export * from './effects/AsciiEffect.js'; +export * from './effects/StereoEffect.js'; + +export * from './environments/DebugEnvironment.js'; +export * from './environments/RoomEnvironment.js'; + +export * from './exporters/GLTFExporter.js'; +export * from './exporters/USDZExporter.js'; +export * from './exporters/PLYExporter.js'; +export * from './exporters/DRACOExporter.js'; +export * from './exporters/ColladaExporter.js'; +export * from './exporters/MMDExporter.js'; +export * from './exporters/STLExporter.js'; +export * from './exporters/OBJExporter.js'; + +export * from './geometries/ParametricGeometries.js'; +export * from './geometries/TextGeometry.js'; +export * from './geometries/ConvexGeometry.js'; +export * from './geometries/ParametricGeometry.js'; +export * from './geometries/LightningStrike.js'; +export * from './geometries/RoundedBoxGeometry.js'; +export * from './geometries/BoxLineGeometry.js'; +export * from './geometries/DecalGeometry.js'; +export * from './geometries/TeapotGeometry.js'; + +export * from './helpers/LightProbeHelper.js'; +export * from './helpers/VertexTangentsHelper.js'; +export * from './helpers/PositionalAudioHelper.js'; +export * from './helpers/VertexNormalsHelper.js'; +export * from './helpers/RectAreaLightHelper.js'; + + +export * from './interactive/SelectionHelper.js'; +export * from './interactive/InteractiveGroup.js'; +export * from './interactive/HTMLMesh.js'; +export * from './interactive/SelectionBox.js'; + +export * from './lights/RectAreaLightUniformsLib.js'; +export * from './lights/LightProbeGenerator.js'; + + +export * from './lines/LineSegmentsGeometry.js'; +export * from './lines/LineGeometry.js'; +export * from './lines/Wireframe.js'; +export * from './lines/WireframeGeometry2.js'; +export * from './lines/Line2.js'; +export * from './lines/LineMaterial.js'; +export * from './lines/LineSegments2.js'; + + +export * from './loaders/FBXLoader.js'; +export * from './loaders/TGALoader.js'; +export * from './loaders/LUTCubeLoader.js'; +export * from './loaders/NRRDLoader.js'; +export * from './loaders/IFCLoader.js'; +export * from './loaders/FontLoader.js'; +export * from './loaders/STLLoader.js'; +export * from './loaders/MTLLoader.js'; +export * from './loaders/BVHLoader.js'; +export * from './loaders/KMZLoader.js'; +export * from './loaders/VRMLoader.js'; +export * from './loaders/VRMLLoader.js'; +export * from './loaders/KTX2Loader.js'; +export * from './loaders/LogLuvLoader.js'; +export * from './loaders/LottieLoader.js'; +export * from './loaders/TTFLoader.js'; +export * from './loaders/RGBELoader.js'; +export * from './loaders/ColladaLoader.js'; +export * from './loaders/MDDLoader.js'; +export * from './loaders/EXRLoader.js'; +export * from './loaders/3MFLoader.js'; +export * from './loaders/XYZLoader.js'; +export * from './loaders/VTKLoader.js'; +export * from './loaders/LUT3dlLoader.js'; +export * from './loaders/DDSLoader.js'; +export * from './loaders/PVRLoader.js'; +export * from './loaders/GCodeLoader.js'; +export * from './loaders/BasisTextureLoader.js'; +export * from './loaders/TDSLoader.js'; +export * from './loaders/LDrawLoader.js'; +export * from './loaders/GLTFLoader.js'; +export * from './loaders/lwo/IFFParser.js'; +export * from './loaders/SVGLoader.js'; +export * from './loaders/3DMLoader.js'; +export * from './loaders/OBJLoader.js'; +export * from './loaders/AMFLoader.js'; +export * from './loaders/MMDLoader.js'; +export * from './loaders/MD2Loader.js'; +export * from './loaders/KTXLoader.js'; +export * from './loaders/TiltLoader.js'; +export * from './loaders/DRACOLoader.js'; +export * from './loaders/HDRCubeTextureLoader.js'; +export * from './loaders/PDBLoader.js'; +export * from './loaders/PRWMLoader.js'; +export * from './loaders/RGBMLoader.js'; +export * from './loaders/VOXLoader.js'; +export * from './loaders/NodeMaterialLoader.js'; +export * from './loaders/PCDLoader.js'; +export * from './loaders/LWOLoader.js'; +export * from './loaders/PLYLoader.js'; + +export * from './objects/Lensflare.js'; +export * from './objects/MarchingCubes.js'; +export * from './objects/LightningStorm.js'; +export * from './objects/ReflectorRTT.js'; +export * from './objects/ReflectorForSSRPass.js'; +export * from './objects/Reflector.js'; +export * from './objects/Refractor.js'; +export * from './objects/ShadowMesh.js'; +export * from './objects/Sky.js'; +export * from './objects/Water.js'; +export { Water as Water2 } from './objects/Water2.js'; + +export * from './math/ConvexHull.js'; +export * from './math/MeshSurfaceSampler.js'; +export * from './math/SimplexNoise.js'; +export * from './math/OBB.js'; +export * from './math/Capsule.js'; +export * from './math/ColorConverter.js'; +export * from './math/ImprovedNoise.js'; +export * from './math/Octree.js'; +export * from './math/Lut.js'; + +export * from './misc/MD2CharacterComplex.js'; +export * from './misc/ConvexObjectBreaker.js'; +export * from './misc/MorphBlendMesh.js'; +export * from './misc/GPUComputationRenderer.js'; +export * from './misc/Gyroscope.js'; +export * from './misc/MorphAnimMesh.js'; +export * from './misc/ProgressiveLightMap.js'; +export * from './misc/RollerCoaster.js'; +export * from './misc/MD2Character.js'; +export * from './misc/VolumeSlice.js'; +export * from './misc/TubePainter.js'; +export * from './misc/Volume.js'; + +export * from './modifiers/CurveModifier.js'; +export * from './modifiers/SimplifyModifier.js'; +export * from './modifiers/EdgeSplitModifier.js'; +export * from './modifiers/TessellateModifier.js'; + +export * from './physics/OimoPhysics.js'; +export * from './physics/AmmoPhysics.js'; + +export * from './postprocessing/LUTPass.js'; +export * from './postprocessing/ClearPass.js'; +export * from './postprocessing/GlitchPass.js'; +export * from './postprocessing/HalftonePass.js'; +export * from './postprocessing/SMAAPass.js'; +export * from './postprocessing/FilmPass.js'; +export * from './postprocessing/OutlinePass.js'; +export * from './postprocessing/SSAOPass.js'; +export * from './postprocessing/SavePass.js'; +export * from './postprocessing/BokehPass.js'; +export * from './postprocessing/SSRrPass.js'; +export * from './postprocessing/Pass.js'; +export * from './postprocessing/TexturePass.js'; +export * from './postprocessing/AdaptiveToneMappingPass.js'; +export * from './postprocessing/UnrealBloomPass.js'; +export * from './postprocessing/CubeTexturePass.js'; +export * from './postprocessing/SAOPass.js'; +export * from './postprocessing/AfterimagePass.js'; +export * from './postprocessing/MaskPass.js'; +export * from './postprocessing/EffectComposer.js'; +export * from './postprocessing/DotScreenPass.js'; +export * from './postprocessing/SSRPass.js'; +export * from './postprocessing/TAARenderPass.js'; +export * from './postprocessing/ShaderPass.js'; +export * from './postprocessing/SSAARenderPass.js'; +export * from './postprocessing/RenderPass.js'; +export * from './postprocessing/BloomPass.js'; + +export * from './renderers/CSS2DRenderer.js'; +export * from './renderers/CSS3DRenderer.js'; +export * from './renderers/Projector.js'; +export * from './renderers/SVGRenderer.js'; +export * from './renderers/webgpu/WebGPU.js'; +export * from './renderers/nodes/Nodes.js'; +export * from './node-editor/NodeEditor.js'; +export { default as WebGLPhysicalContextNode } from './renderers/webgl/nodes/WebGLPhysicalContextNode.js'; +export * from './renderers/webgl/nodes/WebGLNodeBuilder.js'; +export { default as SlotNode } from './renderers/webgl/nodes/SlotNode.js'; +export * from './renderers/webgl/nodes/WebGLNodes.js'; + + +export * from './shaders/SMAAShader.js'; +export * from './shaders/HalftoneShader.js'; +export * from './shaders/ConvolutionShader.js'; +export * from './shaders/SAOShader.js'; +export * from './shaders/GodRaysShader.js'; +export * from './shaders/LuminosityShader.js'; +export * from './shaders/MirrorShader.js'; +export * from './shaders/ToneMapShader.js'; +export * from './shaders/BleachBypassShader.js'; +export * from './shaders/MMDToonShader.js'; +export * from './shaders/BlendShader.js'; +export * from './shaders/KaleidoShader.js'; +export * from './shaders/ACESFilmicToneMappingShader.js'; +export * from './shaders/VerticalBlurShader.js'; +export * from './shaders/SSRrShader.js'; +export * from './shaders/ColorCorrectionShader.js'; +export * from './shaders/PixelShader.js'; +export * from './shaders/BokehShader.js'; +export { BokehShader as BokehShader2 } from './shaders/BokehShader2.js'; +export * from './shaders/FocusShader.js'; +export * from './shaders/WaterRefractionShader.js'; +export * from './shaders/RGBShiftShader.js'; +export * from './shaders/TriangleBlurShader.js'; +export * from './shaders/FilmShader.js'; +export * from './shaders/SepiaShader.js'; +export * from './shaders/FXAAShader.js'; +export * from './shaders/AfterimageShader.js'; +export * from './shaders/DotScreenShader.js'; +export * from './shaders/SubsurfaceScatteringShader.js'; +export * from './shaders/ToonShader.js'; +export * from './shaders/DepthLimitedBlurShader.js'; +export * from './shaders/NormalMapShader.js'; +export * from './shaders/FreiChenShader.js'; +export * from './shaders/VolumeShader.js'; +export * from './shaders/HorizontalTiltShiftShader.js'; +export * from './shaders/VerticalTiltShiftShader.js'; +export * from './shaders/BrightnessContrastShader.js'; +export * from './shaders/SobelOperatorShader.js'; +export * from './shaders/SSAOShader.js'; +export * from './shaders/GammaCorrectionShader.js'; +export * from './shaders/VignetteShader.js'; +export * from './shaders/HorizontalBlurShader.js'; +export * from './shaders/UnpackDepthRGBAShader.js'; +export * from './shaders/HueSaturationShader.js'; +export * from './shaders/DigitalGlitch.js'; +export * from './shaders/BasicShader.js'; +export * from './shaders/CopyShader.js'; +export * from './shaders/LuminosityHighPassShader.js'; +export * from './shaders/DOFMipMapShader.js'; +export * from './shaders/SSRShader.js'; +export * from './shaders/TechnicolorShader.js'; +export * from './shaders/ColorifyShader.js'; + +export * from './textures/FlakesTexture.js'; + +export * as BufferGeometryUtils from './utils/BufferGeometryUtils.js'; +export * as CameraUtils from './utils/CameraUtils.js'; +export * as GeometryUtils from './utils/GeometryUtils.js'; +export * from './utils/GPUStatsPanel.js'; +export * as GeometryCompressionUtils from './utils/GeometryCompressionUtils.js'; +export * as LDrawUtils from './utils/LDrawUtils.js'; +export * from './utils/PackedPhongMaterial.js'; +export * as SceneUtils from './utils/SceneUtils.js'; +export * from './utils/ShadowMapViewer.js'; +export * as SkeletonUtils from './utils/SkeletonUtils.js'; +export * from './utils/UVsDebug.js'; +export * from './utils/WorkerPool.js'; + +export * from './webxr/XRHandMeshModel.js'; +export * from './webxr/XRHandModelFactory.js'; +export * from './webxr/XREstimatedLight.js'; +export * from './webxr/XRControllerModelFactory.js'; +export * from './webxr/OculusHandModel.js'; +export * from './webxr/OculusHandPointerModel.js'; +export * from './webxr/VRButton.js'; +export * from './webxr/Text2D.js'; +export * from './webxr/XRHandPrimitiveModel.js'; +export * from './webxr/ARButton.js'; diff --git a/examples/jsm/csm/CSM.js b/examples/jsm/csm/CSM.js index c96e627f233af0..2a1ffd6f201099 100644 --- a/examples/jsm/csm/CSM.js +++ b/examples/jsm/csm/CSM.js @@ -17,7 +17,7 @@ const _bbox = new Box3(); const _uniformArray = []; const _logArray = []; -export class CSM { +class CSM { constructor( data ) { @@ -375,3 +375,5 @@ export class CSM { } } + +export { CSM }; diff --git a/examples/jsm/curves/CurveExtras.js b/examples/jsm/curves/CurveExtras.js index 19636653f1ad2a..51efb84591f0f2 100644 --- a/examples/jsm/curves/CurveExtras.js +++ b/examples/jsm/curves/CurveExtras.js @@ -404,21 +404,19 @@ class DecoratedTorusKnot5c extends Curve { } -const Curves = { - GrannyKnot: GrannyKnot, - HeartCurve: HeartCurve, - VivianiCurve: VivianiCurve, - KnotCurve: KnotCurve, - HelixCurve: HelixCurve, - TrefoilKnot: TrefoilKnot, - TorusKnot: TorusKnot, - CinquefoilKnot: CinquefoilKnot, - TrefoilPolynomialKnot: TrefoilPolynomialKnot, - FigureEightPolynomialKnot: FigureEightPolynomialKnot, - DecoratedTorusKnot4a: DecoratedTorusKnot4a, - DecoratedTorusKnot4b: DecoratedTorusKnot4b, - DecoratedTorusKnot5a: DecoratedTorusKnot5a, - DecoratedTorusKnot5c: DecoratedTorusKnot5c +export { + GrannyKnot, + HeartCurve, + VivianiCurve, + KnotCurve, + HelixCurve, + TrefoilKnot, + TorusKnot, + CinquefoilKnot, + TrefoilPolynomialKnot, + FigureEightPolynomialKnot, + DecoratedTorusKnot4a, + DecoratedTorusKnot4b, + DecoratedTorusKnot5a, + DecoratedTorusKnot5c }; - -export { Curves }; diff --git a/examples/jsm/loaders/LUT3dlLoader.js b/examples/jsm/loaders/LUT3dlLoader.js index 01153cb16b371e..a9fbbf863c2814 100644 --- a/examples/jsm/loaders/LUT3dlLoader.js +++ b/examples/jsm/loaders/LUT3dlLoader.js @@ -11,7 +11,7 @@ import { LinearFilter, } from 'three'; -export class LUT3dlLoader extends Loader { +class LUT3dlLoader extends Loader { load( url, onLoad, onProgress, onError ) { @@ -149,3 +149,5 @@ export class LUT3dlLoader extends Loader { } } + +export { LUT3dlLoader }; diff --git a/examples/jsm/modifiers/CurveModifier.js b/examples/jsm/modifiers/CurveModifier.js index 8a10796d9013f3..eb56b40fe07a28 100644 --- a/examples/jsm/modifiers/CurveModifier.js +++ b/examples/jsm/modifiers/CurveModifier.js @@ -20,7 +20,7 @@ import { * * @param { number } numberOfCurves the number of curves needed to be described by this texture. */ -export function initSplineTexture( numberOfCurves = 1 ) { +function initSplineTexture( numberOfCurves = 1 ) { const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS ); const dataTexture = new DataTexture( @@ -47,7 +47,7 @@ export function initSplineTexture( numberOfCurves = 1 ) { * @param { Curve } splineCurve The curve to describe * @param { number } offset Which curve slot to write to */ -export function updateSplineTexture( texture, splineCurve, offset = 0 ) { +function updateSplineTexture( texture, splineCurve, offset = 0 ) { const numberOfPoints = Math.floor( TEXTURE_WIDTH * ( TEXTURE_HEIGHT / 4 ) ); splineCurve.arcLengthDivisions = numberOfPoints / 2; @@ -93,7 +93,7 @@ function setTextureValue( texture, index, x, y, z, o ) { * * @param { DataTexture } Texture which holds the curve description */ -export function getUniforms( splineTexture ) { +function getUniforms( splineTexture ) { const uniforms = { spineTexture: { value: splineTexture }, @@ -107,7 +107,7 @@ export function getUniforms( splineTexture ) { } -export function modifyShader( material, uniforms, numberOfCurves = 1 ) { +function modifyShader( material, uniforms, numberOfCurves = 1 ) { if ( material.__ok ) return; material.__ok = true; @@ -196,7 +196,7 @@ vec3 transformedNormal = normalMatrix * (basis * objectNormal); /** * A helper class for making meshes bend aroudn curves */ -export class Flow { +class Flow { /** * @param {Mesh} mesh The mesh to clone and modify to bend around the curve @@ -253,7 +253,7 @@ const matrix = new Matrix4(); /** * A helper class for creating instanced versions of flow, where the instances are placed on the curve. */ -export class InstancedFlow extends Flow { +class InstancedFlow extends Flow { /** * @@ -323,3 +323,12 @@ export class InstancedFlow extends Flow { } } + +export { + initSplineTexture, + updateSplineTexture, + getUniforms, + modifyShader, + Flow, + InstancedFlow, +}; diff --git a/examples/jsm/package.json b/examples/jsm/package.json deleted file mode 100644 index 472002573ef7ac..00000000000000 --- a/examples/jsm/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/examples/jsm/postprocessing/EffectComposer.js b/examples/jsm/postprocessing/EffectComposer.js index dc2d4e3d10ac81..926d509f52eaf0 100644 --- a/examples/jsm/postprocessing/EffectComposer.js +++ b/examples/jsm/postprocessing/EffectComposer.js @@ -1,10 +1,6 @@ import { - BufferGeometry, Clock, - Float32BufferAttribute, LinearFilter, - Mesh, - OrthographicCamera, RGBAFormat, Vector2, WebGLRenderTarget @@ -242,77 +238,4 @@ class EffectComposer { } - -class Pass { - - constructor() { - - // if set to true, the pass is processed by the composer - this.enabled = true; - - // if set to true, the pass indicates to swap read and write buffer after rendering - this.needsSwap = true; - - // if set to true, the pass clears its buffer before rendering - this.clear = false; - - // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer. - this.renderToScreen = false; - - } - - setSize( /* width, height */ ) {} - - render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) { - - console.error( 'THREE.Pass: .render() must be implemented in derived pass.' ); - - } - -} - -// Helper for passes that need to fill the viewport with a single quad. - -const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); - -// https://github.com/mrdoob/three.js/pull/21358 - -const _geometry = new BufferGeometry(); -_geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) ); -_geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) ); - -class FullScreenQuad { - - constructor( material ) { - - this._mesh = new Mesh( _geometry, material ); - - } - - dispose() { - - this._mesh.geometry.dispose(); - - } - - render( renderer ) { - - renderer.render( this._mesh, _camera ); - - } - - get material() { - - return this._mesh.material; - - } - - set material( value ) { - - this._mesh.material = value; - - } - -} - -export { EffectComposer, Pass, FullScreenQuad }; +export { EffectComposer }; diff --git a/examples/jsm/renderers/webgpu/WebGPU.js b/examples/jsm/renderers/webgpu/WebGPU.js new file mode 100644 index 00000000000000..1b1e74f4eee0b3 --- /dev/null +++ b/examples/jsm/renderers/webgpu/WebGPU.js @@ -0,0 +1,32 @@ + +export * from './constants.js'; +export { default as WebGPUTextures } from './WebGPUTextures.js'; +export { default as WebGPUInfo } from './WebGPUInfo.js'; +export { default as WebGPUProgrammableStage } from './WebGPUProgrammableStage.js'; +export { default as WebGPURenderLists } from './WebGPURenderLists.js'; +export { default as WebGPUTextureRenderer } from './WebGPUTextureRenderer.js'; +export { default as WebGPURenderPipelines } from './WebGPURenderPipelines.js'; +export { default as WebGPUGeometries } from './WebGPUGeometries.js'; +export { default as WebGPUNodeBuilder } from './nodes/WebGPUNodeBuilder.js'; +export { WebGPUNodeSampledTexture } from './nodes/WebGPUNodeSampledTexture.js'; +export * from './nodes/WebGPUNodeUniform.js'; +export { default as WebGPUNodeSampler } from './nodes/WebGPUNodeSampler.js'; +export { default as WebGPUNodeUniformsGroup } from './nodes/WebGPUNodeUniformsGroup.js'; +export { default as WebGPUNodes } from './nodes/WebGPUNodes.js'; +export { default as WebGPUBindings } from './WebGPUBindings.js'; +export * from './WebGPUSampledTexture.js'; +export { default as WebGPUUniformsGroup } from './WebGPUUniformsGroup.js'; +export { default as WebGPURenderer } from './WebGPURenderer.js'; +export { default as WebGPUComputePipelines } from './WebGPUComputePipelines.js'; +export * from './WebGPUUniform.js'; +export { default as WebGPUObjects } from './WebGPUObjects.js'; +export { default as WebGPUSampler } from './WebGPUSampler.js'; +export { default as WebGPURenderPipeline } from './WebGPURenderPipeline.js'; +export { default as WebGPUBackground } from './WebGPUBackground.js'; +export { default as WebGPUBinding } from './WebGPUBinding.js'; +export { default as WebGPUProperties } from './WebGPUProperties.js'; +export { default as WebGPUUniformBuffer } from './WebGPUUniformBuffer.js'; +export { default as WebGPUAttributes } from './WebGPUAttributes.js'; +export * as WebGPUBufferUtils from './WebGPUBufferUtils.js'; +export { default as WebGPUStorageBuffer } from './WebGPUStorageBuffer.js'; +export { default as WebGPUTextureUtils } from './WebGPUTextureUtils.js'; diff --git a/examples/jsm/utils/GPUStatsPanel.js b/examples/jsm/utils/GPUStatsPanel.js index 1f9530c2b47bcf..16b33ac78e0f0e 100644 --- a/examples/jsm/utils/GPUStatsPanel.js +++ b/examples/jsm/utils/GPUStatsPanel.js @@ -2,7 +2,7 @@ import Stats from '../libs/stats.module.js'; // https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query/ // https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/ -export class GPUStatsPanel extends Stats.Panel { +class GPUStatsPanel extends Stats.Panel { constructor( context, name = 'GPU MS' ) { @@ -126,3 +126,5 @@ export class GPUStatsPanel extends Stats.Panel { } } + +export { GPUStatsPanel }; diff --git a/examples/jsm/utils/LDrawUtils.js b/examples/jsm/utils/LDrawUtils.js index 62c082f901b774..6029bdc75108f3 100644 --- a/examples/jsm/utils/LDrawUtils.js +++ b/examples/jsm/utils/LDrawUtils.js @@ -9,194 +9,193 @@ import { import { mergeBufferGeometries } from './BufferGeometryUtils.js'; -class LDrawUtils { - static mergeObject( object ) { +function mergeObject( object ) { - // Merges geometries in object by materials and returns new object. Use on not indexed geometries. - // The object buffers reference the old object ones. - // Special treatment is done to the conditional lines generated by LDrawLoader. + // Merges geometries in object by materials and returns new object. Use on not indexed geometries. + // The object buffers reference the old object ones. + // Special treatment is done to the conditional lines generated by LDrawLoader. - function extractGroup( geometry, group, elementSize, isConditionalLine ) { + function extractGroup( geometry, group, elementSize, isConditionalLine ) { - // Extracts a group from a geometry as a new geometry (with attribute buffers referencing original buffers) + // Extracts a group from a geometry as a new geometry (with attribute buffers referencing original buffers) - const newGeometry = new BufferGeometry(); + const newGeometry = new BufferGeometry(); - const originalPositions = geometry.getAttribute( 'position' ).array; - const originalNormals = elementSize === 3 ? geometry.getAttribute( 'normal' ).array : null; + const originalPositions = geometry.getAttribute( 'position' ).array; + const originalNormals = elementSize === 3 ? geometry.getAttribute( 'normal' ).array : null; - const numVertsGroup = Math.min( group.count, Math.floor( originalPositions.length / 3 ) - group.start ); - const vertStart = group.start * 3; - const vertEnd = ( group.start + numVertsGroup ) * 3; + const numVertsGroup = Math.min( group.count, Math.floor( originalPositions.length / 3 ) - group.start ); + const vertStart = group.start * 3; + const vertEnd = ( group.start + numVertsGroup ) * 3; - const positions = originalPositions.subarray( vertStart, vertEnd ); - const normals = originalNormals !== null ? originalNormals.subarray( vertStart, vertEnd ) : null; + const positions = originalPositions.subarray( vertStart, vertEnd ); + const normals = originalNormals !== null ? originalNormals.subarray( vertStart, vertEnd ) : null; - newGeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) ); - if ( normals !== null ) newGeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) ); + newGeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) ); + if ( normals !== null ) newGeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) ); - if ( isConditionalLine ) { + if ( isConditionalLine ) { - const controlArray0 = geometry.getAttribute( 'control0' ).array.subarray( vertStart, vertEnd ); - const controlArray1 = geometry.getAttribute( 'control1' ).array.subarray( vertStart, vertEnd ); - const directionArray = geometry.getAttribute( 'direction' ).array.subarray( vertStart, vertEnd ); + const controlArray0 = geometry.getAttribute( 'control0' ).array.subarray( vertStart, vertEnd ); + const controlArray1 = geometry.getAttribute( 'control1' ).array.subarray( vertStart, vertEnd ); + const directionArray = geometry.getAttribute( 'direction' ).array.subarray( vertStart, vertEnd ); - newGeometry.setAttribute( 'control0', new BufferAttribute( controlArray0, 3, false ) ); - newGeometry.setAttribute( 'control1', new BufferAttribute( controlArray1, 3, false ) ); - newGeometry.setAttribute( 'direction', new BufferAttribute( directionArray, 3, false ) ); - - } - - return newGeometry; + newGeometry.setAttribute( 'control0', new BufferAttribute( controlArray0, 3, false ) ); + newGeometry.setAttribute( 'control1', new BufferAttribute( controlArray1, 3, false ) ); + newGeometry.setAttribute( 'direction', new BufferAttribute( directionArray, 3, false ) ); } - function addGeometry( mat, geometry, geometries ) { + return newGeometry; - const geoms = geometries[ mat.uuid ]; - if ( ! geoms ) { + } - geometries[ mat.uuid ] = { - mat: mat, - arr: [ geometry ] - }; + function addGeometry( mat, geometry, geometries ) { - } else { + const geoms = geometries[ mat.uuid ]; + if ( ! geoms ) { - geoms.arr.push( geometry ); + geometries[ mat.uuid ] = { + mat: mat, + arr: [ geometry ] + }; - } + } else { + + geoms.arr.push( geometry ); } - function permuteAttribute( attribute, elemSize ) { + } - // Permutes first two vertices of each attribute element + function permuteAttribute( attribute, elemSize ) { - if ( ! attribute ) return; + // Permutes first two vertices of each attribute element - const verts = attribute.array; - const numVerts = Math.floor( verts.length / 3 ); - let offset = 0; - for ( let i = 0; i < numVerts; i ++ ) { + if ( ! attribute ) return; - const x = verts[ offset ]; - const y = verts[ offset + 1 ]; - const z = verts[ offset + 2 ]; + const verts = attribute.array; + const numVerts = Math.floor( verts.length / 3 ); + let offset = 0; + for ( let i = 0; i < numVerts; i ++ ) { - verts[ offset ] = verts[ offset + 3 ]; - verts[ offset + 1 ] = verts[ offset + 4 ]; - verts[ offset + 2 ] = verts[ offset + 5 ]; + const x = verts[ offset ]; + const y = verts[ offset + 1 ]; + const z = verts[ offset + 2 ]; - verts[ offset + 3 ] = x; - verts[ offset + 4 ] = y; - verts[ offset + 5 ] = z; + verts[ offset ] = verts[ offset + 3 ]; + verts[ offset + 1 ] = verts[ offset + 4 ]; + verts[ offset + 2 ] = verts[ offset + 5 ]; - offset += elemSize * 3; + verts[ offset + 3 ] = x; + verts[ offset + 4 ] = y; + verts[ offset + 5 ] = z; - } + offset += elemSize * 3; } - // Traverse the object hierarchy collecting geometries and transforming them to world space + } - const meshGeometries = {}; - const linesGeometries = {}; - const condLinesGeometries = {}; + // Traverse the object hierarchy collecting geometries and transforming them to world space - object.updateMatrixWorld( true ); - const normalMatrix = new Matrix3(); + const meshGeometries = {}; + const linesGeometries = {}; + const condLinesGeometries = {}; - object.traverse( c => { + object.updateMatrixWorld( true ); + const normalMatrix = new Matrix3(); - if ( c.isMesh | c.isLineSegments ) { + object.traverse( c => { - const elemSize = c.isMesh ? 3 : 2; + if ( c.isMesh | c.isLineSegments ) { - const geometry = c.geometry.clone(); - const matrixIsInverted = c.matrixWorld.determinant() < 0; - if ( matrixIsInverted ) { + const elemSize = c.isMesh ? 3 : 2; - permuteAttribute( geometry.attributes.position, elemSize ); - permuteAttribute( geometry.attributes.normal, elemSize ); + const geometry = c.geometry.clone(); + const matrixIsInverted = c.matrixWorld.determinant() < 0; + if ( matrixIsInverted ) { - } + permuteAttribute( geometry.attributes.position, elemSize ); + permuteAttribute( geometry.attributes.normal, elemSize ); - geometry.applyMatrix4( c.matrixWorld ); + } - if ( c.isConditionalLine ) { + geometry.applyMatrix4( c.matrixWorld ); - geometry.attributes.control0.applyMatrix4( c.matrixWorld ); - geometry.attributes.control1.applyMatrix4( c.matrixWorld ); - normalMatrix.getNormalMatrix( c.matrixWorld ); - geometry.attributes.direction.applyNormalMatrix( normalMatrix ); + if ( c.isConditionalLine ) { - } + geometry.attributes.control0.applyMatrix4( c.matrixWorld ); + geometry.attributes.control1.applyMatrix4( c.matrixWorld ); + normalMatrix.getNormalMatrix( c.matrixWorld ); + geometry.attributes.direction.applyNormalMatrix( normalMatrix ); - const geometries = c.isMesh ? meshGeometries : ( c.isConditionalLine ? condLinesGeometries : linesGeometries ); + } - if ( Array.isArray( c.material ) ) { + const geometries = c.isMesh ? meshGeometries : ( c.isConditionalLine ? condLinesGeometries : linesGeometries ); - for ( const groupIndex in geometry.groups ) { + if ( Array.isArray( c.material ) ) { - const group = geometry.groups[ groupIndex ]; - const mat = c.material[ group.materialIndex ]; - const newGeometry = extractGroup( geometry, group, elemSize, c.isConditionalLine ); - addGeometry( mat, newGeometry, geometries ); + for ( const groupIndex in geometry.groups ) { - } + const group = geometry.groups[ groupIndex ]; + const mat = c.material[ group.materialIndex ]; + const newGeometry = extractGroup( geometry, group, elemSize, c.isConditionalLine ); + addGeometry( mat, newGeometry, geometries ); - } else { + } - addGeometry( c.material, geometry, geometries ); + } else { - } + addGeometry( c.material, geometry, geometries ); } - } ); + } - // Create object with merged geometries + } ); - const mergedObject = new Group(); + // Create object with merged geometries - const meshMaterialsIds = Object.keys( meshGeometries ); - for ( const i in meshMaterialsIds ) { + const mergedObject = new Group(); - const meshGeometry = meshGeometries[ meshMaterialsIds[ i ] ]; - const mergedGeometry = mergeBufferGeometries( meshGeometry.arr ); - mergedObject.add( new Mesh( mergedGeometry, meshGeometry.mat ) ); + const meshMaterialsIds = Object.keys( meshGeometries ); + for ( const i in meshMaterialsIds ) { - } + const meshGeometry = meshGeometries[ meshMaterialsIds[ i ] ]; + const mergedGeometry = mergeBufferGeometries( meshGeometry.arr ); + mergedObject.add( new Mesh( mergedGeometry, meshGeometry.mat ) ); - const linesMaterialsIds = Object.keys( linesGeometries ); - for ( const i in linesMaterialsIds ) { + } - const lineGeometry = linesGeometries[ linesMaterialsIds[ i ] ]; - const mergedGeometry = mergeBufferGeometries( lineGeometry.arr ); - mergedObject.add( new LineSegments( mergedGeometry, lineGeometry.mat ) ); + const linesMaterialsIds = Object.keys( linesGeometries ); + for ( const i in linesMaterialsIds ) { - } + const lineGeometry = linesGeometries[ linesMaterialsIds[ i ] ]; + const mergedGeometry = mergeBufferGeometries( lineGeometry.arr ); + mergedObject.add( new LineSegments( mergedGeometry, lineGeometry.mat ) ); - const condLinesMaterialsIds = Object.keys( condLinesGeometries ); - for ( const i in condLinesMaterialsIds ) { + } - const condLineGeometry = condLinesGeometries[ condLinesMaterialsIds[ i ] ]; - const mergedGeometry = mergeBufferGeometries( condLineGeometry.arr ); - const condLines = new LineSegments( mergedGeometry, condLineGeometry.mat ); - condLines.isConditionalLine = true; - mergedObject.add( condLines ); + const condLinesMaterialsIds = Object.keys( condLinesGeometries ); + for ( const i in condLinesMaterialsIds ) { - } + const condLineGeometry = condLinesGeometries[ condLinesMaterialsIds[ i ] ]; + const mergedGeometry = mergeBufferGeometries( condLineGeometry.arr ); + const condLines = new LineSegments( mergedGeometry, condLineGeometry.mat ); + condLines.isConditionalLine = true; + mergedObject.add( condLines ); - mergedObject.userData.constructionStep = 0; - mergedObject.userData.numConstructionSteps = 1; + } - return mergedObject; + mergedObject.userData.constructionStep = 0; + mergedObject.userData.numConstructionSteps = 1; - } + return mergedObject; } -export { LDrawUtils }; + + +export { mergeObject }; diff --git a/examples/jsm/utils/WorkerPool.js b/examples/jsm/utils/WorkerPool.js index c8d191609387e6..140f2483327828 100644 --- a/examples/jsm/utils/WorkerPool.js +++ b/examples/jsm/utils/WorkerPool.js @@ -2,7 +2,7 @@ * @author Deepkolos / https://github.com/deepkolos */ -export class WorkerPool { +class WorkerPool { constructor( pool = 4 ) { @@ -100,3 +100,5 @@ export class WorkerPool { } } + +export { WorkerPool }; diff --git a/examples/jsm/webxr/XREstimatedLight.js b/examples/jsm/webxr/XREstimatedLight.js index ddd2c087dc872a..0a2fe22c150fb4 100644 --- a/examples/jsm/webxr/XREstimatedLight.js +++ b/examples/jsm/webxr/XREstimatedLight.js @@ -133,7 +133,7 @@ class SessionLightProbe { } -export class XREstimatedLight extends Group { +class XREstimatedLight extends Group { constructor( renderer, environmentEstimation = true ) { @@ -221,3 +221,5 @@ export class XREstimatedLight extends Group { } } + +export { XREstimatedLight }; diff --git a/examples/webgl_geometries_parametric.html b/examples/webgl_geometries_parametric.html index 8f39594d6a6730..9e1a4eecc6d2a1 100644 --- a/examples/webgl_geometries_parametric.html +++ b/examples/webgl_geometries_parametric.html @@ -29,7 +29,7 @@ import Stats from './jsm/libs/stats.module.js'; - import { Curves } from './jsm/curves/CurveExtras.js'; + import * as Curves from './jsm/curves/CurveExtras.js'; import { ParametricGeometry } from './jsm/geometries/ParametricGeometry.js'; import { ParametricGeometries } from './jsm/geometries/ParametricGeometries.js'; diff --git a/examples/webgl_geometry_extrude_splines.html b/examples/webgl_geometry_extrude_splines.html index 1a0f529d5e7e9c..b65d801e210eba 100644 --- a/examples/webgl_geometry_extrude_splines.html +++ b/examples/webgl_geometry_extrude_splines.html @@ -41,7 +41,7 @@ import Stats from './jsm/libs/stats.module.js'; import { GUI } from './jsm/libs/lil-gui.module.min.js'; - import { Curves } from './jsm/curves/CurveExtras.js'; + import * as Curves from './jsm/curves/CurveExtras.js'; import { OrbitControls } from './jsm/controls/OrbitControls.js'; let container, stats; diff --git a/examples/webgl_loader_ldraw.html b/examples/webgl_loader_ldraw.html index 7f4def486d2b13..b2618d2b48aab8 100644 --- a/examples/webgl_loader_ldraw.html +++ b/examples/webgl_loader_ldraw.html @@ -42,7 +42,7 @@ import { RoomEnvironment } from './jsm/environments/RoomEnvironment.js'; import { LDrawLoader } from './jsm/loaders/LDrawLoader.js'; - import { LDrawUtils } from './jsm/utils/LDrawUtils.js'; + import * as LDrawUtils from './jsm/utils/LDrawUtils.js'; let container, progressBarDiv; diff --git a/package.json b/package.json index 910e1ae6f917e4..92b71b1abebcc0 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "import": "./build/three.module.js", "require": "./build/three.cjs" }, + "./addons": "./examples/jsm/addons.js", "./examples/fonts/*": "./examples/fonts/*", "./examples/jsm/*": "./examples/jsm/*", "./src/*": "./src/*"