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,468 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "three", "./PackedPhongMaterial.js"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("three"), require("./PackedPhongMaterial.js"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.three, global.PackedPhongMaterial);
|
11
|
+
global.GeometryCompressionUtils = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three, _PackedPhongMaterial) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(_exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
_exports.compressNormals = compressNormals;
|
20
|
+
_exports.compressPositions = compressPositions;
|
21
|
+
_exports.compressUvs = compressUvs;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Octahedron and Quantization encodings based on work by:
|
25
|
+
*
|
26
|
+
* @link https://github.com/tsherif/mesh-quantization-example
|
27
|
+
*
|
28
|
+
*/
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Make the input mesh.geometry's normal attribute encoded and compressed by 3 different methods.
|
32
|
+
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the normal data.
|
33
|
+
*
|
34
|
+
* @param {THREE.Mesh} mesh
|
35
|
+
* @param {String} encodeMethod "DEFAULT" || "OCT1Byte" || "OCT2Byte" || "ANGLES"
|
36
|
+
*
|
37
|
+
*/
|
38
|
+
function compressNormals(mesh, encodeMethod) {
|
39
|
+
if (!mesh.geometry) {
|
40
|
+
console.error('Mesh must contain geometry. ');
|
41
|
+
}
|
42
|
+
|
43
|
+
var normal = mesh.geometry.attributes.normal;
|
44
|
+
|
45
|
+
if (!normal) {
|
46
|
+
console.error('Geometry must contain normal attribute. ');
|
47
|
+
}
|
48
|
+
|
49
|
+
if (normal.isPacked) return;
|
50
|
+
|
51
|
+
if (normal.itemSize != 3) {
|
52
|
+
console.error('normal.itemSize is not 3, which cannot be encoded. ');
|
53
|
+
}
|
54
|
+
|
55
|
+
var array = normal.array;
|
56
|
+
var count = normal.count;
|
57
|
+
var result;
|
58
|
+
|
59
|
+
if (encodeMethod == 'DEFAULT') {
|
60
|
+
// TODO: Add 1 byte to the result, making the encoded length to be 4 bytes.
|
61
|
+
result = new Uint8Array(count * 3);
|
62
|
+
|
63
|
+
for (var idx = 0; idx < array.length; idx += 3) {
|
64
|
+
var encoded = defaultEncode(array[idx], array[idx + 1], array[idx + 2], 1);
|
65
|
+
result[idx + 0] = encoded[0];
|
66
|
+
result[idx + 1] = encoded[1];
|
67
|
+
result[idx + 2] = encoded[2];
|
68
|
+
}
|
69
|
+
|
70
|
+
mesh.geometry.setAttribute('normal', new _three.BufferAttribute(result, 3, true));
|
71
|
+
mesh.geometry.attributes.normal.bytes = result.length * 1;
|
72
|
+
} else if (encodeMethod == 'OCT1Byte') {
|
73
|
+
/**
|
74
|
+
* It is not recommended to use 1-byte octahedron normals encoding unless you want to extremely reduce the memory usage
|
75
|
+
* As it makes vertex data not aligned to a 4 byte boundary which may harm some WebGL implementations and sometimes the normal distortion is visible
|
76
|
+
* Please refer to @zeux 's comments in https://github.com/mrdoob/three.js/pull/18208
|
77
|
+
*/
|
78
|
+
result = new Int8Array(count * 2);
|
79
|
+
|
80
|
+
for (var _idx = 0; _idx < array.length; _idx += 3) {
|
81
|
+
var _encoded = octEncodeBest(array[_idx], array[_idx + 1], array[_idx + 2], 1);
|
82
|
+
|
83
|
+
result[_idx / 3 * 2 + 0] = _encoded[0];
|
84
|
+
result[_idx / 3 * 2 + 1] = _encoded[1];
|
85
|
+
}
|
86
|
+
|
87
|
+
mesh.geometry.setAttribute('normal', new _three.BufferAttribute(result, 2, true));
|
88
|
+
mesh.geometry.attributes.normal.bytes = result.length * 1;
|
89
|
+
} else if (encodeMethod == 'OCT2Byte') {
|
90
|
+
result = new Int16Array(count * 2);
|
91
|
+
|
92
|
+
for (var _idx2 = 0; _idx2 < array.length; _idx2 += 3) {
|
93
|
+
var _encoded2 = octEncodeBest(array[_idx2], array[_idx2 + 1], array[_idx2 + 2], 2);
|
94
|
+
|
95
|
+
result[_idx2 / 3 * 2 + 0] = _encoded2[0];
|
96
|
+
result[_idx2 / 3 * 2 + 1] = _encoded2[1];
|
97
|
+
}
|
98
|
+
|
99
|
+
mesh.geometry.setAttribute('normal', new _three.BufferAttribute(result, 2, true));
|
100
|
+
mesh.geometry.attributes.normal.bytes = result.length * 2;
|
101
|
+
} else if (encodeMethod == 'ANGLES') {
|
102
|
+
result = new Uint16Array(count * 2);
|
103
|
+
|
104
|
+
for (var _idx3 = 0; _idx3 < array.length; _idx3 += 3) {
|
105
|
+
var _encoded3 = anglesEncode(array[_idx3], array[_idx3 + 1], array[_idx3 + 2]);
|
106
|
+
|
107
|
+
result[_idx3 / 3 * 2 + 0] = _encoded3[0];
|
108
|
+
result[_idx3 / 3 * 2 + 1] = _encoded3[1];
|
109
|
+
}
|
110
|
+
|
111
|
+
mesh.geometry.setAttribute('normal', new _three.BufferAttribute(result, 2, true));
|
112
|
+
mesh.geometry.attributes.normal.bytes = result.length * 2;
|
113
|
+
} else {
|
114
|
+
console.error('Unrecognized encoding method, should be `DEFAULT` or `ANGLES` or `OCT`. ');
|
115
|
+
}
|
116
|
+
|
117
|
+
mesh.geometry.attributes.normal.needsUpdate = true;
|
118
|
+
mesh.geometry.attributes.normal.isPacked = true;
|
119
|
+
mesh.geometry.attributes.normal.packingMethod = encodeMethod; // modify material
|
120
|
+
|
121
|
+
if (!(mesh.material instanceof _PackedPhongMaterial.PackedPhongMaterial)) {
|
122
|
+
mesh.material = new _PackedPhongMaterial.PackedPhongMaterial().copy(mesh.material);
|
123
|
+
}
|
124
|
+
|
125
|
+
if (encodeMethod == 'ANGLES') {
|
126
|
+
mesh.material.defines.USE_PACKED_NORMAL = 0;
|
127
|
+
}
|
128
|
+
|
129
|
+
if (encodeMethod == 'OCT1Byte') {
|
130
|
+
mesh.material.defines.USE_PACKED_NORMAL = 1;
|
131
|
+
}
|
132
|
+
|
133
|
+
if (encodeMethod == 'OCT2Byte') {
|
134
|
+
mesh.material.defines.USE_PACKED_NORMAL = 1;
|
135
|
+
}
|
136
|
+
|
137
|
+
if (encodeMethod == 'DEFAULT') {
|
138
|
+
mesh.material.defines.USE_PACKED_NORMAL = 2;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
/**
|
142
|
+
* Make the input mesh.geometry's position attribute encoded and compressed.
|
143
|
+
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the position data.
|
144
|
+
*
|
145
|
+
* @param {THREE.Mesh} mesh
|
146
|
+
*
|
147
|
+
*/
|
148
|
+
|
149
|
+
|
150
|
+
function compressPositions(mesh) {
|
151
|
+
if (!mesh.geometry) {
|
152
|
+
console.error('Mesh must contain geometry. ');
|
153
|
+
}
|
154
|
+
|
155
|
+
var position = mesh.geometry.attributes.position;
|
156
|
+
|
157
|
+
if (!position) {
|
158
|
+
console.error('Geometry must contain position attribute. ');
|
159
|
+
}
|
160
|
+
|
161
|
+
if (position.isPacked) return;
|
162
|
+
|
163
|
+
if (position.itemSize != 3) {
|
164
|
+
console.error('position.itemSize is not 3, which cannot be packed. ');
|
165
|
+
}
|
166
|
+
|
167
|
+
var array = position.array;
|
168
|
+
var encodingBytes = 2;
|
169
|
+
var result = quantizedEncode(array, encodingBytes);
|
170
|
+
var quantized = result.quantized;
|
171
|
+
var decodeMat = result.decodeMat; // IMPORTANT: calculate original geometry bounding info first, before updating packed positions
|
172
|
+
|
173
|
+
if (mesh.geometry.boundingBox == null) mesh.geometry.computeBoundingBox();
|
174
|
+
if (mesh.geometry.boundingSphere == null) mesh.geometry.computeBoundingSphere();
|
175
|
+
mesh.geometry.setAttribute('position', new _three.BufferAttribute(quantized, 3));
|
176
|
+
mesh.geometry.attributes.position.isPacked = true;
|
177
|
+
mesh.geometry.attributes.position.needsUpdate = true;
|
178
|
+
mesh.geometry.attributes.position.bytes = quantized.length * encodingBytes; // modify material
|
179
|
+
|
180
|
+
if (!(mesh.material instanceof _PackedPhongMaterial.PackedPhongMaterial)) {
|
181
|
+
mesh.material = new _PackedPhongMaterial.PackedPhongMaterial().copy(mesh.material);
|
182
|
+
}
|
183
|
+
|
184
|
+
mesh.material.defines.USE_PACKED_POSITION = 0;
|
185
|
+
mesh.material.uniforms.quantizeMatPos.value = decodeMat;
|
186
|
+
mesh.material.uniforms.quantizeMatPos.needsUpdate = true;
|
187
|
+
}
|
188
|
+
/**
|
189
|
+
* Make the input mesh.geometry's uv attribute encoded and compressed.
|
190
|
+
* Also will change the mesh.material to `PackedPhongMaterial` which let the vertex shader program decode the uv data.
|
191
|
+
*
|
192
|
+
* @param {THREE.Mesh} mesh
|
193
|
+
*
|
194
|
+
*/
|
195
|
+
|
196
|
+
|
197
|
+
function compressUvs(mesh) {
|
198
|
+
if (!mesh.geometry) {
|
199
|
+
console.error('Mesh must contain geometry property. ');
|
200
|
+
}
|
201
|
+
|
202
|
+
var uvs = mesh.geometry.attributes.uv;
|
203
|
+
|
204
|
+
if (!uvs) {
|
205
|
+
console.error('Geometry must contain uv attribute. ');
|
206
|
+
}
|
207
|
+
|
208
|
+
if (uvs.isPacked) return;
|
209
|
+
var range = {
|
210
|
+
min: Infinity,
|
211
|
+
max: -Infinity
|
212
|
+
};
|
213
|
+
var array = uvs.array;
|
214
|
+
|
215
|
+
for (var i = 0; i < array.length; i++) {
|
216
|
+
range.min = Math.min(range.min, array[i]);
|
217
|
+
range.max = Math.max(range.max, array[i]);
|
218
|
+
}
|
219
|
+
|
220
|
+
var result;
|
221
|
+
|
222
|
+
if (range.min >= -1.0 && range.max <= 1.0) {
|
223
|
+
// use default encoding method
|
224
|
+
result = new Uint16Array(array.length);
|
225
|
+
|
226
|
+
for (var _i = 0; _i < array.length; _i += 2) {
|
227
|
+
var encoded = defaultEncode(array[_i], array[_i + 1], 0, 2);
|
228
|
+
result[_i] = encoded[0];
|
229
|
+
result[_i + 1] = encoded[1];
|
230
|
+
}
|
231
|
+
|
232
|
+
mesh.geometry.setAttribute('uv', new _three.BufferAttribute(result, 2, true));
|
233
|
+
mesh.geometry.attributes.uv.isPacked = true;
|
234
|
+
mesh.geometry.attributes.uv.needsUpdate = true;
|
235
|
+
mesh.geometry.attributes.uv.bytes = result.length * 2;
|
236
|
+
|
237
|
+
if (!(mesh.material instanceof _PackedPhongMaterial.PackedPhongMaterial)) {
|
238
|
+
mesh.material = new _PackedPhongMaterial.PackedPhongMaterial().copy(mesh.material);
|
239
|
+
}
|
240
|
+
|
241
|
+
mesh.material.defines.USE_PACKED_UV = 0;
|
242
|
+
} else {
|
243
|
+
// use quantized encoding method
|
244
|
+
result = quantizedEncodeUV(array, 2);
|
245
|
+
mesh.geometry.setAttribute('uv', new _three.BufferAttribute(result.quantized, 2));
|
246
|
+
mesh.geometry.attributes.uv.isPacked = true;
|
247
|
+
mesh.geometry.attributes.uv.needsUpdate = true;
|
248
|
+
mesh.geometry.attributes.uv.bytes = result.quantized.length * 2;
|
249
|
+
|
250
|
+
if (!(mesh.material instanceof _PackedPhongMaterial.PackedPhongMaterial)) {
|
251
|
+
mesh.material = new _PackedPhongMaterial.PackedPhongMaterial().copy(mesh.material);
|
252
|
+
}
|
253
|
+
|
254
|
+
mesh.material.defines.USE_PACKED_UV = 1;
|
255
|
+
mesh.material.uniforms.quantizeMatUV.value = result.decodeMat;
|
256
|
+
mesh.material.uniforms.quantizeMatUV.needsUpdate = true;
|
257
|
+
}
|
258
|
+
} // Encoding functions
|
259
|
+
|
260
|
+
|
261
|
+
function defaultEncode(x, y, z, bytes) {
|
262
|
+
if (bytes == 1) {
|
263
|
+
var tmpx = Math.round((x + 1) * 0.5 * 255);
|
264
|
+
var tmpy = Math.round((y + 1) * 0.5 * 255);
|
265
|
+
var tmpz = Math.round((z + 1) * 0.5 * 255);
|
266
|
+
return new Uint8Array([tmpx, tmpy, tmpz]);
|
267
|
+
} else if (bytes == 2) {
|
268
|
+
var _tmpx = Math.round((x + 1) * 0.5 * 65535);
|
269
|
+
|
270
|
+
var _tmpy = Math.round((y + 1) * 0.5 * 65535);
|
271
|
+
|
272
|
+
var _tmpz = Math.round((z + 1) * 0.5 * 65535);
|
273
|
+
|
274
|
+
return new Uint16Array([_tmpx, _tmpy, _tmpz]);
|
275
|
+
} else {
|
276
|
+
console.error('number of bytes must be 1 or 2');
|
277
|
+
}
|
278
|
+
} // for `Angles` encoding
|
279
|
+
|
280
|
+
|
281
|
+
function anglesEncode(x, y, z) {
|
282
|
+
var normal0 = parseInt(0.5 * (1.0 + Math.atan2(y, x) / Math.PI) * 65535);
|
283
|
+
var normal1 = parseInt(0.5 * (1.0 + z) * 65535);
|
284
|
+
return new Uint16Array([normal0, normal1]);
|
285
|
+
} // for `Octahedron` encoding
|
286
|
+
|
287
|
+
|
288
|
+
function octEncodeBest(x, y, z, bytes) {
|
289
|
+
var oct, dec, best, currentCos, bestCos; // Test various combinations of ceil and floor
|
290
|
+
// to minimize rounding errors
|
291
|
+
|
292
|
+
best = oct = octEncodeVec3(x, y, z, 'floor', 'floor');
|
293
|
+
dec = octDecodeVec2(oct);
|
294
|
+
bestCos = dot(x, y, z, dec);
|
295
|
+
oct = octEncodeVec3(x, y, z, 'ceil', 'floor');
|
296
|
+
dec = octDecodeVec2(oct);
|
297
|
+
currentCos = dot(x, y, z, dec);
|
298
|
+
|
299
|
+
if (currentCos > bestCos) {
|
300
|
+
best = oct;
|
301
|
+
bestCos = currentCos;
|
302
|
+
}
|
303
|
+
|
304
|
+
oct = octEncodeVec3(x, y, z, 'floor', 'ceil');
|
305
|
+
dec = octDecodeVec2(oct);
|
306
|
+
currentCos = dot(x, y, z, dec);
|
307
|
+
|
308
|
+
if (currentCos > bestCos) {
|
309
|
+
best = oct;
|
310
|
+
bestCos = currentCos;
|
311
|
+
}
|
312
|
+
|
313
|
+
oct = octEncodeVec3(x, y, z, 'ceil', 'ceil');
|
314
|
+
dec = octDecodeVec2(oct);
|
315
|
+
currentCos = dot(x, y, z, dec);
|
316
|
+
|
317
|
+
if (currentCos > bestCos) {
|
318
|
+
best = oct;
|
319
|
+
}
|
320
|
+
|
321
|
+
return best;
|
322
|
+
|
323
|
+
function octEncodeVec3(x0, y0, z0, xfunc, yfunc) {
|
324
|
+
var x = x0 / (Math.abs(x0) + Math.abs(y0) + Math.abs(z0));
|
325
|
+
var y = y0 / (Math.abs(x0) + Math.abs(y0) + Math.abs(z0));
|
326
|
+
|
327
|
+
if (z < 0) {
|
328
|
+
var tempx = (1 - Math.abs(y)) * (x >= 0 ? 1 : -1);
|
329
|
+
var tempy = (1 - Math.abs(x)) * (y >= 0 ? 1 : -1);
|
330
|
+
x = tempx;
|
331
|
+
y = tempy;
|
332
|
+
var diff = 1 - Math.abs(x) - Math.abs(y);
|
333
|
+
|
334
|
+
if (diff > 0) {
|
335
|
+
diff += 0.001;
|
336
|
+
x += x > 0 ? diff / 2 : -diff / 2;
|
337
|
+
y += y > 0 ? diff / 2 : -diff / 2;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
if (bytes == 1) {
|
342
|
+
return new Int8Array([Math[xfunc](x * 127.5 + (x < 0 ? 1 : 0)), Math[yfunc](y * 127.5 + (y < 0 ? 1 : 0))]);
|
343
|
+
}
|
344
|
+
|
345
|
+
if (bytes == 2) {
|
346
|
+
return new Int16Array([Math[xfunc](x * 32767.5 + (x < 0 ? 1 : 0)), Math[yfunc](y * 32767.5 + (y < 0 ? 1 : 0))]);
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
function octDecodeVec2(oct) {
|
351
|
+
var x = oct[0];
|
352
|
+
var y = oct[1];
|
353
|
+
|
354
|
+
if (bytes == 1) {
|
355
|
+
x /= x < 0 ? 127 : 128;
|
356
|
+
y /= y < 0 ? 127 : 128;
|
357
|
+
} else if (bytes == 2) {
|
358
|
+
x /= x < 0 ? 32767 : 32768;
|
359
|
+
y /= y < 0 ? 32767 : 32768;
|
360
|
+
}
|
361
|
+
|
362
|
+
var z = 1 - Math.abs(x) - Math.abs(y);
|
363
|
+
|
364
|
+
if (z < 0) {
|
365
|
+
var tmpx = x;
|
366
|
+
x = (1 - Math.abs(y)) * (x >= 0 ? 1 : -1);
|
367
|
+
y = (1 - Math.abs(tmpx)) * (y >= 0 ? 1 : -1);
|
368
|
+
}
|
369
|
+
|
370
|
+
var length = Math.sqrt(x * x + y * y + z * z);
|
371
|
+
return [x / length, y / length, z / length];
|
372
|
+
}
|
373
|
+
|
374
|
+
function dot(x, y, z, vec3) {
|
375
|
+
return x * vec3[0] + y * vec3[1] + z * vec3[2];
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
function quantizedEncode(array, bytes) {
|
380
|
+
var quantized, segments;
|
381
|
+
|
382
|
+
if (bytes == 1) {
|
383
|
+
quantized = new Uint8Array(array.length);
|
384
|
+
segments = 255;
|
385
|
+
} else if (bytes == 2) {
|
386
|
+
quantized = new Uint16Array(array.length);
|
387
|
+
segments = 65535;
|
388
|
+
} else {
|
389
|
+
console.error('number of bytes error! ');
|
390
|
+
}
|
391
|
+
|
392
|
+
var decodeMat = new _three.Matrix4();
|
393
|
+
var min = new Float32Array(3);
|
394
|
+
var max = new Float32Array(3);
|
395
|
+
min[0] = min[1] = min[2] = Number.MAX_VALUE;
|
396
|
+
max[0] = max[1] = max[2] = -Number.MAX_VALUE;
|
397
|
+
|
398
|
+
for (var i = 0; i < array.length; i += 3) {
|
399
|
+
min[0] = Math.min(min[0], array[i + 0]);
|
400
|
+
min[1] = Math.min(min[1], array[i + 1]);
|
401
|
+
min[2] = Math.min(min[2], array[i + 2]);
|
402
|
+
max[0] = Math.max(max[0], array[i + 0]);
|
403
|
+
max[1] = Math.max(max[1], array[i + 1]);
|
404
|
+
max[2] = Math.max(max[2], array[i + 2]);
|
405
|
+
}
|
406
|
+
|
407
|
+
decodeMat.scale(new _three.Vector3((max[0] - min[0]) / segments, (max[1] - min[1]) / segments, (max[2] - min[2]) / segments));
|
408
|
+
decodeMat.elements[12] = min[0];
|
409
|
+
decodeMat.elements[13] = min[1];
|
410
|
+
decodeMat.elements[14] = min[2];
|
411
|
+
decodeMat.transpose();
|
412
|
+
var multiplier = new Float32Array([max[0] !== min[0] ? segments / (max[0] - min[0]) : 0, max[1] !== min[1] ? segments / (max[1] - min[1]) : 0, max[2] !== min[2] ? segments / (max[2] - min[2]) : 0]);
|
413
|
+
|
414
|
+
for (var _i2 = 0; _i2 < array.length; _i2 += 3) {
|
415
|
+
quantized[_i2 + 0] = Math.floor((array[_i2 + 0] - min[0]) * multiplier[0]);
|
416
|
+
quantized[_i2 + 1] = Math.floor((array[_i2 + 1] - min[1]) * multiplier[1]);
|
417
|
+
quantized[_i2 + 2] = Math.floor((array[_i2 + 2] - min[2]) * multiplier[2]);
|
418
|
+
}
|
419
|
+
|
420
|
+
return {
|
421
|
+
quantized: quantized,
|
422
|
+
decodeMat: decodeMat
|
423
|
+
};
|
424
|
+
}
|
425
|
+
|
426
|
+
function quantizedEncodeUV(array, bytes) {
|
427
|
+
var quantized, segments;
|
428
|
+
|
429
|
+
if (bytes == 1) {
|
430
|
+
quantized = new Uint8Array(array.length);
|
431
|
+
segments = 255;
|
432
|
+
} else if (bytes == 2) {
|
433
|
+
quantized = new Uint16Array(array.length);
|
434
|
+
segments = 65535;
|
435
|
+
} else {
|
436
|
+
console.error('number of bytes error! ');
|
437
|
+
}
|
438
|
+
|
439
|
+
var decodeMat = new _three.Matrix3();
|
440
|
+
var min = new Float32Array(2);
|
441
|
+
var max = new Float32Array(2);
|
442
|
+
min[0] = min[1] = Number.MAX_VALUE;
|
443
|
+
max[0] = max[1] = -Number.MAX_VALUE;
|
444
|
+
|
445
|
+
for (var i = 0; i < array.length; i += 2) {
|
446
|
+
min[0] = Math.min(min[0], array[i + 0]);
|
447
|
+
min[1] = Math.min(min[1], array[i + 1]);
|
448
|
+
max[0] = Math.max(max[0], array[i + 0]);
|
449
|
+
max[1] = Math.max(max[1], array[i + 1]);
|
450
|
+
}
|
451
|
+
|
452
|
+
decodeMat.scale((max[0] - min[0]) / segments, (max[1] - min[1]) / segments);
|
453
|
+
decodeMat.elements[6] = min[0];
|
454
|
+
decodeMat.elements[7] = min[1];
|
455
|
+
decodeMat.transpose();
|
456
|
+
var multiplier = new Float32Array([max[0] !== min[0] ? segments / (max[0] - min[0]) : 0, max[1] !== min[1] ? segments / (max[1] - min[1]) : 0]);
|
457
|
+
|
458
|
+
for (var _i3 = 0; _i3 < array.length; _i3 += 2) {
|
459
|
+
quantized[_i3 + 0] = Math.floor((array[_i3 + 0] - min[0]) * multiplier[0]);
|
460
|
+
quantized[_i3 + 1] = Math.floor((array[_i3 + 1] - min[1]) * multiplier[1]);
|
461
|
+
}
|
462
|
+
|
463
|
+
return {
|
464
|
+
quantized: quantized,
|
465
|
+
decodeMat: decodeMat
|
466
|
+
};
|
467
|
+
}
|
468
|
+
});
|
@@ -0,0 +1,192 @@
|
|
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.GeometryUtils = 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.gosper = gosper;
|
20
|
+
_exports.hilbert2D = hilbert2D;
|
21
|
+
_exports.hilbert3D = hilbert3D;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Generates 2D-Coordinates in a very fast way.
|
25
|
+
*
|
26
|
+
* Based on work by:
|
27
|
+
* @link http://www.openprocessing.org/sketch/15493
|
28
|
+
*
|
29
|
+
* @param center Center of Hilbert curve.
|
30
|
+
* @param size Total width of Hilbert curve.
|
31
|
+
* @param iterations Number of subdivisions.
|
32
|
+
* @param v0 Corner index -X, -Z.
|
33
|
+
* @param v1 Corner index -X, +Z.
|
34
|
+
* @param v2 Corner index +X, +Z.
|
35
|
+
* @param v3 Corner index +X, -Z.
|
36
|
+
*/
|
37
|
+
function hilbert2D() {
|
38
|
+
var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _three.Vector3(0, 0, 0);
|
39
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
40
|
+
var iterations = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
41
|
+
var v0 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
42
|
+
var v1 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
43
|
+
var v2 = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 2;
|
44
|
+
var v3 = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 3;
|
45
|
+
var half = size / 2;
|
46
|
+
var vec_s = [new _three.Vector3(center.x - half, center.y, center.z - half), new _three.Vector3(center.x - half, center.y, center.z + half), new _three.Vector3(center.x + half, center.y, center.z + half), new _three.Vector3(center.x + half, center.y, center.z - half)];
|
47
|
+
var vec = [vec_s[v0], vec_s[v1], vec_s[v2], vec_s[v3]]; // Recurse iterations
|
48
|
+
|
49
|
+
if (0 <= --iterations) {
|
50
|
+
var tmp = [];
|
51
|
+
Array.prototype.push.apply(tmp, hilbert2D(vec[0], half, iterations, v0, v3, v2, v1));
|
52
|
+
Array.prototype.push.apply(tmp, hilbert2D(vec[1], half, iterations, v0, v1, v2, v3));
|
53
|
+
Array.prototype.push.apply(tmp, hilbert2D(vec[2], half, iterations, v0, v1, v2, v3));
|
54
|
+
Array.prototype.push.apply(tmp, hilbert2D(vec[3], half, iterations, v2, v1, v0, v3)); // Return recursive call
|
55
|
+
|
56
|
+
return tmp;
|
57
|
+
} // Return complete Hilbert Curve.
|
58
|
+
|
59
|
+
|
60
|
+
return vec;
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Generates 3D-Coordinates in a very fast way.
|
64
|
+
*
|
65
|
+
* Based on work by:
|
66
|
+
* @link http://www.openprocessing.org/visuals/?visualID=15599
|
67
|
+
*
|
68
|
+
* @param center Center of Hilbert curve.
|
69
|
+
* @param size Total width of Hilbert curve.
|
70
|
+
* @param iterations Number of subdivisions.
|
71
|
+
* @param v0 Corner index -X, +Y, -Z.
|
72
|
+
* @param v1 Corner index -X, +Y, +Z.
|
73
|
+
* @param v2 Corner index -X, -Y, +Z.
|
74
|
+
* @param v3 Corner index -X, -Y, -Z.
|
75
|
+
* @param v4 Corner index +X, -Y, -Z.
|
76
|
+
* @param v5 Corner index +X, -Y, +Z.
|
77
|
+
* @param v6 Corner index +X, +Y, +Z.
|
78
|
+
* @param v7 Corner index +X, +Y, -Z.
|
79
|
+
*/
|
80
|
+
|
81
|
+
|
82
|
+
function hilbert3D() {
|
83
|
+
var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new _three.Vector3(0, 0, 0);
|
84
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
85
|
+
var iterations = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
86
|
+
var v0 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
87
|
+
var v1 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
|
88
|
+
var v2 = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 2;
|
89
|
+
var v3 = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 3;
|
90
|
+
var v4 = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 4;
|
91
|
+
var v5 = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 5;
|
92
|
+
var v6 = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 6;
|
93
|
+
var v7 = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : 7;
|
94
|
+
// Default Vars
|
95
|
+
var half = size / 2;
|
96
|
+
var vec_s = [new _three.Vector3(center.x - half, center.y + half, center.z - half), new _three.Vector3(center.x - half, center.y + half, center.z + half), new _three.Vector3(center.x - half, center.y - half, center.z + half), new _three.Vector3(center.x - half, center.y - half, center.z - half), new _three.Vector3(center.x + half, center.y - half, center.z - half), new _three.Vector3(center.x + half, center.y - half, center.z + half), new _three.Vector3(center.x + half, center.y + half, center.z + half), new _three.Vector3(center.x + half, center.y + half, center.z - half)];
|
97
|
+
var vec = [vec_s[v0], vec_s[v1], vec_s[v2], vec_s[v3], vec_s[v4], vec_s[v5], vec_s[v6], vec_s[v7]]; // Recurse iterations
|
98
|
+
|
99
|
+
if (--iterations >= 0) {
|
100
|
+
var tmp = [];
|
101
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[0], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1));
|
102
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[1], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3));
|
103
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[2], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3));
|
104
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[3], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5));
|
105
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[4], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5));
|
106
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[5], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7));
|
107
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[6], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7));
|
108
|
+
Array.prototype.push.apply(tmp, hilbert3D(vec[7], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7)); // Return recursive call
|
109
|
+
|
110
|
+
return tmp;
|
111
|
+
} // Return complete Hilbert Curve.
|
112
|
+
|
113
|
+
|
114
|
+
return vec;
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Generates a Gosper curve (lying in the XY plane)
|
118
|
+
*
|
119
|
+
* https://gist.github.com/nitaku/6521802
|
120
|
+
*
|
121
|
+
* @param size The size of a single gosper island.
|
122
|
+
*/
|
123
|
+
|
124
|
+
|
125
|
+
function gosper() {
|
126
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
127
|
+
|
128
|
+
function fractalize(config) {
|
129
|
+
var output;
|
130
|
+
var input = config.axiom;
|
131
|
+
|
132
|
+
for (var i = 0, il = config.steps; 0 <= il ? i < il : i > il; 0 <= il ? i++ : i--) {
|
133
|
+
output = '';
|
134
|
+
|
135
|
+
for (var j = 0, jl = input.length; j < jl; j++) {
|
136
|
+
var char = input[j];
|
137
|
+
|
138
|
+
if (char in config.rules) {
|
139
|
+
output += config.rules[char];
|
140
|
+
} else {
|
141
|
+
output += char;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
input = output;
|
146
|
+
}
|
147
|
+
|
148
|
+
return output;
|
149
|
+
}
|
150
|
+
|
151
|
+
function toPoints(config) {
|
152
|
+
var currX = 0,
|
153
|
+
currY = 0;
|
154
|
+
var angle = 0;
|
155
|
+
var path = [0, 0, 0];
|
156
|
+
var fractal = config.fractal;
|
157
|
+
|
158
|
+
for (var i = 0, l = fractal.length; i < l; i++) {
|
159
|
+
var char = fractal[i];
|
160
|
+
|
161
|
+
if (char === '+') {
|
162
|
+
angle += config.angle;
|
163
|
+
} else if (char === '-') {
|
164
|
+
angle -= config.angle;
|
165
|
+
} else if (char === 'F') {
|
166
|
+
currX += config.size * Math.cos(angle);
|
167
|
+
currY += -config.size * Math.sin(angle);
|
168
|
+
path.push(currX, currY, 0);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
return path;
|
173
|
+
} //
|
174
|
+
|
175
|
+
|
176
|
+
var gosper = fractalize({
|
177
|
+
axiom: 'A',
|
178
|
+
steps: 4,
|
179
|
+
rules: {
|
180
|
+
A: 'A+BF++BF-FA--FAFA-BF+',
|
181
|
+
B: '-FA+BFBF++BF+FA--FA-B'
|
182
|
+
}
|
183
|
+
});
|
184
|
+
var points = toPoints({
|
185
|
+
fractal: gosper,
|
186
|
+
size: size,
|
187
|
+
angle: Math.PI / 3 // 60 degrees
|
188
|
+
|
189
|
+
});
|
190
|
+
return points;
|
191
|
+
}
|
192
|
+
});
|