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,400 @@
|
|
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.SkeletonUtils = 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.clone = clone;
|
20
|
+
_exports.findBoneTrackData = findBoneTrackData;
|
21
|
+
_exports.getBoneByName = getBoneByName;
|
22
|
+
_exports.getBones = getBones;
|
23
|
+
_exports.getEqualsBonesNames = getEqualsBonesNames;
|
24
|
+
_exports.getHelperFromSkeleton = getHelperFromSkeleton;
|
25
|
+
_exports.getNearestBone = getNearestBone;
|
26
|
+
_exports.getSkeletonOffsets = getSkeletonOffsets;
|
27
|
+
_exports.renameBones = renameBones;
|
28
|
+
_exports.retarget = retarget;
|
29
|
+
_exports.retargetClip = retargetClip;
|
30
|
+
|
31
|
+
function retarget(target, source) {
|
32
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
33
|
+
var pos = new _three.Vector3(),
|
34
|
+
quat = new _three.Quaternion(),
|
35
|
+
scale = new _three.Vector3(),
|
36
|
+
bindBoneMatrix = new _three.Matrix4(),
|
37
|
+
relativeMatrix = new _three.Matrix4(),
|
38
|
+
globalMatrix = new _three.Matrix4();
|
39
|
+
options.preserveMatrix = options.preserveMatrix !== undefined ? options.preserveMatrix : true;
|
40
|
+
options.preservePosition = options.preservePosition !== undefined ? options.preservePosition : true;
|
41
|
+
options.preserveHipPosition = options.preserveHipPosition !== undefined ? options.preserveHipPosition : false;
|
42
|
+
options.useTargetMatrix = options.useTargetMatrix !== undefined ? options.useTargetMatrix : false;
|
43
|
+
options.hip = options.hip !== undefined ? options.hip : 'hip';
|
44
|
+
options.names = options.names || {};
|
45
|
+
var sourceBones = source.isObject3D ? source.skeleton.bones : getBones(source),
|
46
|
+
bones = target.isObject3D ? target.skeleton.bones : getBones(target);
|
47
|
+
var bindBones, bone, name, boneTo, bonesPosition; // reset bones
|
48
|
+
|
49
|
+
if (target.isObject3D) {
|
50
|
+
target.skeleton.pose();
|
51
|
+
} else {
|
52
|
+
options.useTargetMatrix = true;
|
53
|
+
options.preserveMatrix = false;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (options.preservePosition) {
|
57
|
+
bonesPosition = [];
|
58
|
+
|
59
|
+
for (var i = 0; i < bones.length; i++) {
|
60
|
+
bonesPosition.push(bones[i].position.clone());
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
if (options.preserveMatrix) {
|
65
|
+
// reset matrix
|
66
|
+
target.updateMatrixWorld();
|
67
|
+
target.matrixWorld.identity(); // reset children matrix
|
68
|
+
|
69
|
+
for (var _i = 0; _i < target.children.length; ++_i) {
|
70
|
+
target.children[_i].updateMatrixWorld(true);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
if (options.offsets) {
|
75
|
+
bindBones = [];
|
76
|
+
|
77
|
+
for (var _i2 = 0; _i2 < bones.length; ++_i2) {
|
78
|
+
bone = bones[_i2];
|
79
|
+
name = options.names[bone.name] || bone.name;
|
80
|
+
|
81
|
+
if (options.offsets && options.offsets[name]) {
|
82
|
+
bone.matrix.multiply(options.offsets[name]);
|
83
|
+
bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
|
84
|
+
bone.updateMatrixWorld();
|
85
|
+
}
|
86
|
+
|
87
|
+
bindBones.push(bone.matrixWorld.clone());
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
for (var _i3 = 0; _i3 < bones.length; ++_i3) {
|
92
|
+
bone = bones[_i3];
|
93
|
+
name = options.names[bone.name] || bone.name;
|
94
|
+
boneTo = getBoneByName(name, sourceBones);
|
95
|
+
globalMatrix.copy(bone.matrixWorld);
|
96
|
+
|
97
|
+
if (boneTo) {
|
98
|
+
boneTo.updateMatrixWorld();
|
99
|
+
|
100
|
+
if (options.useTargetMatrix) {
|
101
|
+
relativeMatrix.copy(boneTo.matrixWorld);
|
102
|
+
} else {
|
103
|
+
relativeMatrix.copy(target.matrixWorld).invert();
|
104
|
+
relativeMatrix.multiply(boneTo.matrixWorld);
|
105
|
+
} // ignore scale to extract rotation
|
106
|
+
|
107
|
+
|
108
|
+
scale.setFromMatrixScale(relativeMatrix);
|
109
|
+
relativeMatrix.scale(scale.set(1 / scale.x, 1 / scale.y, 1 / scale.z)); // apply to global matrix
|
110
|
+
|
111
|
+
globalMatrix.makeRotationFromQuaternion(quat.setFromRotationMatrix(relativeMatrix));
|
112
|
+
|
113
|
+
if (target.isObject3D) {
|
114
|
+
var boneIndex = bones.indexOf(bone),
|
115
|
+
wBindMatrix = bindBones ? bindBones[boneIndex] : bindBoneMatrix.copy(target.skeleton.boneInverses[boneIndex]).invert();
|
116
|
+
globalMatrix.multiply(wBindMatrix);
|
117
|
+
}
|
118
|
+
|
119
|
+
globalMatrix.copyPosition(relativeMatrix);
|
120
|
+
}
|
121
|
+
|
122
|
+
if (bone.parent && bone.parent.isBone) {
|
123
|
+
bone.matrix.copy(bone.parent.matrixWorld).invert();
|
124
|
+
bone.matrix.multiply(globalMatrix);
|
125
|
+
} else {
|
126
|
+
bone.matrix.copy(globalMatrix);
|
127
|
+
}
|
128
|
+
|
129
|
+
if (options.preserveHipPosition && name === options.hip) {
|
130
|
+
bone.matrix.setPosition(pos.set(0, bone.position.y, 0));
|
131
|
+
}
|
132
|
+
|
133
|
+
bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
|
134
|
+
bone.updateMatrixWorld();
|
135
|
+
}
|
136
|
+
|
137
|
+
if (options.preservePosition) {
|
138
|
+
for (var _i4 = 0; _i4 < bones.length; ++_i4) {
|
139
|
+
bone = bones[_i4];
|
140
|
+
name = options.names[bone.name] || bone.name;
|
141
|
+
|
142
|
+
if (name !== options.hip) {
|
143
|
+
bone.position.copy(bonesPosition[_i4]);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
if (options.preserveMatrix) {
|
149
|
+
// restore matrix
|
150
|
+
target.updateMatrixWorld(true);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
function retargetClip(target, source, clip) {
|
155
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
156
|
+
options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
|
157
|
+
options.fps = options.fps !== undefined ? options.fps : 30;
|
158
|
+
options.names = options.names || [];
|
159
|
+
|
160
|
+
if (!source.isObject3D) {
|
161
|
+
source = getHelperFromSkeleton(source);
|
162
|
+
}
|
163
|
+
|
164
|
+
var numFrames = Math.round(clip.duration * (options.fps / 1000) * 1000),
|
165
|
+
delta = 1 / options.fps,
|
166
|
+
convertedTracks = [],
|
167
|
+
mixer = new _three.AnimationMixer(source),
|
168
|
+
bones = getBones(target.skeleton),
|
169
|
+
boneDatas = [];
|
170
|
+
var positionOffset, bone, boneTo, boneData, name;
|
171
|
+
mixer.clipAction(clip).play();
|
172
|
+
mixer.update(0);
|
173
|
+
source.updateMatrixWorld();
|
174
|
+
|
175
|
+
for (var i = 0; i < numFrames; ++i) {
|
176
|
+
var time = i * delta;
|
177
|
+
retarget(target, source, options);
|
178
|
+
|
179
|
+
for (var j = 0; j < bones.length; ++j) {
|
180
|
+
name = options.names[bones[j].name] || bones[j].name;
|
181
|
+
boneTo = getBoneByName(name, source.skeleton);
|
182
|
+
|
183
|
+
if (boneTo) {
|
184
|
+
bone = bones[j];
|
185
|
+
boneData = boneDatas[j] = boneDatas[j] || {
|
186
|
+
bone: bone
|
187
|
+
};
|
188
|
+
|
189
|
+
if (options.hip === name) {
|
190
|
+
if (!boneData.pos) {
|
191
|
+
boneData.pos = {
|
192
|
+
times: new Float32Array(numFrames),
|
193
|
+
values: new Float32Array(numFrames * 3)
|
194
|
+
};
|
195
|
+
}
|
196
|
+
|
197
|
+
if (options.useFirstFramePosition) {
|
198
|
+
if (i === 0) {
|
199
|
+
positionOffset = bone.position.clone();
|
200
|
+
}
|
201
|
+
|
202
|
+
bone.position.sub(positionOffset);
|
203
|
+
}
|
204
|
+
|
205
|
+
boneData.pos.times[i] = time;
|
206
|
+
bone.position.toArray(boneData.pos.values, i * 3);
|
207
|
+
}
|
208
|
+
|
209
|
+
if (!boneData.quat) {
|
210
|
+
boneData.quat = {
|
211
|
+
times: new Float32Array(numFrames),
|
212
|
+
values: new Float32Array(numFrames * 4)
|
213
|
+
};
|
214
|
+
}
|
215
|
+
|
216
|
+
boneData.quat.times[i] = time;
|
217
|
+
bone.quaternion.toArray(boneData.quat.values, i * 4);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
mixer.update(delta);
|
222
|
+
source.updateMatrixWorld();
|
223
|
+
}
|
224
|
+
|
225
|
+
for (var _i5 = 0; _i5 < boneDatas.length; ++_i5) {
|
226
|
+
boneData = boneDatas[_i5];
|
227
|
+
|
228
|
+
if (boneData) {
|
229
|
+
if (boneData.pos) {
|
230
|
+
convertedTracks.push(new _three.VectorKeyframeTrack('.bones[' + boneData.bone.name + '].position', boneData.pos.times, boneData.pos.values));
|
231
|
+
}
|
232
|
+
|
233
|
+
convertedTracks.push(new _three.QuaternionKeyframeTrack('.bones[' + boneData.bone.name + '].quaternion', boneData.quat.times, boneData.quat.values));
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
mixer.uncacheAction(clip);
|
238
|
+
return new _three.AnimationClip(clip.name, -1, convertedTracks);
|
239
|
+
}
|
240
|
+
|
241
|
+
function getHelperFromSkeleton(skeleton) {
|
242
|
+
var source = new _three.SkeletonHelper(skeleton.bones[0]);
|
243
|
+
source.skeleton = skeleton;
|
244
|
+
return source;
|
245
|
+
}
|
246
|
+
|
247
|
+
function getSkeletonOffsets(target, source) {
|
248
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
249
|
+
var targetParentPos = new _three.Vector3(),
|
250
|
+
targetPos = new _three.Vector3(),
|
251
|
+
sourceParentPos = new _three.Vector3(),
|
252
|
+
sourcePos = new _three.Vector3(),
|
253
|
+
targetDir = new _three.Vector2(),
|
254
|
+
sourceDir = new _three.Vector2();
|
255
|
+
options.hip = options.hip !== undefined ? options.hip : 'hip';
|
256
|
+
options.names = options.names || {};
|
257
|
+
|
258
|
+
if (!source.isObject3D) {
|
259
|
+
source = getHelperFromSkeleton(source);
|
260
|
+
}
|
261
|
+
|
262
|
+
var nameKeys = Object.keys(options.names),
|
263
|
+
nameValues = Object.values(options.names),
|
264
|
+
sourceBones = source.isObject3D ? source.skeleton.bones : getBones(source),
|
265
|
+
bones = target.isObject3D ? target.skeleton.bones : getBones(target),
|
266
|
+
offsets = [];
|
267
|
+
var bone, boneTo, name, i;
|
268
|
+
target.skeleton.pose();
|
269
|
+
|
270
|
+
for (i = 0; i < bones.length; ++i) {
|
271
|
+
bone = bones[i];
|
272
|
+
name = options.names[bone.name] || bone.name;
|
273
|
+
boneTo = getBoneByName(name, sourceBones);
|
274
|
+
|
275
|
+
if (boneTo && name !== options.hip) {
|
276
|
+
var boneParent = getNearestBone(bone.parent, nameKeys),
|
277
|
+
boneToParent = getNearestBone(boneTo.parent, nameValues);
|
278
|
+
boneParent.updateMatrixWorld();
|
279
|
+
boneToParent.updateMatrixWorld();
|
280
|
+
targetParentPos.setFromMatrixPosition(boneParent.matrixWorld);
|
281
|
+
targetPos.setFromMatrixPosition(bone.matrixWorld);
|
282
|
+
sourceParentPos.setFromMatrixPosition(boneToParent.matrixWorld);
|
283
|
+
sourcePos.setFromMatrixPosition(boneTo.matrixWorld);
|
284
|
+
targetDir.subVectors(new _three.Vector2(targetPos.x, targetPos.y), new _three.Vector2(targetParentPos.x, targetParentPos.y)).normalize();
|
285
|
+
sourceDir.subVectors(new _three.Vector2(sourcePos.x, sourcePos.y), new _three.Vector2(sourceParentPos.x, sourceParentPos.y)).normalize();
|
286
|
+
var laterialAngle = targetDir.angle() - sourceDir.angle();
|
287
|
+
var offset = new _three.Matrix4().makeRotationFromEuler(new _three.Euler(0, 0, laterialAngle));
|
288
|
+
bone.matrix.multiply(offset);
|
289
|
+
bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
|
290
|
+
bone.updateMatrixWorld();
|
291
|
+
offsets[name] = offset;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
return offsets;
|
296
|
+
}
|
297
|
+
|
298
|
+
function renameBones(skeleton, names) {
|
299
|
+
var bones = getBones(skeleton);
|
300
|
+
|
301
|
+
for (var i = 0; i < bones.length; ++i) {
|
302
|
+
var bone = bones[i];
|
303
|
+
|
304
|
+
if (names[bone.name]) {
|
305
|
+
bone.name = names[bone.name];
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
return this;
|
310
|
+
}
|
311
|
+
|
312
|
+
function getBones(skeleton) {
|
313
|
+
return Array.isArray(skeleton) ? skeleton : skeleton.bones;
|
314
|
+
}
|
315
|
+
|
316
|
+
function getBoneByName(name, skeleton) {
|
317
|
+
for (var i = 0, bones = getBones(skeleton); i < bones.length; i++) {
|
318
|
+
if (name === bones[i].name) return bones[i];
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
function getNearestBone(bone, names) {
|
323
|
+
while (bone.isBone) {
|
324
|
+
if (names.indexOf(bone.name) !== -1) {
|
325
|
+
return bone;
|
326
|
+
}
|
327
|
+
|
328
|
+
bone = bone.parent;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
function findBoneTrackData(name, tracks) {
|
333
|
+
var regexp = /\[(.*)\]\.(.*)/,
|
334
|
+
result = {
|
335
|
+
name: name
|
336
|
+
};
|
337
|
+
|
338
|
+
for (var i = 0; i < tracks.length; ++i) {
|
339
|
+
// 1 is track name
|
340
|
+
// 2 is track type
|
341
|
+
var trackData = regexp.exec(tracks[i].name);
|
342
|
+
|
343
|
+
if (trackData && name === trackData[1]) {
|
344
|
+
result[trackData[2]] = i;
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
return result;
|
349
|
+
}
|
350
|
+
|
351
|
+
function getEqualsBonesNames(skeleton, targetSkeleton) {
|
352
|
+
var sourceBones = getBones(skeleton),
|
353
|
+
targetBones = getBones(targetSkeleton),
|
354
|
+
bones = [];
|
355
|
+
|
356
|
+
search: for (var i = 0; i < sourceBones.length; i++) {
|
357
|
+
var boneName = sourceBones[i].name;
|
358
|
+
|
359
|
+
for (var j = 0; j < targetBones.length; j++) {
|
360
|
+
if (boneName === targetBones[j].name) {
|
361
|
+
bones.push(boneName);
|
362
|
+
continue search;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
return bones;
|
368
|
+
}
|
369
|
+
|
370
|
+
function clone(source) {
|
371
|
+
var sourceLookup = new Map();
|
372
|
+
var cloneLookup = new Map();
|
373
|
+
var clone = source.clone();
|
374
|
+
parallelTraverse(source, clone, function (sourceNode, clonedNode) {
|
375
|
+
sourceLookup.set(clonedNode, sourceNode);
|
376
|
+
cloneLookup.set(sourceNode, clonedNode);
|
377
|
+
});
|
378
|
+
clone.traverse(function (node) {
|
379
|
+
if (!node.isSkinnedMesh) return;
|
380
|
+
var clonedMesh = node;
|
381
|
+
var sourceMesh = sourceLookup.get(node);
|
382
|
+
var sourceBones = sourceMesh.skeleton.bones;
|
383
|
+
clonedMesh.skeleton = sourceMesh.skeleton.clone();
|
384
|
+
clonedMesh.bindMatrix.copy(sourceMesh.bindMatrix);
|
385
|
+
clonedMesh.skeleton.bones = sourceBones.map(function (bone) {
|
386
|
+
return cloneLookup.get(bone);
|
387
|
+
});
|
388
|
+
clonedMesh.bind(clonedMesh.skeleton, clonedMesh.bindMatrix);
|
389
|
+
});
|
390
|
+
return clone;
|
391
|
+
}
|
392
|
+
|
393
|
+
function parallelTraverse(a, b, callback) {
|
394
|
+
callback(a, b);
|
395
|
+
|
396
|
+
for (var i = 0; i < a.children.length; i++) {
|
397
|
+
parallelTraverse(a.children[i], b.children[i], callback);
|
398
|
+
}
|
399
|
+
}
|
400
|
+
});
|
@@ -0,0 +1,132 @@
|
|
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.UVsDebug = 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.UVsDebug = UVsDebug;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* tool for "unwrapping" and debugging three.js geometries UV mapping
|
23
|
+
*
|
24
|
+
* Sample usage:
|
25
|
+
* document.body.appendChild( UVsDebug( new THREE.SphereGeometry( 10, 10, 10, 10 ) );
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
function UVsDebug(geometry) {
|
29
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1024;
|
30
|
+
// handles wrapping of uv.x > 1 only
|
31
|
+
var abc = 'abc';
|
32
|
+
var a = new _three.Vector2();
|
33
|
+
var b = new _three.Vector2();
|
34
|
+
var uvs = [new _three.Vector2(), new _three.Vector2(), new _three.Vector2()];
|
35
|
+
var face = [];
|
36
|
+
var canvas = document.createElement('canvas');
|
37
|
+
var width = size; // power of 2 required for wrapping
|
38
|
+
|
39
|
+
var height = size;
|
40
|
+
canvas.width = width;
|
41
|
+
canvas.height = height;
|
42
|
+
var ctx = canvas.getContext('2d');
|
43
|
+
ctx.lineWidth = 1;
|
44
|
+
ctx.strokeStyle = 'rgb( 63, 63, 63 )';
|
45
|
+
ctx.textAlign = 'center'; // paint background white
|
46
|
+
|
47
|
+
ctx.fillStyle = 'rgb( 255, 255, 255 )';
|
48
|
+
ctx.fillRect(0, 0, width, height);
|
49
|
+
|
50
|
+
if (geometry.isGeometry) {
|
51
|
+
console.error('THREE.UVsDebug no longer supports Geometry. Use THREE.BufferGeometry instead.');
|
52
|
+
return;
|
53
|
+
} else {
|
54
|
+
var index = geometry.index;
|
55
|
+
var uvAttribute = geometry.attributes.uv;
|
56
|
+
|
57
|
+
if (index) {
|
58
|
+
// indexed geometry
|
59
|
+
for (var i = 0, il = index.count; i < il; i += 3) {
|
60
|
+
face[0] = index.getX(i);
|
61
|
+
face[1] = index.getX(i + 1);
|
62
|
+
face[2] = index.getX(i + 2);
|
63
|
+
uvs[0].fromBufferAttribute(uvAttribute, face[0]);
|
64
|
+
uvs[1].fromBufferAttribute(uvAttribute, face[1]);
|
65
|
+
uvs[2].fromBufferAttribute(uvAttribute, face[2]);
|
66
|
+
processFace(face, uvs, i / 3);
|
67
|
+
}
|
68
|
+
} else {
|
69
|
+
// non-indexed geometry
|
70
|
+
for (var _i = 0, _il = uvAttribute.count; _i < _il; _i += 3) {
|
71
|
+
face[0] = _i;
|
72
|
+
face[1] = _i + 1;
|
73
|
+
face[2] = _i + 2;
|
74
|
+
uvs[0].fromBufferAttribute(uvAttribute, face[0]);
|
75
|
+
uvs[1].fromBufferAttribute(uvAttribute, face[1]);
|
76
|
+
uvs[2].fromBufferAttribute(uvAttribute, face[2]);
|
77
|
+
processFace(face, uvs, _i / 3);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
return canvas;
|
83
|
+
|
84
|
+
function processFace(face, uvs, index) {
|
85
|
+
// draw contour of face
|
86
|
+
ctx.beginPath();
|
87
|
+
a.set(0, 0);
|
88
|
+
|
89
|
+
for (var j = 0, jl = uvs.length; j < jl; j++) {
|
90
|
+
var uv = uvs[j];
|
91
|
+
a.x += uv.x;
|
92
|
+
a.y += uv.y;
|
93
|
+
|
94
|
+
if (j === 0) {
|
95
|
+
ctx.moveTo(uv.x * (width - 2) + 0.5, (1 - uv.y) * (height - 2) + 0.5);
|
96
|
+
} else {
|
97
|
+
ctx.lineTo(uv.x * (width - 2) + 0.5, (1 - uv.y) * (height - 2) + 0.5);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
ctx.closePath();
|
102
|
+
ctx.stroke(); // calculate center of face
|
103
|
+
|
104
|
+
a.divideScalar(uvs.length); // label the face number
|
105
|
+
|
106
|
+
ctx.font = '18px Arial';
|
107
|
+
ctx.fillStyle = 'rgb( 63, 63, 63 )';
|
108
|
+
ctx.fillText(index, a.x * width, (1 - a.y) * height);
|
109
|
+
|
110
|
+
if (a.x > 0.95) {
|
111
|
+
// wrap x // 0.95 is arbitrary
|
112
|
+
ctx.fillText(index, a.x % 1 * width, (1 - a.y) * height);
|
113
|
+
} //
|
114
|
+
|
115
|
+
|
116
|
+
ctx.font = '12px Arial';
|
117
|
+
ctx.fillStyle = 'rgb( 191, 191, 191 )'; // label uv edge orders
|
118
|
+
|
119
|
+
for (var _j = 0, _jl = uvs.length; _j < _jl; _j++) {
|
120
|
+
var _uv = uvs[_j];
|
121
|
+
b.addVectors(a, _uv).divideScalar(2);
|
122
|
+
var vnum = face[_j];
|
123
|
+
ctx.fillText(abc[_j] + vnum, b.x * width, (1 - b.y) * height);
|
124
|
+
|
125
|
+
if (b.x > 0.95) {
|
126
|
+
// wrap x
|
127
|
+
ctx.fillText(abc[_j] + vnum, b.x % 1 * width, (1 - b.y) * height);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
});
|
@@ -0,0 +1,130 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports);
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports);
|
11
|
+
global.WorkerPool = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(_exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
_exports.WorkerPool = void 0;
|
20
|
+
|
21
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
22
|
+
|
23
|
+
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); } }
|
24
|
+
|
25
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
26
|
+
|
27
|
+
/**
|
28
|
+
* @author Deepkolos / https://github.com/deepkolos
|
29
|
+
*/
|
30
|
+
var WorkerPool = /*#__PURE__*/function () {
|
31
|
+
function WorkerPool() {
|
32
|
+
var pool = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
33
|
+
|
34
|
+
_classCallCheck(this, WorkerPool);
|
35
|
+
|
36
|
+
this.pool = pool;
|
37
|
+
this.queue = [];
|
38
|
+
this.workers = [];
|
39
|
+
this.workersResolve = [];
|
40
|
+
this.workerStatus = 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
_createClass(WorkerPool, [{
|
44
|
+
key: "_initWorker",
|
45
|
+
value: function _initWorker(workerId) {
|
46
|
+
if (!this.workers[workerId]) {
|
47
|
+
var worker = this.workerCreator();
|
48
|
+
worker.addEventListener('message', this._onMessage.bind(this, workerId));
|
49
|
+
this.workers[workerId] = worker;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}, {
|
53
|
+
key: "_getIdleWorker",
|
54
|
+
value: function _getIdleWorker() {
|
55
|
+
for (var i = 0; i < this.pool; i++) {
|
56
|
+
if (!(this.workerStatus & 1 << i)) return i;
|
57
|
+
}
|
58
|
+
|
59
|
+
return -1;
|
60
|
+
}
|
61
|
+
}, {
|
62
|
+
key: "_onMessage",
|
63
|
+
value: function _onMessage(workerId, msg) {
|
64
|
+
var resolve = this.workersResolve[workerId];
|
65
|
+
resolve && resolve(msg);
|
66
|
+
|
67
|
+
if (this.queue.length) {
|
68
|
+
var _this$queue$shift = this.queue.shift(),
|
69
|
+
_resolve = _this$queue$shift.resolve,
|
70
|
+
_msg = _this$queue$shift.msg,
|
71
|
+
transfer = _this$queue$shift.transfer;
|
72
|
+
|
73
|
+
this.workersResolve[workerId] = _resolve;
|
74
|
+
this.workers[workerId].postMessage(_msg, transfer);
|
75
|
+
} else {
|
76
|
+
this.workerStatus ^= 1 << workerId;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}, {
|
80
|
+
key: "setWorkerCreator",
|
81
|
+
value: function setWorkerCreator(workerCreator) {
|
82
|
+
this.workerCreator = workerCreator;
|
83
|
+
}
|
84
|
+
}, {
|
85
|
+
key: "setWorkerLimit",
|
86
|
+
value: function setWorkerLimit(pool) {
|
87
|
+
this.pool = pool;
|
88
|
+
}
|
89
|
+
}, {
|
90
|
+
key: "postMessage",
|
91
|
+
value: function postMessage(msg, transfer) {
|
92
|
+
var _this = this;
|
93
|
+
|
94
|
+
return new Promise(function (resolve) {
|
95
|
+
var workerId = _this._getIdleWorker();
|
96
|
+
|
97
|
+
if (workerId !== -1) {
|
98
|
+
_this._initWorker(workerId);
|
99
|
+
|
100
|
+
_this.workerStatus |= 1 << workerId;
|
101
|
+
_this.workersResolve[workerId] = resolve;
|
102
|
+
|
103
|
+
_this.workers[workerId].postMessage(msg, transfer);
|
104
|
+
} else {
|
105
|
+
_this.queue.push({
|
106
|
+
resolve: resolve,
|
107
|
+
msg: msg,
|
108
|
+
transfer: transfer
|
109
|
+
});
|
110
|
+
}
|
111
|
+
});
|
112
|
+
}
|
113
|
+
}, {
|
114
|
+
key: "dispose",
|
115
|
+
value: function dispose() {
|
116
|
+
this.workers.forEach(function (worker) {
|
117
|
+
return worker.terminate();
|
118
|
+
});
|
119
|
+
this.workersResolve.length = 0;
|
120
|
+
this.workers.length = 0;
|
121
|
+
this.queue.length = 0;
|
122
|
+
this.workerStatus = 0;
|
123
|
+
}
|
124
|
+
}]);
|
125
|
+
|
126
|
+
return WorkerPool;
|
127
|
+
}();
|
128
|
+
|
129
|
+
_exports.WorkerPool = WorkerPool;
|
130
|
+
});
|