super-three 0.141.0 → 0.144.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/build/three.cjs +1558 -1034
- package/build/three.js +1558 -1034
- package/build/three.min.js +1 -1
- package/build/three.module.js +2012 -1243
- package/examples/js/animation/MMDPhysics.js +1 -16
- package/examples/js/controls/ArcballControls.js +16 -3
- package/examples/js/controls/FirstPersonControls.js +0 -7
- package/examples/js/controls/FlyControls.js +0 -8
- package/examples/js/controls/OrbitControls.js +0 -4
- package/examples/js/controls/PointerLockControls.js +0 -8
- package/examples/js/controls/TrackballControls.js +0 -2
- package/examples/js/controls/TransformControls.js +20 -16
- package/examples/js/effects/AnaglyphEffect.js +2 -2
- package/examples/js/effects/OutlineEffect.js +4 -24
- package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/js/effects/PeppersGhostEffect.js +2 -2
- package/examples/js/effects/StereoEffect.js +2 -2
- package/examples/js/environments/RoomEnvironment.js +22 -0
- package/examples/js/exporters/ColladaExporter.js +4 -13
- package/examples/js/exporters/DRACOExporter.js +0 -12
- package/examples/js/exporters/GLTFExporter.js +28 -29
- package/examples/js/exporters/OBJExporter.js +2 -23
- package/examples/js/exporters/PLYExporter.js +12 -24
- package/examples/js/exporters/STLExporter.js +0 -7
- package/examples/js/exporters/USDZExporter.js +6 -0
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/geometries/ParametricGeometry.js +1 -8
- package/examples/js/interactive/SelectionHelper.js +2 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/meshopt_decoder.js +98 -32
- package/examples/js/loaders/ColladaLoader.js +1 -0
- package/examples/js/loaders/DRACOLoader.js +2 -25
- package/examples/js/loaders/EXRLoader.js +2 -13
- package/examples/js/loaders/FBXLoader.js +10 -3
- package/examples/js/loaders/FontLoader.js +3 -16
- package/examples/js/loaders/GLTFLoader.js +52 -36
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
- package/examples/js/loaders/LDrawLoader.js +139 -74
- package/examples/js/loaders/OBJLoader.js +7 -13
- package/examples/js/loaders/PCDLoader.js +59 -14
- package/examples/js/loaders/PLYLoader.js +3 -3
- package/examples/js/loaders/SVGLoader.js +4 -3
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/VRMLLoader.js +33 -24
- package/examples/js/loaders/VTKLoader.js +1 -1
- package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
- package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/ColorConverter.js +0 -50
- package/examples/js/misc/GPUComputationRenderer.js +23 -0
- package/examples/js/misc/Volume.js +198 -190
- package/examples/js/misc/VolumeSlice.js +90 -88
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Reflector.js +9 -2
- package/examples/js/objects/ReflectorForSSRPass.js +3 -4
- package/examples/js/objects/Refractor.js +10 -4
- package/examples/js/objects/ShadowMesh.js +5 -1
- package/examples/js/postprocessing/OutlinePass.js +5 -3
- package/examples/js/renderers/CSS2DRenderer.js +2 -2
- package/examples/js/renderers/CSS3DRenderer.js +2 -2
- package/examples/js/renderers/Projector.js +2 -23
- package/examples/js/shaders/LuminosityShader.js +1 -1
- package/examples/js/shaders/MMDToonShader.js +6 -2
- package/examples/js/shaders/ToneMapShader.js +1 -1
- package/examples/js/utils/BufferGeometryUtils.js +1 -1
- package/examples/js/utils/GeometryUtils.js +2 -18
- package/examples/js/utils/PackedPhongMaterial.js +1 -1
- package/examples/js/utils/SceneUtils.js +0 -16
- package/examples/jsm/animation/MMDPhysics.js +3 -22
- package/examples/jsm/controls/ArcballControls.js +17 -2
- package/examples/jsm/controls/FirstPersonControls.js +0 -7
- package/examples/jsm/controls/FlyControls.js +0 -7
- package/examples/jsm/controls/OrbitControls.js +0 -5
- package/examples/jsm/controls/PointerLockControls.js +0 -7
- package/examples/jsm/controls/TrackballControls.js +0 -3
- package/examples/jsm/controls/TransformControls.js +18 -16
- package/examples/jsm/effects/AnaglyphEffect.js +2 -2
- package/examples/jsm/effects/OutlineEffect.js +4 -25
- package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
- package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
- package/examples/jsm/effects/StereoEffect.js +2 -2
- package/examples/jsm/environments/RoomEnvironment.js +23 -0
- package/examples/jsm/exporters/ColladaExporter.js +4 -13
- package/examples/jsm/exporters/DRACOExporter.js +0 -13
- package/examples/jsm/exporters/GLTFExporter.js +29 -31
- package/examples/jsm/exporters/KTX2Exporter.js +29 -29
- package/examples/jsm/exporters/OBJExporter.js +0 -18
- package/examples/jsm/exporters/PLYExporter.js +14 -22
- package/examples/jsm/exporters/STLExporter.js +1 -9
- package/examples/jsm/exporters/USDZExporter.js +14 -3
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +0 -6
- package/examples/jsm/interactive/HTMLMesh.js +9 -9
- package/examples/jsm/interactive/SelectionHelper.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/loaders/ColladaLoader.js +1 -0
- package/examples/jsm/loaders/DRACOLoader.js +2 -28
- package/examples/jsm/loaders/EXRLoader.js +3 -13
- package/examples/jsm/loaders/FBXLoader.js +10 -3
- package/examples/jsm/loaders/FontLoader.js +3 -16
- package/examples/jsm/loaders/GLTFLoader.js +52 -36
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
- package/examples/jsm/loaders/KTX2Loader.js +192 -30
- package/examples/jsm/loaders/LDrawLoader.js +135 -74
- package/examples/jsm/loaders/OBJLoader.js +6 -14
- package/examples/jsm/loaders/PCDLoader.js +59 -13
- package/examples/jsm/loaders/PLYLoader.js +3 -3
- package/examples/jsm/loaders/RGBELoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/USDZLoader.js +393 -0
- package/examples/jsm/loaders/VRMLLoader.js +23 -25
- package/examples/jsm/loaders/VTKLoader.js +1 -1
- package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
- package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/ColorConverter.js +1 -49
- package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
- package/examples/jsm/misc/Volume.js +169 -171
- package/examples/jsm/misc/VolumeSlice.js +78 -80
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
- package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
- package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
- package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
- package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
- package/examples/jsm/node-editor/math/DotEditor.js +1 -1
- package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
- package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
- package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
- package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
- package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
- package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
- package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
- package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
- package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
- package/examples/jsm/nodes/Nodes.js +43 -13
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
- package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
- package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/core/AttributeNode.js +3 -3
- package/examples/jsm/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
- package/examples/jsm/nodes/core/FunctionNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +14 -12
- package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
- package/examples/jsm/nodes/core/NodeUtils.js +23 -1
- package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
- package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
- package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
- package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
- package/examples/jsm/nodes/materials/Materials.js +13 -25
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
- package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
- package/examples/jsm/nodes/math/MathNode.js +2 -12
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
- package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
- package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
- package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
- package/examples/jsm/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +21 -5
- package/examples/jsm/nodes/utils/TimerNode.js +2 -2
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Reflector.js +12 -5
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
- package/examples/jsm/objects/Refractor.js +12 -6
- package/examples/jsm/objects/ShadowMesh.js +8 -2
- package/examples/jsm/postprocessing/OutlinePass.js +5 -3
- package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
- package/examples/jsm/renderers/Projector.js +2 -24
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/shaders/LuminosityShader.js +1 -1
- package/examples/jsm/shaders/MMDToonShader.js +2 -2
- package/examples/jsm/shaders/ToneMapShader.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
- package/examples/jsm/utils/GeometryUtils.js +17 -25
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
- package/examples/jsm/utils/SceneUtils.js +1 -21
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
- package/examples/jsm/webxr/VRButton.js +1 -7
- package/package.json +18 -14
- package/src/Three.Legacy.js +262 -36
- package/src/Three.js +3 -2
- package/src/animation/AnimationAction.js +6 -5
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +1 -1
- package/src/animation/AnimationUtils.js +204 -199
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/PropertyBinding.js +24 -5
- package/src/cameras/CubeCamera.js +0 -7
- package/src/constants.js +2 -4
- package/src/core/BufferAttribute.js +81 -111
- package/src/core/BufferGeometry.js +3 -41
- package/src/core/InstancedBufferAttribute.js +0 -10
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +56 -7
- package/src/core/Object3D.js +22 -5
- package/src/core/Uniform.js +0 -7
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +104 -88
- package/src/extras/core/Path.js +1 -0
- package/src/extras/core/ShapePath.js +1 -4
- package/src/extras/curves/CatmullRomCurve3.js +4 -2
- package/src/geometries/BoxGeometry.js +1 -1
- package/src/geometries/CapsuleGeometry.js +1 -1
- package/src/geometries/CircleGeometry.js +1 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +2 -1
- package/src/geometries/DodecahedronGeometry.js +1 -1
- package/src/geometries/EdgesGeometry.js +5 -4
- package/src/geometries/ExtrudeGeometry.js +2 -11
- package/src/geometries/IcosahedronGeometry.js +1 -1
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/geometries/OctahedronGeometry.js +1 -1
- package/src/geometries/PlaneGeometry.js +2 -1
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/RingGeometry.js +1 -1
- package/src/geometries/ShapeGeometry.js +2 -1
- package/src/geometries/SphereGeometry.js +2 -1
- package/src/geometries/TetrahedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +2 -1
- package/src/geometries/TorusKnotGeometry.js +2 -1
- package/src/geometries/TubeGeometry.js +2 -1
- package/src/geometries/WireframeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +97 -38
- package/src/helpers/DirectionalLightHelper.js +1 -0
- package/src/helpers/HemisphereLightHelper.js +1 -0
- package/src/helpers/PlaneHelper.js +6 -9
- package/src/helpers/PolarGridHelper.js +18 -14
- package/src/helpers/SpotLightHelper.js +1 -0
- package/src/lights/SpotLight.js +2 -0
- package/src/loaders/FileLoader.js +12 -1
- package/src/loaders/LoadingManager.js +1 -1
- package/src/loaders/MaterialLoader.js +49 -7
- package/src/loaders/ObjectLoader.js +4 -41
- package/src/materials/Material.js +1 -33
- package/src/materials/Materials.js +0 -27
- package/src/materials/MeshLambertMaterial.js +28 -1
- package/src/materials/ShaderMaterial.js +3 -7
- package/src/math/Color.js +3 -13
- package/src/math/MathUtils.js +1 -7
- package/src/math/Matrix3.js +1 -7
- package/src/math/Matrix4.js +3 -27
- package/src/math/Quaternion.js +1 -21
- package/src/math/Vector2.js +4 -24
- package/src/math/Vector3.js +7 -46
- package/src/math/Vector4.js +4 -24
- package/src/renderers/WebGLRenderer.js +84 -8
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib.js +31 -31
- package/src/renderers/shaders/UniformsLib.js +12 -11
- package/src/renderers/shaders/UniformsUtils.js +14 -0
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +37 -13
- package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
- package/src/renderers/webgl/WebGLProgram.js +6 -11
- package/src/renderers/webgl/WebGLPrograms.js +30 -26
- package/src/renderers/webgl/WebGLRenderLists.js +5 -4
- package/src/renderers/webgl/WebGLRenderStates.js +5 -4
- package/src/renderers/webgl/WebGLShaderCache.js +9 -6
- package/src/renderers/webgl/WebGLShadowMap.js +10 -15
- package/src/renderers/webgl/WebGLState.js +47 -0
- package/src/renderers/webgl/WebGLUniforms.js +4 -4
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +2 -0
- package/src/renderers/webvr/WebVRManager.js +42 -9
- package/src/renderers/webvr/WebVRUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +45 -37
- package/src/renderers/webxr/WebXRManager.js +58 -33
- package/src/scenes/Scene.js +16 -3
- package/src/textures/Source.js +1 -1
- package/src/utils.js +1 -1
- package/examples/js/controls/experimental/CameraControls.js +0 -1048
- package/examples/js/loaders/KTX2Loader.js +0 -558
- package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
- package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
- package/examples/jsm/package.json +0 -3
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
- package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* KTX 2.0 is a container format for various GPU texture formats. The loader
|
|
5
5
|
* supports Basis Universal GPU textures, which can be quickly transcoded to
|
|
6
|
-
* a wide variety of GPU texture compression formats
|
|
7
|
-
*
|
|
6
|
+
* a wide variety of GPU texture compression formats, as well as some
|
|
7
|
+
* uncompressed DataTexture and Data3DTexture formats.
|
|
8
8
|
*
|
|
9
9
|
* References:
|
|
10
10
|
* - KTX: http://github.khronos.org/KTX-Specification/
|
|
@@ -13,32 +13,59 @@
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
CompressedTexture,
|
|
16
|
+
Data3DTexture,
|
|
17
|
+
DataTexture,
|
|
16
18
|
FileLoader,
|
|
19
|
+
FloatType,
|
|
20
|
+
HalfFloatType,
|
|
17
21
|
LinearEncoding,
|
|
18
22
|
LinearFilter,
|
|
19
23
|
LinearMipmapLinearFilter,
|
|
20
24
|
Loader,
|
|
21
|
-
|
|
25
|
+
RedFormat,
|
|
26
|
+
RGB_ETC1_Format,
|
|
27
|
+
RGB_ETC2_Format,
|
|
28
|
+
RGB_PVRTC_4BPPV1_Format,
|
|
29
|
+
RGB_S3TC_DXT1_Format,
|
|
22
30
|
RGBA_ASTC_4x4_Format,
|
|
23
31
|
RGBA_BPTC_Format,
|
|
24
32
|
RGBA_ETC2_EAC_Format,
|
|
25
33
|
RGBA_PVRTC_4BPPV1_Format,
|
|
26
34
|
RGBA_S3TC_DXT5_Format,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
RGB_PVRTC_4BPPV1_Format,
|
|
30
|
-
RGB_S3TC_DXT1_Format,
|
|
35
|
+
RGBAFormat,
|
|
36
|
+
RGFormat,
|
|
31
37
|
sRGBEncoding,
|
|
32
38
|
UnsignedByteType
|
|
33
39
|
} from 'three';
|
|
34
40
|
import { WorkerPool } from '../utils/WorkerPool.js';
|
|
41
|
+
import {
|
|
42
|
+
read,
|
|
43
|
+
KHR_DF_FLAG_ALPHA_PREMULTIPLIED,
|
|
44
|
+
KHR_DF_TRANSFER_SRGB,
|
|
45
|
+
KHR_SUPERCOMPRESSION_NONE,
|
|
46
|
+
KHR_SUPERCOMPRESSION_ZSTD,
|
|
47
|
+
VK_FORMAT_UNDEFINED,
|
|
48
|
+
VK_FORMAT_R16_SFLOAT,
|
|
49
|
+
VK_FORMAT_R16G16_SFLOAT,
|
|
50
|
+
VK_FORMAT_R16G16B16A16_SFLOAT,
|
|
51
|
+
VK_FORMAT_R32_SFLOAT,
|
|
52
|
+
VK_FORMAT_R32G32_SFLOAT,
|
|
53
|
+
VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
54
|
+
VK_FORMAT_R8_SRGB,
|
|
55
|
+
VK_FORMAT_R8_UNORM,
|
|
56
|
+
VK_FORMAT_R8G8_SRGB,
|
|
57
|
+
VK_FORMAT_R8G8_UNORM,
|
|
58
|
+
VK_FORMAT_R8G8B8A8_SRGB,
|
|
59
|
+
VK_FORMAT_R8G8B8A8_UNORM,
|
|
60
|
+
} from '../libs/ktx-parse.module.js';
|
|
61
|
+
import { ZSTDDecoder } from '../libs/zstddec.module.js';
|
|
35
62
|
|
|
36
|
-
const KTX2TransferSRGB = 2;
|
|
37
|
-
const KTX2_ALPHA_PREMULTIPLIED = 1;
|
|
38
63
|
const _taskCache = new WeakMap();
|
|
39
64
|
|
|
40
65
|
let _activeLoaders = 0;
|
|
41
66
|
|
|
67
|
+
let _zstd;
|
|
68
|
+
|
|
42
69
|
class KTX2Loader extends Loader {
|
|
43
70
|
|
|
44
71
|
constructor( manager ) {
|
|
@@ -189,8 +216,6 @@ class KTX2Loader extends Loader {
|
|
|
189
216
|
loader.setResponseType( 'arraybuffer' );
|
|
190
217
|
loader.setWithCredentials( this.withCredentials );
|
|
191
218
|
|
|
192
|
-
const texture = new CompressedTexture();
|
|
193
|
-
|
|
194
219
|
loader.load( url, ( buffer ) => {
|
|
195
220
|
|
|
196
221
|
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
@@ -203,21 +228,12 @@ class KTX2Loader extends Loader {
|
|
|
203
228
|
|
|
204
229
|
}
|
|
205
230
|
|
|
206
|
-
this._createTexture(
|
|
207
|
-
.then(
|
|
208
|
-
|
|
209
|
-
texture.copy( _texture );
|
|
210
|
-
texture.needsUpdate = true;
|
|
211
|
-
|
|
212
|
-
if ( onLoad ) onLoad( texture );
|
|
213
|
-
|
|
214
|
-
} )
|
|
231
|
+
this._createTexture( buffer )
|
|
232
|
+
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
|
|
215
233
|
.catch( onError );
|
|
216
234
|
|
|
217
235
|
}, onProgress, onError );
|
|
218
236
|
|
|
219
|
-
return texture;
|
|
220
|
-
|
|
221
237
|
}
|
|
222
238
|
|
|
223
239
|
_createTextureFrom( transcodeResult ) {
|
|
@@ -231,29 +247,39 @@ class KTX2Loader extends Loader {
|
|
|
231
247
|
texture.magFilter = LinearFilter;
|
|
232
248
|
texture.generateMipmaps = false;
|
|
233
249
|
texture.needsUpdate = true;
|
|
234
|
-
texture.encoding = dfdTransferFn ===
|
|
235
|
-
texture.premultiplyAlpha = !! ( dfdFlags &
|
|
250
|
+
texture.encoding = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? sRGBEncoding : LinearEncoding;
|
|
251
|
+
texture.premultiplyAlpha = !! ( dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED );
|
|
236
252
|
|
|
237
253
|
return texture;
|
|
238
254
|
|
|
239
255
|
}
|
|
240
256
|
|
|
241
257
|
/**
|
|
242
|
-
* @param {ArrayBuffer
|
|
258
|
+
* @param {ArrayBuffer} buffer
|
|
243
259
|
* @param {object?} config
|
|
244
|
-
* @return {Promise<CompressedTexture>}
|
|
260
|
+
* @return {Promise<CompressedTexture|DataTexture|Data3DTexture>}
|
|
245
261
|
*/
|
|
246
|
-
_createTexture(
|
|
262
|
+
_createTexture( buffer, config = {} ) {
|
|
263
|
+
|
|
264
|
+
const container = read( new Uint8Array( buffer ) );
|
|
265
|
+
|
|
266
|
+
if ( container.vkFormat !== VK_FORMAT_UNDEFINED ) {
|
|
267
|
+
|
|
268
|
+
return createDataTexture( container );
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
//
|
|
247
273
|
|
|
248
274
|
const taskConfig = config;
|
|
249
275
|
const texturePending = this.init().then( () => {
|
|
250
276
|
|
|
251
|
-
return this.workerPool.postMessage( { type: 'transcode',
|
|
277
|
+
return this.workerPool.postMessage( { type: 'transcode', buffer, taskConfig: taskConfig }, [ buffer ] );
|
|
252
278
|
|
|
253
279
|
} ).then( ( e ) => this._createTextureFrom( e.data ) );
|
|
254
280
|
|
|
255
281
|
// Cache the task result.
|
|
256
|
-
_taskCache.set(
|
|
282
|
+
_taskCache.set( buffer, { promise: texturePending } );
|
|
257
283
|
|
|
258
284
|
return texturePending;
|
|
259
285
|
|
|
@@ -342,7 +368,7 @@ KTX2Loader.BasisWorker = function () {
|
|
|
342
368
|
|
|
343
369
|
try {
|
|
344
370
|
|
|
345
|
-
const { width, height, hasAlpha, mipmaps, format, dfdTransferFn, dfdFlags } = transcode( message.
|
|
371
|
+
const { width, height, hasAlpha, mipmaps, format, dfdTransferFn, dfdFlags } = transcode( message.buffer );
|
|
346
372
|
|
|
347
373
|
const buffers = [];
|
|
348
374
|
|
|
@@ -588,4 +614,140 @@ KTX2Loader.BasisWorker = function () {
|
|
|
588
614
|
|
|
589
615
|
};
|
|
590
616
|
|
|
617
|
+
//
|
|
618
|
+
// DataTexture and Data3DTexture parsing.
|
|
619
|
+
|
|
620
|
+
const FORMAT_MAP = {
|
|
621
|
+
|
|
622
|
+
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: RGBAFormat,
|
|
623
|
+
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: RGBAFormat,
|
|
624
|
+
[ VK_FORMAT_R8G8B8A8_UNORM ]: RGBAFormat,
|
|
625
|
+
[ VK_FORMAT_R8G8B8A8_SRGB ]: RGBAFormat,
|
|
626
|
+
|
|
627
|
+
[ VK_FORMAT_R32G32_SFLOAT ]: RGFormat,
|
|
628
|
+
[ VK_FORMAT_R16G16_SFLOAT ]: RGFormat,
|
|
629
|
+
[ VK_FORMAT_R8G8_UNORM ]: RGFormat,
|
|
630
|
+
[ VK_FORMAT_R8G8_SRGB ]: RGFormat,
|
|
631
|
+
|
|
632
|
+
[ VK_FORMAT_R32_SFLOAT ]: RedFormat,
|
|
633
|
+
[ VK_FORMAT_R16_SFLOAT ]: RedFormat,
|
|
634
|
+
[ VK_FORMAT_R8_SRGB ]: RedFormat,
|
|
635
|
+
[ VK_FORMAT_R8_UNORM ]: RedFormat,
|
|
636
|
+
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
const TYPE_MAP = {
|
|
640
|
+
|
|
641
|
+
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: FloatType,
|
|
642
|
+
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: HalfFloatType,
|
|
643
|
+
[ VK_FORMAT_R8G8B8A8_UNORM ]: UnsignedByteType,
|
|
644
|
+
[ VK_FORMAT_R8G8B8A8_SRGB ]: UnsignedByteType,
|
|
645
|
+
|
|
646
|
+
[ VK_FORMAT_R32G32_SFLOAT ]: FloatType,
|
|
647
|
+
[ VK_FORMAT_R16G16_SFLOAT ]: HalfFloatType,
|
|
648
|
+
[ VK_FORMAT_R8G8_UNORM ]: UnsignedByteType,
|
|
649
|
+
[ VK_FORMAT_R8G8_SRGB ]: UnsignedByteType,
|
|
650
|
+
|
|
651
|
+
[ VK_FORMAT_R32_SFLOAT ]: FloatType,
|
|
652
|
+
[ VK_FORMAT_R16_SFLOAT ]: HalfFloatType,
|
|
653
|
+
[ VK_FORMAT_R8_SRGB ]: UnsignedByteType,
|
|
654
|
+
[ VK_FORMAT_R8_UNORM ]: UnsignedByteType,
|
|
655
|
+
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const ENCODING_MAP = {
|
|
659
|
+
|
|
660
|
+
[ VK_FORMAT_R8G8B8A8_SRGB ]: sRGBEncoding,
|
|
661
|
+
[ VK_FORMAT_R8G8_SRGB ]: sRGBEncoding,
|
|
662
|
+
[ VK_FORMAT_R8_SRGB ]: sRGBEncoding,
|
|
663
|
+
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
async function createDataTexture( container ) {
|
|
667
|
+
|
|
668
|
+
const { vkFormat, pixelWidth, pixelHeight, pixelDepth } = container;
|
|
669
|
+
|
|
670
|
+
if ( FORMAT_MAP[ vkFormat ] === undefined ) {
|
|
671
|
+
|
|
672
|
+
throw new Error( 'THREE.KTX2Loader: Unsupported vkFormat.' );
|
|
673
|
+
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
//
|
|
677
|
+
|
|
678
|
+
const level = container.levels[ 0 ];
|
|
679
|
+
|
|
680
|
+
let levelData;
|
|
681
|
+
let view;
|
|
682
|
+
|
|
683
|
+
if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_NONE ) {
|
|
684
|
+
|
|
685
|
+
levelData = level.levelData;
|
|
686
|
+
|
|
687
|
+
} else if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD ) {
|
|
688
|
+
|
|
689
|
+
if ( ! _zstd ) {
|
|
690
|
+
|
|
691
|
+
_zstd = new Promise( async ( resolve ) => {
|
|
692
|
+
|
|
693
|
+
const zstd = new ZSTDDecoder();
|
|
694
|
+
await zstd.init();
|
|
695
|
+
resolve( zstd );
|
|
696
|
+
|
|
697
|
+
} );
|
|
698
|
+
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
levelData = ( await _zstd ).decode( level.levelData, level.uncompressedByteLength );
|
|
702
|
+
|
|
703
|
+
} else {
|
|
704
|
+
|
|
705
|
+
throw new Error( 'THREE.KTX2Loader: Unsupported supercompressionScheme.' );
|
|
706
|
+
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if ( TYPE_MAP[ vkFormat ] === FloatType ) {
|
|
710
|
+
|
|
711
|
+
view = new Float32Array(
|
|
712
|
+
|
|
713
|
+
levelData.buffer,
|
|
714
|
+
levelData.byteOffset,
|
|
715
|
+
levelData.byteLength / Float32Array.BYTES_PER_ELEMENT
|
|
716
|
+
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
} else if ( TYPE_MAP[ vkFormat ] === HalfFloatType ) {
|
|
720
|
+
|
|
721
|
+
view = new Uint16Array(
|
|
722
|
+
|
|
723
|
+
levelData.buffer,
|
|
724
|
+
levelData.byteOffset,
|
|
725
|
+
levelData.byteLength / Uint16Array.BYTES_PER_ELEMENT
|
|
726
|
+
|
|
727
|
+
);
|
|
728
|
+
|
|
729
|
+
} else {
|
|
730
|
+
|
|
731
|
+
view = levelData;
|
|
732
|
+
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
//
|
|
736
|
+
|
|
737
|
+
const texture = pixelDepth === 0
|
|
738
|
+
? new DataTexture( view, pixelWidth, pixelHeight )
|
|
739
|
+
: new Data3DTexture( view, pixelWidth, pixelHeight, pixelDepth );
|
|
740
|
+
|
|
741
|
+
texture.type = TYPE_MAP[ vkFormat ];
|
|
742
|
+
texture.format = FORMAT_MAP[ vkFormat ];
|
|
743
|
+
texture.encoding = ENCODING_MAP[ vkFormat ] || LinearEncoding;
|
|
744
|
+
|
|
745
|
+
texture.needsUpdate = true;
|
|
746
|
+
|
|
747
|
+
//
|
|
748
|
+
|
|
749
|
+
return Promise.resolve( texture );
|
|
750
|
+
|
|
751
|
+
}
|
|
752
|
+
|
|
591
753
|
export { KTX2Loader };
|
|
@@ -28,10 +28,10 @@ const FINISH_TYPE_METAL = 5;
|
|
|
28
28
|
|
|
29
29
|
// State machine to search a subobject path.
|
|
30
30
|
// The LDraw standard establishes these various possible subfolders.
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
31
|
+
const FILE_LOCATION_TRY_PARTS = 0;
|
|
32
|
+
const FILE_LOCATION_TRY_P = 1;
|
|
33
|
+
const FILE_LOCATION_TRY_MODELS = 2;
|
|
34
|
+
const FILE_LOCATION_AS_IS = 3;
|
|
35
35
|
const FILE_LOCATION_TRY_RELATIVE = 4;
|
|
36
36
|
const FILE_LOCATION_TRY_ABSOLUTE = 5;
|
|
37
37
|
const FILE_LOCATION_NOT_FOUND = 6;
|
|
@@ -688,7 +688,9 @@ class LDrawParsedCache {
|
|
|
688
688
|
result.type = original.type;
|
|
689
689
|
result.category = original.category;
|
|
690
690
|
result.keywords = original.keywords;
|
|
691
|
+
result.author = original.author;
|
|
691
692
|
result.subobjects = original.subobjects;
|
|
693
|
+
result.fileName = original.fileName;
|
|
692
694
|
result.totalFaces = original.totalFaces;
|
|
693
695
|
result.startingConstructionStep = original.startingConstructionStep;
|
|
694
696
|
result.materials = original.materials;
|
|
@@ -700,7 +702,7 @@ class LDrawParsedCache {
|
|
|
700
702
|
async fetchData( fileName ) {
|
|
701
703
|
|
|
702
704
|
let triedLowerCase = false;
|
|
703
|
-
let locationState =
|
|
705
|
+
let locationState = FILE_LOCATION_TRY_PARTS;
|
|
704
706
|
while ( locationState !== FILE_LOCATION_NOT_FOUND ) {
|
|
705
707
|
|
|
706
708
|
let subobjectURL = fileName;
|
|
@@ -743,7 +745,7 @@ class LDrawParsedCache {
|
|
|
743
745
|
fileName = fileName.toLowerCase();
|
|
744
746
|
subobjectURL = fileName;
|
|
745
747
|
triedLowerCase = true;
|
|
746
|
-
locationState =
|
|
748
|
+
locationState = FILE_LOCATION_TRY_PARTS;
|
|
747
749
|
|
|
748
750
|
}
|
|
749
751
|
|
|
@@ -794,6 +796,7 @@ class LDrawParsedCache {
|
|
|
794
796
|
let type = 'Model';
|
|
795
797
|
let category = null;
|
|
796
798
|
let keywords = null;
|
|
799
|
+
let author = null;
|
|
797
800
|
let totalFaces = 0;
|
|
798
801
|
|
|
799
802
|
// split into lines
|
|
@@ -995,6 +998,12 @@ class LDrawParsedCache {
|
|
|
995
998
|
|
|
996
999
|
break;
|
|
997
1000
|
|
|
1001
|
+
case 'Author:':
|
|
1002
|
+
|
|
1003
|
+
author = lp.getToken();
|
|
1004
|
+
|
|
1005
|
+
break;
|
|
1006
|
+
|
|
998
1007
|
default:
|
|
999
1008
|
// Other meta directives are not implemented
|
|
1000
1009
|
break;
|
|
@@ -1221,6 +1230,7 @@ class LDrawParsedCache {
|
|
|
1221
1230
|
type,
|
|
1222
1231
|
category,
|
|
1223
1232
|
keywords,
|
|
1233
|
+
author,
|
|
1224
1234
|
subobjects,
|
|
1225
1235
|
totalFaces,
|
|
1226
1236
|
startingConstructionStep,
|
|
@@ -1356,6 +1366,9 @@ class LDrawPartsGeometryCache {
|
|
|
1356
1366
|
const group = new Group();
|
|
1357
1367
|
group.userData.category = info.category;
|
|
1358
1368
|
group.userData.keywords = info.keywords;
|
|
1369
|
+
group.userData.author = info.author;
|
|
1370
|
+
group.userData.type = info.type;
|
|
1371
|
+
group.userData.fileName = info.fileName;
|
|
1359
1372
|
info.group = group;
|
|
1360
1373
|
|
|
1361
1374
|
const subobjectInfos = await Promise.all( promises );
|
|
@@ -1380,6 +1393,7 @@ class LDrawPartsGeometryCache {
|
|
|
1380
1393
|
subobjectGroup.name = subobject.fileName;
|
|
1381
1394
|
|
|
1382
1395
|
loader.applyMaterialsToMesh( subobjectGroup, subobject.colorCode, info.materials );
|
|
1396
|
+
subobjectGroup.userData.colorCode = subobject.colorCode;
|
|
1383
1397
|
|
|
1384
1398
|
group.add( subobjectGroup );
|
|
1385
1399
|
continue;
|
|
@@ -1473,6 +1487,7 @@ class LDrawPartsGeometryCache {
|
|
|
1473
1487
|
if ( subobject ) {
|
|
1474
1488
|
|
|
1475
1489
|
loader.applyMaterialsToMesh( group, subobject.colorCode, info.materials );
|
|
1490
|
+
group.userData.colorCode = subobject.colorCode;
|
|
1476
1491
|
|
|
1477
1492
|
}
|
|
1478
1493
|
|
|
@@ -1883,6 +1898,16 @@ class LDrawLoader extends Loader {
|
|
|
1883
1898
|
// The path to load parts from the LDraw parts library from.
|
|
1884
1899
|
this.partsLibraryPath = '';
|
|
1885
1900
|
|
|
1901
|
+
// Material assigned to not available colors for meshes and edges
|
|
1902
|
+
this.missingColorMaterial = new MeshStandardMaterial( { color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
|
|
1903
|
+
this.missingColorMaterial.name = 'Missing material';
|
|
1904
|
+
this.missingEdgeColorMaterial = new LineBasicMaterial( { color: 0xFF00FF } );
|
|
1905
|
+
this.missingEdgeColorMaterial.name = 'Missing material - Edge';
|
|
1906
|
+
this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( { fog: true, color: 0xFF00FF } );
|
|
1907
|
+
this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
|
|
1908
|
+
this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
|
|
1909
|
+
this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
|
|
1910
|
+
|
|
1886
1911
|
}
|
|
1887
1912
|
|
|
1888
1913
|
setPartsLibraryPath( path ) {
|
|
@@ -1934,6 +1959,7 @@ class LDrawLoader extends Loader {
|
|
|
1934
1959
|
|
|
1935
1960
|
this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
|
|
1936
1961
|
this.computeConstructionSteps( group );
|
|
1962
|
+
group.userData.fileName = url;
|
|
1937
1963
|
onLoad( group );
|
|
1938
1964
|
|
|
1939
1965
|
} )
|
|
@@ -1949,7 +1975,9 @@ class LDrawLoader extends Loader {
|
|
|
1949
1975
|
.parseModel( text, this.materialLibrary )
|
|
1950
1976
|
.then( group => {
|
|
1951
1977
|
|
|
1978
|
+
this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
|
|
1952
1979
|
this.computeConstructionSteps( group );
|
|
1980
|
+
group.userData.fileName = '';
|
|
1953
1981
|
onLoad( group );
|
|
1954
1982
|
|
|
1955
1983
|
} );
|
|
@@ -2080,8 +2108,11 @@ class LDrawLoader extends Loader {
|
|
|
2080
2108
|
material = loader.getMaterial( colorCode );
|
|
2081
2109
|
if ( material === null ) {
|
|
2082
2110
|
|
|
2083
|
-
// otherwise throw
|
|
2084
|
-
|
|
2111
|
+
// otherwise throw a warning if this is final opportunity to set the material
|
|
2112
|
+
console.warn( `LDrawLoader: Material properties for code ${ colorCode } not available.` );
|
|
2113
|
+
|
|
2114
|
+
// And return the 'missing color' material
|
|
2115
|
+
material = loader.missingColorMaterial;
|
|
2085
2116
|
|
|
2086
2117
|
}
|
|
2087
2118
|
|
|
@@ -2118,8 +2149,8 @@ class LDrawLoader extends Loader {
|
|
|
2118
2149
|
|
|
2119
2150
|
getMainEdgeMaterial() {
|
|
2120
2151
|
|
|
2121
|
-
const
|
|
2122
|
-
return
|
|
2152
|
+
const mat = this.getMaterial( MAIN_EDGE_COLOUR_CODE );
|
|
2153
|
+
return mat ? mat.userData.edgeMaterial : null;
|
|
2123
2154
|
|
|
2124
2155
|
}
|
|
2125
2156
|
|
|
@@ -2162,113 +2193,113 @@ class LDrawLoader extends Loader {
|
|
|
2162
2193
|
|
|
2163
2194
|
}
|
|
2164
2195
|
|
|
2165
|
-
|
|
2196
|
+
if ( ! parseLuminance( token ) ) {
|
|
2166
2197
|
|
|
2167
|
-
|
|
2198
|
+
switch ( token.toUpperCase() ) {
|
|
2168
2199
|
|
|
2169
|
-
|
|
2170
|
-
break;
|
|
2200
|
+
case 'CODE':
|
|
2171
2201
|
|
|
2172
|
-
|
|
2202
|
+
code = lineParser.getToken();
|
|
2203
|
+
break;
|
|
2173
2204
|
|
|
2174
|
-
|
|
2175
|
-
if ( color.startsWith( '0x' ) ) {
|
|
2205
|
+
case 'VALUE':
|
|
2176
2206
|
|
|
2177
|
-
color =
|
|
2207
|
+
color = lineParser.getToken();
|
|
2208
|
+
if ( color.startsWith( '0x' ) ) {
|
|
2178
2209
|
|
|
2179
|
-
|
|
2210
|
+
color = '#' + color.substring( 2 );
|
|
2180
2211
|
|
|
2181
|
-
|
|
2212
|
+
} else if ( ! color.startsWith( '#' ) ) {
|
|
2182
2213
|
|
|
2183
|
-
|
|
2214
|
+
throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
2184
2215
|
|
|
2185
|
-
|
|
2216
|
+
}
|
|
2186
2217
|
|
|
2187
|
-
|
|
2218
|
+
break;
|
|
2188
2219
|
|
|
2189
|
-
|
|
2190
|
-
if ( edgeColor.startsWith( '0x' ) ) {
|
|
2220
|
+
case 'EDGE':
|
|
2191
2221
|
|
|
2192
|
-
edgeColor =
|
|
2222
|
+
edgeColor = lineParser.getToken();
|
|
2223
|
+
if ( edgeColor.startsWith( '0x' ) ) {
|
|
2193
2224
|
|
|
2194
|
-
|
|
2225
|
+
edgeColor = '#' + edgeColor.substring( 2 );
|
|
2195
2226
|
|
|
2196
|
-
|
|
2197
|
-
edgeMaterial = this.getMaterial( edgeColor );
|
|
2198
|
-
if ( ! edgeMaterial ) {
|
|
2227
|
+
} else if ( ! edgeColor.startsWith( '#' ) ) {
|
|
2199
2228
|
|
|
2200
|
-
|
|
2229
|
+
// Try to see if edge color is a color code
|
|
2230
|
+
edgeMaterial = this.getMaterial( edgeColor );
|
|
2231
|
+
if ( ! edgeMaterial ) {
|
|
2201
2232
|
|
|
2202
|
-
|
|
2233
|
+
throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
2203
2234
|
|
|
2204
|
-
|
|
2205
|
-
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
|
2235
|
+
}
|
|
2206
2236
|
|
|
2207
|
-
|
|
2237
|
+
// Get the edge material for this triangle material
|
|
2238
|
+
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
|
2208
2239
|
|
|
2209
|
-
|
|
2240
|
+
}
|
|
2210
2241
|
|
|
2211
|
-
|
|
2242
|
+
break;
|
|
2212
2243
|
|
|
2213
|
-
|
|
2244
|
+
case 'ALPHA':
|
|
2214
2245
|
|
|
2215
|
-
|
|
2246
|
+
alpha = parseInt( lineParser.getToken() );
|
|
2216
2247
|
|
|
2217
|
-
|
|
2248
|
+
if ( isNaN( alpha ) ) {
|
|
2218
2249
|
|
|
2219
|
-
|
|
2250
|
+
throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
|
|
2220
2251
|
|
|
2221
|
-
|
|
2252
|
+
}
|
|
2222
2253
|
|
|
2223
|
-
|
|
2254
|
+
alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
|
|
2224
2255
|
|
|
2225
|
-
|
|
2256
|
+
if ( alpha < 1 ) {
|
|
2226
2257
|
|
|
2227
|
-
|
|
2258
|
+
isTransparent = true;
|
|
2228
2259
|
|
|
2229
|
-
|
|
2260
|
+
}
|
|
2230
2261
|
|
|
2231
|
-
|
|
2262
|
+
break;
|
|
2232
2263
|
|
|
2233
|
-
|
|
2264
|
+
case 'LUMINANCE':
|
|
2234
2265
|
|
|
2235
|
-
|
|
2266
|
+
if ( ! parseLuminance( lineParser.getToken() ) ) {
|
|
2236
2267
|
|
|
2237
|
-
|
|
2268
|
+
throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
|
|
2238
2269
|
|
|
2239
|
-
|
|
2270
|
+
}
|
|
2240
2271
|
|
|
2241
|
-
|
|
2272
|
+
break;
|
|
2242
2273
|
|
|
2243
|
-
|
|
2274
|
+
case 'CHROME':
|
|
2275
|
+
finishType = FINISH_TYPE_CHROME;
|
|
2276
|
+
break;
|
|
2244
2277
|
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2278
|
+
case 'PEARLESCENT':
|
|
2279
|
+
finishType = FINISH_TYPE_PEARLESCENT;
|
|
2280
|
+
break;
|
|
2248
2281
|
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2282
|
+
case 'RUBBER':
|
|
2283
|
+
finishType = FINISH_TYPE_RUBBER;
|
|
2284
|
+
break;
|
|
2252
2285
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2286
|
+
case 'MATTE_METALLIC':
|
|
2287
|
+
finishType = FINISH_TYPE_MATTE_METALLIC;
|
|
2288
|
+
break;
|
|
2256
2289
|
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2290
|
+
case 'METAL':
|
|
2291
|
+
finishType = FINISH_TYPE_METAL;
|
|
2292
|
+
break;
|
|
2260
2293
|
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2294
|
+
case 'MATERIAL':
|
|
2295
|
+
// Not implemented
|
|
2296
|
+
lineParser.setToEnd();
|
|
2297
|
+
break;
|
|
2264
2298
|
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
lineParser.setToEnd();
|
|
2268
|
-
break;
|
|
2299
|
+
default:
|
|
2300
|
+
throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
2269
2301
|
|
|
2270
|
-
|
|
2271
|
-
throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
|
|
2302
|
+
}
|
|
2272
2303
|
|
|
2273
2304
|
}
|
|
2274
2305
|
|
|
@@ -2358,6 +2389,8 @@ class LDrawLoader extends Loader {
|
|
|
2358
2389
|
|
|
2359
2390
|
} );
|
|
2360
2391
|
edgeMaterial.userData.conditionalEdgeMaterial.color.convertSRGBToLinear();
|
|
2392
|
+
edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
|
|
2393
|
+
edgeMaterial.userData.conditionalEdgeMaterial.name = name + ' - Conditional Edge';
|
|
2361
2394
|
|
|
2362
2395
|
}
|
|
2363
2396
|
|
|
@@ -2370,6 +2403,34 @@ class LDrawLoader extends Loader {
|
|
|
2370
2403
|
|
|
2371
2404
|
return material;
|
|
2372
2405
|
|
|
2406
|
+
function parseLuminance( token ) {
|
|
2407
|
+
|
|
2408
|
+
// Returns success
|
|
2409
|
+
|
|
2410
|
+
let lum;
|
|
2411
|
+
|
|
2412
|
+
if ( token.startsWith( 'LUMINANCE' ) ) {
|
|
2413
|
+
|
|
2414
|
+
lum = parseInt( token.substring( 9 ) );
|
|
2415
|
+
|
|
2416
|
+
} else {
|
|
2417
|
+
|
|
2418
|
+
lum = parseInt( token );
|
|
2419
|
+
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
if ( isNaN( lum ) ) {
|
|
2423
|
+
|
|
2424
|
+
return false;
|
|
2425
|
+
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
luminance = Math.max( 0, Math.min( 1, lum / 255 ) );
|
|
2429
|
+
|
|
2430
|
+
return true;
|
|
2431
|
+
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2373
2434
|
}
|
|
2374
2435
|
|
|
2375
2436
|
computeConstructionSteps( model ) {
|