@needle-tools/three 0.145.2 → 0.146.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +3559 -6924
- package/build/three.js +3559 -6924
- package/build/three.min.js +1 -2
- package/build/three.module.js +732 -339
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +94 -28
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLCubeUVMaps.js +1 -1
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
|
|
3
3
|
const _taskCache = new WeakMap();
|
|
4
|
-
|
|
5
4
|
class Rhino3dmLoader extends THREE.Loader {
|
|
6
5
|
|
|
7
6
|
constructor( manager ) {
|
|
@@ -21,21 +20,18 @@
|
|
|
21
20
|
this.warnings = [];
|
|
22
21
|
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
setLibraryPath( path ) {
|
|
26
24
|
|
|
27
25
|
this.libraryPath = path;
|
|
28
26
|
return this;
|
|
29
27
|
|
|
30
28
|
}
|
|
31
|
-
|
|
32
29
|
setWorkerLimit( workerLimit ) {
|
|
33
30
|
|
|
34
31
|
this.workerLimit = workerLimit;
|
|
35
32
|
return this;
|
|
36
33
|
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
load( url, onLoad, onProgress, onError ) {
|
|
40
36
|
|
|
41
37
|
const loader = new THREE.FileLoader( this.manager );
|
|
@@ -50,7 +46,6 @@
|
|
|
50
46
|
if ( _taskCache.has( buffer ) ) {
|
|
51
47
|
|
|
52
48
|
const cachedTask = _taskCache.get( buffer );
|
|
53
|
-
|
|
54
49
|
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
55
50
|
|
|
56
51
|
}
|
|
@@ -65,19 +60,16 @@
|
|
|
65
60
|
}, onProgress, onError );
|
|
66
61
|
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
debug() {
|
|
70
64
|
|
|
71
65
|
console.log( 'Task load: ', this.workerPool.map( worker => worker._taskLoad ) );
|
|
72
66
|
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
decodeObjects( buffer, url ) {
|
|
76
69
|
|
|
77
70
|
let worker;
|
|
78
71
|
let taskID;
|
|
79
72
|
const taskCost = buffer.byteLength;
|
|
80
|
-
|
|
81
73
|
const objectPending = this._getWorker( taskCost ).then( _worker => {
|
|
82
74
|
|
|
83
75
|
worker = _worker;
|
|
@@ -92,7 +84,9 @@
|
|
|
92
84
|
type: 'decode',
|
|
93
85
|
id: taskID,
|
|
94
86
|
buffer
|
|
95
|
-
}, [ buffer ] );
|
|
87
|
+
}, [ buffer ] );
|
|
88
|
+
|
|
89
|
+
// this.debug();
|
|
96
90
|
|
|
97
91
|
} );
|
|
98
92
|
|
|
@@ -100,29 +94,30 @@
|
|
|
100
94
|
|
|
101
95
|
throw e;
|
|
102
96
|
|
|
103
|
-
} );
|
|
104
|
-
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
|
105
|
-
|
|
97
|
+
} );
|
|
106
98
|
|
|
99
|
+
// Remove task from the task list.
|
|
100
|
+
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
|
107
101
|
objectPending.catch( () => true ).then( () => {
|
|
108
102
|
|
|
109
103
|
if ( worker && taskID ) {
|
|
110
104
|
|
|
111
|
-
this._releaseTask( worker, taskID );
|
|
105
|
+
this._releaseTask( worker, taskID );
|
|
106
|
+
|
|
107
|
+
//this.debug();
|
|
112
108
|
|
|
113
109
|
}
|
|
114
110
|
|
|
115
|
-
} );
|
|
111
|
+
} );
|
|
116
112
|
|
|
113
|
+
// Cache the task result.
|
|
117
114
|
_taskCache.set( buffer, {
|
|
118
115
|
url: url,
|
|
119
116
|
promise: objectPending
|
|
120
117
|
} );
|
|
121
|
-
|
|
122
118
|
return objectPending;
|
|
123
119
|
|
|
124
120
|
}
|
|
125
|
-
|
|
126
121
|
parse( data, onLoad, onError ) {
|
|
127
122
|
|
|
128
123
|
this.decodeObjects( data, '' ).then( result => {
|
|
@@ -133,7 +128,6 @@
|
|
|
133
128
|
} ).catch( e => onError( e ) );
|
|
134
129
|
|
|
135
130
|
}
|
|
136
|
-
|
|
137
131
|
_compareMaterials( material ) {
|
|
138
132
|
|
|
139
133
|
const mat = {};
|
|
@@ -143,7 +137,6 @@
|
|
|
143
137
|
mat.color.g = material.color.g;
|
|
144
138
|
mat.color.b = material.color.b;
|
|
145
139
|
mat.type = material.type;
|
|
146
|
-
|
|
147
140
|
for ( let i = 0; i < this.materials.length; i ++ ) {
|
|
148
141
|
|
|
149
142
|
const m = this.materials[ i ];
|
|
@@ -154,7 +147,6 @@
|
|
|
154
147
|
_mat.color.g = m.color.g;
|
|
155
148
|
_mat.color.b = m.color.b;
|
|
156
149
|
_mat.type = m.type;
|
|
157
|
-
|
|
158
150
|
if ( JSON.stringify( mat ) === JSON.stringify( _mat ) ) {
|
|
159
151
|
|
|
160
152
|
return m;
|
|
@@ -167,7 +159,6 @@
|
|
|
167
159
|
return material;
|
|
168
160
|
|
|
169
161
|
}
|
|
170
|
-
|
|
171
162
|
_createMaterial( material ) {
|
|
172
163
|
|
|
173
164
|
if ( material === undefined ) {
|
|
@@ -183,15 +174,15 @@
|
|
|
183
174
|
|
|
184
175
|
const _diffuseColor = material.diffuseColor;
|
|
185
176
|
const diffusecolor = new THREE.Color( _diffuseColor.r / 255.0, _diffuseColor.g / 255.0, _diffuseColor.b / 255.0 );
|
|
186
|
-
|
|
187
177
|
if ( _diffuseColor.r === 0 && _diffuseColor.g === 0 && _diffuseColor.b === 0 ) {
|
|
188
178
|
|
|
189
179
|
diffusecolor.r = 1;
|
|
190
180
|
diffusecolor.g = 1;
|
|
191
181
|
diffusecolor.b = 1;
|
|
192
182
|
|
|
193
|
-
}
|
|
183
|
+
}
|
|
194
184
|
|
|
185
|
+
// console.log( material );
|
|
195
186
|
|
|
196
187
|
const mat = new THREE.MeshStandardMaterial( {
|
|
197
188
|
color: diffusecolor,
|
|
@@ -201,30 +192,24 @@
|
|
|
201
192
|
opacity: 1.0 - material.transparency
|
|
202
193
|
} );
|
|
203
194
|
const textureLoader = new THREE.TextureLoader();
|
|
204
|
-
|
|
205
195
|
for ( let i = 0; i < material.textures.length; i ++ ) {
|
|
206
196
|
|
|
207
197
|
const texture = material.textures[ i ];
|
|
208
|
-
|
|
209
198
|
if ( texture.image !== null ) {
|
|
210
199
|
|
|
211
200
|
const map = textureLoader.load( texture.image );
|
|
212
|
-
|
|
213
201
|
switch ( texture.type ) {
|
|
214
202
|
|
|
215
203
|
case 'Diffuse':
|
|
216
204
|
mat.map = map;
|
|
217
205
|
break;
|
|
218
|
-
|
|
219
206
|
case 'Bump':
|
|
220
207
|
mat.bumpMap = map;
|
|
221
208
|
break;
|
|
222
|
-
|
|
223
209
|
case 'Transparency':
|
|
224
210
|
mat.alphaMap = map;
|
|
225
211
|
mat.transparent = true;
|
|
226
212
|
break;
|
|
227
|
-
|
|
228
213
|
case 'Emap':
|
|
229
214
|
mat.envMap = map;
|
|
230
215
|
break;
|
|
@@ -242,10 +227,10 @@
|
|
|
242
227
|
return mat;
|
|
243
228
|
|
|
244
229
|
}
|
|
245
|
-
|
|
246
230
|
_createGeometry( data ) {
|
|
247
231
|
|
|
248
232
|
// console.log(data);
|
|
233
|
+
|
|
249
234
|
const object = new THREE.Object3D();
|
|
250
235
|
const instanceDefinitionObjects = [];
|
|
251
236
|
const instanceDefinitions = [];
|
|
@@ -258,38 +243,30 @@
|
|
|
258
243
|
object.name = this.url;
|
|
259
244
|
let objects = data.objects;
|
|
260
245
|
const materials = data.materials;
|
|
261
|
-
|
|
262
246
|
for ( let i = 0; i < objects.length; i ++ ) {
|
|
263
247
|
|
|
264
248
|
const obj = objects[ i ];
|
|
265
249
|
const attributes = obj.attributes;
|
|
266
|
-
|
|
267
250
|
switch ( obj.objectType ) {
|
|
268
251
|
|
|
269
252
|
case 'InstanceDefinition':
|
|
270
253
|
instanceDefinitions.push( obj );
|
|
271
254
|
break;
|
|
272
|
-
|
|
273
255
|
case 'InstanceReference':
|
|
274
256
|
instanceReferences.push( obj );
|
|
275
257
|
break;
|
|
276
|
-
|
|
277
258
|
default:
|
|
278
259
|
let _object;
|
|
279
|
-
|
|
280
260
|
if ( attributes.materialIndex >= 0 ) {
|
|
281
261
|
|
|
282
262
|
const rMaterial = materials[ attributes.materialIndex ];
|
|
283
|
-
|
|
284
263
|
let material = this._createMaterial( rMaterial );
|
|
285
|
-
|
|
286
264
|
material = this._compareMaterials( material );
|
|
287
265
|
_object = this._createObject( obj, material );
|
|
288
266
|
|
|
289
267
|
} else {
|
|
290
268
|
|
|
291
269
|
const material = this._createMaterial();
|
|
292
|
-
|
|
293
270
|
_object = this._createObject( obj, material );
|
|
294
271
|
|
|
295
272
|
}
|
|
@@ -302,7 +279,6 @@
|
|
|
302
279
|
|
|
303
280
|
const layer = data.layers[ attributes.layerIndex ];
|
|
304
281
|
_object.visible = layer ? data.layers[ attributes.layerIndex ].visible : true;
|
|
305
|
-
|
|
306
282
|
if ( attributes.isInstanceDefinitionObject ) {
|
|
307
283
|
|
|
308
284
|
instanceDefinitionObjects.push( _object );
|
|
@@ -323,15 +299,12 @@
|
|
|
323
299
|
|
|
324
300
|
const iDef = instanceDefinitions[ i ];
|
|
325
301
|
objects = [];
|
|
326
|
-
|
|
327
302
|
for ( let j = 0; j < iDef.attributes.objectIds.length; j ++ ) {
|
|
328
303
|
|
|
329
304
|
const objId = iDef.attributes.objectIds[ j ];
|
|
330
|
-
|
|
331
305
|
for ( let p = 0; p < instanceDefinitionObjects.length; p ++ ) {
|
|
332
306
|
|
|
333
307
|
const idoId = instanceDefinitionObjects[ p ].userData.attributes.id;
|
|
334
|
-
|
|
335
308
|
if ( objId === idoId ) {
|
|
336
309
|
|
|
337
310
|
objects.push( instanceDefinitionObjects[ p ] );
|
|
@@ -340,13 +313,13 @@
|
|
|
340
313
|
|
|
341
314
|
}
|
|
342
315
|
|
|
343
|
-
}
|
|
316
|
+
}
|
|
344
317
|
|
|
318
|
+
// Currently clones geometry and does not take advantage of instancing
|
|
345
319
|
|
|
346
320
|
for ( let j = 0; j < instanceReferences.length; j ++ ) {
|
|
347
321
|
|
|
348
322
|
const iRef = instanceReferences[ j ];
|
|
349
|
-
|
|
350
323
|
if ( iRef.geometry.parentIdefId === iDef.attributes.id ) {
|
|
351
324
|
|
|
352
325
|
const iRefObject = new THREE.Object3D();
|
|
@@ -354,7 +327,6 @@
|
|
|
354
327
|
const matrix = new THREE.Matrix4();
|
|
355
328
|
matrix.set( xf[ 0 ], xf[ 1 ], xf[ 2 ], xf[ 3 ], xf[ 4 ], xf[ 5 ], xf[ 6 ], xf[ 7 ], xf[ 8 ], xf[ 9 ], xf[ 10 ], xf[ 11 ], xf[ 12 ], xf[ 13 ], xf[ 14 ], xf[ 15 ] );
|
|
356
329
|
iRefObject.applyMatrix4( matrix );
|
|
357
|
-
|
|
358
330
|
for ( let p = 0; p < objects.length; p ++ ) {
|
|
359
331
|
|
|
360
332
|
iRefObject.add( objects[ p ].clone( true ) );
|
|
@@ -373,20 +345,16 @@
|
|
|
373
345
|
return object;
|
|
374
346
|
|
|
375
347
|
}
|
|
376
|
-
|
|
377
348
|
_createObject( obj, mat ) {
|
|
378
349
|
|
|
379
350
|
const loader = new THREE.BufferGeometryLoader();
|
|
380
351
|
const attributes = obj.attributes;
|
|
381
|
-
|
|
382
352
|
let geometry, material, _color, color;
|
|
383
|
-
|
|
384
353
|
switch ( obj.objectType ) {
|
|
385
354
|
|
|
386
355
|
case 'Point':
|
|
387
356
|
case 'PointSet':
|
|
388
357
|
geometry = loader.parse( obj.geometry );
|
|
389
|
-
|
|
390
358
|
if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
|
|
391
359
|
|
|
392
360
|
material = new THREE.PointsMaterial( {
|
|
@@ -411,7 +379,6 @@
|
|
|
411
379
|
const points = new THREE.Points( geometry, material );
|
|
412
380
|
points.userData[ 'attributes' ] = attributes;
|
|
413
381
|
points.userData[ 'objectType' ] = obj.objectType;
|
|
414
|
-
|
|
415
382
|
if ( attributes.name ) {
|
|
416
383
|
|
|
417
384
|
points.name = attributes.name;
|
|
@@ -419,14 +386,12 @@
|
|
|
419
386
|
}
|
|
420
387
|
|
|
421
388
|
return points;
|
|
422
|
-
|
|
423
389
|
case 'Mesh':
|
|
424
390
|
case 'Extrusion':
|
|
425
391
|
case 'SubD':
|
|
426
392
|
case 'Brep':
|
|
427
393
|
if ( obj.geometry === null ) return;
|
|
428
394
|
geometry = loader.parse( obj.geometry );
|
|
429
|
-
|
|
430
395
|
if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
|
|
431
396
|
|
|
432
397
|
mat.vertexColors = true;
|
|
@@ -445,7 +410,6 @@
|
|
|
445
410
|
mesh.receiveShadow = attributes.receivesShadows;
|
|
446
411
|
mesh.userData[ 'attributes' ] = attributes;
|
|
447
412
|
mesh.userData[ 'objectType' ] = obj.objectType;
|
|
448
|
-
|
|
449
413
|
if ( attributes.name ) {
|
|
450
414
|
|
|
451
415
|
mesh.name = attributes.name;
|
|
@@ -453,7 +417,6 @@
|
|
|
453
417
|
}
|
|
454
418
|
|
|
455
419
|
return mesh;
|
|
456
|
-
|
|
457
420
|
case 'Curve':
|
|
458
421
|
geometry = loader.parse( obj.geometry );
|
|
459
422
|
_color = attributes.drawColor;
|
|
@@ -465,7 +428,6 @@
|
|
|
465
428
|
const lines = new THREE.Line( geometry, material );
|
|
466
429
|
lines.userData[ 'attributes' ] = attributes;
|
|
467
430
|
lines.userData[ 'objectType' ] = obj.objectType;
|
|
468
|
-
|
|
469
431
|
if ( attributes.name ) {
|
|
470
432
|
|
|
471
433
|
lines.name = attributes.name;
|
|
@@ -473,7 +435,6 @@
|
|
|
473
435
|
}
|
|
474
436
|
|
|
475
437
|
return lines;
|
|
476
|
-
|
|
477
438
|
case 'TextDot':
|
|
478
439
|
geometry = obj.geometry;
|
|
479
440
|
const ctx = document.createElement( 'canvas' ).getContext( '2d' );
|
|
@@ -508,7 +469,6 @@
|
|
|
508
469
|
sprite.scale.set( width / 10, height / 10, 1.0 );
|
|
509
470
|
sprite.userData[ 'attributes' ] = attributes;
|
|
510
471
|
sprite.userData[ 'objectType' ] = obj.objectType;
|
|
511
|
-
|
|
512
472
|
if ( attributes.name ) {
|
|
513
473
|
|
|
514
474
|
sprite.name = attributes.name;
|
|
@@ -516,11 +476,9 @@
|
|
|
516
476
|
}
|
|
517
477
|
|
|
518
478
|
return sprite;
|
|
519
|
-
|
|
520
479
|
case 'Light':
|
|
521
480
|
geometry = obj.geometry;
|
|
522
481
|
let light;
|
|
523
|
-
|
|
524
482
|
switch ( geometry.lightStyle.name ) {
|
|
525
483
|
|
|
526
484
|
case 'LightStyle_WorldPoint':
|
|
@@ -529,7 +487,6 @@
|
|
|
529
487
|
light.position.set( geometry.location[ 0 ], geometry.location[ 1 ], geometry.location[ 2 ] );
|
|
530
488
|
light.shadow.normalBias = 0.1;
|
|
531
489
|
break;
|
|
532
|
-
|
|
533
490
|
case 'LightStyle_WorldSpot':
|
|
534
491
|
light = new THREE.SpotLight();
|
|
535
492
|
light.castShadow = attributes.castsShadows;
|
|
@@ -538,7 +495,6 @@
|
|
|
538
495
|
light.angle = geometry.spotAngleRadians;
|
|
539
496
|
light.shadow.normalBias = 0.1;
|
|
540
497
|
break;
|
|
541
|
-
|
|
542
498
|
case 'LightStyle_WorldRectangular':
|
|
543
499
|
light = new THREE.RectAreaLight();
|
|
544
500
|
const width = Math.abs( geometry.width[ 2 ] );
|
|
@@ -546,9 +502,8 @@
|
|
|
546
502
|
light.position.set( geometry.location[ 0 ] - height / 2, geometry.location[ 1 ], geometry.location[ 2 ] - width / 2 );
|
|
547
503
|
light.height = height;
|
|
548
504
|
light.width = width;
|
|
549
|
-
light.lookAt(
|
|
505
|
+
light.lookAt( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
|
|
550
506
|
break;
|
|
551
|
-
|
|
552
507
|
case 'LightStyle_WorldDirectional':
|
|
553
508
|
light = new THREE.DirectionalLight();
|
|
554
509
|
light.castShadow = attributes.castsShadows;
|
|
@@ -556,11 +511,9 @@
|
|
|
556
511
|
light.target.position.set( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
|
|
557
512
|
light.shadow.normalBias = 0.1;
|
|
558
513
|
break;
|
|
559
|
-
|
|
560
514
|
case 'LightStyle_WorldLinear':
|
|
561
515
|
// not conversion exists, warning has already been printed to the console
|
|
562
516
|
break;
|
|
563
|
-
|
|
564
517
|
default:
|
|
565
518
|
break;
|
|
566
519
|
|
|
@@ -582,7 +535,6 @@
|
|
|
582
535
|
}
|
|
583
536
|
|
|
584
537
|
}
|
|
585
|
-
|
|
586
538
|
_initLibrary() {
|
|
587
539
|
|
|
588
540
|
if ( ! this.libraryPending ) {
|
|
@@ -594,8 +546,9 @@
|
|
|
594
546
|
|
|
595
547
|
jsLoader.load( 'rhino3dm.js', resolve, undefined, reject );
|
|
596
548
|
|
|
597
|
-
} );
|
|
549
|
+
} );
|
|
598
550
|
|
|
551
|
+
// Load rhino3dm WASM binary.
|
|
599
552
|
const binaryLoader = new THREE.FileLoader( this.manager );
|
|
600
553
|
binaryLoader.setPath( this.libraryPath );
|
|
601
554
|
binaryLoader.setResponseType( 'arraybuffer' );
|
|
@@ -619,7 +572,6 @@
|
|
|
619
572
|
return this.libraryPending;
|
|
620
573
|
|
|
621
574
|
}
|
|
622
|
-
|
|
623
575
|
_getWorker( taskCost ) {
|
|
624
576
|
|
|
625
577
|
return this._initLibrary().then( () => {
|
|
@@ -634,28 +586,21 @@
|
|
|
634
586
|
type: 'init',
|
|
635
587
|
libraryConfig: this.libraryConfig
|
|
636
588
|
} );
|
|
637
|
-
|
|
638
589
|
worker.onmessage = e => {
|
|
639
590
|
|
|
640
591
|
const message = e.data;
|
|
641
|
-
|
|
642
592
|
switch ( message.type ) {
|
|
643
593
|
|
|
644
594
|
case 'warning':
|
|
645
595
|
this.warnings.push( message.data );
|
|
646
596
|
console.warn( message.data );
|
|
647
597
|
break;
|
|
648
|
-
|
|
649
598
|
case 'decode':
|
|
650
599
|
worker._callbacks[ message.id ].resolve( message );
|
|
651
|
-
|
|
652
600
|
break;
|
|
653
|
-
|
|
654
601
|
case 'error':
|
|
655
602
|
worker._callbacks[ message.id ].reject( message );
|
|
656
|
-
|
|
657
603
|
break;
|
|
658
|
-
|
|
659
604
|
default:
|
|
660
605
|
console.error( 'THREE.Rhino3dmLoader: Unexpected message, "' + message.type + '"' );
|
|
661
606
|
|
|
@@ -682,7 +627,6 @@
|
|
|
682
627
|
} );
|
|
683
628
|
|
|
684
629
|
}
|
|
685
|
-
|
|
686
630
|
_releaseTask( worker, taskID ) {
|
|
687
631
|
|
|
688
632
|
worker._taskLoad -= worker._taskCosts[ taskID ];
|
|
@@ -690,7 +634,6 @@
|
|
|
690
634
|
delete worker._taskCosts[ taskID ];
|
|
691
635
|
|
|
692
636
|
}
|
|
693
|
-
|
|
694
637
|
dispose() {
|
|
695
638
|
|
|
696
639
|
for ( let i = 0; i < this.workerPool.length; ++ i ) {
|
|
@@ -705,8 +648,8 @@
|
|
|
705
648
|
}
|
|
706
649
|
|
|
707
650
|
}
|
|
708
|
-
/* WEB WORKER */
|
|
709
651
|
|
|
652
|
+
/* WEB WORKER */
|
|
710
653
|
|
|
711
654
|
function Rhino3dmWorker() {
|
|
712
655
|
|
|
@@ -714,11 +657,9 @@
|
|
|
714
657
|
let libraryConfig;
|
|
715
658
|
let rhino;
|
|
716
659
|
let taskID;
|
|
717
|
-
|
|
718
660
|
onmessage = function ( e ) {
|
|
719
661
|
|
|
720
662
|
const message = e.data;
|
|
721
|
-
|
|
722
663
|
switch ( message.type ) {
|
|
723
664
|
|
|
724
665
|
case 'init':
|
|
@@ -741,7 +682,6 @@
|
|
|
741
682
|
|
|
742
683
|
} );
|
|
743
684
|
break;
|
|
744
|
-
|
|
745
685
|
case 'decode':
|
|
746
686
|
taskID = message.id;
|
|
747
687
|
const buffer = message.buffer;
|
|
@@ -783,28 +723,27 @@
|
|
|
783
723
|
const views = [];
|
|
784
724
|
const namedViews = [];
|
|
785
725
|
const groups = [];
|
|
786
|
-
const strings = [];
|
|
726
|
+
const strings = [];
|
|
727
|
+
|
|
728
|
+
//Handle objects
|
|
787
729
|
|
|
788
730
|
const objs = doc.objects();
|
|
789
731
|
const cnt = objs.count;
|
|
790
|
-
|
|
791
732
|
for ( let i = 0; i < cnt; i ++ ) {
|
|
792
733
|
|
|
793
734
|
const _object = objs.get( i );
|
|
794
|
-
|
|
795
735
|
const object = extractObjectData( _object, doc );
|
|
796
|
-
|
|
797
736
|
_object.delete();
|
|
798
|
-
|
|
799
737
|
if ( object ) {
|
|
800
738
|
|
|
801
739
|
objects.push( object );
|
|
802
740
|
|
|
803
741
|
}
|
|
804
742
|
|
|
805
|
-
}
|
|
806
|
-
// console.log( `Instance Definitions Count: ${doc.instanceDefinitions().count()}` );
|
|
743
|
+
}
|
|
807
744
|
|
|
745
|
+
// Handle instance definitions
|
|
746
|
+
// console.log( `Instance Definitions Count: ${doc.instanceDefinitions().count()}` );
|
|
808
747
|
|
|
809
748
|
for ( let i = 0; i < doc.instanceDefinitions().count(); i ++ ) {
|
|
810
749
|
|
|
@@ -817,26 +756,23 @@
|
|
|
817
756
|
objectType: 'InstanceDefinition'
|
|
818
757
|
} );
|
|
819
758
|
|
|
820
|
-
}
|
|
759
|
+
}
|
|
821
760
|
|
|
761
|
+
// Handle materials
|
|
822
762
|
|
|
823
|
-
const textureTypes = [
|
|
763
|
+
const textureTypes = [
|
|
764
|
+
// rhino.TextureType.Bitmap,
|
|
824
765
|
rhino.TextureType.Diffuse, rhino.TextureType.Bump, rhino.TextureType.Transparency, rhino.TextureType.Opacity, rhino.TextureType.Emap ];
|
|
825
766
|
const pbrTextureTypes = [ rhino.TextureType.PBR_BaseColor, rhino.TextureType.PBR_Subsurface, rhino.TextureType.PBR_SubsurfaceScattering, rhino.TextureType.PBR_SubsurfaceScatteringRadius, rhino.TextureType.PBR_Metallic, rhino.TextureType.PBR_Specular, rhino.TextureType.PBR_SpecularTint, rhino.TextureType.PBR_Roughness, rhino.TextureType.PBR_Anisotropic, rhino.TextureType.PBR_Anisotropic_Rotation, rhino.TextureType.PBR_Sheen, rhino.TextureType.PBR_SheenTint, rhino.TextureType.PBR_Clearcoat, rhino.TextureType.PBR_ClearcoatBump, rhino.TextureType.PBR_ClearcoatRoughness, rhino.TextureType.PBR_OpacityIor, rhino.TextureType.PBR_OpacityRoughness, rhino.TextureType.PBR_Emission, rhino.TextureType.PBR_AmbientOcclusion, rhino.TextureType.PBR_Displacement ];
|
|
826
|
-
|
|
827
767
|
for ( let i = 0; i < doc.materials().count(); i ++ ) {
|
|
828
768
|
|
|
829
769
|
const _material = doc.materials().get( i );
|
|
830
|
-
|
|
831
770
|
const _pbrMaterial = _material.physicallyBased();
|
|
832
|
-
|
|
833
771
|
let material = extractProperties( _material );
|
|
834
772
|
const textures = [];
|
|
835
|
-
|
|
836
773
|
for ( let j = 0; j < textureTypes.length; j ++ ) {
|
|
837
774
|
|
|
838
775
|
const _texture = _material.getTexture( textureTypes[ j ] );
|
|
839
|
-
|
|
840
776
|
if ( _texture ) {
|
|
841
777
|
|
|
842
778
|
let textureType = textureTypes[ j ].constructor.name;
|
|
@@ -848,11 +784,8 @@
|
|
|
848
784
|
texture.wrapU = _texture.wrapU;
|
|
849
785
|
texture.wrapV = _texture.wrapV;
|
|
850
786
|
texture.wrapW = _texture.wrapW;
|
|
851
|
-
|
|
852
787
|
const uvw = _texture.uvwTransform.toFloatArray( true );
|
|
853
|
-
|
|
854
788
|
texture.repeat = [ uvw[ 0 ], uvw[ 5 ] ];
|
|
855
|
-
|
|
856
789
|
if ( image ) {
|
|
857
790
|
|
|
858
791
|
texture.image = 'data:image/png;base64,' + image;
|
|
@@ -872,7 +805,6 @@
|
|
|
872
805
|
}
|
|
873
806
|
|
|
874
807
|
textures.push( texture );
|
|
875
|
-
|
|
876
808
|
_texture.delete();
|
|
877
809
|
|
|
878
810
|
}
|
|
@@ -880,13 +812,11 @@
|
|
|
880
812
|
}
|
|
881
813
|
|
|
882
814
|
material.textures = textures;
|
|
883
|
-
|
|
884
815
|
if ( _pbrMaterial.supported ) {
|
|
885
816
|
|
|
886
817
|
for ( let j = 0; j < pbrTextureTypes.length; j ++ ) {
|
|
887
818
|
|
|
888
819
|
const _texture = _material.getTexture( pbrTextureTypes[ j ] );
|
|
889
|
-
|
|
890
820
|
if ( _texture ) {
|
|
891
821
|
|
|
892
822
|
const image = doc.getEmbeddedFileAsBase64( _texture.fileName );
|
|
@@ -897,7 +827,6 @@
|
|
|
897
827
|
image: 'data:image/png;base64,' + image
|
|
898
828
|
};
|
|
899
829
|
textures.push( texture );
|
|
900
|
-
|
|
901
830
|
_texture.delete();
|
|
902
831
|
|
|
903
832
|
}
|
|
@@ -910,74 +839,73 @@
|
|
|
910
839
|
}
|
|
911
840
|
|
|
912
841
|
materials.push( material );
|
|
913
|
-
|
|
914
842
|
_material.delete();
|
|
915
|
-
|
|
916
843
|
_pbrMaterial.delete();
|
|
917
844
|
|
|
918
|
-
}
|
|
845
|
+
}
|
|
919
846
|
|
|
847
|
+
// Handle layers
|
|
920
848
|
|
|
921
849
|
for ( let i = 0; i < doc.layers().count(); i ++ ) {
|
|
922
850
|
|
|
923
851
|
const _layer = doc.layers().get( i );
|
|
924
|
-
|
|
925
852
|
const layer = extractProperties( _layer );
|
|
926
853
|
layers.push( layer );
|
|
927
|
-
|
|
928
854
|
_layer.delete();
|
|
929
855
|
|
|
930
|
-
}
|
|
856
|
+
}
|
|
931
857
|
|
|
858
|
+
// Handle views
|
|
932
859
|
|
|
933
860
|
for ( let i = 0; i < doc.views().count(); i ++ ) {
|
|
934
861
|
|
|
935
862
|
const _view = doc.views().get( i );
|
|
936
|
-
|
|
937
863
|
const view = extractProperties( _view );
|
|
938
864
|
views.push( view );
|
|
939
|
-
|
|
940
865
|
_view.delete();
|
|
941
866
|
|
|
942
|
-
}
|
|
867
|
+
}
|
|
943
868
|
|
|
869
|
+
// Handle named views
|
|
944
870
|
|
|
945
871
|
for ( let i = 0; i < doc.namedViews().count(); i ++ ) {
|
|
946
872
|
|
|
947
873
|
const _namedView = doc.namedViews().get( i );
|
|
948
|
-
|
|
949
874
|
const namedView = extractProperties( _namedView );
|
|
950
875
|
namedViews.push( namedView );
|
|
951
|
-
|
|
952
876
|
_namedView.delete();
|
|
953
877
|
|
|
954
|
-
}
|
|
878
|
+
}
|
|
955
879
|
|
|
880
|
+
// Handle groups
|
|
956
881
|
|
|
957
882
|
for ( let i = 0; i < doc.groups().count(); i ++ ) {
|
|
958
883
|
|
|
959
884
|
const _group = doc.groups().get( i );
|
|
960
|
-
|
|
961
885
|
const group = extractProperties( _group );
|
|
962
886
|
groups.push( group );
|
|
963
|
-
|
|
964
887
|
_group.delete();
|
|
965
888
|
|
|
966
|
-
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Handle settings
|
|
967
892
|
|
|
893
|
+
const settings = extractProperties( doc.settings() );
|
|
894
|
+
|
|
895
|
+
//TODO: Handle other document stuff like dimstyles, instance definitions, bitmaps etc.
|
|
968
896
|
|
|
969
|
-
const settings = extractProperties( doc.settings() ); //TODO: Handle other document stuff like dimstyles, instance definitions, bitmaps etc.
|
|
970
897
|
// Handle dimstyles
|
|
971
898
|
// console.log( `Dimstyle Count: ${doc.dimstyles().count()}` );
|
|
899
|
+
|
|
972
900
|
// Handle bitmaps
|
|
973
901
|
// console.log( `Bitmap Count: ${doc.bitmaps().count()}` );
|
|
902
|
+
|
|
974
903
|
// Handle strings
|
|
975
904
|
// console.log( `Document Strings Count: ${doc.strings().count()}` );
|
|
976
905
|
// Note: doc.strings().documentUserTextCount() counts any doc.strings defined in a section
|
|
977
906
|
//console.log( `Document User Text Count: ${doc.strings().documentUserTextCount()}` );
|
|
978
907
|
|
|
979
908
|
const strings_count = doc.strings().count();
|
|
980
|
-
|
|
981
909
|
for ( let i = 0; i < strings_count; i ++ ) {
|
|
982
910
|
|
|
983
911
|
strings.push( doc.strings().get( i ) );
|
|
@@ -1001,14 +929,14 @@
|
|
|
1001
929
|
function extractObjectData( object, doc ) {
|
|
1002
930
|
|
|
1003
931
|
const _geometry = object.geometry();
|
|
1004
|
-
|
|
1005
932
|
const _attributes = object.attributes();
|
|
1006
|
-
|
|
1007
933
|
let objectType = _geometry.objectType;
|
|
1008
|
-
let geometry, attributes, position, data, mesh;
|
|
934
|
+
let geometry, attributes, position, data, mesh;
|
|
935
|
+
|
|
936
|
+
// skip instance definition objects
|
|
1009
937
|
//if( _attributes.isInstanceDefinitionObject ) { continue; }
|
|
1010
|
-
// TODO: handle other geometry types
|
|
1011
938
|
|
|
939
|
+
// TODO: handle other geometry types
|
|
1012
940
|
switch ( objectType ) {
|
|
1013
941
|
|
|
1014
942
|
case rhino.ObjectType.Curve:
|
|
@@ -1019,7 +947,6 @@
|
|
|
1019
947
|
position.itemSize = 3;
|
|
1020
948
|
position.type = 'Float32Array';
|
|
1021
949
|
position.array = [];
|
|
1022
|
-
|
|
1023
950
|
for ( let j = 0; j < pts.length; j ++ ) {
|
|
1024
951
|
|
|
1025
952
|
position.array.push( pts[ j ][ 0 ] );
|
|
@@ -1034,7 +961,6 @@
|
|
|
1034
961
|
data
|
|
1035
962
|
};
|
|
1036
963
|
break;
|
|
1037
|
-
|
|
1038
964
|
case rhino.ObjectType.Point:
|
|
1039
965
|
const pt = _geometry.location;
|
|
1040
966
|
position = {};
|
|
@@ -1044,9 +970,7 @@
|
|
|
1044
970
|
position.itemSize = 3;
|
|
1045
971
|
position.type = 'Float32Array';
|
|
1046
972
|
position.array = [ pt[ 0 ], pt[ 1 ], pt[ 2 ] ];
|
|
1047
|
-
|
|
1048
973
|
const _color = _attributes.drawColor( doc );
|
|
1049
|
-
|
|
1050
974
|
color.itemSize = 3;
|
|
1051
975
|
color.type = 'Float32Array';
|
|
1052
976
|
color.array = [ _color.r / 255.0, _color.g / 255.0, _color.b / 255.0 ];
|
|
@@ -1057,27 +981,20 @@
|
|
|
1057
981
|
data
|
|
1058
982
|
};
|
|
1059
983
|
break;
|
|
1060
|
-
|
|
1061
984
|
case rhino.ObjectType.PointSet:
|
|
1062
985
|
case rhino.ObjectType.Mesh:
|
|
1063
986
|
geometry = _geometry.toThreejsJSON();
|
|
1064
987
|
break;
|
|
1065
|
-
|
|
1066
988
|
case rhino.ObjectType.Brep:
|
|
1067
989
|
const faces = _geometry.faces();
|
|
1068
|
-
|
|
1069
990
|
mesh = new rhino.Mesh();
|
|
1070
|
-
|
|
1071
991
|
for ( let faceIndex = 0; faceIndex < faces.count; faceIndex ++ ) {
|
|
1072
992
|
|
|
1073
993
|
const face = faces.get( faceIndex );
|
|
1074
|
-
|
|
1075
994
|
const _mesh = face.getMesh( rhino.MeshType.Any );
|
|
1076
|
-
|
|
1077
995
|
if ( _mesh ) {
|
|
1078
996
|
|
|
1079
997
|
mesh.append( _mesh );
|
|
1080
|
-
|
|
1081
998
|
_mesh.delete();
|
|
1082
999
|
|
|
1083
1000
|
}
|
|
@@ -1096,10 +1013,8 @@
|
|
|
1096
1013
|
|
|
1097
1014
|
mesh.delete();
|
|
1098
1015
|
break;
|
|
1099
|
-
|
|
1100
1016
|
case rhino.ObjectType.Extrusion:
|
|
1101
1017
|
mesh = _geometry.getMesh( rhino.MeshType.Any );
|
|
1102
|
-
|
|
1103
1018
|
if ( mesh ) {
|
|
1104
1019
|
|
|
1105
1020
|
geometry = mesh.toThreejsJSON();
|
|
@@ -1108,14 +1023,11 @@
|
|
|
1108
1023
|
}
|
|
1109
1024
|
|
|
1110
1025
|
break;
|
|
1111
|
-
|
|
1112
1026
|
case rhino.ObjectType.TextDot:
|
|
1113
1027
|
geometry = extractProperties( _geometry );
|
|
1114
1028
|
break;
|
|
1115
|
-
|
|
1116
1029
|
case rhino.ObjectType.Light:
|
|
1117
1030
|
geometry = extractProperties( _geometry );
|
|
1118
|
-
|
|
1119
1031
|
if ( geometry.lightStyle.name === 'LightStyle_WorldLinear' ) {
|
|
1120
1032
|
|
|
1121
1033
|
self.postMessage( {
|
|
@@ -1131,19 +1043,15 @@
|
|
|
1131
1043
|
}
|
|
1132
1044
|
|
|
1133
1045
|
break;
|
|
1134
|
-
|
|
1135
1046
|
case rhino.ObjectType.InstanceReference:
|
|
1136
1047
|
geometry = extractProperties( _geometry );
|
|
1137
1048
|
geometry.xform = extractProperties( _geometry.xform );
|
|
1138
1049
|
geometry.xform.array = _geometry.xform.toFloatArray( true );
|
|
1139
1050
|
break;
|
|
1140
|
-
|
|
1141
1051
|
case rhino.ObjectType.SubD:
|
|
1142
1052
|
// TODO: precalculate resulting vertices and faces and warn on excessive results
|
|
1143
1053
|
_geometry.subdivide( 3 );
|
|
1144
|
-
|
|
1145
1054
|
mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
|
|
1146
|
-
|
|
1147
1055
|
if ( mesh ) {
|
|
1148
1056
|
|
|
1149
1057
|
geometry = mesh.toThreejsJSON();
|
|
@@ -1177,7 +1085,6 @@
|
|
|
1177
1085
|
|
|
1178
1086
|
attributes = extractProperties( _attributes );
|
|
1179
1087
|
attributes.geometry = extractProperties( _geometry );
|
|
1180
|
-
|
|
1181
1088
|
if ( _attributes.groupCount > 0 ) {
|
|
1182
1089
|
|
|
1183
1090
|
attributes.groupIds = _attributes.getGroupList();
|
|
@@ -1224,11 +1131,9 @@
|
|
|
1224
1131
|
function extractProperties( object ) {
|
|
1225
1132
|
|
|
1226
1133
|
const result = {};
|
|
1227
|
-
|
|
1228
1134
|
for ( const property in object ) {
|
|
1229
1135
|
|
|
1230
1136
|
const value = object[ property ];
|
|
1231
|
-
|
|
1232
1137
|
if ( typeof value !== 'function' ) {
|
|
1233
1138
|
|
|
1234
1139
|
if ( typeof value === 'object' && value !== null && value.hasOwnProperty( 'constructor' ) ) {
|
|
@@ -1244,7 +1149,9 @@
|
|
|
1244
1149
|
|
|
1245
1150
|
}
|
|
1246
1151
|
|
|
1247
|
-
} else {
|
|
1152
|
+
} else {
|
|
1153
|
+
|
|
1154
|
+
// these are functions that could be called to extract more data.
|
|
1248
1155
|
//console.log( `${property}: ${object[ property ].constructor.name}` );
|
|
1249
1156
|
}
|
|
1250
1157
|
|
|
@@ -1259,7 +1166,6 @@
|
|
|
1259
1166
|
let pointCount = pointLimit;
|
|
1260
1167
|
let rc = [];
|
|
1261
1168
|
const ts = [];
|
|
1262
|
-
|
|
1263
1169
|
if ( curve instanceof rhino.LineCurve ) {
|
|
1264
1170
|
|
|
1265
1171
|
return [ curve.pointAtStart, curve.pointAtEnd ];
|
|
@@ -1269,7 +1175,6 @@
|
|
|
1269
1175
|
if ( curve instanceof rhino.PolylineCurve ) {
|
|
1270
1176
|
|
|
1271
1177
|
pointCount = curve.pointCount;
|
|
1272
|
-
|
|
1273
1178
|
for ( let i = 0; i < pointCount; i ++ ) {
|
|
1274
1179
|
|
|
1275
1180
|
rc.push( curve.point( i ) );
|
|
@@ -1283,7 +1188,6 @@
|
|
|
1283
1188
|
if ( curve instanceof rhino.PolyCurve ) {
|
|
1284
1189
|
|
|
1285
1190
|
const segmentCount = curve.segmentCount;
|
|
1286
|
-
|
|
1287
1191
|
for ( let i = 0; i < segmentCount; i ++ ) {
|
|
1288
1192
|
|
|
1289
1193
|
const segment = curve.segmentCurve( i );
|
|
@@ -1300,14 +1204,14 @@
|
|
|
1300
1204
|
if ( curve instanceof rhino.ArcCurve ) {
|
|
1301
1205
|
|
|
1302
1206
|
pointCount = Math.floor( curve.angleDegrees / 5 );
|
|
1303
|
-
pointCount = pointCount < 2 ? 2 : pointCount;
|
|
1207
|
+
pointCount = pointCount < 2 ? 2 : pointCount;
|
|
1208
|
+
// alternative to this hardcoded version: https://stackoverflow.com/a/18499923/2179399
|
|
1304
1209
|
|
|
1305
1210
|
}
|
|
1306
1211
|
|
|
1307
1212
|
if ( curve instanceof rhino.NurbsCurve && curve.degree === 1 ) {
|
|
1308
1213
|
|
|
1309
1214
|
const pLine = curve.tryGetPolyline();
|
|
1310
|
-
|
|
1311
1215
|
for ( let i = 0; i < pLine.count; i ++ ) {
|
|
1312
1216
|
|
|
1313
1217
|
rc.push( pLine.get( i ) );
|
|
@@ -1321,11 +1225,9 @@
|
|
|
1321
1225
|
|
|
1322
1226
|
const domain = curve.domain;
|
|
1323
1227
|
const divisions = pointCount - 1.0;
|
|
1324
|
-
|
|
1325
1228
|
for ( let j = 0; j < pointCount; j ++ ) {
|
|
1326
1229
|
|
|
1327
1230
|
const t = domain[ 0 ] + j / divisions * ( domain[ 1 ] - domain[ 0 ] );
|
|
1328
|
-
|
|
1329
1231
|
if ( t === domain[ 0 ] || t === domain[ 1 ] ) {
|
|
1330
1232
|
|
|
1331
1233
|
ts.push( t );
|
|
@@ -1334,14 +1236,15 @@
|
|
|
1334
1236
|
}
|
|
1335
1237
|
|
|
1336
1238
|
const tan = curve.tangentAt( t );
|
|
1337
|
-
const prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );
|
|
1239
|
+
const prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );
|
|
1240
|
+
|
|
1241
|
+
// Duplicated from THREE.Vector3
|
|
1338
1242
|
// How to pass imports to worker?
|
|
1339
1243
|
|
|
1340
1244
|
const tS = tan[ 0 ] * tan[ 0 ] + tan[ 1 ] * tan[ 1 ] + tan[ 2 ] * tan[ 2 ];
|
|
1341
1245
|
const ptS = prevTan[ 0 ] * prevTan[ 0 ] + prevTan[ 1 ] * prevTan[ 1 ] + prevTan[ 2 ] * prevTan[ 2 ];
|
|
1342
1246
|
const denominator = Math.sqrt( tS * ptS );
|
|
1343
1247
|
let angle;
|
|
1344
|
-
|
|
1345
1248
|
if ( denominator === 0 ) {
|
|
1346
1249
|
|
|
1347
1250
|
angle = Math.PI / 2;
|