opal-js_wrap-three 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +4 -4
- data/lib/opal/js_wrap/three/version.rb +1 -1
- data/lib-opal/js_wrap/three/WebGL.js +102 -0
- data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
- data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
- data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
- data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
- data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
- data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
- data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
- data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
- data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
- data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
- data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
- data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
- data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
- data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
- data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
- data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
- data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
- data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
- data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
- data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
- data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
- data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
- data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
- data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
- data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
- data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
- data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
- data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
- data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
- data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
- data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
- data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
- data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
- data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
- data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
- data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
- data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
- data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
- data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
- data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
- data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
- data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
- data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
- data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
- data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
- data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
- data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
- data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
- data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
- data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
- data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
- data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
- data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
- data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
- data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
- data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
- data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
- data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
- data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
- data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
- data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
- data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
- data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
- data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
- data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
- data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
- data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
- data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
- data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
- data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
- data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
- data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
- data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
- data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
- data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
- data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
- data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
- data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
- data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
- data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
- data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
- data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
- data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
- data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
- data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
- data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
- data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
- data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
- data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
- data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
- data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
- data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
- data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
- data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
- data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
- data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
- data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
- data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
- data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
- data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
- data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
- data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
- data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
- data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
- data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
- data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
- data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
- data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
- data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
- data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
- data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
- data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
- data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
- data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
- data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
- data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
- data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
- data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
- data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
- data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
- data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
- data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
- data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
- data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
- data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
- data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
- data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
- data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
- data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
- data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
- data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
- data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
- data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
- data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
- data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
- data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
- data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
- data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
- data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
- data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
- data/lib-opal/js_wrap/three/math/Lut.js +170 -0
- data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
- data/lib-opal/js_wrap/three/math/OBB.js +345 -0
- data/lib-opal/js_wrap/three/math/Octree.js +409 -0
- data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
- data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
- data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
- data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
- data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
- data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
- data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
- data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
- data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
- data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
- data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
- data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
- data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
- data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
- data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
- data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
- data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
- data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
- data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
- data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
- data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
- data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
- data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
- data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
- data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
- data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
- data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
- data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
- data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
- data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
- data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
- data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
- data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
- data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
- data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
- data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
- data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
- data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
- data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
- data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
- data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
- data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
- data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
- data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
- data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
- data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
- data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
- data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
- data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
- data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
- data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
- data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
- data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
- data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
- data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
- data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
- data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
- data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
- data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
- data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
- data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
- data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
- data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
- data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
- data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
- data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
- data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
- data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
- data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
- data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
- data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
- data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
- data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
- data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
- data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
- data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
- data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
- data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
- data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
- data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
- data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
- data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
- data/lib-opal/js_wrap/three/objects/Water.js +246 -0
- data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
- data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
- data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
- data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
- data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
- data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
- data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
- data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
- data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
- data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
- data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
- data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
- data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
- data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
- data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
- data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
- data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
- data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
- data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
- data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
- data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
- data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
- data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
- data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
- data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
- data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
- data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
- data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
- data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
- data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
- data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
- data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
- data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
- data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
- data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
- data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
- data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
- data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
- data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
- data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
- data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
- data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
- data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
- data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
- data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
- data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
- data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
- data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
- data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
- data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
- data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
- data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
- data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
- data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
- data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
- data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
- data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
- data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
- data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
- data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
- data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
- data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
- data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
- data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
- data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
- data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
- data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
- data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
- data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
- data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
- data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
- data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
- data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
- data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
- data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
- data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
- data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
- data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
- data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
- data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
- data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
- data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
- data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
- data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
- data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
- data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
- data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
- data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
- data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
- data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
- data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
- data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
- data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
- data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
- data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
- data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
- data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
- data/opal-js_wrap-three.gemspec +4 -4
- metadata +502 -5
@@ -0,0 +1,1737 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "three"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("three"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.three);
|
11
|
+
global.LDrawLoader = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(_exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
_exports.LDrawLoader = void 0;
|
20
|
+
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
22
|
+
|
23
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
24
|
+
|
25
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
26
|
+
|
27
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
28
|
+
|
29
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
30
|
+
|
31
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
32
|
+
|
33
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
34
|
+
|
35
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
36
|
+
|
37
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
38
|
+
|
39
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
40
|
+
|
41
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
42
|
+
|
43
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
44
|
+
|
45
|
+
// Special surface finish tag types.
|
46
|
+
// Note: "MATERIAL" tag (e.g. GLITTER, SPECKLE) is not implemented
|
47
|
+
var FINISH_TYPE_DEFAULT = 0;
|
48
|
+
var FINISH_TYPE_CHROME = 1;
|
49
|
+
var FINISH_TYPE_PEARLESCENT = 2;
|
50
|
+
var FINISH_TYPE_RUBBER = 3;
|
51
|
+
var FINISH_TYPE_MATTE_METALLIC = 4;
|
52
|
+
var FINISH_TYPE_METAL = 5; // State machine to search a subobject path.
|
53
|
+
// The LDraw standard establishes these various possible subfolders.
|
54
|
+
|
55
|
+
var FILE_LOCATION_AS_IS = 0;
|
56
|
+
var FILE_LOCATION_TRY_PARTS = 1;
|
57
|
+
var FILE_LOCATION_TRY_P = 2;
|
58
|
+
var FILE_LOCATION_TRY_MODELS = 3;
|
59
|
+
var FILE_LOCATION_TRY_RELATIVE = 4;
|
60
|
+
var FILE_LOCATION_TRY_ABSOLUTE = 5;
|
61
|
+
var FILE_LOCATION_NOT_FOUND = 6;
|
62
|
+
|
63
|
+
var _tempVec0 = new _three.Vector3();
|
64
|
+
|
65
|
+
var _tempVec1 = new _three.Vector3();
|
66
|
+
|
67
|
+
var LDrawConditionalLineMaterial = /*#__PURE__*/function (_ShaderMaterial) {
|
68
|
+
_inherits(LDrawConditionalLineMaterial, _ShaderMaterial);
|
69
|
+
|
70
|
+
var _super = _createSuper(LDrawConditionalLineMaterial);
|
71
|
+
|
72
|
+
function LDrawConditionalLineMaterial(parameters) {
|
73
|
+
var _this;
|
74
|
+
|
75
|
+
_classCallCheck(this, LDrawConditionalLineMaterial);
|
76
|
+
|
77
|
+
_this = _super.call(this, {
|
78
|
+
uniforms: _three.UniformsUtils.merge([_three.UniformsLib.fog, {
|
79
|
+
diffuse: {
|
80
|
+
value: new _three.Color()
|
81
|
+
},
|
82
|
+
opacity: {
|
83
|
+
value: 1.0
|
84
|
+
}
|
85
|
+
}]),
|
86
|
+
vertexShader:
|
87
|
+
/* glsl */
|
88
|
+
"\n\t\t\t\tattribute vec3 control0;\n\t\t\t\tattribute vec3 control1;\n\t\t\t\tattribute vec3 direction;\n\t\t\t\tvarying float discardFlag;\n\n\t\t\t\t#include <common>\n\t\t\t\t#include <color_pars_vertex>\n\t\t\t\t#include <fog_pars_vertex>\n\t\t\t\t#include <logdepthbuf_pars_vertex>\n\t\t\t\t#include <clipping_planes_pars_vertex>\n\t\t\t\tvoid main() {\n\t\t\t\t\t#include <color_vertex>\n\n\t\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t\t// Transform the line segment ends and control points into camera clip space\n\t\t\t\t\tvec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );\n\t\t\t\t\tvec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );\n\t\t\t\t\tvec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tvec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );\n\n\t\t\t\t\tc0.xy /= c0.w;\n\t\t\t\t\tc1.xy /= c1.w;\n\t\t\t\t\tp0.xy /= p0.w;\n\t\t\t\t\tp1.xy /= p1.w;\n\n\t\t\t\t\t// Get the direction of the segment and an orthogonal vector\n\t\t\t\t\tvec2 dir = p1.xy - p0.xy;\n\t\t\t\t\tvec2 norm = vec2( -dir.y, dir.x );\n\n\t\t\t\t\t// Get control point directions from the line\n\t\t\t\t\tvec2 c0dir = c0.xy - p1.xy;\n\t\t\t\t\tvec2 c1dir = c1.xy - p1.xy;\n\n\t\t\t\t\t// If the vectors to the controls points are pointed in different directions away\n\t\t\t\t\t// from the line segment then the line should not be drawn.\n\t\t\t\t\tfloat d0 = dot( normalize( norm ), normalize( c0dir ) );\n\t\t\t\t\tfloat d1 = dot( normalize( norm ), normalize( c1dir ) );\n\t\t\t\t\tdiscardFlag = float( sign( d0 ) != sign( d1 ) );\n\n\t\t\t\t\t#include <logdepthbuf_vertex>\n\t\t\t\t\t#include <clipping_planes_vertex>\n\t\t\t\t\t#include <fog_vertex>\n\t\t\t\t}\n\t\t\t",
|
89
|
+
fragmentShader:
|
90
|
+
/* glsl */
|
91
|
+
"\n\t\t\tuniform vec3 diffuse;\n\t\t\tuniform float opacity;\n\t\t\tvarying float discardFlag;\n\n\t\t\t#include <common>\n\t\t\t#include <color_pars_fragment>\n\t\t\t#include <fog_pars_fragment>\n\t\t\t#include <logdepthbuf_pars_fragment>\n\t\t\t#include <clipping_planes_pars_fragment>\n\t\t\tvoid main() {\n\n\t\t\t\tif ( discardFlag > 0.5 ) discard;\n\n\t\t\t\t#include <clipping_planes_fragment>\n\t\t\t\tvec3 outgoingLight = vec3( 0.0 );\n\t\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\t\t\t#include <logdepthbuf_fragment>\n\t\t\t\t#include <color_fragment>\n\t\t\t\toutgoingLight = diffuseColor.rgb; // simple shader\n\t\t\t\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t\t\t\t#include <tonemapping_fragment>\n\t\t\t\t#include <encodings_fragment>\n\t\t\t\t#include <fog_fragment>\n\t\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t}\n\t\t\t"
|
92
|
+
});
|
93
|
+
Object.defineProperties(_assertThisInitialized(_this), {
|
94
|
+
opacity: {
|
95
|
+
get: function get() {
|
96
|
+
return this.uniforms.opacity.value;
|
97
|
+
},
|
98
|
+
set: function set(value) {
|
99
|
+
this.uniforms.opacity.value = value;
|
100
|
+
}
|
101
|
+
},
|
102
|
+
color: {
|
103
|
+
get: function get() {
|
104
|
+
return this.uniforms.diffuse.value;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
});
|
108
|
+
|
109
|
+
_this.setValues(parameters);
|
110
|
+
|
111
|
+
_this.isLDrawConditionalLineMaterial = true;
|
112
|
+
return _this;
|
113
|
+
}
|
114
|
+
|
115
|
+
return _createClass(LDrawConditionalLineMaterial);
|
116
|
+
}(_three.ShaderMaterial);
|
117
|
+
|
118
|
+
function smoothNormals(faces, lineSegments) {
|
119
|
+
function hashVertex(v) {
|
120
|
+
// NOTE: 1e2 is pretty coarse but was chosen because it allows edges
|
121
|
+
// to be smoothed as expected (see minifig arms). The errors between edges
|
122
|
+
// could be due to matrix multiplication.
|
123
|
+
var x = ~~(v.x * 1e2);
|
124
|
+
var y = ~~(v.y * 1e2);
|
125
|
+
var z = ~~(v.z * 1e2);
|
126
|
+
return "".concat(x, ",").concat(y, ",").concat(z);
|
127
|
+
}
|
128
|
+
|
129
|
+
function hashEdge(v0, v1) {
|
130
|
+
return "".concat(hashVertex(v0), "_").concat(hashVertex(v1));
|
131
|
+
}
|
132
|
+
|
133
|
+
var hardEdges = new Set();
|
134
|
+
var halfEdgeList = {};
|
135
|
+
var normals = []; // Save the list of hard edges by hash
|
136
|
+
|
137
|
+
for (var i = 0, l = lineSegments.length; i < l; i++) {
|
138
|
+
var ls = lineSegments[i];
|
139
|
+
var vertices = ls.vertices;
|
140
|
+
var v0 = vertices[0];
|
141
|
+
var v1 = vertices[1];
|
142
|
+
hardEdges.add(hashEdge(v0, v1));
|
143
|
+
hardEdges.add(hashEdge(v1, v0));
|
144
|
+
} // track the half edges associated with each triangle
|
145
|
+
|
146
|
+
|
147
|
+
for (var _i = 0, _l = faces.length; _i < _l; _i++) {
|
148
|
+
var tri = faces[_i];
|
149
|
+
var _vertices = tri.vertices;
|
150
|
+
var vertCount = _vertices.length;
|
151
|
+
|
152
|
+
for (var i2 = 0; i2 < vertCount; i2++) {
|
153
|
+
var index = i2;
|
154
|
+
var next = (i2 + 1) % vertCount;
|
155
|
+
var _v = _vertices[index];
|
156
|
+
var _v2 = _vertices[next];
|
157
|
+
var hash = hashEdge(_v, _v2); // don't add the triangle if the edge is supposed to be hard
|
158
|
+
|
159
|
+
if (hardEdges.has(hash)) continue;
|
160
|
+
var info = {
|
161
|
+
index: index,
|
162
|
+
tri: tri
|
163
|
+
};
|
164
|
+
halfEdgeList[hash] = info;
|
165
|
+
}
|
166
|
+
} // Iterate until we've tried to connect all faces to share normals
|
167
|
+
|
168
|
+
|
169
|
+
while (true) {
|
170
|
+
// Stop if there are no more faces left
|
171
|
+
var halfEdge = null;
|
172
|
+
|
173
|
+
for (var key in halfEdgeList) {
|
174
|
+
halfEdge = halfEdgeList[key];
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
|
178
|
+
if (halfEdge === null) {
|
179
|
+
break;
|
180
|
+
} // Exhaustively find all connected faces
|
181
|
+
|
182
|
+
|
183
|
+
var queue = [halfEdge];
|
184
|
+
|
185
|
+
while (queue.length > 0) {
|
186
|
+
// initialize all vertex normals in this triangle
|
187
|
+
var _tri = queue.pop().tri;
|
188
|
+
var _vertices2 = _tri.vertices;
|
189
|
+
var vertNormals = _tri.normals;
|
190
|
+
var faceNormal = _tri.faceNormal; // Check if any edge is connected to another triangle edge
|
191
|
+
|
192
|
+
var _vertCount = _vertices2.length;
|
193
|
+
|
194
|
+
for (var _i2 = 0; _i2 < _vertCount; _i2++) {
|
195
|
+
var _index = _i2;
|
196
|
+
|
197
|
+
var _next = (_i2 + 1) % _vertCount;
|
198
|
+
|
199
|
+
var _v3 = _vertices2[_index];
|
200
|
+
var _v4 = _vertices2[_next]; // delete this triangle from the list so it won't be found again
|
201
|
+
|
202
|
+
var _hash = hashEdge(_v3, _v4);
|
203
|
+
|
204
|
+
delete halfEdgeList[_hash];
|
205
|
+
var reverseHash = hashEdge(_v4, _v3);
|
206
|
+
var otherInfo = halfEdgeList[reverseHash];
|
207
|
+
|
208
|
+
if (otherInfo) {
|
209
|
+
var otherTri = otherInfo.tri;
|
210
|
+
var otherIndex = otherInfo.index;
|
211
|
+
var otherNormals = otherTri.normals;
|
212
|
+
var otherVertCount = otherNormals.length;
|
213
|
+
var otherFaceNormal = otherTri.faceNormal; // NOTE: If the angle between faces is > 67.5 degrees then assume it's
|
214
|
+
// hard edge. There are some cases where the line segments do not line up exactly
|
215
|
+
// with or span multiple triangle edges (see Lunar Vehicle wheels).
|
216
|
+
|
217
|
+
if (Math.abs(otherTri.faceNormal.dot(_tri.faceNormal)) < 0.25) {
|
218
|
+
continue;
|
219
|
+
} // if this triangle has already been traversed then it won't be in
|
220
|
+
// the halfEdgeList. If it has not then add it to the queue and delete
|
221
|
+
// it so it won't be found again.
|
222
|
+
|
223
|
+
|
224
|
+
if (reverseHash in halfEdgeList) {
|
225
|
+
queue.push(otherInfo);
|
226
|
+
delete halfEdgeList[reverseHash];
|
227
|
+
} // share the first normal
|
228
|
+
|
229
|
+
|
230
|
+
var otherNext = (otherIndex + 1) % otherVertCount;
|
231
|
+
|
232
|
+
if (vertNormals[_index] && otherNormals[otherNext] && vertNormals[_index] !== otherNormals[otherNext]) {
|
233
|
+
otherNormals[otherNext].norm.add(vertNormals[_index].norm);
|
234
|
+
vertNormals[_index].norm = otherNormals[otherNext].norm;
|
235
|
+
}
|
236
|
+
|
237
|
+
var sharedNormal1 = vertNormals[_index] || otherNormals[otherNext];
|
238
|
+
|
239
|
+
if (sharedNormal1 === null) {
|
240
|
+
// it's possible to encounter an edge of a triangle that has already been traversed meaning
|
241
|
+
// both edges already have different normals defined and shared. To work around this we create
|
242
|
+
// a wrapper object so when those edges are merged the normals can be updated everywhere.
|
243
|
+
sharedNormal1 = {
|
244
|
+
norm: new _three.Vector3()
|
245
|
+
};
|
246
|
+
normals.push(sharedNormal1.norm);
|
247
|
+
}
|
248
|
+
|
249
|
+
if (vertNormals[_index] === null) {
|
250
|
+
vertNormals[_index] = sharedNormal1;
|
251
|
+
sharedNormal1.norm.add(faceNormal);
|
252
|
+
}
|
253
|
+
|
254
|
+
if (otherNormals[otherNext] === null) {
|
255
|
+
otherNormals[otherNext] = sharedNormal1;
|
256
|
+
sharedNormal1.norm.add(otherFaceNormal);
|
257
|
+
} // share the second normal
|
258
|
+
|
259
|
+
|
260
|
+
if (vertNormals[_next] && otherNormals[otherIndex] && vertNormals[_next] !== otherNormals[otherIndex]) {
|
261
|
+
otherNormals[otherIndex].norm.add(vertNormals[_next].norm);
|
262
|
+
vertNormals[_next].norm = otherNormals[otherIndex].norm;
|
263
|
+
}
|
264
|
+
|
265
|
+
var sharedNormal2 = vertNormals[_next] || otherNormals[otherIndex];
|
266
|
+
|
267
|
+
if (sharedNormal2 === null) {
|
268
|
+
sharedNormal2 = {
|
269
|
+
norm: new _three.Vector3()
|
270
|
+
};
|
271
|
+
normals.push(sharedNormal2.norm);
|
272
|
+
}
|
273
|
+
|
274
|
+
if (vertNormals[_next] === null) {
|
275
|
+
vertNormals[_next] = sharedNormal2;
|
276
|
+
sharedNormal2.norm.add(faceNormal);
|
277
|
+
}
|
278
|
+
|
279
|
+
if (otherNormals[otherIndex] === null) {
|
280
|
+
otherNormals[otherIndex] = sharedNormal2;
|
281
|
+
sharedNormal2.norm.add(otherFaceNormal);
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
} // The normals of each face have been added up so now we average them by normalizing the vector.
|
287
|
+
|
288
|
+
|
289
|
+
for (var _i3 = 0, _l2 = normals.length; _i3 < _l2; _i3++) {
|
290
|
+
normals[_i3].normalize();
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
function isPartType(type) {
|
295
|
+
return type === 'Part';
|
296
|
+
}
|
297
|
+
|
298
|
+
function isModelType(type) {
|
299
|
+
return type === 'Model' || type === 'Unofficial_Model';
|
300
|
+
}
|
301
|
+
|
302
|
+
function isPrimitiveType(type) {
|
303
|
+
return /primitive/i.test(type) || type === 'Subpart';
|
304
|
+
}
|
305
|
+
|
306
|
+
var LineParser = /*#__PURE__*/function () {
|
307
|
+
function LineParser(line, lineNumber) {
|
308
|
+
_classCallCheck(this, LineParser);
|
309
|
+
|
310
|
+
this.line = line;
|
311
|
+
this.lineLength = line.length;
|
312
|
+
this.currentCharIndex = 0;
|
313
|
+
this.currentChar = ' ';
|
314
|
+
this.lineNumber = lineNumber;
|
315
|
+
}
|
316
|
+
|
317
|
+
_createClass(LineParser, [{
|
318
|
+
key: "seekNonSpace",
|
319
|
+
value: function seekNonSpace() {
|
320
|
+
while (this.currentCharIndex < this.lineLength) {
|
321
|
+
this.currentChar = this.line.charAt(this.currentCharIndex);
|
322
|
+
|
323
|
+
if (this.currentChar !== ' ' && this.currentChar !== '\t') {
|
324
|
+
return;
|
325
|
+
}
|
326
|
+
|
327
|
+
this.currentCharIndex++;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}, {
|
331
|
+
key: "getToken",
|
332
|
+
value: function getToken() {
|
333
|
+
var pos0 = this.currentCharIndex++; // Seek space
|
334
|
+
|
335
|
+
while (this.currentCharIndex < this.lineLength) {
|
336
|
+
this.currentChar = this.line.charAt(this.currentCharIndex);
|
337
|
+
|
338
|
+
if (this.currentChar === ' ' || this.currentChar === '\t') {
|
339
|
+
break;
|
340
|
+
}
|
341
|
+
|
342
|
+
this.currentCharIndex++;
|
343
|
+
}
|
344
|
+
|
345
|
+
var pos1 = this.currentCharIndex;
|
346
|
+
this.seekNonSpace();
|
347
|
+
return this.line.substring(pos0, pos1);
|
348
|
+
}
|
349
|
+
}, {
|
350
|
+
key: "getRemainingString",
|
351
|
+
value: function getRemainingString() {
|
352
|
+
return this.line.substring(this.currentCharIndex, this.lineLength);
|
353
|
+
}
|
354
|
+
}, {
|
355
|
+
key: "isAtTheEnd",
|
356
|
+
value: function isAtTheEnd() {
|
357
|
+
return this.currentCharIndex >= this.lineLength;
|
358
|
+
}
|
359
|
+
}, {
|
360
|
+
key: "setToEnd",
|
361
|
+
value: function setToEnd() {
|
362
|
+
this.currentCharIndex = this.lineLength;
|
363
|
+
}
|
364
|
+
}, {
|
365
|
+
key: "getLineNumberString",
|
366
|
+
value: function getLineNumberString() {
|
367
|
+
return this.lineNumber >= 0 ? ' at line ' + this.lineNumber : '';
|
368
|
+
}
|
369
|
+
}]);
|
370
|
+
|
371
|
+
return LineParser;
|
372
|
+
}();
|
373
|
+
|
374
|
+
var LDrawFileCache = /*#__PURE__*/function () {
|
375
|
+
function LDrawFileCache(loader) {
|
376
|
+
_classCallCheck(this, LDrawFileCache);
|
377
|
+
|
378
|
+
this.cache = {};
|
379
|
+
this.loader = loader;
|
380
|
+
}
|
381
|
+
|
382
|
+
_createClass(LDrawFileCache, [{
|
383
|
+
key: "setData",
|
384
|
+
value: function setData(key, contents) {
|
385
|
+
this.cache[key.toLowerCase()] = contents;
|
386
|
+
}
|
387
|
+
}, {
|
388
|
+
key: "loadData",
|
389
|
+
value: function () {
|
390
|
+
var _loadData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(fileName) {
|
391
|
+
var _this2 = this;
|
392
|
+
|
393
|
+
var key;
|
394
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
395
|
+
while (1) {
|
396
|
+
switch (_context2.prev = _context2.next) {
|
397
|
+
case 0:
|
398
|
+
key = fileName.toLowerCase();
|
399
|
+
|
400
|
+
if (!(key in this.cache)) {
|
401
|
+
_context2.next = 3;
|
402
|
+
break;
|
403
|
+
}
|
404
|
+
|
405
|
+
return _context2.abrupt("return", this.cache[key]);
|
406
|
+
|
407
|
+
case 3:
|
408
|
+
this.cache[fileName] = new Promise( /*#__PURE__*/function () {
|
409
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(resolve, reject) {
|
410
|
+
var triedLowerCase, locationState, subobjectURL, loader, fileLoader, text;
|
411
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
412
|
+
while (1) {
|
413
|
+
switch (_context.prev = _context.next) {
|
414
|
+
case 0:
|
415
|
+
triedLowerCase = false;
|
416
|
+
locationState = FILE_LOCATION_AS_IS;
|
417
|
+
|
418
|
+
case 2:
|
419
|
+
if (!(locationState !== FILE_LOCATION_NOT_FOUND)) {
|
420
|
+
_context.next = 42;
|
421
|
+
break;
|
422
|
+
}
|
423
|
+
|
424
|
+
subobjectURL = fileName;
|
425
|
+
_context.t0 = locationState;
|
426
|
+
_context.next = _context.t0 === FILE_LOCATION_AS_IS ? 7 : _context.t0 === FILE_LOCATION_TRY_PARTS ? 9 : _context.t0 === FILE_LOCATION_TRY_P ? 12 : _context.t0 === FILE_LOCATION_TRY_MODELS ? 15 : _context.t0 === FILE_LOCATION_TRY_RELATIVE ? 18 : _context.t0 === FILE_LOCATION_TRY_ABSOLUTE ? 21 : 23;
|
427
|
+
break;
|
428
|
+
|
429
|
+
case 7:
|
430
|
+
locationState = locationState + 1;
|
431
|
+
return _context.abrupt("break", 23);
|
432
|
+
|
433
|
+
case 9:
|
434
|
+
subobjectURL = 'parts/' + subobjectURL;
|
435
|
+
locationState = locationState + 1;
|
436
|
+
return _context.abrupt("break", 23);
|
437
|
+
|
438
|
+
case 12:
|
439
|
+
subobjectURL = 'p/' + subobjectURL;
|
440
|
+
locationState = locationState + 1;
|
441
|
+
return _context.abrupt("break", 23);
|
442
|
+
|
443
|
+
case 15:
|
444
|
+
subobjectURL = 'models/' + subobjectURL;
|
445
|
+
locationState = locationState + 1;
|
446
|
+
return _context.abrupt("break", 23);
|
447
|
+
|
448
|
+
case 18:
|
449
|
+
subobjectURL = fileName.substring(0, fileName.lastIndexOf('/') + 1) + subobjectURL;
|
450
|
+
locationState = locationState + 1;
|
451
|
+
return _context.abrupt("break", 23);
|
452
|
+
|
453
|
+
case 21:
|
454
|
+
if (triedLowerCase) {
|
455
|
+
// Try absolute path
|
456
|
+
locationState = FILE_LOCATION_NOT_FOUND;
|
457
|
+
} else {
|
458
|
+
// Next attempt is lower case
|
459
|
+
fileName = fileName.toLowerCase();
|
460
|
+
subobjectURL = fileName;
|
461
|
+
triedLowerCase = true;
|
462
|
+
locationState = FILE_LOCATION_AS_IS;
|
463
|
+
}
|
464
|
+
|
465
|
+
return _context.abrupt("break", 23);
|
466
|
+
|
467
|
+
case 23:
|
468
|
+
loader = _this2.loader;
|
469
|
+
fileLoader = new _three.FileLoader(loader.manager);
|
470
|
+
fileLoader.setPath(loader.partsLibraryPath);
|
471
|
+
fileLoader.setRequestHeader(loader.requestHeader);
|
472
|
+
fileLoader.setWithCredentials(loader.withCredentials);
|
473
|
+
_context.prev = 28;
|
474
|
+
_context.next = 31;
|
475
|
+
return fileLoader.loadAsync(subobjectURL);
|
476
|
+
|
477
|
+
case 31:
|
478
|
+
text = _context.sent;
|
479
|
+
|
480
|
+
_this2.setData(fileName, text);
|
481
|
+
|
482
|
+
resolve(text);
|
483
|
+
return _context.abrupt("return");
|
484
|
+
|
485
|
+
case 37:
|
486
|
+
_context.prev = 37;
|
487
|
+
_context.t1 = _context["catch"](28);
|
488
|
+
return _context.abrupt("continue", 2);
|
489
|
+
|
490
|
+
case 40:
|
491
|
+
_context.next = 2;
|
492
|
+
break;
|
493
|
+
|
494
|
+
case 42:
|
495
|
+
reject();
|
496
|
+
|
497
|
+
case 43:
|
498
|
+
case "end":
|
499
|
+
return _context.stop();
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}, _callee, null, [[28, 37]]);
|
503
|
+
}));
|
504
|
+
|
505
|
+
return function (_x2, _x3) {
|
506
|
+
return _ref.apply(this, arguments);
|
507
|
+
};
|
508
|
+
}());
|
509
|
+
return _context2.abrupt("return", this.cache[fileName]);
|
510
|
+
|
511
|
+
case 5:
|
512
|
+
case "end":
|
513
|
+
return _context2.stop();
|
514
|
+
}
|
515
|
+
}
|
516
|
+
}, _callee2, this);
|
517
|
+
}));
|
518
|
+
|
519
|
+
function loadData(_x) {
|
520
|
+
return _loadData.apply(this, arguments);
|
521
|
+
}
|
522
|
+
|
523
|
+
return loadData;
|
524
|
+
}()
|
525
|
+
}]);
|
526
|
+
|
527
|
+
return LDrawFileCache;
|
528
|
+
}();
|
529
|
+
|
530
|
+
function sortByMaterial(a, b) {
|
531
|
+
if (a.colourCode === b.colourCode) {
|
532
|
+
return 0;
|
533
|
+
}
|
534
|
+
|
535
|
+
if (a.colourCode < b.colourCode) {
|
536
|
+
return -1;
|
537
|
+
}
|
538
|
+
|
539
|
+
return 1;
|
540
|
+
}
|
541
|
+
|
542
|
+
function createObject(elements, elementSize) {
|
543
|
+
var isConditionalSegments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
544
|
+
var totalElements = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
545
|
+
// Creates a LineSegments (elementSize = 2) or a Mesh (elementSize = 3 )
|
546
|
+
// With per face / segment material, implemented with mesh groups and materials array
|
547
|
+
// Sort the faces or line segments by colour code to make later the mesh groups
|
548
|
+
elements.sort(sortByMaterial);
|
549
|
+
|
550
|
+
if (totalElements === null) {
|
551
|
+
totalElements = elements.length;
|
552
|
+
}
|
553
|
+
|
554
|
+
var positions = new Float32Array(elementSize * totalElements * 3);
|
555
|
+
var normals = elementSize === 3 ? new Float32Array(elementSize * totalElements * 3) : null;
|
556
|
+
var materials = [];
|
557
|
+
var quadArray = new Array(6);
|
558
|
+
var bufferGeometry = new _three.BufferGeometry();
|
559
|
+
var prevMaterial = null;
|
560
|
+
var index0 = 0;
|
561
|
+
var numGroupVerts = 0;
|
562
|
+
var offset = 0;
|
563
|
+
|
564
|
+
for (var iElem = 0, nElem = elements.length; iElem < nElem; iElem++) {
|
565
|
+
var elem = elements[iElem];
|
566
|
+
var vertices = elem.vertices;
|
567
|
+
|
568
|
+
if (vertices.length === 4) {
|
569
|
+
quadArray[0] = vertices[0];
|
570
|
+
quadArray[1] = vertices[1];
|
571
|
+
quadArray[2] = vertices[2];
|
572
|
+
quadArray[3] = vertices[0];
|
573
|
+
quadArray[4] = vertices[2];
|
574
|
+
quadArray[5] = vertices[3];
|
575
|
+
vertices = quadArray;
|
576
|
+
}
|
577
|
+
|
578
|
+
for (var j = 0, l = vertices.length; j < l; j++) {
|
579
|
+
var v = vertices[j];
|
580
|
+
var index = offset + j * 3;
|
581
|
+
positions[index + 0] = v.x;
|
582
|
+
positions[index + 1] = v.y;
|
583
|
+
positions[index + 2] = v.z;
|
584
|
+
}
|
585
|
+
|
586
|
+
if (elementSize === 3) {
|
587
|
+
var elemNormals = elem.normals;
|
588
|
+
|
589
|
+
if (elemNormals.length === 4) {
|
590
|
+
quadArray[0] = elemNormals[0];
|
591
|
+
quadArray[1] = elemNormals[1];
|
592
|
+
quadArray[2] = elemNormals[2];
|
593
|
+
quadArray[3] = elemNormals[0];
|
594
|
+
quadArray[4] = elemNormals[2];
|
595
|
+
quadArray[5] = elemNormals[3];
|
596
|
+
elemNormals = quadArray;
|
597
|
+
}
|
598
|
+
|
599
|
+
for (var _j = 0, _l3 = elemNormals.length; _j < _l3; _j++) {
|
600
|
+
var n = elem.faceNormal;
|
601
|
+
|
602
|
+
if (elemNormals[_j]) {
|
603
|
+
n = elemNormals[_j].norm;
|
604
|
+
}
|
605
|
+
|
606
|
+
var _index2 = offset + _j * 3;
|
607
|
+
|
608
|
+
normals[_index2 + 0] = n.x;
|
609
|
+
normals[_index2 + 1] = n.y;
|
610
|
+
normals[_index2 + 2] = n.z;
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
if (prevMaterial !== elem.material) {
|
615
|
+
if (prevMaterial !== null) {
|
616
|
+
bufferGeometry.addGroup(index0, numGroupVerts, materials.length - 1);
|
617
|
+
}
|
618
|
+
|
619
|
+
materials.push(elem.material);
|
620
|
+
prevMaterial = elem.material;
|
621
|
+
index0 = offset / 3;
|
622
|
+
numGroupVerts = vertices.length;
|
623
|
+
} else {
|
624
|
+
numGroupVerts += vertices.length;
|
625
|
+
}
|
626
|
+
|
627
|
+
offset += 3 * vertices.length;
|
628
|
+
}
|
629
|
+
|
630
|
+
if (numGroupVerts > 0) {
|
631
|
+
bufferGeometry.addGroup(index0, Infinity, materials.length - 1);
|
632
|
+
}
|
633
|
+
|
634
|
+
bufferGeometry.setAttribute('position', new _three.BufferAttribute(positions, 3));
|
635
|
+
|
636
|
+
if (normals !== null) {
|
637
|
+
bufferGeometry.setAttribute('normal', new _three.BufferAttribute(normals, 3));
|
638
|
+
}
|
639
|
+
|
640
|
+
var object3d = null;
|
641
|
+
|
642
|
+
if (elementSize === 2) {
|
643
|
+
object3d = new _three.LineSegments(bufferGeometry, materials.length === 1 ? materials[0] : materials);
|
644
|
+
} else if (elementSize === 3) {
|
645
|
+
object3d = new _three.Mesh(bufferGeometry, materials.length === 1 ? materials[0] : materials);
|
646
|
+
}
|
647
|
+
|
648
|
+
if (isConditionalSegments) {
|
649
|
+
object3d.isConditionalLine = true;
|
650
|
+
var controlArray0 = new Float32Array(elements.length * 3 * 2);
|
651
|
+
var controlArray1 = new Float32Array(elements.length * 3 * 2);
|
652
|
+
var directionArray = new Float32Array(elements.length * 3 * 2);
|
653
|
+
|
654
|
+
for (var i = 0, _l4 = elements.length; i < _l4; i++) {
|
655
|
+
var os = elements[i];
|
656
|
+
var _vertices3 = os.vertices;
|
657
|
+
var controlPoints = os.controlPoints;
|
658
|
+
var c0 = controlPoints[0];
|
659
|
+
var c1 = controlPoints[1];
|
660
|
+
var v0 = _vertices3[0];
|
661
|
+
var v1 = _vertices3[1];
|
662
|
+
|
663
|
+
var _index3 = i * 3 * 2;
|
664
|
+
|
665
|
+
controlArray0[_index3 + 0] = c0.x;
|
666
|
+
controlArray0[_index3 + 1] = c0.y;
|
667
|
+
controlArray0[_index3 + 2] = c0.z;
|
668
|
+
controlArray0[_index3 + 3] = c0.x;
|
669
|
+
controlArray0[_index3 + 4] = c0.y;
|
670
|
+
controlArray0[_index3 + 5] = c0.z;
|
671
|
+
controlArray1[_index3 + 0] = c1.x;
|
672
|
+
controlArray1[_index3 + 1] = c1.y;
|
673
|
+
controlArray1[_index3 + 2] = c1.z;
|
674
|
+
controlArray1[_index3 + 3] = c1.x;
|
675
|
+
controlArray1[_index3 + 4] = c1.y;
|
676
|
+
controlArray1[_index3 + 5] = c1.z;
|
677
|
+
directionArray[_index3 + 0] = v1.x - v0.x;
|
678
|
+
directionArray[_index3 + 1] = v1.y - v0.y;
|
679
|
+
directionArray[_index3 + 2] = v1.z - v0.z;
|
680
|
+
directionArray[_index3 + 3] = v1.x - v0.x;
|
681
|
+
directionArray[_index3 + 4] = v1.y - v0.y;
|
682
|
+
directionArray[_index3 + 5] = v1.z - v0.z;
|
683
|
+
}
|
684
|
+
|
685
|
+
bufferGeometry.setAttribute('control0', new _three.BufferAttribute(controlArray0, 3, false));
|
686
|
+
bufferGeometry.setAttribute('control1', new _three.BufferAttribute(controlArray1, 3, false));
|
687
|
+
bufferGeometry.setAttribute('direction', new _three.BufferAttribute(directionArray, 3, false));
|
688
|
+
}
|
689
|
+
|
690
|
+
return object3d;
|
691
|
+
} //
|
692
|
+
|
693
|
+
|
694
|
+
var LDrawLoader = /*#__PURE__*/function (_Loader) {
|
695
|
+
_inherits(LDrawLoader, _Loader);
|
696
|
+
|
697
|
+
var _super2 = _createSuper(LDrawLoader);
|
698
|
+
|
699
|
+
function LDrawLoader(manager) {
|
700
|
+
var _this3;
|
701
|
+
|
702
|
+
_classCallCheck(this, LDrawLoader);
|
703
|
+
|
704
|
+
_this3 = _super2.call(this, manager); // Array of THREE.Material
|
705
|
+
|
706
|
+
_this3.materials = []; // Not using THREE.Cache here because it returns the previous HTML error response instead of calling onError()
|
707
|
+
// This also allows to handle the embedded text files ("0 FILE" lines)
|
708
|
+
|
709
|
+
_this3.cache = new LDrawFileCache(_assertThisInitialized(_this3)); // This object is a map from file names to paths. It agilizes the paths search. If it is not set then files will be searched by trial and error.
|
710
|
+
|
711
|
+
_this3.fileMap = null;
|
712
|
+
_this3.rootParseScope = _this3.newParseScopeLevel(); // Add default main triangle and line edge materials (used in pieces that can be coloured with a main color)
|
713
|
+
|
714
|
+
_this3.setMaterials([_this3.parseColourMetaDirective(new LineParser('Main_Colour CODE 16 VALUE #FF8080 EDGE #333333')), _this3.parseColourMetaDirective(new LineParser('Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333'))]); // If this flag is set to true, each subobject will be a Object.
|
715
|
+
// If not (the default), only one object which contains all the merged primitives will be created.
|
716
|
+
|
717
|
+
|
718
|
+
_this3.separateObjects = false; // If this flag is set to true the vertex normals will be smoothed.
|
719
|
+
|
720
|
+
_this3.smoothNormals = true; // The path to load parts from the LDraw parts library from.
|
721
|
+
|
722
|
+
_this3.partsLibraryPath = '';
|
723
|
+
return _this3;
|
724
|
+
}
|
725
|
+
|
726
|
+
_createClass(LDrawLoader, [{
|
727
|
+
key: "setPartsLibraryPath",
|
728
|
+
value: function setPartsLibraryPath(path) {
|
729
|
+
this.partsLibraryPath = path;
|
730
|
+
return this;
|
731
|
+
}
|
732
|
+
}, {
|
733
|
+
key: "preloadMaterials",
|
734
|
+
value: function () {
|
735
|
+
var _preloadMaterials = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(url) {
|
736
|
+
var fileLoader, text, colorLineRegex, lines, materials, i, l, line, directive, material;
|
737
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
738
|
+
while (1) {
|
739
|
+
switch (_context3.prev = _context3.next) {
|
740
|
+
case 0:
|
741
|
+
fileLoader = new _three.FileLoader(this.manager);
|
742
|
+
fileLoader.setPath(this.path);
|
743
|
+
fileLoader.setRequestHeader(this.requestHeader);
|
744
|
+
fileLoader.setWithCredentials(this.withCredentials);
|
745
|
+
_context3.next = 6;
|
746
|
+
return fileLoader.loadAsync(url);
|
747
|
+
|
748
|
+
case 6:
|
749
|
+
text = _context3.sent;
|
750
|
+
colorLineRegex = /^0 !COLOUR/;
|
751
|
+
lines = text.split(/[\n\r]/g);
|
752
|
+
materials = [];
|
753
|
+
|
754
|
+
for (i = 0, l = lines.length; i < l; i++) {
|
755
|
+
line = lines[i];
|
756
|
+
|
757
|
+
if (colorLineRegex.test(line)) {
|
758
|
+
directive = line.replace(colorLineRegex, '');
|
759
|
+
material = this.parseColourMetaDirective(new LineParser(directive));
|
760
|
+
materials.push(material);
|
761
|
+
}
|
762
|
+
}
|
763
|
+
|
764
|
+
this.setMaterials(materials);
|
765
|
+
|
766
|
+
case 12:
|
767
|
+
case "end":
|
768
|
+
return _context3.stop();
|
769
|
+
}
|
770
|
+
}
|
771
|
+
}, _callee3, this);
|
772
|
+
}));
|
773
|
+
|
774
|
+
function preloadMaterials(_x4) {
|
775
|
+
return _preloadMaterials.apply(this, arguments);
|
776
|
+
}
|
777
|
+
|
778
|
+
return preloadMaterials;
|
779
|
+
}()
|
780
|
+
}, {
|
781
|
+
key: "load",
|
782
|
+
value: function load(url, onLoad, onProgress, onError) {
|
783
|
+
var _this4 = this;
|
784
|
+
|
785
|
+
if (!this.fileMap) {
|
786
|
+
this.fileMap = {};
|
787
|
+
}
|
788
|
+
|
789
|
+
var fileLoader = new _three.FileLoader(this.manager);
|
790
|
+
fileLoader.setPath(this.path);
|
791
|
+
fileLoader.setRequestHeader(this.requestHeader);
|
792
|
+
fileLoader.setWithCredentials(this.withCredentials);
|
793
|
+
fileLoader.load(url, function (text) {
|
794
|
+
_this4.processObject(text, null, url, _this4.rootParseScope).then(function (result) {
|
795
|
+
onLoad(result.groupObject);
|
796
|
+
});
|
797
|
+
}, onProgress, onError);
|
798
|
+
}
|
799
|
+
}, {
|
800
|
+
key: "parse",
|
801
|
+
value: function parse(text, path, onLoad) {
|
802
|
+
// Async parse. This function calls onParse with the parsed THREE.Object3D as parameter
|
803
|
+
this.processObject(text, null, path, this.rootParseScope).then(function (result) {
|
804
|
+
onLoad(result.groupObject);
|
805
|
+
});
|
806
|
+
}
|
807
|
+
}, {
|
808
|
+
key: "setMaterials",
|
809
|
+
value: function setMaterials(materials) {
|
810
|
+
// Clears parse scopes stack, adds new scope with material library
|
811
|
+
this.rootParseScope = this.newParseScopeLevel(materials);
|
812
|
+
this.rootParseScope.isFromParse = false;
|
813
|
+
this.materials = materials;
|
814
|
+
return this;
|
815
|
+
}
|
816
|
+
}, {
|
817
|
+
key: "setFileMap",
|
818
|
+
value: function setFileMap(fileMap) {
|
819
|
+
this.fileMap = fileMap;
|
820
|
+
return this;
|
821
|
+
}
|
822
|
+
}, {
|
823
|
+
key: "newParseScopeLevel",
|
824
|
+
value: function newParseScopeLevel() {
|
825
|
+
var materials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
826
|
+
var parentScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
827
|
+
// Adds a new scope level, assign materials to it and returns it
|
828
|
+
var matLib = {};
|
829
|
+
|
830
|
+
if (materials) {
|
831
|
+
for (var i = 0, n = materials.length; i < n; i++) {
|
832
|
+
var material = materials[i];
|
833
|
+
matLib[material.userData.code] = material;
|
834
|
+
}
|
835
|
+
}
|
836
|
+
|
837
|
+
var newParseScope = {
|
838
|
+
parentScope: parentScope,
|
839
|
+
lib: matLib,
|
840
|
+
url: null,
|
841
|
+
// Subobjects
|
842
|
+
subobjects: null,
|
843
|
+
numSubobjects: 0,
|
844
|
+
subobjectIndex: 0,
|
845
|
+
inverted: false,
|
846
|
+
category: null,
|
847
|
+
keywords: null,
|
848
|
+
// Current subobject
|
849
|
+
currentFileName: null,
|
850
|
+
mainColourCode: parentScope ? parentScope.mainColourCode : '16',
|
851
|
+
mainEdgeColourCode: parentScope ? parentScope.mainEdgeColourCode : '24',
|
852
|
+
currentMatrix: new _three.Matrix4(),
|
853
|
+
matrix: new _three.Matrix4(),
|
854
|
+
// If false, it is a root material scope previous to parse
|
855
|
+
isFromParse: true,
|
856
|
+
faces: null,
|
857
|
+
lineSegments: null,
|
858
|
+
conditionalSegments: null,
|
859
|
+
totalFaces: 0,
|
860
|
+
// If true, this object is the start of a construction step
|
861
|
+
startingConstructionStep: false
|
862
|
+
};
|
863
|
+
return newParseScope;
|
864
|
+
}
|
865
|
+
}, {
|
866
|
+
key: "addMaterial",
|
867
|
+
value: function addMaterial(material, parseScope) {
|
868
|
+
// Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
|
869
|
+
var matLib = parseScope.lib;
|
870
|
+
|
871
|
+
if (!matLib[material.userData.code]) {
|
872
|
+
this.materials.push(material);
|
873
|
+
}
|
874
|
+
|
875
|
+
matLib[material.userData.code] = material;
|
876
|
+
return this;
|
877
|
+
}
|
878
|
+
}, {
|
879
|
+
key: "getMaterial",
|
880
|
+
value: function getMaterial(colourCode) {
|
881
|
+
var parseScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rootParseScope;
|
882
|
+
|
883
|
+
// Given a colour code search its material in the parse scopes stack
|
884
|
+
if (colourCode.startsWith('0x2')) {
|
885
|
+
// Special 'direct' material value (RGB colour)
|
886
|
+
var colour = colourCode.substring(3);
|
887
|
+
return this.parseColourMetaDirective(new LineParser('Direct_Color_' + colour + ' CODE -1 VALUE #' + colour + ' EDGE #' + colour + ''));
|
888
|
+
}
|
889
|
+
|
890
|
+
while (parseScope) {
|
891
|
+
var material = parseScope.lib[colourCode];
|
892
|
+
|
893
|
+
if (material) {
|
894
|
+
return material;
|
895
|
+
} else {
|
896
|
+
parseScope = parseScope.parentScope;
|
897
|
+
}
|
898
|
+
} // Material was not found
|
899
|
+
|
900
|
+
|
901
|
+
return null;
|
902
|
+
}
|
903
|
+
}, {
|
904
|
+
key: "parseColourMetaDirective",
|
905
|
+
value: function parseColourMetaDirective(lineParser) {
|
906
|
+
// Parses a colour definition and returns a THREE.Material
|
907
|
+
var code = null; // Triangle and line colours
|
908
|
+
|
909
|
+
var colour = 0xFF00FF;
|
910
|
+
var edgeColour = 0xFF00FF; // Transparency
|
911
|
+
|
912
|
+
var alpha = 1;
|
913
|
+
var isTransparent = false; // Self-illumination:
|
914
|
+
|
915
|
+
var luminance = 0;
|
916
|
+
var finishType = FINISH_TYPE_DEFAULT;
|
917
|
+
var edgeMaterial = null;
|
918
|
+
var name = lineParser.getToken();
|
919
|
+
|
920
|
+
if (!name) {
|
921
|
+
throw 'LDrawLoader: Material name was expected after "!COLOUR tag' + lineParser.getLineNumberString() + '.';
|
922
|
+
} // Parse tag tokens and their parameters
|
923
|
+
|
924
|
+
|
925
|
+
var token = null;
|
926
|
+
|
927
|
+
while (true) {
|
928
|
+
token = lineParser.getToken();
|
929
|
+
|
930
|
+
if (!token) {
|
931
|
+
break;
|
932
|
+
}
|
933
|
+
|
934
|
+
switch (token.toUpperCase()) {
|
935
|
+
case 'CODE':
|
936
|
+
code = lineParser.getToken();
|
937
|
+
break;
|
938
|
+
|
939
|
+
case 'VALUE':
|
940
|
+
colour = lineParser.getToken();
|
941
|
+
|
942
|
+
if (colour.startsWith('0x')) {
|
943
|
+
colour = '#' + colour.substring(2);
|
944
|
+
} else if (!colour.startsWith('#')) {
|
945
|
+
throw 'LDrawLoader: Invalid colour while parsing material' + lineParser.getLineNumberString() + '.';
|
946
|
+
}
|
947
|
+
|
948
|
+
break;
|
949
|
+
|
950
|
+
case 'EDGE':
|
951
|
+
edgeColour = lineParser.getToken();
|
952
|
+
|
953
|
+
if (edgeColour.startsWith('0x')) {
|
954
|
+
edgeColour = '#' + edgeColour.substring(2);
|
955
|
+
} else if (!edgeColour.startsWith('#')) {
|
956
|
+
// Try to see if edge colour is a colour code
|
957
|
+
edgeMaterial = this.getMaterial(edgeColour);
|
958
|
+
|
959
|
+
if (!edgeMaterial) {
|
960
|
+
throw 'LDrawLoader: Invalid edge colour while parsing material' + lineParser.getLineNumberString() + '.';
|
961
|
+
} // Get the edge material for this triangle material
|
962
|
+
|
963
|
+
|
964
|
+
edgeMaterial = edgeMaterial.userData.edgeMaterial;
|
965
|
+
}
|
966
|
+
|
967
|
+
break;
|
968
|
+
|
969
|
+
case 'ALPHA':
|
970
|
+
alpha = parseInt(lineParser.getToken());
|
971
|
+
|
972
|
+
if (isNaN(alpha)) {
|
973
|
+
throw 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.';
|
974
|
+
}
|
975
|
+
|
976
|
+
alpha = Math.max(0, Math.min(1, alpha / 255));
|
977
|
+
|
978
|
+
if (alpha < 1) {
|
979
|
+
isTransparent = true;
|
980
|
+
}
|
981
|
+
|
982
|
+
break;
|
983
|
+
|
984
|
+
case 'LUMINANCE':
|
985
|
+
luminance = parseInt(lineParser.getToken());
|
986
|
+
|
987
|
+
if (isNaN(luminance)) {
|
988
|
+
throw 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.';
|
989
|
+
}
|
990
|
+
|
991
|
+
luminance = Math.max(0, Math.min(1, luminance / 255));
|
992
|
+
break;
|
993
|
+
|
994
|
+
case 'CHROME':
|
995
|
+
finishType = FINISH_TYPE_CHROME;
|
996
|
+
break;
|
997
|
+
|
998
|
+
case 'PEARLESCENT':
|
999
|
+
finishType = FINISH_TYPE_PEARLESCENT;
|
1000
|
+
break;
|
1001
|
+
|
1002
|
+
case 'RUBBER':
|
1003
|
+
finishType = FINISH_TYPE_RUBBER;
|
1004
|
+
break;
|
1005
|
+
|
1006
|
+
case 'MATTE_METALLIC':
|
1007
|
+
finishType = FINISH_TYPE_MATTE_METALLIC;
|
1008
|
+
break;
|
1009
|
+
|
1010
|
+
case 'METAL':
|
1011
|
+
finishType = FINISH_TYPE_METAL;
|
1012
|
+
break;
|
1013
|
+
|
1014
|
+
case 'MATERIAL':
|
1015
|
+
// Not implemented
|
1016
|
+
lineParser.setToEnd();
|
1017
|
+
break;
|
1018
|
+
|
1019
|
+
default:
|
1020
|
+
throw 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.';
|
1021
|
+
break;
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
var material = null;
|
1026
|
+
|
1027
|
+
switch (finishType) {
|
1028
|
+
case FINISH_TYPE_DEFAULT:
|
1029
|
+
material = new _three.MeshStandardMaterial({
|
1030
|
+
color: colour,
|
1031
|
+
roughness: 0.3,
|
1032
|
+
metalness: 0
|
1033
|
+
});
|
1034
|
+
break;
|
1035
|
+
|
1036
|
+
case FINISH_TYPE_PEARLESCENT:
|
1037
|
+
// Try to imitate pearlescency by setting the specular to the complementary of the color, and low shininess
|
1038
|
+
var specular = new _three.Color(colour);
|
1039
|
+
var hsl = specular.getHSL({
|
1040
|
+
h: 0,
|
1041
|
+
s: 0,
|
1042
|
+
l: 0
|
1043
|
+
});
|
1044
|
+
hsl.h = (hsl.h + 0.5) % 1;
|
1045
|
+
hsl.l = Math.min(1, hsl.l + (1 - hsl.l) * 0.7);
|
1046
|
+
specular.setHSL(hsl.h, hsl.s, hsl.l);
|
1047
|
+
material = new _three.MeshPhongMaterial({
|
1048
|
+
color: colour,
|
1049
|
+
specular: specular,
|
1050
|
+
shininess: 10,
|
1051
|
+
reflectivity: 0.3
|
1052
|
+
});
|
1053
|
+
break;
|
1054
|
+
|
1055
|
+
case FINISH_TYPE_CHROME:
|
1056
|
+
// Mirror finish surface
|
1057
|
+
material = new _three.MeshStandardMaterial({
|
1058
|
+
color: colour,
|
1059
|
+
roughness: 0,
|
1060
|
+
metalness: 1
|
1061
|
+
});
|
1062
|
+
break;
|
1063
|
+
|
1064
|
+
case FINISH_TYPE_RUBBER:
|
1065
|
+
// Rubber finish
|
1066
|
+
material = new _three.MeshStandardMaterial({
|
1067
|
+
color: colour,
|
1068
|
+
roughness: 0.9,
|
1069
|
+
metalness: 0
|
1070
|
+
});
|
1071
|
+
break;
|
1072
|
+
|
1073
|
+
case FINISH_TYPE_MATTE_METALLIC:
|
1074
|
+
// Brushed metal finish
|
1075
|
+
material = new _three.MeshStandardMaterial({
|
1076
|
+
color: colour,
|
1077
|
+
roughness: 0.8,
|
1078
|
+
metalness: 0.4
|
1079
|
+
});
|
1080
|
+
break;
|
1081
|
+
|
1082
|
+
case FINISH_TYPE_METAL:
|
1083
|
+
// Average metal finish
|
1084
|
+
material = new _three.MeshStandardMaterial({
|
1085
|
+
color: colour,
|
1086
|
+
roughness: 0.2,
|
1087
|
+
metalness: 0.85
|
1088
|
+
});
|
1089
|
+
break;
|
1090
|
+
|
1091
|
+
default:
|
1092
|
+
// Should not happen
|
1093
|
+
break;
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
material.transparent = isTransparent;
|
1097
|
+
material.premultipliedAlpha = true;
|
1098
|
+
material.opacity = alpha;
|
1099
|
+
material.depthWrite = !isTransparent;
|
1100
|
+
material.polygonOffset = true;
|
1101
|
+
material.polygonOffsetFactor = 1;
|
1102
|
+
|
1103
|
+
if (luminance !== 0) {
|
1104
|
+
material.emissive.set(material.color).multiplyScalar(luminance);
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
if (!edgeMaterial) {
|
1108
|
+
// This is the material used for edges
|
1109
|
+
edgeMaterial = new _three.LineBasicMaterial({
|
1110
|
+
color: edgeColour,
|
1111
|
+
transparent: isTransparent,
|
1112
|
+
opacity: alpha,
|
1113
|
+
depthWrite: !isTransparent
|
1114
|
+
});
|
1115
|
+
edgeMaterial.userData.code = code;
|
1116
|
+
edgeMaterial.name = name + ' - Edge'; // This is the material used for conditional edges
|
1117
|
+
|
1118
|
+
edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial({
|
1119
|
+
fog: true,
|
1120
|
+
transparent: isTransparent,
|
1121
|
+
depthWrite: !isTransparent,
|
1122
|
+
color: edgeColour,
|
1123
|
+
opacity: alpha
|
1124
|
+
});
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
material.userData.code = code;
|
1128
|
+
material.name = name;
|
1129
|
+
material.userData.edgeMaterial = edgeMaterial;
|
1130
|
+
return material;
|
1131
|
+
} //
|
1132
|
+
|
1133
|
+
}, {
|
1134
|
+
key: "objectParse",
|
1135
|
+
value: function objectParse(text, parseScope) {
|
1136
|
+
// Retrieve data from the parent parse scope
|
1137
|
+
var currentParseScope = parseScope;
|
1138
|
+
var parentParseScope = currentParseScope.parentScope; // Main colour codes passed to this subobject (or default codes 16 and 24 if it is the root object)
|
1139
|
+
|
1140
|
+
var mainColourCode = currentParseScope.mainColourCode;
|
1141
|
+
var mainEdgeColourCode = currentParseScope.mainEdgeColourCode; // Parse result variables
|
1142
|
+
|
1143
|
+
var faces;
|
1144
|
+
var lineSegments;
|
1145
|
+
var conditionalSegments;
|
1146
|
+
var subobjects = [];
|
1147
|
+
var category = null;
|
1148
|
+
var keywords = null;
|
1149
|
+
|
1150
|
+
if (text.indexOf('\r\n') !== -1) {
|
1151
|
+
// This is faster than String.split with regex that splits on both
|
1152
|
+
text = text.replace(/\r\n/g, '\n');
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
var lines = text.split('\n');
|
1156
|
+
var numLines = lines.length;
|
1157
|
+
var parsingEmbeddedFiles = false;
|
1158
|
+
var currentEmbeddedFileName = null;
|
1159
|
+
var currentEmbeddedText = null;
|
1160
|
+
var bfcCertified = false;
|
1161
|
+
var bfcCCW = true;
|
1162
|
+
var bfcInverted = false;
|
1163
|
+
var bfcCull = true;
|
1164
|
+
var type = '';
|
1165
|
+
var startingConstructionStep = false;
|
1166
|
+
var scope = this;
|
1167
|
+
|
1168
|
+
function parseColourCode(lineParser, forEdge) {
|
1169
|
+
// Parses next colour code and returns a THREE.Material
|
1170
|
+
var colourCode = lineParser.getToken();
|
1171
|
+
|
1172
|
+
if (!forEdge && colourCode === '16') {
|
1173
|
+
colourCode = mainColourCode;
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
if (forEdge && colourCode === '24') {
|
1177
|
+
colourCode = mainEdgeColourCode;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
var material = scope.getMaterial(colourCode, currentParseScope);
|
1181
|
+
|
1182
|
+
if (!material) {
|
1183
|
+
throw 'LDrawLoader: Unknown colour code "' + colourCode + '" is used' + lineParser.getLineNumberString() + ' but it was not defined previously.';
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
return material;
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
function parseVector(lp) {
|
1190
|
+
var v = new _three.Vector3(parseFloat(lp.getToken()), parseFloat(lp.getToken()), parseFloat(lp.getToken()));
|
1191
|
+
|
1192
|
+
if (!scope.separateObjects) {
|
1193
|
+
v.applyMatrix4(currentParseScope.currentMatrix);
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
return v;
|
1197
|
+
} // Parse all line commands
|
1198
|
+
|
1199
|
+
|
1200
|
+
for (var lineIndex = 0; lineIndex < numLines; lineIndex++) {
|
1201
|
+
var line = lines[lineIndex];
|
1202
|
+
if (line.length === 0) continue;
|
1203
|
+
|
1204
|
+
if (parsingEmbeddedFiles) {
|
1205
|
+
if (line.startsWith('0 FILE ')) {
|
1206
|
+
// Save previous embedded file in the cache
|
1207
|
+
this.cache.setData(currentEmbeddedFileName.toLowerCase(), currentEmbeddedText); // New embedded text file
|
1208
|
+
|
1209
|
+
currentEmbeddedFileName = line.substring(7);
|
1210
|
+
currentEmbeddedText = '';
|
1211
|
+
} else {
|
1212
|
+
currentEmbeddedText += line + '\n';
|
1213
|
+
}
|
1214
|
+
|
1215
|
+
continue;
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
var lp = new LineParser(line, lineIndex + 1);
|
1219
|
+
lp.seekNonSpace();
|
1220
|
+
|
1221
|
+
if (lp.isAtTheEnd()) {
|
1222
|
+
// Empty line
|
1223
|
+
continue;
|
1224
|
+
} // Parse the line type
|
1225
|
+
|
1226
|
+
|
1227
|
+
var lineType = lp.getToken();
|
1228
|
+
var material = void 0;
|
1229
|
+
var segment = void 0;
|
1230
|
+
var inverted = void 0;
|
1231
|
+
var ccw = void 0;
|
1232
|
+
var doubleSided = void 0;
|
1233
|
+
var v0 = void 0,
|
1234
|
+
v1 = void 0,
|
1235
|
+
v2 = void 0,
|
1236
|
+
v3 = void 0,
|
1237
|
+
c0 = void 0,
|
1238
|
+
c1 = void 0,
|
1239
|
+
faceNormal = void 0;
|
1240
|
+
|
1241
|
+
switch (lineType) {
|
1242
|
+
// Line type 0: Comment or META
|
1243
|
+
case '0':
|
1244
|
+
// Parse meta directive
|
1245
|
+
var meta = lp.getToken();
|
1246
|
+
|
1247
|
+
if (meta) {
|
1248
|
+
switch (meta) {
|
1249
|
+
case '!LDRAW_ORG':
|
1250
|
+
type = lp.getToken();
|
1251
|
+
currentParseScope.faces = [];
|
1252
|
+
currentParseScope.lineSegments = [];
|
1253
|
+
currentParseScope.conditionalSegments = [];
|
1254
|
+
currentParseScope.type = type;
|
1255
|
+
var isRoot = !parentParseScope.isFromParse;
|
1256
|
+
|
1257
|
+
if (isRoot || scope.separateObjects && !isPrimitiveType(type)) {
|
1258
|
+
currentParseScope.groupObject = new _three.Group();
|
1259
|
+
currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
|
1260
|
+
} // If the scale of the object is negated then the triangle winding order
|
1261
|
+
// needs to be flipped.
|
1262
|
+
|
1263
|
+
|
1264
|
+
if (currentParseScope.matrix.determinant() < 0 && (scope.separateObjects && isPrimitiveType(type) || !scope.separateObjects)) {
|
1265
|
+
currentParseScope.inverted = !currentParseScope.inverted;
|
1266
|
+
}
|
1267
|
+
|
1268
|
+
faces = currentParseScope.faces;
|
1269
|
+
lineSegments = currentParseScope.lineSegments;
|
1270
|
+
conditionalSegments = currentParseScope.conditionalSegments;
|
1271
|
+
break;
|
1272
|
+
|
1273
|
+
case '!COLOUR':
|
1274
|
+
material = this.parseColourMetaDirective(lp);
|
1275
|
+
|
1276
|
+
if (material) {
|
1277
|
+
this.addMaterial(material, parseScope);
|
1278
|
+
} else {
|
1279
|
+
console.warn('LDrawLoader: Error parsing material' + lp.getLineNumberString());
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
break;
|
1283
|
+
|
1284
|
+
case '!CATEGORY':
|
1285
|
+
category = lp.getToken();
|
1286
|
+
break;
|
1287
|
+
|
1288
|
+
case '!KEYWORDS':
|
1289
|
+
var newKeywords = lp.getRemainingString().split(',');
|
1290
|
+
|
1291
|
+
if (newKeywords.length > 0) {
|
1292
|
+
if (!keywords) {
|
1293
|
+
keywords = [];
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
newKeywords.forEach(function (keyword) {
|
1297
|
+
keywords.push(keyword.trim());
|
1298
|
+
});
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
break;
|
1302
|
+
|
1303
|
+
case 'FILE':
|
1304
|
+
if (lineIndex > 0) {
|
1305
|
+
// Start embedded text files parsing
|
1306
|
+
parsingEmbeddedFiles = true;
|
1307
|
+
currentEmbeddedFileName = lp.getRemainingString();
|
1308
|
+
currentEmbeddedText = '';
|
1309
|
+
bfcCertified = false;
|
1310
|
+
bfcCCW = true;
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
break;
|
1314
|
+
|
1315
|
+
case 'BFC':
|
1316
|
+
// Changes to the backface culling state
|
1317
|
+
while (!lp.isAtTheEnd()) {
|
1318
|
+
var token = lp.getToken();
|
1319
|
+
|
1320
|
+
switch (token) {
|
1321
|
+
case 'CERTIFY':
|
1322
|
+
case 'NOCERTIFY':
|
1323
|
+
bfcCertified = token === 'CERTIFY';
|
1324
|
+
bfcCCW = true;
|
1325
|
+
break;
|
1326
|
+
|
1327
|
+
case 'CW':
|
1328
|
+
case 'CCW':
|
1329
|
+
bfcCCW = token === 'CCW';
|
1330
|
+
break;
|
1331
|
+
|
1332
|
+
case 'INVERTNEXT':
|
1333
|
+
bfcInverted = true;
|
1334
|
+
break;
|
1335
|
+
|
1336
|
+
case 'CLIP':
|
1337
|
+
case 'NOCLIP':
|
1338
|
+
bfcCull = token === 'CLIP';
|
1339
|
+
break;
|
1340
|
+
|
1341
|
+
default:
|
1342
|
+
console.warn('THREE.LDrawLoader: BFC directive "' + token + '" is unknown.');
|
1343
|
+
break;
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
break;
|
1348
|
+
|
1349
|
+
case 'STEP':
|
1350
|
+
startingConstructionStep = true;
|
1351
|
+
break;
|
1352
|
+
|
1353
|
+
default:
|
1354
|
+
// Other meta directives are not implemented
|
1355
|
+
break;
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
break;
|
1360
|
+
// Line type 1: Sub-object file
|
1361
|
+
|
1362
|
+
case '1':
|
1363
|
+
material = parseColourCode(lp);
|
1364
|
+
var posX = parseFloat(lp.getToken());
|
1365
|
+
var posY = parseFloat(lp.getToken());
|
1366
|
+
var posZ = parseFloat(lp.getToken());
|
1367
|
+
var m0 = parseFloat(lp.getToken());
|
1368
|
+
var m1 = parseFloat(lp.getToken());
|
1369
|
+
var m2 = parseFloat(lp.getToken());
|
1370
|
+
var m3 = parseFloat(lp.getToken());
|
1371
|
+
var m4 = parseFloat(lp.getToken());
|
1372
|
+
var m5 = parseFloat(lp.getToken());
|
1373
|
+
var m6 = parseFloat(lp.getToken());
|
1374
|
+
var m7 = parseFloat(lp.getToken());
|
1375
|
+
var m8 = parseFloat(lp.getToken());
|
1376
|
+
var matrix = new _three.Matrix4().set(m0, m1, m2, posX, m3, m4, m5, posY, m6, m7, m8, posZ, 0, 0, 0, 1);
|
1377
|
+
var fileName = lp.getRemainingString().trim().replace(/\\/g, '/');
|
1378
|
+
|
1379
|
+
if (scope.fileMap[fileName]) {
|
1380
|
+
// Found the subobject path in the preloaded file path map
|
1381
|
+
fileName = scope.fileMap[fileName];
|
1382
|
+
} else {
|
1383
|
+
// Standardized subfolders
|
1384
|
+
if (fileName.startsWith('s/')) {
|
1385
|
+
fileName = 'parts/' + fileName;
|
1386
|
+
} else if (fileName.startsWith('48/')) {
|
1387
|
+
fileName = 'p/' + fileName;
|
1388
|
+
}
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
subobjects.push({
|
1392
|
+
material: material,
|
1393
|
+
matrix: matrix,
|
1394
|
+
fileName: fileName,
|
1395
|
+
inverted: bfcInverted !== currentParseScope.inverted,
|
1396
|
+
startingConstructionStep: startingConstructionStep
|
1397
|
+
});
|
1398
|
+
bfcInverted = false;
|
1399
|
+
break;
|
1400
|
+
// Line type 2: Line segment
|
1401
|
+
|
1402
|
+
case '2':
|
1403
|
+
material = parseColourCode(lp, true);
|
1404
|
+
v0 = parseVector(lp);
|
1405
|
+
v1 = parseVector(lp);
|
1406
|
+
segment = {
|
1407
|
+
material: material.userData.edgeMaterial,
|
1408
|
+
colourCode: material.userData.code,
|
1409
|
+
v0: v0,
|
1410
|
+
v1: v1,
|
1411
|
+
vertices: [v0, v1]
|
1412
|
+
};
|
1413
|
+
lineSegments.push(segment);
|
1414
|
+
break;
|
1415
|
+
// Line type 5: Conditional Line segment
|
1416
|
+
|
1417
|
+
case '5':
|
1418
|
+
material = parseColourCode(lp, true);
|
1419
|
+
v0 = parseVector(lp);
|
1420
|
+
v1 = parseVector(lp);
|
1421
|
+
c0 = parseVector(lp);
|
1422
|
+
c1 = parseVector(lp);
|
1423
|
+
segment = {
|
1424
|
+
material: material.userData.edgeMaterial.userData.conditionalEdgeMaterial,
|
1425
|
+
colourCode: material.userData.code,
|
1426
|
+
vertices: [v0, v1],
|
1427
|
+
controlPoints: [c0, c1]
|
1428
|
+
};
|
1429
|
+
conditionalSegments.push(segment);
|
1430
|
+
break;
|
1431
|
+
// Line type 3: Triangle
|
1432
|
+
|
1433
|
+
case '3':
|
1434
|
+
material = parseColourCode(lp);
|
1435
|
+
inverted = currentParseScope.inverted;
|
1436
|
+
ccw = bfcCCW !== inverted;
|
1437
|
+
doubleSided = !bfcCertified || !bfcCull;
|
1438
|
+
|
1439
|
+
if (ccw === true) {
|
1440
|
+
v0 = parseVector(lp);
|
1441
|
+
v1 = parseVector(lp);
|
1442
|
+
v2 = parseVector(lp);
|
1443
|
+
} else {
|
1444
|
+
v2 = parseVector(lp);
|
1445
|
+
v1 = parseVector(lp);
|
1446
|
+
v0 = parseVector(lp);
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
_tempVec0.subVectors(v1, v0);
|
1450
|
+
|
1451
|
+
_tempVec1.subVectors(v2, v1);
|
1452
|
+
|
1453
|
+
faceNormal = new _three.Vector3().crossVectors(_tempVec0, _tempVec1).normalize();
|
1454
|
+
faces.push({
|
1455
|
+
material: material,
|
1456
|
+
colourCode: material.userData.code,
|
1457
|
+
faceNormal: faceNormal,
|
1458
|
+
vertices: [v0, v1, v2],
|
1459
|
+
normals: [null, null, null]
|
1460
|
+
});
|
1461
|
+
currentParseScope.totalFaces++;
|
1462
|
+
|
1463
|
+
if (doubleSided === true) {
|
1464
|
+
faces.push({
|
1465
|
+
material: material,
|
1466
|
+
colourCode: material.userData.code,
|
1467
|
+
faceNormal: faceNormal,
|
1468
|
+
vertices: [v2, v1, v0],
|
1469
|
+
normals: [null, null, null]
|
1470
|
+
});
|
1471
|
+
currentParseScope.totalFaces++;
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
break;
|
1475
|
+
// Line type 4: Quadrilateral
|
1476
|
+
|
1477
|
+
case '4':
|
1478
|
+
material = parseColourCode(lp);
|
1479
|
+
inverted = currentParseScope.inverted;
|
1480
|
+
ccw = bfcCCW !== inverted;
|
1481
|
+
doubleSided = !bfcCertified || !bfcCull;
|
1482
|
+
|
1483
|
+
if (ccw === true) {
|
1484
|
+
v0 = parseVector(lp);
|
1485
|
+
v1 = parseVector(lp);
|
1486
|
+
v2 = parseVector(lp);
|
1487
|
+
v3 = parseVector(lp);
|
1488
|
+
} else {
|
1489
|
+
v3 = parseVector(lp);
|
1490
|
+
v2 = parseVector(lp);
|
1491
|
+
v1 = parseVector(lp);
|
1492
|
+
v0 = parseVector(lp);
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
_tempVec0.subVectors(v1, v0);
|
1496
|
+
|
1497
|
+
_tempVec1.subVectors(v2, v1);
|
1498
|
+
|
1499
|
+
faceNormal = new _three.Vector3().crossVectors(_tempVec0, _tempVec1).normalize(); // specifically place the triangle diagonal in the v0 and v1 slots so we can
|
1500
|
+
// account for the doubling of vertices later when smoothing normals.
|
1501
|
+
|
1502
|
+
faces.push({
|
1503
|
+
material: material,
|
1504
|
+
colourCode: material.userData.code,
|
1505
|
+
faceNormal: faceNormal,
|
1506
|
+
vertices: [v0, v1, v2, v3],
|
1507
|
+
normals: [null, null, null, null]
|
1508
|
+
});
|
1509
|
+
currentParseScope.totalFaces += 2;
|
1510
|
+
|
1511
|
+
if (doubleSided === true) {
|
1512
|
+
faces.push({
|
1513
|
+
material: material,
|
1514
|
+
colourCode: material.userData.code,
|
1515
|
+
faceNormal: faceNormal,
|
1516
|
+
vertices: [v3, v2, v1, v0],
|
1517
|
+
normals: [null, null, null, null]
|
1518
|
+
});
|
1519
|
+
currentParseScope.totalFaces += 2;
|
1520
|
+
}
|
1521
|
+
|
1522
|
+
break;
|
1523
|
+
|
1524
|
+
default:
|
1525
|
+
throw 'LDrawLoader: Unknown line type "' + lineType + '"' + lp.getLineNumberString() + '.';
|
1526
|
+
break;
|
1527
|
+
}
|
1528
|
+
}
|
1529
|
+
|
1530
|
+
if (parsingEmbeddedFiles) {
|
1531
|
+
this.cache.setData(currentEmbeddedFileName.toLowerCase(), currentEmbeddedText);
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
currentParseScope.category = category;
|
1535
|
+
currentParseScope.keywords = keywords;
|
1536
|
+
currentParseScope.subobjects = subobjects;
|
1537
|
+
currentParseScope.numSubobjects = subobjects.length;
|
1538
|
+
currentParseScope.subobjectIndex = 0;
|
1539
|
+
}
|
1540
|
+
}, {
|
1541
|
+
key: "computeConstructionSteps",
|
1542
|
+
value: function computeConstructionSteps(model) {
|
1543
|
+
// Sets userdata.constructionStep number in Group objects and userData.numConstructionSteps number in the root Group object.
|
1544
|
+
var stepNumber = 0;
|
1545
|
+
model.traverse(function (c) {
|
1546
|
+
if (c.isGroup) {
|
1547
|
+
if (c.userData.startingConstructionStep) {
|
1548
|
+
stepNumber++;
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
c.userData.constructionStep = stepNumber;
|
1552
|
+
}
|
1553
|
+
});
|
1554
|
+
model.userData.numConstructionSteps = stepNumber + 1;
|
1555
|
+
}
|
1556
|
+
}, {
|
1557
|
+
key: "finalizeObject",
|
1558
|
+
value: function finalizeObject(subobjectParseScope) {
|
1559
|
+
var parentParseScope = subobjectParseScope.parentScope; // Smooth the normals if this is a part or if this is a case where the subpart
|
1560
|
+
// is added directly into the parent model (meaning it will never get smoothed by
|
1561
|
+
// being added to a part)
|
1562
|
+
|
1563
|
+
var doSmooth = isPartType(subobjectParseScope.type) || !isPartType(subobjectParseScope.type) && !isModelType(subobjectParseScope.type) && isModelType(subobjectParseScope.parentScope.type);
|
1564
|
+
|
1565
|
+
if (this.smoothNormals && doSmooth) {
|
1566
|
+
smoothNormals(subobjectParseScope.faces, subobjectParseScope.lineSegments);
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
var isRoot = !parentParseScope.isFromParse;
|
1570
|
+
|
1571
|
+
if (this.separateObjects && !isPrimitiveType(subobjectParseScope.type) || isRoot) {
|
1572
|
+
var objGroup = subobjectParseScope.groupObject;
|
1573
|
+
|
1574
|
+
if (subobjectParseScope.faces.length > 0) {
|
1575
|
+
objGroup.add(createObject(subobjectParseScope.faces, 3, false, subobjectParseScope.totalFaces));
|
1576
|
+
}
|
1577
|
+
|
1578
|
+
if (subobjectParseScope.lineSegments.length > 0) {
|
1579
|
+
objGroup.add(createObject(subobjectParseScope.lineSegments, 2));
|
1580
|
+
}
|
1581
|
+
|
1582
|
+
if (subobjectParseScope.conditionalSegments.length > 0) {
|
1583
|
+
objGroup.add(createObject(subobjectParseScope.conditionalSegments, 2, true));
|
1584
|
+
}
|
1585
|
+
|
1586
|
+
if (parentParseScope.groupObject) {
|
1587
|
+
objGroup.name = subobjectParseScope.fileName;
|
1588
|
+
objGroup.userData.category = subobjectParseScope.category;
|
1589
|
+
objGroup.userData.keywords = subobjectParseScope.keywords;
|
1590
|
+
subobjectParseScope.matrix.decompose(objGroup.position, objGroup.quaternion, objGroup.scale);
|
1591
|
+
parentParseScope.groupObject.add(objGroup);
|
1592
|
+
}
|
1593
|
+
} else {
|
1594
|
+
var separateObjects = this.separateObjects;
|
1595
|
+
var parentLineSegments = parentParseScope.lineSegments;
|
1596
|
+
var parentConditionalSegments = parentParseScope.conditionalSegments;
|
1597
|
+
var parentFaces = parentParseScope.faces;
|
1598
|
+
var lineSegments = subobjectParseScope.lineSegments;
|
1599
|
+
var conditionalSegments = subobjectParseScope.conditionalSegments;
|
1600
|
+
var faces = subobjectParseScope.faces;
|
1601
|
+
|
1602
|
+
for (var i = 0, l = lineSegments.length; i < l; i++) {
|
1603
|
+
var ls = lineSegments[i];
|
1604
|
+
|
1605
|
+
if (separateObjects) {
|
1606
|
+
var vertices = ls.vertices;
|
1607
|
+
vertices[0].applyMatrix4(subobjectParseScope.matrix);
|
1608
|
+
vertices[1].applyMatrix4(subobjectParseScope.matrix);
|
1609
|
+
}
|
1610
|
+
|
1611
|
+
parentLineSegments.push(ls);
|
1612
|
+
}
|
1613
|
+
|
1614
|
+
for (var _i4 = 0, _l5 = conditionalSegments.length; _i4 < _l5; _i4++) {
|
1615
|
+
var os = conditionalSegments[_i4];
|
1616
|
+
|
1617
|
+
if (separateObjects) {
|
1618
|
+
var _vertices4 = os.vertices;
|
1619
|
+
var controlPoints = os.controlPoints;
|
1620
|
+
|
1621
|
+
_vertices4[0].applyMatrix4(subobjectParseScope.matrix);
|
1622
|
+
|
1623
|
+
_vertices4[1].applyMatrix4(subobjectParseScope.matrix);
|
1624
|
+
|
1625
|
+
controlPoints[0].applyMatrix4(subobjectParseScope.matrix);
|
1626
|
+
controlPoints[1].applyMatrix4(subobjectParseScope.matrix);
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
parentConditionalSegments.push(os);
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
for (var _i5 = 0, _l6 = faces.length; _i5 < _l6; _i5++) {
|
1633
|
+
var tri = faces[_i5];
|
1634
|
+
|
1635
|
+
if (separateObjects) {
|
1636
|
+
var _vertices5 = tri.vertices;
|
1637
|
+
|
1638
|
+
for (var _i6 = 0, _l7 = _vertices5.length; _i6 < _l7; _i6++) {
|
1639
|
+
_vertices5[_i6] = _vertices5[_i6].clone().applyMatrix4(subobjectParseScope.matrix);
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
_tempVec0.subVectors(_vertices5[1], _vertices5[0]);
|
1643
|
+
|
1644
|
+
_tempVec1.subVectors(_vertices5[2], _vertices5[1]);
|
1645
|
+
|
1646
|
+
tri.faceNormal.crossVectors(_tempVec0, _tempVec1).normalize();
|
1647
|
+
}
|
1648
|
+
|
1649
|
+
parentFaces.push(tri);
|
1650
|
+
}
|
1651
|
+
|
1652
|
+
parentParseScope.totalFaces += subobjectParseScope.totalFaces;
|
1653
|
+
}
|
1654
|
+
}
|
1655
|
+
}, {
|
1656
|
+
key: "processObject",
|
1657
|
+
value: function () {
|
1658
|
+
var _processObject = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(text, subobject, url, parentScope) {
|
1659
|
+
var scope, parseScope, parentParseScope, subobjects, promises, i, l, subobjectScopes, _i7, _l8, loadSubobject;
|
1660
|
+
|
1661
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
1662
|
+
while (1) {
|
1663
|
+
switch (_context4.prev = _context4.next) {
|
1664
|
+
case 0:
|
1665
|
+
loadSubobject = function _loadSubobject(subobject) {
|
1666
|
+
return scope.cache.loadData(subobject.fileName).then(function (text) {
|
1667
|
+
return scope.processObject(text, subobject, url, parseScope);
|
1668
|
+
}).catch(function () {
|
1669
|
+
console.warn('LDrawLoader: Subobject "' + subobject.fileName + '" could not be found.');
|
1670
|
+
});
|
1671
|
+
};
|
1672
|
+
|
1673
|
+
scope = this;
|
1674
|
+
parseScope = this.newParseScopeLevel(null, parentScope);
|
1675
|
+
parseScope.url = url;
|
1676
|
+
parentParseScope = parseScope.parentScope; // Set current matrix
|
1677
|
+
|
1678
|
+
if (subobject) {
|
1679
|
+
parseScope.currentMatrix.multiplyMatrices(parentParseScope.currentMatrix, subobject.matrix);
|
1680
|
+
parseScope.matrix.copy(subobject.matrix);
|
1681
|
+
parseScope.inverted = subobject.inverted;
|
1682
|
+
parseScope.startingConstructionStep = subobject.startingConstructionStep;
|
1683
|
+
parseScope.mainColourCode = subobject.material.userData.code;
|
1684
|
+
parseScope.mainEdgeColourCode = subobject.material.userData.edgeMaterial.userData.code;
|
1685
|
+
parseScope.fileName = subobject.fileName;
|
1686
|
+
} // Parse the object
|
1687
|
+
|
1688
|
+
|
1689
|
+
this.objectParse(text, parseScope);
|
1690
|
+
subobjects = parseScope.subobjects;
|
1691
|
+
promises = [];
|
1692
|
+
|
1693
|
+
for (i = 0, l = subobjects.length; i < l; i++) {
|
1694
|
+
promises.push(loadSubobject(parseScope.subobjects[i]));
|
1695
|
+
} // Kick off of the downloads in parallel but process all the subobjects
|
1696
|
+
// in order so all the assembly instructions are correct
|
1697
|
+
|
1698
|
+
|
1699
|
+
_context4.next = 12;
|
1700
|
+
return Promise.all(promises);
|
1701
|
+
|
1702
|
+
case 12:
|
1703
|
+
subobjectScopes = _context4.sent;
|
1704
|
+
|
1705
|
+
for (_i7 = 0, _l8 = subobjectScopes.length; _i7 < _l8; _i7++) {
|
1706
|
+
this.finalizeObject(subobjectScopes[_i7]);
|
1707
|
+
} // If it is root object then finalize this object and compute construction steps
|
1708
|
+
|
1709
|
+
|
1710
|
+
if (!parentParseScope.isFromParse) {
|
1711
|
+
this.finalizeObject(parseScope);
|
1712
|
+
this.computeConstructionSteps(parseScope.groupObject);
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
return _context4.abrupt("return", parseScope);
|
1716
|
+
|
1717
|
+
case 16:
|
1718
|
+
case "end":
|
1719
|
+
return _context4.stop();
|
1720
|
+
}
|
1721
|
+
}
|
1722
|
+
}, _callee4, this);
|
1723
|
+
}));
|
1724
|
+
|
1725
|
+
function processObject(_x5, _x6, _x7, _x8) {
|
1726
|
+
return _processObject.apply(this, arguments);
|
1727
|
+
}
|
1728
|
+
|
1729
|
+
return processObject;
|
1730
|
+
}()
|
1731
|
+
}]);
|
1732
|
+
|
1733
|
+
return LDrawLoader;
|
1734
|
+
}(_three.Loader);
|
1735
|
+
|
1736
|
+
_exports.LDrawLoader = LDrawLoader;
|
1737
|
+
});
|